summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorLaurent Balland-Poirier <laurent.balland-poirier@laposte.net>2016-07-17 18:20:24 +0200
committerLaurent BP <laurent.balland-poirier@laposte.net>2016-08-16 19:20:57 +0000
commit6e44bb1b67f41dc7dbf15fe4502578a38ac59738 (patch)
tree089b78269a39bbe36d4bb38955ebdea65ba335f0 /svl
parente8ac831bd6d5f2524bab826bfbedf23f8952bbce (diff)
Fraction Number Format: add UI/Sidebar options
Enable modification of fraction number format through dialog UI: - negative in red - "Decimal places" is replaced with "Denominator places" - leading zeros for integer part - thousand separator for integer part Update: options in Sidebar Thousand separator works, also for ' ' as thousand separator Change-Id: I0ed2952ed9cd8afb5444b44997526e5019a5858d Reviewed-on: https://gerrit.libreoffice.org/27268 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Laurent BP <laurent.balland-poirier@laposte.net>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zforlist.cxx20
-rw-r--r--svl/source/numbers/zformat.cxx11
-rw-r--r--svl/source/numbers/zforscan.cxx5
3 files changed, 31 insertions, 5 deletions
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 5ca78ed0b370..0eaab97f467a 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -2858,7 +2858,7 @@ OUString SvNumberFormatter::GenerateFormat(sal_uInt32 nIndex,
}
}
}
- if (nPrecision > 0)
+ if (nPrecision > 0 && eType != css::util::NumberFormat::FRACTION )
{
sString.append(GetNumDecimalSep());
padToLength(sString, sString.getLength() + nPrecision, '0');
@@ -2931,6 +2931,24 @@ OUString SvNumberFormatter::GenerateFormat(sal_uInt32 nIndex,
}
sString.append(sNegStr.makeStringAndClear());
}
+ else if (eType == css::util::NumberFormat::FRACTION)
+ {
+ OUString aIntegerFractionDelimiterString = pFormat->GetIntegerFractionDelimiterString( 0 );
+ if ( aIntegerFractionDelimiterString == " " )
+ sString.append( aIntegerFractionDelimiterString );
+ else
+ {
+ sString.append( '"' );
+ sString.append( aIntegerFractionDelimiterString );
+ sString.append( '"' );
+ }
+ sString.append( pFormat->GetNumeratorString( 0 ) );
+ sString.append( '/' );
+ if ( nPrecision > 0 )
+ padToLength(sString, sString.getLength() + nPrecision, '?');
+ else
+ sString.append( '#' );
+ }
if (eType != css::util::NumberFormat::CURRENCY)
{
bool insertBrackets = false;
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index a31754778b21..2cd92827f420 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2004,7 +2004,8 @@ OUString lcl_GetFractionIntegerString(const ImpSvNumberformatInfo &rInfo, sal_uI
{
if( rInfo.nTypeArray[i] == NF_SYMBOLTYPE_FRACBLANK )
{
- for( i--; i >= 0 && rInfo.nTypeArray[i] == NF_SYMBOLTYPE_DIGIT ; i-- )
+ for( i--; i >= 0 && ( rInfo.nTypeArray[i] == NF_SYMBOLTYPE_DIGIT
+ || rInfo.nTypeArray[i] == NF_SYMBOLTYPE_THSEP ); i-- )
{
aIntegerString.insert( 0, rInfo.sStrArray[i] );
}
@@ -4350,7 +4351,13 @@ void SvNumberformat::GetNumForInfo( sal_uInt16 nNumFor, short& rScannedType,
const ImpSvNumberformatInfo& rInfo = NumFor[nNumFor].Info();
rScannedType = rInfo.eScannedType;
bThousand = rInfo.bThousand;
- nPrecision = rInfo.nCntPost;
+ nPrecision = (rInfo.eScannedType == css::util::NumberFormat::FRACTION)
+ ? rInfo.nCntExp // number of denominator digits for fraction
+ : rInfo.nCntPost;
+ sal_Int32 nPosHash = 1;
+ if ( rInfo.eScannedType == css::util::NumberFormat::FRACTION &&
+ ( (nPosHash += GetDenominatorString(nNumFor).indexOf('#')) > 0 ) )
+ nPrecision -= nPosHash;
if (bStandard && rInfo.eScannedType == css::util::NumberFormat::NUMBER)
{
// StandardFormat
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index 3642e91b0a56..82971a5fe0da 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -1047,8 +1047,9 @@ bool ImpSvNumberformatScan::IsLastBlankBeforeFrac(sal_uInt16 i)
{
bStop = true;
}
- else if ( nTypeArray[i] == NF_SYMBOLTYPE_DEL &&
- sStrArray[i][0] == ' ')
+ else if ( ( nTypeArray[i] == NF_SYMBOLTYPE_DEL &&
+ sStrArray[i][0] == ' ') ||
+ nTypeArray[i] == NF_SYMBOLTYPE_STRING ) // integer/fraction delimiter can also be a string
{
res = false;
}