[Libreoffice-commits] core.git: xmloff/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Nov 20 16:05:50 UTC 2020


 xmloff/source/draw/layerimp.cxx |   49 ++++++++++++++--------------------------
 xmloff/source/draw/layerimp.hxx |   10 ++------
 xmloff/source/draw/ximpstyl.cxx |    4 +--
 3 files changed, 23 insertions(+), 40 deletions(-)

New commits:
commit 6d63302127be4f7ebc12369cde286d7e5114ad63
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Fri Nov 20 14:22:41 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Nov 20 17:04:55 2020 +0100

    fastparser in SdXMLLayerContext
    
    Change-Id: I807c9028fa197079da79270f8d7ad9339d7bedf4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106228
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmloff/source/draw/layerimp.cxx b/xmloff/source/draw/layerimp.cxx
index ab809d320695..e7af0c3f5499 100644
--- a/xmloff/source/draw/layerimp.cxx
+++ b/xmloff/source/draw/layerimp.cxx
@@ -53,7 +53,7 @@ namespace {
 class SdXMLLayerContext : public SvXMLImportContext
 {
 public:
-    SdXMLLayerContext( SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, const Reference< XNameAccess >& xLayerManager );
+    SdXMLLayerContext( SvXMLImport& rImport, const Reference< XFastAttributeList >& xAttrList, const Reference< XNameAccess >& xLayerManager );
 
     virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList ) override;
     virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
@@ -69,30 +69,26 @@ private:
 
 }
 
-SdXMLLayerContext::SdXMLLayerContext( SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, const Reference< XNameAccess >& xLayerManager )
-: SvXMLImportContext(rImport, nPrefix, rLocalName)
+SdXMLLayerContext::SdXMLLayerContext( SvXMLImport& rImport, const Reference< XFastAttributeList >& xAttrList, const Reference< XNameAccess >& xLayerManager )
+: SvXMLImportContext(rImport)
 , mxLayerManager( xLayerManager )
 {
-    const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
-    for(sal_Int16 i=0; i < nAttrCount; i++)
+    for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
     {
-        OUString aLocalName;
-        if( GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( i ), &aLocalName ) == XML_NAMESPACE_DRAW )
+        OUString sValue = aIter.toString();
+        switch(aIter.getToken())
         {
-            const OUString sValue( xAttrList->getValueByIndex( i ) );
-
-            if( IsXMLToken( aLocalName, XML_NAME ) )
-            {
+            case XML_ELEMENT(DRAW, XML_NAME):
                 msName = sValue;
-            }
-            else if ( IsXMLToken( aLocalName, XML_DISPLAY))
-            {
+                break;
+            case XML_ELEMENT(DRAW, XML_DISPLAY):
                 msDisplay = sValue;
-            }
-            else if ( IsXMLToken( aLocalName, XML_PROTECTED))
-            {
+                break;
+            case XML_ELEMENT(DRAW, XML_PROTECTED):
                 msProtected = sValue;
-            }
+                break;
+            default:
+                XMLOFF_WARN_UNKNOWN("xmloff", aIter);
         }
     }
 
@@ -172,16 +168,6 @@ void SdXMLLayerContext::endFastElement(sal_Int32 )
 }
 
 
-SdXMLLayerSetContext::SdXMLLayerSetContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName,
-        const css::uno::Reference< css::xml::sax::XAttributeList>&)
-: SvXMLImportContext(rImport, nPrfx, rLocalName)
-{
-    Reference< XLayerSupplier > xLayerSupplier( rImport.GetModel(), UNO_QUERY );
-    SAL_WARN_IF( !xLayerSupplier.is(), "xmloff", "xmloff::SdXMLLayerSetContext::SdXMLLayerSetContext(), XModel is not supporting XLayerSupplier!" );
-    if( xLayerSupplier.is() )
-        mxLayerManager = xLayerSupplier->getLayerManager();
-}
-
 SdXMLLayerSetContext::SdXMLLayerSetContext( SvXMLImport& rImport )
 : SvXMLImportContext(rImport)
 {
@@ -195,10 +181,11 @@ SdXMLLayerSetContext::~SdXMLLayerSetContext()
 {
 }
 
-SvXMLImportContextRef SdXMLLayerSetContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,
-        const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList )
+css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLLayerSetContext::createFastChildContext(
+    sal_Int32 /*nElement*/,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
 {
-    return new SdXMLLayerContext( GetImport(), nPrefix, rLocalName, xAttrList, mxLayerManager );
+    return new SdXMLLayerContext( GetImport(), xAttrList, mxLayerManager );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/draw/layerimp.hxx b/xmloff/source/draw/layerimp.hxx
index aa1869473ddc..1f31916e5325 100644
--- a/xmloff/source/draw/layerimp.hxx
+++ b/xmloff/source/draw/layerimp.hxx
@@ -31,16 +31,12 @@ private:
     css::uno::Reference< css::container::XNameAccess > mxLayerManager;
 
 public:
-
-    SdXMLLayerSetContext( SvXMLImport& rImport,
-        sal_uInt16 nPrfx,
-        const OUString& rLocalName,
-        const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList);
     SdXMLLayerSetContext( SvXMLImport& rImport );
     virtual ~SdXMLLayerSetContext() override;
 
-    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;
 };
 
 #endif // INCLUDED_XMLOFF_SOURCE_DRAW_LAYERIMP_HXX
diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx
index 10720869eaa3..9e4fc706fe96 100644
--- a/xmloff/source/draw/ximpstyl.cxx
+++ b/xmloff/source/draw/ximpstyl.cxx
@@ -1363,13 +1363,13 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLMasterStylesConte
 SvXMLImportContextRef SdXMLMasterStylesContext::CreateChildContext(
     sal_uInt16 nPrefix,
     const OUString& rLocalName,
-    const uno::Reference< xml::sax::XAttributeList >& xAttrList)
+    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 );
+        xContext = new SdXMLLayerSetContext( GetImport() );
     }
 
     return xContext;


More information about the Libreoffice-commits mailing list