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

Noel (via logerrit) logerrit at kemper.freedesktop.org
Fri Dec 4 16:39:57 UTC 2020


 xmloff/inc/txtfldi.hxx                |    7 +-
 xmloff/source/forms/elementimport.cxx |    9 ++-
 xmloff/source/forms/elementimport.hxx |    6 +-
 xmloff/source/text/txtfldi.cxx        |   80 ++++++++++++++--------------------
 4 files changed, 44 insertions(+), 58 deletions(-)

New commits:
commit 3d0084770923ed8c17e496965abae862a4796e63
Author:     Noel <noelgrandin at gmail.com>
AuthorDate: Fri Dec 4 16:14:16 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Dec 4 17:39:12 2020 +0100

    fastparser in a couple of random places
    
    Change-Id: I9c88c826cfffa71f389f78f9d18d46e097e540ec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107217
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmloff/inc/txtfldi.hxx b/xmloff/inc/txtfldi.hxx
index bebc30a5b135..10c33b3bfa31 100644
--- a/xmloff/inc/txtfldi.hxx
+++ b/xmloff/inc/txtfldi.hxx
@@ -1061,10 +1061,9 @@ private:
     virtual void PrepareField(
         const css::uno::Reference< css::beans::XPropertySet > & xPropertySet) 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;
     virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
 };
 
diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx
index 896aaf3cd3cc..6f892de8ca09 100644
--- a/xmloff/source/forms/elementimport.cxx
+++ b/xmloff/source/forms/elementimport.cxx
@@ -1301,10 +1301,11 @@ namespace xmloff
         enableTrackAttributes();
     }
 
-    SvXMLImportContextRef OTextLikeImport::CreateChildContext( sal_uInt16 _nPrefix, const OUString& _rLocalName,
-        const Reference< XAttributeList >& _rxAttrList )
+    css::uno::Reference< css::xml::sax::XFastContextHandler > OTextLikeImport::createFastChildContext(
+        sal_Int32 nElement,
+        const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
     {
-        if ( ( XML_NAMESPACE_TEXT == _nPrefix ) && _rLocalName.equalsIgnoreAsciiCase("p") )
+        if ( nElement == XML_ELEMENT(TEXT, XML_P) )
         {
             OSL_ENSURE( m_eElementType == OControlElement::TEXT_AREA,
                 "OTextLikeImport::CreateChildContext: text paragraphs in a non-text-area?" );
@@ -1327,7 +1328,7 @@ namespace xmloff
                     if ( m_xCursor.is() )
                     {
                         m_bEncounteredTextPara = true;
-                        return xTextImportHelper->CreateTextChildContext( m_rContext.getGlobalContext(), _nPrefix, _rLocalName, _rxAttrList );
+                        return xTextImportHelper->CreateTextChildContext( m_rContext.getGlobalContext(), nElement, xAttrList );
                     }
                 }
                 else
diff --git a/xmloff/source/forms/elementimport.hxx b/xmloff/source/forms/elementimport.hxx
index 67eebc2f2a7a..a3f9d6de4359 100644
--- a/xmloff/source/forms/elementimport.hxx
+++ b/xmloff/source/forms/elementimport.hxx
@@ -420,9 +420,9 @@ namespace xmloff
         virtual void SAL_CALL startFastElement(
             sal_Int32 nElement,
             const css::uno::Reference< css::xml::sax::XFastAttributeList >& _rxAttrList) override;
-        virtual SvXMLImportContextRef CreateChildContext(
-            sal_uInt16 _nPrefix, const OUString& _rLocalName,
-            const css::uno::Reference< css::xml::sax::XAttributeList >& _rxAttrList) 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;
         virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
 
     private:
diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx
index 60c6027ce83b..96cfd80041f8 100644
--- a/xmloff/source/text/txtfldi.cxx
+++ b/xmloff/source/text/txtfldi.cxx
@@ -3309,65 +3309,51 @@ void XMLAnnotationImportContext::ProcessAttribute(
         XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
 }
 
-SvXMLImportContextRef XMLAnnotationImportContext::CreateChildContext(
-    sal_uInt16 nPrefix,
-    const OUString& rLocalName,
-    const Reference<XAttributeList >& xAttrList )
+css::uno::Reference< css::xml::sax::XFastContextHandler > XMLAnnotationImportContext::createFastChildContext(
+    sal_Int32 nElement,
+    const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
 {
-    SvXMLImportContext *pContext = nullptr;
-    if( XML_NAMESPACE_DC == nPrefix )
-    {
-        if( IsXMLToken( rLocalName, XML_CREATOR ) )
-            pContext = new XMLStringBufferImportContext(GetImport(), aAuthorBuffer);
-        else if( IsXMLToken( rLocalName, XML_DATE ) )
-            pContext = new XMLStringBufferImportContext(GetImport(), aDateBuffer);
-    }
-    else if (((XML_NAMESPACE_TEXT == nPrefix || XML_NAMESPACE_LO_EXT == nPrefix)
-                 && IsXMLToken(rLocalName, XML_SENDER_INITIALS))
-             || (XML_NAMESPACE_META == nPrefix
-                 && IsXMLToken(rLocalName, XML_CREATOR_INITIALS)))
-    {
-        pContext = new XMLStringBufferImportContext(GetImport(), aInitialsBuffer);
-    }
+    if( nElement == XML_ELEMENT(DC, XML_CREATOR) )
+        return new XMLStringBufferImportContext(GetImport(), aAuthorBuffer);
+    else if( nElement == XML_ELEMENT(DC, XML_DATE) )
+        return new XMLStringBufferImportContext(GetImport(), aDateBuffer);
+    else if (nElement == XML_ELEMENT(TEXT,XML_SENDER_INITIALS) ||
+             nElement == XML_ELEMENT(LO_EXT, XML_SENDER_INITIALS) ||
+             nElement == XML_ELEMENT(META, XML_CREATOR_INITIALS))
+        return new XMLStringBufferImportContext(GetImport(), aInitialsBuffer);
 
-    if( !pContext )
+    try
     {
-        try
+        bool bOK = true;
+        if ( !mxField.is() )
+            bOK = CreateField( mxField, sServicePrefix + GetServiceName() );
+        if (bOK)
         {
-            bool bOK = true;
-            if ( !mxField.is() )
-                bOK = CreateField( mxField, sServicePrefix + GetServiceName() );
-            if (bOK)
+            Any aAny = mxField->getPropertyValue( "TextRange" );
+            Reference< XText > xText;
+            aAny >>= xText;
+            if( xText.is() )
             {
-                Any aAny = mxField->getPropertyValue( "TextRange" );
-                Reference< XText > xText;
-                aAny >>= xText;
-                if( xText.is() )
+                rtl::Reference < XMLTextImportHelper > xTxtImport = GetImport().GetTextImport();
+                if( !mxCursor.is() )
                 {
-                    rtl::Reference < XMLTextImportHelper > xTxtImport = GetImport().GetTextImport();
-                    if( !mxCursor.is() )
-                    {
-                        mxOldCursor = xTxtImport->GetCursor();
-                        mxCursor = xText->createTextCursor();
-                    }
+                    mxOldCursor = xTxtImport->GetCursor();
+                    mxCursor = xText->createTextCursor();
+                }
 
-                    if( mxCursor.is() )
-                    {
-                        xTxtImport->SetCursor( mxCursor );
-                        pContext = xTxtImport->CreateTextChildContext( GetImport(), nPrefix, rLocalName, xAttrList );
-                    }
+                if( mxCursor.is() )
+                {
+                    xTxtImport->SetCursor( mxCursor );
+                    return xTxtImport->CreateTextChildContext( GetImport(), nElement, xAttrList );
                 }
             }
         }
-        catch (const Exception&)
-        {
-        }
-
-        if( !pContext )
-            pContext = new XMLStringBufferImportContext(GetImport(), aTextBuffer);
+    }
+    catch (const Exception&)
+    {
     }
 
-    return pContext;
+    return new XMLStringBufferImportContext(GetImport(), aTextBuffer);
 }
 
 void XMLAnnotationImportContext::endFastElement(sal_Int32 )


More information about the Libreoffice-commits mailing list