summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2012-11-13 16:15:06 +0000
committerNoel Power <noel.power@suse.com>2012-11-13 16:24:17 +0000
commit4be8c3205afd55fa7e1f578384d3c91ebd8b5ec3 (patch)
treed2d868dd02fad59066f19ac77ebf6b2cc883a10e /xmloff
parentf3d2d9aaaf72291a5733b5ba0edd1c7b75e4f345 (diff)
save fixed denominator for fractions fdo#56419
Change-Id: I612ff2340b272661067cb6a54106e91443fec91e
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/xmloff/xmlnumfe.hxx2
-rw-r--r--xmloff/inc/xmloff/xmltoken.hxx1
-rw-r--r--xmloff/source/core/xmltoken.cxx1
-rw-r--r--xmloff/source/style/xmlnumfe.cxx21
-rw-r--r--xmloff/source/style/xmlnumfi.cxx20
5 files changed, 34 insertions, 11 deletions
diff --git a/xmloff/inc/xmloff/xmlnumfe.hxx b/xmloff/inc/xmloff/xmlnumfe.hxx
index d3bac9b86910..112c846fc4b5 100644
--- a/xmloff/inc/xmloff/xmlnumfe.hxx
+++ b/xmloff/inc/xmloff/xmlnumfe.hxx
@@ -67,7 +67,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 bb246d0ca4e4..6559b454728e 100644
--- a/xmloff/inc/xmloff/xmltoken.hxx
+++ b/xmloff/inc/xmloff/xmltoken.hxx
@@ -590,6 +590,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 ed094eac3a00..975349d18a43 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -594,6 +594,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 4d6373d1f30b..2bc69affc454 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -683,7 +683,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();
@@ -701,17 +701,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,
@@ -1422,7 +1428,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 db08434b6e7a..13cfef1e57c6 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -130,6 +130,7 @@ struct SvXMLNumberInfo
sal_Int32 nExpDigits;
sal_Int32 nNumerDigits;
sal_Int32 nDenomDigits;
+ sal_Int32 nFracDenominator;
sal_Bool bGrouping;
sal_Bool bDecReplace;
sal_Bool bVarDecimals;
@@ -138,7 +139,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;
}
@@ -293,6 +294,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,
@@ -586,6 +588,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 },
@@ -989,6 +992,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;
@@ -1216,8 +1223,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;