summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-02-10 16:03:54 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-02-10 16:17:47 -0500
commitd12c0e5d36cc106cb4f9a27dba2f29c10b5d6f93 (patch)
tree27a66fa0218f76093a0561eda53d0742d1262c8a
parentc3c1a8f373e73d8bfa3180a21ccae0e4fb1cd982 (diff)
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
-rw-r--r--sc/source/filter/inc/numberformatsbuffer.hxx2
-rw-r--r--sc/source/filter/inc/stylesbuffer.hxx4
-rw-r--r--sc/source/filter/oox/stylesbuffer.cxx47
3 files changed, 38 insertions, 15 deletions
diff --git a/sc/source/filter/inc/numberformatsbuffer.hxx b/sc/source/filter/inc/numberformatsbuffer.hxx
index 32c36111c69b..52a68f02a9c6 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 6802e9b7dc26..e3c4036e0355 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 49b1194f0ee0..d14b35369266 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;
}