[Libreoffice-commits] core.git: Branch 'libreoffice-5-1-0' - xmloff/source
Laurent Balland-Poirier
laurent.balland-poirier at laposte.net
Mon Jan 25 13:02:27 PST 2016
xmloff/source/style/xmlnumfe.cxx | 16 ++++++++++++++--
xmloff/source/style/xmlnumfi.cxx | 19 +++++++++++++------
2 files changed, 27 insertions(+), 8 deletions(-)
New commits:
commit f3a1b5ef1d5d8995156092dcbd8ebc39608ff3bd
Author: Laurent Balland-Poirier <laurent.balland-poirier at laposte.net>
Date: Wed Dec 30 23:32:15 2015 +0100
tdf#40517 Export/Import in ODF decimal replacement with space
Number format such as "0.???" is saved in ODF with number:decimal-replacement=" "
Change-Id: I0dd19b5ea126f380bcf17a3ccc5d8c355119e23b
Reviewed-on: https://gerrit.libreoffice.org/21021
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: jan iversen <jani at documentfoundation.org>
(cherry picked from commit 3ee66e306cf0ca9c2b56de26c28e8130d7b72f64)
Reviewed-on: https://gerrit.libreoffice.org/21613
Tested-by: jan iversen <jani at documentfoundation.org>
(cherry picked from commit 50a3c6b2f3b849885580b304929eabe4a71b9162)
Reviewed-on: https://gerrit.libreoffice.org/21657
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Eike Rathke <erack at redhat.com>
Reviewed-by: Michael Stahl <mstahl at redhat.com>
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index 136c3d2..41c549d 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -1179,6 +1179,7 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
bool bCurrFound = false;
bool bInInteger = true;
bool bExpSign = true;
+ bool bDecAlign = false; // decimal alignment with "?"
sal_Int32 nExpDigits = 0;
sal_Int32 nIntegerSymbols = 0; // for embedded-text, including "#"
sal_Int32 nTrailingThousands = 0; // thousands-separators after all digits
@@ -1207,9 +1208,17 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
}
else if ( !bInInteger && pElemStr )
{
- for ( sal_Int32 i = pElemStr->getLength()-1; i >= 0 && (*pElemStr)[i] == '#'; i-- )
+ for ( sal_Int32 i = pElemStr->getLength()-1; i >= 0 ; i-- )
{
- nMinDecimals --;
+ sal_Unicode aChar = (*pElemStr)[i];
+ if ( aChar == '#' || aChar == '?' )
+ {
+ nMinDecimals --;
+ if ( aChar == '?' )
+ bDecAlign = true;
+ }
+ else
+ break;
}
}
if ( bInInteger && pElemStr )
@@ -1429,6 +1438,9 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
OUStringBuffer sDashStr;
if (bDecDashes && nPrecision > 0)
comphelper::string::padToLength(sDashStr, nPrecision, '-');
+ // "?" in decimal part are replaced by space character
+ if (bDecAlign && nPrecision > 0)
+ sDashStr = " ";
WriteNumberElement_Impl(nDecimals, nMinDecimals, nInteger, sDashStr.makeStringAndClear(),
bThousand, nTrailingThousands, aEmbeddedEntries);
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index db1edc7..bb8f97f 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -102,6 +102,7 @@ struct SvXMLNumberInfo
bool bGrouping;
bool bDecReplace;
bool bExpSign;
+ bool bDecAlign;
double fDisplayFactor;
std::map<sal_Int32, OUString> m_EmbeddedElements;
@@ -109,7 +110,7 @@ struct SvXMLNumberInfo
{
nDecimals = nInteger = nExpDigits = nExpInterval = nNumerDigits = nDenomDigits =
nFracDenominator = nMinDecimalDigits = -1;
- bGrouping = bDecReplace = false;
+ bGrouping = bDecReplace = bDecAlign = false;
bExpSign = true;
fDisplayFactor = 1.0;
}
@@ -948,10 +949,16 @@ SvXMLNumFmtElementContext::SvXMLNumFmtElementContext( SvXMLImport& rImport,
aNumInfo.fDisplayFactor = fAttrDouble;
break;
case XML_TOK_ELEM_ATTR_DECIMAL_REPLACEMENT:
- if ( !sValue.isEmpty() )
- aNumInfo.bDecReplace = true; // only a default string is supported
+ if ( sValue == " " )
+ {
+ aNumInfo.bDecAlign = true; // space replacement for "?"
+ bVarDecimals = true;
+ }
else
- bVarDecimals = true; // empty replacement string: variable decimals
+ if ( sValue.isEmpty() )
+ bVarDecimals = true; // empty replacement string: variable decimals
+ else // all other strings
+ aNumInfo.bDecReplace = true; // decimal replacement with dashes
break;
case XML_TOK_ELEM_ATTR_MIN_EXPONENT_DIGITS:
if (::sax::Converter::convertNumber( nAttrVal, sValue, 0 ))
@@ -1884,8 +1891,8 @@ void SvXMLNumFormatContext::AddNumber( const SvXMLNumberInfo& rInfo )
if ( ( rInfo.bDecReplace || rInfo.nMinDecimalDigits < rInfo.nDecimals ) && nPrec ) // add decimal replacement (dashes)
{
- // add dashes for explicit decimal replacement, # for variable decimals
- sal_Unicode cAdd = rInfo.bDecReplace ? '-' : '#';
+ // add dashes for explicit decimal replacement, # or ? for variable decimals
+ sal_Unicode cAdd = rInfo.bDecReplace ? '-' : ( rInfo.bDecAlign ? '?': '#' );
if ( rInfo.nMinDecimalDigits == 0 )
aFormatCode.append( pData->GetLocaleData( nFormatLang ).getNumDecimalSep() );
More information about the Libreoffice-commits
mailing list