1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __FLDSET_H__ |
|
17 #define __FLDSET_H__ |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <e32base.h> |
|
21 #include <fldinfo.h> |
|
22 #include <fldbase.h> |
|
23 #include <fldbltin.h> |
|
24 |
|
25 // |
|
26 // Classes declared in this file |
|
27 class CTextFieldSet; |
|
28 // |
|
29 // Classes referenced |
|
30 class RReadStream; |
|
31 class RWriteStream; |
|
32 class TTextFieldEntry; |
|
33 class CStreamStore; |
|
34 class CStoreMap; |
|
35 class TRollbackInfo; |
|
36 |
|
37 /** |
|
38 @internalComponent |
|
39 */ |
|
40 const TInt KFieldArrayGranularity=1; |
|
41 |
|
42 |
|
43 class CTextFieldSet : public CBase |
|
44 /** |
|
45 The engine that keeps the field table up to date |
|
46 @internalComponent |
|
47 */ |
|
48 { |
|
49 public: |
|
50 enum {ENoPasteLimit=-1}; |
|
51 public: |
|
52 IMPORT_C static CTextFieldSet* NewL(TInt aDocumentLength=0); |
|
53 IMPORT_C static CTextFieldSet* NewL(const MTextFieldFactory* aFactory,const CStreamStore& aStore,TStreamId aStreamId); |
|
54 IMPORT_C ~CTextFieldSet(); |
|
55 // |
|
56 // Factory functions |
|
57 IMPORT_C void SetFieldFactory(MTextFieldFactory* aFactory); |
|
58 IMPORT_C MTextFieldFactory* FieldFactory()const; |
|
59 // |
|
60 IMPORT_C void Reset(); // removes all fields from the array and reinitialises field array |
|
61 // |
|
62 // Persistence |
|
63 IMPORT_C TStreamId StoreL(CStreamStore& aStore)const; |
|
64 IMPORT_C void RestoreL(const CStreamStore& aFieldStore,TStreamId aStreamId); |
|
65 // |
|
66 // Component persistence |
|
67 IMPORT_C void StoreFieldsL(CStreamStore& aStore,CStoreMap& aMap)const; |
|
68 IMPORT_C void RestoreFieldsL(const CStreamStore& aFieldStore); |
|
69 // |
|
70 // Headstream persistence |
|
71 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
72 IMPORT_C void ExternalizeL(RWriteStream& aStream)const; |
|
73 // Cut/Paste |
|
74 IMPORT_C TStreamId CopyToStoreL(CStreamStore& aStore,TInt aPos,TInt aLength)const; |
|
75 IMPORT_C void CopyComponentsL(CStreamStore& aStore,CStoreMap& aMap,TInt aPos,TInt aLength)const; |
|
76 IMPORT_C void CopyToStreamL(RWriteStream& aStream,TInt aPos,TInt aLength)const; |
|
77 IMPORT_C void PasteFromStoreL(const CStreamStore& aFieldStore,TStreamId aStreamId,TInt aPos,TInt aMaxLen=ENoPasteLimit); |
|
78 IMPORT_C void PasteComponentsL(const CStreamStore& aFieldStore,TInt aPos); |
|
79 IMPORT_C void PasteFromStreamL(RReadStream& aStream,TInt aPos,TInt aMaxLen=ENoPasteLimit); |
|
80 // Insert/Remove field |
|
81 IMPORT_C CTextField* NewFieldL(TUid aFieldType); |
|
82 IMPORT_C TInt InsertFieldL(TInt aPos,CTextField* aField,TUid aFieldType); // inserts a field (including text) into doc (returns error num if it fails) |
|
83 IMPORT_C TInt RemoveField(TInt aPos); // remove the field aPos is in |
|
84 IMPORT_C TInt NewFieldValueL(HBufC*& aBuf, TInt aPos); // returns new value of the field in aBuf (or returns false if aPos not in field) |
|
85 // Update field set |
|
86 IMPORT_C void NotifyInsertion(TInt aPos, TInt aNumberAdded); |
|
87 IMPORT_C void NotifyDeletion(TInt aPos, TInt aNumberRemoved); |
|
88 IMPORT_C void NotifyFieldUpdate(TInt aPos, TInt aNewFieldValueLength); |
|
89 // Utilities |
|
90 IMPORT_C TInt FieldCount() const; // returns total number of fields in document |
|
91 IMPORT_C TInt CharCount() const; // returns num characters in the document (according to fields) |
|
92 IMPORT_C TBool FindFields(TInt aPos) const; // Returns ETrue if aPos is in a field |
|
93 IMPORT_C TBool FindFields(TFindFieldInfo& aInfo,TInt aPos,TInt aRange=0) const; // finds num fields at least partly in range. Returns true if aPos is in field, and returns info on the first field in aRange |
|
94 IMPORT_C const CTextField* TextField(TInt aPos)const; |
|
95 // Rollback |
|
96 IMPORT_C void RollbackPaste(); // call to carry out rollback if a paste goes wrong |
|
97 protected: |
|
98 CTextFieldSet(); |
|
99 void ConstructL(TInt aDocumentLength); |
|
100 void ConstructL(const CStreamStore& aFieldStore,TStreamId aStreamId); |
|
101 private: |
|
102 // persistence |
|
103 void StoreFieldsL(CStreamStore& aStore,CStoreMap& aMap,CArrayFixSeg<TTextFieldEntry>* aArray)const; |
|
104 void DoRestoreL(const CStreamStore& aFieldStore,TStreamId aStreamId); |
|
105 void DoRestoreFieldsL(CArrayFixSeg<TTextFieldEntry>* aArray,const CStreamStore& aFieldStore,TInt aStartIndex=0); |
|
106 void InternalizeL(CArrayFixSeg<TTextFieldEntry>* aArray,RReadStream& aStream); |
|
107 void ExternalizeL(RWriteStream& aStream,CArrayFixSeg<TTextFieldEntry>* aArray)const; |
|
108 void DoPasteL(CArrayFixSeg<TTextFieldEntry>* aSourceArray,TInt aPos); |
|
109 // utility functions |
|
110 void AddInitialFieldEntryL(CArrayFixSeg<TTextFieldEntry>* aArray,TInt aDocumentLength); // used to initialise the array |
|
111 void InsertEntryL(TInt aIndex,TTextFieldEntry& aEntry); // inserts into iFieldArray |
|
112 void InsertEntryL(TInt aIndex,TTextFieldEntry& aEntry,CArrayFixSeg<TTextFieldEntry>* aArray); |
|
113 void AppendEntryL(TTextFieldEntry& aEntry); // appends into iFieldArray |
|
114 void AppendEntryL(TTextFieldEntry& aEntry,CArrayFixSeg<TTextFieldEntry>* aArray); |
|
115 void CopyToArrayL(CArrayFixSeg<TTextFieldEntry>* aArray,TInt aPos,TInt aLength)const; |
|
116 TBool InField(const TInt aPos, TInt& anIndex, TInt& anOffset) const; // anOffset set to distance into field or gap |
|
117 void DeleteFieldEntry(TInt anIndex); |
|
118 void DeleteFieldEntry(CArrayFixSeg<TTextFieldEntry>* aArray,TInt anIndex); |
|
119 TTextFieldEntry SplitEntry(TInt aIndex,TInt aOffset,TInt aRange)const; |
|
120 TInt EntryLen(const TTextFieldEntry& aEntry)const; |
|
121 TInt EntryLen(TInt aIndex)const; |
|
122 // rollback |
|
123 void RecordRollbackInfoL(TInt aPastePos); |
|
124 private: |
|
125 MTextFieldFactory* iFieldFactory; |
|
126 CArrayFixSeg<TTextFieldEntry>* iFieldArray; // Array of fields in the document |
|
127 TRollbackInfo* iRollbackInfo; |
|
128 __DECLARE_TEST; |
|
129 }; |
|
130 |
|
131 class TFieldMapExternalizer : public MExternalizer<TStreamRef> |
|
132 /** |
|
133 Allows NULL streams id's to be written out |
|
134 when no reference is found in a store map. |
|
135 @internalComponent |
|
136 */ |
|
137 { |
|
138 private: |
|
139 friend class CPlainText; |
|
140 friend class CTextFieldSet; |
|
141 private: |
|
142 IMPORT_C TFieldMapExternalizer(const CStoreMap& aMap); |
|
143 IMPORT_C void ExternalizeL(const TStreamRef& anObject,RWriteStream& aStream) const; |
|
144 private: |
|
145 const CStoreMap* iMap; |
|
146 }; |
|
147 |
|
148 #endif |
|