sc/source/filter/inc/stylesbuffer.hxx    |    3 ++
 sc/source/filter/oox/stylesbuffer.cxx    |   38 ++++++++++++++++++++++++++++---
 sc/source/filter/oox/worksheethelper.cxx |   11 ++++++--
 3 files changed, 46 insertions(+), 6 deletions(-)

New commits:
commit baebfeca06ad107937aa2c655d914720f71a5635
Author: Kohei Yoshida <kohei.yosh...@collabora.com>
Date:   Thu Sep 25 19:38:51 2014 -0400

    Set cell style name to the document directly, bypassing the UNO API.
    
    Change-Id: I28decfdfd8248fb9b95416b9b269a4ffabcc6370

diff --git a/sc/source/filter/inc/stylesbuffer.hxx 
b/sc/source/filter/inc/stylesbuffer.hxx
index b2e1186..c2f364e 100644
--- a/sc/source/filter/inc/stylesbuffer.hxx
+++ b/sc/source/filter/inc/stylesbuffer.hxx
@@ -669,6 +669,8 @@ public:
     /** Writes all formatting attributes to the passed property set. */
     void                writeToPropertySet( PropertySet& rPropSet ) const;
 
+    void writeToDoc( ScDocumentImport& rDoc, const 
css::table::CellRangeAddress& rRange ) const;
+
     const ::ScPatternAttr& createPattern( bool bSkipPoolDefs = false );
 
 private:
@@ -912,6 +914,7 @@ public:
 
     /** Writes the cell formatting attributes of the specified XF to the 
passed property set. */
     void                writeCellXfToPropertySet( PropertySet& rPropSet, 
sal_Int32 nXfId ) const;
+    void writeCellXfToDoc( ScDocumentImport& rDoc, const 
css::table::CellRangeAddress& rRange, sal_Int32 nXfId ) const;
 
     bool                hasBorder( sal_Int32 nBorderId ) const;
 private:
diff --git a/sc/source/filter/oox/stylesbuffer.cxx 
b/sc/source/filter/oox/stylesbuffer.cxx
index adead6d..2afedcc 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -77,6 +77,7 @@
 #include "attrib.hxx"
 #include "globstr.hrc"
 #include "xlconst.hxx"
+#include <documentimport.hxx>
 
 using ::com::sun::star::table::BorderLine2;
 namespace oox {
@@ -2191,9 +2192,10 @@ void Xf::writeToPropertyMap( PropertyMap& rPropMap ) 
const
 {
     StylesBuffer& rStyles = getStyles();
 
-    // create and set cell style
-    if( isCellXf() )
-        rPropMap.setProperty( PROP_CellStyle, rStyles.createCellStyle( 
maModel.mnStyleXfId ));
+    // create and set cell style.
+
+    // TODO : We should gradually move things to writeToDoc, to set cell
+    // styles to the document directly.
 
     if( maModel.mbFontUsed )
         rStyles.writeFontToPropertyMap( rPropMap, maModel.mnFontId );
@@ -2223,6 +2225,26 @@ void Xf::writeToPropertySet( PropertySet& rPropSet ) 
const
     rPropSet.setProperties( aPropMap );
 }
 
+void Xf::writeToDoc( ScDocumentImport& rDoc, const table::CellRangeAddress& 
rRange ) const
+{
+    if (isCellXf())
+    {
+        const StylesBuffer& rStyles = getStyles();
+        OUString aStyleName = rStyles.createCellStyle(maModel.mnStyleXfId);
+
+        ScStyleSheet* pStyleSheet =
+            static_cast<ScStyleSheet*>(
+                rDoc.getDoc().GetStyleSheetPool()->Find(aStyleName, 
SFX_STYLE_FAMILY_PARA));
+
+        if (pStyleSheet)
+        {
+            rDoc.getDoc().ApplyStyleAreaTab(
+                rRange.StartColumn, rRange.StartRow, rRange.EndColumn, 
rRange.EndRow, rRange.Sheet,
+                *pStyleSheet);
+        }
+    }
+}
+
 const ::ScPatternAttr&
 Xf::createPattern( bool bSkipPoolDefs )
 {
@@ -3148,6 +3170,16 @@ void StylesBuffer::writeCellXfToPropertySet( 
PropertySet& rPropSet, sal_Int32 nX
         pXf->writeToPropertySet( rPropSet );
 }
 
+void StylesBuffer::writeCellXfToDoc(
+    ScDocumentImport& rDoc, const table::CellRangeAddress& rRange, sal_Int32 
nXfId ) const
+{
+    Xf* pXf = maCellXfs.get(nXfId).get();
+    if (!pXf)
+        return;
+
+    pXf->writeToDoc(rDoc, rRange);
+}
+
 bool StylesBuffer::hasBorder( sal_Int32 nBorderId ) const
 {
     Border* pBorder = maBorders.get( nBorderId ).get();
diff --git a/sc/source/filter/oox/worksheethelper.cxx 
b/sc/source/filter/oox/worksheethelper.cxx
index 7ba4baf..9aa8abd 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -301,7 +301,7 @@ public:
         are cached and converted in the finalizeImport() call. */
     void                setColumnModel( const ColumnModel& rModel );
     /** Converts column default cell formatting. */
-    void                convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 
nLastCol, sal_Int32 nXfId ) const;
+    void convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 nLastCol, 
sal_Int32 nXfId );
 
     /** Sets default height and hidden state for all unused rows in the sheet. 
*/
     void                setDefaultRowSettings( double fHeight, bool 
bCustomHeight, bool bHidden, bool bThickTop, bool bThickBottom );
@@ -829,13 +829,18 @@ void WorksheetGlobals::setColumnModel( const ColumnModel& 
rModel )
     }
 }
 
-void WorksheetGlobals::convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 
nLastCol, sal_Int32 nXfId ) const
+void WorksheetGlobals::convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 
nLastCol, sal_Int32 nXfId )
 {
     CellRangeAddress aRange( getSheetIndex(), nFirstCol, 0, nLastCol, 
mrMaxApiPos.Row );
     if( getAddressConverter().validateCellRange( aRange, true, false ) )
     {
+        const StylesBuffer& rStyles = getStyles();
+
         PropertySet aPropSet( getCellRange( aRange ) );
-        getStyles().writeCellXfToPropertySet( aPropSet, nXfId );
+        rStyles.writeCellXfToPropertySet(aPropSet, nXfId);
+
+        ScDocumentImport& rDoc = getDocImport();
+        rStyles.writeCellXfToDoc(rDoc, aRange, nXfId);
     }
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to