[Libreoffice-commits] .: sc/qa sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Sep 26 02:40:53 PDT 2012


 sc/qa/unit/data/xlsx/formats.xlsx            |binary
 sc/qa/unit/subsequent_filters-test.cxx       |    2 --
 sc/source/filter/inc/numberformatsbuffer.hxx |    3 ++-
 sc/source/filter/inc/stylesbuffer.hxx        |    1 +
 sc/source/filter/oox/numberformatsbuffer.cxx |    6 ++++++
 sc/source/filter/oox/stylesbuffer.cxx        |   19 ++++++++++++++++++-
 6 files changed, 27 insertions(+), 4 deletions(-)

New commits:
commit 4e0e0d4759cc0f1b2c5ea3c64d2421c1a0dbe87e
Author: Noel Power <noel.power at suse.com>
Date:   Wed Sep 26 10:10:53 2012 +0100

    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 )

diff --git a/sc/qa/unit/data/xlsx/formats.xlsx b/sc/qa/unit/data/xlsx/formats.xlsx
index 1c451be..e579fa5 100644
Binary files a/sc/qa/unit/data/xlsx/formats.xlsx and b/sc/qa/unit/data/xlsx/formats.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 3428582..fb286e8 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 e5b7eee..721ff8d 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 43b22a9..d757c39 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 2c3c421..72bc935 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 cb1ce6e..f9b9779 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() );


More information about the Libreoffice-commits mailing list