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