summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Johansson <sleeping.pillow@gmail.com>2015-03-19 20:30:41 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-03-23 16:11:28 +0000
commitc3979944ced7075e9851a69a93fa41d6680bff80 (patch)
tree89ffb04050fcda6480db315c7ff194c40ec5a161
parentfix double delete on loading ooo123605-1.odt (diff)
downloadcore-c3979944ced7075e9851a69a93fa41d6680bff80.tar.gz
core-c3979944ced7075e9851a69a93fa41d6680bff80.zip
tdf#89437 Ordinal suffix should never be superscript in some languages
Printing ordinal suffixes as superscript is just not done in Swedish and likely a few other languages but this change only cares for Swedish at the moment. Change-Id: Ib7600ceb0534793d900f13b2740e63c1f7f34ba9 Reviewed-on: https://gerrit.libreoffice.org/14913 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 307c25fe460857c52f0b9c2078e83f6d12f8bdc9) Reviewed-on: https://gerrit.libreoffice.org/14967
-rw-r--r--editeng/source/misc/svxacorr.cxx108
1 files changed, 59 insertions, 49 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 4745c0bafdb4..608ae6151e88 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -436,69 +436,79 @@ bool SvxAutoCorrect::FnCptlSttWrd( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
bool SvxAutoCorrect::FnChgOrdinalNumber(
- SvxAutoCorrDoc& rDoc, const OUString& rTxt,
- sal_Int32 nSttPos, sal_Int32 nEndPos,
- LanguageType eLang )
+ SvxAutoCorrDoc& rDoc, const OUString& rTxt,
+ sal_Int32 nSttPos, sal_Int32 nEndPos,
+ LanguageType eLang)
{
-// 1st, 2nd, 3rd, 4 - 0th
-// 201th or 201st
-// 12th or 12nd
- CharClass& rCC = GetCharClass( eLang );
+ // 1st, 2nd, 3rd, 4 - 0th
+ // 201th or 201st
+ // 12th or 12nd
bool bChg = false;
- for( ; nSttPos < nEndPos; ++nSttPos )
- if( !lcl_IsInAsciiArr( sImplSttSkipChars, rTxt[ nSttPos ] ))
- break;
- for( ; nSttPos < nEndPos; --nEndPos )
- if( !lcl_IsInAsciiArr( sImplEndSkipChars, rTxt[ nEndPos - 1 ] ))
- break;
+ // In some languages ordinal suffixes should never be
+ // changed to superscript. Let's break for those languages.
+ switch (eLang)
+ {
+ case LANGUAGE_SWEDISH:
+ case LANGUAGE_SWEDISH_FINLAND:
+ break;
+ default:
+ CharClass& rCC = GetCharClass(eLang);
+ for (; nSttPos < nEndPos; ++nSttPos)
+ if (!lcl_IsInAsciiArr(sImplSttSkipChars, rTxt[nSttPos]))
+ break;
+ for (; nSttPos < nEndPos; --nEndPos)
+ if (!lcl_IsInAsciiArr(sImplEndSkipChars, rTxt[nEndPos - 1]))
+ break;
- // Get the last number in the string to check
- sal_Int32 nNumEnd = nEndPos;
- bool foundEnd = false;
- bool validNumber = true;
- sal_Int32 i = nEndPos;
- while ( i > nSttPos )
- {
- i--;
- bool isDigit = rCC.isDigit( rTxt, i );
- if ( foundEnd )
- validNumber |= isDigit;
+ // Get the last number in the string to check
+ sal_Int32 nNumEnd = nEndPos;
+ bool foundEnd = false;
+ bool validNumber = true;
+ sal_Int32 i = nEndPos;
- if ( isDigit && !foundEnd )
+ while (i > nSttPos)
{
- foundEnd = true;
- nNumEnd = i;
- }
- }
+ i--;
+ bool isDigit = rCC.isDigit(rTxt, i);
+ if (foundEnd)
+ validNumber |= isDigit;
- if ( foundEnd && validNumber ) {
- sal_Int32 nNum = rTxt.copy( nSttPos, nNumEnd - nSttPos + 1 ).toInt32( );
+ if (isDigit && !foundEnd)
+ {
+ foundEnd = true;
+ nNumEnd = i;
+ }
+ }
- // Check if the characters after that number correspond to the ordinal suffix
- uno::Reference< i18n::XOrdinalSuffix > xOrdSuffix
- = i18n::OrdinalSuffix::create( comphelper::getProcessComponentContext() );
+ if (foundEnd && validNumber) {
+ sal_Int32 nNum = rTxt.copy(nSttPos, nNumEnd - nSttPos + 1).toInt32();
- uno::Sequence< OUString > aSuffixes = xOrdSuffix->getOrdinalSuffix( nNum, rCC.getLanguageTag().getLocale( ) );
- for ( sal_Int32 nSuff = 0; nSuff < aSuffixes.getLength(); nSuff++ )
- {
- OUString sSuffix( aSuffixes[ nSuff ] );
- OUString sEnd = rTxt.copy( nNumEnd + 1, nEndPos - nNumEnd - 1 );
+ // Check if the characters after that number correspond to the ordinal suffix
+ uno::Reference< i18n::XOrdinalSuffix > xOrdSuffix
+ = i18n::OrdinalSuffix::create(comphelper::getProcessComponentContext());
- if ( sSuffix == sEnd )
+ uno::Sequence< OUString > aSuffixes = xOrdSuffix->getOrdinalSuffix(nNum, rCC.getLanguageTag().getLocale());
+ for (sal_Int32 nSuff = 0; nSuff < aSuffixes.getLength(); nSuff++)
{
- // Check if the ordinal suffix has to be set as super script
- if ( rCC.isLetter( sSuffix ) )
+ OUString sSuffix(aSuffixes[nSuff]);
+ OUString sEnd = rTxt.copy(nNumEnd + 1, nEndPos - nNumEnd - 1);
+
+ if (sSuffix == sEnd)
{
- // Do the change
- SvxEscapementItem aSvxEscapementItem( DFLT_ESC_AUTO_SUPER,
- DFLT_ESC_PROP, SID_ATTR_CHAR_ESCAPEMENT );
- rDoc.SetAttr( nNumEnd + 1 , nEndPos,
- SID_ATTR_CHAR_ESCAPEMENT,
- aSvxEscapementItem);
- bChg = true;
+ // Check if the ordinal suffix has to be set as super script
+ if (rCC.isLetter(sSuffix))
+ {
+ // Do the change
+ SvxEscapementItem aSvxEscapementItem(DFLT_ESC_AUTO_SUPER,
+ DFLT_ESC_PROP, SID_ATTR_CHAR_ESCAPEMENT);
+ rDoc.SetAttr(nNumEnd + 1, nEndPos,
+ SID_ATTR_CHAR_ESCAPEMENT,
+ aSvxEscapementItem);
+ bChg = true;
+ }
}
}
}