textrendering/texthandling/stext/MParser.cpp
changeset 0 1fb32624e06b
equal deleted inserted replaced
-1:000000000000 0:1fb32624e06b
       
     1 /*
       
     2 * Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <mparser.h>
       
    20 
       
    21 
       
    22 // Given the text object, scan the specified range of the text buffer
       
    23 // (from aStartScan to one before aEndScan) and show the first match, if
       
    24 // any, that you would like tagged by setting the range (from aStartTag
       
    25 // to one before aEndTag). Return ETrue if you find anything, EFalse
       
    26 // otherwise. This function must be defined. If aAllowBack is ETrue then
       
    27 // the parser is allowed to recognise tags that start before but
       
    28 // continue into the range specified, otherwise it is not allowed to do
       
    29 // so (and, if it does, will assert in debug mode).
       
    30 // virtual TBool ParseThisText(const CRichText& aTextObj,
       
    31 //							   TBool aAllowBack,
       
    32 //							   TInt aStartScan,
       
    33 //							   TInt aScanLength,
       
    34 //							   TInt& aStartTag,
       
    35 //							   TInt& aTagLength) = 0;
       
    36 
       
    37 
       
    38 // The text cursor is over the text string in aTextObj (aLength
       
    39 // characters starting at aStartText). Return a const ptr to the string
       
    40 // that should be displayed for a "Do It!" button. (This can be
       
    41 // constant, such as a _LIT, or change according to the tagged text.)
       
    42 // The parser retains ownership of this string and, if necessary, should
       
    43 // delete it when this function is next called or when the parser is
       
    44 // deleted. This function will normally be invoked directly by UIKON and
       
    45 // must be defined.
       
    46 // virtual const TDesC& CreateDoItText(const CRichText& aTextObj,
       
    47 //									   TInt aStartText,
       
    48 //									   TInt aLength) = 0;
       
    49 
       
    50 
       
    51 // The text cursor is over the text string in aTextObj (aLength
       
    52 // characters starting at aStartText) and the "Do It!" button has been
       
    53 // pushed (or some other activation method has been triggered). Do
       
    54 // whatever should happen (such as launching a browser with the
       
    55 // indicated URL). If the parser requires a copy of the text to pass on,
       
    56 // it is up to it to take one before doing anything (such as handing it
       
    57 // to a separate thread) and to dispose of it later. This function will
       
    58 // normally be invoked directly by UIKON and must be defined.
       
    59 // virtual void ActivateThisTextL(const CRichText& aTextObj,
       
    60 //							      TInt aStartText,
       
    61 //							      TInt aLength) = 0;
       
    62 
       
    63 
       
    64 // Whether this parser makes any formatting changes to text that is
       
    65 // recognised and tagged as soon as it has been recognised. If it does
       
    66 // then this function should be overridden with one that returns ETrue
       
    67 // and the GetRecogniseFormat() function should be overridden
       
    68 // appropriately - otherwise do nothing.
       
    69 EXPORT_C TBool MParser::ReformatOnRecognise() const
       
    70 	{
       
    71 	return EFalse;
       
    72 	}
       
    73 
       
    74 
       
    75 // Whether this parser makes any formatting changes to text that is
       
    76 // recognised and tagged when the text cursor moves onto it. If it does
       
    77 // then this function should be overridden with one that returns ETrue
       
    78 // and the GetRolloverFormat() function should be overridden
       
    79 // appropriately otherwise do nothing.
       
    80 EXPORT_C TBool MParser::ReformatOnRollover() const
       
    81 	{
       
    82 	return EFalse;
       
    83 	}
       
    84 
       
    85 
       
    86 // Given an existing format, modify it to reflect the highlighting
       
    87 // changes that apply immediately some text is recognised and tagged by
       
    88 // this parser. If this parser does not make any highlighting changes at
       
    89 // recognise time then this function should not be overridden.
       
    90 EXPORT_C void MParser::GetRecogniseFormat(TCharFormat& /*aFormat*/)
       
    91 	{
       
    92 	}
       
    93 
       
    94 
       
    95 // Given an existing format, modify it to reflect the highlighting 
       
    96 // changes that apply when the text cursor moves onto text that has been
       
    97 // recognised and tagged by this parser. This should include all changes
       
    98 // that you wish to make to the base format as this will *not* be
       
    99 // applied cumulatively to the recognise highlighting. If this parser
       
   100 // does not make any highlighting changes at rollover time then this
       
   101 // function should not be overridden and any recognise highlighting will
       
   102 // remain.
       
   103 EXPORT_C void MParser::GetRolloverFormat(TCharFormat& aFormat)
       
   104 	{
       
   105 	GetRecogniseFormat(aFormat);
       
   106 	}
       
   107 
       
   108 
       
   109 EXPORT_C TBool MParser::ConfirmCursorOverTag(const CRichText& /*aTextObj*/,
       
   110 	TInt /*aTagStart*/, TInt /*aTagLen*/, TInt /*aCurPos*/)
       
   111 /**
       
   112  This confirmation routine is called by the parsing framework when
       
   113  it's logic determines the cursor is over a tag. It gives the parser 
       
   114  a chance to override the default cursor-tag rollover matching. This
       
   115  is not necessary if the default behaviour is acceptable.
       
   116  It is called from the CRichText::CursorOverTag()
       
   117  when the framework tests for format redraw when over a tag and 
       
   118  CRichText::OverrideFormatForParsersIfApplicable() when Tagma
       
   119  is formatting text.
       
   120 @publishedPartner
       
   121 @released
       
   122 @param aTextObj
       
   123  A reference to the text document tag is within.
       
   124 @param aTagStart
       
   125  The document position of the first tag character.
       
   126 @param aTagLen
       
   127  The number of characters in the tag.
       
   128 @param aCurPos
       
   129  The cursor position used in calculation of calling routines.
       
   130 @return TBool
       
   131  ETrue if parser agrees cursor over a tag, EFalse otherwise.
       
   132 */
       
   133 	{
       
   134 	return ETrue;
       
   135 	}
       
   136 
       
   137 
       
   138 EXPORT_C void MParser::MParser_Reserved_2() {}