24 #include "TXTSTD.H" |
24 #include "TXTSTD.H" |
25 #include "TXTRTPFL.H" |
25 #include "TXTRTPFL.H" |
26 #include "ParseLst.h" |
26 #include "ParseLst.h" |
27 #include "TXTCLIPBOARD.H" |
27 #include "TXTCLIPBOARD.H" |
28 |
28 |
|
29 #include "OstTraceDefinitions.h" |
|
30 #ifdef OST_TRACE_COMPILER_IN_USE |
|
31 #include "TXTRICHTraces.h" |
|
32 #endif |
|
33 |
29 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
34 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
30 #include "TXTETEXT_INTERNAL.H" |
35 #include "TXTETEXT_INTERNAL.H" |
31 #include "TXTRICH_INTERNAL.H" |
36 #include "TXTRICH_INTERNAL.H" |
32 #endif |
37 #endif |
33 |
38 |
35 // Provides class invariants. Explanations below: |
40 // Provides class invariants. Explanations below: |
36 // |
41 // |
37 { |
42 { |
38 #ifdef _DEBUG |
43 #ifdef _DEBUG |
39 // ASSERT: The global format layers are never null. |
44 // ASSERT: The global format layers are never null. |
|
45 if (iGlobalParaFormatLayer == NULL) |
|
46 { |
|
47 OstTrace0( TRACE_DUMP, CRICHTEXT_DBGTESTINVARIANT, "Invariant" ); |
|
48 } |
40 __ASSERT_DEBUG(iGlobalParaFormatLayer != NULL, User::Invariant()); |
49 __ASSERT_DEBUG(iGlobalParaFormatLayer != NULL, User::Invariant()); |
|
50 if (iGlobalCharFormatLayer == NULL) |
|
51 { |
|
52 OstTrace0( TRACE_DUMP, DUP1_CRICHTEXT_DBGTESTINVARIANT, "Invariant" ); |
|
53 } |
41 __ASSERT_DEBUG(iGlobalCharFormatLayer != NULL, User::Invariant()); |
54 __ASSERT_DEBUG(iGlobalCharFormatLayer != NULL, User::Invariant()); |
42 if (IndexPresent()) |
55 if (IndexPresent()) |
43 { |
56 { |
44 // ASSERT: The sum of para lengths == the length as described by the document storage. |
57 // ASSERT: The sum of para lengths == the length as described by the document storage. |
45 TInt cumulativeParaLength = 0; |
58 TInt cumulativeParaLength = 0; |
47 for (TInt offset = 0; offset < maxPara; offset++) |
60 for (TInt offset = 0; offset < maxPara; offset++) |
48 { |
61 { |
49 TParaAttribsEntry entry = (*iIndex->iParaIx)[offset]; |
62 TParaAttribsEntry entry = (*iIndex->iParaIx)[offset]; |
50 cumulativeParaLength += entry.iLength; |
63 cumulativeParaLength += entry.iLength; |
51 } |
64 } |
|
65 if (cumulativeParaLength != (DocumentLength() + 1)) |
|
66 { |
|
67 OstTrace0( TRACE_DUMP, DUP2_CRICHTEXT_DBGTESTINVARIANT, "Invariant" ); |
|
68 } |
52 __ASSERT_DEBUG(cumulativeParaLength == (DocumentLength() + 1), User::Invariant()); |
69 __ASSERT_DEBUG(cumulativeParaLength == (DocumentLength() + 1), User::Invariant()); |
53 } |
70 } |
54 // Change here for defect INC005336. |
71 // Change here for defect INC005336. |
55 // This defect is present when the assertion below fails. |
72 // This defect is present when the assertion below fails. |
|
73 if ((iParserData != NULL) && |
|
74 (iParserData->HaveRange()) && |
|
75 (iParserData->EndParse() > DocumentLength())) |
|
76 { |
|
77 OstTrace0( TRACE_DUMP, DUP3_CRICHTEXT_DBGTESTINVARIANT, "Invariant" ); |
|
78 } |
56 __ASSERT_DEBUG( (iParserData == NULL) || \ |
79 __ASSERT_DEBUG( (iParserData == NULL) || \ |
57 (!iParserData->HaveRange()) || \ |
80 (!iParserData->HaveRange()) || \ |
58 (iParserData->EndParse() <= DocumentLength()), User::Invariant()); |
81 (iParserData->EndParse() <= DocumentLength()), User::Invariant()); |
59 #endif |
82 #endif |
60 } |
83 } |
78 or multiple paragraphs, and thus affects the granularity of aggregate objects |
101 or multiple paragraphs, and thus affects the granularity of aggregate objects |
79 used internally for storing paragraph attributes. Default = EMultiPara. |
102 used internally for storing paragraph attributes. Default = EMultiPara. |
80 @return The rich text object. */ |
103 @return The rich text object. */ |
81 { |
104 { |
82 // Create new rich text containing just a single end-of-document character. |
105 // Create new rich text containing just a single end-of-document character. |
|
106 if (aGlobalParaLayer == NULL) |
|
107 { |
|
108 OstTrace0( TRACE_FATAL, CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
|
109 } |
83 __ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle)); |
110 __ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle)); |
|
111 if (aGlobalCharLayer == NULL) |
|
112 { |
|
113 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
|
114 } |
84 __ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle)); |
115 __ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle)); |
85 |
116 |
86 CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer); |
117 CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer); |
87 CleanupStack::PushL(self); |
118 CleanupStack::PushL(self); |
88 self->ConstructL(aStorage, aDefaultTextGranularity, aParaType); |
119 self->ConstructL(aStorage, aDefaultTextGranularity, aParaType); |
120 @param aParaType This argument indicates whether you are using a single paragraph |
151 @param aParaType This argument indicates whether you are using a single paragraph |
121 or multiple paragraphs, and thus affects the granularity of aggregate objects |
152 or multiple paragraphs, and thus affects the granularity of aggregate objects |
122 used internally for storing paragraph attributes. Default = EMultiPara. |
153 used internally for storing paragraph attributes. Default = EMultiPara. |
123 @return The new rich text object. */ |
154 @return The new rich text object. */ |
124 { |
155 { |
|
156 if (aGlobalParaLayer == NULL) |
|
157 { |
|
158 OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
|
159 } |
125 __ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle)); |
160 __ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle)); |
|
161 if (aGlobalCharLayer == NULL) |
|
162 { |
|
163 OstTrace0( TRACE_FATAL, DUP3_CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
|
164 } |
126 __ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle)); |
165 __ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle)); |
127 |
166 |
128 CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer, CONST_CAST(CStyleList*, &aStyleList)); |
167 CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer, CONST_CAST(CStyleList*, &aStyleList)); |
129 CleanupStack::PushL(self); |
168 CleanupStack::PushL(self); |
130 self->ConstructL(aStorage, aDefaultTextGranularity, aParaType); |
169 self->ConstructL(aStorage, aDefaultTextGranularity, aParaType); |
157 if the text object supports fields. |
196 if the text object supports fields. |
158 @param aStorage The type of in-memory buffer to use. Defaults to ESegmentedStorage |
197 @param aStorage The type of in-memory buffer to use. Defaults to ESegmentedStorage |
159 which should rarely need to be changed. |
198 which should rarely need to be changed. |
160 @return The new rich text object. */ |
199 @return The new rich text object. */ |
161 { |
200 { |
|
201 if (aGlobalParaLayer == NULL) |
|
202 { |
|
203 OstTrace0( TRACE_FATAL, DUP4_CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
|
204 } |
162 __ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle)); |
205 __ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle)); |
|
206 if (aGlobalCharLayer == NULL) |
|
207 { |
|
208 OstTrace0( TRACE_FATAL, DUP5_CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
|
209 } |
163 __ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle)); |
210 __ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle)); |
164 |
211 |
165 CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer); |
212 CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer); |
166 CleanupStack::PushL(self); |
213 CleanupStack::PushL(self); |
167 self->ConstructL(aStore, aStreamId, NULL, NULL, aFieldFactory, aStorage); |
214 self->ConstructL(aStore, aStreamId, NULL, NULL, aFieldFactory, aStorage); |
203 which should rarely need to be changed. |
250 which should rarely need to be changed. |
204 @return The new rich text object. */ |
251 @return The new rich text object. */ |
205 { |
252 { |
206 // Restore a new rich text from the specified stream, that uses the specified global layers, and the |
253 // Restore a new rich text from the specified stream, that uses the specified global layers, and the |
207 // specified picture header factory and store, if this rich text supports pictures. |
254 // specified picture header factory and store, if this rich text supports pictures. |
|
255 if (!aPictureFactory && aStoreResolver) |
|
256 { |
|
257 OstTrace0( TRACE_FATAL, DUP6_CRICHTEXT_NEWL, "EInvalidPictureFactorySettings" ); |
|
258 } |
208 __ASSERT_ALWAYS(!(!aPictureFactory && aStoreResolver), Panic(EInvalidPictureFactorySettings)); |
259 __ASSERT_ALWAYS(!(!aPictureFactory && aStoreResolver), Panic(EInvalidPictureFactorySettings)); |
|
260 if (aGlobalParaLayer == NULL) |
|
261 { |
|
262 OstTrace0( TRACE_FATAL, DUP7_CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
|
263 } |
209 __ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle)); |
264 __ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle)); |
|
265 if (aGlobalCharLayer == NULL) |
|
266 { |
|
267 OstTrace0( TRACE_FATAL, DUP8_CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
|
268 } |
210 __ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle)); |
269 __ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle)); |
211 |
270 |
212 CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer); |
271 CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer); |
213 CleanupStack::PushL(self); |
272 CleanupStack::PushL(self); |
214 self->ConstructL(aStore, aStreamId, aPictureFactory, aStoreResolver, aFieldFactory, aStorage); |
273 self->ConstructL(aStore, aStreamId, aPictureFactory, aStoreResolver, aFieldFactory, aStorage); |
381 TStreamId CRichText::DoCopyToStoreL(CStreamStore& aStore,TInt aPos,TInt aLength,TStreamId aPlainTextId,TBool aCopyStyles) const |
440 TStreamId CRichText::DoCopyToStoreL(CStreamStore& aStore,TInt aPos,TInt aLength,TStreamId aPlainTextId,TBool aCopyStyles) const |
382 { |
441 { |
383 __TEST_INVARIANT; |
442 __TEST_INVARIANT; |
384 |
443 |
385 TInt documentLength = DocumentLength(); |
444 TInt documentLength = DocumentLength(); |
|
445 if (aPos < 0 || aPos > documentLength) |
|
446 { |
|
447 OstTrace0( TRACE_FATAL, CRICHTEXT_DOCOPYTOSTOREL, "ECharPosBeyondDocument" ); |
|
448 } |
386 __ASSERT_ALWAYS(aPos >= 0 && aPos <= documentLength,Panic(ECharPosBeyondDocument)); |
449 __ASSERT_ALWAYS(aPos >= 0 && aPos <= documentLength,Panic(ECharPosBeyondDocument)); |
|
450 if (aLength < 0) |
|
451 { |
|
452 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DOCOPYTOSTOREL, "ECopyToClipboardNegativeLength" ); |
|
453 } |
387 __ASSERT_ALWAYS(aLength >= 0,Panic(ECopyToClipboardNegativeLength)); |
454 __ASSERT_ALWAYS(aLength >= 0,Panic(ECopyToClipboardNegativeLength)); |
|
455 if (aPos + aLength > documentLength) |
|
456 { |
|
457 OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_DOCOPYTOSTOREL, "ECharPosBeyondDocument" ); |
|
458 } |
388 __ASSERT_ALWAYS(aPos + aLength <= documentLength,Panic(ECharPosBeyondDocument)); |
459 __ASSERT_ALWAYS(aPos + aLength <= documentLength,Panic(ECharPosBeyondDocument)); |
389 |
460 |
390 if (aLength == 0) |
461 if (aLength == 0) |
391 return KNullStreamId; |
462 return KNullStreamId; |
392 |
463 |
488 // instance at character position aPos. Returns the number of characters pasted. |
559 // instance at character position aPos. Returns the number of characters pasted. |
489 // May be 0. |
560 // May be 0. |
490 // |
561 // |
491 { |
562 { |
492 __TEST_INVARIANT; |
563 __TEST_INVARIANT; |
|
564 if (aPos > DocumentLength()) |
|
565 { |
|
566 OstTrace0( TRACE_FATAL, CRICHTEXT_DOPASTERTFROMSTOREL, "ECharPosBeyondDocument" ); |
|
567 } |
493 __ASSERT_ALWAYS(aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
568 __ASSERT_ALWAYS(aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
494 |
569 |
495 TUid type = KClipboardUidTypeRichTextWithStyles; |
570 TUid type = KClipboardUidTypeRichTextWithStyles; |
496 TStreamId id = aDictionary.At(type); |
571 TStreamId id = aDictionary.At(type); |
497 if (id == KNullStreamId) |
572 if (id == KNullStreamId) |
530 { |
605 { |
531 if (!IndexPresent()) |
606 if (!IndexPresent()) |
532 CreateAndGenerateMarkupComponentL(); // create the index if it does not already exist |
607 CreateAndGenerateMarkupComponentL(); // create the index if it does not already exist |
533 TStreamId id = aDictionary.At(KClipboardUidTypePlainText); |
608 TStreamId id = aDictionary.At(KClipboardUidTypePlainText); |
534 // ASSERT: We have rich text, so the plain text stream must exist. |
609 // ASSERT: We have rich text, so the plain text stream must exist. |
|
610 if (id == KNullStreamId) |
|
611 { |
|
612 OstTrace0( TRACE_FATAL, CRICHTEXT_PASTERICHTEXTFROMSTOREL, "EClipboardIntegrity" ); |
|
613 } |
535 __ASSERT_ALWAYS(id != KNullStreamId,Panic(EClipboardIntegrity)); |
614 __ASSERT_ALWAYS(id != KNullStreamId,Panic(EClipboardIntegrity)); |
536 TInt consumed = CPlainText::DoPasteFromStoreL(aStore, id, aPos); |
615 TInt consumed = CPlainText::DoPasteFromStoreL(aStore, id, aPos); |
537 TRAPD(ret, CompletePasteRichTextFromStoreL(aStore, aRichTextStreamId, aPos, aStylePasteMode)); |
616 TRAPD(ret, CompletePasteRichTextFromStoreL(aStore, aRichTextStreamId, aPos, aStylePasteMode)); |
538 if (ret != KErrNone) |
617 if (ret != KErrNone) |
539 { |
618 { |
540 CPlainText::Delete(aPos,consumed); |
619 CPlainText::Delete(aPos,consumed); |
|
620 OstTrace1( TRACE_FATAL, DUP1_CRICHTEXT_PASTERICHTEXTFROMSTOREL, "Leave code=%d", ret ); |
541 User::Leave(ret); |
621 User::Leave(ret); |
542 } |
622 } |
543 return consumed; |
623 return consumed; |
544 } |
624 } |
545 |
625 |
623 @param aChar The character to insert. Must not be a picture character or a |
703 @param aChar The character to insert. Must not be a picture character or a |
624 panic occurs. |
704 panic occurs. |
625 @param aBuf The descriptor to insert. */ |
705 @param aBuf The descriptor to insert. */ |
626 { |
706 { |
627 __TEST_INVARIANT; |
707 __TEST_INVARIANT; |
|
708 if (aPos < 0 || aPos > DocumentLength()) |
|
709 { |
|
710 OstTrace0( TRACE_FATAL, CRICHTEXT_INSERTL, "ECharPosBeyondDocument" ); |
|
711 } |
628 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
712 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
|
713 if (aChar == EPictureCharacter) |
|
714 { |
|
715 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_INSERTL, "ENonOverloadedInsertCalledWithPictureCharacter" ); |
|
716 } |
629 __ASSERT_ALWAYS(aChar!= EPictureCharacter, Panic(ENonOverloadedInsertCalledWithPictureCharacter)); |
717 __ASSERT_ALWAYS(aChar!= EPictureCharacter, Panic(ENonOverloadedInsertCalledWithPictureCharacter)); |
630 |
718 |
631 if (aChar < 0x10000) |
719 if (aChar < 0x10000) |
632 { |
720 { |
633 TBuf<1> content; |
721 TBuf<1> content; |
667 // Updates the index accordingly, and accounts for all embedded paragraph delimiters |
755 // Updates the index accordingly, and accounts for all embedded paragraph delimiters |
668 // in the passed buffer aBuf. |
756 // in the passed buffer aBuf. |
669 // |
757 // |
670 { |
758 { |
671 __TEST_INVARIANT; |
759 __TEST_INVARIANT; |
|
760 if (aPos < 0 || aPos > DocumentLength()) |
|
761 { |
|
762 OstTrace0( TRACE_FATAL, CRICHTEXT_RTINSERTL, "ECharPosBeyondDocument" ); |
|
763 } |
672 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
764 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
673 |
765 |
674 int length = aBuf.Length(); |
766 int length = aBuf.Length(); |
675 CPlainText::InsertL(aPos, aBuf); |
767 CPlainText::InsertL(aPos, aBuf); |
676 if (IndexPresent()) |
768 if (IndexPresent()) |
706 be valid, or a panic occurs. |
798 be valid, or a panic occurs. |
707 @param aHeader A picture header. This holds a pointer to the picture to insert, |
799 @param aHeader A picture header. This holds a pointer to the picture to insert, |
708 and information about the picture. */ |
800 and information about the picture. */ |
709 { |
801 { |
710 __TEST_INVARIANT; |
802 __TEST_INVARIANT; |
|
803 if (aPos < 0 || aPos > DocumentLength()) |
|
804 { |
|
805 OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_INSERTL, "ECharPosBeyondDocument" ); |
|
806 } |
711 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
807 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
712 |
808 |
713 CleanupStack::PushL(aHeader.iPicture); |
809 CleanupStack::PushL(aHeader.iPicture); |
714 |
810 |
715 if (!IndexPresent()) |
811 if (!IndexPresent()) |
756 // Deletes aRange number of characters from the text component |
852 // Deletes aRange number of characters from the text component |
757 // and the corresponding index data. |
853 // and the corresponding index data. |
758 // Delete commences at, and includes, character position aPos. |
854 // Delete commences at, and includes, character position aPos. |
759 __TEST_INVARIANT; |
855 __TEST_INVARIANT; |
760 |
856 |
|
857 if (aPos < 0 || aPos > DocumentLength()) |
|
858 { |
|
859 OstTrace0( TRACE_FATAL, CRICHTEXT_DELETEL, "ECharPosBeyondDocument" ); |
|
860 } |
761 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
861 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
|
862 if (aLength < 0) |
|
863 { |
|
864 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DELETEL, "EDebugDeleteZeroLength" ); |
|
865 } |
762 __ASSERT_ALWAYS(aLength >= 0, Panic(EDebugDeleteZeroLength)); |
866 __ASSERT_ALWAYS(aLength >= 0, Panic(EDebugDeleteZeroLength)); |
|
867 if (aPos + (aLength - 1) > DocumentLength()) |
|
868 { |
|
869 OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_DELETEL, "ECharPosBeyondDocument" ); |
|
870 } |
763 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
871 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
764 |
872 |
765 TBool requireMerge = EFalse; |
873 TBool requireMerge = EFalse; |
766 if (!IndexPresent()) |
874 if (!IndexPresent()) |
767 CPlainText::Delete(aPos,aLength); |
875 CPlainText::Delete(aPos,aLength); |
795 __TEST_INVARIANT; |
903 __TEST_INVARIANT; |
796 |
904 |
797 // Store the length of the text before we commence with deletions. |
905 // Store the length of the text before we commence with deletions. |
798 TInt initialDocLen=DocumentLength(); |
906 TInt initialDocLen=DocumentLength(); |
799 |
907 |
|
908 if (aPos < 0 || aPos > initialDocLen) |
|
909 { |
|
910 OstTrace0( TRACE_FATAL, CRICHTEXT_DELETEPARAGRAPH, "ECharPosBeyondDocument" ); |
|
911 } |
800 __ASSERT_ALWAYS(aPos >= 0 && aPos <= initialDocLen, Panic(ECharPosBeyondDocument)); |
912 __ASSERT_ALWAYS(aPos >= 0 && aPos <= initialDocLen, Panic(ECharPosBeyondDocument)); |
|
913 if (aPos + aLength > initialDocLen + 1) |
|
914 { |
|
915 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DELETEPARAGRAPH, "ECharPosBeyondDocument" ); |
|
916 } |
801 __ASSERT_ALWAYS(aPos + aLength <= initialDocLen + 1, Panic(ECharPosBeyondDocument)); |
917 __ASSERT_ALWAYS(aPos + aLength <= initialDocLen + 1, Panic(ECharPosBeyondDocument)); |
802 |
918 |
803 if (aLength <= 0) |
919 if (aLength <= 0) |
804 return; |
920 return; |
805 |
921 |
845 { |
961 { |
846 // Removes aLength characters from *within* a single paragraph only. |
962 // Removes aLength characters from *within* a single paragraph only. |
847 // Guaranteed not to leave if this pre-condition holds true. |
963 // Guaranteed not to leave if this pre-condition holds true. |
848 __TEST_INVARIANT; |
964 __TEST_INVARIANT; |
849 |
965 |
|
966 if (aPos < 0 || aPos > DocumentLength()) |
|
967 { |
|
968 OstTrace0( TRACE_FATAL, CRICHTEXT_DELETEFROMPARAGRAPH, "ECharPosBeyondDocument" ); |
|
969 } |
850 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
970 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
|
971 if (aPos + (aLength - 1) > DocumentLength()) |
|
972 { |
|
973 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DELETEFROMPARAGRAPH, "ECharPosBeyondDocument" ); |
|
974 } |
851 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
975 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
852 |
976 |
853 if (aLength <= 0) |
977 if (aLength <= 0) |
854 return; |
978 return; |
855 |
979 |
932 // Returns the paragraph offset for the specified character position aPos. |
1056 // Returns the paragraph offset for the specified character position aPos. |
933 // aPos is in turn modified to hold the character position of the first character |
1057 // aPos is in turn modified to hold the character position of the first character |
934 // of this paragraph. If aPos is already on a paragraph boundary then do nothing. |
1058 // of this paragraph. If aPos is already on a paragraph boundary then do nothing. |
935 // |
1059 // |
936 __TEST_INVARIANT; |
1060 __TEST_INVARIANT; |
|
1061 if (aPos < 0 || aPos > DocumentLength()) |
|
1062 { |
|
1063 OstTrace0( TRACE_FATAL, CRICHTEXT_PARAGRAPHNUMBERFORPOS, "ECharPosBeyondDocument" ); |
|
1064 } |
937 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1065 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
938 |
1066 |
939 if (IndexPresent()) |
1067 if (IndexPresent()) |
940 return iIndex->ParagraphNumberForPos(aPos); |
1068 return iIndex->ParagraphNumberForPos(aPos); |
941 else |
1069 else |
970 reinterpret_cast<CRichTextIndex*>(aCRichTextIndex)->CancelInsertCharFormat(); |
1098 reinterpret_cast<CRichTextIndex*>(aCRichTextIndex)->CancelInsertCharFormat(); |
971 } |
1099 } |
972 |
1100 |
973 void CRichText::SetExtendedInsertCharFormatL(const TCharFormatX& aFormat, const TCharFormatXMask& aMask, TInt aPos) |
1101 void CRichText::SetExtendedInsertCharFormatL(const TCharFormatX& aFormat, const TCharFormatXMask& aMask, TInt aPos) |
974 { |
1102 { |
|
1103 if (aPos < 0 || aPos > DocumentLength()) |
|
1104 { |
|
1105 OstTrace0( TRACE_FATAL, CRICHTEXT_SETEXTENDEDINSERTCHARFORMATL, "ECharPosBeyondDocument" ); |
|
1106 } |
975 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1107 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
976 CreateAndGenerateMarkupComponentL(); |
1108 CreateAndGenerateMarkupComponentL(); |
977 CRichTextIndex* index = iIndex.AsPtr(); |
1109 CRichTextIndex* index = iIndex.AsPtr(); |
978 if (index->InsertCharFormatIsActive()) |
1110 if (index->InsertCharFormatIsActive()) |
979 { |
1111 { |
1052 // If aPos is on a phrase boundary, and the whole phrase or more is deleted then |
1184 // If aPos is on a phrase boundary, and the whole phrase or more is deleted then |
1053 // remember temporarily the phrase format. This is applied to any content that is |
1185 // remember temporarily the phrase format. This is applied to any content that is |
1054 // immediately inserted. |
1186 // immediately inserted. |
1055 // |
1187 // |
1056 __TEST_INVARIANT; |
1188 __TEST_INVARIANT; |
|
1189 if (aPos < 0 || aPos > DocumentLength()) |
|
1190 { |
|
1191 OstTrace0( TRACE_FATAL, CRICHTEXT_DELSETINSERTCHARFORMATL, "ECharPosBeyondDocument" ); |
|
1192 } |
1057 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1193 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
|
1194 if (aLength < 0) |
|
1195 { |
|
1196 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DELSETINSERTCHARFORMATL, "EDebugDeleteZeroLength" ); |
|
1197 } |
1058 __ASSERT_ALWAYS(aLength >= 0, Panic(EDebugDeleteZeroLength)); |
1198 __ASSERT_ALWAYS(aLength >= 0, Panic(EDebugDeleteZeroLength)); |
|
1199 if (aPos + (aLength - 1) > DocumentLength()) |
|
1200 { |
|
1201 OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_DELSETINSERTCHARFORMATL, "ECharPosBeyondDocument" ); |
|
1202 } |
1059 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1203 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1060 |
1204 |
1061 TBool parasMerged = EFalse; |
1205 TBool parasMerged = EFalse; |
1062 if (!IndexPresent()) |
1206 if (!IndexPresent()) |
1063 CPlainText::DeleteL(aPos, aLength); |
1207 CPlainText::DeleteL(aPos, aLength); |
1110 { |
1254 { |
1111 // Applies the specified format attributes to the paragraphs covering |
1255 // Applies the specified format attributes to the paragraphs covering |
1112 // character position aPos to aPos+aLength-1. |
1256 // character position aPos to aPos+aLength-1. |
1113 // |
1257 // |
1114 __TEST_INVARIANT; |
1258 __TEST_INVARIANT; |
|
1259 if (aPos < 0 || aPos > DocumentLength()) |
|
1260 { |
|
1261 OstTrace0( TRACE_FATAL, CRICHTEXT_APPLYPARAFORMATL, "ECharPosBeyondDocument" ); |
|
1262 } |
1115 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1263 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
|
1264 if (aLength < 0) |
|
1265 { |
|
1266 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_APPLYPARAFORMATL, "EApplyParaFormatNegativeLength" ); |
|
1267 } |
1116 __ASSERT_ALWAYS(aLength >= 0,Panic(EApplyParaFormatNegativeLength)); |
1268 __ASSERT_ALWAYS(aLength >= 0,Panic(EApplyParaFormatNegativeLength)); |
|
1269 if (aPos + (aLength - 1) > DocumentLength()) |
|
1270 { |
|
1271 OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_APPLYPARAFORMATL, "ECharPosBeyondDocument" ); |
|
1272 } |
1117 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1273 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1118 |
1274 |
1119 CreateAndGenerateMarkupComponentL(); |
1275 CreateAndGenerateMarkupComponentL(); |
1120 iIndex->ApplyParaFormatL(aFormat, aMask, aPos, aLength); |
1276 iIndex->ApplyParaFormatL(aFormat, aMask, aPos, aLength); |
1121 SetHasChanged(ETrue); |
1277 SetHasChanged(ETrue); |
1145 // |
1301 // |
1146 __ETEXT_WATCH(APPLY_CHAR_FORMAT); |
1302 __ETEXT_WATCH(APPLY_CHAR_FORMAT); |
1147 __TEST_INVARIANT; |
1303 __TEST_INVARIANT; |
1148 |
1304 |
1149 TInt document_length = DocumentLength(); |
1305 TInt document_length = DocumentLength(); |
|
1306 if (aPos < 0) |
|
1307 { |
|
1308 OstTrace0( TRACE_FATAL, CRICHTEXT_APPLYCHARFORMATL, "ECharPosBeyondDocument" ); |
|
1309 } |
1150 __ASSERT_ALWAYS(aPos >= 0,Panic(ECharPosBeyondDocument)); |
1310 __ASSERT_ALWAYS(aPos >= 0,Panic(ECharPosBeyondDocument)); |
|
1311 if (aLength < 0) |
|
1312 { |
|
1313 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_APPLYCHARFORMATL, "EApplyCharFormatNegativeLength" ); |
|
1314 } |
1151 __ASSERT_ALWAYS(aLength >= 0,Panic(EApplyCharFormatNegativeLength)); |
1315 __ASSERT_ALWAYS(aLength >= 0,Panic(EApplyCharFormatNegativeLength)); |
|
1316 if (aPos + aLength - 1 > document_length) |
|
1317 { |
|
1318 OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_APPLYCHARFORMATL, "ECharPosBeyondDocument" ); |
|
1319 } |
1152 __ASSERT_ALWAYS(aPos + aLength - 1 <= document_length,Panic(ECharPosBeyondDocument)); |
1320 __ASSERT_ALWAYS(aPos + aLength - 1 <= document_length,Panic(ECharPosBeyondDocument)); |
1153 |
1321 |
1154 //If some characters are highlighted AND current position + highlighted txt = document length |
1322 //If some characters are highlighted AND current position + highlighted txt = document length |
1155 // Fix for INC097216. Compensate for the changes introduced to Form in defect fix INC087637, |
1323 // Fix for INC097216. Compensate for the changes introduced to Form in defect fix INC087637, |
1156 // which now considers the height of the EOD character; meaning that this character now |
1324 // which now considers the height of the EOD character; meaning that this character now |
1168 |
1336 |
1169 // This method is used internally only. It does not format the EOD character. |
1337 // This method is used internally only. It does not format the EOD character. |
1170 void CRichText::ApplyExtendedCharFormatL(const TCharFormatX& aFormat,const TCharFormatXMask& aMask,TInt aPos,TInt aLength) |
1338 void CRichText::ApplyExtendedCharFormatL(const TCharFormatX& aFormat,const TCharFormatXMask& aMask,TInt aPos,TInt aLength) |
1171 { |
1339 { |
1172 TInt document_length = DocumentLength(); |
1340 TInt document_length = DocumentLength(); |
|
1341 if (aPos < 0) |
|
1342 { |
|
1343 OstTrace0( TRACE_FATAL, CRICHTEXT_APPLYEXTENDEDCHARFORMATL, "ECharPosBeyondDocument" ); |
|
1344 } |
1173 __ASSERT_ALWAYS(aPos >= 0,Panic(ECharPosBeyondDocument)); |
1345 __ASSERT_ALWAYS(aPos >= 0,Panic(ECharPosBeyondDocument)); |
|
1346 if (aLength < 0) |
|
1347 { |
|
1348 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_APPLYEXTENDEDCHARFORMATL, "EApplyCharFormatNegativeLength" ); |
|
1349 } |
1174 __ASSERT_ALWAYS(aLength >= 0,Panic(EApplyCharFormatNegativeLength)); |
1350 __ASSERT_ALWAYS(aLength >= 0,Panic(EApplyCharFormatNegativeLength)); |
|
1351 if (aPos + aLength - 1 > document_length) |
|
1352 { |
|
1353 OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_APPLYEXTENDEDCHARFORMATL, "ECharPosBeyondDocument" ); |
|
1354 } |
1175 __ASSERT_ALWAYS(aPos + aLength - 1 <= document_length,Panic(ECharPosBeyondDocument)); |
1355 __ASSERT_ALWAYS(aPos + aLength - 1 <= document_length,Panic(ECharPosBeyondDocument)); |
1176 |
1356 |
1177 DoApplyExtendedCharFormatL(aFormat, aMask, aPos, aLength); |
1357 DoApplyExtendedCharFormatL(aFormat, aMask, aPos, aLength); |
1178 } |
1358 } |
1179 |
1359 |
1226 { |
1406 { |
1227 // Applies the specified paragraph style to the paragraphs covering |
1407 // Applies the specified paragraph style to the paragraphs covering |
1228 // character positions aPos to aPos+aLength-1. |
1408 // character positions aPos to aPos+aLength-1. |
1229 // |
1409 // |
1230 __TEST_INVARIANT; |
1410 __TEST_INVARIANT; |
|
1411 if (aPos < 0 || aPos > DocumentLength()) |
|
1412 { |
|
1413 OstTrace0( TRACE_FATAL, CRICHTEXT_APPLYPARAGRAPHSTYLEL, "ECharPosBeyondDocument" ); |
|
1414 } |
1231 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1415 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
|
1416 if (aLength < 0) |
|
1417 { |
|
1418 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_APPLYPARAGRAPHSTYLEL, "EApplyParaStyleNegativeLength" ); |
|
1419 } |
1232 __ASSERT_ALWAYS(aLength >= 0, Panic(EApplyParaStyleNegativeLength)); |
1420 __ASSERT_ALWAYS(aLength >= 0, Panic(EApplyParaStyleNegativeLength)); |
|
1421 if (aPos + (aLength - 1) > DocumentLength()) |
|
1422 { |
|
1423 OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_APPLYPARAGRAPHSTYLEL, "ECharPosBeyondDocument" ); |
|
1424 } |
1233 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1425 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
|
1426 if (!StyleListPresent()) |
|
1427 { |
|
1428 OstTrace0( TRACE_FATAL, DUP3_CRICHTEXT_APPLYPARAGRAPHSTYLEL, "ERichTextNotSetForUsingStyles" ); |
|
1429 } |
1234 __ASSERT_ALWAYS(StyleListPresent(), Panic(ERichTextNotSetForUsingStyles)); |
1430 __ASSERT_ALWAYS(StyleListPresent(), Panic(ERichTextNotSetForUsingStyles)); |
1235 |
1431 |
1236 CreateAndGenerateMarkupComponentL(); |
1432 CreateAndGenerateMarkupComponentL(); |
1237 iIndex->ApplyParagraphStyleL(aStyle, aPos, aLength, iGlobalCharFormatLayer, aMode); |
1433 iIndex->ApplyParagraphStyleL(aStyle, aPos, aLength, iGlobalCharFormatLayer, aMode); |
1238 SetHasChanged(ETrue); |
1434 SetHasChanged(ETrue); |
1260 @param aFrom The paragraph style to remove. */ |
1456 @param aFrom The paragraph style to remove. */ |
1261 { |
1457 { |
1262 // Update the rich text index following the change of an applied paragraph style. |
1458 // Update the rich text index following the change of an applied paragraph style. |
1263 // |
1459 // |
1264 __TEST_INVARIANT; |
1460 __TEST_INVARIANT; |
|
1461 if (!StyleListPresent()) |
|
1462 { |
|
1463 OstTrace0( TRACE_FATAL, CRICHTEXT_NOTIFYSTYLECHANGEDL, "ERichTextNotSetForUsingStyles" ); |
|
1464 } |
1265 __ASSERT_ALWAYS(StyleListPresent(), Panic(ERichTextNotSetForUsingStyles)); |
1465 __ASSERT_ALWAYS(StyleListPresent(), Panic(ERichTextNotSetForUsingStyles)); |
1266 |
1466 |
1267 CreateAndGenerateMarkupComponentL(); |
1467 CreateAndGenerateMarkupComponentL(); |
1268 iIndex->NotifyStyleChangedL(aTo, aFrom, *iGlobalParaFormatLayer, *iGlobalCharFormatLayer); |
1468 iIndex->NotifyStyleChangedL(aTo, aFrom, *iGlobalParaFormatLayer, *iGlobalCharFormatLayer); |
1269 SetHasChanged(ETrue); |
1469 SetHasChanged(ETrue); |
1283 @return Pointer to the paragraph style which applies to the paragraph containing |
1483 @return Pointer to the paragraph style which applies to the paragraph containing |
1284 document position aPos. Its type (returned by CParaFormatLayer::Type()) |
1484 document position aPos. Its type (returned by CParaFormatLayer::Type()) |
1285 indicates whether this object is a style, or just a paragraph format layer. */ |
1485 indicates whether this object is a style, or just a paragraph format layer. */ |
1286 { |
1486 { |
1287 __TEST_INVARIANT; |
1487 __TEST_INVARIANT; |
|
1488 if (aPos < 0 || aPos > DocumentLength()) |
|
1489 { |
|
1490 OstTrace0( TRACE_FATAL, CRICHTEXT_PARAGRAPHSTYLE, "ECharPosBeyondDocument" ); |
|
1491 } |
1288 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1492 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
|
1493 if (aLength < 0) |
|
1494 { |
|
1495 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_PARAGRAPHSTYLE, "EParagraphStyleNegativeLength" ); |
|
1496 } |
1289 __ASSERT_ALWAYS(aLength >= 0,Panic(EParagraphStyleNegativeLength)); |
1497 __ASSERT_ALWAYS(aLength >= 0,Panic(EParagraphStyleNegativeLength)); |
|
1498 if (aPos + (aLength - 1) > DocumentLength()) |
|
1499 { |
|
1500 OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_PARAGRAPHSTYLE, "ECharPosBeyondDocument" ); |
|
1501 } |
1290 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1502 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1291 |
1503 |
1292 if (IndexPresent()) |
1504 if (IndexPresent()) |
1293 return iIndex->ParagraphStyle(aStyleChangesOverRange, aPos, aLength); |
1505 return iIndex->ParagraphStyle(aStyleChangesOverRange, aPos, aLength); |
1294 else |
1506 else |
1335 // |
1547 // |
1336 __ETEXT_WATCH(REMOVE_PARA_FORMAT); |
1548 __ETEXT_WATCH(REMOVE_PARA_FORMAT); |
1337 |
1549 |
1338 __TEST_INVARIANT; |
1550 __TEST_INVARIANT; |
1339 |
1551 |
|
1552 if (aPos < 0 || aPos > DocumentLength()) |
|
1553 { |
|
1554 OstTrace0( TRACE_FATAL, CRICHTEXT_REMOVESPECIFICPARAFORMATL, "ECharPosBeyondDocument" ); |
|
1555 } |
1340 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1556 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
|
1557 if (aLength < 0) |
|
1558 { |
|
1559 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_REMOVESPECIFICPARAFORMATL, "ERemoveSpecificParaFormatNegativeLength" ); |
|
1560 } |
1341 __ASSERT_ALWAYS(aLength >= 0, Panic(ERemoveSpecificParaFormatNegativeLength)); |
1561 __ASSERT_ALWAYS(aLength >= 0, Panic(ERemoveSpecificParaFormatNegativeLength)); |
|
1562 if (aPos + (aLength - 1) > DocumentLength()) |
|
1563 { |
|
1564 OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_REMOVESPECIFICPARAFORMATL, "ECharPosBeyondDocument" ); |
|
1565 } |
1342 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1566 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1343 |
1567 |
1344 if (IndexPresent()) |
1568 if (IndexPresent()) |
1345 { |
1569 { |
1346 iIndex->RemoveSpecificParaFormatL(aPos, aLength); |
1570 iIndex->RemoveSpecificParaFormatL(aPos, aLength); |
1368 function has no effect. */ |
1592 function has no effect. */ |
1369 { |
1593 { |
1370 __TEST_INVARIANT; |
1594 __TEST_INVARIANT; |
1371 |
1595 |
1372 TInt document_length = DocumentLength(); |
1596 TInt document_length = DocumentLength(); |
|
1597 if (aPos < 0 || aPos > DocumentLength()) |
|
1598 { |
|
1599 OstTrace0( TRACE_FATAL, CRICHTEXT_REMOVESPECIFICCHARFORMATL, "ECharPosBeyondDocument" ); |
|
1600 } |
1373 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1601 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
|
1602 if (aLength < 0) |
|
1603 { |
|
1604 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_REMOVESPECIFICCHARFORMATL, "ERemoveSpecificParaFormatNegativeLength" ); |
|
1605 } |
1374 __ASSERT_ALWAYS(aLength >= 0, Panic(ERemoveSpecificParaFormatNegativeLength)); |
1606 __ASSERT_ALWAYS(aLength >= 0, Panic(ERemoveSpecificParaFormatNegativeLength)); |
|
1607 if (aPos + (aLength - 1) > DocumentLength()) |
|
1608 { |
|
1609 OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_REMOVESPECIFICCHARFORMATL, "ECharPosBeyondDocument" ); |
|
1610 } |
1375 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1611 __ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1376 |
1612 |
1377 // in correspondance to INC097216, character format removing considers the height of end of document |
1613 // in correspondance to INC097216, character format removing considers the height of end of document |
1378 // character |
1614 // character |
1379 if (aPos + aLength == document_length) |
1615 if (aPos + aLength == document_length) |
1418 |
1654 |
1419 void CRichText::GetTextAndExtendedFormat(TPtrC& aText,TCharFormatX& aFormat,TInt aPos) const |
1655 void CRichText::GetTextAndExtendedFormat(TPtrC& aText,TCharFormatX& aFormat,TInt aPos) const |
1420 { |
1656 { |
1421 __TEST_INVARIANT; |
1657 __TEST_INVARIANT; |
1422 TInt documentLength = DocumentLength(); |
1658 TInt documentLength = DocumentLength(); |
|
1659 if (aPos < 0 || aPos > documentLength) |
|
1660 { |
|
1661 OstTrace0( TRACE_FATAL, CRICHTEXT_GETTEXTANDEXTENDEDFORMAT, "ECharPosBeyondDocument" ); |
|
1662 } |
1423 __ASSERT_ALWAYS(aPos >= 0 && aPos <= documentLength, Panic(ECharPosBeyondDocument)); |
1663 __ASSERT_ALWAYS(aPos >= 0 && aPos <= documentLength, Panic(ECharPosBeyondDocument)); |
1424 if (!IndexPresent()) |
1664 if (!IndexPresent()) |
1425 { |
1665 { |
1426 aText.Set(Read(aPos)); |
1666 aText.Set(Read(aPos)); |
1427 iGlobalCharFormatLayer->SenseEffective(aFormat); |
1667 iGlobalCharFormatLayer->SenseEffective(aFormat); |
1441 @param aPos Document position of the picture. Must be a valid position. |
1681 @param aPos Document position of the picture. Must be a valid position. |
1442 @return KErrNotFound if there is no picture at the specified document position, |
1682 @return KErrNotFound if there is no picture at the specified document position, |
1443 KErrNone if there is. */ |
1683 KErrNone if there is. */ |
1444 { |
1684 { |
1445 __TEST_INVARIANT; |
1685 __TEST_INVARIANT; |
|
1686 if (aPos < 0 || aPos > DocumentLength()) |
|
1687 { |
|
1688 OstTrace0( TRACE_FATAL, CRICHTEXT_GETPICTURESIZEINTWIPS, "ECharPosBeyondDocument" ); |
|
1689 } |
1446 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1690 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1447 |
1691 |
1448 if (IndexPresent()) |
1692 if (IndexPresent()) |
1449 return iIndex->GetPictureSizeInTwips(aSize, aPos); |
1693 return iIndex->GetPictureSizeInTwips(aSize, aPos); |
1450 else |
1694 else |
1470 and the second argument is MLayDoc::EForceLoadFalse. */ |
1714 and the second argument is MLayDoc::EForceLoadFalse. */ |
1471 { |
1715 { |
1472 __ETEXT_WATCH(PICTURE_HANDLE); |
1716 __ETEXT_WATCH(PICTURE_HANDLE); |
1473 |
1717 |
1474 __TEST_INVARIANT; |
1718 __TEST_INVARIANT; |
|
1719 if (aPos<0 || aPos>DocumentLength()) |
|
1720 { |
|
1721 OstTrace0( TRACE_FATAL, CRICHTEXT_PICTUREHANDLEL, "ECharPosBeyondDocument" ); |
|
1722 } |
1475 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1723 __ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1476 |
1724 |
1477 if (IndexPresent()) |
1725 if (IndexPresent()) |
1478 return iIndex->PictureHandleL(aPos, aForceLoad); |
1726 return iIndex->PictureHandleL(aPos, aForceLoad); |
1479 else |
1727 else |
1492 @param aPos Any document position within the paragraph of interest. */ |
1740 @param aPos Any document position within the paragraph of interest. */ |
1493 { |
1741 { |
1494 __ETEXT_WATCH(GET_PARAGRAPH_FORMAT) |
1742 __ETEXT_WATCH(GET_PARAGRAPH_FORMAT) |
1495 |
1743 |
1496 __TEST_INVARIANT; |
1744 __TEST_INVARIANT; |
|
1745 if (aPos < 0 || aPos > DocumentLength()) |
|
1746 { |
|
1747 OstTrace0( TRACE_FATAL, CRICHTEXT_GETPARAGRAPHFORMATL, "ECharPosBeyondDocument" ); |
|
1748 } |
1497 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1749 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1498 |
1750 |
1499 if (!IndexPresent()) |
1751 if (!IndexPresent()) |
1500 CGlobalText::GetParagraphFormatL(aFormat, aPos); |
1752 CGlobalText::GetParagraphFormatL(aFormat, aPos); |
1501 else |
1753 else |
1553 // aFormat takes the values of all attributes, and the mask aMask indicates those values that change |
1809 // aFormat takes the values of all attributes, and the mask aMask indicates those values that change |
1554 // over the selected region, and are therefore *indeterminate*. |
1810 // over the selected region, and are therefore *indeterminate*. |
1555 // Application: seeding paragraph formatting dialogs. |
1811 // Application: seeding paragraph formatting dialogs. |
1556 // |
1812 // |
1557 __TEST_INVARIANT; |
1813 __TEST_INVARIANT; |
|
1814 if (aPos < 0 || aPos > DocumentLength()) |
|
1815 { |
|
1816 OstTrace0( TRACE_FATAL, CRICHTEXT_GETPARAFORMATL, "ECharPosBeyondDocument" ); |
|
1817 } |
1558 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1818 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
|
1819 if (aLength < 0) |
|
1820 { |
|
1821 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_GETPARAFORMATL, "EGetParaFormatNegativeLength" ); |
|
1822 } |
1559 __ASSERT_ALWAYS(aLength >= 0, Panic(EGetParaFormatNegativeLength)); |
1823 __ASSERT_ALWAYS(aLength >= 0, Panic(EGetParaFormatNegativeLength)); |
|
1824 if (aPos + aLength > DocumentLength()) |
|
1825 { |
|
1826 OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_GETPARAFORMATL, "ECharPosBeyondDocument" ); |
|
1827 } |
1560 __ASSERT_ALWAYS(aPos + aLength <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1828 __ASSERT_ALWAYS(aPos + aLength <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1561 |
1829 |
1562 if (IndexPresent()) |
1830 if (IndexPresent()) |
1563 iIndex->GetParaFormatL(aFormat, aVaries, aPos, aLength, aMode); |
1831 iIndex->GetParaFormatL(aFormat, aVaries, aPos, aLength, aMode); |
1564 else |
1832 else |
1601 |
1869 |
1602 void CRichText::GetExtendedCharFormat(TCharFormatX& aFormat, TCharFormatXMask& aVaries, TInt aPos, TInt aLength) const |
1870 void CRichText::GetExtendedCharFormat(TCharFormatX& aFormat, TCharFormatXMask& aVaries, TInt aPos, TInt aLength) const |
1603 { |
1871 { |
1604 __TEST_INVARIANT; |
1872 __TEST_INVARIANT; |
1605 int document_length = DocumentLength(); |
1873 int document_length = DocumentLength(); |
|
1874 if (aPos < 0 || aPos > document_length) |
|
1875 { |
|
1876 OstTrace0( TRACE_FATAL, CRICHTEXT_GETEXTENDEDCHARFORMAT, "ECharPosBeyondDocument" ); |
|
1877 } |
1606 __ASSERT_ALWAYS(aPos >= 0 && aPos <= document_length, Panic(ECharPosBeyondDocument)); |
1878 __ASSERT_ALWAYS(aPos >= 0 && aPos <= document_length, Panic(ECharPosBeyondDocument)); |
|
1879 if (aLength < 0) |
|
1880 { |
|
1881 OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_GETEXTENDEDCHARFORMAT, "EGetCharFormatNegativeLength" ); |
|
1882 } |
1607 __ASSERT_ALWAYS(aLength >= 0, Panic(EGetCharFormatNegativeLength)); |
1883 __ASSERT_ALWAYS(aLength >= 0, Panic(EGetCharFormatNegativeLength)); |
|
1884 if (aPos + aLength - 1 > document_length) |
|
1885 { |
|
1886 OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_GETEXTENDEDCHARFORMAT, "ECharPosBeyondDocument" ); |
|
1887 } |
1608 __ASSERT_ALWAYS(aPos + aLength - 1 <= document_length, Panic(ECharPosBeyondDocument)); |
1888 __ASSERT_ALWAYS(aPos + aLength - 1 <= document_length, Panic(ECharPosBeyondDocument)); |
1609 |
1889 |
1610 if (IndexPresent()) |
1890 if (IndexPresent()) |
1611 iIndex->GetCharFormat(aFormat, aVaries, aPos, aLength); |
1891 iIndex->GetCharFormat(aFormat, aVaries, aPos, aLength); |
1612 else |
1892 else |
1624 { |
1904 { |
1625 __ETEXT_WATCH(GET_SPECIFIC_CHARS); |
1905 __ETEXT_WATCH(GET_SPECIFIC_CHARS); |
1626 |
1906 |
1627 __TEST_INVARIANT; |
1907 __TEST_INVARIANT; |
1628 |
1908 |
|
1909 if (aPos < 0 || aPos > DocumentLength()) |
|
1910 { |
|
1911 OstTrace0( TRACE_FATAL, CRICHTEXT_GETSPECIFICCHARFORMATLEFTRIGHT, "ECharPosBeyondDocument" ); |
|
1912 } |
1629 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1913 __ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1630 |
1914 |
1631 if (IndexPresent()) |
1915 if (IndexPresent()) |
1632 { |
1916 { |
1633 TCharFormatX format; |
1917 TCharFormatX format; |
1781 consumed += viewLength; |
2065 consumed += viewLength; |
1782 } |
2066 } |
1783 |
2067 |
1784 if (IndexPresent()) |
2068 if (IndexPresent()) |
1785 { |
2069 { |
|
2070 if (!aSource.IndexPresent()) |
|
2071 { |
|
2072 OstTrace0( TRACE_DUMP, DUP1_CRICHTEXT_DOAPPENDTAKINGSOLEPICTUREOWNERSHIPL, "Invariant" ); |
|
2073 } |
1786 __ASSERT_DEBUG(aSource.IndexPresent(), User::Invariant()); // PrepareAppend should have sorted this |
2074 __ASSERT_DEBUG(aSource.IndexPresent(), User::Invariant()); // PrepareAppend should have sorted this |
1787 |
2075 |
1788 TGlobalLayerInfoAppend info(GlobalParaFormatLayer(), GlobalCharFormatLayer(), aSource.GlobalParaFormatLayer(), aSource.GlobalCharFormatLayer()); |
2076 TGlobalLayerInfoAppend info(GlobalParaFormatLayer(), GlobalCharFormatLayer(), aSource.GlobalParaFormatLayer(), aSource.GlobalCharFormatLayer()); |
1789 iIndex->AppendTakingSolePictureOwnershipL(aSource.iIndex, info); |
2077 iIndex->AppendTakingSolePictureOwnershipL(aSource.iIndex, info); |
1790 } |
2078 } |