[Libreoffice-commits] .: Branch 'libreoffice-3-6' - svl/inc svl/source xmloff/inc xmloff/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Nov 14 03:53:33 PST 2012
svl/inc/svl/zformat.hxx | 1 +
svl/source/numbers/zformat.cxx | 9 ++++++++-
xmloff/inc/xmloff/xmlnumfe.hxx | 2 +-
xmloff/inc/xmloff/xmltoken.hxx | 1 +
xmloff/source/core/xmltoken.cxx | 1 +
xmloff/source/style/xmlnumfe.cxx | 21 ++++++++++++++-------
xmloff/source/style/xmlnumfi.cxx | 20 +++++++++++++++++---
7 files changed, 43 insertions(+), 12 deletions(-)
New commits:
commit b25a6c815beb5c9bb7f3205b4841186fbd0b425c
Author: Noel Power <noel.power at suse.com>
Date: Tue Nov 13 16:15:06 2012 +0000
save fixed denominator for fractions fdo#56419
Change-Id: I612ff2340b272661067cb6a54106e91443fec91e
Reviewed-on: https://gerrit.libreoffice.org/1056
Reviewed-by: Tor Lillqvist <tml at iki.fi>
Tested-by: Tor Lillqvist <tml at iki.fi>
diff --git a/svl/inc/svl/zformat.hxx b/svl/inc/svl/zformat.hxx
index 03c2661..e28a2ba 100644
--- a/svl/inc/svl/zformat.hxx
+++ b/svl/inc/svl/zformat.hxx
@@ -298,6 +298,7 @@ public:
// bString==true: first/last SYMBOLTYPE_STRING or SYMBOLTYPE_CURRENCY
short GetNumForType( sal_uInt16 nNumFor, sal_uInt16 nPos, bool bString = false ) const;
+ sal_Int32 GetForcedDenominatorForType( sal_uInt16 nNumFor ) const;
/** If the count of string elements (substrings, ignoring [modifiers] and
so on) in a subformat code nNumFor (0..3) is equal to the given number.
Used by ImpSvNumberInputScan::IsNumberFormatMain() to detect a matched
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 5efeb3e..fa39283 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2139,7 +2139,7 @@ void lcl_GetOutputStringScientific(
fNumber, rtl_math_StringFormat_E, nPrec, rFormatter.GetNumDecimalSep().GetChar(0));
}
-sal_Int32 lcl_GetForcedDenominator(ImpSvNumberformatInfo &rInfo, sal_uInt16 nAnz)
+sal_Int32 lcl_GetForcedDenominator(const ImpSvNumberformatInfo &rInfo, sal_uInt16 nAnz)
{
sal_uInt16 i;
rtl::OUString aDiv;
@@ -2168,6 +2168,13 @@ void lcl_ForcedDenominator(sal_uLong &nFrac, sal_uLong &nDiv, sal_uLong nForcedD
}
+sal_Int32 SvNumberformat::GetForcedDenominatorForType( sal_uInt16 nNumFor ) const
+{
+ const ImpSvNumberformatInfo& rInfo = NumFor[nNumFor].Info();
+ sal_uInt16 nAnz = NumFor[nNumFor].GetCount();
+ return lcl_GetForcedDenominator( rInfo, nAnz );
+}
+
bool SvNumberformat::GetOutputString(double fNumber, sal_uInt16 nCharCount, String& rOutString) const
{
using namespace std;
diff --git a/xmloff/inc/xmloff/xmlnumfe.hxx b/xmloff/inc/xmloff/xmlnumfe.hxx
index b1f00e7..6521a44 100644
--- a/xmloff/inc/xmloff/xmlnumfe.hxx
+++ b/xmloff/inc/xmloff/xmlnumfe.hxx
@@ -76,7 +76,7 @@ private:
SAL_DLLPRIVATE void WriteScientificElement_Impl( sal_Int32 nDecimals, sal_Int32 nInteger,
sal_Bool bGrouping, sal_Int32 nExp );
SAL_DLLPRIVATE void WriteFractionElement_Impl( sal_Int32 nInteger, sal_Bool bGrouping,
- sal_Int32 nNumerator, sal_Int32 nDenominator );
+ sal_Int32 nNumeratorDigits, sal_Int32 nDenominatorDigits, sal_Int32 nDenominator );
SAL_DLLPRIVATE void WriteCurrencyElement_Impl( const ::rtl::OUString& rString,
const ::rtl::OUString& rExt );
SAL_DLLPRIVATE void WriteBooleanElement_Impl();
diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx
index e45091e..16fe5e8 100644
--- a/xmloff/inc/xmloff/xmltoken.hxx
+++ b/xmloff/inc/xmloff/xmltoken.hxx
@@ -597,6 +597,7 @@ namespace xmloff { namespace token {
XML_DELAY,
XML_DELETION,
XML_DELETIONS,
+ XML_DENOMINATOR_VALUE,
XML_DEPENDENCE,
XML_DEPENDENCES,
XML_DEPENDENCIES,
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 875d0d9..a1147aa 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -601,6 +601,7 @@ namespace xmloff { namespace token {
TOKEN( "delay", XML_DELAY ),
TOKEN( "deletion", XML_DELETION ),
TOKEN( "deletions", XML_DELETIONS ),
+ TOKEN( "denominator-value", XML_DENOMINATOR_VALUE ),
TOKEN( "dependence", XML_DEPENDENCE ),
TOKEN( "dependences", XML_DEPENDENCES ),
TOKEN( "dependencies", XML_DEPENDENCIES ),
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index c4f9360..27c0b94 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -675,7 +675,7 @@ void SvXMLNumFmtExport::WriteScientificElement_Impl(
void SvXMLNumFmtExport::WriteFractionElement_Impl(
sal_Int32 nInteger, sal_Bool bGrouping,
- sal_Int32 nNumerator, sal_Int32 nDenominator )
+ sal_Int32 nNumeratorDigits, sal_Int32 nDenominatorDigits, sal_Int32 nDenominator )
{
FinishTextElement_Impl();
@@ -693,17 +693,23 @@ void SvXMLNumFmtExport::WriteFractionElement_Impl(
}
// numerator digits
- if ( nNumerator >= 0 )
+ if ( nNumeratorDigits >= 0 )
{
rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_MIN_NUMERATOR_DIGITS,
- OUString::valueOf( nNumerator ) );
+ OUString::valueOf( nNumeratorDigits ) );
}
- // denominator digits
- if ( nDenominator >= 0 )
+ if ( nDenominator )
+ {
+ rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_DENOMINATOR_VALUE,
+ OUString::valueOf( nDenominator) );
+ }
+ // I guess it's not necessary to export nDenominatorDigits
+ // if we have a forced denominator ( remove ? )
+ if ( nDenominatorDigits >= 0 )
{
rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_MIN_DENOMINATOR_DIGITS,
- OUString::valueOf( nDenominator ) );
+ OUString::valueOf( nDenominatorDigits ) );
}
SvXMLElementExport aElem( rExport, XML_NAMESPACE_NUMBER, XML_FRACTION,
@@ -1414,7 +1420,8 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
// min-integer-digits attribute must be written.
nInteger = -1;
}
- WriteFractionElement_Impl( nInteger, bThousand, nPrecision, nPrecision );
+ sal_Int32 nDenominator = rFormat.GetForcedDenominatorForType( nPart );
+ WriteFractionElement_Impl( nInteger, bThousand, nPrecision, nPrecision, nDenominator );
bAnyContent = sal_True;
}
break;
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index 15d55fe..fcd92bd 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -129,6 +129,7 @@ struct SvXMLNumberInfo
sal_Int32 nExpDigits;
sal_Int32 nNumerDigits;
sal_Int32 nDenomDigits;
+ sal_Int32 nFracDenominator;
sal_Bool bGrouping;
sal_Bool bDecReplace;
sal_Bool bVarDecimals;
@@ -137,7 +138,7 @@ struct SvXMLNumberInfo
SvXMLNumberInfo()
{
- nDecimals = nInteger = nExpDigits = nNumerDigits = nDenomDigits = -1;
+ nDecimals = nInteger = nExpDigits = nNumerDigits = nDenomDigits = nFracDenominator = -1;
bGrouping = bDecReplace = bVarDecimals = sal_False;
fDisplayFactor = 1.0;
}
@@ -291,6 +292,7 @@ enum SvXMLStyleElemAttrTokens
XML_TOK_ELEM_ATTR_GROUPING,
XML_TOK_ELEM_ATTR_DISPLAY_FACTOR,
XML_TOK_ELEM_ATTR_DECIMAL_REPLACEMENT,
+ XML_TOK_ELEM_ATTR_DENOMINATOR_VALUE,
XML_TOK_ELEM_ATTR_MIN_EXPONENT_DIGITS,
XML_TOK_ELEM_ATTR_MIN_NUMERATOR_DIGITS,
XML_TOK_ELEM_ATTR_MIN_DENOMINATOR_DIGITS,
@@ -583,6 +585,7 @@ const SvXMLTokenMap& SvXMLNumImpData::GetStyleElemAttrTokenMap()
{ XML_NAMESPACE_NUMBER, XML_GROUPING, XML_TOK_ELEM_ATTR_GROUPING },
{ XML_NAMESPACE_NUMBER, XML_DISPLAY_FACTOR, XML_TOK_ELEM_ATTR_DISPLAY_FACTOR },
{ XML_NAMESPACE_NUMBER, XML_DECIMAL_REPLACEMENT, XML_TOK_ELEM_ATTR_DECIMAL_REPLACEMENT },
+ { XML_NAMESPACE_NUMBER, XML_DENOMINATOR_VALUE, XML_TOK_ELEM_ATTR_DENOMINATOR_VALUE },
{ XML_NAMESPACE_NUMBER, XML_MIN_EXPONENT_DIGITS, XML_TOK_ELEM_ATTR_MIN_EXPONENT_DIGITS },
{ XML_NAMESPACE_NUMBER, XML_MIN_NUMERATOR_DIGITS, XML_TOK_ELEM_ATTR_MIN_NUMERATOR_DIGITS },
{ XML_NAMESPACE_NUMBER, XML_MIN_DENOMINATOR_DIGITS, XML_TOK_ELEM_ATTR_MIN_DENOMINATOR_DIGITS },
@@ -986,6 +989,10 @@ SvXMLNumFmtElementContext::SvXMLNumFmtElementContext( SvXMLImport& rImport,
if (::sax::Converter::convertNumber( nAttrVal, sValue, 0 ))
aNumInfo.nDenomDigits = nAttrVal;
break;
+ case XML_TOK_ELEM_ATTR_DENOMINATOR_VALUE:
+ if (::sax::Converter::convertNumber( nAttrVal, sValue, 0 ))
+ aNumInfo.nFracDenominator = nAttrVal;
+ break;
case XML_TOK_ELEM_ATTR_LANGUAGE:
sLanguage = sValue;
break;
@@ -1207,8 +1214,15 @@ void SvXMLNumFmtElementContext::EndElement()
for (i=0; i<aNumInfo.nNumerDigits; i++)
rParent.AddToCode( OUString::valueOf((sal_Unicode)'?') );
rParent.AddToCode( OUString::valueOf((sal_Unicode)'/') );
- for (i=0; i<aNumInfo.nDenomDigits; i++)
- rParent.AddToCode( OUString::valueOf((sal_Unicode)'?') );
+ if ( aNumInfo.nFracDenominator > 0 )
+ {
+ rParent.AddToCode( OUString::valueOf( aNumInfo.nFracDenominator ) );
+ }
+ else
+ {
+ for (i=0; i<aNumInfo.nDenomDigits; i++)
+ rParent.AddToCode( OUString::valueOf((sal_Unicode)'?') );
+ }
}
break;
More information about the Libreoffice-commits
mailing list