[Libreoffice-commits] .: xmloff/inc xmloff/Library_xo.mk xmloff/source
Nigel Hawkins
nhawkins at kemper.freedesktop.org
Thu Aug 11 14:21:18 PDT 2011
xmloff/Library_xo.mk | 4
xmloff/inc/xmloff/xmlcnimp.hxx | 87 ++---------
xmloff/source/core/SvXMLAttr.cxx | 72 +++++++++
xmloff/source/core/SvXMLAttr.hxx | 58 +++++++
xmloff/source/core/SvXMLAttrCollection.cxx | 188 ++++++++++++++++++++++++
xmloff/source/core/SvXMLAttrCollection.hxx | 90 +++++++++++
xmloff/source/core/unoatrcn.cxx | 1
xmloff/source/core/xmlcnimp.cxx | 148 +++++++++++++++++++
xmloff/source/core/xmlcnitm.cxx | 221 -----------------------------
9 files changed, 580 insertions(+), 289 deletions(-)
New commits:
commit 40283f019e15e7e2fe2082653344067dce037892
Author: Nigel Hawkins <n.hawkins at gmx.com>
Date: Wed Aug 10 15:14:10 2011 +0100
Replace SvArray stuff with vector in xmloff/xmlcnimp.hxx and refactor
LGPLv3+/MPL1.1
diff --git a/xmloff/Library_xo.mk b/xmloff/Library_xo.mk
index 9f1cc21..b8fec46 100644
--- a/xmloff/Library_xo.mk
+++ b/xmloff/Library_xo.mk
@@ -100,6 +100,8 @@ $(eval $(call gb_Library_add_exception_objects,xo,\
xmloff/source/core/RDFaExportHelper \
xmloff/source/core/RDFaImportHelper \
xmloff/source/core/SettingsExportHelper \
+ xmloff/source/core/SvXMLAttr \
+ xmloff/source/core/SvXMLAttrCollection \
xmloff/source/core/XMLBase64Export \
xmloff/source/core/XMLBase64ImportContext \
xmloff/source/core/XMLBasicExportFilter \
@@ -111,7 +113,7 @@ $(eval $(call gb_Library_add_exception_objects,xo,\
xmloff/source/core/nmspmap \
xmloff/source/core/unoatrcn \
xmloff/source/core/unointerfacetouniqueidentifiermapper \
- xmloff/source/core/xmlcnitm \
+ xmloff/source/core/xmlcnimp \
xmloff/source/core/xmlehelp \
xmloff/source/core/xmlerror \
xmloff/source/core/xmlexp \
diff --git a/xmloff/inc/xmloff/xmlcnimp.hxx b/xmloff/inc/xmloff/xmlcnimp.hxx
index 013dfb8..b8b67bc 100644
--- a/xmloff/inc/xmloff/xmlcnimp.hxx
+++ b/xmloff/inc/xmloff/xmlcnimp.hxx
@@ -29,32 +29,21 @@
#ifndef _XMLOFF_XMLCNIMP_HXX
#define _XMLOFF_XMLCNIMP_HXX
-#include "sal/config.h"
-#include "xmloff/dllapi.h"
-#include "sal/types.h"
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <svl/svarray.hxx>
-#include <xmloff/nmspmap.hxx>
-
-#define _SVSTDARR_USHORTS
-#include <svl/svstdarr.hxx>
+#include "xmloff/dllapi.h" //XMLOFF_DLLPUBLIC
+#include <sal/types.h> //sal_uInt16 and sal_Bool
+#include <boost/scoped_ptr.hpp>
namespace rtl { class OUString; }
-
-class SvXMLAttrContainerData_Impl;
+class SvXMLAttrCollection; //Forward declaration only.
class XMLOFF_DLLPUBLIC SvXMLAttrContainerData
{
- SvXMLNamespaceMap aNamespaceMap;
- SvUShorts aPrefixPoss;
- SvXMLAttrContainerData_Impl *pLNames;
- SvXMLAttrContainerData_Impl *pValues;
+private:
+ boost::scoped_ptr<SvXMLAttrCollection> pimpl;
- SAL_DLLPRIVATE inline sal_uInt16 GetPrefixPos( sal_uInt16 i ) const;
public:
-
- SvXMLAttrContainerData( const SvXMLAttrContainerData& rImpl );
SvXMLAttrContainerData();
+ SvXMLAttrContainerData(const SvXMLAttrContainerData &rCopy);
~SvXMLAttrContainerData();
int operator ==( const SvXMLAttrContainerData& rCmp ) const;
@@ -66,66 +55,30 @@ public:
const ::rtl::OUString& rLName,
const ::rtl::OUString& rValue );
- sal_uInt16 GetAttrCount() const;
- inline ::rtl::OUString GetAttrNamespace( sal_uInt16 i ) const;
- inline ::rtl::OUString GetAttrPrefix( sal_uInt16 i ) const;
- const ::rtl::OUString& GetAttrLName( sal_uInt16 i ) const;
- const ::rtl::OUString& GetAttrValue( sal_uInt16 i ) const;
+ size_t GetAttrCount() const;
+ const rtl::OUString GetAttrNamespace( size_t i ) const;
+ const rtl::OUString GetAttrPrefix( size_t i ) const;
+ const rtl::OUString& GetAttrLName( size_t i ) const;
+ const rtl::OUString& GetAttrValue( size_t i ) const;
- sal_uInt16 GetFirstNamespaceIndex() const { return aNamespaceMap.GetFirstIndex(); }
- sal_uInt16 GetNextNamespaceIndex( sal_uInt16 nIdx ) const { return aNamespaceMap.GetNextIndex( nIdx ); }
- inline const ::rtl::OUString& GetNamespace( sal_uInt16 i ) const;
- inline const ::rtl::OUString& GetPrefix( sal_uInt16 i ) const;
+ sal_uInt16 GetFirstNamespaceIndex() const;
+ sal_uInt16 GetNextNamespaceIndex( sal_uInt16 nIdx ) const;
+ const ::rtl::OUString& GetNamespace( sal_uInt16 i ) const;
+ const ::rtl::OUString& GetPrefix( sal_uInt16 i ) const;
- sal_Bool SetAt( sal_uInt16 i,
+ sal_Bool SetAt( size_t i,
const ::rtl::OUString& rLName, const rtl::OUString& rValue );
- sal_Bool SetAt( sal_uInt16 i,
+ sal_Bool SetAt( size_t i,
const ::rtl::OUString& rPrefix, const rtl::OUString& rNamespace,
const ::rtl::OUString& rLName, const rtl::OUString& rValue );
- sal_Bool SetAt( sal_uInt16 i,
+ sal_Bool SetAt( size_t i,
const ::rtl::OUString& rPrefix,
const ::rtl::OUString& rLName,
const ::rtl::OUString& rValue );
- void Remove( sal_uInt16 i );
+ void Remove( size_t i );
};
-inline sal_uInt16 SvXMLAttrContainerData::GetPrefixPos( sal_uInt16 i ) const
-{
-// DBG_ASSERT( i >= 0 && i < aPrefixPoss.Count(),
-// "SvXMLAttrContainerData::GetPrefixPos: illegal index" );
- return aPrefixPoss[i];
-}
-
-inline ::rtl::OUString SvXMLAttrContainerData::GetAttrNamespace( sal_uInt16 i ) const
-{
- ::rtl::OUString sRet;
- sal_uInt16 nPos = GetPrefixPos( i );
- if( USHRT_MAX != nPos )
- sRet = aNamespaceMap.GetNameByIndex( nPos );
- return sRet;
-}
-
-inline ::rtl::OUString SvXMLAttrContainerData::GetAttrPrefix( sal_uInt16 i ) const
-{
- ::rtl::OUString sRet;
- sal_uInt16 nPos = GetPrefixPos( i );
- if( USHRT_MAX != nPos )
- sRet = aNamespaceMap.GetPrefixByIndex( nPos );
- return sRet;
-}
-
-inline const ::rtl::OUString& SvXMLAttrContainerData::GetNamespace(
- sal_uInt16 i ) const
-{
- return aNamespaceMap.GetNameByIndex( i );
-}
-
-inline const ::rtl::OUString& SvXMLAttrContainerData::GetPrefix( sal_uInt16 i ) const
-{
- return aNamespaceMap.GetPrefixByIndex( i );
-}
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/core/SvXMLAttr.cxx b/xmloff/source/core/SvXMLAttr.cxx
new file mode 100644
index 0000000..2a42dff
--- /dev/null
+++ b/xmloff/source/core/SvXMLAttr.cxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Nigel Hawkins - n.hawkins at gmx.com
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Major Contributor(s):
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <limits.h> //USHRT_MAX
+#include "SvXMLAttr.hxx"
+
+SvXMLAttr::SvXMLAttr( const rtl::OUString& rLName,
+ const rtl::OUString& rValue ) :
+ aPrefixPos(USHRT_MAX),
+ aLName(rLName),
+ aValue(rValue)
+{
+}
+
+SvXMLAttr::SvXMLAttr( const sal_uInt16 nPos,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue ) :
+ aPrefixPos(nPos),
+ aLName(rLName),
+ aValue(rValue)
+{
+}
+
+bool SvXMLAttr::operator== (const SvXMLAttr &rCmp) const
+{
+ return ( rCmp.aPrefixPos == aPrefixPos ) &&
+ ( rCmp.aLName == aLName ) &&
+ ( rCmp.aValue == aValue );
+}
+
+sal_uInt16 SvXMLAttr::getPrefixPos() const
+{
+ return aPrefixPos;
+}
+
+const rtl::OUString& SvXMLAttr::getLName() const
+{
+ return aLName;
+}
+
+const rtl::OUString& SvXMLAttr::getValue() const {
+ return aValue;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/core/SvXMLAttr.hxx b/xmloff/source/core/SvXMLAttr.hxx
new file mode 100644
index 0000000..6ac9cd9
--- /dev/null
+++ b/xmloff/source/core/SvXMLAttr.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Nigel Hawkins - n.hawkins at gmx.com
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Major Contributor(s):
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef _XMLOFF_SVXMLATTR_HXX
+#define _XMLOFF_SVXMLATTR_HXX
+
+#include <rtl/ustring.hxx> //rtl::OUString
+
+class SvXMLAttr {
+private:
+ sal_uInt16 aPrefixPos;
+ rtl::OUString aLName;
+ rtl::OUString aValue;
+public:
+ // Assuming OUString is well behaved, the default copy constructor and
+ // assignment operator are fine.
+ SvXMLAttr( const rtl::OUString& rLName,
+ const rtl::OUString& rValue );
+ SvXMLAttr( const sal_uInt16 nPos,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue );
+ bool operator== (const SvXMLAttr &rCmp) const;
+
+ sal_uInt16 getPrefixPos() const;
+ const rtl::OUString& getLName() const;
+ const rtl::OUString& getValue() const;
+};
+
+#endif /* _XMLOFF_SVXMLATTR_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/core/SvXMLAttrCollection.cxx b/xmloff/source/core/SvXMLAttrCollection.cxx
new file mode 100644
index 0000000..748ed5d
--- /dev/null
+++ b/xmloff/source/core/SvXMLAttrCollection.cxx
@@ -0,0 +1,188 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Nigel Hawkins - n.hawkins at gmx.com
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Major Contributor(s):
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "SvXMLAttrCollection.hxx"
+#include <limits.h> //USHRT_MAX
+
+bool SvXMLAttrCollection::operator ==( const SvXMLAttrCollection& rCmp ) const
+{
+ return (rCmp.aNamespaceMap == aNamespaceMap) &&
+ (rCmp.aAttrs == aAttrs);
+}
+
+sal_Bool SvXMLAttrCollection::AddAttr( const rtl::OUString& rLName,
+ const rtl::OUString& rValue )
+{
+ aAttrs.push_back( SvXMLAttr(rLName, rValue) );
+ return sal_True;
+}
+
+sal_Bool SvXMLAttrCollection::AddAttr( const rtl::OUString& rPrefix,
+ const rtl::OUString& rNamespace,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue )
+{
+ sal_uInt16 nPos = aNamespaceMap.Add( rPrefix, rNamespace );
+ aAttrs.push_back( SvXMLAttr(nPos, rLName, rValue) );
+ return sal_True;
+}
+
+sal_Bool SvXMLAttrCollection::AddAttr( const rtl::OUString& rPrefix,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue )
+{
+ sal_uInt16 nPos = aNamespaceMap.GetIndexByPrefix( rPrefix );
+ if( USHRT_MAX == nPos )
+ return sal_False;
+ aAttrs.push_back( SvXMLAttr(nPos, rLName, rValue) );
+ return sal_True;
+}
+
+sal_Bool SvXMLAttrCollection::SetAt( size_t i,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue )
+{
+ if( i >= GetAttrCount() )
+ return sal_False;
+ aAttrs[i] = SvXMLAttr(rLName, rValue);
+ return sal_True;
+}
+
+sal_Bool SvXMLAttrCollection::SetAt( size_t i,
+ const rtl::OUString& rPrefix,
+ const rtl::OUString& rNamespace,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue )
+{
+ if( i >= GetAttrCount() )
+ return sal_False;
+
+ sal_uInt16 nPos = aNamespaceMap.Add( rPrefix, rNamespace );
+ if( USHRT_MAX == nPos )
+ return sal_False;
+
+ aAttrs[i] = SvXMLAttr(nPos, rLName, rValue);
+ return sal_True;
+}
+
+sal_Bool SvXMLAttrCollection::SetAt( size_t i,
+ const rtl::OUString& rPrefix,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue )
+{
+ if( i >= GetAttrCount() )
+ return sal_False;
+
+ sal_uInt16 nPos = aNamespaceMap.GetIndexByPrefix( rPrefix );
+ if( USHRT_MAX == nPos )
+ return sal_False;
+
+ aAttrs[i] = SvXMLAttr(nPos, rLName, rValue);
+ return sal_True;
+}
+
+void SvXMLAttrCollection::Remove( size_t i )
+{
+ if( i < GetAttrCount() )
+ {
+ aAttrs.erase( aAttrs.begin() + i );
+ }
+ else
+ {
+ OSL_FAIL( "illegal index" );
+ }
+}
+
+size_t SvXMLAttrCollection::GetAttrCount() const
+{
+ return aAttrs.size();
+}
+
+const rtl::OUString& SvXMLAttrCollection::GetAttrLName(size_t i) const
+{
+ OSL_ENSURE( i < aAttrs.size(), "SvXMLAttrContainerData::GetLName: illegal index" );
+ return aAttrs[i].getLName();
+}
+
+const rtl::OUString& SvXMLAttrCollection::GetAttrValue(size_t i) const
+{
+ OSL_ENSURE( i < aAttrs.size(), "SvXMLAttrContainerData::GetValue: illegal index" );
+ return aAttrs[i].getValue();
+}
+
+const rtl::OUString SvXMLAttrCollection::GetAttrNamespace( size_t i ) const
+{
+ rtl::OUString sRet;
+ sal_uInt16 nPos = GetPrefixPos( i );
+ //Does this point to a valid namespace entry?
+ if( USHRT_MAX != nPos )
+ sRet = aNamespaceMap.GetNameByIndex( nPos );
+ return sRet;
+}
+
+const rtl::OUString SvXMLAttrCollection::GetAttrPrefix( size_t i ) const
+{
+ rtl::OUString sRet;
+ sal_uInt16 nPos = GetPrefixPos( i );
+ //Does this point to a valid namespace entry?
+ if( USHRT_MAX != nPos )
+ sRet = aNamespaceMap.GetPrefixByIndex( nPos );
+ return sRet;
+}
+
+const rtl::OUString& SvXMLAttrCollection::GetNamespace( sal_uInt16 i ) const
+{
+ return aNamespaceMap.GetNameByIndex( i );
+}
+
+const rtl::OUString& SvXMLAttrCollection::GetPrefix( sal_uInt16 i ) const
+{
+ return aNamespaceMap.GetPrefixByIndex( i );
+}
+
+sal_uInt16 SvXMLAttrCollection::GetFirstNamespaceIndex() const
+{
+ return aNamespaceMap.GetFirstIndex();
+}
+
+sal_uInt16 SvXMLAttrCollection::GetNextNamespaceIndex( sal_uInt16 nIdx ) const
+{
+ return aNamespaceMap.GetNextIndex( nIdx );
+}
+
+sal_uInt16 SvXMLAttrCollection::GetPrefixPos( size_t i ) const
+{
+// DBG_ASSERT( i >= 0 && i < aAttrs.size(),
+// "SvXMLAttrCollection::GetPrefixPos: illegal index" );
+ return aAttrs[i].getPrefixPos();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
diff --git a/xmloff/source/core/SvXMLAttrCollection.hxx b/xmloff/source/core/SvXMLAttrCollection.hxx
new file mode 100644
index 0000000..96fb88a
--- /dev/null
+++ b/xmloff/source/core/SvXMLAttrCollection.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Nigel Hawkins - n.hawkins at gmx.com
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Major Contributor(s):
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef SVXMLATTRCOLLECTION_HXX_
+#define SVXMLATTRCOLLECTION_HXX_
+
+#include "SvXMLAttr.hxx"
+
+#include <xmloff/nmspmap.hxx> //SvXMLNamespaceMap
+#include <rtl/ustring.hxx> //rtl::OUString
+#include <sal/types.h> //sal_uInt16 and sal_Bool
+#include <vector>
+
+class SvXMLAttrCollection
+{
+public:
+ SvXMLNamespaceMap aNamespaceMap;
+ std::vector<SvXMLAttr> aAttrs;
+
+ bool operator==(const SvXMLAttrCollection &rCmp) const;
+ sal_Bool AddAttr( const rtl::OUString& rLName,
+ const rtl::OUString& rValue );
+ sal_Bool AddAttr( const rtl::OUString& rPrefix,
+ const rtl::OUString& rNamespace,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue );
+ sal_Bool AddAttr( const rtl::OUString& rPrefix,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue );
+
+ sal_Bool SetAt( size_t i,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue );
+ sal_Bool SetAt( size_t i,
+ const rtl::OUString& rPrefix,
+ const rtl::OUString& rNamespace,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue );
+ sal_Bool SetAt( size_t i,
+ const rtl::OUString& rPrefix,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue );
+
+ void Remove( size_t i );
+
+ size_t GetAttrCount() const;
+ const rtl::OUString& GetAttrLName(size_t i) const;
+ const rtl::OUString& GetAttrValue(size_t i) const;
+ const rtl::OUString GetAttrNamespace( size_t i ) const;
+ const rtl::OUString GetAttrPrefix( size_t i ) const;
+ const rtl::OUString& GetNamespace( sal_uInt16 i ) const;
+ const rtl::OUString& GetPrefix( sal_uInt16 i ) const;
+ sal_uInt16 GetFirstNamespaceIndex() const;
+ sal_uInt16 GetNextNamespaceIndex( sal_uInt16 nIdx ) const;
+
+private:
+ sal_uInt16 GetPrefixPos( size_t i ) const;
+};
+
+#endif /* SVXMLATTRCOLLECTION_HXX_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
diff --git a/xmloff/source/core/unoatrcn.cxx b/xmloff/source/core/unoatrcn.cxx
index 38e0d4c..32b11db 100644
--- a/xmloff/source/core/unoatrcn.cxx
+++ b/xmloff/source/core/unoatrcn.cxx
@@ -33,6 +33,7 @@
#include <rtl/ustrbuf.hxx>
#include <rtl/memory.h>
#include <comphelper/servicehelper.hxx>
+#include <limits.h>
#include <xmloff/xmlcnimp.hxx>
diff --git a/xmloff/source/core/xmlcnimp.cxx b/xmloff/source/core/xmlcnimp.cxx
new file mode 100644
index 0000000..79f6ef6
--- /dev/null
+++ b/xmloff/source/core/xmlcnimp.cxx
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "SvXMLAttrCollection.hxx"
+#include <xmloff/xmlcnimp.hxx>
+#include <rtl/ustring.hxx> //rtl::OUString
+
+SvXMLAttrContainerData::SvXMLAttrContainerData() : pimpl( new SvXMLAttrCollection() )
+{
+}
+
+SvXMLAttrContainerData::SvXMLAttrContainerData(const SvXMLAttrContainerData &rCopy) :
+ pimpl( new SvXMLAttrCollection( *(rCopy.pimpl) ) )
+{
+}
+
+//Need destructor defined (despite it being empty) to avoid "checked_delete"
+//compiler errors.
+SvXMLAttrContainerData::~SvXMLAttrContainerData()
+{
+}
+
+int SvXMLAttrContainerData::operator ==( const SvXMLAttrContainerData& rCmp ) const
+{
+ return ( *(rCmp.pimpl) == *(pimpl) );
+}
+
+sal_Bool SvXMLAttrContainerData::AddAttr( const rtl::OUString& rLName,
+ const rtl::OUString& rValue )
+{
+ return pimpl->AddAttr(rLName, rValue);
+}
+
+sal_Bool SvXMLAttrContainerData::AddAttr( const rtl::OUString& rPrefix,
+ const rtl::OUString& rNamespace,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue )
+{
+ return pimpl->AddAttr(rPrefix, rNamespace, rLName, rValue);
+}
+
+sal_Bool SvXMLAttrContainerData::AddAttr( const rtl::OUString& rPrefix,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue )
+{
+ return pimpl->AddAttr(rPrefix, rLName, rValue);
+}
+
+sal_Bool SvXMLAttrContainerData::SetAt( size_t i,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue )
+{
+ return pimpl->SetAt(i, rLName, rValue);
+}
+
+sal_Bool SvXMLAttrContainerData::SetAt( size_t i,
+ const rtl::OUString& rPrefix,
+ const rtl::OUString& rNamespace,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue )
+{
+ return pimpl->SetAt(i, rPrefix, rNamespace, rLName, rValue);
+}
+
+sal_Bool SvXMLAttrContainerData::SetAt( size_t i,
+ const rtl::OUString& rPrefix,
+ const rtl::OUString& rLName,
+ const rtl::OUString& rValue )
+{
+ return pimpl->SetAt(i, rPrefix, rLName, rValue);
+}
+
+void SvXMLAttrContainerData::Remove( size_t i )
+{
+ pimpl->Remove(i);
+}
+
+size_t SvXMLAttrContainerData::GetAttrCount() const
+{
+ return pimpl->GetAttrCount();
+}
+
+const rtl::OUString& SvXMLAttrContainerData::GetAttrLName(size_t i) const
+{
+ return pimpl->GetAttrLName(i);
+}
+
+const rtl::OUString& SvXMLAttrContainerData::GetAttrValue(size_t i) const
+{
+ return pimpl->GetAttrValue(i);
+}
+
+const rtl::OUString SvXMLAttrContainerData::GetAttrNamespace( size_t i ) const
+{
+ return pimpl->GetAttrNamespace(i);
+}
+
+const rtl::OUString SvXMLAttrContainerData::GetAttrPrefix( size_t i ) const
+{
+ return pimpl->GetAttrPrefix(i);
+}
+
+const rtl::OUString& SvXMLAttrContainerData::GetNamespace( sal_uInt16 i ) const
+{
+ return pimpl->GetNamespace(i);
+}
+
+const rtl::OUString& SvXMLAttrContainerData::GetPrefix( sal_uInt16 i ) const
+{
+ return pimpl->GetPrefix(i);
+}
+
+sal_uInt16 SvXMLAttrContainerData::GetFirstNamespaceIndex() const
+{
+ return pimpl->GetFirstNamespaceIndex();
+}
+
+sal_uInt16 SvXMLAttrContainerData::GetNextNamespaceIndex( sal_uInt16 nIdx ) const
+{
+ return pimpl->GetNextNamespaceIndex( nIdx );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/core/xmlcnitm.cxx b/xmloff/source/core/xmlcnitm.cxx
deleted file mode 100644
index 7c7864b..0000000
--- a/xmloff/source/core/xmlcnitm.cxx
+++ /dev/null
@@ -1,221 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmloff.hxx"
-#include <tools/debug.hxx>
-#include <com/sun/star/xml/AttributeData.hpp>
-#include <com/sun/star/lang/XUnoTunnel.hpp>
-
-#include <xmloff/xmlcnimp.hxx>
-#include "xmloff/unoatrcn.hxx"
-
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::container;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::xml;
-
-using ::rtl::OUString;
-
-typedef ::rtl::OUString *OUStringPtr;
-SV_DECL_PTRARR_DEL( SvXMLAttrContainerData_Impl, OUStringPtr, 5, 5 )
-SV_IMPL_PTRARR( SvXMLAttrContainerData_Impl, OUStringPtr )
-
-
-SvXMLAttrContainerData::SvXMLAttrContainerData(
- const SvXMLAttrContainerData& rImpl ) :
- aNamespaceMap( rImpl.aNamespaceMap ),
- pLNames( new SvXMLAttrContainerData_Impl ),
- pValues( new SvXMLAttrContainerData_Impl )
-{
- sal_uInt16 nCount = rImpl.pLNames->Count();
- for( sal_uInt16 i=0; i<nCount; i++ )
- {
- aPrefixPoss.Insert( rImpl.aPrefixPoss[i], i );
- pLNames->Insert( new OUString( *(*rImpl.pLNames)[i] ), i );
- pValues->Insert( new OUString( *(*rImpl.pValues)[i] ), i );
- }
-}
-
-SvXMLAttrContainerData::SvXMLAttrContainerData() :
- pLNames( new SvXMLAttrContainerData_Impl ),
- pValues( new SvXMLAttrContainerData_Impl )
-{
-}
-
-SvXMLAttrContainerData::~SvXMLAttrContainerData()
-{
- delete pLNames;
- delete pValues;
-}
-
-int SvXMLAttrContainerData::operator ==(
- const SvXMLAttrContainerData& rCmp ) const
-{
- sal_Bool bRet = pLNames->Count() == rCmp.pLNames->Count() &&
- aNamespaceMap == rCmp.aNamespaceMap;
- if( bRet )
- {
- sal_uInt16 nCount = pLNames->Count();
- sal_uInt16 i;
- for( i=0; bRet && i < nCount; i++ )
- bRet = aPrefixPoss[i] == rCmp.aPrefixPoss[i];
-
- if( bRet )
- {
- for( i=0; bRet && i < nCount; i++ )
- bRet = *(*pLNames)[i] == *(*rCmp.pLNames)[i] &&
- *(*pValues)[i] == *(*rCmp.pValues)[i];
- }
- }
-
- return (int)bRet;
-}
-
-sal_Bool SvXMLAttrContainerData::AddAttr( const OUString& rLName,
- const OUString& rValue )
-{
- aPrefixPoss.Insert( USHRT_MAX, aPrefixPoss.Count() );
- pLNames->Insert( new OUString(rLName), pLNames->Count() );
- pValues->Insert( new OUString(rValue), pValues->Count() );
-
- return sal_True;
-}
-
-sal_Bool SvXMLAttrContainerData::AddAttr( const OUString& rPrefix,
- const OUString& rNamespace,
- const OUString& rLName,
- const OUString& rValue )
-{
- sal_uInt16 nPos = aNamespaceMap.Add( rPrefix, rNamespace );
- aPrefixPoss.Insert( nPos, aPrefixPoss.Count() );
- pLNames->Insert( new OUString(rLName), pLNames->Count() );
- pValues->Insert( new OUString(rValue), pValues->Count() );
-
- return sal_True;
-}
-
-sal_Bool SvXMLAttrContainerData::AddAttr( const OUString& rPrefix,
- const OUString& rLName,
- const OUString& rValue )
-{
- sal_uInt16 nPos = aNamespaceMap.GetIndexByPrefix( rPrefix );
- if( USHRT_MAX == nPos )
- return sal_False;
-
- aPrefixPoss.Insert( nPos, aPrefixPoss.Count() );
- pLNames->Insert( new OUString(rLName), pLNames->Count() );
- pValues->Insert( new OUString(rValue), pValues->Count() );
-
- return sal_True;
-}
-
-sal_Bool SvXMLAttrContainerData::SetAt( sal_uInt16 i,
- const rtl::OUString& rLName, const rtl::OUString& rValue )
-{
- if( i >= GetAttrCount() )
- return sal_False;
-
- *(*pLNames)[i] = rLName;
- *(*pValues)[i] = rValue;
- aPrefixPoss[i] = USHRT_MAX;
-
- return sal_True;
-}
-
-sal_Bool SvXMLAttrContainerData::SetAt( sal_uInt16 i,
- const rtl::OUString& rPrefix, const rtl::OUString& rNamespace,
- const rtl::OUString& rLName, const rtl::OUString& rValue )
-{
- if( i >= GetAttrCount() )
- return sal_False;
-
- sal_uInt16 nPos = aNamespaceMap.Add( rPrefix, rNamespace );
- if( USHRT_MAX == nPos )
- return sal_False;
-
- *(*pLNames)[i] = rLName;
- *(*pValues)[i] = rValue;
- aPrefixPoss[i] = nPos;
-
- return sal_True;
-}
-
-sal_Bool SvXMLAttrContainerData::SetAt( sal_uInt16 i,
- const rtl::OUString& rPrefix,
- const rtl::OUString& rLName,
- const rtl::OUString& rValue )
-{
- if( i >= GetAttrCount() )
- return sal_False;
-
- sal_uInt16 nPos = aNamespaceMap.GetIndexByPrefix( rPrefix );
- if( USHRT_MAX == nPos )
- return sal_False;
-
- *(*pLNames)[i] = rLName;
- *(*pValues)[i] = rValue;
- aPrefixPoss[i] = nPos;
-
- return sal_True;
-}
-
-void SvXMLAttrContainerData::Remove( sal_uInt16 i )
-{
- if( i < GetAttrCount() )
- {
- delete (*pLNames)[i];
- pLNames->Remove( i );
- delete (*pValues)[i];
- pValues->Remove( i );
- aPrefixPoss.Remove( i );
- }
- else
- {
- OSL_FAIL( "illegal index" );
- }
-}
-
-sal_uInt16 SvXMLAttrContainerData::GetAttrCount() const
-{
- return pLNames->Count();
-}
-
-const ::rtl::OUString& SvXMLAttrContainerData::GetAttrLName(sal_uInt16 i) const
-{
- OSL_ENSURE( i < pLNames->Count(), "SvXMLAttrContainerData::GetLName: illegal index" );
- return *(*pLNames)[i];
-}
-
-const ::rtl::OUString& SvXMLAttrContainerData::GetAttrValue(sal_uInt16 i) const
-{
- OSL_ENSURE( i < pValues->Count(), "SvXMLAttrContainerData::GetValue: illegal index" );
- return *(*pValues)[i];
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list