1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/fldset.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,148 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// 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
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __FLDSET_H__
1.20 +#define __FLDSET_H__
1.21 +
1.22 +#include <e32std.h>
1.23 +#include <e32base.h>
1.24 +#include <fldinfo.h>
1.25 +#include <fldbase.h>
1.26 +#include <fldbltin.h>
1.27 +
1.28 +//
1.29 +// Classes declared in this file
1.30 +class CTextFieldSet;
1.31 +//
1.32 +// Classes referenced
1.33 +class RReadStream;
1.34 +class RWriteStream;
1.35 +class TTextFieldEntry;
1.36 +class CStreamStore;
1.37 +class CStoreMap;
1.38 +class TRollbackInfo;
1.39 +
1.40 +/**
1.41 +@internalComponent
1.42 +*/
1.43 +const TInt KFieldArrayGranularity=1;
1.44 +
1.45 +
1.46 +class CTextFieldSet : public CBase
1.47 +/**
1.48 +The engine that keeps the field table up to date
1.49 +@internalComponent
1.50 +*/
1.51 + {
1.52 +public:
1.53 + enum {ENoPasteLimit=-1};
1.54 +public:
1.55 + IMPORT_C static CTextFieldSet* NewL(TInt aDocumentLength=0);
1.56 + IMPORT_C static CTextFieldSet* NewL(const MTextFieldFactory* aFactory,const CStreamStore& aStore,TStreamId aStreamId);
1.57 + IMPORT_C ~CTextFieldSet();
1.58 + //
1.59 + // Factory functions
1.60 + IMPORT_C void SetFieldFactory(MTextFieldFactory* aFactory);
1.61 + IMPORT_C MTextFieldFactory* FieldFactory()const;
1.62 + //
1.63 + IMPORT_C void Reset(); // removes all fields from the array and reinitialises field array
1.64 + //
1.65 + // Persistence
1.66 + IMPORT_C TStreamId StoreL(CStreamStore& aStore)const;
1.67 + IMPORT_C void RestoreL(const CStreamStore& aFieldStore,TStreamId aStreamId);
1.68 + //
1.69 + // Component persistence
1.70 + IMPORT_C void StoreFieldsL(CStreamStore& aStore,CStoreMap& aMap)const;
1.71 + IMPORT_C void RestoreFieldsL(const CStreamStore& aFieldStore);
1.72 + //
1.73 + // Headstream persistence
1.74 + IMPORT_C void InternalizeL(RReadStream& aStream);
1.75 + IMPORT_C void ExternalizeL(RWriteStream& aStream)const;
1.76 + // Cut/Paste
1.77 + IMPORT_C TStreamId CopyToStoreL(CStreamStore& aStore,TInt aPos,TInt aLength)const;
1.78 + IMPORT_C void CopyComponentsL(CStreamStore& aStore,CStoreMap& aMap,TInt aPos,TInt aLength)const;
1.79 + IMPORT_C void CopyToStreamL(RWriteStream& aStream,TInt aPos,TInt aLength)const;
1.80 + IMPORT_C void PasteFromStoreL(const CStreamStore& aFieldStore,TStreamId aStreamId,TInt aPos,TInt aMaxLen=ENoPasteLimit);
1.81 + IMPORT_C void PasteComponentsL(const CStreamStore& aFieldStore,TInt aPos);
1.82 + IMPORT_C void PasteFromStreamL(RReadStream& aStream,TInt aPos,TInt aMaxLen=ENoPasteLimit);
1.83 + // Insert/Remove field
1.84 + IMPORT_C CTextField* NewFieldL(TUid aFieldType);
1.85 + IMPORT_C TInt InsertFieldL(TInt aPos,CTextField* aField,TUid aFieldType); // inserts a field (including text) into doc (returns error num if it fails)
1.86 + IMPORT_C TInt RemoveField(TInt aPos); // remove the field aPos is in
1.87 + IMPORT_C TInt NewFieldValueL(HBufC*& aBuf, TInt aPos); // returns new value of the field in aBuf (or returns false if aPos not in field)
1.88 + // Update field set
1.89 + IMPORT_C void NotifyInsertion(TInt aPos, TInt aNumberAdded);
1.90 + IMPORT_C void NotifyDeletion(TInt aPos, TInt aNumberRemoved);
1.91 + IMPORT_C void NotifyFieldUpdate(TInt aPos, TInt aNewFieldValueLength);
1.92 + // Utilities
1.93 + IMPORT_C TInt FieldCount() const; // returns total number of fields in document
1.94 + IMPORT_C TInt CharCount() const; // returns num characters in the document (according to fields)
1.95 + IMPORT_C TBool FindFields(TInt aPos) const; // Returns ETrue if aPos is in a field
1.96 + 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
1.97 + IMPORT_C const CTextField* TextField(TInt aPos)const;
1.98 + // Rollback
1.99 + IMPORT_C void RollbackPaste(); // call to carry out rollback if a paste goes wrong
1.100 +protected:
1.101 + CTextFieldSet();
1.102 + void ConstructL(TInt aDocumentLength);
1.103 + void ConstructL(const CStreamStore& aFieldStore,TStreamId aStreamId);
1.104 +private:
1.105 + // persistence
1.106 + void StoreFieldsL(CStreamStore& aStore,CStoreMap& aMap,CArrayFixSeg<TTextFieldEntry>* aArray)const;
1.107 + void DoRestoreL(const CStreamStore& aFieldStore,TStreamId aStreamId);
1.108 + void DoRestoreFieldsL(CArrayFixSeg<TTextFieldEntry>* aArray,const CStreamStore& aFieldStore,TInt aStartIndex=0);
1.109 + void InternalizeL(CArrayFixSeg<TTextFieldEntry>* aArray,RReadStream& aStream);
1.110 + void ExternalizeL(RWriteStream& aStream,CArrayFixSeg<TTextFieldEntry>* aArray)const;
1.111 + void DoPasteL(CArrayFixSeg<TTextFieldEntry>* aSourceArray,TInt aPos);
1.112 + // utility functions
1.113 + void AddInitialFieldEntryL(CArrayFixSeg<TTextFieldEntry>* aArray,TInt aDocumentLength); // used to initialise the array
1.114 + void InsertEntryL(TInt aIndex,TTextFieldEntry& aEntry); // inserts into iFieldArray
1.115 + void InsertEntryL(TInt aIndex,TTextFieldEntry& aEntry,CArrayFixSeg<TTextFieldEntry>* aArray);
1.116 + void AppendEntryL(TTextFieldEntry& aEntry); // appends into iFieldArray
1.117 + void AppendEntryL(TTextFieldEntry& aEntry,CArrayFixSeg<TTextFieldEntry>* aArray);
1.118 + void CopyToArrayL(CArrayFixSeg<TTextFieldEntry>* aArray,TInt aPos,TInt aLength)const;
1.119 + TBool InField(const TInt aPos, TInt& anIndex, TInt& anOffset) const; // anOffset set to distance into field or gap
1.120 + void DeleteFieldEntry(TInt anIndex);
1.121 + void DeleteFieldEntry(CArrayFixSeg<TTextFieldEntry>* aArray,TInt anIndex);
1.122 + TTextFieldEntry SplitEntry(TInt aIndex,TInt aOffset,TInt aRange)const;
1.123 + TInt EntryLen(const TTextFieldEntry& aEntry)const;
1.124 + TInt EntryLen(TInt aIndex)const;
1.125 + // rollback
1.126 + void RecordRollbackInfoL(TInt aPastePos);
1.127 +private:
1.128 + MTextFieldFactory* iFieldFactory;
1.129 + CArrayFixSeg<TTextFieldEntry>* iFieldArray; // Array of fields in the document
1.130 + TRollbackInfo* iRollbackInfo;
1.131 + __DECLARE_TEST;
1.132 + };
1.133 +
1.134 +class TFieldMapExternalizer : public MExternalizer<TStreamRef>
1.135 +/**
1.136 +Allows NULL streams id's to be written out
1.137 +when no reference is found in a store map.
1.138 +@internalComponent
1.139 +*/
1.140 + {
1.141 +private:
1.142 + friend class CPlainText;
1.143 + friend class CTextFieldSet;
1.144 +private:
1.145 + IMPORT_C TFieldMapExternalizer(const CStoreMap& aMap);
1.146 + IMPORT_C void ExternalizeL(const TStreamRef& anObject,RWriteStream& aStream) const;
1.147 +private:
1.148 + const CStoreMap* iMap;
1.149 + };
1.150 +
1.151 +#endif