os/textandloc/textrendering/textformatting/test/tbandformat/inc/bandtestdocument.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/textrendering/textformatting/test/tbandformat/inc/bandtestdocument.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,134 @@
     1.4 +/*
     1.5 +* Copyright (c) 2006-2009 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 "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 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#ifndef __BANDTESTDOCUMENT_H
    1.23 +#define __BANDTESTDOCUMENT_H
    1.24 +
    1.25 +#include <e32std.h>
    1.26 +
    1.27 +/**
    1.28 +@file
    1.29 +@internalComponent 
    1.30 +*/
    1.31 +class MDesCArray;
    1.32 +class CRichText;
    1.33 +class CBandMaintainer;
    1.34 +class CTmTextLayout;
    1.35 +class TBandTestAction;
    1.36 +
    1.37 +/**
    1.38 +This class represents a specification for a document and a view. 
    1.39 +
    1.40 +- The document content is represented by a descriptor array in which each descriptor is a paragraph. 
    1.41 +
    1.42 +- The view is represented simply by the TInt aTopOfBand argument, which tells us how
    1.43 +many paragraphs to lose from the top of the band. So if it is zero, then we just initialise
    1.44 +the doc and don't scroll at all; if it is 1 we scroll down until 1 paragraph is removed from
    1.45 +the top of the band, and so on. Currently it's basically only ever set to 1 or 0, and is thus
    1.46 +used as a boolean "top_of_doc!=top_of_band"
    1.47 +
    1.48 +Having initialised one of these objects with the document content and view, you can set up 
    1.49 +the CRichText and associated text views by calling SetupDocumentL. This will clear any text
    1.50 +that exists in the richtext, re-create it according to the specification for the document 
    1.51 +contents and set up the view according to the view specification.
    1.52 +*/
    1.53 +class TDocumentSpec
    1.54 +	{
    1.55 +public:
    1.56 +	IMPORT_C TDocumentSpec(const MDesCArray& aTextContents, TInt aTopOfBand);
    1.57 +	IMPORT_C void SetupDocumentL(CRichText& aRichText, CBandMaintainer& aMaintainer);
    1.58 +private:	
    1.59 +	const MDesCArray& iContents;
    1.60 +	TInt iTopOfBand;
    1.61 +	};
    1.62 +	
    1.63 +/**
    1.64 +Given an array of lines in aLines, this function will first retrieve a subset of the lines thought to be 
    1.65 +of particular interest to the reformatting algorithm. 
    1.66 +
    1.67 +In general, for each paragraph in the lines supplied, lines of interest are:
    1.68 +(1) special cases:
    1.69 +	- the first line
    1.70 +	- the second line
    1.71 +	- the penultimate line
    1.72 +	- the last line
    1.73 +(2) normal cases
    1.74 +- at least 2 lines from the middle
    1.75 +
    1.76 +So:
    1.77 +- if the paragraph contains 6 lines or fewer, we take them all, giving us the 4 special cases,
    1.78 +and two lines from the middle
    1.79 +- otherwise, we take the 4 special cases, and a couple from the middle
    1.80 +
    1.81 +It then retrieves the start, middle and end-1 positions from each line, and put them, in order, in aPositions
    1.82 +*/	
    1.83 +IMPORT_C void PositionsToTestL(const RArray<TTmLineInfo>& aLines, RArray<TInt>& aPositions);
    1.84 +
    1.85 +/**
    1.86 +Given:
    1.87 +- a document specification aDocumentSpec
    1.88 +- an action aAction,
    1.89 +- an array of positions aPositions
    1.90 +
    1.91 +This function will iteratively execute the action at each position supplied. 
    1.92 +For each position N it will iteratively execute the action as follows:
    1.93 +- at N, with a length of 1
    1.94 +- at N, with a length of ((N+1)-N) +1
    1.95 +- at N, with a length of ((N+2)-N) +1
    1.96 +
    1.97 +So if the positions are 1, 5 and 10, it will execute actions as follows:
    1.98 +pos 1, length 1
    1.99 +pos 1, length 5
   1.100 +pos 1, length 10
   1.101 +pos 5, length 1
   1.102 +pos 5, length 5
   1.103 +pos 10, length 1
   1.104 +
   1.105 +It will reset the document and view each time.
   1.106 +*/
   1.107 +IMPORT_C void ExecuteTestL(CRichText& aRichText, CBandMaintainer& aMaintainer, 
   1.108 +	TBandTestAction& aAction, TDocumentSpec& aDocumentSpec, RArray<TInt>& aPositions);
   1.109 +
   1.110 +/**
   1.111 +Given
   1.112 +- a document specification aDocumentSpec
   1.113 +- a string to insert aTextToInsert
   1.114 +- an array of positions aPositions
   1.115 +
   1.116 +This function will initialise the document and view, then iteratively insert the string
   1.117 +at each position.
   1.118 +
   1.119 +It will reset the document and view each time.
   1.120 +*/
   1.121 +IMPORT_C void InsertTextL(CRichText& aRichText, CBandMaintainer& aMaintainer, 
   1.122 +	CBandValidator& aValidator, TDocumentSpec& aDocumentSpec, const TDesC& aTextToInsert, RArray<TInt>& aPositions);
   1.123 +
   1.124 +/**
   1.125 +Given a text layout aLayout, this function will retrieve all the visible lines and
   1.126 +place them in aVisibleLines.
   1.127 +*/
   1.128 +IMPORT_C void GetVisibleLinesL(const CTextLayout& aLayout, RArray<TTmLineInfo>& aVisibleLines);
   1.129 +
   1.130 +/**
   1.131 +Given a text layout aTmLayout, this function will retrieve all the lines constituting the
   1.132 +formatted band and place them in aLinesInBand
   1.133 +*/
   1.134 +IMPORT_C void GetLinesInBandL(const CTmTextLayout& aTmLayout, RArray<TTmLineInfo>& aLinesInBand);
   1.135 +
   1.136 +
   1.137 +#endif
   1.138 \ No newline at end of file