Clipboard allows applications to read and write data to and from a shared clipboard.
The clipboard is implemented as a direct file store, as defined in the File Store API. Data placed on the clipboard is in streams. Every data type placed on the clipboard is identified by a UID. The store has a stream dictionary to allow an application to retrieve the data by specifying its UID.
The clipboard class, CClipboard , provides operations to get the clipboard file store and stream dictionary. Applications then read or write data using the standard store and stream interfaces. It also provides special support for copying and pasting a TReal to and from the clipboard.
To place data on the clipboard, construct a CClipboard object and prepare it for the data to be written, using the NewForWritingLC() static member function as illustrated in the following code fragment:
CClipboard* cb = CClipboard::NewForWritingLC( fsSession );
The function requires a file server session.
The file associated with the clipboard's store may or may not exist. If it already exists, any existing content is discarded; if the file does not exist, it is created. In either event, NewForWritingLC() results in an empty clipboard.
Once the CClipboard object has been created, data is stored into the clipboard 's store. Both the store ( CStreamStore ) and the stream dictionary ( CStreamDictionary ), which the example needs to access, are encapsulated by CClipboard . The class, therefore, provides the Store() and StreamDictionary() member functions to return suitable references.
Following is an example on how to create data for clipboard. In this example, the data to be placed on the clipboard's store is a single object item:
RStoreWriteStream stream; TStreamId stid = stream.CreateLC( cb->Store() ); stream << *item; stream.CommitL(); ( cb->StreamDictionary() ).AssignL( KExampleClipUid,stid ); CleanupStack::PopAndDestroy(); // stream cb->CommitL(); CleanupStack::PopAndDestroy(); // cb
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.