xref: /aoo4110/main/xmloff/inc/StyleMap.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_STYLEMAP_HXX
25 #define _XMLOFF_STYLEMAP_HXX
26 
27 #include <com/sun/star/lang/XUnoTunnel.hpp>
28 #include <cppuhelper/implbase1.hxx>
29 #include <hash_map>
30 
31 struct StyleNameKey_Impl
32 {
33 	sal_uInt16 m_nFamily;
34 	::rtl::OUString m_aName;
35 
StyleNameKey_ImplStyleNameKey_Impl36 	inline StyleNameKey_Impl( sal_uInt16 nFamily,
37 						 	  const ::rtl::OUString& rName ) :
38 		m_nFamily( nFamily ),
39 		m_aName( rName )
40 	{
41 	}
42 
StyleNameKey_ImplStyleNameKey_Impl43 	inline StyleNameKey_Impl() :
44 		m_nFamily( 0 )
45 	{
46 	}
47 };
48 
49 struct StyleNameHash_Impl
50 {
51 	inline size_t operator()( const StyleNameKey_Impl& r ) const;
52 	inline bool operator()( const StyleNameKey_Impl& r1,
53 				   			const StyleNameKey_Impl& r2 ) const;
54 };
55 
operator ()(const StyleNameKey_Impl & r) const56 inline size_t StyleNameHash_Impl::operator()( const StyleNameKey_Impl& r ) const
57 {
58 	return static_cast< size_t >( r.m_nFamily ) +
59 		   static_cast< size_t >( r.m_aName.hashCode() );
60 }
61 
operator ()(const StyleNameKey_Impl & r1,const StyleNameKey_Impl & r2) const62 inline bool StyleNameHash_Impl::operator()(
63 		const StyleNameKey_Impl& r1,
64 		const StyleNameKey_Impl& r2 ) const
65 {
66 	return r1.m_nFamily == r2.m_nFamily && r1.m_aName == r2.m_aName;
67 }
68 
69 class StyleMap :
70 	public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XUnoTunnel>,
71 	public ::std::hash_map< StyleNameKey_Impl, ::rtl::OUString,
72 						    StyleNameHash_Impl, StyleNameHash_Impl >
73 {
74 
75 public:
76 
77 	StyleMap();
78 	virtual ~StyleMap();
79 
80 	static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
81 	static StyleMap* getImplementation(
82 			::com::sun::star::uno::Reference<
83 				::com::sun::star::uno::XInterface > ) throw();
84 
85 	// XUnoTunnel
86     virtual sal_Int64 SAL_CALL getSomething(
87 				const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
88 };
89 
90 #endif	//  _XMLOFF_STYLEMAP_HXX
91 
92