LibreOffice Module framework (master) 1
uielementwrapperbase.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
21
22#include <com/sun/star/beans/PropertyAttribute.hpp>
23#include <com/sun/star/beans/PropertyValue.hpp>
24
25#include <vcl/svapp.hxx>
27
31constexpr OUStringLiteral UIELEMENT_PROPNAME_RESOURCEURL = u"ResourceURL";
32constexpr OUStringLiteral UIELEMENT_PROPNAME_TYPE = u"Type";
33constexpr OUStringLiteral UIELEMENT_PROPNAME_FRAME = u"Frame";
34
35using namespace ::com::sun::star::uno;
36using namespace ::com::sun::star::beans;
37using namespace ::com::sun::star::frame;
38
39namespace framework
40{
41
43 : ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >( m_aMutex )
44 , ::cppu::OPropertySetHelper ( *static_cast< ::cppu::OBroadcastHelper* >(this) )
45 , m_aListenerContainer ( m_aMutex )
46 , m_nType ( nType )
47 , m_bInitialized ( false )
48 , m_bDisposed ( false )
49{
50}
51
53{
54}
55
57{
58 Any aRet = UIElementWrapperBase_BASE::queryInterface( _rType );
59 if ( !aRet.hasValue() )
60 aRet = OPropertySetHelper::queryInterface( _rType );
61 return aRet;
62}
63
64Sequence< Type > SAL_CALL UIElementWrapperBase::getTypes( )
65{
67 UIElementWrapperBase_BASE::getTypes(),
69 );
70}
71
72void SAL_CALL UIElementWrapperBase::addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener )
73{
75}
76
77void SAL_CALL UIElementWrapperBase::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener )
78{
80}
81
82void SAL_CALL UIElementWrapperBase::initialize( const Sequence< Any >& aArguments )
83{
85
86 if ( m_bInitialized )
87 return;
88
89 for ( const Any& rArg : aArguments )
90 {
91 PropertyValue aPropValue;
92 if ( rArg >>= aPropValue )
93 {
94 if ( aPropValue.Name == "ResourceURL" )
95 aPropValue.Value >>= m_aResourceURL;
96 else if ( aPropValue.Name == "Frame" )
97 {
98 Reference< XFrame > xFrame;
99 aPropValue.Value >>= xFrame;
101 }
102 }
103 }
104
105 m_bInitialized = true;
106}
107
108// XUIElement
109css::uno::Reference< css::frame::XFrame > SAL_CALL UIElementWrapperBase::getFrame()
110{
111 css::uno::Reference< css::frame::XFrame > xFrame( m_xWeakFrame );
112 return xFrame;
113}
114
116{
117 return m_aResourceURL;
118}
119
120::sal_Int16 SAL_CALL UIElementWrapperBase::getType()
121{
122 return m_nType;
123}
124
125// XUpdatable
127{
128 // can be implemented by derived class
129}
130
131// XPropertySet helper
133 Any& /*aOldValue*/ ,
134 sal_Int32 /*nHandle*/ ,
135 const Any& /*aValue*/ )
136{
137 // Initialize state with sal_False !!!
138 // (Handle can be invalid)
139 return false;
140}
141
142void SAL_CALL UIElementWrapperBase::setFastPropertyValue_NoBroadcast( sal_Int32 /*nHandle*/ ,
143 const css::uno::Any& /*aValue*/ )
144{
145}
146
147void SAL_CALL UIElementWrapperBase::getFastPropertyValue( css::uno::Any& aValue ,
148 sal_Int32 nHandle ) const
149{
150 switch( nHandle )
151 {
153 aValue <<= m_aResourceURL;
154 break;
156 aValue <<= m_nType;
157 break;
159 Reference< XFrame > xFrame( m_xWeakFrame );
160 aValue <<= xFrame;
161 break;
162 }
163}
164
166{
167 // Define static member to give structure of properties to baseclass "OPropertySetHelper".
168 // "impl_getStaticPropertyDescriptor" is a non exported and static function, who will define a static propertytable.
169 // "true" say: Table is sorted by name.
170 static ::cppu::OPropertyArrayHelper ourInfoHelper( impl_getStaticPropertyDescriptor(), true );
171
172 return ourInfoHelper;
173}
174
175css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL UIElementWrapperBase::getPropertySetInfo()
176{
177 // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
178 // (Use method "getInfoHelper()".)
179 static css::uno::Reference< css::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
180
181 return xInfo;
182}
183
184css::uno::Sequence< css::beans::Property > UIElementWrapperBase::impl_getStaticPropertyDescriptor()
185{
186 // Create a property array to initialize sequence!
187 // Table of all predefined properties of this class. It's used from OPropertySetHelper-class!
188 // Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!!
189 // It's necessary for methods of OPropertySetHelper.
190 // ATTENTION:
191 // YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!!
192
193 return
194 {
195 css::beans::Property( UIELEMENT_PROPNAME_FRAME, UIELEMENT_PROPHANDLE_FRAME , cppu::UnoType<XFrame>::get(), css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
196 css::beans::Property( UIELEMENT_PROPNAME_RESOURCEURL, UIELEMENT_PROPHANDLE_RESOURCEURL , cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
197 css::beans::Property( UIELEMENT_PROPNAME_TYPE, UIELEMENT_PROPHANDLE_TYPE , cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY )
198 };
199}
200
201}
202
203/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 removeInterface(const css::uno::Type &rKey, const css::uno::Reference< css::uno::XInterface > &rxIFace)
sal_Int32 addInterface(const css::uno::Type &rKey, const css::uno::Reference< css::uno::XInterface > &r)
static css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL createPropertySetInfo(IPropertyArrayHelper &rProperties)
css::uno::Sequence< css::uno::Type > getTypes()
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &aValue, sal_Int32 nHandle) const override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
static css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor()
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &aConvertedValue, css::uno::Any &aOldValue, sal_Int32 nHandle, const css::uno::Any &aValue) override
virtual void SAL_CALL update() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &type) override
virtual OUString SAL_CALL getResourceURL() override
comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerContainer
virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getFrame() override
css::uno::WeakReference< css::frame::XFrame > m_xWeakFrame
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &aValue) override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
OUString m_aResourceURL
container for ALL Listener
virtual ::sal_Int16 SAL_CALL getType() override
float u
bool m_bDisposed
Sequence< PropertyValue > aArguments
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
Type
QPRO_FUNC_TYPE nType
sal_Int32 nHandle
Reference< XFrame > xFrame
unsigned char sal_Bool
std::mutex m_aMutex
constexpr OUStringLiteral UIELEMENT_PROPNAME_RESOURCEURL
constexpr OUStringLiteral UIELEMENT_PROPNAME_FRAME
const int UIELEMENT_PROPHANDLE_RESOURCEURL
const int UIELEMENT_PROPHANDLE_FRAME
constexpr OUStringLiteral UIELEMENT_PROPNAME_TYPE
const int UIELEMENT_PROPHANDLE_TYPE