39 #include "TXTPLAIN.H" |
39 #include "TXTPLAIN.H" |
40 #include "TXTSTD.H" |
40 #include "TXTSTD.H" |
41 #include "TXTRTPFL.H" |
41 #include "TXTRTPFL.H" |
42 #include "TXTCLIPBOARD.H" |
42 #include "TXTCLIPBOARD.H" |
43 |
43 |
|
44 #include "OstTraceDefinitions.h" |
|
45 #ifdef OST_TRACE_COMPILER_IN_USE |
|
46 #include "TXTETEXTTraces.h" |
|
47 #endif |
|
48 |
44 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
49 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
45 #include "TXTETEXT_INTERNAL.H" |
50 #include "TXTETEXT_INTERNAL.H" |
46 #endif |
51 #endif |
47 |
52 |
48 const TUint KFieldCountLimit = 255; |
53 const TUint KFieldCountLimit = 255; |
256 } |
261 } |
257 |
262 |
258 EXPORT_C void CEditableText::StartFepInlineEditL(TBool& aParagraphContainingStartPositionOfInlineTextHasChangedFormat,TInt& aNumberOfCharactersSuccessfullyDeleted,TInt& aNumberOfCharactersSuccessfullyInserted,TInt& aPositionOfInsertionPointInDocument,TInt aNewPositionOfInsertionPointInDocument,const TDesC& aInitialInlineText,TInt aPositionOfInlineTextInDocument,TInt aNumberOfCharactersToHide,MFepInlineTextFormatRetriever& aInlineTextFormatRetriever) |
263 EXPORT_C void CEditableText::StartFepInlineEditL(TBool& aParagraphContainingStartPositionOfInlineTextHasChangedFormat,TInt& aNumberOfCharactersSuccessfullyDeleted,TInt& aNumberOfCharactersSuccessfullyInserted,TInt& aPositionOfInsertionPointInDocument,TInt aNewPositionOfInsertionPointInDocument,const TDesC& aInitialInlineText,TInt aPositionOfInlineTextInDocument,TInt aNumberOfCharactersToHide,MFepInlineTextFormatRetriever& aInlineTextFormatRetriever) |
259 /** @internalAll */ |
264 /** @internalAll */ |
260 { |
265 { |
|
266 if (aPositionOfInlineTextInDocument<0 || aNumberOfCharactersToHide<0 || aPositionOfInlineTextInDocument+aNumberOfCharactersToHide>DocumentLength()) |
|
267 { |
|
268 OstTrace0( TRACE_DUMP, CEDITABLETEXT_STARTFEPINLINEEDITL, "ECharPosBeyondDocument" ); |
|
269 } |
261 __ASSERT_ALWAYS(aPositionOfInlineTextInDocument>=0 && aNumberOfCharactersToHide>=0 && aPositionOfInlineTextInDocument+aNumberOfCharactersToHide<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
270 __ASSERT_ALWAYS(aPositionOfInlineTextInDocument>=0 && aNumberOfCharactersToHide>=0 && aPositionOfInlineTextInDocument+aNumberOfCharactersToHide<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
|
271 if (InlineEditData()!=NULL) |
|
272 { |
|
273 OstTrace0( TRACE_DUMP, DUP1_CEDITABLETEXT_STARTFEPINLINEEDITL, "EAlreadyFepInlineEditing" ); |
|
274 } |
262 __ASSERT_ALWAYS(InlineEditData()==NULL,Panic(EAlreadyFepInlineEditing)); |
275 __ASSERT_ALWAYS(InlineEditData()==NULL,Panic(EAlreadyFepInlineEditing)); |
263 aParagraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse; |
276 aParagraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse; |
264 aNumberOfCharactersSuccessfullyDeleted=0; |
277 aNumberOfCharactersSuccessfullyDeleted=0; |
265 aNumberOfCharactersSuccessfullyInserted=0; |
278 aNumberOfCharactersSuccessfullyInserted=0; |
266 CInlineEditData* const inlineEditData=new(ELeave) CInlineEditData; |
279 CInlineEditData* const inlineEditData=new(ELeave) CInlineEditData; |
293 |
306 |
294 EXPORT_C void CEditableText::UpdateFepInlineTextL(TBool& aParagraphContainingStartPositionOfInlineTextHasChangedFormat,TInt& aNumberOfCharactersSuccessfullyDeleted,TInt& aNumberOfCharactersSuccessfullyInserted,TInt& aPositionOfInsertionPointInDocument,TInt aNewPositionOfInsertionPointInDocument,const TDesC& aNewInlineText) |
307 EXPORT_C void CEditableText::UpdateFepInlineTextL(TBool& aParagraphContainingStartPositionOfInlineTextHasChangedFormat,TInt& aNumberOfCharactersSuccessfullyDeleted,TInt& aNumberOfCharactersSuccessfullyInserted,TInt& aPositionOfInsertionPointInDocument,TInt aNewPositionOfInsertionPointInDocument,const TDesC& aNewInlineText) |
295 /** @internalAll */ |
308 /** @internalAll */ |
296 { |
309 { |
297 CInlineEditData* const inlineEditData=InlineEditData(); |
310 CInlineEditData* const inlineEditData=InlineEditData(); |
|
311 if (inlineEditData==NULL) |
|
312 { |
|
313 OstTrace0( TRACE_DUMP, CEDITABLETEXT_UPDATEFEPINLINETEXTL, "ENotCurrentlyFepInlineEditing" ); |
|
314 } |
298 __ASSERT_ALWAYS(inlineEditData!=NULL,Panic(ENotCurrentlyFepInlineEditing)); |
315 __ASSERT_ALWAYS(inlineEditData!=NULL,Panic(ENotCurrentlyFepInlineEditing)); |
299 aParagraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse; |
316 aParagraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse; |
300 aNumberOfCharactersSuccessfullyDeleted=0; |
317 aNumberOfCharactersSuccessfullyDeleted=0; |
301 aNumberOfCharactersSuccessfullyInserted=0; |
318 aNumberOfCharactersSuccessfullyInserted=0; |
302 HBufC*& inlineText=inlineEditData->iInlineText; |
319 HBufC*& inlineText=inlineEditData->iInlineText; |
303 HBufC* oldInlineText=inlineText; |
320 HBufC* oldInlineText=inlineText; |
|
321 if (oldInlineText!=NULL && inlineEditData->iLengthOfInlineText!=oldInlineText->Length()) |
|
322 { |
|
323 OstTrace0( TRACE_DUMP, DUP1_CEDITABLETEXT_UPDATEFEPINLINETEXTL, "EDebug" ); |
|
324 } |
304 __ASSERT_DEBUG(oldInlineText==NULL || inlineEditData->iLengthOfInlineText==oldInlineText->Length(),Panic(EDebug)); |
325 __ASSERT_DEBUG(oldInlineText==NULL || inlineEditData->iLengthOfInlineText==oldInlineText->Length(),Panic(EDebug)); |
305 const TInt lengthOfNewInlineText=aNewInlineText.Length(); |
326 const TInt lengthOfNewInlineText=aNewInlineText.Length(); |
306 if (oldInlineText!=NULL && *oldInlineText==aNewInlineText) |
327 if (oldInlineText!=NULL && *oldInlineText==aNewInlineText) |
307 { |
328 { |
308 aNumberOfCharactersSuccessfullyDeleted=lengthOfNewInlineText; |
329 aNumberOfCharactersSuccessfullyDeleted=lengthOfNewInlineText; |
344 /** |
365 /** |
345 * @internalAll |
366 * @internalAll |
346 */ |
367 */ |
347 { |
368 { |
348 const CInlineEditData* const inlineEditData=InlineEditData(); |
369 const CInlineEditData* const inlineEditData=InlineEditData(); |
|
370 if (inlineEditData==NULL) |
|
371 { |
|
372 OstTrace0( TRACE_FATAL, DUP1_CEDITABLETEXT_COMMITFEPINLINEEDITL, "ENotCurrentlyFepInlineEditing" ); |
|
373 } |
349 __ASSERT_ALWAYS(inlineEditData!=NULL,Panic(ENotCurrentlyFepInlineEditing)); |
374 __ASSERT_ALWAYS(inlineEditData!=NULL,Panic(ENotCurrentlyFepInlineEditing)); |
|
375 if (inlineEditData->iInlineText!=NULL && inlineEditData->iLengthOfInlineText!=inlineEditData->iInlineText->Length()) |
|
376 { |
|
377 OstTrace0( TRACE_DUMP, CEDITABLETEXT_COMMITFEPINLINEEDITL, "EDebug" ); |
|
378 } |
350 __ASSERT_DEBUG(inlineEditData->iInlineText==NULL || inlineEditData->iLengthOfInlineText==inlineEditData->iInlineText->Length(),Panic(EDebug)); |
379 __ASSERT_DEBUG(inlineEditData->iInlineText==NULL || inlineEditData->iLengthOfInlineText==inlineEditData->iInlineText->Length(),Panic(EDebug)); |
351 aParagraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse; |
380 aParagraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse; |
352 const TInt lengthOfInlineText=inlineEditData->iLengthOfInlineText; |
381 const TInt lengthOfInlineText=inlineEditData->iLengthOfInlineText; |
353 aNumberOfCharactersSuccessfullyDeleted=lengthOfInlineText; |
382 aNumberOfCharactersSuccessfullyDeleted=lengthOfInlineText; |
354 aNumberOfCharactersSuccessfullyInserted=lengthOfInlineText; |
383 aNumberOfCharactersSuccessfullyInserted=lengthOfInlineText; |
368 const CInlineEditData* inlineEditData=InlineEditData(); |
397 const CInlineEditData* inlineEditData=InlineEditData(); |
369 if (inlineEditData!=NULL) |
398 if (inlineEditData!=NULL) |
370 { |
399 { |
371 const TInt positionOfInlineTextInDocument=inlineEditData->iPositionOfInlineTextInDocument; |
400 const TInt positionOfInlineTextInDocument=inlineEditData->iPositionOfInlineTextInDocument; |
372 const TInt lengthOfInlineText=inlineEditData->iLengthOfInlineText; |
401 const TInt lengthOfInlineText=inlineEditData->iLengthOfInlineText; |
|
402 if (inlineEditData->iInlineText!=NULL && lengthOfInlineText!=inlineEditData->iInlineText->Length()) |
|
403 { |
|
404 OstTrace0( TRACE_DUMP, CEDITABLETEXT_CANCELFEPINLINEEDIT, "EDebug" ); |
|
405 } |
373 __ASSERT_DEBUG(inlineEditData->iInlineText==NULL || lengthOfInlineText==inlineEditData->iInlineText->Length(),Panic(EDebug)); |
406 __ASSERT_DEBUG(inlineEditData->iInlineText==NULL || lengthOfInlineText==inlineEditData->iInlineText->Length(),Panic(EDebug)); |
374 TRAPD(notUsed, |
407 TRAPD(notUsed, |
375 if (lengthOfInlineText>0) |
408 if (lengthOfInlineText>0) |
376 { |
409 { |
377 aParagraphContainingStartPositionOfInlineTextHasChangedFormat=DeleteWithoutDestroyingFormatL(positionOfInlineTextInDocument,lengthOfInlineText); |
410 aParagraphContainingStartPositionOfInlineTextHasChangedFormat=DeleteWithoutDestroyingFormatL(positionOfInlineTextInDocument,lengthOfInlineText); |
379 aPositionOfInsertionPointInDocument=inlineEditData->iPositionOfInlineTextInDocument; |
412 aPositionOfInsertionPointInDocument=inlineEditData->iPositionOfInlineTextInDocument; |
380 } |
413 } |
381 const HBufC* const hiddenText=inlineEditData->iHiddenText; |
414 const HBufC* const hiddenText=inlineEditData->iHiddenText; |
382 if (hiddenText!=NULL) |
415 if (hiddenText!=NULL) |
383 { |
416 { |
|
417 if (hiddenText->Length()<=0) |
|
418 { |
|
419 OstTrace0( TRACE_DUMP, DUP1_CEDITABLETEXT_CANCELFEPINLINEEDIT, "EDebug" ); |
|
420 } |
384 __ASSERT_DEBUG(hiddenText->Length()>0, Panic(EDebug)); |
421 __ASSERT_DEBUG(hiddenText->Length()>0, Panic(EDebug)); |
385 InsertL(positionOfInlineTextInDocument,*hiddenText); |
422 InsertL(positionOfInlineTextInDocument,*hiddenText); |
386 aNumberOfCharactersSuccessfullyInserted=hiddenText->Length(); |
423 aNumberOfCharactersSuccessfullyInserted=hiddenText->Length(); |
387 aPositionOfInsertionPointInDocument=aNewPositionOfInsertionPointInDocument; |
424 aPositionOfInsertionPointInDocument=aNewPositionOfInsertionPointInDocument; |
388 } |
425 } |
560 |
597 |
561 EXPORT_C void CPlainText::DoConstructL(TDocumentStorage aStorage,TInt aDefaultTextGranularity,MTextFieldFactory* aFieldFactory) |
598 EXPORT_C void CPlainText::DoConstructL(TDocumentStorage aStorage,TInt aDefaultTextGranularity,MTextFieldFactory* aFieldFactory) |
562 /** Allocates storage of CBufFlat or CBufSeg, according to the parameter aStorage. |
599 /** Allocates storage of CBufFlat or CBufSeg, according to the parameter aStorage. |
563 Creates & initializes the field set.*/ |
600 Creates & initializes the field set.*/ |
564 { |
601 { |
|
602 if (iByteStore!=NULL) |
|
603 { |
|
604 OstTrace0( TRACE_DUMP, CPLAINTEXT_DOCONSTRUCTL, "EConstructCalledTwice" ); |
|
605 } |
565 __ASSERT_DEBUG(iByteStore==NULL,Panic(EConstructCalledTwice)); |
606 __ASSERT_DEBUG(iByteStore==NULL,Panic(EConstructCalledTwice)); |
566 |
607 |
567 iByteStore=(aStorage==ESegmentedStorage) |
608 iByteStore=(aStorage==ESegmentedStorage) |
568 ? (CBufBase*)CBufSeg::NewL(aDefaultTextGranularity*sizeof(TText)) |
609 ? (CBufBase*)CBufSeg::NewL(aDefaultTextGranularity*sizeof(TText)) |
569 : (CBufBase*)CBufFlat::NewL(aDefaultTextGranularity*sizeof(TText)); |
610 : (CBufBase*)CBufFlat::NewL(aDefaultTextGranularity*sizeof(TText)); |
882 |
923 |
883 TStreamId CPlainText::DoCopyToStoreL(CStreamStore& aStore,CStreamDictionary& aDictionary,TInt aPos,TInt aLength) const |
924 TStreamId CPlainText::DoCopyToStoreL(CStreamStore& aStore,CStreamDictionary& aDictionary,TInt aPos,TInt aLength) const |
884 { |
925 { |
885 __TEST_INVARIANT; |
926 __TEST_INVARIANT; |
886 TInt documentLength = DocumentLength(); |
927 TInt documentLength = DocumentLength(); |
|
928 if (aPos < 0 || aPos > documentLength) |
|
929 { |
|
930 OstTrace0( TRACE_FATAL, CPLAINTEXT_DOCOPYTOSTOREL, "ECharPosBeyondDocument" ); |
|
931 } |
887 __ASSERT_ALWAYS(aPos >= 0 && aPos <= documentLength,Panic(ECharPosBeyondDocument)); |
932 __ASSERT_ALWAYS(aPos >= 0 && aPos <= documentLength,Panic(ECharPosBeyondDocument)); |
|
933 if (aLength < 0) |
|
934 { |
|
935 OstTrace0( TRACE_FATAL, DUP1_CPLAINTEXT_DOCOPYTOSTOREL, "ECopyToStreamNegativeLength" ); |
|
936 } |
888 __ASSERT_ALWAYS(aLength >= 0,Panic(ECopyToStreamNegativeLength)); |
937 __ASSERT_ALWAYS(aLength >= 0,Panic(ECopyToStreamNegativeLength)); |
|
938 if (aPos + aLength > documentLength) |
|
939 { |
|
940 OstTrace0( TRACE_FATAL, DUP2_CPLAINTEXT_DOCOPYTOSTOREL, "ECharPosBeyondDocument" ); |
|
941 } |
889 __ASSERT_ALWAYS(aPos + aLength <= documentLength,Panic(ECharPosBeyondDocument)); |
942 __ASSERT_ALWAYS(aPos + aLength <= documentLength,Panic(ECharPosBeyondDocument)); |
890 |
943 |
891 if (aLength == 0) |
944 if (aLength == 0) |
892 return KNullStreamId; |
945 return KNullStreamId; |
893 |
946 |
922 // Write the plain text to the stream. |
975 // Write the plain text to the stream. |
923 void CPlainText::CopyToStreamL(RWriteStream& aStream,TInt aPos,TInt aLength)const |
976 void CPlainText::CopyToStreamL(RWriteStream& aStream,TInt aPos,TInt aLength)const |
924 { |
977 { |
925 __TEST_INVARIANT; |
978 __TEST_INVARIANT; |
926 TInt documentLength = DocumentLength(); |
979 TInt documentLength = DocumentLength(); |
|
980 if (aPos < 0 || aPos > documentLength) |
|
981 { |
|
982 OstTrace0( TRACE_FATAL, CPLAINTEXT_COPYTOSTREAML, "ECharPosBeyondDocument" ); |
|
983 } |
927 __ASSERT_ALWAYS(aPos >= 0 && aPos <= documentLength,Panic(ECharPosBeyondDocument)); |
984 __ASSERT_ALWAYS(aPos >= 0 && aPos <= documentLength,Panic(ECharPosBeyondDocument)); |
|
985 if (aLength < 0) |
|
986 { |
|
987 OstTrace0( TRACE_FATAL, DUP1_CPLAINTEXT_COPYTOSTREAML, "ECopyToStreamNegativeLength" ); |
|
988 } |
928 __ASSERT_ALWAYS(aLength >= 0,Panic(ECopyToStreamNegativeLength)); |
989 __ASSERT_ALWAYS(aLength >= 0,Panic(ECopyToStreamNegativeLength)); |
|
990 if (aPos + aLength > documentLength) |
|
991 { |
|
992 OstTrace0( TRACE_FATAL, DUP2_CPLAINTEXT_COPYTOSTREAML, "ECharPosBeyondDocument" ); |
|
993 } |
929 __ASSERT_ALWAYS(aPos + aLength <= documentLength,Panic(ECharPosBeyondDocument)); |
994 __ASSERT_ALWAYS(aPos + aLength <= documentLength,Panic(ECharPosBeyondDocument)); |
930 |
995 |
931 aStream.WriteInt32L(aLength); |
996 aStream.WriteInt32L(aLength); |
932 ::ExternalizeTextL(aStream,*iByteStore,aPos,aLength,FALSE); |
997 ::ExternalizeTextL(aStream,*iByteStore,aPos,aLength,FALSE); |
933 |
998 |
959 } |
1024 } |
960 |
1025 |
961 |
1026 |
962 TInt CPlainText::DoPasteFromStoreL(const CStreamStore& aStore,TStreamId aStreamId,TInt aPos) |
1027 TInt CPlainText::DoPasteFromStoreL(const CStreamStore& aStore,TStreamId aStreamId,TInt aPos) |
963 { |
1028 { |
|
1029 if (aPos>DocumentLength()) |
|
1030 { |
|
1031 OstTrace0( TRACE_FATAL, CPLAINTEXT_DOPASTEFROMSTOREL, "ECharPosBeyondDocument" ); |
|
1032 } |
964 __ASSERT_ALWAYS(aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1033 __ASSERT_ALWAYS(aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
965 |
1034 |
966 TInt charsPasted=0; |
1035 TInt charsPasted=0; |
967 if (aStreamId!=KNullStreamId) |
1036 if (aStreamId!=KNullStreamId) |
968 {// There is a recognised type in the clipboard. |
1037 {// There is a recognised type in the clipboard. |
1005 implied elsewhere, such as in the formatting information stored in CRichText objects. |
1074 implied elsewhere, such as in the formatting information stored in CRichText objects. |
1006 */ |
1075 */ |
1007 if (error != KErrNone) |
1076 if (error != KErrNone) |
1008 { |
1077 { |
1009 DoPtDelete(aPos,chars_read); |
1078 DoPtDelete(aPos,chars_read); |
|
1079 OstTrace1( TRACE_FATAL, DUP1_CPLAINTEXT_PASTEFROMSTREAML, "Leave code=%d", error ); |
1010 User::Leave(error); |
1080 User::Leave(error); |
1011 } |
1081 } |
1012 |
1082 |
1013 __TEST_INVARIANT; |
1083 __TEST_INVARIANT; |
1014 return chars_read; |
1084 return chars_read; |
1056 |
1126 |
1057 void CPlainText::InsertEodL() |
1127 void CPlainText::InsertEodL() |
1058 /** Inserts the end-of-document character upon document construction.*/ |
1128 /** Inserts the end-of-document character upon document construction.*/ |
1059 { |
1129 { |
1060 // ASSERT: The plain text component is empty. |
1130 // ASSERT: The plain text component is empty. |
|
1131 if (DocumentLength()!=-1) |
|
1132 { |
|
1133 OstTrace0( TRACE_DUMP, DUP1_CPLAINTEXT_INSERTEODL, "ECorruptTextStore" ); |
|
1134 } |
1061 __ASSERT_DEBUG(DocumentLength()==-1,Panic(ECorruptTextStore)); |
1135 __ASSERT_DEBUG(DocumentLength()==-1,Panic(ECorruptTextStore)); |
1062 TBuf<1> content; |
1136 TBuf<1> content; |
1063 content.Append(EParagraphDelimiter); |
1137 content.Append(EParagraphDelimiter); |
1064 TPtrC eod(content); |
1138 TPtrC eod(content); |
1065 DoPtInsertL(0,eod); |
1139 DoPtInsertL(0,eod); |
1099 |
1173 |
1100 @return The number of characters in the text object. */ |
1174 @return The number of characters in the text object. */ |
1101 {return ((iByteStore->Size()/sizeof(TText))-1);} |
1175 {return ((iByteStore->Size()/sizeof(TText))-1);} |
1102 |
1176 |
1103 |
1177 |
1104 |
|
1105 |
|
1106 EXPORT_C void CPlainText::InsertL(TInt aInsertPos,const TChar& aChar) |
1178 EXPORT_C void CPlainText::InsertL(TInt aInsertPos,const TChar& aChar) |
1107 /** Inserts either a single character or a descriptor into the text object |
1179 /** Inserts either a single character or a descriptor into the text object |
1108 at a specified document position. |
1180 at a specified document position. |
1109 |
1181 |
1110 Updates the page table. |
1182 Updates the page table. |
1113 Must be valid, or a panic occurs. |
1185 Must be valid, or a panic occurs. |
1114 @param aChar The character to insert. |
1186 @param aChar The character to insert. |
1115 @param aBuf The descriptor to insert. */ |
1187 @param aBuf The descriptor to insert. */ |
1116 { |
1188 { |
1117 __TEST_INVARIANT; |
1189 __TEST_INVARIANT; |
|
1190 if (aInsertPos<0 || aInsertPos>DocumentLength()) |
|
1191 { |
|
1192 OstTrace0( TRACE_FATAL, CPLAINTEXT_INSERTL, "ECharPosBeyondDocument" ); |
|
1193 } |
1118 __ASSERT_ALWAYS(aInsertPos>=0 && aInsertPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1194 __ASSERT_ALWAYS(aInsertPos>=0 && aInsertPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1119 |
1195 |
1120 TBuf<1> content; |
1196 TInt contentLength = 1; |
1121 content.Append(aChar); |
1197 if (aChar < 0x10000) |
1122 DoPtInsertL(aInsertPos,content); |
1198 { |
|
1199 TBuf<1> content; |
|
1200 content.Append(aChar); |
|
1201 DoPtInsertL(aInsertPos,content); |
|
1202 } |
|
1203 else |
|
1204 { |
|
1205 TText16 high = TChar::GetHighSurrogate(aChar); |
|
1206 TText16 low = TChar::GetLowSurrogate(aChar); |
|
1207 RDebug::Print(_L("CPlainText::InsertL(%d), %X expand to %X %X."), aInsertPos, TUint(aChar), high, low); |
|
1208 |
|
1209 TBuf<2> content; |
|
1210 contentLength = 2; |
|
1211 content.Append(high); |
|
1212 content.Append(low); |
|
1213 DoPtInsertL(aInsertPos,content); |
|
1214 } |
1123 if (FieldSetPresent()) |
1215 if (FieldSetPresent()) |
1124 iFieldSet->NotifyInsertion(aInsertPos,content.Length()); // length always 1 - optimise??? |
1216 iFieldSet->NotifyInsertion(aInsertPos,contentLength); |
|
1217 |
1125 SetHasChanged(ETrue); |
1218 SetHasChanged(ETrue); |
1126 |
1219 |
1127 __TEST_INVARIANT; |
1220 __TEST_INVARIANT; |
1128 } |
1221 } |
1129 |
1222 |
1139 EXPORT_C void CPlainText::PtInsertL(TInt aPos,const TDesC& aBuf) |
1232 EXPORT_C void CPlainText::PtInsertL(TInt aPos,const TDesC& aBuf) |
1140 /** Inserts the contents a aBuf into the document at position aInsertPos. |
1233 /** Inserts the contents a aBuf into the document at position aInsertPos. |
1141 Maintain field set.*/ |
1234 Maintain field set.*/ |
1142 { |
1235 { |
1143 __TEST_INVARIANT; |
1236 __TEST_INVARIANT; |
|
1237 if (aPos<0 || aPos>DocumentLength()) |
|
1238 { |
|
1239 OstTrace0( TRACE_FATAL, CPLAINTEXT_PTINSERTL, "ECharPosBeyondDocument" ); |
|
1240 } |
1144 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1241 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1145 |
1242 |
1146 DoPtInsertL(aPos,aBuf); |
1243 DoPtInsertL(aPos,aBuf); |
1147 if (FieldSetPresent()) |
1244 if (FieldSetPresent()) |
1148 iFieldSet->NotifyInsertion(aPos,aBuf.Length()); |
1245 iFieldSet->NotifyInsertion(aPos,aBuf.Length()); |
1224 must be reformatted. |
1321 must be reformatted. |
1225 In global text, this clearly has no reasonable meaning, so always returns |
1322 In global text, this clearly has no reasonable meaning, so always returns |
1226 EFalse, so no reformatting occurs.*/ |
1323 EFalse, so no reformatting occurs.*/ |
1227 { |
1324 { |
1228 TInt documentLength=DocumentLength()+1; |
1325 TInt documentLength=DocumentLength()+1; |
|
1326 if (aPos<0 || aPos>documentLength) |
|
1327 { |
|
1328 OstTrace0( TRACE_FATAL, CPLAINTEXT_DOPTDELETE, "ECharPosBeyondDocument" ); |
|
1329 } |
1229 __ASSERT_ALWAYS(aPos>=0 && aPos<=documentLength,Panic(ECharPosBeyondDocument)); |
1330 __ASSERT_ALWAYS(aPos>=0 && aPos<=documentLength,Panic(ECharPosBeyondDocument)); |
|
1331 if (aLength<0) |
|
1332 { |
|
1333 OstTrace0( TRACE_FATAL, DUP1_CPLAINTEXT_DOPTDELETE, "EDeleteNegativeLength" ); |
|
1334 } |
1230 __ASSERT_ALWAYS(aLength>=0,Panic(EDeleteNegativeLength)); |
1335 __ASSERT_ALWAYS(aLength>=0,Panic(EDeleteNegativeLength)); |
|
1336 if (aPos+aLength>documentLength) |
|
1337 { |
|
1338 OstTrace0( TRACE_FATAL, DUP2_CPLAINTEXT_DOPTDELETE, "ECharPosBeyondDocument" ); |
|
1339 } |
1231 __ASSERT_ALWAYS(aPos+aLength<=documentLength,Panic(ECharPosBeyondDocument)); |
1340 __ASSERT_ALWAYS(aPos+aLength<=documentLength,Panic(ECharPosBeyondDocument)); |
1232 |
1341 |
1233 iByteStore->Delete(aPos*sizeof(TText),aLength*sizeof(TText)); |
1342 iByteStore->Delete(aPos*sizeof(TText),aLength*sizeof(TText)); |
1234 UpdatePageTable(aPos,-aLength); |
1343 UpdatePageTable(aPos,-aLength); |
1235 |
1344 |
1297 If EOrganiseByParagraph, lines do not wrap and paragraph delimiters are |
1410 If EOrganiseByParagraph, lines do not wrap and paragraph delimiters are |
1298 converted into CR/LF pairs. |
1411 converted into CR/LF pairs. |
1299 @param aMaxLineLength The maximum number of characters in each line, (only |
1412 @param aMaxLineLength The maximum number of characters in each line, (only |
1300 relevant if the text organisation is EOrganiseByLine). */ |
1413 relevant if the text organisation is EOrganiseByLine). */ |
1301 { |
1414 { |
|
1415 if (aTextOrganisation != EOrganiseByParagraph && aLineWrap <= 0) |
|
1416 { |
|
1417 OstTrace0( TRACE_DUMP, CPLAINTEXT_EXPORTASTEXTL, "EExportLineWrapInvalid" ); |
|
1418 } |
1302 __ASSERT_DEBUG(aTextOrganisation == EOrganiseByParagraph || aLineWrap > 0,Panic(EExportLineWrapInvalid)); |
1419 __ASSERT_DEBUG(aTextOrganisation == EOrganiseByParagraph || aLineWrap > 0,Panic(EExportLineWrapInvalid)); |
1303 RFs file_session; |
1420 RFs file_session; |
1304 TInt error = file_session.Connect(); |
1421 TInt error = file_session.Connect(); |
1305 if (error == KErrNone) |
1422 if (error == KErrNone) |
1306 { |
1423 { |
1468 @param aStartPos The document position at which to begin reading. Must be valid or a panic occurs. |
1589 @param aStartPos The document position at which to begin reading. Must be valid or a panic occurs. |
1469 @return Constant pointer to a section of the text object. |
1590 @return Constant pointer to a section of the text object. |
1470 */ |
1591 */ |
1471 { |
1592 { |
1472 __TEST_INVARIANT; |
1593 __TEST_INVARIANT; |
|
1594 if (aStartPos<0 || aStartPos>DocumentLength()) |
|
1595 { |
|
1596 OstTrace0( TRACE_FATAL, DUP1_CPLAINTEXT_READ, "ECharPosBeyondDocument" ); |
|
1597 } |
1473 __ASSERT_ALWAYS(aStartPos>=0 && aStartPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1598 __ASSERT_ALWAYS(aStartPos>=0 && aStartPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1474 |
1599 |
1475 TPtr8 buf=iByteStore->Ptr(aStartPos*sizeof(TText)); |
1600 TPtr8 buf=iByteStore->Ptr(aStartPos*sizeof(TText)); |
1476 return TPtrC((TText*)buf.Ptr(),buf.Length()/sizeof(TText)); |
1601 return TPtrC((TText*)buf.Ptr(),buf.Length()/sizeof(TText)); |
1477 } |
1602 } |
1494 @param aLength The number of characters to read, inclusive of the character at position aStartPos. |
1619 @param aLength The number of characters to read, inclusive of the character at position aStartPos. |
1495 @return Constant pointer to a section of the text object. |
1620 @return Constant pointer to a section of the text object. |
1496 */ |
1621 */ |
1497 { |
1622 { |
1498 __TEST_INVARIANT; |
1623 __TEST_INVARIANT; |
|
1624 if (aStartPos<0 || aStartPos>DocumentLength()) |
|
1625 { |
|
1626 OstTrace0( TRACE_FATAL, CPLAINTEXT_READ, "ECharPosBeyondDocument" ); |
|
1627 } |
1499 __ASSERT_ALWAYS(aStartPos>=0 && aStartPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1628 __ASSERT_ALWAYS(aStartPos>=0 && aStartPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1500 |
1629 |
1501 TPtr8 buf=iByteStore->Ptr(aStartPos*sizeof(TText)); |
1630 TPtr8 buf=iByteStore->Ptr(aStartPos*sizeof(TText)); |
1502 TInt length=Min(aLength,((TInt)buf.Length()/sizeof(TText))); |
1631 TInt length=Min(aLength,((TInt)buf.Length()/sizeof(TText))); |
1503 return TPtrC((TText*)buf.Ptr(),length); |
1632 return TPtrC((TText*)buf.Ptr(),length); |
1517 @param aPos The document position from which to copy. Must be valid or a |
1646 @param aPos The document position from which to copy. Must be valid or a |
1518 panic occurs.*/ |
1647 panic occurs.*/ |
1519 { |
1648 { |
1520 __TEST_INVARIANT; |
1649 __TEST_INVARIANT; |
1521 TInt documentLength=DocumentLength(); |
1650 TInt documentLength=DocumentLength(); |
|
1651 if (aPos<0 || aPos>documentLength) |
|
1652 { |
|
1653 OstTrace0( TRACE_FATAL, CPLAINTEXT_EXTRACT, "ECharPosBeyondDocument" ); |
|
1654 } |
1522 __ASSERT_ALWAYS(aPos>=0 && aPos<=documentLength,Panic(ECharPosBeyondDocument)); |
1655 __ASSERT_ALWAYS(aPos>=0 && aPos<=documentLength,Panic(ECharPosBeyondDocument)); |
|
1656 if (aBuf.MaxLength()<documentLength - aPos) |
|
1657 { |
|
1658 OstTrace0( TRACE_FATAL, DUP1_CPLAINTEXT_EXTRACT, "EExtractBufferTooSmall" ); |
|
1659 } |
1523 __ASSERT_ALWAYS(aBuf.MaxLength()>=documentLength - aPos,Panic(EExtractBufferTooSmall)); |
1660 __ASSERT_ALWAYS(aBuf.MaxLength()>=documentLength - aPos,Panic(EExtractBufferTooSmall)); |
1524 |
1661 |
1525 DoExtract(aBuf,aPos,documentLength-aPos); |
1662 DoExtract(aBuf,aPos,documentLength-aPos); |
1526 } |
1663 } |
1527 |
1664 |
1539 @param aPos The document position from which to copy. Must be valid or a panic |
1676 @param aPos The document position from which to copy. Must be valid or a panic |
1540 occurs. |
1677 occurs. |
1541 @param aLength The number of characters to copy. */ |
1678 @param aLength The number of characters to copy. */ |
1542 { |
1679 { |
1543 __TEST_INVARIANT; |
1680 __TEST_INVARIANT; |
|
1681 if (aPos<0 || aPos>DocumentLength()) |
|
1682 { |
|
1683 OstTrace0( TRACE_FATAL, DUP2_CPLAINTEXT_EXTRACT, "ECharPosBeyondDocument" ); |
|
1684 } |
1544 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1685 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
|
1686 if (aBuf.MaxLength()<aLength) |
|
1687 { |
|
1688 OstTrace0( TRACE_FATAL, DUP3_CPLAINTEXT_EXTRACT, "EExtractBufferTooSmall" ); |
|
1689 } |
1545 __ASSERT_ALWAYS(aBuf.MaxLength()>=aLength,Panic(EExtractBufferTooSmall)); |
1690 __ASSERT_ALWAYS(aBuf.MaxLength()>=aLength,Panic(EExtractBufferTooSmall)); |
1546 |
1691 |
1547 DoExtract(aBuf,aPos,aLength); |
1692 DoExtract(aBuf,aPos,aLength); |
1548 } |
1693 } |
1549 |
1694 |
1550 // Extract text, optionally discarding some characters such as control characters and soft hyphens or |
1695 // Extract text, optionally discarding some characters such as control characters and soft hyphens or |
1551 // inline text, depending on the flag. |
1696 // inline text, depending on the flag. |
1552 EXPORT_C void CPlainText::ExtractSelectively(TDes& aBuf,TInt aPos,TInt aLength,TUint aFlags) |
1697 EXPORT_C void CPlainText::ExtractSelectively(TDes& aBuf,TInt aPos,TInt aLength,TUint aFlags) |
1553 { |
1698 { |
|
1699 if (aPos < 0 || aPos > DocumentLength()) |
|
1700 { |
|
1701 OstTrace0( TRACE_FATAL, CPLAINTEXT_EXTRACTSELECTIVELY, "ECharPosBeyondDocument" ); |
|
1702 } |
1554 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(),Panic(ECharPosBeyondDocument)); |
1703 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(),Panic(ECharPosBeyondDocument)); |
1555 DoExtract(aBuf,aPos,aLength,aFlags); |
1704 DoExtract(aBuf,aPos,aLength,aFlags); |
1556 } |
1705 } |
1557 |
1706 |
1558 |
1707 |
1639 // specified by the character position aPos. |
1788 // specified by the character position aPos. |
1640 // Called from i) Insert ii) Delete iii) Paste from clipboard iv) Text file import. |
1789 // Called from i) Insert ii) Delete iii) Paste from clipboard iv) Text file import. |
1641 // |
1790 // |
1642 { |
1791 { |
1643 __TEST_INVARIANT; |
1792 __TEST_INVARIANT; |
|
1793 if (aPos<0 || aPos>DocumentLength()+1) |
|
1794 { |
|
1795 OstTrace0( TRACE_FATAL, CPLAINTEXT_UPDATEPAGETABLE, "ECharPosBeyondDocument" ); |
|
1796 } |
1644 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength()+1,Panic(ECharPosBeyondDocument)); |
1797 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength()+1,Panic(ECharPosBeyondDocument)); |
1645 |
1798 |
1646 if (iPageTable) |
1799 if (iPageTable) |
1647 (*iPageTable)[PageContainingPos(aPos)]+=aLength; |
1800 (*iPageTable)[PageContainingPos(aPos)]+=aLength; |
1648 } |
1801 } |
1655 |
1808 |
1656 @param aPos A document position. Must be valid or a panic occurs. |
1809 @param aPos A document position. Must be valid or a panic occurs. |
1657 @return The page number containing document position aPos. */ |
1810 @return The page number containing document position aPos. */ |
1658 { |
1811 { |
1659 __TEST_INVARIANT; |
1812 __TEST_INVARIANT; |
|
1813 if (aPos<0 || aPos>DocumentLength()) |
|
1814 { |
|
1815 OstTrace0( TRACE_FATAL, CPLAINTEXT_PAGECONTAININGPOS, "ECharPosBeyondDocument" ); |
|
1816 } |
1660 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1817 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1661 |
1818 |
1662 if (!iPageTable || (iPageTable->Count()<1)) |
1819 if (!iPageTable || (iPageTable->Count()<1)) |
1663 return 0; |
1820 return 0; |
1664 else |
1821 else |
1708 NULL, or a panic occurs. |
1865 NULL, or a panic occurs. |
1709 @param aFieldType Identifies the type of field to insert. For the built in |
1866 @param aFieldType Identifies the type of field to insert. For the built in |
1710 field types, see the UID values defined in flddef.h. */ |
1867 field types, see the UID values defined in flddef.h. */ |
1711 { |
1868 { |
1712 __TEST_INVARIANT; |
1869 __TEST_INVARIANT; |
|
1870 if (aPos<0 || aPos>DocumentLength()) |
|
1871 { |
|
1872 OstTrace0( TRACE_FATAL, CPLAINTEXT_INSERTFIELDL, "ECharPosBeyondDocument" ); |
|
1873 } |
1713 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1874 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
|
1875 if (!aField) |
|
1876 { |
|
1877 OstTrace0( TRACE_FATAL, DUP1_CPLAINTEXT_INSERTFIELDL, "ENoTextField" ); |
|
1878 } |
1714 __ASSERT_ALWAYS(aField,Panic(ENoTextField)); |
1879 __ASSERT_ALWAYS(aField,Panic(ENoTextField)); |
1715 |
1880 |
1716 if (!FieldSetPresent()) |
1881 if (!FieldSetPresent()) |
1717 CreateFieldSetL(DocumentLength()); |
1882 CreateFieldSetL(DocumentLength()); |
1718 iFieldSet->InsertFieldL(aPos,aField,aFieldType); |
1883 iFieldSet->InsertFieldL(aPos,aField,aFieldType); |
1735 |
1900 |
1736 @param aPos A document position in the field to be updated. Must be a valid |
1901 @param aPos A document position in the field to be updated. Must be a valid |
1737 position, or a panic occurs. */ |
1902 position, or a panic occurs. */ |
1738 { |
1903 { |
1739 __TEST_INVARIANT; |
1904 __TEST_INVARIANT; |
|
1905 if (aPos<0 || aPos>DocumentLength()) |
|
1906 { |
|
1907 OstTrace0( TRACE_FATAL, CPLAINTEXT_UPDATEFIELDL, "ECharPosBeyondDocument" ); |
|
1908 } |
1740 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1909 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1741 |
1910 |
1742 if (!FieldSetPresent()) |
1911 if (!FieldSetPresent()) |
1743 return; |
1912 return; |
1744 TFindFieldInfo info; |
1913 TFindFieldInfo info; |
1799 valid position or a panic occurs. |
1968 valid position or a panic occurs. |
1800 @return ETrue if a field was located at aPos. EFalse if no field was located |
1969 @return ETrue if a field was located at aPos. EFalse if no field was located |
1801 at aPos. */ |
1970 at aPos. */ |
1802 { |
1971 { |
1803 __TEST_INVARIANT; |
1972 __TEST_INVARIANT; |
|
1973 if (aPos<0 || aPos>DocumentLength()) |
|
1974 { |
|
1975 OstTrace0( TRACE_FATAL, CPLAINTEXT_REMOVEFIELD, "ECharPosBeyondDocument" ); |
|
1976 } |
1804 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1977 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1805 |
1978 |
1806 TBool fieldRemoved=EFalse; |
1979 TBool fieldRemoved=EFalse; |
1807 |
1980 |
1808 if (FieldSetPresent()) |
1981 if (FieldSetPresent()) |
1885 position or a panic occurs. |
2058 position or a panic occurs. |
1886 @return ETrue if there was a field located at aPos. EFalse if there was no |
2059 @return ETrue if there was a field located at aPos. EFalse if there was no |
1887 field located at aPos. */ |
2060 field located at aPos. */ |
1888 { |
2061 { |
1889 __TEST_INVARIANT; |
2062 __TEST_INVARIANT; |
|
2063 if (aPos<0 || aPos>DocumentLength()) |
|
2064 { |
|
2065 OstTrace0( TRACE_FATAL, CPLAINTEXT_CONVERTFIELDTOTEXT, "ECharPosBeyondDocument" ); |
|
2066 } |
1890 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
2067 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1891 |
2068 |
1892 TBool fieldConverted=EFalse; |
2069 TBool fieldConverted=EFalse; |
1893 |
2070 |
1894 if (FieldSetPresent()) |
2071 if (FieldSetPresent()) |