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