diff options
-rw-r--r-- | include/xmloff/txtimp.hxx | 6 | ||||
-rw-r--r-- | xmloff/source/text/XMLChangeElementImportContext.cxx | 16 | ||||
-rw-r--r-- | xmloff/source/text/XMLChangeElementImportContext.hxx | 9 | ||||
-rw-r--r-- | xmloff/source/text/XMLChangeInfoContext.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/text/XMLChangeInfoContext.hxx | 2 | ||||
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 43 |
6 files changed, 60 insertions, 20 deletions
diff --git a/include/xmloff/txtimp.hxx b/include/xmloff/txtimp.hxx index 94d1d6580ab2..bdd0e169c9d1 100644 --- a/include/xmloff/txtimp.hxx +++ b/include/xmloff/txtimp.hxx @@ -59,6 +59,7 @@ namespace frame { class XModel; } namespace container { class XNameContainer; class XIndexReplace; } namespace beans { class XPropertySet; } namespace xml::sax { class XAttributeList; } +namespace xml::sax { class XFastAttributeList; } namespace util { struct DateTime; } } @@ -397,6 +398,11 @@ public: SvXMLImportContext *CreateTextChildContext( SvXMLImport& rImport, + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList, + XMLTextType eType = XMLTextType::Shape ); + SvXMLImportContext *CreateTextChildContext( + SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList, XMLTextType eType = XMLTextType::Shape ); diff --git a/xmloff/source/text/XMLChangeElementImportContext.cxx b/xmloff/source/text/XMLChangeElementImportContext.cxx index a3bce265ae43..4fc81a755eda 100644 --- a/xmloff/source/text/XMLChangeElementImportContext.cxx +++ b/xmloff/source/text/XMLChangeElementImportContext.cxx @@ -44,17 +44,15 @@ XMLChangeElementImportContext::XMLChangeElementImportContext( { } -SvXMLImportContextRef XMLChangeElementImportContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference<XAttributeList> & xAttrList) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLChangeElementImportContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContextRef xContext; - if ( (XML_NAMESPACE_OFFICE == nPrefix) && - IsXMLToken( rLocalName, XML_CHANGE_INFO) ) + if ( nElement == XML_ELEMENT(OFFICE, XML_CHANGE_INFO) ) { - xContext = new XMLChangeInfoContext(GetImport(), nPrefix, rLocalName, + xContext = new XMLChangeInfoContext(GetImport(), rChangedRegion, maType); } else @@ -63,7 +61,7 @@ SvXMLImportContextRef XMLChangeElementImportContext::CreateChildContext( rChangedRegion.UseRedlineText(); xContext = GetImport().GetTextImport()->CreateTextChildContext( - GetImport(), nPrefix, rLocalName, xAttrList, + GetImport(), nElement, xAttrList, XMLTextType::ChangedRegion); if (!xContext) @@ -74,7 +72,7 @@ SvXMLImportContextRef XMLChangeElementImportContext::CreateChildContext( } } - return xContext; + return xContext.get(); } void XMLChangeElementImportContext::startFastElement( sal_Int32, const Reference< css::xml::sax::XFastAttributeList >& ) diff --git a/xmloff/source/text/XMLChangeElementImportContext.hxx b/xmloff/source/text/XMLChangeElementImportContext.hxx index e43e86248224..fb7bef4aa13f 100644 --- a/xmloff/source/text/XMLChangeElementImportContext.hxx +++ b/xmloff/source/text/XMLChangeElementImportContext.hxx @@ -37,7 +37,7 @@ class XMLChangedRegionImportContext; * Import <text:deletion> and <text:insertion> elements contained in a * <text:changed-region> element. */ -class XMLChangeElementImportContext : public SvXMLImportContext + class XMLChangeElementImportContext : public SvXMLImportContext { /** * accept text content (paragraphs) in element as redline content? @@ -60,7 +60,6 @@ class XMLChangeElementImportContext : public SvXMLImportContext public: - XMLChangeElementImportContext( SvXMLImport& rImport, /// accept text content (paragraphs) in element as redline content? @@ -69,10 +68,8 @@ public: XMLChangedRegionImportContext& rParent, OUString const & rType); - virtual SvXMLImportContextRef CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; // Start- and EndElement are needed here to set the inside_deleted_section // flag at the corresponding TextImportHelper diff --git a/xmloff/source/text/XMLChangeInfoContext.cxx b/xmloff/source/text/XMLChangeInfoContext.cxx index fd51c12f55d5..c49dc1889832 100644 --- a/xmloff/source/text/XMLChangeInfoContext.cxx +++ b/xmloff/source/text/XMLChangeInfoContext.cxx @@ -35,11 +35,9 @@ using ::com::sun::star::xml::sax::XAttributeList; XMLChangeInfoContext::XMLChangeInfoContext( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, XMLChangedRegionImportContext& rPParent, const OUString& rChangeType) -: SvXMLImportContext(rImport, nPrefix, rLocalName) +: SvXMLImportContext(rImport) , rType(rChangeType) , rChangedRegion(rPParent) { diff --git a/xmloff/source/text/XMLChangeInfoContext.hxx b/xmloff/source/text/XMLChangeInfoContext.hxx index 1c2d9356c284..8d1f3965e283 100644 --- a/xmloff/source/text/XMLChangeInfoContext.hxx +++ b/xmloff/source/text/XMLChangeInfoContext.hxx @@ -53,8 +53,6 @@ public: XMLChangeInfoContext( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, XMLChangedRegionImportContext& rChangedRegion, const OUString& rChangeType); diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index f37e571ab51b..88695e599a8b 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -69,6 +69,7 @@ #include <com/sun/star/beans/XPropertyState.hpp> #include <txtlists.hxx> #include <xmloff/odffields.hxx> +#include <comphelper/attributelist.hxx> using ::com::sun::star::ucb::XAnyCompare; @@ -2134,6 +2135,48 @@ void XMLTextImportHelper::SetAutoStyles( SvXMLStylesContext *pStyles ) SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( SvXMLImport& rImport, + sal_Int32 Element, + const Reference< XFastAttributeList > & Attribs, + XMLTextType eType ) +{ + // fall back to slow-parser path + const OUString& rPrefix = SvXMLImport::getNamespacePrefixFromToken(Element, &GetXMLImport().GetNamespaceMap()); + const OUString& rLocalName = SvXMLImport::getNameFromToken( Element ); + OUString aName = rPrefix.isEmpty() ? rLocalName : rPrefix + SvXMLImport::aNamespaceSeparator + rLocalName; + OUString aLocalName; + sal_uInt16 nPrefix = + GetXMLImport().GetNamespaceMap().GetKeyByAttrName( aName, &aLocalName ); + + rtl::Reference < comphelper::AttributeList > maAttrList = new comphelper::AttributeList(); + + if ( Attribs.is() ) + { + for( auto &it : sax_fastparser::castToFastAttributeList( Attribs ) ) + { + sal_Int32 nToken = it.getToken(); + const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken(nToken, &GetXMLImport().GetNamespaceMap()); + OUString sAttrName = SvXMLImport::getNameFromToken( nToken ); + if ( !rAttrNamespacePrefix.isEmpty() ) + sAttrName = rAttrNamespacePrefix + SvXMLImport::aNamespaceSeparator + sAttrName; + + maAttrList->AddAttribute( sAttrName, "CDATA", it.toString() ); + } + + const uno::Sequence< xml::Attribute > unknownAttribs = Attribs->getUnknownAttributes(); + for ( const auto& rUnknownAttrib : unknownAttribs ) + { + const OUString& rAttrValue = rUnknownAttrib.Value; + const OUString& rAttrName = rUnknownAttrib.Name; + // note: rAttrName is expected to be namespace-prefixed here + maAttrList->AddAttribute( rAttrName, "CDATA", rAttrValue ); + } + } + + return CreateTextChildContext(rImport, nPrefix, aLocalName, maAttrList.get(), eType ); +} + +SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( + SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList > & xAttrList, XMLTextType eType ) |