diff options
Diffstat (limited to 'sc/source/filter')
-rw-r--r-- | sc/source/filter/inc/numberformatsbuffer.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/inc/stylesbuffer.hxx | 4 | ||||
-rw-r--r-- | sc/source/filter/oox/stylesbuffer.cxx | 47 |
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 cbedfb3a2464..269478485269 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; @@ -772,6 +772,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 96333d683962..ba102a91ec2c 100644 --- a/sc/source/filter/oox/stylesbuffer.cxx +++ b/sc/source/filter/oox/stylesbuffer.cxx @@ -2625,6 +2625,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 { @@ -3261,21 +3277,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; } |