xref: /AOO41X/main/xmloff/source/forms/ifacecompare.hxx (revision ecfe53c5d1886e1e0d215b0d140d05282ab1c477)
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_FORMS_IFACECOMPARE_HXX_
25 #define _XMLOFF_FORMS_IFACECOMPARE_HXX_
26 
27 #include <comphelper/stl_types.hxx>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/drawing/XDrawPage.hpp>
30 
31 //.........................................................................
32 namespace xmloff
33 {
34 //.........................................................................
35 
36     //=====================================================================
37     //= OInterfaceCompare
38     //=====================================================================
39     /** is stl-compliant structure for comparing Reference&lt; &lt;iface&gt; &gt; instances
40     */
41     template < class IAFCE >
42     struct OInterfaceCompare
43         :public ::std::binary_function  <   ::com::sun::star::uno::Reference< IAFCE >
44                                         ,   ::com::sun::star::uno::Reference< IAFCE >
45                                         ,   bool
46                                         >
47     {
operator ()xmloff::OInterfaceCompare48         bool operator() (const ::com::sun::star::uno::Reference< IAFCE >& lhs, const ::com::sun::star::uno::Reference< IAFCE >& rhs) const
49         {
50             return lhs.get() < rhs.get();
51                 // this does not make any sense if you see the semantics of the pointer returned by get:
52                 // It's a pointer to a point in memory where an interface implementation lies.
53                 // But for our purpose (provide a reliable less-operator which can be used with the STL), this is
54                 // sufficient ....
55         }
56     };
57 
58     typedef OInterfaceCompare< ::com::sun::star::beans::XPropertySet >  OPropertySetCompare;
59     typedef OInterfaceCompare< ::com::sun::star::drawing::XDrawPage >   ODrawPageCompare;
60 
61 //.........................................................................
62 }   // namespace xmloff
63 //.........................................................................
64 
65 #endif // _XMLOFF_FORMS_IFACECOMPARE_HXX_
66 
67