LibreOffice Module sc (master) 1
Functions
naturalsort Namespace Reference

Functions

static bool SplitString (const OUString &sWhole, OUString &sPrefix, OUString &sSuffix, double &fNum)
 Splits a given string into three parts: the prefix, number string, and the suffix. More...
 
static short Compare (const OUString &sInput1, const OUString &sInput2, const bool bCaseSens, const ScUserListData *pData, const CollatorWrapper *pCW)
 Naturally compares two given strings. More...
 

Function Documentation

◆ Compare()

static short naturalsort::Compare ( const OUString &  sInput1,
const OUString &  sInput2,
const bool  bCaseSens,
const ScUserListData pData,
const CollatorWrapper pCW 
)
static

Naturally compares two given strings.

This is the main function that should be called externally. It returns either 1, 0, or -1 depending on the comparison result of given two strings.

Parameters
sInput1Input string 1
sInput2Input string 2
bCaseSensBoolean value for case sensitivity
pDataPointer to user defined sort list
pCWPointer to collator wrapper for normal string comparison
Returns
Returns 1 if sInput1 is greater, 0 if sInput1 == sInput2, and -1 if sInput2 is greater.

Definition at line 162 of file table3.cxx.

References CollatorWrapper::compareString(), pData, and SplitString().

Referenced by ScTable::CompareCell(), and ScTable::IsSorted().

◆ SplitString()

static bool naturalsort::SplitString ( const OUString &  sWhole,
OUString &  sPrefix,
OUString &  sSuffix,
double &  fNum 
)
static

Splits a given string into three parts: the prefix, number string, and the suffix.

Parameters
sWholeOriginal string to be split into pieces
sPrefixPrefix string that consists of the part before the first number token. If no number was found, sPrefix is unchanged.
sSuffixString after the last number token. This may still contain number strings. If no number was found, sSuffix is unchanged.
fNumNumber converted from the middle number string If no number was found, fNum is unchanged.
Returns
Returns TRUE if a numeral element is found in a given string, or FALSE if no numeral element is found.

Definition at line 102 of file table3.cxx.

References CharClass::getCharacterType(), ScGlobal::getCharClass(), ScGlobal::getLocaleData(), LocaleDataWrapper::getNumDecimalSep(), nPos, nType, CharClass::parsePredefinedToken(), SAL_WARN, sPrefix, and sSuffix.

Referenced by Compare().