From d87cb77b42b591b1333aacd60e107514d6e20864 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 4 Sep 2013 15:35:18 +0100 Subject: Resolves: fdo#68431 style:font-name unknown in non autostyles in impress/draw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib904af4fac5659821ba3b5dbbf62370df8243001 Reviewed-on: https://gerrit.libreoffice.org/5810 Reviewed-by: Pierre-Eric Pelloux-Prayer Tested-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/xmloff/xmlexppr.hxx | 11 ++++--- sc/source/filter/xml/xmlstyle.cxx | 4 ++- sc/source/filter/xml/xmlstyle.hxx | 2 ++ xmloff/inc/XMLChartPropertySetMapper.hxx | 1 + xmloff/source/chart/PropertyMaps.cxx | 3 +- xmloff/source/draw/sdpropls.cxx | 6 ++-- xmloff/source/draw/sdpropls.hxx | 2 ++ xmloff/source/style/PageMasterExportPropMapper.cxx | 3 +- xmloff/source/style/PageMasterExportPropMapper.hxx | 1 + xmloff/source/style/styleexp.cxx | 2 +- xmloff/source/style/xmlexppr.cxx | 7 ++-- xmloff/source/text/txtexppr.cxx | 38 +++++++++++++--------- xmloff/source/text/txtexppr.hxx | 2 ++ 13 files changed, 53 insertions(+), 29 deletions(-) diff --git a/include/xmloff/xmlexppr.hxx b/include/xmloff/xmlexppr.hxx index b63b69ccb05b..28f8372b7bc9 100644 --- a/include/xmloff/xmlexppr.hxx +++ b/include/xmloff/xmlexppr.hxx @@ -55,10 +55,11 @@ protected: ::std::vector< XMLPropertyState > _Filter( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rPropSet, - const sal_Bool bDefault ) const; + bool bDefault, bool bDisableFoFontFamily) const; /** Application-specific filter. By default do nothing. */ virtual void ContextFilter( + bool bEnableFoFontFamily, ::std::vector< XMLPropertyState >& rProperties, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rPropSet ) const; @@ -107,8 +108,8 @@ public: filter-processes. */ ::std::vector< XMLPropertyState > Filter( const ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > rPropSet ) const - { return _Filter(rPropSet, sal_False); } + ::com::sun::star::beans::XPropertySet > rPropSet, bool bEnableFoFontFamily = false) const + { return _Filter(rPropSet, false, bEnableFoFontFamily); } /** Like Filter(), except that: * - only properties that have the map flag MID_FLAG_DEFAULT_ITEM_EXPORT @@ -117,8 +118,8 @@ public: */ ::std::vector< XMLPropertyState > FilterDefaults( const ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > rPropSet ) const - { return _Filter(rPropSet, sal_True); } + ::com::sun::star::beans::XPropertySet > rPropSet, bool bEnableFoFontFamily = false) const + { return _Filter(rPropSet, true, bEnableFoFontFamily); } /** Compare to arrays of XMLPropertyState */ sal_Bool Equals( const ::std::vector< XMLPropertyState >& aProperties1, diff --git a/sc/source/filter/xml/xmlstyle.cxx b/sc/source/filter/xml/xmlstyle.cxx index e43ca7f202b5..e2bd28fa9917 100644 --- a/sc/source/filter/xml/xmlstyle.cxx +++ b/sc/source/filter/xml/xmlstyle.cxx @@ -186,6 +186,7 @@ ScXMLCellExportPropertyMapper::~ScXMLCellExportPropertyMapper() } void ScXMLCellExportPropertyMapper::ContextFilter( + bool bEnableFoFontFamily, ::std::vector< XMLPropertyState >& rProperties, uno::Reference< beans::XPropertySet > rPropSet ) const { @@ -503,7 +504,7 @@ void ScXMLCellExportPropertyMapper::ContextFilter( pDiagonalBLTRWidthState->maValue.clear(); } - SvXMLExportPropertyMapper::ContextFilter(rProperties, rPropSet); + SvXMLExportPropertyMapper::ContextFilter(bEnableFoFontFamily, rProperties, rPropSet); } /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_EXPORT flag set */ @@ -553,6 +554,7 @@ ScXMLRowExportPropertyMapper::~ScXMLRowExportPropertyMapper() } void ScXMLRowExportPropertyMapper::ContextFilter( + bool /* bEnableFoFontFamily */, ::std::vector< XMLPropertyState >& /* rProperties */, uno::Reference< beans::XPropertySet > /* rPropSet */ ) const { diff --git a/sc/source/filter/xml/xmlstyle.hxx b/sc/source/filter/xml/xmlstyle.hxx index 344bed8dafbe..4dc79a202ad9 100644 --- a/sc/source/filter/xml/xmlstyle.hxx +++ b/sc/source/filter/xml/xmlstyle.hxx @@ -106,6 +106,7 @@ class ScXMLCellExportPropertyMapper : public SvXMLExportPropertyMapper protected: /** Application-specific filter. By default do nothing. */ virtual void ContextFilter( + bool bEnableFoFontFamily, ::std::vector< XMLPropertyState >& rProperties, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rPropSet ) const; @@ -135,6 +136,7 @@ class ScXMLRowExportPropertyMapper : public SvXMLExportPropertyMapper protected: /** Application-specific filter. By default do nothing. */ virtual void ContextFilter( + bool bEnableFoFontFamily, ::std::vector< XMLPropertyState >& rProperties, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rPropSet ) const; diff --git a/xmloff/inc/XMLChartPropertySetMapper.hxx b/xmloff/inc/XMLChartPropertySetMapper.hxx index 5d353833a124..f2726baf09ed 100644 --- a/xmloff/inc/XMLChartPropertySetMapper.hxx +++ b/xmloff/inc/XMLChartPropertySetMapper.hxx @@ -58,6 +58,7 @@ private: protected: virtual void ContextFilter( + bool bEnableFoFontFamily, ::std::vector< XMLPropertyState >& rProperties, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rPropSet ) const; diff --git a/xmloff/source/chart/PropertyMaps.cxx b/xmloff/source/chart/PropertyMaps.cxx index f712aeb1ff9c..dc303f8abe7c 100644 --- a/xmloff/source/chart/PropertyMaps.cxx +++ b/xmloff/source/chart/PropertyMaps.cxx @@ -191,6 +191,7 @@ XMLChartExportPropertyMapper::~XMLChartExportPropertyMapper() } void XMLChartExportPropertyMapper::ContextFilter( + bool bEnableFoFontFamily, std::vector< XMLPropertyState >& rProperties, uno::Reference< beans::XPropertySet > rPropSet ) const { @@ -266,7 +267,7 @@ void XMLChartExportPropertyMapper::ContextFilter( } } - SvXMLExportPropertyMapper::ContextFilter(rProperties, rPropSet); + SvXMLExportPropertyMapper::ContextFilter(bEnableFoFontFamily, rProperties, rPropSet); } void XMLChartExportPropertyMapper::handleElementItem( diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx index 828b2c6561d6..d6fe22513f0b 100644 --- a/xmloff/source/draw/sdpropls.cxx +++ b/xmloff/source/draw/sdpropls.cxx @@ -1186,6 +1186,7 @@ XMLShapeExportPropertyMapper::~XMLShapeExportPropertyMapper() } void XMLShapeExportPropertyMapper::ContextFilter( + bool bEnableFoFontFamily, std::vector< XMLPropertyState >& rProperties, uno::Reference< beans::XPropertySet > rPropSet ) const { @@ -1506,7 +1507,7 @@ void XMLShapeExportPropertyMapper::ContextFilter( if( pClipState != NULL && pClip11State != NULL ) pClip11State->mnIndex = -1; - SvXMLExportPropertyMapper::ContextFilter(rProperties, rPropSet); + SvXMLExportPropertyMapper::ContextFilter(bEnableFoFontFamily, rProperties, rPropSet); } void XMLShapeExportPropertyMapper::handleSpecialItem( @@ -1567,6 +1568,7 @@ XMLPageExportPropertyMapper::~XMLPageExportPropertyMapper() } void XMLPageExportPropertyMapper::ContextFilter( + bool bEnableFoFontFamily, std::vector< XMLPropertyState >& rProperties, uno::Reference< beans::XPropertySet > rPropSet ) const { @@ -1711,7 +1713,7 @@ void XMLPageExportPropertyMapper::ContextFilter( pTransType->mnIndex = -1; } - SvXMLExportPropertyMapper::ContextFilter(rProperties, rPropSet); + SvXMLExportPropertyMapper::ContextFilter(bEnableFoFontFamily, rProperties, rPropSet); } void XMLPageExportPropertyMapper::handleElementItem( diff --git a/xmloff/source/draw/sdpropls.hxx b/xmloff/source/draw/sdpropls.hxx index 3f55a330d60c..eb1e9e91479c 100644 --- a/xmloff/source/draw/sdpropls.hxx +++ b/xmloff/source/draw/sdpropls.hxx @@ -239,6 +239,7 @@ private: protected: virtual void ContextFilter( + bool bEnableFoFontFamily, ::std::vector< XMLPropertyState >& rProperties, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rPropSet ) const; @@ -276,6 +277,7 @@ private: protected: virtual void ContextFilter( + bool bEnableFoFontFamily, ::std::vector< XMLPropertyState >& rProperties, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rPropSet ) const; diff --git a/xmloff/source/style/PageMasterExportPropMapper.cxx b/xmloff/source/style/PageMasterExportPropMapper.cxx index 0bf9d9ea4a65..b9da68a4783a 100644 --- a/xmloff/source/style/PageMasterExportPropMapper.cxx +++ b/xmloff/source/style/PageMasterExportPropMapper.cxx @@ -304,6 +304,7 @@ void XMLPageMasterExportPropMapper::handleSpecialItem( } void XMLPageMasterExportPropMapper::ContextFilter( + bool bEnableFoFontFamily, ::std::vector< XMLPropertyState >& rPropState, Reference< XPropertySet > rPropSet ) const { @@ -452,7 +453,7 @@ void XMLPageMasterExportPropMapper::ContextFilter( lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_ZEROVALUES), "PrintZeroValues", rPropSet); } - SvXMLExportPropertyMapper::ContextFilter(rPropState,rPropSet); + SvXMLExportPropertyMapper::ContextFilter(bEnableFoFontFamily, rPropState, rPropSet); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/style/PageMasterExportPropMapper.hxx b/xmloff/source/style/PageMasterExportPropMapper.hxx index 2bd6dbbd022e..7e3c022c4d66 100644 --- a/xmloff/source/style/PageMasterExportPropMapper.hxx +++ b/xmloff/source/style/PageMasterExportPropMapper.hxx @@ -33,6 +33,7 @@ protected: XMLFootnoteSeparatorExport aFootnoteSeparatorExport; virtual void ContextFilter( + bool bEnableFoFontFamily, ::std::vector< XMLPropertyState >& rProperties, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rPropSet ) const; diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx index 858d68a4c360..0d7ca9fbb3e9 100644 --- a/xmloff/source/style/styleexp.cxx +++ b/xmloff/source/style/styleexp.cxx @@ -318,7 +318,7 @@ sal_Bool XMLStyleExport::exportStyle( // ::std::vector< XMLPropertyState > xPropStates = - rPropMapper->Filter( xPropSet ); + rPropMapper->Filter( xPropSet, true ); rPropMapper->exportXML( GetExport(), xPropStates, XML_EXPORT_FLAG_IGN_WS ); diff --git a/xmloff/source/style/xmlexppr.cxx b/xmloff/source/style/xmlexppr.cxx index df146bdc8405..6892e489fe27 100644 --- a/xmloff/source/style/xmlexppr.cxx +++ b/xmloff/source/style/xmlexppr.cxx @@ -582,7 +582,7 @@ void SvXMLExportPropertyMapper::ChainExportMapper( vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter( const Reference< XPropertySet > xPropSet, - const sal_Bool bDefault ) const + bool bDefault, bool bEnableFoFontFamily) const { vector< XMLPropertyState > aPropStateArray; @@ -675,7 +675,7 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter( // Call centext-filter if( !aPropStateArray.empty() ) - ContextFilter( aPropStateArray, xPropSet ); + ContextFilter(bEnableFoFontFamily, aPropStateArray, xPropSet); // Have to do if we change from a vector to a list or something like that @@ -686,12 +686,13 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter( } void SvXMLExportPropertyMapper::ContextFilter( + bool bEnableFoFontFamily, vector< XMLPropertyState >& rProperties, Reference< XPropertySet > rPropSet ) const { // Derived class could implement this. if (mpImpl->mxNextMapper.is()) - mpImpl->mxNextMapper->ContextFilter(rProperties, rPropSet); + mpImpl->mxNextMapper->ContextFilter(bEnableFoFontFamily, rProperties, rPropSet); } // Compares two Sequences of XMLPropertyState: diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx index ec4e43929508..6c560cc2ac7f 100644 --- a/xmloff/source/text/txtexppr.cxx +++ b/xmloff/source/text/txtexppr.cxx @@ -190,6 +190,7 @@ XMLTextExportPropertySetMapper::~XMLTextExportPropertySetMapper() } void XMLTextExportPropertySetMapper::ContextFontFilter( + bool bEnableFoFontFamily, XMLPropertyState *pFontNameState, XMLPropertyState *pFontFamilyNameState, XMLPropertyState *pFontStyleNameState, @@ -241,19 +242,25 @@ void XMLTextExportPropertySetMapper::ContextFontFilter( { OUString sName( ((SvXMLExport&)GetExport()).GetFontAutoStylePool()->Find( sFamilyName, sStyleName, nFamily, nPitch, eEnc ) ); - if( !sName.isEmpty() ) + if (!sName.isEmpty()) { pFontNameState->maValue <<= sName; - if( pFontFamilyNameState ) - pFontFamilyNameState->mnIndex = -1; - if( pFontStyleNameState ) - pFontStyleNameState->mnIndex = -1; - if( pFontFamilyState ) - pFontFamilyState->mnIndex = -1; - if( pFontPitchState ) - pFontPitchState->mnIndex = -1; - if( pFontCharsetState ) - pFontCharsetState->mnIndex = -1; + //Resolves: fdo#68431 style:font-name unrecognized by LibreOffice + //<= 4.1 in styles (but recognized in autostyles) so add + //fo:font-family, etc + if (!bEnableFoFontFamily) + { + if( pFontFamilyNameState ) + pFontFamilyNameState->mnIndex = -1; + if( pFontStyleNameState ) + pFontStyleNameState->mnIndex = -1; + if( pFontFamilyState ) + pFontFamilyState->mnIndex = -1; + if( pFontPitchState ) + pFontPitchState->mnIndex = -1; + if( pFontCharsetState ) + pFontCharsetState->mnIndex = -1; + } } else { @@ -479,6 +486,7 @@ static void lcl_FilterBorders( } void XMLTextExportPropertySetMapper::ContextFilter( + bool bEnableFoFontFamily, ::std::vector< XMLPropertyState >& rProperties, Reference< XPropertySet > rPropSet ) const { @@ -781,15 +789,15 @@ void XMLTextExportPropertySetMapper::ContextFilter( } if( pFontNameState ) - ContextFontFilter( pFontNameState, pFontFamilyNameState, + ContextFontFilter( bEnableFoFontFamily, pFontNameState, pFontFamilyNameState, pFontStyleNameState, pFontFamilyState, pFontPitchState, pFontCharsetState ); if( pFontNameCJKState ) - ContextFontFilter( pFontNameCJKState, pFontFamilyNameCJKState, + ContextFontFilter( bEnableFoFontFamily, pFontNameCJKState, pFontFamilyNameCJKState, pFontStyleNameCJKState, pFontFamilyCJKState, pFontPitchCJKState, pFontCharsetCJKState ); if( pFontNameCTLState ) - ContextFontFilter( pFontNameCTLState, pFontFamilyNameCTLState, + ContextFontFilter( bEnableFoFontFamily, pFontNameCTLState, pFontFamilyNameCTLState, pFontStyleNameCTLState, pFontFamilyCTLState, pFontPitchCTLState, pFontCharsetCTLState ); @@ -1055,7 +1063,7 @@ void XMLTextExportPropertySetMapper::ContextFilter( if( pClipState != NULL && pClip11State != NULL ) pClip11State->mnIndex = -1; - SvXMLExportPropertyMapper::ContextFilter(rProperties,rPropSet); + SvXMLExportPropertyMapper::ContextFilter(bEnableFoFontFamily, rProperties, rPropSet); } namespace { diff --git a/xmloff/source/text/txtexppr.hxx b/xmloff/source/text/txtexppr.hxx index 2736cd22b7f7..204141869564 100644 --- a/xmloff/source/text/txtexppr.hxx +++ b/xmloff/source/text/txtexppr.hxx @@ -35,6 +35,7 @@ class XMLTextExportPropertySetMapper: public SvXMLExportPropertyMapper sal_Bool bDropWholeWord; void ContextFontFilter( + bool bEnableFoFontFamily, XMLPropertyState *pFontNameState, XMLPropertyState *pFontFamilyNameState, XMLPropertyState *pFontStyleNameState, @@ -56,6 +57,7 @@ protected: /** Application-specific filter. By default do nothing. */ virtual void ContextFilter( + bool bEnableFoFontFamily, ::std::vector< XMLPropertyState >& rProperties, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rPropSet ) const; -- cgit v1.2.3