Update ooo320-m1
[ooovba.git] / framework / inc / stdtypes.h
blob5af49e0178490ab25c6c55958346186454ead6f9
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: stdtypes.h,v $
10 * $Revision: 1.10 $
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 __FRAMEWORK_STDTYPES_H_
32 #define __FRAMEWORK_STDTYPES_H_
34 #include <vector>
35 #include <queue>
36 #include <hash_map>
38 //_________________________________________________________________________________________________________________
39 // own includes
40 //_________________________________________________________________________________________________________________
41 #include <general.h>
43 //_________________________________________________________________________________________________________________
44 // interface includes
45 //_________________________________________________________________________________________________________________
47 #ifndef __COM_SUN_STAR_AWT_KEYEVENT_HPP_
48 #include <com/sun/star/awt/KeyEvent.hpp>
49 #endif
51 //_________________________________________________________________________________________________________________
52 // other includes
53 //_________________________________________________________________________________________________________________
54 #include <comphelper/sequenceasvector.hxx>
55 #include <cppuhelper/interfacecontainer.hxx>
56 #include <rtl/ustring.hxx>
58 //_________________________________________________________________________________________________________________
59 // namespace
60 //_________________________________________________________________________________________________________________
62 namespace framework{
64 //_________________________________________________________________________________________________________________
65 // definitions
66 //_________________________________________________________________________________________________________________
68 /**
69 Own hash functions used for stl-structures ... e.g. hash tables/maps ...
71 struct OUStringHashCode
73 size_t operator()( const ::rtl::OUString& sString ) const
75 return sString.hashCode();
79 struct ShortHashCode
81 size_t operator()( const ::sal_Int16& nShort ) const
83 return (size_t)nShort;
87 struct Int32HashCode
89 size_t operator()( const ::sal_Int32& nValue ) const
91 return (size_t)nValue;
95 struct KeyEventHashCode
97 size_t operator()( const css::awt::KeyEvent& aEvent ) const
99 return (size_t)(aEvent.KeyCode +
100 //aEvent.KeyChar +
101 //aEvent.KeyFunc +
102 aEvent.Modifiers);
106 struct KeyEventEqualsFunc
108 bool operator()(const css::awt::KeyEvent aKey1,
109 const css::awt::KeyEvent aKey2) const
111 return (
112 (aKey1.KeyCode == aKey2.KeyCode ) &&
113 //(aKey1.KeyChar == aKey2.KeyChar ) &&
114 //(aKey1.KeyFunc == aKey2.KeyFunc ) &&
115 (aKey1.Modifiers == aKey2.Modifiers)
120 //_________________________________________________________________________________________________________________
123 Basic string list based on a std::vector()
124 It implements some additional funtionality which can be usefull but
125 is missing at the normal vector implementation.
127 class OUStringList : public ::comphelper::SequenceAsVector< ::rtl::OUString >
129 public:
131 // insert given element as the first one into the vector
132 void push_front( const ::rtl::OUString& sElement )
134 insert( begin(), sElement );
137 // search for given element
138 iterator find( const ::rtl::OUString& sElement )
140 return ::std::find(begin(), end(), sElement);
143 const_iterator findConst( const ::rtl::OUString& sElement ) const
145 return ::std::find(begin(), end(), sElement);
148 // the only way to free used memory realy!
149 void free()
151 OUStringList().swap( *this );
155 //_________________________________________________________________________________________________________________
158 Basic string queue based on a std::queue()
159 It implements some additional funtionality which can be usefull but
160 is missing at the normal std implementation.
162 typedef ::std::queue< ::rtl::OUString > OUStringQueue;
164 //_________________________________________________________________________________________________________________
167 Basic hash based on a std::hash_map() which provides key=[OUString] and value=[template type] pairs
168 It implements some additional funtionality which can be usefull but
169 is missing at the normal hash implementation.
171 template< class TType >
172 class BaseHash : public ::std::hash_map< ::rtl::OUString ,
173 TType ,
174 OUStringHashCode ,
175 ::std::equal_to< ::rtl::OUString > >
177 public:
179 // the only way to free used memory realy!
180 void free()
182 BaseHash().swap( *this );
186 //_________________________________________________________________________________________________________________
189 Basic OUString hash.
190 Key and values are OUStrings.
192 typedef BaseHash< ::rtl::OUString > OUStringHash;
194 //_________________________________________________________________________________________________________________
197 It can be used to map names (e.g. of properties) to her corresponding handles.
198 Our helper class OPropertySetHelper works optimized with handles but sometimes we have only a property name.
199 Mapping between these two parts of a property should be done in the fastest way :-)
201 typedef BaseHash< sal_Int32 > NameToHandleHash;
203 //_________________________________________________________________________________________________________________
206 Sometimes we need this template to implement listener container ...
207 and we need it at different positions ...
208 So it's better to declare it one times only!
210 typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< ::rtl::OUString ,
211 OUStringHashCode ,
212 ::std::equal_to< ::rtl::OUString > > ListenerHash;
214 } // namespace framework
216 #endif // #ifndef __FRAMEWORK_STDTYPES_H_