summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/xmloff/XMLEventsImportContext.hxx12
-rw-r--r--include/xmloff/xmlevent.hxx2
-rw-r--r--include/xmloff/xmlscripti.hxx5
-rw-r--r--xmloff/inc/XMLEventImportHelper.hxx2
-rw-r--r--xmloff/inc/XMLScriptContextFactory.hxx2
-rw-r--r--xmloff/inc/XMLStarBasicContextFactory.hxx2
-rw-r--r--xmloff/source/script/XMLEventImportHelper.cxx6
-rw-r--r--xmloff/source/script/XMLEventsImportContext.cxx76
-rw-r--r--xmloff/source/script/XMLScriptContextFactory.cxx4
-rw-r--r--xmloff/source/script/XMLStarBasicContextFactory.cxx4
-rw-r--r--xmloff/source/script/xmlscripti.cxx21
11 files changed, 92 insertions, 44 deletions
diff --git a/include/xmloff/XMLEventsImportContext.hxx b/include/xmloff/XMLEventsImportContext.hxx
index 0dd1a0194f4b..4b843015fa14 100644
--- a/include/xmloff/XMLEventsImportContext.hxx
+++ b/include/xmloff/XMLEventsImportContext.hxx
@@ -75,6 +75,10 @@ public:
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);
@@ -112,6 +116,14 @@ protected:
sal_uInt16 nPrefix,
const OUString& rLocalName,
const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList ) override;
+
+ virtual void SAL_CALL startFastElement( sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override;
+
+ virtual void SAL_CALL endFastElement( sal_Int32 nElement ) 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;
};
#endif
diff --git a/include/xmloff/xmlevent.hxx b/include/xmloff/xmlevent.hxx
index 433d9b076201..ebbd400755fc 100644
--- a/include/xmloff/xmlevent.hxx
+++ b/include/xmloff/xmlevent.hxx
@@ -128,8 +128,6 @@ public:
virtual SvXMLImportContext* CreateContext(
SvXMLImport& rImport, /// import context
- sal_uInt16 nPrefix, /// element: namespace prefix
- const OUString& rLocalName, /// element: local name
const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList, /// attribute list
/// the context for the enclosing <script:events> element
XMLEventsImportContext* rEvents,
diff --git a/include/xmloff/xmlscripti.hxx b/include/xmloff/xmlscripti.hxx
index 75b7115df526..06d2e3fcaafa 100644
--- a/include/xmloff/xmlscripti.hxx
+++ b/include/xmloff/xmlscripti.hxx
@@ -38,11 +38,6 @@ public:
const css::uno::Reference< css::frame::XModel>& rDocModel );
virtual ~XMLScriptContext() override;
- // Create child element.
- 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/xmloff/inc/XMLEventImportHelper.hxx b/xmloff/inc/XMLEventImportHelper.hxx
index 6e4c8dce9fd6..ddc696b3d772 100644
--- a/xmloff/inc/XMLEventImportHelper.hxx
+++ b/xmloff/inc/XMLEventImportHelper.hxx
@@ -84,8 +84,6 @@ public:
/// create an appropriate import context for a particular event
SvXMLImportContext* CreateContext(
SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList,
XMLEventsImportContext* rEvents,
const OUString& rXmlEventName,
diff --git a/xmloff/inc/XMLScriptContextFactory.hxx b/xmloff/inc/XMLScriptContextFactory.hxx
index 8b0e57b6d5c7..de0eed0a67e1 100644
--- a/xmloff/inc/XMLScriptContextFactory.hxx
+++ b/xmloff/inc/XMLScriptContextFactory.hxx
@@ -38,8 +38,6 @@ public:
virtual SvXMLImportContext *
CreateContext(SvXMLImport & rImport, /// import context
- sal_uInt16 nPrefix, /// element: namespace prefix
- const OUString & rLocalName, /// element: local name
/// attribute list
const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList,
/// the context for the enclosing <script:events> element
diff --git a/xmloff/inc/XMLStarBasicContextFactory.hxx b/xmloff/inc/XMLStarBasicContextFactory.hxx
index 3c708fe9cda7..b000a9f9c728 100644
--- a/xmloff/inc/XMLStarBasicContextFactory.hxx
+++ b/xmloff/inc/XMLStarBasicContextFactory.hxx
@@ -39,8 +39,6 @@ public:
virtual SvXMLImportContext* CreateContext(
SvXMLImport& rImport, /// import context
- sal_uInt16 nPrefix, /// element: namespace prefix
- const OUString& rLocalName, /// element: local name
const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList,/// attribute list
/// the context for the enclosing <script:events> element
XMLEventsImportContext* rEvents,
diff --git a/xmloff/source/script/XMLEventImportHelper.cxx b/xmloff/source/script/XMLEventImportHelper.cxx
index bbdb65ecbcd0..f657198dc910 100644
--- a/xmloff/source/script/XMLEventImportHelper.cxx
+++ b/xmloff/source/script/XMLEventImportHelper.cxx
@@ -99,8 +99,6 @@ void XMLEventImportHelper::PopTranslationTable()
SvXMLImportContext* XMLEventImportHelper::CreateContext(
SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
const Reference<XAttributeList> & xAttrList,
XMLEventsImportContext* rEvents,
const OUString& rXmlEventName,
@@ -132,7 +130,7 @@ SvXMLImportContext* XMLEventImportHelper::CreateContext(
{
// delegate to factory
pContext = aFactoryIterator->second->CreateContext(
- rImport, nPrefix, rLocalName, xAttrList,
+ rImport, xAttrList,
rEvents, aNameIter->second);
}
}
@@ -140,7 +138,7 @@ SvXMLImportContext* XMLEventImportHelper::CreateContext(
// default context (if no context was created above)
if( nullptr == pContext )
{
- pContext = new SvXMLImportContext(rImport, nPrefix, rLocalName);
+ pContext = new SvXMLImportContext(rImport);
Sequence<OUString> aMsgParams(2);
diff --git a/xmloff/source/script/XMLEventsImportContext.cxx b/xmloff/source/script/XMLEventsImportContext.cxx
index aea5eb9e62ac..d58be893909a 100644
--- a/xmloff/source/script/XMLEventsImportContext.cxx
+++ b/xmloff/source/script/XMLEventsImportContext.cxx
@@ -22,6 +22,7 @@
#include <XMLEventImportHelper.hxx>
#include <com/sun/star/document/XEventsSupplier.hpp>
+#include <comphelper/attributelist.hxx>
#include <xmloff/xmlimp.hxx>
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmlnmspe.hxx>
@@ -57,6 +58,14 @@ XMLEventsImportContext::XMLEventsImportContext(
{
}
+XMLEventsImportContext::XMLEventsImportContext(
+ SvXMLImport& rImport,
+ const Reference<XEventsSupplier> & xEventsSupplier) :
+ SvXMLImportContext(rImport),
+ xEvents(xEventsSupplier->getEvents())
+{
+}
+
XMLEventsImportContext::XMLEventsImportContext(
SvXMLImport& rImport,
@@ -87,8 +96,8 @@ void XMLEventsImportContext::EndElement()
}
SvXMLImportContextRef XMLEventsImportContext::CreateChildContext(
- sal_uInt16 p_nPrefix,
- const OUString& rLocalName,
+ sal_uInt16 /*p_nPrefix*/,
+ const OUString& /*rLocalName*/,
const Reference<XAttributeList> & xAttrList )
{
// a) search for script:language and script:event-name attribute
@@ -124,8 +133,67 @@ SvXMLImportContextRef XMLEventsImportContext::CreateChildContext(
// b) delegate to factory
return GetImport().GetEventImport().CreateContext(
- GetImport(), p_nPrefix, rLocalName, xAttrList,
- this, sEventName, sLanguage);
+ GetImport(), xAttrList, this, sEventName, sLanguage);
+}
+
+void XMLEventsImportContext::startFastElement(sal_Int32 /*nElement*/,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >&)
+{
+ // nothing to be done
+}
+
+void XMLEventsImportContext::endFastElement(sal_Int32 /*nElement*/)
+{
+ // nothing to be done
+}
+
+css::uno::Reference< css::xml::sax::XFastContextHandler > XMLEventsImportContext::createFastChildContext(
+ sal_Int32 /*nElement*/,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& 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;
+ sax_fastparser::FastAttributeList *pAttribList =
+ sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
+ for (auto &aIter : *pAttribList)
+ {
+ OUString sValue = aIter.toString();
+
+ if (aIter.getToken() == XML_ELEMENT(SCRIPT, XML_EVENT_NAME))
+ {
+ sEventName = sValue;
+ }
+ else if (aIter.getToken() == XML_ELEMENT(SCRIPT, XML_EVENT_NAME))
+ {
+ sLanguage = sValue;
+ // else: ignore -> let child context handle this
+ }
+ // 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);
}
void XMLEventsImportContext::SetEvents(
diff --git a/xmloff/source/script/XMLScriptContextFactory.cxx b/xmloff/source/script/XMLScriptContextFactory.cxx
index 35b13d0ed95a..da44c70d7d01 100644
--- a/xmloff/source/script/XMLScriptContextFactory.cxx
+++ b/xmloff/source/script/XMLScriptContextFactory.cxx
@@ -46,8 +46,6 @@ XMLScriptContextFactory::~XMLScriptContextFactory()
SvXMLImportContext * XMLScriptContextFactory::CreateContext
(SvXMLImport & rImport,
- sal_uInt16 p_nPrefix,
- const OUString & rLocalName,
const Reference<XAttributeList> & xAttrList,
XMLEventsImportContext * rEvents,
const OUString & rApiEventName)
@@ -84,7 +82,7 @@ SvXMLImportContext * XMLScriptContextFactory::CreateContext
rEvents->AddEventValues(rApiEventName, aValues);
// return dummy context
- return new SvXMLImportContext(rImport, p_nPrefix, rLocalName);
+ return new SvXMLImportContext(rImport);
}
diff --git a/xmloff/source/script/XMLStarBasicContextFactory.cxx b/xmloff/source/script/XMLStarBasicContextFactory.cxx
index 15c7464bea80..7f76539789a0 100644
--- a/xmloff/source/script/XMLStarBasicContextFactory.cxx
+++ b/xmloff/source/script/XMLStarBasicContextFactory.cxx
@@ -48,8 +48,6 @@ XMLStarBasicContextFactory::~XMLStarBasicContextFactory()
SvXMLImportContext* XMLStarBasicContextFactory::CreateContext(
SvXMLImport& rImport,
- sal_uInt16 p_nPrefix,
- const OUString& rLocalName,
const Reference<XAttributeList> & xAttrList,
XMLEventsImportContext* rEvents,
const OUString& rApiEventName)
@@ -110,7 +108,7 @@ SvXMLImportContext* XMLStarBasicContextFactory::CreateContext(
rEvents->AddEventValues(rApiEventName, aValues);
// return dummy context
- return new SvXMLImportContext(rImport, p_nPrefix, rLocalName);
+ return new SvXMLImportContext(rImport);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/script/xmlscripti.cxx b/xmloff/source/script/xmlscripti.cxx
index 1cee9101a080..3820ab14e97e 100644
--- a/xmloff/source/script/xmlscripti.cxx
+++ b/xmloff/source/script/xmlscripti.cxx
@@ -122,26 +122,13 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLScriptContext::crea
return new XMLScriptChildContext( GetImport(), m_xModel, aLanguage );
}
}
- return nullptr;
-}
-
-SvXMLImportContextRef XMLScriptContext::CreateChildContext(
- sal_uInt16 nPrefix, const OUString& rLName,
- const Reference<XAttributeList>& /*xAttrList*/ )
-{
- SvXMLImportContextRef xContext;
-
- if ( nPrefix == XML_NAMESPACE_OFFICE )
+ else if ( nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) )
{
- if ( IsXMLToken( rLName, XML_EVENT_LISTENERS ) )
- {
- Reference< XEventsSupplier> xSupplier( GetImport().GetModel(), UNO_QUERY );
- xContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName, xSupplier );
- }
+ Reference< XEventsSupplier> xSupplier( GetImport().GetModel(), UNO_QUERY );
+ return new XMLEventsImportContext( GetImport(), xSupplier );
}
- return xContext;
+ return nullptr;
}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */