xref: /trunk/main/xmloff/inc/xmloff/xmlcnimp.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _XMLOFF_XMLCNIMP_HXX
29 #define _XMLOFF_XMLCNIMP_HXX
30 
31 #include "sal/config.h"
32 #include "xmloff/dllapi.h"
33 #include "sal/types.h"
34 #include <com/sun/star/container/XNameAccess.hpp>
35 #include <svl/svarray.hxx>
36 #include <xmloff/nmspmap.hxx>
37 
38 #define _SVSTDARR_USHORTS
39 #include <svl/svstdarr.hxx>
40 
41 namespace rtl { class OUString; }
42 
43 class SvXMLAttrContainerData_Impl;
44 
45 class XMLOFF_DLLPUBLIC SvXMLAttrContainerData
46 {
47 	SvXMLNamespaceMap	aNamespaceMap;
48 	SvUShorts			aPrefixPoss;
49 	SvXMLAttrContainerData_Impl	*pLNames;
50 	SvXMLAttrContainerData_Impl	*pValues;
51 
52 	SAL_DLLPRIVATE inline sal_uInt16 GetPrefixPos( sal_uInt16 i ) const;
53 public:
54 
55 	SvXMLAttrContainerData( const SvXMLAttrContainerData& rImpl );
56 	SvXMLAttrContainerData();
57 	~SvXMLAttrContainerData();
58 
59 	int  operator ==( const SvXMLAttrContainerData& rCmp ) const;
60 
61 	sal_Bool AddAttr( const ::rtl::OUString& rLName, const rtl::OUString& rValue );
62 	sal_Bool AddAttr( const ::rtl::OUString& rPrefix, const rtl::OUString& rNamespace,
63 			  	  const ::rtl::OUString& rLName, const rtl::OUString& rValue );
64 	sal_Bool AddAttr( const ::rtl::OUString& rPrefix,
65 				  const ::rtl::OUString& rLName,
66 				  const ::rtl::OUString& rValue );
67 
68 	sal_uInt16 GetAttrCount() const;
69 	inline ::rtl::OUString GetAttrNamespace( sal_uInt16 i ) const;
70 	inline ::rtl::OUString GetAttrPrefix( sal_uInt16 i ) const;
71 	const ::rtl::OUString& GetAttrLName( sal_uInt16 i ) const;
72 	const ::rtl::OUString& GetAttrValue( sal_uInt16 i ) const;
73 
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;
78 
79 	sal_Bool SetAt( sal_uInt16 i,
80 				const ::rtl::OUString& rLName, const rtl::OUString& rValue );
81 	sal_Bool SetAt( sal_uInt16 i,
82 				const ::rtl::OUString& rPrefix, const rtl::OUString& rNamespace,
83 				const ::rtl::OUString& rLName, const rtl::OUString& rValue );
84 	sal_Bool SetAt( sal_uInt16 i,
85 				const ::rtl::OUString& rPrefix,
86 				const ::rtl::OUString& rLName,
87 				const ::rtl::OUString& rValue );
88 
89 	void Remove( sal_uInt16 i );
90 };
91 
92 inline sal_uInt16 SvXMLAttrContainerData::GetPrefixPos( sal_uInt16 i ) const
93 {
94 //	DBG_ASSERT( i >= 0 && i < aPrefixPoss.Count(),
95 //				"SvXMLAttrContainerData::GetPrefixPos: illegal index" );
96 	return aPrefixPoss[i];
97 }
98 
99 inline ::rtl::OUString SvXMLAttrContainerData::GetAttrNamespace( sal_uInt16 i ) const
100 {
101 	::rtl::OUString sRet;
102 	sal_uInt16 nPos = GetPrefixPos( i );
103 	if( USHRT_MAX != nPos )
104 		sRet = aNamespaceMap.GetNameByIndex( nPos );
105 	return sRet;
106 }
107 
108 inline ::rtl::OUString SvXMLAttrContainerData::GetAttrPrefix( sal_uInt16 i ) const
109 {
110 	::rtl::OUString sRet;
111 	sal_uInt16 nPos = GetPrefixPos( i );
112 	if( USHRT_MAX != nPos )
113 		sRet = aNamespaceMap.GetPrefixByIndex( nPos );
114 	return sRet;
115 }
116 
117 inline const ::rtl::OUString& SvXMLAttrContainerData::GetNamespace(
118 															sal_uInt16 i ) const
119 {
120 	return aNamespaceMap.GetNameByIndex( i );
121 }
122 
123 inline const ::rtl::OUString& SvXMLAttrContainerData::GetPrefix( sal_uInt16 i ) const
124 {
125 	return aNamespaceMap.GetPrefixByIndex( i );
126 }
127 
128 #endif
129 
130