summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNiklas Nebel <nn@openoffice.org>2002-06-11 17:11:40 +0000
committerNiklas Nebel <nn@openoffice.org>2002-06-11 17:11:40 +0000
commitbab8dacf9c66e9d0cb663b5b7296e21ad82b72aa (patch)
tree806cde978e38b0c023c32897e42fd0374a7ff36b /xmloff
parent845e1be9be44d1d0de4f02b333f0f88f3a541990 (diff)
#99413# support display-factor attribute in number element
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/dtd/datastyl.mod4
-rw-r--r--xmloff/source/core/xmltoken.cxx6
-rw-r--r--xmloff/source/style/xmlnumfe.cxx29
-rw-r--r--xmloff/source/style/xmlnumfi.cxx30
4 files changed, 59 insertions, 10 deletions
diff --git a/xmloff/dtd/datastyl.mod b/xmloff/dtd/datastyl.mod
index 80edbe78c197..26e39821ce95 100644
--- a/xmloff/dtd/datastyl.mod
+++ b/xmloff/dtd/datastyl.mod
@@ -1,6 +1,6 @@
<!--
- $Id: datastyl.mod,v 1.9 2001-11-23 18:57:36 nn Exp $
+ $Id: datastyl.mod,v 1.10 2002-06-11 18:06:26 nn Exp $
The Contents of this file are made available subject to the terms of
either of the following licenses
@@ -193,6 +193,8 @@
<!ATTLIST number:number number:decimal-replacement CDATA #IMPLIED>
+<!ATTLIST number:number number:display-factor %float; "1">
+
<!ATTLIST number:scientific-number number:min-exponent-digits %integer; #IMPLIED>
<!ATTLIST number:fraction number:min-numerator-digits %integer; #IMPLIED>
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 90040ebcc351..6beda8617e37 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmltoken.cxx,v $
*
- * $Revision: 1.36 $
+ * $Revision: 1.37 $
*
- * last change: $Author: dvo $ $Date: 2002-06-11 14:59:34 $
+ * last change: $Author: nn $ $Date: 2002-06-11 18:08:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -2115,6 +2115,8 @@ namespace xmloff { namespace token {
TOKEN( "table-type" ), // XML_TABLE_TYPE
+ TOKEN( "display-factor" ), // XML_DISPLAY_FACTOR
+
{ 0, NULL, NULL } // XML_TOKEN_END
};
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index 545853623064..f48eb04dc9ff 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlnumfe.cxx,v $
*
- * $Revision: 1.26 $
+ * $Revision: 1.27 $
*
- * last change: $Author: nn $ $Date: 2001-11-23 18:55:46 $
+ * last change: $Author: nn $ $Date: 2002-06-11 18:11:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -632,6 +632,7 @@ void SvXMLNumFmtExport::WriteAMPMElement_Impl()
void SvXMLNumFmtExport::WriteNumberElement_Impl(
sal_Int32 nDecimals, sal_Int32 nInteger,
const OUString& rDashStr, sal_Bool bGrouping,
+ sal_Int32 nTrailingThousands,
const SvXMLEmbeddedTextEntryArr& rEmbeddedEntries )
{
FinishTextElement_Impl();
@@ -663,6 +664,17 @@ void SvXMLNumFmtExport::WriteNumberElement_Impl(
rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_GROUPING, XML_TRUE );
}
+ // display-factor if there are trailing thousands separators
+ if ( nTrailingThousands )
+ {
+ // each separator character removes three digits
+ double fFactor = SolarMath::Pow10Exp( 1.0, 3 * nTrailingThousands );
+
+ OUStringBuffer aFactStr;
+ SvXMLUnitConverter::convertDouble( aFactStr, fFactor );
+ rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_DISPLAY_FACTOR, aFactStr.makeStringAndClear() );
+ }
+
SvXMLElementExport aElem( rExport, XML_NAMESPACE_NUMBER, XML_NUMBER,
sal_True, sal_True );
@@ -1190,7 +1202,7 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
if ( eBuiltIn == NF_NUMBER_STANDARD )
{
// default number format contains just one number element
- WriteNumberElement_Impl( -1, 1, OUString(), sal_False, aEmbeddedEntries );
+ WriteNumberElement_Impl( -1, 1, OUString(), sal_False, 0, aEmbeddedEntries );
bAnyContent = sal_True;
}
else if ( eBuiltIn == NF_BOOLEAN )
@@ -1209,6 +1221,7 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
sal_Bool bInInteger = sal_True;
sal_Int32 nExpDigits = 0;
sal_Int32 nIntegerSymbols = 0; // for embedded-text, including "#"
+ sal_Int32 nTrailingThousands = 0; // thousands-separators after all digits
OUString sCurrExt;
OUString aCalendar;
sal_uInt16 nPos = 0;
@@ -1230,10 +1243,15 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
bDecDashes = TRUE;
if ( bInInteger && pElemStr )
nIntegerSymbols += pElemStr->Len();
+ nTrailingThousands = 0;
break;
case XMLNUM_SYMBOLTYPE_DECSEP:
bInInteger = sal_False;
break;
+ case XMLNUM_SYMBOLTYPE_THSEP:
+ if (pElemStr)
+ nTrailingThousands += pElemStr->Len(); // is reset to 0 if digits follow
+ break;
case XMLNUM_SYMBOLTYPE_EXP:
bExpFound = sal_True; // following digits are exponent digits
bInInteger = sal_False;
@@ -1346,7 +1364,7 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
}
break;
case NF_KEY_GENERAL :
- WriteNumberElement_Impl( -1, 1, OUString(), sal_False, aEmbeddedEntries );
+ WriteNumberElement_Impl( -1, 1, OUString(), sal_False, 0, aEmbeddedEntries );
break;
case NF_KEY_CCC:
if (pElemStr)
@@ -1413,7 +1431,8 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
if ( bDecDashes && nPrecision > 0 )
sDashStr.Fill( nPrecision, '-' );
- WriteNumberElement_Impl( nDecimals, nInteger, sDashStr, bThousand, aEmbeddedEntries );
+ WriteNumberElement_Impl( nDecimals, nInteger, sDashStr, bThousand,
+ nTrailingThousands, aEmbeddedEntries );
bAnyContent = sal_True;
}
break;
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index 7c504607c41b..73891318cd28 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlnumfi.cxx,v $
*
- * $Revision: 1.24 $
+ * $Revision: 1.25 $
*
- * last change: $Author: nn $ $Date: 2002-05-22 10:46:12 $
+ * last change: $Author: nn $ $Date: 2002-06-11 18:11:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,6 +64,7 @@
#include <svtools/zforlist.hxx>
#include <svtools/zformat.hxx>
#include <svtools/numuno.hxx>
+#include <tools/solmath.hxx>
#include <tools/isolang.hxx>
#include <tools/debug.hxx>
#include <rtl/ustrbuf.hxx>
@@ -155,12 +156,14 @@ struct SvXMLNumberInfo
sal_Int32 nDenomDigits;
sal_Bool bGrouping;
sal_Bool bDecReplace;
+ double fDisplayFactor;
SvXMLEmbeddedElementArr aEmbeddedElements;
SvXMLNumberInfo()
{
nDecimals = nInteger = nExpDigits = nNumerDigits = nDenomDigits = -1;
bGrouping = bDecReplace = sal_False;
+ fDisplayFactor = 1.0;
}
};
@@ -317,6 +320,7 @@ enum SvXMLStyleElemAttrTokens
XML_TOK_ELEM_ATTR_DECIMAL_PLACES,
XML_TOK_ELEM_ATTR_MIN_INTEGER_DIGITS,
XML_TOK_ELEM_ATTR_GROUPING,
+ XML_TOK_ELEM_ATTR_DISPLAY_FACTOR,
XML_TOK_ELEM_ATTR_DECIMAL_REPLACEMENT,
XML_TOK_ELEM_ATTR_MIN_EXPONENT_DIGITS,
XML_TOK_ELEM_ATTR_MIN_NUMERATOR_DIGITS,
@@ -413,6 +417,7 @@ static __FAR_DATA SvXMLTokenMapEntry aStyleElemAttrMap[] =
{ XML_NAMESPACE_NUMBER, XML_DECIMAL_PLACES, XML_TOK_ELEM_ATTR_DECIMAL_PLACES },
{ XML_NAMESPACE_NUMBER, XML_MIN_INTEGER_DIGITS, XML_TOK_ELEM_ATTR_MIN_INTEGER_DIGITS },
{ 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_MIN_EXPONENT_DIGITS, XML_TOK_ELEM_ATTR_MIN_EXPONENT_DIGITS },
{ XML_NAMESPACE_NUMBER, XML_MIN_NUMERATOR_DIGITS, XML_TOK_ELEM_ATTR_MIN_NUMERATOR_DIGITS },
@@ -809,6 +814,7 @@ SvXMLNumFmtElementContext::SvXMLNumFmtElementContext( SvXMLImport& rImport,
sal_Int32 nAttrVal;
sal_Bool bAttrBool;
sal_uInt16 nAttrEnum;
+ double fAttrDouble;
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
for( sal_Int16 i=0; i < nAttrCount; i++ )
@@ -835,6 +841,10 @@ SvXMLNumFmtElementContext::SvXMLNumFmtElementContext( SvXMLImport& rImport,
if ( SvXMLUnitConverter::convertBool( bAttrBool, sValue ) )
aNumInfo.bGrouping = bAttrBool;
break;
+ case XML_TOK_ELEM_ATTR_DISPLAY_FACTOR:
+ if ( SvXMLUnitConverter::convertDouble( fAttrDouble, sValue ) )
+ aNumInfo.fDisplayFactor = fAttrDouble;
+ break;
case XML_TOK_ELEM_ATTR_DECIMAL_REPLACEMENT:
if ( sValue.getLength() > 0 )
aNumInfo.bDecReplace = sal_True; // only a default string is supported
@@ -1679,6 +1689,22 @@ void SvXMLNumFormatContext::AddNumber( const SvXMLNumberInfo& rInfo )
for ( sal_uInt16 i=0; i<nPrec; i++)
aFormatCode.append( (sal_Unicode)'-' );
}
+
+ // add extra thousands separators for display factor
+
+ if ( rInfo.fDisplayFactor != 1.0 && rInfo.fDisplayFactor > 0.0 )
+ {
+ // test for 1.0 is just for optimization - nSepCount would be 0
+
+ // one separator for each factor of 1000
+ sal_Int32 nSepCount = (sal_Int32) SolarMath::Round( log10(rInfo.fDisplayFactor) / 3.0 );
+ if ( nSepCount > 0 )
+ {
+ OUString aSep = pData->GetLocaleData( nFormatLang ).getNumThousandSep();
+ for ( sal_Int32 i=0; i<nSepCount; i++ )
+ aFormatCode.append( aSep );
+ }
+ }
}
void SvXMLNumFormatContext::AddCurrency( const rtl::OUString& rContent, LanguageType nLang )