textrendering/texthandling/stext/TXTRICH.CPP
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 06 Jul 2010 16:23:19 +0300
changeset 44 601ab138ba0b
parent 37 6be019398652
child 49 4d76f1414957
permissions -rw-r--r--
Revision: 201027 Kit: 2010127
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
/*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
* All rights reserved.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
* Initial Contributors:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
* Contributors:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
* Description: 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
#include <e32std.h>
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
#include <e32base.h>
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
#include "TXTRICH.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
#include "TXTINDEX.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
#include "TXTSTD.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
#include "TXTRTPFL.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
#include "ParseLst.h"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
#include "TXTCLIPBOARD.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    29
#include "OstTraceDefinitions.h"
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    30
#ifdef OST_TRACE_COMPILER_IN_USE
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    31
#include "TXTRICHTraces.h"
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    32
#endif
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    33
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
#include "TXTETEXT_INTERNAL.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
#include "TXTRICH_INTERNAL.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
#endif
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
EXPORT_C void CRichText::__DbgTestInvariant()const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
// Provides class invariants.  Explanations below:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
#ifdef _DEBUG
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
// ASSERT: The global format layers are never null.
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    45
	if (iGlobalParaFormatLayer == NULL)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    46
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    47
	    OstTrace0( TRACE_DUMP, CRICHTEXT_DBGTESTINVARIANT, "Invariant" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    48
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
	__ASSERT_DEBUG(iGlobalParaFormatLayer != NULL, User::Invariant());
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    50
	if (iGlobalCharFormatLayer == NULL)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    51
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    52
	    OstTrace0( TRACE_DUMP, DUP1_CRICHTEXT_DBGTESTINVARIANT, "Invariant" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    53
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
	__ASSERT_DEBUG(iGlobalCharFormatLayer != NULL, User::Invariant());
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
// ASSERT: The sum of para lengths == the length as described by the document storage.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
		TInt cumulativeParaLength = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
		TInt maxPara = iIndex->iParaIx->Count();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
		for (TInt offset = 0; offset < maxPara; offset++)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    61
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    62
			TParaAttribsEntry entry = (*iIndex->iParaIx)[offset];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    63
			cumulativeParaLength += entry.iLength;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
			}
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    65
		if (cumulativeParaLength != (DocumentLength() + 1))
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    66
		    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    67
		    OstTrace0( TRACE_DUMP, DUP2_CRICHTEXT_DBGTESTINVARIANT, "Invariant" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    68
		    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
		__ASSERT_DEBUG(cumulativeParaLength == (DocumentLength() + 1), User::Invariant());
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
		// Change here for defect INC005336.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
		// This defect is present when the assertion below fails.
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    73
        if ((iParserData != NULL) &&
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    74
                (iParserData->HaveRange()) &&
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    75
                (iParserData->EndParse() > DocumentLength()))
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    76
            {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    77
            OstTrace0( TRACE_DUMP, DUP3_CRICHTEXT_DBGTESTINVARIANT, "Invariant" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    78
            }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
		__ASSERT_DEBUG( (iParserData == NULL) || \
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
			(!iParserData->HaveRange()) || \
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
			(iParserData->EndParse() <= DocumentLength()), User::Invariant());
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
#endif
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
EXPORT_C CRichText* CRichText::NewL(const CParaFormatLayer* aGlobalParaLayer,const CCharFormatLayer* aGlobalCharLayer,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
									TDocumentStorage aStorage,TInt aDefaultTextGranularity,TParaType aParaType)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
/** Allocates and constructs an empty rich text object, with a global character
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88
and paragraph format layer. A single end-of-document delimiter is inserted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    89
No style list is allocated.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    91
@param aGlobalParaLayer Pointer to the paragraph format layer referenced by
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    92
the rich text object. Must not be NULL, or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
@param aGlobalCharLayer Pointer to the character format layer referenced by
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    94
the rich text object. Must not be NULL, or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    95
@param aStorage The type of in-memory buffer to use. Defaults to ESegmentedStorage
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
which should rarely need to be changed.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    97
@param aDefaultTextGranularity Specifies the granularity of the in-memory buffer.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    98
Default is EDefaultTextGranularity bytes (=256), and this should rarely need
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
to be changed.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
@param aParaType This argument indicates whether you are using a single paragraph
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
or multiple paragraphs, and thus affects the granularity of aggregate objects
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
used internally for storing paragraph attributes. Default = EMultiPara.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
@return The rich text object. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
	// Create new rich text containing just a single end-of-document character.
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   106
	if (aGlobalParaLayer == NULL)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   107
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   108
	    OstTrace0( TRACE_FATAL, CRICHTEXT_NEWL, "ENullFormatLayerHandle" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   109
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
	__ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   111
	if (aGlobalCharLayer == NULL)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   112
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   113
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_NEWL, "ENullFormatLayerHandle" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   114
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
	__ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   116
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   117
	CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   118
	CleanupStack::PushL(self);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   119
	self->ConstructL(aStorage, aDefaultTextGranularity, aParaType);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
	CleanupStack::Pop();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   121
	return self;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   122
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   124
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   125
// Create new rich text that supports Paragraph Styles, containing just a single end-of-document character.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   126
EXPORT_C CRichText* CRichText::NewL(const CParaFormatLayer* aGlobalParaLayer,const CCharFormatLayer* aGlobalCharLayer,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   127
									const CStyleList& aStyleList,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
									TDocumentStorage aStorage,TInt aDefaultTextGranularity,TParaType aParaType)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
/** Allocates and constructs an empty rich text object which supports styles. It
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130
is constructed with a global character and paragraph format layer and a style
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   131
list. A single end-of-document delimiter is inserted. The rich text object
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   132
takes ownership of the style list.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   133
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   134
Note:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   135
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   136
A rich text object not constructed with a style list may still use styles,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   137
by calling SetStyleListExternallyOwned() at any time after construction. In
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   138
this case, the rich text object does not own the style list.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   139
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   140
@param aGlobalParaLayer Pointer to the paragraph format layer referenced by
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   141
the rich text object. Must not be NULL, or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   142
@param aGlobalCharLayer Pointer to the character format layer referenced by
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   143
the rich text object. Must not be NULL, or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   144
@param aStyleList Style list. Holds the set of paragraph styles which can be
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   145
used in the rich text object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   146
@param aStorage The type of in-memory buffer to use. Defaults to ESegmentedStorage
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   147
which should rarely need to be changed.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   148
@param aDefaultTextGranularity Specifies the granularity of the in-memory buffer.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   149
Default is EDefaultTextGranularity bytes (=256), and this should rarely need
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   150
to be changed.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   151
@param aParaType This argument indicates whether you are using a single paragraph
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   152
or multiple paragraphs, and thus affects the granularity of aggregate objects
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   153
used internally for storing paragraph attributes. Default = EMultiPara.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   154
@return The new rich text object. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   155
	{
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   156
	if (aGlobalParaLayer == NULL)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   157
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   158
	    OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_NEWL, "ENullFormatLayerHandle" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   159
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   160
	__ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   161
	if (aGlobalCharLayer == NULL)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   162
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   163
	    OstTrace0( TRACE_FATAL, DUP3_CRICHTEXT_NEWL, "ENullFormatLayerHandle" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   164
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   165
	__ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   166
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   167
	CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer, CONST_CAST(CStyleList*, &aStyleList));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   168
	CleanupStack::PushL(self);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   169
	self->ConstructL(aStorage, aDefaultTextGranularity, aParaType);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   170
	CleanupStack::Pop();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   171
	return self;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   172
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   173
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   174
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   175
// Restore into a new rich text object, using the specified global layers.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   176
EXPORT_C CRichText* CRichText::NewL(const CStreamStore& aStore,TStreamId aStreamId,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   177
									const CParaFormatLayer* aGlobalParaLayer,const CCharFormatLayer* aGlobalCharLayer,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   178
									MTextFieldFactory* aFieldFactory,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   179
									TDocumentStorage aStorage)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   180
/** Allocates and constructs a rich text object with a field factory. Its text
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   181
content is internalized from a stream store.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   182
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   183
Note:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   184
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   185
A rich text object not constructed with a field factory may still support
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   186
the addition of fields, by calling SetFieldFactory(), defined in the base
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   187
class CPlainText.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   188
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   189
@param aStore Stream store from which the object is restored.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   190
@param aStreamId ID of the stream store.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   191
@param aGlobalParaLayer Pointer to the paragraph format layer referenced by
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   192
the rich text object. Must not be NULL, or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   193
@param aGlobalCharLayer Pointer to the character format layer referenced by
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   194
the rich text object. Must not be NULL, or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   195
@param aFieldFactory Pointer to a field factory. A field factory must be provided
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   196
if the text object supports fields.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   197
@param aStorage The type of in-memory buffer to use. Defaults to ESegmentedStorage
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   198
which should rarely need to be changed.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   199
@return The new rich text object. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   200
	{
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   201
	if (aGlobalParaLayer == NULL)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   202
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   203
	    OstTrace0( TRACE_FATAL, DUP4_CRICHTEXT_NEWL, "ENullFormatLayerHandle" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   204
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   205
	__ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   206
	if (aGlobalCharLayer == NULL)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   207
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   208
	    OstTrace0( TRACE_FATAL, DUP5_CRICHTEXT_NEWL, "ENullFormatLayerHandle" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   209
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   210
	__ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   211
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   212
	CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   213
	CleanupStack::PushL(self);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   214
	self->ConstructL(aStore, aStreamId, NULL, NULL, aFieldFactory, aStorage);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   215
	CleanupStack::Pop();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   216
	return self;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   217
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   218
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   219
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   220
EXPORT_C CRichText* CRichText::NewL(const CStreamStore& aStore, TStreamId aStreamId,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   221
									const CParaFormatLayer* aGlobalParaLayer, const CCharFormatLayer* aGlobalCharLayer,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   222
									MPictureFactory* aPictureFactory, MRichTextStoreResolver* aStoreResolver,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   223
									MTextFieldFactory* aFieldFactory,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   224
									TDocumentStorage aStorage)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   225
/** Allocates and constructs a rich text object with a field factory and a picture
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   226
factory. Its text content is internalized from a stream store.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   227
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   228
Note:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   229
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   230
A rich text object not constructed with a field factory may still support
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   231
the addition of fields, by calling SetFieldFactory(), defined in the base
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   232
class CPlainText.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   233
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   234
@param aStore Stream store from which the object is restored.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   235
@param aStreamId ID of the stream store.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   236
@param aGlobalParaLayer Pointer to the paragraph format layer referenced by
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   237
the rich text object. Must not be NULL, or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   238
@param aGlobalCharLayer Pointer to the character format layer referenced by
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   239
the rich text object. Must not be NULL, or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   240
@param aPictureFactory The picture factory. This is needed to load pictures
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   241
into memory, (see PictureHandleL()). If a store resolver is specified (not
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   242
NULL), then a factory must also be specified, or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   243
@param aStoreResolver A store resolver. This determines which file store the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   244
picture is stored in. It is used to get from a reference to an embedded picture
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   245
within a CRichText object to the actual picture itself. Picture loading is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   246
done by the picture factory.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   247
@param aFieldFactory Pointer to a field factory. A field factory must be provided
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   248
if the text object supports fields.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   249
@param aStorage The type of in-memory buffer to use. Defaults to ESegmentedStorage
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   250
which should rarely need to be changed.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   251
@return The new rich text object. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   252
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   253
	// Restore a new rich text from the specified stream, that uses the specified global layers, and the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   254
	// specified picture header factory and store, if this rich text supports pictures.
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   255
	if (!aPictureFactory && aStoreResolver)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   256
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   257
	    OstTrace0( TRACE_FATAL, DUP6_CRICHTEXT_NEWL, "EInvalidPictureFactorySettings" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   258
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   259
	__ASSERT_ALWAYS(!(!aPictureFactory && aStoreResolver), Panic(EInvalidPictureFactorySettings));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   260
	if (aGlobalParaLayer == NULL)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   261
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   262
	    OstTrace0( TRACE_FATAL, DUP7_CRICHTEXT_NEWL, "ENullFormatLayerHandle" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   263
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   264
	__ASSERT_ALWAYS(aGlobalParaLayer != NULL, Panic(ENullFormatLayerHandle));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   265
	if (aGlobalCharLayer == NULL)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   266
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   267
	    OstTrace0( TRACE_FATAL, DUP8_CRICHTEXT_NEWL, "ENullFormatLayerHandle" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   268
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   269
	__ASSERT_ALWAYS(aGlobalCharLayer != NULL, Panic(ENullFormatLayerHandle));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   270
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   271
	CRichText* self = new(ELeave) CRichText(aGlobalParaLayer, aGlobalCharLayer);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   272
	CleanupStack::PushL(self);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   273
	self->ConstructL(aStore, aStreamId, aPictureFactory, aStoreResolver, aFieldFactory, aStorage);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   274
	CleanupStack::Pop();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   275
	return self;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   276
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   277
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   278
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   279
EXPORT_C CRichText::CRichText(const CParaFormatLayer* aGlobalParaLayer, const CCharFormatLayer* aGlobalCharLayer,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   280
							  CStyleList* aStyleList):
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   281
	CGlobalText(aGlobalParaLayer, aGlobalCharLayer),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   282
	iStyleList(aStyleList)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   283
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   284
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   285
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   286
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   287
EXPORT_C void CRichText::ConstructL(TDocumentStorage aStorage, TInt aDefaultTextGranularity, TParaType aParaType)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   288
// Initialises and updates the index following the CPlainText::ConstructL
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   289
// insertion of the end-of-document character.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   290
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   291
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   292
	CPlainText::ConstructL(aStorage, aDefaultTextGranularity);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   293
	SetParaTypeIsSingle(aParaType == ESinglePara);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   294
	iParserData = new(ELeave) CParserData(DocumentLength());
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   295
	TInt a;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   296
	TInt b;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   297
	ParseText(a, b, ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   298
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   299
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   300
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   301
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   302
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   303
EXPORT_C void CRichText::ConstructL(const CStreamStore& aStore,TStreamId aStreamId,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   304
									MPictureFactory* aPictureFactory, MRichTextStoreResolver* aStoreResolver,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   305
									MTextFieldFactory* aFieldFactory,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   306
									TDocumentStorage aStorage)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   307
// Initialises and updates the index following the CPlainText::ConstructL
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   308
// insertion of the end-of-document character.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   309
// Sets the picture header factory if provided.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   310
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   311
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   312
	CPlainText::ConstructL(aStore, aStreamId, aFieldFactory, aStorage);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   313
	SetPictureFactory(aPictureFactory, aStoreResolver);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   314
	if (iParserData == NULL)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   315
		iParserData = new(ELeave) CParserData(DocumentLength());
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   316
	TInt a;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   317
	TInt b;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   318
	ParseText(a, b, ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   319
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   320
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   321
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   322
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   323
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   324
EXPORT_C CRichText::~CRichText()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   325
/** The destructor frees all resources owned by the rich text object, prior to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   326
its destruction. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   327
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   328
	// We cannot call DestroyParserSystem() here because it applies to all instances in the thread
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   329
	delete iParserData;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   330
	KillStyleList();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   331
	KillIndex();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   332
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   333
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   334
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   335
void CRichText::KillStyleList()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   336
// Free up the style table
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   337
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   338
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   339
	if (StyleListPresent() && !StyleListExternallyOwned())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   340
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   341
		delete iStyleList.AsPtr();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   342
		iStyleList = NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   343
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   344
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   345
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   346
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   347
void CRichText::KillIndex()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   348
// Delete the rich text index if it's resident in memory.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   349
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   350
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   351
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   352
		delete iIndex.AsPtr();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   353
	iIndex=NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   354
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   355
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   356
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   357
TBool CRichText::CreateEmptyMarkupComponentL()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   358
// If necessary, creates an empty markup component.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   359
// Returns ETrue if the markup component was created as a result of this function,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   360
// otherwise returns EFalse.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   361
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   362
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   363
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   364
		return EFalse;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   365
	TInt paraGran = (ParaTypeIsSingle()) ? KSingleParaGranularity : KMultiParaGranularity;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   366
	TInt phrGran = (ParaTypeIsSingle()) ? KSmallPhraseGranularity : KLargePhraseGranularity;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   367
	iIndex = CRichTextIndex::NewL(iGlobalParaFormatLayer, iGlobalCharFormatLayer, *this,paraGran,phrGran);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   368
	return ETrue;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   369
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   370
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   371
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   372
void CRichText::CreateAndGenerateMarkupComponentL()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   373
// Checks if the rich text index needs to be created and does so if necessary.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   374
// Called by all public rich text functions that manipulate specific formatting.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   375
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   376
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   377
	if (CreateEmptyMarkupComponentL())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   378
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   379
		TRAPD(ret, GenerateMarkupL());
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   380
		if (ret != KErrNone)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   381
			{// destroy this partially set markup component
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   382
			delete iIndex.AsPtr();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   383
			iIndex = NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   384
			User::Leave(ret);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   385
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   386
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   387
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   388
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   389
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   390
void CRichText::GenerateMarkupL()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   391
// Generate markup data corresponding to the current text content.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   392
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   393
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   394
	TInt remainingLength = DocumentLength();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   395
	TInt startPos = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   396
	while (remainingLength)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   397
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   398
		TPtrC buf = Read(startPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   399
		TInt consumed = buf.Length();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   400
		if (consumed > remainingLength)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   401
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   402
			consumed = remainingLength;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   403
			buf.Set(buf.Ptr(), consumed);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   404
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   405
		iIndex->InsertL(startPos, buf, *iGlobalParaFormatLayer);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   406
		remainingLength -= consumed;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   407
		startPos += consumed;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   408
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   409
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   410
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   411
EXPORT_C void CRichText::CopyToStoreL(CStreamStore& aStore,CStreamDictionary& aDictionary,TInt aPos,TInt aLength) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   412
/** Copies a portion of the rich text object, with components to the clipboard.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   413
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   414
A panic occurs in the following circumstances:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   415
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   416
aPos is an invalid document position
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   417
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   418
aLength is invalid (zero or less)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   419
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   420
the sum of aPos and aLength is greater than or equal to the number of characters
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   421
in the document
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   422
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   423
@param aStore Stream store to which the rich text is written.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   424
@param aDictionary The stream dictionary.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   425
@param aPos The document position from which to begin copying.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   426
@param aLength The number of characters to copy. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   427
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   428
	if (aLength > 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   429
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   430
		TStreamId plainTextId = CPlainText::DoCopyToStoreL(aStore,aDictionary,aPos,aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   431
		TStreamId id = DoCopyToStoreL(aStore,aPos,aLength,plainTextId,FALSE);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   432
		aDictionary.AssignL(KClipboardUidTypeRichText,id);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   433
		TStreamId idStyles = DoCopyToStoreL(aStore,aPos,aLength,plainTextId,TRUE);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   434
		aDictionary.AssignL(KClipboardUidTypeRichTextWithStyles,idStyles);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   435
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   436
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   437
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   438
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   439
// Copy the selected region of rich text, with components, to the specified store.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   440
TStreamId CRichText::DoCopyToStoreL(CStreamStore& aStore,TInt aPos,TInt aLength,TStreamId aPlainTextId,TBool aCopyStyles) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   441
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   442
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   443
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   444
	TInt documentLength = DocumentLength();
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   445
	if (aPos < 0 || aPos > documentLength)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   446
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   447
	    OstTrace0( TRACE_FATAL, CRICHTEXT_DOCOPYTOSTOREL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   448
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   449
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= documentLength,Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   450
	if (aLength < 0)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   451
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   452
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DOCOPYTOSTOREL, "ECopyToClipboardNegativeLength" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   453
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   454
	__ASSERT_ALWAYS(aLength >= 0,Panic(ECopyToClipboardNegativeLength));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   455
	if (aPos + aLength > documentLength)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   456
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   457
	    OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_DOCOPYTOSTOREL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   458
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   459
	__ASSERT_ALWAYS(aPos + aLength <= documentLength,Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   460
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   461
	if (aLength == 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   462
		return KNullStreamId;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   463
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   464
	CStoreMap* map = CStoreMap::NewLC(aStore);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   465
	CopyComponentsL(aStore,*map,aPos,aLength,aPlainTextId);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   466
	RStoreWriteStream stream(*map);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   467
	TStreamId id = stream.CreateLC(aStore);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   468
	CopyToStreamL(stream,aPos,aLength,aPlainTextId,aCopyStyles);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   469
	stream.CommitL();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   470
	map->Reset();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   471
	CleanupStack::PopAndDestroy(2);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   472
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   473
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   474
	return id;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   475
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   476
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   477
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   478
EXPORT_C void CRichText::CopyComponentsL(CStreamStore& aStore,CStoreMap& aMap,TInt aPos,TInt aLength,TStreamId aPlainTextId) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   479
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   480
	if (aPlainTextId == KNullStreamId)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   481
		CPlainText::CopyComponentsL(aStore,aMap,aPos,aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   482
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   483
		iIndex->StorePicturesL(aStore,aMap,aPos,aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   484
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   485
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   486
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   487
// Copy the selected region of rich text and components to the specified stream.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   488
EXPORT_C void CRichText::CopyToStreamL(RWriteStream& aStream,TInt aPos,TInt aLength) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   489
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   490
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   491
	CopyToStreamL(aStream, aPos, aLength, KNullStreamId);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   492
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   493
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   494
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   495
/*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   496
Copy the selected region of rich text and components to the specified stream.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   497
If aPlainTextId is NULL the plain text component is stored in-line,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   498
otherwise the reference to the plain text stream component is stored.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   499
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   500
EXPORT_C void CRichText::CopyToStreamL(RWriteStream& aStream,TInt aPos,TInt aLength,TStreamId aPlainTextId) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   501
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   502
	CopyToStreamL(aStream,aPos,aLength,aPlainTextId,TRUE);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   503
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   504
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   505
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   506
void CRichText::CopyToStreamL(RWriteStream& aStream,TInt aPos,TInt aLength,TStreamId aPlainTextId,TBool aCopyStyles) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   507
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   508
	if (aPlainTextId == KNullStreamId)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   509
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   510
		aStream.WriteUint8L(TRUE);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   511
		CPlainText::CopyToStreamL(aStream,aPos,aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   512
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   513
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   514
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   515
		aStream.WriteUint8L(FALSE);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   516
		aStream << aPlainTextId;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   517
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   518
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   519
	if (!IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   520
		CONST_CAST(CRichText*,this)->CreateAndGenerateMarkupComponentL();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   521
	aStream.WriteUint8L(TRUE);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   522
	iIndex->CopyToStreamL(aStream,aPos,aLength,aCopyStyles);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   523
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   524
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   525
EXPORT_C TInt CRichText::PasteFromStoreL(const CStreamStore& aStore, const CStreamDictionary& aDictionary, TInt aPos, CParagraphStyle::TStylePasteMode aStylePasteMode)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   526
/** Pastes the contents of the clipboard into the rich text object at the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   527
specified document position. Returns the number of characters pasted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   528
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   529
If the text in the clipboard has been formatted using styles, the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   530
aStylePasteMode argument indicates whether the styles should be preserved
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   531
or discarded. If the argument is not specified, the pasted rich text
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   532
retains all formatting specified in the styles, and any new style
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   533
definitions are added to the style list of the rich text object into which
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   534
it is pasted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   535
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   536
@param aStore The stream store from which to paste the rich text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   537
@param aDictionary The stream dictionary.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   538
@param aPos The document position at which to paste the rich text. Must be
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   539
valid, or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   540
@param aStylePasteMode Indicates whether styles in the pasted text should be
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   541
preserved or discarded.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   542
@return The number of characters pasted. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   543
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   544
	return DoPasteRtFromStoreL(aStore, aDictionary, aPos, aStylePasteMode);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   545
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   546
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   547
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   548
EXPORT_C TInt CRichText::PasteFromStoreL(const CStreamStore& aStore, const CStreamDictionary& aDictionary, TInt aPos)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   549
// Paste the lesser of i) aMaxPasteLength ii) the entire clipboard contents.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   550
// Return a count of the number of characters pasted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   551
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   552
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   553
	return DoPasteRtFromStoreL(aStore, aDictionary, aPos, CParagraphStyle::EAddNewStyles);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   554
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   555
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   556
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   557
TInt CRichText::DoPasteRtFromStoreL(const CStreamStore& aStore, const CStreamDictionary& aDictionary, TInt aPos, CParagraphStyle::TStylePasteMode aStylePasteMode)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   558
// Paste the rich text data from the specified clipboard, inserting it into this
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   559
// instance at character position aPos.  Returns the number of characters pasted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   560
// May be 0.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   561
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   562
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   563
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   564
	if (aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   565
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   566
	    OstTrace0( TRACE_FATAL, CRICHTEXT_DOPASTERTFROMSTOREL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   567
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   568
	__ASSERT_ALWAYS(aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   569
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   570
	TUid type = KClipboardUidTypeRichTextWithStyles;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   571
	TStreamId id = aDictionary.At(type);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   572
	if (id == KNullStreamId)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   573
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   574
		type = KClipboardUidTypeRichText;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   575
		id = aDictionary.At(type);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   576
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   577
	if (id == KNullStreamId)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   578
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   579
		type = KClipboardUidTypePlainText;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   580
		id = aDictionary.At(type);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   581
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   582
	TInt consumed = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   583
	if (id == KNullStreamId)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   584
		return consumed;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   585
	if (type == KClipboardUidTypeRichText || type == KClipboardUidTypeRichTextWithStyles)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   586
		consumed = PasteRichTextFromStoreL(aStore, aDictionary, id, aPos, aStylePasteMode);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   587
	else if (type == KClipboardUidTypePlainText)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   588
		consumed = PastePlainTextFromStoreL(aStore, id, aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   589
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   590
	if (consumed)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   591
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   592
		iParserData->MergeRange(aPos,0,consumed);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   593
		CallEditObserver(aPos, consumed);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   594
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   595
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   596
	SetHasChanged(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   597
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   598
	return consumed;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   599
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   600
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   601
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   602
TInt CRichText::PasteRichTextFromStoreL(const CStreamStore& aStore, const CStreamDictionary& aDictionary, TStreamId& aRichTextStreamId, TInt aPos,CParagraphStyle::TStylePasteMode aStylePasteMode)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   603
// Paste the plain text stream, then open and paste the rich text markup from the specified stream.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   604
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   605
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   606
	if (!IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   607
		CreateAndGenerateMarkupComponentL();  // create the index if it does not already exist
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   608
	TStreamId id = aDictionary.At(KClipboardUidTypePlainText);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   609
// ASSERT: We have rich text, so the plain text stream must exist.
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   610
	if (id == KNullStreamId)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   611
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   612
	    OstTrace0( TRACE_FATAL, CRICHTEXT_PASTERICHTEXTFROMSTOREL, "EClipboardIntegrity" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   613
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   614
	__ASSERT_ALWAYS(id != KNullStreamId,Panic(EClipboardIntegrity));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   615
	TInt consumed = CPlainText::DoPasteFromStoreL(aStore, id, aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   616
	TRAPD(ret, CompletePasteRichTextFromStoreL(aStore, aRichTextStreamId, aPos, aStylePasteMode));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   617
	if (ret != KErrNone)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   618
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   619
		CPlainText::Delete(aPos,consumed);
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   620
		OstTrace1( TRACE_FATAL, DUP1_CRICHTEXT_PASTERICHTEXTFROMSTOREL, "Leave code=%d", ret );
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   621
		User::Leave(ret);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   622
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   623
	return consumed;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   624
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   625
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   626
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   627
void CRichText::CompletePasteRichTextFromStoreL(const CStreamStore& aStore, TStreamId& aRichTextStreamId, TInt aPos, CParagraphStyle::TStylePasteMode aStylePasteMode)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   628
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   629
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   630
	RStoreReadStream stream;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   631
	stream.OpenLC(aStore, aRichTextStreamId);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   632
	TBool plainTextInline = (TBool)stream.ReadUint8L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   633
	if (!plainTextInline)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   634
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   635
		TStreamId dummy;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   636
		stream >> dummy;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   637
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   638
	TBool markupPresentInClipboard = (TBool)stream.ReadUint8L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   639
	if (markupPresentInClipboard)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   640
		iIndex->PasteFromStreamL(aStore, stream, aPos,aStylePasteMode, iGlobalParaFormatLayer, iGlobalCharFormatLayer);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   641
	CleanupStack::PopAndDestroy();  // stream
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   642
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   643
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   644
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   645
TInt CRichText::PastePlainTextFromStoreL(const CStreamStore& aStore, TStreamId& anId, TInt aPos)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   646
// Paste the plain text stream, then update the rich text index to show any paragraph delimiters pasted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   647
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   648
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   649
	TInt consumed = CPlainText::DoPasteFromStoreL(aStore, anId, aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   650
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   651
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   652
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   653
		TRAPD(ret, CompletePastePlainTextL(aPos, consumed));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   654
		if (ret != KErrNone)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   655
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   656
			CPlainText::Delete(aPos,consumed);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   657
			User::Leave(ret);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   658
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   659
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   660
	return consumed;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   661
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   662
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   663
void CRichText::CompletePastePlainTextL(TInt aPos, TInt aCharacterCount)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   664
// Updates the rich text index following the pasting of global text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   665
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   666
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   667
	HBufC* buf = HBufC::NewLC(aCharacterCount);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   668
	TPtr bf = buf->Des();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   669
	Extract(bf, aPos, aCharacterCount);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   670
	iIndex->InsertL(aPos, bf, *iGlobalParaFormatLayer);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   671
	CleanupStack::PopAndDestroy();  // buf
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   672
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   673
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   674
EXPORT_C void CRichText::Reset()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   675
/** Resets the document's contents to a single end-of-document delimiter. Also
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   676
deletes the style list if owned by the object. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   677
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   678
	// Resets document contents to single end-of-document charcter,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   679
	// and resets the index to match document content.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   680
	TInt length = DocumentLength();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   681
	CPlainText::Reset();  // remove all content bar eod character
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   682
	KillStyleList();  // does not get destroyed if externally owned
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   683
	KillIndex();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   684
	SetHasChanged(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   685
	iParserData->KillRange();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   686
	iParserData->iLastKnownCursor = -1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   687
	CallEditObserver(0, -length);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   688
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   689
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   690
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   691
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   692
EXPORT_C void CRichText::InsertL(TInt aPos, const TChar& aChar)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   693
/** Inserts either a single character or a descriptor into the text object
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   694
at a specified document position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   695
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   696
The insertion position must be valid or a panic occurs.Note:A panic
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   697
occurs if the text object is in an "insert pending" state (i.e.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   698
SetInsertCharFormatL() has been called and has not been
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   699
cancelled using CancelInsertCharFormat()) and aPos is not
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   700
the same as the insertion point.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   701
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   702
@param aPos The document position at which to insert the character/descriptor.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   703
@param aChar The character to insert. Must not be a picture character or a
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   704
panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   705
@param aBuf The descriptor to insert. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   706
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   707
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   708
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   709
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   710
	    OstTrace0( TRACE_FATAL, CRICHTEXT_INSERTL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   711
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   712
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   713
	if (aChar == EPictureCharacter)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   714
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   715
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_INSERTL, "ENonOverloadedInsertCalledWithPictureCharacter" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   716
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   717
	__ASSERT_ALWAYS(aChar!= EPictureCharacter, Panic(ENonOverloadedInsertCalledWithPictureCharacter));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   718
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   719
	if (aChar < 0x10000)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   720
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   721
		TBuf<1> content;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   722
		content.Append(aChar);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   723
		RtInsertL(aPos, content);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   724
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   725
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   726
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   727
		TText16 high = TChar::GetHighSurrogate(aChar);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   728
		TText16 low = TChar::GetLowSurrogate(aChar);
37
6be019398652 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 32
diff changeset
   729
		RDebug::Print(_L("CRichText::InsertL(), %X expand to %X %X."), TUint(aChar), high, low);
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   730
		
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   731
		TBuf<2> content;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   732
		content.Append(high);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   733
		content.Append(low);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   734
		RtInsertL(aPos, content);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   735
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   736
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   737
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   738
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   739
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   740
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   741
EXPORT_C void CRichText::InsertL(TInt aPos, const TDesC& aBuf)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   742
// Inserts the contents of aBuf into the text component at character position aPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   743
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   744
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   745
	__ETEXT_WATCH(INSERT_DESC);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   746
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   747
	RtInsertL(aPos, aBuf);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   748
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   749
	__ETEXT_WATCH_END(INSERT_DESC);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   750
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   751
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   752
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   753
EXPORT_C void CRichText::RtInsertL(TInt aPos, const TDesC& aBuf)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   754
// Inserts the contents a aBuf into the text component at position aPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   755
// Updates the index accordingly, and accounts for all embedded paragraph delimiters
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   756
// in the passed buffer aBuf.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   757
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   758
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   759
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   760
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   761
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   762
	    OstTrace0( TRACE_FATAL, CRICHTEXT_RTINSERTL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   763
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   764
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   765
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   766
	int length = aBuf.Length();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   767
	CPlainText::InsertL(aPos, aBuf);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   768
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   769
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   770
		TRAPD(ret, iIndex->InsertL(aPos, aBuf, *iGlobalParaFormatLayer));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   771
		if (ret != KErrNone)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   772
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   773
			CPlainText::Delete(aPos,length);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   774
			User::Leave(ret);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   775
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   776
		SetHasChanged(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   777
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   778
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   779
	iParserData->MergeRange(aPos,0,length);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   780
	CallEditObserver(aPos,length);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   781
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   782
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   783
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   784
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   785
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   786
EXPORT_C void CRichText::InsertL(TInt aPos,const TPictureHeader& aHeader)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   787
/**Inserts a picture header into the text object at a specified document
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   788
position. The picture header specified must reference a valid picture, or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   789
a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   790
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   791
A panic also occurs if the text object is in an "insert pending" state
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   792
(SetInsertCharFormatL() has been called and has not been cancelled using
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   793
CancelInsertCharFormat()) and aPos is not the same as the insertion point.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   794
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   795
This method takes ownership of a picture referenced in aHeader.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   796
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   797
@param aPos The document position at which to insert the picture header. Must
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   798
be valid, or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   799
@param aHeader A picture header. This holds a pointer to the picture to insert,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   800
and information about the picture. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   801
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   802
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   803
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   804
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   805
	    OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_INSERTL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   806
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   807
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   808
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   809
	CleanupStack::PushL(aHeader.iPicture);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   810
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   811
	if (!IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   812
		CreateAndGenerateMarkupComponentL();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   813
	TBuf<1> picture;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   814
	picture.Append(EPictureCharacter);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   815
	CPlainText::InsertL(aPos, picture);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   816
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   817
    CleanupStack::Pop(aHeader.iPicture);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   818
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   819
	TBool pictureOwnershipTaken(EFalse);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   820
	TRAPD(ret, iIndex->InsertL(aPos, aHeader,pictureOwnershipTaken));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   821
	if (ret != KErrNone)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   822
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   823
		if(!pictureOwnershipTaken)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   824
		    {
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   825
		    const_cast <TPictureHeader&> (aHeader).DeletePicture();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   826
		    }
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   827
		CPlainText::Delete(aPos,picture.Length());  // remove the picture place-holder
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   828
    	User::Leave(ret);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   829
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   830
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   831
	SetHasChanged(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   832
	iParserData->MergeRange(aPos,0,1);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   833
	CallEditObserver(aPos,1);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   834
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   835
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   836
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   837
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   838
EXPORT_C TBool CRichText::DeleteL(TInt aPos, TInt aLength)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   839
/** Deletes one or more characters beginning at, and including, the character at
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   840
a specified document position. Can leave because paragraphs may be merged
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   841
and reformatted by the function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   842
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   843
@param aPos The start of the range of characters to delete. Must be valid
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   844
or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   845
@param aLength The number of characters to delete. Must be positive or a panic
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   846
occurs. The sum of aPos and aLength must be less than the document length,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   847
or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   848
@return Indicates whether two paragraphs have been merged as a result of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   849
delete, indicating that the formatting of part of the resulting paragraph
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   850
may have changed. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   851
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   852
	// Deletes aRange number of characters from the text component
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   853
	// and the corresponding index data.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   854
	// Delete commences at, and includes, character position aPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   855
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   856
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   857
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   858
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   859
	    OstTrace0( TRACE_FATAL, CRICHTEXT_DELETEL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   860
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   861
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   862
	if (aLength < 0)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   863
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   864
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DELETEL, "EDebugDeleteZeroLength" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   865
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   866
	__ASSERT_ALWAYS(aLength >= 0, Panic(EDebugDeleteZeroLength));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   867
	if (aPos + (aLength - 1) > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   868
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   869
	    OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_DELETEL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   870
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   871
	__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   872
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   873
	TBool requireMerge = EFalse;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   874
	if (!IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   875
		CPlainText::Delete(aPos,aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   876
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   877
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   878
		iIndex->CancelInsertCharFormat();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   879
		TIndexDeleteInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   880
		iIndex->SetForDeleteL(info, aPos, aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   881
		CPlainText::Delete(aPos,aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   882
		requireMerge = iIndex->DeleteNow(info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   883
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   884
	iParserData->MergeRange(aPos,aLength,0);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   885
	CallEditObserver(aPos,-aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   886
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   887
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   888
	return requireMerge;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   889
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   890
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   891
EXPORT_C void CRichText::DeleteParagraph(TInt aPos, TInt aLength)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   892
/** Deletes one or more whole paragraphs of text. No paragraphs can be merged together
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   893
by this function, so it cannot leave it must only be used to delete entire
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   894
paragraphs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   895
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   896
@param aPos The document position of the start of the first paragraph to delete.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   897
Must be a valid position or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   898
@param aLength The number of characters to delete. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   899
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   900
	// Use to remove entire paragraphs of text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   901
	// Leave-safe if called in this context.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   902
	// MUST NOT CALL if not in this context.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   903
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   904
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   905
	// Store the length of the text before we commence with deletions.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   906
	TInt initialDocLen=DocumentLength();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   907
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   908
	if (aPos < 0 || aPos > initialDocLen)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   909
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   910
	    OstTrace0( TRACE_FATAL, CRICHTEXT_DELETEPARAGRAPH, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   911
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   912
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= initialDocLen, Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   913
	if (aPos + aLength > initialDocLen + 1)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   914
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   915
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DELETEPARAGRAPH, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   916
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   917
	__ASSERT_ALWAYS(aPos + aLength <= initialDocLen + 1, Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   918
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   919
	if (aLength <= 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   920
		return;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   921
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   922
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   923
		iIndex->DeleteParagraph(aPos, aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   924
	CPlainText::Delete(aPos,aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   925
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   926
	// Change here for defect INC005336.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   927
	// Previously the MergeRange call (see else line) was incorrectly handling
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   928
	// the scenario where all but the first paragraph was deleted e.g. pasting
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   929
	// multi line buffer into a single line text control in a new email on Techview
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   930
	// emulator.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   931
	// This was because the deletion in the two lines above would delete the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   932
	// 'end-of-text' maker causing the iEndParse member of CParserData to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   933
	// index the char right after the end of test marker. This would panic
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   934
	// plugin parsers thatsubsquently executed.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   935
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   936
	if (aPos+aLength > initialDocLen)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   937
		// When deletion includes the end-of-text marker, adjust start
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   938
		// supplied so that it appears to MergeRange that we are
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   939
		// deleting the paragraph and CR just before it which belongs
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   940
		// to the previous paragraph and not the end-of-text marker.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   941
		// This is actually the end result of the deletion anyway!
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   942
		iParserData->MergeRange(initialDocLen-aLength,aLength,0);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   943
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   944
		// All other deletions which don't.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   945
		iParserData->MergeRange(aPos,aLength,0);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   946
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   947
	CallEditObserver(aPos,-aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   948
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   949
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   950
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   951
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   952
EXPORT_C void CRichText::DeleteFromParagraph(TInt aPos, TInt aLength)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   953
/** Removes a range of characters from within a single paragraph only. Should not
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   954
be used for deleting an entire paragraph or paragraphs because this may cause
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   955
it to leave. Otherwise, it is guaranteed not to leave.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   956
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   957
@param aPos The document position of the start of the range of characters
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   958
to delete. Must be a valid document position, or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   959
@param aLength The number of characters to delete. The sum of aPos and aLength
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   960
must be less than the document length, or a panic occurs. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   961
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   962
	// Removes aLength characters from *within* a single paragraph only.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   963
	// Guaranteed not to leave if this pre-condition holds true.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   964
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   965
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   966
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   967
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   968
	    OstTrace0( TRACE_FATAL, CRICHTEXT_DELETEFROMPARAGRAPH, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   969
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   970
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   971
	if (aPos + (aLength - 1) > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   972
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   973
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DELETEFROMPARAGRAPH, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
   974
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   975
	__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   976
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   977
	if (aLength <= 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   978
		return;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   979
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   980
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   981
		iIndex->DeleteFromParagraph(aPos, aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   982
	CPlainText::Delete(aPos,aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   983
	iParserData->MergeRange(aPos,aLength,0);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   984
	CallEditObserver(aPos,-aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   985
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   986
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   987
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   988
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   989
EXPORT_C TInt CRichText::ParagraphCount()const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   990
/** Gets a count of the number of paragraphs in the text object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   991
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   992
Note:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   993
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   994
The paragraph delimiter which terminates every text object means this function
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   995
always returns a count of at least one.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   996
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   997
@return The number of paragraphs in the document. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   998
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   999
	// Returns a count of the number of paragraphs
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1000
	// in the document.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1001
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1002
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1003
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1004
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1005
		return iIndex->ParagraphCount();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1006
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1007
		return CPlainText::ParagraphCount();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1008
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1009
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1010
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1011
EXPORT_C TEtextComponentInfo CRichText::ComponentInfo() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1012
/** Gets information about the number of components contained in the text object
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1013
(the field count, the picture count and the style count).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1014
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1015
@return Contains the component information. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1016
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1017
	return TEtextComponentInfo(FieldCount(), PictureCount(), StyleCount());
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1018
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1019
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1020
EXPORT_C TInt CRichText::CharPosOfParagraph(TInt& aLength, TInt aParaOffset) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1021
/** Finds the length and the start position of a paragraph identified by its
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1022
paragraph number. The first paragraph is numbered zero.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1023
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1024
Notes:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1025
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1026
if aParaOffset is invalid, (equal to or greater than the total number of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1027
paragraphs), the function's return value is EScanEndOfData (= -1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1028
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1029
@param aLength On return contains the length of the specified paragraph.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1030
@param aParaOffset The paragraph number. The first paragraph is numbered zero.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1031
@return The document position of the first character in the paragraph. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1032
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1033
	// Returns the character position of the first character of paragraph aParaOffset,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1034
	// where aParaOffset specifies the nth paragraph.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1035
	// The length of this nth paragraph is written to aLength.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1036
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1037
	// If aParaOffset specifies a paragraph that does not exist, EScanEndOfData is returned.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1038
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1039
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1040
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1041
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1042
		return iIndex->CharPosOfParagraph(aLength, aParaOffset);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1043
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1044
		return CPlainText::CharPosOfParagraph(aLength, aParaOffset);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1045
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1046
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1047
EXPORT_C TInt CRichText::ParagraphNumberForPos(TInt& aPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1048
/** Gets the number of the paragraph which contains a document position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1049
Paragraph numbering begins at zero.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1050
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1051
@param aPos A document position. Must be valid or a panic occurs. On return,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1052
contains the document position of the first character in the paragraph in
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1053
which it is located.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1054
@return The number of the paragraph containing the specified document position. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1055
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1056
	// Returns the paragraph offset for the specified character position aPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1057
	// aPos is in turn modified to hold the character position of the first character
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1058
	// of this paragraph.  If aPos is already on a paragraph boundary then do nothing.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1059
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1060
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1061
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1062
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1063
	    OstTrace0( TRACE_FATAL, CRICHTEXT_PARAGRAPHNUMBERFORPOS, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1064
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1065
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1066
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1067
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1068
		return iIndex->ParagraphNumberForPos(aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1069
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1070
		return CPlainText::ParagraphNumberForPos(aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1071
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1072
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1073
/** Applies character formatting to a zero length selection, for example
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1074
turning bold on. This has the effect that the formatting will be applied to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1075
text subsequently inserted at the position. This "insert pending" state is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1076
cancelled by calling CancelInsertCharFormat().
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1077
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1078
Note 1: After calling this function, if text is inserted at a different
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1079
position to aPos, a panic will occur, unless CancelInsertCharFormat() has been
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1080
called before the insertion to cancel the "insert pending" state.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1081
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1082
Note 2: If the insert character format is being set for the end of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1083
paragraph, the paragraph delimiter is set to that format as well. This helps
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1084
end-of-paragraph behaviour be more similar to other places.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1085
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1086
@param aFormat The character format values to apply.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1087
@param aMask Character format mask specifying the attributes affected.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1088
@param aPos The document position at which to insert the character format.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1089
@pre aPos must be a valid position, or a panic will occur. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1090
EXPORT_C void CRichText::SetInsertCharFormatL(const TCharFormat& aFormat,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1091
	const TCharFormatMask& aMask, TInt aPos)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1092
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1093
	SetExtendedInsertCharFormatL(aFormat, aMask,aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1094
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1095
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1096
void CancelInsertCharFormat(TAny* aCRichTextIndex)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1097
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1098
	reinterpret_cast<CRichTextIndex*>(aCRichTextIndex)->CancelInsertCharFormat();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1099
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1100
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1101
void CRichText::SetExtendedInsertCharFormatL(const TCharFormatX& aFormat, const TCharFormatXMask& aMask, TInt aPos)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1102
	{
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1103
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1104
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1105
	    OstTrace0( TRACE_FATAL, CRICHTEXT_SETEXTENDEDINSERTCHARFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1106
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1107
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1108
	CreateAndGenerateMarkupComponentL();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1109
	CRichTextIndex* index = iIndex.AsPtr();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1110
	if (index->InsertCharFormatIsActive())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1111
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1112
		TCharFormatX format = aFormat;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1113
        TCharFormatXMask mask = aMask;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1114
        CCharFormatLayer* currentLayer = index->GetCurrentInsertCharFormat();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1115
        currentLayer->Sense(format,mask);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1116
		CCharFormatLayer* newLayer = CCharFormatLayer::NewCopyBaseL(currentLayer);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1117
		CleanupStack::PushL(newLayer);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1118
        newLayer->SetL(format,mask);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1119
		if (Read(aPos, 1)[0] == EParagraphDelimiter)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1120
			index->ApplyCharFormatL(aFormat, aMask, aPos, 1, EFalse);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1121
		if (index->InsertCharFormatIsActive())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1122
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1123
			currentLayer = index->GetCurrentInsertCharFormat();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1124
			currentLayer->Swap(*newLayer);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1125
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1126
		CleanupStack::PopAndDestroy(newLayer);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1127
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1128
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1129
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1130
		TCleanupItem cleanup(::CancelInsertCharFormat, index);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1131
		CleanupStack::PushL(cleanup);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1132
		index->NewInsertCharFormatL(aFormat, aMask, aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1133
		if (Read(aPos, 1)[0] == EParagraphDelimiter)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1134
			index->ApplyCharFormatL(aFormat, aMask, aPos, 1, EFalse);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1135
		CleanupStack::Pop();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1136
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1137
	SetHasChanged(TRUE);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1138
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1139
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1140
EXPORT_C void CRichText::ExtendedInterface(TAny*& aInterface, TUid aInterfaceId)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1141
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1142
Returns the interface corresponding to the specified UID if it exists, or 0 if not. 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1143
Overridden versions should base call rather than returning 0.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1144
For KUidRichText, CRichText will be returned if rich text is supported.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1145
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1146
@param aInterfaceId The UID indicating the interface to return
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1147
@param aInterface The interface corresponding to aInterfaceId
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1148
if it is supported, or 0 if it is not
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1149
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1150
	{ 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1151
	if(KUidRichText == aInterfaceId) 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1152
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1153
		aInterface = REINTERPRET_CAST(TAny*, this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1154
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1155
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1156
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1157
	    CGlobalText::ExtendedInterface(aInterface, aInterfaceId);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1158
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1159
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1160
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1161
EXPORT_C TBool CRichText::DelSetInsertCharFormatL(TInt aPos, TInt aLength)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1162
/** Deletes a range of characters. The range affected is from aPos to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1163
aPos+(aLength-1) inclusive. It differs from DeleteL() in that this function
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1164
preserves the formatting of the deleted character at position aPos, so that
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1165
any text subsequently inserted at aPos will have that formatting applied to it.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1166
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1167
A panic occurs if:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1168
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1169
after calling this function, text is inserted at a different position to aPos,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1170
without calling CancelInsertCharFormat() before the insertion
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1171
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1172
aPos is invalid
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1173
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1174
aLength is negative
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1175
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1176
the range goes beyond the end of the document
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1177
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1178
@param aPos The document position of the first character to delete.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1179
@param aLength The number of characters to delete.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1180
@return ETrue if two paragraphs have been merged as a result of the deletion;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1181
EFalse if there has been no paragraph merge. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1182
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1183
	// Delete aLength characters, commencing at, and including, aPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1184
	// If aPos is on a phrase boundary, and the whole phrase or more is deleted then
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1185
	// remember temporarily the phrase format.  This is applied to any content that is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1186
	// immediately inserted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1187
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1188
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1189
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1190
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1191
	    OstTrace0( TRACE_FATAL, CRICHTEXT_DELSETINSERTCHARFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1192
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1193
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1194
	if (aLength < 0)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1195
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1196
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_DELSETINSERTCHARFORMATL, "EDebugDeleteZeroLength" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1197
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1198
	__ASSERT_ALWAYS(aLength >= 0, Panic(EDebugDeleteZeroLength));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1199
	if (aPos + (aLength - 1) > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1200
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1201
	    OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_DELSETINSERTCHARFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1202
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1203
	__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1204
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1205
	TBool parasMerged = EFalse;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1206
	if (!IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1207
		CPlainText::DeleteL(aPos, aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1208
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1209
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1210
		parasMerged = iIndex->DelSetInsertCharFormatL(aPos, aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1211
		CPlainText::Delete(aPos,aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1212
		SetHasChanged(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1213
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1214
	iParserData->MergeRange(aPos,aLength,0);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1215
	CallEditObserver(aPos,-aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1216
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1217
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1218
	return parasMerged;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1219
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1220
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1221
EXPORT_C void CRichText::CancelInsertCharFormat()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1222
/** Cancels the "insert pending" state set by a call to SetInsertCharFormatL()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1223
or DelSetInsertCharFormatL().
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1224
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1225
This function removes the restriction on the text insertion position imposed
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1226
by these two functions. It is recommended that it is called before every cursor
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1227
movement, scroll, paste, etc. This call is a small overhead, and has no effect
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1228
if not applicable. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1229
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1230
	// Cancels the transitory state where a specified character format
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1231
	// is applied *on top of* any inherited formatting.  eg, when bold is on.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1232
	// Cancel when: (1) the text position is altered.  (2) the first character
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1233
	// has been inserted following the setting of this state.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1234
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1235
	if (IndexPresent() && iIndex->InsertCharFormatIsActive())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1236
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1237
		iIndex->CancelInsertCharFormat();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1238
		SetHasChanged(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1239
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1240
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1241
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1242
EXPORT_C void CRichText::ApplyParaFormatL(const CParaFormat* aFormat, const TParaFormatMask& aMask, TInt aPos, TInt aLength)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1243
/** Applies paragraph formatting to a range of paragraphs. The attributes which
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1244
are set in the mask are taken from aFormat and applied. The attributes which
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1245
are not set in the mask are not changed.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1246
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1247
The region affected consists of every paragraph containing one or more
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1248
characters in the range aPos to aPos+(aLength-1).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1249
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1250
@param aFormat Contains the paragraph format attribute values to apply.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1251
@param aMask Specifies which paragraph format attributes should be affected.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1252
@param aPos The document position of the start of the range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1253
@param aLength The number of characters in the range. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1254
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1255
	// Applies the specified format attributes to the paragraphs covering
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1256
	// character position aPos to aPos+aLength-1.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1257
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1258
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1259
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1260
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1261
	    OstTrace0( TRACE_FATAL, CRICHTEXT_APPLYPARAFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1262
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1263
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1264
	if (aLength < 0)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1265
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1266
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_APPLYPARAFORMATL, "EApplyParaFormatNegativeLength" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1267
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1268
	__ASSERT_ALWAYS(aLength >= 0,Panic(EApplyParaFormatNegativeLength));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1269
	if (aPos + (aLength - 1) > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1270
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1271
	    OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_APPLYPARAFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1272
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1273
	__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1274
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1275
	CreateAndGenerateMarkupComponentL();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1276
	iIndex->ApplyParaFormatL(aFormat, aMask, aPos, aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1277
	SetHasChanged(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1278
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1279
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1280
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1281
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1282
EXPORT_C void CRichText::ApplyCharFormatL(const TCharFormat& aFormat, const TCharFormatMask& aMask, TInt aPos, TInt aLength)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1283
/** Applies character formatting to a range of characters. The attributes which
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1284
are set in the mask are read from aFormat and applied. The attributes which
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1285
are not set in the mask are not changed. The range of characters affected
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1286
is from aPos to aPos+(aLength-1) inclusive. The sum of aPos and aLength
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1287
must be less than or equal to the document length, or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1288
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1289
@param aFormat Contains the character format attribute values to apply.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1290
@param aMask Bitmask specifying which character format attributes should be
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1291
applied.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1292
@param aPos Document position from which to apply the new character formatting.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1293
Must be greater than or equal to zero, or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1294
@param aLength The number of characters to which the new formatting should
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1295
be applied. Must be greater than or equal to zero, or a panic occurs. If the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1296
length is zero, the function has the same effect as SetInsertCharFormatL(). */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1297
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1298
	// Applies the specified character formatting to the characters conatined within the range
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1299
	// aPos to aPos+(aLength-1).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1300
	// If aLength is zero, the SetInsertCharFormat state is called.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1301
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1302
	__ETEXT_WATCH(APPLY_CHAR_FORMAT);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1303
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1304
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1305
	TInt document_length = DocumentLength();
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1306
	if (aPos < 0)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1307
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1308
	    OstTrace0( TRACE_FATAL, CRICHTEXT_APPLYCHARFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1309
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1310
	__ASSERT_ALWAYS(aPos >= 0,Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1311
	if (aLength < 0)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1312
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1313
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_APPLYCHARFORMATL, "EApplyCharFormatNegativeLength" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1314
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1315
	__ASSERT_ALWAYS(aLength >= 0,Panic(EApplyCharFormatNegativeLength));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1316
	if (aPos + aLength - 1 > document_length)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1317
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1318
	    OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_APPLYCHARFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1319
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1320
	__ASSERT_ALWAYS(aPos + aLength - 1 <= document_length,Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1321
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1322
	//If some characters are highlighted AND current position + highlighted txt = document length	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1323
	// Fix for INC097216. Compensate for the changes introduced to Form in defect fix INC087637,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1324
	// which now considers the height of the EOD character; meaning that this character now 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1325
	// needs to be formatted along with rest of text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1326
	if ((aLength > 0) && (aPos + aLength == document_length))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1327
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1328
		aLength++;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1329
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1330
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1331
	DoApplyExtendedCharFormatL(aFormat, aMask, aPos, aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1332
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1333
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1334
	__ETEXT_WATCH_END(APPLY_CHAR_FORMAT);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1335
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1336
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1337
// This method is used internally only. It does not format the EOD character.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1338
void CRichText::ApplyExtendedCharFormatL(const TCharFormatX& aFormat,const TCharFormatXMask& aMask,TInt aPos,TInt aLength)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1339
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1340
	TInt document_length = DocumentLength();
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1341
	if (aPos < 0)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1342
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1343
	    OstTrace0( TRACE_FATAL, CRICHTEXT_APPLYEXTENDEDCHARFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1344
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1345
	__ASSERT_ALWAYS(aPos >= 0,Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1346
	if (aLength < 0)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1347
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1348
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_APPLYEXTENDEDCHARFORMATL, "EApplyCharFormatNegativeLength" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1349
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1350
	__ASSERT_ALWAYS(aLength >= 0,Panic(EApplyCharFormatNegativeLength));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1351
	if (aPos + aLength - 1 > document_length)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1352
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1353
	    OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_APPLYEXTENDEDCHARFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1354
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1355
	__ASSERT_ALWAYS(aPos + aLength - 1 <= document_length,Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1356
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1357
	DoApplyExtendedCharFormatL(aFormat, aMask, aPos, aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1358
	}	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1359
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1360
// Apply the extended character formatting.	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1361
void CRichText::DoApplyExtendedCharFormatL(const TCharFormatX& aFormat,const TCharFormatXMask& aMask,TInt aPos,TInt aLength)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1362
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1363
	if (aLength > 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1364
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1365
		CreateAndGenerateMarkupComponentL();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1366
		iIndex->ApplyCharFormatL(aFormat,aMask,aPos,aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1367
		SetHasChanged(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1368
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1369
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1370
		SetExtendedInsertCharFormatL(aFormat,aMask,aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1371
	}		
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1372
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1373
EXPORT_C void CRichText::SetStyleListExternallyOwned(const CStyleList& aStyleList)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1374
/** Assigns an externally owned style list to the rich text object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1375
Replaces any previous style list used by the object. Calls
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1376
SetStyleListExternallyOwned(ETrue).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1377
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1378
@param aExternallyOwned The style list to assign to this rich text object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1379
Not owned by the rich text object. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1380
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1381
	CStyleList* styleList = CONST_CAST(CStyleList*, &aStyleList);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1382
	iStyleList = styleList;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1383
	SetStyleListExternallyOwned(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1384
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1385
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1386
EXPORT_C void CRichText::ApplyParagraphStyleL(const CParagraphStyle& aStyle, TInt aPos, TInt aLength, CParagraphStyle::TApplyParaStyleMode aMode)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1387
/** Applies a specified paragraph style to a range of paragraphs. The region
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1388
affected consists of every paragraph containing one or more characters in the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1389
range aPos to aPos+(aLength-1).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1390
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1391
A panic occurs if:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1392
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1393
aPos is invalid, or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1394
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1395
aLength is negative, or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1396
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1397
the range goes beyond the end of the document, or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1398
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1399
the rich text object has no style list
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1400
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1401
@param aStyle The style to apply.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1402
@param aPos The document position of the start of the range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1403
@param aLength The number of characters in the range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1404
@param aMode Controls what specific formatting, if any, should be preserved
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1405
when the style is applied. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1406
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1407
	// Applies the specified paragraph style to the paragraphs covering
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1408
	// character positions aPos to aPos+aLength-1.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1409
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1410
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1411
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1412
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1413
	    OstTrace0( TRACE_FATAL, CRICHTEXT_APPLYPARAGRAPHSTYLEL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1414
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1415
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1416
	if (aLength < 0)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1417
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1418
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_APPLYPARAGRAPHSTYLEL, "EApplyParaStyleNegativeLength" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1419
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1420
	__ASSERT_ALWAYS(aLength >= 0, Panic(EApplyParaStyleNegativeLength));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1421
	if (aPos + (aLength - 1) > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1422
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1423
	    OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_APPLYPARAGRAPHSTYLEL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1424
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1425
	__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1426
	if (!StyleListPresent())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1427
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1428
	    OstTrace0( TRACE_FATAL, DUP3_CRICHTEXT_APPLYPARAGRAPHSTYLEL, "ERichTextNotSetForUsingStyles" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1429
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1430
	__ASSERT_ALWAYS(StyleListPresent(), Panic(ERichTextNotSetForUsingStyles));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1431
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1432
	CreateAndGenerateMarkupComponentL();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1433
	iIndex->ApplyParagraphStyleL(aStyle, aPos, aLength, iGlobalCharFormatLayer, aMode);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1434
	SetHasChanged(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1435
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1436
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1437
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1438
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1439
EXPORT_C void CRichText::NotifyStyleChangedL(const CParagraphStyle* aTo, const CParagraphStyle* aFrom)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1440
/** Removes a style from every paragraph in the document to which it applies,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1441
and replaces it with another.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1442
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1443
If style aTo is NULL, aFrom is replaced by the global character and paragraph
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1444
format layers, so that in effect, style aFrom is removed. Any specific
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1445
formatting which has been applied to the paragraphs is retained.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1446
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1447
Notes:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1448
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1449
This function should be called on the text content object after changing a
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1450
style in the style list.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1451
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1452
A panic occurs if the rich text object does not use a style list (this can
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1453
be tested for using StyleListPresent()).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1454
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1455
@param aTo The new paragraph style to apply.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1456
@param aFrom The paragraph style to remove. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1457
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1458
	// Update the rich text index following the change of an applied paragraph style.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1459
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1460
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1461
	if (!StyleListPresent())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1462
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1463
	    OstTrace0( TRACE_FATAL, CRICHTEXT_NOTIFYSTYLECHANGEDL, "ERichTextNotSetForUsingStyles" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1464
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1465
	__ASSERT_ALWAYS(StyleListPresent(), Panic(ERichTextNotSetForUsingStyles));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1466
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1467
	CreateAndGenerateMarkupComponentL();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1468
	iIndex->NotifyStyleChangedL(aTo, aFrom, *iGlobalParaFormatLayer, *iGlobalCharFormatLayer);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1469
	SetHasChanged(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1470
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1471
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1472
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1473
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1474
EXPORT_C const CParaFormatLayer* CRichText::ParagraphStyle(TBool& aStyleChangesOverRange, TInt aPos, TInt aLength) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1475
/** Gets a pointer to the first paragraph style encountered in the specified
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1476
range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1477
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1478
@param aStyleChangesOverRange On return, set to ETrue if more than one paragraph
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1479
style is used over the specified range of characters. Otherwise EFalse
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1480
@param aPos The document position of the start of the range. Must be valid.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1481
@param aLength The number of characters in the range. Must be greater than
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1482
or equal to zero.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1483
@return Pointer to the paragraph style which applies to the paragraph containing
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1484
document position aPos. Its type (returned by CParaFormatLayer::Type())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1485
indicates whether this object is a style, or just a paragraph format layer. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1486
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1487
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1488
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1489
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1490
	    OstTrace0( TRACE_FATAL, CRICHTEXT_PARAGRAPHSTYLE, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1491
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1492
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1493
	if (aLength < 0)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1494
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1495
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_PARAGRAPHSTYLE, "EParagraphStyleNegativeLength" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1496
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1497
	__ASSERT_ALWAYS(aLength >= 0,Panic(EParagraphStyleNegativeLength));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1498
	if (aPos + (aLength - 1) > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1499
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1500
	    OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_PARAGRAPHSTYLE, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1501
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1502
	__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1503
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1504
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1505
		return iIndex->ParagraphStyle(aStyleChangesOverRange, aPos, aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1506
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1507
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1508
		aStyleChangesOverRange = EFalse;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1509
		return iGlobalParaFormatLayer;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1510
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1511
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1512
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1513
EXPORT_C void CRichText::SetHasChanged(TBool aHasChanged)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1514
/** Sets whether the document's content or formatting has changed. This function
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1515
is called with an value of ETrue by all functions which modify the text content
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1516
or formatting. Use CEditableText::HasChanged() to test whether the document
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1517
has changed.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1518
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1519
@param aHasChanged ETrue if the text object has been changed, EFalse if not. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1520
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1521
	// Replaces the base class method of the same name.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1522
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1523
	if (aHasChanged && IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1524
		iIndex->DocumentChanged();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1525
	CGlobalText::SetHasChanged(aHasChanged);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1526
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1527
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1528
EXPORT_C void CRichText::RemoveSpecificParaFormatL(TInt aPos, TInt aLength)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1529
/** Removes all specific paragraph formatting from a range of paragraphs. This
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1530
does not remove formatting from the object's global paragraph format layer.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1531
The region affected consists of every paragraph containing one or more
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1532
characters in the range covered by document position aPos to aPos+(aLength-1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1533
inclusive.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1534
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1535
A panic occurs in the following situations:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1536
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1537
the position is negative,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1538
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1539
the length is negative,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1540
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1541
the range goes beyond the end of the document
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1542
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1543
@param aPos The document position of the start of the range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1544
@param aLength The number of characters in the range. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1545
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1546
	// Removes all specific paragraph formatting from the selected region.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1547
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1548
	__ETEXT_WATCH(REMOVE_PARA_FORMAT);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1549
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1550
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1551
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1552
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1553
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1554
	    OstTrace0( TRACE_FATAL, CRICHTEXT_REMOVESPECIFICPARAFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1555
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1556
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1557
	if (aLength < 0)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1558
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1559
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_REMOVESPECIFICPARAFORMATL, "ERemoveSpecificParaFormatNegativeLength" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1560
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1561
	__ASSERT_ALWAYS(aLength >= 0, Panic(ERemoveSpecificParaFormatNegativeLength));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1562
	if (aPos + (aLength - 1) > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1563
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1564
	    OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_REMOVESPECIFICPARAFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1565
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1566
	__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1567
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1568
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1569
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1570
		iIndex->RemoveSpecificParaFormatL(aPos, aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1571
		SetHasChanged(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1572
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1573
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1574
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1575
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1576
	__ETEXT_WATCH_END(REMOVE_PARA_FORMAT);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1577
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1578
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1579
EXPORT_C void CRichText::RemoveSpecificCharFormatL(TInt aPos, TInt aLength)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1580
/** Removes all specific character formatting from a range of characters (does
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1581
not remove the formatting which has been taken from the object's global character
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1582
format layer). A panic occurs in the following situations:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1583
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1584
the position is negative,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1585
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1586
the length is negative,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1587
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1588
the range goes beyond the end of the document
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1589
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1590
@param aPos The document position of the start of the region affected.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1591
@param aLength The number of characters in the region affected. If zero, the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1592
function has no effect. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1593
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1594
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1595
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1596
	TInt document_length = DocumentLength();
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1597
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1598
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1599
	    OstTrace0( TRACE_FATAL, CRICHTEXT_REMOVESPECIFICCHARFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1600
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1601
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1602
	if (aLength < 0)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1603
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1604
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_REMOVESPECIFICCHARFORMATL, "ERemoveSpecificParaFormatNegativeLength" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1605
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1606
	__ASSERT_ALWAYS(aLength >= 0, Panic(ERemoveSpecificParaFormatNegativeLength));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1607
	if (aPos + (aLength - 1) > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1608
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1609
	    OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_REMOVESPECIFICCHARFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1610
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1611
	__ASSERT_ALWAYS(aPos + (aLength - 1) <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1612
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1613
	// in correspondance to INC097216, character format removing considers the height of end of document
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1614
    // character
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1615
    if (aPos + aLength == document_length)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1616
   		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1617
        aLength++;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1618
        }
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1619
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1620
	if (aLength > 0 && IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1621
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1622
		iIndex->RemoveSpecificCharFormatL(aPos, aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1623
		SetHasChanged(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1624
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1625
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1626
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1627
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1628
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1629
EXPORT_C void CRichText::GetChars(TPtrC& aText, TCharFormat& aFormat, TInt aPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1630
/** Gets a constant pointer descriptor to a portion of the text object
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1631
with constant character formatting.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1632
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1633
The view starts at the document position specified, and ends at: the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1634
last character which shares the same character formatting, orthe end
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1635
of the document, orthe end of the segment, if segmented storage is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1636
being usedwhichever occurs first. Also fills a character format object
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1637
with the character formatting of the range of characters.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1638
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1639
@param aView On return, a constant pointer to a portion of the text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1640
@param aFormat On return, contains the character formatting of the text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1641
@param aPos The start position for the view. Must be a valid document
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1642
position, or a panic occurs. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1643
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1644
	// Get a run of text and its format, starting at aPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1645
	__ETEXT_WATCH(GET_CHARS)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1646
	TCharFormatX format;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1647
	GetTextAndExtendedFormat(aText, format, aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1648
	OverrideFormatForParsersIfApplicable(aText, format, aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1649
	aFormat = format.iCharFormat;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1650
	OverrideFormatOfInlineTextIfApplicable(aText, aFormat, aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1651
	__ETEXT_WATCH_END(GET_CHARS)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1652
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1653
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1654
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1655
void CRichText::GetTextAndExtendedFormat(TPtrC& aText,TCharFormatX& aFormat,TInt aPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1656
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1657
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1658
	TInt documentLength = DocumentLength();
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1659
	if (aPos < 0 || aPos > documentLength)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1660
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1661
	    OstTrace0( TRACE_FATAL, CRICHTEXT_GETTEXTANDEXTENDEDFORMAT, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1662
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1663
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= documentLength, Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1664
	if (!IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1665
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1666
		aText.Set(Read(aPos));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1667
		iGlobalCharFormatLayer->SenseEffective(aFormat);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1668
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1669
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1670
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1671
		int phrase_length = iIndex->GetChars(aFormat,aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1672
		aText.Set(Read(aPos,phrase_length));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1673
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1674
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1675
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1676
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1677
EXPORT_C TInt CRichText::GetPictureSizeInTwips(TSize& aSize, TInt aPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1678
/** Gets the size of a picture located at a specified document position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1679
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1680
@param aSize On return, contains the size of the picture located at aPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1681
@param aPos Document position of the picture. Must be a valid position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1682
@return KErrNotFound if there is no picture at the specified document position,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1683
KErrNone if there is. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1684
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1685
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1686
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1687
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1688
	    OstTrace0( TRACE_FATAL, CRICHTEXT_GETPICTURESIZEINTWIPS, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1689
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1690
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1691
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1692
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1693
		return iIndex->GetPictureSizeInTwips(aSize, aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1694
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1695
		return KErrNotFound;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1696
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1697
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1698
EXPORT_C CPicture* CRichText::PictureHandleL(TInt aPos, MLayDoc::TForcePictureLoad aForceLoad) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1699
/** Gets a pointer to the picture located at a specified document position, if
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1700
one exists. If the picture is not in memory, the function loads it (if the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1701
second argument has a value of MLayDoc::EForceLoadTrue).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1702
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1703
Note:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1704
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1705
In order to load the picture, a picture factory and a store resolver must
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1706
have been set.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1707
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1708
@param aPos Document position of the picture character. Must be a valid position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1709
@param aForceLoad If the picture is not loaded into memory,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1710
MLayDoc::EForceLoadTrue loads it using the picture factory;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1711
MLayDoc::EForceLoadFalse does not, and in this case, the function returns NULL.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1712
@return A pointer to the picture located at aPos. NULL if aPos does not specify
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1713
a picture character, or if there is a picture at aPos which is not in memory,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1714
and the second argument is MLayDoc::EForceLoadFalse. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1715
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1716
	__ETEXT_WATCH(PICTURE_HANDLE);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1717
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1718
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1719
	if (aPos<0 || aPos>DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1720
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1721
	    OstTrace0( TRACE_FATAL, CRICHTEXT_PICTUREHANDLEL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1722
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1723
	__ASSERT_ALWAYS(aPos>=0 && aPos<=DocumentLength(),Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1724
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1725
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1726
		return iIndex->PictureHandleL(aPos, aForceLoad);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1727
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1728
		return NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1729
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1730
	__ETEXT_WATCH_END(PICTURE_HANDLE);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1731
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1732
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1733
EXPORT_C void CRichText::GetParagraphFormatL(CParaFormat* aFormat, TInt aPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1734
/** Gets the effective paragraph formatting which applies to the paragraph which
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1735
contains a specified document position. On return, aFormat is filled with
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1736
values for all paragraph format attributes.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1737
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1738
@param aFormat On return, filled with the paragraph's effective paragraph
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1739
formatting.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1740
@param aPos Any document position within the paragraph of interest. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1741
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1742
	__ETEXT_WATCH(GET_PARAGRAPH_FORMAT)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1743
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1744
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1745
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1746
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1747
	    OstTrace0( TRACE_FATAL, CRICHTEXT_GETPARAGRAPHFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1748
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1749
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1750
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1751
	if (!IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1752
		CGlobalText::GetParagraphFormatL(aFormat, aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1753
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1754
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1755
		aFormat->Reset();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1756
		iIndex->GetParagraphFormatL(aFormat, aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1757
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1758
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1759
	__ETEXT_WATCH_END(GET_PARAGRAPH_FORMAT)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1760
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1761
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1762
EXPORT_C void CRichText::GetSpecificParagraphFormatL(CParaFormat* aFormat,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1763
													 TParaFormatMask& aMask,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1764
													 TInt aPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1765
// Fills aFormat with the effective Paragraph format attributes for the paragraph
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1766
// in which character position aPos is contained.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1767
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1768
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1769
	__ETEXT_WATCH(GET_PARAGRAPH_FORMAT)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1770
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1771
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1772
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1773
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1774
	    OstTrace0( TRACE_FATAL, CRICHTEXT_GETSPECIFICPARAGRAPHFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1775
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1776
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1777
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1778
	aFormat->Reset();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1779
	aMask.ClearAll();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1780
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1781
		iIndex->GetSpecificParagraphFormatL(aFormat, aMask, aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1782
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1783
	__ETEXT_WATCH_END(GET_PARAGRAPH_FORMAT)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1784
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1785
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1786
EXPORT_C void CRichText::GetParaFormatL(CParaFormat* aFormat, TParaFormatMask& aVaries, TInt aPos, TInt aLength,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1787
										CParaFormat::TParaFormatGetMode aMode) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1788
/** Gets the effective paragraph formatting which applies to a range of paragraphs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1789
The region involved is every paragraph containing one or more characters in
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1790
the range aPos to aPos+(aLength-1) inclusive. On return, aFormat is filled
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1791
with values for all paragraph format attributes and the mask indicates the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1792
values that change over the region, and whose value is therefore indeterminate.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1793
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1794
Note:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1795
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1796
If aMode has a value of EFixedAttributes, the function cannot leave.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1797
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1798
@param aFormat Must not be NULL or a panic occurs. On return, contains the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1799
effective paragraph formatting for the range of paragraphs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1800
@param aVaries On return, a bitmask indicating which paragraph format attributes
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1801
vary over the range of characters selected.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1802
@param aPos The document position of the start of the range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1803
@param aLength The number of characters in the range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1804
@param aMode The default, EAllAttributes means that values for all paragraph
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1805
format attributes are written to aFormat. EFixedAttributes means that tabs,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1806
bullets and borders are not written to aFormat. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1807
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1808
	// Senses the paragraph format of para(s) covered by the region aPos to aPos+aLength-1.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1809
	// aFormat takes the values of all attributes, and the mask aMask indicates those values that change
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1810
	// over the selected region, and are therefore *indeterminate*.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1811
	// Application: seeding paragraph formatting dialogs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1812
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1813
	__TEST_INVARIANT;
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1814
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1815
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1816
	    OstTrace0( TRACE_FATAL, CRICHTEXT_GETPARAFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1817
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1818
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1819
	if (aLength < 0)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1820
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1821
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_GETPARAFORMATL, "EGetParaFormatNegativeLength" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1822
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1823
	__ASSERT_ALWAYS(aLength >= 0, Panic(EGetParaFormatNegativeLength));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1824
	if (aPos + aLength > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1825
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1826
	    OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_GETPARAFORMATL, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1827
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1828
	__ASSERT_ALWAYS(aPos + aLength <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1829
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1830
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1831
		iIndex->GetParaFormatL(aFormat, aVaries, aPos, aLength, aMode);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1832
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1833
		CGlobalText::GetParaFormatL(aFormat, aVaries, aPos, aLength, aMode);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1834
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1835
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1836
EXPORT_C void CRichText::GetCharFormat(TCharFormat& aFormat, TCharFormatMask& aVaries, TInt aPos, TInt aLength) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1837
/** Gets the effective character formatting which applies to a range of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1838
characters. The range of characters involved is from aPos to aPos+(aLength-1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1839
inclusive. On return, aFormat is filled with values for all character format
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1840
attributes, and on return, the mask indicates the values that change over the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1841
region, and whose value is therefore indeterminate.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1842
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1843
The length value can be zero. In this case, the character formatting sensed
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1844
is that of the character immediately to the left of the position specified.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1845
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1846
@param aFormat On return, contains the character format values for the range
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1847
of characters.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1848
@param aVaries On return, indicates which character format attributes vary
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1849
over the range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1850
@param aPos Document position of the start of the range. Must be valid or a
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1851
panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1852
@param aLength Number of characters in the range. Must be greater than or equal
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1853
to zero, or a panic occurs. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1854
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1855
	// Senses the character formatting of the phrase(s) covered by the region aPos to aPos+aLength-1.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1856
	// May be called with zero length.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1857
	// aFormat takes the values of all character format attributes, and the mask aMask indicates those
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1858
	// values that change over the selected region, and are therefore *indeterminate*.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1859
	// Application: seeding character formatting dialogs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1860
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1861
	TCharFormatX format;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1862
	TCharFormatXMask varies;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1863
	GetExtendedCharFormat(format, varies, aPos, aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1864
	aFormat = format.iCharFormat;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1865
	varies.ClearExtendedAttribs();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1866
	aVaries = varies;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1867
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1868
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1869
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1870
void CRichText::GetExtendedCharFormat(TCharFormatX& aFormat, TCharFormatXMask& aVaries, TInt aPos, TInt aLength) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1871
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1872
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1873
	int document_length = DocumentLength();
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1874
	if (aPos < 0 || aPos > document_length)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1875
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1876
	    OstTrace0( TRACE_FATAL, CRICHTEXT_GETEXTENDEDCHARFORMAT, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1877
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1878
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= document_length, Panic(ECharPosBeyondDocument));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1879
	if (aLength < 0)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1880
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1881
	    OstTrace0( TRACE_FATAL, DUP1_CRICHTEXT_GETEXTENDEDCHARFORMAT, "EGetCharFormatNegativeLength" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1882
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1883
	__ASSERT_ALWAYS(aLength >= 0, Panic(EGetCharFormatNegativeLength));
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1884
	if (aPos + aLength - 1 > document_length)
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1885
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1886
	    OstTrace0( TRACE_FATAL, DUP2_CRICHTEXT_GETEXTENDEDCHARFORMAT, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1887
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1888
	__ASSERT_ALWAYS(aPos + aLength - 1 <= document_length, Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1889
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1890
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1891
		iIndex->GetCharFormat(aFormat, aVaries, aPos, aLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1892
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1893
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1894
		iGlobalCharFormatLayer->SenseEffective(aFormat);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1895
		aVaries.ClearAll();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1896
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1897
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1898
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1899
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1900
void CRichText::GetSpecificCharFormatLeftRight(TCharFormat& aFormat,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1901
									TCharFormatMask& aMask,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1902
									TInt aPos,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1903
									TBool aLeft) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1904
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1905
	__ETEXT_WATCH(GET_SPECIFIC_CHARS);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1906
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1907
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1908
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1909
	if (aPos < 0 || aPos > DocumentLength())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1910
	    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1911
	    OstTrace0( TRACE_FATAL, CRICHTEXT_GETSPECIFICCHARFORMATLEFTRIGHT, "ECharPosBeyondDocument" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  1912
	    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1913
	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1914
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1915
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1916
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1917
		TCharFormatX format;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1918
		TCharFormatXMask mask;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1919
		iIndex->GetSpecificCharFormatDirection(format, mask, aPos, aLeft);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1920
		aFormat = format.iCharFormat;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1921
		mask.ClearExtendedAttribs();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1922
		aMask = mask;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1923
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1924
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1925
	__ETEXT_WATCH_END(GET_SPECIFIC_CHARS);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1926
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1927
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1928
EXPORT_C void CRichText::GetSpecificCharFormat(TCharFormat& aFormat, TCharFormatMask& aMask, TInt aPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1929
/** Gets the specific character formatting which applies to the character to the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1930
left of a document position. Specific formatting is just the formatting which
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1931
has been applied over the object's global format layers - it is not the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1932
same as the effective formatting.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1933
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1934
@param aFormat On return contains the specific character formatting which
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1935
applies to the character to the left of the document position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1936
@param aMask On return, indicates which character format attributes have been
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1937
applied specifically, (not taken from the global layers).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1938
@param aPos The document position. Must be valid or a panic occurs. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1939
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1940
	// Return the format attributes store in the specific layer only, for the specified document position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1941
	// THIS IS NOT THE EFFECTIVE FORMAT, BUT THE SPECIFIC FORMATTING ONLY.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1942
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1943
	GetSpecificCharFormatLeftRight(aFormat, aMask, aPos, ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1944
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1945
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1946
EXPORT_C void CRichText::GetSpecificCharFormatRight(TCharFormat& aFormat, TCharFormatMask& aMask, TInt aPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1947
/** Gets the specific character formatting which applies to the character logically
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1948
after a document position. Note that this is not necessarily the character
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1949
to the right of the document position, because right to left text is supported.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1950
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1951
Specific formatting is just the formatting which has been applied over the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1952
object's global format layers it is not the same as the effective formatting.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1953
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1954
@param aFormat On return, contains the specific character formatting which
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1955
applies to the character logically after the document position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1956
@param aMask On return, indicates which character format attributes have been
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1957
applied specifically, (not taken from the global layers).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1958
@param aPos The document position. Must be valid or a panic occurs. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1959
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1960
	GetSpecificCharFormatLeftRight(aFormat, aMask, aPos, EFalse);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1961
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1962
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1963
TBool CRichText::IndexPresent()const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1964
// Returns ETrue if the rich text index is present, otherwise
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1965
// returns EFalse.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1966
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1967
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1968
	return iIndex.IsPtr() && iIndex.AsPtr();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1969
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1970
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1971
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1972
EXPORT_C TInt CRichText::PictureCount() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1973
/** Gets a count of the number of pictures contained in the rich text object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1974
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1975
@return The picture count. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1976
	{return (IndexPresent()) ? iIndex->iPictureCount : 0;}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1977
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1978
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1979
void CRichText::SetParaTypeIsSingle(TBool aBool)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1980
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1981
	if (aBool)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1982
		iFlags |= KParaTypeIsSingle;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1983
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1984
		iFlags &= ~KParaTypeIsSingle;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1985
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1986
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1987
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1988
TBool CRichText::ParaTypeIsSingle() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1989
	{return iFlags & KParaTypeIsSingle;}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1990
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1991
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1992
EXPORT_C void CRichText::AppendTakingSolePictureOwnershipL(const CRichText& aSource)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1993
/** Appends a rich text object to this one. The text is appended immediately after
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1994
the end-of-text paragraph delimiter. The incoming text's formatting is set
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1995
to be based on the global formatting of this rich text object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1996
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1997
Notes:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1998
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1999
If this rich text object is empty (e.g. because it is newly initialised, or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2000
has been reset), then the end-of-text delimiter of the incoming rich text
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2001
is not appended. This avoids the possibility of having a trailing paragraph
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2002
delimiter, giving one more empty line than would typically be desired.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2003
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2004
If the incoming rich text contains pictures which have been loaded into memory,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2005
their sole ownership is transferred to the current rich text object. In aSource,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2006
these picture handles are set to NULL.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2007
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2008
@param aSource The rich text object to append. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2009
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2010
	// Appends the specified rich text object to this one.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2011
	// If this rich text is empty or has been newly initialised or reset, then the final paragraph delimiter
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2012
	// of the incoming rich text is NOT appended, thus avoiding the prospect of having a trailing, empty
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2013
	// paragraph delimiter, giving one more empty line than would typically be desired.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2014
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2015
	__ETEXT_WATCH(APPEND_RICH_TEXT);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2016
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2017
	// Append the text
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2018
	const TInt thisDocumentLength = DocumentLength();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2019
	MPictureFactory* factory = NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2020
	MRichTextStoreResolver* resolver = NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2021
	if (thisDocumentLength == 0)  // this is an empty document
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2022
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2023
		factory = iPictureFactory;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2024
		resolver = iStoreResolver;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2025
		Reset();  // destroy the markup component if it exists.  Makes the job easier
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2026
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2027
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2028
	PrepareAppendMarkupL(aSource);  // requires no rollback - objects in a (bigger) stable state
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2029
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2030
	TRAPD(ret, DoAppendTakingSolePictureOwnershipL(aSource));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2031
	if (ret != KErrNone)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2032
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2033
		CPlainText::Delete(thisDocumentLength,DocumentLength() - thisDocumentLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2034
		User::Leave(ret);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2035
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2036
	if (thisDocumentLength == 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2037
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2038
		DeleteParagraph(0, 1);   // remove excess first paragraph from empty documents
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2039
		SetPictureFactory(factory, resolver);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2040
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2041
	int new_length = DocumentLength() - thisDocumentLength;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2042
	iParserData->MergeRange(thisDocumentLength,0,new_length);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2043
	CallEditObserver(thisDocumentLength,new_length);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2044
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2045
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2046
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2047
	__ETEXT_WATCH_END(APPEND_RICH_TEXT);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2048
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2049
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2050
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2051
void CRichText::DoAppendTakingSolePictureOwnershipL(const CRichText& aSource)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2052
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2053
	TInt lengthRemaining = aSource.DocumentLength() + 1;  // we want to append the para delimiters also!
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2054
	TInt consumed = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2055
	FOREVER
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2056
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2057
		TPtrC view = aSource.Read(consumed);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2058
		if (view.Length() > lengthRemaining)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2059
			view.Set(view.Ptr(), lengthRemaining);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2060
		CPlainText::DoPtInsertL(DocumentLength() + 1, view);  // insert AFTER the final paragraph delimiter
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2061
		TInt viewLength = view.Length();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2062
		lengthRemaining -= viewLength;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2063
		if (lengthRemaining == 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2064
			break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2065
		consumed += viewLength;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2066
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2067
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2068
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2069
		{
44
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  2070
		if (!aSource.IndexPresent())
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  2071
		    {
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  2072
		    OstTrace0( TRACE_DUMP, DUP1_CRICHTEXT_DOAPPENDTAKINGSOLEPICTUREOWNERSHIPL, "Invariant" );
601ab138ba0b Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
  2073
		    }
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2074
		__ASSERT_DEBUG(aSource.IndexPresent(), User::Invariant());       // PrepareAppend should have sorted this
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2075
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2076
		TGlobalLayerInfoAppend info(GlobalParaFormatLayer(), GlobalCharFormatLayer(), aSource.GlobalParaFormatLayer(), aSource.GlobalCharFormatLayer());
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2077
		iIndex->AppendTakingSolePictureOwnershipL(aSource.iIndex, info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2078
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2079
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2080
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2081
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2082
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2083
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2084
void CRichText::PrepareAppendMarkupL(const CRichText& aSource)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2085
// Guarantees that both the component and aggregate objects have a valid markup component.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2086
//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2087
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2088
	if (aSource.HasMarkupData() && !HasMarkupData())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2089
		CreateAndGenerateMarkupComponentL();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2090
	else if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2091
		CONST_CAST(CRichText&, aSource).CreateAndGenerateMarkupComponentL();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2092
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2093
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2094
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2095
EXPORT_C void CRichText::AppendParagraphL(TInt aReplicas)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2096
/** Appends one or more empty paragraphs to the document. The new paragraphs take
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2097
on the formatting specified in the global format layers.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2098
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2099
@param aReplicas The number of empty paragraphs to append to the document.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2100
By default, a single paragraph. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2101
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2102
	// Inserts an empty paragraph at the end of the document.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2103
	// The new paragraph takes on the format as described
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2104
	// by the global format layers.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2105
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2106
	__ETEXT_WATCH(APPEND_PARAGRAPH);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2107
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2108
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2109
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2110
	TInt documentLength = DocumentLength();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2111
	if (aReplicas == 1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2112
		CPlainText::InsertL(documentLength, CEditableText::EParagraphDelimiter);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2113
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2114
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2115
		HBufC* bb = HBufC::NewLC(aReplicas);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2116
		TPtr buf = bb->Des();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2117
		buf.Fill(CEditableText::EParagraphDelimiter, aReplicas);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2118
		CPlainText::InsertL(documentLength, buf);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2119
		CleanupStack::PopAndDestroy();  // bb
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2120
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2121
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2122
	if (IndexPresent())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2123
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2124
		TRAPD(ret,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2125
		iIndex->AppendParagraphL(iGlobalParaFormatLayer, iGlobalCharFormatLayer, aReplicas));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2126
		if (ret != KErrNone)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2127
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2128
			CPlainText::Delete(DocumentLength() - aReplicas, aReplicas);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2129
			User::Leave(ret);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2130
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2131
		SetHasChanged(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2132
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2133
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2134
	int new_length = DocumentLength() - documentLength;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2135
	iParserData->MergeRange(documentLength,0,new_length);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2136
	CallEditObserver(documentLength,new_length);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2137
	__TEST_INVARIANT;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2138
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2139
	__ETEXT_WATCH_END(APPEND_PARAGRAPH);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2140
	}