[Libreoffice-commits] core.git: dbaccess/source include/xmloff sc/source sw/source xmloff/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jan 21 07:22:07 UTC 2020
dbaccess/source/filter/xml/xmlfilter.cxx | 6 +-
include/xmloff/xmlscripti.hxx | 7 ++-
sc/source/filter/xml/xmlimprt.cxx | 13 ++---
sc/source/filter/xml/xmlimprt.hxx | 3 -
sw/source/filter/xml/xmlimp.cxx | 11 +++-
sw/source/filter/xml/xmlimp.hxx | 2
sw/source/filter/xml/xmlscript.cxx | 5 --
xmloff/source/draw/sdxmlimp.cxx | 23 +++++-----
xmloff/source/script/xmlscripti.cxx | 69 +++++++++++++++----------------
9 files changed, 72 insertions(+), 67 deletions(-)
New commits:
commit 5a73d3908c30c898a0f21208810332d36657adee
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jan 20 16:14:07 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jan 21 08:21:29 2020 +0100
use FastParser in XMLScriptContext
Change-Id: I7c5f5b77a78307c556ee5718480346ed3dd159fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87075
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx
index 96a34742fba0..b8a6cc215d26 100644
--- a/dbaccess/source/filter/xml/xmlfilter.cxx
+++ b/dbaccess/source/filter/xml/xmlfilter.cxx
@@ -512,9 +512,6 @@ public:
rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
pContext = rImport.CreateStylesContext(nPrefix, rLocalName, xAttrList, true);
break;
- case XML_TOK_CONTENT_SCRIPTS:
- pContext = new XMLScriptContext(GetImport(), rLocalName, rImport.GetModel());
- break;
default:
break;
}
@@ -533,6 +530,9 @@ public:
case XML_ELEMENT(OOO, XML_BODY):
return new DBXMLDocumentBodyContext(rImport);
break;
+ case XML_ELEMENT(OFFICE, XML_SCRIPTS):
+ return new XMLScriptContext(GetImport(), rImport.GetModel());
+ break;
default: break;
}
return nullptr;
diff --git a/include/xmloff/xmlscripti.hxx b/include/xmloff/xmlscripti.hxx
index 94034fe5cce0..75b7115df526 100644
--- a/include/xmloff/xmlscripti.hxx
+++ b/include/xmloff/xmlscripti.hxx
@@ -35,7 +35,6 @@ private:
public:
XMLScriptContext( SvXMLImport& rImport,
- const OUString& rLName,
const css::uno::Reference< css::frame::XModel>& rDocModel );
virtual ~XMLScriptContext() override;
@@ -44,7 +43,11 @@ public:
const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override;
- virtual void EndElement() 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;
+
+ virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {}
};
#endif // INCLUDED_XMLOFF_XMLSCRIPTI_HXX
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 2cb864cb56f5..da52b0424516 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -373,10 +373,6 @@ SvXMLImportContextRef ScXMLDocContext_Impl::CreateChildContext( sal_uInt16 nPref
case XML_TOK_DOC_META:
SAL_INFO("sc", "XML_TOK_DOC_META: should not have come here, maybe document is invalid?");
break;
- case XML_TOK_DOC_SCRIPTS:
- if (GetScImport().getImportFlags() & SvXMLImportFlags::SCRIPTS)
- pContext = GetScImport().CreateScriptContext( rLocalName );
- break;
case XML_TOK_DOC_SETTINGS:
if (GetScImport().getImportFlags() & SvXMLImportFlags::SETTINGS)
pContext = new XMLDocumentSettingsContext(GetScImport(), nPrefix, rLocalName, xAttrList );
@@ -398,6 +394,10 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
if (GetScImport().getImportFlags() & SvXMLImportFlags::CONTENT)
pContext = new ScXMLBodyContext_Impl( GetScImport() );
break;
+ case XML_ELEMENT( OFFICE, XML_SCRIPTS ):
+ if (GetScImport().getImportFlags() & SvXMLImportFlags::SCRIPTS)
+ pContext = GetScImport().CreateScriptContext();
+ break;
//TODO: handle all other cases
}
@@ -788,14 +788,13 @@ SvXMLImportContext *ScXMLImport::CreateMetaContext(
return pContext;
}
-SvXMLImportContext *ScXMLImport::CreateScriptContext(
- const OUString& rLocalName )
+SvXMLImportContext *ScXMLImport::CreateScriptContext()
{
SvXMLImportContext* pContext = nullptr;
if( !(IsStylesOnlyMode()) )
{
- pContext = new XMLScriptContext( *this, rLocalName, GetModel() );
+ pContext = new XMLScriptContext( *this, GetModel() );
}
return pContext;
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 5dc661cae26b..a225957f014d 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -313,8 +313,7 @@ public:
const sal_Int32 nElement );
SvXMLImportContext *CreateFontDeclsContext(const sal_uInt16 nPrefix, const OUString& rLocalName,
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList);
- SvXMLImportContext *CreateScriptContext(
- const OUString& rLocalName );
+ SvXMLImportContext *CreateScriptContext();
SvXMLImportContext *CreateStylesContext(const OUString& rLocalName,
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList,
bool bAutoStyles );
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 9f56a8f2fb06..d2ff23ec00d6 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -211,8 +211,14 @@ SwXMLDocContext_Impl::SwXMLDocContext_Impl( SwXMLImport& rImport ) :
}
uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SwXMLDocContext_Impl::createFastChildContext(
- sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
+ sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
{
+ switch (nElement)
+ {
+ case XML_ELEMENT(OFFICE, XML_SCRIPTS):
+ return GetSwImport().CreateScriptContext();
+ break;
+ }
return nullptr;
}
@@ -251,9 +257,6 @@ SvXMLImportContextRef SwXMLDocContext_Impl::CreateChildContext(
case XML_TOK_DOC_META:
OSL_FAIL("XML_TOK_DOC_META: should not have come here, maybe document is invalid?");
break;
- case XML_TOK_DOC_SCRIPT:
- pContext = GetSwImport().CreateScriptContext( rLocalName );
- break;
case XML_TOK_DOC_BODY:
GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
pContext = new SwXMLBodyContext_Impl( GetSwImport(), nPrefix,
diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx
index 986b4a99bea9..b8357b88eaec 100644
--- a/sw/source/filter/xml/xmlimp.hxx
+++ b/sw/source/filter/xml/xmlimp.hxx
@@ -134,7 +134,7 @@ public:
// NB: in contrast to other CreateFooContexts, this particular one handles
// the root element (i.e. office:document-meta)
SvXMLImportContext *CreateMetaContext( const sal_Int32 nElement );
- SvXMLImportContext *CreateScriptContext( const OUString& rLocalName );
+ SvXMLImportContext *CreateScriptContext();
SvXMLImportContext *CreateStylesContext(
const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList,
diff --git a/sw/source/filter/xml/xmlscript.cxx b/sw/source/filter/xml/xmlscript.cxx
index aa54efa5dc5a..a0bd5096f356 100644
--- a/sw/source/filter/xml/xmlscript.cxx
+++ b/sw/source/filter/xml/xmlscript.cxx
@@ -24,14 +24,13 @@
using namespace ::com::sun::star;
-SvXMLImportContext *SwXMLImport::CreateScriptContext(
- const OUString& rLocalName )
+SvXMLImportContext *SwXMLImport::CreateScriptContext()
{
SvXMLImportContext *pContext = nullptr;
if( !(IsStylesOnlyMode() || IsInsertMode()) )
{
- pContext = new XMLScriptContext( *this, rLocalName, GetModel() );
+ pContext = new XMLScriptContext( *this, GetModel() );
}
return pContext;
diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx
index 66f6643d6215..98a4ebccbbd3 100644
--- a/xmloff/source/draw/sdxmlimp.cxx
+++ b/xmloff/source/draw/sdxmlimp.cxx
@@ -173,15 +173,6 @@ SvXMLImportContextRef SdXMLDocContext_Impl::CreateChildContext(
SAL_INFO("xmloff.draw", "XML_TOK_DOC_META: should not have come here, maybe document is invalid?");
break;
}
- case XML_TOK_DOC_SCRIPT:
- {
- if( GetImport().getImportFlags() & SvXMLImportFlags::SCRIPTS )
- {
- // office:script inside office:document
- xContext = new XMLScriptContext( GetSdImport(), rLocalName, GetSdImport().GetModel() );
- }
- break;
- }
case XML_TOK_DOC_BODY:
{
if( GetImport().getImportFlags() & SvXMLImportFlags::CONTENT )
@@ -198,8 +189,20 @@ SvXMLImportContextRef SdXMLDocContext_Impl::CreateChildContext(
}
uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SdXMLDocContext_Impl::createFastChildContext(
- sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
+ sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
{
+ switch (nElement)
+ {
+ case XML_ELEMENT(OFFICE, XML_SCRIPTS):
+ {
+ if( GetImport().getImportFlags() & SvXMLImportFlags::SCRIPTS )
+ {
+ // office:script inside office:document
+ return new XMLScriptContext( GetSdImport(), GetSdImport().GetModel() );
+ }
+ break;
+ }
+ }
return nullptr;
}
diff --git a/xmloff/source/script/xmlscripti.cxx b/xmloff/source/script/xmlscripti.cxx
index e038515ed5f9..1cee9101a080 100644
--- a/xmloff/source/script/xmlscripti.cxx
+++ b/xmloff/source/script/xmlscripti.cxx
@@ -48,21 +48,25 @@ private:
OUString const m_aLanguage;
public:
- XMLScriptChildContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ XMLScriptChildContext( SvXMLImport& rImport,
const css::uno::Reference< css::frame::XModel>& rxModel,
const OUString& rLanguage );
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 >& /*xAttrList*/ ) override
+ { return nullptr; }
- virtual void EndElement() override;
+ virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {}
};
}
-XMLScriptChildContext::XMLScriptChildContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+XMLScriptChildContext::XMLScriptChildContext( SvXMLImport& rImport,
const Reference< frame::XModel >& rxModel, const OUString& rLanguage )
- :SvXMLImportContext( rImport, nPrfx, rLName )
+ :SvXMLImportContext( rImport )
,m_xModel( rxModel )
,m_xDocumentScripts( rxModel, UNO_QUERY )
,m_aLanguage( rLanguage )
@@ -74,7 +78,6 @@ SvXMLImportContextRef XMLScriptChildContext::CreateChildContext(
const Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
{
SvXMLImportContextRef xContext;
-
if ( m_xDocumentScripts.is() )
{ // document supports embedding scripts/macros
OUString aBasic( GetImport().GetNamespaceMap().GetPrefixByKey( XML_NAMESPACE_OOO ) + ":Basic" );
@@ -86,15 +89,11 @@ SvXMLImportContextRef XMLScriptChildContext::CreateChildContext(
return xContext;
}
-void XMLScriptChildContext::EndElement()
-{
-}
-
// XMLScriptContext: context for <office:scripts> element
-XMLScriptContext::XMLScriptContext( SvXMLImport& rImport, const OUString& rLName,
+XMLScriptContext::XMLScriptContext( SvXMLImport& rImport,
const Reference<XModel>& rDocModel )
- :SvXMLImportContext( rImport, XML_NAMESPACE_OFFICE, rLName )
+ :SvXMLImportContext( rImport )
,m_xModel( rDocModel )
{
}
@@ -103,9 +102,32 @@ XMLScriptContext::~XMLScriptContext()
{
}
+css::uno::Reference< css::xml::sax::XFastContextHandler > XMLScriptContext::createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
+{
+ if ( nElement == XML_ELEMENT(OFFICE, XML_SCRIPT) )
+ {
+ if ( m_xModel.is() )
+ {
+ OUString aLanguage = xAttrList->getValue( XML_ELEMENT(SCRIPT, XML_LANGUAGE) );
+
+ uno::Sequence< beans::PropertyValue > aMedDescr = m_xModel->getArgs();
+ sal_Int32 nNewLen = aMedDescr.getLength() + 1;
+ aMedDescr.realloc( nNewLen );
+ aMedDescr[nNewLen-1].Name = "BreakMacroSignature";
+ aMedDescr[nNewLen-1].Value <<= true;
+ m_xModel->attachResource( m_xModel->getURL(), aMedDescr );
+
+ return new XMLScriptChildContext( GetImport(), m_xModel, aLanguage );
+ }
+ }
+ return nullptr;
+}
+
SvXMLImportContextRef XMLScriptContext::CreateChildContext(
sal_uInt16 nPrefix, const OUString& rLName,
- const Reference<XAttributeList>& xAttrList )
+ const Reference<XAttributeList>& /*xAttrList*/ )
{
SvXMLImportContextRef xContext;
@@ -116,33 +138,10 @@ SvXMLImportContextRef XMLScriptContext::CreateChildContext(
Reference< XEventsSupplier> xSupplier( GetImport().GetModel(), UNO_QUERY );
xContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName, xSupplier );
}
- else if ( IsXMLToken( rLName, XML_SCRIPT ) )
- {
- OUString aAttrName( GetImport().GetNamespaceMap().GetPrefixByKey( XML_NAMESPACE_SCRIPT ) + ":language" );
- if ( xAttrList.is() )
- {
- OUString aLanguage = xAttrList->getValueByName( aAttrName );
-
- if ( m_xModel.is() )
- {
- uno::Sequence< beans::PropertyValue > aMedDescr = m_xModel->getArgs();
- sal_Int32 nNewLen = aMedDescr.getLength() + 1;
- aMedDescr.realloc( nNewLen );
- aMedDescr[nNewLen-1].Name = "BreakMacroSignature";
- aMedDescr[nNewLen-1].Value <<= true;
- m_xModel->attachResource( m_xModel->getURL(), aMedDescr );
-
- xContext = new XMLScriptChildContext( GetImport(), nPrefix, rLName, m_xModel, aLanguage );
- }
- }
- }
}
return xContext;
}
-void XMLScriptContext::EndElement()
-{
-}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list