[Libreoffice-commits] core.git: include/svl svl/source
Laurent BP (via logerrit)
logerrit at kemper.freedesktop.org
Mon May 25 20:43:58 UTC 2020
include/svl/zformat.hxx | 2 ++
svl/source/numbers/zforlist.cxx | 2 +-
svl/source/numbers/zformat.cxx | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 37 insertions(+), 1 deletion(-)
New commits:
commit 20f3a7e461381eb0db3e4ff526b69f3b1185c1c9
Author: Laurent BP <laurent.balland-poirier at laposte.net>
AuthorDate: Sun May 24 13:29:45 2020 +0200
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Mon May 25 22:43:13 2020 +0200
tdf#133342 Add user defined percent string
With Add/Delete decimal place, insert percent char
and string text between number and '%'
Change-Id: I4a97e4361228020803810692d7977e5806baf180
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94757
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack at redhat.com>
diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx
index 5b6f70243f96..abd805d187e5 100644
--- a/include/svl/zformat.hxx
+++ b/include/svl/zformat.hxx
@@ -297,6 +297,8 @@ public:
// nPos == 0xFFFF => last substring
short GetNumForType( sal_uInt16 nNumFor, sal_uInt16 nPos ) const;
+ OUString GetPercentString( sal_uInt16 nNumFor = 0 ) const;
+
OUString GetDenominatorString( sal_uInt16 nNumFor ) const;
OUString GetNumeratorString( sal_uInt16 nNumFor ) const;
OUString GetIntegerFractionDelimiterString( sal_uInt16 nNumFor ) const;
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 8186800ec613..f8652a0c1284 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -3094,7 +3094,7 @@ OUString SvNumberFormatter::GenerateFormat(sal_uInt32 nIndex,
}
if (eType == SvNumFormatType::PERCENT)
{
- sString.append('%');
+ sString.append( pFormat->GetPercentString() );
}
else if (eType == SvNumFormatType::SCIENTIFIC)
{
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 4532e33449b1..8e78cf6ee613 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2289,6 +2289,33 @@ void lcl_GetOutputStringScientific(double fNumber, sal_uInt16 nCharCount,
nPrec, rFormatter.GetNumDecimalSep()[0], true );
}
+OUString lcl_GetPercentString(const ImpSvNumberformatInfo &rInfo, sal_uInt16 nCnt)
+{
+ sal_Int32 i;
+ OUStringBuffer aPercentString;
+ for( i = 0; i < nCnt; i++ )
+ {
+ if( rInfo.nTypeArray[i] == NF_SYMBOLTYPE_PERCENT )
+ {
+ aPercentString.append( rInfo.sStrArray[i] );
+ bool bStringFound = false;
+ for( i--; i >= 0 && rInfo.nTypeArray[i] == NF_SYMBOLTYPE_STRING ; i-- )
+ {
+ if( !bStringFound )
+ {
+ bStringFound = true;
+ aPercentString.insert( 0, "\"" );
+ }
+ aPercentString.insert( 0, rInfo.sStrArray[i] );
+ }
+ i = nCnt;
+ if( bStringFound )
+ aPercentString.insert( 0, "\"" );
+ }
+ }
+ return aPercentString.makeStringAndClear();
+}
+
OUString lcl_GetDenominatorString(const ImpSvNumberformatInfo &rInfo, sal_uInt16 nCnt)
{
sal_Int32 i;
@@ -2363,6 +2390,13 @@ OUString lcl_GetIntegerFractionDelimiterString(const ImpSvNumberformatInfo &rInf
}
+OUString SvNumberformat::GetPercentString( sal_uInt16 nNumFor ) const
+{
+ const ImpSvNumberformatInfo& rInfo = NumFor[nNumFor].Info();
+ sal_uInt16 nCnt = NumFor[nNumFor].GetCount();
+ return lcl_GetPercentString( rInfo, nCnt );
+}
+
OUString SvNumberformat::GetDenominatorString( sal_uInt16 nNumFor ) const
{
const ImpSvNumberformatInfo& rInfo = NumFor[nNumFor].Info();
More information about the Libreoffice-commits
mailing list