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