bump product version to 5.0.4.1
[LibreOffice.git] / forms / source / misc / componenttools.cxx
blob62e7609f62eaa189d328b618a3d9ce83db1ef3bb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "componenttools.hxx"
22 #include <com/sun/star/container/XChild.hpp>
24 #include <algorithm>
25 #include <iterator>
28 namespace frm
32 using ::com::sun::star::frame::XModel;
33 using ::com::sun::star::uno::XInterface;
34 using ::com::sun::star::uno::Reference;
35 using ::com::sun::star::uno::UNO_QUERY;
36 using ::com::sun::star::container::XChild;
38 TypeBag::TypeBag( const TypeSequence& _rTypes1 )
40 addTypes( _rTypes1 );
44 TypeBag::TypeBag( const TypeSequence& _rTypes1, const TypeSequence& _rTypes2 )
46 addTypes( _rTypes1 );
47 addTypes( _rTypes2 );
51 TypeBag::TypeBag( const TypeSequence& _rTypes1, const TypeSequence& _rTypes2, const TypeSequence& _rTypes3 )
53 addTypes( _rTypes1 );
54 addTypes( _rTypes2 );
55 addTypes( _rTypes3 );
59 void TypeBag::addTypes( const TypeSequence& _rTypes )
61 ::std::copy(
62 _rTypes.getConstArray(),
63 _rTypes.getConstArray() + _rTypes.getLength(),
64 ::std::insert_iterator< TypeSet >( m_aTypes, m_aTypes.begin() )
69 void TypeBag::addType( const Type& i_rType )
71 m_aTypes.insert( i_rType );
75 void TypeBag::removeType( const TypeBag::Type& i_rType )
77 m_aTypes.erase( i_rType );
81 TypeBag::TypeSequence TypeBag::getTypes() const
83 TypeSequence aTypes( m_aTypes.size() );
84 ::std::copy( m_aTypes.begin(), m_aTypes.end(), aTypes.getArray() );
85 return aTypes;
89 Reference< XModel > getXModel( const Reference< XInterface >& _rxComponent )
91 Reference< XInterface > xParent = _rxComponent;
92 Reference< XModel > xModel( xParent, UNO_QUERY );
93 while ( xParent.is() && !xModel.is() )
95 Reference< XChild > xChild( xParent, UNO_QUERY );
96 xParent.set( xChild.is() ? xChild->getParent() : Reference< XInterface >(), UNO_QUERY );
97 xModel.set( xParent, UNO_QUERY );
99 return xModel;
103 } // namespace frm
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */