diff options
22 files changed, 128 insertions, 176 deletions
diff --git a/dbaccess/source/filter/xml/xmlStyleImport.cxx b/dbaccess/source/filter/xml/xmlStyleImport.cxx index e94d8e43e609..50a1bbedcdd7 100644 --- a/dbaccess/source/filter/xml/xmlStyleImport.cxx +++ b/dbaccess/source/filter/xml/xmlStyleImport.cxx @@ -134,11 +134,8 @@ ODBFilter& OTableStyleContext::GetOwnImport() OTableStylesContext::OTableStylesContext( SvXMLImport& rImport, - sal_uInt16 nPrfx , - const OUString& rLName , - const Reference< XAttributeList > & xAttrList, - const bool bTempAutoStyles ) - : SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList ) + bool bTempAutoStyles ) + : SvXMLStylesContext( rImport ) , m_nNumberFormatIndex(-1) , m_nMasterPageNameIndex(-1) , bAutoStyles(bTempAutoStyles) diff --git a/dbaccess/source/filter/xml/xmlStyleImport.hxx b/dbaccess/source/filter/xml/xmlStyleImport.hxx index 6d8b72069f39..4d36a34eb82b 100644 --- a/dbaccess/source/filter/xml/xmlStyleImport.hxx +++ b/dbaccess/source/filter/xml/xmlStyleImport.hxx @@ -93,10 +93,7 @@ namespace dbaxml public: - OTableStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx , - const OUString& rLName , - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList, - const bool bAutoStyles ); + OTableStylesContext( SvXMLImport& rImport, bool bAutoStyles ); virtual ~OTableStylesContext() override; virtual void EndElement() override; diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx index 5b250b9f881c..97dd78c21c01 100644 --- a/dbaccess/source/filter/xml/xmlfilter.cxx +++ b/dbaccess/source/filter/xml/xmlfilter.cxx @@ -426,33 +426,23 @@ public: { } - virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix, - const OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList> & xAttrList) override + virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) override { - SvXMLImportContext *pContext = nullptr; - ODBFilter & rImport(static_cast<ODBFilter&>(GetImport())); - const SvXMLTokenMap& rTokenMap = rImport.GetDocContentElemTokenMap(); - switch (rTokenMap.Get(nPrefix, rLocalName)) + switch (nElement) { - case XML_TOK_CONTENT_STYLES: + case XML_ELEMENT(OFFICE, XML_STYLES): + case XML_ELEMENT(OOO, XML_STYLES): rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = rImport.CreateStylesContext(nPrefix, rLocalName, xAttrList, false); + return rImport.CreateStylesContext(false); break; - case XML_TOK_CONTENT_AUTOSTYLES: + case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES): + case XML_ELEMENT(OOO, XML_AUTOMATIC_STYLES): rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = rImport.CreateStylesContext(nPrefix, rLocalName, xAttrList, true); - break; - default: + return rImport.CreateStylesContext(true); break; } - - return pContext; - } - virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( - sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) override - { return nullptr; } }; @@ -492,28 +482,9 @@ public: { } - virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix, - const OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList> & xAttrList) override - { - SvXMLImportContext *pContext = nullptr; - - ODBFilter & rImport(static_cast<ODBFilter&>(GetImport())); - const SvXMLTokenMap& rTokenMap = rImport.GetDocContentElemTokenMap(); - switch (rTokenMap.Get(nPrefix, rLocalName)) - { - case XML_TOK_CONTENT_AUTOSTYLES: - rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = rImport.CreateStylesContext(nPrefix, rLocalName, xAttrList, true); - break; - default: - break; - } - - return pContext; - } virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) override { @@ -527,6 +498,11 @@ public: case XML_ELEMENT(OFFICE, XML_SCRIPTS): return new XMLScriptContext(GetImport(), rImport.GetModel()); break; + case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES): + case XML_ELEMENT(OOO, XML_AUTOMATIC_STYLES): + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + return rImport.CreateStylesContext(true); + break; default: break; } return nullptr; @@ -634,10 +610,9 @@ const SvXMLTokenMap& ODBFilter::GetDocContentElemTokenMap() const -SvXMLImportContext* ODBFilter::CreateStylesContext(sal_uInt16 _nPrefix,const OUString& rLocalName, - const uno::Reference< XAttributeList>& xAttrList, bool bIsAutoStyle ) +SvXMLImportContext* ODBFilter::CreateStylesContext( bool bIsAutoStyle ) { - SvXMLImportContext *pContext = new OTableStylesContext(*this, _nPrefix, rLocalName, xAttrList, bIsAutoStyle); + SvXMLImportContext *pContext = new OTableStylesContext(*this, bIsAutoStyle); if (bIsAutoStyle) SetAutoStyles(static_cast<SvXMLStylesContext*>(pContext)); else diff --git a/dbaccess/source/filter/xml/xmlfilter.hxx b/dbaccess/source/filter/xml/xmlfilter.hxx index d722821baf29..16e4b2c557cf 100644 --- a/dbaccess/source/filter/xml/xmlfilter.hxx +++ b/dbaccess/source/filter/xml/xmlfilter.hxx @@ -83,8 +83,7 @@ private: static void fillPropertyMap(const Any& _rValue,TPropertyNameMap& _rMap); public: - SvXMLImportContext* CreateStylesContext(sal_uInt16 nPrefix,const OUString& rLocalName, - const Reference< XAttributeList>& xAttrList, bool bIsAutoStyle ); + SvXMLImportContext* CreateStylesContext( bool bIsAutoStyle ); protected: // SvXMLImport diff --git a/include/xmloff/XMLTextMasterStylesContext.hxx b/include/xmloff/XMLTextMasterStylesContext.hxx index 035812e653b9..99f595a98c37 100644 --- a/include/xmloff/XMLTextMasterStylesContext.hxx +++ b/include/xmloff/XMLTextMasterStylesContext.hxx @@ -43,6 +43,7 @@ public: XMLTextMasterStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList); + XMLTextMasterStylesContext( SvXMLImport& rImport ); virtual ~XMLTextMasterStylesContext() override; }; diff --git a/include/xmloff/xmlstyle.hxx b/include/xmloff/xmlstyle.hxx index a18070f6a747..84a35e431d53 100644 --- a/include/xmloff/xmlstyle.hxx +++ b/include/xmloff/xmlstyle.hxx @@ -198,9 +198,18 @@ public: const OUString& rLName, const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList, bool bAutomatic = false ); + SvXMLStylesContext( SvXMLImport& rImport, + bool bAutomatic = false ); virtual ~SvXMLStylesContext() override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + + // Create child element. + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; + // Create child element. virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 0e22d225672a..fdc16dfd477d 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -357,14 +357,6 @@ SvXMLImportContextRef ScXMLDocContext_Impl::CreateChildContext( sal_uInt16 nPref if (GetScImport().getImportFlags() & SvXMLImportFlags::FONTDECLS) pContext = GetScImport().CreateFontDeclsContext(nPrefix, rLocalName, xAttrList); break; - case XML_TOK_DOC_STYLES: - if (GetScImport().getImportFlags() & SvXMLImportFlags::STYLES) - pContext = GetScImport().CreateStylesContext( rLocalName, xAttrList, false); - break; - case XML_TOK_DOC_AUTOSTYLES: - if (GetScImport().getImportFlags() & SvXMLImportFlags::AUTOSTYLES) - pContext = GetScImport().CreateStylesContext( rLocalName, xAttrList, true); - break; case XML_TOK_DOC_MASTERSTYLES: if (GetScImport().getImportFlags() & SvXMLImportFlags::MASTERSTYLES) pContext = new ScXMLMasterStylesContext( GetImport(), nPrefix, rLocalName, @@ -398,6 +390,14 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL if (GetScImport().getImportFlags() & SvXMLImportFlags::SETTINGS) pContext = new XMLDocumentSettingsContext(GetScImport()); break; + case XML_ELEMENT(OFFICE, XML_STYLES): + if (GetScImport().getImportFlags() & SvXMLImportFlags::STYLES) + pContext = GetScImport().CreateStylesContext( false); + break; + case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES): + if (GetScImport().getImportFlags() & SvXMLImportFlags::AUTOSTYLES) + pContext = GetScImport().CreateStylesContext( true); + break; //TODO: handle all other cases } @@ -752,11 +752,10 @@ SvXMLImportContext *ScXMLImport::CreateFontDeclsContext(const sal_uInt16 nPrefix return pContext; } -SvXMLImportContext *ScXMLImport::CreateStylesContext(const OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList, bool bIsAutoStyle ) +SvXMLImportContext *ScXMLImport::CreateStylesContext( bool bIsAutoStyle ) { SvXMLImportContext* pContext = new XMLTableStylesContext( - *this, XML_NAMESPACE_OFFICE, rLocalName, xAttrList, bIsAutoStyle); + *this, bIsAutoStyle); if (bIsAutoStyle) SetAutoStyles(static_cast<SvXMLStylesContext*>(pContext)); diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx index a225957f014d..a471a44a7975 100644 --- a/sc/source/filter/xml/xmlimprt.hxx +++ b/sc/source/filter/xml/xmlimprt.hxx @@ -314,9 +314,7 @@ public: SvXMLImportContext *CreateFontDeclsContext(const sal_uInt16 nPrefix, const OUString& rLocalName, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList); SvXMLImportContext *CreateScriptContext(); - SvXMLImportContext *CreateStylesContext(const OUString& rLocalName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList, - bool bAutoStyles ); + SvXMLImportContext *CreateStylesContext( bool bAutoStyles ); SvXMLImportContext *CreateBodyContext( const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList ); diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx index 1a92449707ec..e4fc574948a5 100644 --- a/sc/source/filter/xml/xmlstyli.cxx +++ b/sc/source/filter/xml/xmlstyli.cxx @@ -680,11 +680,8 @@ static const OUStringLiteral gsRowStyleServiceName(XML_STYLE_FAMILY_TABLE_ROW_ST static const OUStringLiteral gsTableStyleServiceName(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME); XMLTableStylesContext::XMLTableStylesContext( SvXMLImport& rImport, - sal_uInt16 nPrfx , - const OUString& rLName , - const uno::Reference< XAttributeList > & xAttrList, const bool bTempAutoStyles ) - : SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList ) + : SvXMLStylesContext( rImport ) , nNumberFormatIndex(-1) , nConditionalFormatIndex(-1) , nCellStyleIndex(-1) diff --git a/sc/source/filter/xml/xmlstyli.hxx b/sc/source/filter/xml/xmlstyli.hxx index 21e2ae976ed4..666bfa9fef7f 100644 --- a/sc/source/filter/xml/xmlstyli.hxx +++ b/sc/source/filter/xml/xmlstyli.hxx @@ -152,10 +152,7 @@ protected: public: - XMLTableStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx , - const OUString& rLName , - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList, - const bool bAutoStyles ); + XMLTableStylesContext( SvXMLImport& rImport, bool bAutoStyles ); virtual ~XMLTableStylesContext() override; virtual void EndElement() override; diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx index 0150700d17a2..cb97973995ee 100644 --- a/sw/source/filter/xml/xmlfmt.cxx +++ b/sw/source/filter/xml/xmlfmt.cxx @@ -704,8 +704,6 @@ public: SwXMLStylesContext_Impl( SwXMLImport& rImport, - const OUString& rLName , - const uno::Reference< xml::sax::XAttributeList > & xAttrList, bool bAuto ); virtual bool InsertStyleFamily( sal_uInt16 nFamily ) const override; @@ -805,10 +803,9 @@ SvXMLStyleContext *SwXMLStylesContext_Impl::CreateDefaultStyleStyleChildContext( } SwXMLStylesContext_Impl::SwXMLStylesContext_Impl( - SwXMLImport& rImport, const OUString& rLName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList, + SwXMLImport& rImport, bool bAuto ) : - SvXMLStylesContext( rImport, XML_NAMESPACE_OFFICE, rLName, xAttrList, bAuto ) + SvXMLStylesContext( rImport, bAuto ) { } @@ -910,10 +907,7 @@ protected: public: - SwXMLMasterStylesContext_Impl( - SwXMLImport& rImport, - const OUString& rLName , - const uno::Reference< xml::sax::XAttributeList > & xAttrList ); + SwXMLMasterStylesContext_Impl( SwXMLImport& rImport ); virtual void EndElement() override; }; @@ -921,10 +915,8 @@ public: } SwXMLMasterStylesContext_Impl::SwXMLMasterStylesContext_Impl( - SwXMLImport& rImport, - const OUString& rLName , - const uno::Reference< xml::sax::XAttributeList > & xAttrList ) : - XMLTextMasterStylesContext( rImport, XML_NAMESPACE_OFFICE, rLName, xAttrList ) + SwXMLImport& rImport ) : + XMLTextMasterStylesContext( rImport ) { } @@ -949,13 +941,9 @@ void SwXMLMasterStylesContext_Impl::EndElement() } SvXMLImportContext *SwXMLImport::CreateStylesContext( - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList, bool bAuto ) { - SvXMLStylesContext *pContext = - new SwXMLStylesContext_Impl( *this, rLocalName, - xAttrList, bAuto ); + SvXMLStylesContext *pContext = new SwXMLStylesContext_Impl( *this, bAuto ); if( bAuto ) SetAutoStyles( pContext ); else @@ -964,12 +952,10 @@ SvXMLImportContext *SwXMLImport::CreateStylesContext( return pContext; } -SvXMLImportContext *SwXMLImport::CreateMasterStylesContext( - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +SvXMLImportContext *SwXMLImport::CreateMasterStylesContext() { SvXMLStylesContext *pContext = - new SwXMLMasterStylesContext_Impl( *this, rLocalName, xAttrList ); + new SwXMLMasterStylesContext_Impl( *this ); SetMasterStyles( pContext ); return pContext; diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 29035b03829d..1735a9716140 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -221,6 +221,20 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SwXMLDocContext_Impl::c case XML_ELEMENT(OFFICE, XML_SETTINGS): return new XMLDocumentSettingsContext( GetImport() ); break; + case XML_ELEMENT(OFFICE, XML_STYLES): + GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + return GetSwImport().CreateStylesContext( false ); + break; + case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES): + // don't use the autostyles from the styles-document for the progress + if ( !IsPrefixFilledIn() || ! IsXMLToken( GetLocalName(), XML_DOCUMENT_STYLES ) ) + GetSwImport().GetProgressBarHelper()->Increment + ( PROGRESS_BAR_STEP ); + return GetSwImport().CreateStylesContext( true ); + break; + case XML_ELEMENT(OFFICE, XML_MASTER_STYLES): + return GetSwImport().CreateMasterStylesContext(); + break; } return nullptr; } @@ -239,24 +253,6 @@ SvXMLImportContextRef SwXMLDocContext_Impl::CreateChildContext( pContext = GetSwImport().CreateFontDeclsContext( rLocalName, xAttrList ); break; - case XML_TOK_DOC_STYLES: - GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = GetSwImport().CreateStylesContext( rLocalName, xAttrList, - false ); - break; - case XML_TOK_DOC_AUTOSTYLES: - // don't use the autostyles from the styles-document for the progress - if ( !IsPrefixFilledIn() || ! IsXMLToken( GetLocalName(), XML_DOCUMENT_STYLES ) ) - GetSwImport().GetProgressBarHelper()->Increment - ( PROGRESS_BAR_STEP ); - pContext = GetSwImport().CreateStylesContext( rLocalName, xAttrList, - true ); - break; - - case XML_TOK_DOC_MASTERSTYLES: - pContext = GetSwImport().CreateMasterStylesContext( rLocalName, - xAttrList ); - break; case XML_TOK_DOC_META: OSL_FAIL("XML_TOK_DOC_META: should not have come here, maybe document is invalid?"); break; diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx index b8357b88eaec..10c064b7846c 100644 --- a/sw/source/filter/xml/xmlimp.hxx +++ b/sw/source/filter/xml/xmlimp.hxx @@ -135,13 +135,8 @@ public: // the root element (i.e. office:document-meta) SvXMLImportContext *CreateMetaContext( const sal_Int32 nElement ); SvXMLImportContext *CreateScriptContext(); - SvXMLImportContext *CreateStylesContext( - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList, - bool bAuto ); - SvXMLImportContext *CreateMasterStylesContext( - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ); + SvXMLImportContext *CreateStylesContext( bool bAuto ); + SvXMLImportContext *CreateMasterStylesContext(); SvXMLImportContext *CreateFontDeclsContext( const OUString& rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ); diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx index 73e726fe03d6..690038c80bf8 100644 --- a/xmloff/inc/SchXMLImport.hxx +++ b/xmloff/inc/SchXMLImport.hxx @@ -162,8 +162,7 @@ public: virtual ~SchXMLImport() throw () override; - SvXMLImportContext* CreateStylesContext( const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ); + SvXMLImportContext* CreateStylesContext(); // XImporter virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override; diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx index 3432da7906fd..354e4ae4cf85 100644 --- a/xmloff/source/chart/SchXMLImport.cxx +++ b/xmloff/source/chart/SchXMLImport.cxx @@ -529,15 +529,12 @@ SvXMLImportContext *SchXMLImport::CreateFastContext( sal_Int32 nElement, return pContext; } -SvXMLImportContext* SchXMLImport::CreateStylesContext( - const OUString& rLocalName, - const Reference<xml::sax::XAttributeList>& xAttrList ) +SvXMLImportContext* SchXMLImport::CreateStylesContext() { //#i103287# make sure that the version information is set before importing all the properties (especially stroke-opacity!) SchXMLTools::setBuildIDAtImportInfo( GetModel(), getImportInfo() ); - SvXMLStylesContext* pStylesCtxt = - new SvXMLStylesContext( *(this), XML_NAMESPACE_OFFICE, rLocalName, xAttrList ); + SvXMLStylesContext* pStylesCtxt = new SvXMLStylesContext( *this ); // set context at base class, so that all auto-style classes are imported SetAutoStyles( pStylesCtxt ); diff --git a/xmloff/source/chart/contexts.cxx b/xmloff/source/chart/contexts.cxx index d2059a1a44e7..218a91e194a2 100644 --- a/xmloff/source/chart/contexts.cxx +++ b/xmloff/source/chart/contexts.cxx @@ -84,26 +84,13 @@ SchXMLDocContext::~SchXMLDocContext() SvXMLImportContextRef SchXMLDocContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList >& xAttrList ) + const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/ ) { SvXMLImportContextRef xContext; const SvXMLTokenMap& rTokenMap = mrImportHelper.GetDocElemTokenMap(); - SvXMLImportFlags nFlags = GetImport().getImportFlags(); switch( rTokenMap.Get( nPrefix, rLocalName )) { - case XML_TOK_DOC_AUTOSTYLES: - if( nFlags & SvXMLImportFlags::AUTOSTYLES ) - // not nice, but this is safe, as the SchXMLDocContext class can only by - // instantiated by the chart import class SchXMLImport (header is not exported) - xContext = - static_cast< SchXMLImport& >( GetImport() ).CreateStylesContext( rLocalName, xAttrList ); - break; - case XML_TOK_DOC_STYLES: - // for draw styles containing gradients/hatches/markers and dashes - if( nFlags & SvXMLImportFlags::STYLES ) - xContext = new SvXMLStylesContext( GetImport(), nPrefix, rLocalName, xAttrList ); - break; case XML_TOK_DOC_META: // we come here in the flat ODF file format, // if XDocumentPropertiesSupplier is not supported at the model @@ -122,6 +109,19 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SchXMLDocContext::creat case XML_ELEMENT(OFFICE, XML_BODY): if( nFlags & SvXMLImportFlags::CONTENT ) return new SchXMLBodyContext_Impl( mrImportHelper, GetImport() ); + break; + case XML_ELEMENT(OFFICE, XML_STYLES): + // for draw styles containing gradients/hatches/markers and dashes + if( nFlags & SvXMLImportFlags::STYLES ) + return new SvXMLStylesContext( GetImport() ); + break; + case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES): + if( nFlags & SvXMLImportFlags::AUTOSTYLES ) + // not nice, but this is safe, as the SchXMLDocContext class can only by + // instantiated by the chart import class SchXMLImport (header is not exported) + return + static_cast< SchXMLImport& >( GetImport() ).CreateStylesContext(); + break; } return nullptr; } diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx index b14251d98e6c..7ccf05c73ff4 100644 --- a/xmloff/source/draw/sdxmlimp.cxx +++ b/xmloff/source/draw/sdxmlimp.cxx @@ -129,24 +129,6 @@ SvXMLImportContextRef SdXMLDocContext_Impl::CreateChildContext( xContext = GetSdImport().CreateFontDeclsContext( rLocalName, xAttrList ); break; } - case XML_TOK_DOC_STYLES: - { - if( GetImport().getImportFlags() & SvXMLImportFlags::STYLES ) - { - // office:styles inside office:document - xContext = GetSdImport().CreateStylesContext(rLocalName, xAttrList); - } - break; - } - case XML_TOK_DOC_AUTOSTYLES: - { - if( GetImport().getImportFlags() & SvXMLImportFlags::AUTOSTYLES ) - { - // office:automatic-styles inside office:document - xContext = GetSdImport().CreateAutoStylesContext(rLocalName, xAttrList); - } - break; - } case XML_TOK_DOC_META: { SAL_INFO("xmloff.draw", "XML_TOK_DOC_META: should not have come here, maybe document is invalid?"); @@ -197,6 +179,24 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SdXMLDocContext_Impl::c } break; } + case XML_ELEMENT(OFFICE, XML_STYLES): + { + if( GetImport().getImportFlags() & SvXMLImportFlags::STYLES ) + { + // office:styles inside office:document + return GetSdImport().CreateStylesContext(); + } + break; + } + case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES): + { + if( GetImport().getImportFlags() & SvXMLImportFlags::AUTOSTYLES ) + { + // office:automatic-styles inside office:document + return GetSdImport().CreateAutoStylesContext(); + } + break; + } } return nullptr; } @@ -702,26 +702,24 @@ SvXMLImportContext *SdXMLImport::CreateMetaContext(const sal_Int32 /*nElement*/, return pContext; } -SvXMLStylesContext *SdXMLImport::CreateStylesContext(const OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList) +SvXMLStylesContext *SdXMLImport::CreateStylesContext() { if(GetShapeImport()->GetStylesContext()) return GetShapeImport()->GetStylesContext(); GetShapeImport()->SetStylesContext(new SdXMLStylesContext( - *this, rLocalName, xAttrList, false)); + *this, false)); return GetShapeImport()->GetStylesContext(); } -SvXMLStylesContext *SdXMLImport::CreateAutoStylesContext(const OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList) +SvXMLStylesContext *SdXMLImport::CreateAutoStylesContext() { if(GetShapeImport()->GetAutoStylesContext()) return GetShapeImport()->GetAutoStylesContext(); GetShapeImport()->SetAutoStylesContext(new SdXMLStylesContext( - *this, rLocalName, xAttrList, true)); + *this, true)); return GetShapeImport()->GetAutoStylesContext(); } diff --git a/xmloff/source/draw/sdxmlimp_impl.hxx b/xmloff/source/draw/sdxmlimp_impl.hxx index 32f9690634f3..93fc2f242153 100644 --- a/xmloff/source/draw/sdxmlimp_impl.hxx +++ b/xmloff/source/draw/sdxmlimp_impl.hxx @@ -202,10 +202,8 @@ public: // the root element (i.e. office:document-meta) SvXMLImportContext* CreateMetaContext(const sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList); - SvXMLStylesContext* CreateStylesContext(const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList); - SvXMLStylesContext* CreateAutoStylesContext(const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList); + SvXMLStylesContext* CreateStylesContext(); + SvXMLStylesContext* CreateAutoStylesContext(); SvXMLImportContext* CreateMasterStylesContext(); SvXMLImportContext *CreateFontDeclsContext(const OUString& rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ); diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx index 4d0084bb9412..e1fc43066ddf 100644 --- a/xmloff/source/draw/ximpstyl.cxx +++ b/xmloff/source/draw/ximpstyl.cxx @@ -881,10 +881,8 @@ SvXMLImportContextRef SdXMLMasterPageContext::CreateChildContext( SdXMLStylesContext::SdXMLStylesContext( SdXMLImport& rImport, - const OUString& rLName, - const uno::Reference< xml::sax::XAttributeList >& xAttrList, bool bIsAutoStyle) -: SvXMLStylesContext(rImport, XML_NAMESPACE_OFFICE, rLName, xAttrList), +: SvXMLStylesContext(rImport), mbIsAutoStyle(bIsAutoStyle) { Reference< uno::XComponentContext > xContext = rImport.GetComponentContext(); diff --git a/xmloff/source/draw/ximpstyl.hxx b/xmloff/source/draw/ximpstyl.hxx index b9038609715f..6ca56fd7d3fc 100644 --- a/xmloff/source/draw/ximpstyl.hxx +++ b/xmloff/source/draw/ximpstyl.hxx @@ -205,8 +205,6 @@ public: SdXMLStylesContext( SdXMLImport& rImport, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList, bool bIsAutoStyle); virtual void EndElement() override; diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index 352eba7cee7f..1c4bd1f4ea3c 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -754,10 +754,22 @@ SvXMLStylesContext::SvXMLStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx, { } +SvXMLStylesContext::SvXMLStylesContext( SvXMLImport& rImport, bool bAuto ) : + SvXMLImportContext( rImport ), + mpImpl( new SvXMLStylesContext_Impl( bAuto ) ) +{ +} + SvXMLStylesContext::~SvXMLStylesContext() { } +css::uno::Reference< css::xml::sax::XFastContextHandler > SvXMLStylesContext::createFastChildContext( + sal_Int32 /*nElement*/, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) +{ + return nullptr; +} + SvXMLImportContextRef SvXMLStylesContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > & xAttrList ) diff --git a/xmloff/source/text/XMLTextMasterStylesContext.cxx b/xmloff/source/text/XMLTextMasterStylesContext.cxx index c8af93f582ba..228e36cc1ee9 100644 --- a/xmloff/source/text/XMLTextMasterStylesContext.cxx +++ b/xmloff/source/text/XMLTextMasterStylesContext.cxx @@ -44,6 +44,12 @@ XMLTextMasterStylesContext::XMLTextMasterStylesContext( { } +XMLTextMasterStylesContext::XMLTextMasterStylesContext( + SvXMLImport& rImport ) : + SvXMLStylesContext( rImport ) +{ +} + XMLTextMasterStylesContext::~XMLTextMasterStylesContext() { } |