2003-03-27 16:05:12 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 08:24:40 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2003-03-27 16:05:12 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2003-03-27 16:05:12 +00:00
|
|
|
*
|
2008-04-11 08:24:40 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-03-27 16:05:12 +00:00
|
|
|
*
|
2008-04-11 08:24:40 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2003-03-27 16:05:12 +00:00
|
|
|
*
|
2008-04-11 08:24:40 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2003-03-27 16:05:12 +00:00
|
|
|
*
|
2008-04-11 08:24:40 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2003-03-27 16:05:12 +00:00
|
|
|
*
|
2008-04-11 08:24:40 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2003-03-27 16:05:12 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 11:16:52 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_toolkit.hxx"
|
|
|
|
|
2007-06-27 11:21:36 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
2007-11-26 15:27:22 +00:00
|
|
|
#include <vcl/window.hxx>
|
|
|
|
#include <vcl/wall.hxx>
|
2010-10-16 03:20:00 -05:00
|
|
|
#include <osl/mutex.hxx>
|
2003-03-27 16:05:12 +00:00
|
|
|
#include <toolkit/controls/dialogcontrol.hxx>
|
|
|
|
#include <toolkit/helper/property.hxx>
|
|
|
|
#include <toolkit/helper/unopropertyarrayhelper.hxx>
|
|
|
|
#include <toolkit/controls/stdtabcontroller.hxx>
|
|
|
|
#include <com/sun/star/awt/PosSize.hpp>
|
2007-06-20 09:25:44 +00:00
|
|
|
#include <com/sun/star/awt/WindowAttribute.hpp>
|
2007-01-02 14:34:44 +00:00
|
|
|
#include <com/sun/star/resource/XStringResourceResolver.hpp>
|
2007-11-26 15:27:22 +00:00
|
|
|
#include <com/sun/star/graphic/XGraphicProvider.hpp>
|
2011-03-11 18:04:44 +00:00
|
|
|
#include <tools/list.hxx>
|
2003-03-27 16:05:12 +00:00
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
|
|
|
#include <tools/debug.hxx>
|
2007-03-15 14:36:05 +00:00
|
|
|
#include <tools/diagnose_ex.h>
|
2010-08-12 17:36:53 +02:00
|
|
|
#include <comphelper/sequence.hxx>
|
2003-03-27 16:05:12 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vcl/outdev.hxx>
|
|
|
|
|
2007-11-26 15:27:22 +00:00
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
|
|
|
#include <unotools/ucbstreamhelper.hxx>
|
|
|
|
#include <vcl/graph.hxx>
|
|
|
|
#include <vcl/image.hxx>
|
2003-03-27 16:05:12 +00:00
|
|
|
#include <map>
|
|
|
|
#include <algorithm>
|
2011-03-11 18:04:44 +00:00
|
|
|
#include <functional>
|
2007-11-26 15:27:22 +00:00
|
|
|
#include "tools/urlobj.hxx"
|
|
|
|
#include "osl/file.hxx"
|
2003-03-27 16:05:12 +00:00
|
|
|
|
2007-01-02 14:34:44 +00:00
|
|
|
using namespace ::com::sun::star;
|
2003-03-27 16:05:12 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::awt;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
|
2007-11-26 15:27:22 +00:00
|
|
|
#define PROPERTY_DIALOGSOURCEURL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogSourceURL" ))
|
|
|
|
#define PROPERTY_IMAGEURL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ImageURL" ))
|
|
|
|
#define PROPERTY_GRAPHIC ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Graphic" ))
|
2010-08-12 17:36:53 +02:00
|
|
|
//
|
|
|
|
////HELPER
|
2007-11-26 15:27:22 +00:00
|
|
|
::rtl::OUString getPhysicalLocation( const ::com::sun::star::uno::Any& rbase, const ::com::sun::star::uno::Any& rUrl );
|
2007-01-02 14:34:44 +00:00
|
|
|
|
2003-03-27 16:05:12 +00:00
|
|
|
// ----------------------------------------------------
|
|
|
|
// class UnoControlDialogModel
|
|
|
|
// ----------------------------------------------------
|
2011-03-11 18:04:44 +00:00
|
|
|
UnoControlDialogModel::UnoControlDialogModel( const Reference< XMultiServiceFactory >& i_factory )
|
|
|
|
:ControlModelContainerBase( i_factory )
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
|
|
|
|
// ImplRegisterProperty( BASEPROPERTY_BORDER );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_ENABLED );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
|
|
|
|
// ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_HELPURL );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_TITLE );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_SIZEABLE );
|
2007-07-06 13:27:12 +00:00
|
|
|
ImplRegisterProperty( BASEPROPERTY_DESKTOP_AS_PARENT );
|
2007-06-20 09:25:44 +00:00
|
|
|
ImplRegisterProperty( BASEPROPERTY_DECORATION );
|
2007-11-26 15:27:22 +00:00
|
|
|
ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_GRAPHIC );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_IMAGEURL );
|
2003-03-27 16:05:12 +00:00
|
|
|
|
|
|
|
Any aBool;
|
|
|
|
aBool <<= (sal_Bool) sal_True;
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_MOVEABLE, aBool );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_CLOSEABLE, aBool );
|
|
|
|
}
|
|
|
|
|
|
|
|
UnoControlDialogModel::UnoControlDialogModel( const UnoControlDialogModel& rModel )
|
2011-03-11 18:04:44 +00:00
|
|
|
: ControlModelContainerBase( rModel )
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
UnoControlDialogModel::~UnoControlDialogModel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-02-11 18:06:45 +01:00
|
|
|
UnoControlModel* UnoControlDialogModel::Clone() const
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-02-11 18:06:45 +01:00
|
|
|
// clone the container itself
|
|
|
|
UnoControlDialogModel* pClone = new UnoControlDialogModel( *this );
|
2003-03-27 16:05:12 +00:00
|
|
|
|
2011-02-11 18:06:45 +01:00
|
|
|
Clone_Impl(*pClone);
|
|
|
|
|
|
|
|
return pClone;
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
|
2003-03-27 16:05:12 +00:00
|
|
|
::rtl::OUString UnoControlDialogModel::getServiceName( ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
return ::rtl::OUString::createFromAscii( szServiceName_UnoControlDialogModel );
|
|
|
|
}
|
|
|
|
|
|
|
|
Any UnoControlDialogModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
|
|
|
|
{
|
2007-01-02 14:34:44 +00:00
|
|
|
Any aAny;
|
|
|
|
|
|
|
|
switch ( nPropId )
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2007-01-02 14:34:44 +00:00
|
|
|
case BASEPROPERTY_DEFAULTCONTROL:
|
|
|
|
aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlDialog );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aAny = UnoControlModel::ImplGetDefaultValue( nPropId );
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
|
2007-01-02 14:34:44 +00:00
|
|
|
return aAny;
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
::cppu::IPropertyArrayHelper& UnoControlDialogModel::getInfoHelper()
|
|
|
|
{
|
|
|
|
static UnoPropertyArrayHelper* pHelper = NULL;
|
|
|
|
if ( !pHelper )
|
|
|
|
{
|
|
|
|
Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
|
|
|
|
pHelper = new UnoPropertyArrayHelper( aIDs );
|
|
|
|
}
|
|
|
|
return *pHelper;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XMultiPropertySet
|
|
|
|
Reference< XPropertySetInfo > UnoControlDialogModel::getPropertySetInfo( ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
|
|
|
|
return xInfo;
|
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
// ============================================================================
|
|
|
|
// = class UnoDialogControl
|
|
|
|
// ============================================================================
|
2003-03-27 16:05:12 +00:00
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
UnoDialogControl::UnoDialogControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory )
|
|
|
|
:ControlContainerBase( i_factory )
|
|
|
|
,maTopWindowListeners( *this )
|
|
|
|
,mbWindowListener(false)
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
maComponentInfos.nWidth = 300;
|
|
|
|
maComponentInfos.nHeight = 450;
|
|
|
|
}
|
2003-03-27 16:05:12 +00:00
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
UnoDialogControl::~UnoDialogControl()
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
::rtl::OUString UnoDialogControl::GetComponentServiceName()
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
sal_Bool bDecoration( sal_True );
|
|
|
|
ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration;
|
|
|
|
if ( bDecoration )
|
|
|
|
return ::rtl::OUString::createFromAscii( "Dialog" );
|
|
|
|
else
|
|
|
|
return ::rtl::OUString::createFromAscii( "TabPage" );
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
// XInterface
|
|
|
|
Any UnoDialogControl::queryAggregation( const Type & rType ) throw(RuntimeException)
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
uno::Any aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( awt::XTopWindow*, this ) );
|
|
|
|
if ( !aRet.hasValue() )
|
|
|
|
aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( awt::XDialog*, this ) );
|
|
|
|
if ( !aRet.hasValue() )
|
|
|
|
aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( awt::XWindowListener*, this ) );
|
|
|
|
return (aRet.hasValue() ? aRet : ControlContainerBase::queryAggregation( rType ));
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
//lang::XTypeProvider
|
|
|
|
IMPL_XTYPEPROVIDER_START( UnoDialogControl)
|
|
|
|
getCppuType( ( uno::Reference< awt::XTopWindow>* ) NULL ),
|
|
|
|
getCppuType( ( uno::Reference< awt::XDialog>* ) NULL ),
|
|
|
|
getCppuType( ( uno::Reference< awt::XWindowListener>* ) NULL ),
|
|
|
|
ControlContainerBase::getTypes()
|
|
|
|
IMPL_XTYPEPROVIDER_END
|
2003-03-27 16:05:12 +00:00
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void UnoDialogControl::dispose() throw(RuntimeException)
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
SolarMutexGuard aGuard;
|
2003-03-27 16:05:12 +00:00
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
EventObject aEvt;
|
|
|
|
aEvt.Source = static_cast< ::cppu::OWeakObject* >( this );
|
|
|
|
maTopWindowListeners.disposeAndClear( aEvt );
|
|
|
|
ControlContainerBase::dispose();
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void SAL_CALL UnoDialogControl::disposing(
|
|
|
|
const EventObject& Source )
|
|
|
|
throw(RuntimeException)
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
ControlContainerBase::disposing( Source );
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
sal_Bool UnoDialogControl::setModel( const Reference< XControlModel >& rxModel ) throw(RuntimeException)
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
// #Can we move all the Resource stuff to the ControlContainerBase ?
|
|
|
|
SolarMutexGuard aGuard;
|
|
|
|
sal_Bool bRet = ControlContainerBase::setModel( rxModel );
|
|
|
|
ImplStartListingForResourceEvents();
|
|
|
|
return bRet;
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void UnoDialogControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException)
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
SolarMutexGuard aGuard;
|
2007-06-27 11:21:36 +00:00
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
UnoControlContainer::createPeer( rxToolkit, rParentPeer );
|
2003-03-27 16:05:12 +00:00
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
|
|
|
|
if ( xTW.is() )
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
xTW->setMenuBar( mxMenuBar );
|
|
|
|
|
|
|
|
if ( !mbWindowListener )
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
Reference< XWindowListener > xWL( static_cast< cppu::OWeakObject*>( this ), UNO_QUERY );
|
|
|
|
addWindowListener( xWL );
|
|
|
|
mbWindowListener = true;
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
2011-03-11 18:04:44 +00:00
|
|
|
|
|
|
|
if ( maTopWindowListeners.getLength() )
|
|
|
|
xTW->addTopWindowListener( &maTopWindowListeners );
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void UnoDialogControl::PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor& rDesc )
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
sal_Bool bDecoration( sal_True );
|
|
|
|
ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration;
|
|
|
|
if ( !bDecoration )
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
// Now we have to manipulate the WindowDescriptor
|
|
|
|
rDesc.WindowAttributes = rDesc.WindowAttributes | ::com::sun::star::awt::WindowAttribute::NODECORATION;
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
// We have to set the graphic property before the peer
|
|
|
|
// will be created. Otherwise the properties will be copied
|
|
|
|
// into the peer via propertiesChangeEvents. As the order of
|
|
|
|
// can lead to overwrites we have to set the graphic property
|
|
|
|
// before the propertiesChangeEvents are sent!
|
|
|
|
::rtl::OUString aImageURL;
|
|
|
|
Reference< graphic::XGraphic > xGraphic;
|
|
|
|
if (( ImplGetPropertyValue( PROPERTY_IMAGEURL ) >>= aImageURL ) &&
|
|
|
|
( aImageURL.getLength() > 0 ))
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
::rtl::OUString absoluteUrl =
|
|
|
|
getPhysicalLocation( ImplGetPropertyValue( PROPERTY_DIALOGSOURCEURL ),
|
|
|
|
ImplGetPropertyValue( PROPERTY_IMAGEURL ));
|
2003-03-27 16:05:12 +00:00
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
xGraphic = ControlContainerBase::Impl_getGraphicFromURL_nothrow( absoluteUrl );
|
|
|
|
ImplSetPropertyValue( PROPERTY_GRAPHIC, uno::makeAny( xGraphic ), sal_True );
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void UnoDialogControl::addTopWindowListener( const Reference< XTopWindowListener >& rxListener ) throw (RuntimeException)
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
maTopWindowListeners.addInterface( rxListener );
|
|
|
|
if( getPeer().is() && maTopWindowListeners.getLength() == 1 )
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
|
|
|
|
xTW->addTopWindowListener( &maTopWindowListeners );
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void UnoDialogControl::removeTopWindowListener( const Reference< XTopWindowListener >& rxListener ) throw (RuntimeException)
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
if( getPeer().is() && maTopWindowListeners.getLength() == 1 )
|
|
|
|
{
|
|
|
|
Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
|
|
|
|
xTW->removeTopWindowListener( &maTopWindowListeners );
|
|
|
|
}
|
|
|
|
maTopWindowListeners.removeInterface( rxListener );
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void UnoDialogControl::toFront( ) throw (RuntimeException)
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
SolarMutexGuard aGuard;
|
|
|
|
if ( getPeer().is() )
|
|
|
|
{
|
|
|
|
Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
|
|
|
|
if( xTW.is() )
|
|
|
|
xTW->toFront();
|
|
|
|
}
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void UnoDialogControl::toBack( ) throw (RuntimeException)
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
SolarMutexGuard aGuard;
|
|
|
|
if ( getPeer().is() )
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
|
|
|
|
if( xTW.is() )
|
|
|
|
xTW->toBack();
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void UnoDialogControl::setMenuBar( const Reference< XMenuBar >& rxMenuBar ) throw (RuntimeException)
|
2010-10-06 10:16:39 +01:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
SolarMutexGuard aGuard;
|
|
|
|
mxMenuBar = rxMenuBar;
|
|
|
|
if ( getPeer().is() )
|
2010-10-06 10:16:39 +01:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
|
|
|
|
if( xTW.is() )
|
|
|
|
xTW->setMenuBar( mxMenuBar );
|
2010-10-06 10:16:39 +01:00
|
|
|
}
|
|
|
|
}
|
2011-03-11 18:04:44 +00:00
|
|
|
static ::Size ImplMapPixelToAppFont( OutputDevice* pOutDev, const ::Size& aSize )
|
2010-10-06 10:16:39 +01:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
::Size aTmp = pOutDev->PixelToLogic( aSize, MAP_APPFONT );
|
|
|
|
return aTmp;
|
|
|
|
}
|
|
|
|
// ::com::sun::star::awt::XWindowListener
|
|
|
|
void SAL_CALL UnoDialogControl::windowResized( const ::com::sun::star::awt::WindowEvent& e )
|
|
|
|
throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OutputDevice*pOutDev = Application::GetDefaultDevice();
|
|
|
|
DBG_ASSERT( pOutDev, "Missing Default Device!" );
|
|
|
|
if ( pOutDev && !mbSizeModified )
|
2010-10-06 10:16:39 +01:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
// Currentley we are simply using MAP_APPFONT
|
|
|
|
::Size aAppFontSize( e.Width, e.Height );
|
|
|
|
|
|
|
|
Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW );
|
|
|
|
Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY );
|
|
|
|
OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" );
|
|
|
|
if ( xDialogDevice.is() )
|
2010-10-06 10:16:39 +01:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
DeviceInfo aDeviceInfo( xDialogDevice->getInfo() );
|
|
|
|
aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
|
|
|
|
aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
|
2010-10-06 10:16:39 +01:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize );
|
2003-03-27 16:05:12 +00:00
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
// Remember that changes have been done by listener. No need to
|
|
|
|
// update the position because of property change event.
|
|
|
|
mbSizeModified = true;
|
|
|
|
Sequence< rtl::OUString > aProps( 2 );
|
|
|
|
Sequence< Any > aValues( 2 );
|
|
|
|
// Properties in a sequence must be sorted!
|
|
|
|
aProps[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Height" ));
|
|
|
|
aProps[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" ));
|
|
|
|
aValues[0] <<= aAppFontSize.Height();
|
|
|
|
aValues[1] <<= aAppFontSize.Width();
|
2003-03-27 16:05:12 +00:00
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
ImplSetPropertyValues( aProps, aValues, true );
|
|
|
|
mbSizeModified = false;
|
2003-03-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void SAL_CALL UnoDialogControl::windowMoved( const ::com::sun::star::awt::WindowEvent& e )
|
|
|
|
throw (::com::sun::star::uno::RuntimeException)
|
2003-03-27 16:05:12 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
OutputDevice*pOutDev = Application::GetDefaultDevice();
|
|
|
|
DBG_ASSERT( pOutDev, "Missing Default Device!" );
|
|
|
|
if ( pOutDev && !mbPosModified )
|
|
|
|
{
|
|
|
|
// Currentley we are simply using MAP_APPFONT
|
|
|
|
Any aAny;
|
|
|
|
::Size aTmp( e.X, e.Y );
|
|
|
|
aTmp = ImplMapPixelToAppFont( pOutDev, aTmp );
|
2003-03-27 16:05:12 +00:00
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
// Remember that changes have been done by listener. No need to
|
|
|
|
// update the position because of property change event.
|
|
|
|
mbPosModified = true;
|
|
|
|
Sequence< rtl::OUString > aProps( 2 );
|
|
|
|
Sequence< Any > aValues( 2 );
|
|
|
|
aProps[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ));
|
|
|
|
aProps[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ));
|
|
|
|
aValues[0] <<= aTmp.Width();
|
|
|
|
aValues[1] <<= aTmp.Height();
|
2007-01-02 14:34:44 +00:00
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
ImplSetPropertyValues( aProps, aValues, true );
|
|
|
|
mbPosModified = false;
|
|
|
|
}
|
2007-01-02 14:34:44 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void SAL_CALL UnoDialogControl::windowShown( const ::com::sun::star::lang::EventObject& e )
|
|
|
|
throw (::com::sun::star::uno::RuntimeException)
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
(void)e;
|
2007-01-02 14:34:44 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void SAL_CALL UnoDialogControl::windowHidden( const ::com::sun::star::lang::EventObject& e )
|
|
|
|
throw (::com::sun::star::uno::RuntimeException)
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
(void)e;
|
2007-01-02 14:34:44 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void UnoDialogControl::setTitle( const ::rtl::OUString& Title ) throw(RuntimeException)
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
SolarMutexGuard aGuard;
|
|
|
|
Any aAny;
|
|
|
|
aAny <<= Title;
|
|
|
|
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ), aAny, sal_True );
|
2007-01-02 14:34:44 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
::rtl::OUString UnoDialogControl::getTitle() throw(RuntimeException)
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
SolarMutexGuard aGuard;
|
|
|
|
return ImplGetPropertyValue_UString( BASEPROPERTY_TITLE );
|
2007-01-02 14:34:44 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
sal_Int16 UnoDialogControl::execute() throw(RuntimeException)
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
SolarMutexGuard aGuard;
|
|
|
|
sal_Int16 nDone = -1;
|
|
|
|
if ( getPeer().is() )
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
Reference< XDialog > xDlg( getPeer(), UNO_QUERY );
|
|
|
|
if( xDlg.is() )
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
GetComponentInfos().bVisible = sal_True;
|
|
|
|
nDone = xDlg->execute();
|
|
|
|
GetComponentInfos().bVisible = sal_False;
|
2007-01-02 14:34:44 +00:00
|
|
|
}
|
|
|
|
}
|
2011-03-11 18:04:44 +00:00
|
|
|
return nDone;
|
2007-01-02 14:34:44 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void UnoDialogControl::endExecute() throw(RuntimeException)
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
SolarMutexGuard aGuard;
|
|
|
|
if ( getPeer().is() )
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
Reference< XDialog > xDlg( getPeer(), UNO_QUERY );
|
|
|
|
if( xDlg.is() )
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
xDlg->endExecute();
|
|
|
|
GetComponentInfos().bVisible = sal_False;
|
2007-01-02 14:34:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// XModifyListener
|
2011-03-11 18:04:44 +00:00
|
|
|
void SAL_CALL UnoDialogControl::modified(
|
|
|
|
const lang::EventObject& /*rEvent*/ )
|
|
|
|
throw (RuntimeException)
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
ImplUpdateResourceResolver();
|
2007-01-02 14:34:44 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
void UnoDialogControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents ) throw(RuntimeException)
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
sal_Int32 nLen = rEvents.getLength();
|
|
|
|
for( sal_Int32 i = 0; i < nLen; i++ )
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
const PropertyChangeEvent& rEvt = rEvents.getConstArray()[i];
|
|
|
|
Reference< XControlModel > xModel( rEvt.Source, UNO_QUERY );
|
|
|
|
sal_Bool bOwnModel = (XControlModel*)xModel.get() == (XControlModel*)getModel().get();
|
|
|
|
if ( bOwnModel && rEvt.PropertyName.equalsAsciiL( "ImageURL", 8 ))
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
::rtl::OUString aImageURL;
|
|
|
|
Reference< graphic::XGraphic > xGraphic;
|
|
|
|
if (( ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEURL ) ) >>= aImageURL ) &&
|
|
|
|
( aImageURL.getLength() > 0 ))
|
2007-01-02 14:34:44 +00:00
|
|
|
{
|
2011-03-11 18:04:44 +00:00
|
|
|
::rtl::OUString absoluteUrl =
|
|
|
|
getPhysicalLocation( ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DIALOGSOURCEURL )),
|
|
|
|
uno::makeAny(aImageURL));
|
2007-01-02 14:34:44 +00:00
|
|
|
|
2011-03-11 18:04:44 +00:00
|
|
|
xGraphic = Impl_getGraphicFromURL_nothrow( absoluteUrl );
|
2007-01-02 14:34:44 +00:00
|
|
|
}
|
2011-03-11 18:04:44 +00:00
|
|
|
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC), uno::makeAny( xGraphic ), sal_True );
|
|
|
|
break;
|
2007-01-02 14:34:44 +00:00
|
|
|
}
|
|
|
|
}
|
2011-03-11 18:04:44 +00:00
|
|
|
ControlContainerBase::ImplModelPropertiesChanged(rEvents);
|
2007-01-02 14:34:44 +00:00
|
|
|
}
|