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