Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qclipboard_s60.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5151#include "qevent.h"
    5252#include "private/qcore_symbian_p.h"
     53#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
     54#include "txtclipboard.h"
     55#endif
     56#include "txtetext.h"
    5357#include <QtDebug>
    5458
     
    5761QT_BEGIN_NAMESPACE
    5862
    59 //###  Mime Type mapping to UIDs
    60 
    6163const TUid KQtCbDataStream = {0x2001B2DD};
    62 
     64const TInt KPlainTextBegin = 0;
    6365
    6466class QClipboardData
     
    142144        HBufC* stringData = TPtrC(reinterpret_cast<const TUint16*>((*iter).utf16())).AllocLC();
    143145        QByteArray ba = aData->data((*iter));
    144         qDebug() << "copy to clipboard mime: " << *iter << " data: " << ba;
    145146        // mime type
    146147        aStream << TCardinality(stringData->Size());
     
    151152        CleanupStack::PopAndDestroy(stringData);
    152153    }
     154}
     155
     156void 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
     172void 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);
    153191}
    154192
     
    175213        aStream.ReadL(reinterpret_cast<uchar*>(ba.data_ptr()->data),dataSize);
    176214        ba.data_ptr()->size = dataSize;
    177         qDebug() << "paste from clipboard mime: " << mimeType << " data: " << ba;
    178215        aData->setData(mimeType,ba);
    179216    }
     
    193230    if (mode != Clipboard) return 0;
    194231    QClipboardData *d = clipboardData();
     232    bool dataExists(false);
    195233    if (d)
    196234    {
     
    199237            CClipboard* cb = CClipboard::NewForReadingLC(fs);
    200238            Q_ASSERT(cb);
     239            //stream for qt
    201240            RStoreReadStream stream;
    202241            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);
    207260        });
    208261        if (err != KErrNone){
     
    210263        }
    211264
     265        if (dataExists) {
     266            return d->source();
     267        }
    212268    }
    213269    return 0;
     
    224280            RFs fs = qt_s60GetRFs();
    225281            CClipboard* cb = CClipboard::NewForWritingLC(fs);
     282            //stream for qt
    226283            RStoreWriteStream  stream;
    227284            TStreamId stid = stream.CreateLC(cb->Store());
     
    231288            (cb->StreamDictionary()).AssignL(KQtCbDataStream,stid);
    232289            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);
    234298        });
    235299        if (err != KErrNone){
Note: See TracChangeset for help on using the changeset viewer.