TBidirectionalState Class Reference

class TBidirectionalState

The bidirectional state class. This class contains functions that implement the Unicode Bidirectional Algorithm, which changes text from logical order to display order for the correct display of right-to-left scripts, like Arabic and Hebrew. A TBidirectionalState object carries the embedding level and stack from one line to the next. On construction it is in its 'start of paragraph' state.

Public Member Functions
TBidirectionalState ()
TBidirectionalState ( TChar::TBdCategory , TChar::TBdCategory , TBool )
TInt CatToNumber ( TInt )
TCategory CharToBdCat ( TChar::TBdCategory )
void DeneutralizeRuns ( TRunInfo *, TRunInfo *, TCategory , TCategory )
IMPORT_C void ExternalizeL ( RWriteStream &)
TInt GenerateBdRunArray (const TText *, TInt , TBidirectionalState::TRunInfo *, TInt )
void HandleBdControls ( TReorderContext &)
IMPORT_C void InternalizeL ( RReadStream &)
IMPORT_C TBool IsDefault ()
TBool ParRightToLeft ()
void PrepareForNextLine (const TReorderContext &)
IMPORT_C void ReorderLine ( TRunInfo *, TInt , TBool , TBool , TBool , TChar::TBdCategory , TChar::TBdCategory , TBool &)
IMPORT_C void ReorderLine ( TRunInfo *, TInt , TBool , TBool , TBool , TChar::TBdCategory , TChar::TBdCategory )
void ReorderRuns ( TReorderContext &)
IMPORT_C TInt ReorderText (const TText *, TInt , TBool , TText *&)
IMPORT_C void Reset ()
void ResolveImplicitLevels ( TReorderContext &)
void ResolveNeutralTypes ( TReorderContext &)
void ResolveWeakTypesW1W2W3 ( TReorderContext &)
void ResolveWeakTypesW4W5W6 ( TReorderContext &)
void ResolveWeakTypesW7 ( TReorderContext &)
IMPORT_C void ReverseGroups ( TText *, TInt )
TCategory UintToBdCat ( TUint )
IMPORT_C TBool operator== (const TBidirectionalState &)
Private Member Functions
TCategory Pop ()
TCategory Push ( TCategory )
const TStackItem & State ()
Private Member Enumerations
enum anonymous { EMaxExplicitLevel  = 61, EMaxLevel  = 63, EMaxStackLevels  = 62 }
enum TCategory {
ELeftToRight  = 1 << TChar::ELeftToRight, ELeftToRightEmbedding  = 1 << TChar::ELeftToRightEmbedding, ELeftToRightOverride  = 1 << TChar::ELeftToRightOverride, ERightToLeft  = 1 << TChar::ERightToLeft, ERightToLeftArabic  = 1 << TChar::ERightToLeftArabic, ERightToLeftEmbedding  = 1 << TChar::ERightToLeftEmbedding, ERightToLeftOverride  = 1 << TChar::ERightToLeftOverride, EPopDirectionalFormat  = 1 << TChar::EPopDirectionalFormat, EEuropeanNumber  = 1 << TChar::EEuropeanNumber, EEuropeanNumberSeparator  = 1 << TChar::EEuropeanNumberSeparator, EEuropeanNumberTerminator  = 1 << TChar::EEuropeanNumberTerminator, EArabicNumber  = 1 << TChar::EArabicNumber, ECommonNumberSeparator  = 1 << TChar::ECommonNumberSeparator, ENonSpacingMark  = 1 << TChar::ENonSpacingMark, EBoundaryNeutral  = 1 << TChar::EBoundaryNeutral, EParagraphSeparator  = 1 << TChar::EParagraphSeparator, ESegmentSeparator  = 1 << TChar::ESegmentSeparator, EWhitespace  = 1 << TChar::EWhitespace, EOtherNeutral  = 1 << TChar::EOtherNeutral, EBdControlsGroup  = ELeftToRightEmbedding | ERightToLeftEmbedding | ELeftToRightOverride | ERightToLeftOverride | EPopDirectionalFormat, ELeftToRightGroup  = ELeftToRight | EEuropeanNumber | ELeftToRightOverride | ELeftToRightEmbedding, ERightToLeftGroup  = ERightToLeft | EArabicNumber | ERightToLeftArabic | ERightToLeftOverride | ERightToLeftEmbedding, EStrongGroup  = ELeftToRightEmbedding | ERightToLeftEmbedding | ELeftToRightOverride | ERightToLeftOverride | ELeftToRight | ERightToLeft | ERightToLeftArabic, ENoCategory  = 0
}
enum TOverrideState { ENoOverrideState  = 0, ELeftToRightOverrideState  = ELeftToRightOverride, ERightToLeftOverrideState  = ERightToLeftOverride }
Private Attributes
TCategory iPreviousCategory
TCategory iPreviousStrongCategory
TInt8 iPushesBeyond60
TInt8 iPushesBeyond61
TStackItem iStack
TInt16 iStackLevel

Constructor & Destructor Documentation

TBidirectionalState()

IMPORT_C TBidirectionalState ( )

Standard constructor.

TBidirectionalState(TChar::TBdCategory, TChar::TBdCategory, TBool)

TBidirectionalState ( TChar::TBdCategory aPrevCat,
TChar::TBdCategory aPrevStrongCat,
TBool aParRightToLeft
)

Constructor suitable for test code.

Parameters

TChar::TBdCategory aPrevCat
TChar::TBdCategory aPrevStrongCat
TBool aParRightToLeft

Member Functions Documentation

CatToNumber(TInt)

TInt CatToNumber ( TInt aCat ) [static]

Finds the highest bit set in the input. Used to convert TBidirectionalState::TCategory into TChar::TBdCategory .

Parameters

TInt aCat a TBidirectionalState::TCategory.

CharToBdCat(TChar::TBdCategory)

TCategory CharToBdCat ( TChar::TBdCategory aCat ) [static]

Parameters

TChar::TBdCategory aCat

DeneutralizeRuns(TRunInfo *, TRunInfo *, TCategory, TCategory)

void DeneutralizeRuns ( TRunInfo * aStart,
TRunInfo * aEnd,
TCategory aStartCategory,
TCategory aEndCategory
) [static]

Turn all ON (Other Neutral) into non-neutrals according to the rules N1 and N2.

Parameters

TRunInfo * aStart The start of the run array to be altered.
TRunInfo * aEnd One past the end of the run array to be altered.
TCategory aStartCategory The last non-neutral before the run, must be ELeftToRight or ERightToLeft.
TCategory aEndCategory The first non-neutral after the run, must be ELeftToRight or ERightToLeft.

ExternalizeL(RWriteStream &)

IMPORT_C void ExternalizeL ( RWriteStream & aDest )

Serializes a bidirectional state to an output stream.

Parameters

RWriteStream & aDest An output stream.

GenerateBdRunArray(const TText *, TInt, TBidirectionalState::TRunInfo *, TInt)

TInt GenerateBdRunArray ( const TText * aText,
TInt aLength,
TBidirectionalState::TRunInfo * aRun,
TInt aMaxRuns
) [static]

Analyse the input text for runs of characters that share the same bidirectional class. Categories TChar::EEuropeanNumberSeparator and TChar::ECommonNumberSeparator are kept as singletons due to a limitation in the reordering logic.

Parameters

const TText * aText The text to be analysed.
TInt aLength The length of the text to be analysed.
TBidirectionalState::TRunInfo * aRun Output buffer for the runs after analysis. May be null if there is to be no output.
TInt aMaxRuns The size of the aRun array. No more than this number of runs will be output.

HandleBdControls(TReorderContext &)

void HandleBdControls ( TReorderContext & aContext )

Handle LRO, RLO, LRE, RLE and PDF. After this phase, these categories will no longer be found.

This corresponds to Unicode(3.2) Bidirectional Algorithm phases X1-X7. Phase X8 is not required as the run is assumed to be all in one paragraph. Phases X9-X10 are implicit in other functions.

Parameters

TReorderContext & aContext

InternalizeL(RReadStream &)

IMPORT_C void InternalizeL ( RReadStream & aSource )

Reads a bidirectional state from an input stream, translating it from its serialized form.

Parameters

RReadStream & aSource A source stream.

IsDefault()

IMPORT_C TBool IsDefault ( ) const

Returns Gets the default 'start of paragraph' state.

ParRightToLeft()

TBool ParRightToLeft ( ) const [inline]

Pop()

TCategory Pop ( ) [private]

PrepareForNextLine(const TReorderContext &)

void PrepareForNextLine ( const TReorderContext & aContext )

Fold context information back into TBidirectionalState .

Parameters

const TReorderContext & aContext

Push(TCategory)

TCategory Push ( TCategory aStartCategory ) [private]

Parameters

TCategory aStartCategory

ReorderLine(TRunInfo *, TInt, TBool, TBool, TBool, TChar::TBdCategory, TChar::TBdCategory, TBool &)

IMPORT_C void ReorderLine ( TRunInfo * aRunInfo,
TInt aRuns,
TBool aParStart,
TBool aParEnd,
TBool aParRightToLeft,
TChar::TBdCategory aNextCategory,
TChar::TBdCategory aNextStrongCategory,
TBool & aVisualEndIsAmbiguous
)

Reorders a line of text and updates the bidirectional state for the next line.

Parameters

TRunInfo * aRunInfo An array of objects representing runs of characters with the same bidirectional category. Any number of characters can be combined into a run if they have the same category, except for the categories TChar::EEuropeanNumberSeparator and TChar::ECommonNumberSeparator, which should be put into single-character runs because the reordering logic depends on this.
TInt aRuns Number of 'run info' objects.
TBool aParStart Tells the function whether the line is the first line of a paragraph.
TBool aParEnd Tells the function whether the line is the last line of a paragraph.
TBool aParRightToLeft ETrue if the default directionality of the text to be re-ordered is right-to-left.
TChar::TBdCategory aNextCategory The category of the character immediately after the end of the line. This is ignored if aParEnd is ETrue.
TChar::TBdCategory aNextStrongCategory The category of the first strong character (one of the categories ELeftToRight, ELeftToRightEmbedding, ELeftToRightOverride, ERightToLeft, ERightToLeftArabic, ERightToLeftEmbedding or ERightToLeftOverride) after the end of the line. This is ignored if aParEnd is ETrue.
TBool & aVisualEndIsAmbiguous EFalse if the logical end of this line is at the visual end and the logical beginning of the next line is at the visual beginning.

ReorderLine(TRunInfo *, TInt, TBool, TBool, TBool, TChar::TBdCategory, TChar::TBdCategory)

IMPORT_C void ReorderLine ( TRunInfo * aRunInfo,
TInt aRuns,
TBool aParStart,
TBool aParEnd,
TBool aParRightToLeft,
TChar::TBdCategory aNextCategory,
TChar::TBdCategory aNextStrongCategory
)

Reorders a line of text and updates the bidirectional state for the next line.

Parameters

TRunInfo * aRunInfo An array of objects representing runs of characters with the same bidirectional category. Any number of characters can be combined into a run if they have the same category, except for the categories TChar::EEuropeanNumberSeparator and TChar::ECommonNumberSeparator, which should be put into single-character runs because the reordering logic depends on this.
TInt aRuns Number of 'run info' objects.
TBool aParStart Tells the function whether the line is the first line of a paragraph.
TBool aParEnd Tells the function whether the line is the last line of a paragraph.
TBool aParRightToLeft ETrue if the default directionality of the text to be re-ordered is right-to-left.
TChar::TBdCategory aNextCategory The category of the character immediately after the end of the line. This is ignored if aParEnd is ETrue.
TChar::TBdCategory aNextStrongCategory The category of the first strong character (one of the categories ELeftToRight, ELeftToRightEmbedding, ELeftToRightOverride, ERightToLeft, ERightToLeftArabic, ERightToLeftEmbedding or ERightToLeftOverride) after the end of the line. This is ignored if aParEnd is ETrue.

ReorderRuns(TReorderContext &)

void ReorderRuns ( TReorderContext & aContext )

Phase L2.

Parameters

TReorderContext & aContext

ReorderText(const TText *, TInt, TBool, TText *&)

IMPORT_C TInt ReorderText ( const TText * aText,
TInt aLength,
TBool aParRightToLeft,
TText *& aNewText
) [static]

Reorders text according to the Unicode Bidirectional Reordering algorithm.

Reorders the input text from logical order (which may be bidirectional) to display order (strictly left to right).

Parameters

const TText * aText The input text in logical order.
TInt aLength The length of the input text.
TBool aParRightToLeft ETrue if the default directionality of the text to be re-ordered is right-to-left.
TText *& aNewText Returns the re-ordered text. If the text did not need re-ordering, or if there was an error, aText will be returned. Otherwise, ownership of a newly allocated buffer will be returned to the caller. This buffer must be deleted with delete[] (or CleanupArrayDeletePushL()) and not delete (or CleanupStack::PushL()).

Reset()

IMPORT_C void Reset ( )

Sets the object to its default 'start of paragraph' state.

ResolveImplicitLevels(TReorderContext &)

void ResolveImplicitLevels ( TReorderContext & aContext )

Phases I1 and I2.

Parameters

TReorderContext & aContext

ResolveNeutralTypes(TReorderContext &)

void ResolveNeutralTypes ( TReorderContext & aContext )

This phase removes the ON (Other Neutral) category, leaving only L, R, EN, and AN; no need to update aContext.iCategories.

Parameters

TReorderContext & aContext

ResolveWeakTypesW1W2W3(TReorderContext &)

void ResolveWeakTypesW1W2W3 ( TReorderContext & aContext )

Unicode(3.2) Bidirectional Algorithm phases W1, W2 and W3.

Parameters

TReorderContext & aContext

ResolveWeakTypesW4W5W6(TReorderContext &)

void ResolveWeakTypesW4W5W6 ( TReorderContext & aContext )

This phase removes categories NSM, AL, ES, ET, CS, BS, S, WS and BN, leaving only L, R, EN, AN and ON.

Parameters

TReorderContext & aContext

ResolveWeakTypesW7(TReorderContext &)

void ResolveWeakTypesW7 ( TReorderContext & aContext )

Parameters

TReorderContext & aContext

ReverseGroups(TText *, TInt)

IMPORT_C void ReverseGroups ( TText * aStart,
TInt aLength
) [static]

A utility to reverse text apart from combining characters, which remains after their base characters. This is what is needed when drawing right-to-left text.

Parameters

TText * aStart Start position of text to be reversed.
TInt aLength Length of text to be reversed.

State()

const TStackItem & State ( ) const [private, inline]

UintToBdCat(TUint)

TCategory UintToBdCat ( TUint aCat ) [static]

Parameters

TUint aCat

operator==(const TBidirectionalState &)

IMPORT_C TBool operator== ( const TBidirectionalState & aState ) const

Return ETrue if two bidirectional states are identical.

Parameters

const TBidirectionalState & aState A bidirectional state.

Member Enumerations Documentation

Enum anonymous

Enumerators

EMaxExplicitLevel = 61
EMaxLevel = 63
EMaxStackLevels = 62

Enum TCategory

Enumerators

ELeftToRight = 1 << TChar::ELeftToRight
ELeftToRightEmbedding = 1 << TChar::ELeftToRightEmbedding
ELeftToRightOverride = 1 << TChar::ELeftToRightOverride
ERightToLeft = 1 << TChar::ERightToLeft
ERightToLeftArabic = 1 << TChar::ERightToLeftArabic
ERightToLeftEmbedding = 1 << TChar::ERightToLeftEmbedding
ERightToLeftOverride = 1 << TChar::ERightToLeftOverride
EPopDirectionalFormat = 1 << TChar::EPopDirectionalFormat
EEuropeanNumber = 1 << TChar::EEuropeanNumber
EEuropeanNumberSeparator = 1 << TChar::EEuropeanNumberSeparator
EEuropeanNumberTerminator = 1 << TChar::EEuropeanNumberTerminator
EArabicNumber = 1 << TChar::EArabicNumber
ECommonNumberSeparator = 1 << TChar::ECommonNumberSeparator
ENonSpacingMark = 1 << TChar::ENonSpacingMark
EBoundaryNeutral = 1 << TChar::EBoundaryNeutral
EParagraphSeparator = 1 << TChar::EParagraphSeparator
ESegmentSeparator = 1 << TChar::ESegmentSeparator
EWhitespace = 1 << TChar::EWhitespace
EOtherNeutral = 1 << TChar::EOtherNeutral
EBdControlsGroup = ELeftToRightEmbedding | ERightToLeftEmbedding | ELeftToRightOverride | ERightToLeftOverride | EPopDirectionalFormat
ELeftToRightGroup = ELeftToRight | EEuropeanNumber | ELeftToRightOverride | ELeftToRightEmbedding
ERightToLeftGroup = ERightToLeft | EArabicNumber | ERightToLeftArabic | ERightToLeftOverride | ERightToLeftEmbedding
EStrongGroup = ELeftToRightEmbedding | ERightToLeftEmbedding | ELeftToRightOverride | ERightToLeftOverride | ELeftToRight | ERightToLeft | ERightToLeftArabic
ENoCategory = 0

Enum TOverrideState

Enumerators

ENoOverrideState = 0
ELeftToRightOverrideState = ELeftToRightOverride
ERightToLeftOverrideState = ERightToLeftOverride

Member Data Documentation

TCategory iPreviousCategory

TCategory iPreviousCategory [private]

TCategory iPreviousStrongCategory

TCategory iPreviousStrongCategory [private]

TInt8 iPushesBeyond60

TInt8 iPushesBeyond60 [private]

TInt8 iPushesBeyond61

TInt8 iPushesBeyond61 [private]

TStackItem iStack

TStackItem iStack [private]

TInt16 iStackLevel

TInt16 iStackLevel [private]