1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/textandlocutils/inlinetext/inc/InlineTextBase.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,248 @@
1.4 +/*
1.5 +* Copyright (c) 2007 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 the License "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 +* Base classes used for holding inline text for the Form MTmInlineTextSource interface.
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +#ifndef INLINETEXTBASE_H
1.24 +#define INLINETEXTBASE_H
1.25 +
1.26 +// INCLUDES
1.27 +#include <e32std.h>
1.28 +#include <e32base.h>
1.29 +#include <medobsrv.h>
1.30 +#include <inlinetext.h>
1.31 +
1.32 +// CONSTANTS
1.33 +enum TInlineTextPanic
1.34 + {
1.35 + EInlineTextBadInlineTextFetch,
1.36 + EInlineTextStoreCorrupted
1.37 + };
1.38 +
1.39 +#define KInlineTextParagraphDelimiter 0x2029
1.40 +
1.41 +GLREF_C void Panic(TInlineTextPanic aPanic);
1.42 +
1.43 +// CLASS DECLARATION
1.44 +
1.45 +class TTmDocPos;
1.46 +
1.47 +/**
1.48 +* This class is used to hold text that is being formatted into text via the inline text
1.49 +* interface.
1.50 +*
1.51 +* @lib InlineText
1.52 +* @since 3.2
1.53 +*/
1.54 +NONSHARABLE_CLASS(CInlineTextPositionedText): public CBase
1.55 + {
1.56 + public: // 2stage constructor and descructor
1.57 + /**
1.58 + * Fully constructs the object given position and text. A copy of the passed-in text is made
1.59 + * on the heap, owned by the constructed object.
1.60 + *
1.61 + * @param aPosition TTmDocPos at which text is to be reported
1.62 + * @param aInlineText Text to be returned at this position
1.63 + *
1.64 + * @return pointer to fully constructed object
1.65 + */
1.66 + static CInlineTextPositionedText* NewL( const TTmDocPos& aPosition, const TDesC& aInlineText );
1.67 +
1.68 + /**
1.69 + * Destructor
1.70 + */
1.71 + ~CInlineTextPositionedText();
1.72 +
1.73 + public:
1.74 +
1.75 + /**
1.76 + * Access method to the position in the document of the inline text
1.77 + * @return TTmDocPos of the inline text
1.78 + */
1.79 + const TTmDocPos& DocPos() const;
1.80 +
1.81 + /**
1.82 + * Access method to the text for the inline edit
1.83 + * @return reference to an unmodifiable descriptor for the text held in this object
1.84 + */
1.85 + const TDesC& InlineText() const;
1.86 +
1.87 + private:
1.88 + /**
1.89 + * C++ constructor
1.90 + */
1.91 + CInlineTextPositionedText( const TTmDocPos& aPosition );
1.92 +
1.93 + /**
1.94 + * This method completes the construction by allocating the text storage..
1.95 + */
1.96 + void ConstructL( const TDesC& aInlineText );
1.97 +
1.98 + private:
1.99 + TTmDocPos iDocPos;
1.100 + HBufC* iText; // owned
1.101 + };
1.102 +
1.103 +/**
1.104 +* Class to hold an array of inline texts for access
1.105 +*
1.106 +* @lib InlineText
1.107 +* @since 3.2
1.108 +*/
1.109 +NONSHARABLE_CLASS(CInlineTextStore) : public CArrayPtrFlat<CInlineTextPositionedText>
1.110 + {
1.111 + public: // 2-stage constructor and destructor
1.112 + static CInlineTextStore* NewL();
1.113 + ~CInlineTextStore();
1.114 +
1.115 + public:
1.116 + /**
1.117 + * Clears and destroys all inline texts
1.118 + */
1.119 + void Clear();
1.120 +
1.121 + /**
1.122 + * Clears and destroys inline texts in a range of document positions. Range is taken
1.123 + * to be inclusive.
1.124 + * @param aStart First position from which and including inline texts are removed
1.125 + * @param aEnd Final position up to which and including inline texts are removed
1.126 + */
1.127 + void ClearRange( const TTmDocPos& aStart, const TTmDocPos& aEnd );
1.128 +
1.129 + /**
1.130 + * Insert the inline text object into the store
1.131 + * @param aInlineText object to add
1.132 + */
1.133 + void InsertInlineTextL( CInlineTextPositionedText* aInlineText );
1.134 +
1.135 + /**
1.136 + * Returns the pointer to the document position closest after or including the passed-in
1.137 + * position.
1.138 + * @param aDocPos position from which to look for inline texts
1.139 + * @return pointer to document position at or closest after input position
1.140 + * NULL if none is found
1.141 + */
1.142 + const TTmDocPos* NextInlineTextDocPos( const TTmDocPos& aDocPos ) const;
1.143 +
1.144 + /**
1.145 + * Searches for the input document position and returns the index in the Store
1.146 + * @param aDocPos input document position
1.147 + * @return index at which the input position is found
1.148 + * -1 if the document position is not in the store
1.149 + */
1.150 + TInt IndexFromDocPos( const TTmDocPos& aDocPos ) const;
1.151 +
1.152 + private:
1.153 + /**
1.154 + * Private constructor; no derivation permitted
1.155 + */
1.156 + CInlineTextStore();
1.157 +
1.158 + /**
1.159 + * Internal method for determining index of the position later or including
1.160 + * the passed-in position
1.161 + */
1.162 + TInt NextIndexStartingAtDocPos( const TTmDocPos& aDocPos ) const;
1.163 +
1.164 + private: // data members
1.165 +
1.166 + };
1.167 +
1.168 +/**
1.169 +* Concrete implementation of MTmInlineTextSource, adding an edit observation interface
1.170 +* and common infrastructure for managing inline texts
1.171 +*
1.172 +* @lib InlineText
1.173 +* @since 3.2
1.174 +*/
1.175 +NONSHARABLE_CLASS(CInlineTextSource) : public CBase, public MTmInlineTextSource, public MEditObserver
1.176 + {
1.177 + public: // C++ constructor and destructor
1.178 + CInlineTextSource(); // Class is intended for derivation
1.179 + ~CInlineTextSource();
1.180 +
1.181 + /**
1.182 + * 2nd state constructor
1.183 + */
1.184 + void ConstructL();
1.185 +
1.186 + public: // From MTmInlineTextSource
1.187 +
1.188 + /**
1.189 + * Reports the next position into which inline text should be inserted
1.190 + *
1.191 + * See inlinetext.h
1.192 + */
1.193 + virtual TInt GetNextInlineTextPosition(const TTmDocPos& aFrom, TInt aMaxLength, TTmDocPos& aNext);
1.194 +
1.195 + /**
1.196 + * Gets a view of the text to be inserted at aAt.
1.197 + *
1.198 + * See inlinetext.h
1.199 + */
1.200 + virtual TPtrC GetInlineText(const TTmDocPos& aAt);
1.201 +
1.202 + public: // From MEditObserver
1.203 +
1.204 + /**
1.205 + * See medobsrv.h
1.206 + *
1.207 + * This class implements an empty implementation of this method. Implement in subclass only if
1.208 + * action is to be taken upon edit - and if edit event is actually going to be supplied, which
1.209 + * is only available in the context of CEikRichTextEditor
1.210 + */
1.211 + virtual void EditObserver(TInt aStart, TInt aExtent);
1.212 +
1.213 + public:
1.214 + // New methods
1.215 +
1.216 + /**
1.217 + * Framework method to inform subclasses what part of the document is currently being interrogated
1.218 + * for inline edits.
1.219 + * Currently this will be where formatting is performed and the store of inline texts updated.
1.220 + * (In future, an edit observer interface of some kind will be used to trigger that)
1.221 + *
1.222 + * @param aFrom position from which to re-consider the formatting
1.223 + * @param aTo position up to which to re-consider the formatting
1.224 + */
1.225 + virtual void CheckFormattingL(const TTmDocPos& aFrom, const TTmDocPos& aTo );
1.226 +
1.227 + /**
1.228 + * Non-virtual method for checking for inline text. Similar behaviour to GetInlineText, except
1.229 + * that is it const, and will not panic (but just return EFalse) if there is no inline text
1.230 + * at the input TTmDocPos.
1.231 + *
1.232 + * @param aAt Position at which to access inline text
1.233 + * @param aPtrFound This contains the inline text if ETrue is returned
1.234 + * @return EFalse if there is no inline text at the input position
1.235 + */
1.236 + TBool HasInlineTextAt( const TTmDocPos& aAt, TPtrC& aPtrFound ) const;
1.237 +
1.238 + protected:
1.239 +
1.240 + /**
1.241 + * Access to the inline text store for derived classes
1.242 + */
1.243 + CInlineTextStore* InlineTextStore() const;
1.244 +
1.245 + private:
1.246 + CInlineTextStore* iInlineTextStore; // owned
1.247 + };
1.248 +
1.249 +#endif
1.250 +
1.251 +// End of File