Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "componenttools.hxx"
30 : :
31 : : #include <com/sun/star/container/XChild.hpp>
32 : :
33 : : #include <algorithm>
34 : : #include <iterator>
35 : :
36 : : //........................................................................
37 : : namespace frm
38 : : {
39 : : //........................................................................
40 : :
41 : : /** === begin UNO using === **/
42 : : using ::com::sun::star::frame::XModel;
43 : : using ::com::sun::star::uno::XInterface;
44 : : using ::com::sun::star::uno::Reference;
45 : : using ::com::sun::star::uno::UNO_QUERY;
46 : : using ::com::sun::star::container::XChild;
47 : : /** === end UNO using === **/
48 : :
49 : : //====================================================================
50 : : //= TypeBag
51 : : //====================================================================
52 : : //--------------------------------------------------------------------
53 : 164 : TypeBag::TypeBag( const TypeSequence& _rTypes1 )
54 : : {
55 [ + - ]: 164 : addTypes( _rTypes1 );
56 : 164 : }
57 : :
58 : : //--------------------------------------------------------------------
59 : 58 : TypeBag::TypeBag( const TypeSequence& _rTypes1, const TypeSequence& _rTypes2 )
60 : : {
61 [ + - ]: 58 : addTypes( _rTypes1 );
62 [ + - ]: 58 : addTypes( _rTypes2 );
63 : 58 : }
64 : :
65 : : //--------------------------------------------------------------------
66 : 104 : TypeBag::TypeBag( const TypeSequence& _rTypes1, const TypeSequence& _rTypes2, const TypeSequence& _rTypes3 )
67 : : {
68 [ + - ]: 104 : addTypes( _rTypes1 );
69 [ + - ]: 104 : addTypes( _rTypes2 );
70 [ + - ]: 104 : addTypes( _rTypes3 );
71 : 104 : }
72 : :
73 : : //--------------------------------------------------------------------
74 : 872 : void TypeBag::addTypes( const TypeSequence& _rTypes )
75 : : {
76 : : ::std::copy(
77 : : _rTypes.getConstArray(),
78 : 872 : _rTypes.getConstArray() + _rTypes.getLength(),
79 : : ::std::insert_iterator< TypeSet >( m_aTypes, m_aTypes.begin() )
80 [ + - ]: 1744 : );
81 : 872 : }
82 : :
83 : : //--------------------------------------------------------------------
84 : 0 : void TypeBag::addType( const Type& i_rType )
85 : : {
86 : 0 : m_aTypes.insert( i_rType );
87 : 0 : }
88 : :
89 : : //--------------------------------------------------------------------
90 : 0 : void TypeBag::removeType( const TypeBag::Type& i_rType )
91 : : {
92 : 0 : m_aTypes.erase( i_rType );
93 : 0 : }
94 : :
95 : : //--------------------------------------------------------------------
96 : 326 : TypeBag::TypeSequence TypeBag::getTypes() const
97 : : {
98 : 326 : TypeSequence aTypes( m_aTypes.size() );
99 [ + - ][ + - ]: 326 : ::std::copy( m_aTypes.begin(), m_aTypes.end(), aTypes.getArray() );
100 : 326 : return aTypes;
101 : : }
102 : :
103 : : //====================================================================
104 : 538 : Reference< XModel > getXModel( const Reference< XInterface >& _rxComponent )
105 : : {
106 : 538 : Reference< XInterface > xParent = _rxComponent;
107 [ + - ]: 538 : Reference< XModel > xModel( xParent, UNO_QUERY );
108 [ + + ][ + + ]: 1654 : while ( xParent.is() && !xModel.is() )
[ + + ]
109 : : {
110 [ + - ]: 1116 : Reference< XChild > xChild( xParent, UNO_QUERY );
111 [ + - ][ + - ]: 1116 : xParent.set( xChild.is() ? xChild->getParent() : Reference< XInterface >(), UNO_QUERY );
[ + - ][ + - ]
112 [ + - ]: 1116 : xModel.set( xParent, UNO_QUERY );
113 : 1116 : }
114 : 538 : return xModel;
115 : : }
116 : :
117 : : //........................................................................
118 : : } // namespace frm
119 : : //........................................................................
120 : :
121 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|