dependencies/xcfw/gmxmlentityconverter.h
author kashif.sayed
Fri, 26 Mar 2010 02:10:38 +0530
branchv5backport
changeset 27 28544f9237c7
parent 17 c9bafd575d88
permissions -rw-r--r--
. user: kashif.sayed branch 'v5backport' changed dependencies/bld.inf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
     1
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
     2
// All rights reserved.
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
     3
// This component and the accompanying materials are made available
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
     5
// which accompanies this distribution, and is available
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
     7
//
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
     8
// Initial Contributors:
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    10
//
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    11
// Contributors:
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    12
//
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    13
// Description:
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    14
//
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    15
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    16
/**
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    17
 @file
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    18
*/
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    19
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    20
#ifndef __GMXMLENTITYCONVERTER_H__
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    21
#define __GMXMLENTITYCONVERTER_H__
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    22
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    23
#include <e32std.h>
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    24
#include <txtetext.h>
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    25
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    26
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    27
class CMDXMLEntityConverter: public CBase
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    28
/**
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    29
 * This class represents a generic entity converter for an XML parser or composer.
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    30
 * It is responsible for converting entity references to text and vice-versa.
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    31
 * @publishedPartner
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    32
 * @released
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    33
 */
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    34
	{
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    35
public:
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    36
	/**
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    37
	 * Constructor
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    38
	 */
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    39
	IMPORT_C CMDXMLEntityConverter();
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    40
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    41
	/** Destructor. */
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    42
	IMPORT_C virtual ~CMDXMLEntityConverter();
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    43
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    44
	/**
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    45
	 * Takes a block of text and converts any entity references found to the
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    46
	 * appropriate text.  Because built-in and character entity references are
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    47
	 * longer than the replacement text, this takes place in-situ.
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    48
	 * @param aTextToConvert Text to be converted - replacement text goes
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    49
	 * out in the same
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    50
	 * @return Returns KErrNone if successful or no entity found
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    51
	 * @return Returns KErrXMLBadEntity if malformed entity found
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    52
	 */
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    53
	TInt EntityToTextL(TDes& aTextToConvert);
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    54
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    55
	/**
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    56
	 * Outputs a block of text to a composer with offending characters replaced by
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    57
	 * entity references.
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    58
	 * @param aComposer the composer to be used for output
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    59
	 * @param aTextToConvert The text to be converted.
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    60
	 * @return Returns KErrNone if succcessful or a file write error
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    61
	 * @leave can Leave due to OOM
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    62
	 */
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    63
	IMPORT_C virtual TInt OutputComposedTextL( CMDXMLComposer* aComposer, const TDesC& aTextToConvert );
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    64
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    65
protected:
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    66
	/**
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    67
	 * DTD Specific entity to text converter
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    68
	 * Takes a block of text and converts any entity references found to the
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    69
	 * appropriate text.  We hope that this can happen in-situ.
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    70
	 * @param aTextToConvert Text to be converted - replacement text goes
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    71
	 * out in the same
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    72
	 * @return Returns KErrNone if successful or no entity found
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    73
	 * @return Returns KErrXMLBadEntity if malformed entity found
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    74
	 */
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    75
	virtual TInt DTDEntityToText(TDes& aTextToConvert);
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    76
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    77
private:
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    78
	/**
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    79
	 * Replaces the built in entity reference with its replacement text.
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    80
	 * @param aTextToConvert An entity reference to convert.  This should begin with &
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    81
	 * and end with ;.
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    82
	 * @return Returns KErrNone if successful
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    83
	 * @return Returns KErrUnsupported if aTextToConvert contains no recognised entity references
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    84
	 * @return Returns KErrOverflow or KErrGeneral if the character reference couldn't be parsed
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    85
	 */
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    86
	TInt ConvertEntityRefL(TDes& aTextToConvert);
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    87
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    88
	};
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    89
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    90
c9bafd575d88 xcfw component compiles now
jake
parents:
diff changeset
    91
#endif