summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-10-29 09:46:05 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-10-30 10:55:23 +0200
commit45de43ce9f1441735817fa82924ddc4508d221cd (patch)
treee9fdee9ac7ed122ac27c1ef7acac968fdfa73217
parentb3bf75786f6cfd3feae735ae705e87f48d8059ed (diff)
Prepare for removal of non-const operator[] from Sequence in i18npool
Change-Id: Ib4c59c45098376f2e0a610a8ffefb4af5306bd6d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124372 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx9
-rw-r--r--i18npool/source/localedata/LocaleNode.cxx6
-rw-r--r--i18npool/source/localedata/localedata.cxx52
-rw-r--r--i18npool/source/nativenumber/nativenumbersupplier.cxx69
-rw-r--r--i18npool/source/search/textsearch.cxx84
-rw-r--r--i18npool/source/textconversion/textconversion_ko.cxx6
-rw-r--r--i18npool/source/textconversion/textconversion_zh.cxx11
-rw-r--r--i18npool/source/transliteration/textToPronounce_zh.cxx9
-rw-r--r--i18npool/source/transliteration/transliterationImpl.cxx18
-rw-r--r--i18npool/source/transliteration/transliteration_Numeric.cxx17
10 files changed, 154 insertions, 127 deletions
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index e5d631e3e1e5..831b502a2771 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -1121,11 +1121,12 @@ OUString DefaultNumberingProvider::makeNumberingIdentifier(sal_Int16 index)
OUStringBuffer result;
Locale aLocale("en", OUString(), OUString());
Sequence<beans::PropertyValue> aProperties(2);
- aProperties[0].Name = "NumberingType";
- aProperties[0].Value <<= aSupportedTypes[index].nType;
- aProperties[1].Name = "Value";
+ auto aPropertiesRange = asNonConstRange(aProperties);
+ aPropertiesRange[0].Name = "NumberingType";
+ aPropertiesRange[0].Value <<= aSupportedTypes[index].nType;
+ aPropertiesRange[1].Name = "Value";
for (sal_Int32 j = 1; j <= 3; j++) {
- aProperties[1].Value <<= j;
+ aPropertiesRange[1].Value <<= j;
result.append( makeNumberingString( aProperties, aLocale ) );
result.append(", ");
}
diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx
index 86fc96495bd4..f4c0aaefdc94 100644
--- a/i18npool/source/localedata/LocaleNode.cxx
+++ b/i18npool/source/localedata/LocaleNode.cxx
@@ -2364,10 +2364,12 @@ void LCOutlineNumberingLevelNode::generateCode (const OFileWriter &of) const
Attr::Attr (const Reference< XAttributeList > & attr) {
sal_Int16 len = attr->getLength();
name.realloc (len);
+ auto pName = name.getArray();
value.realloc (len);
+ auto pValue = value.getArray();
for (sal_Int16 i =0; i< len;i++) {
- name[i] = attr->getNameByIndex(i);
- value[i] = attr -> getValueByIndex(i);
+ pName[i] = attr->getNameByIndex(i);
+ pValue[i] = attr -> getValueByIndex(i);
}
}
diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx
index 5aecfa32a7fd..5e8f1dee2f79 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -758,6 +758,7 @@ LocaleDataImpl::getAllCalendars2( const Locale& rLocale )
allCalendars = func(calendarsCount);
Sequence< Calendar2 > calendarsSeq(calendarsCount);
+ auto calendarsSeqRange = asNonConstRange(calendarsSeq);
sal_Int16 offset = REF_OFFSET_COUNT;
for(sal_Int16 i = 0; i < calendarsCount; i++) {
OUString calendarID(allCalendars[offset]);
@@ -780,7 +781,7 @@ LocaleDataImpl::getAllCalendars2( const Locale& rLocale )
offset++;
Calendar2 aCalendar(days, months, gmonths, pmonths, eras, startOfWeekDay,
minimalDaysInFirstWeek, defaultCalendar, calendarID);
- calendarsSeq[i] = aCalendar;
+ calendarsSeqRange[i] = aCalendar;
}
return calendarsSeq;
}
@@ -812,6 +813,7 @@ LocaleDataImpl::getAllCurrencies2( const Locale& rLocale )
sal_Unicode **allCurrencies = func(currencyCount);
Sequence< Currency2 > seq(currencyCount);
+ auto seqRange = asNonConstRange(seq);
for(int i = 0, nOff = 0; i < currencyCount; i++, nOff += 8 ) {
Currency2 cur(
OUString(allCurrencies[nOff]), // string ID
@@ -823,7 +825,7 @@ LocaleDataImpl::getAllCurrencies2( const Locale& rLocale )
allCurrencies[nOff+6][0], // short DecimalPlaces
allCurrencies[nOff+7][0] != 0 // boolean LegacyOnly
);
- seq[i] = cur;
+ seqRange[i] = cur;
}
return seq;
}
@@ -867,6 +869,7 @@ LocaleDataImpl::getAllFormats( const Locale& rLocale )
formatCount += section[1].getFunc( *this, rLocale, "getAllFormats1");
Sequence< FormatElement > seq(formatCount);
+ auto seqRange = asNonConstRange(seq);
sal_Int32 f = 0;
for (const FormatSection & s : section)
{
@@ -883,7 +886,7 @@ LocaleDataImpl::getAllFormats( const Locale& rLocale )
OUString(formatArray[nOff + 4]),
formatArray[nOff + 5][0],
formatArray[nOff + 6][0] != 0);
- seq[f] = elem;
+ seqRange[f] = elem;
}
}
}
@@ -901,9 +904,10 @@ LocaleDataImpl::getDateAcceptancePatterns( const Locale& rLocale )
sal_Int16 patternsCount = 0;
sal_Unicode **patternsArray = func( patternsCount );
Sequence< OUString > seq( patternsCount );
+ auto seqRange = asNonConstRange(seq);
for (sal_Int16 i = 0; i < patternsCount; ++i)
{
- seq[i] = OUString( patternsArray[i] );
+ seqRange[i] = OUString( patternsArray[i] );
}
return seq;
}
@@ -943,11 +947,12 @@ LocaleDataImpl::getCollatorImplementations( const Locale& rLocale )
sal_Int16 collatorCount = 0;
sal_Unicode **collatorArray = func(collatorCount);
Sequence< Implementation > seq(collatorCount);
+ auto seqRange = asNonConstRange(seq);
for(sal_Int16 i = 0; i < collatorCount; i++) {
Implementation impl(
OUString(collatorArray[i * COLLATOR_ELEMENTS + COLLATOR_OFFSET_ALGO]),
collatorArray[i * COLLATOR_ELEMENTS + COLLATOR_OFFSET_DEFAULT][0] != 0);
- seq[i] = impl;
+ seqRange[i] = impl;
}
return seq;
}
@@ -965,8 +970,9 @@ LocaleDataImpl::getCollationOptions( const Locale& rLocale )
sal_Int16 optionsCount = 0;
sal_Unicode **optionsArray = func(optionsCount);
Sequence< OUString > seq(optionsCount);
+ auto seqRange = asNonConstRange(seq);
for(sal_Int16 i = 0; i < optionsCount; i++) {
- seq[i] = OUString( optionsArray[i] );
+ seqRange[i] = OUString( optionsArray[i] );
}
return seq;
}
@@ -984,8 +990,9 @@ LocaleDataImpl::getSearchOptions( const Locale& rLocale )
sal_Int16 optionsCount = 0;
sal_Unicode **optionsArray = func(optionsCount);
Sequence< OUString > seq(optionsCount);
+ auto seqRange = asNonConstRange(seq);
for(sal_Int16 i = 0; i < optionsCount; i++) {
- seq[i] = OUString( optionsArray[i] );
+ seqRange[i] = OUString( optionsArray[i] );
}
return seq;
}
@@ -1012,8 +1019,9 @@ LocaleDataImpl::getIndexAlgorithm( const Locale& rLocale )
if ( indexArray ) {
Sequence< OUString > seq(indexCount);
+ auto seqRange = asNonConstRange(seq);
for(sal_Int16 i = 0; i < indexCount; i++) {
- seq[i] = indexArray[i*5];
+ seqRange[i] = indexArray[i*5];
}
return seq;
}
@@ -1096,8 +1104,9 @@ LocaleDataImpl::getUnicodeScripts( const Locale& rLocale )
sal_Int16 scriptCount = 0;
sal_Unicode **scriptArray = func(scriptCount);
Sequence< UnicodeScript > seq(scriptCount);
+ auto seqRange = asNonConstRange(seq);
for(sal_Int16 i = 0; i < scriptCount; i++) {
- seq[i] = UnicodeScript( OUString(scriptArray[i]).toInt32() );
+ seqRange[i] = UnicodeScript( OUString(scriptArray[i]).toInt32() );
}
return seq;
}
@@ -1115,8 +1124,9 @@ LocaleDataImpl::getFollowPageWords( const Locale& rLocale )
sal_Int16 wordCount = 0;
sal_Unicode **wordArray = func(wordCount);
Sequence< OUString > seq(wordCount);
+ auto seqRange = asNonConstRange(seq);
for(sal_Int16 i = 0; i < wordCount; i++) {
- seq[i] = OUString(wordArray[i]);
+ seqRange[i] = OUString(wordArray[i]);
}
return seq;
}
@@ -1135,9 +1145,10 @@ LocaleDataImpl::getTransliterations( const Locale& rLocale )
sal_Unicode **transliterationsArray = func(transliterationsCount);
Sequence< OUString > seq(transliterationsCount);
+ auto seqRange = asNonConstRange(seq);
for(int i = 0; i < transliterationsCount; i++) {
OUString elem(transliterationsArray[i]);
- seq[i] = elem;
+ seqRange[i] = elem;
}
return seq;
}
@@ -1213,9 +1224,10 @@ LocaleDataImpl::getBreakIteratorRules( const Locale& rLocale )
sal_Int16 LCBreakIteratorRuleCount = 0;
sal_Unicode **LCBreakIteratorRulesArray = func(LCBreakIteratorRuleCount);
Sequence< OUString > seq(LCBreakIteratorRuleCount);
+ auto seqRange = asNonConstRange(seq);
for(int i = 0; i < LCBreakIteratorRuleCount; i++) {
OUString elem(LCBreakIteratorRulesArray[i]);
- seq[i] = elem;
+ seqRange[i] = elem;
}
return seq;
}
@@ -1234,9 +1246,10 @@ LocaleDataImpl::getReservedWord( const Locale& rLocale )
sal_Int16 LCReservedWordsCount = 0;
sal_Unicode **LCReservedWordsArray = func(LCReservedWordsCount);
Sequence< OUString > seq(LCReservedWordsCount);
+ auto seqRange = asNonConstRange(seq);
for(int i = 0; i < LCReservedWordsCount; i++) {
OUString elem(LCReservedWordsArray[i]);
- seq[i] = elem;
+ seqRange[i] = elem;
}
return seq;
}
@@ -1261,16 +1274,18 @@ LocaleDataImpl::getContinuousNumberingLevels( const lang::Locale& rLocale )
// allocate memory for nAttributes attributes for each of the nStyles styles.
Sequence< Sequence<beans::PropertyValue> > pv( nStyles );
- for( auto& i : asNonConstRange(pv) ) {
+ auto pvRange = asNonConstRange(pv);
+ for( auto& i : pvRange ) {
i = Sequence<beans::PropertyValue>( nAttributes );
}
sal_Unicode const *** pStyle = p0;
for( int i=0; i<nStyles; i++ ) {
sal_Unicode const ** pAttribute = pStyle[i];
+ auto pvElementRange = asNonConstRange(pvRange[i]);
for( int j=0; j<nAttributes; j++ ) { // prefix, numberingtype, ...
sal_Unicode const * pString = pAttribute[j];
- beans::PropertyValue& rVal = pv[i][j];
+ beans::PropertyValue& rVal = pvElementRange[j];
OUString sVal;
if( pString ) {
if( 0 != j && 2 != j )
@@ -1367,7 +1382,7 @@ LocaleDataImpl::getOutlineNumberingLevels( const lang::Locale& rLocale )
sal_Unicode const **** p0 = func( nStyles, nLevels, nAttributes );
Sequence< Reference<container::XIndexAccess> > aRet( nStyles );
-
+ auto aRetRange = asNonConstRange(aRet);
sal_Unicode const **** pStyle = p0;
for( i=0; i<nStyles; i++ )
{
@@ -1411,7 +1426,7 @@ LocaleDataImpl::getOutlineNumberingLevels( const lang::Locale& rLocale )
level[j].nFirstLineOffset = 0;
level[j].sTransliteration.clear();
level[j].nNatNum = 0;
- aRet[i] = new OutlineNumbering( std::move(level), nLevels );
+ aRetRange[i] = new OutlineNumbering( std::move(level), nLevels );
}
return aRet;
}
@@ -1472,6 +1487,7 @@ Sequence< Locale > SAL_CALL
LocaleDataImpl::getAllInstalledLocaleNames()
{
Sequence< lang::Locale > seq( nbOfLocales );
+ auto seqRange = asNonConstRange(seq);
sal_Int16 nInstalled = 0;
for(const auto & i : aLibTable) {
@@ -1483,7 +1499,7 @@ LocaleDataImpl::getAllInstalledLocaleNames()
if (lcl_LookupTableStatic::get().getFunctionSymbolByName( name, "getLocaleItem", &pCachedItem )) {
if( pCachedItem )
cachedItem = std::move( pCachedItem );
- seq[nInstalled++] = LanguageTag::convertToLocale( name.replace( cUnder, cHyphen), false);
+ seqRange[nInstalled++] = LanguageTag::convertToLocale( name.replace( cUnder, cHyphen), false);
}
}
if ( nInstalled < nbOfLocales )
diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx
index 13d6698ae203..c3c1cc6139ff 100644
--- a/i18npool/source/nativenumber/nativenumbersupplier.cxx
+++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx
@@ -87,6 +87,7 @@ static OUString AsciiToNativeChar( const OUString& inStr, sal_Int32 nCount,
rtl_uString *newStr = rtl_uString_alloc(nCount);
if (pOffset)
pOffset->realloc(nCount);
+ auto ppOffset = pOffset ? pOffset->getArray() : nullptr;
for (sal_Int32 i = 0; i < nCount; i++)
{
@@ -102,8 +103,8 @@ static OUString AsciiToNativeChar( const OUString& inStr, sal_Int32 nCount,
}
else
newStr->buffer[i] = ch;
- if (pOffset)
- (*pOffset)[i] = i;
+ if (ppOffset)
+ ppOffset[i] = i;
}
return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
}
@@ -113,42 +114,43 @@ static bool AsciiToNative_numberMaker(const sal_Unicode *str, sal_Int32 begin, s
const Number *number, const sal_Unicode* numberChar)
{
sal_Unicode multiChar = (multiChar_index == -1 ? 0 : number->multiplierChar[multiChar_index]);
+ auto ppOffset = pOffset ? pOffset->getArray() : nullptr;
if ( len <= number->multiplierExponent[number->exponentCount-1] ) {
if (number->multiplierExponent[number->exponentCount-1] > 1) {
bool bNotZero = false;
for (const sal_Int32 end = begin+len; begin < end; begin++) {
if (bNotZero || str[begin] != NUMBER_ZERO) {
dst[count] = numberChar[str[begin] - NUMBER_ZERO];
- if (pOffset)
- (*pOffset)[count] = begin + startPos;
+ if (ppOffset)
+ ppOffset[count] = begin + startPos;
count++;
bNotZero = true;
}
}
if (bNotZero && multiChar > 0) {
dst[count] = multiChar;
- if (pOffset)
- (*pOffset)[count] = begin + startPos;
+ if (ppOffset)
+ ppOffset[count] = begin + startPos;
count++;
}
return bNotZero;
} else if (str[begin] != NUMBER_ZERO) {
if (!(number->numberFlag & (multiChar_index < 0 ? 0 : NUMBER_OMIT_ONE_CHECK(multiChar_index))) || str[begin] != NUMBER_ONE) {
dst[count] = numberChar[str[begin] - NUMBER_ZERO];
- if (pOffset)
- (*pOffset)[count] = begin + startPos;
+ if (ppOffset)
+ ppOffset[count] = begin + startPos;
count++;
}
if (multiChar > 0) {
dst[count] = multiChar;
- if (pOffset)
- (*pOffset)[count] = begin + startPos;
+ if (ppOffset)
+ ppOffset[count] = begin + startPos;
count++;
}
} else if (!(number->numberFlag & NUMBER_OMIT_ZERO) && count > 0 && dst[count-1] != numberChar[0]) {
dst[count] = numberChar[0];
- if (pOffset)
- (*pOffset)[count] = begin + startPos;
+ if (ppOffset)
+ ppOffset[count] = begin + startPos;
count++;
}
return str[begin] != NUMBER_ZERO;
@@ -170,8 +172,8 @@ static bool AsciiToNative_numberMaker(const sal_Unicode *str, sal_Int32 begin, s
count--;
if (multiChar > 0) {
dst[count] = multiChar;
- if (pOffset)
- (*pOffset)[count] = begin + startPos;
+ if (ppOffset)
+ ppOffset[count] = begin + startPos;
count++;
}
}
@@ -200,6 +202,7 @@ static OUString AsciiToNative( const OUString& inStr, sal_Int32 nCount,
if (pOffset)
pOffset->realloc( nCount * 2 );
+ auto ppOffset = pOffset ? pOffset->getArray() : nullptr;
bool bDoDecimal = false;
for (i = 0; i <= nCount; i++)
@@ -207,8 +210,8 @@ static OUString AsciiToNative( const OUString& inStr, sal_Int32 nCount,
if (i < nCount && isNumber(str[i])) {
if (bDoDecimal) {
newStr[count] = numberChar[str[i] - NUMBER_ZERO];
- if (pOffset)
- (*pOffset)[count] = i;
+ if (ppOffset)
+ ppOffset[count] = i;
count++;
}
else
@@ -229,15 +232,15 @@ static OUString AsciiToNative( const OUString& inStr, sal_Int32 nCount,
count--;
if (bNotZero && _count == count && end != len) {
newStr[count] = number->multiplierChar[0];
- if (pOffset)
- (*pOffset)[count] = i - len;
+ if (ppOffset)
+ ppOffset[count] = i - len;
count++;
}
}
if (! bNotZero && ! (number->numberFlag & NUMBER_OMIT_ONLY_ZERO)) {
newStr[count] = numberChar[0];
- if (pOffset)
- (*pOffset)[count] = i - len;
+ if (ppOffset)
+ ppOffset[count] = i - len;
count++;
}
len = 0;
@@ -252,8 +255,8 @@ static OUString AsciiToNative( const OUString& inStr, sal_Int32 nCount,
newStr[count] = (SeparatorChar[number->number] ? SeparatorChar[number->number] : str[i]);
else
newStr[count] = str[i];
- if (pOffset)
- (*pOffset)[count] = i;
+ if (ppOffset)
+ ppOffset[count] = i;
count++;
}
}
@@ -272,6 +275,7 @@ void NativeToAscii_numberMaker(sal_Int16 max, sal_Int16 prev, const sal_Unicode
sal_Int32& i, sal_Int32 nCount, sal_Unicode *dst, sal_Int32& count, Sequence< sal_Int32 >* pOffset,
OUString& numberChar, OUString& multiplierChar)
{
+ auto ppOffset = pOffset ? pOffset->getArray() : nullptr;
sal_Int16 curr = 0, num = 0, end = 0, shift = 0;
while (++i < nCount) {
if ((curr = sal::static_int_cast<sal_Int16>( numberChar.indexOf(str[i]) )) >= 0) {
@@ -290,16 +294,16 @@ void NativeToAscii_numberMaker(sal_Int16 max, sal_Int16 prev, const sal_Unicode
end = curr;
while (end++ < prev) {
dst[count] = NUMBER_ZERO + (end == prev ? num : 0);
- if (pOffset)
- (*pOffset)[count] = i;
+ if (ppOffset)
+ ppOffset[count] = i;
count++;
}
if (shift) {
count -= max;
for (const sal_Int32 countEnd = count+shift; count < countEnd; count++) {
dst[count] = dst[count + curr];
- if (pOffset)
- (*pOffset)[count] = (*pOffset)[count + curr];
+ if (ppOffset)
+ ppOffset[count] = ppOffset[count + curr];
}
max = curr;
}
@@ -311,8 +315,8 @@ void NativeToAscii_numberMaker(sal_Int16 max, sal_Int16 prev, const sal_Unicode
}
while (end++ < prev) {
dst[count] = NUMBER_ZERO + (end == prev ? num : 0);
- if (pOffset)
- (*pOffset)[count] = i - 1;
+ if (ppOffset)
+ ppOffset[count] = i - 1;
count++;
}
}
@@ -333,6 +337,7 @@ OUString NativeToAscii(const OUString& inStr,
std::unique_ptr<sal_Unicode[]> newStr(new sal_Unicode[nCount * MultiplierExponent_7_CJK[0] + 2]);
if (pOffset)
pOffset->realloc( nCount * MultiplierExponent_7_CJK[0] + 1 );
+ auto ppOffset = pOffset ? pOffset->getArray() : nullptr;
sal_Int32 count = 0, index;
sal_Int32 i;
@@ -348,8 +353,8 @@ OUString NativeToAscii(const OUString& inStr,
if ((index = multiplierChar.indexOf(str[i])) >= 0) {
if (count == 0 || !isNumber(newStr[count-1])) { // add 1 in front of multiplier
newStr[count] = NUMBER_ONE;
- if (pOffset)
- (*pOffset)[count] = i;
+ if (ppOffset)
+ ppOffset[count] = i;
count++;
}
index = MultiplierExponent_7_CJK[index % ExponentCount_7_CJK];
@@ -378,8 +383,8 @@ OUString NativeToAscii(const OUString& inStr,
newStr[count] = MinusChar[NumberChar_HalfWidth];
else
newStr[count] = str[i];
- if (pOffset)
- (*pOffset)[count] = i;
+ if (ppOffset)
+ ppOffset[count] = i;
count++;
}
}
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx
index dcb31762e6c2..c5e48a12b4c0 100644
--- a/i18npool/source/search/textsearch.cxx
+++ b/i18npool/source/search/textsearch.cxx
@@ -372,6 +372,8 @@ SearchResult TextSearch::searchForward( const OUString& searchStr, sal_Int32 sta
const sal_Int32 nOffsets = offset.getLength();
if (nOffsets)
{
+ auto sres_startOffsetRange = asNonConstRange(sres.startOffset);
+ auto sres_endOffsetRange = asNonConstRange(sres.endOffset);
// For regex nGroups is the number of groups+1 with group 0 being
// the entire match.
const sal_Int32 nGroups = sres.startOffset.getLength();
@@ -381,7 +383,7 @@ SearchResult TextSearch::searchForward( const OUString& searchStr, sal_Int32 sta
// Result offsets are negative (-1) if a group expression was
// not matched.
if (nStart >= 0)
- sres.startOffset[k] = (nStart < nOffsets ? offset[nStart] : (offset[nOffsets - 1] + 1));
+ sres_startOffsetRange[k] = (nStart < nOffsets ? offset[nStart] : (offset[nOffsets - 1] + 1));
// JP 20.6.2001: end is ever exclusive and then don't return
// the position of the next character - return the
// next position behind the last found character!
@@ -390,9 +392,9 @@ SearchResult TextSearch::searchForward( const OUString& searchStr, sal_Int32 sta
if (nStop >= 0)
{
if (nStop > 0)
- sres.endOffset[k] = offset[(nStop <= nOffsets ? nStop : nOffsets) - 1] + 1;
+ sres_endOffsetRange[k] = offset[(nStop <= nOffsets ? nStop : nOffsets) - 1] + 1;
else
- sres.endOffset[k] = offset[0];
+ sres_endOffsetRange[k] = offset[0];
}
}
}
@@ -424,13 +426,15 @@ SearchResult TextSearch::searchForward( const OUString& searchStr, sal_Int32 sta
bUsePrimarySrchStr = false;
sres2 = (this->*fnForward)( in_str, startPos, endPos );
+ auto sres2_startOffsetRange = asNonConstRange(sres2.startOffset);
+ auto sres2_endOffsetRange = asNonConstRange(sres2.endOffset);
for ( int k = 0; k < sres2.startOffset.getLength(); k++ )
{
if (sres2.startOffset[k])
- sres2.startOffset[k] = offset[sres2.startOffset[k]-1] + 1;
+ sres2_startOffsetRange[k] = offset[sres2.startOffset[k]-1] + 1;
if (sres2.endOffset[k])
- sres2.endOffset[k] = offset[sres2.endOffset[k]-1] + 1;
+ sres2_endOffsetRange[k] = offset[sres2.endOffset[k]-1] + 1;
}
// pick first and long one
@@ -490,6 +494,8 @@ SearchResult TextSearch::searchBackward( const OUString& searchStr, sal_Int32 st
const sal_Int32 nOffsets = offset.getLength();
if (nOffsets)
{
+ auto sres_startOffsetRange = asNonConstRange(sres.startOffset);
+ auto sres_endOffsetRange = asNonConstRange(sres.endOffset);
// For regex nGroups is the number of groups+1 with group 0 being
// the entire match.
const sal_Int32 nGroups = sres.startOffset.getLength();
@@ -501,9 +507,9 @@ SearchResult TextSearch::searchBackward( const OUString& searchStr, sal_Int32 st
if (nStart >= 0)
{
if (nStart > 0)
- sres.startOffset[k] = offset[(nStart <= nOffsets ? nStart : nOffsets) - 1] + 1;
+ sres_startOffsetRange[k] = offset[(nStart <= nOffsets ? nStart : nOffsets) - 1] + 1;
else
- sres.startOffset[k] = offset[0];
+ sres_startOffsetRange[k] = offset[0];
}
// JP 20.6.2001: end is ever exclusive and then don't return
// the position of the next character - return the
@@ -511,7 +517,7 @@ SearchResult TextSearch::searchBackward( const OUString& searchStr, sal_Int32 st
// "a b c" find "b" must return 2,3 and not 2,4!!!
const sal_Int32 nStop = sres.endOffset[k];
if (nStop >= 0)
- sres.endOffset[k] = (nStop < nOffsets ? offset[nStop] : (offset[nOffsets - 1] + 1));
+ sres_endOffsetRange[k] = (nStop < nOffsets ? offset[nStop] : (offset[nOffsets - 1] + 1));
}
}
}
@@ -542,13 +548,15 @@ SearchResult TextSearch::searchBackward( const OUString& searchStr, sal_Int32 st
bUsePrimarySrchStr = false;
sres2 = (this->*fnBackward)( in_str, startPos, endPos );
+ auto sres2_startOffsetRange = asNonConstRange(sres2.startOffset);
+ auto sres2_endOffsetRange = asNonConstRange(sres2.endOffset);
for( int k = 0; k < sres2.startOffset.getLength(); k++ )
{
if (sres2.startOffset[k])
- sres2.startOffset[k] = offset[sres2.startOffset[k]-1]+1;
+ sres2_startOffsetRange[k] = offset[sres2.startOffset[k]-1]+1;
if (sres2.endOffset[k])
- sres2.endOffset[k] = offset[sres2.endOffset[k]-1]+1;
+ sres2_endOffsetRange[k] = offset[sres2.endOffset[k]-1]+1;
}
// pick last and long one
@@ -760,10 +768,8 @@ SearchResult TextSearch::NSrchFrwrd( const OUString& searchStr, sal_Int32 startP
}
aRet.subRegExpressions = 1;
- aRet.startOffset.realloc( 1 );
- aRet.startOffset[ 0 ] = nCmpIdx;
- aRet.endOffset.realloc( 1 );
- aRet.endOffset[ 0 ] = nCmpIdx + sSearchKey.getLength();
+ aRet.startOffset = { nCmpIdx };
+ aRet.endOffset = { nCmpIdx + sSearchKey.getLength() };
return aRet;
}
@@ -829,20 +835,16 @@ SearchResult TextSearch::NSrchBkwrd( const OUString& searchStr, sal_Int32 startP
( bDelimBefore && bDelimBehind )) // 4
{
aRet.subRegExpressions = 1;
- aRet.startOffset.realloc( 1 );
- aRet.startOffset[ 0 ] = nCmpIdx;
- aRet.endOffset.realloc( 1 );
- aRet.endOffset[ 0 ] = nCmpIdx - sSearchKey.getLength();
+ aRet.startOffset = { nCmpIdx };
+ aRet.endOffset = { nCmpIdx - sSearchKey.getLength() };
return aRet;
}
}
else
{
aRet.subRegExpressions = 1;
- aRet.startOffset.realloc( 1 );
- aRet.startOffset[ 0 ] = nCmpIdx;
- aRet.endOffset.realloc( 1 );
- aRet.endOffset[ 0 ] = nCmpIdx - sSearchKey.getLength();
+ aRet.startOffset = { nCmpIdx };
+ aRet.endOffset = { nCmpIdx - sSearchKey.getLength() };
return aRet;
}
}
@@ -985,12 +987,14 @@ SearchResult TextSearch::RESrchFrwrd( const OUString& searchStr,
const int nGroupCount = pRegexMatcher->groupCount();
aRet.subRegExpressions = nGroupCount + 1;
aRet.startOffset.realloc( aRet.subRegExpressions);
+ auto pstartOffset = aRet.startOffset.getArray();
aRet.endOffset.realloc( aRet.subRegExpressions);
- aRet.startOffset[0] = pRegexMatcher->start( nIcuErr);
- aRet.endOffset[0] = pRegexMatcher->end( nIcuErr);
+ auto pendOffset = aRet.endOffset.getArray();
+ pstartOffset[0] = pRegexMatcher->start( nIcuErr);
+ pendOffset[0] = pRegexMatcher->end( nIcuErr);
for( int i = 1; i <= nGroupCount; ++i) {
- aRet.startOffset[i] = pRegexMatcher->start( i, nIcuErr);
- aRet.endOffset[i] = pRegexMatcher->end( i, nIcuErr);
+ pstartOffset[i] = pRegexMatcher->start( i, nIcuErr);
+ pendOffset[i] = pRegexMatcher->end( i, nIcuErr);
}
return aRet;
@@ -1055,13 +1059,15 @@ SearchResult TextSearch::RESrchBkwrd( const OUString& searchStr,
const int nGroupCount = pRegexMatcher->groupCount();
aRet.subRegExpressions = nGroupCount + 1;
aRet.startOffset.realloc( aRet.subRegExpressions);
+ auto pstartOffset = aRet.startOffset.getArray();
aRet.endOffset.realloc( aRet.subRegExpressions);
+ auto pendOffset = aRet.endOffset.getArray();
// NOTE: existing users of backward search seem to expect startOfs/endOfs being inverted!
- aRet.startOffset[0] = pRegexMatcher->end( nIcuErr);
- aRet.endOffset[0] = pRegexMatcher->start( nIcuErr);
+ pstartOffset[0] = pRegexMatcher->end( nIcuErr);
+ pendOffset[0] = pRegexMatcher->start( nIcuErr);
for( int i = 1; i <= nGroupCount; ++i) {
- aRet.startOffset[i] = pRegexMatcher->end( i, nIcuErr);
- aRet.endOffset[i] = pRegexMatcher->start( i, nIcuErr);
+ pstartOffset[i] = pRegexMatcher->end( i, nIcuErr);
+ pendOffset[i] = pRegexMatcher->start( i, nIcuErr);
}
return aRet;
@@ -1095,10 +1101,8 @@ SearchResult TextSearch::ApproxSrchFrwrd( const OUString& searchStr,
pWLD->WLD( searchStr.getStr() + nStt, nEnd - nStt ) <= nLimit )
{
aRet.subRegExpressions = 1;
- aRet.startOffset.realloc( 1 );
- aRet.startOffset[ 0 ] = nStt;
- aRet.endOffset.realloc( 1 );
- aRet.endOffset[ 0 ] = nEnd;
+ aRet.startOffset = { nStt };
+ aRet.endOffset = { nEnd };
break;
}
@@ -1139,10 +1143,8 @@ SearchResult TextSearch::ApproxSrchBkwrd( const OUString& searchStr,
pWLD->WLD( searchStr.getStr() + nStt, nEnd - nStt ) <= nLimit )
{
aRet.subRegExpressions = 1;
- aRet.startOffset.realloc( 1 );
- aRet.startOffset[ 0 ] = nEnd;
- aRet.endOffset.realloc( 1 );
- aRet.endOffset[ 0 ] = nStt;
+ aRet.startOffset = { nEnd };
+ aRet.endOffset = { nStt };
break;
}
if( !nStt )
@@ -1159,10 +1161,8 @@ namespace {
void setWildcardMatch( css::util::SearchResult& rRes, sal_Int32 nStartOffset, sal_Int32 nEndOffset )
{
rRes.subRegExpressions = 1;
- rRes.startOffset.realloc(1);
- rRes.endOffset.realloc(1);
- rRes.startOffset[0] = nStartOffset;
- rRes.endOffset[0] = nEndOffset;
+ rRes.startOffset = { nStartOffset };
+ rRes.endOffset = { nEndOffset };
}
}
diff --git a/i18npool/source/textconversion/textconversion_ko.cxx b/i18npool/source/textconversion/textconversion_ko.cxx
index e03286b772d7..fac1e7bc194b 100644
--- a/i18npool/source/textconversion/textconversion_ko.cxx
+++ b/i18npool/source/textconversion/textconversion_ko.cxx
@@ -150,8 +150,9 @@ TextConversion_ko::getCharConversions(const OUString& aText, sal_Int32 nStartPos
const sal_Unicode *ptr = getHangul2HanjaData() + Hangul_ko[current].address;
sal_Int16 count = Hangul_ko[current].count;
output.realloc(count);
+ auto poutput = output.getArray();
for (sal_Int16 i = 0; i < count; i++)
- output[i] = OUString(ptr + i, 1);
+ poutput[i] = OUString(ptr + i, 1);
break;
}
}
@@ -178,8 +179,7 @@ TextConversion_ko::getCharConversions(const OUString& aText, sal_Int32 nStartPos
}
if (count > 0)
{
- output.realloc(1);
- output[0] = OUString(newStr.get(), count);
+ output = { OUString(newStr.get(), count) };
}
}
return output;
diff --git a/i18npool/source/textconversion/textconversion_zh.cxx b/i18npool/source/textconversion/textconversion_zh.cxx
index 23689c0b568e..13059dba5d91 100644
--- a/i18npool/source/textconversion/textconversion_zh.cxx
+++ b/i18npool/source/textconversion/textconversion_zh.cxx
@@ -166,6 +166,7 @@ TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos,
std::unique_ptr<sal_Unicode[]> newStr(new sal_Unicode[nLength * 2 + 1]);
sal_Int32 currPos = 0, count = 0;
+ auto offsetRange = asNonConstRange(offset);
while (currPos < nLength) {
sal_Int32 len = nLength - currPos;
bool found = false;
@@ -198,7 +199,7 @@ TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos,
if (word.getLength() != conversions[0].getLength())
one2one=false;
while (current < conversions[0].getLength()) {
- offset[count] = nStartPos + currPos + (current *
+ offsetRange[count] = nStartPos + currPos + (current *
word.getLength() / conversions[0].getLength());
newStr[count++] = conversions[0][current++];
}
@@ -235,7 +236,7 @@ TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos,
one2one=false;
sal_Int32 convertedLength=OUString(&wordData[current]).getLength();
while (wordData[current]) {
- offset[count]=nStartPos + currPos + ((current-start) *
+ offsetRange[count]=nStartPos + currPos + ((current-start) *
word.getLength() / convertedLength);
newStr[count++] = wordData[current++];
}
@@ -252,7 +253,7 @@ TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos,
}
if (!found) {
if (offset.hasElements())
- offset[count]=nStartPos+currPos;
+ offsetRange[count]=nStartPos+currPos;
newStr[count++] =
getOneCharConversion(aText[nStartPos+currPos], charData, charIndex);
currPos++;
@@ -270,8 +271,8 @@ TextConversion_zh::getConversions( const OUString& aText, sal_Int32 nStartPos, s
{
TextConversionResult result;
- result.Candidates.realloc(1);
- result.Candidates[0] = getConversion( aText, nStartPos, nLength, rLocale, nConversionType, nConversionOptions);
+ result.Candidates =
+ { getConversion( aText, nStartPos, nLength, rLocale, nConversionType, nConversionOptions) };
result.Boundary.startPos = nStartPos;
result.Boundary.endPos = nStartPos + nLength;
diff --git a/i18npool/source/transliteration/textToPronounce_zh.cxx b/i18npool/source/transliteration/textToPronounce_zh.cxx
index 29e274c452e8..ad33bdf31dca 100644
--- a/i18npool/source/transliteration/textToPronounce_zh.cxx
+++ b/i18npool/source/transliteration/textToPronounce_zh.cxx
@@ -62,14 +62,15 @@ TextToPronounce_zh::foldingImpl(const OUString & inStr, sal_Int32 startPos,
if (startPos + nCount > inStr.getLength())
nCount = inStr.getLength() - startPos;
- if (pOffset)
- (*pOffset)[0] = 0;
+ auto ppOffset = pOffset ? pOffset->getArray() : nullptr;
+ if (ppOffset)
+ ppOffset[0] = 0;
for (sal_Int32 i = 0; i < nCount; i++) {
OUString pron(getPronounce(chArr[i]));
sb.append(pron);
- if (pOffset)
- (*pOffset)[i + 1] = (*pOffset)[i] + pron.getLength();
+ if (ppOffset)
+ ppOffset[i + 1] = (*pOffset)[i] + pron.getLength();
}
return sb.makeStringAndClear();
}
diff --git a/i18npool/source/transliteration/transliterationImpl.cxx b/i18npool/source/transliteration/transliterationImpl.cxx
index 55236ec3dfa9..54305126c640 100644
--- a/i18npool/source/transliteration/transliterationImpl.cxx
+++ b/i18npool/source/transliteration/transliterationImpl.cxx
@@ -329,7 +329,7 @@ TransliterationImpl::transliterate( const OUString& inStr, sal_Int32 startPos, s
assert(from.getLength() == nCount);
from.swap(to);
for (sal_Int32& ix : asNonConstRange(to))
- ix = std::as_const(from)[ix];
+ ix = from[ix];
}
offset = to;
return tmpStr;
@@ -369,20 +369,20 @@ TransliterationImpl::folding( const OUString& inStr, sal_Int32 startPos, sal_Int
auto [begin, end] = asNonConstRange(offset);
std::iota(begin, end, startPos);
- sal_Int16 from = 0, to = 1;
- Sequence<sal_Int32> off[2];
+ Sequence<sal_Int32> from;
+ Sequence<sal_Int32> to = offset;
- off[to] = offset;
for (sal_Int32 i = 0; i < numCascade; i++) {
- tmpStr = bodyCascade[i]->folding(tmpStr, 0, nCount, off[from]);
+ tmpStr = bodyCascade[i]->folding(tmpStr, 0, nCount, from);
nCount = tmpStr.getLength();
- std::swap(from, to);
- for (sal_Int32 j = 0; j < nCount; j++)
- off[to][j] = off[from][off[to][j]];
+ assert(from.getLength() == nCount);
+ from.swap(to);
+ for (sal_Int32& ix : asNonConstRange(to))
+ ix = from[ix];
}
- offset = off[to];
+ offset = to;
return tmpStr;
}
}
diff --git a/i18npool/source/transliteration/transliteration_Numeric.cxx b/i18npool/source/transliteration/transliteration_Numeric.cxx
index 22b3769068f5..57c5b7e9942b 100644
--- a/i18npool/source/transliteration/transliteration_Numeric.cxx
+++ b/i18npool/source/transliteration/transliteration_Numeric.cxx
@@ -71,6 +71,7 @@ transliteration_Numeric::transliterateBullet( const OUString& inStr, sal_Int32 s
if (pOffset)
pOffset->realloc(nCount);
+ auto ppOffset = pOffset ? pOffset->getArray() : nullptr;
for (sal_Int32 i = startPos; i < endPos; i++) {
if (isNumber(inStr[i]))
@@ -83,22 +84,22 @@ transliteration_Numeric::transliterateBullet( const OUString& inStr, sal_Int32 s
}
} else {
if (number == 0) {
- if (pOffset)
- (*pOffset)[j] = startPos;
+ if (ppOffset)
+ ppOffset[j] = startPos;
out[j++] = NUMBER_ZERO;
} else if (number > tableSize && !recycleSymbol) {
for (sal_Int32 k = startPos; k < i; k++) {
- if (pOffset)
- (*pOffset)[j] = k;
+ if (ppOffset)
+ ppOffset[j] = k;
out[j++] = inStr[k];
}
} else if (number > 0) {
- if (pOffset)
- (*pOffset)[j] = startPos;
+ if (ppOffset)
+ ppOffset[j] = startPos;
out[j++] = table[--number % tableSize];
} else if (i < endPos) {
- if (pOffset)
- (*pOffset)[j] = i;
+ if (ppOffset)
+ ppOffset[j] = i;
out[j++] = inStr[i];
}
number = -1;