author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 06 Jul 2010 16:23:19 +0300 | |
changeset 44 | 601ab138ba0b |
parent 37 | 6be019398652 |
child 49 | 4d76f1414957 |
permissions | -rw-r--r-- |
32 | 1 |
/* |
2 |
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include <e32std.h> |
|
20 |
#include <e32base.h> |
|
21 |
||
22 |
#include "TXTRICH.H" |
|
23 |
#include "TXTINDEX.H" |
|
24 |
#include "TXTSTD.H" |
|
25 |
#include "TXTRTPFL.H" |
|
26 |
#include "ParseLst.h" |
|
27 |
#include "TXTCLIPBOARD.H" |
|
28 |
||
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
29 |
#include "OstTraceDefinitions.h" |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
30 |
#ifdef OST_TRACE_COMPILER_IN_USE |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
31 |
#include "TXTRICHTraces.h" |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
32 |
#endif |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
33 |
|
32 | 34 |
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
35 |
#include "TXTETEXT_INTERNAL.H" |
|
36 |
#include "TXTRICH_INTERNAL.H" |
|
37 |
#endif |
|
38 |
||
39 |
EXPORT_C void CRichText::__DbgTestInvariant()const |
|
40 |
// Provides class invariants. Explanations below: |
|
41 |
// |
|
42 |
{ |
|
43 |
#ifdef _DEBUG |
|
44 |
// ASSERT: The global format layers are never null. |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
45 |
if (iGlobalParaFormatLayer == NULL) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
46 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
47 |
OstTrace0( TRACE_DUMP, CRICHTEXT_DBGTESTINVARIANT, "Invariant" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
48 |
} |
32 | 49 |
__ASSERT_DEBUG(iGlobalParaFormatLayer != NULL, User::Invariant()); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
50 |
if (iGlobalCharFormatLayer == NULL) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
51 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
52 |
OstTrace0( TRACE_DUMP, DUP1_CRICHTEXT_DBGTESTINVARIANT, "Invariant" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
53 |
} |
32 | 54 |
__ASSERT_DEBUG(iGlobalCharFormatLayer != NULL, User::Invariant()); |
55 |
if (IndexPresent()) |
|
56 |
{ |
|
57 |
// ASSERT: The sum of para lengths == the length as described by the document storage. |
|
58 |
TInt cumulativeParaLength = 0; |
|
59 |
TInt maxPara = iIndex->iParaIx->Count(); |
|
60 |
for (TInt offset = 0; offset < maxPara; offset++) |
|
61 |
{ |
|
62 |
TParaAttribsEntry entry = (*iIndex->iParaIx)[offset]; |
|
63 |
cumulativeParaLength += entry.iLength; |
|
64 |
} |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
65 |
if (cumulativeParaLength != (DocumentLength() + 1)) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
66 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
67 |
OstTrace0( TRACE_DUMP, DUP2_CRICHTEXT_DBGTESTINVARIANT, "Invariant" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
68 |
} |
32 | 69 |
__ASSERT_DEBUG(cumulativeParaLength == (DocumentLength() + 1), User::Invariant()); |
70 |
} |
|
71 |
// Change here for defect INC005336. |
|
72 |
// This defect is present when the assertion below fails. |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
73 |
if ((iParserData != NULL) && |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
74 |
(iParserData->HaveRange()) && |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
75 |
(iParserData->EndParse() > DocumentLength())) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
76 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
77 |
OstTrace0( TRACE_DUMP, DUP3_CRICHTEXT_DBGTESTINVARIANT, "Invariant" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
78 |
} |
32 | 79 |
__ASSERT_DEBUG( (iParserData == NULL) || \ |
80 |
(!iParserData->HaveRange()) || \ |
|
81 |
(iParserData->EndParse() <= DocumentLength()), User::Invariant()); |
|
82 |
#endif |
|
83 |
} |
|
84 |
||
85 |
EXPORT_C CRichText* CRichText::NewL(const CParaFormatLayer* aGlobalParaLayer,const CCharFormatLayer* aGlobalCharLayer, |
|
86 |
TDocumentStorage aStorage,TInt aDefaultTextGranularity,TParaType aParaType) |
|
87 |
/** Allocates and constructs an empty rich text object, with a global character |
|
88 |
and paragraph format layer. A single end-of-document delimiter is inserted. |
|
89 |
No style list is allocated. |
|
90 |
||
91 |
@param aGlobalParaLayer Pointer to the paragraph format layer referenced by |
|
92 |
the rich text object. Must not be NULL, or a panic occurs. |
|
93 |
@param aGlobalCharLayer Pointer to the character format layer referenced by |
|
94 |
the rich text object. Must not be NULL, or a panic occurs. |
|
95 |
@param aStorage The type of in-memory buffer to use. Defaults to ESegmentedStorage |
|
96 |
which should rarely need to be changed. |
|
97 |
@param aDefaultTextGranularity Specifies the granularity of the in-memory buffer. |
|
98 |
Default is EDefaultTextGranularity bytes (=256), and this should rarely need |
|
99 |
to be changed. |
|
100 |
@param aParaType This argument indicates whether you are using a single paragraph |
|
101 |
or multiple paragraphs, and thus affects the granularity of aggregate objects |
|
102 |
used internally for storing paragraph attributes. Default = EMultiPara. |
|
103 |
@return The rich text object. */ |
|
104 |
{ |
|
105 |
// Create new rich text containing just a single end-of-document character. |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
106 |
if (aGlobalParaLayer == NULL) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
107 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
108 |
OstTrace0( TRACE_FATAL, CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
109 |
} |
32 | 110 |
__ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
111 |
if (aGlobalCharLayer == NULL) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
112 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
113 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
114 |
} |
32 | 115 |
__ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle)); |
116 |
||
117 |
CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer); |
|
118 |
CleanupStack::PushL(self); |
|
119 |
self->ConstructL(aStorage, aDefaultTextGranularity, aParaType); |
|
120 |
CleanupStack::Pop(); |
|
121 |
return self; |
|
122 |
} |
|
123 |
||
124 |
||
125 |
// Create new rich text that supports Paragraph Styles, containing just a single end-of-document character. |
|
126 |
EXPORT_C CRichText* CRichText::NewL(const CParaFormatLayer* aGlobalParaLayer,const CCharFormatLayer* aGlobalCharLayer, |
|
127 |
const CStyleList& aStyleList, |
|
128 |
TDocumentStorage aStorage,TInt aDefaultTextGranularity,TParaType aParaType) |
|
129 |
/** Allocates and constructs an empty rich text object which supports styles. It |
|
130 |
is constructed with a global character and paragraph format layer and a style |
|
131 |
list. A single end-of-document delimiter is inserted. The rich text object |
|
132 |
takes ownership of the style list. |
|
133 |
||
134 |
Note: |
|
135 |
||
136 |
A rich text object not constructed with a style list may still use styles, |
|
137 |
by calling SetStyleListExternallyOwned() at any time after construction. In |
|
138 |
this case, the rich text object does not own the style list. |
|
139 |
||
140 |
@param aGlobalParaLayer Pointer to the paragraph format layer referenced by |
|
141 |
the rich text object. Must not be NULL, or a panic occurs. |
|
142 |
@param aGlobalCharLayer Pointer to the character format layer referenced by |
|
143 |
the rich text object. Must not be NULL, or a panic occurs. |
|
144 |
@param aStyleList Style list. Holds the set of paragraph styles which can be |
|
145 |
used in the rich text object. |
|
146 |
@param aStorage The type of in-memory buffer to use. Defaults to ESegmentedStorage |
|
147 |
which should rarely need to be changed. |
|
148 |
@param aDefaultTextGranularity Specifies the granularity of the in-memory buffer. |
|
149 |
Default is EDefaultTextGranularity bytes (=256), and this should rarely need |
|
150 |
to be changed. |
|
151 |
@param aParaType This argument indicates whether you are using a single paragraph |
|
152 |
or multiple paragraphs, and thus affects the granularity of aggregate objects |
|
153 |
used internally for storing paragraph attributes. Default = EMultiPara. |
|
154 |
@return The new rich text object. */ |
|
155 |
{ |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
156 |
if (aGlobalParaLayer == NULL) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
157 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
158 |
OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
159 |
} |
32 | 160 |
__ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
161 |
if (aGlobalCharLayer == NULL) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
162 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
163 |
OstTrace0( TRACE_FATAL, DUP3_CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
164 |
} |
32 | 165 |
__ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle)); |
166 |
||
167 |
CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer, CONST_CAST(CStyleList*, &aStyleList)); |
|
168 |
CleanupStack::PushL(self); |
|
169 |
self->ConstructL(aStorage, aDefaultTextGranularity, aParaType); |
|
170 |
CleanupStack::Pop(); |
|
171 |
return self; |
|
172 |
} |
|
173 |
||
174 |
||
175 |
// Restore into a new rich text object, using the specified global layers. |
|
176 |
EXPORT_C CRichText* CRichText::NewL(const CStreamStore& aStore,TStreamId aStreamId, |
|
177 |
const CParaFormatLayer* aGlobalParaLayer,const CCharFormatLayer* aGlobalCharLayer, |
|
178 |
MTextFieldFactory* aFieldFactory, |
|
179 |
TDocumentStorage aStorage) |
|
180 |
/** Allocates and constructs a rich text object with a field factory. Its text |
|
181 |
content is internalized from a stream store. |
|
182 |
||
183 |
Note: |
|
184 |
||
185 |
A rich text object not constructed with a field factory may still support |
|
186 |
the addition of fields, by calling SetFieldFactory(), defined in the base |
|
187 |
class CPlainText. |
|
188 |
||
189 |
@param aStore Stream store from which the object is restored. |
|
190 |
@param aStreamId ID of the stream store. |
|
191 |
@param aGlobalParaLayer Pointer to the paragraph format layer referenced by |
|
192 |
the rich text object. Must not be NULL, or a panic occurs. |
|
193 |
@param aGlobalCharLayer Pointer to the character format layer referenced by |
|
194 |
the rich text object. Must not be NULL, or a panic occurs. |
|
195 |
@param aFieldFactory Pointer to a field factory. A field factory must be provided |
|
196 |
if the text object supports fields. |
|
197 |
@param aStorage The type of in-memory buffer to use. Defaults to ESegmentedStorage |
|
198 |
which should rarely need to be changed. |
|
199 |
@return The new rich text object. */ |
|
200 |
{ |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
201 |
if (aGlobalParaLayer == NULL) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
202 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
203 |
OstTrace0( TRACE_FATAL, DUP4_CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
204 |
} |
32 | 205 |
__ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
206 |
if (aGlobalCharLayer == NULL) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
207 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
208 |
OstTrace0( TRACE_FATAL, DUP5_CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
209 |
} |
32 | 210 |
__ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle)); |
211 |
||
212 |
CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer); |
|
213 |
CleanupStack::PushL(self); |
|
214 |
self->ConstructL(aStore, aStreamId, NULL, NULL, aFieldFactory, aStorage); |
|
215 |
CleanupStack::Pop(); |
|
216 |
return self; |
|
217 |
} |
|
218 |
||
219 |
||
220 |
EXPORT_C CRichText* CRichText::NewL(const CStreamStore& aStore, TStreamId aStreamId, |
|
221 |
const CParaFormatLayer* aGlobalParaLayer, const CCharFormatLayer* aGlobalCharLayer, |
|
222 |
MPictureFactory* aPictureFactory, MRichTextStoreResolver* aStoreResolver, |
|
223 |
MTextFieldFactory* aFieldFactory, |
|
224 |
TDocumentStorage aStorage) |
|
225 |
/** Allocates and constructs a rich text object with a field factory and a picture |
|
226 |
factory. Its text content is internalized from a stream store. |
|
227 |
||
228 |
Note: |
|
229 |
||
230 |
A rich text object not constructed with a field factory may still support |
|
231 |
the addition of fields, by calling SetFieldFactory(), defined in the base |
|
232 |
class CPlainText. |
|
233 |
||
234 |
@param aStore Stream store from which the object is restored. |
|
235 |
@param aStreamId ID of the stream store. |
|
236 |
@param aGlobalParaLayer Pointer to the paragraph format layer referenced by |
|
237 |
the rich text object. Must not be NULL, or a panic occurs. |
|
238 |
@param aGlobalCharLayer Pointer to the character format layer referenced by |
|
239 |
the rich text object. Must not be NULL, or a panic occurs. |
|
240 |
@param aPictureFactory The picture factory. This is needed to load pictures |
|
241 |
into memory, (see PictureHandleL()). If a store resolver is specified (not |
|
242 |
NULL), then a factory must also be specified, or a panic occurs. |
|
243 |
@param aStoreResolver A store resolver. This determines which file store the |
|
244 |
picture is stored in. It is used to get from a reference to an embedded picture |
|
245 |
within a CRichText object to the actual picture itself. Picture loading is |
|
246 |
done by the picture factory. |
|
247 |
@param aFieldFactory Pointer to a field factory. A field factory must be provided |
|
248 |
if the text object supports fields. |
|
249 |
@param aStorage The type of in-memory buffer to use. Defaults to ESegmentedStorage |
|
250 |
which should rarely need to be changed. |
|
251 |
@return The new rich text object. */ |
|
252 |
{ |
|
253 |
// Restore a new rich text from the specified stream, that uses the specified global layers, and the |
|
254 |
// specified picture header factory and store, if this rich text supports pictures. |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
255 |
if (!aPictureFactory && aStoreResolver) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
256 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
257 |
OstTrace0( TRACE_FATAL, DUP6_CRICHTEXT_NEWL, "EInvalidPictureFactorySettings" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
258 |
} |
32 | 259 |
__ASSERT_ALWAYS(!(!aPictureFactory && aStoreResolver), Panic(EInvalidPictureFactorySettings)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
260 |
if (aGlobalParaLayer == NULL) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
261 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
262 |
OstTrace0( TRACE_FATAL, DUP7_CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
263 |
} |
32 | 264 |
__ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
265 |
if (aGlobalCharLayer == NULL) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
266 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
267 |
OstTrace0( TRACE_FATAL, DUP8_CRICHTEXT_NEWL, "ENullFormatLayerHandle" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
268 |
} |
32 | 269 |
__ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle)); |
270 |
||
271 |
CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer); |
|
272 |
CleanupStack::PushL(self); |
|
273 |
self->ConstructL(aStore, aStreamId, aPictureFactory, aStoreResolver, aFieldFactory, aStorage); |
|
274 |
CleanupStack::Pop(); |
|
275 |
return self; |
|
276 |
} |
|
277 |
||
278 |
||
279 |
EXPORT_C CRichText::CRichText(const CParaFormatLayer* aGlobalParaLayer, const CCharFormatLayer* aGlobalCharLayer, |
|
280 |
CStyleList* aStyleList): |
|
281 |
CGlobalText(aGlobalParaLayer, aGlobalCharLayer), |
|
282 |
iStyleList(aStyleList) |
|
283 |
{ |
|
284 |
} |
|
285 |
||
286 |
||
287 |
EXPORT_C void CRichText::ConstructL(TDocumentStorage aStorage, TInt aDefaultTextGranularity, TParaType aParaType) |
|
288 |
// Initialises and updates the index following the CPlainText::ConstructL |
|
289 |
// insertion of the end-of-document character. |
|
290 |
// |
|
291 |
{ |
|
292 |
CPlainText::ConstructL(aStorage, aDefaultTextGranularity); |
|
293 |
SetParaTypeIsSingle(aParaType == ESinglePara); |
|
294 |
iParserData = new(ELeave) CParserData(DocumentLength()); |
|
295 |
TInt a; |
|
296 |
TInt b; |
|
297 |
ParseText(a, b, ETrue); |
|
298 |
||
299 |
__TEST_INVARIANT; |
|
300 |
} |
|
301 |
||
302 |
||
303 |
EXPORT_C void CRichText::ConstructL(const CStreamStore& aStore,TStreamId aStreamId, |
|
304 |
MPictureFactory* aPictureFactory, MRichTextStoreResolver* aStoreResolver, |
|
305 |
MTextFieldFactory* aFieldFactory, |
|
306 |
TDocumentStorage aStorage) |
|
307 |
// Initialises and updates the index following the CPlainText::ConstructL |
|
308 |
// insertion of the end-of-document character. |
|
309 |
// Sets the picture header factory if provided. |
|
310 |
// |
|
311 |
{ |
|
312 |
CPlainText::ConstructL(aStore, aStreamId, aFieldFactory, aStorage); |
|
313 |
SetPictureFactory(aPictureFactory, aStoreResolver); |
|
314 |
if (iParserData == NULL) |
|
315 |
iParserData = new(ELeave) CParserData(DocumentLength()); |
|
316 |
TInt a; |
|
317 |
TInt b; |
|
318 |
ParseText(a, b, ETrue); |
|
319 |
||
320 |
__TEST_INVARIANT; |
|
321 |
} |
|
322 |
||
323 |
||
324 |
EXPORT_C CRichText::~CRichText() |
|
325 |
/** The destructor frees all resources owned by the rich text object, prior to |
|
326 |
its destruction. */ |
|
327 |
{ |
|
328 |
// We cannot call DestroyParserSystem() here because it applies to all instances in the thread |
|
329 |
delete iParserData; |
|
330 |
KillStyleList(); |
|
331 |
KillIndex(); |
|
332 |
} |
|
333 |
||
334 |
||
335 |
void CRichText::KillStyleList() |
|
336 |
// Free up the style table |
|
337 |
// |
|
338 |
{ |
|
339 |
if (StyleListPresent() && !StyleListExternallyOwned()) |
|
340 |
{ |
|
341 |
delete iStyleList.AsPtr(); |
|
342 |
iStyleList = NULL; |
|
343 |
} |
|
344 |
} |
|
345 |
||
346 |
||
347 |
void CRichText::KillIndex() |
|
348 |
// Delete the rich text index if it's resident in memory. |
|
349 |
// |
|
350 |
{ |
|
351 |
if (IndexPresent()) |
|
352 |
delete iIndex.AsPtr(); |
|
353 |
iIndex=NULL; |
|
354 |
} |
|
355 |
||
356 |
||
357 |
TBool CRichText::CreateEmptyMarkupComponentL() |
|
358 |
// If necessary, creates an empty markup component. |
|
359 |
// Returns ETrue if the markup component was created as a result of this function, |
|
360 |
// otherwise returns EFalse. |
|
361 |
// |
|
362 |
{ |
|
363 |
if (IndexPresent()) |
|
364 |
return EFalse; |
|
365 |
TInt paraGran = (ParaTypeIsSingle()) ? KSingleParaGranularity : KMultiParaGranularity; |
|
366 |
TInt phrGran = (ParaTypeIsSingle()) ? KSmallPhraseGranularity : KLargePhraseGranularity; |
|
367 |
iIndex = CRichTextIndex::NewL(iGlobalParaFormatLayer, iGlobalCharFormatLayer, *this,paraGran,phrGran); |
|
368 |
return ETrue; |
|
369 |
} |
|
370 |
||
371 |
||
372 |
void CRichText::CreateAndGenerateMarkupComponentL() |
|
373 |
// Checks if the rich text index needs to be created and does so if necessary. |
|
374 |
// Called by all public rich text functions that manipulate specific formatting. |
|
375 |
// |
|
376 |
{ |
|
377 |
if (CreateEmptyMarkupComponentL()) |
|
378 |
{ |
|
379 |
TRAPD(ret, GenerateMarkupL()); |
|
380 |
if (ret != KErrNone) |
|
381 |
{// destroy this partially set markup component |
|
382 |
delete iIndex.AsPtr(); |
|
383 |
iIndex = NULL; |
|
384 |
User::Leave(ret); |
|
385 |
} |
|
386 |
} |
|
387 |
} |
|
388 |
||
389 |
||
390 |
void CRichText::GenerateMarkupL() |
|
391 |
// Generate markup data corresponding to the current text content. |
|
392 |
// |
|
393 |
{ |
|
394 |
TInt remainingLength = DocumentLength(); |
|
395 |
TInt startPos = 0; |
|
396 |
while (remainingLength) |
|
397 |
{ |
|
398 |
TPtrC buf = Read(startPos); |
|
399 |
TInt consumed = buf.Length(); |
|
400 |
if (consumed > remainingLength) |
|
401 |
{ |
|
402 |
consumed = remainingLength; |
|
403 |
buf.Set(buf.Ptr(), consumed); |
|
404 |
} |
|
405 |
iIndex->InsertL(startPos, buf, *iGlobalParaFormatLayer); |
|
406 |
remainingLength -= consumed; |
|
407 |
startPos += consumed; |
|
408 |
} |
|
409 |
} |
|
410 |
||
411 |
EXPORT_C void CRichText::CopyToStoreL(CStreamStore& aStore,CStreamDictionary& aDictionary,TInt aPos,TInt aLength) const |
|
412 |
/** Copies a portion of the rich text object, with components to the clipboard. |
|
413 |
||
414 |
A panic occurs in the following circumstances: |
|
415 |
||
416 |
aPos is an invalid document position |
|
417 |
||
418 |
aLength is invalid (zero or less) |
|
419 |
||
420 |
the sum of aPos and aLength is greater than or equal to the number of characters |
|
421 |
in the document |
|
422 |
||
423 |
@param aStore Stream store to which the rich text is written. |
|
424 |
@param aDictionary The stream dictionary. |
|
425 |
@param aPos The document position from which to begin copying. |
|
426 |
@param aLength The number of characters to copy. */ |
|
427 |
{ |
|
428 |
if (aLength > 0) |
|
429 |
{ |
|
430 |
TStreamId plainTextId = CPlainText::DoCopyToStoreL(aStore,aDictionary,aPos,aLength); |
|
431 |
TStreamId id = DoCopyToStoreL(aStore,aPos,aLength,plainTextId,FALSE); |
|
432 |
aDictionary.AssignL(KClipboardUidTypeRichText,id); |
|
433 |
TStreamId idStyles = DoCopyToStoreL(aStore,aPos,aLength,plainTextId,TRUE); |
|
434 |
aDictionary.AssignL(KClipboardUidTypeRichTextWithStyles,idStyles); |
|
435 |
} |
|
436 |
} |
|
437 |
||
438 |
||
439 |
// Copy the selected region of rich text, with components, to the specified store. |
|
440 |
TStreamId CRichText::DoCopyToStoreL(CStreamStore& aStore,TInt aPos,TInt aLength,TStreamId aPlainTextId,TBool aCopyStyles) const |
|
441 |
{ |
|
442 |
__TEST_INVARIANT; |
|
443 |
||
444 |
TInt documentLength = DocumentLength(); |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
445 |
if (aPos < 0 || aPos > documentLength) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
446 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
447 |
OstTrace0( TRACE_FATAL, CRICHTEXT_DOCOPYTOSTOREL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
448 |
} |
32 | 449 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= documentLength,Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
450 |
if (aLength < 0) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
451 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
452 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DOCOPYTOSTOREL, "ECopyToClipboardNegativeLength" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
453 |
} |
32 | 454 |
__ASSERT_ALWAYS(aLength >= 0,Panic(ECopyToClipboardNegativeLength)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
455 |
if (aPos + aLength > documentLength) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
456 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
457 |
OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_DOCOPYTOSTOREL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
458 |
} |
32 | 459 |
__ASSERT_ALWAYS(aPos + aLength <= documentLength,Panic(ECharPosBeyondDocument)); |
460 |
||
461 |
if (aLength == 0) |
|
462 |
return KNullStreamId; |
|
463 |
||
464 |
CStoreMap* map = CStoreMap::NewLC(aStore); |
|
465 |
CopyComponentsL(aStore,*map,aPos,aLength,aPlainTextId); |
|
466 |
RStoreWriteStream stream(*map); |
|
467 |
TStreamId id = stream.CreateLC(aStore); |
|
468 |
CopyToStreamL(stream,aPos,aLength,aPlainTextId,aCopyStyles); |
|
469 |
stream.CommitL(); |
|
470 |
map->Reset(); |
|
471 |
CleanupStack::PopAndDestroy(2); |
|
472 |
||
473 |
__TEST_INVARIANT; |
|
474 |
return id; |
|
475 |
} |
|
476 |
||
477 |
||
478 |
EXPORT_C void CRichText::CopyComponentsL(CStreamStore& aStore,CStoreMap& aMap,TInt aPos,TInt aLength,TStreamId aPlainTextId) const |
|
479 |
{ |
|
480 |
if (aPlainTextId == KNullStreamId) |
|
481 |
CPlainText::CopyComponentsL(aStore,aMap,aPos,aLength); |
|
482 |
if (IndexPresent()) |
|
483 |
iIndex->StorePicturesL(aStore,aMap,aPos,aLength); |
|
484 |
} |
|
485 |
||
486 |
||
487 |
// Copy the selected region of rich text and components to the specified stream. |
|
488 |
EXPORT_C void CRichText::CopyToStreamL(RWriteStream& aStream,TInt aPos,TInt aLength) const |
|
489 |
{ |
|
490 |
__TEST_INVARIANT; |
|
491 |
CopyToStreamL(aStream, aPos, aLength, KNullStreamId); |
|
492 |
} |
|
493 |
||
494 |
||
495 |
/* |
|
496 |
Copy the selected region of rich text and components to the specified stream. |
|
497 |
If aPlainTextId is NULL the plain text component is stored in-line, |
|
498 |
otherwise the reference to the plain text stream component is stored. |
|
499 |
*/ |
|
500 |
EXPORT_C void CRichText::CopyToStreamL(RWriteStream& aStream,TInt aPos,TInt aLength,TStreamId aPlainTextId) const |
|
501 |
{ |
|
502 |
CopyToStreamL(aStream,aPos,aLength,aPlainTextId,TRUE); |
|
503 |
} |
|
504 |
||
505 |
||
506 |
void CRichText::CopyToStreamL(RWriteStream& aStream,TInt aPos,TInt aLength,TStreamId aPlainTextId,TBool aCopyStyles) const |
|
507 |
{ |
|
508 |
if (aPlainTextId == KNullStreamId) |
|
509 |
{ |
|
510 |
aStream.WriteUint8L(TRUE); |
|
511 |
CPlainText::CopyToStreamL(aStream,aPos,aLength); |
|
512 |
} |
|
513 |
else |
|
514 |
{ |
|
515 |
aStream.WriteUint8L(FALSE); |
|
516 |
aStream << aPlainTextId; |
|
517 |
} |
|
518 |
||
519 |
if (!IndexPresent()) |
|
520 |
CONST_CAST(CRichText*,this)->CreateAndGenerateMarkupComponentL(); |
|
521 |
aStream.WriteUint8L(TRUE); |
|
522 |
iIndex->CopyToStreamL(aStream,aPos,aLength,aCopyStyles); |
|
523 |
} |
|
524 |
||
525 |
EXPORT_C TInt CRichText::PasteFromStoreL(const CStreamStore& aStore, const CStreamDictionary& aDictionary, TInt aPos, CParagraphStyle::TStylePasteMode aStylePasteMode) |
|
526 |
/** Pastes the contents of the clipboard into the rich text object at the |
|
527 |
specified document position. Returns the number of characters pasted. |
|
528 |
||
529 |
If the text in the clipboard has been formatted using styles, the |
|
530 |
aStylePasteMode argument indicates whether the styles should be preserved |
|
531 |
or discarded. If the argument is not specified, the pasted rich text |
|
532 |
retains all formatting specified in the styles, and any new style |
|
533 |
definitions are added to the style list of the rich text object into which |
|
534 |
it is pasted. |
|
535 |
||
536 |
@param aStore The stream store from which to paste the rich text. |
|
537 |
@param aDictionary The stream dictionary. |
|
538 |
@param aPos The document position at which to paste the rich text. Must be |
|
539 |
valid, or a panic occurs. |
|
540 |
@param aStylePasteMode Indicates whether styles in the pasted text should be |
|
541 |
preserved or discarded. |
|
542 |
@return The number of characters pasted. */ |
|
543 |
{ |
|
544 |
return DoPasteRtFromStoreL(aStore, aDictionary, aPos, aStylePasteMode); |
|
545 |
} |
|
546 |
||
547 |
||
548 |
EXPORT_C TInt CRichText::PasteFromStoreL(const CStreamStore& aStore, const CStreamDictionary& aDictionary, TInt aPos) |
|
549 |
// Paste the lesser of i) aMaxPasteLength ii) the entire clipboard contents. |
|
550 |
// Return a count of the number of characters pasted. |
|
551 |
// |
|
552 |
{ |
|
553 |
return DoPasteRtFromStoreL(aStore, aDictionary, aPos, CParagraphStyle::EAddNewStyles); |
|
554 |
} |
|
555 |
||
556 |
||
557 |
TInt CRichText::DoPasteRtFromStoreL(const CStreamStore& aStore, const CStreamDictionary& aDictionary, TInt aPos, CParagraphStyle::TStylePasteMode aStylePasteMode) |
|
558 |
// Paste the rich text data from the specified clipboard, inserting it into this |
|
559 |
// instance at character position aPos. Returns the number of characters pasted. |
|
560 |
// May be 0. |
|
561 |
// |
|
562 |
{ |
|
563 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
564 |
if (aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
565 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
566 |
OstTrace0( TRACE_FATAL, CRICHTEXT_DOPASTERTFROMSTOREL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
567 |
} |
32 | 568 |
__ASSERT_ALWAYS(aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
569 |
||
570 |
TUid type = KClipboardUidTypeRichTextWithStyles; |
|
571 |
TStreamId id = aDictionary.At(type); |
|
572 |
if (id == KNullStreamId) |
|
573 |
{ |
|
574 |
type = KClipboardUidTypeRichText; |
|
575 |
id = aDictionary.At(type); |
|
576 |
} |
|
577 |
if (id == KNullStreamId) |
|
578 |
{ |
|
579 |
type = KClipboardUidTypePlainText; |
|
580 |
id = aDictionary.At(type); |
|
581 |
} |
|
582 |
TInt consumed = 0; |
|
583 |
if (id == KNullStreamId) |
|
584 |
return consumed; |
|
585 |
if (type == KClipboardUidTypeRichText || type == KClipboardUidTypeRichTextWithStyles) |
|
586 |
consumed = PasteRichTextFromStoreL(aStore, aDictionary, id, aPos, aStylePasteMode); |
|
587 |
else if (type == KClipboardUidTypePlainText) |
|
588 |
consumed = PastePlainTextFromStoreL(aStore, id, aPos); |
|
589 |
||
590 |
if (consumed) |
|
591 |
{ |
|
592 |
iParserData->MergeRange(aPos,0,consumed); |
|
593 |
CallEditObserver(aPos, consumed); |
|
594 |
} |
|
595 |
||
596 |
SetHasChanged(ETrue); |
|
597 |
__TEST_INVARIANT; |
|
598 |
return consumed; |
|
599 |
} |
|
600 |
||
601 |
||
602 |
TInt CRichText::PasteRichTextFromStoreL(const CStreamStore& aStore, const CStreamDictionary& aDictionary, TStreamId& aRichTextStreamId, TInt aPos,CParagraphStyle::TStylePasteMode aStylePasteMode) |
|
603 |
// Paste the plain text stream, then open and paste the rich text markup from the specified stream. |
|
604 |
// |
|
605 |
{ |
|
606 |
if (!IndexPresent()) |
|
607 |
CreateAndGenerateMarkupComponentL(); // create the index if it does not already exist |
|
608 |
TStreamId id = aDictionary.At(KClipboardUidTypePlainText); |
|
609 |
// ASSERT: We have rich text, so the plain text stream must exist. |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
610 |
if (id == KNullStreamId) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
611 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
612 |
OstTrace0( TRACE_FATAL, CRICHTEXT_PASTERICHTEXTFROMSTOREL, "EClipboardIntegrity" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
613 |
} |
32 | 614 |
__ASSERT_ALWAYS(id != KNullStreamId,Panic(EClipboardIntegrity)); |
615 |
TInt consumed = CPlainText::DoPasteFromStoreL(aStore, id, aPos); |
|
616 |
TRAPD(ret, CompletePasteRichTextFromStoreL(aStore, aRichTextStreamId, aPos, aStylePasteMode)); |
|
617 |
if (ret != KErrNone) |
|
618 |
{ |
|
619 |
CPlainText::Delete(aPos,consumed); |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
620 |
OstTrace1( TRACE_FATAL, DUP1_CRICHTEXT_PASTERICHTEXTFROMSTOREL, "Leave code=%d", ret ); |
32 | 621 |
User::Leave(ret); |
622 |
} |
|
623 |
return consumed; |
|
624 |
} |
|
625 |
||
626 |
||
627 |
void CRichText::CompletePasteRichTextFromStoreL(const CStreamStore& aStore, TStreamId& aRichTextStreamId, TInt aPos, CParagraphStyle::TStylePasteMode aStylePasteMode) |
|
628 |
// |
|
629 |
{ |
|
630 |
RStoreReadStream stream; |
|
631 |
stream.OpenLC(aStore, aRichTextStreamId); |
|
632 |
TBool plainTextInline = (TBool)stream.ReadUint8L(); |
|
633 |
if (!plainTextInline) |
|
634 |
{ |
|
635 |
TStreamId dummy; |
|
636 |
stream >> dummy; |
|
637 |
} |
|
638 |
TBool markupPresentInClipboard = (TBool)stream.ReadUint8L(); |
|
639 |
if (markupPresentInClipboard) |
|
640 |
iIndex->PasteFromStreamL(aStore, stream, aPos,aStylePasteMode, iGlobalParaFormatLayer, iGlobalCharFormatLayer); |
|
641 |
CleanupStack::PopAndDestroy(); // stream |
|
642 |
} |
|
643 |
||
644 |
||
645 |
TInt CRichText::PastePlainTextFromStoreL(const CStreamStore& aStore, TStreamId& anId, TInt aPos) |
|
646 |
// Paste the plain text stream, then update the rich text index to show any paragraph delimiters pasted. |
|
647 |
// |
|
648 |
{ |
|
649 |
TInt consumed = CPlainText::DoPasteFromStoreL(aStore, anId, aPos); |
|
650 |
// |
|
651 |
if (IndexPresent()) |
|
652 |
{ |
|
653 |
TRAPD(ret, CompletePastePlainTextL(aPos, consumed)); |
|
654 |
if (ret != KErrNone) |
|
655 |
{ |
|
656 |
CPlainText::Delete(aPos,consumed); |
|
657 |
User::Leave(ret); |
|
658 |
} |
|
659 |
} |
|
660 |
return consumed; |
|
661 |
} |
|
662 |
||
663 |
void CRichText::CompletePastePlainTextL(TInt aPos, TInt aCharacterCount) |
|
664 |
// Updates the rich text index following the pasting of global text. |
|
665 |
// |
|
666 |
{ |
|
667 |
HBufC* buf = HBufC::NewLC(aCharacterCount); |
|
668 |
TPtr bf = buf->Des(); |
|
669 |
Extract(bf, aPos, aCharacterCount); |
|
670 |
iIndex->InsertL(aPos, bf, *iGlobalParaFormatLayer); |
|
671 |
CleanupStack::PopAndDestroy(); // buf |
|
672 |
} |
|
673 |
||
674 |
EXPORT_C void CRichText::Reset() |
|
675 |
/** Resets the document's contents to a single end-of-document delimiter. Also |
|
676 |
deletes the style list if owned by the object. */ |
|
677 |
{ |
|
678 |
// Resets document contents to single end-of-document charcter, |
|
679 |
// and resets the index to match document content. |
|
680 |
TInt length = DocumentLength(); |
|
681 |
CPlainText::Reset(); // remove all content bar eod character |
|
682 |
KillStyleList(); // does not get destroyed if externally owned |
|
683 |
KillIndex(); |
|
684 |
SetHasChanged(ETrue); |
|
685 |
iParserData->KillRange(); |
|
686 |
iParserData->iLastKnownCursor = -1; |
|
687 |
CallEditObserver(0, -length); |
|
688 |
||
689 |
__TEST_INVARIANT; |
|
690 |
} |
|
691 |
||
692 |
EXPORT_C void CRichText::InsertL(TInt aPos, const TChar& aChar) |
|
693 |
/** Inserts either a single character or a descriptor into the text object |
|
694 |
at a specified document position. |
|
695 |
||
696 |
The insertion position must be valid or a panic occurs.Note:A panic |
|
697 |
occurs if the text object is in an "insert pending" state (i.e. |
|
698 |
SetInsertCharFormatL() has been called and has not been |
|
699 |
cancelled using CancelInsertCharFormat()) and aPos is not |
|
700 |
the same as the insertion point. |
|
701 |
||
702 |
@param aPos The document position at which to insert the character/descriptor. |
|
703 |
@param aChar The character to insert. Must not be a picture character or a |
|
704 |
panic occurs. |
|
705 |
@param aBuf The descriptor to insert. */ |
|
706 |
{ |
|
707 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
708 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
709 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
710 |
OstTrace0( TRACE_FATAL, CRICHTEXT_INSERTL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
711 |
} |
32 | 712 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
713 |
if (aChar == EPictureCharacter) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
714 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
715 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_INSERTL, "ENonOverloadedInsertCalledWithPictureCharacter" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
716 |
} |
32 | 717 |
__ASSERT_ALWAYS(aChar!= EPictureCharacter, Panic(ENonOverloadedInsertCalledWithPictureCharacter)); |
718 |
||
719 |
if (aChar < 0x10000) |
|
720 |
{ |
|
721 |
TBuf<1> content; |
|
722 |
content.Append(aChar); |
|
723 |
RtInsertL(aPos, content); |
|
724 |
} |
|
725 |
else |
|
726 |
{ |
|
727 |
TText16 high = TChar::GetHighSurrogate(aChar); |
|
728 |
TText16 low = TChar::GetLowSurrogate(aChar); |
|
37
6be019398652
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
729 |
RDebug::Print(_L("CRichText::InsertL(), %X expand to %X %X."), TUint(aChar), high, low); |
32 | 730 |
|
731 |
TBuf<2> content; |
|
732 |
content.Append(high); |
|
733 |
content.Append(low); |
|
734 |
RtInsertL(aPos, content); |
|
735 |
} |
|
736 |
||
737 |
__TEST_INVARIANT; |
|
738 |
} |
|
739 |
||
740 |
||
741 |
EXPORT_C void CRichText::InsertL(TInt aPos, const TDesC& aBuf) |
|
742 |
// Inserts the contents of aBuf into the text component at character position aPos. |
|
743 |
// |
|
744 |
{ |
|
745 |
__ETEXT_WATCH(INSERT_DESC); |
|
746 |
||
747 |
RtInsertL(aPos, aBuf); |
|
748 |
||
749 |
__ETEXT_WATCH_END(INSERT_DESC); |
|
750 |
} |
|
751 |
||
752 |
||
753 |
EXPORT_C void CRichText::RtInsertL(TInt aPos, const TDesC& aBuf) |
|
754 |
// Inserts the contents a aBuf into the text component at position aPos. |
|
755 |
// Updates the index accordingly, and accounts for all embedded paragraph delimiters |
|
756 |
// in the passed buffer aBuf. |
|
757 |
// |
|
758 |
{ |
|
759 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
760 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
761 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
762 |
OstTrace0( TRACE_FATAL, CRICHTEXT_RTINSERTL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
763 |
} |
32 | 764 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
765 |
||
766 |
int length = aBuf.Length(); |
|
767 |
CPlainText::InsertL(aPos, aBuf); |
|
768 |
if (IndexPresent()) |
|
769 |
{ |
|
770 |
TRAPD(ret, iIndex->InsertL(aPos, aBuf, *iGlobalParaFormatLayer)); |
|
771 |
if (ret != KErrNone) |
|
772 |
{ |
|
773 |
CPlainText::Delete(aPos,length); |
|
774 |
User::Leave(ret); |
|
775 |
} |
|
776 |
SetHasChanged(ETrue); |
|
777 |
} |
|
778 |
||
779 |
iParserData->MergeRange(aPos,0,length); |
|
780 |
CallEditObserver(aPos,length); |
|
781 |
||
782 |
__TEST_INVARIANT; |
|
783 |
} |
|
784 |
||
785 |
||
786 |
EXPORT_C void CRichText::InsertL(TInt aPos,const TPictureHeader& aHeader) |
|
787 |
/**Inserts a picture header into the text object at a specified document |
|
788 |
position. The picture header specified must reference a valid picture, or |
|
789 |
a panic occurs. |
|
790 |
||
791 |
A panic also occurs if the text object is in an "insert pending" state |
|
792 |
(SetInsertCharFormatL() has been called and has not been cancelled using |
|
793 |
CancelInsertCharFormat()) and aPos is not the same as the insertion point. |
|
794 |
||
795 |
This method takes ownership of a picture referenced in aHeader. |
|
796 |
||
797 |
@param aPos The document position at which to insert the picture header. Must |
|
798 |
be valid, or a panic occurs. |
|
799 |
@param aHeader A picture header. This holds a pointer to the picture to insert, |
|
800 |
and information about the picture. */ |
|
801 |
{ |
|
802 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
803 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
804 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
805 |
OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_INSERTL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
806 |
} |
32 | 807 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
808 |
||
809 |
CleanupStack::PushL(aHeader.iPicture); |
|
810 |
||
811 |
if (!IndexPresent()) |
|
812 |
CreateAndGenerateMarkupComponentL(); |
|
813 |
TBuf<1> picture; |
|
814 |
picture.Append(EPictureCharacter); |
|
815 |
CPlainText::InsertL(aPos, picture); |
|
816 |
||
817 |
CleanupStack::Pop(aHeader.iPicture); |
|
818 |
||
819 |
TBool pictureOwnershipTaken(EFalse); |
|
820 |
TRAPD(ret, iIndex->InsertL(aPos, aHeader,pictureOwnershipTaken)); |
|
821 |
if (ret != KErrNone) |
|
822 |
{ |
|
823 |
if(!pictureOwnershipTaken) |
|
824 |
{ |
|
825 |
const_cast <TPictureHeader&> (aHeader).DeletePicture(); |
|
826 |
} |
|
827 |
CPlainText::Delete(aPos,picture.Length()); // remove the picture place-holder |
|
828 |
User::Leave(ret); |
|
829 |
} |
|
830 |
||
831 |
SetHasChanged(ETrue); |
|
832 |
iParserData->MergeRange(aPos,0,1); |
|
833 |
CallEditObserver(aPos,1); |
|
834 |
__TEST_INVARIANT; |
|
835 |
} |
|
836 |
||
837 |
||
838 |
EXPORT_C TBool CRichText::DeleteL(TInt aPos, TInt aLength) |
|
839 |
/** Deletes one or more characters beginning at, and including, the character at |
|
840 |
a specified document position. Can leave because paragraphs may be merged |
|
841 |
and reformatted by the function. |
|
842 |
||
843 |
@param aPos The start of the range of characters to delete. Must be valid |
|
844 |
or a panic occurs. |
|
845 |
@param aLength The number of characters to delete. Must be positive or a panic |
|
846 |
occurs. The sum of aPos and aLength must be less than the document length, |
|
847 |
or a panic occurs. |
|
848 |
@return Indicates whether two paragraphs have been merged as a result of the |
|
849 |
delete, indicating that the formatting of part of the resulting paragraph |
|
850 |
may have changed. */ |
|
851 |
{ |
|
852 |
// Deletes aRange number of characters from the text component |
|
853 |
// and the corresponding index data. |
|
854 |
// Delete commences at, and includes, character position aPos. |
|
855 |
__TEST_INVARIANT; |
|
856 |
||
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
857 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
858 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
859 |
OstTrace0( TRACE_FATAL, CRICHTEXT_DELETEL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
860 |
} |
32 | 861 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
862 |
if (aLength < 0) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
863 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
864 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DELETEL, "EDebugDeleteZeroLength" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
865 |
} |
32 | 866 |
__ASSERT_ALWAYS(aLength >= 0, Panic(EDebugDeleteZeroLength)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
867 |
if (aPos + (aLength - 1) > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
868 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
869 |
OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_DELETEL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
870 |
} |
32 | 871 |
__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
872 |
||
873 |
TBool requireMerge = EFalse; |
|
874 |
if (!IndexPresent()) |
|
875 |
CPlainText::Delete(aPos,aLength); |
|
876 |
else |
|
877 |
{ |
|
878 |
iIndex->CancelInsertCharFormat(); |
|
879 |
TIndexDeleteInfo info; |
|
880 |
iIndex->SetForDeleteL(info, aPos, aLength); |
|
881 |
CPlainText::Delete(aPos,aLength); |
|
882 |
requireMerge = iIndex->DeleteNow(info); |
|
883 |
} |
|
884 |
iParserData->MergeRange(aPos,aLength,0); |
|
885 |
CallEditObserver(aPos,-aLength); |
|
886 |
||
887 |
__TEST_INVARIANT; |
|
888 |
return requireMerge; |
|
889 |
} |
|
890 |
||
891 |
EXPORT_C void CRichText::DeleteParagraph(TInt aPos, TInt aLength) |
|
892 |
/** Deletes one or more whole paragraphs of text. No paragraphs can be merged together |
|
893 |
by this function, so it cannot leave it must only be used to delete entire |
|
894 |
paragraphs. |
|
895 |
||
896 |
@param aPos The document position of the start of the first paragraph to delete. |
|
897 |
Must be a valid position or a panic occurs. |
|
898 |
@param aLength The number of characters to delete. */ |
|
899 |
{ |
|
900 |
// Use to remove entire paragraphs of text. |
|
901 |
// Leave-safe if called in this context. |
|
902 |
// MUST NOT CALL if not in this context. |
|
903 |
__TEST_INVARIANT; |
|
904 |
||
905 |
// Store the length of the text before we commence with deletions. |
|
906 |
TInt initialDocLen=DocumentLength(); |
|
907 |
||
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
908 |
if (aPos < 0 || aPos > initialDocLen) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
909 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
910 |
OstTrace0( TRACE_FATAL, CRICHTEXT_DELETEPARAGRAPH, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
911 |
} |
32 | 912 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= initialDocLen, Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
913 |
if (aPos + aLength > initialDocLen + 1) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
914 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
915 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DELETEPARAGRAPH, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
916 |
} |
32 | 917 |
__ASSERT_ALWAYS(aPos + aLength <= initialDocLen + 1, Panic(ECharPosBeyondDocument)); |
918 |
||
919 |
if (aLength <= 0) |
|
920 |
return; |
|
921 |
||
922 |
if (IndexPresent()) |
|
923 |
iIndex->DeleteParagraph(aPos, aLength); |
|
924 |
CPlainText::Delete(aPos,aLength); |
|
925 |
||
926 |
// Change here for defect INC005336. |
|
927 |
// Previously the MergeRange call (see else line) was incorrectly handling |
|
928 |
// the scenario where all but the first paragraph was deleted e.g. pasting |
|
929 |
// multi line buffer into a single line text control in a new email on Techview |
|
930 |
// emulator. |
|
931 |
// This was because the deletion in the two lines above would delete the |
|
932 |
// 'end-of-text' maker causing the iEndParse member of CParserData to |
|
933 |
// index the char right after the end of test marker. This would panic |
|
934 |
// plugin parsers thatsubsquently executed. |
|
935 |
||
936 |
if (aPos+aLength > initialDocLen) |
|
937 |
// When deletion includes the end-of-text marker, adjust start |
|
938 |
// supplied so that it appears to MergeRange that we are |
|
939 |
// deleting the paragraph and CR just before it which belongs |
|
940 |
// to the previous paragraph and not the end-of-text marker. |
|
941 |
// This is actually the end result of the deletion anyway! |
|
942 |
iParserData->MergeRange(initialDocLen-aLength,aLength,0); |
|
943 |
else |
|
944 |
// All other deletions which don't. |
|
945 |
iParserData->MergeRange(aPos,aLength,0); |
|
946 |
||
947 |
CallEditObserver(aPos,-aLength); |
|
948 |
||
949 |
__TEST_INVARIANT; |
|
950 |
} |
|
951 |
||
952 |
EXPORT_C void CRichText::DeleteFromParagraph(TInt aPos, TInt aLength) |
|
953 |
/** Removes a range of characters from within a single paragraph only. Should not |
|
954 |
be used for deleting an entire paragraph or paragraphs because this may cause |
|
955 |
it to leave. Otherwise, it is guaranteed not to leave. |
|
956 |
||
957 |
@param aPos The document position of the start of the range of characters |
|
958 |
to delete. Must be a valid document position, or a panic occurs. |
|
959 |
@param aLength The number of characters to delete. The sum of aPos and aLength |
|
960 |
must be less than the document length, or a panic occurs. */ |
|
961 |
{ |
|
962 |
// Removes aLength characters from *within* a single paragraph only. |
|
963 |
// Guaranteed not to leave if this pre-condition holds true. |
|
964 |
__TEST_INVARIANT; |
|
965 |
||
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
966 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
967 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
968 |
OstTrace0( TRACE_FATAL, CRICHTEXT_DELETEFROMPARAGRAPH, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
969 |
} |
32 | 970 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
971 |
if (aPos + (aLength - 1) > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
972 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
973 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DELETEFROMPARAGRAPH, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
974 |
} |
32 | 975 |
__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
976 |
||
977 |
if (aLength <= 0) |
|
978 |
return; |
|
979 |
||
980 |
if (IndexPresent()) |
|
981 |
iIndex->DeleteFromParagraph(aPos, aLength); |
|
982 |
CPlainText::Delete(aPos,aLength); |
|
983 |
iParserData->MergeRange(aPos,aLength,0); |
|
984 |
CallEditObserver(aPos,-aLength); |
|
985 |
||
986 |
__TEST_INVARIANT; |
|
987 |
} |
|
988 |
||
989 |
EXPORT_C TInt CRichText::ParagraphCount()const |
|
990 |
/** Gets a count of the number of paragraphs in the text object. |
|
991 |
||
992 |
Note: |
|
993 |
||
994 |
The paragraph delimiter which terminates every text object means this function |
|
995 |
always returns a count of at least one. |
|
996 |
||
997 |
@return The number of paragraphs in the document. */ |
|
998 |
{ |
|
999 |
// Returns a count of the number of paragraphs |
|
1000 |
// in the document. |
|
1001 |
// |
|
1002 |
__TEST_INVARIANT; |
|
1003 |
||
1004 |
if (IndexPresent()) |
|
1005 |
return iIndex->ParagraphCount(); |
|
1006 |
else |
|
1007 |
return CPlainText::ParagraphCount(); |
|
1008 |
} |
|
1009 |
||
1010 |
||
1011 |
EXPORT_C TEtextComponentInfo CRichText::ComponentInfo() const |
|
1012 |
/** Gets information about the number of components contained in the text object |
|
1013 |
(the field count, the picture count and the style count). |
|
1014 |
||
1015 |
@return Contains the component information. */ |
|
1016 |
{ |
|
1017 |
return TEtextComponentInfo(FieldCount(), PictureCount(), StyleCount()); |
|
1018 |
} |
|
1019 |
||
1020 |
EXPORT_C TInt CRichText::CharPosOfParagraph(TInt& aLength, TInt aParaOffset) const |
|
1021 |
/** Finds the length and the start position of a paragraph identified by its |
|
1022 |
paragraph number. The first paragraph is numbered zero. |
|
1023 |
||
1024 |
Notes: |
|
1025 |
||
1026 |
if aParaOffset is invalid, (equal to or greater than the total number of |
|
1027 |
paragraphs), the function's return value is EScanEndOfData (= -1) |
|
1028 |
||
1029 |
@param aLength On return contains the length of the specified paragraph. |
|
1030 |
@param aParaOffset The paragraph number. The first paragraph is numbered zero. |
|
1031 |
@return The document position of the first character in the paragraph. */ |
|
1032 |
{ |
|
1033 |
// Returns the character position of the first character of paragraph aParaOffset, |
|
1034 |
// where aParaOffset specifies the nth paragraph. |
|
1035 |
// The length of this nth paragraph is written to aLength. |
|
1036 |
// |
|
1037 |
// If aParaOffset specifies a paragraph that does not exist, EScanEndOfData is returned. |
|
1038 |
// |
|
1039 |
__TEST_INVARIANT; |
|
1040 |
||
1041 |
if (IndexPresent()) |
|
1042 |
return iIndex->CharPosOfParagraph(aLength, aParaOffset); |
|
1043 |
else |
|
1044 |
return CPlainText::CharPosOfParagraph(aLength, aParaOffset); |
|
1045 |
} |
|
1046 |
||
1047 |
EXPORT_C TInt CRichText::ParagraphNumberForPos(TInt& aPos) const |
|
1048 |
/** Gets the number of the paragraph which contains a document position. |
|
1049 |
Paragraph numbering begins at zero. |
|
1050 |
||
1051 |
@param aPos A document position. Must be valid or a panic occurs. On return, |
|
1052 |
contains the document position of the first character in the paragraph in |
|
1053 |
which it is located. |
|
1054 |
@return The number of the paragraph containing the specified document position. */ |
|
1055 |
{ |
|
1056 |
// Returns the paragraph offset for the specified character position aPos. |
|
1057 |
// aPos is in turn modified to hold the character position of the first character |
|
1058 |
// of this paragraph. If aPos is already on a paragraph boundary then do nothing. |
|
1059 |
// |
|
1060 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1061 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1062 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1063 |
OstTrace0( TRACE_FATAL, CRICHTEXT_PARAGRAPHNUMBERFORPOS, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1064 |
} |
32 | 1065 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1066 |
||
1067 |
if (IndexPresent()) |
|
1068 |
return iIndex->ParagraphNumberForPos(aPos); |
|
1069 |
else |
|
1070 |
return CPlainText::ParagraphNumberForPos(aPos); |
|
1071 |
} |
|
1072 |
||
1073 |
/** Applies character formatting to a zero length selection, for example |
|
1074 |
turning bold on. This has the effect that the formatting will be applied to |
|
1075 |
text subsequently inserted at the position. This "insert pending" state is |
|
1076 |
cancelled by calling CancelInsertCharFormat(). |
|
1077 |
||
1078 |
Note 1: After calling this function, if text is inserted at a different |
|
1079 |
position to aPos, a panic will occur, unless CancelInsertCharFormat() has been |
|
1080 |
called before the insertion to cancel the "insert pending" state. |
|
1081 |
||
1082 |
Note 2: If the insert character format is being set for the end of the |
|
1083 |
paragraph, the paragraph delimiter is set to that format as well. This helps |
|
1084 |
end-of-paragraph behaviour be more similar to other places. |
|
1085 |
||
1086 |
@param aFormat The character format values to apply. |
|
1087 |
@param aMask Character format mask specifying the attributes affected. |
|
1088 |
@param aPos The document position at which to insert the character format. |
|
1089 |
@pre aPos must be a valid position, or a panic will occur. */ |
|
1090 |
EXPORT_C void CRichText::SetInsertCharFormatL(const TCharFormat& aFormat, |
|
1091 |
const TCharFormatMask& aMask, TInt aPos) |
|
1092 |
{ |
|
1093 |
SetExtendedInsertCharFormatL(aFormat, aMask,aPos); |
|
1094 |
} |
|
1095 |
||
1096 |
void CancelInsertCharFormat(TAny* aCRichTextIndex) |
|
1097 |
{ |
|
1098 |
reinterpret_cast<CRichTextIndex*>(aCRichTextIndex)->CancelInsertCharFormat(); |
|
1099 |
} |
|
1100 |
||
1101 |
void CRichText::SetExtendedInsertCharFormatL(const TCharFormatX& aFormat, const TCharFormatXMask& aMask, TInt aPos) |
|
1102 |
{ |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1103 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1104 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1105 |
OstTrace0( TRACE_FATAL, CRICHTEXT_SETEXTENDEDINSERTCHARFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1106 |
} |
32 | 1107 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1108 |
CreateAndGenerateMarkupComponentL(); |
|
1109 |
CRichTextIndex* index = iIndex.AsPtr(); |
|
1110 |
if (index->InsertCharFormatIsActive()) |
|
1111 |
{ |
|
1112 |
TCharFormatX format = aFormat; |
|
1113 |
TCharFormatXMask mask = aMask; |
|
1114 |
CCharFormatLayer* currentLayer = index->GetCurrentInsertCharFormat(); |
|
1115 |
currentLayer->Sense(format,mask); |
|
1116 |
CCharFormatLayer* newLayer = CCharFormatLayer::NewCopyBaseL(currentLayer); |
|
1117 |
CleanupStack::PushL(newLayer); |
|
1118 |
newLayer->SetL(format,mask); |
|
1119 |
if (Read(aPos, 1)[0] == EParagraphDelimiter) |
|
1120 |
index->ApplyCharFormatL(aFormat, aMask, aPos, 1, EFalse); |
|
1121 |
if (index->InsertCharFormatIsActive()) |
|
1122 |
{ |
|
1123 |
currentLayer = index->GetCurrentInsertCharFormat(); |
|
1124 |
currentLayer->Swap(*newLayer); |
|
1125 |
} |
|
1126 |
CleanupStack::PopAndDestroy(newLayer); |
|
1127 |
} |
|
1128 |
else |
|
1129 |
{ |
|
1130 |
TCleanupItem cleanup(::CancelInsertCharFormat, index); |
|
1131 |
CleanupStack::PushL(cleanup); |
|
1132 |
index->NewInsertCharFormatL(aFormat, aMask, aPos); |
|
1133 |
if (Read(aPos, 1)[0] == EParagraphDelimiter) |
|
1134 |
index->ApplyCharFormatL(aFormat, aMask, aPos, 1, EFalse); |
|
1135 |
CleanupStack::Pop(); |
|
1136 |
} |
|
1137 |
SetHasChanged(TRUE); |
|
1138 |
} |
|
1139 |
||
1140 |
EXPORT_C void CRichText::ExtendedInterface(TAny*& aInterface, TUid aInterfaceId) |
|
1141 |
/** |
|
1142 |
Returns the interface corresponding to the specified UID if it exists, or 0 if not. |
|
1143 |
Overridden versions should base call rather than returning 0. |
|
1144 |
For KUidRichText, CRichText will be returned if rich text is supported. |
|
1145 |
||
1146 |
@param aInterfaceId The UID indicating the interface to return |
|
1147 |
@param aInterface The interface corresponding to aInterfaceId |
|
1148 |
if it is supported, or 0 if it is not |
|
1149 |
*/ |
|
1150 |
{ |
|
1151 |
if(KUidRichText == aInterfaceId) |
|
1152 |
{ |
|
1153 |
aInterface = REINTERPRET_CAST(TAny*, this); |
|
1154 |
} |
|
1155 |
else |
|
1156 |
{ |
|
1157 |
CGlobalText::ExtendedInterface(aInterface, aInterfaceId); |
|
1158 |
} |
|
1159 |
} |
|
1160 |
||
1161 |
EXPORT_C TBool CRichText::DelSetInsertCharFormatL(TInt aPos, TInt aLength) |
|
1162 |
/** Deletes a range of characters. The range affected is from aPos to |
|
1163 |
aPos+(aLength-1) inclusive. It differs from DeleteL() in that this function |
|
1164 |
preserves the formatting of the deleted character at position aPos, so that |
|
1165 |
any text subsequently inserted at aPos will have that formatting applied to it. |
|
1166 |
||
1167 |
A panic occurs if: |
|
1168 |
||
1169 |
after calling this function, text is inserted at a different position to aPos, |
|
1170 |
without calling CancelInsertCharFormat() before the insertion |
|
1171 |
||
1172 |
aPos is invalid |
|
1173 |
||
1174 |
aLength is negative |
|
1175 |
||
1176 |
the range goes beyond the end of the document |
|
1177 |
||
1178 |
@param aPos The document position of the first character to delete. |
|
1179 |
@param aLength The number of characters to delete. |
|
1180 |
@return ETrue if two paragraphs have been merged as a result of the deletion; |
|
1181 |
EFalse if there has been no paragraph merge. */ |
|
1182 |
{ |
|
1183 |
// Delete aLength characters, commencing at, and including, aPos. |
|
1184 |
// If aPos is on a phrase boundary, and the whole phrase or more is deleted then |
|
1185 |
// remember temporarily the phrase format. This is applied to any content that is |
|
1186 |
// immediately inserted. |
|
1187 |
// |
|
1188 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1189 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1190 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1191 |
OstTrace0( TRACE_FATAL, CRICHTEXT_DELSETINSERTCHARFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1192 |
} |
32 | 1193 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1194 |
if (aLength < 0) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1195 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1196 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DELSETINSERTCHARFORMATL, "EDebugDeleteZeroLength" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1197 |
} |
32 | 1198 |
__ASSERT_ALWAYS(aLength >= 0, Panic(EDebugDeleteZeroLength)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1199 |
if (aPos + (aLength - 1) > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1200 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1201 |
OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_DELSETINSERTCHARFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1202 |
} |
32 | 1203 |
__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1204 |
||
1205 |
TBool parasMerged = EFalse; |
|
1206 |
if (!IndexPresent()) |
|
1207 |
CPlainText::DeleteL(aPos, aLength); |
|
1208 |
else |
|
1209 |
{ |
|
1210 |
parasMerged = iIndex->DelSetInsertCharFormatL(aPos, aLength); |
|
1211 |
CPlainText::Delete(aPos,aLength); |
|
1212 |
SetHasChanged(ETrue); |
|
1213 |
} |
|
1214 |
iParserData->MergeRange(aPos,aLength,0); |
|
1215 |
CallEditObserver(aPos,-aLength); |
|
1216 |
||
1217 |
__TEST_INVARIANT; |
|
1218 |
return parasMerged; |
|
1219 |
} |
|
1220 |
||
1221 |
EXPORT_C void CRichText::CancelInsertCharFormat() |
|
1222 |
/** Cancels the "insert pending" state set by a call to SetInsertCharFormatL() |
|
1223 |
or DelSetInsertCharFormatL(). |
|
1224 |
||
1225 |
This function removes the restriction on the text insertion position imposed |
|
1226 |
by these two functions. It is recommended that it is called before every cursor |
|
1227 |
movement, scroll, paste, etc. This call is a small overhead, and has no effect |
|
1228 |
if not applicable. */ |
|
1229 |
{ |
|
1230 |
// Cancels the transitory state where a specified character format |
|
1231 |
// is applied *on top of* any inherited formatting. eg, when bold is on. |
|
1232 |
// Cancel when: (1) the text position is altered. (2) the first character |
|
1233 |
// has been inserted following the setting of this state. |
|
1234 |
// |
|
1235 |
if (IndexPresent() && iIndex->InsertCharFormatIsActive()) |
|
1236 |
{ |
|
1237 |
iIndex->CancelInsertCharFormat(); |
|
1238 |
SetHasChanged(ETrue); |
|
1239 |
} |
|
1240 |
} |
|
1241 |
||
1242 |
EXPORT_C void CRichText::ApplyParaFormatL(const CParaFormat* aFormat, const TParaFormatMask& aMask, TInt aPos, TInt aLength) |
|
1243 |
/** Applies paragraph formatting to a range of paragraphs. The attributes which |
|
1244 |
are set in the mask are taken from aFormat and applied. The attributes which |
|
1245 |
are not set in the mask are not changed. |
|
1246 |
||
1247 |
The region affected consists of every paragraph containing one or more |
|
1248 |
characters in the range aPos to aPos+(aLength-1). |
|
1249 |
||
1250 |
@param aFormat Contains the paragraph format attribute values to apply. |
|
1251 |
@param aMask Specifies which paragraph format attributes should be affected. |
|
1252 |
@param aPos The document position of the start of the range. |
|
1253 |
@param aLength The number of characters in the range. */ |
|
1254 |
{ |
|
1255 |
// Applies the specified format attributes to the paragraphs covering |
|
1256 |
// character position aPos to aPos+aLength-1. |
|
1257 |
// |
|
1258 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1259 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1260 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1261 |
OstTrace0( TRACE_FATAL, CRICHTEXT_APPLYPARAFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1262 |
} |
32 | 1263 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1264 |
if (aLength < 0) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1265 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1266 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_APPLYPARAFORMATL, "EApplyParaFormatNegativeLength" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1267 |
} |
32 | 1268 |
__ASSERT_ALWAYS(aLength >= 0,Panic(EApplyParaFormatNegativeLength)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1269 |
if (aPos + (aLength - 1) > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1270 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1271 |
OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_APPLYPARAFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1272 |
} |
32 | 1273 |
__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1274 |
||
1275 |
CreateAndGenerateMarkupComponentL(); |
|
1276 |
iIndex->ApplyParaFormatL(aFormat, aMask, aPos, aLength); |
|
1277 |
SetHasChanged(ETrue); |
|
1278 |
||
1279 |
__TEST_INVARIANT; |
|
1280 |
} |
|
1281 |
||
1282 |
EXPORT_C void CRichText::ApplyCharFormatL(const TCharFormat& aFormat, const TCharFormatMask& aMask, TInt aPos, TInt aLength) |
|
1283 |
/** Applies character formatting to a range of characters. The attributes which |
|
1284 |
are set in the mask are read from aFormat and applied. The attributes which |
|
1285 |
are not set in the mask are not changed. The range of characters affected |
|
1286 |
is from aPos to aPos+(aLength-1) inclusive. The sum of aPos and aLength |
|
1287 |
must be less than or equal to the document length, or a panic occurs. |
|
1288 |
||
1289 |
@param aFormat Contains the character format attribute values to apply. |
|
1290 |
@param aMask Bitmask specifying which character format attributes should be |
|
1291 |
applied. |
|
1292 |
@param aPos Document position from which to apply the new character formatting. |
|
1293 |
Must be greater than or equal to zero, or a panic occurs. |
|
1294 |
@param aLength The number of characters to which the new formatting should |
|
1295 |
be applied. Must be greater than or equal to zero, or a panic occurs. If the |
|
1296 |
length is zero, the function has the same effect as SetInsertCharFormatL(). */ |
|
1297 |
{ |
|
1298 |
// Applies the specified character formatting to the characters conatined within the range |
|
1299 |
// aPos to aPos+(aLength-1). |
|
1300 |
// If aLength is zero, the SetInsertCharFormat state is called. |
|
1301 |
// |
|
1302 |
__ETEXT_WATCH(APPLY_CHAR_FORMAT); |
|
1303 |
__TEST_INVARIANT; |
|
1304 |
||
1305 |
TInt document_length = DocumentLength(); |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1306 |
if (aPos < 0) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1307 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1308 |
OstTrace0( TRACE_FATAL, CRICHTEXT_APPLYCHARFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1309 |
} |
32 | 1310 |
__ASSERT_ALWAYS(aPos >= 0,Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1311 |
if (aLength < 0) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1312 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1313 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_APPLYCHARFORMATL, "EApplyCharFormatNegativeLength" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1314 |
} |
32 | 1315 |
__ASSERT_ALWAYS(aLength >= 0,Panic(EApplyCharFormatNegativeLength)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1316 |
if (aPos + aLength - 1 > document_length) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1317 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1318 |
OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_APPLYCHARFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1319 |
} |
32 | 1320 |
__ASSERT_ALWAYS(aPos + aLength - 1 <= document_length,Panic(ECharPosBeyondDocument)); |
1321 |
||
1322 |
//If some characters are highlighted AND current position + highlighted txt = document length |
|
1323 |
// Fix for INC097216. Compensate for the changes introduced to Form in defect fix INC087637, |
|
1324 |
// which now considers the height of the EOD character; meaning that this character now |
|
1325 |
// needs to be formatted along with rest of text. |
|
1326 |
if ((aLength > 0) && (aPos + aLength == document_length)) |
|
1327 |
{ |
|
1328 |
aLength++; |
|
1329 |
} |
|
1330 |
||
1331 |
DoApplyExtendedCharFormatL(aFormat, aMask, aPos, aLength); |
|
1332 |
||
1333 |
__TEST_INVARIANT; |
|
1334 |
__ETEXT_WATCH_END(APPLY_CHAR_FORMAT); |
|
1335 |
} |
|
1336 |
||
1337 |
// This method is used internally only. It does not format the EOD character. |
|
1338 |
void CRichText::ApplyExtendedCharFormatL(const TCharFormatX& aFormat,const TCharFormatXMask& aMask,TInt aPos,TInt aLength) |
|
1339 |
{ |
|
1340 |
TInt document_length = DocumentLength(); |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1341 |
if (aPos < 0) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1342 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1343 |
OstTrace0( TRACE_FATAL, CRICHTEXT_APPLYEXTENDEDCHARFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1344 |
} |
32 | 1345 |
__ASSERT_ALWAYS(aPos >= 0,Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1346 |
if (aLength < 0) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1347 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1348 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_APPLYEXTENDEDCHARFORMATL, "EApplyCharFormatNegativeLength" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1349 |
} |
32 | 1350 |
__ASSERT_ALWAYS(aLength >= 0,Panic(EApplyCharFormatNegativeLength)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1351 |
if (aPos + aLength - 1 > document_length) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1352 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1353 |
OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_APPLYEXTENDEDCHARFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1354 |
} |
32 | 1355 |
__ASSERT_ALWAYS(aPos + aLength - 1 <= document_length,Panic(ECharPosBeyondDocument)); |
1356 |
||
1357 |
DoApplyExtendedCharFormatL(aFormat, aMask, aPos, aLength); |
|
1358 |
} |
|
1359 |
||
1360 |
// Apply the extended character formatting. |
|
1361 |
void CRichText::DoApplyExtendedCharFormatL(const TCharFormatX& aFormat,const TCharFormatXMask& aMask,TInt aPos,TInt aLength) |
|
1362 |
{ |
|
1363 |
if (aLength > 0) |
|
1364 |
{ |
|
1365 |
CreateAndGenerateMarkupComponentL(); |
|
1366 |
iIndex->ApplyCharFormatL(aFormat,aMask,aPos,aLength); |
|
1367 |
SetHasChanged(ETrue); |
|
1368 |
} |
|
1369 |
else |
|
1370 |
SetExtendedInsertCharFormatL(aFormat,aMask,aPos); |
|
1371 |
} |
|
1372 |
||
1373 |
EXPORT_C void CRichText::SetStyleListExternallyOwned(const CStyleList& aStyleList) |
|
1374 |
/** Assigns an externally owned style list to the rich text object. |
|
1375 |
Replaces any previous style list used by the object. Calls |
|
1376 |
SetStyleListExternallyOwned(ETrue). |
|
1377 |
||
1378 |
@param aExternallyOwned The style list to assign to this rich text object. |
|
1379 |
Not owned by the rich text object. */ |
|
1380 |
{ |
|
1381 |
CStyleList* styleList = CONST_CAST(CStyleList*, &aStyleList); |
|
1382 |
iStyleList = styleList; |
|
1383 |
SetStyleListExternallyOwned(ETrue); |
|
1384 |
} |
|
1385 |
||
1386 |
EXPORT_C void CRichText::ApplyParagraphStyleL(const CParagraphStyle& aStyle, TInt aPos, TInt aLength, CParagraphStyle::TApplyParaStyleMode aMode) |
|
1387 |
/** Applies a specified paragraph style to a range of paragraphs. The region |
|
1388 |
affected consists of every paragraph containing one or more characters in the |
|
1389 |
range aPos to aPos+(aLength-1). |
|
1390 |
||
1391 |
A panic occurs if: |
|
1392 |
||
1393 |
aPos is invalid, or |
|
1394 |
||
1395 |
aLength is negative, or |
|
1396 |
||
1397 |
the range goes beyond the end of the document, or |
|
1398 |
||
1399 |
the rich text object has no style list |
|
1400 |
||
1401 |
@param aStyle The style to apply. |
|
1402 |
@param aPos The document position of the start of the range. |
|
1403 |
@param aLength The number of characters in the range. |
|
1404 |
@param aMode Controls what specific formatting, if any, should be preserved |
|
1405 |
when the style is applied. */ |
|
1406 |
{ |
|
1407 |
// Applies the specified paragraph style to the paragraphs covering |
|
1408 |
// character positions aPos to aPos+aLength-1. |
|
1409 |
// |
|
1410 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1411 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1412 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1413 |
OstTrace0( TRACE_FATAL, CRICHTEXT_APPLYPARAGRAPHSTYLEL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1414 |
} |
32 | 1415 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1416 |
if (aLength < 0) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1417 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1418 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_APPLYPARAGRAPHSTYLEL, "EApplyParaStyleNegativeLength" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1419 |
} |
32 | 1420 |
__ASSERT_ALWAYS(aLength >= 0, Panic(EApplyParaStyleNegativeLength)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1421 |
if (aPos + (aLength - 1) > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1422 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1423 |
OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_APPLYPARAGRAPHSTYLEL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1424 |
} |
32 | 1425 |
__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1426 |
if (!StyleListPresent()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1427 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1428 |
OstTrace0( TRACE_FATAL, DUP3_CRICHTEXT_APPLYPARAGRAPHSTYLEL, "ERichTextNotSetForUsingStyles" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1429 |
} |
32 | 1430 |
__ASSERT_ALWAYS(StyleListPresent(), Panic(ERichTextNotSetForUsingStyles)); |
1431 |
||
1432 |
CreateAndGenerateMarkupComponentL(); |
|
1433 |
iIndex->ApplyParagraphStyleL(aStyle, aPos, aLength, iGlobalCharFormatLayer, aMode); |
|
1434 |
SetHasChanged(ETrue); |
|
1435 |
||
1436 |
__TEST_INVARIANT; |
|
1437 |
} |
|
1438 |
||
1439 |
EXPORT_C void CRichText::NotifyStyleChangedL(const CParagraphStyle* aTo, const CParagraphStyle* aFrom) |
|
1440 |
/** Removes a style from every paragraph in the document to which it applies, |
|
1441 |
and replaces it with another. |
|
1442 |
||
1443 |
If style aTo is NULL, aFrom is replaced by the global character and paragraph |
|
1444 |
format layers, so that in effect, style aFrom is removed. Any specific |
|
1445 |
formatting which has been applied to the paragraphs is retained. |
|
1446 |
||
1447 |
Notes: |
|
1448 |
||
1449 |
This function should be called on the text content object after changing a |
|
1450 |
style in the style list. |
|
1451 |
||
1452 |
A panic occurs if the rich text object does not use a style list (this can |
|
1453 |
be tested for using StyleListPresent()). |
|
1454 |
||
1455 |
@param aTo The new paragraph style to apply. |
|
1456 |
@param aFrom The paragraph style to remove. */ |
|
1457 |
{ |
|
1458 |
// Update the rich text index following the change of an applied paragraph style. |
|
1459 |
// |
|
1460 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1461 |
if (!StyleListPresent()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1462 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1463 |
OstTrace0( TRACE_FATAL, CRICHTEXT_NOTIFYSTYLECHANGEDL, "ERichTextNotSetForUsingStyles" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1464 |
} |
32 | 1465 |
__ASSERT_ALWAYS(StyleListPresent(), Panic(ERichTextNotSetForUsingStyles)); |
1466 |
||
1467 |
CreateAndGenerateMarkupComponentL(); |
|
1468 |
iIndex->NotifyStyleChangedL(aTo, aFrom, *iGlobalParaFormatLayer, *iGlobalCharFormatLayer); |
|
1469 |
SetHasChanged(ETrue); |
|
1470 |
||
1471 |
__TEST_INVARIANT; |
|
1472 |
} |
|
1473 |
||
1474 |
EXPORT_C const CParaFormatLayer* CRichText::ParagraphStyle(TBool& aStyleChangesOverRange, TInt aPos, TInt aLength) const |
|
1475 |
/** Gets a pointer to the first paragraph style encountered in the specified |
|
1476 |
range. |
|
1477 |
||
1478 |
@param aStyleChangesOverRange On return, set to ETrue if more than one paragraph |
|
1479 |
style is used over the specified range of characters. Otherwise EFalse |
|
1480 |
@param aPos The document position of the start of the range. Must be valid. |
|
1481 |
@param aLength The number of characters in the range. Must be greater than |
|
1482 |
or equal to zero. |
|
1483 |
@return Pointer to the paragraph style which applies to the paragraph containing |
|
1484 |
document position aPos. Its type (returned by CParaFormatLayer::Type()) |
|
1485 |
indicates whether this object is a style, or just a paragraph format layer. */ |
|
1486 |
{ |
|
1487 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1488 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1489 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1490 |
OstTrace0( TRACE_FATAL, CRICHTEXT_PARAGRAPHSTYLE, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1491 |
} |
32 | 1492 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1493 |
if (aLength < 0) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1494 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1495 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_PARAGRAPHSTYLE, "EParagraphStyleNegativeLength" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1496 |
} |
32 | 1497 |
__ASSERT_ALWAYS(aLength >= 0,Panic(EParagraphStyleNegativeLength)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1498 |
if (aPos + (aLength - 1) > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1499 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1500 |
OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_PARAGRAPHSTYLE, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1501 |
} |
32 | 1502 |
__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1503 |
||
1504 |
if (IndexPresent()) |
|
1505 |
return iIndex->ParagraphStyle(aStyleChangesOverRange, aPos, aLength); |
|
1506 |
else |
|
1507 |
{ |
|
1508 |
aStyleChangesOverRange = EFalse; |
|
1509 |
return iGlobalParaFormatLayer; |
|
1510 |
} |
|
1511 |
} |
|
1512 |
||
1513 |
EXPORT_C void CRichText::SetHasChanged(TBool aHasChanged) |
|
1514 |
/** Sets whether the document's content or formatting has changed. This function |
|
1515 |
is called with an value of ETrue by all functions which modify the text content |
|
1516 |
or formatting. Use CEditableText::HasChanged() to test whether the document |
|
1517 |
has changed. |
|
1518 |
||
1519 |
@param aHasChanged ETrue if the text object has been changed, EFalse if not. */ |
|
1520 |
{ |
|
1521 |
// Replaces the base class method of the same name. |
|
1522 |
// |
|
1523 |
if (aHasChanged && IndexPresent()) |
|
1524 |
iIndex->DocumentChanged(); |
|
1525 |
CGlobalText::SetHasChanged(aHasChanged); |
|
1526 |
} |
|
1527 |
||
1528 |
EXPORT_C void CRichText::RemoveSpecificParaFormatL(TInt aPos, TInt aLength) |
|
1529 |
/** Removes all specific paragraph formatting from a range of paragraphs. This |
|
1530 |
does not remove formatting from the object's global paragraph format layer. |
|
1531 |
The region affected consists of every paragraph containing one or more |
|
1532 |
characters in the range covered by document position aPos to aPos+(aLength-1) |
|
1533 |
inclusive. |
|
1534 |
||
1535 |
A panic occurs in the following situations: |
|
1536 |
||
1537 |
the position is negative, |
|
1538 |
||
1539 |
the length is negative, |
|
1540 |
||
1541 |
the range goes beyond the end of the document |
|
1542 |
||
1543 |
@param aPos The document position of the start of the range. |
|
1544 |
@param aLength The number of characters in the range. */ |
|
1545 |
{ |
|
1546 |
// Removes all specific paragraph formatting from the selected region. |
|
1547 |
// |
|
1548 |
__ETEXT_WATCH(REMOVE_PARA_FORMAT); |
|
1549 |
||
1550 |
__TEST_INVARIANT; |
|
1551 |
||
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1552 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1553 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1554 |
OstTrace0( TRACE_FATAL, CRICHTEXT_REMOVESPECIFICPARAFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1555 |
} |
32 | 1556 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1557 |
if (aLength < 0) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1558 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1559 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_REMOVESPECIFICPARAFORMATL, "ERemoveSpecificParaFormatNegativeLength" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1560 |
} |
32 | 1561 |
__ASSERT_ALWAYS(aLength >= 0, Panic(ERemoveSpecificParaFormatNegativeLength)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1562 |
if (aPos + (aLength - 1) > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1563 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1564 |
OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_REMOVESPECIFICPARAFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1565 |
} |
32 | 1566 |
__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1567 |
||
1568 |
if (IndexPresent()) |
|
1569 |
{ |
|
1570 |
iIndex->RemoveSpecificParaFormatL(aPos, aLength); |
|
1571 |
SetHasChanged(ETrue); |
|
1572 |
} |
|
1573 |
||
1574 |
__TEST_INVARIANT; |
|
1575 |
||
1576 |
__ETEXT_WATCH_END(REMOVE_PARA_FORMAT); |
|
1577 |
} |
|
1578 |
||
1579 |
EXPORT_C void CRichText::RemoveSpecificCharFormatL(TInt aPos, TInt aLength) |
|
1580 |
/** Removes all specific character formatting from a range of characters (does |
|
1581 |
not remove the formatting which has been taken from the object's global character |
|
1582 |
format layer). A panic occurs in the following situations: |
|
1583 |
||
1584 |
the position is negative, |
|
1585 |
||
1586 |
the length is negative, |
|
1587 |
||
1588 |
the range goes beyond the end of the document |
|
1589 |
||
1590 |
@param aPos The document position of the start of the region affected. |
|
1591 |
@param aLength The number of characters in the region affected. If zero, the |
|
1592 |
function has no effect. */ |
|
1593 |
{ |
|
1594 |
__TEST_INVARIANT; |
|
1595 |
||
1596 |
TInt document_length = DocumentLength(); |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1597 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1598 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1599 |
OstTrace0( TRACE_FATAL, CRICHTEXT_REMOVESPECIFICCHARFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1600 |
} |
32 | 1601 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1602 |
if (aLength < 0) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1603 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1604 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_REMOVESPECIFICCHARFORMATL, "ERemoveSpecificParaFormatNegativeLength" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1605 |
} |
32 | 1606 |
__ASSERT_ALWAYS(aLength >= 0, Panic(ERemoveSpecificParaFormatNegativeLength)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1607 |
if (aPos + (aLength - 1) > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1608 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1609 |
OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_REMOVESPECIFICCHARFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1610 |
} |
32 | 1611 |
__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1612 |
||
1613 |
// in correspondance to INC097216, character format removing considers the height of end of document |
|
1614 |
// character |
|
1615 |
if (aPos + aLength == document_length) |
|
1616 |
{ |
|
1617 |
aLength++; |
|
1618 |
} |
|
1619 |
||
1620 |
if (aLength > 0 && IndexPresent()) |
|
1621 |
{ |
|
1622 |
iIndex->RemoveSpecificCharFormatL(aPos, aLength); |
|
1623 |
SetHasChanged(ETrue); |
|
1624 |
} |
|
1625 |
||
1626 |
__TEST_INVARIANT; |
|
1627 |
} |
|
1628 |
||
1629 |
EXPORT_C void CRichText::GetChars(TPtrC& aText, TCharFormat& aFormat, TInt aPos) const |
|
1630 |
/** Gets a constant pointer descriptor to a portion of the text object |
|
1631 |
with constant character formatting. |
|
1632 |
||
1633 |
The view starts at the document position specified, and ends at: the |
|
1634 |
last character which shares the same character formatting, orthe end |
|
1635 |
of the document, orthe end of the segment, if segmented storage is |
|
1636 |
being usedwhichever occurs first. Also fills a character format object |
|
1637 |
with the character formatting of the range of characters. |
|
1638 |
||
1639 |
@param aView On return, a constant pointer to a portion of the text. |
|
1640 |
@param aFormat On return, contains the character formatting of the text. |
|
1641 |
@param aPos The start position for the view. Must be a valid document |
|
1642 |
position, or a panic occurs. */ |
|
1643 |
{ |
|
1644 |
// Get a run of text and its format, starting at aPos. |
|
1645 |
__ETEXT_WATCH(GET_CHARS) |
|
1646 |
TCharFormatX format; |
|
1647 |
GetTextAndExtendedFormat(aText, format, aPos); |
|
1648 |
OverrideFormatForParsersIfApplicable(aText, format, aPos); |
|
1649 |
aFormat = format.iCharFormat; |
|
1650 |
OverrideFormatOfInlineTextIfApplicable(aText, aFormat, aPos); |
|
1651 |
__ETEXT_WATCH_END(GET_CHARS) |
|
1652 |
} |
|
1653 |
||
1654 |
||
1655 |
void CRichText::GetTextAndExtendedFormat(TPtrC& aText,TCharFormatX& aFormat,TInt aPos) const |
|
1656 |
{ |
|
1657 |
__TEST_INVARIANT; |
|
1658 |
TInt documentLength = DocumentLength(); |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1659 |
if (aPos < 0 || aPos > documentLength) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1660 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1661 |
OstTrace0( TRACE_FATAL, CRICHTEXT_GETTEXTANDEXTENDEDFORMAT, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1662 |
} |
32 | 1663 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= documentLength, Panic(ECharPosBeyondDocument)); |
1664 |
if (!IndexPresent()) |
|
1665 |
{ |
|
1666 |
aText.Set(Read(aPos)); |
|
1667 |
iGlobalCharFormatLayer->SenseEffective(aFormat); |
|
1668 |
} |
|
1669 |
else |
|
1670 |
{ |
|
1671 |
int phrase_length = iIndex->GetChars(aFormat,aPos); |
|
1672 |
aText.Set(Read(aPos,phrase_length)); |
|
1673 |
} |
|
1674 |
__TEST_INVARIANT; |
|
1675 |
} |
|
1676 |
||
1677 |
EXPORT_C TInt CRichText::GetPictureSizeInTwips(TSize& aSize, TInt aPos) const |
|
1678 |
/** Gets the size of a picture located at a specified document position. |
|
1679 |
||
1680 |
@param aSize On return, contains the size of the picture located at aPos. |
|
1681 |
@param aPos Document position of the picture. Must be a valid position. |
|
1682 |
@return KErrNotFound if there is no picture at the specified document position, |
|
1683 |
KErrNone if there is. */ |
|
1684 |
{ |
|
1685 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1686 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1687 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1688 |
OstTrace0( TRACE_FATAL, CRICHTEXT_GETPICTURESIZEINTWIPS, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1689 |
} |
32 | 1690 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1691 |
||
1692 |
if (IndexPresent()) |
|
1693 |
return iIndex->GetPictureSizeInTwips(aSize, aPos); |
|
1694 |
else |
|
1695 |
return KErrNotFound; |
|
1696 |
} |
|
1697 |
||
1698 |
EXPORT_C CPicture* CRichText::PictureHandleL(TInt aPos, MLayDoc::TForcePictureLoad aForceLoad) const |
|
1699 |
/** Gets a pointer to the picture located at a specified document position, if |
|
1700 |
one exists. If the picture is not in memory, the function loads it (if the |
|
1701 |
second argument has a value of MLayDoc::EForceLoadTrue). |
|
1702 |
||
1703 |
Note: |
|
1704 |
||
1705 |
In order to load the picture, a picture factory and a store resolver must |
|
1706 |
have been set. |
|
1707 |
||
1708 |
@param aPos Document position of the picture character. Must be a valid position. |
|
1709 |
@param aForceLoad If the picture is not loaded into memory, |
|
1710 |
MLayDoc::EForceLoadTrue loads it using the picture factory; |
|
1711 |
MLayDoc::EForceLoadFalse does not, and in this case, the function returns NULL. |
|
1712 |
@return A pointer to the picture located at aPos. NULL if aPos does not specify |
|
1713 |
a picture character, or if there is a picture at aPos which is not in memory, |
|
1714 |
and the second argument is MLayDoc::EForceLoadFalse. */ |
|
1715 |
{ |
|
1716 |
__ETEXT_WATCH(PICTURE_HANDLE); |
|
1717 |
||
1718 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1719 |
if (aPos<0 || aPos>DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1720 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1721 |
OstTrace0( TRACE_FATAL, CRICHTEXT_PICTUREHANDLEL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1722 |
} |
32 | 1723 |
__ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument)); |
1724 |
||
1725 |
if (IndexPresent()) |
|
1726 |
return iIndex->PictureHandleL(aPos, aForceLoad); |
|
1727 |
else |
|
1728 |
return NULL; |
|
1729 |
||
1730 |
__ETEXT_WATCH_END(PICTURE_HANDLE); |
|
1731 |
} |
|
1732 |
||
1733 |
EXPORT_C void CRichText::GetParagraphFormatL(CParaFormat* aFormat, TInt aPos) const |
|
1734 |
/** Gets the effective paragraph formatting which applies to the paragraph which |
|
1735 |
contains a specified document position. On return, aFormat is filled with |
|
1736 |
values for all paragraph format attributes. |
|
1737 |
||
1738 |
@param aFormat On return, filled with the paragraph's effective paragraph |
|
1739 |
formatting. |
|
1740 |
@param aPos Any document position within the paragraph of interest. */ |
|
1741 |
{ |
|
1742 |
__ETEXT_WATCH(GET_PARAGRAPH_FORMAT) |
|
1743 |
||
1744 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1745 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1746 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1747 |
OstTrace0( TRACE_FATAL, CRICHTEXT_GETPARAGRAPHFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1748 |
} |
32 | 1749 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1750 |
||
1751 |
if (!IndexPresent()) |
|
1752 |
CGlobalText::GetParagraphFormatL(aFormat, aPos); |
|
1753 |
else |
|
1754 |
{ |
|
1755 |
aFormat->Reset(); |
|
1756 |
iIndex->GetParagraphFormatL(aFormat, aPos); |
|
1757 |
} |
|
1758 |
||
1759 |
__ETEXT_WATCH_END(GET_PARAGRAPH_FORMAT) |
|
1760 |
} |
|
1761 |
||
1762 |
EXPORT_C void CRichText::GetSpecificParagraphFormatL(CParaFormat* aFormat, |
|
1763 |
TParaFormatMask& aMask, |
|
1764 |
TInt aPos) const |
|
1765 |
// Fills aFormat with the effective Paragraph format attributes for the paragraph |
|
1766 |
// in which character position aPos is contained. |
|
1767 |
// |
|
1768 |
{ |
|
1769 |
__ETEXT_WATCH(GET_PARAGRAPH_FORMAT) |
|
1770 |
||
1771 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1772 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1773 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1774 |
OstTrace0( TRACE_FATAL, CRICHTEXT_GETSPECIFICPARAGRAPHFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1775 |
} |
32 | 1776 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1777 |
||
1778 |
aFormat->Reset(); |
|
1779 |
aMask.ClearAll(); |
|
1780 |
if (IndexPresent()) |
|
1781 |
iIndex->GetSpecificParagraphFormatL(aFormat, aMask, aPos); |
|
1782 |
||
1783 |
__ETEXT_WATCH_END(GET_PARAGRAPH_FORMAT) |
|
1784 |
} |
|
1785 |
||
1786 |
EXPORT_C void CRichText::GetParaFormatL(CParaFormat* aFormat, TParaFormatMask& aVaries, TInt aPos, TInt aLength, |
|
1787 |
CParaFormat::TParaFormatGetMode aMode) const |
|
1788 |
/** Gets the effective paragraph formatting which applies to a range of paragraphs. |
|
1789 |
The region involved is every paragraph containing one or more characters in |
|
1790 |
the range aPos to aPos+(aLength-1) inclusive. On return, aFormat is filled |
|
1791 |
with values for all paragraph format attributes and the mask indicates the |
|
1792 |
values that change over the region, and whose value is therefore indeterminate. |
|
1793 |
||
1794 |
Note: |
|
1795 |
||
1796 |
If aMode has a value of EFixedAttributes, the function cannot leave. |
|
1797 |
||
1798 |
@param aFormat Must not be NULL or a panic occurs. On return, contains the |
|
1799 |
effective paragraph formatting for the range of paragraphs. |
|
1800 |
@param aVaries On return, a bitmask indicating which paragraph format attributes |
|
1801 |
vary over the range of characters selected. |
|
1802 |
@param aPos The document position of the start of the range. |
|
1803 |
@param aLength The number of characters in the range. |
|
1804 |
@param aMode The default, EAllAttributes means that values for all paragraph |
|
1805 |
format attributes are written to aFormat. EFixedAttributes means that tabs, |
|
1806 |
bullets and borders are not written to aFormat. */ |
|
1807 |
{ |
|
1808 |
// Senses the paragraph format of para(s) covered by the region aPos to aPos+aLength-1. |
|
1809 |
// aFormat takes the values of all attributes, and the mask aMask indicates those values that change |
|
1810 |
// over the selected region, and are therefore *indeterminate*. |
|
1811 |
// Application: seeding paragraph formatting dialogs. |
|
1812 |
// |
|
1813 |
__TEST_INVARIANT; |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1814 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1815 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1816 |
OstTrace0( TRACE_FATAL, CRICHTEXT_GETPARAFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1817 |
} |
32 | 1818 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1819 |
if (aLength < 0) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1820 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1821 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_GETPARAFORMATL, "EGetParaFormatNegativeLength" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1822 |
} |
32 | 1823 |
__ASSERT_ALWAYS(aLength >= 0, Panic(EGetParaFormatNegativeLength)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1824 |
if (aPos + aLength > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1825 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1826 |
OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_GETPARAFORMATL, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1827 |
} |
32 | 1828 |
__ASSERT_ALWAYS(aPos + aLength <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1829 |
||
1830 |
if (IndexPresent()) |
|
1831 |
iIndex->GetParaFormatL(aFormat, aVaries, aPos, aLength, aMode); |
|
1832 |
else |
|
1833 |
CGlobalText::GetParaFormatL(aFormat, aVaries, aPos, aLength, aMode); |
|
1834 |
} |
|
1835 |
||
1836 |
EXPORT_C void CRichText::GetCharFormat(TCharFormat& aFormat, TCharFormatMask& aVaries, TInt aPos, TInt aLength) const |
|
1837 |
/** Gets the effective character formatting which applies to a range of |
|
1838 |
characters. The range of characters involved is from aPos to aPos+(aLength-1) |
|
1839 |
inclusive. On return, aFormat is filled with values for all character format |
|
1840 |
attributes, and on return, the mask indicates the values that change over the |
|
1841 |
region, and whose value is therefore indeterminate. |
|
1842 |
||
1843 |
The length value can be zero. In this case, the character formatting sensed |
|
1844 |
is that of the character immediately to the left of the position specified. |
|
1845 |
||
1846 |
@param aFormat On return, contains the character format values for the range |
|
1847 |
of characters. |
|
1848 |
@param aVaries On return, indicates which character format attributes vary |
|
1849 |
over the range. |
|
1850 |
@param aPos Document position of the start of the range. Must be valid or a |
|
1851 |
panic occurs. |
|
1852 |
@param aLength Number of characters in the range. Must be greater than or equal |
|
1853 |
to zero, or a panic occurs. */ |
|
1854 |
{ |
|
1855 |
// Senses the character formatting of the phrase(s) covered by the region aPos to aPos+aLength-1. |
|
1856 |
// May be called with zero length. |
|
1857 |
// aFormat takes the values of all character format attributes, and the mask aMask indicates those |
|
1858 |
// values that change over the selected region, and are therefore *indeterminate*. |
|
1859 |
// Application: seeding character formatting dialogs. |
|
1860 |
// |
|
1861 |
TCharFormatX format; |
|
1862 |
TCharFormatXMask varies; |
|
1863 |
GetExtendedCharFormat(format, varies, aPos, aLength); |
|
1864 |
aFormat = format.iCharFormat; |
|
1865 |
varies.ClearExtendedAttribs(); |
|
1866 |
aVaries = varies; |
|
1867 |
} |
|
1868 |
||
1869 |
||
1870 |
void CRichText::GetExtendedCharFormat(TCharFormatX& aFormat, TCharFormatXMask& aVaries, TInt aPos, TInt aLength) const |
|
1871 |
{ |
|
1872 |
__TEST_INVARIANT; |
|
1873 |
int document_length = DocumentLength(); |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1874 |
if (aPos < 0 || aPos > document_length) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1875 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1876 |
OstTrace0( TRACE_FATAL, CRICHTEXT_GETEXTENDEDCHARFORMAT, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1877 |
} |
32 | 1878 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= document_length, Panic(ECharPosBeyondDocument)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1879 |
if (aLength < 0) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1880 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1881 |
OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_GETEXTENDEDCHARFORMAT, "EGetCharFormatNegativeLength" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1882 |
} |
32 | 1883 |
__ASSERT_ALWAYS(aLength >= 0, Panic(EGetCharFormatNegativeLength)); |
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1884 |
if (aPos + aLength - 1 > document_length) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1885 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1886 |
OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_GETEXTENDEDCHARFORMAT, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1887 |
} |
32 | 1888 |
__ASSERT_ALWAYS(aPos + aLength - 1 <= document_length, Panic(ECharPosBeyondDocument)); |
1889 |
||
1890 |
if (IndexPresent()) |
|
1891 |
iIndex->GetCharFormat(aFormat, aVaries, aPos, aLength); |
|
1892 |
else |
|
1893 |
{ |
|
1894 |
iGlobalCharFormatLayer->SenseEffective(aFormat); |
|
1895 |
aVaries.ClearAll(); |
|
1896 |
} |
|
1897 |
} |
|
1898 |
||
1899 |
||
1900 |
void CRichText::GetSpecificCharFormatLeftRight(TCharFormat& aFormat, |
|
1901 |
TCharFormatMask& aMask, |
|
1902 |
TInt aPos, |
|
1903 |
TBool aLeft) const |
|
1904 |
{ |
|
1905 |
__ETEXT_WATCH(GET_SPECIFIC_CHARS); |
|
1906 |
||
1907 |
__TEST_INVARIANT; |
|
1908 |
||
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1909 |
if (aPos < 0 || aPos > DocumentLength()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1910 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1911 |
OstTrace0( TRACE_FATAL, CRICHTEXT_GETSPECIFICCHARFORMATLEFTRIGHT, "ECharPosBeyondDocument" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
1912 |
} |
32 | 1913 |
__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument)); |
1914 |
||
1915 |
if (IndexPresent()) |
|
1916 |
{ |
|
1917 |
TCharFormatX format; |
|
1918 |
TCharFormatXMask mask; |
|
1919 |
iIndex->GetSpecificCharFormatDirection(format, mask, aPos, aLeft); |
|
1920 |
aFormat = format.iCharFormat; |
|
1921 |
mask.ClearExtendedAttribs(); |
|
1922 |
aMask = mask; |
|
1923 |
} |
|
1924 |
||
1925 |
__ETEXT_WATCH_END(GET_SPECIFIC_CHARS); |
|
1926 |
} |
|
1927 |
||
1928 |
EXPORT_C void CRichText::GetSpecificCharFormat(TCharFormat& aFormat, TCharFormatMask& aMask, TInt aPos) const |
|
1929 |
/** Gets the specific character formatting which applies to the character to the |
|
1930 |
left of a document position. Specific formatting is just the formatting which |
|
1931 |
has been applied over the object's global format layers - it is not the |
|
1932 |
same as the effective formatting. |
|
1933 |
||
1934 |
@param aFormat On return contains the specific character formatting which |
|
1935 |
applies to the character to the left of the document position. |
|
1936 |
@param aMask On return, indicates which character format attributes have been |
|
1937 |
applied specifically, (not taken from the global layers). |
|
1938 |
@param aPos The document position. Must be valid or a panic occurs. */ |
|
1939 |
{ |
|
1940 |
// Return the format attributes store in the specific layer only, for the specified document position. |
|
1941 |
// THIS IS NOT THE EFFECTIVE FORMAT, BUT THE SPECIFIC FORMATTING ONLY. |
|
1942 |
// |
|
1943 |
GetSpecificCharFormatLeftRight(aFormat, aMask, aPos, ETrue); |
|
1944 |
} |
|
1945 |
||
1946 |
EXPORT_C void CRichText::GetSpecificCharFormatRight(TCharFormat& aFormat, TCharFormatMask& aMask, TInt aPos) const |
|
1947 |
/** Gets the specific character formatting which applies to the character logically |
|
1948 |
after a document position. Note that this is not necessarily the character |
|
1949 |
to the right of the document position, because right to left text is supported. |
|
1950 |
||
1951 |
Specific formatting is just the formatting which has been applied over the |
|
1952 |
object's global format layers it is not the same as the effective formatting. |
|
1953 |
||
1954 |
@param aFormat On return, contains the specific character formatting which |
|
1955 |
applies to the character logically after the document position. |
|
1956 |
@param aMask On return, indicates which character format attributes have been |
|
1957 |
applied specifically, (not taken from the global layers). |
|
1958 |
@param aPos The document position. Must be valid or a panic occurs. */ |
|
1959 |
{ |
|
1960 |
GetSpecificCharFormatLeftRight(aFormat, aMask, aPos, EFalse); |
|
1961 |
} |
|
1962 |
||
1963 |
TBool CRichText::IndexPresent()const |
|
1964 |
// Returns ETrue if the rich text index is present, otherwise |
|
1965 |
// returns EFalse. |
|
1966 |
// |
|
1967 |
{ |
|
1968 |
return iIndex.IsPtr() && iIndex.AsPtr(); |
|
1969 |
} |
|
1970 |
||
1971 |
||
1972 |
EXPORT_C TInt CRichText::PictureCount() const |
|
1973 |
/** Gets a count of the number of pictures contained in the rich text object. |
|
1974 |
||
1975 |
@return The picture count. */ |
|
1976 |
{return (IndexPresent()) ? iIndex->iPictureCount : 0;} |
|
1977 |
||
1978 |
||
1979 |
void CRichText::SetParaTypeIsSingle(TBool aBool) |
|
1980 |
{ |
|
1981 |
if (aBool) |
|
1982 |
iFlags |= KParaTypeIsSingle; |
|
1983 |
else |
|
1984 |
iFlags &= ~KParaTypeIsSingle; |
|
1985 |
} |
|
1986 |
||
1987 |
||
1988 |
TBool CRichText::ParaTypeIsSingle() const |
|
1989 |
{return iFlags & KParaTypeIsSingle;} |
|
1990 |
||
1991 |
||
1992 |
EXPORT_C void CRichText::AppendTakingSolePictureOwnershipL(const CRichText& aSource) |
|
1993 |
/** Appends a rich text object to this one. The text is appended immediately after |
|
1994 |
the end-of-text paragraph delimiter. The incoming text's formatting is set |
|
1995 |
to be based on the global formatting of this rich text object. |
|
1996 |
||
1997 |
Notes: |
|
1998 |
||
1999 |
If this rich text object is empty (e.g. because it is newly initialised, or |
|
2000 |
has been reset), then the end-of-text delimiter of the incoming rich text |
|
2001 |
is not appended. This avoids the possibility of having a trailing paragraph |
|
2002 |
delimiter, giving one more empty line than would typically be desired. |
|
2003 |
||
2004 |
If the incoming rich text contains pictures which have been loaded into memory, |
|
2005 |
their sole ownership is transferred to the current rich text object. In aSource, |
|
2006 |
these picture handles are set to NULL. |
|
2007 |
||
2008 |
@param aSource The rich text object to append. */ |
|
2009 |
{ |
|
2010 |
// Appends the specified rich text object to this one. |
|
2011 |
// If this rich text is empty or has been newly initialised or reset, then the final paragraph delimiter |
|
2012 |
// of the incoming rich text is NOT appended, thus avoiding the prospect of having a trailing, empty |
|
2013 |
// paragraph delimiter, giving one more empty line than would typically be desired. |
|
2014 |
// |
|
2015 |
__ETEXT_WATCH(APPEND_RICH_TEXT); |
|
2016 |
||
2017 |
// Append the text |
|
2018 |
const TInt thisDocumentLength = DocumentLength(); |
|
2019 |
MPictureFactory* factory = NULL; |
|
2020 |
MRichTextStoreResolver* resolver = NULL; |
|
2021 |
if (thisDocumentLength == 0) // this is an empty document |
|
2022 |
{ |
|
2023 |
factory = iPictureFactory; |
|
2024 |
resolver = iStoreResolver; |
|
2025 |
Reset(); // destroy the markup component if it exists. Makes the job easier |
|
2026 |
} |
|
2027 |
// |
|
2028 |
PrepareAppendMarkupL(aSource); // requires no rollback - objects in a (bigger) stable state |
|
2029 |
// |
|
2030 |
TRAPD(ret, DoAppendTakingSolePictureOwnershipL(aSource)); |
|
2031 |
if (ret != KErrNone) |
|
2032 |
{ |
|
2033 |
CPlainText::Delete(thisDocumentLength,DocumentLength() - thisDocumentLength); |
|
2034 |
User::Leave(ret); |
|
2035 |
} |
|
2036 |
if (thisDocumentLength == 0) |
|
2037 |
{ |
|
2038 |
DeleteParagraph(0, 1); // remove excess first paragraph from empty documents |
|
2039 |
SetPictureFactory(factory, resolver); |
|
2040 |
} |
|
2041 |
int new_length = DocumentLength() - thisDocumentLength; |
|
2042 |
iParserData->MergeRange(thisDocumentLength,0,new_length); |
|
2043 |
CallEditObserver(thisDocumentLength,new_length); |
|
2044 |
||
2045 |
__TEST_INVARIANT; |
|
2046 |
||
2047 |
__ETEXT_WATCH_END(APPEND_RICH_TEXT); |
|
2048 |
} |
|
2049 |
||
2050 |
||
2051 |
void CRichText::DoAppendTakingSolePictureOwnershipL(const CRichText& aSource) |
|
2052 |
{ |
|
2053 |
TInt lengthRemaining = aSource.DocumentLength() + 1; // we want to append the para delimiters also! |
|
2054 |
TInt consumed = 0; |
|
2055 |
FOREVER |
|
2056 |
{ |
|
2057 |
TPtrC view = aSource.Read(consumed); |
|
2058 |
if (view.Length() > lengthRemaining) |
|
2059 |
view.Set(view.Ptr(), lengthRemaining); |
|
2060 |
CPlainText::DoPtInsertL(DocumentLength() + 1, view); // insert AFTER the final paragraph delimiter |
|
2061 |
TInt viewLength = view.Length(); |
|
2062 |
lengthRemaining -= viewLength; |
|
2063 |
if (lengthRemaining == 0) |
|
2064 |
break; |
|
2065 |
consumed += viewLength; |
|
2066 |
} |
|
2067 |
||
2068 |
if (IndexPresent()) |
|
2069 |
{ |
|
44
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
2070 |
if (!aSource.IndexPresent()) |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
2071 |
{ |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
2072 |
OstTrace0( TRACE_DUMP, DUP1_CRICHTEXT_DOAPPENDTAKINGSOLEPICTUREOWNERSHIPL, "Invariant" ); |
601ab138ba0b
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
2073 |
} |
32 | 2074 |
__ASSERT_DEBUG(aSource.IndexPresent(), User::Invariant()); // PrepareAppend should have sorted this |
2075 |
||
2076 |
TGlobalLayerInfoAppend info(GlobalParaFormatLayer(), GlobalCharFormatLayer(), aSource.GlobalParaFormatLayer(), aSource.GlobalCharFormatLayer()); |
|
2077 |
iIndex->AppendTakingSolePictureOwnershipL(aSource.iIndex, info); |
|
2078 |
} |
|
2079 |
||
2080 |
__TEST_INVARIANT; |
|
2081 |
} |
|
2082 |
||
2083 |
||
2084 |
void CRichText::PrepareAppendMarkupL(const CRichText& aSource) |
|
2085 |
// Guarantees that both the component and aggregate objects have a valid markup component. |
|
2086 |
// |
|
2087 |
{ |
|
2088 |
if (aSource.HasMarkupData() && !HasMarkupData()) |
|
2089 |
CreateAndGenerateMarkupComponentL(); |
|
2090 |
else if (IndexPresent()) |
|
2091 |
CONST_CAST(CRichText&, aSource).CreateAndGenerateMarkupComponentL(); |
|
2092 |
} |
|
2093 |
||
2094 |
||
2095 |
EXPORT_C void CRichText::AppendParagraphL(TInt aReplicas) |
|
2096 |
/** Appends one or more empty paragraphs to the document. The new paragraphs take |
|
2097 |
on the formatting specified in the global format layers. |
|
2098 |
||
2099 |
@param aReplicas The number of empty paragraphs to append to the document. |
|
2100 |
By default, a single paragraph. */ |
|
2101 |
{ |
|
2102 |
// Inserts an empty paragraph at the end of the document. |
|
2103 |
// The new paragraph takes on the format as described |
|
2104 |
// by the global format layers. |
|
2105 |
// |
|
2106 |
__ETEXT_WATCH(APPEND_PARAGRAPH); |
|
2107 |
||
2108 |
__TEST_INVARIANT; |
|
2109 |
||
2110 |
TInt documentLength = DocumentLength(); |
|
2111 |
if (aReplicas == 1) |
|
2112 |
CPlainText::InsertL(documentLength, CEditableText::EParagraphDelimiter); |
|
2113 |
else |
|
2114 |
{ |
|
2115 |
HBufC* bb = HBufC::NewLC(aReplicas); |
|
2116 |
TPtr buf = bb->Des(); |
|
2117 |
buf.Fill(CEditableText::EParagraphDelimiter, aReplicas); |
|
2118 |
CPlainText::InsertL(documentLength, buf); |
|
2119 |
CleanupStack::PopAndDestroy(); // bb |
|
2120 |
} |
|
2121 |
// |
|
2122 |
if (IndexPresent()) |
|
2123 |
{ |
|
2124 |
TRAPD(ret, |
|
2125 |
iIndex->AppendParagraphL(iGlobalParaFormatLayer, iGlobalCharFormatLayer, aReplicas)); |
|
2126 |
if (ret != KErrNone) |
|
2127 |
{ |
|
2128 |
CPlainText::Delete(DocumentLength() - aReplicas, aReplicas); |
|
2129 |
User::Leave(ret); |
|
2130 |
} |
|
2131 |
SetHasChanged(ETrue); |
|
2132 |
} |
|
2133 |
||
2134 |
int new_length = DocumentLength() - documentLength; |
|
2135 |
iParserData->MergeRange(documentLength,0,new_length); |
|
2136 |
CallEditObserver(documentLength,new_length); |
|
2137 |
__TEST_INVARIANT; |
|
2138 |
||
2139 |
__ETEXT_WATCH_END(APPEND_PARAGRAPH); |
|
2140 |
} |