diff options
Diffstat (limited to 'xmloff/source/draw/ximpstyl.cxx')
-rw-r--r-- | xmloff/source/draw/ximpstyl.cxx | 111 |
1 files changed, 58 insertions, 53 deletions
diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx index 136713271f8d..b093c5e3d90b 100644 --- a/xmloff/source/draw/ximpstyl.cxx +++ b/xmloff/source/draw/ximpstyl.cxx @@ -717,66 +717,63 @@ SdXMLPresentationPlaceholderContext::~SdXMLPresentationPlaceholderContext() SdXMLMasterPageContext::SdXMLMasterPageContext( SdXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const uno::Reference< xml::sax::XAttributeList>& xAttrList, + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes) -: SdXMLGenericPageContext( rImport, nPrfx, rLName, xAttrList, rShapes ) +: SdXMLGenericPageContext( rImport, xAttrList, rShapes ) { - const bool bHandoutMaster = IsXMLToken( rLName, XML_HANDOUT_MASTER ); + const bool bHandoutMaster = (nElement & TOKEN_MASK) == XML_HANDOUT_MASTER; OUString sStyleName, sPageMasterName; - const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for(sal_Int16 i=0; i < nAttrCount; i++) + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList ); + for (auto &aIter : *pAttribList) { - OUString sAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = GetSdImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - OUString sValue = xAttrList->getValueByIndex( i ); - const SvXMLTokenMap& rAttrTokenMap = GetSdImport().GetMasterPageAttrTokenMap(); - - switch(rAttrTokenMap.Get(nPrefix, aLocalName)) + const OUString sValue = aIter.toString(); + switch(aIter.getToken()) { - case XML_TOK_MASTERPAGE_NAME: + case XML_ELEMENT(STYLE, XML_NAME): { msName = sValue; break; } - case XML_TOK_MASTERPAGE_DISPLAY_NAME: + case XML_ELEMENT(STYLE, XML_DISPLAY_NAME): { msDisplayName = sValue; break; } - case XML_TOK_MASTERPAGE_PAGE_MASTER_NAME: + case XML_ELEMENT(STYLE, XML_PAGE_LAYOUT_NAME): { sPageMasterName = sValue; break; } - case XML_TOK_MASTERPAGE_STYLE_NAME: + case XML_ELEMENT(DRAW, XML_STYLE_NAME): { sStyleName = sValue; break; } - case XML_TOK_MASTERPAGE_PAGE_LAYOUT_NAME: + case XML_ELEMENT(PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME): { maPageLayoutName = sValue; break; } - case XML_TOK_MASTERPAGE_USE_HEADER_NAME: + case XML_ELEMENT(PRESENTATION, XML_USE_HEADER_NAME): { maUseHeaderDeclName = sValue; break; } - case XML_TOK_MASTERPAGE_USE_FOOTER_NAME: + case XML_ELEMENT(PRESENTATION, XML_USE_FOOTER_NAME): { maUseFooterDeclName = sValue; break; } - case XML_TOK_MASTERPAGE_USE_DATE_TIME_NAME: + case XML_ELEMENT(PRESENTATION, XML_USE_DATE_TIME_NAME): { maUseDateTimeDeclName = sValue; break; } + default: + SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << sValue); } } @@ -812,7 +809,7 @@ SdXMLMasterPageContext::~SdXMLMasterPageContext() { } -void SdXMLMasterPageContext::EndElement() +void SdXMLMasterPageContext::endFastElement(sal_Int32 nElement) { // set styles on master-page if(!msName.isEmpty() && GetSdImport().GetShapeImport()->GetStylesContext()) @@ -822,7 +819,7 @@ void SdXMLMasterPageContext::EndElement() pSdContext->SetMasterPageStyles(*this); } - SdXMLGenericPageContext::EndElement(); + SdXMLGenericPageContext::endFastElement(nElement); GetImport().GetShapeImport()->endPage(GetLocalShapesContext()); } @@ -853,7 +850,22 @@ SvXMLImportContextRef SdXMLMasterPageContext::CreateChildContext( } break; } - case XML_TOK_MASTERPAGE_NOTES: + } + + // call base class + if (!xContext) + xContext = SdXMLGenericPageContext::CreateChildContext(nPrefix, rLocalName, xAttrList); + + return xContext; +} + +css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLMasterPageContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) +{ + switch (nElement) + { + case XML_ELEMENT(PRESENTATION, XML_NOTES): { if( GetSdImport().IsImpress() ) { @@ -865,18 +877,13 @@ SvXMLImportContextRef SdXMLMasterPageContext::CreateChildContext( if(xNotesDrawPage.is()) { // presentation:notes inside master-page context - xContext = new SdXMLNotesContext( GetSdImport(), nPrefix, rLocalName, xAttrList, xNotesDrawPage); + return new SdXMLNotesContext( GetSdImport(), xAttrList, xNotesDrawPage); } } } } } - - // call base class - if (!xContext) - xContext = SdXMLGenericPageContext::CreateChildContext(nPrefix, rLocalName, xAttrList); - - return xContext; + return SdXMLGenericPageContext::createFastChildContext(nElement, xAttrList); } SdXMLStylesContext::SdXMLStylesContext( @@ -1388,21 +1395,10 @@ SdXMLMasterStylesContext::SdXMLMasterStylesContext( } css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLMasterStylesContext::createFastChildContext( - sal_Int32 /*nElement*/, - const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - return nullptr; -} - -SvXMLImportContextRef SdXMLMasterStylesContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList >& xAttrList) -{ - SvXMLImportContextRef xContext; - - if(nPrefix == XML_NAMESPACE_STYLE - && IsXMLToken( rLocalName, XML_MASTER_PAGE ) ) + if( nElement == XML_ELEMENT(STYLE, XML_MASTER_PAGE) ) { // style:masterpage inside office:styles context uno::Reference< drawing::XDrawPage > xNewMasterPage; @@ -1432,15 +1428,14 @@ SvXMLImportContextRef SdXMLMasterStylesContext::CreateChildContext( { const rtl::Reference<SdXMLMasterPageContext> xLclContext{ new SdXMLMasterPageContext(GetSdImport(), - nPrefix, rLocalName, xAttrList, xNewMasterPage)}; - xContext = xLclContext.get(); + nElement, xAttrList, xNewMasterPage)}; maMasterPageList.push_back(xLclContext); + return xLclContext.get(); } } } } - else if(nPrefix == XML_NAMESPACE_STYLE - && IsXMLToken( rLocalName, XML_HANDOUT_MASTER ) ) + else if( nElement == XML_ELEMENT(STYLE, XML_HANDOUT_MASTER) ) { uno::Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetSdImport().GetModel(), uno::UNO_QUERY ); if( xHandoutSupp.is() ) @@ -1448,12 +1443,22 @@ SvXMLImportContextRef SdXMLMasterStylesContext::CreateChildContext( uno::Reference< drawing::XShapes > xHandoutPage = xHandoutSupp->getHandoutMasterPage(); if(xHandoutPage.is() && GetSdImport().GetShapeImport()->GetStylesContext()) { - xContext = new SdXMLMasterPageContext(GetSdImport(), - nPrefix, rLocalName, xAttrList, xHandoutPage); + return new SdXMLMasterPageContext(GetSdImport(), + nElement, xAttrList, xHandoutPage); } } } - else if( (nPrefix == XML_NAMESPACE_DRAW )&& IsXMLToken( rLocalName, XML_LAYER_SET ) ) + return nullptr; +} + +SvXMLImportContextRef SdXMLMasterStylesContext::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList) +{ + SvXMLImportContextRef xContext; + + if( (nPrefix == XML_NAMESPACE_DRAW) && IsXMLToken( rLocalName, XML_LAYER_SET ) ) { xContext = new SdXMLLayerSetContext( GetImport(), nPrefix, rLocalName, xAttrList ); } |