1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: stdtypes.h,v $
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_
38 //_________________________________________________________________________________________________________________
40 //_________________________________________________________________________________________________________________
43 //_________________________________________________________________________________________________________________
45 //_________________________________________________________________________________________________________________
47 #ifndef __COM_SUN_STAR_AWT_KEYEVENT_HPP_
48 #include <com/sun/star/awt/KeyEvent.hpp>
51 //_________________________________________________________________________________________________________________
53 //_________________________________________________________________________________________________________________
54 #include <comphelper/sequenceasvector.hxx>
55 #include <cppuhelper/interfacecontainer.hxx>
56 #include <rtl/ustring.hxx>
58 //_________________________________________________________________________________________________________________
60 //_________________________________________________________________________________________________________________
64 //_________________________________________________________________________________________________________________
66 //_________________________________________________________________________________________________________________
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();
81 size_t operator()( const ::sal_Int16
& nShort
) const
83 return (size_t)nShort
;
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
+
106 struct KeyEventEqualsFunc
108 bool operator()(const css::awt::KeyEvent aKey1
,
109 const css::awt::KeyEvent aKey2
) const
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
>
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!
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
,
175 ::std::equal_to
< ::rtl::OUString
> >
179 // the only way to free used memory realy!
182 BaseHash().swap( *this );
186 //_________________________________________________________________________________________________________________
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
,
212 ::std::equal_to
< ::rtl::OUString
> > ListenerHash
;
214 } // namespace framework
216 #endif // #ifndef __FRAMEWORK_STDTYPES_H_