TBidirectionalState Class Reference

#include <bidi.h>

Link against: gdi.lib

class TBidirectionalState

Nested Classes and Structures

Public Member Functions
TBidirectionalState()
TBidirectionalState(TChar::TBdCategory, TChar::TBdCategory, TBool)
TInt CatToNumber(TInt)
TCategoryCharToBdCat(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)
TCategoryUintToBdCat(TUint)
IMPORT_C TBooloperator==(const TBidirectionalState &)

Detailed Description

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.

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.

Member Function Documentation

CatToNumber ( TInt )

TInt CatToNumber(TIntaCat)[static]

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

ParameterDescription
aCata TBidirectionalState::TCategory.

Returns: The equivalent TChar::TBdCategory.

CharToBdCat ( TChar::TBdCategory )

TCategoryCharToBdCat(TChar::TBdCategoryaCat)[static]

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.

ParameterDescription
aStartThe start of the run array to be altered.
aEndOne past the end of the run array to be altered.
aStartCategoryThe last non-neutral before the run, must be ELeftToRight or ERightToLeft.
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.

ParameterDescription
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.

ParameterDescription
aTextThe text to be analysed.
aLengthThe length of the text to be analysed.
aRunOutput buffer for the runs after analysis. May be null if there is to be no output.
aMaxRunsThe size of the aRun array. No more than this number of runs will be output.

Returns: The number of runs that are required for the full results of the analysis.

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.

InternalizeL ( RReadStream & )

IMPORT_C voidInternalizeL(RReadStream &aSource)

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

ParameterDescription
aSourceA source stream.

IsDefault ( )

IMPORT_C TBoolIsDefault()const

Returns Gets the default 'start of paragraph' state.

Returns: ETrue if the object is in its default 'start of paragraph' state.

ParRightToLeft ( )

TBool ParRightToLeft()const [inline]

PrepareForNextLine ( const TReorderContext & )

voidPrepareForNextLine(const TReorderContext &aContext)

Fold context information back into TBidirectionalState.

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.

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

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

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).

ParameterDescription
aTextThe input text in logical order.
aLengthThe length of the input text.
aParRightToLeftETrue if the default directionality of the text to be re-ordered is right-to-left.
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()).

Returns: A system-wide error value if there has been an error; KErrNone if there has not.

Reset ( )

IMPORT_C voidReset()

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

ResolveImplicitLevels ( TReorderContext & )

voidResolveImplicitLevels(TReorderContext &aContext)

Phases I1 and I2.

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.

ResolveWeakTypesW1W2W3 ( TReorderContext & )

voidResolveWeakTypesW1W2W3(TReorderContext &aContext)

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

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.

ResolveWeakTypesW7 ( TReorderContext & )

voidResolveWeakTypesW7(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.

ParameterDescription
aStartStart position of text to be reversed.
aLengthLength of text to be reversed.

UintToBdCat ( TUint )

TCategoryUintToBdCat(TUintaCat)[static]

operator== ( const TBidirectionalState & )

IMPORT_C TBooloperator==(const TBidirectionalState &aState)const

Return ETrue if two bidirectional states are identical.

ParameterDescription
aStateA bidirectional state.

Returns: ETrue if two bidirectional states are identical.