summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@gmail.com>2016-02-06 18:38:32 +0100
committerMatúš Kukan <matus.kukan@gmail.com>2016-02-06 18:41:33 +0100
commit8998768a34751d35403678a81464a26835b2230e (patch)
tree5f2973f81a5c856921b99d144972d9f1baeeb6f8 /sax
parent225e2a3cec2546d5d41fec21a4219c9a2f5ddf76 (diff)
sax: Use comphelper's AttributeList
Change-Id: I6eb0115dba8797025a513cf1e6cfbfbe0b6f7e50
Diffstat (limited to 'sax')
-rw-r--r--sax/Library_expwrap.mk2
-rw-r--r--sax/source/expatwrap/attrlistimpl.cxx162
-rw-r--r--sax/source/expatwrap/attrlistimpl.hxx76
-rw-r--r--sax/source/expatwrap/sax_expat.cxx10
4 files changed, 6 insertions, 244 deletions
diff --git a/sax/Library_expwrap.mk b/sax/Library_expwrap.mk
index 0c44d308c51c..e8e049ab1efd 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 61bfe2b2ef83..000000000000
--- 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 7910767f7739..000000000000
--- 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 be80a8005a5a..ce8c0f12d6a4 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] ) );