xref: /aoo4110/main/xmloff/inc/xmloff/xmlcnimp.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _XMLOFF_XMLCNIMP_HXX
25 #define _XMLOFF_XMLCNIMP_HXX
26 
27 #include "sal/config.h"
28 #include "xmloff/dllapi.h"
29 #include "sal/types.h"
30 #include <com/sun/star/container/XNameAccess.hpp>
31 #include <svl/svarray.hxx>
32 #include <xmloff/nmspmap.hxx>
33 
34 #define _SVSTDARR_USHORTS
35 #include <svl/svstdarr.hxx>
36 
37 namespace rtl { class OUString; }
38 
39 class SvXMLAttrContainerData_Impl;
40 
41 class XMLOFF_DLLPUBLIC SvXMLAttrContainerData
42 {
43 	SvXMLNamespaceMap	aNamespaceMap;
44 	SvUShorts			aPrefixPoss;
45 	SvXMLAttrContainerData_Impl	*pLNames;
46 	SvXMLAttrContainerData_Impl	*pValues;
47 
48 	SAL_DLLPRIVATE inline sal_uInt16 GetPrefixPos( sal_uInt16 i ) const;
49 public:
50 
51 	SvXMLAttrContainerData( const SvXMLAttrContainerData& rImpl );
52 	SvXMLAttrContainerData();
53 	~SvXMLAttrContainerData();
54 
55 	int  operator ==( const SvXMLAttrContainerData& rCmp ) const;
56 
57 	sal_Bool AddAttr( const ::rtl::OUString& rLName, const rtl::OUString& rValue );
58 	sal_Bool AddAttr( const ::rtl::OUString& rPrefix, const rtl::OUString& rNamespace,
59 			  	  const ::rtl::OUString& rLName, const rtl::OUString& rValue );
60 	sal_Bool AddAttr( const ::rtl::OUString& rPrefix,
61 				  const ::rtl::OUString& rLName,
62 				  const ::rtl::OUString& rValue );
63 
64 	sal_uInt16 GetAttrCount() const;
65 	inline ::rtl::OUString GetAttrNamespace( sal_uInt16 i ) const;
66 	inline ::rtl::OUString GetAttrPrefix( sal_uInt16 i ) const;
67 	const ::rtl::OUString& GetAttrLName( sal_uInt16 i ) const;
68 	const ::rtl::OUString& GetAttrValue( sal_uInt16 i ) const;
69 
GetFirstNamespaceIndex() const70 	sal_uInt16 GetFirstNamespaceIndex() const { return aNamespaceMap.GetFirstIndex(); }
GetNextNamespaceIndex(sal_uInt16 nIdx) const71 	sal_uInt16 GetNextNamespaceIndex( sal_uInt16 nIdx ) const { return aNamespaceMap.GetNextIndex( nIdx ); }
72 	inline const ::rtl::OUString& GetNamespace( sal_uInt16 i ) const;
73 	inline const ::rtl::OUString& GetPrefix( sal_uInt16 i ) const;
74 
75 	sal_Bool SetAt( sal_uInt16 i,
76 				const ::rtl::OUString& rLName, const rtl::OUString& rValue );
77 	sal_Bool SetAt( sal_uInt16 i,
78 				const ::rtl::OUString& rPrefix, const rtl::OUString& rNamespace,
79 				const ::rtl::OUString& rLName, const rtl::OUString& rValue );
80 	sal_Bool SetAt( sal_uInt16 i,
81 				const ::rtl::OUString& rPrefix,
82 				const ::rtl::OUString& rLName,
83 				const ::rtl::OUString& rValue );
84 
85 	void Remove( sal_uInt16 i );
86 };
87 
GetPrefixPos(sal_uInt16 i) const88 inline sal_uInt16 SvXMLAttrContainerData::GetPrefixPos( sal_uInt16 i ) const
89 {
90 //	DBG_ASSERT( i >= 0 && i < aPrefixPoss.Count(),
91 //				"SvXMLAttrContainerData::GetPrefixPos: illegal index" );
92 	return aPrefixPoss[i];
93 }
94 
GetAttrNamespace(sal_uInt16 i) const95 inline ::rtl::OUString SvXMLAttrContainerData::GetAttrNamespace( sal_uInt16 i ) const
96 {
97 	::rtl::OUString sRet;
98 	sal_uInt16 nPos = GetPrefixPos( i );
99 	if( USHRT_MAX != nPos )
100 		sRet = aNamespaceMap.GetNameByIndex( nPos );
101 	return sRet;
102 }
103 
GetAttrPrefix(sal_uInt16 i) const104 inline ::rtl::OUString SvXMLAttrContainerData::GetAttrPrefix( sal_uInt16 i ) const
105 {
106 	::rtl::OUString sRet;
107 	sal_uInt16 nPos = GetPrefixPos( i );
108 	if( USHRT_MAX != nPos )
109 		sRet = aNamespaceMap.GetPrefixByIndex( nPos );
110 	return sRet;
111 }
112 
GetNamespace(sal_uInt16 i) const113 inline const ::rtl::OUString& SvXMLAttrContainerData::GetNamespace(
114 															sal_uInt16 i ) const
115 {
116 	return aNamespaceMap.GetNameByIndex( i );
117 }
118 
GetPrefix(sal_uInt16 i) const119 inline const ::rtl::OUString& SvXMLAttrContainerData::GetPrefix( sal_uInt16 i ) const
120 {
121 	return aNamespaceMap.GetPrefixByIndex( i );
122 }
123 
124 #endif
125 
126