Update contrib.
2 * Copyright (c) 2003-2007 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: ?Description
21 #include "InlineTextCompositeSource.h"
26 // MODULE DATA STRUCTURES
28 _LIT( KBadCharacter, " " );
30 // ============================ MEMBER FUNCTIONS ===============================
33 EXPORT_C CInlineTextCompositeSource* CInlineTextCompositeSource::NewL()
35 CInlineTextCompositeSource* self = new (ELeave) CInlineTextCompositeSource();
36 CleanupStack::PushL( self );
42 CInlineTextCompositeSource::~CInlineTextCompositeSource()
44 // delete the pointed-to objects because this object owns them
45 if (iInlineTextSourceArray)
46 iInlineTextSourceArray->ResetAndDestroy();
47 delete iInlineTextSourceArray;
50 EXPORT_C void CInlineTextCompositeSource::InstallInlineTextSourceL( CInlineTextSource* aInlineTextSource )
52 if ( aInlineTextSource )
53 iInlineTextSourceArray->AppendL( aInlineTextSource );
57 TInt CInlineTextCompositeSource::GetNextInlineTextPosition(
58 const TTmDocPos& aFrom,
62 TInt retValue = KErrNotFound;
64 // For now, call CheckFormattingL() at the top of each
65 TTmDocPos to( aFrom.iPos + aMaxLength - 1, EFalse );
68 to = aFrom; // Makes at least a legal, if zero containing, range
70 TRAP_IGNORE( CheckFormattingL( aFrom, to ) );
72 // The individual formatters are requested and the minimum position is returned
73 TTmDocPos minDocPos(aFrom);
74 minDocPos.iPos += ( aMaxLength + 2); // Ensure it is bigger than legal
76 TInt count = iInlineTextSourceArray->Count();
77 for ( TInt i = 0; i < count; i++ )
79 TTmDocPos thisNextPos;
80 TInt err = iInlineTextSourceArray->At(i)
81 ->GetNextInlineTextPosition( aFrom, aMaxLength, thisNextPos );
82 if ( err == KErrNone ) // one has been found
84 if ( thisNextPos < minDocPos )
86 minDocPos = thisNextPos;
91 if ( retValue == KErrNone )
98 TPtrC CInlineTextCompositeSource::GetInlineText(const TTmDocPos& aAt)
100 TInt count = iInlineTextSourceArray->Count();
101 for ( TInt i = 0; i < count; i++ )
104 if ( iInlineTextSourceArray->At(i)->HasInlineTextAt( aAt, retPtr ) )
110 buf.Format( _L("Bad fetch of inline text at Pos: %d Trailing/Leading: %d"),
113 RDebug::Print( buf );
115 __ASSERT_DEBUG( EFalse, Panic( EInlineTextBadInlineTextFetch ) );
118 return KBadCharacter();
123 // Formatting notification is just passed to all inline text formatters
125 void CInlineTextCompositeSource::CheckFormattingL(
126 const TTmDocPos& aFrom, const TTmDocPos& aTo )
128 TInt count = iInlineTextSourceArray->Count();
129 for ( TInt i = 0; i < count; i++ )
131 iInlineTextSourceArray->At(i)->CheckFormattingL( aFrom, aTo );
135 CInlineTextCompositeSource::CInlineTextCompositeSource()
138 void CInlineTextCompositeSource::ConstructL()
140 iInlineTextSourceArray = new (ELeave) CInlineTextSourceArray(1); // Unit granularity
143 void CInlineTextCompositeSource::EditObserver( TInt aStart, TInt aExtent )
145 TInt count = iInlineTextSourceArray->Count();
146 for ( TInt i = 0; i < count; i++ )
148 iInlineTextSourceArray->At(i)->EditObserver( aStart, aExtent );