summaryrefslogtreecommitdiff
path: root/xmloff/source/style
diff options
context:
space:
mode:
authorNiklas Nebel <nn@openoffice.org>2002-10-23 16:12:18 +0000
committerNiklas Nebel <nn@openoffice.org>2002-10-23 16:12:18 +0000
commit3e01dc0ff14df3bc7dcb4bb8f622c21cfc089c30 (patch)
tree8b4225030c74329cf7a964d0b95bdd9f651ce789 /xmloff/source/style
parentdf441555609bd9427c1ea8cbe8f1677dce30a8ad (diff)
#102244# handling of formats with a text part
Diffstat (limited to 'xmloff/source/style')
-rw-r--r--xmloff/source/style/xmlnumfe.cxx54
-rw-r--r--xmloff/source/style/xmlnumfi.cxx22
2 files changed, 67 insertions, 9 deletions
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index 5097d682371a..7537769c5bed 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlnumfe.cxx,v $
*
- * $Revision: 1.30 $
+ * $Revision: 1.31 $
*
- * last change: $Author: nn $ $Date: 2002-10-01 13:34:58 $
+ * last change: $Author: nn $ $Date: 2002-10-23 17:12:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1638,13 +1638,44 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
// mapping (conditions) must be last elements
//
- SvNumberformatLimitOps eOp1, eOp2;
- double fLimit1, fLimit2;
- rFormat.GetConditions( eOp1, fLimit1, eOp2, fLimit2 );
if (bDefPart)
{
+ SvNumberformatLimitOps eOp1, eOp2;
+ double fLimit1, fLimit2;
+ rFormat.GetConditions( eOp1, fLimit1, eOp2, fLimit2 );
+
WriteMapElement_Impl( eOp1, fLimit1, nKey, 0 );
WriteMapElement_Impl( eOp2, fLimit2, nKey, 1 );
+
+ if ( rFormat.HasTextFormat() )
+ {
+ // 4th part is for text -> make an "all other numbers" condition for the 3rd part
+ // by reversing the 2nd condition
+
+ SvNumberformatLimitOps eOp3 = NUMBERFORMAT_OP_NO;
+ double fLimit3 = fLimit2;
+ switch ( eOp2 )
+ {
+ case NUMBERFORMAT_OP_EQ: eOp3 = NUMBERFORMAT_OP_NE; break;
+ case NUMBERFORMAT_OP_NE: eOp3 = NUMBERFORMAT_OP_EQ; break;
+ case NUMBERFORMAT_OP_LT: eOp3 = NUMBERFORMAT_OP_GE; break;
+ case NUMBERFORMAT_OP_LE: eOp3 = NUMBERFORMAT_OP_GT; break;
+ case NUMBERFORMAT_OP_GT: eOp3 = NUMBERFORMAT_OP_LE; break;
+ case NUMBERFORMAT_OP_GE: eOp3 = NUMBERFORMAT_OP_LT; break;
+ }
+
+ if ( fLimit1 == fLimit2 &&
+ ( ( eOp1 == NUMBERFORMAT_OP_LT && eOp2 == NUMBERFORMAT_OP_GT ) ||
+ ( eOp1 == NUMBERFORMAT_OP_GT && eOp2 == NUMBERFORMAT_OP_LT ) ) )
+ {
+ // For <x and >x, add =x as last condition
+ // (just for readability, <=x would be valid, too)
+
+ eOp3 = NUMBERFORMAT_OP_EQ;
+ }
+
+ WriteMapElement_Impl( eOp3, fLimit3, nKey, 2 );
+ }
}
}
@@ -1662,6 +1693,19 @@ void SvXMLNumFmtExport::ExportFormat_Impl( const SvNumberformat& rFormat, sal_uI
if (rFormat.GetNumForType( nPart, 0, sal_False ) != 0)
nUsedParts = nPart+1;
+ SvNumberformatLimitOps eOp1, eOp2;
+ double fLimit1, fLimit2;
+ rFormat.GetConditions( eOp1, fLimit1, eOp2, fLimit2 );
+
+ // if conditions are set, even empty formats must be written
+
+ if ( eOp1 != NUMBERFORMAT_OP_NO && nUsedParts < 2 )
+ nUsedParts = 2;
+ if ( eOp2 != NUMBERFORMAT_OP_NO && nUsedParts < 3 )
+ nUsedParts = 3;
+ if ( rFormat.HasTextFormat() && nUsedParts < 4 )
+ nUsedParts = 4;
+
for (nPart=0; nPart<nUsedParts; nPart++)
{
sal_Bool bDefault = ( nPart+1 == nUsedParts ); // last = default
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index 8cd586a08e31..25edc75da62d 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlnumfi.cxx,v $
*
- * $Revision: 1.28 $
+ * $Revision: 1.29 $
*
- * last change: $Author: er $ $Date: 2002-10-08 16:11:19 $
+ * last change: $Author: nn $ $Date: 2002-10-23 17:12:18 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1961,9 +1961,16 @@ void SvXMLNumFormatContext::AddCondition( const sal_Int32 nIndex )
//! collect all conditions first and adjust default to >=0, >0 or <0 depending on count
//! allow blanks in conditions
sal_Bool bFirstCond = ( aConditions.getLength() == 0 );
- if ( bFirstCond && sRealCond.compareToAscii( ">=0" ) == 0 )
+ if ( bFirstCond && aMyConditions.size() == 1 && sRealCond.compareToAscii( ">=0" ) == 0 )
bDefaultCond = sal_True;
+ if ( nType == XML_TOK_STYLES_TEXT_STYLE && nIndex == 2 )
+ {
+ // The third condition in a number format with a text part can only be
+ // "all other numbers", the condition string must be empty.
+ bDefaultCond = sal_True;
+ }
+
if (!bDefaultCond)
{
sal_Int32 nPos = sRealCond.indexOf( '.' );
@@ -2003,9 +2010,16 @@ void SvXMLNumFormatContext::AddCondition( const sal_Int32 nIndex, const rtl::OUS
//! collect all conditions first and adjust default to >=0, >0 or <0 depending on count
//! allow blanks in conditions
sal_Bool bFirstCond = ( aConditions.getLength() == 0 );
- if ( bFirstCond && sRealCond.compareToAscii( ">=0" ) == 0 )
+ if ( bFirstCond && aMyConditions.size() == 1 && sRealCond.compareToAscii( ">=0" ) == 0 )
bDefaultCond = sal_True;
+ if ( nType == XML_TOK_STYLES_TEXT_STYLE && nIndex == 2 )
+ {
+ // The third condition in a number format with a text part can only be
+ // "all other numbers", the condition string must be empty.
+ bDefaultCond = sal_True;
+ }
+
if (!bDefaultCond)
{
sal_Int32 nPos = sRealCond.indexOf( '.' );