1*24acc546SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*24acc546SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*24acc546SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*24acc546SAndrew Rist * distributed with this work for additional information 6*24acc546SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*24acc546SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*24acc546SAndrew Rist * "License"); you may not use this file except in compliance 9*24acc546SAndrew Rist * with the License. You may obtain a copy of the License at 10*24acc546SAndrew Rist * 11*24acc546SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*24acc546SAndrew Rist * 13*24acc546SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*24acc546SAndrew Rist * software distributed under the License is distributed on an 15*24acc546SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*24acc546SAndrew Rist * KIND, either express or implied. See the License for the 17*24acc546SAndrew Rist * specific language governing permissions and limitations 18*24acc546SAndrew Rist * under the License. 19*24acc546SAndrew Rist * 20*24acc546SAndrew Rist *************************************************************/ 21*24acc546SAndrew Rist 22*24acc546SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_forms.hxx" 26cdf0e10cSrcweir #include "componenttools.hxx" 27cdf0e10cSrcweir 28cdf0e10cSrcweir /** === begin UNO includes === **/ 29cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 30cdf0e10cSrcweir /** === end UNO includes === **/ 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <algorithm> 33cdf0e10cSrcweir #include <iterator> 34cdf0e10cSrcweir 35cdf0e10cSrcweir //........................................................................ 36cdf0e10cSrcweir namespace frm 37cdf0e10cSrcweir { 38cdf0e10cSrcweir //........................................................................ 39cdf0e10cSrcweir 40cdf0e10cSrcweir /** === begin UNO using === **/ 41cdf0e10cSrcweir using ::com::sun::star::frame::XModel; 42cdf0e10cSrcweir using ::com::sun::star::uno::XInterface; 43cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 44cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 45cdf0e10cSrcweir using ::com::sun::star::container::XChild; 46cdf0e10cSrcweir /** === end UNO using === **/ 47cdf0e10cSrcweir 48cdf0e10cSrcweir //==================================================================== 49cdf0e10cSrcweir //= TypeBag 50cdf0e10cSrcweir //==================================================================== 51cdf0e10cSrcweir //-------------------------------------------------------------------- TypeBag(const TypeSequence & _rTypes1)52cdf0e10cSrcweir TypeBag::TypeBag( const TypeSequence& _rTypes1 ) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir addTypes( _rTypes1 ); 55cdf0e10cSrcweir } 56cdf0e10cSrcweir 57cdf0e10cSrcweir //-------------------------------------------------------------------- TypeBag(const TypeSequence & _rTypes1,const TypeSequence & _rTypes2)58cdf0e10cSrcweir TypeBag::TypeBag( const TypeSequence& _rTypes1, const TypeSequence& _rTypes2 ) 59cdf0e10cSrcweir { 60cdf0e10cSrcweir addTypes( _rTypes1 ); 61cdf0e10cSrcweir addTypes( _rTypes2 ); 62cdf0e10cSrcweir } 63cdf0e10cSrcweir 64cdf0e10cSrcweir //-------------------------------------------------------------------- TypeBag(const TypeSequence & _rTypes1,const TypeSequence & _rTypes2,const TypeSequence & _rTypes3)65cdf0e10cSrcweir TypeBag::TypeBag( const TypeSequence& _rTypes1, const TypeSequence& _rTypes2, const TypeSequence& _rTypes3 ) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir addTypes( _rTypes1 ); 68cdf0e10cSrcweir addTypes( _rTypes2 ); 69cdf0e10cSrcweir addTypes( _rTypes3 ); 70cdf0e10cSrcweir } 71cdf0e10cSrcweir 72cdf0e10cSrcweir //-------------------------------------------------------------------- addTypes(const TypeSequence & _rTypes)73cdf0e10cSrcweir void TypeBag::addTypes( const TypeSequence& _rTypes ) 74cdf0e10cSrcweir { 75cdf0e10cSrcweir ::std::copy( 76cdf0e10cSrcweir _rTypes.getConstArray(), 77cdf0e10cSrcweir _rTypes.getConstArray() + _rTypes.getLength(), 78cdf0e10cSrcweir ::std::insert_iterator< TypeSet >( m_aTypes, m_aTypes.begin() ) 79cdf0e10cSrcweir ); 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir //-------------------------------------------------------------------- addType(const Type & i_rType)83cdf0e10cSrcweir void TypeBag::addType( const Type& i_rType ) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir m_aTypes.insert( i_rType ); 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88cdf0e10cSrcweir //-------------------------------------------------------------------- removeType(const TypeBag::Type & i_rType)89cdf0e10cSrcweir void TypeBag::removeType( const TypeBag::Type& i_rType ) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir m_aTypes.erase( i_rType ); 92cdf0e10cSrcweir } 93cdf0e10cSrcweir 94cdf0e10cSrcweir //-------------------------------------------------------------------- getTypes() const95cdf0e10cSrcweir TypeBag::TypeSequence TypeBag::getTypes() const 96cdf0e10cSrcweir { 97cdf0e10cSrcweir TypeSequence aTypes( m_aTypes.size() ); 98cdf0e10cSrcweir ::std::copy( m_aTypes.begin(), m_aTypes.end(), aTypes.getArray() ); 99cdf0e10cSrcweir return aTypes; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir //==================================================================== getXModel(const Reference<XInterface> & _rxComponent)103cdf0e10cSrcweir Reference< XModel > getXModel( const Reference< XInterface >& _rxComponent ) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir Reference< XInterface > xParent = _rxComponent; 106cdf0e10cSrcweir Reference< XModel > xModel( xParent, UNO_QUERY );; 107cdf0e10cSrcweir while ( xParent.is() && !xModel.is() ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir Reference< XChild > xChild( xParent, UNO_QUERY ); 110cdf0e10cSrcweir xParent.set( xChild.is() ? xChild->getParent() : Reference< XInterface >(), UNO_QUERY ); 111cdf0e10cSrcweir xModel.set( xParent, UNO_QUERY ); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir return xModel; 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116cdf0e10cSrcweir //........................................................................ 117cdf0e10cSrcweir } // namespace frm 118cdf0e10cSrcweir //........................................................................ 119cdf0e10cSrcweir 120