LibreOffice Module forms (master) 1
componenttools.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <componenttools.hxx>
21
22#include <com/sun/star/container/XChild.hpp>
24
25#include <algorithm>
26#include <iterator>
27
28
29namespace frm
30{
31
32
33 using ::com::sun::star::frame::XModel;
34 using ::com::sun::star::uno::XInterface;
35 using ::com::sun::star::uno::Reference;
36 using ::com::sun::star::uno::UNO_QUERY;
37 using ::com::sun::star::container::XChild;
38
39 TypeBag::TypeBag( const TypeSequence& _rTypes1 )
40 {
41 addTypes( _rTypes1 );
42 }
43
44
45 TypeBag::TypeBag( const TypeSequence& _rTypes1, const TypeSequence& _rTypes2 )
46 {
47 addTypes( _rTypes1 );
48 addTypes( _rTypes2 );
49 }
50
51
52 TypeBag::TypeBag( const TypeSequence& _rTypes1, const TypeSequence& _rTypes2, const TypeSequence& _rTypes3 )
53 {
54 addTypes( _rTypes1 );
55 addTypes( _rTypes2 );
56 addTypes( _rTypes3 );
57 }
58
59
60 void TypeBag::addTypes( const TypeSequence& _rTypes )
61 {
63 _rTypes.begin(),
64 _rTypes.end(),
65 ::std::insert_iterator< TypeSet >( m_aTypes, m_aTypes.begin() )
66 );
67 }
68
69
70 void TypeBag::addType( const css::uno::Type& i_rType )
71 {
72 m_aTypes.insert( i_rType );
73 }
74
75
76 void TypeBag::removeType( const css::uno::Type& i_rType )
77 {
78 m_aTypes.erase( i_rType );
79 }
80
81
83 {
85 }
86
87
88 Reference< XModel > getXModel( const Reference< XInterface >& _rxComponent )
89 {
90 Reference< XInterface > xParent = _rxComponent;
91 Reference< XModel > xModel( xParent, UNO_QUERY );
92 while ( xParent.is() && !xModel.is() )
93 {
94 Reference< XChild > xChild( xParent, UNO_QUERY );
95 xParent.set( xChild.is() ? xChild->getParent() : Reference< XInterface >(), UNO_QUERY );
96 xModel.set( xParent, UNO_QUERY );
97 }
98 return xModel;
99 }
100
101
102} // namespace frm
103
104
105/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Sequence< css::uno::Type > TypeSequence
void addTypes(const TypeSequence &_rTypes)
void removeType(const css::uno::Type &i_rType)
TypeBag(const TypeSequence &_rTypes1)
void addType(const css::uno::Type &i_rType)
TypeSequence getTypes() const
returns the types represented by this bag
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25
css::uno::Reference< css::frame::XModel > getXModel(const css::uno::Reference< css::uno::XInterface > &_rxComponent)
void copy(const css::uno::Reference< css::beans::XPropertySet > &, css::uno::Reference< css::beans::XPropertySet > const &)
copy the properties from one PropertySet into the next
Reference< XModel > xModel