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

Mohammed Abdul Azeem azeemmysore at gmail.com
Thu Jun 29 15:50:36 UTC 2017


 include/sax/fastattribs.hxx      |    1 +
 sax/source/tools/fastattribs.cxx |    8 ++++++++
 sc/source/filter/xml/xmlrowi.cxx |   10 ++++++----
 xmloff/source/core/xmlimp.cxx    |   24 +++++++++++++++---------
 4 files changed, 30 insertions(+), 13 deletions(-)

New commits:
commit b3b6ce3febbf3073dd9e16d908137e41ab473dca
Author: Mohammed Abdul Azeem <azeemmysore at gmail.com>
Date:   Thu Jun 29 13:49:18 2017 +0530

    Added find function to FastAttributeList:
    
    It returns a FastAttributeIter, which can be used to
    obtain value in different formats directly. Also, avoids
    one unnecessary iteration.
    
    Change-Id: Ic28e0177100738bbd71a3a89634cae9f1f7ee996
    Reviewed-on: https://gerrit.libreoffice.org/39380
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/include/sax/fastattribs.hxx b/include/sax/fastattribs.hxx
index 70ddc4c8bb85..c813fcf6944d 100644
--- a/include/sax/fastattribs.hxx
+++ b/include/sax/fastattribs.hxx
@@ -164,6 +164,7 @@ public:
     };
     const FastAttributeIter begin() const { return FastAttributeIter(*this, 0); }
     const FastAttributeIter end() const { return FastAttributeIter(*this, maAttributeTokens.size()); }
+    const FastAttributeIter find( sal_Int32 nToken ) const;
 
 private:
     sal_Char *mpChunk; ///< buffer to store all attribute values - null terminated strings
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index 985293ff0caf..564f71d27b81 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -230,6 +230,14 @@ Sequence< FastAttribute > FastAttributeList::getFastAttributes(  )
     return aSeq;
 }
 
+const FastAttributeList::FastAttributeIter FastAttributeList::find( sal_Int32 nToken ) const
+{
+    for (size_t i = 0; i < maAttributeTokens.size(); ++i)
+        if( maAttributeTokens[i] == nToken )
+            return FastAttributeIter(*this, i);
+    return end();
+}
+
 sal_Int32 FastTokenHandlerBase::getTokenFromChars(
         const css::uno::Reference< css::xml::sax::XFastTokenHandler > &xTokenHandler,
         FastTokenHandlerBase *pTokenHandler,
diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx
index ab5fdf5eefa2..8903287504ac 100644
--- a/sc/source/filter/xml/xmlrowi.cxx
+++ b/sc/source/filter/xml/xmlrowi.cxx
@@ -227,11 +227,13 @@ ScXMLTableRowsContext::ScXMLTableRowsContext( ScXMLImport& rImport,
     {
         nGroupStartRow = rImport.GetTables().GetCurrentRow();
         ++nGroupStartRow;
-        if ( xAttrList.is() &&
-            xAttrList->hasAttribute( XML_ELEMENT( TABLE, XML_DISPLAY ) ) )
+        if ( xAttrList.is() )
         {
-            bGroupDisplay = IsXMLToken( xAttrList->getValue(
-                                XML_ELEMENT( TABLE, XML_DISPLAY ) ), XML_TRUE );
+            sax_fastparser::FastAttributeList *pAttribList =
+                static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
+            auto &aIter( pAttribList->find( XML_ELEMENT( TABLE, XML_DISPLAY ) ) );
+            if( aIter != pAttribList->end() )
+                bGroupDisplay = IsXMLToken( aIter.toCString(), XML_TRUE );
         }
     }
 }
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 5d9d1de5123e..92836d1af191 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -788,17 +788,23 @@ void SAL_CALL SvXMLImport::setDocumentLocator( const uno::Reference< xml::sax::X
 void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element,
     const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
 {
-    if ( Attribs.is() && Attribs->hasAttribute( XML_ELEMENT( OFFICE, XML_VERSION ) ) )
+    if ( Attribs.is() )
     {
-        mpImpl->aODFVersion = Attribs->getValue( XML_ELEMENT( OFFICE, XML_VERSION ) );
-
-        // the ODF version in content.xml and manifest.xml must be the same starting from ODF1.2
-        if ( mpImpl->mStreamName == "content.xml" && !IsODFVersionConsistent( mpImpl->aODFVersion ) )
+        sax_fastparser::FastAttributeList *pAttribList =
+            static_cast< sax_fastparser::FastAttributeList *>( Attribs.get() );
+        auto &aIter( pAttribList->find( XML_ELEMENT( OFFICE, XML_VERSION ) ) );
+        if( aIter != pAttribList->end() )
         {
-            throw xml::sax::SAXException("Inconsistent ODF versions in content.xml and manifest.xml!",
-                    uno::Reference< uno::XInterface >(),
-                    uno::makeAny(
-                        packages::zip::ZipIOException("Inconsistent ODF versions in content.xml and manifest.xml!" ) ) );
+            mpImpl->aODFVersion = aIter.toString();
+
+            // the ODF version in content.xml and manifest.xml must be the same starting from ODF1.2
+            if ( mpImpl->mStreamName == "content.xml" && !IsODFVersionConsistent( mpImpl->aODFVersion ) )
+            {
+                throw xml::sax::SAXException("Inconsistent ODF versions in content.xml and manifest.xml!",
+                        uno::Reference< uno::XInterface >(),
+                        uno::makeAny(
+                            packages::zip::ZipIOException("Inconsistent ODF versions in content.xml and manifest.xml!" ) ) );
+            }
         }
     }
 


More information about the Libreoffice-commits mailing list