update dev300-m58
[ooovba.git] / forms / source / misc / componenttools.cxx
blobe4d262144d621df878dc1feb154f186ea1189a62
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: componenttools.cxx,v $
10 * $Revision: 1.6.42.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_forms.hxx"
33 #include "componenttools.hxx"
35 /** === begin UNO includes === **/
36 #include <com/sun/star/container/XChild.hpp>
37 /** === end UNO includes === **/
39 #include <algorithm>
40 #include <iterator>
42 //........................................................................
43 namespace frm
45 //........................................................................
47 /** === begin UNO using === **/
48 using ::com::sun::star::frame::XModel;
49 using ::com::sun::star::uno::XInterface;
50 using ::com::sun::star::uno::Reference;
51 using ::com::sun::star::uno::UNO_QUERY;
52 using ::com::sun::star::container::XChild;
53 /** === end UNO using === **/
55 //====================================================================
56 //= TypeBag
57 //====================================================================
58 //--------------------------------------------------------------------
59 TypeBag::TypeBag( const TypeSequence& _rTypes1 )
61 addTypes( _rTypes1 );
64 //--------------------------------------------------------------------
65 TypeBag::TypeBag( const TypeSequence& _rTypes1, const TypeSequence& _rTypes2 )
67 addTypes( _rTypes1 );
68 addTypes( _rTypes2 );
71 //--------------------------------------------------------------------
72 TypeBag::TypeBag( const TypeSequence& _rTypes1, const TypeSequence& _rTypes2, const TypeSequence& _rTypes3 )
74 addTypes( _rTypes1 );
75 addTypes( _rTypes2 );
76 addTypes( _rTypes3 );
79 //--------------------------------------------------------------------
80 void TypeBag::addTypes( const TypeSequence& _rTypes )
82 ::std::copy(
83 _rTypes.getConstArray(),
84 _rTypes.getConstArray() + _rTypes.getLength(),
85 ::std::insert_iterator< TypeSet >( m_aTypes, m_aTypes.begin() )
89 //--------------------------------------------------------------------
90 TypeBag::TypeSequence TypeBag::getTypes() const
92 TypeSequence aTypes( m_aTypes.size() );
93 ::std::copy( m_aTypes.begin(), m_aTypes.end(), aTypes.getArray() );
94 return aTypes;
97 //====================================================================
98 Reference< XModel > getXModel( const Reference< XInterface >& _rxComponent )
100 Reference< XInterface > xParent = _rxComponent;
101 Reference< XModel > xModel( xParent, UNO_QUERY );;
102 while ( xParent.is() && !xModel.is() )
104 Reference< XChild > xChild( xParent, UNO_QUERY );
105 xParent.set( xChild.is() ? xChild->getParent() : Reference< XInterface >(), UNO_QUERY );
106 xModel.set( xParent, UNO_QUERY );
108 return xModel;
111 //........................................................................
112 } // namespace frm
113 //........................................................................