sl@0: /* sl@0: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #ifndef __BANDTESTDOCUMENT_H sl@0: #define __BANDTESTDOCUMENT_H sl@0: sl@0: #include sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: class MDesCArray; sl@0: class CRichText; sl@0: class CBandMaintainer; sl@0: class CTmTextLayout; sl@0: class TBandTestAction; sl@0: sl@0: /** sl@0: This class represents a specification for a document and a view. sl@0: sl@0: - The document content is represented by a descriptor array in which each descriptor is a paragraph. sl@0: sl@0: - The view is represented simply by the TInt aTopOfBand argument, which tells us how sl@0: many paragraphs to lose from the top of the band. So if it is zero, then we just initialise sl@0: the doc and don't scroll at all; if it is 1 we scroll down until 1 paragraph is removed from sl@0: the top of the band, and so on. Currently it's basically only ever set to 1 or 0, and is thus sl@0: used as a boolean "top_of_doc!=top_of_band" sl@0: sl@0: Having initialised one of these objects with the document content and view, you can set up sl@0: the CRichText and associated text views by calling SetupDocumentL. This will clear any text sl@0: that exists in the richtext, re-create it according to the specification for the document sl@0: contents and set up the view according to the view specification. sl@0: */ sl@0: class TDocumentSpec sl@0: { sl@0: public: sl@0: IMPORT_C TDocumentSpec(const MDesCArray& aTextContents, TInt aTopOfBand); sl@0: IMPORT_C void SetupDocumentL(CRichText& aRichText, CBandMaintainer& aMaintainer); sl@0: private: sl@0: const MDesCArray& iContents; sl@0: TInt iTopOfBand; sl@0: }; sl@0: sl@0: /** sl@0: Given an array of lines in aLines, this function will first retrieve a subset of the lines thought to be sl@0: of particular interest to the reformatting algorithm. sl@0: sl@0: In general, for each paragraph in the lines supplied, lines of interest are: sl@0: (1) special cases: sl@0: - the first line sl@0: - the second line sl@0: - the penultimate line sl@0: - the last line sl@0: (2) normal cases sl@0: - at least 2 lines from the middle sl@0: sl@0: So: sl@0: - if the paragraph contains 6 lines or fewer, we take them all, giving us the 4 special cases, sl@0: and two lines from the middle sl@0: - otherwise, we take the 4 special cases, and a couple from the middle sl@0: sl@0: It then retrieves the start, middle and end-1 positions from each line, and put them, in order, in aPositions sl@0: */ sl@0: IMPORT_C void PositionsToTestL(const RArray& aLines, RArray& aPositions); sl@0: sl@0: /** sl@0: Given: sl@0: - a document specification aDocumentSpec sl@0: - an action aAction, sl@0: - an array of positions aPositions sl@0: sl@0: This function will iteratively execute the action at each position supplied. sl@0: For each position N it will iteratively execute the action as follows: sl@0: - at N, with a length of 1 sl@0: - at N, with a length of ((N+1)-N) +1 sl@0: - at N, with a length of ((N+2)-N) +1 sl@0: sl@0: So if the positions are 1, 5 and 10, it will execute actions as follows: sl@0: pos 1, length 1 sl@0: pos 1, length 5 sl@0: pos 1, length 10 sl@0: pos 5, length 1 sl@0: pos 5, length 5 sl@0: pos 10, length 1 sl@0: sl@0: It will reset the document and view each time. sl@0: */ sl@0: IMPORT_C void ExecuteTestL(CRichText& aRichText, CBandMaintainer& aMaintainer, sl@0: TBandTestAction& aAction, TDocumentSpec& aDocumentSpec, RArray& aPositions); sl@0: sl@0: /** sl@0: Given sl@0: - a document specification aDocumentSpec sl@0: - a string to insert aTextToInsert sl@0: - an array of positions aPositions sl@0: sl@0: This function will initialise the document and view, then iteratively insert the string sl@0: at each position. sl@0: sl@0: It will reset the document and view each time. sl@0: */ sl@0: IMPORT_C void InsertTextL(CRichText& aRichText, CBandMaintainer& aMaintainer, sl@0: CBandValidator& aValidator, TDocumentSpec& aDocumentSpec, const TDesC& aTextToInsert, RArray& aPositions); sl@0: sl@0: /** sl@0: Given a text layout aLayout, this function will retrieve all the visible lines and sl@0: place them in aVisibleLines. sl@0: */ sl@0: IMPORT_C void GetVisibleLinesL(const CTextLayout& aLayout, RArray& aVisibleLines); sl@0: sl@0: /** sl@0: Given a text layout aTmLayout, this function will retrieve all the lines constituting the sl@0: formatted band and place them in aLinesInBand sl@0: */ sl@0: IMPORT_C void GetLinesInBandL(const CTmTextLayout& aTmLayout, RArray& aLinesInBand); sl@0: sl@0: sl@0: #endif