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)
voidDeneutralizeRuns(TRunInfo *, TRunInfo *, TCategory, TCategory)
IMPORT_C voidExternalizeL(RWriteStream &)
TInt GenerateBdRunArray(const TText *, TInt, TBidirectionalState::TRunInfo *, TInt)
voidHandleBdControls(TReorderContext &)
IMPORT_C voidInternalizeL(RReadStream &)
IMPORT_C TBoolIsDefault()
TBool ParRightToLeft()
voidPrepareForNextLine(const TReorderContext &)
IMPORT_C voidReorderLine(TRunInfo *, TInt, TBool, TBool, TBool, TChar::TBdCategory, TChar::TBdCategory, TBool &)
IMPORT_C voidReorderLine(TRunInfo *, TInt, TBool, TBool, TBool, TChar::TBdCategory, TChar::TBdCategory)
voidReorderRuns(TReorderContext &)
IMPORT_C TIntReorderText(const TText *, TInt, TBool, TText *&)
IMPORT_C voidReset()
voidResolveImplicitLevels(TReorderContext &)
voidResolveNeutralTypes(TReorderContext &)
voidResolveWeakTypesW1W2W3(TReorderContext &)
voidResolveWeakTypesW4W5W6(TReorderContext &)
voidResolveWeakTypesW7(TReorderContext &)
IMPORT_C voidReverseGroups(TText *, TInt)
TCategory UintToBdCat(TUint)
IMPORT_C TBooloperator==(const TBidirectionalState &)
Private Member Functions
TCategory Pop()
TCategory Push(TCategory)
const TStackItem &State()
Private Member Enumerations
enumanonymous { EMaxExplicitLevel = 61, EMaxLevel = 63, EMaxStackLevels = 62 }
enumTCategory {
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
}
enumTOverrideState { 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_CTBidirectionalState()

Standard constructor.

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

TBidirectionalState(TChar::TBdCategoryaPrevCat,
TChar::TBdCategoryaPrevStrongCat,
TBoolaParRightToLeft
)

Constructor suitable for test code.

Parameters

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

Member Functions Documentation

CatToNumber(TInt)

TInt CatToNumber(TIntaCat)[static]

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

Parameters

TInt aCata TBidirectionalState::TCategory.

CharToBdCat(TChar::TBdCategory)

TCategory CharToBdCat(TChar::TBdCategoryaCat)[static]

Parameters

TChar::TBdCategory aCat

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

voidDeneutralizeRuns(TRunInfo *aStart,
TRunInfo *aEnd,
TCategoryaStartCategory,
TCategoryaEndCategory
)[static]

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

Parameters

TRunInfo * aStartThe start of the run array to be altered.
TRunInfo * aEndOne past the end of the run array to be altered.
TCategory aStartCategoryThe last non-neutral before the run, must be ELeftToRight or ERightToLeft.
TCategory aEndCategoryThe first non-neutral after the run, must be ELeftToRight or ERightToLeft.

ExternalizeL(RWriteStream &)

IMPORT_C voidExternalizeL(RWriteStream &aDest)

Serializes a bidirectional state to an output stream.

Parameters

RWriteStream & aDestAn output stream.

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

TInt GenerateBdRunArray(const TText *aText,
TIntaLength,
TBidirectionalState::TRunInfo *aRun,
TIntaMaxRuns
)[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 * aTextThe text to be analysed.
TInt aLengthThe length of the text to be analysed.
TBidirectionalState::TRunInfo * aRunOutput buffer for the runs after analysis. May be null if there is to be no output.
TInt aMaxRunsThe size of the aRun array. No more than this number of runs will be output.

HandleBdControls(TReorderContext &)

voidHandleBdControls(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 voidInternalizeL(RReadStream &aSource)

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

Parameters

RReadStream & aSourceA source stream.

IsDefault()

IMPORT_C TBoolIsDefault()const

Returns Gets the default 'start of paragraph' state.

ParRightToLeft()

TBool ParRightToLeft()const [inline]

Pop()

TCategory Pop()[private]

PrepareForNextLine(const TReorderContext &)

voidPrepareForNextLine(const TReorderContext &aContext)

Fold context information back into TBidirectionalState.

Parameters

const TReorderContext & aContext

Push(TCategory)

TCategory Push(TCategoryaStartCategory)[private]

Parameters

TCategory aStartCategory

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

IMPORT_C voidReorderLine(TRunInfo *aRunInfo,
TIntaRuns,
TBoolaParStart,
TBoolaParEnd,
TBoolaParRightToLeft,
TChar::TBdCategoryaNextCategory,
TChar::TBdCategoryaNextStrongCategory,
TBool &aVisualEndIsAmbiguous
)

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

Parameters

TRunInfo * aRunInfoAn 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 aRunsNumber of 'run info' objects.
TBool aParStartTells the function whether the line is the first line of a paragraph.
TBool aParEndTells the function whether the line is the last line of a paragraph.
TBool aParRightToLeftETrue if the default directionality of the text to be re-ordered is right-to-left.
TChar::TBdCategory aNextCategoryThe category of the character immediately after the end of the line. This is ignored if aParEnd is ETrue.
TChar::TBdCategory aNextStrongCategoryThe 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 & aVisualEndIsAmbiguousEFalse 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 voidReorderLine(TRunInfo *aRunInfo,
TIntaRuns,
TBoolaParStart,
TBoolaParEnd,
TBoolaParRightToLeft,
TChar::TBdCategoryaNextCategory,
TChar::TBdCategoryaNextStrongCategory
)

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

Parameters

TRunInfo * aRunInfoAn 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 aRunsNumber of 'run info' objects.
TBool aParStartTells the function whether the line is the first line of a paragraph.
TBool aParEndTells the function whether the line is the last line of a paragraph.
TBool aParRightToLeftETrue if the default directionality of the text to be re-ordered is right-to-left.
TChar::TBdCategory aNextCategoryThe category of the character immediately after the end of the line. This is ignored if aParEnd is ETrue.
TChar::TBdCategory aNextStrongCategoryThe 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 &)

voidReorderRuns(TReorderContext &aContext)

Phase L2.

Parameters

TReorderContext & aContext

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

IMPORT_C TIntReorderText(const TText *aText,
TIntaLength,
TBoolaParRightToLeft,
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 * aTextThe input text in logical order.
TInt aLengthThe length of the input text.
TBool aParRightToLeftETrue if the default directionality of the text to be re-ordered is right-to-left.
TText *& aNewTextReturns 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 voidReset()

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

ResolveImplicitLevels(TReorderContext &)

voidResolveImplicitLevels(TReorderContext &aContext)

Phases I1 and I2.

Parameters

TReorderContext & aContext

ResolveNeutralTypes(TReorderContext &)

voidResolveNeutralTypes(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 &)

voidResolveWeakTypesW1W2W3(TReorderContext &aContext)

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

Parameters

TReorderContext & aContext

ResolveWeakTypesW4W5W6(TReorderContext &)

voidResolveWeakTypesW4W5W6(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 &)

voidResolveWeakTypesW7(TReorderContext &aContext)

Parameters

TReorderContext & aContext

ReverseGroups(TText *, TInt)

IMPORT_C voidReverseGroups(TText *aStart,
TIntaLength
)[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 * aStartStart position of text to be reversed.
TInt aLengthLength of text to be reversed.

State()

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

UintToBdCat(TUint)

TCategory UintToBdCat(TUintaCat)[static]

Parameters

TUint aCat

operator==(const TBidirectionalState &)

IMPORT_C TBooloperator==(const TBidirectionalState &aState)const

Return ETrue if two bidirectional states are identical.

Parameters

const TBidirectionalState & aStateA 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]