summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-11-20 15:07:42 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-11-21 07:06:11 +0100
commitd0a60f7785dc66e0d491b50e093ebcf606627226 (patch)
tree24bebb09abae30dba9ad07a3b0c347d5c37fbf64
parent8c14adfa76956e76bac98330ce67f080c90af184 (diff)
fastparser in XMLEventsImportContext
Change-Id: Ifeeb2220ec6dfe6ec91f238137796d7d9e517465 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106261 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--include/xmloff/XMLEventsImportContext.hxx19
-rw-r--r--include/xmloff/xmlevent.hxx4
-rw-r--r--xmloff/inc/XMLEventImportHelper.hxx4
-rw-r--r--xmloff/inc/XMLScriptContextFactory.hxx2
-rw-r--r--xmloff/inc/XMLStarBasicContextFactory.hxx2
-rw-r--r--xmloff/source/script/XMLEventImportHelper.cxx2
-rw-r--r--xmloff/source/script/XMLEventsImportContext.cxx78
-rw-r--r--xmloff/source/script/XMLScriptContextFactory.cxx21
-rw-r--r--xmloff/source/script/XMLStarBasicContextFactory.cxx21
-rw-r--r--xmloff/source/text/XMLAutoTextContainerEventImport.cxx3
-rw-r--r--xmloff/source/text/XMLTextFrameContext.cxx3
-rw-r--r--xmloff/source/text/txtparai.cxx3
12 files changed, 23 insertions, 139 deletions
diff --git a/include/xmloff/XMLEventsImportContext.hxx b/include/xmloff/XMLEventsImportContext.hxx
index 36b18f86fd90..dc03d91a61ab 100644
--- a/include/xmloff/XMLEventsImportContext.hxx
+++ b/include/xmloff/XMLEventsImportContext.hxx
@@ -59,28 +59,14 @@ protected:
public:
-
- XMLEventsImportContext(
- SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLocalName);
-
XMLEventsImportContext(SvXMLImport& rImport);
XMLEventsImportContext(
SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLocalName,
const css::uno::Reference<css::document::XEventsSupplier> & xEventsSupplier);
XMLEventsImportContext(
SvXMLImport& rImport,
- const css::uno::Reference<css::document::XEventsSupplier> & xEventsSupplier);
-
- XMLEventsImportContext(
- SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLocalName,
const css::uno::Reference<css::container::XNameReplace> & xNameRepl);
virtual ~XMLEventsImportContext() override;
@@ -107,11 +93,6 @@ public:
protected:
- 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;
};
diff --git a/include/xmloff/xmlevent.hxx b/include/xmloff/xmlevent.hxx
index c212e4415e73..900a03694ae7 100644
--- a/include/xmloff/xmlevent.hxx
+++ b/include/xmloff/xmlevent.hxx
@@ -33,7 +33,7 @@ namespace com::sun::star::uno { template <typename > class Sequence; }
*/
namespace com::sun::star {
- namespace xml::sax { class XAttributeList; }
+ namespace xml::sax { class XFastAttributeList; }
namespace beans { struct PropertyValue; }
}
@@ -128,7 +128,7 @@ public:
virtual SvXMLImportContext* CreateContext(
SvXMLImport& rImport, /// import context
- const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList, /// attribute list
+ const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList, /// attribute list
/// the context for the enclosing <script:events> element
XMLEventsImportContext* rEvents,
/// the event name (as understood by the API)
diff --git a/xmloff/inc/XMLEventImportHelper.hxx b/xmloff/inc/XMLEventImportHelper.hxx
index d2514ebe46b6..0f0c15b292c5 100644
--- a/xmloff/inc/XMLEventImportHelper.hxx
+++ b/xmloff/inc/XMLEventImportHelper.hxx
@@ -29,7 +29,7 @@
namespace com::sun::star {
- namespace xml::sax { class XAttributeList; }
+ namespace xml::sax { class XFastAttributeList; }
}
class XMLEventContextFactory;
class XMLEventsImportContext;
@@ -84,7 +84,7 @@ public:
/// create an appropriate import context for a particular event
SvXMLImportContext* CreateContext(
SvXMLImport& rImport,
- const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList> & xAttrList,
XMLEventsImportContext* rEvents,
const OUString& rXmlEventName,
const OUString& rLanguage);
diff --git a/xmloff/inc/XMLScriptContextFactory.hxx b/xmloff/inc/XMLScriptContextFactory.hxx
index cd4ade05b848..53317c4bb0c8 100644
--- a/xmloff/inc/XMLScriptContextFactory.hxx
+++ b/xmloff/inc/XMLScriptContextFactory.hxx
@@ -39,7 +39,7 @@ public:
virtual SvXMLImportContext *
CreateContext(SvXMLImport & rImport, /// import context
/// attribute list
- const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList> & xAttrList,
/// the context for the enclosing <script:events> element
XMLEventsImportContext * rEvents,
/// the event name (as understood by the API)
diff --git a/xmloff/inc/XMLStarBasicContextFactory.hxx b/xmloff/inc/XMLStarBasicContextFactory.hxx
index 12daf023b065..b375f546bb4c 100644
--- a/xmloff/inc/XMLStarBasicContextFactory.hxx
+++ b/xmloff/inc/XMLStarBasicContextFactory.hxx
@@ -39,7 +39,7 @@ public:
virtual SvXMLImportContext* CreateContext(
SvXMLImport& rImport, /// import context
- const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList,/// attribute list
+ const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList,/// attribute list
/// the context for the enclosing <script:events> element
XMLEventsImportContext* rEvents,
/// the event name (as understood by the API)
diff --git a/xmloff/source/script/XMLEventImportHelper.cxx b/xmloff/source/script/XMLEventImportHelper.cxx
index 12c8237f158a..18b795ee1f3d 100644
--- a/xmloff/source/script/XMLEventImportHelper.cxx
+++ b/xmloff/source/script/XMLEventImportHelper.cxx
@@ -99,7 +99,7 @@ void XMLEventImportHelper::PopTranslationTable()
SvXMLImportContext* XMLEventImportHelper::CreateContext(
SvXMLImport& rImport,
- const Reference<XAttributeList> & xAttrList,
+ const Reference<css::xml::sax::XFastAttributeList> & xAttrList,
XMLEventsImportContext* rEvents,
const OUString& rXmlEventName,
const OUString& rLanguage)
diff --git a/xmloff/source/script/XMLEventsImportContext.cxx b/xmloff/source/script/XMLEventsImportContext.cxx
index 012156831671..f128cfa625f9 100644
--- a/xmloff/source/script/XMLEventsImportContext.cxx
+++ b/xmloff/source/script/XMLEventsImportContext.cxx
@@ -39,14 +39,6 @@ using ::com::sun::star::document::XEventsSupplier;
using ::com::sun::star::lang::IllegalArgumentException;
-XMLEventsImportContext::XMLEventsImportContext(
- SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLocalName) :
- SvXMLImportContext(rImport, nPrfx, rLocalName)
-{
-}
-
XMLEventsImportContext::XMLEventsImportContext(SvXMLImport& rImport) :
SvXMLImportContext(rImport)
{
@@ -55,16 +47,6 @@ XMLEventsImportContext::XMLEventsImportContext(SvXMLImport& rImport) :
XMLEventsImportContext::XMLEventsImportContext(
SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLocalName,
- const Reference<XEventsSupplier> & xEventsSupplier) :
- SvXMLImportContext(rImport, nPrfx, rLocalName),
- xEvents(xEventsSupplier->getEvents())
-{
-}
-
-XMLEventsImportContext::XMLEventsImportContext(
- SvXMLImport& rImport,
const Reference<XEventsSupplier> & xEventsSupplier) :
SvXMLImportContext(rImport),
xEvents(xEventsSupplier->getEvents())
@@ -74,10 +56,8 @@ XMLEventsImportContext::XMLEventsImportContext(
XMLEventsImportContext::XMLEventsImportContext(
SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLocalName,
const Reference<XNameReplace> & xNameReplace) :
- SvXMLImportContext(rImport, nPrfx, rLocalName),
+ SvXMLImportContext(rImport),
xEvents(xNameReplace)
{
}
@@ -89,47 +69,6 @@ XMLEventsImportContext::~XMLEventsImportContext()
}
-SvXMLImportContextRef XMLEventsImportContext::CreateChildContext(
- sal_uInt16 /*p_nPrefix*/,
- const OUString& /*rLocalName*/,
- const Reference<XAttributeList> & xAttrList )
-{
- // a) search for script:language and script:event-name attribute
- // b) delegate to factory. The factory will:
- // 1) translate XML event name into API event name
- // 2) get proper event context factory from import
- // 3) instantiate context
-
- // a) search for script:language and script:event-name attribute
- OUString sLanguage;
- OUString sEventName;
- sal_Int16 nCount = xAttrList->getLength();
- for (sal_Int16 nAttr = 0; nAttr < nCount; nAttr++)
- {
- OUString sLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
- GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), &sLocalName );
-
- if (XML_NAMESPACE_SCRIPT == nPrefix)
- {
- if (IsXMLToken(sLocalName, XML_EVENT_NAME))
- {
- sEventName = xAttrList->getValueByIndex(nAttr);
- }
- else if (IsXMLToken(sLocalName, XML_LANGUAGE))
- {
- sLanguage = xAttrList->getValueByIndex(nAttr);
- }
- // else: ignore -> let child context handle this
- }
- // else: ignore -> let child context handle this
- }
-
- // b) delegate to factory
- return GetImport().GetEventImport().CreateContext(
- GetImport(), xAttrList, this, sEventName, sLanguage);
-}
-
css::uno::Reference< css::xml::sax::XFastContextHandler > XMLEventsImportContext::createFastChildContext(
sal_Int32 /*nElement*/,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
@@ -159,22 +98,9 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLEventsImportContext
// else: ignore -> let child context handle this
}
- rtl::Reference < comphelper::AttributeList > rAttrList = new comphelper::AttributeList;
- const Sequence< css::xml::FastAttribute > fastAttribs = xAttrList->getFastAttributes();
- for (const auto& rAttr : fastAttribs)
- {
- const OUString& rAttrValue = rAttr.Value;
- sal_Int32 nToken = rAttr.Token;
- const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken( nToken, nullptr );
- OUString sAttrName = SvXMLImport::getNameFromToken( nToken );
- if ( !rAttrNamespacePrefix.isEmpty() )
- sAttrName = rAttrNamespacePrefix + ":" + sAttrName;
- rAttrList->AddAttribute( sAttrName, "CDATA", rAttrValue );
- }
-
// b) delegate to factory
return GetImport().GetEventImport().CreateContext(
- GetImport(), rAttrList.get(), this, sEventName, sLanguage);
+ GetImport(), xAttrList, this, sEventName, sLanguage);
}
void XMLEventsImportContext::SetEvents(
diff --git a/xmloff/source/script/XMLScriptContextFactory.cxx b/xmloff/source/script/XMLScriptContextFactory.cxx
index 1792b88d2207..3b535771470f 100644
--- a/xmloff/source/script/XMLScriptContextFactory.cxx
+++ b/xmloff/source/script/XMLScriptContextFactory.cxx
@@ -26,7 +26,7 @@
using namespace ::xmloff::token;
-using ::com::sun::star::xml::sax::XAttributeList;
+using ::com::sun::star::xml::sax::XFastAttributeList;
using ::com::sun::star::beans::PropertyValue;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -40,25 +40,16 @@ XMLScriptContextFactory::XMLScriptContextFactory() {}
XMLScriptContextFactory::~XMLScriptContextFactory() {}
SvXMLImportContext* XMLScriptContextFactory::CreateContext(
- SvXMLImport& rImport, const Reference<XAttributeList>& xAttrList,
+ SvXMLImport& rImport, const Reference<XFastAttributeList>& xAttrList,
XMLEventsImportContext* rEvents, const OUString& rApiEventName)
{
OUString sURLVal;
- sal_Int16 nCount = xAttrList->getLength();
- for (sal_Int16 nAttr = 0; nAttr < nCount; nAttr++)
+ for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList))
{
- OUString sLocalName;
- sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(
- xAttrList->getNameByIndex(nAttr), &sLocalName);
-
- if (XML_NAMESPACE_XLINK == nPrefix)
- {
- if (IsXMLToken(sLocalName, XML_HREF))
- sURLVal = xAttrList->getValueByIndex(nAttr);
- // else: ignore
- }
- // else ignore
+ if (aIter.getToken() == XML_ELEMENT(XLINK, XML_HREF))
+ sURLVal = aIter.toString();
+ // else: ignore
}
Sequence<PropertyValue> aValues(2);
diff --git a/xmloff/source/script/XMLStarBasicContextFactory.cxx b/xmloff/source/script/XMLStarBasicContextFactory.cxx
index 4c384f98acc6..a0c9d7b0c193 100644
--- a/xmloff/source/script/XMLStarBasicContextFactory.cxx
+++ b/xmloff/source/script/XMLStarBasicContextFactory.cxx
@@ -27,7 +27,7 @@
using namespace ::xmloff::token;
-using ::com::sun::star::xml::sax::XAttributeList;
+using ::com::sun::star::xml::sax::XFastAttributeList;
using ::com::sun::star::beans::PropertyValue;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -48,28 +48,17 @@ XMLStarBasicContextFactory::~XMLStarBasicContextFactory()
SvXMLImportContext* XMLStarBasicContextFactory::CreateContext(
SvXMLImport& rImport,
- const Reference<XAttributeList> & xAttrList,
+ const Reference<XFastAttributeList> & xAttrList,
XMLEventsImportContext* rEvents,
const OUString& rApiEventName)
{
OUString sLibraryVal;
OUString sMacroNameVal;
- sal_Int16 nCount = xAttrList->getLength();
- for(sal_Int16 nAttr = 0; nAttr < nCount; nAttr++)
+ for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
{
- OUString sLocalName;
- sal_uInt16 nPrefix = rImport.GetNamespaceMap().
- GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), &sLocalName );
-
- if (XML_NAMESPACE_SCRIPT == nPrefix)
- {
- if (IsXMLToken(sLocalName, XML_MACRO_NAME))
- {
- sMacroNameVal = xAttrList->getValueByIndex(nAttr);
- }
- // else: ignore
- }
+ if (aIter.getToken() == XML_ELEMENT(SCRIPT, XML_MACRO_NAME))
+ sMacroNameVal = aIter.toString();
// else: ignore
}
diff --git a/xmloff/source/text/XMLAutoTextContainerEventImport.cxx b/xmloff/source/text/XMLAutoTextContainerEventImport.cxx
index 5167bd3fadcb..1c9bc76eaaa1 100644
--- a/xmloff/source/text/XMLAutoTextContainerEventImport.cxx
+++ b/xmloff/source/text/XMLAutoTextContainerEventImport.cxx
@@ -56,8 +56,7 @@ SvXMLImportContextRef XMLAutoTextContainerEventImport::CreateChildContext(
if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
IsXMLToken( rLocalName, XML_EVENT_LISTENERS) )
{
- return new XMLEventsImportContext(GetImport(), nPrefix, rLocalName,
- rEvents);
+ return new XMLEventsImportContext(GetImport(), rEvents);
}
return nullptr;
}
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx
index f9417c264806..08ad2d7dc489 100644
--- a/xmloff/source/text/XMLTextFrameContext.cxx
+++ b/xmloff/source/text/XMLTextFrameContext.cxx
@@ -1651,8 +1651,7 @@ SvXMLImportContextRef XMLTextFrameContext::CreateChildContext(
if (xEventsSupplier.is())
{
// OK, we have the events, so create the context
- xContext = new XMLEventsImportContext(GetImport(), p_nPrefix,
- rLocalName, xEventsSupplier);
+ xContext = new XMLEventsImportContext(GetImport(), xEventsSupplier);
}
}
}
diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx
index 7546d4b40eb2..d8e0812bee0c 100644
--- a/xmloff/source/text/txtparai.cxx
+++ b/xmloff/source/text/txtparai.cxx
@@ -502,8 +502,7 @@ SvXMLImportContextRef XMLImpHyperlinkContext_Impl::CreateChildContext(
if ( (nPrefix == XML_NAMESPACE_OFFICE) &&
IsXMLToken(rLocalName, XML_EVENT_LISTENERS) )
{
- XMLEventsImportContext* pCtxt = new XMLEventsImportContext(
- GetImport(), nPrefix, rLocalName);
+ XMLEventsImportContext* pCtxt = new XMLEventsImportContext(GetImport());
if (mpHint)
mpHint->SetEventsContext(pCtxt);
return pCtxt;