2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-12 17:21:24 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2004-02-25 16:47:49 +00:00
|
|
|
|
|
|
|
#include <helper/uielementwrapperbase.hxx>
|
|
|
|
#include <general.h>
|
|
|
|
#include <properties.h>
|
|
|
|
|
|
|
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
|
|
|
|
#include <vcl/svapp.hxx>
|
2013-07-15 13:47:03 +02:00
|
|
|
#include <comphelper/sequence.hxx>
|
2004-02-25 16:47:49 +00:00
|
|
|
|
|
|
|
const int UIELEMENT_PROPHANDLE_RESOURCEURL = 1;
|
|
|
|
const int UIELEMENT_PROPHANDLE_TYPE = 2;
|
2004-07-06 15:57:38 +00:00
|
|
|
const int UIELEMENT_PROPHANDLE_FRAME = 3;
|
|
|
|
const int UIELEMENT_PROPCOUNT = 3;
|
2012-03-31 15:54:07 +01:00
|
|
|
const char UIELEMENT_PROPNAME_RESOURCEURL[] = "ResourceURL";
|
|
|
|
const char UIELEMENT_PROPNAME_TYPE[] = "Type";
|
|
|
|
const char UIELEMENT_PROPNAME_FRAME[] = "Frame";
|
2004-02-25 16:47:49 +00:00
|
|
|
|
2004-07-06 15:57:38 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::frame;
|
2004-02-25 16:47:49 +00:00
|
|
|
|
|
|
|
namespace framework
|
|
|
|
{
|
|
|
|
|
|
|
|
UIElementWrapperBase::UIElementWrapperBase( sal_Int16 nType )
|
2014-03-18 15:07:28 +01:00
|
|
|
: ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >( m_aMutex )
|
2017-09-04 08:53:38 +02:00
|
|
|
, ::cppu::OPropertySetHelper ( *static_cast< ::cppu::OBroadcastHelper* >(this) )
|
2014-03-18 15:07:28 +01:00
|
|
|
, m_aListenerContainer ( m_aMutex )
|
2004-02-25 16:47:49 +00:00
|
|
|
, m_nType ( nType )
|
2014-04-04 15:53:21 +02:00
|
|
|
, m_bInitialized ( false )
|
|
|
|
, m_bDisposed ( false )
|
2004-02-25 16:47:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
UIElementWrapperBase::~UIElementWrapperBase()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
Any SAL_CALL UIElementWrapperBase::queryInterface( const Type& _rType )
|
2013-07-15 13:47:03 +02:00
|
|
|
{
|
|
|
|
Any aRet = UIElementWrapperBase_BASE::queryInterface( _rType );
|
|
|
|
if ( !aRet.hasValue() )
|
|
|
|
aRet = OPropertySetHelper::queryInterface( _rType );
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
Sequence< Type > SAL_CALL UIElementWrapperBase::getTypes( )
|
2013-07-15 13:47:03 +02:00
|
|
|
{
|
|
|
|
return comphelper::concatSequences(
|
|
|
|
UIElementWrapperBase_BASE::getTypes(),
|
|
|
|
::cppu::OPropertySetHelper::getTypes()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL UIElementWrapperBase::addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener )
|
2004-02-25 16:47:49 +00:00
|
|
|
{
|
2014-05-15 22:51:43 +02:00
|
|
|
m_aListenerContainer.addInterface( cppu::UnoType<css::lang::XEventListener>::get(), xListener );
|
2004-02-25 16:47:49 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL UIElementWrapperBase::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener )
|
2004-02-25 16:47:49 +00:00
|
|
|
{
|
2014-05-15 22:51:43 +02:00
|
|
|
m_aListenerContainer.removeInterface( cppu::UnoType<css::lang::XEventListener>::get(), xListener );
|
2004-02-25 16:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL UIElementWrapperBase::initialize( const Sequence< Any >& aArguments )
|
|
|
|
{
|
2014-03-18 15:07:28 +01:00
|
|
|
SolarMutexGuard g;
|
2004-02-25 16:47:49 +00:00
|
|
|
|
|
|
|
if ( !m_bInitialized )
|
|
|
|
{
|
|
|
|
for ( sal_Int32 n = 0; n < aArguments.getLength(); n++ )
|
|
|
|
{
|
|
|
|
PropertyValue aPropValue;
|
|
|
|
if ( aArguments[n] >>= aPropValue )
|
|
|
|
{
|
2012-04-06 14:28:18 +02:00
|
|
|
if ( aPropValue.Name == "ResourceURL" )
|
2004-02-25 16:47:49 +00:00
|
|
|
aPropValue.Value >>= m_aResourceURL;
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( aPropValue.Name == "Frame" )
|
2004-07-06 15:57:38 +00:00
|
|
|
{
|
|
|
|
Reference< XFrame > xFrame;
|
|
|
|
aPropValue.Value >>= xFrame;
|
|
|
|
m_xWeakFrame = xFrame;
|
|
|
|
}
|
2004-02-25 16:47:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-04 15:53:21 +02:00
|
|
|
m_bInitialized = true;
|
2004-02-25 16:47:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-09 11:07:43 +02:00
|
|
|
// XUIElement
|
2017-01-26 12:28:58 +01:00
|
|
|
css::uno::Reference< css::frame::XFrame > SAL_CALL UIElementWrapperBase::getFrame()
|
2010-04-09 11:07:43 +02:00
|
|
|
{
|
2015-10-13 16:59:57 +02:00
|
|
|
css::uno::Reference< css::frame::XFrame > xFrame( m_xWeakFrame );
|
2010-04-09 11:07:43 +02:00
|
|
|
return xFrame;
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
OUString SAL_CALL UIElementWrapperBase::getResourceURL()
|
2010-04-09 11:07:43 +02:00
|
|
|
{
|
|
|
|
return m_aResourceURL;
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
::sal_Int16 SAL_CALL UIElementWrapperBase::getType()
|
2010-04-09 11:07:43 +02:00
|
|
|
{
|
|
|
|
return m_nType;
|
|
|
|
}
|
|
|
|
|
2004-07-06 15:57:38 +00:00
|
|
|
// XUpdatable
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL UIElementWrapperBase::update()
|
2004-07-06 15:57:38 +00:00
|
|
|
{
|
|
|
|
// can be implemented by derived class
|
|
|
|
}
|
|
|
|
|
2004-02-25 16:47:49 +00:00
|
|
|
// XPropertySet helper
|
2006-06-19 10:20:23 +00:00
|
|
|
sal_Bool SAL_CALL UIElementWrapperBase::convertFastPropertyValue( Any& /*aConvertedValue*/ ,
|
|
|
|
Any& /*aOldValue*/ ,
|
|
|
|
sal_Int32 /*nHandle*/ ,
|
2017-01-26 12:28:58 +01:00
|
|
|
const Any& /*aValue*/ )
|
2004-02-25 16:47:49 +00:00
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
// Initialize state with sal_False !!!
|
2004-02-25 16:47:49 +00:00
|
|
|
// (Handle can be invalid)
|
2016-04-20 17:17:17 +02:00
|
|
|
return false;
|
2004-02-25 16:47:49 +00:00
|
|
|
}
|
|
|
|
|
2006-06-19 10:20:23 +00:00
|
|
|
void SAL_CALL UIElementWrapperBase::setFastPropertyValue_NoBroadcast( sal_Int32 /*nHandle*/ ,
|
2017-01-26 12:28:58 +01:00
|
|
|
const css::uno::Any& /*aValue*/ )
|
2004-02-25 16:47:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-10-13 16:59:57 +02:00
|
|
|
void SAL_CALL UIElementWrapperBase::getFastPropertyValue( css::uno::Any& aValue ,
|
2004-02-25 16:47:49 +00:00
|
|
|
sal_Int32 nHandle ) const
|
|
|
|
{
|
|
|
|
switch( nHandle )
|
|
|
|
{
|
|
|
|
case UIELEMENT_PROPHANDLE_RESOURCEURL:
|
|
|
|
aValue <<= m_aResourceURL;
|
|
|
|
break;
|
|
|
|
case UIELEMENT_PROPHANDLE_TYPE:
|
|
|
|
aValue <<= m_nType;
|
|
|
|
break;
|
2004-07-06 15:57:38 +00:00
|
|
|
case UIELEMENT_PROPHANDLE_FRAME:
|
|
|
|
Reference< XFrame > xFrame( m_xWeakFrame );
|
|
|
|
aValue <<= xFrame;
|
|
|
|
break;
|
2004-02-25 16:47:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
::cppu::IPropertyArrayHelper& SAL_CALL UIElementWrapperBase::getInfoHelper()
|
|
|
|
{
|
2017-06-07 19:42:35 +02:00
|
|
|
// Define static member to give structure of properties to baseclass "OPropertySetHelper".
|
|
|
|
// "impl_getStaticPropertyDescriptor" is a non exported and static function, who will define a static propertytable.
|
|
|
|
// "true" say: Table is sorted by name.
|
|
|
|
static ::cppu::OPropertyArrayHelper ourInfoHelper( impl_getStaticPropertyDescriptor(), true );
|
2004-02-25 16:47:49 +00:00
|
|
|
|
2017-06-07 19:42:35 +02:00
|
|
|
return ourInfoHelper;
|
2004-02-25 16:47:49 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL UIElementWrapperBase::getPropertySetInfo()
|
2004-02-25 16:47:49 +00:00
|
|
|
{
|
2017-06-07 19:42:35 +02:00
|
|
|
// Create structure of propertysetinfo for baseclass "OPropertySetHelper".
|
|
|
|
// (Use method "getInfoHelper()".)
|
|
|
|
static css::uno::Reference< css::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
|
2004-02-25 16:47:49 +00:00
|
|
|
|
2017-06-07 19:42:35 +02:00
|
|
|
return xInfo;
|
2004-02-25 16:47:49 +00:00
|
|
|
}
|
|
|
|
|
2015-10-13 16:59:57 +02:00
|
|
|
const css::uno::Sequence< css::beans::Property > UIElementWrapperBase::impl_getStaticPropertyDescriptor()
|
2004-02-25 16:47:49 +00:00
|
|
|
{
|
2011-06-01 11:39:41 +01:00
|
|
|
// Create a property array to initialize sequence!
|
2004-02-25 16:47:49 +00:00
|
|
|
// Table of all predefined properties of this class. Its used from OPropertySetHelper-class!
|
|
|
|
// Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!!
|
|
|
|
// It's necessary for methods of OPropertySetHelper.
|
|
|
|
// ATTENTION:
|
|
|
|
// YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!!
|
|
|
|
|
2015-10-13 16:59:57 +02:00
|
|
|
const css::beans::Property pProperties[] =
|
2004-02-25 16:47:49 +00:00
|
|
|
{
|
2017-01-30 16:38:54 +02:00
|
|
|
css::beans::Property( UIELEMENT_PROPNAME_FRAME, UIELEMENT_PROPHANDLE_FRAME , cppu::UnoType<XFrame>::get(), css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
|
|
|
|
css::beans::Property( UIELEMENT_PROPNAME_RESOURCEURL, UIELEMENT_PROPHANDLE_RESOURCEURL , cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
|
|
|
|
css::beans::Property( UIELEMENT_PROPNAME_TYPE, UIELEMENT_PROPHANDLE_TYPE , cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY )
|
2004-02-25 16:47:49 +00:00
|
|
|
};
|
|
|
|
// Use it to initialize sequence!
|
2015-10-13 16:59:57 +02:00
|
|
|
const css::uno::Sequence< css::beans::Property > lPropertyDescriptor( pProperties, UIELEMENT_PROPCOUNT );
|
2011-06-01 11:39:41 +01:00
|
|
|
// Return "PropertyDescriptor"
|
2004-02-25 16:47:49 +00:00
|
|
|
return lPropertyDescriptor;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|