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