[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Tue Feb 11 04:28:21 PST 2014


 sc/source/filter/inc/numberformatsbuffer.hxx |    2 -
 sc/source/filter/inc/stylesbuffer.hxx        |    4 +-
 sc/source/filter/oox/stylesbuffer.cxx        |   47 +++++++++++++++++++--------
 3 files changed, 38 insertions(+), 15 deletions(-)

New commits:
commit cd519128e9719875ccdc185afc47a28a5f107e0f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Feb 10 16:03:54 2014 -0500

    cp#100030: Use internal API to fill dxf styles during xlsx import.
    
    It's faster, and it actually prevents a bug where styles fail to get
    set when the document contains at least one protected sheet.
    
    Change-Id: I9a5d7250ca44dd46364ab62f2e0130e967427c66
    (cherry picked from commit d12c0e5d36cc106cb4f9a27dba2f29c10b5d6f93)
    Reviewed-on: https://gerrit.libreoffice.org/7982
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/filter/inc/numberformatsbuffer.hxx b/sc/source/filter/inc/numberformatsbuffer.hxx
index 32c3611..52a68f0 100644
--- a/sc/source/filter/inc/numberformatsbuffer.hxx
+++ b/sc/source/filter/inc/numberformatsbuffer.hxx
@@ -77,7 +77,7 @@ public:
     sal_Int32           finalizeImport(
                             const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& rxNumFmts,
                             const ::com::sun::star::lang::Locale& rFromLocale );
-    void                fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const;
+    void fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs = false ) const;
     /** Writes the number format to the passed property map. */
     void                writeToPropertyMap( PropertyMap& rPropMap ) const;
 
diff --git a/sc/source/filter/inc/stylesbuffer.hxx b/sc/source/filter/inc/stylesbuffer.hxx
index 6802e9b..e3c4036 100644
--- a/sc/source/filter/inc/stylesbuffer.hxx
+++ b/sc/source/filter/inc/stylesbuffer.hxx
@@ -520,7 +520,7 @@ public:
     /** Returns the converted API border data struct. */
     inline const ApiBorderData& getApiData() const { return maApiData; }
 
-    void                fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const;
+    void fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs = false ) const;
 
     /** Writes all border attributes to the passed property map. */
     void                writeToPropertyMap( PropertyMap& rPropMap ) const;
@@ -771,6 +771,8 @@ public:
     /** Writes all formatting attributes to the passed property set. */
     void                writeToPropertySet( PropertySet& rPropSet ) const;
 
+    void fillToItemSet( SfxItemSet& rSet ) const;
+
 private:
     FontRef             mxFont;             /// Font data.
     NumberFormatRef     mxNumFmt;           /// Number format data.
diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx
index 49b1194..d14b353 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -2498,6 +2498,22 @@ void Dxf::writeToPropertySet( PropertySet& rPropSet ) const
     rPropSet.setProperties( aPropMap );
 }
 
+void Dxf::fillToItemSet( SfxItemSet& rSet ) const
+{
+    if (mxFont)
+        mxFont->fillToItemSet(rSet, FONT_PROPTYPE_CELL);
+    if (mxNumFmt)
+        mxNumFmt->fillToItemSet(rSet);
+    if (mxAlignment)
+        mxAlignment->fillToItemSet(rSet);
+    if (mxProtection)
+        mxProtection->fillToItemSet(rSet);
+    if (mxBorder)
+        mxBorder->fillToItemSet(rSet);
+    if (mxFill)
+        mxFill->fillToItemSet(rSet);
+}
+
 // ============================================================================
 
 namespace {
@@ -3111,21 +3127,26 @@ OUString StylesBuffer::createCellStyle( sal_Int32 nXfId ) const
 OUString StylesBuffer::createDxfStyle( sal_Int32 nDxfId ) const
 {
     OUString& rStyleName = maDxfStyles[ nDxfId ];
-    if( rStyleName.isEmpty() )
+    if (!rStyleName.isEmpty())
+        return rStyleName;
+
+    if (Dxf* pDxf = maDxfs.get(nDxfId).get())
     {
-        if( Dxf* pDxf = maDxfs.get( nDxfId ).get() )
-        {
-            rStyleName = OUStringBuffer( "ConditionalStyle_" ).append( nDxfId + 1 ).makeStringAndClear();
-            // create the style sheet (this may change rStyleName if such a style already exists)
-            Reference< XStyle > xStyle = createStyleObject( rStyleName, false );
-            // write style formatting properties
-            PropertySet aPropSet( xStyle );
-            pDxf->writeToPropertySet( aPropSet );
-        }
-        // on error: fallback to default style
-        if( rStyleName.isEmpty() )
-            rStyleName = maCellStyles.getDefaultStyleName();
+        rStyleName = OUStringBuffer("ConditionalStyle_").append(nDxfId + 1).makeStringAndClear();
+
+        // Create a cell style. This may overwrite an existing style if
+        // one with the same name exists.
+        SfxItemSet& rStyleItemSet =
+            ScfTools::MakeCellStyleSheet(
+                *getScDocument().GetStyleSheetPool(), rStyleName, true).GetItemSet();
+
+        pDxf->fillToItemSet(rStyleItemSet);
     }
+
+    // on error: fallback to default style
+    if (rStyleName.isEmpty())
+        rStyleName = maCellStyles.getDefaultStyleName();
+
     return rStyleName;
 }
 


More information about the Libreoffice-commits mailing list