Changeset 846 for trunk/src/gui/kernel/qclipboard_s60.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/kernel/qclipboard_s60.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 51 51 #include "qevent.h" 52 52 #include "private/qcore_symbian_p.h" 53 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS 54 #include "txtclipboard.h" 55 #endif 56 #include "txtetext.h" 53 57 #include <QtDebug> 54 58 … … 57 61 QT_BEGIN_NAMESPACE 58 62 59 //### Mime Type mapping to UIDs60 61 63 const TUid KQtCbDataStream = {0x2001B2DD}; 62 64 const TInt KPlainTextBegin = 0; 63 65 64 66 class QClipboardData … … 142 144 HBufC* stringData = TPtrC(reinterpret_cast<const TUint16*>((*iter).utf16())).AllocLC(); 143 145 QByteArray ba = aData->data((*iter)); 144 qDebug() << "copy to clipboard mime: " << *iter << " data: " << ba;145 146 // mime type 146 147 aStream << TCardinality(stringData->Size()); … … 151 152 CleanupStack::PopAndDestroy(stringData); 152 153 } 154 } 155 156 void writeToSymbianStoreLX(const QMimeData* aData, CClipboard* clipboard) 157 { 158 // This function both leaves and throws exceptions. There must be no destructor 159 // dependencies between cleanup styles, and no cleanup stack dependencies on stacked objects. 160 if (aData->hasText()) { 161 CPlainText* text = CPlainText::NewL(); 162 CleanupStack::PushL(text); 163 164 TPtrC textPtr(qt_QString2TPtrC(aData->text())); 165 text->InsertL(KPlainTextBegin, textPtr); 166 text->CopyToStoreL(clipboard->Store(), clipboard->StreamDictionary(), 167 KPlainTextBegin, textPtr.Length()); 168 CleanupStack::PopAndDestroy(text); 169 } 170 } 171 172 void readSymbianStoreLX(QMimeData* aData, CClipboard* clipboard) 173 { 174 // This function both leaves and throws exceptions. There must be no destructor 175 // dependencies between cleanup styles, and no cleanup stack dependencies on stacked objects. 176 CPlainText* text = CPlainText::NewL(); 177 CleanupStack::PushL(text); 178 TInt dataLength = text->PasteFromStoreL(clipboard->Store(), clipboard->StreamDictionary(), 179 KPlainTextBegin); 180 if (dataLength == 0) { 181 User::Leave(KErrNotFound); 182 } 183 HBufC* hBuf = HBufC::NewL(dataLength); 184 TPtr buf = hBuf->Des(); 185 text->Extract(buf, KPlainTextBegin, dataLength); 186 187 QString string = qt_TDesC2QString(buf); 188 CleanupStack::PopAndDestroy(text); 189 190 aData->setText(string); 153 191 } 154 192 … … 175 213 aStream.ReadL(reinterpret_cast<uchar*>(ba.data_ptr()->data),dataSize); 176 214 ba.data_ptr()->size = dataSize; 177 qDebug() << "paste from clipboard mime: " << mimeType << " data: " << ba;178 215 aData->setData(mimeType,ba); 179 216 } … … 193 230 if (mode != Clipboard) return 0; 194 231 QClipboardData *d = clipboardData(); 232 bool dataExists(false); 195 233 if (d) 196 234 { … … 199 237 CClipboard* cb = CClipboard::NewForReadingLC(fs); 200 238 Q_ASSERT(cb); 239 //stream for qt 201 240 RStoreReadStream stream; 202 241 TStreamId stid = (cb->StreamDictionary()).At(KQtCbDataStream); 203 stream.OpenLC(cb->Store(),stid); 204 QT_TRYCATCH_LEAVING(readFromStreamLX(d->source(),stream)); 205 CleanupStack::PopAndDestroy(2,cb); 206 return d->source(); 242 if (stid != 0) { 243 stream.OpenLC(cb->Store(),stid); 244 QT_TRYCATCH_LEAVING(readFromStreamLX(d->source(),stream)); 245 CleanupStack::PopAndDestroy(&stream); 246 dataExists = true; 247 } 248 else { 249 //symbian clipboard 250 RStoreReadStream symbianStream; 251 TStreamId symbianStId = (cb->StreamDictionary()).At(KClipboardUidTypePlainText); 252 if (symbianStId != 0) { 253 symbianStream.OpenLC(cb->Store(), symbianStId); 254 QT_TRYCATCH_LEAVING(readSymbianStoreLX(d->source(), cb)); 255 CleanupStack::PopAndDestroy(&symbianStream); 256 dataExists = true; 257 } 258 } 259 CleanupStack::PopAndDestroy(cb); 207 260 }); 208 261 if (err != KErrNone){ … … 210 263 } 211 264 265 if (dataExists) { 266 return d->source(); 267 } 212 268 } 213 269 return 0; … … 224 280 RFs fs = qt_s60GetRFs(); 225 281 CClipboard* cb = CClipboard::NewForWritingLC(fs); 282 //stream for qt 226 283 RStoreWriteStream stream; 227 284 TStreamId stid = stream.CreateLC(cb->Store()); … … 231 288 (cb->StreamDictionary()).AssignL(KQtCbDataStream,stid); 232 289 cb->CommitL(); 233 CleanupStack::PopAndDestroy(2,cb); 290 291 //stream for symbian 292 RStoreWriteStream symbianStream; 293 TStreamId symbianStId = symbianStream.CreateLC(cb->Store()); 294 QT_TRYCATCH_LEAVING(writeToSymbianStoreLX(src, cb)); 295 (cb->StreamDictionary()).AssignL(KClipboardUidTypePlainText, symbianStId); 296 cb->CommitL(); 297 CleanupStack::PopAndDestroy(3,cb); 234 298 }); 235 299 if (err != KErrNone){
Note:
See TracChangeset
for help on using the changeset viewer.