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 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_forms.hxx" 30 #include "componenttools.hxx" 31 32 /** === begin UNO includes === **/ 33 #include <com/sun/star/container/XChild.hpp> 34 /** === end UNO includes === **/ 35 36 #include <algorithm> 37 #include <iterator> 38 39 //........................................................................ 40 namespace frm 41 { 42 //........................................................................ 43 44 /** === begin UNO using === **/ 45 using ::com::sun::star::frame::XModel; 46 using ::com::sun::star::uno::XInterface; 47 using ::com::sun::star::uno::Reference; 48 using ::com::sun::star::uno::UNO_QUERY; 49 using ::com::sun::star::container::XChild; 50 /** === end UNO using === **/ 51 52 //==================================================================== 53 //= TypeBag 54 //==================================================================== 55 //-------------------------------------------------------------------- 56 TypeBag::TypeBag( const TypeSequence& _rTypes1 ) 57 { 58 addTypes( _rTypes1 ); 59 } 60 61 //-------------------------------------------------------------------- 62 TypeBag::TypeBag( const TypeSequence& _rTypes1, const TypeSequence& _rTypes2 ) 63 { 64 addTypes( _rTypes1 ); 65 addTypes( _rTypes2 ); 66 } 67 68 //-------------------------------------------------------------------- 69 TypeBag::TypeBag( const TypeSequence& _rTypes1, const TypeSequence& _rTypes2, const TypeSequence& _rTypes3 ) 70 { 71 addTypes( _rTypes1 ); 72 addTypes( _rTypes2 ); 73 addTypes( _rTypes3 ); 74 } 75 76 //-------------------------------------------------------------------- 77 void TypeBag::addTypes( const TypeSequence& _rTypes ) 78 { 79 ::std::copy( 80 _rTypes.getConstArray(), 81 _rTypes.getConstArray() + _rTypes.getLength(), 82 ::std::insert_iterator< TypeSet >( m_aTypes, m_aTypes.begin() ) 83 ); 84 } 85 86 //-------------------------------------------------------------------- 87 void TypeBag::addType( const Type& i_rType ) 88 { 89 m_aTypes.insert( i_rType ); 90 } 91 92 //-------------------------------------------------------------------- 93 void TypeBag::removeType( const TypeBag::Type& i_rType ) 94 { 95 m_aTypes.erase( i_rType ); 96 } 97 98 //-------------------------------------------------------------------- 99 TypeBag::TypeSequence TypeBag::getTypes() const 100 { 101 TypeSequence aTypes( m_aTypes.size() ); 102 ::std::copy( m_aTypes.begin(), m_aTypes.end(), aTypes.getArray() ); 103 return aTypes; 104 } 105 106 //==================================================================== 107 Reference< XModel > getXModel( const Reference< XInterface >& _rxComponent ) 108 { 109 Reference< XInterface > xParent = _rxComponent; 110 Reference< XModel > xModel( xParent, UNO_QUERY );; 111 while ( xParent.is() && !xModel.is() ) 112 { 113 Reference< XChild > xChild( xParent, UNO_QUERY ); 114 xParent.set( xChild.is() ? xChild->getParent() : Reference< XInterface >(), UNO_QUERY ); 115 xModel.set( xParent, UNO_QUERY ); 116 } 117 return xModel; 118 } 119 120 //........................................................................ 121 } // namespace frm 122 //........................................................................ 123 124