Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_svtools / xmlcnimp.hxx
blobedc7efe369d8e12ab6b8b305e7faa16bd53df482
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlcnimp.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVTOOLS_XMLCNIMP_HXX
32 #define _SVTOOLS_XMLCNIMP_HXX
34 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
35 #include <com/sun/star/container/XNameAccess.hpp>
36 #endif
38 #ifndef _SVARRAY_HXX
39 #include <bf_svtools/svarray.hxx>
40 #endif
42 #ifndef _SVTOOLS_NMSPMAP_HXX
43 #include <xmloff/nmspmap.hxx>
44 #endif
46 namespace rtl { class OUString; }
48 namespace binfilter
51 typedef ::rtl::OUString *OUStringPtr;
53 SV_DECL_PTRARR_DEL( OUStringsDtor2_Impl, OUStringPtr, 5, 5 )
55 class SvXMLAttrContainerItem_Impl
57 SvXMLNamespaceMap aNamespaceMap;
58 SvUShorts aPrefixPoss;
59 OUStringsDtor2_Impl aLNames;
60 OUStringsDtor2_Impl aValues;
62 inline sal_uInt16 GetPrefixPos( sal_uInt16 i ) const;
63 public:
65 SvXMLAttrContainerItem_Impl( const SvXMLAttrContainerItem_Impl& rImpl );
66 SvXMLAttrContainerItem_Impl();
68 int operator ==( const SvXMLAttrContainerItem_Impl& rCmp ) const;
70 BOOL AddAttr( const ::rtl::OUString& rLName, const ::rtl::OUString& rValue );
71 BOOL AddAttr( const ::rtl::OUString& rPrefix, const ::rtl::OUString& rNamespace,
72 const ::rtl::OUString& rLName, const ::rtl::OUString& rValue );
73 BOOL AddAttr( const ::rtl::OUString& rPrefix,
74 const ::rtl::OUString& rLName,
75 const ::rtl::OUString& rValue );
77 sal_uInt16 GetAttrCount() const { return aLNames.Count(); }
78 inline ::rtl::OUString GetAttrNamespace( sal_uInt16 i ) const;
79 inline ::rtl::OUString GetAttrPrefix( sal_uInt16 i ) const;
80 inline const ::rtl::OUString& GetAttrLName( sal_uInt16 i ) const;
81 inline const ::rtl::OUString& GetAttrValue( sal_uInt16 i ) const;
83 sal_uInt16 GetFirstNamespaceIndex() const { return aNamespaceMap.GetFirstIndex(); }
84 sal_uInt16 GetNextNamespaceIndex( sal_uInt16 nIdx ) const { return aNamespaceMap.GetNextIndex( nIdx ); }
85 inline const ::rtl::OUString& GetNamespace( sal_uInt16 i ) const;
86 inline const ::rtl::OUString& GetPrefix( sal_uInt16 i ) const;
88 BOOL SetAt( sal_uInt16 i,
89 const ::rtl::OUString& rLName, const ::rtl::OUString& rValue );
90 BOOL SetAt( sal_uInt16 i,
91 const ::rtl::OUString& rPrefix, const ::rtl::OUString& rNamespace,
92 const ::rtl::OUString& rLName, const ::rtl::OUString& rValue );
93 BOOL SetAt( sal_uInt16 i,
94 const ::rtl::OUString& rPrefix,
95 const ::rtl::OUString& rLName,
96 const ::rtl::OUString& rValue );
98 void Remove( sal_uInt16 i );
101 inline sal_uInt16 SvXMLAttrContainerItem_Impl::GetPrefixPos( sal_uInt16 i ) const
103 // DBG_ASSERT( i >= 0 && i < aPrefixPoss.Count(),
104 // "SvXMLAttrContainerItem_Impl::GetPrefixPos: illegal index" );
105 return aPrefixPoss[i];
108 inline ::rtl::OUString SvXMLAttrContainerItem_Impl::GetAttrNamespace( sal_uInt16 i ) const
110 ::rtl::OUString sRet;
111 sal_uInt16 nPos = GetPrefixPos( i );
112 if( USHRT_MAX != nPos )
113 sRet = aNamespaceMap.GetNameByIndex( nPos );
114 return sRet;
117 inline ::rtl::OUString SvXMLAttrContainerItem_Impl::GetAttrPrefix( sal_uInt16 i ) const
119 ::rtl::OUString sRet;
120 sal_uInt16 nPos = GetPrefixPos( i );
121 if( USHRT_MAX != nPos )
122 sRet = aNamespaceMap.GetPrefixByIndex( nPos );
123 return sRet;
126 inline const ::rtl::OUString& SvXMLAttrContainerItem_Impl::GetAttrLName(sal_uInt16 i) const
128 DBG_ASSERT( i >= 0 && i < aLNames.Count(),
129 "SvXMLAttrContainerItem_Impl::GetLName: illegal index" );
130 return *aLNames[i];
133 inline const ::rtl::OUString& SvXMLAttrContainerItem_Impl::GetAttrValue(sal_uInt16 i) const
135 DBG_ASSERT( i >= 0 && i < aValues.Count(),
136 "SvXMLAttrContainerItem_Impl::GetValue: illegal index" );
137 return *aValues[i];
140 inline const ::rtl::OUString& SvXMLAttrContainerItem_Impl::GetNamespace(
141 sal_uInt16 i ) const
143 return aNamespaceMap.GetNameByIndex( i );
146 inline const ::rtl::OUString& SvXMLAttrContainerItem_Impl::GetPrefix( sal_uInt16 i ) const
148 return aNamespaceMap.GetPrefixByIndex( i );
153 #endif