summaryrefslogtreecommitdiff
path: root/sw/source/core/fields
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2018-05-18 16:54:15 +0200
committerLászló Németh <nemeth@numbertext.org>2018-05-22 10:00:41 +0200
commit3bac2853374303edb38815842ce494daa1614764 (patch)
tree5ff605ef551cf1083634ed4a9b23e27712c991ec /sw/source/core/fields
parentce005c88e2054ea06e1667195bf6585efc4961ae (diff)
tdf#117171 support localized page number numbering styles
in ordinal and cardinal number names and ordinal indicators. Change-Id: I35fa9c5c31b31f112ac0bb7feb5d310daca819e1 Reviewed-on: https://gerrit.libreoffice.org/54553 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source/core/fields')
-rw-r--r--sw/source/core/fields/docufld.cxx14
-rw-r--r--sw/source/core/fields/fldbas.cxx8
2 files changed, 13 insertions, 9 deletions
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx
index fa08469d50fe..5d362a8bb6d0 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -106,7 +106,7 @@ SwPageNumberFieldType::SwPageNumberFieldType()
OUString SwPageNumberFieldType::Expand( SvxNumType nFormat, short nOff,
sal_uInt16 const nPageNumber, sal_uInt16 const nMaxPage,
- const OUString& rUserStr ) const
+ const OUString& rUserStr, LanguageType nLang ) const
{
SvxNumType nTmpFormat = (SVX_NUM_PAGEDESC == nFormat) ? m_nNumberingType : nFormat;
int const nTmp = nPageNumber + nOff;
@@ -117,7 +117,7 @@ OUString SwPageNumberFieldType::Expand( SvxNumType nFormat, short nOff,
if( SVX_NUM_CHAR_SPECIAL == nTmpFormat )
return rUserStr;
- return FormatNumber( nTmp, nTmpFormat );
+ return FormatNumber( nTmp, nTmpFormat, nLang );
}
SwFieldType* SwPageNumberFieldType::Copy() const
@@ -189,22 +189,22 @@ OUString SwPageNumberField::Expand() const
if( PG_NEXT == m_nSubType && 1 != m_nOffset )
{
- sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), 1, m_nPageNumber, m_nMaxPage, m_sUserStr);
+ sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), 1, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage());
if (!sRet.isEmpty())
{
- sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr);
+ sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage());
}
}
else if( PG_PREV == m_nSubType && -1 != m_nOffset )
{
- sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), -1, m_nPageNumber, m_nMaxPage, m_sUserStr);
+ sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), -1, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage());
if (!sRet.isEmpty())
{
- sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr);
+ sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage());
}
}
else
- sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr);
+ sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage());
return sRet;
}
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index a68c1f7bc61e..3087bc382eb8 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -433,7 +433,7 @@ SwField * SwField::CopyField() const
}
/// expand numbering
-OUString FormatNumber(sal_uInt32 nNum, SvxNumType nFormat)
+OUString FormatNumber(sal_uInt32 nNum, SvxNumType nFormat, LanguageType nLang)
{
if(SVX_NUM_PAGEDESC == nFormat)
return OUString::number( nNum );
@@ -442,7 +442,11 @@ OUString FormatNumber(sal_uInt32 nNum, SvxNumType nFormat)
OSL_ENSURE(nFormat != SVX_NUM_NUMBER_NONE, "wrong number format" );
aNumber.SetNumberingType(nFormat);
- return aNumber.GetNumStr(nNum);
+
+ if (nLang == LANGUAGE_NONE)
+ return aNumber.GetNumStr(nNum);
+ else
+ return aNumber.GetNumStr(nNum, LanguageTag::convertToLocale(nLang));
}
SwValueFieldType::SwValueFieldType(SwDoc *const pDoc, SwFieldIds const nWhichId)