[Libreoffice-commits] core.git: comphelper/source include/comphelper sax/Library_expwrap.mk sax/source

Matúš Kukan matus.kukan at gmail.com
Sat Feb 6 17:57:36 UTC 2016


 comphelper/source/xml/attributelist.cxx |   14 +-
 include/comphelper/attributelist.hxx    |    9 -
 sax/Library_expwrap.mk                  |    2 
 sax/source/expatwrap/attrlistimpl.cxx   |  162 --------------------------------
 sax/source/expatwrap/attrlistimpl.hxx   |   76 ---------------
 sax/source/expatwrap/sax_expat.cxx      |   10 -
 6 files changed, 18 insertions(+), 255 deletions(-)

New commits:
commit 8998768a34751d35403678a81464a26835b2230e
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Sat Feb 6 18:38:32 2016 +0100

    sax: Use comphelper's AttributeList
    
    Change-Id: I6eb0115dba8797025a513cf1e6cfbfbe0b6f7e50

diff --git a/comphelper/source/xml/attributelist.cxx b/comphelper/source/xml/attributelist.cxx
index 3342ef2..f196b48 100644
--- a/comphelper/source/xml/attributelist.cxx
+++ b/comphelper/source/xml/attributelist.cxx
@@ -106,18 +106,20 @@ AttributeList::AttributeList()
     m_pImpl = new AttributeList_Impl;
 }
 
-
-
 AttributeList::~AttributeList()
 {
     delete m_pImpl;
 }
 
-void AttributeList::AddAttribute(   const OUString &sName ,
-                                        const OUString &sType ,
-                                        const OUString &sValue )
+void AttributeList::AddAttribute(const OUString &sName,
+        const OUString &sType, const OUString &sValue)
+{
+    m_pImpl->vecAttribute.push_back( TagAttribute_Impl(sName, sType, sValue) );
+}
+
+void AttributeList::Clear()
 {
-    m_pImpl->vecAttribute.push_back( TagAttribute_Impl( sName , sType , sValue ) );
+    m_pImpl->vecAttribute.clear();
 }
 
 } // namespace comphelper
diff --git a/include/comphelper/attributelist.hxx b/include/comphelper/attributelist.hxx
index 1337a3a..18aaa50 100644
--- a/include/comphelper/attributelist.hxx
+++ b/include/comphelper/attributelist.hxx
@@ -30,10 +30,8 @@ namespace comphelper
 
 struct AttributeList_Impl;
 
-class COMPHELPER_DLLPUBLIC AttributeList : public ::cppu::WeakImplHelper
-<
-    css::xml::sax::XAttributeList
->
+class COMPHELPER_DLLPUBLIC AttributeList :
+    public ::cppu::WeakImplHelper<css::xml::sax::XAttributeList>
 {
     AttributeList_Impl *m_pImpl;
 public:
@@ -41,7 +39,8 @@ public:
     virtual ~AttributeList();
 
     // methods that are not contained in any interface
-    void AddAttribute( const OUString &sName , const OUString &sType , const OUString &sValue );
+    void AddAttribute(const OUString &sName , const OUString &sType , const OUString &sValue);
+    void Clear();
 
     // css::xml::sax::XAttributeList
     virtual sal_Int16 SAL_CALL getLength()
diff --git a/sax/Library_expwrap.mk b/sax/Library_expwrap.mk
index 0c44d30..e8e049a 100644
--- a/sax/Library_expwrap.mk
+++ b/sax/Library_expwrap.mk
@@ -30,6 +30,7 @@ $(eval $(call gb_Library_use_externals,expwrap,\
 ))
 
 $(eval $(call gb_Library_use_libraries,expwrap,\
+	comphelper \
 	cppu \
 	cppuhelper \
 	sal \
@@ -39,7 +40,6 @@ $(eval $(call gb_Library_use_libraries,expwrap,\
 ))
 
 $(eval $(call gb_Library_add_exception_objects,expwrap,\
-	sax/source/expatwrap/attrlistimpl \
 	sax/source/expatwrap/sax_expat \
 	sax/source/expatwrap/saxwriter \
 	sax/source/expatwrap/xml2utf \
diff --git a/sax/source/expatwrap/attrlistimpl.cxx b/sax/source/expatwrap/attrlistimpl.cxx
deleted file mode 100644
index 61bfe2b..0000000
--- a/sax/source/expatwrap/attrlistimpl.cxx
+++ /dev/null
@@ -1,162 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "attrlistimpl.hxx"
-
-#include <vector>
-
-#include <cppuhelper/weak.hxx>
-
-using namespace ::std;
-using namespace ::cppu;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::util;
-using namespace ::com::sun::star::xml::sax;
-
-
-namespace sax_expatwrap {
-struct TagAttribute
-{
-    TagAttribute( const OUString &aName, const OUString &aType , const OUString &aValue )
-    {
-        this->sName     = aName;
-        this->sType     = aType;
-        this->sValue    = aValue;
-    }
-
-    OUString sName;
-    OUString sType;
-    OUString sValue;
-};
-
-struct AttributeList_impl
-{
-    AttributeList_impl()
-    {
-        // performance improvement during adding
-        vecAttribute.reserve(20);
-    }
-    vector<struct TagAttribute> vecAttribute;
-};
-
-
-
-sal_Int16 AttributeList::getLength() throw (RuntimeException, std::exception)
-{
-    return static_cast<sal_Int16>(m_pImpl->vecAttribute.size());
-}
-
-
-AttributeList::AttributeList( const AttributeList &r ) :
-    cppu::WeakImplHelper<XAttributeList, XCloneable>(),
-    m_pImpl( new AttributeList_impl )
-{
-    *m_pImpl = *(r.m_pImpl);
-}
-
-OUString AttributeList::getNameByIndex(sal_Int16 i) throw (RuntimeException, std::exception)
-{
-    if( std::vector< TagAttribute >::size_type(i) < m_pImpl->vecAttribute.size() ) {
-        return m_pImpl->vecAttribute[i].sName;
-    }
-    return OUString();
-}
-
-
-OUString AttributeList::getTypeByIndex(sal_Int16 i) throw (RuntimeException, std::exception)
-{
-    if( std::vector< TagAttribute >::size_type(i) < m_pImpl->vecAttribute.size() ) {
-        return m_pImpl->vecAttribute[i].sType;
-    }
-    return OUString();
-}
-
-OUString AttributeList::getValueByIndex(sal_Int16 i) throw (RuntimeException, std::exception)
-{
-    if( std::vector< TagAttribute >::size_type(i) < m_pImpl->vecAttribute.size() ) {
-        return m_pImpl->vecAttribute[i].sValue;
-    }
-    return OUString();
-
-}
-
-OUString AttributeList::getTypeByName( const OUString& sName ) throw (RuntimeException, std::exception)
-{
-    vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
-
-    for (; ii != m_pImpl->vecAttribute.end(); ++ii )
-    {
-        if( (*ii).sName == sName )
-        {
-            return (*ii).sType;
-        }
-    }
-    return OUString();
-}
-
-OUString AttributeList::getValueByName(const OUString& sName) throw (RuntimeException, std::exception)
-{
-    vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
-
-    for (; ii != m_pImpl->vecAttribute.end(); ++ii)
-    {
-        if( (*ii).sName == sName )
-        {
-            return (*ii).sValue;
-        }
-    }
-    return OUString();
-}
-
-
-Reference< XCloneable > AttributeList::createClone() throw (RuntimeException, std::exception)
-{
-    AttributeList *p = new AttributeList( *this );
-    return Reference< XCloneable > ( static_cast<XCloneable *>(p) );
-}
-
-
-
-AttributeList::AttributeList()
-   : m_pImpl( new AttributeList_impl )
-{
-}
-
-
-
-AttributeList::~AttributeList()
-{
-}
-
-
-void AttributeList::addAttribute(   const OUString &sName ,
-                                        const OUString &sType ,
-                                        const OUString &sValue )
-{
-    m_pImpl->vecAttribute.push_back( TagAttribute( sName , sType , sValue ) );
-}
-
-void AttributeList::clear()
-{
-    m_pImpl->vecAttribute.clear();
-}
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sax/source/expatwrap/attrlistimpl.hxx b/sax/source/expatwrap/attrlistimpl.hxx
deleted file mode 100644
index 7910767..0000000
--- a/sax/source/expatwrap/attrlistimpl.hxx
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_SAX_SOURCE_EXPATWRAP_ATTRLISTIMPL_HXX
-#define INCLUDED_SAX_SOURCE_EXPATWRAP_ATTRLISTIMPL_HXX
-
-#include "sal/config.h"
-#include <cppuhelper/implbase.hxx>
-#include <com/sun/star/uno/RuntimeException.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/xml/sax/XAttributeList.hpp>
-#include <memory>
-
-namespace sax_expatwrap
-{
-
-struct AttributeList_impl;
-
-//FIXME
-class AttributeList :
-    public ::cppu::WeakImplHelper<
-                css::xml::sax::XAttributeList,
-                css::util::XCloneable >
-{
-public:
-    AttributeList();
-    AttributeList( const AttributeList & );
-    virtual ~AttributeList();
-
-    void addAttribute( const OUString &sName ,
-        const OUString &sType , const OUString &sValue );
-    void clear();
-public:
-    // XAttributeList
-    virtual sal_Int16 SAL_CALL getLength()
-        throw(css::uno::RuntimeException, std::exception) override;
-    virtual OUString SAL_CALL getNameByIndex(sal_Int16 i)
-        throw(css::uno::RuntimeException, std::exception) override;
-    virtual OUString SAL_CALL getTypeByIndex(sal_Int16 i)
-        throw(css::uno::RuntimeException, std::exception) override;
-    virtual OUString SAL_CALL getTypeByName(const OUString& aName)
-        throw(css::uno::RuntimeException, std::exception) override;
-    virtual OUString SAL_CALL getValueByIndex(sal_Int16 i)
-        throw(css::uno::RuntimeException, std::exception) override;
-    virtual OUString SAL_CALL getValueByName(const OUString& aName)
-        throw( css::uno::RuntimeException, std::exception) override;
-
-    // XCloneable
-    virtual css::uno::Reference< XCloneable > SAL_CALL
-        createClone()   throw(css::uno::RuntimeException, std::exception) override;
-
-private:
-    std::unique_ptr<AttributeList_impl> m_pImpl;
-};
-
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sax/source/expatwrap/sax_expat.cxx b/sax/source/expatwrap/sax_expat.cxx
index be80a80..ce8c0f1 100644
--- a/sax/source/expatwrap/sax_expat.cxx
+++ b/sax/source/expatwrap/sax_expat.cxx
@@ -32,6 +32,7 @@
 #include <com/sun/star/io/XSeekable.hpp>
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 
+#include <comphelper/attributelist.hxx>
 #include <cppuhelper/weak.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/supportsservice.hxx>
@@ -47,7 +48,6 @@ using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::xml::sax;
 using namespace ::com::sun::star::io;
 
-#include "attrlistimpl.hxx"
 #include "xml2utf.hxx"
 
 namespace {
@@ -165,7 +165,7 @@ public: // module scope
     css::uno::Reference < XLocator >      rDocumentLocator;
 
 
-    rtl::Reference < sax_expatwrap::AttributeList > rAttrList;
+    rtl::Reference < comphelper::AttributeList > rAttrList;
 
     // External entity stack
     vector<struct Entity>   vecEntity;
@@ -375,7 +375,7 @@ SaxExpatParser::SaxExpatParser(  )
 
     // Performance-improvement; handing out the same object with every call of
     // the startElement callback is allowed (see sax-specification):
-    m_pImpl->rAttrList = new sax_expatwrap::AttributeList;
+    m_pImpl->rAttrList = new comphelper::AttributeList;
 
     m_pImpl->bExceptionWasThrown = false;
     m_pImpl->bRTExceptionWasThrown = false;
@@ -735,11 +735,11 @@ void SaxExpatParser_Impl::callbackStartElement( void *pvThis ,
     if( pImpl->rDocumentHandler.is() ) {
 
         int i = 0;
-        pImpl->rAttrList->clear();
+        pImpl->rAttrList->Clear();
 
         while( awAttributes[i] ) {
             assert(awAttributes[i+1]);
-            pImpl->rAttrList->addAttribute(
+            pImpl->rAttrList->AddAttribute(
                 XML_CHAR_TO_OUSTRING( awAttributes[i] ) ,
                 pImpl->sCDATA,  // expat doesn't know types
                 XML_CHAR_TO_OUSTRING( awAttributes[i+1] ) );


More information about the Libreoffice-commits mailing list