summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2012-09-26 10:10:53 +0100
committerNoel Power <noel.power@suse.com>2012-09-26 10:40:31 +0100
commit4e0e0d4759cc0f1b2c5ea3c64d2421c1a0dbe87e (patch)
tree1a500fc5e7b8635b03a0f8673a3d5cc4e0502c89 /sc
parent211916f86585cb4f6258eb30e0474e4c21cd37f1 (diff)
don't let numforats in dxf entries clobber global number formats & update test
* Enabling the disabled test which checked a cell style attribute ( that was getting clobbered by the dxf entries above ) * squash the 'escape' characters in dxf num formats ( probably should do this in general * regenerate the formats.xlsx file ( I had to manually tweak this as the conditional tests were failing with the excel created document )
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/data/xlsx/formats.xlsxbin9169 -> 13816 bytes
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx2
-rw-r--r--sc/source/filter/inc/numberformatsbuffer.hxx3
-rw-r--r--sc/source/filter/inc/stylesbuffer.hxx1
-rw-r--r--sc/source/filter/oox/numberformatsbuffer.cxx6
-rw-r--r--sc/source/filter/oox/stylesbuffer.cxx19
6 files changed, 27 insertions, 4 deletions
diff --git a/sc/qa/unit/data/xlsx/formats.xlsx b/sc/qa/unit/data/xlsx/formats.xlsx
index 1c451be9a294..e579fa5065ed 100644
--- a/sc/qa/unit/data/xlsx/formats.xlsx
+++ b/sc/qa/unit/data/xlsx/formats.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 3428582f2765..fb286e818424 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -656,9 +656,7 @@ void testFormats_Impl(ScFiltersTest* pFiltersTest, ScDocument* pDoc, sal_Int32 n
// check actual align applied to cell, should be the same as
// the style
eHorJustify = static_cast<SvxCellHorJustify>(static_cast< const SvxHorJustifyItem& >(pPattern->GetItem( ATTR_HOR_JUSTIFY ) ).GetValue() );
-#if ENABLE_WHEN_FIXED
CPPUNIT_ASSERT_EQUAL_MESSAGE("cell with 'Excel Built-in Date' style should be aligned centre horizontally", SVX_HOR_JUSTIFY_CENTER, eHorJustify);
-#endif
}
}
diff --git a/sc/source/filter/inc/numberformatsbuffer.hxx b/sc/source/filter/inc/numberformatsbuffer.hxx
index e5b7eeebe1cc..721ff8dd5d7d 100644
--- a/sc/source/filter/inc/numberformatsbuffer.hxx
+++ b/sc/source/filter/inc/numberformatsbuffer.hxx
@@ -119,7 +119,7 @@ public:
/** Writes the specified number format to the passed property map. */
void writeToPropertyMap( PropertyMap& rPropMap, sal_Int32 nNumFmtId ) const;
-
+ sal_Int32 nextFreeId(){ return ++mnHighestId; }
private:
/** Inserts built-in number formats for the current system language. */
void insertBuiltinFormats();
@@ -129,6 +129,7 @@ private:
NumberFormatMap maNumFmts; /// List of number formats.
::rtl::OUString maLocaleStr; /// Current office locale.
+ sal_Int32 mnHighestId;
};
// ============================================================================
diff --git a/sc/source/filter/inc/stylesbuffer.hxx b/sc/source/filter/inc/stylesbuffer.hxx
index 43b22a967d9e..d757c39e02e5 100644
--- a/sc/source/filter/inc/stylesbuffer.hxx
+++ b/sc/source/filter/inc/stylesbuffer.hxx
@@ -909,6 +909,7 @@ public:
FontRef createFont( sal_Int32* opnFontId = 0 );
/** Creates a number format. */
NumberFormatRef createNumFmt( sal_Int32 nNumFmtId, const ::rtl::OUString& rFmtCode );
+ sal_Int32 nextFreeNumFmtId();
/** Creates a new empty border object.
@param opnBorderId (out-param) The identifier of the new border object. */
BorderRef createBorder( sal_Int32* opnBorderId = 0 );
diff --git a/sc/source/filter/oox/numberformatsbuffer.cxx b/sc/source/filter/oox/numberformatsbuffer.cxx
index 2c3c42156a8b..72bc935fb223 100644
--- a/sc/source/filter/oox/numberformatsbuffer.cxx
+++ b/sc/source/filter/oox/numberformatsbuffer.cxx
@@ -1981,6 +1981,8 @@ NumberFormatRef NumberFormatsBuffer::createNumFmt( sal_Int32 nNumFmtId, const OU
{
xNumFmt.reset( new NumberFormat( *this ) );
maNumFmts[ nNumFmtId ] = xNumFmt;
+ if ( nNumFmtId > mnHighestId )
+ mnHighestId = nNumFmtId;
xNumFmt->setFormatCode( rFmtCode );
}
return xNumFmt;
@@ -2081,7 +2083,11 @@ void NumberFormatsBuffer::insertBuiltinFormats()
// copy reused number formats
for( ReuseMap::const_iterator aRIt = aReuseMap.begin(), aREnd = aReuseMap.end(); aRIt != aREnd; ++aRIt )
+ {
maNumFmts[ aRIt->first ] = maNumFmts[ aRIt->second ];
+ if ( aRIt->first > mnHighestId )
+ mnHighestId = aRIt->first;
+ }
}
// ============================================================================
diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx
index cb1ce6eef76c..f9b9779d32ff 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -2445,7 +2445,19 @@ FillRef Dxf::createFill( bool bAlwaysNew )
void Dxf::importNumFmt( const AttributeList& rAttribs )
{
- mxNumFmt = getStyles().importNumFmt( rAttribs );
+ // don't propagate number formats defined in Dxf entries
+ // they can have the same id ( but different format codes ) as those
+ // defined globally earlier. We discard the id defined in XML_numFmtId
+ // and generate one ourselves ( this assumes that the normal numberformat
+ // import has already taken place )
+ sal_Int32 nNumFmtId = getStyles().nextFreeNumFmtId();
+ OUString aFmtCode = rAttribs.getXString( XML_formatCode, OUString() );
+ // we might need to do this generally for format codes,
+ // specifically for a fraction code '\ ?/?' is passed to us in xml, the '\' is not
+ // an escape character but merely should be telling the formatter to display the next
+ // char in the format ( afaics it does that anyhow )
+ aFmtCode = aFmtCode.replaceAll("\\", "");
+ mxNumFmt = getStyles().createNumFmt( nNumFmtId, aFmtCode );
}
void Dxf::importDxf( SequenceInputStream& rStrm )
@@ -2942,6 +2954,11 @@ NumberFormatRef StylesBuffer::createNumFmt( sal_Int32 nNumFmtId, const OUString&
return maNumFmts.createNumFmt( nNumFmtId, rFmtCode );
}
+sal_Int32 StylesBuffer::nextFreeNumFmtId()
+{
+ return maNumFmts.nextFreeId();
+}
+
BorderRef StylesBuffer::createBorder( sal_Int32* opnBorderId )
{
if( opnBorderId ) *opnBorderId = static_cast< sal_Int32 >( maBorders.size() );