update dev300-m57
[ooovba.git] / svtools / inc / xmlcnimp.hxx
blobbc7a1ed4a910ea10048c33eb76a4f9a52cf741b5
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.5 $
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 #include <com/sun/star/container/XNameAccess.hpp>
35 #include <svtools/svarray.hxx>
37 #ifndef _SVTOOLS_NMSPMAP_HXX
38 #include <xmloff/nmspmap.hxx>
39 #endif
41 namespace rtl { class OUString; }
43 typedef ::rtl::OUString *OUStringPtr;
44 SV_DECL_PTRARR_DEL( OUStringsDtor2_Impl, OUStringPtr, 5, 5 )
46 class SvXMLAttrContainerItem_Impl
48 SvXMLNamespaceMap aNamespaceMap;
49 SvUShorts aPrefixPoss;
50 OUStringsDtor2_Impl aLNames;
51 OUStringsDtor2_Impl aValues;
53 inline sal_uInt16 GetPrefixPos( sal_uInt16 i ) const;
54 public:
56 SvXMLAttrContainerItem_Impl( const SvXMLAttrContainerItem_Impl& rImpl );
57 SvXMLAttrContainerItem_Impl();
59 int operator ==( const SvXMLAttrContainerItem_Impl& rCmp ) const;
61 BOOL AddAttr( const ::rtl::OUString& rLName, const ::rtl::OUString& rValue );
62 BOOL AddAttr( const ::rtl::OUString& rPrefix, const ::rtl::OUString& rNamespace,
63 const ::rtl::OUString& rLName, const ::rtl::OUString& rValue );
64 BOOL AddAttr( const ::rtl::OUString& rPrefix,
65 const ::rtl::OUString& rLName,
66 const ::rtl::OUString& rValue );
68 sal_uInt16 GetAttrCount() const { return aLNames.Count(); }
69 inline ::rtl::OUString GetAttrNamespace( sal_uInt16 i ) const;
70 inline ::rtl::OUString GetAttrPrefix( sal_uInt16 i ) const;
71 inline const ::rtl::OUString& GetAttrLName( sal_uInt16 i ) const;
72 inline const ::rtl::OUString& GetAttrValue( sal_uInt16 i ) const;
74 sal_uInt16 GetFirstNamespaceIndex() const { return aNamespaceMap.GetFirstIndex(); }
75 sal_uInt16 GetNextNamespaceIndex( sal_uInt16 nIdx ) const { return aNamespaceMap.GetNextIndex( nIdx ); }
76 inline const ::rtl::OUString& GetNamespace( sal_uInt16 i ) const;
77 inline const ::rtl::OUString& GetPrefix( sal_uInt16 i ) const;
79 BOOL SetAt( sal_uInt16 i,
80 const ::rtl::OUString& rLName, const ::rtl::OUString& rValue );
81 BOOL SetAt( sal_uInt16 i,
82 const ::rtl::OUString& rPrefix, const ::rtl::OUString& rNamespace,
83 const ::rtl::OUString& rLName, const ::rtl::OUString& rValue );
84 BOOL SetAt( sal_uInt16 i,
85 const ::rtl::OUString& rPrefix,
86 const ::rtl::OUString& rLName,
87 const ::rtl::OUString& rValue );
89 void Remove( sal_uInt16 i );
92 inline sal_uInt16 SvXMLAttrContainerItem_Impl::GetPrefixPos( sal_uInt16 i ) const
94 // DBG_ASSERT( i >= 0 && i < aPrefixPoss.Count(),
95 // "SvXMLAttrContainerItem_Impl::GetPrefixPos: illegal index" );
96 return aPrefixPoss[i];
99 inline ::rtl::OUString SvXMLAttrContainerItem_Impl::GetAttrNamespace( sal_uInt16 i ) const
101 ::rtl::OUString sRet;
102 sal_uInt16 nPos = GetPrefixPos( i );
103 if( USHRT_MAX != nPos )
104 sRet = aNamespaceMap.GetNameByIndex( nPos );
105 return sRet;
108 inline ::rtl::OUString SvXMLAttrContainerItem_Impl::GetAttrPrefix( sal_uInt16 i ) const
110 ::rtl::OUString sRet;
111 sal_uInt16 nPos = GetPrefixPos( i );
112 if( USHRT_MAX != nPos )
113 sRet = aNamespaceMap.GetPrefixByIndex( nPos );
114 return sRet;
117 inline const ::rtl::OUString& SvXMLAttrContainerItem_Impl::GetAttrLName(sal_uInt16 i) const
119 DBG_ASSERT( i >= 0 && i < aLNames.Count(),
120 "SvXMLAttrContainerItem_Impl::GetLName: illegal index" );
121 return *aLNames[i];
124 inline const ::rtl::OUString& SvXMLAttrContainerItem_Impl::GetAttrValue(sal_uInt16 i) const
126 DBG_ASSERT( i >= 0 && i < aValues.Count(),
127 "SvXMLAttrContainerItem_Impl::GetValue: illegal index" );
128 return *aValues[i];
131 inline const ::rtl::OUString& SvXMLAttrContainerItem_Impl::GetNamespace(
132 sal_uInt16 i ) const
134 return aNamespaceMap.GetNameByIndex( i );
137 inline const ::rtl::OUString& SvXMLAttrContainerItem_Impl::GetPrefix( sal_uInt16 i ) const
139 return aNamespaceMap.GetPrefixByIndex( i );
142 #endif