// Create clipboard object
TRAPD(ret,cb=CClipboard::NewForReadingL(fsSession));
CleanupStack::PushL(cb);
_LIT(KNoPaste,"Nothing to paste");
if (ret!=KErrNone)
{
doShow(KNoPaste,NULL);
User::Leave(ret);
}
// Get stream from store
TStreamId stid = (cb->StreamDictionary()).At(KExampleClipUid);
if (stid == KNullStreamId)
{
doShow(KNoPaste,NULL);
User::Leave(0);
}
// Read stream
RStoreReadStream stream;
stream.OpenLC(cb->Store(),stid);
stream >> *item;
To attempt to retrieve data from the clipboard, first construct a
CClipboard
object and prepare it for reading using either
NewForReadingL()
or NewForReadingLC()
. In this
example, the construction of the CClipboard
is executed within a
TRAPD
harness. This is not essential, but allows suitable text to
be displayed if construction of CClipboard
fails. Note, if the
file associated with the clipboard's store does not exist, is corrupt or is in
use, the resulting error is trapped inside NewForReadingL()
and
the function constructs an empty stream dictionary.
This example is only interested in a stream which is the external
representation of a particular type of object. It therefore looks in the stream
dictionary for a streamid that matches the UID
KExampleClipUid
.
If there is a suitable stream, it is opened and the
item
object is internalised from that stream.