LibreOffice
LibreOffice 24.2 SDK API Reference
Public Member Functions | List of all members
XCharacterClassification Interface Referencepublished

Character classification (upper, lower, digit, letter, number, ...) and generic Unicode enabled parser. More...

import"XCharacterClassification.idl";

Inheritance diagram for XCharacterClassification:
XInterface CharacterClassification

Public Member Functions

string toUpper ([in] string aText, [in] long nPos, [in] long nCount, [in] com::sun::star::lang::Locale aLocale)
 Convert lower case alpha to upper case alpha, starting at position nPos for nCount code points. More...
 
string toLower ([in] string aText, [in] long nPos, [in] long nCount, [in] com::sun::star::lang::Locale aLocale)
 Convert upper case alpha to lower case alpha, starting at position nPos for nCount code points. More...
 
string toTitle ([in] string aText, [in] long nPos, [in] long nCount, [in] com::sun::star::lang::Locale aLocale)
 Convert to title case, starting at position nPos for nCount code points. More...
 
short getType ([in] string aText, [in] long nPos)
 Get UnicodeType of character at position nPos. More...
 
short getCharacterDirection ([in] string aText, [in] long nPos)
 Get DirectionProperty of character at position nPos. More...
 
short getScript ([in] string aText, [in] long nPos)
 Get UnicodeScript of character at position nPos. More...
 
long getCharacterType ([in] string aText, [in] long nPos, [in] com::sun::star::lang::Locale aLocale)
 Get KCharacterType of character at position nPos. More...
 
long getStringType ([in] string aText, [in] long nPos, [in] long nCount, [in] com::sun::star::lang::Locale aLocale)
 Get accumulated KCharacterTypes of string starting at position nPos of length nCount code points. More...
 
ParseResult parseAnyToken ([in] string aText, [in] long nPos, [in] com::sun::star::lang::Locale aLocale, [in] long nStartCharFlags, [in] string aUserDefinedCharactersStart, [in] long nContCharFlags, [in] string aUserDefinedCharactersCont)
 Parse a string for a token starting at position nPos. More...
 
ParseResult parsePredefinedToken ([in] long nTokenType, [in] string aText, [in] long nPos, [in] com::sun::star::lang::Locale aLocale, [in] long nStartCharFlags, [in] string aUserDefinedCharactersStart, [in] long nContCharFlags, [in] string aUserDefinedCharactersCont)
 Parse a string for a token of type nTokenType starting at position nPos. More...
 
- Public Member Functions inherited from XInterface
any queryInterface ([in] type aType)
 queries for a new interface to an existing UNO object. More...
 
void acquire ()
 increases the reference counter by one. More...
 
void release ()
 decreases the reference counter by one. More...
 

Detailed Description

Character classification (upper, lower, digit, letter, number, ...) and generic Unicode enabled parser.

Developers Guide
Office Development - Implementing a New Locale - XCharacterClassification
Office Development - Overview and Using the API - XCharacterClassification

Member Function Documentation

◆ getCharacterDirection()

short getCharacterDirection ( [in] string  aText,
[in] long  nPos 
)

Get DirectionProperty of character at position nPos.

◆ getCharacterType()

long getCharacterType ( [in] string  aText,
[in] long  nPos,
[in] com::sun::star::lang::Locale  aLocale 
)

Get KCharacterType of character at position nPos.

◆ getScript()

short getScript ( [in] string  aText,
[in] long  nPos 
)

Get UnicodeScript of character at position nPos.

◆ getStringType()

long getStringType ( [in] string  aText,
[in] long  nPos,
[in] long  nCount,
[in] com::sun::star::lang::Locale  aLocale 
)

Get accumulated KCharacterTypes of string starting at position nPos of length nCount code points.

Returns
A number with appropriate flags set to indicate what type of characters the string contains, each flag value being one of KCharacterType values.
Note
The accumulated bits of several characters are meaningless as soon as characters of different classifications are involved, which even may have a common subset like KCharacterType::LETTER or KCharacterType::PRINTABLE, unless it is to be determined what overall character properties are present in the string. Use getCharacterType() of single characters instead and handle bits as needed if sets of character properties are to be obtained.

◆ getType()

short getType ( [in] string  aText,
[in] long  nPos 
)

Get UnicodeType of character at position nPos.

◆ parseAnyToken()

ParseResult parseAnyToken ( [in] string  aText,
[in] long  nPos,
[in] com::sun::star::lang::Locale  aLocale,
[in] long  nStartCharFlags,
[in] string  aUserDefinedCharactersStart,
[in] long  nContCharFlags,
[in] string  aUserDefinedCharactersCont 
)

Parse a string for a token starting at position nPos.

A name or identifier must match the KParseTokens criteria passed in nStartCharFlags and nContCharFlags and may additionally contain characters of aUserDefinedCharactersStart and/or aUserDefinedCharactersCont.

Returns
A filled ParseResult structure. If no unambiguous token could be parsed, ParseResult::TokenType will be set to 0 (zero), other fields will contain the values parsed so far.

If a token may represent either a numeric value or a name according to the passed Start/Cont-Flags/Chars, both KParseType::ASC_NUM (or KParseType::UNI_NUM) and KParseType::IDENTNAME are set in ParseResult::TokenType.

Parameters
aTextText to be parsed.
nPosPosition where parsing starts.
aLocaleThe locale, for example, for decimal and group separator or character type determination.
nStartCharFlagsA set of KParseTokens constants determining the allowed characters a name or identifier may start with.
aUserDefinedCharactersStartA set of additionally allowed characters a name or identifier may start with.
nContCharFlagsA set of KParseTokens constants determining the allowed characters a name or identifier may continue with.
aUserDefinedCharactersContA set of additionally allowed characters a name or identifier may continue with.
using namespace ::com::sun::star::i18n;
// First character of an identifier may be any alphabetic or underscore.
// Continuing characters may be any alphanumeric or underscore or dot.
// No further characters assumed to be contained in an identifier
OUString aEmptyString;
// Parse any token.
ParseResult rRes = xCC->parseAnyToken( aText, nPos, aLocale,
nStartFlags, aEmptyString, nContFlags, aEmptyString );
// Get parsed token.
fValue = rRes.Value;
if ( rRes.TokenType & KParseType::IDENTNAME )
aName = aText.copy( nPos, rRes.EndPos - nPos );
else if ( rRes.TokenType & KParseType::SINGLE_QUOTE_NAME )
aName = rRes.DequotedNameOrString;
else if ( rRes.TokenType & KParseType::DOUBLE_QUOTE_STRING )
aString = rRes.DequotedNameOrString;
else if ( rRes.TokenType & KParseType::BOOLEAN )
aSymbol = aText.copy( nPos, rRes.EndPos - nPos );
else if ( rRes.TokenType & KParseType::ONE_SINGLE_CHAR )
aSymbol = aText.copy( nPos, rRes.EndPos - nPos );

◆ parsePredefinedToken()

ParseResult parsePredefinedToken ( [in] long  nTokenType,
[in] string  aText,
[in] long  nPos,
[in] com::sun::star::lang::Locale  aLocale,
[in] long  nStartCharFlags,
[in] string  aUserDefinedCharactersStart,
[in] long  nContCharFlags,
[in] string  aUserDefinedCharactersCont 
)

Parse a string for a token of type nTokenType starting at position nPos.

Other parameters are the same as in parseAnyToken(). If the actual token does not match the passed nTokenType a ParseResult::TokenType set to 0 (zero) is returned.

Parameters
nTokenTypeOne or more of the KParseType constants.
aTextSee parseAnyToken
nPosSee parseAnyToken
aLocaleSee parseAnyToken
nStartCharFlagsSee parseAnyToken
aUserDefinedCharactersStartSee parseAnyToken
nContCharFlagsSee parseAnyToken
aUserDefinedCharactersContSee parseAnyToken
// Determine if a given name is a valid name (not quoted) and contains
// only allowed characters.
using namespace ::com::sun::star::i18n;
// First character of an identifier may be any alphanumeric or underscore.
// No further characters assumed to be contained in an identifier start.
OUString aEmptyString;
// Continuing characters may be any alphanumeric or underscore.
sal_Int32 nContFlags = nStartFlags;
// Additionally, continuing characters may contain a blank.
OUString aContChars( " " );
// Parse predefined (must be an IDENTNAME) token.
ParseResult rRes = xCC->parsePredefinedToken( KParseType::IDENTNAME, rName, 0, aLocale,
nStartFlags, aEmptyString, nContFlags, aContChars );
// Test if it is an identifier name and if it only is one
// and no more else is following it.
bValid = (rRes.TokenType & KParseType::IDENTNAME) && rRes.EndPos == rName.Len();

◆ toLower()

string toLower ( [in] string  aText,
[in] long  nPos,
[in] long  nCount,
[in] com::sun::star::lang::Locale  aLocale 
)

Convert upper case alpha to lower case alpha, starting at position nPos for nCount code points.

◆ toTitle()

string toTitle ( [in] string  aText,
[in] long  nPos,
[in] long  nCount,
[in] com::sun::star::lang::Locale  aLocale 
)

Convert to title case, starting at position nPos for nCount code points.

◆ toUpper()

string toUpper ( [in] string  aText,
[in] long  nPos,
[in] long  nCount,
[in] com::sun::star::lang::Locale  aLocale 
)

Convert lower case alpha to upper case alpha, starting at position nPos for nCount code points.


The documentation for this interface was generated from the following file: