sl@0: // Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef LINEBREAK_H_ sl@0: #define LINEBREAK_H_ sl@0: sl@0: #include sl@0: class MContingentLineBreaker; sl@0: class MContingentLineBreakerL; sl@0: class TDesC16; sl@0: class TUid; sl@0: sl@0: sl@0: /** sl@0: This enumeration holds the possible panic codes that may be raised sl@0: by the LineBreak API on detecting an unrecoverable error. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TLineBreakPanic sl@0: { sl@0: /** Not used */ sl@0: ELineBreakPanic_Unknown = 0, sl@0: /** Internal error, error found in data table */ sl@0: ELineBreakPanic_BadTable = 1, sl@0: /** One or more of the input parameters to the interface were invalid */ sl@0: ELineBreakPanic_InvalidInputParam = 2, sl@0: /** Raised when an output parameter breaks an API condition */ sl@0: ELineBreakPanic_InvalidOutputParam = 3, sl@0: }; sl@0: sl@0: sl@0: sl@0: class MLineBreaker sl@0: /** sl@0: Customizes the Unicode line-breaking algorithm. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: { sl@0: public: sl@0: /** The Unicode line breaking classes; see Unicode Technical Report 14. sl@0: Not a named enumerated type, so that overriding classes may add new sl@0: line breaking classes freely. sl@0: The description of each constant gives the name of the line-breaking sl@0: class, an example and a brief, imprecise description of the default sl@0: behaviour of characters of that class. */ sl@0: enum sl@0: { sl@0: /** Opening Punctuation (e.g. '['). Breaking after prohibited. */ sl@0: EOpLineBreakClass, sl@0: /** Closing Punctuation (e.g. ']'). Breaking before prohibited. */ sl@0: EClLineBreakClass, sl@0: /** Ambiguous Quotes (e.g. '"'). Breaking before and after prohibited. */ sl@0: EQuLineBreakClass, sl@0: /** Glue (e.g. Non-breaking space). Breaking before and after prohibited sl@0: unless spaces are present. */ sl@0: EGlLineBreakClass, sl@0: /** Non-Starter (e.g. small Japanese kana). Breaking before prohibited sl@0: if no spaces present. */ sl@0: ENsLineBreakClass, sl@0: /** Exclamation or Interrogation (e.g. '?'). Like closing punctuation sl@0: except before Postfix or Non-starter. */ sl@0: EExLineBreakClass, sl@0: /** Symbol (e.g. '/'. Like Alphabetic, but allows breaking before sl@0: Alphabetic. */ sl@0: ESyLineBreakClass, sl@0: /** Numeric Infix Separator (e.g. ','). Forbids breaking after any and before sl@0: Numeric. */ sl@0: EIsLineBreakClass, sl@0: /** Numeric Prefix (e.g. '$'). Forbids breaking before Numeric. */ sl@0: EPrLineBreakClass, sl@0: /** Numeric Postfix (e.g. '%'). Forbids breaking after Numeric. */ sl@0: EPoLineBreakClass, sl@0: /** Numeric (e.g. '1'). */ sl@0: ENuLineBreakClass, sl@0: /** Alphabetic (e.g. 'a'). */ sl@0: EAlLineBreakClass, sl@0: /** Ideographic (e.g. Japanese Kanji). Generally break before or after */ sl@0: EIdLineBreakClass, sl@0: /** Inseparable (e.g. ellipsis). Forbid breaks between Inseparables. */ sl@0: EInLineBreakClass, sl@0: /** Hyphen (e.g. '-'). Allows a break after except before Numeric. */ sl@0: EHyLineBreakClass, sl@0: /** Break After. Generally allow a break after. Breaking between Break sl@0: Afters not separated by spaces is prohibited. */ sl@0: EBaLineBreakClass, sl@0: /** Break Before. Generally allow a break before. Breaking between Break sl@0: Befores not separated by spaces is prohibited. */ sl@0: EBbLineBreakClass, sl@0: /** Break Before and After. Generally allow a break before or after. sl@0: Breaking between Break Before and Afters is prohibited, even if spaces sl@0: are present. */ sl@0: EB2LineBreakClass, sl@0: /** Zero-Width Space. Allow a break. */ sl@0: EZwLineBreakClass, sl@0: /** Combining Mark. Takes on the class of its base class. */ sl@0: ECmLineBreakClass, sl@0: /** Mandatory Break. */ sl@0: EBkLineBreakClass, sl@0: /** Carriage Return. Break after unless part of a CRLF pair. */ sl@0: ECrLineBreakClass, sl@0: /** Line Feed. Break after. */ sl@0: ELfLineBreakClass, sl@0: /** Surrogate. Half of a surrogate pair. */ sl@0: ESgLineBreakClass, sl@0: /** Contingent Break (e.g. embedded pictures). Uses external sl@0: information */ sl@0: ECbLineBreakClass, sl@0: sl@0: /** Space. Intervening characters of class Space are indicated by sl@0: aHaveSpaces in LineBreakPossible. */ sl@0: ESpLineBreakClass, sl@0: sl@0: /** Complex Context (e.g. Thai). Runs of Complex Context are passed to sl@0: GetLineBreakInContext. */ sl@0: ESaLineBreakClass, sl@0: sl@0: /** Ambiguous. Characters of ambiguous East Asian width are treated sl@0: as Alphabetic, unless they are resolved as being "Wide", in which case sl@0: they are treated as Ideographic. */ sl@0: EAiLineBreakClass, sl@0: sl@0: /** The Xx class is used when the class is unknown; e.g.; outside the provided context. */ sl@0: EXxLineBreakClass, sl@0: sl@0: /** The number of Unicode line break classes. */ sl@0: ELineBreakClasses sl@0: }; sl@0: sl@0: IMPORT_C virtual TUint LineBreakClass(TUint aCode, sl@0: TUint& aRangeStart, TUint& aRangeEnd) const; sl@0: IMPORT_C virtual TBool LineBreakPossible(TUint aPrevClass, TUint aNextClass, sl@0: TBool aHaveSpaces) const; sl@0: IMPORT_C virtual TBool GetLineBreakInContext(const TDesC16& aText, sl@0: TInt aMinBreakPos, TInt aMaxBreakPos, TBool aForwards, sl@0: TInt& aBreakPos) const; sl@0: IMPORT_C virtual TBool IsHangingCharacter(TUint aChar) const; sl@0: IMPORT_C TBool GetLineBreak(const TDesC16& aText, sl@0: TInt aMinBreakPos, TInt aMaxBreakPos, TBool aForwards, sl@0: MContingentLineBreaker* aCbDelegate, sl@0: TInt& aBreakPos, TInt& aBreakPosAfterSpaces) const; sl@0: IMPORT_C TBool GetLineBreakL(const TDesC16& aText, sl@0: TInt aMinBreakPos, TInt aMaxBreakPos, TBool aForwards, sl@0: MContingentLineBreakerL* aCbDelegate, sl@0: TInt& aBreakPos, TInt& aBreakPosAfterSpaces) const; sl@0: IMPORT_C virtual void* ExtendedInterface(TUid& aUid) const; sl@0: }; sl@0: sl@0: sl@0: class MContingentLineBreaker sl@0: /** sl@0: Used to determine the line breaks around pictures and other characters with sl@0: the CB (contingent line break) class in situations where this operation cannot sl@0: leave. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: { sl@0: public: sl@0: /** Determines if a break is legal before the picture at aTextPosition. sl@0: sl@0: @param aTextPosition The position of a character of line breaking class ECbLineBreakClass sl@0: in the text as supplied to MLineBreaker::GetLineBreak(), which may refer to sl@0: a picture. sl@0: @param aPrecedingClass The class of the character preceding aTextPosition. sl@0: @param aHasSpaces ETrue if spaces separate the preceding class from this. sl@0: @return ETrue if a line break is legal here. */ sl@0: virtual TBool IsLegalBreakBefore(TInt aTextPosition, TInt aPrecedingClass, sl@0: TBool aHasSpaces) = 0; sl@0: /** Determines if a break is legal after the picture at aTextPosition. sl@0: sl@0: @param aTextPosition The position of a character of line breaking class ECbLineBreakClass sl@0: in the text as supplied to MLineBreaker::GetLineBreak, which may refer to sl@0: a picture. sl@0: @param aFollowingClass The class of the character immediately following aTextPosition. sl@0: @param aHasSpaces ETrue if spaces separate the following class from this. sl@0: @return ETrue if a line break is legal here. */ sl@0: virtual TBool IsLegalBreakAfter(TInt aTextPosition, TInt aFollowingClass, sl@0: TBool aHasSpaces) = 0; sl@0: }; sl@0: sl@0: sl@0: sl@0: class MContingentLineBreakerL sl@0: /** sl@0: Used to determine the line breaks around pictures and other characters with sl@0: the CB (contingent line break) class in situations where this operation may sl@0: leave. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: { sl@0: public: sl@0: /** Determines if a break is legal before the picture at aTextPosition. sl@0: sl@0: @param aTextPosition The position of a character of line breaking class ECbLineBreakClass sl@0: in the text as supplied to MLineBreaker::GetLineBreak(), which may refer to sl@0: a picture. sl@0: @param aPrecedingClass The class of the character preceding aTextPosition. sl@0: @param aHasSpaces ETrue if spaces separate the preceding class from this. sl@0: @return ETrue if a line break is legal here. */ sl@0: virtual TBool IsLegalBreakBeforeL(TInt aTextPosition, TInt aPrecedingClass, sl@0: TBool aHasSpaces) = 0; sl@0: /** Determines if a break is legal after the picture at aTextPosition. sl@0: sl@0: @param aTextPosition The position of a character of line breaking class ECbLineBreakClass sl@0: in the text as supplied to MLineBreaker::GetLineBreak(), which may refer to sl@0: a picture. sl@0: @param aFollowingClass The class of the character immediately following aTextPosition. sl@0: @param aHasSpaces ETrue if spaces separate the preceding class from this. sl@0: @return ETrue if a line break is legal here. */ sl@0: virtual TBool IsLegalBreakAfterL(TInt aTextPosition, TInt aFollowingClass, sl@0: TBool aHasSpaces) = 0; sl@0: }; sl@0: sl@0: #endif