1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/textrendering/texthandling/stext/TXTINDEX.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,764 @@
1.4 +/*
1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#ifndef __TXTINDEX_H__
1.23 +#define __TXTINDEX_H__
1.24 +
1.25 +#include <e32std.h>
1.26 +#include <e32base.h>
1.27 +#include <txtmrtsr.h>
1.28 +#include <txtrich.h>
1.29 +#include "TXTSTD.H"
1.30 +
1.31 +// forward declarations
1.32 +class CParaAttribs;
1.33 +class CPicturePhrase;
1.34 +class RReadStream;
1.35 +class RWriteStream;
1.36 +class CStoreMap;
1.37 +class CStreamStore;
1.38 +class CPicture;
1.39 +class CCharFormatLayer;
1.40 +class CParaFormatLayer;
1.41 +class CRichText;
1.42 +class MPictureFactory;
1.43 +
1.44 +/**
1.45 +@internalComponent
1.46 +*/
1.47 +enum TRichTextStylePasteMode
1.48 + {
1.49 + EAddNewStyles,
1.50 + EConvertNewStyles,
1.51 + EIgnoreNewStyles
1.52 + };
1.53 +
1.54 +class TTextFragment
1.55 +/**
1.56 +Describes a fragment of text that does not conform to the ERA text model.
1.57 +@internalComponent
1.58 +*/
1.59 + {
1.60 +public:
1.61 + TTextFragment();
1.62 +public:
1.63 + TInt iLength; // Number of characters in text fragment
1.64 + TInt iPhraseCount; // Number of distinct phrases in text fragment.
1.65 + };
1.66 +
1.67 +
1.68 +class RPhraseAttribsEntry
1.69 +/**
1.70 +Provides a full description of a phrase.
1.71 +A phrase consists of a specified number of contiguous characters [the phrase length]
1.72 +of identical character format.
1.73 +Where a picture is included as text content, it is described by its own phrase.
1.74 +@internalComponent
1.75 +*/
1.76 + {
1.77 +public:
1.78 + enum {EPictureIndicator = -1};
1.79 + enum {EPicturePhraseLength = 1};
1.80 +public:
1.81 + RPhraseAttribsEntry();
1.82 + RPhraseAttribsEntry(CCharFormatLayer* aCharFormat, TInt aLength = 0); // Sets iLen to zero - empty text phrase
1.83 + RPhraseAttribsEntry(CPicturePhrase* aPicturePhrase); // Sets iLen to EPictureIndicator
1.84 + inline RPhraseAttribsEntry(const RPhraseAttribsEntry& aPhrase);
1.85 + void Discard();
1.86 + inline RPhraseAttribsEntry& operator=(const RPhraseAttribsEntry& aPhrase);
1.87 + //
1.88 + // Persist
1.89 + void ExternalizeL(RWriteStream& aStream) const;
1.90 + //
1.91 + // General enquiry
1.92 + inline TBool IsPicturePhrase() const;
1.93 + TBool IsIdentical(const RPhraseAttribsEntry& aPhrase) const;
1.94 + //
1.95 + // Getters
1.96 + inline TInt Length() const;
1.97 + CCharFormatLayer* CharFormat() const;
1.98 + CCharFormatLayer* ReleaseCharFormatLayerOwnership();
1.99 + TInt GetPictureSizeInTwips(TSize& aSize) const;
1.100 + TPictureHeader* PictureHeaderPtr() const;
1.101 + TPictureHeader PictureHeader() const;
1.102 + const CPicture* PictureHandleL(const MPictureFactory* aFactory,
1.103 + const MRichTextStoreResolver* aResolver,
1.104 + TInt aPos,
1.105 + MLayDoc::TForcePictureLoad aForceLoad) const;
1.106 + //
1.107 + // Setters
1.108 + void AdjustLength(TInt aIncrement);
1.109 + void SetLength(TInt aLength);
1.110 +private:
1.111 + void AssignAndRelease(const RPhraseAttribsEntry& aPhrase);
1.112 +private:
1.113 + TInt iLength; // No. of characters covered by this phrase
1.114 + union
1.115 + {
1.116 + CCharFormatLayer* iCharFormat; // *OWNED* format of this text phrase
1.117 + CPicturePhrase* iPicturePhrase; // *OWNED* pointer to picture phrase information
1.118 + };
1.119 + __DECLARE_TEST;
1.120 + };
1.121 +
1.122 +
1.123 +NONSHARABLE_CLASS(CPicturePhrase) : public CBase
1.124 +/**
1.125 +A low-level class providing a pointer to the character format layer for this picture phrase,
1.126 +and a pointer to a picture itself. (Which may be expressed in its persistent form).
1.127 +@internalComponent
1.128 +*/
1.129 + {
1.130 +public:
1.131 + static CPicturePhrase* NewL(const TPictureHeader& aPicHdr,
1.132 + TCharFormatX& aFormat,
1.133 + TCharFormatXMask& aMask,
1.134 + CCharFormatLayer* aCharBase,
1.135 + TBool& aPictureOwnershipTaken);
1.136 +
1.137 + static CPicturePhrase* NewL(const TPictureHeader& aPicHdr,
1.138 + CCharFormatLayer* aCharLayer,
1.139 + TBool& aPictureOwnershipTaken);
1.140 + ~CPicturePhrase();
1.141 +protected:
1.142 + CPicturePhrase(const TPictureHeader& aPicHdr,TBool& aPictureOwnershipTaken);
1.143 + CPicturePhrase(const TPictureHeader& aPicHdr, CCharFormatLayer* aCharLayer,TBool& aPictureOwnershipTaken);
1.144 + void ConstructL(TCharFormatX& aFormat, TCharFormatXMask& aMask, CCharFormatLayer* aCharBase);
1.145 +public:
1.146 + CCharFormatLayer* iCharFormat;
1.147 + TPictureHeader iPicHdr;
1.148 + };
1.149 +
1.150 +
1.151 +class TParaAttribsEntry
1.152 +/**
1.153 +Records the length of a paragraph (no. of characters).
1.154 +and references a CParaAttributes.
1.155 +@internalComponent
1.156 +*/
1.157 + {
1.158 +public:
1.159 + TParaAttribsEntry();
1.160 + TParaAttribsEntry(TInt aLength, CParaAttribs* aParaAttribs);
1.161 +public:
1.162 + TInt iLength; // Number of characters in the paragraph (paragraph delimiter inclusive).
1.163 + CParaAttribs* iParaAttribs; // Only references this, does not own it.
1.164 + };
1.165 +
1.166 +
1.167 +class TCurrentIndexRecords
1.168 +/**
1.169 +Packages current phrase & para records.
1.170 +@internalComponent
1.171 +*/
1.172 + {
1.173 +public:
1.174 + TCurrentIndexRecords();
1.175 +public:
1.176 + TParaAttribsEntry* iParaEntry;
1.177 + CParaAttribs* iParaAttribs;
1.178 + RPhraseAttribsEntry* iPhrase; // May be NULL.
1.179 + };
1.180 +
1.181 +
1.182 +
1.183 +class TLogicalPosition
1.184 +/**
1.185 +Locates the current cursor position within all aspects of the index.
1.186 +@internalComponent
1.187 +*/
1.188 + {
1.189 +public:
1.190 + TLogicalPosition();
1.191 + void Clear();
1.192 +public:
1.193 + TInt iDocPos; // Absolute document position.
1.194 + TInt iParaElement; // paragraph index
1.195 + TInt iParaElementOffset; // position from start of paragraph
1.196 + TInt iParaBasePhraseElement; // index of the first phrase in the paragraph
1.197 + TInt iPhraseElement;
1.198 + TInt iPhraseElementOffset;
1.199 + };
1.200 +
1.201 +
1.202 +
1.203 +NONSHARABLE_CLASS(CParaAttribs) : public CBase
1.204 +/**
1.205 +Describes the attributes that apply to the paragraph.
1.206 +*owns* an iParaFormat(Layer), and *owns* an iPhraseAttribsIndex
1.207 +or charFormatLayer.
1.208 +@internalComponent
1.209 +*/
1.210 + {
1.211 +public:
1.212 + enum TParaRefCount {EPrimeNonSharedCount, EPrimeSharedCount};
1.213 + enum {EPhraseIxGranularity = 1};
1.214 +public:
1.215 + // Create a CParaAttribs with constant character formatting.
1.216 + static CParaAttribs* NewL(const CParaFormatLayer* aParaLayer, const CCharFormatLayer* aCharLayer);
1.217 + // Create a CParaAttribs with specific character formatting.
1.218 + static CParaAttribs* NewL(const CParaFormatLayer* aParaLayer);
1.219 + static CParaAttribs* NewL(const CParaAttribs* aParaAttribs);
1.220 + void Release();
1.221 + void Release(TInt aCount);
1.222 + //
1.223 + // Utility functions
1.224 + inline TBool IsShared() const;
1.225 + TInt PhraseCount() const;
1.226 +protected:
1.227 + CParaAttribs();
1.228 + ~CParaAttribs();
1.229 + CParaAttribs* CopyParaFormatL();
1.230 +private:
1.231 +public:
1.232 + TDblQueLink link;
1.233 + TInt iRefCount; // Indicates re-use of this.
1.234 + CParaFormatLayer* iParaFormat;
1.235 + union
1.236 + {
1.237 + CCharFormatLayer* iCharFormat; // iRefCount>0 - a single shared phrase - constant char format.
1.238 + TInt iPhraseCount; // iRefCount==0 - the number of phrases in this para.
1.239 + };
1.240 + };
1.241 +
1.242 +
1.243 +//
1.244 +
1.245 +class TRtPasteContext
1.246 +/**
1.247 +Provides the context for pasting of pictures from a clipboard.
1.248 +@internalComponent
1.249 +*/
1.250 + {
1.251 +public:
1.252 + TRtPasteContext(const CStreamStore* aStore, const CParaFormatLayer* aGlobalParaLayer, const CCharFormatLayer* aGlobalCharLayer, const CStyleList* aStyleList);
1.253 +public:
1.254 + const CStreamStore* iStore; // the clipboard store
1.255 + const CParaFormatLayer* iGlobalParaLayer; // the global para layer of the target text document
1.256 + const CCharFormatLayer* iGlobalCharLayer; // the global char layer of the target text document
1.257 + const CStyleList* iStyleList; // style list is present
1.258 + TBool iParagraphStylesFlag; // ETrue indicates presence of inline style references in index data
1.259 + TBool iIncompleteParaFlag; // ETrue indicates the pasted text fragment has no final para delimiter
1.260 + TBool iApplyFormatToLastFlag; // ETrue indicates that para format should be applied to last text fragment
1.261 + TLogicalPosition iPastePos; // the character position at which the text is to be pasted
1.262 + TInt iParasPasted; // the number of paragraphs successfully pasted
1.263 + TInt iStylePasteMode;
1.264 + };
1.265 +
1.266 +
1.267 +
1.268 +class TIndexDeleteInfo
1.269 +/**
1.270 +Contains information pertaining to an index delete operation.
1.271 +Carries between a SetForDeleteL and a DeleteNow method call.
1.272 +@internalComponent
1.273 +*/
1.274 + {
1.275 +public:
1.276 + enum TDeleteType
1.277 + {
1.278 + EDeleteFromParagraph,
1.279 + EDeleteParagraph,
1.280 + ENonspecificDelete
1.281 + };
1.282 +public:
1.283 + TInt iStartPara;
1.284 + TInt iEndPara;
1.285 + TLogicalPosition iDeletePos;
1.286 + TInt iDeleteLength;
1.287 + TDeleteType iDeleteType;
1.288 + };
1.289 +
1.290 +
1.291 +class TRichTextMapEntry
1.292 +/**
1.293 +A utility class for patching references to persisted shared objects
1.294 +of the specified type.
1.295 +Code at the bottom of the header
1.296 +@internalComponent
1.297 +*/
1.298 + {
1.299 +public:
1.300 + TRichTextMapEntry(TInt aRefNumber, TAny* aItem);
1.301 + TRichTextMapEntry(TAny* aS, TAny* aT);
1.302 +public:
1.303 + union
1.304 + {// The source item - a reference to a persistent one, or the in-memory original.
1.305 + TInt iRefNumber;
1.306 + TAny* iS; // only used in appending one rich text to another
1.307 + };
1.308 + TAny* iT; // the newly created/restored item - the target
1.309 + };
1.310 +
1.311 +
1.312 +template <class T>
1.313 +class CRichTextStoreMap : public CBase
1.314 +/**
1.315 +//
1.316 +A utility class for patching references to persisted shared objects
1.317 +of the specified type.
1.318 +Code at the bottom of the header
1.319 +Used for clipboarding to i) patch references to paragraph styles
1.320 +ii) patch references to shared paragraph formats
1.321 +and also used in the appending of one rich text to another.
1.322 +@internalComponent
1.323 +*/
1.324 + {
1.325 +public:
1.326 + static CRichTextStoreMap* NewLC(TInt aMaximumCapacity);
1.327 + ~CRichTextStoreMap();
1.328 + //
1.329 + void Bind(TInt aRefNumber, T* aItem);
1.330 + void Bind(T* aS, T* aT);
1.331 + //
1.332 + T* Item(TInt aRefNo)const;
1.333 + T* Item(const T* aS)const;
1.334 + inline const TRichTextMapEntry& At(TInt aIndex)const;
1.335 + //
1.336 + inline TInt Count()const;
1.337 + //
1.338 + void __DbgTestInvariant()const;
1.339 +private:
1.340 + void ConstructL(TInt aMaximumCapacity);
1.341 +private:
1.342 + CArrayFixFlat<TRichTextMapEntry>* iMap;
1.343 +public:
1.344 + TInt iCapacity;
1.345 + };
1.346 +
1.347 +
1.348 +class TGlobalLayerInfoAppend
1.349 +/**
1.350 +@internalComponent
1.351 +*/
1.352 + {
1.353 +public:
1.354 + TGlobalLayerInfoAppend();
1.355 + TGlobalLayerInfoAppend(const CParaFormatLayer* aAggParaFormatLayer, const CCharFormatLayer* aAggCharFormatLayer,
1.356 + const CParaFormatLayer* aComParaFormatLayer, const CCharFormatLayer* aComCharFormatLayer);
1.357 +public:
1.358 + const CParaFormatLayer* iAggParaFormatLayer;
1.359 + const CCharFormatLayer* iAggCharFormatLayer;
1.360 + const CParaFormatLayer* iComParaFormatLayer;
1.361 + const CCharFormatLayer* iComCharFormatLayer;
1.362 + };
1.363 +
1.364 +const TInt KSingleParaGranularity = 1;
1.365 +const TInt KMultiParaGranularity = 16;
1.366 +const TInt KSmallPhraseGranularity = 5;
1.367 +const TInt KLargePhraseGranularity = 16;
1.368 +const TUint32 KPhraseSplit = 0x01;
1.369 +const TUint32 KSpecificMarkupInternalized = 0x04;
1.370 +
1.371 +/**
1.372 +@internalComponent
1.373 +*/
1.374 +typedef CRichTextStoreMap<CParagraphStyle> CStyleMap;
1.375 +typedef CRichTextStoreMap<CParaAttribs> CParaAttribsMap;
1.376 +
1.377 +/** Stores the paragraph and character formatting information for CRichText.
1.378 +
1.379 +iParaIx stores the paragraph formatting, one entry per paragraph. Paragraphs
1.380 +are pieces of text delimited by the Unicode Paragraph Delimiter character
1.381 +U+2029.
1.382 +
1.383 +iPhraseIx stores the character formatting.
1.384 +
1.385 +Paragraph formatting information can be shared or not shared between
1.386 +paragraphs. Sharing is only permitted for paragraphs that do not have any
1.387 +character formatting applied to their text.
1.388 +
1.389 +A phrase is a run of consistently formatted characters. A phrase may only
1.390 +contain a paragraph delimiter in its last character. In other words, phrases
1.391 +are not permitted to span paragraph boundaries.
1.392 +
1.393 +iPhraseIx only stores formatting for the non-shared paragraphs. Therefore
1.394 +adding up the lengths of all the phrases in iPhraseIx will yield the sum of the
1.395 +non-shared paragraphs stored in iParaIx.
1.396 +
1.397 +Note that the "nominal" paragraph delimiter at the end of the text which is not
1.398 +stored by CRichText is covered by both character and paragraph formatting. So
1.399 +the length of the final paragraph and final phrase (if appropriate) includes
1.400 +this character.
1.401 +
1.402 +@internalComponent
1.403 +*/
1.404 +class CRichTextIndex : public CBase
1.405 + {
1.406 +public:
1.407 + static CRichTextIndex* NewL(const CParaFormatLayer* aGlobalParaLayer, const CCharFormatLayer* aGlobalCharLayer,
1.408 + const CRichText& aText,
1.409 + TInt aParaGran,TInt aPhraseGran);
1.410 + static CRichTextIndex* NewL(const CStreamStore& aStore, TStreamId aId,
1.411 + const CParaFormatLayer* aGlobalParaLayer,
1.412 + const CCharFormatLayer* aGlobalCharLayer,
1.413 + const CRichText& aText);
1.414 + ~CRichTextIndex();
1.415 + //
1.416 + // Store/Restore functions - Deferred loading of pictures
1.417 + TStreamId StoreMarkupL(CStreamStore& aStore, const CStyleList* aStyleList) const;
1.418 + //
1.419 + void RestoreL(const CStreamStore& aStore, TStreamId aId,
1.420 + const CParaFormatLayer* aGlobalParaLayer, const CCharFormatLayer* aGlobalCharLayer,
1.421 + const CStyleList* aStyleList);
1.422 + //
1.423 + void StorePicturesL(CStreamStore& aStore, CStoreMap& aMap) const;
1.424 + void StorePicturesL(CStreamStore& aStore, CStoreMap& aMap, TInt aPos, TInt aLength) const;
1.425 + void DetachFromStoreL(CPicture::TDetach aDegree, TInt aPos, TInt aLength);
1.426 + void ExternalizeL(RWriteStream& aStream) const;
1.427 + void InternalizeL(RReadStream& aStream, const CParaFormatLayer* aGlobalParaLayer, const CCharFormatLayer* aGlobalCharLayer,
1.428 + const CStyleList* aStyleList);
1.429 + //
1.430 + // 3n Persist functions
1.431 + TBool HasMarkupData(const CFormatLayer* aGlobalParaFormatLayer) const;
1.432 + TPictureHeader PictureHeader(TInt aPos) const;
1.433 + TPictureHeader* PictureHeaderPtr(TInt aPos);
1.434 + //
1.435 + // Undo/CutPaste
1.436 + void CopyToStreamL(RWriteStream& aStream, TInt aPos, TInt aLength, TBool aCopyStyles) const;
1.437 + void PasteFromStreamL(const CStreamStore& aStore, RReadStream& aStream, TInt aPos, CParagraphStyle::TStylePasteMode aStylePasteMode, const CParaFormatLayer* aGlobalParaLayer, const CCharFormatLayer* aGlobalCharLayer);
1.438 + //
1.439 + // Content modifier functions
1.440 + void Reset(const CParaFormatLayer& aNormalParagraphStyle);
1.441 + void InsertL(TInt aPos, const TDesC& aBuf, const CParaFormatLayer& aGlobalParaFormatLayer);
1.442 + void InsertL(TInt aPos, const TPictureHeader& aPicHdr, TBool& aPictureOwnershipTaken);
1.443 + void SetForDeleteL(TIndexDeleteInfo& aInfo, TInt aPos, TInt aLength);
1.444 + TBool DeleteNow(TIndexDeleteInfo& aInfo);
1.445 + void DeleteFromParagraph(TInt aPos, TInt aLength);
1.446 + TBool DeleteParagraph(TInt aPos, TInt aLength);
1.447 + void Normalize(TInt aPos);
1.448 + //
1.449 + // Insert a new paragraph at position aPos, based on the 'Normal' global defaults.
1.450 + // Any explicit paragraph/character formatting is carried forward into this paragraph.
1.451 + void InsertParagraphL(TInt aPos, const CParaFormatLayer& aGlobalParaFormatLayer);
1.452 + //
1.453 + // Special behaviour format modifier functions.
1.454 + TBool InsertCharFormatIsActive();
1.455 + void SetInsertCharFormatL(const TCharFormatX& aFormat, const TCharFormatXMask& aMask, TInt aPos);
1.456 + void NewInsertCharFormatL(const TCharFormatX& aFormat,
1.457 + const TCharFormatXMask& aMask, TInt aPos);
1.458 + void UpdateInsertCharFormatL(const TCharFormatX& aFormat,
1.459 + const TCharFormatXMask& aMask);
1.460 + CCharFormatLayer* GetCurrentInsertCharFormat();
1.461 + void CancelInsertCharFormat();
1.462 + TBool DelSetInsertCharFormatL(TInt aPos, TInt aLength);
1.463 + //
1.464 + // Laydoc interface support
1.465 + void GetParagraphFormatL(CParaFormat* aFormat,TInt aPos) const;
1.466 + TInt GetChars(TCharFormatX& aFormat,TInt aPos) const;
1.467 + TInt GetPictureSizeInTwips(TSize& aSize, TInt aPos) const;
1.468 + CPicture* PictureHandleL(TInt aPos, MLayDoc::TForcePictureLoad aForceLoad) const;
1.469 + //
1.470 + // FormatText interface support
1.471 + void GetParaFormatL(CParaFormat* aFormat, TParaFormatMask& aUndeterminedMask, TInt aPos, TInt aLength,
1.472 + CParaFormat::TParaFormatGetMode aMode) const;
1.473 + void ApplyParaFormatL(const CParaFormat* aFormat, const TParaFormatMask& aMask, TInt aPos, TInt aLength);
1.474 + void GetCharFormat(TCharFormatX& aFormat, TCharFormatXMask& aMask,TInt aPos, TInt aLength) const;
1.475 + void ApplyCharFormatL(const TCharFormatX& aFormat, const TCharFormatXMask& aMask, TInt aPos, TInt aLength, TBool aRemoveSpecific = EFalse);
1.476 + void RemoveSpecificCharFormatL(TInt aPos, TInt aLength);
1.477 + void RemoveSpecificParaFormatL(TInt aPos, TInt aLength);
1.478 + //
1.479 + //
1.480 + void GetSpecificCharFormat(TCharFormatX& aFormat, TCharFormatXMask& aMask, TInt aPos) const;
1.481 + void GetSpecificCharFormatDirection(TCharFormatX& aFormat, TCharFormatXMask& aMask,
1.482 + TInt aPos, TBool aGetLeft) const;
1.483 + //
1.484 + // Paragraph style implementation
1.485 + void ApplyParagraphStyleL(const CParagraphStyle& aStyle, TInt aPos, TInt aLength, const CCharFormatLayer* aCharStyleNormal, CParagraphStyle::TApplyParaStyleMode aMode);
1.486 + void NotifyStyleChangedL(const CParagraphStyle* aTo, const CParagraphStyle* aFrom, const CParaFormatLayer& aGlobalParaFormatLayer, const CCharFormatLayer& aGlobalCharFormatLayer);
1.487 + const CParaFormatLayer* ParagraphStyle(TBool& aStylesChangesOverRange, TInt aPos, TInt aLength) const;
1.488 + //
1.489 + // Utility functions
1.490 + inline TInt ParagraphCount() const;
1.491 + TInt CharPosOfParagraph(TInt& aLength, TInt aParaOffset) const;
1.492 + TInt ParagraphNumberForPos(TInt& aPos) const;
1.493 + inline void SetSpecificMarkupInternalized(TBool aBool);
1.494 + inline TBool SpecificMarkupInternalized() const;
1.495 + void DocumentChanged()const;
1.496 + //
1.497 + // Speciality functions
1.498 + void AppendTakingSolePictureOwnershipL(const CRichTextIndex* aSource, const TGlobalLayerInfoAppend& aGlobalLayerInfo);
1.499 + void AppendParagraphL(const CParaFormatLayer* aGlobalParaFormatLayer, const CCharFormatLayer* aGlobalCharFormatLayer,
1.500 + TInt aReplicas);
1.501 + TInt SharedParaCount(const CRichTextIndex* aSource) const;
1.502 + void GetSpecificParagraphFormatL(CParaFormat* aFormat,
1.503 + TParaFormatMask& aMask,
1.504 + TInt aPos) const;
1.505 +private:
1.506 + enum TScanToPositionMode {EScanToPositionMatchLeft, EScanToPositionAbsolute};
1.507 + enum {EInsertCharFormatReset = -1};
1.508 + enum TPositionOrPhrase {EPositionOnly, EFollowingPhrase};
1.509 +private:
1.510 + CRichTextIndex(const CRichText& aText);
1.511 + void ConstructL(const CParaFormatLayer* aGlobalParaFormat, const CCharFormatLayer* aGlobalCharFormat, TInt aParaGran, TInt aPhraseGran);
1.512 + //
1.513 + // Persistence/Copy,Paste
1.514 + void InternalizeRtiHeaderL(RReadStream& aStream, TRtPasteContext& aContext);
1.515 + void ExternalizeRtiHeaderL(RWriteStream& aStream, const TLogicalPosition& aEnd, const CStyleList* aStyleList) const;
1.516 + void ExternalizeReferencedStylesL(RWriteStream& aStream, const TLogicalPosition& aStart, const TLogicalPosition& aEnd) const;
1.517 + void InternalizeSharedFormatsL(RReadStream& aStream, const TRtPasteContext& aContext);
1.518 + void ExternalizeSharedFormatsL(RWriteStream& aStream, const TLogicalPosition& aStart, const TLogicalPosition& aEnd, const CStyleList* aStyleList) const;
1.519 + void InternalizeParaIxL(RReadStream& aStream, const TRtPasteContext& aContext);
1.520 + void ExternalizeParagraphFormatL(RWriteStream& aStream, const CParaFormatLayer& aSpecificParaFormatLayer, const CStyleList* aStyleList) const;
1.521 + CParaFormatLayer* InternalizeParagraphFormatL(RReadStream& aStream, const TRtPasteContext& aContext);
1.522 + CParaFormatLayer* PasteParagraphFormatL(RReadStream& aStream, const TRtPasteContext& aContext, CStyleMap* styleMap);
1.523 + RPhraseAttribsEntry* ExternalizeParaIxL(RWriteStream& aStream, const TLogicalPosition& aStart,
1.524 + const TLogicalPosition& aEnd, const CStyleList* aStyleList) const;
1.525 + void InternalizePhraseIxL(RReadStream& aStream, const CCharFormatLayer* aGlobalCharFormat);
1.526 + void ExternalizePhraseIxL(RWriteStream& aStream) const;
1.527 + void ExternalizePhraseIxL(RWriteStream& aStream,
1.528 + const TLogicalPosition& aStartPos,
1.529 + TLogicalPosition& aEndPos,
1.530 + const RPhraseAttribsEntry* aVirtualTrailingText) const;
1.531 + inline void ExternalizePhraseCountL(RWriteStream& aStream, TInt aPhraseCount) const;
1.532 + void ExternalizePhrasesL(RWriteStream& aStream, TInt aStart, TInt aPhraseCount, const RPhraseAttribsEntry* aVirtualPhrase = NULL) const;
1.533 + TInt MarkStyleRegister(TDes8& aBuf, TInt aStartPara, TInt aEndPara) const;
1.534 + TInt MarkRegister(TDes8& aBuf, TInt aStartPara, TInt aEndPara) const;
1.535 + void GenerateAllPhraseLinksL();
1.536 + void GeneratePhraseLink(CCharFormatLayer* aPhraseCharFormatLayer, const CParaFormatLayer* aBase);
1.537 + void ExternalizeItemsPresentInStyleRegisterL(RWriteStream& aStream, TInt aRefStyleCount, const TDes8& aBuf) const;
1.538 + void ExternalizeItemsPresentInRegisterL(RWriteStream& aStream, TInt aParaCount, const TDes8& aBuf, const CStyleList* aStyleList) const;
1.539 + CParaAttribs* SharedParaAttribs(TUint8 aOrdinal);
1.540 + TUint8 RefNum(const CParaAttribs* aParaAttribs) const;
1.541 + //
1.542 + // Copy,Paste
1.543 + void PasteStylesL(RReadStream& aStream, CStyleMap& aMap, const TRtPasteContext& aContext);
1.544 + void PasteSharedFormatsL(RReadStream& aStream, CParaAttribsMap& aMap, const TRtPasteContext& aContext, CStyleMap* aStyleMap);
1.545 + void ImposeCharacterStyleL(CCharFormatLayer** aCharLayer);
1.546 + void PasteIxL(RReadStream& aStream, TRtPasteContext& aContext, const CParaAttribsMap& aMap, CStyleMap* aStyleMap/*,CParaAttribs* aSecondReserved*/);
1.547 + TInt PasteParaIxL(RReadStream& aStream, TRtPasteContext& aContext, TInt aCompleteParaCount, const CParaAttribsMap& aMap, RPhraseAttribsEntry*& aFirstParaVirtualPhrase, CStyleMap* aStyleMap);
1.548 + TParaAttribsEntry DoPasteIntoParaL(RReadStream& aStream, const CParaAttribsMap& aMap, const TRtPasteContext& aContext, CStyleMap* aStyleMap);
1.549 + TParaAttribsEntry DoPasteFirstIntoParaL(RReadStream& aStream, const CParaAttribsMap& aMap, const TRtPasteContext& aContext, RPhraseAttribsEntry*& aFirstParaVirtualPhrase, CStyleMap* aStyleMap);
1.550 + void DoPasteCleanup(TLogicalPosition& aNormalizePos, CParaAttribs* aReclaimed);
1.551 + TTextFragment GetTextFragmentL(RReadStream& aStream);
1.552 + void PastePhraseIxL(RReadStream& aStream, TRtPasteContext& aContext, const RPhraseAttribsEntry* aFirstParaVirtualPhrase);
1.553 + void DoPastePhraseL(RReadStream& aStream, const TRtPasteContext& aContext, RPhraseAttribsEntry& aPhrase);
1.554 + void RbPasteSharedFormatsL(TInt aRet);
1.555 + void NormalizeSharedList();
1.556 + void RbRemoveInsertedParaAttribsEntries(TInt aFirstParaInsertPos, TInt aInsertedParaCount);
1.557 + void RbPasteParaIxL(const TLogicalPosition& aPastePos, TInt aParaCount, TInt aRet);
1.558 + void RbPastePhraseIxL(const TLogicalPosition& aPos,TInt aPhraseCount, TInt aRet);
1.559 + void RbRemoveInsertedPhraseAttribsEntries(TInt aFirstPhraseInsertPos, TInt aInsertedPhraseCount);
1.560 + TUint8 ReadTUint8CountL(RReadStream& aStream) const;
1.561 + //
1.562 + // General utility
1.563 + void DoSoloInsertL(TInt aPos, TInt aLength);
1.564 + void ScanToPosition(TInt aCharPos, TScanToPositionMode aMode, TLogicalPosition* aLastUsed=NULL); // Reset the logical position to the passed document position.
1.565 + inline TInt PhraseCount() const;
1.566 + TBool FirstPhraseOfParagraph() const; // Interrogates current iPos record.
1.567 + TInt CurrentPhraseLength() const; // Encapsulates constant/specific character formatting.
1.568 + TInt CurrentPhraseOffset() const; // Encapsulates constant/specific character formatting.
1.569 + void CheckForUndetermined(const TCharFormatX& aFormatA, const TCharFormatX& aFormatB, TCharFormatXMask& aVaries) const;
1.570 + void GetCurrentRecords(TCurrentIndexRecords& aRecord) const;
1.571 + void GetPhraseFormat(TCurrentIndexRecords& aCurrent, TCharFormatX& aFormat, TCharFormatXMask& aMask, CCharFormatLayer*& aCharBase) const;
1.572 + TInt OwningParagraph(TInt aPos, TLogicalPosition* aLastUsed = NULL) const;
1.573 + TBool MergePhrases(TInt aPos);
1.574 + TBool MergePhrases(const TLogicalPosition& aPos);
1.575 + TBool DeleteInsertCharFormat();
1.576 + void ConsolidateAt(TInt aPosition, TPositionOrPhrase aPositionOrPhrase);
1.577 + void RemoveFromPhraseIx(TInt aPos, TInt aCount = 1);
1.578 + void SplitPhraseL(TInt aSplitPos);
1.579 + void SplitPhraseL(TInt aPhraseElement, TInt aPhraseOffset, CParaAttribs* aParaAttribs);
1.580 + void DoSplitPhraseL(RPhraseAttribsEntry& aCurrentPhrase, TInt aPhraseOffset, CParaAttribs* aParaAttribs);
1.581 + TUint8 SharedParaAttribsEntryCountL() const;
1.582 + void ModifySpecificFormatting(CParaFormatLayer& aPl, CCharFormatLayer& aCl, CParagraphStyle::TApplyParaStyleMode aMode);
1.583 +//
1.584 +// support for applycharformat
1.585 + static void ApplyCharFormatCleanup(TAny* aPtr);
1.586 + void ApplyCharFormatRollback();
1.587 + TInt MergePhrases(TInt aPhrase, RPhraseAttribsEntry& aPhraseAttribs, CParaAttribs& aParaAttribs);
1.588 + void SplitPhraseL(TInt aPhrase, TInt anOffset, RPhraseAttribsEntry& aPhraseAttribs, CParaAttribs& aParaAttribs);
1.589 + void Share(TParaAttribsEntry& aParaEntry, TInt aPhrase);
1.590 + //
1.591 + // Specific rollback
1.592 + void RbInsertPicture(CParaAttribs* aGoodParaAttribs);
1.593 + //
1.594 + // General implementation
1.595 + void NormalizeNow(const TLogicalPosition& aNormalizePos);
1.596 + TBool DeleteParagraphText(TInt& aLength);
1.597 + TBool DoDeleteFromParagraph(const TIndexDeleteInfo& aInfo);
1.598 + void TidyAfterDelete(const TIndexDeleteInfo& aInfo);
1.599 + CParaAttribs* ReserveCellL();
1.600 + CParaAttribs* ReserveCellLC();
1.601 + void DoNewInsertCharFormatL(const TCharFormatX& aFormat,
1.602 + const TCharFormatXMask& aMask, CCharFormatLayer* aBasedOn,
1.603 + CParaAttribs* aParaAttribs);
1.604 + TInt ParaLengthFromBuffer(TDesC& aBuf) const;
1.605 + inline const CStreamStore* ResolvedStreamStore(TInt aPos) const;
1.606 + //
1.607 + // Agenda functions
1.608 + void AppendSharedFormatsL(CParaAttribsMap& aMap, const CRichTextIndex* aSource, const TGlobalLayerInfoAppend& aGlobalLayerInfo);
1.609 + void AppendParaIndexL(const CRichTextIndex* aSource, const TGlobalLayerInfoAppend& aGlobalLayerInfo);
1.610 + void AppendPhraseIndexL(const CRichTextIndex* aSource, const TGlobalLayerInfoAppend& aGlobalLayerInfo);
1.611 + //
1.612 + // Shared list management utilities
1.613 + CParaAttribs* RequestReclaimShareL(CParaAttribs* aParaAttribs, TParaAttribsEntry* aParaEntry);
1.614 + CParaAttribs* RequestShareL(CParaAttribs* aParaAttribs, CCharFormatLayer* aCharFormat = NULL, CParaAttribs* aReservedCell = NULL);
1.615 + CParaAttribs* GetParaAttribsL(const CParaFormatLayer* aParaFormat, const CCharFormatLayer* aCharFormat, CParaAttribs* aReservedCell = NULL);
1.616 + CParaAttribs* RequestShare(const TLogicalPosition& aLogicalPosition);
1.617 + CParaAttribs* GetParaAttribs(const TLogicalPosition& aLogicalPosition);
1.618 + CParaAttribs* GetParaAttribs(CParaAttribs* aParaAttribs, CCharFormatLayer& aCharFormatLayer);
1.619 + CParaAttribs* FindSharedParaAttribs(const CParaFormatLayer& aParaFormatLayer, const CCharFormatLayer& aCharFormatLayer);
1.620 + void RebalanceIndex();
1.621 + void SplitParagraphAtPastePosL(TLogicalPosition& aPastePos, TLogicalPosition& aNewPos,
1.622 + const CParaFormatLayer& aGlobalParaFormatLayer);
1.623 + //
1.624 + inline void SetPhraseSplit(TBool aBool);
1.625 + inline TBool PhraseSplit() const;
1.626 +private:
1.627 + const CRichText& iText; // backward reference to owning rich text.
1.628 + TUint32 iFlags;
1.629 + TInt iPendingNewPhrasePos; // When *INSERTSTATE* is active, this is used to place the zero-length phrase.
1.630 + CParaAttribs* iRollbackParaAttribsHandle;
1.631 + __MUTABLE TDblQue<CParaAttribs> iSharedParaQueHead;
1.632 + __MUTABLE TLogicalPosition iLastUsed;
1.633 + CCharFormatLayer* iLastCharacterStyle;
1.634 +public:
1.635 + CArrayFixSeg<TParaAttribsEntry>* iParaIx; // One entry per paragraph
1.636 + CArrayFixSeg<RPhraseAttribsEntry>* iPhraseIx; // One entry per phrase in the rich text
1.637 + __MUTABLE TLogicalPosition iPos;
1.638 + TInt iPictureCount; // a count of the number of pictures contained by this text
1.639 +
1.640 + __DECLARE_TEST;
1.641 + };
1.642 +
1.643 +////////////////////////////////////////
1.644 +
1.645 +template <class T>
1.646 +void CRichTextStoreMap<T>::__DbgTestInvariant() const
1.647 +// Provides class invariants. Explanations below:
1.648 +//
1.649 + {
1.650 +#ifdef _DEBUG
1.651 + TInt count = Count();
1.652 + for (TInt ii = 0; ii < count; ii++)
1.653 + {
1.654 + TInt ref = (*iMap)[ii].iRefNumber;
1.655 + __ASSERT_DEBUG(ref > 0, User::Invariant());
1.656 + }
1.657 +#endif
1.658 + }
1.659 +
1.660 +
1.661 +template <class T>
1.662 +CRichTextStoreMap<T>* CRichTextStoreMap<T>::NewLC(TInt aMaximumCapacity)
1.663 +// Return a handle to a new instance of this class.
1.664 +//
1.665 + {
1.666 + CRichTextStoreMap* self = new(ELeave) CRichTextStoreMap();
1.667 + CleanupStack::PushL(self);
1.668 + self->ConstructL(aMaximumCapacity);
1.669 + return self;
1.670 + }
1.671 +
1.672 +
1.673 +
1.674 +template <class T>
1.675 +void CRichTextStoreMap<T>::ConstructL(TInt aMaximumCapacity)
1.676 +//
1.677 +//
1.678 + {
1.679 + if (aMaximumCapacity > 0)
1.680 + {
1.681 + iMap = new(ELeave) CArrayFixFlat<TRichTextMapEntry>(aMaximumCapacity);
1.682 + iMap->SetReserveL(aMaximumCapacity); // never need to allocate memory
1.683 + }
1.684 + iCapacity = aMaximumCapacity;
1.685 + }
1.686 +
1.687 +
1.688 +template <class T>
1.689 +CRichTextStoreMap<T>::~CRichTextStoreMap()
1.690 +//
1.691 +//
1.692 + {delete iMap;}
1.693 +
1.694 +
1.695 +template <class T>
1.696 +void CRichTextStoreMap<T>::Bind(TInt aRef, T* aT)
1.697 +//
1.698 +//
1.699 + {
1.700 + __TEST_INVARIANT;
1.701 + __ASSERT_ALWAYS(Count() <= iCapacity, Panic(ESharedFormatsMapOverFlow));
1.702 +
1.703 + TRichTextMapEntry entry(aRef, aT);
1.704 + iMap->AppendL(entry); // will not fail: we have reserved the space
1.705 +
1.706 + __TEST_INVARIANT;
1.707 + }
1.708 +
1.709 +
1.710 +
1.711 +template <class T>
1.712 +void CRichTextStoreMap<T>::Bind(T* aS, T* aT)
1.713 +//
1.714 +//
1.715 + {
1.716 + __TEST_INVARIANT;
1.717 + __ASSERT_ALWAYS(Count() <= iCapacity, Panic(ESharedFormatsMapOverFlow));
1.718 +
1.719 + TRichTextMapEntry entry(aS, aT);
1.720 + iMap->AppendL(entry); // will not fail: we have reserved the space
1.721 +
1.722 + __TEST_INVARIANT;
1.723 + }
1.724 +
1.725 +
1.726 +template <class T>
1.727 +T* CRichTextStoreMap<T>::Item(TInt aRef) const
1.728 +//
1.729 +//
1.730 + {
1.731 + TInt count = Count();
1.732 + if (count > 0)
1.733 + {
1.734 + const TRichTextMapEntry* entry = &(*iMap)[0];
1.735 + for (const TRichTextMapEntry* end = entry + count; entry < end; entry++)
1.736 + {
1.737 + if (entry->iRefNumber == aRef)
1.738 + return (T*)entry->iT;
1.739 + }
1.740 + }
1.741 + return NULL;
1.742 + }
1.743 +
1.744 +
1.745 +template <class T>
1.746 +T* CRichTextStoreMap<T>::Item(const T* aS) const
1.747 +//
1.748 +//
1.749 + {
1.750 + TInt count = Count();
1.751 + if (count > 0)
1.752 + {
1.753 + const TRichTextMapEntry* entry = &(*iMap)[0];
1.754 + for (const TRichTextMapEntry* end = entry + count; entry < end; entry++)
1.755 + {
1.756 + if (entry->iS == (TAny*)aS)
1.757 + return (T*)entry->iT;
1.758 + }
1.759 + }
1.760 + return NULL;
1.761 + }
1.762 +
1.763 +
1.764 +#include "TXTINDEX.INL"
1.765 +
1.766 +
1.767 +#endif