1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <helper/uielementwrapperbase.hxx>
22 #include <com/sun/star/beans/PropertyAttribute.hpp>
23 #include <com/sun/star/beans/PropertyValue.hpp>
25 #include <vcl/svapp.hxx>
26 #include <comphelper/sequence.hxx>
28 const int UIELEMENT_PROPHANDLE_RESOURCEURL
= 1;
29 const int UIELEMENT_PROPHANDLE_TYPE
= 2;
30 const int UIELEMENT_PROPHANDLE_FRAME
= 3;
31 constexpr OUString UIELEMENT_PROPNAME_RESOURCEURL
= u
"ResourceURL"_ustr
;
32 constexpr OUString UIELEMENT_PROPNAME_TYPE
= u
"Type"_ustr
;
33 constexpr OUString UIELEMENT_PROPNAME_FRAME
= u
"Frame"_ustr
;
35 using namespace ::com::sun::star::uno
;
36 using namespace ::com::sun::star::beans
;
37 using namespace ::com::sun::star::frame
;
42 UIElementWrapperBase::UIElementWrapperBase( sal_Int16 nType
)
43 : ::cppu::OBroadcastHelperVar
< ::cppu::OMultiTypeInterfaceContainerHelper
, ::cppu::OMultiTypeInterfaceContainerHelper::keyType
>( m_aMutex
)
44 , ::cppu::OPropertySetHelper ( *static_cast< ::cppu::OBroadcastHelper
* >(this) )
45 , m_aListenerContainer ( m_aMutex
)
47 , m_bInitialized ( false )
48 , m_bDisposed ( false )
52 UIElementWrapperBase::~UIElementWrapperBase()
56 Any SAL_CALL
UIElementWrapperBase::queryInterface( const Type
& _rType
)
58 Any aRet
= UIElementWrapperBase_BASE::queryInterface( _rType
);
59 if ( !aRet
.hasValue() )
60 aRet
= OPropertySetHelper::queryInterface( _rType
);
64 Sequence
< Type
> SAL_CALL
UIElementWrapperBase::getTypes( )
66 return comphelper::concatSequences(
67 UIElementWrapperBase_BASE::getTypes(),
68 ::cppu::OPropertySetHelper::getTypes()
72 void SAL_CALL
UIElementWrapperBase::addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
)
74 m_aListenerContainer
.addInterface( cppu::UnoType
<css::lang::XEventListener
>::get(), xListener
);
77 void SAL_CALL
UIElementWrapperBase::removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
)
79 m_aListenerContainer
.removeInterface( cppu::UnoType
<css::lang::XEventListener
>::get(), xListener
);
82 void SAL_CALL
UIElementWrapperBase::initialize( const Sequence
< Any
>& aArguments
)
89 for ( const Any
& rArg
: aArguments
)
91 PropertyValue aPropValue
;
92 if ( rArg
>>= aPropValue
)
94 if ( aPropValue
.Name
== "ResourceURL" )
95 aPropValue
.Value
>>= m_aResourceURL
;
96 else if ( aPropValue
.Name
== "Frame" )
98 Reference
< XFrame
> xFrame
;
99 aPropValue
.Value
>>= xFrame
;
100 m_xWeakFrame
= xFrame
;
105 m_bInitialized
= true;
109 css::uno::Reference
< css::frame::XFrame
> SAL_CALL
UIElementWrapperBase::getFrame()
111 css::uno::Reference
< css::frame::XFrame
> xFrame( m_xWeakFrame
);
115 OUString SAL_CALL
UIElementWrapperBase::getResourceURL()
117 return m_aResourceURL
;
120 ::sal_Int16 SAL_CALL
UIElementWrapperBase::getType()
126 void SAL_CALL
UIElementWrapperBase::update()
128 // can be implemented by derived class
131 // XPropertySet helper
132 sal_Bool SAL_CALL
UIElementWrapperBase::convertFastPropertyValue( Any
& /*aConvertedValue*/ ,
134 sal_Int32
/*nHandle*/ ,
135 const Any
& /*aValue*/ )
137 // Initialize state with sal_False !!!
138 // (Handle can be invalid)
142 void SAL_CALL
UIElementWrapperBase::setFastPropertyValue_NoBroadcast( sal_Int32
/*nHandle*/ ,
143 const css::uno::Any
& /*aValue*/ )
147 void SAL_CALL
UIElementWrapperBase::getFastPropertyValue( css::uno::Any
& aValue
,
148 sal_Int32 nHandle
) const
152 case UIELEMENT_PROPHANDLE_RESOURCEURL
:
153 aValue
<<= m_aResourceURL
;
155 case UIELEMENT_PROPHANDLE_TYPE
:
158 case UIELEMENT_PROPHANDLE_FRAME
:
159 Reference
< XFrame
> xFrame( m_xWeakFrame
);
165 ::cppu::IPropertyArrayHelper
& SAL_CALL
UIElementWrapperBase::getInfoHelper()
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 );
172 return ourInfoHelper
;
175 css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
UIElementWrapperBase::getPropertySetInfo()
177 // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
178 // (Use method "getInfoHelper()".)
179 static css::uno::Reference
< css::beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
184 css::uno::Sequence
< css::beans::Property
> UIElementWrapperBase::impl_getStaticPropertyDescriptor()
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.
191 // YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!!
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
)
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */