[Libreoffice-commits] core.git: sw/inc sw/source
László Németh
nemeth at numbertext.org
Tue May 22 08:01:11 UTC 2018
sw/inc/docufld.hxx | 2 +-
sw/inc/fldbas.hxx | 2 +-
sw/source/core/fields/docufld.cxx | 14 +++++++-------
sw/source/core/fields/fldbas.cxx | 8 ++++++--
4 files changed, 15 insertions(+), 11 deletions(-)
New commits:
commit 3bac2853374303edb38815842ce494daa1614764
Author: László Németh <nemeth at numbertext.org>
Date: Fri May 18 16:54:15 2018 +0200
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 at libreoffice.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx
index db58e2dd2f49..28dc230ce8fb 100644
--- a/sw/inc/docufld.hxx
+++ b/sw/inc/docufld.hxx
@@ -131,7 +131,7 @@ public:
SwPageNumberFieldType();
OUString Expand( SvxNumType nFormat, short nOff, sal_uInt16 const nPageNumber,
- sal_uInt16 const nMaxPage, const OUString& ) const;
+ sal_uInt16 const nMaxPage, const OUString&, LanguageType = LANGUAGE_NONE ) const;
void ChangeExpansion( SwDoc* pDoc,
bool bVirtPageNum, const SvxNumType* pNumFormat );
virtual SwFieldType* Copy() const override;
diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index 247a221cdbc5..98aedb854b22 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -221,7 +221,7 @@ enum SwDateTimeSubType {
};
/// General tools.
-OUString FormatNumber(sal_uInt32 nNum, SvxNumType nFormat);
+OUString FormatNumber(sal_uInt32 nNum, SvxNumType nFormat, LanguageType nLang = LANGUAGE_NONE);
/** Instances of SwFields and those derived from it occur 0 to n times.
For each class there is one instance of the associated type class.
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)
More information about the Libreoffice-commits
mailing list