os/textandloc/textrendering/textformatting/test/tbandformat/inc/bandtestdocument.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #ifndef __BANDTESTDOCUMENT_H
    20 #define __BANDTESTDOCUMENT_H
    21 
    22 #include <e32std.h>
    23 
    24 /**
    25 @file
    26 @internalComponent 
    27 */
    28 class MDesCArray;
    29 class CRichText;
    30 class CBandMaintainer;
    31 class CTmTextLayout;
    32 class TBandTestAction;
    33 
    34 /**
    35 This class represents a specification for a document and a view. 
    36 
    37 - The document content is represented by a descriptor array in which each descriptor is a paragraph. 
    38 
    39 - The view is represented simply by the TInt aTopOfBand argument, which tells us how
    40 many paragraphs to lose from the top of the band. So if it is zero, then we just initialise
    41 the doc and don't scroll at all; if it is 1 we scroll down until 1 paragraph is removed from
    42 the top of the band, and so on. Currently it's basically only ever set to 1 or 0, and is thus
    43 used as a boolean "top_of_doc!=top_of_band"
    44 
    45 Having initialised one of these objects with the document content and view, you can set up 
    46 the CRichText and associated text views by calling SetupDocumentL. This will clear any text
    47 that exists in the richtext, re-create it according to the specification for the document 
    48 contents and set up the view according to the view specification.
    49 */
    50 class TDocumentSpec
    51 	{
    52 public:
    53 	IMPORT_C TDocumentSpec(const MDesCArray& aTextContents, TInt aTopOfBand);
    54 	IMPORT_C void SetupDocumentL(CRichText& aRichText, CBandMaintainer& aMaintainer);
    55 private:	
    56 	const MDesCArray& iContents;
    57 	TInt iTopOfBand;
    58 	};
    59 	
    60 /**
    61 Given an array of lines in aLines, this function will first retrieve a subset of the lines thought to be 
    62 of particular interest to the reformatting algorithm. 
    63 
    64 In general, for each paragraph in the lines supplied, lines of interest are:
    65 (1) special cases:
    66 	- the first line
    67 	- the second line
    68 	- the penultimate line
    69 	- the last line
    70 (2) normal cases
    71 - at least 2 lines from the middle
    72 
    73 So:
    74 - if the paragraph contains 6 lines or fewer, we take them all, giving us the 4 special cases,
    75 and two lines from the middle
    76 - otherwise, we take the 4 special cases, and a couple from the middle
    77 
    78 It then retrieves the start, middle and end-1 positions from each line, and put them, in order, in aPositions
    79 */	
    80 IMPORT_C void PositionsToTestL(const RArray<TTmLineInfo>& aLines, RArray<TInt>& aPositions);
    81 
    82 /**
    83 Given:
    84 - a document specification aDocumentSpec
    85 - an action aAction,
    86 - an array of positions aPositions
    87 
    88 This function will iteratively execute the action at each position supplied. 
    89 For each position N it will iteratively execute the action as follows:
    90 - at N, with a length of 1
    91 - at N, with a length of ((N+1)-N) +1
    92 - at N, with a length of ((N+2)-N) +1
    93 
    94 So if the positions are 1, 5 and 10, it will execute actions as follows:
    95 pos 1, length 1
    96 pos 1, length 5
    97 pos 1, length 10
    98 pos 5, length 1
    99 pos 5, length 5
   100 pos 10, length 1
   101 
   102 It will reset the document and view each time.
   103 */
   104 IMPORT_C void ExecuteTestL(CRichText& aRichText, CBandMaintainer& aMaintainer, 
   105 	TBandTestAction& aAction, TDocumentSpec& aDocumentSpec, RArray<TInt>& aPositions);
   106 
   107 /**
   108 Given
   109 - a document specification aDocumentSpec
   110 - a string to insert aTextToInsert
   111 - an array of positions aPositions
   112 
   113 This function will initialise the document and view, then iteratively insert the string
   114 at each position.
   115 
   116 It will reset the document and view each time.
   117 */
   118 IMPORT_C void InsertTextL(CRichText& aRichText, CBandMaintainer& aMaintainer, 
   119 	CBandValidator& aValidator, TDocumentSpec& aDocumentSpec, const TDesC& aTextToInsert, RArray<TInt>& aPositions);
   120 
   121 /**
   122 Given a text layout aLayout, this function will retrieve all the visible lines and
   123 place them in aVisibleLines.
   124 */
   125 IMPORT_C void GetVisibleLinesL(const CTextLayout& aLayout, RArray<TTmLineInfo>& aVisibleLines);
   126 
   127 /**
   128 Given a text layout aTmLayout, this function will retrieve all the lines constituting the
   129 formatted band and place them in aLinesInBand
   130 */
   131 IMPORT_C void GetLinesInBandL(const CTmTextLayout& aTmLayout, RArray<TTmLineInfo>& aLinesInBand);
   132 
   133 
   134 #endif