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