00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <baclipb.h>
00018
00019 #include "CommonToResourceFilesEx.h"
00020 #include "Basics.h"
00021
00022
00025
00026
00027
00028 static void doExampleL()
00029 {
00030 doCopyL();
00031 doPasteL();
00032 }
00033
00036
00037
00038 static void doCopyL()
00039 {
00040 _LIT(KSomeText,"Some text");
00041 _LIT(KContentOfTheCClassAObject,"Content of the CClassA object ...");
00042
00043
00044 CClassA* item = new (ELeave) CClassA;
00045 CleanupStack::PushL(item);
00046
00047
00048 item->iBuffer = KSomeText;
00049 item->iXA = -1;
00050 item->iYA = 2;
00051
00052
00053 doShow(KContentOfTheCClassAObject,item);
00054
00055
00056
00057 CClipboard* cb = CClipboard::NewForWritingLC(fsSession);
00058
00059
00060
00061
00062
00063
00064
00065 RStoreWriteStream stream;
00066 TStreamId stid = stream.CreateLC(cb->Store());
00067 stream << *item;
00068 stream.CommitL();
00069 (cb->StreamDictionary()).AssignL(KExampleClipUid,stid);
00070 CleanupStack::PopAndDestroy();
00071
00072
00073
00074 cb->CommitL();
00075
00076
00077
00078 CleanupStack::PopAndDestroy(2);
00079 }
00080
00083
00084 static void doPasteL()
00085 {
00086 _LIT(KNothingToPaste,"Nothing to paste");
00087 _LIT(KTheCClassAObjectAfterPastingIn,"The CClassA object after pasting in ...");
00088
00089 CClipboard* cb = NULL;
00090
00091
00092
00093 TRAPD(ret,cb=CClipboard::NewForReadingL(fsSession));
00094 CleanupStack::PushL(cb);
00095 if (ret!=KErrNone)
00096 {
00097 doShow(KNothingToPaste,NULL);
00098 User::Leave(ret);
00099 }
00100
00101
00102 CClassA* item = new (ELeave) CClassA;
00103 CleanupStack::PushL(item);
00104
00105
00106 TStreamId stid = (cb->StreamDictionary()).At(KExampleClipUid);
00107 if (stid == KNullStreamId)
00108 {
00109 doShow(KNothingToPaste,NULL);
00110 User::Leave(0);
00111 }
00112
00113
00114 RStoreReadStream stream;
00115 stream.OpenLC(cb->Store(),stid);
00116 stream >> *item;
00117 CleanupStack::PopAndDestroy();
00118
00119
00120
00121 doShow(KTheCClassAObjectAfterPastingIn,item);
00122
00123
00124
00125
00126 CleanupStack::PopAndDestroy(2);
00127 }
00128
00131
00132 static void doShow(const TDesC& aHeading,const CClassA* anItem)
00133 {
00134 _LIT(KNewline,"\n");
00135 _LIT(KFormatS,"\n%S");
00136 _LIT(KFormatD,"\n%d");
00137 _LIT(KFormatU,"\n%u");
00138
00139 console->Printf(KNewline);
00140 console->Printf(aHeading);
00141 if (anItem)
00142 {
00143 console->Printf(KFormatS,&anItem->iBuffer);
00144 console->Printf(KFormatD,anItem->iXA);
00145 console->Printf(KFormatU,anItem->iYA);
00146 console->Printf(KNewline);
00147 }
00148 }
00149
00152
00153 CClassA::CClassA()
00154 {
00155 _LIT(KDefault,"DEFAULT");
00156 iBuffer = KDefault;
00157 }
00158
00159 void CClassA::ExternalizeL(RWriteStream& aStream) const
00160 {
00161 aStream << iBuffer;
00162 aStream.WriteInt32L(iXA);
00163 aStream.WriteUint32L(iYA);
00164 }
00165
00166 void CClassA::InternalizeL(RReadStream& aStream)
00167 {
00168 aStream >> iBuffer;
00169 iXA = aStream.ReadInt32L();
00170 iYA = aStream.ReadUint32L();
00171 }
00172
00173
00174
00175
00176
00177