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 FORMS_SOURCE_INC_COMPONENTTOOLS_HXX
25 #define FORMS_SOURCE_INC_COMPONENTTOOLS_HXX
26 
27 /** === begin UNO includes === **/
28 #include <com/sun/star/uno/Type.hxx>
29 #include <com/sun/star/uno/Sequence.hxx>
30 #include <com/sun/star/frame/XModel.hpp>
31 /** === end UNO includes === **/
32 
33 #include <set>
34 #include <functional>
35 
36 //........................................................................
37 namespace frm
38 {
39 //........................................................................
40 
41     struct TypeCompareLess : public ::std::binary_function< ::com::sun::star::uno::Type, ::com::sun::star::uno::Type, bool >
42     {
43     private:
44         typedef ::com::sun::star::uno::Type             Type;
45 
46     public:
operator ()frm::TypeCompareLess47         bool operator()( const Type& _rLHS, const Type& _rRHS ) const
48         {
49             return _rLHS.getTypeName() < _rRHS.getTypeName();
50         }
51     };
52 
53 	//====================================================================
54 	//= TypeBag
55 	//====================================================================
56     /** a helper class which merges sequences of <type scope="com::sun::star::uno">Type</type>s,
57         so that the resulting sequence contains every type at most once
58     */
59 	class TypeBag
60 	{
61     public:
62         typedef ::com::sun::star::uno::Type             Type;
63         typedef ::com::sun::star::uno::Sequence< Type > TypeSequence;
64         typedef ::std::set< Type, TypeCompareLess >     TypeSet;
65 
66     private:
67         TypeSet     m_aTypes;
68 
69     public:
70         TypeBag(
71             const TypeSequence& _rTypes1
72         );
73 
74         TypeBag(
75             const TypeSequence& _rTypes1,
76             const TypeSequence& _rTypes2
77         );
78         TypeBag(
79             const TypeSequence& _rTypes1,
80             const TypeSequence& _rTypes2,
81             const TypeSequence& _rTypes3
82         );
83 
84         void    addType( const Type& i_rType );
85         void    addTypes( const TypeSequence& _rTypes );
86         void    removeType( const Type& i_rType );
87 
88         /** returns the types represented by this bag
89         */
90         TypeSequence    getTypes() const;
91 	};
92 
93     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >  getXModel(
94         const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent );
95 
96 //........................................................................
97 } // namespace frm
98 //........................................................................
99 
100 #endif // FORMS_SOURCE_INC_COMPONENTTOOLS_HXX
101 
102