os/graphics/graphicsdeviceinterface/gdi/inc/LineBreak.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef LINEBREAK_H_
    17 #define LINEBREAK_H_
    18 
    19 #include <e32def.h>
    20 class MContingentLineBreaker;
    21 class MContingentLineBreakerL;
    22 class TDesC16;
    23 class TUid;
    24 
    25 
    26 /**
    27  This enumeration holds the possible panic codes that may be raised
    28  by the LineBreak API on detecting an unrecoverable error.
    29 @publishedAll
    30 @released
    31 */
    32 enum TLineBreakPanic
    33 	{
    34 	/** Not used */
    35 	ELineBreakPanic_Unknown				= 0,
    36 	/** Internal error, error found in data table */
    37 	ELineBreakPanic_BadTable			= 1,
    38 	/** One or more of the input parameters to the interface were invalid */
    39 	ELineBreakPanic_InvalidInputParam	= 2,
    40 	/** Raised when an output parameter breaks an API condition */
    41 	ELineBreakPanic_InvalidOutputParam	= 3,
    42 	};
    43 
    44 
    45 
    46 class MLineBreaker
    47 /**
    48 Customizes the Unicode line-breaking algorithm. 
    49 @publishedAll
    50 @released
    51 */
    52 	{
    53 public:
    54 	/** The Unicode line breaking classes; see Unicode Technical Report 14.
    55 	Not a named enumerated type, so that overriding classes may add new
    56 	line breaking classes freely.
    57 	The description of each constant gives the name of the line-breaking
    58 	class, an example and a brief, imprecise description of the default
    59 	behaviour of characters of that class.	 */
    60 	enum
    61 		{
    62 		/** Opening Punctuation (e.g. '['). Breaking after prohibited. */
    63 		EOpLineBreakClass,
    64 		/** Closing Punctuation (e.g. ']'). Breaking before prohibited. */
    65 		EClLineBreakClass,
    66 		/** Ambiguous Quotes (e.g. '"'). Breaking before and after prohibited. */
    67 		EQuLineBreakClass,
    68 		/** Glue (e.g. Non-breaking space). Breaking before and after prohibited
    69 		unless spaces are present. */
    70 		EGlLineBreakClass,
    71 		/** Non-Starter (e.g. small Japanese kana). Breaking before prohibited
    72 		if no spaces present. */
    73 		ENsLineBreakClass,
    74 		/** Exclamation or Interrogation (e.g. '?'). Like closing punctuation
    75 		except before Postfix or Non-starter. */
    76 		EExLineBreakClass,
    77 		/** Symbol (e.g. '/'. Like Alphabetic, but allows breaking before
    78 		Alphabetic. */
    79 		ESyLineBreakClass,
    80 		/** Numeric Infix Separator (e.g. ','). Forbids breaking after any and before
    81 		Numeric. */
    82 		EIsLineBreakClass,
    83 		/** Numeric Prefix (e.g. '$'). Forbids breaking before Numeric. */
    84 		EPrLineBreakClass,
    85 		/** Numeric Postfix (e.g. '%'). Forbids breaking after Numeric. */
    86 		EPoLineBreakClass,
    87 		/** Numeric (e.g. '1'). */
    88 		ENuLineBreakClass,
    89 		/** Alphabetic (e.g. 'a'). */
    90 		EAlLineBreakClass,
    91 		/** Ideographic (e.g. Japanese Kanji). Generally break before or after */
    92 		EIdLineBreakClass,
    93 		/** Inseparable (e.g. ellipsis). Forbid breaks between Inseparables. */
    94 		EInLineBreakClass,
    95 		/** Hyphen (e.g. '-'). Allows a break after except before Numeric. */
    96 		EHyLineBreakClass,
    97 		/** Break After. Generally allow a break after. Breaking between Break
    98 		Afters not separated by spaces is prohibited. */
    99 		EBaLineBreakClass,
   100 		/** Break Before. Generally allow a break before. Breaking between Break
   101 		Befores not separated by spaces is prohibited. */
   102 		EBbLineBreakClass,
   103 		/** Break Before and After. Generally allow a break before or after.
   104 		Breaking between Break Before and Afters is prohibited, even if spaces
   105 		are present. */
   106 		EB2LineBreakClass,
   107 		/** Zero-Width Space. Allow a break. */
   108 		EZwLineBreakClass,
   109 		/** Combining Mark. Takes on the class of its base class. */
   110 		ECmLineBreakClass,
   111 		/** Mandatory Break. */
   112 		EBkLineBreakClass,
   113 		/** Carriage Return. Break after unless part of a CRLF pair. */
   114 		ECrLineBreakClass,
   115 		/** Line Feed. Break after. */
   116 		ELfLineBreakClass,
   117 		/** Surrogate. Half of a surrogate pair. */
   118 		ESgLineBreakClass,
   119 		/** Contingent Break (e.g. embedded pictures). Uses external
   120 		information */
   121 		ECbLineBreakClass,
   122 
   123 		/** Space. Intervening characters of class Space are indicated by
   124 		aHaveSpaces in LineBreakPossible. */
   125 		ESpLineBreakClass, 
   126 
   127 		/** Complex Context (e.g. Thai). Runs of Complex Context are passed to
   128 		GetLineBreakInContext. */
   129 		ESaLineBreakClass,
   130 
   131 		/** Ambiguous. Characters of ambiguous East Asian width are treated
   132 		as Alphabetic, unless they are resolved as being "Wide", in which case
   133 		they are treated as Ideographic. */
   134 		EAiLineBreakClass,
   135 
   136 		/** The Xx class is used when the class is unknown; e.g.; outside the provided context. */
   137 		EXxLineBreakClass,
   138 
   139 		/** The number of Unicode line break classes. */
   140 		ELineBreakClasses
   141 		};
   142 
   143 	IMPORT_C virtual TUint LineBreakClass(TUint aCode,
   144 		TUint& aRangeStart, TUint& aRangeEnd) const;
   145 	IMPORT_C virtual TBool LineBreakPossible(TUint aPrevClass, TUint aNextClass,
   146 		TBool aHaveSpaces) const;
   147 	IMPORT_C virtual TBool GetLineBreakInContext(const TDesC16& aText,
   148 		TInt aMinBreakPos, TInt aMaxBreakPos, TBool aForwards,
   149 		TInt& aBreakPos) const;
   150 	IMPORT_C virtual TBool IsHangingCharacter(TUint aChar) const;
   151 	IMPORT_C TBool GetLineBreak(const TDesC16& aText,
   152 		TInt aMinBreakPos, TInt aMaxBreakPos, TBool aForwards,
   153 		MContingentLineBreaker* aCbDelegate,
   154 		TInt& aBreakPos, TInt& aBreakPosAfterSpaces) const;
   155 	IMPORT_C TBool GetLineBreakL(const TDesC16& aText,
   156 		TInt aMinBreakPos, TInt aMaxBreakPos, TBool aForwards,
   157 		MContingentLineBreakerL* aCbDelegate,
   158 		TInt& aBreakPos, TInt& aBreakPosAfterSpaces) const;
   159 	IMPORT_C virtual void* ExtendedInterface(TUid& aUid) const;
   160 	};
   161 
   162 
   163 class MContingentLineBreaker
   164 /**
   165 Used to determine the line breaks around pictures and other characters with 
   166 the CB (contingent line break) class in situations where this operation cannot 
   167 leave. 
   168 @publishedAll
   169 @released
   170 */
   171 	{
   172 public:
   173 	/** Determines if a break is legal before the picture at aTextPosition. 
   174 	
   175 	@param aTextPosition The position of a character of line breaking class ECbLineBreakClass 
   176 	in the text as supplied to MLineBreaker::GetLineBreak(), which may refer to 
   177 	a picture.
   178 	@param aPrecedingClass The class of the character preceding aTextPosition.
   179 	@param aHasSpaces ETrue if spaces separate the preceding class from this.
   180 	@return ETrue if a line break is legal here. */
   181 	virtual TBool IsLegalBreakBefore(TInt aTextPosition, TInt aPrecedingClass,
   182 		TBool aHasSpaces) = 0;
   183 	/** Determines if a break is legal after the picture at aTextPosition. 
   184 	
   185 	@param aTextPosition The position of a character of line breaking class ECbLineBreakClass 
   186 	in the text as supplied to MLineBreaker::GetLineBreak, which may refer to 
   187 	a picture.
   188 	@param aFollowingClass The class of the character immediately following aTextPosition.
   189 	@param aHasSpaces ETrue if spaces separate the following class from this.
   190 	@return ETrue if a line break is legal here. */
   191 	virtual TBool IsLegalBreakAfter(TInt aTextPosition, TInt aFollowingClass,
   192 		TBool aHasSpaces) = 0;
   193 	};
   194 
   195 
   196 
   197 class MContingentLineBreakerL
   198 /**
   199 Used to determine the line breaks around pictures and other characters with 
   200 the CB (contingent line break) class in situations where this operation may 
   201 leave. 
   202 @publishedAll
   203 @released
   204 */
   205 	{
   206 public:
   207 	/** Determines if a break is legal before the picture at aTextPosition. 
   208 	
   209 	@param aTextPosition The position of a character of line breaking class ECbLineBreakClass 
   210 	in the text as supplied to MLineBreaker::GetLineBreak(), which may refer to 
   211 	a picture.
   212 	@param aPrecedingClass The class of the character preceding aTextPosition.
   213 	@param aHasSpaces ETrue if spaces separate the preceding class from this.
   214 	@return ETrue if a line break is legal here. */
   215 	virtual TBool IsLegalBreakBeforeL(TInt aTextPosition, TInt aPrecedingClass,
   216 		TBool aHasSpaces) = 0;
   217 	/** Determines if a break is legal after the picture at aTextPosition. 
   218 	
   219 	@param aTextPosition The position of a character of line breaking class ECbLineBreakClass 
   220 	in the text as supplied to MLineBreaker::GetLineBreak(), which may refer to 
   221 	a picture.
   222 	@param aFollowingClass The class of the character immediately following aTextPosition.
   223 	@param aHasSpaces ETrue if spaces separate the preceding class from this.
   224 	@return ETrue if a line break is legal here. */
   225 	virtual TBool IsLegalBreakAfterL(TInt aTextPosition, TInt aFollowingClass,
   226 		TBool aHasSpaces) = 0;
   227 	};
   228 
   229 #endif