diff options
Diffstat (limited to 'toolkit/source/awt')
41 files changed, 19049 insertions, 0 deletions
diff --git a/toolkit/source/awt/asynccallback.cxx b/toolkit/source/awt/asynccallback.cxx new file mode 100644 index 000000000000..593feb582274 --- /dev/null +++ b/toolkit/source/awt/asynccallback.cxx @@ -0,0 +1,199 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + +#include "vcl/svapp.hxx" +#include "vos/mutex.hxx" +#include "sal/config.h" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/implementationentry.hxx" +#include "cppuhelper/implbase2.hxx" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/awt/XRequestCallback.hpp" + + +// component helper namespace +namespace comp_AsyncCallback { + +namespace css = ::com::sun::star; + +// component and service helper functions: +::rtl::OUString SAL_CALL _getImplementationName(); +css::uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames(); +css::uno::Reference< css::uno::XInterface > SAL_CALL _create( css::uno::Reference< css::uno::XComponentContext > const & context ); + +} // closing component helper namespace + + + +/// anonymous implementation namespace +namespace { + +namespace css = ::com::sun::star; + +class AsyncCallback: + public ::cppu::WeakImplHelper2< + css::lang::XServiceInfo, + css::awt::XRequestCallback> +{ +public: + explicit AsyncCallback(css::uno::Reference< css::uno::XComponentContext > const & context); + + // ::com::sun::star::lang::XServiceInfo: + virtual ::rtl::OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString & ServiceName) throw (css::uno::RuntimeException); + virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException); + + // ::com::sun::star::awt::XRequestCallback: + virtual void SAL_CALL addCallback(const css::uno::Reference< css::awt::XCallback > & xCallback, const ::com::sun::star::uno::Any & aData) throw (css::uno::RuntimeException); + +private: + + struct CallbackData + { + CallbackData( const css::uno::Reference< css::awt::XCallback >& rCallback, const css::uno::Any& rAny ) : + xCallback( rCallback ), aData( rAny ) {} + + css::uno::Reference< css::awt::XCallback > xCallback; + css::uno::Any aData; + }; + + DECL_STATIC_LINK( AsyncCallback, Notify_Impl, CallbackData* ); + + AsyncCallback(AsyncCallback &); // not defined + void operator =(AsyncCallback &); // not defined + + virtual ~AsyncCallback() {} + + css::uno::Reference< css::uno::XComponentContext > m_xContext; +}; + +AsyncCallback::AsyncCallback(css::uno::Reference< css::uno::XComponentContext > const & context) : + m_xContext(context) +{} + +// com.sun.star.uno.XServiceInfo: +::rtl::OUString SAL_CALL AsyncCallback::getImplementationName() throw (css::uno::RuntimeException) +{ + return comp_AsyncCallback::_getImplementationName(); +} + +::sal_Bool SAL_CALL AsyncCallback::supportsService(::rtl::OUString const & serviceName) throw (css::uno::RuntimeException) +{ + const css::uno::Sequence< ::rtl::OUString > serviceNames = comp_AsyncCallback::_getSupportedServiceNames(); + for (::sal_Int32 i = 0; i < serviceNames.getLength(); ++i) { + if (serviceNames[i] == serviceName) + return sal_True; + } + return sal_False; +} + +css::uno::Sequence< ::rtl::OUString > SAL_CALL AsyncCallback::getSupportedServiceNames() throw (css::uno::RuntimeException) +{ + return comp_AsyncCallback::_getSupportedServiceNames(); +} + +// ::com::sun::star::awt::XRequestCallback: +void SAL_CALL AsyncCallback::addCallback(const css::uno::Reference< css::awt::XCallback > & xCallback, const ::com::sun::star::uno::Any & aData) throw (css::uno::RuntimeException) +{ + if ( Application::IsInMain() ) + { + osl::Guard< vos::IMutex > aSolarGuard( Application::GetSolarMutex() ); + CallbackData* pCallbackData = new CallbackData( xCallback, aData ); + Application::PostUserEvent( STATIC_LINK( this, AsyncCallback, Notify_Impl ), pCallbackData ); + } +} + +// private asynchronous link to call reference to the callback object +IMPL_STATIC_LINK_NOINSTANCE( AsyncCallback, Notify_Impl, CallbackData*, pCallbackData ) +{ + try + { + // Asynchronous execution + // Check pointer and reference before! + if ( pCallbackData && pCallbackData->xCallback.is() ) + pCallbackData->xCallback->notify( pCallbackData->aData ); + } + catch ( css::uno::Exception& ) + { + } + + delete pCallbackData; + return 0; +} + +} // closing anonymous implementation namespace + + + +// component helper namespace +namespace comp_AsyncCallback { + +::rtl::OUString SAL_CALL _getImplementationName() { + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.awt.comp.AsyncCallback")); +} + +css::uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames() +{ + css::uno::Sequence< ::rtl::OUString > s(1); + s[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.awt.AsyncCallback")); + return s; +} + +css::uno::Reference< css::uno::XInterface > SAL_CALL _create( + const css::uno::Reference< css::uno::XComponentContext > & context) + SAL_THROW((css::uno::Exception)) +{ + return static_cast< ::cppu::OWeakObject * >(new AsyncCallback(context)); +} + +} // closing component helper namespace + +static ::cppu::ImplementationEntry const entries[] = { + { &comp_AsyncCallback::_create, + &comp_AsyncCallback::_getImplementationName, + &comp_AsyncCallback::_getSupportedServiceNames, + &::cppu::createSingleComponentFactory, 0, 0 }, + { 0, 0, 0, 0, 0, 0 } +}; + +void * SAL_CALL comp_AsyncCallback_component_getFactory( + const char * implName, void * serviceManager, void * registryKey) +{ + return ::cppu::component_getFactoryHelper( + implName, serviceManager, registryKey, entries); +} + +sal_Bool SAL_CALL comp_AsyncCallback_component_writeInfo( + void * serviceManager, void * registryKey) +{ + return ::cppu::component_writeInfoHelper(serviceManager, registryKey, entries); +} diff --git a/toolkit/source/awt/forward.hxx b/toolkit/source/awt/forward.hxx new file mode 100644 index 000000000000..0228be562b2c --- /dev/null +++ b/toolkit/source/awt/forward.hxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifndef AWT_FORWARD_HXX +#define AWT_FORWARD_HXX + +#include <comphelper/uno3.hxx> + +#define IMPLEMENT_FORWARD_XTYPEPROVIDER1( classname, baseclass ) \ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL classname::getTypes( ) throw (::com::sun::star::uno::RuntimeException) \ + { return baseclass::getTypes(); } \ + IMPLEMENT_GET_IMPLEMENTATION_ID( classname ) + +#define IMPLEMENT_2_FORWARD_XINTERFACE1( classname, refcountbase1, refcountbase2 ) \ + void SAL_CALL classname::acquire() throw() { refcountbase1::acquire(); refcountbase2::acquire(); } \ + void SAL_CALL classname::release() throw() { refcountbase1::release(); refcountbase2::release(); } \ + ::com::sun::star::uno::Any SAL_CALL classname::queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException) \ + { \ + ::com::sun::star::uno::Any aReturn = refcountbase1::queryInterface( _rType ); \ + if ( !aReturn.hasValue() ) \ + { \ + aReturn = refcountbase2::queryInterface( _rType ); \ + } \ + return aReturn; \ + } + +#define IMPLEMENT_2_FORWARD_XINTERFACE2( classname, refcountbase1, refcountbase2, baseclass3 ) \ + void SAL_CALL classname::acquire() throw() { refcountbase1::acquire(); refcountbase2::acquire(); } \ + void SAL_CALL classname::release() throw() { refcountbase1::release(); refcountbase2::release(); } \ + ::com::sun::star::uno::Any SAL_CALL classname::queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException) \ + { \ + ::com::sun::star::uno::Any aReturn = refcountbase1::queryInterface( _rType ); \ + if ( !aReturn.hasValue() ) \ + { \ + aReturn = refcountbase2::queryInterface( _rType ); \ + if ( !aReturn.hasValue() ) \ + aReturn = baseclass3::queryInterface( _rType ); \ + } \ + return aReturn; \ + } + +#if defined (_MSC_VER) && (_MSC_VER <= 1310) +// Windows .Net2003 build fix +#define W3K_EXPLICIT_CAST(x) static_cast <XWindow2*> (&x) +#else // !(defined (_MSC_VER) && (_MSC_VER <= 1310)) +#define W3K_EXPLICIT_CAST(x) x +#endif // !(defined (_MSC_VER) && (_MSC_VER <= 1310)) + +#endif /* AWT_FORWARD_HXX */ diff --git a/toolkit/source/awt/makefile.mk b/toolkit/source/awt/makefile.mk new file mode 100644 index 000000000000..a53e9e22ba2d --- /dev/null +++ b/toolkit/source/awt/makefile.mk @@ -0,0 +1,83 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# 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. +# +# 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). +# +# 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. +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=toolkit +TARGET=awt + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +.IF "$(GUIBASE)"=="aqua" +CFLAGSCXX+=$(OBJCXXFLAGS) +.ENDIF # "$(GUIBASE)"=="aqua" + +SLOFILES= \ + $(SLO)$/vclxaccessiblecomponent.obj \ + $(SLO)$/vclxbitmap.obj \ + $(SLO)$/vclxcontainer.obj \ + $(SLO)$/vclxdevice.obj \ + $(SLO)$/vclxfont.obj \ + $(SLO)$/vclxgraphics.obj \ + $(SLO)$/vclxmenu.obj \ + $(SLO)$/vclxpointer.obj \ + $(SLO)$/vclxprinter.obj \ + $(SLO)$/vclxregion.obj \ + $(SLO)$/vclxsystemdependentwindow.obj \ + $(SLO)$/vclxtoolkit.obj \ + $(SLO)$/vclxtopwindow.obj \ + $(SLO)$/vclxwindow.obj \ + $(SLO)$/vclxwindow1.obj \ + $(SLO)$/vclxwindows.obj \ + $(SLO)$/vclxspinbutton.obj \ + $(SLO)$/xsimpleanimation.obj \ + $(SLO)$/xthrobber.obj \ + $(SLO)$/asynccallback.obj\ + $(SLO)/vclxbutton.obj\ + $(SLO)/vclxdialog.obj\ + $(SLO)/vclxfixedline.obj\ + $(SLO)/vclxplugin.obj\ + $(SLO)/vclxscroller.obj\ + $(SLO)/vclxsplitter.obj\ + $(SLO)/vclxtabcontrol.obj\ + $(SLO)/vclxtabpage.obj + +SRS1NAME=$(TARGET) +SRC1FILES=\ + xthrobber.src + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/toolkit/source/awt/non-interactable-containers.xml b/toolkit/source/awt/non-interactable-containers.xml new file mode 100644 index 000000000000..0ffdb7e9d58d --- /dev/null +++ b/toolkit/source/awt/non-interactable-containers.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<dialog xmlns="http://openoffice.org/2007/layout" + xmlns:cnt="http://openoffice.org/2007/layout/container" + title="Interactable Containers" optimumsize="true" + border="true" sizeable="true" moveable="true"> + <hbox> + <table columns="3" cnt:title="Page 1"> + <pushbutton cnt:x-expand="false" cnt:row-span="2" label="1,1" /> + <pushbutton cnt:y-expand="false" label="1,2" /> + <pushbutton cnt:y-expand="false" label="1,3" /> + <pushbutton cnt:col-span="2" label="2,1" /> + </table> + </hbox> +</dialog> diff --git a/toolkit/source/awt/vclxaccessiblecomponent.cxx b/toolkit/source/awt/vclxaccessiblecomponent.cxx new file mode 100644 index 000000000000..175289d1ac84 --- /dev/null +++ b/toolkit/source/awt/vclxaccessiblecomponent.cxx @@ -0,0 +1,924 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + + +#include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/accessibility/AccessibleEventId.hpp> +#include <com/sun/star/accessibility/XAccessibleEventListener.hpp> +#include <com/sun/star/accessibility/AccessibleRelationType.hpp> +#include <toolkit/awt/vclxaccessiblecomponent.hxx> +#include <toolkit/helper/externallock.hxx> +#include <toolkit/awt/vclxwindow.hxx> +#include <toolkit/helper/convert.hxx> +#include <toolkit/awt/vclxfont.hxx> +#include <vcl/dialog.hxx> +#include <vcl/window.hxx> +#include <tools/debug.hxx> +#include <unotools/accessiblestatesethelper.hxx> +#include <unotools/accessiblerelationsethelper.hxx> +#include <vcl/svapp.hxx> +#include <vcl/menu.hxx> + +#ifndef VCLEVENT_WINDOW_FRAMETITLECHANGED +#define VCLEVENT_WINDOW_FRAMETITLECHANGED 1018 // pData = XubString* = oldTitle +#endif + +using namespace ::com::sun::star; +using namespace ::comphelper; + + +DBG_NAME(VCLXAccessibleComponent) + + +// ---------------------------------------------------- +// class VCLXAccessibleComponent +// ---------------------------------------------------- +VCLXAccessibleComponent::VCLXAccessibleComponent( VCLXWindow* pVCLXindow ) + : AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() ) + , OAccessibleImplementationAccess( ) +{ + DBG_CTOR( VCLXAccessibleComponent, 0 ); + mpVCLXindow = pVCLXindow; + mxWindow = pVCLXindow; + + m_pSolarLock = static_cast< VCLExternalSolarLock* >( getExternalLock( ) ); + + DBG_ASSERT( pVCLXindow->GetWindow(), "VCLXAccessibleComponent - no window!" ); + if ( pVCLXindow->GetWindow() ) + { + pVCLXindow->GetWindow()->AddEventListener( LINK( this, VCLXAccessibleComponent, WindowEventListener ) ); + pVCLXindow->GetWindow()->AddChildEventListener( LINK( this, VCLXAccessibleComponent, WindowChildEventListener ) ); + } + + // announce the XAccessible of our creator to the base class + lateInit( pVCLXindow ); +} + +VCLXAccessibleComponent::~VCLXAccessibleComponent() +{ + DBG_DTOR( VCLXAccessibleComponent, 0 ); + + ensureDisposed(); + + if ( mpVCLXindow && mpVCLXindow->GetWindow() ) + { + mpVCLXindow->GetWindow()->RemoveEventListener( LINK( this, VCLXAccessibleComponent, WindowEventListener ) ); + mpVCLXindow->GetWindow()->RemoveChildEventListener( LINK( this, VCLXAccessibleComponent, WindowChildEventListener ) ); + } + + delete m_pSolarLock; + m_pSolarLock = NULL; + // This is not completely safe. If we assume that the base class dtor calls some method which + // uses this lock, the we crash. However, as the base class' dtor does not have a chance to call _out_ + // virtual methods, this is no problem as long as the base class is safe, i.e. does not use the external + // lock from within it's dtor. At the moment, we _know_ the base class is safe in this respect, so + // let's assume it keeps this way. + // @see OAccessibleContextHelper::OAccessibleContextHelper( IMutex* ) +} + +IMPLEMENT_FORWARD_XINTERFACE3( VCLXAccessibleComponent, AccessibleExtendedComponentHelper_BASE, OAccessibleImplementationAccess, VCLXAccessibleComponent_BASE ) +IMPLEMENT_FORWARD_XTYPEPROVIDER3( VCLXAccessibleComponent, AccessibleExtendedComponentHelper_BASE, OAccessibleImplementationAccess, VCLXAccessibleComponent_BASE ) + +::rtl::OUString VCLXAccessibleComponent::getImplementationName() throw (uno::RuntimeException) +{ + return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleWindow" ); +} + +sal_Bool VCLXAccessibleComponent::supportsService( const ::rtl::OUString& rServiceName ) throw (uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() ); + const ::rtl::OUString* pNames = aNames.getConstArray(); + const ::rtl::OUString* pEnd = pNames + aNames.getLength(); + for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames ) + ; + + return pNames != pEnd; +} + +uno::Sequence< ::rtl::OUString > VCLXAccessibleComponent::getSupportedServiceNames() throw (uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aNames(1); + aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleWindow" ); + return aNames; +} + +IMPL_LINK( VCLXAccessibleComponent, WindowEventListener, VclSimpleEvent*, pEvent ) +{ + DBG_CHKTHIS(VCLXAccessibleComponent,0); + + DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" ); + + /* Ignore VCLEVENT_WINDOW_ENDPOPUPMODE, because the UNO accessibility wrapper + * might have been destroyed by the previous VCLEventListener (if no AT tool + * is running), e.g. sub-toolbars in impress. + */ + if ( pEvent && pEvent->ISA( VclWindowEvent ) && mxWindow.is() /* #122218# */ && (pEvent->GetId() != VCLEVENT_WINDOW_ENDPOPUPMODE) ) + { + DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow(), "Window???" ); + if( !((VclWindowEvent*)pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent->GetId() == VCLEVENT_OBJECT_DYING ) ) + { + ProcessWindowEvent( *(VclWindowEvent*)pEvent ); + } + } + return 0; +} + +IMPL_LINK( VCLXAccessibleComponent, WindowChildEventListener, VclSimpleEvent*, pEvent ) +{ + DBG_CHKTHIS(VCLXAccessibleComponent,0); + + DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" ); + if ( pEvent && pEvent->ISA( VclWindowEvent ) && mxWindow.is() /* #i68079# */ ) + { + DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow(), "Window???" ); + if( !((VclWindowEvent*)pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() ) + { + // #103087# to prevent an early release of the component + uno::Reference< accessibility::XAccessibleContext > xTmp = this; + + ProcessWindowChildEvent( *(VclWindowEvent*)pEvent ); + } + } + return 0; +} + +uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::GetChildAccessible( const VclWindowEvent& rVclWindowEvent ) +{ + // checks if the data in the window event is our direct child + // and returns its accessible + + // MT: Change this later, normaly a show/hide event shouldn't have the Window* in pData. + Window* pChildWindow = (Window *) rVclWindowEvent.GetData(); + if( pChildWindow && GetWindow() == pChildWindow->GetAccessibleParentWindow() ) + return pChildWindow->GetAccessible( rVclWindowEvent.GetId() == VCLEVENT_WINDOW_SHOW ); + else + return uno::Reference< accessibility::XAccessible > (); +} + +void VCLXAccessibleComponent::ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent ) +{ + uno::Any aOldValue, aNewValue; + uno::Reference< accessibility::XAccessible > xAcc; + + switch ( rVclWindowEvent.GetId() ) + { + case VCLEVENT_WINDOW_SHOW: // send create on show for direct accessible children + { + xAcc = GetChildAccessible( rVclWindowEvent ); + if( xAcc.is() ) + { + aNewValue <<= xAcc; + NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD, aOldValue, aNewValue ); + } + } + break; + case VCLEVENT_WINDOW_HIDE: // send destroy on hide for direct accessible children + { + xAcc = GetChildAccessible( rVclWindowEvent ); + if( xAcc.is() ) + { + aOldValue <<= xAcc; + NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD, aOldValue, aNewValue ); + } + } + break; + } +} + +void VCLXAccessibleComponent::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + uno::Any aOldValue, aNewValue; + + Window* pAccWindow = rVclWindowEvent.GetWindow(); + DBG_ASSERT( pAccWindow, "VCLXAccessibleComponent::ProcessWindowEvent - Window?" ); + + switch ( rVclWindowEvent.GetId() ) + { + case VCLEVENT_OBJECT_DYING: + { + pAccWindow->RemoveEventListener( LINK( this, VCLXAccessibleComponent, WindowEventListener ) ); + pAccWindow->RemoveChildEventListener( LINK( this, VCLXAccessibleComponent, WindowChildEventListener ) ); + mxWindow.clear(); + mpVCLXindow = NULL; + } + break; + // + // dont handle CHILDCREATED events here + // they are handled separately as child events, see ProcessWindowChildEvent above + // + /* + case VCLEVENT_WINDOW_CHILDCREATED: + { + Window* pWindow = (Window*) rVclWindowEvent.GetData(); + DBG_ASSERT( pWindow, "VCLEVENT_WINDOW_CHILDCREATED - Window=?" ); + aNewValue <<= pWindow->GetAccessible(); + NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD, aOldValue, aNewValue ); + } + break; + */ + case VCLEVENT_WINDOW_CHILDDESTROYED: + { + Window* pWindow = (Window*) rVclWindowEvent.GetData(); + DBG_ASSERT( pWindow, "VCLEVENT_WINDOW_CHILDDESTROYED - Window=?" ); + if ( pWindow->GetAccessible( FALSE ).is() ) + { + aOldValue <<= pWindow->GetAccessible( FALSE ); + NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD, aOldValue, aNewValue ); + } + } + break; + + // + // show and hide will be handled as child events only and are + // responsible for sending create/destroy events, see ProcessWindowChildEvent above + // + /* + case VCLEVENT_WINDOW_SHOW: + { + aNewValue <<= accessibility::AccessibleStateType::VISIBLE; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + + aNewValue <<= accessibility::AccessibleStateType::SHOWING; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + + aNewValue.clear(); + aOldValue <<= accessibility::AccessibleStateType::INVALID; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + break; + case VCLEVENT_WINDOW_HIDE: + { + aOldValue <<= accessibility::AccessibleStateType::VISIBLE; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + + aOldValue <<= accessibility::AccessibleStateType::SHOWING; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + + aOldValue.clear(); + aNewValue <<= accessibility::AccessibleStateType::INVALID; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + break; + */ + case VCLEVENT_WINDOW_ACTIVATE: + { + // avoid notification if a child frame is already active + // only one frame may be active at a given time + if ( !pAccWindow->HasActiveChildFrame() && + ( getAccessibleRole() == accessibility::AccessibleRole::FRAME || + getAccessibleRole() == accessibility::AccessibleRole::ALERT || + getAccessibleRole() == accessibility::AccessibleRole::DIALOG ) ) // #i18891# + { + aNewValue <<= accessibility::AccessibleStateType::ACTIVE; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + } + break; + case VCLEVENT_WINDOW_DEACTIVATE: + { + if ( getAccessibleRole() == accessibility::AccessibleRole::FRAME || + getAccessibleRole() == accessibility::AccessibleRole::ALERT || + getAccessibleRole() == accessibility::AccessibleRole::DIALOG ) // #i18891# + { + aOldValue <<= accessibility::AccessibleStateType::ACTIVE; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + } + break; + case VCLEVENT_WINDOW_GETFOCUS: + case VCLEVENT_CONTROL_GETFOCUS: + { + if( (pAccWindow->IsCompoundControl() && rVclWindowEvent.GetId() == VCLEVENT_CONTROL_GETFOCUS) || + (!pAccWindow->IsCompoundControl() && rVclWindowEvent.GetId() == VCLEVENT_WINDOW_GETFOCUS) ) + { + // if multiple listeners were registered it is possible that the + // focus was changed during event processing (eg SfxTopWindow ) + // #106082# allow ChildPathFocus only for CompoundControls, for windows the focus must be in the window itself + if( (pAccWindow->IsCompoundControl() && pAccWindow->HasChildPathFocus()) || + (!pAccWindow->IsCompoundControl() && pAccWindow->HasFocus()) ) + { + aNewValue <<= accessibility::AccessibleStateType::FOCUSED; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + } + } + break; + case VCLEVENT_WINDOW_LOSEFOCUS: + case VCLEVENT_CONTROL_LOSEFOCUS: + { + if( (pAccWindow->IsCompoundControl() && rVclWindowEvent.GetId() == VCLEVENT_CONTROL_LOSEFOCUS) || + (!pAccWindow->IsCompoundControl() && rVclWindowEvent.GetId() == VCLEVENT_WINDOW_LOSEFOCUS) ) + { + aOldValue <<= accessibility::AccessibleStateType::FOCUSED; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + } + break; + case VCLEVENT_WINDOW_FRAMETITLECHANGED: + { + ::rtl::OUString aOldName( *((::rtl::OUString*) rVclWindowEvent.GetData()) ); + ::rtl::OUString aNewName( getAccessibleName() ); + aOldValue <<= aOldName; + aNewValue <<= aNewName; + NotifyAccessibleEvent( accessibility::AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue ); + } + break; + case VCLEVENT_WINDOW_ENABLED: + { + aNewValue <<= accessibility::AccessibleStateType::ENABLED; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + aNewValue <<= accessibility::AccessibleStateType::SENSITIVE; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + break; + case VCLEVENT_WINDOW_DISABLED: + { + aOldValue <<= accessibility::AccessibleStateType::SENSITIVE; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + + aOldValue <<= accessibility::AccessibleStateType::ENABLED; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + break; + case VCLEVENT_WINDOW_MOVE: + case VCLEVENT_WINDOW_RESIZE: + { + NotifyAccessibleEvent( accessibility::AccessibleEventId::BOUNDRECT_CHANGED, aOldValue, aNewValue ); + } + break; + case VCLEVENT_WINDOW_MENUBARADDED: + { + MenuBar* pMenuBar = (MenuBar*) rVclWindowEvent.GetData(); + if ( pMenuBar ) + { + uno::Reference< accessibility::XAccessible > xChild( pMenuBar->GetAccessible() ); + if ( xChild.is() ) + { + aNewValue <<= xChild; + NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD, aOldValue, aNewValue ); + } + } + } + break; + case VCLEVENT_WINDOW_MENUBARREMOVED: + { + MenuBar* pMenuBar = (MenuBar*) rVclWindowEvent.GetData(); + if ( pMenuBar ) + { + uno::Reference< accessibility::XAccessible > xChild( pMenuBar->GetAccessible() ); + if ( xChild.is() ) + { + aOldValue <<= xChild; + NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD, aOldValue, aNewValue ); + } + } + } + break; + case VCLEVENT_WINDOW_MINIMIZE: + { + aNewValue <<= accessibility::AccessibleStateType::ICONIFIED; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + break; + case VCLEVENT_WINDOW_NORMALIZE: + { + aOldValue <<= accessibility::AccessibleStateType::ICONIFIED; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + break; + default: + { + } + break; + } +} + +void VCLXAccessibleComponent::disposing() +{ + if ( mpVCLXindow && mpVCLXindow->GetWindow() ) + { + mpVCLXindow->GetWindow()->RemoveEventListener( LINK( this, VCLXAccessibleComponent, WindowEventListener ) ); + mpVCLXindow->GetWindow()->RemoveChildEventListener( LINK( this, VCLXAccessibleComponent, WindowChildEventListener ) ); + } + + AccessibleExtendedComponentHelper_BASE::disposing(); + + mxWindow.clear(); + mpVCLXindow = NULL; +} + +Window* VCLXAccessibleComponent::GetWindow() const +{ + return GetVCLXWindow() ? GetVCLXWindow()->GetWindow() : NULL; +} + +void VCLXAccessibleComponent::FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet ) +{ + Window* pWindow = GetWindow(); + if ( pWindow ) + { + Window *pLabeledBy = pWindow->GetLabeledBy(); + if ( pLabeledBy && pLabeledBy != pWindow ) + { + uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1); + aSequence[0] = pLabeledBy->GetAccessible(); + rRelationSet.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABELED_BY, aSequence ) ); + } + + Window* pLabelFor = pWindow->GetLabelFor(); + if ( pLabelFor && pLabelFor != pWindow ) + { + uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1); + aSequence[0] = pLabelFor->GetAccessible(); + rRelationSet.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABEL_FOR, aSequence ) ); + } + } +} + +void VCLXAccessibleComponent::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) +{ + Window* pWindow = GetWindow(); + if ( pWindow ) + { + if ( pWindow->IsVisible() ) + { + rStateSet.AddState( accessibility::AccessibleStateType::VISIBLE ); + rStateSet.AddState( accessibility::AccessibleStateType::SHOWING ); + } + else + { + rStateSet.AddState( accessibility::AccessibleStateType::INVALID ); + } + + if ( pWindow->IsEnabled() ) + { + rStateSet.AddState( accessibility::AccessibleStateType::ENABLED ); + rStateSet.AddState( accessibility::AccessibleStateType::SENSITIVE ); + } + + if ( pWindow->HasChildPathFocus() && + ( getAccessibleRole() == accessibility::AccessibleRole::FRAME || + getAccessibleRole() == accessibility::AccessibleRole::ALERT || + getAccessibleRole() == accessibility::AccessibleRole::DIALOG ) ) // #i18891# + rStateSet.AddState( accessibility::AccessibleStateType::ACTIVE ); + + // #104290# MT: This way, a ComboBox doesn't get state FOCUSED. + // I also don't understand + // a) why WINDOW_FIRSTCHILD is used here (which btw is a border window in the case of a combo box) + // b) why HasFocus() is nout "enough" for a compound control + /* + Window* pChild = pWindow->GetWindow( WINDOW_FIRSTCHILD ); + if ( ( !pWindow->IsCompoundControl() && pWindow->HasFocus() ) || + ( pWindow->IsCompoundControl() && pChild && pChild->HasFocus() ) ) + rStateSet.AddState( accessibility::AccessibleStateType::FOCUSED ); + */ + if ( pWindow->HasFocus() || ( pWindow->IsCompoundControl() && pWindow->HasChildPathFocus() ) ) + rStateSet.AddState( accessibility::AccessibleStateType::FOCUSED ); + + if ( pWindow->IsWait() ) + rStateSet.AddState( accessibility::AccessibleStateType::BUSY ); + + if ( pWindow->GetStyle() & WB_SIZEABLE ) + rStateSet.AddState( accessibility::AccessibleStateType::RESIZABLE ); + + if( pWindow->IsDialog() ) + { + Dialog *pDlg = static_cast< Dialog* >( pWindow ); + if( pDlg->IsInExecute() ) + rStateSet.AddState( accessibility::AccessibleStateType::MODAL ); + } + } + else + { + rStateSet.AddState( accessibility::AccessibleStateType::DEFUNC ); + } + +/* + +MUST BE SET FROM DERIVED CLASSES: + +CHECKED +COLLAPSED +EXPANDED +EXPANDABLE +EDITABLE +FOCUSABLE +HORIZONTAL +VERTICAL +ICONIFIED +MULTILINE +MULTI_SELECTABLE +PRESSED +SELECTABLE +SELECTED +SINGLE_LINE +TRANSIENT + + */ +} + + +// accessibility::XAccessibleContext +sal_Int32 VCLXAccessibleComponent::getAccessibleChildCount() throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + sal_Int32 nChildren = 0; + if ( GetWindow() ) + nChildren = GetWindow()->GetAccessibleChildWindowCount(); + + return nChildren; +} + +uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::getAccessibleChild( sal_Int32 i ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + if ( i >= getAccessibleChildCount() ) + throw lang::IndexOutOfBoundsException(); + + uno::Reference< accessibility::XAccessible > xAcc; + if ( GetWindow() ) + { + Window* pChild = GetWindow()->GetAccessibleChildWindow( (USHORT)i ); + if ( pChild ) + xAcc = pChild->GetAccessible(); + } + + return xAcc; +} + +uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::getVclParent() const +{ + uno::Reference< accessibility::XAccessible > xAcc; + if ( GetWindow() ) + { + Window* pParent = GetWindow()->GetAccessibleParentWindow(); + if ( pParent ) + xAcc = pParent->GetAccessible(); + } + return xAcc; +} + +uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::getAccessibleParent( ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + uno::Reference< accessibility::XAccessible > xAcc( implGetForeignControlledParent() ); + if ( !xAcc.is() ) + // we do _not_ have a foreign-controlled parent -> default to our VCL parent + xAcc = getVclParent(); + + return xAcc; +} + +sal_Int32 VCLXAccessibleComponent::getAccessibleIndexInParent( ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + sal_Int32 nIndex = -1; + + uno::Reference< accessibility::XAccessible > xAcc( implGetForeignControlledParent() ); + if ( xAcc.is() ) + { // we _do_ have a foreign-controlled parent -> use the base class' implementation, + // which goes the UNO way + nIndex = AccessibleExtendedComponentHelper_BASE::getAccessibleIndexInParent( ); + } + else + { + if ( GetWindow() ) + { + Window* pParent = GetWindow()->GetAccessibleParentWindow(); + if ( pParent ) + { + /* + for ( USHORT n = pParent->GetAccessibleChildWindowCount(); n; ) + { + Window* pChild = pParent->GetAccessibleChildWindow( --n ); + if ( pChild == GetWindow() ) + { + nIndex = n; + break; + } + } + */ + // Iterate over all the parent's children and search for this object. + // this should be compatible with the code in SVX + uno::Reference< accessibility::XAccessible > xParentAcc( pParent->GetAccessible() ); + if ( xParentAcc.is() ) + { + uno::Reference< accessibility::XAccessibleContext > xParentContext ( xParentAcc->getAccessibleContext() ); + if ( xParentContext.is() ) + { + sal_Int32 nChildCount = xParentContext->getAccessibleChildCount(); + for ( sal_Int32 i=0; i<nChildCount; i++ ) + { + uno::Reference< accessibility::XAccessible > xChild( xParentContext->getAccessibleChild(i) ); + if ( xChild.is() ) + { + uno::Reference< accessibility::XAccessibleContext > xChildContext = xChild->getAccessibleContext(); + if ( xChildContext == (accessibility::XAccessibleContext*) this ) + { + nIndex = i; + break; + } + } + } + } + } + } + } + } + return nIndex; +} + +sal_Int16 VCLXAccessibleComponent::getAccessibleRole( ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + sal_Int16 nRole = 0; + + if ( GetWindow() ) + nRole = GetWindow()->GetAccessibleRole(); + + return nRole; +} + +::rtl::OUString VCLXAccessibleComponent::getAccessibleDescription( ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + ::rtl::OUString aDescription; + + if ( GetWindow() ) + aDescription = GetWindow()->GetAccessibleDescription(); + + return aDescription; +} + +::rtl::OUString VCLXAccessibleComponent::getAccessibleName( ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + ::rtl::OUString aName; + if ( GetWindow() ) + { + aName = GetWindow()->GetAccessibleName(); +#if OSL_DEBUG_LEVEL > 1 + aName += String( RTL_CONSTASCII_USTRINGPARAM( " (Type = " ) ); + aName += String::CreateFromInt32( GetWindow()->GetType() ); + aName += String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ); +#endif + } + return aName; +} + +uno::Reference< accessibility::XAccessibleRelationSet > VCLXAccessibleComponent::getAccessibleRelationSet( ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; + uno::Reference< accessibility::XAccessibleRelationSet > xSet = pRelationSetHelper; + FillAccessibleRelationSet( *pRelationSetHelper ); + return xSet; +} + +uno::Reference< accessibility::XAccessibleStateSet > VCLXAccessibleComponent::getAccessibleStateSet( ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; + uno::Reference< accessibility::XAccessibleStateSet > xSet = pStateSetHelper; + FillAccessibleStateSet( *pStateSetHelper ); + return xSet; +} + +lang::Locale VCLXAccessibleComponent::getLocale() throw (accessibility::IllegalAccessibleComponentStateException, uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + return Application::GetSettings().GetLocale(); +} + +uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::getAccessibleAtPoint( const awt::Point& rPoint ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + uno::Reference< accessibility::XAccessible > xChild; + for ( sal_uInt32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i ) + { + uno::Reference< accessibility::XAccessible > xAcc = getAccessibleChild( i ); + if ( xAcc.is() ) + { + uno::Reference< accessibility::XAccessibleComponent > xComp( xAcc->getAccessibleContext(), uno::UNO_QUERY ); + if ( xComp.is() ) + { + Rectangle aRect = VCLRectangle( xComp->getBounds() ); + Point aPos = VCLPoint( rPoint ); + if ( aRect.IsInside( aPos ) ) + { + xChild = xAcc; + break; + } + } + } + } + + return xChild; +} + +// accessibility::XAccessibleComponent +awt::Rectangle VCLXAccessibleComponent::implGetBounds() throw (uno::RuntimeException) +{ + awt::Rectangle aBounds ( 0, 0, 0, 0 ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + { + Rectangle aRect = pWindow->GetWindowExtentsRelative( NULL ); + aBounds = AWTRectangle( aRect ); + Window* pParent = pWindow->GetAccessibleParentWindow(); + if ( pParent ) + { + Rectangle aParentRect = pParent->GetWindowExtentsRelative( NULL ); + awt::Point aParentScreenLoc = AWTPoint( aParentRect.TopLeft() ); + aBounds.X -= aParentScreenLoc.X; + aBounds.Y -= aParentScreenLoc.Y; + } + } + + uno::Reference< accessibility::XAccessible > xParent( implGetForeignControlledParent() ); + if ( xParent.is() ) + { // hmm, we can't rely on our VCL coordinates, as in the Accessibility Hierarchy, somebody gave + // us a parent which is different from our VCL parent + // (actually, we did not check if it's really different ...) + + // the screen location of the foreign parent + uno::Reference< accessibility::XAccessibleComponent > xParentComponent( xParent->getAccessibleContext(), uno::UNO_QUERY ); + DBG_ASSERT( xParentComponent.is(), "VCLXAccessibleComponent::implGetBounds: invalid (foreign) parent component!" ); + + awt::Point aScreenLocForeign( 0, 0 ); + if ( xParentComponent.is() ) + aScreenLocForeign = xParentComponent->getLocationOnScreen(); + + // the screen location of the VCL parent + xParent = getVclParent(); + if ( xParent.is() ) + xParentComponent = xParentComponent.query( xParent->getAccessibleContext() ); + + awt::Point aScreenLocVCL( 0, 0 ); + if ( xParentComponent.is() ) + aScreenLocVCL = xParentComponent->getLocationOnScreen(); + + // the difference between them + awt::Size aOffset( aScreenLocVCL.X - aScreenLocForeign.X, aScreenLocVCL.Y - aScreenLocForeign.Y ); + // move the bounds + aBounds.X += aOffset.Width; + aBounds.Y += aOffset.Height; + } + + return aBounds; +} + +awt::Point VCLXAccessibleComponent::getLocationOnScreen( ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + awt::Point aPos; + if ( GetWindow() ) + { + Rectangle aRect = GetWindow()->GetWindowExtentsRelative( NULL ); + aPos.X = aRect.Left(); + aPos.Y = aRect.Top(); + } + + return aPos; +} + +void VCLXAccessibleComponent::grabFocus( ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + uno::Reference< accessibility::XAccessibleStateSet > xStates = getAccessibleStateSet(); + if ( mxWindow.is() && xStates.is() && xStates->contains( accessibility::AccessibleStateType::FOCUSABLE ) ) + mxWindow->setFocus(); +} + +sal_Int32 SAL_CALL VCLXAccessibleComponent::getForeground( ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + sal_Int32 nColor = 0; + Window* pWindow = GetWindow(); + if ( pWindow ) + { + if ( pWindow->IsControlForeground() ) + nColor = pWindow->GetControlForeground().GetColor(); + else + { + Font aFont; + if ( pWindow->IsControlFont() ) + aFont = pWindow->GetControlFont(); + else + aFont = pWindow->GetFont(); + nColor = aFont.GetColor().GetColor(); + } + } + + return nColor; +} + +sal_Int32 SAL_CALL VCLXAccessibleComponent::getBackground( ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + sal_Int32 nColor = 0; + Window* pWindow = GetWindow(); + if ( pWindow ) + { + if ( pWindow->IsControlBackground() ) + nColor = pWindow->GetControlBackground().GetColor(); + else + nColor = pWindow->GetBackground().GetColor().GetColor(); + } + + return nColor; +} + +// XAccessibleExtendedComponent + +uno::Reference< awt::XFont > SAL_CALL VCLXAccessibleComponent::getFont( ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + uno::Reference< awt::XFont > xFont; + Window* pWindow = GetWindow(); + if ( pWindow ) + { + uno::Reference< awt::XDevice > xDev( pWindow->GetComponentInterface(), uno::UNO_QUERY ); + if ( xDev.is() ) + { + Font aFont; + if ( pWindow->IsControlFont() ) + aFont = pWindow->GetControlFont(); + else + aFont = pWindow->GetFont(); + VCLXFont* pVCLXFont = new VCLXFont; + pVCLXFont->Init( *xDev.get(), aFont ); + xFont = pVCLXFont; + } + } + + return xFont; +} + +::rtl::OUString SAL_CALL VCLXAccessibleComponent::getTitledBorderText( ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + ::rtl::OUString sRet; + if ( GetWindow() ) + sRet = GetWindow()->GetText(); + + return sRet; +} + +::rtl::OUString SAL_CALL VCLXAccessibleComponent::getToolTipText( ) throw (uno::RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + ::rtl::OUString sRet; + if ( GetWindow() ) + sRet = GetWindow()->GetQuickHelpText(); + + return sRet; +} + diff --git a/toolkit/source/awt/vclxbitmap.cxx b/toolkit/source/awt/vclxbitmap.cxx new file mode 100644 index 000000000000..44d909674ca4 --- /dev/null +++ b/toolkit/source/awt/vclxbitmap.cxx @@ -0,0 +1,93 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + + +#include <toolkit/awt/vclxbitmap.hxx> +#include <toolkit/helper/macros.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <tools/stream.hxx> +#include <rtl/memory.h> +#include <rtl/uuid.h> + +// ---------------------------------------------------- +// class VCLXBitmap +// ---------------------------------------------------- + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXBitmap::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XBitmap*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XDisplayBitmap*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) ); + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); +} + +// ::com::sun::star::lang::XUnoTunnel +IMPL_XUNOTUNNEL( VCLXBitmap ) + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXBitmap ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayBitmap>* ) NULL ) +IMPL_XTYPEPROVIDER_END + + +// ::com::sun::star::awt::XBitmap +::com::sun::star::awt::Size VCLXBitmap::getSize() throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::awt::Size aSize( maBitmap.GetSizePixel().Width(), maBitmap.GetSizePixel().Height() ); + return aSize; +} + +::com::sun::star::uno::Sequence< sal_Int8 > VCLXBitmap::getDIB() throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + SvMemoryStream aMem; + aMem << maBitmap.GetBitmap(); + return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() ); +} + +::com::sun::star::uno::Sequence< sal_Int8 > VCLXBitmap::getMaskDIB() throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + SvMemoryStream aMem; + aMem << maBitmap.GetMask(); + return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() ); +} + + + + diff --git a/toolkit/source/awt/vclxbutton.cxx b/toolkit/source/awt/vclxbutton.cxx new file mode 100644 index 000000000000..3701eee409c3 --- /dev/null +++ b/toolkit/source/awt/vclxbutton.cxx @@ -0,0 +1,126 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#include "vclxbutton.hxx" + +#include <layout/core/helper.hxx> +#include <com/sun/star/awt/ImagePosition.hpp> +#include <vcl/button.hxx> + +namespace css = com::sun::star; + +namespace layoutimpl +{ + +VCLXIconButton::VCLXIconButton( Window *p, rtl::OUString aDefaultLabel, char const *pGraphName ) + : VCLXButton() +{ + /* FIXME: before Window is set, setLabel, setProperty->setImage + * are silent no-ops. */ + p->SetComponentInterface( this ); + + setLabel( aDefaultLabel ); + setProperty( rtl::OUString::createFromAscii( "Graphic" ), + css::uno::Any( layoutimpl::loadGraphic( pGraphName ) ) ); + setProperty( rtl::OUString::createFromAscii( "ImagePosition" ), + css::uno::Any( css::awt::ImagePosition::LeftCenter ) ); + setProperty( rtl::OUString::createFromAscii( "Align" ), + css::uno::Any( (sal_Int16) 1 /* magic - center */ ) ); +} + +// FIXME: l10n/i18n of Reset & Apply + +VCLXOKButton::VCLXOKButton( Window *p ) + : VCLXIconButton( p, Button::GetStandardText( BUTTON_OK ), + "res/commandimagelist/sc_ok.png" ) +{ +} + +VCLXCancelButton::VCLXCancelButton( Window *p ) + : VCLXIconButton( p, Button::GetStandardText( BUTTON_CANCEL ), +// : VCLXIconButton( xButton, rtl::OUString::createFromAscii( "~Cancel " ), + "res/commandimagelist/sc_cancel.png" ) +{ +} + +VCLXYesButton::VCLXYesButton( Window *p ) + : VCLXIconButton( p, Button::GetStandardText( BUTTON_YES ), + "res/commandimagelist/sc_yes.png" ) +{ +} + +VCLXNoButton::VCLXNoButton( Window *p ) + : VCLXIconButton( p, Button::GetStandardText( BUTTON_NO ), + "res/commandimagelist/sc_no.png" ) +{ +} + +VCLXRetryButton::VCLXRetryButton( Window *p ) + : VCLXIconButton( p, Button::GetStandardText( BUTTON_RETRY ), + "res/commandimagelist/sc_retry.png" ) +{ +} + +VCLXIgnoreButton::VCLXIgnoreButton( Window *p ) + : VCLXIconButton( p, Button::GetStandardText( BUTTON_IGNORE ), + "res/commandimagelist/sc_ignore.png" ) +{ +} + +VCLXResetButton::VCLXResetButton( Window *p ) + : VCLXIconButton( p, rtl::OUString::createFromAscii( "~Reset " ), + "res/commandimagelist/sc_reset.png" ) +{ +} + +VCLXApplyButton::VCLXApplyButton( Window *p ) + : VCLXIconButton( p, rtl::OUString::createFromAscii( "Apply" ), + "res/commandimagelist/sc_apply.png" ) +{ +} + +VCLXHelpButton::VCLXHelpButton( Window *p ) + : VCLXIconButton( p, Button::GetStandardText( BUTTON_HELP ), + "res/commandimagelist/sc_help.png" ) +{ +} + +VCLXMoreButton::VCLXMoreButton( Window *p ) + : VCLXIconButton( p, Button::GetStandardText( BUTTON_MORE ), +// : VCLXIconButton( p, rtl::OUString::createFromAscii( "More " ), + "res/commandimagelist/sc_more.png" ) +{ +} + +VCLXAdvancedButton::VCLXAdvancedButton( Window *p ) +// : VCLXIconButton( p, Button::GetStandardText( BUTTON_ADVANCED ), + : VCLXIconButton( p, rtl::OUString::createFromAscii( "Advanced " ), + "res/commandimagelist/sc_advanced.png" ) +{ +} + +} // namespace layoutimpl diff --git a/toolkit/source/awt/vclxbutton.hxx b/toolkit/source/awt/vclxbutton.hxx new file mode 100644 index 000000000000..5ec29321cb4f --- /dev/null +++ b/toolkit/source/awt/vclxbutton.hxx @@ -0,0 +1,114 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifndef LAYOUT_AWT_VCLXBUTTON_HXX +#define LAYOUT_AWT_VCLXBUTTON_HXX + +#include <toolkit/awt/vclxwindows.hxx> + +/* Replacements for broken toolkit/ impls. of ok, cancel, help button, etc. */ + +namespace layoutimpl +{ + +class VCLXIconButton : public VCLXButton +{ +public: + VCLXIconButton( Window* p, rtl::OUString aDefaultLabel, const char *pGraphName ); + void Show (); +}; + +class VCLXOKButton : public VCLXIconButton +{ +public: + VCLXOKButton( Window *p ); +}; + +class VCLXCancelButton : public VCLXIconButton +{ +public: + VCLXCancelButton( Window *p ); +}; + +class VCLXYesButton : public VCLXIconButton +{ +public: + VCLXYesButton( Window *p ); +}; + +class VCLXNoButton : public VCLXIconButton +{ +public: + VCLXNoButton( Window *p ); +}; + +class VCLXRetryButton : public VCLXIconButton +{ +public: + VCLXRetryButton( Window *p ); +}; + +class VCLXIgnoreButton : public VCLXIconButton +{ +public: + VCLXIgnoreButton( Window *p ); +}; + +class VCLXResetButton : public VCLXIconButton +{ +public: + VCLXResetButton( Window *p ); +}; + +class VCLXApplyButton : public VCLXIconButton +{ +public: + VCLXApplyButton( Window *p ); +}; + +class VCLXHelpButton : public VCLXIconButton +{ +public: + VCLXHelpButton( Window *p ); +}; + +// TODO. Reuse vcl/Morebutton, or make AdvancedButton reuse me? +class VCLXMoreButton : public VCLXIconButton +{ +public: + VCLXMoreButton( Window *p ); +}; + +class VCLXAdvancedButton : public VCLXIconButton +{ +public: + VCLXAdvancedButton( Window *p ); +}; + +} // namespace layoutimpl + +#endif // LAYOUT_AWT_VCLXBUTTON_HXX diff --git a/toolkit/source/awt/vclxcontainer.cxx b/toolkit/source/awt/vclxcontainer.cxx new file mode 100644 index 000000000000..d86b3bbb5591 --- /dev/null +++ b/toolkit/source/awt/vclxcontainer.cxx @@ -0,0 +1,239 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + + +#include <toolkit/awt/vclxcontainer.hxx> +#include <toolkit/helper/macros.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <rtl/memory.h> +#include <rtl/uuid.h> + +#include <vcl/window.hxx> +#include <tools/debug.hxx> + +// ---------------------------------------------------- +// class VCLXContainer +// ---------------------------------------------------- + +void VCLXContainer::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + VCLXWindow::ImplGetPropertyIds( rIds ); +} + +VCLXContainer::VCLXContainer() +{ +} + +VCLXContainer::~VCLXContainer() +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXContainer::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XVclContainer*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XVclContainerPeer*, this ) ); + return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXContainer ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainer>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerPeer>* ) NULL ), + VCLXWindow::getTypes() +IMPL_XTYPEPROVIDER_END + + +// ::com::sun::star::awt::XVclContainer +void VCLXContainer::addVclContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + GetContainerListeners().addInterface( rxListener ); +} + +void VCLXContainer::removeVclContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + GetContainerListeners().removeInterface( rxListener ); +} + +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > > VCLXContainer::getWindows( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + // Bei allen Childs das Container-Interface abfragen... + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > > aSeq; + Window* pWindow = GetWindow(); + if ( pWindow ) + { + sal_uInt16 nChilds = pWindow->GetChildCount(); + if ( nChilds ) + { + aSeq = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >( nChilds ); + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pChildRefs = aSeq.getArray(); + for ( sal_uInt16 n = 0; n < nChilds; n++ ) + { + Window* pChild = pWindow->GetChild( n ); + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xWP = pChild->GetComponentInterface( sal_True ); + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xW( xWP, ::com::sun::star::uno::UNO_QUERY ); + pChildRefs[n] = xW; + } + } + } + return aSeq; +} + + +// ::com::sun::star::awt::XVclContainerPeer +void VCLXContainer::enableDialogControl( sal_Bool bEnable ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + { + WinBits nStyle = pWindow->GetStyle(); + if ( bEnable ) + nStyle |= WB_DIALOGCONTROL; + else + nStyle &= (~WB_DIALOGCONTROL); + pWindow->SetStyle( nStyle ); + } +} + +void VCLXContainer::setTabOrder( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >& Components, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Tabs, sal_Bool bGroupControl ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_uInt32 nCount = Components.getLength(); + DBG_ASSERT( nCount == (sal_uInt32)Tabs.getLength(), "setTabOrder: TabCount != ComponentCount" ); + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pComps = Components.getConstArray(); + const ::com::sun::star::uno::Any* pTabs = Tabs.getConstArray(); + + Window* pPrevWin = NULL; + for ( sal_uInt32 n = 0; n < nCount; n++ ) + { + // ::com::sun::star::style::TabStop + Window* pWin = VCLUnoHelper::GetWindow( pComps[n] ); + // NULL kann vorkommen, wenn die ::com::sun::star::uno::Sequence vom TabController kommt und eine Peer fehlt! + if ( pWin ) + { + // Reihenfolge der Fenster vor der Manipulation des Styles, + // weil z.B. der RadioButton in StateChanged das PREV-Window beruecksichtigt. + if ( pPrevWin ) + pWin->SetZOrder( pPrevWin, WINDOW_ZORDER_BEHIND ); + + WinBits nStyle = pWin->GetStyle(); + nStyle &= ~(WB_TABSTOP|WB_NOTABSTOP|WB_GROUP); + if ( pTabs[n].getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN ) + { + sal_Bool bTab = false; + pTabs[n] >>= bTab; + nStyle |= ( bTab ? WB_TABSTOP : WB_NOTABSTOP ); + } + pWin->SetStyle( nStyle ); + + if ( bGroupControl ) + { + if ( n == 0 ) + pWin->SetDialogControlStart( sal_True ); + else + pWin->SetDialogControlStart( sal_False ); + } + + pPrevWin = pWin; + } + } +} + +void VCLXContainer::setGroup( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >& Components ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_uInt32 nCount = Components.getLength(); + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pComps = Components.getConstArray(); + + Window* pPrevWin = NULL; + Window* pPrevRadio = NULL; + for ( sal_uInt32 n = 0; n < nCount; n++ ) + { + Window* pWin = VCLUnoHelper::GetWindow( pComps[n] ); + if ( pWin ) + { + Window* pSortBehind = pPrevWin; + // #57096# Alle Radios hintereinander sortieren... + sal_Bool bNewPrevWin = sal_True; + if ( pWin->GetType() == WINDOW_RADIOBUTTON ) + { + if ( pPrevRadio ) + { + bNewPrevWin = ( pPrevWin == pPrevRadio ); // Radio-Button wurde vor das PreWin sortiert.... + pSortBehind = pPrevRadio; + } + pPrevRadio = pWin; + } + + // Z-Order + if ( pSortBehind ) + pWin->SetZOrder( pSortBehind, WINDOW_ZORDER_BEHIND ); + + WinBits nStyle = pWin->GetStyle(); + if ( n == 0 ) + nStyle |= WB_GROUP; + else + nStyle &= (~WB_GROUP); + pWin->SetStyle( nStyle ); + + // Ein WB_GROUP hinter die Gruppe, falls keine Gruppe mehr folgt. + if ( n == ( nCount - 1 ) ) + { + Window* pBehindLast = pWin->GetWindow( WINDOW_NEXT ); + if ( pBehindLast ) + { + WinBits nLastStyle = pBehindLast->GetStyle(); + nLastStyle |= WB_GROUP; + pBehindLast->SetStyle( nLastStyle ); + } + } + + if ( bNewPrevWin ) + pPrevWin = pWin; + } + } +} + + + + + diff --git a/toolkit/source/awt/vclxdevice.cxx b/toolkit/source/awt/vclxdevice.cxx new file mode 100644 index 000000000000..310f01a97679 --- /dev/null +++ b/toolkit/source/awt/vclxdevice.cxx @@ -0,0 +1,382 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" +#include <com/sun/star/awt/DeviceCapability.hpp> + +#include <com/sun/star/util/MeasureUnit.hpp> + +#include <toolkit/awt/vclxdevice.hxx> +#include <toolkit/awt/vclxfont.hxx> +#include <toolkit/awt/vclxbitmap.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <toolkit/helper/macros.hxx> +#include <cppuhelper/typeprovider.hxx> + +#include <rtl/memory.h> +#include <rtl/uuid.h> + +#include <vcl/svapp.hxx> +#include <vcl/outdev.hxx> +#include <vcl/window.hxx> +#include <vcl/print.hxx> +#include <vcl/virdev.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/font.hxx> + +// ---------------------------------------------------- +// class VCLXDevice +// ---------------------------------------------------- +VCLXDevice::VCLXDevice() : mrMutex( Application::GetSolarMutex() ) +{ + mpOutputDevice = NULL; + nFlags = 0; +} + +VCLXDevice::~VCLXDevice() +{ +// Was thought for #88347#, but didn't help, because the interface will not be released +// But would be a good idea anyway, check after 6.0, it's a little bit dangerous now +// if( mpOutputDevice && IsCreatedWithToolkit() ) +// { +// delete mpOutputDevice; +// } +} + +void VCLXDevice::DestroyOutputDevice() +{ + delete mpOutputDevice; + mpOutputDevice = NULL; +} + +void VCLXDevice::SetCreatedWithToolkit( sal_Bool bCreatedWithToolkit ) +{ + if ( bCreatedWithToolkit ) + nFlags |= FLAGS_CREATEDWITHTOOLKIT; + else + nFlags &= ~FLAGS_CREATEDWITHTOOLKIT; +} + +sal_Bool VCLXDevice::IsCreatedWithToolkit() const +{ + return ( nFlags & FLAGS_CREATEDWITHTOOLKIT ) != 0; +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXDevice::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XDevice*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XUnitConversion*, this ) ); + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); +} + +// ::com::sun::star::lang::XUnoTunnel +IMPL_XUNOTUNNEL( VCLXDevice ) + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXDevice ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnitConversion>* ) NULL ) +IMPL_XTYPEPROVIDER_END + + +// ::com::sun::star::awt::XDevice, +::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > VCLXDevice::createGraphics( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > xRef; + + if ( mpOutputDevice ) + xRef = mpOutputDevice->CreateUnoGraphics(); + + return xRef; +} + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXDevice::createDevice( sal_Int32 nWidth, sal_Int32 nHeight ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > xRef; + if ( GetOutputDevice() ) + { + VCLXVirtualDevice* pVDev = new VCLXVirtualDevice; + VirtualDevice* pVclVDev = new VirtualDevice( *GetOutputDevice() ); + pVclVDev->SetOutputSizePixel( Size( nWidth, nHeight ) ); + pVDev->SetVirtualDevice( pVclVDev ); + xRef = pVDev; + } + return xRef; +} + +::com::sun::star::awt::DeviceInfo VCLXDevice::getInfo() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::awt::DeviceInfo aInfo; + + if( mpOutputDevice ) + { + Size aDevSz; + OutDevType eDevType = mpOutputDevice->GetOutDevType(); + if ( eDevType == OUTDEV_WINDOW ) + { + aDevSz = ((Window*)mpOutputDevice)->GetSizePixel(); + ((Window*)mpOutputDevice)->GetBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset ); + } + else if ( eDevType == OUTDEV_PRINTER ) + { + aDevSz = ((Printer*)mpOutputDevice)->GetPaperSizePixel(); + Size aOutSz = mpOutputDevice->GetOutputSizePixel(); + Point aOffset = ((Printer*)mpOutputDevice)->GetPageOffset(); + aInfo.LeftInset = aOffset.X(); + aInfo.TopInset = aOffset.Y(); + aInfo.RightInset = aDevSz.Width() - aOutSz.Width() - aOffset.X(); + aInfo.BottomInset = aDevSz.Height() - aOutSz.Height() - aOffset.Y(); + } + else // VirtualDevice + { + aDevSz = mpOutputDevice->GetOutputSizePixel(); + aInfo.LeftInset = 0; + aInfo.TopInset = 0; + aInfo.RightInset = 0; + aInfo.BottomInset = 0; + } + + aInfo.Width = aDevSz.Width(); + aInfo.Height = aDevSz.Height(); + + Size aTmpSz = mpOutputDevice->LogicToPixel( Size( 1000, 1000 ), MapMode( MAP_CM ) ); + aInfo.PixelPerMeterX = aTmpSz.Width()/10; + aInfo.PixelPerMeterY = aTmpSz.Height()/10; + + aInfo.BitsPerPixel = mpOutputDevice->GetBitCount(); + + aInfo.Capabilities = 0; + if ( mpOutputDevice->GetOutDevType() != OUTDEV_PRINTER ) + aInfo.Capabilities = ::com::sun::star::awt::DeviceCapability::RASTEROPERATIONS|::com::sun::star::awt::DeviceCapability::GETBITS; + } + + return aInfo; +} + +::com::sun::star::uno::Sequence< ::com::sun::star::awt::FontDescriptor > VCLXDevice::getFontDescriptors( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Sequence< ::com::sun::star::awt::FontDescriptor> aFonts; + if( mpOutputDevice ) + { + int nFonts = mpOutputDevice->GetDevFontCount(); + if ( nFonts ) + { + aFonts = ::com::sun::star::uno::Sequence< ::com::sun::star::awt::FontDescriptor>( nFonts ); + ::com::sun::star::awt::FontDescriptor* pFonts = aFonts.getArray(); + for ( int n = 0; n < nFonts; n++ ) + pFonts[n] = VCLUnoHelper::CreateFontDescriptor( mpOutputDevice->GetDevFont( n ) ); + } + } + return aFonts; +} + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > VCLXDevice::getFont( const ::com::sun::star::awt::FontDescriptor& rDescriptor ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > xRef; + if( mpOutputDevice ) + { + VCLXFont* pMetric = new VCLXFont; + pMetric->Init( *this, VCLUnoHelper::CreateFont( rDescriptor, mpOutputDevice->GetFont() ) ); + xRef = pMetric; + } + return xRef; +} + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > VCLXDevice::createBitmap( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp; + if( mpOutputDevice ) + { + Bitmap aBmp = mpOutputDevice->GetBitmap( Point( nX, nY ), Size( nWidth, nHeight ) ); + + VCLXBitmap* pBmp = new VCLXBitmap; + pBmp->SetBitmap( BitmapEx( aBmp ) ); + xBmp = pBmp; + } + return xBmp; +} + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayBitmap > VCLXDevice::createDisplayBitmap( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >& rxBitmap ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + BitmapEx aBmp = VCLUnoHelper::GetBitmap( rxBitmap ); + VCLXBitmap* pBmp = new VCLXBitmap; + pBmp->SetBitmap( aBmp ); + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayBitmap > xDBmp = pBmp; + return xDBmp; +} + + +VCLXVirtualDevice::~VCLXVirtualDevice() +{ + ::vos::OGuard aGuard( GetMutex() ); + + DestroyOutputDevice(); +} + + +// ----------------------------------------------------------------------------- +// ::com::sun::star::awt::XTextConstraints +// ----------------------------------------------------------------------------- +// ::sal_Int32 SAL_CALL VCLXDevice::getTextWidth( const ::rtl::OUString& Text ) throw (::com::sun::star::uno::RuntimeException) +// { +// ::vos::OGuard aGuard( GetMutex() ); +// if (Text.getLength() == 0) +// { +// return 0; +// } +// +// return 1; +// } +// +// ::sal_Int32 SAL_CALL VCLXDevice::getTextHeight( ) throw (::com::sun::star::uno::RuntimeException) +// { +// ::vos::OGuard aGuard( GetMutex() ); +// return 1; +// } + + +// ----------------------------------------------------------------------------- +// Interface implementation of ::com::sun::star::awt::XUnitConversion +// ----------------------------------------------------------------------------- + +::com::sun::star::awt::Point SAL_CALL VCLXDevice::convertPointToLogic( const ::com::sun::star::awt::Point& aPoint, ::sal_Int16 TargetUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + (void)aPoint; + ::vos::OGuard aGuard( GetMutex() ); + if (TargetUnit == com::sun::star::util::MeasureUnit::PERCENT ) + { + // percentage not allowed here + throw ::com::sun::star::lang::IllegalArgumentException(); + } + + ::com::sun::star::awt::Point aAWTPoint(0,0); + // X,Y + + if( mpOutputDevice ) + { + MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(TargetUnit)); + ::Point aVCLPoint = VCLUnoHelper::ConvertToVCLPoint(aPoint); + ::Point aDevPoint = mpOutputDevice->PixelToLogic(aVCLPoint, aMode ); + aAWTPoint = VCLUnoHelper::ConvertToAWTPoint(aDevPoint); + } + + return aAWTPoint; +} + + +::com::sun::star::awt::Point SAL_CALL VCLXDevice::convertPointToPixel( const ::com::sun::star::awt::Point& aPoint, ::sal_Int16 SourceUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + (void)aPoint; + ::vos::OGuard aGuard( GetMutex() ); + if (SourceUnit == com::sun::star::util::MeasureUnit::PERCENT || + SourceUnit == com::sun::star::util::MeasureUnit::PIXEL ) + { + // pixel or percentage not allowed here + throw ::com::sun::star::lang::IllegalArgumentException(); + } + + ::com::sun::star::awt::Point aAWTPoint(0,0); + + if( mpOutputDevice ) + { + MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(SourceUnit)); + ::Point aVCLPoint = VCLUnoHelper::ConvertToVCLPoint(aPoint); + ::Point aDevPoint = mpOutputDevice->LogicToPixel(aVCLPoint, aMode ); + aAWTPoint = VCLUnoHelper::ConvertToAWTPoint(aDevPoint); + } + + return aAWTPoint; +} + +::com::sun::star::awt::Size SAL_CALL VCLXDevice::convertSizeToLogic( const ::com::sun::star::awt::Size& aSize, ::sal_Int16 TargetUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + (void)aSize; + ::vos::OGuard aGuard( GetMutex() ); + if (TargetUnit == com::sun::star::util::MeasureUnit::PERCENT) + { + // percentage not allowed here + throw ::com::sun::star::lang::IllegalArgumentException(); + } + + ::com::sun::star::awt::Size aAWTSize(0,0); + // Width, Height + + + if( mpOutputDevice ) + { + MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(TargetUnit)); + ::Size aVCLSize = VCLUnoHelper::ConvertToVCLSize(aSize); + ::Size aDevSz = mpOutputDevice->PixelToLogic(aVCLSize, aMode ); + aAWTSize = VCLUnoHelper::ConvertToAWTSize(aDevSz); + } + + return aAWTSize; +} + +::com::sun::star::awt::Size SAL_CALL VCLXDevice::convertSizeToPixel( const ::com::sun::star::awt::Size& aSize, ::sal_Int16 SourceUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + (void)aSize; + ::vos::OGuard aGuard( GetMutex() ); + if (SourceUnit == com::sun::star::util::MeasureUnit::PERCENT || + SourceUnit == com::sun::star::util::MeasureUnit::PIXEL) + { + // pixel or percentage not allowed here + throw ::com::sun::star::lang::IllegalArgumentException(); + } + + ::com::sun::star::awt::Size aAWTSize(0,0); + // Width, Height + if( mpOutputDevice ) + { + MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(SourceUnit)); + ::Size aVCLSize = VCLUnoHelper::ConvertToVCLSize(aSize); + ::Size aDevSz = mpOutputDevice->LogicToPixel(aVCLSize, aMode ); + aAWTSize = VCLUnoHelper::ConvertToAWTSize(aDevSz); + } + + return aAWTSize; +} + diff --git a/toolkit/source/awt/vclxdialog.cxx b/toolkit/source/awt/vclxdialog.cxx new file mode 100644 index 000000000000..43861c3ed347 --- /dev/null +++ b/toolkit/source/awt/vclxdialog.cxx @@ -0,0 +1,279 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#include "vclxdialog.hxx" + +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/awt/SystemDependentXWindow.hpp> +#include <com/sun/star/lang/SystemDependent.hpp> + +#include <cppuhelper/typeprovider.hxx> + +#include <toolkit/awt/vclxmenu.hxx> +#include <toolkit/helper/macros.hxx> +#include <toolkit/helper/property.hxx> + +#ifdef WNT +#include <tools/prewin.h> +#include <windows.h> +#include <tools/postwin.h> +#elif defined ( QUARTZ ) +#include "premac.h" +#include <Cocoa/Cocoa.h> +#include "postmac.h" +#endif + +#include <vcl/dialog.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <vcl/sysdata.hxx> +#include <vcl/wrkwin.hxx> + +#include "forward.hxx" + +namespace layoutimpl +{ + +DBG_NAME( VCLXDialog ) + +VCLXDialog::VCLXDialog() + : VCLXWindow() + , VCLXTopWindow_Base( true ) + , VCLXDialog_Base() + , Bin() + , bRealized( false ) + , bResizeSafeguard( false ) +{ + DBG_CTOR( VCLXDialog, NULL ); + +/* mxLayoutUnit = uno::Reference< awt::XLayoutUnit >( new LayoutUnit() ); + assert(mxLayoutUnit.is());*/ +} + +VCLXDialog::~VCLXDialog() +{ + DBG_DTOR( VCLXDialog, NULL ); +} + +vos::IMutex& VCLXDialog::GetMutexImpl() +{ + return VCLXWindow::GetMutex(); +} + +Window* VCLXDialog::GetWindowImpl() +{ + return VCLXWindow::GetWindow(); +} + +::cppu::OInterfaceContainerHelper& VCLXDialog::GetTopWindowListenersImpl() +{ + return GetTopWindowListeners(); +} + +IMPLEMENT_2_FORWARD_XINTERFACE2( VCLXDialog, VCLXWindow, Bin, VCLXDialog_Base ); + +IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXDialog, VCLXWindow, VCLXDialog_Base ); + +void SAL_CALL VCLXDialog::dispose() throw(::com::sun::star::uno::RuntimeException) +{ + { + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::lang::EventObject aDisposeEvent; + aDisposeEvent.Source = W3K_EXPLICIT_CAST (*this); +// maTabListeners.disposeAndClear( aDisposeEvent ); + } + + VCLXWindow::dispose(); +} + +void VCLXDialog::resizedCb() +{ + queueResize(); +} + +void SAL_CALL VCLXDialog::allocateArea( const css::awt::Rectangle &rArea ) + throw (css::uno::RuntimeException) +{ + ::com::sun::star::awt::Size reqSize = Bin::getMinimumSize(); + reqSize.Height = getHeightForWidth( rArea.Width ); + + if ( !bRealized ) + { + setPosSize( 0, 0, reqSize.Width, reqSize.Height, ::com::sun::star::awt::PosSize::SIZE ); + bRealized = true; + setVisible( true ); + } + else + { + ::com::sun::star::awt::Size curSize = getSize(); + if ( reqSize.Width > curSize.Width ) + setPosSize( 0, 0, reqSize.Width, 0, ::com::sun::star::awt::PosSize::WIDTH ); + if ( reqSize.Height > curSize.Height ) + setPosSize( 0, 0, 0, reqSize.Height, ::com::sun::star::awt::PosSize::HEIGHT ); + } + + ::com::sun::star::awt::Size size = getSize(); + maAllocation.Width = size.Width; + maAllocation.Height = size.Height; + + Bin::allocateArea( maAllocation ); +} + +void VCLXDialog::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) +{ + ::vos::OClearableGuard aGuard( GetMutex() ); + + switch ( _rVclWindowEvent.GetId() ) + { + case VCLEVENT_WINDOW_RESIZE: + resizedCb(); + default: + aGuard.clear(); + VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); + break; + } +} + +void SAL_CALL VCLXDialog::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any &Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { +/* sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) + { + default: +*/ + VCLXWindow::setProperty( PropertyName, Value ); +/* } +*/ + } +} + +::com::sun::star::uno::Any SAL_CALL VCLXDialog::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aReturn; + if ( GetWindow() ) + { +/* + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) + { + default: +*/ + aReturn = VCLXWindow::getProperty( PropertyName ); +/* + } +*/ + } + return aReturn; +} + +void VCLXDialog::setTitle( const ::rtl::OUString& Title ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + pWindow->SetText( Title ); +} + +void VCLXDialog::setHelpId( sal_Int32 id ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + pWindow->SetHelpId( id ); +} + +::rtl::OUString VCLXDialog::getTitle() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::rtl::OUString aTitle; + Window* pWindow = GetWindow(); + if ( pWindow ) + aTitle = pWindow->GetText(); + return aTitle; +} + +sal_Int16 VCLXDialog::execute() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int16 nRet = 0; + if ( GetWindow() ) + { + Dialog* pDlg = (Dialog*) GetWindow(); + Window* pParent = pDlg->GetWindow( WINDOW_PARENTOVERLAP ); + Window* pOldParent = NULL; + if ( pParent && !pParent->IsReallyVisible() ) + { + pOldParent = pDlg->GetParent(); + Window* pFrame = pDlg->GetWindow( WINDOW_FRAME ); + if ( pFrame != pDlg ) + pDlg->SetParent( pFrame ); + } + nRet = pDlg->Execute(); + if ( pOldParent ) + pDlg->SetParent( pOldParent ); + } + return nRet; +} + +void VCLXDialog::endDialog( sal_Int32 nResult ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( nResult == BUTTONID_HELP ) + { + // UGH: c&p button.cxx + ::Window* pFocusWin = Application::GetFocusWindow(); + if ( !pFocusWin ) + pFocusWin = GetWindow(); + + HelpEvent aEvt( pFocusWin->GetPointerPosPixel(), HELPMODE_CONTEXT ); + pFocusWin->RequestHelp( aEvt ); + return; + } + + Dialog* pDlg = (Dialog*) GetWindow(); + if ( pDlg ) + pDlg->EndDialog( nResult ); +} + +void VCLXDialog::endExecute() throw(::com::sun::star::uno::RuntimeException) +{ + endDialog( 0 ); +} + +} // namespace layoutimpl diff --git a/toolkit/source/awt/vclxdialog.hxx b/toolkit/source/awt/vclxdialog.hxx new file mode 100644 index 000000000000..64b2c03f90d5 --- /dev/null +++ b/toolkit/source/awt/vclxdialog.hxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifndef LAYOUT_AWT_VCLXDIALOG_HXX +#define LAYOUT_AWT_VCLXDIALOG_HXX + +#include <com/sun/star/awt/XDialog2.hpp> +#include <com/sun/star/awt/XSystemDependentWindowPeer.hpp> +#include <com/sun/star/awt/XTopWindow.hpp> +#include <comphelper/uno3.hxx> +#include <layout/core/bin.hxx> +#include <toolkit/awt/vclxtopwindow.hxx> + +namespace layoutimpl +{ + +typedef ::cppu::ImplHelper1 < ::com::sun::star::awt::XDialog2 > VCLXDialog_Base; + +class TOOLKIT_DLLPUBLIC VCLXDialog : public VCLXWindow + , public VCLXTopWindow_Base + , public VCLXDialog_Base + , public Bin +{ +private: + bool bRealized, bResizeSafeguard; + css::uno::Reference< css::awt::XLayoutUnit > mxLayoutUnit; + + VCLXDialog( const VCLXDialog& ); // never implemented + VCLXDialog& operator=( const VCLXDialog& ); // never implemented + +protected: + vos::IMutex& GetMutexImpl(); + Window* GetWindowImpl(); + ::cppu::OInterfaceContainerHelper& GetTopWindowListenersImpl(); + + ~VCLXDialog(); + + // XInterface + DECLARE_XINTERFACE() + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XComponent + void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + + // VclWindowPeer + virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); + + // VCLXWindow + void ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ); + + // ::com::sun::star::awt::XDialog + void SAL_CALL setTitle( const ::rtl::OUString& Title ) throw(::com::sun::star::uno::RuntimeException); + ::rtl::OUString SAL_CALL getTitle() throw(::com::sun::star::uno::RuntimeException); + sal_Int16 SAL_CALL execute() throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL endExecute() throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::awt::XLayoutContainer + virtual void SAL_CALL allocateArea( const css::awt::Rectangle &rArea ) + throw (css::uno::RuntimeException); + + void resizedCb(); + + static void ImplGetPropertyIds( std::list< sal_uInt16 > &/*aIds*/ ) + { + } + virtual void GetPropertyIds( std::list< sal_uInt16 > &aIds ) { return ImplGetPropertyIds( aIds ); } + + +public: + VCLXDialog(); + + // ::com::sun::star::awt::XDialog2 + void SAL_CALL endDialog( sal_Int32 nResult ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL setHelpId( sal_Int32 id ) throw(::com::sun::star::uno::RuntimeException); + +}; + +} // namespace layoutimpl + +#endif /* LAYOUT_AWT_VCLXDIALOG_HXX */ diff --git a/toolkit/source/awt/vclxfixedline.cxx b/toolkit/source/awt/vclxfixedline.cxx new file mode 100644 index 000000000000..8c77a4f35e19 --- /dev/null +++ b/toolkit/source/awt/vclxfixedline.cxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#include "vclxfixedline.hxx" + +#include <com/sun/star/awt/PosSize.hpp> +#include <toolkit/helper/property.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <tools/debug.hxx> +#include <vcl/fixed.hxx> + +#include "forward.hxx" + +namespace layoutimpl +{ + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star; + +DBG_NAME( VCLXFixedLine ) + +VCLXFixedLine::VCLXFixedLine() + : VCLXWindow() +{ + DBG_CTOR( VCLXFixedLine, NULL ); +} + +VCLXFixedLine::~VCLXFixedLine() +{ + DBG_DTOR( VCLXFixedLine, NULL ); +} + +IMPLEMENT_FORWARD_XTYPEPROVIDER1( VCLXFixedLine, VCLXWindow ); + +void SAL_CALL VCLXFixedLine::dispose() throw(RuntimeException) +{ + { + ::vos::OGuard aGuard( GetMutex() ); + + EventObject aDisposeEvent; + aDisposeEvent.Source = W3K_EXPLICIT_CAST (*this); + } + + VCLXWindow::dispose(); +} + +::com::sun::star::awt::Size SAL_CALL VCLXFixedLine::getMinimumSize() + throw(::com::sun::star::uno::RuntimeException) +{ + return awt::Size( 8, 8 ); +} + +void VCLXFixedLine::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) +{ + ::vos::OClearableGuard aGuard( GetMutex() ); +/* + switch ( _rVclWindowEvent.GetId() ) + { + default: + aGuard.clear(); +*/ + VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); +/* + break; + } +*/ +} + +void SAL_CALL VCLXFixedLine::setProperty( const ::rtl::OUString& PropertyName, const Any &Value ) throw(RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { +/* + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) + { + default: +*/ + VCLXWindow::setProperty( PropertyName, Value ); +// } + } +} + +Any SAL_CALL VCLXFixedLine::getProperty( const ::rtl::OUString& PropertyName ) throw(RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Any aReturn; + if ( GetWindow() ) + { +/* + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) + { + default: +*/ + aReturn = VCLXWindow::getProperty( PropertyName ); + // } + } + return aReturn; +} + +} // namespace layoutimpl diff --git a/toolkit/source/awt/vclxfixedline.hxx b/toolkit/source/awt/vclxfixedline.hxx new file mode 100644 index 000000000000..d7dfd76d961f --- /dev/null +++ b/toolkit/source/awt/vclxfixedline.hxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifndef LAYOUT_AWT_VCLXFIXEDLINE_HXX +#define LAYOUT_AWT_VCLXFIXEDLINE_HXX + +#include <comphelper/uno3.hxx> +#include <toolkit/awt/vclxwindow.hxx> + +/* We just provide our own FixedLine, because default has no width... */ + +class FixedLine; + +namespace layoutimpl +{ + +class VCLXFixedLine :public VCLXWindow +{ +public: + VCLXFixedLine(); + +protected: + ~VCLXFixedLine(); + + // XInterface + // DECLARE_XINTERFACE() + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XComponent + void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::awt::Size SAL_CALL getMinimumSize() + throw(::com::sun::star::uno::RuntimeException); + + // VclWindowPeer + virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); + + // VCLXWindow + void ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ); + +private: + VCLXFixedLine( const VCLXFixedLine& ); // never implemented + VCLXFixedLine& operator=( const VCLXFixedLine& ); // never implemented +}; + +} // namespace layoutimpl + +#endif /* LAYOUT_AWT_VCLXFIXEDLINE_HXX */ diff --git a/toolkit/source/awt/vclxfont.cxx b/toolkit/source/awt/vclxfont.cxx new file mode 100644 index 000000000000..53175ec79d24 --- /dev/null +++ b/toolkit/source/awt/vclxfont.cxx @@ -0,0 +1,252 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + + +#include <toolkit/awt/vclxfont.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <toolkit/helper/macros.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <rtl/memory.h> +#include <rtl/uuid.h> +#include <rtl/ustring.h> + +#include <vcl/outdev.hxx> + +// ---------------------------------------------------- +// class VCLXFont +// ---------------------------------------------------- +VCLXFont::VCLXFont() +{ + mpFontMetric = NULL; +} + +VCLXFont::~VCLXFont() +{ + delete mpFontMetric; +} + +void VCLXFont::Init( ::com::sun::star::awt::XDevice& rxDev, const Font& rFont ) +{ + mxDevice = &rxDev; + + delete mpFontMetric; + mpFontMetric = NULL; + + maFont = rFont; +} + +BOOL VCLXFont::ImplAssertValidFontMetric() +{ + if ( !mpFontMetric && mxDevice.is() ) + { + OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( mxDevice ); + if ( pOutDev ) + { + Font aOldFont = pOutDev->GetFont(); + pOutDev->SetFont( maFont ); + mpFontMetric = new FontMetric( pOutDev->GetFontMetric() ); + pOutDev->SetFont( aOldFont ); + } + } + return mpFontMetric ? TRUE : FALSE; +} + + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXFont::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XFont*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XFont2*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) ); + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); +} + +// ::com::sun::star::lang::XUnoTunnel +IMPL_XUNOTUNNEL( VCLXFont ) + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXFont ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont2>* ) NULL ) +IMPL_XTYPEPROVIDER_END + + +::com::sun::star::awt::FontDescriptor VCLXFont::getFontDescriptor( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + return VCLUnoHelper::CreateFontDescriptor( maFont ); + +} + +::com::sun::star::awt::SimpleFontMetric VCLXFont::getFontMetric( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::awt::SimpleFontMetric aFM; + if ( ImplAssertValidFontMetric() ) + aFM = VCLUnoHelper::CreateFontMetric( *mpFontMetric ); + return aFM; +} + +sal_Int16 VCLXFont::getCharWidth( sal_Unicode c ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + sal_Int16 nRet = -1; + OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( mxDevice ); + if ( pOutDev ) + { + Font aOldFont = pOutDev->GetFont(); + pOutDev->SetFont( maFont ); + + nRet = sal::static_int_cast< sal_Int16 >( + pOutDev->GetTextWidth( String(c) )); + + pOutDev->SetFont( aOldFont ); + } + return nRet; +} + +::com::sun::star::uno::Sequence< sal_Int16 > VCLXFont::getCharWidths( sal_Unicode nFirst, sal_Unicode nLast ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::uno::Sequence<sal_Int16> aSeq; + OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( mxDevice ); + if ( pOutDev ) + { + Font aOldFont = pOutDev->GetFont(); + pOutDev->SetFont( maFont ); + + sal_Int16 nCount = nLast-nFirst + 1; + aSeq = ::com::sun::star::uno::Sequence<sal_Int16>( nCount ); + for ( USHORT n = 0; n < nCount; n++ ) + { + aSeq.getArray()[n] = sal::static_int_cast< sal_Int16 >( + pOutDev->GetTextWidth( + String(static_cast< sal_Unicode >(nFirst+n)) )); + } + + pOutDev->SetFont( aOldFont ); + } + return aSeq; +} + +sal_Int32 VCLXFont::getStringWidth( const ::rtl::OUString& str ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + sal_Int32 nRet = -1; + OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( mxDevice ); + if ( pOutDev ) + { + Font aOldFont = pOutDev->GetFont(); + pOutDev->SetFont( maFont ); + nRet = pOutDev->GetTextWidth( str ); + pOutDev->SetFont( aOldFont ); + } + return nRet; +} + +sal_Int32 VCLXFont::getStringWidthArray( const ::rtl::OUString& str, ::com::sun::star::uno::Sequence< sal_Int32 >& rDXArray ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + sal_Int32 nRet = -1; + OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( mxDevice ); + if ( pOutDev ) + { + Font aOldFont = pOutDev->GetFont(); + pOutDev->SetFont( maFont ); + rDXArray = ::com::sun::star::uno::Sequence<sal_Int32>( str.getLength() ); + nRet = pOutDev->GetTextArray( str, rDXArray.getArray() ); + pOutDev->SetFont( aOldFont ); + } + return nRet; +} + +void VCLXFont::getKernPairs( ::com::sun::star::uno::Sequence< sal_Unicode >& rnChars1, ::com::sun::star::uno::Sequence< sal_Unicode >& rnChars2, ::com::sun::star::uno::Sequence< sal_Int16 >& rnKerns ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( mxDevice ); + if( pOutDev ) + { + Font aOldFont = pOutDev->GetFont(); + pOutDev->SetFont( maFont ); + + ULONG nPairs = pOutDev->GetKerningPairCount(); + if ( nPairs ) + { + KerningPair* pData = new KerningPair[ nPairs ]; + pOutDev->GetKerningPairs( nPairs, pData ); + + rnChars1 = ::com::sun::star::uno::Sequence<sal_Unicode>( nPairs ); + rnChars2 = ::com::sun::star::uno::Sequence<sal_Unicode>( nPairs ); + rnKerns = ::com::sun::star::uno::Sequence<sal_Int16>( nPairs ); + + sal_Unicode* pChars1 = rnChars1.getArray(); + sal_Unicode* pChars2 = rnChars2.getArray(); + sal_Int16* pKerns = rnKerns.getArray(); + + for ( ULONG n = 0; n < nPairs; n++ ) + { + pChars1[n] = pData[n].nChar1; + pChars2[n] = pData[n].nChar2; + pKerns[n] = sal::static_int_cast< sal_Int16 >(pData[n].nKern); + } + + + delete[] pData; + } + pOutDev->SetFont( aOldFont ); + } +} + +// ::com::sun::star::awt::XFont2 +sal_Bool VCLXFont::hasGlyphs( const ::rtl::OUString& aText ) + throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( mxDevice ); + if ( pOutDev ) + { + String aStr( aText ); + if ( pOutDev->HasGlyphs( maFont, aStr, 0, aStr.Len() ) == STRING_LEN ) + { + return sal_True; + } + } + + return sal_False; +} diff --git a/toolkit/source/awt/vclxgraphics.cxx b/toolkit/source/awt/vclxgraphics.cxx new file mode 100644 index 000000000000..bfbdb531e8d2 --- /dev/null +++ b/toolkit/source/awt/vclxgraphics.cxx @@ -0,0 +1,478 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + +#include <toolkit/awt/vclxgraphics.hxx> +#include <toolkit/awt/vclxdevice.hxx> +#include <toolkit/helper/macros.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <rtl/memory.h> +#include <rtl/uuid.h> + +#include <vcl/svapp.hxx> +#include <vcl/outdev.hxx> +#include <vcl/gradient.hxx> +#include <tools/debug.hxx> + + +// ---------------------------------------------------- +// class VCLXGraphics +// ---------------------------------------------------- + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXGraphics::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XGraphics*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ) ); + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); +} + +// ::com::sun::star::lang::XUnoTunnel +IMPL_XUNOTUNNEL( VCLXGraphics ) + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXGraphics ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics>* ) NULL ) +IMPL_XTYPEPROVIDER_END + +VCLXGraphics::VCLXGraphics() : mrMutex( Application::GetSolarMutex() ) +{ + mpOutputDevice = NULL; + mpClipRegion = NULL; +} + +VCLXGraphics::~VCLXGraphics() +{ + List* pLst = mpOutputDevice ? mpOutputDevice->GetUnoGraphicsList() : NULL; + if ( pLst ) + pLst->Remove( this ); + + delete mpClipRegion; +} + +void VCLXGraphics::SetOutputDevice( OutputDevice* pOutDev ) +{ + mpOutputDevice = pOutDev; + mxDevice = NULL; +} + +void VCLXGraphics::Init( OutputDevice* pOutDev ) +{ + DBG_ASSERT( !mpOutputDevice, "VCLXGraphics::Init allready has pOutDev !" ); + mpOutputDevice = pOutDev; + + maFont = mpOutputDevice->GetFont(); + maTextColor = COL_BLACK; + maTextFillColor = COL_TRANSPARENT; + maLineColor = COL_BLACK; + maFillColor = COL_WHITE; + meRasterOp = ROP_OVERPAINT; + mpClipRegion = NULL; + + // Register at OutputDevice + List* pLst = mpOutputDevice->GetUnoGraphicsList(); + if ( !pLst ) + pLst = mpOutputDevice->CreateUnoGraphicsList(); + pLst->Insert( this, LIST_APPEND ); +} + +void VCLXGraphics::InitOutputDevice( sal_uInt16 nFlags ) +{ + if(mpOutputDevice) + { + NAMESPACE_VOS(OGuard) aVclGuard( Application::GetSolarMutex() ); + + if ( nFlags & INITOUTDEV_FONT ) + { + mpOutputDevice->SetFont( maFont ); + mpOutputDevice->SetTextColor( maTextColor ); + mpOutputDevice->SetTextFillColor( maTextFillColor ); + } + + if ( nFlags & INITOUTDEV_COLORS ) + { + mpOutputDevice->SetLineColor( maLineColor ); + mpOutputDevice->SetFillColor( maFillColor ); + } + + if ( nFlags & INITOUTDEV_RASTEROP ) + { + mpOutputDevice->SetRasterOp( meRasterOp ); + } + + if ( nFlags & INITOUTDEV_CLIPREGION ) + { + if( mpClipRegion ) + mpOutputDevice->SetClipRegion( *mpClipRegion ); + else + mpOutputDevice->SetClipRegion(); + } + } +} + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXGraphics::getDevice() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( !mxDevice.is() && mpOutputDevice ) + { + VCLXDevice* pDev = new VCLXDevice; + pDev->SetOutputDevice( mpOutputDevice ); + mxDevice = pDev; + } + return mxDevice; +} + +::com::sun::star::awt::SimpleFontMetric VCLXGraphics::getFontMetric() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::awt::SimpleFontMetric aM; + if( mpOutputDevice ) + { + mpOutputDevice->SetFont( maFont ); + aM = VCLUnoHelper::CreateFontMetric( mpOutputDevice->GetFontMetric() ); + } + return aM; +} + +void VCLXGraphics::setFont( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont >& rxFont ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + maFont = VCLUnoHelper::CreateFont( rxFont ); +} + +void VCLXGraphics::selectFont( const ::com::sun::star::awt::FontDescriptor& rDescription ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + maFont = VCLUnoHelper::CreateFont( rDescription, Font() ); +} + +void VCLXGraphics::setTextColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + maTextColor = Color( (sal_uInt32)nColor ); +} + +void VCLXGraphics::setTextFillColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + maTextFillColor = Color( (sal_uInt32)nColor ); +} + +void VCLXGraphics::setLineColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + maLineColor = Color( (sal_uInt32)nColor ); +} + +void VCLXGraphics::setFillColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + maFillColor = Color( (sal_uInt32)nColor ); +} + +void VCLXGraphics::setRasterOp( ::com::sun::star::awt::RasterOperation eROP ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + meRasterOp = (RasterOp)eROP; +} + +void VCLXGraphics::setClipRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + delete mpClipRegion; + if ( rxRegion.is() ) + mpClipRegion = new Region( VCLUnoHelper::GetRegion( rxRegion ) ); + else + mpClipRegion = NULL; +} + +void VCLXGraphics::intersectClipRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( rxRegion.is() ) + { + Region aRegion( VCLUnoHelper::GetRegion( rxRegion ) ); + if ( !mpClipRegion ) + mpClipRegion = new Region( aRegion ); + else + mpClipRegion->Intersect( aRegion ); + } +} + +void VCLXGraphics::push( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + + if( mpOutputDevice ) + mpOutputDevice->Push(); +} + +void VCLXGraphics::pop( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + + if( mpOutputDevice ) + mpOutputDevice->Pop(); +} + +void VCLXGraphics::copy( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice >& rxSource, sal_Int32 nSourceX, sal_Int32 nSourceY, sal_Int32 nSourceWidth, sal_Int32 nSourceHeight, sal_Int32 nDestX, sal_Int32 nDestY, sal_Int32 nDestWidth, sal_Int32 nDestHeight ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( mpOutputDevice ) + { + VCLXDevice* pFromDev = VCLXDevice::GetImplementation( rxSource ); + DBG_ASSERT( pFromDev, "VCLXGraphics::copy - invalid device" ); + if ( pFromDev ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP ); + mpOutputDevice->DrawOutDev( Point( nDestX, nDestY ), Size( nDestWidth, nDestHeight ), + Point( nSourceX, nSourceY ), Size( nSourceWidth, nSourceHeight ), *pFromDev->GetOutputDevice() ); + } + } +} + +void VCLXGraphics::draw( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayBitmap >& rxBitmapHandle, sal_Int32 nSourceX, sal_Int32 nSourceY, sal_Int32 nSourceWidth, sal_Int32 nSourceHeight, sal_Int32 nDestX, sal_Int32 nDestY, sal_Int32 nDestWidth, sal_Int32 nDestHeight ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP); + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBitmap( rxBitmapHandle, ::com::sun::star::uno::UNO_QUERY ); + BitmapEx aBmpEx = VCLUnoHelper::GetBitmap( xBitmap ); + + Point aPos(nDestX - nSourceX, nDestY - nSourceY); + Size aSz = aBmpEx.GetSizePixel(); + + if(nDestWidth != nSourceWidth) + { + float zoomX = (float)nDestWidth / (float)nSourceWidth; + aSz.Width() = (long) ((float)aSz.Width() * zoomX); + } + + if(nDestHeight != nSourceHeight) + { + float zoomY = (float)nDestHeight / (float)nSourceHeight; + aSz.Height() = (long) ((float)aSz.Height() * zoomY); + } + + if(nSourceX || nSourceY || aSz.Width() != nSourceWidth || aSz.Height() != nSourceHeight) + mpOutputDevice->IntersectClipRegion(Region(Rectangle(nDestX, nDestY, nDestX + nDestWidth - 1, nDestY + nDestHeight - 1))); + + mpOutputDevice->DrawBitmapEx( aPos, aSz, aBmpEx ); + } +} + +void VCLXGraphics::drawPixel( sal_Int32 x, sal_Int32 y ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS ); + mpOutputDevice->DrawPixel( Point( x, y ) ); + } +} + +void VCLXGraphics::drawLine( sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS ); + mpOutputDevice->DrawLine( Point( x1, y1 ), Point( x2, y2 ) ); + } +} + +void VCLXGraphics::drawRect( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS ); + mpOutputDevice->DrawRect( Rectangle( Point( x, y ), Size( width, height ) ) ); + } +} + +void VCLXGraphics::drawRoundedRect( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int32 nHorzRound, sal_Int32 nVertRound ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS ); + mpOutputDevice->DrawRect( Rectangle( Point( x, y ), Size( width, height ) ), nHorzRound, nVertRound ); + } +} + +void VCLXGraphics::drawPolyLine( const ::com::sun::star::uno::Sequence< sal_Int32 >& DataX, const ::com::sun::star::uno::Sequence< sal_Int32 >& DataY ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS ); + mpOutputDevice->DrawPolyLine( VCLUnoHelper::CreatePolygon( DataX, DataY ) ); + } +} + +void VCLXGraphics::drawPolygon( const ::com::sun::star::uno::Sequence< sal_Int32 >& DataX, const ::com::sun::star::uno::Sequence< sal_Int32 >& DataY ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS ); + mpOutputDevice->DrawPolygon( VCLUnoHelper::CreatePolygon( DataX, DataY ) ); + } +} + +void VCLXGraphics::drawPolyPolygon( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_Int32 > >& DataX, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_Int32 > >& DataY ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS ); + sal_uInt16 nPolys = (sal_uInt16) DataX.getLength(); + PolyPolygon aPolyPoly( nPolys ); + for ( sal_uInt16 n = 0; n < nPolys; n++ ) + aPolyPoly[n] = VCLUnoHelper::CreatePolygon( DataX.getConstArray()[n], DataY.getConstArray()[n] ); + + mpOutputDevice->DrawPolyPolygon( aPolyPoly ); + } +} + +void VCLXGraphics::drawEllipse( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS ); + mpOutputDevice->DrawEllipse( Rectangle( Point( x, y ), Size( width, height ) ) ); + } +} + +void VCLXGraphics::drawArc( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS ); + mpOutputDevice->DrawArc( Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) ); + } +} + +void VCLXGraphics::drawPie( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS ); + mpOutputDevice->DrawPie( Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) ); + } +} + +void VCLXGraphics::drawChord( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS ); + mpOutputDevice->DrawChord( Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) ); + } +} + +void VCLXGraphics::drawGradient( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, const ::com::sun::star::awt::Gradient& rGradient ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS ); + Gradient aGradient((GradientStyle)rGradient.Style, rGradient.StartColor, rGradient.EndColor); + aGradient.SetAngle(rGradient.Angle); + aGradient.SetBorder(rGradient.Border); + aGradient.SetOfsX(rGradient.XOffset); + aGradient.SetOfsY(rGradient.YOffset); + aGradient.SetStartIntensity(rGradient.StartIntensity); + aGradient.SetEndIntensity(rGradient.EndIntensity); + aGradient.SetSteps(rGradient.StepCount); + mpOutputDevice->DrawGradient( Rectangle( Point( x, y ), Size( width, height ) ), aGradient ); + } +} + +void VCLXGraphics::drawText( sal_Int32 x, sal_Int32 y, const ::rtl::OUString& rText ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS |INITOUTDEV_FONT); + mpOutputDevice->DrawText( Point( x, y ), rText ); + } +} + +void VCLXGraphics::drawTextArray( sal_Int32 x, sal_Int32 y, const ::rtl::OUString& rText, const ::com::sun::star::uno::Sequence< sal_Int32 >& rLongs ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if( mpOutputDevice ) + { + InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS|INITOUTDEV_FONT ); + mpOutputDevice->DrawTextArray( Point( x, y ), rText, rLongs.getConstArray() ); + } +} + + + + diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx new file mode 100644 index 000000000000..1992a8d721a6 --- /dev/null +++ b/toolkit/source/awt/vclxmenu.cxx @@ -0,0 +1,1059 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + + +#include <toolkit/awt/vclxmenu.hxx> +#include <toolkit/helper/macros.hxx> +#include <toolkit/helper/servicenames.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <toolkit/helper/convert.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <rtl/memory.h> +#include <rtl/uuid.h> + +#include <vcl/menu.hxx> +#include <vcl/keycod.hxx> +#include <vcl/image.hxx> +#include <vcl/mnemonic.hxx> + +#include <com/sun/star/awt/KeyModifier.hpp> + + +#ifdef DBG_UTIL + #define THROW_MENUITEM_NOT_FOUND( Func, nItemId ) \ + if ( MENU_ITEM_NOTFOUND == mpMenu->GetItemPos( nItemId ) ) \ + throw ::com::sun::star::container::NoSuchElementException( \ + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( Func ) ) \ + += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": There is no menu item with " ) ) \ + += ::rtl::OUString::valueOf( sal_Int32( nItemId ) ) \ + += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " as identifier" ) ), \ + *this \ + ); + #define THROW_MENUPOS_NOT_FOUND( Func, nPos ) \ + if ( MENU_ITEM_NOTFOUND == sal_uInt16( nPos ) ) \ + throw ::com::sun::star::container::NoSuchElementException( \ + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( Func ) ) \ + += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": There is no menu item at position " ) ) \ + += ::rtl::OUString::valueOf( sal_Int32( nPos ) ), \ + *this \ + ); +#else + #define THROW_MENUITEM_NOT_FOUND( Func, nItemId ) \ + if ( MENU_ITEM_NOTFOUND == mpMenu->GetItemPos( nItemId ) ) \ + throw ::com::sun::star::container::NoSuchElementException(); + #define THROW_MENUPOS_NOT_FOUND( Func, nPos ) \ + if ( MENU_ITEM_NOTFOUND == sal_uInt16( nPos ) ) \ + throw ::com::sun::star::container::NoSuchElementException(); +#endif + + +// ---------------------------------------------------- +// class VCLXMenu +// ---------------------------------------------------- + +DBG_NAME(VCLXMenu) + +VCLXMenu::VCLXMenu() : maMenuListeners( *this ) +{ + DBG_CTOR( VCLXMenu, 0 ); + mpMenu = NULL; +} + +VCLXMenu::VCLXMenu( Menu* pMenu ) : maMenuListeners( *this ) +{ + DBG_CTOR( VCLXMenu, 0 ); + mpMenu = pMenu; +} + +VCLXMenu::~VCLXMenu() +{ + DBG_DTOR( VCLXMenu, 0 ); + for ( sal_uInt32 n = maPopupMenueRefs.Count(); n; ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > * pRef = maPopupMenueRefs.GetObject( --n ); + delete pRef; + } + if ( mpMenu ) + { + mpMenu->RemoveEventListener( LINK( this, VCLXMenu, MenuEventListener ) ); + delete mpMenu; + } +} + +BOOL VCLXMenu::IsPopupMenu() const +{ + return (mpMenu && ! mpMenu->IsMenuBar()); +} + +void VCLXMenu::ImplCreateMenu( sal_Bool bPopup ) +{ + DBG_ASSERT( !mpMenu, "CreateMenu: Menu exists!" ); + + if ( bPopup ) + mpMenu = new PopupMenu; + else + mpMenu = new MenuBar; + + mpMenu->AddEventListener( LINK( this, VCLXMenu, MenuEventListener ) ); +} + +IMPL_LINK( VCLXMenu, MenuEventListener, VclSimpleEvent*, pEvent ) +{ + DBG_ASSERT( pEvent && pEvent->ISA( VclMenuEvent ), "Unknown Event!" ); + if ( pEvent && pEvent->ISA( VclMenuEvent ) ) + { + DBG_ASSERT( ((VclMenuEvent*)pEvent)->GetMenu() && mpMenu, "Menu???" ); + + VclMenuEvent* pMenuEvent = (VclMenuEvent*)pEvent; + if ( pMenuEvent->GetMenu() == mpMenu ) // Also called for the root menu + { + switch ( pMenuEvent->GetId() ) + { + case VCLEVENT_MENU_SELECT: + { + if ( maMenuListeners.getLength() ) + { + ::com::sun::star::awt::MenuEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.MenuId = mpMenu->GetCurItemId(); + maMenuListeners.select( aEvent ); + } + } + break; + case VCLEVENT_OBJECT_DYING: + { + mpMenu = NULL; + } + break; + case VCLEVENT_MENU_HIGHLIGHT: + { + if ( maMenuListeners.getLength() ) + { + ::com::sun::star::awt::MenuEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.MenuId = mpMenu->GetCurItemId(); + maMenuListeners.highlight( aEvent ); + } + } + break; + case VCLEVENT_MENU_ACTIVATE: + { + if ( maMenuListeners.getLength() ) + { + ::com::sun::star::awt::MenuEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.MenuId = mpMenu->GetCurItemId(); + maMenuListeners.activate( aEvent ); + } + } + break; + case VCLEVENT_MENU_DEACTIVATE: + { + if ( maMenuListeners.getLength() ) + { + ::com::sun::star::awt::MenuEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.MenuId = mpMenu->GetCurItemId(); + maMenuListeners.deactivate( aEvent ); + } + } + break; + + // ignore accessibility events + case VCLEVENT_MENU_ENABLE: + case VCLEVENT_MENU_INSERTITEM: + case VCLEVENT_MENU_REMOVEITEM: + case VCLEVENT_MENU_SUBMENUACTIVATE: + case VCLEVENT_MENU_SUBMENUDEACTIVATE: + case VCLEVENT_MENU_SUBMENUCHANGED: + case VCLEVENT_MENU_DEHIGHLIGHT: + case VCLEVENT_MENU_DISABLE: + case VCLEVENT_MENU_ITEMTEXTCHANGED: + case VCLEVENT_MENU_ITEMCHECKED: + case VCLEVENT_MENU_ITEMUNCHECKED: + case VCLEVENT_MENU_SHOW: + case VCLEVENT_MENU_HIDE: + break; + + default: DBG_ERROR( "MenuEventListener - Unknown event!" ); + } + } + } + return 0; +} + + +//============================================================================= +//============================================================================= +//============================================================================= + + +// ::com::sun::star::lang::XServiceInfo +::rtl::OUString SAL_CALL VCLXMenu::getImplementationName( ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); + const sal_Bool bIsPopupMenu = IsPopupMenu(); + aGuard.clear(); + + ::rtl::OUString implName( RTL_CONSTASCII_USTRINGPARAM( "stardiv.Toolkit." ) ); + if ( bIsPopupMenu ) + implName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VCLXPopupMenu" ) ); + else + implName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VCLXMenuBar" ) ); + + return implName; +} + + +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL VCLXMenu::getSupportedServiceNames( ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); + const sal_Bool bIsPopupMenu = IsPopupMenu(); + aGuard.clear(); + + ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames( 1 ); + if ( bIsPopupMenu ) + aNames[ 0 ] = ::rtl::OUString::createFromAscii( szServiceName2_PopupMenu ); + else + aNames[ 0 ] = ::rtl::OUString::createFromAscii( szServiceName2_MenuBar ); + + return aNames; +} + + +::sal_Bool SAL_CALL VCLXMenu::supportsService( const ::rtl::OUString& rServiceName ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() ); + + if ( aServiceNames[ 0 ] == rServiceName ) + return sal_True; + + return sal_False; +} + + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXMenu::queryInterface( const ::com::sun::star::uno::Type & rType ) +throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); + const sal_Bool bIsPopupMenu = IsPopupMenu(); + aGuard.clear(); + + ::com::sun::star::uno::Any aRet; + + if ( bIsPopupMenu ) + aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XMenu*, (::com::sun::star::awt::XMenuBar*) this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XPopupMenu*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XPopupMenuExtended*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XMenuExtended*, (::com::sun::star::awt::XPopupMenuExtended*) this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XMenuExtended2*, (::com::sun::star::awt::XPopupMenuExtended*) this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XServiceInfo*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ) ); + else + aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XMenu*, (::com::sun::star::awt::XMenuBar*) this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XMenuBar*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XMenuBarExtended*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XMenuExtended*, (::com::sun::star::awt::XMenuBarExtended*) this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XMenuExtended2*, (::com::sun::star::awt::XMenuBarExtended*) this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XServiceInfo*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ) ); + + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); +} + +// ::com::sun::star::lang::XUnoTunnel +IMPL_XUNOTUNNEL( VCLXMenu ) + +// ::com::sun::star::lang::XTypeProvider +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > VCLXMenu::getTypes() +throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); + const sal_Bool bIsPopupMenu = IsPopupMenu(); + aGuard.clear(); + + static ::cppu::OTypeCollection* pCollectionMenuBar = NULL; + static ::cppu::OTypeCollection* pCollectionPopupMenu = NULL; + + if ( bIsPopupMenu ) + { + if( !pCollectionPopupMenu ) + { + ::osl::Guard< ::osl::Mutex > aGlobalGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pCollectionPopupMenu ) + { + static ::cppu::OTypeCollection collectionPopupMenu( + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenu>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenuExtended>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuExtended>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuExtended2>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo>* ) NULL ) ); + pCollectionPopupMenu = &collectionPopupMenu; + } + } + + return (*pCollectionPopupMenu).getTypes(); + } + else + { + if( !pCollectionMenuBar ) + { + ::osl::Guard< ::osl::Mutex > aGlobalGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pCollectionMenuBar ) + { + static ::cppu::OTypeCollection collectionMenuBar( + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenu>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuBar>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuBarExtended>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuExtended>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuExtended2>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo>* ) NULL ) ); + pCollectionMenuBar = &collectionMenuBar; + } + } + return (*pCollectionMenuBar).getTypes(); + } +} + + +::com::sun::star::uno::Sequence< sal_Int8 > VCLXMenu::getImplementationId() +throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); + const sal_Bool bIsPopupMenu = IsPopupMenu(); + aGuard.clear(); + + static ::cppu::OImplementationId* pIdMenuBar = NULL; + static ::cppu::OImplementationId* pIdPopupMenu = NULL; + + if ( bIsPopupMenu ) + { + if( !pIdPopupMenu ) + { + ::osl::Guard< ::osl::Mutex > aGlobalGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pIdPopupMenu ) + { + static ::cppu::OImplementationId idPopupMenu( sal_False ); + pIdPopupMenu = &idPopupMenu; + } + } + + return (*pIdPopupMenu).getImplementationId(); + } + else + { + if( !pIdMenuBar ) + { + ::osl::Guard< ::osl::Mutex > aGlobalGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pIdMenuBar ) + { + static ::cppu::OImplementationId idMenuBar( sal_False ); + pIdMenuBar = &idMenuBar; + } + } + + return (*pIdMenuBar).getImplementationId(); + } +} + + +//============================================================================= +//============================================================================= +//============================================================================= + + +void VCLXMenu::addMenuListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + maMenuListeners.addInterface( rxListener ); +} + +void VCLXMenu::removeMenuListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + maMenuListeners.removeInterface( rxListener ); +} + +void VCLXMenu::insertItem( sal_Int16 nItemId, const ::rtl::OUString& aText, sal_Int16 nItemStyle, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu ) + mpMenu->InsertItem( nItemId, aText, (MenuItemBits)nItemStyle, nPos ); +} + +void VCLXMenu::removeItem( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + sal_Int32 nItemCount = (sal_Int32)mpMenu->GetItemCount(); + if ( mpMenu && ( nCount > 0 ) && ( nPos >= 0 ) && ( nPos < nItemCount ) && ( nItemCount > 0 )) + { + sal_Int16 nP = sal::static_int_cast< sal_Int16 >( + Min( (int)(nPos+nCount), (int)nItemCount )); + while( nP-nPos > 0 ) + mpMenu->RemoveItem( --nP ); + } +} + +sal_Int16 VCLXMenu::getItemCount( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + return mpMenu ? mpMenu->GetItemCount() : 0; +} + +sal_Int16 VCLXMenu::getItemId( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + return mpMenu ? mpMenu->GetItemId( nPos ) : 0; +} + +sal_Int16 VCLXMenu::getItemPos( sal_Int16 nId ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + return mpMenu ? mpMenu->GetItemPos( nId ) : 0; +} + +void VCLXMenu::enableItem( sal_Int16 nItemId, sal_Bool bEnable ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu ) + mpMenu->EnableItem( nItemId, bEnable ); +} + +sal_Bool VCLXMenu::isItemEnabled( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + return mpMenu ? mpMenu->IsItemEnabled( nItemId ) : sal_False; +} + +void VCLXMenu::setItemText( sal_Int16 nItemId, const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu ) + mpMenu->SetItemText( nItemId, aText ); +} + +::rtl::OUString VCLXMenu::getItemText( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::rtl::OUString aItemText; + if ( mpMenu ) + aItemText = mpMenu->GetItemText( nItemId ); + return aItemText; +} + +void VCLXMenu::setPopupMenu( sal_Int16 nItemId, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu >& rxPopupMenu ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + VCLXMenu* pVCLMenu = VCLXMenu::GetImplementation( rxPopupMenu ); + DBG_ASSERT( pVCLMenu && pVCLMenu->GetMenu() && pVCLMenu->IsPopupMenu(), "setPopupMenu: Invalid Menu!" ); + + if ( mpMenu && pVCLMenu && pVCLMenu->GetMenu() && pVCLMenu->IsPopupMenu() ) + { + // Selbst eine Ref halten! + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > * pNewRef = new ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > ; + *pNewRef = rxPopupMenu; + maPopupMenueRefs.Insert( pNewRef, LIST_APPEND ); + + mpMenu->SetPopupMenu( nItemId, (PopupMenu*) pVCLMenu->GetMenu() ); + } +} + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > VCLXMenu::getPopupMenu( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > aRef; + Menu* pMenu = mpMenu ? mpMenu->GetPopupMenu( nItemId ) : NULL; + if ( pMenu ) + { + for ( sal_uInt32 n = maPopupMenueRefs.Count(); n; ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > * pRef = maPopupMenueRefs.GetObject( --n ); + Menu* pM = ((VCLXMenu*)pRef->get())->GetMenu(); + if ( pM == pMenu ) + { + aRef = *pRef; + break; + } + } + } + return aRef; +} + +// ::com::sun::star::awt::XPopupMenu +void VCLXMenu::insertSeparator( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu ) + mpMenu->InsertSeparator( nPos ); +} + +void VCLXMenu::setDefaultItem( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu ) + mpMenu->SetDefaultItem( nItemId ); +} + +sal_Int16 VCLXMenu::getDefaultItem( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + return mpMenu ? mpMenu->GetDefaultItem() : 0; +} + +void VCLXMenu::checkItem( sal_Int16 nItemId, sal_Bool bCheck ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu ) + mpMenu->CheckItem( nItemId, bCheck ); +} + +sal_Bool VCLXMenu::isItemChecked( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + return mpMenu ? mpMenu->IsItemChecked( nItemId ) : sal_False; +} + +sal_Int16 VCLXMenu::execute( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& rxWindowPeer, const ::com::sun::star::awt::Rectangle& rArea, sal_Int16 nFlags ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + sal_Int16 nRet = 0; + if ( mpMenu && IsPopupMenu() ) + nRet = ((PopupMenu*)mpMenu)->Execute( VCLUnoHelper::GetWindow( rxWindowPeer ), VCLRectangle(rArea), nFlags | POPUPMENU_NOMOUSEUPCLOSE ); + return nRet; +} + + +void SAL_CALL VCLXMenu::setCommand( sal_Int16 nItemId, const ::rtl::OUString& aCommand ) throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu ) + mpMenu->SetItemCommand( nItemId, aCommand ); +} + +::rtl::OUString SAL_CALL VCLXMenu::getCommand( sal_Int16 nItemId ) throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::rtl::OUString aItemCommand; + if ( mpMenu ) + aItemCommand = mpMenu->GetItemCommand( nItemId ); + return aItemCommand; +} + +void SAL_CALL VCLXMenu::setHelpCommand( sal_Int16 nItemId, const ::rtl::OUString& aHelp ) throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu ) + mpMenu->SetHelpCommand( nItemId, aHelp ); +} + +::rtl::OUString SAL_CALL VCLXMenu::getHelpCommand( sal_Int16 nItemId ) throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::rtl::OUString aHelpCommand; + if ( mpMenu ) + aHelpCommand = mpMenu->GetHelpCommand( nItemId ); + return aHelpCommand; +} + + +// ============================================================================ +// ============================================================================ +// ============================================================================ + + +// BEGIN ANONYMOUS NAMESPACE +namespace +{ + namespace css = ::com::sun::star; + + Image lcl_XGraphic2VCLImage( + const css::uno::Reference< css::graphic::XGraphic >& xGraphic, + sal_Bool bResize ) + { + Image aImage; + if ( !xGraphic.is() ) + return aImage; + + aImage = Image( xGraphic ); + const ::Size aCurSize = aImage.GetSizePixel(); + const sal_Int32 nCurWidth = aCurSize.Width(); + const sal_Int32 nCurHeight = aCurSize.Height(); + const sal_Int32 nIdeal( 16 ); + + if ( nCurWidth > 0 && nCurHeight > 0 ) + { + if ( bResize && ( nCurWidth > nIdeal || nCurHeight > nIdeal ) ) + { + sal_Int32 nIdealWidth = nCurWidth > nIdeal ? nIdeal : nCurWidth; + sal_Int32 nIdealHeight = nCurHeight > nIdeal ? nIdeal : nCurHeight; + + ::Size aNewSize( nIdealWidth, nIdealHeight ); + + sal_Bool bModified( sal_False ); + BitmapEx aBitmapEx = aImage.GetBitmapEx(); + bModified = aBitmapEx.Scale( aNewSize, BMP_SCALE_INTERPOLATE ); + + if ( bModified ) + aImage = Image( aBitmapEx ); + } + } + return aImage; + } + + /** + As svtools builds after toolkit, we can not include/use + svtools/inc/acceleratorexecute.hxx + So I just copy here svt::AcceleratorExecute::st_AWTKey2VCLKey + and svt::AcceleratorExecute::st_VCLKey2AWTKey + */ + css::awt::KeyEvent lcl_VCLKey2AWTKey(const KeyCode& aVCLKey) + { + css::awt::KeyEvent aAWTKey; + aAWTKey.Modifiers = 0; + aAWTKey.KeyCode = (sal_Int16)aVCLKey.GetCode(); + + if (aVCLKey.IsShift()) + aAWTKey.Modifiers |= css::awt::KeyModifier::SHIFT; + if (aVCLKey.IsMod1()) + aAWTKey.Modifiers |= css::awt::KeyModifier::MOD1; + if (aVCLKey.IsMod2()) + aAWTKey.Modifiers |= css::awt::KeyModifier::MOD2; + if (aVCLKey.IsMod3()) + aAWTKey.Modifiers |= css::awt::KeyModifier::MOD3; + + return aAWTKey; + } + + KeyCode lcl_AWTKey2VCLKey(const css::awt::KeyEvent& aAWTKey) + { + sal_Bool bShift = ((aAWTKey.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT ); + sal_Bool bMod1 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD1 ) == css::awt::KeyModifier::MOD1 ); + sal_Bool bMod2 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD2 ) == css::awt::KeyModifier::MOD2 ); + sal_Bool bMod3 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD3 ) == css::awt::KeyModifier::MOD3 ); + USHORT nKey = (USHORT)aAWTKey.KeyCode; + + return KeyCode(nKey, bShift, bMod1, bMod2, bMod3); + } + +} // END ANONYMOUS NAMESPACE + + +// ============================================================================ +// ============================================================================ +// ============================================================================ + + +// XMenuExtended2 Methods + +::sal_Bool SAL_CALL VCLXMenu::isPopupMenu( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + return IsPopupMenu(); +} + +void SAL_CALL VCLXMenu::clear( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + if ( mpMenu ) + mpMenu->Clear(); +} + + +::com::sun::star::awt::MenuItemType SAL_CALL VCLXMenu::getItemType( ::sal_Int16 nItemPos ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::awt::MenuItemType aMenuItemType = + ::com::sun::star::awt::MenuItemType_DONTKNOW; + if ( mpMenu ) + { + THROW_MENUPOS_NOT_FOUND( "VCLXMenu::getItemType()", nItemPos ) + aMenuItemType = ( (::com::sun::star::awt::MenuItemType) mpMenu->GetItemType( nItemPos ) ); + } + + return aMenuItemType; +} + +void SAL_CALL VCLXMenu::hideDisabledEntries( ::sal_Bool bHide ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + if ( mpMenu ) + { + if ( bHide ) + mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() | MENU_FLAG_HIDEDISABLEDENTRIES ); + else + mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() & ~MENU_FLAG_HIDEDISABLEDENTRIES ); + } +} + + +// ============================================================================ +// ============================================================================ +// ============================================================================ + + +// XPopupMenuExtended Methods + +::sal_Bool SAL_CALL VCLXMenu::isInExecute( ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + return ( (PopupMenu*) mpMenu )->IsInExecute(); + else + return sal_False; +} + + +void SAL_CALL VCLXMenu::endExecute() +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + ( (PopupMenu*) mpMenu )->EndExecute(); +} + + +void SAL_CALL VCLXMenu::setLogo( const ::com::sun::star::awt::MenuLogo& aMenuLogo ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu ) + { + if ( aMenuLogo.Graphic.is() ) + { + Image aImage = lcl_XGraphic2VCLImage( aMenuLogo.Graphic, sal_False ); + MenuLogo aVCLMenuLogo; + + aVCLMenuLogo.aBitmap = aImage.GetBitmapEx(); + aVCLMenuLogo.aStartColor = Color( (sal_uInt32)(aMenuLogo.StartColor) ); + aVCLMenuLogo.aEndColor = Color( (sal_uInt32)(aMenuLogo.EndColor) ); + + mpMenu->SetLogo( aVCLMenuLogo ); + } + else + mpMenu->SetLogo(); + } +} + + +::com::sun::star::awt::MenuLogo SAL_CALL VCLXMenu::getLogo( ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::awt::MenuLogo aAWTMenuLogo; + if ( mpMenu ) + { + if ( mpMenu->HasLogo() ) + { + MenuLogo aVCLMenuLogo = mpMenu->GetLogo(); + aAWTMenuLogo.Graphic = Image(aVCLMenuLogo.aBitmap).GetXGraphic(); + aAWTMenuLogo.StartColor = aVCLMenuLogo.aStartColor.GetColor(); + aAWTMenuLogo.EndColor = aVCLMenuLogo.aEndColor.GetColor(); + } + } + return aAWTMenuLogo; +} + + +void SAL_CALL VCLXMenu::enableAutoMnemonics( ::sal_Bool bEnable ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + if ( mpMenu ) + { + if ( !bEnable ) + mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS ); + else + mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() & ~MENU_FLAG_NOAUTOMNEMONICS ); + } +} + + +void SAL_CALL VCLXMenu::setAcceleratorKeyEvent( ::sal_Int16 nItemId, + const ::com::sun::star::awt::KeyEvent& aKeyEvent ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setAcceleratorKeyEvent()", nItemId ) + KeyCode aVCLKeyCode = lcl_AWTKey2VCLKey( aKeyEvent ); + mpMenu->SetAccelKey( nItemId, aVCLKeyCode ); + } +} + + +::com::sun::star::awt::KeyEvent SAL_CALL VCLXMenu::getAcceleratorKeyEvent( ::sal_Int16 nItemId ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::awt::KeyEvent aKeyEvent; + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getAcceleratorKeyEvent()", nItemId ) + KeyCode nKeyCode = mpMenu->GetAccelKey( nItemId ); + aKeyEvent = lcl_VCLKey2AWTKey( nKeyCode ); + } + + return aKeyEvent; +} + + +void SAL_CALL VCLXMenu::setHelpText( ::sal_Int16 nItemId, const ::rtl::OUString& sHelpText ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setHelpText()", nItemId ) + mpMenu->SetHelpText( nItemId, sHelpText ); + } +} + + +::rtl::OUString SAL_CALL VCLXMenu::getHelpText( ::sal_Int16 nItemId ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + rtl::OUString sHelpText; + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getHelpText()", nItemId ) + sHelpText = mpMenu->GetHelpText( nItemId ); + } + + return sHelpText; +} + + +void SAL_CALL VCLXMenu::setTipHelpText( ::sal_Int16 nItemId, const ::rtl::OUString& sTipHelpText ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setTipHelpText()", nItemId ) + mpMenu->SetTipHelpText( nItemId, sTipHelpText ); + } +} + + +::rtl::OUString SAL_CALL VCLXMenu::getTipHelpText( ::sal_Int16 nItemId ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + rtl::OUString sTipHelpText; + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getTipHelpText()", nItemId ) + sTipHelpText = mpMenu->GetTipHelpText( nItemId ); + } + return sTipHelpText; +} + + +void SAL_CALL VCLXMenu::setItemImage( + ::sal_Int16 nItemId, + const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& xGraphic, ::sal_Bool bScale ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setItemImage()", nItemId ) + Image aImage = lcl_XGraphic2VCLImage( xGraphic, bScale ); + mpMenu->SetItemImage( nItemId, aImage ); + } +} + + +::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > SAL_CALL VCLXMenu::getItemImage( ::sal_Int16 nItemId ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > rxGraphic; + + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getItemImage()", nItemId ) + Image aImage = mpMenu->GetItemImage( nItemId ); + if ( !!aImage ) + rxGraphic = aImage.GetXGraphic(); + } + return rxGraphic; +} + + +void SAL_CALL VCLXMenu::setItemImageAngle( ::sal_Int16 nItemId, ::sal_Int32 nAngle ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setItemImageAngle()", nItemId ) + mpMenu->SetItemImageAngle( nItemId, nAngle ); + } +} + + +::sal_Int32 SAL_CALL VCLXMenu::getItemImageAngle( ::sal_Int16 nItemId ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::sal_Int32 nItemImageAngle( 0 ); + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getItemImageAngle()", nItemId ) + nItemImageAngle = mpMenu->GetItemImageAngle( nItemId ); + } + return nItemImageAngle; +} + + +void SAL_CALL VCLXMenu::setItemImageMirrorMode( ::sal_Int16 nItemId, ::sal_Bool bMirror ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setItemImageMirrorMode()", nItemId ) + mpMenu->SetItemImageMirrorMode( nItemId, bMirror ); + } +} + + +::sal_Bool SAL_CALL VCLXMenu::isItemImageInMirrorMode( ::sal_Int16 nItemId ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + sal_Bool bMirrorMode( sal_False ); + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::isItemImageInMirrorMode()", nItemId ) + bMirrorMode = mpMenu->GetItemImageMirrorMode( nItemId ); + } + return bMirrorMode; +} + + +// ---------------------------------------------------- +// class VCLXMenuBar +// ---------------------------------------------------- + +DBG_NAME(VCLXMenuBar); + +VCLXMenuBar::VCLXMenuBar() +{ + DBG_CTOR( VCLXMenuBar, 0 ); + ImplCreateMenu( FALSE ); +} + +VCLXMenuBar::VCLXMenuBar( MenuBar* pMenuBar ) : VCLXMenu( (Menu *)pMenuBar ) +{ + DBG_CTOR( VCLXMenuBar, 0 ); +} + +// ---------------------------------------------------- +// class VCLXPopupMenu +// ---------------------------------------------------- + +DBG_NAME(VCLXPopupMenu); + +VCLXPopupMenu::VCLXPopupMenu() +{ + DBG_CTOR( VCLXPopupMenu, 0 ); + ImplCreateMenu( TRUE ); +} diff --git a/toolkit/source/awt/vclxplugin.cxx b/toolkit/source/awt/vclxplugin.cxx new file mode 100644 index 000000000000..29264ef0a85d --- /dev/null +++ b/toolkit/source/awt/vclxplugin.cxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#include "vclxplugin.hxx" + +#include <com/sun/star/awt/PosSize.hpp> +#include <toolkit/helper/convert.hxx> +#include <toolkit/helper/property.hxx> +#include <vcl/ctrl.hxx> + +#include "forward.hxx" + +namespace layoutimpl +{ + +using namespace ::com::sun::star; + +VCLXPlugin::VCLXPlugin( Window *p, WinBits b ) + : VCLXWindow() + , mpWindow( p ) + , mpPlugin( 0 ) + , mStyle( b ) +{ +} + +VCLXPlugin::~VCLXPlugin() +{ +} + +void SAL_CALL VCLXPlugin::dispose() throw(uno::RuntimeException) +{ + { + ::vos::OGuard aGuard( GetMutex() ); + + lang::EventObject aDisposeEvent; + aDisposeEvent.Source = W3K_EXPLICIT_CAST (*this); + } + + VCLXWindow::dispose(); +} + +void VCLXPlugin::SetPlugin( ::Control *p ) +{ + mpPlugin = p; +} + +awt::Size SAL_CALL VCLXPlugin::getMinimumSize() + throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OClearableGuard aGuard( GetMutex() ); + if ( mpPlugin ) + return AWTSize( mpPlugin->GetSizePixel() ); + return awt::Size(); +} + +} // namespace layoutimpl diff --git a/toolkit/source/awt/vclxplugin.hxx b/toolkit/source/awt/vclxplugin.hxx new file mode 100644 index 000000000000..49a2b2950854 --- /dev/null +++ b/toolkit/source/awt/vclxplugin.hxx @@ -0,0 +1,67 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifndef LAYOUT_AWT_VCLXPLUGIN_HXX +#define LAYOUT_AWT_VCLXPLUGIN_HXX + +#include <toolkit/awt/vclxwindow.hxx> +#include <vcl/wintypes.hxx> + +class Control; +namespace layoutimpl +{ + +namespace css = ::com::sun::star; + +class VCLXPlugin : public VCLXWindow +{ +public: + Window *mpWindow; + ::Control *mpPlugin; + WinBits mStyle; + + VCLXPlugin( Window *p, WinBits b ); + + void SetPlugin( ::Control *p ); + +protected: + ~VCLXPlugin(); + + // XComponent + void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::awt::Size SAL_CALL getMinimumSize() + throw(::com::sun::star::uno::RuntimeException); + +private: + VCLXPlugin( VCLXPlugin const & ); + VCLXPlugin& operator=( VCLXPlugin const & ); +}; + +} // namespace layoutimpl + +#endif /* LAYOUT_AWT_VCLXPLUGIN_HXX */ diff --git a/toolkit/source/awt/vclxpointer.cxx b/toolkit/source/awt/vclxpointer.cxx new file mode 100644 index 000000000000..d6f2160fb694 --- /dev/null +++ b/toolkit/source/awt/vclxpointer.cxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + + +#include <toolkit/awt/vclxpointer.hxx> +#include <toolkit/helper/macros.hxx> +#include <cppuhelper/typeprovider.hxx> + +// ---------------------------------------------------- +// class VCLXPointer +// ---------------------------------------------------- +VCLXPointer::VCLXPointer() +{ +} + +VCLXPointer::~VCLXPointer() +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXPointer::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XPointer*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) ); + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); +} + +// ::com::sun::star::lang::XUnoTunnel +IMPL_XUNOTUNNEL( VCLXPointer ) + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXPointer ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPointer>* ) NULL ) +IMPL_XTYPEPROVIDER_END + +void VCLXPointer::setType( sal_Int32 nType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + maPointer = Pointer( (PointerStyle)nType ); +} + +sal_Int32 VCLXPointer::getType() throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + return (sal_Int32)maPointer.GetStyle(); +} + + + diff --git a/toolkit/source/awt/vclxprinter.cxx b/toolkit/source/awt/vclxprinter.cxx new file mode 100644 index 000000000000..3c100c7c2186 --- /dev/null +++ b/toolkit/source/awt/vclxprinter.cxx @@ -0,0 +1,463 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + + +#include <toolkit/awt/vclxprinter.hxx> +#include <toolkit/helper/macros.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <rtl/memory.h> +#include <rtl/uuid.h> + + +#include <vcl/print.hxx> +#include <vcl/jobset.hxx> +#include <vcl/svapp.hxx> + +#include <tools/debug.hxx> +#include <tools/stream.hxx> + +#include <toolkit/awt/vclxdevice.hxx> + + +#define BINARYSETUPMARKER 0x23864691 + +#define PROPERTY_Orientation 0 +#define PROPERTY_Horizontal 1 + +::com::sun::star::beans::Property* ImplGetProperties( sal_uInt16& rElementCount ) +{ + static ::com::sun::star::beans::Property* pProperties = NULL; + static sal_uInt16 nElements = 0; + if( !pProperties ) + { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pProperties ) + { + static ::com::sun::star::beans::Property __FAR_DATA aPropTable[] = + { + ::com::sun::star::beans::Property( ::rtl::OUString::createFromAscii( "Orientation" ), PROPERTY_Orientation, ::getCppuType((const sal_Int16*)0), 0 ), + ::com::sun::star::beans::Property( ::rtl::OUString::createFromAscii( "Horizontal" ), PROPERTY_Horizontal, ::getBooleanCppuType(), 0 ) + }; + pProperties = aPropTable; + nElements = sizeof( aPropTable ) / sizeof( ::com::sun::star::beans::Property ); + } + } + rElementCount = nElements; + return pProperties; +} + +// ---------------------------------------------------- +// class VCLXPrinterPropertySet +// ---------------------------------------------------- + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXPrinterPropertySet::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::beans::XMultiPropertySet*, this ), + SAL_STATIC_CAST( ::com::sun::star::beans::XFastPropertySet*, this ), + SAL_STATIC_CAST( ::com::sun::star::beans::XPropertySet*, (::cppu::OPropertySetHelper*) this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XPrinterPropertySet*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) ); + return (aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXPrinterPropertySet ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPrinterPropertySet>* ) NULL ) +IMPL_XTYPEPROVIDER_END + +VCLXPrinterPropertySet::VCLXPrinterPropertySet( const String& rPrinterName ) + : OPropertySetHelper( BrdcstHelper ) + , mpPrinter( new Printer( rPrinterName ) ) +{ + osl::Guard< vos::IMutex > aSolarGuard( Application::GetSolarMutex() ); + + mnOrientation = 0; + mbHorizontal = sal_False; +} + +VCLXPrinterPropertySet::~VCLXPrinterPropertySet() +{ + osl::Guard< vos::IMutex > aSolarGuard( Application::GetSolarMutex() ); + mpPrinter.reset(); +} + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXPrinterPropertySet::GetDevice() +{ + if ( !mxPrnDevice.is() ) + { + VCLXDevice* pDev = new VCLXDevice; + pDev->SetOutputDevice( GetPrinter() ); + mxPrnDevice = pDev; + } + return mxPrnDevice; +} + +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > VCLXPrinterPropertySet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) +{ + static ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} + +::cppu::IPropertyArrayHelper& VCLXPrinterPropertySet::getInfoHelper() +{ + static ::cppu::OPropertyArrayHelper* pPropertyArrayHelper = NULL; + if ( !pPropertyArrayHelper ) + { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pPropertyArrayHelper ) + { + sal_uInt16 nElements; + ::com::sun::star::beans::Property* pProps = ImplGetProperties( nElements ); + pPropertyArrayHelper = new ::cppu::OPropertyArrayHelper( pProps, nElements, sal_False ); + } + } + return *pPropertyArrayHelper ; +} + +sal_Bool VCLXPrinterPropertySet::convertFastPropertyValue( ::com::sun::star::uno::Any & rConvertedValue, ::com::sun::star::uno::Any & rOldValue, sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::lang::IllegalArgumentException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); + + sal_Bool bDifferent = sal_False; + switch ( nHandle ) + { + case PROPERTY_Orientation: + { + sal_Int16 n; + if( ( rValue >>= n ) && ( n != mnOrientation ) ) + { + rConvertedValue <<= n; + rOldValue <<= mnOrientation; + bDifferent = sal_True; + } + } + break; + case PROPERTY_Horizontal: + { + sal_Bool b; + if( ( rValue >>= b ) && ( b != mbHorizontal ) ) + { + rConvertedValue <<= b; + rOldValue <<= mbHorizontal; + bDifferent = sal_True; + } + } + break; + default: + { + DBG_ERROR( "VCLXPrinterPropertySet_Impl::convertFastPropertyValue - invalid Handle" ); + } + } + return bDifferent; +} + +void VCLXPrinterPropertySet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception) +{ + ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); + + switch( nHandle ) + { + case PROPERTY_Orientation: + { + rValue >>= mnOrientation; + } + break; + case PROPERTY_Horizontal: + { + rValue >>= mbHorizontal; + } + break; + default: + { + DBG_ERROR( "VCLXPrinterPropertySet_Impl::convertFastPropertyValue - invalid Handle" ); + } + } +} + +void VCLXPrinterPropertySet::getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const +{ + ::osl::Guard< ::osl::Mutex > aGuard( ((VCLXPrinterPropertySet*)this)->Mutex ); + + switch( nHandle ) + { + case PROPERTY_Orientation: + rValue <<= mnOrientation; + break; + case PROPERTY_Horizontal: + rValue <<= mbHorizontal; + break; + default: + { + DBG_ERROR( "VCLXPrinterPropertySet_Impl::convertFastPropertyValue - invalid Handle" ); + } + } +} + +// ::com::sun::star::awt::XPrinterPropertySet +void VCLXPrinterPropertySet::setHorizontal( sal_Bool bHorizontal ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); + + ::com::sun::star::uno::Any aValue; + aValue <<= bHorizontal; + setFastPropertyValue( PROPERTY_Horizontal, aValue ); +} + +::com::sun::star::uno::Sequence< ::rtl::OUString > VCLXPrinterPropertySet::getFormDescriptions( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); + + sal_uInt16 nPaperBinCount = GetPrinter()->GetPaperBinCount(); + ::com::sun::star::uno::Sequence< ::rtl::OUString > aDescriptions( nPaperBinCount ); + for ( sal_uInt16 n = 0; n < nPaperBinCount; n++ ) + { + // Format: <DisplayFormName;FormNameId;DisplayPaperBinName;PaperBinNameId;DisplayPaperName;PaperNameId> + String aDescr( RTL_CONSTASCII_USTRINGPARAM( "*;*;" ) ); + aDescr += GetPrinter()->GetPaperBinName( n ); + aDescr += ';'; + aDescr += n; + aDescr.AppendAscii( ";*;*", 4 ); + + aDescriptions.getArray()[n] = aDescr; + } + return aDescriptions; +} + +void VCLXPrinterPropertySet::selectForm( const ::rtl::OUString& rFormDescription ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); + + sal_Int32 nIndex = 0; + sal_uInt16 nPaperBin = sal::static_int_cast< sal_uInt16 >( + rFormDescription.getToken( 3, ';', nIndex ).toInt32()); + GetPrinter()->SetPaperBin( nPaperBin ); +} + +::com::sun::star::uno::Sequence< sal_Int8 > VCLXPrinterPropertySet::getBinarySetup( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); + + SvMemoryStream aMem; + aMem << BINARYSETUPMARKER; + aMem << GetPrinter()->GetJobSetup(); + return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() ); +} + +void VCLXPrinterPropertySet::setBinarySetup( const ::com::sun::star::uno::Sequence< sal_Int8 >& data ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); + + SvMemoryStream aMem( (char*) data.getConstArray(), data.getLength(), STREAM_READ ); + sal_uInt32 nMarker; + aMem >> nMarker; + DBG_ASSERT( nMarker == BINARYSETUPMARKER, "setBinarySetup - invalid!" ); + if ( nMarker == BINARYSETUPMARKER ) + { + JobSetup aSetup; + aMem >> aSetup; + GetPrinter()->SetJobSetup( aSetup ); + } +} + + +// ---------------------------------------------------- +// class VCLXPrinter +// ---------------------------------------------------- +VCLXPrinter::VCLXPrinter( const String& rPrinterName ) + : VCLXPrinterPropertySet( rPrinterName ) +{ +} + +VCLXPrinter::~VCLXPrinter() +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXPrinter::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XPrinter*, this ) ); + + if ( !aRet.hasValue() ) + aRet = VCLXPrinterPropertySet::queryInterface( rType ); + + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXPrinter ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPrinter>* ) NULL ), + VCLXPrinterPropertySet::getTypes() +IMPL_XTYPEPROVIDER_END + +sal_Bool VCLXPrinter::start( const ::rtl::OUString& /*rJobName*/, sal_Int16 /*nCopies*/, sal_Bool /*bCollate*/ ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); + + sal_Bool bDone = sal_True; + if ( mpListener.get() ) + { + maInitJobSetup = mpPrinter->GetJobSetup(); + mpListener.reset( new vcl::OldStylePrintAdaptor( mpPrinter ) ); + } + + return bDone; +} + +void VCLXPrinter::end( ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); + + if ( mpListener.get() ) + { + Printer::PrintJob( mpListener, maInitJobSetup ); + mpListener.reset(); + } +} + +void VCLXPrinter::terminate( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); + + mpListener.reset(); +} + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXPrinter::startPage( ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); + + if ( mpListener.get() ) + { + mpListener->StartPage(); + } + return GetDevice(); +} + +void VCLXPrinter::endPage( ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); + + if ( mpListener.get() ) + { + mpListener->EndPage(); + } +} + + +// ---------------------------------------------------- +// class VCLXInfoPrinter +// ---------------------------------------------------- + +VCLXInfoPrinter::VCLXInfoPrinter( const String& rPrinterName ) + : VCLXPrinterPropertySet( rPrinterName ) +{ +} + +VCLXInfoPrinter::~VCLXInfoPrinter() +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXInfoPrinter::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XInfoPrinter*, this ) ); + + if ( !aRet.hasValue() ) + aRet = VCLXPrinterPropertySet::queryInterface( rType ); + + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXInfoPrinter ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XInfoPrinter>* ) NULL ), + VCLXPrinterPropertySet::getTypes() +IMPL_XTYPEPROVIDER_END + +// ::com::sun::star::awt::XInfoPrinter +::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXInfoPrinter::createDevice( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); + + return GetDevice(); +} + +// ---------------------------------------------------- +// class VCLXPrinterServer +// ---------------------------------------------------- + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXPrinterServer::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XPrinterServer*, this ) ); + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXPrinterServer ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPrinterServer>* ) NULL ) +IMPL_XTYPEPROVIDER_END + +// ::com::sun::star::awt::XPrinterServer +::com::sun::star::uno::Sequence< ::rtl::OUString > VCLXPrinterServer::getPrinterNames( ) throw(::com::sun::star::uno::RuntimeException) +{ + const std::vector<rtl::OUString>& rQueues = Printer::GetPrinterQueues(); + sal_uInt32 nPrinters = rQueues.size(); + + ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames( nPrinters ); + for ( sal_uInt32 n = 0; n < nPrinters; n++ ) + aNames.getArray()[n] = rQueues[n]; + + return aNames; +} + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XPrinter > VCLXPrinterServer::createPrinter( const ::rtl::OUString& rPrinterName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPrinter > xP; + xP = new VCLXPrinter( rPrinterName ); + return xP; +} + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XInfoPrinter > VCLXPrinterServer::createInfoPrinter( const ::rtl::OUString& rPrinterName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XInfoPrinter > xP; + xP = new VCLXInfoPrinter( rPrinterName ); + return xP; +} + + + diff --git a/toolkit/source/awt/vclxregion.cxx b/toolkit/source/awt/vclxregion.cxx new file mode 100644 index 000000000000..3c4bbcad2d79 --- /dev/null +++ b/toolkit/source/awt/vclxregion.cxx @@ -0,0 +1,171 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + + +#include <toolkit/awt/vclxregion.hxx> +#include <toolkit/helper/macros.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <toolkit/helper/convert.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <rtl/memory.h> +#include <rtl/uuid.h> +#include <vcl/svapp.hxx> + +// ---------------------------------------------------- +// class VCLXRegion +// ---------------------------------------------------- +VCLXRegion::VCLXRegion() +{ +} + +VCLXRegion::~VCLXRegion() +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXRegion::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XRegion*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) ); + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); +} + +// ::com::sun::star::lang::XUnoTunnel +IMPL_XUNOTUNNEL( VCLXRegion ) + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXRegion ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion>* ) NULL ) +IMPL_XTYPEPROVIDER_END + + + +::com::sun::star::awt::Rectangle VCLXRegion::getBounds() throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + return AWTRectangle( maRegion.GetBoundRect() ); +} + +void VCLXRegion::clear() throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + maRegion.SetEmpty(); +} + +void VCLXRegion::move( sal_Int32 nHorzMove, sal_Int32 nVertMove ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + maRegion.Move( nHorzMove, nVertMove ); +} + +void VCLXRegion::unionRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + maRegion.Union( VCLRectangle( rRect ) ); +} + +void VCLXRegion::intersectRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + maRegion.Intersect( VCLRectangle( rRect ) ); +} + +void VCLXRegion::excludeRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + maRegion.Exclude( VCLRectangle( rRect ) ); +} + +void VCLXRegion::xOrRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + maRegion.XOr( VCLRectangle( rRect ) ); +} + +void VCLXRegion::unionRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( rxRegion.is() ) + maRegion.Union( VCLUnoHelper::GetRegion( rxRegion ) ); +} + +void VCLXRegion::intersectRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( rxRegion.is() ) + maRegion.Intersect( VCLUnoHelper::GetRegion( rxRegion ) ); +} + +void VCLXRegion::excludeRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( rxRegion.is() ) + maRegion.Exclude( VCLUnoHelper::GetRegion( rxRegion ) ); +} + +void VCLXRegion::xOrRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( rxRegion.is() ) + maRegion.XOr( VCLUnoHelper::GetRegion( rxRegion ) ); +} + +::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle > VCLXRegion::getRectangles() throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ULONG nRects = maRegion.GetRectCount(); + ::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle > aRects( nRects ); + + Rectangle aRect; + sal_uInt32 nR = 0; + RegionHandle h = maRegion.BeginEnumRects(); + while ( maRegion.GetNextEnumRect( h, aRect ) ) + aRects.getArray()[nR++] = AWTRectangle( aRect ); + maRegion.EndEnumRects( h ); + + return aRects; +} + + + diff --git a/toolkit/source/awt/vclxscroller.cxx b/toolkit/source/awt/vclxscroller.cxx new file mode 100644 index 000000000000..834632a7548b --- /dev/null +++ b/toolkit/source/awt/vclxscroller.cxx @@ -0,0 +1,212 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#include "vclxscroller.hxx" + +#include <assert.h> +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/awt/ScrollBarOrientation.hpp> +#include <sal/macros.h> +#include <toolkit/helper/property.hxx> +#include <tools/debug.hxx> +#include <vcl/scrbar.hxx> + +#include "forward.hxx" + +namespace layoutimpl +{ + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star; + +DBG_NAME( VCLXScroller ) + +VCLXScroller::VCLXScroller() + : VCLXWindow() + , Bin() +{ + DBG_CTOR( VCLXScroller, NULL ); + mpHorScrollBar = mpVerScrollBar = 0; +} + +VCLXScroller::~VCLXScroller() +{ + DBG_DTOR( VCLXScroller, NULL ); +} + +IMPLEMENT_2_FORWARD_XINTERFACE1( VCLXScroller, VCLXWindow, Container ); + +IMPLEMENT_FORWARD_XTYPEPROVIDER1( VCLXScroller, VCLXWindow ); + +void SAL_CALL VCLXScroller::dispose() throw(RuntimeException) +{ + { + ::vos::OGuard aGuard( GetMutex() ); + + EventObject aDisposeEvent; + aDisposeEvent.Source = W3K_EXPLICIT_CAST (*this); +// maTabListeners.disposeAndClear( aDisposeEvent ); + } + + VCLXWindow::dispose(); +} + +void VCLXScroller::ensureScrollBars() +{ + + if ( !mpVerScrollBar ) + { + mpVerScrollBar = new ScrollBar( GetWindow() , WB_VERT ); + mpVerScrollBar->SetLineSize( 4 ); + mpVerScrollBar->SetPageSize( 15 ); + mpVerScrollBar->Show(); + mpVerScrollBar->SetScrollHdl( LINK( this, VCLXScroller, ScrollHdl ) ); + } + if ( !mpHorScrollBar ) + { + mpHorScrollBar = new ScrollBar( GetWindow() , WB_HORZ ); + mpHorScrollBar->SetLineSize( 4 ); + mpHorScrollBar->SetPageSize( 15 ); + mpHorScrollBar->Show(); + mpHorScrollBar->SetScrollHdl( LINK( this, VCLXScroller, ScrollHdl ) ); + } // mpContent = new FixedImage( this, ImplGetWinBits( WindowAttributes, 0 ) ); + +} + +void SAL_CALL VCLXScroller::allocateArea( + const ::com::sun::star::awt::Rectangle &rArea ) + throw (::com::sun::star::uno::RuntimeException) +{ + ensureScrollBars(); // shouldn't be needed + + maAllocation = rArea; + setPosSize( rArea.X, rArea.Y, rArea.Width, rArea.Height, PosSize::POSSIZE ); + + mpHorScrollBar->SetRangeMin( 0 ); + mpHorScrollBar->SetRangeMax( SAL_MAX( maChildRequisition.Width - rArea.Width, 0 ) ); + mpVerScrollBar->SetRangeMin( 0 ); + mpVerScrollBar->SetRangeMax( SAL_MAX( maChildRequisition.Height - rArea.Height, 0 ) ); + + int thumbX = mpHorScrollBar->GetThumbPos(); + int thumbY = mpVerScrollBar->GetThumbPos(); + int thumbWidth = mpVerScrollBar->GetSizePixel().getWidth(); + int thumbHeight = mpHorScrollBar->GetSizePixel().getHeight(); + + mpHorScrollBar->SetPosSizePixel( rArea.X, rArea.Y + rArea.Height - thumbHeight - 2, + rArea.Width - thumbWidth, thumbHeight ); + mpVerScrollBar->SetPosSizePixel( rArea.X + rArea.Width - thumbWidth - 2, rArea.Y-2, + thumbWidth, rArea.Height - thumbHeight ); + + awt::Rectangle childRect( rArea.X - thumbX, rArea.Y - thumbY, + SAL_MAX( maChildRequisition.Width, rArea.Width ) - thumbWidth - 4, + SAL_MAX( maChildRequisition.Height, rArea.Height ) - thumbHeight - 4 ); + if ( mxChild.is() ) + allocateChildAt( mxChild, childRect ); +} + +#define MAX_CHILD_REQ 40 +::com::sun::star::awt::Size SAL_CALL VCLXScroller::getMinimumSize() + throw(::com::sun::star::uno::RuntimeException) +{ + ensureScrollBars(); + assert( mpHorScrollBar && mpVerScrollBar ); + awt::Size childSize = Bin::getMinimumSize(); + int thumbWidth = mpVerScrollBar->GetSizePixel().getWidth(); + int thumbHeight = mpHorScrollBar->GetSizePixel().getHeight(); + maRequisition = awt::Size( + SAL_MIN( MAX_CHILD_REQ, childSize.Width ) + thumbWidth, + SAL_MIN( MAX_CHILD_REQ, childSize.Height ) + thumbHeight ); + return maRequisition; +} + +void VCLXScroller::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) +{ +/* + ::vos::OClearableGuard aGuard( GetMutex() ); + + switch ( _rVclWindowEvent.GetId() ) + { + default: + aGuard.clear(); +*/ + VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); +/* + break; + } +*/ +} + +void SAL_CALL VCLXScroller::setProperty( const ::rtl::OUString& PropertyName, const Any &Value ) throw(RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { +/* + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) + { + default: +*/ + VCLXWindow::setProperty( PropertyName, Value ); +/* + } +*/ + } +} + +Any SAL_CALL VCLXScroller::getProperty( const ::rtl::OUString& PropertyName ) throw(RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Any aReturn; + if ( GetWindow() ) + { +/* + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) + { + default: +*/ + aReturn = VCLXWindow::getProperty( PropertyName ); + +// } + } + return aReturn; +} + +IMPL_LINK( VCLXScroller, ScrollHdl, ScrollBar *, pScrollBar ) +{ + (void) pScrollBar; + forceRecalc(); + return 0; +} + +} // namespace layoutimpl diff --git a/toolkit/source/awt/vclxscroller.hxx b/toolkit/source/awt/vclxscroller.hxx new file mode 100644 index 000000000000..be2524020c72 --- /dev/null +++ b/toolkit/source/awt/vclxscroller.hxx @@ -0,0 +1,87 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifndef LAYOUT_AWT_VCLXSCROLLER_HXX +#define LAYOUT_AWT_VCLXSCROLLER_HXX + +#include <comphelper/uno3.hxx> +#include <layout/core/bin.hxx> +#include <toolkit/awt/vclxwindow.hxx> + +class ScrollBar; +class FixedImage; + +namespace layoutimpl +{ + +class VCLXScroller :public VCLXWindow + ,public Bin +{ +public: + VCLXScroller(); + +protected: + ~VCLXScroller(); + + // XInterface + DECLARE_XINTERFACE() + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XComponent + void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::awt::XLayoutContainer + virtual void SAL_CALL allocateArea( const ::com::sun::star::awt::Rectangle &rArea ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Size SAL_CALL getMinimumSize() + throw(::com::sun::star::uno::RuntimeException); + + // VclWindowPeer + virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); + + // VCLXWindow + void ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ); + +private: + VCLXScroller( const VCLXScroller& ); // never implemented + VCLXScroller& operator=( const VCLXScroller& ); // never implemented + + // because the underlying window is only setup-ed after construction, init + // scrollbars at play-time + void ensureScrollBars(); + + FixedImage *mpContent; // dummy + ScrollBar *mpHorScrollBar, *mpVerScrollBar; + DECL_LINK( ScrollHdl, ScrollBar* ); +}; + +} // namespace layoutimpl + +#endif /* LAYOUT_AWT_VCLXSCROLLER_HXX */ diff --git a/toolkit/source/awt/vclxspinbutton.cxx b/toolkit/source/awt/vclxspinbutton.cxx new file mode 100644 index 000000000000..e9c2b3271396 --- /dev/null +++ b/toolkit/source/awt/vclxspinbutton.cxx @@ -0,0 +1,355 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" +#include "toolkit/awt/vclxspinbutton.hxx" +#include "toolkit/helper/property.hxx" +#include <com/sun/star/awt/ScrollBarOrientation.hpp> + + +#include <tools/debug.hxx> +#include <vcl/spin.hxx> + +namespace toolkit +{ + void setButtonLikeFaceColor( Window* _pWindow, const ::com::sun::star::uno::Any& _rColorValue ); + ::com::sun::star::uno::Any getButtonLikeFaceColor( const Window* _pWindow ); +} + +//........................................................................ +namespace toolkit +{ +//........................................................................ + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::awt; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::beans; + + //-------------------------------------------------------------------- + namespace + { + void lcl_modifyStyle( Window* _pWindow, WinBits _nStyleBits, sal_Bool _bShouldBePresent ) + { + WinBits nStyle = _pWindow->GetStyle(); + if ( _bShouldBePresent ) + nStyle |= _nStyleBits; + else + nStyle &= ~_nStyleBits; + _pWindow->SetStyle( nStyle ); + } + } + + //==================================================================== + //= VCLXSpinButton + //==================================================================== + DBG_NAME( VCLXSpinButton ) + //-------------------------------------------------------------------- + VCLXSpinButton::VCLXSpinButton() + :maAdjustmentListeners( *this ) + { + DBG_CTOR( VCLXSpinButton, NULL ); + } + + //-------------------------------------------------------------------- + VCLXSpinButton::~VCLXSpinButton() + { + DBG_DTOR( VCLXSpinButton, NULL ); + } + + //-------------------------------------------------------------------- + IMPLEMENT_FORWARD_XINTERFACE2( VCLXSpinButton, VCLXWindow, VCLXSpinButton_Base ) + + //-------------------------------------------------------------------- + IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXSpinButton, VCLXWindow, VCLXSpinButton_Base ) + + //-------------------------------------------------------------------- + void SAL_CALL VCLXSpinButton::dispose( ) throw(RuntimeException) + { + { + ::vos::OGuard aGuard( GetMutex() ); + + EventObject aDisposeEvent; + aDisposeEvent.Source = *this; + maAdjustmentListeners.disposeAndClear( aDisposeEvent ); + } + + VCLXWindow::dispose(); + } + + //-------------------------------------------------------------------- + void SAL_CALL VCLXSpinButton::addAdjustmentListener( const Reference< XAdjustmentListener >& listener ) throw (RuntimeException) + { + if ( listener.is() ) + maAdjustmentListeners.addInterface( listener ); + } + + //-------------------------------------------------------------------- + void SAL_CALL VCLXSpinButton::removeAdjustmentListener( const Reference< XAdjustmentListener >& listener ) throw (RuntimeException) + { + if ( listener.is() ) + maAdjustmentListeners.removeInterface( listener ); + } + + namespace + { + typedef void (SpinButton::*SetSpinButtonValue) (long); + typedef long (SpinButton::*GetSpinButtonValue) (void) const; + + //................................................................ + void lcl_setSpinButtonValue( ::vos::IMutex& _rMutex, Window* _pWindow, SetSpinButtonValue _pSetter, sal_Int32 _nValue ) + { + ::vos::OGuard aGuard( _rMutex ); + + SpinButton* pSpinButton = static_cast< SpinButton* >( _pWindow ); + if ( pSpinButton ) + (pSpinButton->*_pSetter)( _nValue ); + } + + //................................................................ + sal_Int32 lcl_getSpinButtonValue( ::vos::IMutex& _rMutex, const Window* _pWindow, GetSpinButtonValue _pGetter ) + { + ::vos::OGuard aGuard( _rMutex ); + + sal_Int32 nValue = 0; + + const SpinButton* pSpinButton = static_cast< const SpinButton* >( _pWindow ); + if ( pSpinButton ) + nValue = (pSpinButton->*_pGetter)( ); + return nValue; + } + } + + //-------------------------------------------------------------------- + void SAL_CALL VCLXSpinButton::setValue( sal_Int32 n ) throw (RuntimeException) + { + lcl_setSpinButtonValue( GetMutex(), GetWindow(), &SpinButton::SetValue, n ); + } + + //-------------------------------------------------------------------- + void SAL_CALL VCLXSpinButton::setValues( sal_Int32 minValue, sal_Int32 maxValue, sal_Int32 currentValue ) throw (RuntimeException) + { + ::vos::OGuard aGuard( GetMutex() ); + + setMinimum( minValue ); + setMaximum( maxValue ); + setValue( currentValue ); + } + + //-------------------------------------------------------------------- + sal_Int32 SAL_CALL VCLXSpinButton::getValue( ) throw (RuntimeException) + { + return lcl_getSpinButtonValue( GetMutex(), GetWindow(), &SpinButton::GetValue ); + } + + //-------------------------------------------------------------------- + void SAL_CALL VCLXSpinButton::setMinimum( sal_Int32 minValue ) throw (RuntimeException) + { + lcl_setSpinButtonValue( GetMutex(), GetWindow(), &SpinButton::SetRangeMin, minValue ); + } + + //-------------------------------------------------------------------- + void SAL_CALL VCLXSpinButton::setMaximum( sal_Int32 maxValue ) throw (RuntimeException) + { + lcl_setSpinButtonValue( GetMutex(), GetWindow(), &SpinButton::SetRangeMax, maxValue ); + } + + //-------------------------------------------------------------------- + sal_Int32 SAL_CALL VCLXSpinButton::getMinimum( ) throw (RuntimeException) + { + return lcl_getSpinButtonValue( GetMutex(), GetWindow(), &SpinButton::GetRangeMin ); + } + + //-------------------------------------------------------------------- + sal_Int32 SAL_CALL VCLXSpinButton::getMaximum( ) throw (RuntimeException) + { + return lcl_getSpinButtonValue( GetMutex(), GetWindow(), &SpinButton::GetRangeMax ); + } + + //-------------------------------------------------------------------- + void SAL_CALL VCLXSpinButton::setSpinIncrement( sal_Int32 spinIncrement ) throw (RuntimeException) + { + lcl_setSpinButtonValue( GetMutex(), GetWindow(), &SpinButton::SetValueStep, spinIncrement ); + } + + //-------------------------------------------------------------------- + sal_Int32 SAL_CALL VCLXSpinButton::getSpinIncrement( ) throw (RuntimeException) + { + return lcl_getSpinButtonValue( GetMutex(), GetWindow(), &SpinButton::GetValueStep ); + } + + //-------------------------------------------------------------------- + void SAL_CALL VCLXSpinButton::setOrientation( sal_Int32 orientation ) throw (NoSupportException, RuntimeException) + { + ::vos::OGuard aGuard( GetMutex() ); + + lcl_modifyStyle( GetWindow(), WB_HSCROLL, orientation == ScrollBarOrientation::HORIZONTAL ); + } + + //-------------------------------------------------------------------- + sal_Int32 SAL_CALL VCLXSpinButton::getOrientation( ) throw (RuntimeException) + { + return ( 0 != ( GetWindow()->GetStyle() & WB_HSCROLL ) ) + ? ScrollBarOrientation::HORIZONTAL + : ScrollBarOrientation::VERTICAL; + } + + //-------------------------------------------------------------------- + void VCLXSpinButton::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) + { + ::vos::OClearableGuard aGuard( GetMutex() ); + Reference< XSpinValue > xKeepAlive( this ); + SpinButton* pSpinButton = static_cast< SpinButton* >( GetWindow() ); + if ( !pSpinButton ) + return; + + switch ( _rVclWindowEvent.GetId() ) + { + case VCLEVENT_SPINBUTTON_UP: + case VCLEVENT_SPINBUTTON_DOWN: + if ( maAdjustmentListeners.getLength() ) + { + AdjustmentEvent aEvent; + aEvent.Source = *this; + aEvent.Value = pSpinButton->GetValue(); + + aGuard.clear(); + maAdjustmentListeners.adjustmentValueChanged( aEvent ); + } + break; + + default: + xKeepAlive.clear(); + aGuard.clear(); + VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); + break; + } + } + + //-------------------------------------------------------------------- + void SAL_CALL VCLXSpinButton::setProperty( const ::rtl::OUString& PropertyName, const Any& Value ) throw(RuntimeException) + { + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int32 nValue = 0; + sal_Bool bIsLongValue = ( Value >>= nValue ); + + if ( GetWindow() ) + { + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) + { + case BASEPROPERTY_BACKGROUNDCOLOR: + // the default implementation of the base class doesn't work here, since our + // interpretation for this property is slightly different + setButtonLikeFaceColor( GetWindow(), Value); + break; + + case BASEPROPERTY_SPINVALUE: + if ( bIsLongValue ) + setValue( nValue ); + break; + + case BASEPROPERTY_SPINVALUE_MIN: + if ( bIsLongValue ) + setMinimum( nValue ); + break; + + case BASEPROPERTY_SPINVALUE_MAX: + if ( bIsLongValue ) + setMaximum( nValue ); + break; + + case BASEPROPERTY_SPININCREMENT: + if ( bIsLongValue ) + setSpinIncrement( nValue ); + break; + + case BASEPROPERTY_ORIENTATION: + if ( bIsLongValue ) + lcl_modifyStyle( GetWindow(), WB_HSCROLL, nValue == ScrollBarOrientation::HORIZONTAL ); + break; + + default: + VCLXWindow::setProperty( PropertyName, Value ); + } + } + } + + //-------------------------------------------------------------------- + Any SAL_CALL VCLXSpinButton::getProperty( const ::rtl::OUString& PropertyName ) throw(RuntimeException) + { + ::vos::OGuard aGuard( GetMutex() ); + + Any aReturn; + + if ( GetWindow() ) + { + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) + { + case BASEPROPERTY_BACKGROUNDCOLOR: + // the default implementation of the base class doesn't work here, since our + // interpretation for this property is slightly different + aReturn = getButtonLikeFaceColor( GetWindow() ); + break; + + case BASEPROPERTY_SPINVALUE: + aReturn <<= (sal_Int32)getValue( ); + break; + + case BASEPROPERTY_SPINVALUE_MIN: + aReturn <<= (sal_Int32)getMinimum( ); + break; + + case BASEPROPERTY_SPINVALUE_MAX: + aReturn <<= (sal_Int32)getMaximum( ); + break; + + case BASEPROPERTY_SPININCREMENT: + aReturn <<= (sal_Int32)getSpinIncrement( ); + break; + + case BASEPROPERTY_ORIENTATION: + aReturn <<= (sal_Int32) + ( ( 0 != ( GetWindow()->GetStyle() & WB_HSCROLL ) ) + ? ScrollBarOrientation::HORIZONTAL + : ScrollBarOrientation::VERTICAL + ); + break; + + default: + aReturn = VCLXWindow::getProperty( PropertyName ); + } + } + return aReturn; + } + +//........................................................................ +} // namespace toolkit +//........................................................................ diff --git a/toolkit/source/awt/vclxsplitter.cxx b/toolkit/source/awt/vclxsplitter.cxx new file mode 100644 index 000000000000..07fcf96cb813 --- /dev/null +++ b/toolkit/source/awt/vclxsplitter.cxx @@ -0,0 +1,245 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#include "vclxsplitter.hxx" + +#include <assert.h> +#include <com/sun/star/awt/PosSize.hpp> +#include <sal/macros.h> +#include <toolkit/helper/property.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <vcl/split.hxx> + +#include "forward.hxx" + +namespace layoutimpl +{ + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star; + +VCLXSplitter::ChildProps::ChildProps( VCLXSplitter::ChildData *pData ) +{ + addProp( RTL_CONSTASCII_USTRINGPARAM( "Shrink" ), + ::getCppuType( static_cast< const rtl::OUString* >( NULL ) ), + &(pData->mbShrink) ); +} + +VCLXSplitter::ChildData::ChildData( uno::Reference< awt::XLayoutConstrains > const& xChild ) + : Box_Base::ChildData( xChild ) + , mbShrink( false ) +{ +} + +VCLXSplitter::ChildData* +VCLXSplitter::createChild( uno::Reference< awt::XLayoutConstrains > const& xChild ) +{ + return new ChildData( xChild ); +} + +VCLXSplitter::ChildProps* +VCLXSplitter::createChildProps( Box_Base::ChildData *pData ) +{ + return new ChildProps( static_cast<VCLXSplitter::ChildData*> ( pData ) ); +} + + +DBG_NAME( VCLXSplitter ); + +VCLXSplitter::VCLXSplitter( bool bHorizontal ) + : VCLXWindow() + , Box_Base() +{ + DBG_CTOR( VCLXSplitter, NULL ); + mnHandleRatio = 0.5; + mbHandlePressed = false; + mbHorizontal = bHorizontal; + mpSplitter = NULL; +} + +VCLXSplitter::~VCLXSplitter() +{ + DBG_DTOR( VCLXSplitter, NULL ); +} + +IMPLEMENT_2_FORWARD_XINTERFACE1( VCLXSplitter, VCLXWindow, Container ); + +IMPLEMENT_FORWARD_XTYPEPROVIDER1( VCLXSplitter, VCLXWindow ); + +VCLXSplitter::ChildData* +VCLXSplitter::getChild( int i ) +{ + if ( maChildren.size() && i == 0 ) + return static_cast<VCLXSplitter::ChildData*>( maChildren.front() ); + else if ( maChildren.size() > 1 && i == 1 ) + return static_cast<VCLXSplitter::ChildData*>( maChildren.back() ); + return 0; +} + +void SAL_CALL VCLXSplitter::dispose() throw(RuntimeException) +{ + { + ::vos::OGuard aGuard( GetMutex() ); + + EventObject aDisposeEvent; + aDisposeEvent.Source = W3K_EXPLICIT_CAST (*this); +// maTabListeners.disposeAndClear( aDisposeEvent ); + } + + VCLXWindow::dispose(); +} + +void VCLXSplitter::ensureSplitter() +{ + if ( !mpSplitter ) + { + mpSplitter = new Splitter( GetWindow() , mbHorizontal ? WB_HORZ : WB_VERT ); + mpSplitter->Show(); + mpSplitter->SetEndSplitHdl( LINK( this, VCLXSplitter, HandleMovedHdl ) ); + } +} + +void SAL_CALL VCLXSplitter::addChild( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains > &xChild ) + throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::awt::MaxChildrenException) +{ + if ( maChildren.size() == 2 ) + throw css::awt::MaxChildrenException(); + Box_Base::addChild( xChild ); +} + +void SAL_CALL VCLXSplitter::allocateArea( + const ::com::sun::star::awt::Rectangle &rArea ) + throw (::com::sun::star::uno::RuntimeException) +{ + ensureSplitter(); // shouldn't be needed... + getMinimumSize(); + int splitDiff; + if ( mbHorizontal ) + splitDiff = rArea.Width - maAllocation.Width; + else + splitDiff = rArea.Height - maAllocation.Height; + + assert( mpSplitter ); + if ( splitDiff ) + mpSplitter->SetSplitPosPixel( mpSplitter->GetSplitPosPixel() + splitDiff/2 ); + + maAllocation = rArea; + int width = mbHorizontal ? rArea.Width : rArea.Height; + int splitLen = 2; + int splitPos = mpSplitter->GetSplitPosPixel(); + setPosSize( rArea.X, rArea.Y, rArea.Width, rArea.Height, PosSize::POSSIZE ); + if ( mbHorizontal ) + mpSplitter->SetPosSizePixel( splitPos, 0, splitLen, rArea.Height, PosSize::POSSIZE ); + else + mpSplitter->SetPosSizePixel( 0, splitPos, rArea.Width, splitLen, PosSize::POSSIZE ); + mpSplitter->SetDragRectPixel( ::Rectangle( 0, 0, rArea.Width, rArea.Height ) ); + int leftWidth = splitPos; + int rightWidth = width - splitPos; + + if ( getChild( 0 ) && getChild( 0 )->mxChild.is() ) + { + awt::Rectangle childRect( 0, 0, rArea.Width, rArea.Height ); + + if ( mbHorizontal ) + childRect.Width = leftWidth - 2; + else + childRect.Height = leftWidth - 2; + allocateChildAt( getChild( 0 )->mxChild, childRect ); + } + if ( getChild( 0 ) && getChild( 0 )->mxChild.is() ) + { + awt::Rectangle childRect( 0, 0, rArea.Width, rArea.Height ); + + if ( mbHorizontal ) + { + childRect.X += leftWidth + splitLen + 2; + childRect.Width = rightWidth; + } + else + { + childRect.Y += leftWidth + splitLen + 2; + childRect.Height = rightWidth; + } + allocateChildAt( getChild( 1 )->mxChild, childRect ); + } +} + +::com::sun::star::awt::Size SAL_CALL VCLXSplitter::getMinimumSize() + throw(::com::sun::star::uno::RuntimeException) +{ + ensureSplitter(); + + awt::Size size( mbHorizontal ? 2 : 0, mbHorizontal ? 0 : 2 ); + for ( unsigned int i = 0; i < 2; i++ ) + { + if ( getChild( i ) && getChild( i )->mxChild.is() ) + { + awt::Size childSize = getChild( i )->mxChild->getMinimumSize(); + if ( mbHorizontal ) + { + size.Width += childSize.Width; + size.Height = SAL_MAX( size.Height, childSize.Height ); + } + else + { + size.Width = SAL_MAX( size.Width, childSize.Width ); + size.Height += childSize.Height; + } + } + } + + maRequisition = size; + return size; +} + +void VCLXSplitter::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) +{ + VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); +} + +void SAL_CALL VCLXSplitter::setProperty( const ::rtl::OUString& PropertyName, const Any &Value ) throw(RuntimeException) +{ + VCLXWindow::setProperty( PropertyName, Value ); +} + +Any SAL_CALL VCLXSplitter::getProperty( const ::rtl::OUString& PropertyName ) throw(RuntimeException) +{ + return VCLXWindow::getProperty( PropertyName ); +} + +IMPL_LINK( VCLXSplitter, HandleMovedHdl, Splitter *, pSplitter ) +{ + (void) pSplitter; + forceRecalc(); + return 0; +} + +} // namespace layoutimpl diff --git a/toolkit/source/awt/vclxsplitter.hxx b/toolkit/source/awt/vclxsplitter.hxx new file mode 100644 index 000000000000..69be466e6be8 --- /dev/null +++ b/toolkit/source/awt/vclxsplitter.hxx @@ -0,0 +1,121 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifndef LAYOUT_AWT_VCLXSPLITTER_HXX +#define LAYOUT_AWT_VCLXSPLITTER_HXX + +#include <com/sun/star/awt/MaxChildrenException.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <comphelper/uno3.hxx> +#include <layout/core/box-base.hxx> +#include <toolkit/awt/vclxwindow.hxx> + +class Splitter; + +namespace layoutimpl +{ + +class VCLXSplitter :public VCLXWindow + ,public Box_Base +{ +private: + VCLXSplitter( const VCLXSplitter& ); // never implemented + VCLXSplitter& operator=( const VCLXSplitter& ); // never implemented + +public: + VCLXSplitter( bool bHorizontal ); + +protected: + ~VCLXSplitter(); + + // XInterface + DECLARE_XINTERFACE() + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XComponent + void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::awt::XLayoutContainer + virtual void SAL_CALL addChild( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains >& Child ) + throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::awt::MaxChildrenException); + + virtual void SAL_CALL allocateArea( const ::com::sun::star::awt::Rectangle &rArea ) + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::awt::Size SAL_CALL getMinimumSize() + throw(::com::sun::star::uno::RuntimeException); + + // unimplemented: + virtual sal_Bool SAL_CALL hasHeightForWidth() + throw(css::uno::RuntimeException) + { return false; } + virtual sal_Int32 SAL_CALL getHeightForWidth( sal_Int32 /*nWidth*/ ) + throw(css::uno::RuntimeException) + { return maRequisition.Height; } + + // VclWindowPeer + virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); + + // VCLXWindow + void ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ); + +public: + // Maps page ids to child references + struct ChildData : public Box_Base::ChildData + { + sal_Bool mbShrink; + ChildData( css::uno::Reference< css::awt::XLayoutConstrains > const& xChild ); + }; + + struct ChildProps : public Box_Base::ChildProps + { + ChildProps( VCLXSplitter::ChildData *pData ); + }; + +protected: + + ChildData *createChild( css::uno::Reference< css::awt::XLayoutConstrains > const& xChild ); + ChildProps *createChildProps( Box_Base::ChildData* pData ); + + ChildData* getChild( int i ); + + float mnHandleRatio; + bool mbHandlePressed; + + DECL_LINK( HandleMovedHdl, Splitter* ); + bool mbHorizontal; + Splitter *mpSplitter; + void ensureSplitter(); +}; + +} // namespace layoutimpl + +#endif /* LAYOUT_AWT_VCLXSPLITTER_HXX */ diff --git a/toolkit/source/awt/vclxsystemdependentwindow.cxx b/toolkit/source/awt/vclxsystemdependentwindow.cxx new file mode 100644 index 000000000000..a0d8febb44f0 --- /dev/null +++ b/toolkit/source/awt/vclxsystemdependentwindow.cxx @@ -0,0 +1,124 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + + +#include <com/sun/star/lang/SystemDependent.hpp> + +#if defined UNX && ! defined QUARTZ && ! defined _COM_SUN_STAR_AWT_SYSTEMDEPENDENTXWINDOW_HPP_ +#include <com/sun/star/awt/SystemDependentXWindow.hpp> +#endif + +#include <toolkit/awt/vclxsystemdependentwindow.hxx> +#include <toolkit/helper/macros.hxx> +#include <cppuhelper/typeprovider.hxx> + +#ifdef WNT +#include <tools/prewin.h> +#include <windows.h> +#include <tools/postwin.h> +#elif defined ( QUARTZ ) +#include "premac.h" +#include <Cocoa/Cocoa.h> +#include "postmac.h" +#endif + +#include <vcl/syschild.hxx> +#include <vcl/sysdata.hxx> + +// ---------------------------------------------------- +// class VCLXSystemDependentWindow +// ---------------------------------------------------- +VCLXSystemDependentWindow::VCLXSystemDependentWindow() +{ +} + +VCLXSystemDependentWindow::~VCLXSystemDependentWindow() +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXSystemDependentWindow::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XSystemDependentWindowPeer*, this ) ); + return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXSystemDependentWindow ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSystemDependentWindowPeer>* ) NULL ), + VCLXWindow::getTypes() +IMPL_XTYPEPROVIDER_END + +::com::sun::star::uno::Any VCLXSystemDependentWindow::getWindowHandle( const ::com::sun::star::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 SystemType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + // TODO, check the process id + ::com::sun::star::uno::Any aRet; + Window* pWindow = GetWindow(); + if ( pWindow ) + { + const SystemEnvData* pSysData = ((SystemChildWindow *)pWindow)->GetSystemData(); + if( pSysData ) + { +#if (defined WNT) + if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_WIN32 ) + { + aRet <<= (sal_Int32)pSysData->hWnd; + } +#elif (defined OS2) + if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_OS2 ) + { + aRet <<= (sal_Int32)pSysData->hWnd; + } +#elif (defined QUARTZ) + if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_MAC ) + { + aRet <<= (sal_IntPtr)pSysData->pView; + } +#elif (defined UNX) + if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_XWINDOW ) + { + ::com::sun::star::awt::SystemDependentXWindow aSD; + aSD.DisplayPointer = sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_IntPtr >(pSysData->pDisplay)); + aSD.WindowHandle = pSysData->aWindow; + aRet <<= aSD; + } +#endif + } + } + return aRet; +} + + + + + diff --git a/toolkit/source/awt/vclxtabcontrol.cxx b/toolkit/source/awt/vclxtabcontrol.cxx new file mode 100644 index 000000000000..1dfd52678957 --- /dev/null +++ b/toolkit/source/awt/vclxtabcontrol.cxx @@ -0,0 +1,540 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#include "vclxtabcontrol.hxx" + +#include <com/sun/star/awt/PosSize.hpp> +#include <sal/macros.h> +#include <toolkit/helper/property.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <vcl/tabctrl.hxx> +#include <vcl/tabpage.hxx> + +#include "forward.hxx" + +namespace layoutimpl +{ + +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star; + +VCLXTabControl::ChildProps::ChildProps( VCLXTabControl::ChildData *pData ) +{ + addProp( RTL_CONSTASCII_USTRINGPARAM( "Title" ), + ::getCppuType( static_cast< const rtl::OUString* >( NULL ) ), + &(pData->maTitle) ); +} + +VCLXTabControl::ChildData::ChildData( uno::Reference< awt::XLayoutConstrains > const& xChild ) + : Box_Base::ChildData( xChild ) + , maTitle() +{ +} + +VCLXTabControl::ChildData* +VCLXTabControl::createChild( uno::Reference< awt::XLayoutConstrains > const& xChild ) +{ + return new ChildData( xChild ); +} + +VCLXTabControl::ChildProps* +VCLXTabControl::createChildProps( Box_Base::ChildData *pData ) +{ + return new ChildProps( static_cast<VCLXTabControl::ChildData*> ( pData ) ); +} + +DBG_NAME( VCLXTabControl ); + +#if !defined (__GNUC__) +#define __PRETTY_FUNCTION__ __FUNCTION__ +#endif /* !__GNUC__ */ + +VCLXTabControl::VCLXTabControl() + : VCLXWindow() + , VCLXTabControl_Base() + , Box_Base() + , mTabId (1) + , bRealized (false) +{ +#ifndef __SUNPRO_CC + OSL_TRACE ("\n********%s:%x", __PRETTY_FUNCTION__, this); +#endif + DBG_CTOR( VCLXTabControl, NULL ); +} + +VCLXTabControl::~VCLXTabControl() +{ + DBG_DTOR( VCLXTabControl, NULL ); +} + +IMPLEMENT_2_FORWARD_XINTERFACE2( VCLXTabControl, VCLXWindow, Container, VCLXTabControl_Base ); + +IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXTabControl, VCLXWindow, VCLXTabControl_Base ); + +void SAL_CALL VCLXTabControl::dispose( ) throw(uno::RuntimeException) +{ + { + ::vos::OGuard aGuard( GetMutex() ); + + EventObject aDisposeEvent; + aDisposeEvent.Source = W3K_EXPLICIT_CAST (*this); +// maTabListeners.disposeAndClear( aDisposeEvent ); + } + + VCLXWindow::dispose(); +} + +#if 0 +void SAL_CALL VCLXTabControl::addTabListener( const Reference< XTabListener >& listener ) throw (uno::RuntimeException) +{ + if ( listener.is() ) + maTabListeners.addInterface( listener ); +} + +void SAL_CALL VCLXTabControl::removeTabListener( const Reference< XTabListener >& listener ) throw (uno::RuntimeException) +{ + if ( listener.is() ) + maTabListeners.removeInterface( listener ); +} +#endif + +TabControl *VCLXTabControl::getTabControl() const throw (uno::RuntimeException) +{ + TabControl *pTabControl = static_cast< TabControl* >( GetWindow() ); + if ( pTabControl ) + return pTabControl; + throw uno::RuntimeException(); +} + +sal_Int32 SAL_CALL VCLXTabControl::insertTab() throw (uno::RuntimeException) +{ + TabControl *pTabControl = getTabControl(); + USHORT id = sal::static_int_cast< USHORT >( mTabId++ ); + rtl::OUString title (RTL_CONSTASCII_USTRINGPARAM( "" ) ); + pTabControl->InsertPage( id, title.getStr(), TAB_APPEND ); + pTabControl->SetTabPage( id, new TabPage( pTabControl ) ); + return id; +} + +void SAL_CALL VCLXTabControl::removeTab( sal_Int32 ID ) throw (uno::RuntimeException, IndexOutOfBoundsException) +{ + TabControl *pTabControl = getTabControl(); + if ( pTabControl->GetTabPage( sal::static_int_cast< USHORT >( ID ) ) == NULL ) + throw IndexOutOfBoundsException(); + pTabControl->RemovePage( sal::static_int_cast< USHORT >( ID ) ); +} + +void SAL_CALL VCLXTabControl::activateTab( sal_Int32 ID ) throw (uno::RuntimeException, IndexOutOfBoundsException) +{ + TabControl *pTabControl = getTabControl(); + if ( pTabControl->GetTabPage( sal::static_int_cast< USHORT >( ID ) ) == NULL ) + throw IndexOutOfBoundsException(); + pTabControl->SelectTabPage( sal::static_int_cast< USHORT >( ID ) ); +} + +sal_Int32 SAL_CALL VCLXTabControl::getActiveTabID() throw (uno::RuntimeException) +{ + return getTabControl()->GetCurPageId( ); +} + +void SAL_CALL VCLXTabControl::addTabListener( const uno::Reference< awt::XTabListener >& xListener ) throw (uno::RuntimeException) +{ + for ( std::list< uno::Reference + < awt::XTabListener > >::const_iterator it + = mxTabListeners.begin(); it != mxTabListeners.end(); it++ ) + { + if ( *it == xListener ) + // already added + return; + } + mxTabListeners.push_back( xListener ); +} + +void SAL_CALL VCLXTabControl::removeTabListener( const uno::Reference< awt::XTabListener >& xListener ) throw (uno::RuntimeException) +{ + for ( std::list< uno::Reference + < awt::XTabListener > >::iterator it + = mxTabListeners.begin(); it != mxTabListeners.end(); it++ ) + { + if ( *it == xListener ) + { + mxTabListeners.erase( it ); + break; + } + } +} + +void SAL_CALL VCLXTabControl::setTabProps( sal_Int32 ID, const uno::Sequence< NamedValue >& Properties ) throw (uno::RuntimeException, IndexOutOfBoundsException) +{ + TabControl *pTabControl = getTabControl(); + if ( pTabControl->GetTabPage( sal::static_int_cast< USHORT >( ID ) ) == NULL ) + throw IndexOutOfBoundsException(); + + for ( int i = 0; i < Properties.getLength(); i++ ) + { + const rtl::OUString &name = Properties[i].Name; + const uno::Any &value = Properties[i].Value; + + if ( name == rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ) ) + { + rtl::OUString title = value.get<rtl::OUString>(); + pTabControl->SetPageText( sal::static_int_cast< USHORT >( ID ), title.getStr() ); + } + } +} + +uno::Sequence< NamedValue > SAL_CALL VCLXTabControl::getTabProps( sal_Int32 ID ) + throw (IndexOutOfBoundsException, uno::RuntimeException) +{ + TabControl *pTabControl = getTabControl(); + if ( pTabControl->GetTabPage( sal::static_int_cast< USHORT >( ID ) ) == NULL ) + throw IndexOutOfBoundsException(); + +#define ADD_PROP( seq, i, name, val ) { \ + NamedValue value; \ + value.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( name ) ); \ + value.Value = uno::makeAny( val ); \ + seq[i] = value; \ + } + + uno::Sequence< NamedValue > props( 2 ); + ADD_PROP( props, 0, "Title", rtl::OUString( pTabControl->GetPageText( sal::static_int_cast< USHORT >( ID ) ) ) ); + ADD_PROP( props, 1, "Position", pTabControl->GetPagePos( sal::static_int_cast< USHORT >( ID ) ) ); +#undef ADD_PROP + return props; +} + +// TODO: draw tab border here +void SAL_CALL VCLXTabControl::draw( sal_Int32 nX, sal_Int32 nY ) throw(uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + TabControl *pTabControl = getTabControl(); + TabPage *pTabPage = pTabControl->GetTabPage( sal::static_int_cast< USHORT >( getActiveTabID() ) ); + if ( pTabPage ) + { + ::Point aPos( nX, nY ); + ::Size aSize = pTabPage->GetSizePixel(); + + OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); + aPos = pDev->PixelToLogic( aPos ); + aSize = pDev->PixelToLogic( aSize ); + + pTabPage->Draw( pDev, aPos, aSize, 0 ); + } + + VCLXWindow::draw( nX, nY ); +} + +void VCLXTabControl::AddChild (uno::Reference< awt::XLayoutConstrains > const& xChild) + +{ +#ifndef __SUNPRO_CC + OSL_TRACE ("%s: children: %d", __PRETTY_FUNCTION__, maChildren.size ()); +#endif + mIdMap[ xChild ] = mTabId++; + Box_Base::AddChild( xChild ); +#ifndef __SUNPRO_CC + OSL_TRACE ("%s: children: %d", __PRETTY_FUNCTION__, maChildren.size ()); +#endif +} + +void SAL_CALL VCLXTabControl::addChild( + const uno::Reference< awt::XLayoutConstrains > &xChild ) + throw (uno::RuntimeException, awt::MaxChildrenException) +{ + mIdMap[ xChild ] = insertTab(); + Box_Base::addChild( xChild ); +} + +void SAL_CALL VCLXTabControl::removeChild( const uno::Reference< awt::XLayoutConstrains > &xChild ) + throw (uno::RuntimeException) +{ + removeTab( mIdMap[xChild] ); + mIdMap[ xChild ] = -1; + Box_Base::removeChild( xChild ); +} + +static void setChildrenVisible( uno::Reference < awt::XLayoutConstrains > xChild, bool visible ) +{ + uno::Reference< awt::XWindow > xWin( xChild, uno::UNO_QUERY); + if ( xWin.is() ) + { + xWin->setVisible( visible ); + } + + uno::Reference < awt::XLayoutContainer > xCont( xChild, uno::UNO_QUERY ); + if ( xCont.is()) + { + uno::Sequence< uno::Reference < awt::XLayoutConstrains > > children = xCont->getChildren(); + for ( int i = 0; i < children.getLength(); i++ ) + { + setChildrenVisible( children[i], visible ); + } + } +} + +void SAL_CALL VCLXTabControl::allocateArea (awt::Rectangle const &area) + throw (uno::RuntimeException) +{ +#ifndef __SUNPRO_CC + OSL_TRACE ("\n%s", __PRETTY_FUNCTION__); +#endif + maAllocation = area; + + TabControl *pTabControl = getTabControl(); + +// FIXME: this is wrong. We just want to set tab controls pos/size for +// the tabs menu, otherwise, it gets events that should go to children +// (I guess we could solve this by making the tabcontrol as the actual +// XWindow parent of its children, when importing...) Not sure about +// TabPage drawing... That doesn't work on gtk+; just ignoring that. +// LATER: Nah, the proper fix is to get the XWindow hierarchy +// straight. + +#if 0 + setPosSize( area.X, area.Y, area.Width, area.Height, awt::PosSize::POSSIZE ); +#else + awt::Size currentSize = getSize(); + awt::Size requestedSize (area.Width, area.Height); +// requestedSize.Height = getHeightForWidth( area.Width ); + + awt::Size minimumSize = getMinimumSize(); + if (requestedSize.Width < minimumSize.Width) + requestedSize.Width = minimumSize.Width; + if (requestedSize.Height < minimumSize.Height) + requestedSize.Height = minimumSize.Height; + + Size pageSize = static_cast<TabControl*> (GetWindow ())->GetTabPageSizePixel (); + awt::Size pageBasedSize (0, 0); + pageBasedSize.Width = pageSize.Width (); + pageBasedSize.Height = pageSize.Height (); + + const int wc = 0; + const int hc = 20; + static int pwc = 0; + static int phc = 40; + + if (requestedSize.Width < pageBasedSize.Width) + requestedSize.Width = pageBasedSize.Width + wc; + if (requestedSize.Height < pageBasedSize.Height) + requestedSize.Height = pageBasedSize.Height + hc; + + Size windowSize = GetWindow()->GetSizePixel(); + Window *parent = GetWindow()->GetParent(); + Size parentSize = parent->GetSizePixel(); + +#ifndef __SUNPRO_CC +#ifdef GCC_MAJOR + OSL_TRACE ("\n%s", __PRETTY_FUNCTION__); +#endif /* GCC_MAJOR */ + OSL_TRACE ("%s: cursize: %d ,%d", __FUNCTION__, currentSize.Width, currentSize.Height ); + OSL_TRACE ("%s: area: %d, %d", __FUNCTION__, area.Width, area.Height ); + OSL_TRACE ("%s: minimum: %d, %d", __FUNCTION__, minimumSize.Width, minimumSize.Height ); + OSL_TRACE ("%s: requestedSize: %d, %d", __FUNCTION__, requestedSize.Width, requestedSize.Height ); + OSL_TRACE ("%s: pageBasedSize: %d, %d", __FUNCTION__, pageBasedSize.Width, pageBasedSize.Height ); + + //OSL_TRACE ("%s: parent: %d, %d", __FUNCTION__, parentSize.Width(), parentSize.Height() ); + //OSL_TRACE ("%s: window: %d, %d", __FUNCTION__, windowSize.Width(), windowSize.Height() ); +#endif + + //bRealized = false; + if (!bRealized) + { + setPosSize( area.X, area.Y, requestedSize.Width, requestedSize.Height, awt::PosSize::POSSIZE ); + bRealized = true; + } + else + { + if ( requestedSize.Width > currentSize.Width + 10) + setPosSize( 0, 0, requestedSize.Width, 0, awt::PosSize::WIDTH ); + if ( requestedSize.Height > currentSize.Height + 10) + setPosSize( 0, 0, 0, requestedSize.Height, awt::PosSize::HEIGHT ); + } +#endif + + if (pageBasedSize.Width > parentSize.Width () + || pageBasedSize.Height > parentSize.Height ()) + //parent->SetSizePixel ( Size (pageBasedSize.Width, pageBasedSize.Height)); + //parent->SetSizePixel ( Size (pageBasedSize.Width + pwc, pageBasedSize.Height + phc)); + parent->SetSizePixel ( Size (requestedSize.Width + pwc, requestedSize.Height + phc)); + + // FIXME: we can save cycles by setting visibility more sensibly. Having + // it here does makes it easier when changing tabs (just needs a recalc()) + unsigned i = 0; + for ( std::list<Box_Base::ChildData *>::const_iterator it + = maChildren.begin(); it != maChildren.end(); it++, i++ ) + { + ChildData *child = static_cast<VCLXTabControl::ChildData*> ( *it ); + uno::Reference + < awt::XLayoutConstrains > xChild( child->mxChild ); + if ( xChild.is() ) + { + uno::Reference< awt::XWindow > xWin( xChild, uno::UNO_QUERY ); + bool active = (i+1 == (unsigned) getActiveTabID()); + + // HACK: since our layout:: container don't implement XWindow, we have no easy + // way to set them invisible; lets just set all their children as such :P +#if 0 + if ( xWin.is() ) + xWin->setVisible( active ); +#else + setChildrenVisible( xChild, active ); +#endif + + if ( active ) + { + ::Rectangle label_rect = pTabControl->GetTabBounds( sal::static_int_cast< USHORT >( i+1 ) ); + ::Rectangle page_rect = pTabControl->GetTabPageBounds( sal::static_int_cast< USHORT >( i+1 ) ); + + awt::Rectangle childRect; + childRect.X = page_rect.Left(); + childRect.Y = SAL_MAX( label_rect.Bottom(), page_rect.Top() ); + childRect.Width = page_rect.Right() - page_rect.Left(); + childRect.Height = page_rect.Bottom() - childRect.Y; + + allocateChildAt( xChild, childRect ); + } + } + } +} + +awt::Size SAL_CALL VCLXTabControl::getMinimumSize() + throw(uno::RuntimeException) +{ + awt::Size requestedSize = VCLXWindow::getMinimumSize(); + awt::Size childrenSize( 0, 0 ); + + TabControl* pTabControl = static_cast< TabControl* >( GetWindow() ); + if ( !pTabControl ) + return requestedSize; + + // calculate size to accomodate all children + unsigned i = 0; + for ( std::list<Box_Base::ChildData *>::const_iterator it + = maChildren.begin(); it != maChildren.end(); it++, i++ ) + { + ChildData *child = static_cast<VCLXTabControl::ChildData*> ( *it ); + if ( child->mxChild.is() ) + { + // set the title prop here... + pTabControl->SetPageText( sal::static_int_cast< USHORT >( i+1 ), child->maTitle.getStr() ); + + awt::Size childSize( child->mxChild->getMinimumSize() ); + childrenSize.Width = SAL_MAX( childSize.Width, childrenSize.Width ); + childrenSize.Height = SAL_MAX( childSize.Height, childrenSize.Height ); + } + } + +#ifndef __SUNPRO_CC +#ifdef GCC_MAJOR + OSL_TRACE ("\n%s", __PRETTY_FUNCTION__); +#endif /* GCC_MAJOR */ + OSL_TRACE ("%s: children: %d", __FUNCTION__, i); + OSL_TRACE ("%s: childrenSize: %d, %d", __FUNCTION__, childrenSize.Width, childrenSize.Height ); +#endif + + requestedSize.Width += childrenSize.Width; + requestedSize.Height += childrenSize.Height + 20; + + maRequisition = requestedSize; + return requestedSize; +} + +void VCLXTabControl::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) +{ + ::vos::OClearableGuard aGuard( GetMutex() ); + TabControl* pTabControl = static_cast< TabControl* >( GetWindow() ); + if ( !pTabControl ) + return; + + switch ( _rVclWindowEvent.GetId() ) + { + case VCLEVENT_TABPAGE_ACTIVATE: + forceRecalc(); + case VCLEVENT_TABPAGE_DEACTIVATE: + case VCLEVENT_TABPAGE_INSERTED: + case VCLEVENT_TABPAGE_REMOVED: + case VCLEVENT_TABPAGE_REMOVEDALL: + case VCLEVENT_TABPAGE_PAGETEXTCHANGED: + { + ULONG page = (ULONG) _rVclWindowEvent.GetData(); + for ( std::list< uno::Reference + < awt::XTabListener > >::iterator it + = mxTabListeners.begin(); it != mxTabListeners.end(); it++) + { + uno::Reference + < awt::XTabListener > listener = *it; + + switch ( _rVclWindowEvent.GetId() ) + { + + case VCLEVENT_TABPAGE_ACTIVATE: + listener->activated( page ); + break; + case VCLEVENT_TABPAGE_DEACTIVATE: + listener->deactivated( page ); + break; + case VCLEVENT_TABPAGE_INSERTED: + listener->inserted( page ); + break; + case VCLEVENT_TABPAGE_REMOVED: + listener->removed( page ); + break; + case VCLEVENT_TABPAGE_REMOVEDALL: + for ( int i = 1; i < mTabId; i++) + { + if ( pTabControl->GetTabPage( sal::static_int_cast< USHORT >( i ) ) ) + listener->removed( i ); + } + break; + case VCLEVENT_TABPAGE_PAGETEXTCHANGED: + listener->changed( page, getTabProps( page ) ); + break; + } + } + break; + } + default: + aGuard.clear(); + VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); + break; + } +} + +void SAL_CALL VCLXTabControl::setProperty( const ::rtl::OUString& PropertyName, const uno::Any &Value ) throw(uno::RuntimeException) +{ + VCLXWindow::setProperty( PropertyName, Value ); +} + +uno::Any SAL_CALL VCLXTabControl::getProperty( const ::rtl::OUString& PropertyName ) throw(uno::RuntimeException) +{ + return VCLXWindow::getProperty( PropertyName ); +} + +} // namespace layoutimpl diff --git a/toolkit/source/awt/vclxtabcontrol.hxx b/toolkit/source/awt/vclxtabcontrol.hxx new file mode 100644 index 000000000000..8f5debf2626c --- /dev/null +++ b/toolkit/source/awt/vclxtabcontrol.hxx @@ -0,0 +1,144 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifndef LAYOUT_AWT_VCLXTABCONTROLLER_HXX +#define LAYOUT_AWT_VCLXTABCONTROLLER_HXX + +#include <com/sun/star/awt/XSimpleTabController.hpp> +#include <comphelper/uno3.hxx> +#include <layout/core/box-base.hxx> +#include <map> +#include <toolkit/awt/vclxwindow.hxx> + +class TabControl; + +namespace layoutimpl +{ + +typedef ::cppu::ImplHelper1 < ::com::sun::star::awt::XSimpleTabController + > VCLXTabControl_Base; + +class VCLXTabControl :public VCLXWindow + ,public VCLXTabControl_Base + ,public Box_Base +{ + int mTabId; + bool bRealized; + +public: + VCLXTabControl(); + + void AddChild (css::uno::Reference <css::awt::XLayoutConstrains> const &); + +protected: + ~VCLXTabControl(); + + // XInterface + DECLARE_XINTERFACE() + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XComponent + void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) throw (::com::sun::star::uno::RuntimeException); + + // XSimpleTabController + virtual ::sal_Int32 SAL_CALL insertTab() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeTab( ::sal_Int32 ID ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setTabProps( ::sal_Int32 ID, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Properties ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > SAL_CALL getTabProps( ::sal_Int32 ID ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL activateTab( ::sal_Int32 ID ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getActiveTabID() throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL addTabListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeTabListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::awt::XLayoutContainer + virtual void SAL_CALL addChild( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains >& Child ) + throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::awt::MaxChildrenException); + virtual void SAL_CALL removeChild( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains >& Child ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL allocateArea( const ::com::sun::star::awt::Rectangle &rArea ) + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::awt::Size SAL_CALL getMinimumSize() + throw(::com::sun::star::uno::RuntimeException); + + // unimplemented: + virtual sal_Bool SAL_CALL hasHeightForWidth() + throw(css::uno::RuntimeException) + { return false; } + virtual sal_Int32 SAL_CALL getHeightForWidth( sal_Int32 /*nWidth*/ ) + throw(css::uno::RuntimeException) + { return maRequisition.Height; } + + // VclWindowPeer + virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); + + // VCLXWindow + void ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ); + +public: + // Maps page ids to child references + struct ChildData : public Box_Base::ChildData + { + rtl::OUString maTitle; + ChildData( css::uno::Reference< css::awt::XLayoutConstrains > const& xChild ); + }; + + struct ChildProps : public Box_Base::ChildProps + { + ChildProps( VCLXTabControl::ChildData *pData ); + }; + +protected: + ChildData *createChild( css::uno::Reference< css::awt::XLayoutConstrains > const& xChild ); + ChildProps *createChildProps( Box_Base::ChildData* pData ); + + + std::map< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains >, sal_Int32 > mIdMap; + // FIXME: we might want to use a Multiplexer + std::list< ::com::sun::star::uno::Reference + < ::com::sun::star::awt::XTabListener > > mxTabListeners; + + inline TabControl *getTabControl() const throw (::com::sun::star::uno::RuntimeException); + +private: + VCLXTabControl( const VCLXTabControl& ); // never implemented + VCLXTabControl& operator=( const VCLXTabControl& ); // never implemented +}; + +} // namespace layoutimpl + +#endif /* LAYOUT_AWT_VCLXTABCONTROLLER_HXX */ diff --git a/toolkit/source/awt/vclxtabpage.cxx b/toolkit/source/awt/vclxtabpage.cxx new file mode 100644 index 000000000000..6523f7e98c5f --- /dev/null +++ b/toolkit/source/awt/vclxtabpage.cxx @@ -0,0 +1,156 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#include "vclxtabpage.hxx" +#include "forward.hxx" + +#include <com/sun/star/awt/PosSize.hpp> +#include <toolkit/helper/convert.hxx> +#include <vcl/tabpage.hxx> +#include <vcl/tabctrl.hxx> + +#if !defined (__GNUC__) +#define __PRETTY_FUNCTION__ __FUNCTION__ +#endif /* !__GNUC__ */ + +namespace layoutimpl +{ + +using namespace ::com::sun::star; + +// XInterface +IMPLEMENT_FORWARD_XINTERFACE2( VCLXTabPage, VCLXWindow, Bin ); + +// XTypeProvider +IMPLEMENT_FORWARD_XTYPEPROVIDER1( VCLXTabPage, VCLXWindow ); + +VCLXTabPage::VCLXTabPage( Window *p ) + : VCLXWindow() + , Bin() + , bRealized( false ) +{ + /* FIXME: before Window is set, setLabel, setProperty->setImage + * are silent no-ops. */ + p->SetComponentInterface( this ); +} + +VCLXTabPage::~VCLXTabPage() +{ +} + +void SAL_CALL VCLXTabPage::dispose() throw(uno::RuntimeException) +{ + { + ::vos::OGuard aGuard( GetMutex() ); + + lang::EventObject aDisposeEvent; + aDisposeEvent.Source = W3K_EXPLICIT_CAST (*this); + } + + VCLXWindow::dispose(); +} + +void SAL_CALL VCLXTabPage::allocateArea( awt::Rectangle const& area ) + throw (uno::RuntimeException) +{ + awt::Size currentSize = getSize(); + awt::Size requestedSize = getMinimumSize(); + requestedSize.Height = getHeightForWidth( area.Width ); + + if ( currentSize.Width > 0 && currentSize.Height > 0 + && requestedSize.Width > currentSize.Width ) + requestedSize.Width = currentSize.Width; + if ( currentSize.Width > 0 && currentSize.Height > 0 + && requestedSize.Height > currentSize.Height ) + requestedSize.Height = currentSize.Height; + + // FIXME: missing destructor? + if ( !GetWindow() ) + return; + + Size windowSize = GetWindow()->GetSizePixel(); + Window *parent = GetWindow()->GetParent(); + Size parentSize = parent->GetSizePixel(); + + Point pos = GetWindow()->GetPosPixel(); +#ifndef __SUNPRO_CC + OSL_TRACE ("\n%s", __PRETTY_FUNCTION__); + OSL_TRACE ("%s: curpos: %d ,%d", __FUNCTION__, pos.X(), pos.Y() ); + + OSL_TRACE ("%s: cursize: %d ,%d", __FUNCTION__, currentSize.Width, currentSize.Height ); + OSL_TRACE ("%s: area: %d, %d", __FUNCTION__, area.Width, area.Height ); + OSL_TRACE ("%s: requestedSize: %d, %d", __FUNCTION__, requestedSize.Width, requestedSize.Height ); + OSL_TRACE ("%s: parent: %d, %d", __FUNCTION__, parentSize.Width(), parentSize.Height() ); + OSL_TRACE ("%s: window: %d, %d", __FUNCTION__, windowSize.Width(), windowSize.Height() ); +#endif + +#if 0 + if (requestedSize.Width > parentSize.Width () + || requestedSize.Height > parentSize.Height ()) + { +#ifndef __SUNPRO_CC + OSL_TRACE ("%s: ***setting parent: %d, %d", __FUNCTION__, requestedSize.Width, requestedSize.Height ); +#endif + parent->SetSizePixel ( Size (requestedSize.Width, requestedSize.Height) ); + + if (Window *grand_parent = parent->GetParent ()) + grand_parent->SetSizePixel ( Size (requestedSize.Width, requestedSize.Height) ); + } +#endif + + if ( !bRealized ) + { + setPosSize( area.X, area.Y, requestedSize.Width, requestedSize.Height, awt::PosSize::SIZE ); + bRealized = true; + } + else + { + if ( requestedSize.Width > currentSize.Width + 10) + setPosSize( 0, 0, requestedSize.Width, 0, awt::PosSize::WIDTH ); + if ( requestedSize.Height > currentSize.Height + 10) + setPosSize( 0, 0, 0, requestedSize.Height, awt::PosSize::HEIGHT ); + } + + awt::Size newSize = getSize(); +#ifndef __SUNPRO_CC + OSL_TRACE ("%s: newSize: %d, %d", __FUNCTION__, newSize.Width, newSize.Height ); +#endif + maAllocation.Width = newSize.Width; + maAllocation.Height = newSize.Height; + + Bin::allocateArea( maAllocation ); +} + +awt::Size SAL_CALL VCLXTabPage::getMinimumSize() + throw(uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + return Bin::getMinimumSize(); +} + +} // namespace layoutimpl diff --git a/toolkit/source/awt/vclxtabpage.hxx b/toolkit/source/awt/vclxtabpage.hxx new file mode 100644 index 000000000000..215ee49c5716 --- /dev/null +++ b/toolkit/source/awt/vclxtabpage.hxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifndef LAYOUT_AWT_VCLXTABPAGE_HXX +#define LAYOUT_AWT_VCLXTABPAGE_HXX + +#include <toolkit/awt/vclxwindow.hxx> +#include <layout/core/bin.hxx> +#include <comphelper/uno3.hxx> + +namespace layoutimpl +{ + +namespace css = ::com::sun::star; + +class VCLXTabPage : public VCLXWindow + , public Bin +{ + bool bRealized; + +public: + VCLXTabPage( Window *p ); + + // XInterface + DECLARE_XINTERFACE() + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + +protected: + ~VCLXTabPage(); + + // XComponent + void SAL_CALL dispose() throw(css::uno::RuntimeException); + + // ::com::sun::star::awt::XLayoutContainer + virtual void SAL_CALL allocateArea( css::awt::Rectangle const& rArea ) + throw (css::uno::RuntimeException); + virtual css::awt::Size SAL_CALL getMinimumSize() + throw(css::uno::RuntimeException); + +private: + VCLXTabPage( VCLXTabPage const & ); + VCLXTabPage& operator=( VCLXTabPage const & ); +}; + +} // namespace layoutimpl + +#endif /* LAYOUT_AWT_VCLXTABPAGE_HXX */ diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx new file mode 100644 index 000000000000..2eeafa73d2d2 --- /dev/null +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -0,0 +1,1697 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> + +#ifndef _SVWIN_HXX +#include <tools/svwin.h> +#endif +#include <stdio.h> +#include <com/sun/star/awt/WindowAttribute.hpp> +#include <com/sun/star/awt/VclWindowPeerAttribute.hpp> +#include <com/sun/star/awt/WindowClass.hpp> +#include <com/sun/star/awt/MessageBoxButtons.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/SystemDependent.hpp> +#include <com/sun/star/awt/FocusEvent.hpp> +#include <com/sun/star/awt/KeyEvent.hpp> +#include <com/sun/star/awt/KeyModifier.hpp> +#include <com/sun/star/lang/EventObject.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/uno/XInterface.hpp> +#include <com/sun/star/beans/NamedValue.hpp> +#include <cppuhelper/typeprovider.hxx> +#include <osl/conditn.hxx> +#include <rtl/memory.h> +#include <rtl/uuid.h> +#include <rtl/process.h> + +#ifdef WNT +#include <tools/prewin.h> +#include <windows.h> +#include <tools/postwin.h> +#elif (defined QUARTZ) +#include "premac.h" +#include <Cocoa/Cocoa.h> +#include "postmac.h" +#endif +#include <vcl/sysdata.hxx> + +#include <toolkit/awt/vclxwindows.hxx> +#include <toolkit/awt/vclxsystemdependentwindow.hxx> +#include <toolkit/awt/vclxregion.hxx> +#include <toolkit/awt/vclxtoolkit.hxx> + +#include <toolkit/awt/xsimpleanimation.hxx> +#include <toolkit/awt/xthrobber.hxx> +#include <toolkit/awt/vclxtopwindow.hxx> +#include <toolkit/awt/vclxwindow.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <toolkit/helper/unowrapper.hxx> +#include <toolkit/helper/servicenames.hxx> + + +#include <toolkit/helper/macros.hxx> +#include <toolkit/helper/convert.hxx> +#include <vcl/unohelp.hxx> +#include <vcl/btndlg.hxx> +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +#include <vcl/combobox.hxx> +#include <vcl/ctrl.hxx> +#include <vcl/dialog.hxx> +#include <vcl/dockingarea.hxx> +#include <vcl/dockwin.hxx> +#include <vcl/edit.hxx> +#include <vcl/field.hxx> +#include <vcl/fixed.hxx> +#include <vcl/floatwin.hxx> +#include <vcl/group.hxx> +#include <vcl/imgctrl.hxx> +#include <vcl/longcurr.hxx> +#include <vcl/lstbox.hxx> +#include <vcl/menubtn.hxx> +#include <vcl/morebtn.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/scrbar.hxx> +#include <vcl/spin.hxx> +#include <vcl/split.hxx> +#include <vcl/splitwin.hxx> +#include <vcl/status.hxx> +#include <vcl/svapp.hxx> +#include <vcl/syschild.hxx> +#include <vcl/tabctrl.hxx> +#include <vcl/tabdlg.hxx> +#include <vcl/tabpage.hxx> +#include <vcl/toolbox.hxx> +#include <vcl/virdev.hxx> +#include <vcl/window.hxx> +#include <vcl/wrkwin.hxx> +#include "toolkit/awt/vclxspinbutton.hxx" + +#include <tools/debug.hxx> +#include <comphelper/processfactory.hxx> + +namespace css = ::com::sun::star; + +#define VCLWINDOW_FRAMEWINDOW 0x1000 +#define VCLWINDOW_SYSTEMCHILDWINDOW 0x1001 + +#if (defined WNT) +#define SYSTEM_DEPENDENT_TYPE ::com::sun::star::lang::SystemDependent::SYSTEM_WIN32 +#elif (defined OS2) +#define SYSTEM_DEPENDENT_TYPE ::com::sun::star::lang::SystemDependent::SYSTEM_OS2 +#elif (defined QUARTZ) +#define SYSTEM_DEPENDENT_TYPE ::com::sun::star::lang::SystemDependent::SYSTEM_MAC +#elif (defined UNX) +#define SYSTEM_DEPENDENT_TYPE ::com::sun::star::lang::SystemDependent::SYSTEM_XWINDOW +#endif + +TOOLKIT_DLLPUBLIC WinBits ImplGetWinBits( sal_uInt32 nComponentAttribs, sal_uInt16 nCompType ) +{ + WinBits nWinBits = 0; + + sal_Bool bMessBox = sal_False; + if ( ( nCompType == WINDOW_INFOBOX ) || + ( nCompType == WINDOW_MESSBOX ) || + ( nCompType == WINDOW_QUERYBOX ) || + ( nCompType == WINDOW_WARNINGBOX ) || + ( nCompType == WINDOW_ERRORBOX ) ) + { + bMessBox = sal_True; + } + + bool bDecoratedWindow = false; + if ( bMessBox + || ( nCompType == WINDOW_DIALOG ) + || ( nCompType == WINDOW_MODELESSDIALOG ) + || ( nCompType == WINDOW_MODALDIALOG ) + || ( nCompType == WINDOW_SYSTEMDIALOG ) + || ( nCompType == WINDOW_PATHDIALOG ) + || ( nCompType == WINDOW_FILEDIALOG ) + || ( nCompType == WINDOW_PRINTERSETUPDIALOG ) + || ( nCompType == WINDOW_PRINTDIALOG ) + || ( nCompType == WINDOW_COLORDIALOG ) + || ( nCompType == WINDOW_FONTDIALOG ) + || ( nCompType == WINDOW_DOCKINGWINDOW ) + || ( nCompType == WINDOW_TABDIALOG ) + || ( nCompType == WINDOW_BUTTONDIALOG ) + || ( nCompType == WINDOW_SYSTEMCHILDWINDOW ) + ) + { + bDecoratedWindow = true; + } + + if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::BORDER ) + nWinBits |= WB_BORDER; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::NOBORDER ) + nWinBits |= WB_NOBORDER; + if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::SIZEABLE ) + nWinBits |= WB_SIZEABLE; + if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::MOVEABLE ) + nWinBits |= WB_MOVEABLE; + if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::CLOSEABLE ) + nWinBits |= WB_CLOSEABLE; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::HSCROLL ) + nWinBits |= WB_HSCROLL; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::VSCROLL ) + nWinBits |= WB_VSCROLL; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::LEFT ) + nWinBits |= WB_LEFT; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::CENTER ) + nWinBits |= WB_CENTER; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::RIGHT ) + nWinBits |= WB_RIGHT; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::SPIN ) + nWinBits |= WB_SPIN; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::SORT ) + nWinBits |= WB_SORT; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DROPDOWN ) + nWinBits |= WB_DROPDOWN; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEFBUTTON ) + nWinBits |= WB_DEFBUTTON; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::READONLY ) + nWinBits |= WB_READONLY; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::CLIPCHILDREN ) + nWinBits |= WB_CLIPCHILDREN; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::GROUP ) + nWinBits |= WB_GROUP; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::NOLABEL ) //added for issue79712 + nWinBits |= WB_NOLABEL; + + // These bits are not uniqe + if ( bMessBox ) + { + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::OK ) + nWinBits |= WB_OK; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::OK_CANCEL ) + nWinBits |= WB_OK_CANCEL; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::YES_NO ) + nWinBits |= WB_YES_NO; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::YES_NO_CANCEL ) + nWinBits |= WB_YES_NO_CANCEL; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::RETRY_CANCEL ) + nWinBits |= WB_RETRY_CANCEL; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_OK ) + nWinBits |= WB_DEF_OK; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_CANCEL ) + nWinBits |= WB_DEF_CANCEL; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_RETRY ) + nWinBits |= WB_DEF_RETRY; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_YES ) + nWinBits |= WB_DEF_YES; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_NO ) + nWinBits |= WB_DEF_NO; + } + if ( nCompType == WINDOW_MULTILINEEDIT ) + { + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::AUTOHSCROLL ) + nWinBits |= WB_AUTOHSCROLL; + if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::AUTOVSCROLL ) + nWinBits |= WB_AUTOVSCROLL; + } + + + if ( bDecoratedWindow ) + { + if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::NODECORATION ) + { + // No decoration removes several window attributes and must + // set WB_NOBORDER! + nWinBits &= ~WB_BORDER; + nWinBits &= ~WB_SIZEABLE; + nWinBits &= ~WB_MOVEABLE; + nWinBits &= ~WB_CLOSEABLE; + nWinBits |= WB_NOBORDER; + } + } + + return nWinBits; +} + +struct ComponentInfo +{ + const char* pName; + WindowType nWinType; +}; + +static ComponentInfo __FAR_DATA aComponentInfos [] = +{ + { "buttondialog", WINDOW_BUTTONDIALOG }, + { "cancelbutton", WINDOW_CANCELBUTTON }, + { "checkbox", WINDOW_CHECKBOX }, + { "combobox", WINDOW_COMBOBOX }, + { "control", WINDOW_CONTROL }, + { "currencybox", WINDOW_CURRENCYBOX }, + { "currencyfield", WINDOW_CURRENCYFIELD }, + { "datebox", WINDOW_DATEBOX }, + { "datefield", WINDOW_DATEFIELD }, + { "dialog", WINDOW_DIALOG }, + { "dockingarea", WINDOW_DOCKINGAREA }, + { "dockingwindow", WINDOW_DOCKINGWINDOW }, + { "edit", WINDOW_EDIT }, + { "errorbox", WINDOW_ERRORBOX }, + { "fixedbitmap", WINDOW_FIXEDBITMAP }, + { "fixedimage", WINDOW_FIXEDIMAGE }, + { "fixedline", WINDOW_FIXEDLINE }, + { "fixedtext", WINDOW_FIXEDTEXT }, + { "floatingwindow", WINDOW_FLOATINGWINDOW }, + { "framewindow", VCLWINDOW_FRAMEWINDOW }, + { "groupbox", WINDOW_GROUPBOX }, + { "helpbutton", WINDOW_HELPBUTTON }, + { "imagebutton", WINDOW_IMAGEBUTTON }, + { "imageradiobutton", WINDOW_IMAGERADIOBUTTON }, + { "infobox", WINDOW_INFOBOX }, + { "listbox", WINDOW_LISTBOX }, + { "longcurrencybox", WINDOW_LONGCURRENCYBOX }, + { "longcurrencyfield", WINDOW_LONGCURRENCYFIELD }, + { "menubutton", WINDOW_MENUBUTTON }, + { "messbox", WINDOW_MESSBOX }, + { "metricbox", WINDOW_METRICBOX }, + { "metricfield", WINDOW_METRICFIELD }, + { "modaldialog", WINDOW_MODALDIALOG }, + { "modelessdialog", WINDOW_MODELESSDIALOG }, + { "morebutton", WINDOW_MOREBUTTON }, + { "multilineedit", WINDOW_MULTILINEEDIT }, + { "multilistbox", WINDOW_MULTILISTBOX }, + { "numericbox", WINDOW_NUMERICBOX }, + { "numericfield", WINDOW_NUMERICFIELD }, + { "okbutton", WINDOW_OKBUTTON }, + { "patternbox", WINDOW_PATTERNBOX }, + { "patternfield", WINDOW_PATTERNFIELD }, + { "pushbutton", WINDOW_PUSHBUTTON }, + { "querybox", WINDOW_QUERYBOX }, + { "radiobutton", WINDOW_RADIOBUTTON }, + { "scrollbar", WINDOW_SCROLLBAR }, + { "scrollbarbox", WINDOW_SCROLLBARBOX }, + { "simpleanimation", WINDOW_CONTROL }, + { "spinbutton", WINDOW_SPINBUTTON }, + { "spinfield", WINDOW_SPINFIELD }, + { "throbber", WINDOW_CONTROL }, + { "splitter", WINDOW_SPLITTER }, + { "splitwindow", WINDOW_SPLITWINDOW }, + { "statusbar", WINDOW_STATUSBAR }, + { "systemchildwindow", VCLWINDOW_SYSTEMCHILDWINDOW }, + { "tabcontrol", WINDOW_TABCONTROL }, + { "tabdialog", WINDOW_TABDIALOG }, + { "tabpage", WINDOW_TABPAGE }, + { "timebox", WINDOW_TIMEBOX }, + { "timefield", WINDOW_TIMEFIELD }, + { "toolbox", WINDOW_TOOLBOX }, + { "tristatebox", WINDOW_TRISTATEBOX }, + { "warningbox", WINDOW_WARNINGBOX }, + { "window", WINDOW_WINDOW }, + { "workwindow", WINDOW_WORKWINDOW } +}; + +extern "C" +{ +static int +#if defined( WNT ) + __cdecl +#endif +#if defined( ICC ) && defined( OS2 ) +_Optlink +#endif + ComponentInfoCompare( const void* pFirst, const void* pSecond) +{ + return( strcmp( ((ComponentInfo*)pFirst)->pName, + ((ComponentInfo*)pSecond)->pName ) ); +} +} + +sal_uInt16 ImplGetComponentType( const String& rServiceName ) +{ + static sal_Bool bSorted = sal_False; + if( !bSorted ) + { + qsort( (void*) aComponentInfos, + sizeof( aComponentInfos ) / sizeof( ComponentInfo ), + sizeof( ComponentInfo ), + ComponentInfoCompare ); + bSorted = sal_True; + } + + + ComponentInfo aSearch; + ByteString aServiceName( rServiceName, gsl_getSystemTextEncoding() ); + aServiceName.ToLowerAscii(); + if ( aServiceName.Len() ) + aSearch.pName = aServiceName.GetBuffer(); + else + aSearch.pName = "window"; + + ComponentInfo* pInf = (ComponentInfo*) bsearch( &aSearch, + (void*) aComponentInfos, + sizeof( aComponentInfos ) / sizeof( ComponentInfo ), + sizeof( ComponentInfo ), + ComponentInfoCompare ); + + return pInf ? pInf->nWinType : 0; +} + + +// ---------------------------------------------------- +// class VCLXToolkit +// ---------------------------------------------------- + +static sal_Int32 nVCLToolkitInstanceCount = 0; +static BOOL bInitedByVCLToolkit = sal_False; +//static cppu::OInterfaceContainerHelper * pToolkits = 0; + +static osl::Mutex & getInitMutex() +{ + static osl::Mutex * pM; + if( !pM ) + { + osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); + if( !pM ) + { + static osl::Mutex aMutex; + pM = &aMutex; + } + } + return *pM; +} + +static osl::Condition & getInitCondition() +{ + static osl::Condition * pC = 0; + if( !pC ) + { + osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); + if( !pC ) + { + static osl::Condition aCondition; + pC = &aCondition; + } + } + return *pC; +} + +struct ToolkitThreadData +{ + VCLXToolkit * pTk; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr; + + ToolkitThreadData( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr, VCLXToolkit * pTk_ ) + : pTk( pTk_ ) + , xSMgr( rSMgr ) + { + } +}; + +extern "C" +{ +static void SAL_CALL ToolkitWorkerFunction( void* pArgs ) +{ + ToolkitThreadData * pTTD = (ToolkitThreadData *)pArgs; + bInitedByVCLToolkit = InitVCL( pTTD->xSMgr ); + if( bInitedByVCLToolkit ) + { + UnoWrapper* pUnoWrapper = new UnoWrapper( pTTD->pTk ); + Application::SetUnoWrapper( pUnoWrapper ); + } + getInitCondition().set(); + if( bInitedByVCLToolkit ) + { + { + osl::Guard< vos::IMutex > aGuard( Application::GetSolarMutex() ); + Application::Execute(); + } + try + { + pTTD->pTk->dispose(); + } + catch( com::sun::star::uno::Exception & ) + { + } + /* + if( pToolkits ) + { + cppu::OInterfaceIteratorHelper aIt( *pToolkits ); + ::com::sun::star::uno::XInterface * pI; + while( pI = aIt.next() ) + ((::com::sun::star::lang::XComponent *)pI)->dispose(); + + // delete toolkit container + osl::Guard< osl::Mutex > aGuard( getInitMutex() ); + delete pToolkits; + pToolkits = 0; + } + */ + DeInitVCL(); + } + else + { + JoinMainLoopThread(); + } + delete pTTD; +} +} + +// contructor, which might initialize VCL +VCLXToolkit::VCLXToolkit( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr ): + cppu::WeakComponentImplHelper7< + ::com::sun::star::awt::XToolkit, + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::awt::XSystemChildFactory, + ::com::sun::star::awt::XMessageBoxFactory, + ::com::sun::star::awt::XDataTransferProviderAccess, + ::com::sun::star::awt::XExtendedToolkit, + ::com::sun::star::awt::XReschedule>( GetMutex() ), + m_aTopWindowListeners(rBHelper.rMutex), + m_aKeyHandlers(rBHelper.rMutex), + m_aFocusListeners(rBHelper.rMutex), + m_aEventListenerLink(LINK(this, VCLXToolkit, eventListenerHandler)), + m_aKeyListenerLink(LINK(this, VCLXToolkit, keyListenerHandler)), + m_bEventListener(false), + m_bKeyListener(false) +{ + hSvToolsLib = NULL; + fnSvtCreateWindow = NULL; + + osl::Guard< osl::Mutex > aGuard( getInitMutex() ); + nVCLToolkitInstanceCount++; + if( ( nVCLToolkitInstanceCount == 1 ) && ( !Application::IsInMain() ) ) + { + // setup execute thread + CreateMainLoopThread( ToolkitWorkerFunction, new ToolkitThreadData( rSMgr, this ) ); + getInitCondition().wait(); + /* + if( bInitedByVCLToolkit ) + { + // insert in disposing list + if( !pToolkits ) + pToolkits = new cppu::OInterfaceContainerHelper( getInitMutex() ); + pToolkits->addInterface( (::com::sun::star::lang::XComponent *)this ); + } + */ + } +} + +VCLXToolkit::~VCLXToolkit() +{ +} + + +void SAL_CALL VCLXToolkit::disposing() +{ + if ( hSvToolsLib ) + { + osl_unloadModule( hSvToolsLib ); + hSvToolsLib = NULL; + fnSvtCreateWindow = NULL; + } + + { + osl::Guard< osl::Mutex > aGuard( getInitMutex() ); + if( --nVCLToolkitInstanceCount == 0 ) + { + if( bInitedByVCLToolkit ) + { + Application::Quit(); + JoinMainLoopThread(); + bInitedByVCLToolkit = sal_False; + } + } + } + + if (m_bEventListener) + { + ::Application::RemoveEventListener(m_aEventListenerLink); + m_bEventListener = false; + } + if (m_bKeyListener) + { + ::Application::RemoveKeyListener(m_aKeyListenerLink); + m_bKeyListener = false; + } + ::css::lang::EventObject aEvent( + static_cast< ::cppu::OWeakObject * >(this)); + m_aTopWindowListeners.disposeAndClear(aEvent); + m_aKeyHandlers.disposeAndClear(aEvent); + m_aFocusListeners.disposeAndClear(aEvent); + +/* + osl::Guard< osl::Mutex > aGuard( getInitMutex() ); + // insert in disposing list + if( pToolkits ) + { + // remove from the disposing list + pToolkits->removeInterface( (::com::sun::star::lang::XComponent *)this ); + } +*/ +} + + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > VCLXToolkit::getDesktopWindow( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xRef; + // 07/00: AppWindow doesn't exist anymore... + return xRef; +} + +::com::sun::star::awt::Rectangle VCLXToolkit::getWorkArea( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::awt::Rectangle aRect; + // 07/00: AppWindow doesn't exist anymore... + return aRect; +} + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > VCLXToolkit::createWindow( const ::com::sun::star::awt::WindowDescriptor& rDescriptor ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + return ImplCreateWindow( rDescriptor, WinBits(0) ); +} + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXToolkit::createScreenCompatibleDevice( sal_Int32 Width, sal_Int32 Height ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > xRef; + VCLXVirtualDevice* pVDev = new VCLXVirtualDevice; + + osl::Guard< vos::IMutex > aSolarGuard( Application::GetSolarMutex() ); + + VirtualDevice* pV = new VirtualDevice; + pV->SetOutputSizePixel( Size( Width, Height ) ); + pVDev->SetVirtualDevice( pV ); + + xRef = pVDev; + return xRef; +} + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion > VCLXToolkit::createRegion( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion > xRef = new VCLXRegion; + return xRef; +} + +Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, + const ::com::sun::star::awt::WindowDescriptor& rDescriptor, + Window* pParent, WinBits nWinBits ) +{ + String aServiceName( rDescriptor.WindowServiceName ); + aServiceName.ToLowerAscii(); + + Window* pNewWindow = NULL; + sal_uInt16 nType = ImplGetComponentType( aServiceName ); + + if ( !pParent ) + { + // Wenn die Component einen Parent braucht, dann NULL zurueckgeben, + // spaeter mal ::com::sun::star::uno::Exception... + sal_Bool bException = sal_True; + if ( ( nType == WINDOW_DIALOG ) || ( nType == WINDOW_MODALDIALOG ) || ( nType == WINDOW_MODELESSDIALOG ) ) + bException = sal_False; + else if ( ( nType == WINDOW_WINDOW ) || + ( nType == WINDOW_WORKWINDOW ) || + ( nType == VCLWINDOW_FRAMEWINDOW ) ) + { + if ( rDescriptor.Type == ::com::sun::star::awt::WindowClass_TOP ) + bException = sal_False; + } + + if ( bException ) + { + *ppNewComp = NULL; + return NULL; + } + } + + if ( nType ) + { + NAMESPACE_VOS(OGuard) aVclGuard( Application::GetSolarMutex() ); + switch ( (WindowType)nType ) + { + case WINDOW_CANCELBUTTON: + pNewWindow = new CancelButton( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WINDOW_CHECKBOX: + pNewWindow = new CheckBox( pParent, nWinBits ); + *ppNewComp = new VCLXCheckBox; + break; + case WINDOW_COMBOBOX: + pNewWindow = new ComboBox( pParent, nWinBits|WB_AUTOHSCROLL ); + ((ComboBox*)pNewWindow)->EnableAutoSize( sal_False ); + *ppNewComp = new VCLXComboBox; + break; + case WINDOW_CURRENCYBOX: + pNewWindow = new CurrencyBox( pParent, nWinBits ); + break; + case WINDOW_CURRENCYFIELD: + pNewWindow = new CurrencyField( pParent, nWinBits ); + static_cast<CurrencyField*>(pNewWindow)->EnableEmptyFieldValue( TRUE ); + *ppNewComp = new VCLXNumericField; + ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(CurrencyField*)pNewWindow ); + break; + case WINDOW_DATEBOX: + pNewWindow = new DateBox( pParent, nWinBits ); + break; + case WINDOW_DATEFIELD: + pNewWindow = new DateField( pParent, nWinBits ); + static_cast<DateField*>(pNewWindow)->EnableEmptyFieldValue( TRUE ); + *ppNewComp = new VCLXDateField; + ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(DateField*)pNewWindow ); + break; + case WINDOW_DOCKINGAREA: + pNewWindow = new DockingAreaWindow( pParent ); + break; + case WINDOW_MULTILINEEDIT: + case WINDOW_EDIT: + pNewWindow = new Edit( pParent, nWinBits ); + *ppNewComp = new VCLXEdit; + break; + case WINDOW_ERRORBOX: + pNewWindow = new ErrorBox( pParent, nWinBits, String() ); + *ppNewComp = new VCLXMessageBox; + break; + case WINDOW_FIXEDBITMAP: + pNewWindow = new FixedBitmap( pParent, nWinBits ); + break; + case WINDOW_FIXEDIMAGE: + pNewWindow = new ImageControl( pParent, nWinBits ); + *ppNewComp = new VCLXImageControl; + break; + case WINDOW_FIXEDLINE: + pNewWindow = new FixedLine( pParent, nWinBits ); + break; + case WINDOW_FIXEDTEXT: + pNewWindow = new FixedText( pParent, nWinBits ); + *ppNewComp = new VCLXFixedText; + break; + case WINDOW_FLOATINGWINDOW: + pNewWindow = new FloatingWindow( pParent, nWinBits ); + break; + case WINDOW_GROUPBOX: + pNewWindow = new GroupBox( pParent, nWinBits ); + break; + case WINDOW_HELPBUTTON: + pNewWindow = new HelpButton( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WINDOW_IMAGEBUTTON: + pNewWindow = new ImageButton( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WINDOW_IMAGERADIOBUTTON: + pNewWindow = new ImageRadioButton( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WINDOW_INFOBOX: + pNewWindow = new InfoBox( pParent, String() ); + *ppNewComp = new VCLXMessageBox; + break; + case WINDOW_LISTBOX: + pNewWindow = new ListBox( pParent, nWinBits|WB_SIMPLEMODE|WB_AUTOHSCROLL ); + ((ListBox*)pNewWindow)->EnableAutoSize( sal_False ); + *ppNewComp = new VCLXListBox; + break; + case WINDOW_LONGCURRENCYBOX: + pNewWindow = new LongCurrencyBox( pParent, nWinBits ); + break; + case WINDOW_LONGCURRENCYFIELD: + pNewWindow = new LongCurrencyField( pParent, nWinBits ); + *ppNewComp = new VCLXCurrencyField; + ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(LongCurrencyField*)pNewWindow ); + break; + case WINDOW_MENUBUTTON: + pNewWindow = new MenuButton( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WINDOW_MESSBOX: + pNewWindow = new MessBox( pParent, nWinBits, String(), String() ); + *ppNewComp = new VCLXMessageBox; + break; + case WINDOW_METRICBOX: + pNewWindow = new MetricBox( pParent, nWinBits ); + break; + case WINDOW_METRICFIELD: + pNewWindow = new MetricField( pParent, nWinBits ); + *ppNewComp = new VCLXMetricField; + ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(MetricField*)pNewWindow ); + break; + case WINDOW_DIALOG: + case WINDOW_MODALDIALOG: + case WINDOW_MODELESSDIALOG: + { + // Modal/Modeless nur durch Show/Execute + if ( (pParent == NULL ) && ( rDescriptor.ParentIndex == -1 ) ) + pParent = DIALOG_NO_PARENT; + pNewWindow = new Dialog( pParent, nWinBits ); + *ppNewComp = new VCLXDialog; + } + break; + case WINDOW_MOREBUTTON: + pNewWindow = new MoreButton( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WINDOW_MULTILISTBOX: + pNewWindow = new MultiListBox( pParent, nWinBits ); + *ppNewComp = new VCLXListBox; + break; + case WINDOW_NUMERICBOX: + pNewWindow = new NumericBox( pParent, nWinBits ); + break; + case WINDOW_NUMERICFIELD: + pNewWindow = new NumericField( pParent, nWinBits ); + static_cast<NumericField*>(pNewWindow)->EnableEmptyFieldValue( TRUE ); + *ppNewComp = new VCLXNumericField; + ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(NumericField*)pNewWindow ); + break; + case WINDOW_OKBUTTON: + pNewWindow = new OKButton( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WINDOW_PATTERNBOX: + pNewWindow = new PatternBox( pParent, nWinBits ); + break; + case WINDOW_PATTERNFIELD: + pNewWindow = new PatternField( pParent, nWinBits ); + *ppNewComp = new VCLXPatternField; + ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(PatternField*)pNewWindow ); + break; + case WINDOW_PUSHBUTTON: + pNewWindow = new PushButton( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WINDOW_QUERYBOX: + pNewWindow = new QueryBox( pParent, nWinBits, String() ); + *ppNewComp = new VCLXMessageBox; + break; + case WINDOW_RADIOBUTTON: + pNewWindow = new RadioButton( pParent, nWinBits ); + *ppNewComp = new VCLXRadioButton; + + // by default, disable RadioCheck + // Since the VCLXRadioButton really cares for it's RadioCheck settings, this is important: + // if we enable it, the VCLXRadioButton will use RadioButton::Check instead of RadioButton::SetState + // This leads to a strange behaviour if the control is newly created: when settings the initial + // state to "checked", the RadioButton::Check (called because RadioCheck=TRUE) will uncheck + // _all_other_ radio buttons in the same group. However, at this moment the grouping of the controls + // is not really valid: the controls are grouped after they have been created, but we're still in + // the creation process, so the RadioButton::Check relies on invalid grouping information. + // 07.08.2001 - #87254# - frank.schoenheit@sun.com + static_cast<RadioButton*>(pNewWindow)->EnableRadioCheck( FALSE ); + break; + case WINDOW_SCROLLBAR: + pNewWindow = new ScrollBar( pParent, nWinBits ); + *ppNewComp = new VCLXScrollBar; + break; + case WINDOW_SCROLLBARBOX: + pNewWindow = new ScrollBarBox( pParent, nWinBits ); + break; + case WINDOW_SPINBUTTON: + pNewWindow = new SpinButton( pParent, nWinBits ); + *ppNewComp = new ::toolkit::VCLXSpinButton; + break; + case WINDOW_SPINFIELD: + pNewWindow = new SpinField( pParent, nWinBits ); + *ppNewComp = new VCLXNumericField; + break; + case WINDOW_SPLITTER: + pNewWindow = new Splitter( pParent, nWinBits ); + break; + case WINDOW_SPLITWINDOW: + pNewWindow = new SplitWindow( pParent, nWinBits ); + break; + case WINDOW_STATUSBAR: + pNewWindow = new StatusBar( pParent, nWinBits ); + break; + case VCLWINDOW_SYSTEMCHILDWINDOW: + pNewWindow = new SystemChildWindow( pParent, nWinBits ); + *ppNewComp = new VCLXSystemDependentWindow(); + break; + case WINDOW_TABCONTROL: + pNewWindow = new TabControl( pParent, nWinBits ); + break; + case WINDOW_TABDIALOG: + pNewWindow = new TabDialog( pParent, nWinBits ); + break; + case WINDOW_TABPAGE: + pNewWindow = new TabPage( pParent, nWinBits ); + *ppNewComp = new VCLXTabPage; + break; + case WINDOW_TIMEBOX: + pNewWindow = new TimeBox( pParent, nWinBits ); + break; + case WINDOW_TIMEFIELD: + pNewWindow = new TimeField( pParent, nWinBits ); + static_cast<TimeField*>(pNewWindow)->EnableEmptyFieldValue( TRUE ); + *ppNewComp = new VCLXTimeField; + ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(TimeField*)pNewWindow ); + break; + case WINDOW_TOOLBOX: + pNewWindow = new ToolBox( pParent, nWinBits ); + *ppNewComp = new VCLXToolBox; + break; + case WINDOW_TRISTATEBOX: + pNewWindow = new TriStateBox( pParent, nWinBits ); + break; + case WINDOW_WARNINGBOX: + pNewWindow = new WarningBox( pParent, nWinBits, String() ); + *ppNewComp = new VCLXMessageBox; + break; + case WINDOW_WORKWINDOW: + case WINDOW_WINDOW: + case VCLWINDOW_FRAMEWINDOW: + case WINDOW_DOCKINGWINDOW: + if ( rDescriptor.Type == ::com::sun::star::awt::WindowClass_TOP ) + { + if (nType == WINDOW_DOCKINGWINDOW ) + pNewWindow = new DockingWindow( pParent, nWinBits ); + else + { + if ((pParent == NULL) && rDescriptor.Parent.is()) + { + // try to get a system dependent window handle + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSystemDependentWindowPeer > xSystemDepParent(rDescriptor.Parent, ::com::sun::star::uno::UNO_QUERY); + + if (xSystemDepParent.is()) + { + sal_Int8 processID[16]; + + rtl_getGlobalProcessId( (sal_uInt8*)processID ); + + ::com::sun::star::uno::Sequence<sal_Int8> processIdSeq(processID, 16); + + ::com::sun::star::uno::Any anyHandle = xSystemDepParent->getWindowHandle(processIdSeq, SYSTEM_DEPENDENT_TYPE); + + // use sal_Int64 here to accomodate all int types + // uno::Any shift operator whill upcast if necessary + sal_Int64 nWindowHandle = 0; + sal_Bool bXEmbed = sal_False; + + bool bUseParentData = true; + if( ! (anyHandle >>= nWindowHandle) ) + { + css::uno::Sequence< css::beans::NamedValue > aProps; + if( anyHandle >>= aProps ) + { + const int nProps = aProps.getLength(); + const css::beans::NamedValue* pProps = aProps.getConstArray(); + for( int i = 0; i < nProps; i++ ) + { + if( pProps[i].Name.equalsAscii( "WINDOW" ) ) + pProps[i].Value >>= nWindowHandle; + else if( pProps[i].Name.equalsAscii( "XEMBED" ) ) + pProps[i].Value >>= bXEmbed; + } + } + else + bUseParentData = false; + } + + if( bUseParentData ) + { + SystemParentData aParentData; + aParentData.nSize = sizeof( aParentData ); + #if defined QUARTZ + aParentData.pView = reinterpret_cast<NSView*>(nWindowHandle); + #elif defined UNX + aParentData.aWindow = nWindowHandle; + aParentData.bXEmbedSupport = bXEmbed; + #elif defined WNT + aParentData.hWnd = reinterpret_cast<HWND>(nWindowHandle); + #elif defined OS2 + aParentData.hWnd = (HWND)nWindowHandle; + #endif + pNewWindow = new WorkWindow( &aParentData ); + } + } + } + + if (!pNewWindow) + pNewWindow = new WorkWindow( pParent, nWinBits ); + } + + *ppNewComp = new VCLXTopWindow( pNewWindow->GetType() == WINDOW_WORKWINDOW ); + } + else if ( rDescriptor.Type == ::com::sun::star::awt::WindowClass_CONTAINER ) + { + if (nType == WINDOW_DOCKINGWINDOW ) + pNewWindow = new DockingWindow( pParent, nWinBits ); + else + pNewWindow = new Window( pParent, nWinBits ); + *ppNewComp = new VCLXContainer; + } + else + { + if (nType == WINDOW_DOCKINGWINDOW ) + pNewWindow = new DockingWindow( pParent, nWinBits ); + else + pNewWindow = new Window( pParent, nWinBits ); + *ppNewComp = new VCLXWindow; + } + break; + case WINDOW_CONTROL: + if ( rDescriptor.WindowServiceName.equalsIgnoreAsciiCase( + ::rtl::OUString::createFromAscii("simpleanimation") ) ) + { + nWinBits |= WB_SCALE; + pNewWindow = new FixedImage( pParent, nWinBits ); + *ppNewComp = new ::toolkit::XSimpleAnimation; + } + else if ( rDescriptor.WindowServiceName.equalsIgnoreAsciiCase( + ::rtl::OUString::createFromAscii("throbber") ) ) + { + nWinBits |= WB_SCALE; + pNewWindow = new FixedImage( pParent, nWinBits ); + *ppNewComp = new ::toolkit::XThrobber; + } + break; + default: DBG_ERRORFILE( "UNO3!" ); + } + } + + return pNewWindow; +} + +extern "C" { static void SAL_CALL thisModule() {} } + +css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow( + const css::awt::WindowDescriptor& rDescriptor, + WinBits nForceWinBits ) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + osl::Guard< vos::IMutex > aSolarGuard( Application::GetSolarMutex() ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xRef; + + Window* pParent = NULL; + if ( rDescriptor.Parent.is() ) + { + VCLXWindow* pParentComponent = VCLXWindow::GetImplementation( rDescriptor.Parent ); + + // #103939# Don't through assertion, may be it's a system dependend window, used in ImplCreateWindow. + // DBG_ASSERT( pParentComponent, "ParentComponent not valid" ); + + if ( pParentComponent ) + pParent = pParentComponent->GetWindow(); + } + + WinBits nWinBits = ImplGetWinBits( rDescriptor.WindowAttributes, + ImplGetComponentType( rDescriptor.WindowServiceName ) ); + nWinBits |= nForceWinBits; + + VCLXWindow* pNewComp = NULL; + + Window* pNewWindow = NULL; + // Try to create the window with SvTools + // (do this _before_ creating it on our own: The old mechanism (extended toolkit in SvTools) did it this way, + // and we need to stay compatible) + // try to load the lib + if ( !fnSvtCreateWindow && !hSvToolsLib ) + { + ::rtl::OUString aLibName = ::vcl::unohelper::CreateLibraryName( "svt", TRUE ); + hSvToolsLib = osl_loadModuleRelative( + &thisModule, aLibName.pData, SAL_LOADMODULE_DEFAULT ); + if ( hSvToolsLib ) + { + ::rtl::OUString aFunctionName( RTL_CONSTASCII_USTRINGPARAM( "CreateWindow" ) ); + fnSvtCreateWindow = (FN_SvtCreateWindow)osl_getFunctionSymbol( hSvToolsLib, aFunctionName.pData ); + } + } + // ask the SvTool creation function + if ( fnSvtCreateWindow ) + pNewWindow = fnSvtCreateWindow( &pNewComp, &rDescriptor, pParent, nWinBits ); + + // if SvTools could not provide a window, create it ourself + if ( !pNewWindow ) + pNewWindow = ImplCreateWindow( &pNewComp, rDescriptor, pParent, nWinBits ); + + DBG_ASSERT( pNewWindow, "createWindow: Unknown Component!" ); + DBG_ASSERTWARNING( pNewComp, "createWindow: No special Interface!" ); + + if ( pNewWindow ) + { + pNewWindow->SetCreatedWithToolkit( sal_True ); + //pNewWindow->SetPosPixel( Point() ); // do not force (0,0) position, keep default pos instead + + if ( rDescriptor.WindowAttributes & ::com::sun::star::awt::WindowAttribute::MINSIZE ) + { + pNewWindow->SetSizePixel( Size() ); + } + else if ( rDescriptor.WindowAttributes & ::com::sun::star::awt::WindowAttribute::FULLSIZE ) + { + if ( pParent ) + pNewWindow->SetSizePixel( pParent->GetOutputSizePixel() ); + } + else if ( !VCLUnoHelper::IsZero( rDescriptor.Bounds ) ) + { + Rectangle aRect = VCLRectangle( rDescriptor.Bounds ); + pNewWindow->SetPosSizePixel( aRect.TopLeft(), aRect.GetSize() ); + } + + if ( !pNewComp ) + { + // Default-Interface + xRef = pNewWindow->GetComponentInterface( sal_True ); + } + else + { + pNewComp->SetCreatedWithToolkit( TRUE ); + xRef = pNewComp; + pNewWindow->SetComponentInterface( xRef ); + } + DBG_ASSERT( pNewWindow->GetComponentInterface( FALSE ) == xRef, + "VCLXToolkit::createWindow: did #133706# resurge?" ); + + if ( rDescriptor.WindowAttributes & ::com::sun::star::awt::WindowAttribute::SHOW ) + pNewWindow->Show(); + } + + return xRef; +} + +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > > VCLXToolkit::createWindows( const ::com::sun::star::uno::Sequence< ::com::sun::star::awt::WindowDescriptor >& rDescriptors ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + sal_uInt32 nComponents = rDescriptors.getLength(); + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > > aSeq( nComponents ); + for ( sal_uInt32 n = 0; n < nComponents; n++ ) + { + ::com::sun::star::awt::WindowDescriptor aDescr = rDescriptors.getConstArray()[n]; + + if ( aDescr.ParentIndex == (-1) ) + aDescr.Parent = NULL; + else if ( ( aDescr.ParentIndex >= 0 ) && ( aDescr.ParentIndex < (short)n ) ) + aDescr.Parent = aSeq.getConstArray()[aDescr.ParentIndex]; + aSeq.getArray()[n] = createWindow( aDescr ); + } + return aSeq; +} + +// ::com::sun::star::awt::XSystemChildFactory +::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > VCLXToolkit::createSystemChild( const ::com::sun::star::uno::Any& Parent, const ::com::sun::star::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 nSystemType ) throw(::com::sun::star::uno::RuntimeException) +{ + Window* pChildWindow = NULL; + if ( nSystemType == SYSTEM_DEPENDENT_TYPE ) + { + // use sal_Int64 here to accomodate all int types + // uno::Any shift operator whill upcast if necessary + sal_Int64 nWindowHandle = 0; + sal_Bool bXEmbed = sal_False; + + bool bUseParentData = true; + if( ! (Parent >>= nWindowHandle) ) + { + css::uno::Sequence< css::beans::NamedValue > aProps; + if( Parent >>= aProps ) + { + const int nProps = aProps.getLength(); + const css::beans::NamedValue* pProps = aProps.getConstArray(); + for( int i = 0; i < nProps; i++ ) + { + if( pProps[i].Name.equalsAscii( "WINDOW" ) ) + pProps[i].Value >>= nWindowHandle; + else if( pProps[i].Name.equalsAscii( "XEMBED" ) ) + pProps[i].Value >>= bXEmbed; + } + } + else + bUseParentData = false; + } + + if( bUseParentData ) + { + SystemParentData aParentData; + aParentData.nSize = sizeof( aParentData ); + #if defined QUARTZ + aParentData.pView = reinterpret_cast<NSView*>(nWindowHandle); + #elif defined UNX + aParentData.aWindow = nWindowHandle; + aParentData.bXEmbedSupport = bXEmbed; + #elif defined WNT + aParentData.hWnd = reinterpret_cast<HWND>(nWindowHandle); + #elif defined OS2 + aParentData.hWnd = (HWND)nWindowHandle; + #endif + osl::Guard< vos::IMutex > aGuard( Application::GetSolarMutex() ); + try + { + pChildWindow = new WorkWindow( &aParentData ); + } + catch ( ::com::sun::star::uno::RuntimeException & rEx ) + { + // system child window could not be created + OSL_TRACE( + "VCLXToolkit::createSystemChild: caught %s\n", + ::rtl::OUStringToOString( + rEx.Message, RTL_TEXTENCODING_UTF8).getStr()); + pChildWindow = NULL; + } + } + } + else if (nSystemType == com::sun::star::lang::SystemDependent::SYSTEM_JAVA) + { + osl::Guard< vos::IMutex > aGuard(Application::GetSolarMutex()); + pChildWindow = new WorkWindow(0, Parent); + } + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xPeer; + if ( pChildWindow ) + { + VCLXTopWindow* pPeer = new VCLXTopWindow(true); + osl::Guard< vos::IMutex > aGuard( Application::GetSolarMutex() ); + pPeer->SetWindow( pChildWindow ); + xPeer = pPeer; + } + + return xPeer; +} + +// ::com::sun::star::awt::XMessageBoxFactory +::com::sun::star::uno::Reference< ::com::sun::star::awt::XMessageBox > SAL_CALL VCLXToolkit::createMessageBox( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& aParent, + const ::com::sun::star::awt::Rectangle& aPosSize, + const ::rtl::OUString& aType, + ::sal_Int32 aButtons, + const ::rtl::OUString& aTitle, + const ::rtl::OUString& aMessage ) throw (::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::awt::WindowDescriptor aDescriptor; + + sal_Int32 nWindowAttributes = css::awt::WindowAttribute::BORDER|css::awt::WindowAttribute::MOVEABLE|css::awt::WindowAttribute::CLOSEABLE; + + // Map button definitions to window attributes + if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_OK ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::OK; + else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_OK_CANCEL ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::OK_CANCEL; + else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_YES_NO ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::YES_NO; + else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_YES_NO_CANCEL ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::YES_NO_CANCEL; + else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_RETRY_CANCEL ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::RETRY_CANCEL; + + // Map default button definitions to window attributes + if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_OK ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_OK; + else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_CANCEL ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_CANCEL; + else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_YES ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_YES; + else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_NO ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_NO; + else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_RETRY ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_RETRY; + + // No more bits for VclWindowPeerAttribute possible. Mapping must be + // done explicitly using VCL methods + WinBits nAddWinBits( 0 ); + if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_ABORT_IGNORE_RETRY ) + nAddWinBits |= WB_ABORT_RETRY_IGNORE; + if ( sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_IGNORE ) + nAddWinBits |= WB_DEF_IGNORE; + + aDescriptor.Type = css::awt::WindowClass_MODALTOP; + aDescriptor.WindowServiceName = aType; + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = aParent; + aDescriptor.Bounds = aPosSize; + aDescriptor.WindowAttributes = nWindowAttributes; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMessageBox > xMsgBox( + ImplCreateWindow( aDescriptor, nAddWinBits ), css::uno::UNO_QUERY ); + css::uno::Reference< css::awt::XWindow > xWindow( xMsgBox, css::uno::UNO_QUERY ); + if ( xMsgBox.is() && xWindow.is() ) + { + Window * pWindow = VCLUnoHelper::GetWindow( xWindow ); + if ( pWindow ) + { + osl::Guard< vos::IMutex > aGuard(Application::GetSolarMutex()); + xMsgBox->setCaptionText( aTitle ); + xMsgBox->setMessageText( aMessage ); + } + } + + return xMsgBox; +} + +::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer > SAL_CALL VCLXToolkit::getDragGestureRecognizer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& window ) throw(::com::sun::star::uno::RuntimeException) +{ + Window * pWindow = VCLUnoHelper::GetWindow( window ); + + if( pWindow ) + return pWindow->GetDragGestureRecognizer(); + + return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer >(); +} + +::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource > SAL_CALL VCLXToolkit::getDragSource( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& window ) throw(::com::sun::star::uno::RuntimeException) +{ + Window * pWindow = VCLUnoHelper::GetWindow( window ); + + if( pWindow ) + return pWindow->GetDragSource(); + + return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource >(); +} + +::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTarget > SAL_CALL VCLXToolkit::getDropTarget( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& window ) throw(::com::sun::star::uno::RuntimeException) +{ + Window * pWindow = VCLUnoHelper::GetWindow( window ); + + if( pWindow ) + return pWindow->GetDropTarget(); + + return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTarget >(); +} + +::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > SAL_CALL VCLXToolkit::getClipboard( const ::rtl::OUString& clipboardName ) throw(::com::sun::star::uno::RuntimeException) +{ + if( clipboardName.getLength() == 0 ) + { + if( !mxClipboard.is() ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); + if ( xFactory.is() ) + { + // remember clipboard here + mxClipboard = ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > ( + xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.SystemClipboard" ) ), ::com::sun::star::uno::UNO_QUERY ); + } + } + + return mxClipboard; + } + + else if( clipboardName.equals( ::rtl::OUString::createFromAscii("Selection") ) ) + { + return mxSelection; + } + + return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >(); +} + +// XServiceInfo +::rtl::OUString VCLXToolkit::getImplementationName() throw(::com::sun::star::uno::RuntimeException) +{ + return rtl::OUString::createFromAscii( "stardiv.Toolkit.VCLXToolkit" ); +} + +sal_Bool VCLXToolkit::supportsService( const ::rtl::OUString& rServiceName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Sequence< ::rtl::OUString > aSNL = getSupportedServiceNames(); + const ::rtl::OUString* pArray = aSNL.getConstArray(); + const ::rtl::OUString* pArrayEnd = aSNL.getConstArray(); + for (; pArray != pArrayEnd; ++pArray ) + if( *pArray == rServiceName ) + break; + + return pArray != pArrayEnd; +} + +::com::sun::star::uno::Sequence< ::rtl::OUString > VCLXToolkit::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException) +{ + ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( szServiceName2_Toolkit ) ); + return ::com::sun::star::uno::Sequence< ::rtl::OUString >( &aServiceName, 1); +} + +// css::awt::XExtendedToolkit: + +// virtual +::sal_Int32 SAL_CALL VCLXToolkit::getTopWindowCount() + throw (::css::uno::RuntimeException) +{ + return static_cast< ::sal_Int32 >(::Application::GetTopWindowCount()); + // XXX numeric overflow +} + +// virtual +::css::uno::Reference< ::css::awt::XTopWindow > SAL_CALL +VCLXToolkit::getTopWindow(::sal_Int32 nIndex) + throw (::css::uno::RuntimeException) +{ + ::Window * p = ::Application::GetTopWindow(static_cast< long >(nIndex)); + // XXX numeric overflow + return ::css::uno::Reference< ::css::awt::XTopWindow >( + p == 0 ? 0 : static_cast< ::css::awt::XWindow * >(p->GetWindowPeer()), + ::css::uno::UNO_QUERY); +} + +// virtual +::css::uno::Reference< ::css::awt::XTopWindow > SAL_CALL +VCLXToolkit::getActiveTopWindow() throw (::css::uno::RuntimeException) +{ + ::Window * p = ::Application::GetActiveTopWindow(); + return ::css::uno::Reference< ::css::awt::XTopWindow >( + p == 0 ? 0 : static_cast< ::css::awt::XWindow * >(p->GetWindowPeer()), + ::css::uno::UNO_QUERY); +} + +// virtual +void SAL_CALL VCLXToolkit::addTopWindowListener( + ::css::uno::Reference< ::css::awt::XTopWindowListener > const & rListener) + throw (::css::uno::RuntimeException) +{ + OSL_ENSURE(rListener.is(), "Null rListener"); + ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex); + if (rBHelper.bDisposed || rBHelper.bInDispose) + { + aGuard.clear(); + rListener->disposing( + ::css::lang::EventObject( + static_cast< ::cppu::OWeakObject * >(this))); + } + else if (m_aTopWindowListeners.addInterface(rListener) == 1 + && !m_bEventListener) + { + m_bEventListener = true; + ::Application::AddEventListener(m_aEventListenerLink); + } +} + +// virtual +void SAL_CALL VCLXToolkit::removeTopWindowListener( + ::css::uno::Reference< ::css::awt::XTopWindowListener > const & rListener) + throw (::css::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(rBHelper.rMutex); + if (!(rBHelper.bDisposed || rBHelper.bInDispose) + && m_aTopWindowListeners.removeInterface(rListener) == 0 + && m_aFocusListeners.getLength() == 0 && m_bEventListener) + { + ::Application::RemoveEventListener(m_aEventListenerLink); + m_bEventListener = false; + } +} + +// virtual +void SAL_CALL VCLXToolkit::addKeyHandler( + ::css::uno::Reference< ::css::awt::XKeyHandler > const & rHandler) + throw (::css::uno::RuntimeException) +{ + OSL_ENSURE(rHandler.is(), "Null rHandler"); + ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex); + if (rBHelper.bDisposed || rBHelper.bInDispose) + { + aGuard.clear(); + rHandler->disposing( + ::css::lang::EventObject( + static_cast< ::cppu::OWeakObject * >(this))); + } + else if (m_aKeyHandlers.addInterface(rHandler) == 1 && !m_bKeyListener) + { + m_bKeyListener = true; + ::Application::AddKeyListener(m_aKeyListenerLink); + } +} + +// virtual +void SAL_CALL VCLXToolkit::removeKeyHandler( + ::css::uno::Reference< ::css::awt::XKeyHandler > const & rHandler) + throw (::css::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(rBHelper.rMutex); + if (!(rBHelper.bDisposed || rBHelper.bInDispose) + && m_aKeyHandlers.removeInterface(rHandler) == 0 && m_bKeyListener) + { + ::Application::RemoveKeyListener(m_aKeyListenerLink); + m_bKeyListener = false; + } +} + +// virtual +void SAL_CALL VCLXToolkit::addFocusListener( + ::css::uno::Reference< ::css::awt::XFocusListener > const & rListener) + throw (::css::uno::RuntimeException) +{ + OSL_ENSURE(rListener.is(), "Null rListener"); + ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex); + if (rBHelper.bDisposed || rBHelper.bInDispose) + { + aGuard.clear(); + rListener->disposing( + ::css::lang::EventObject( + static_cast< ::cppu::OWeakObject * >(this))); + } + else if (m_aFocusListeners.addInterface(rListener) == 1 + && !m_bEventListener) + { + m_bEventListener = true; + ::Application::AddEventListener(m_aEventListenerLink); + } +} + +// virtual +void SAL_CALL VCLXToolkit::removeFocusListener( + ::css::uno::Reference< ::css::awt::XFocusListener > const & rListener) + throw (::css::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(rBHelper.rMutex); + if (!(rBHelper.bDisposed || rBHelper.bInDispose) + && m_aFocusListeners.removeInterface(rListener) == 0 + && m_aTopWindowListeners.getLength() == 0 && m_bEventListener) + { + ::Application::RemoveEventListener(m_aEventListenerLink); + m_bEventListener = false; + } +} + +// virtual +void SAL_CALL VCLXToolkit::fireFocusGained( + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > const &) + throw (::com::sun::star::uno::RuntimeException) +{ +} + +// virtual +void SAL_CALL VCLXToolkit::fireFocusLost( + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > const &) + throw (::com::sun::star::uno::RuntimeException) +{ +} + + +IMPL_LINK(VCLXToolkit, eventListenerHandler, ::VclSimpleEvent const *, pEvent) +{ + switch (pEvent->GetId()) + { + case VCLEVENT_WINDOW_SHOW: + callTopWindowListeners( + pEvent, &::css::awt::XTopWindowListener::windowOpened); + break; + case VCLEVENT_WINDOW_HIDE: + callTopWindowListeners( + pEvent, &::css::awt::XTopWindowListener::windowClosed); + break; + case VCLEVENT_WINDOW_ACTIVATE: + callTopWindowListeners( + pEvent, &::css::awt::XTopWindowListener::windowActivated); + break; + case VCLEVENT_WINDOW_DEACTIVATE: + callTopWindowListeners( + pEvent, &::css::awt::XTopWindowListener::windowDeactivated); + break; + case VCLEVENT_WINDOW_CLOSE: + callTopWindowListeners( + pEvent, &::css::awt::XTopWindowListener::windowClosing); + break; + case VCLEVENT_WINDOW_GETFOCUS: + callFocusListeners(pEvent, true); + break; + case VCLEVENT_WINDOW_LOSEFOCUS: + callFocusListeners(pEvent, false); + break; + case VCLEVENT_WINDOW_MINIMIZE: + callTopWindowListeners( + pEvent, &::css::awt::XTopWindowListener::windowMinimized); + break; + case VCLEVENT_WINDOW_NORMALIZE: + callTopWindowListeners( + pEvent, &::css::awt::XTopWindowListener::windowNormalized); + break; + } + return 0; +} + +IMPL_LINK(VCLXToolkit, keyListenerHandler, ::VclSimpleEvent const *, pEvent) +{ + switch (pEvent->GetId()) + { + case VCLEVENT_WINDOW_KEYINPUT: + return callKeyHandlers(pEvent, true); + case VCLEVENT_WINDOW_KEYUP: + return callKeyHandlers(pEvent, false); + } + return 0; +} + +void VCLXToolkit::callTopWindowListeners( + ::VclSimpleEvent const * pEvent, + void (SAL_CALL ::css::awt::XTopWindowListener::* pFn)( + ::css::lang::EventObject const &)) +{ + ::Window * pWindow + = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow(); + if (pWindow->IsTopWindow()) + { + ::css::uno::Sequence< ::css::uno::Reference< ::css::uno::XInterface > > + aListeners(m_aTopWindowListeners.getElements()); + if (aListeners.hasElements()) + { + ::css::lang::EventObject aAwtEvent( + static_cast< ::css::awt::XWindow * >(pWindow->GetWindowPeer())); + for (::sal_Int32 i = 0; i < aListeners.getLength(); ++i) + { + ::css::uno::Reference< ::css::awt::XTopWindowListener > + xListener(aListeners[i], ::css::uno::UNO_QUERY); + try + { + (xListener.get()->*pFn)(aAwtEvent); + } + catch (::css::uno::RuntimeException & rEx) + { + OSL_TRACE( + "VCLXToolkit::callTopWindowListeners: caught %s\n", + ::rtl::OUStringToOString( + rEx.Message, RTL_TEXTENCODING_UTF8).getStr()); + } + } + } + } +} + +long VCLXToolkit::callKeyHandlers(::VclSimpleEvent const * pEvent, + bool bPressed) +{ + ::css::uno::Sequence< ::css::uno::Reference< ::css::uno::XInterface > > + aHandlers(m_aKeyHandlers.getElements()); + + if (aHandlers.hasElements()) + { + ::Window * pWindow = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow(); + + // See implementation in vclxwindow.cxx for mapping between VCL and UNO AWT event + ::KeyEvent * pKeyEvent = static_cast< ::KeyEvent * >( + static_cast< ::VclWindowEvent const * >(pEvent)->GetData()); + ::css::awt::KeyEvent aAwtEvent( + static_cast< ::css::awt::XWindow * >(pWindow->GetWindowPeer()), + (pKeyEvent->GetKeyCode().IsShift() + ? ::css::awt::KeyModifier::SHIFT : 0) + | (pKeyEvent->GetKeyCode().IsMod1() + ? ::css::awt::KeyModifier::MOD1 : 0) + | (pKeyEvent->GetKeyCode().IsMod2() + ? ::css::awt::KeyModifier::MOD2 : 0) + | (pKeyEvent->GetKeyCode().IsMod3() + ? ::css::awt::KeyModifier::MOD3 : 0), + pKeyEvent->GetKeyCode().GetCode(), pKeyEvent->GetCharCode(), + sal::static_int_cast< sal_Int16 >( + pKeyEvent->GetKeyCode().GetFunction())); + for (::sal_Int32 i = 0; i < aHandlers.getLength(); ++i) + { + ::css::uno::Reference< ::css::awt::XKeyHandler > xHandler( + aHandlers[i], ::css::uno::UNO_QUERY); + try + { + if ((bPressed ? xHandler->keyPressed(aAwtEvent) + : xHandler->keyReleased(aAwtEvent))) + return 1; + } + catch (::css::uno::RuntimeException & rEx) + { + OSL_TRACE( + "VCLXToolkit::callKeyHandlers: caught %s\n", + ::rtl::OUStringToOString( + rEx.Message, RTL_TEXTENCODING_UTF8).getStr()); + } + } + } + return 0; +} + +void VCLXToolkit::callFocusListeners(::VclSimpleEvent const * pEvent, + bool bGained) +{ + ::Window * pWindow + = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow(); + if (pWindow->IsTopWindow()) + { + ::css::uno::Sequence< ::css::uno::Reference< ::css::uno::XInterface > > + aListeners(m_aFocusListeners.getElements()); + if (aListeners.hasElements()) + { + // Ignore the interior of compound controls when determining the + // window that gets the focus next (see implementation in + // vclxwindow.cxx for mapping between VCL and UNO AWT event): + ::css::uno::Reference< css::uno::XInterface > xNext; + ::Window * pFocus = ::Application::GetFocusWindow(); + for (::Window * p = pFocus; p != 0; p = p->GetParent()) + if (!p->IsCompoundControl()) + { + pFocus = p; + break; + } + if (pFocus != 0) + xNext = pFocus->GetComponentInterface(true); + ::css::awt::FocusEvent aAwtEvent( + static_cast< ::css::awt::XWindow * >(pWindow->GetWindowPeer()), + pWindow->GetGetFocusFlags(), xNext, false); + for (::sal_Int32 i = 0; i < aListeners.getLength(); ++i) + { + ::css::uno::Reference< ::css::awt::XFocusListener > xListener( + aListeners[i], ::css::uno::UNO_QUERY); + try + { + bGained ? xListener->focusGained(aAwtEvent) + : xListener->focusLost(aAwtEvent); + } + catch (::css::uno::RuntimeException & rEx) + { + OSL_TRACE( + "VCLXToolkit::callFocusListeners: caught %s\n", + ::rtl::OUStringToOString( + rEx.Message, RTL_TEXTENCODING_UTF8).getStr()); + } + } + } + } +} + +// css::awt::XReschedule: + +void SAL_CALL VCLXToolkit::reschedule() + throw (::com::sun::star::uno::RuntimeException) +{ + Application::Reschedule(true); +} + diff --git a/toolkit/source/awt/vclxtopwindow.cxx b/toolkit/source/awt/vclxtopwindow.cxx new file mode 100644 index 000000000000..10220a87de63 --- /dev/null +++ b/toolkit/source/awt/vclxtopwindow.cxx @@ -0,0 +1,345 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" +#include <com/sun/star/lang/SystemDependent.hpp> +#include <com/sun/star/awt/SystemDependentXWindow.hpp> + +#ifdef WNT +#include <tools/prewin.h> +#include <windows.h> +#include <tools/postwin.h> +#elif defined ( QUARTZ ) +#include "premac.h" +#include <Cocoa/Cocoa.h> +#include "postmac.h" +#endif + +#include <vcl/syschild.hxx> +#include <vcl/sysdata.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <comphelper/sequence.hxx> + +#include <toolkit/awt/vclxtopwindow.hxx> +#include <toolkit/awt/vclxmenu.hxx> +#include <toolkit/helper/macros.hxx> + +#include <vcl/wrkwin.hxx> +#include <vcl/syswin.hxx> +#include <vcl/menu.hxx> +#include <vcl/svapp.hxx> + +#include <tools/debug.hxx> + +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Type; +using ::com::sun::star::uno::Any; +using ::com::sun::star::lang::IndexOutOfBoundsException; + +VCLXTopWindow_Base::VCLXTopWindow_Base( const bool _bSupportSystemWindowPeer ) + :m_bWHWND( _bSupportSystemWindowPeer ) +{ +} + +VCLXTopWindow_Base::~VCLXTopWindow_Base() +{ +} + +Any VCLXTopWindow_Base::queryInterface( const Type & rType ) throw(RuntimeException) +{ + ::com::sun::star::uno::Any aRet( VCLXTopWindow_XBase::queryInterface( rType ) ); + + // do not expose XSystemDependentWindowPeer if we do not have a system window handle + if ( !aRet.hasValue() && m_bWHWND ) + aRet = VCLXTopWindow_SBase::queryInterface( rType ); + + return aRet; +} + +Sequence< Type > VCLXTopWindow_Base::getTypes() throw(RuntimeException) +{ + Sequence< Type > aTypes( VCLXTopWindow_XBase::getTypes() ); + if ( m_bWHWND ) + aTypes = ::comphelper::concatSequences( aTypes, VCLXTopWindow_SBase::getTypes() ); + return aTypes; +} + +::com::sun::star::uno::Any VCLXTopWindow_Base::getWindowHandle( const ::com::sun::star::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 SystemType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutexImpl() ); + + // TODO, check the process id + ::com::sun::star::uno::Any aRet; + Window* pWindow = GetWindowImpl(); + if ( pWindow ) + { + const SystemEnvData* pSysData = ((SystemWindow *)pWindow)->GetSystemData(); + if( pSysData ) + { +#if (defined WNT) + if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_WIN32 ) + { + aRet <<= (sal_Int32)pSysData->hWnd; + } +#elif (defined OS2) + if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_OS2 ) + { + aRet <<= (sal_Int32)pSysData->hWnd; + } +#elif (defined QUARTZ) + if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_MAC ) + { + aRet <<= (sal_IntPtr)pSysData->pView; + } +#elif (defined UNX) + if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_XWINDOW ) + { + ::com::sun::star::awt::SystemDependentXWindow aSD; + aSD.DisplayPointer = sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_IntPtr >(pSysData->pDisplay)); + aSD.WindowHandle = pSysData->aWindow; + aRet <<= aSD; + } +#endif + } + } + return aRet; +} + +void VCLXTopWindow_Base::addTopWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTopWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutexImpl() ); + + GetTopWindowListenersImpl().addInterface( rxListener ); +} + +void VCLXTopWindow_Base::removeTopWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTopWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutexImpl() ); + + GetTopWindowListenersImpl().removeInterface( rxListener ); +} + +void VCLXTopWindow_Base::toFront( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutexImpl() ); + + Window* pWindow = GetWindowImpl(); + if ( pWindow ) + ((WorkWindow*)pWindow)->ToTop( TOTOP_RESTOREWHENMIN ); +} + +void VCLXTopWindow_Base::toBack( ) throw(::com::sun::star::uno::RuntimeException) +{ +#if 0 // Not possible in VCL... + + ::vos::OGuard aGuard( GetMutexImpl() ); + + Window* pWindow = GetWindowImpl(); + if ( pWindow ) + { + ((WorkWindow*)pWindow)->ToBack(); + } +#endif +} + +void VCLXTopWindow_Base::setMenuBar( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuBar >& rxMenu ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutexImpl() ); + + SystemWindow* pWindow = (SystemWindow*) GetWindowImpl(); + if ( pWindow ) + { + pWindow->SetMenuBar( NULL ); + if ( rxMenu.is() ) + { + VCLXMenu* pMenu = VCLXMenu::GetImplementation( rxMenu ); + if ( pMenu && !pMenu->IsPopupMenu() ) + pWindow->SetMenuBar( (MenuBar*) pMenu->GetMenu() ); + } + } + mxMenuBar = rxMenu; +} + +//-------------------------------------------------------------------- +::sal_Bool SAL_CALL VCLXTopWindow_Base::getIsMaximized() throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutexImpl() ); + + const WorkWindow* pWindow = dynamic_cast< const WorkWindow* >( GetWindowImpl() ); + if ( !pWindow ) + return sal_False; + + return pWindow->IsMaximized(); +} + +//-------------------------------------------------------------------- +void SAL_CALL VCLXTopWindow_Base::setIsMaximized( ::sal_Bool _ismaximized ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutexImpl() ); + + WorkWindow* pWindow = dynamic_cast< WorkWindow* >( GetWindowImpl() ); + if ( !pWindow ) + return; + + pWindow->Maximize( _ismaximized ); +} + +//-------------------------------------------------------------------- +::sal_Bool SAL_CALL VCLXTopWindow_Base::getIsMinimized() throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutexImpl() ); + + const WorkWindow* pWindow = dynamic_cast< const WorkWindow* >( GetWindowImpl() ); + if ( !pWindow ) + return sal_False; + + return pWindow->IsMinimized(); +} + +//-------------------------------------------------------------------- +void SAL_CALL VCLXTopWindow_Base::setIsMinimized( ::sal_Bool _isMinimized ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutexImpl() ); + + WorkWindow* pWindow = dynamic_cast< WorkWindow* >( GetWindowImpl() ); + if ( !pWindow ) + return; + + _isMinimized ? pWindow->Minimize() : pWindow->Restore(); +} + +//-------------------------------------------------------------------- +::sal_Int32 SAL_CALL VCLXTopWindow_Base::getDisplay() throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutexImpl() ); + + const SystemWindow* pWindow = dynamic_cast< const SystemWindow* >( GetWindowImpl() ); + if ( !pWindow ) + return 0; + + return pWindow->GetScreenNumber(); +} + +//-------------------------------------------------------------------- +void SAL_CALL VCLXTopWindow_Base::setDisplay( ::sal_Int32 _display ) throw (RuntimeException, IndexOutOfBoundsException) +{ + ::vos::OGuard aGuard( GetMutexImpl() ); + + if ( ( _display < 0 ) || ( _display >= (sal_Int32)Application::GetScreenCount() ) ) + throw IndexOutOfBoundsException(); + + SystemWindow* pWindow = dynamic_cast< SystemWindow* >( GetWindowImpl() ); + if ( !pWindow ) + return; + + pWindow->SetScreenNumber( _display ); +} + +// ---------------------------------------------------- +// class VCLXTopWindow +// ---------------------------------------------------- + +void VCLXTopWindow::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + VCLXContainer::ImplGetPropertyIds( rIds ); +} + +VCLXTopWindow::VCLXTopWindow(bool bWHWND) + : VCLXTopWindow_Base( bWHWND ) +{ +} + +VCLXTopWindow::~VCLXTopWindow() +{ +} + +vos::IMutex& VCLXTopWindow::GetMutexImpl() +{ + return VCLXContainer::GetMutex(); +} + +Window* VCLXTopWindow::GetWindowImpl() +{ + return VCLXContainer::GetWindow(); +} + +::cppu::OInterfaceContainerHelper& VCLXTopWindow::GetTopWindowListenersImpl() +{ + return GetTopWindowListeners(); +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXTopWindow::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet( VCLXTopWindow_Base::queryInterface( rType ) ); + + if ( !aRet.hasValue() ) + aRet = VCLXContainer::queryInterface( rType ); + + return aRet; +} + +::com::sun::star::uno::Sequence< sal_Int8 > VCLXTopWindow::getImplementationId() throw(::com::sun::star::uno::RuntimeException) +{ + static ::cppu::OImplementationId* pId = NULL; + static ::cppu::OImplementationId* pIdWithHandle = NULL; + if ( isSystemDependentWindowPeer() ) + { + if( !pIdWithHandle ) + { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pIdWithHandle ) + { + static ::cppu::OImplementationId idWithHandle( sal_False ); + pIdWithHandle = &idWithHandle; + } + } + + return (*pIdWithHandle).getImplementationId(); + } + else + { + if( !pId ) + { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pId ) + { + static ::cppu::OImplementationId id( sal_False ); + pId = &id; + } + } + + return (*pId).getImplementationId(); + } +} + +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > VCLXTopWindow::getTypes() throw(::com::sun::star::uno::RuntimeException) +{ + return ::comphelper::concatSequences( VCLXTopWindow_Base::getTypes(), VCLXContainer::getTypes() ); +} diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx new file mode 100644 index 000000000000..248571819067 --- /dev/null +++ b/toolkit/source/awt/vclxwindow.cxx @@ -0,0 +1,2776 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" +#include <com/sun/star/awt/WindowEvent.hpp> +#include <com/sun/star/awt/KeyEvent.hpp> +#include <com/sun/star/awt/KeyModifier.hpp> +#include <com/sun/star/awt/MouseEvent.hpp> +#include <com/sun/star/awt/MouseButton.hpp> +#include <com/sun/star/awt/MouseWheelBehavior.hpp> +#include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/awt/Style.hpp> +#include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <com/sun/star/awt/DockingEvent.hpp> +#include <com/sun/star/awt/EndDockingEvent.hpp> +#include <com/sun/star/awt/EndPopupModeEvent.hpp> +#include <com/sun/star/awt/XWindowListener2.hpp> +#include <com/sun/star/style/VerticalAlignment.hpp> +#include <com/sun/star/text/WritingMode2.hpp> +#include <toolkit/awt/vclxwindow.hxx> +#include <toolkit/awt/vclxpointer.hxx> +#include <toolkit/awt/vclxwindows.hxx> +#include <toolkit/helper/macros.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <toolkit/helper/convert.hxx> +#include <toolkit/helper/macros.hxx> +#include <toolkit/helper/property.hxx> +#include <toolkit/helper/accessibilityclient.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <rtl/memory.h> +#include <rtl/uuid.h> +#include <rtl/ustrbuf.hxx> +#include <vcl/svapp.hxx> +#include <vcl/window.hxx> +#include <tools/color.hxx> +#include <vcl/dockwin.hxx> +#include <vcl/pdfextoutdevdata.hxx> +#include <vcl/tabpage.hxx> +#include <vcl/button.hxx> +#include <comphelper/asyncnotification.hxx> +#include <toolkit/helper/solarrelease.hxx> + +#include <toolkit/helper/unopropertyarrayhelper.hxx> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::lang::EventObject; +using ::com::sun::star::awt::XWindowListener2; +using ::com::sun::star::awt::XDockableWindowListener; +using ::com::sun::star::awt::XDevice; +using ::com::sun::star::style::VerticalAlignment; +using ::com::sun::star::style::VerticalAlignment_TOP; +using ::com::sun::star::style::VerticalAlignment_MIDDLE; +using ::com::sun::star::style::VerticalAlignment_BOTTOM; +using ::com::sun::star::style::VerticalAlignment_MAKE_FIXED_SIZE; + +namespace WritingMode2 = ::com::sun::star::text::WritingMode2; +namespace MouseWheelBehavior = ::com::sun::star::awt::MouseWheelBehavior; + + +//==================================================================== +//= misc helpers +//==================================================================== +namespace +{ + //................................................................ + //. FlagGuard + //................................................................ + class FlagGuard + { + private: + bool& m_rFlag; + + public: + FlagGuard( bool& _rFlag ) + :m_rFlag( _rFlag ) + { + m_rFlag = true; + } + ~FlagGuard() + { + m_rFlag = false; + } + }; + + //................................................................ + //. MouseEventType + //................................................................ + enum MouseEventType + { + META_FIRST_MOUSE_EVENT = 0, + + EVENT_MOUSE_PRESSED = 0, + EVENT_MOUSE_RELEASED = 1, + EVENT_MOUSE_ENTERED = 2, + EVENT_MOUSE_EXITED = 3, + + META_LAST_MOUSE_EVENT = 3 + }; + + //................................................................ + //. PlainEventType + //................................................................ + enum PlainEventType + { + META_FIRST_PLAIN_EVENT = 4, + + EVENT_WINDOW_ENABLED = 4, + EVENT_WINDOW_DISABLED = 5, + + META_LAST_PLAIN_EVENT = 5 + }; + +#if OSL_DEBUG_LEVEL > 0 + static void checkEventDefinitions() + { + OSL_ENSURE( (int)META_LAST_MOUSE_EVENT < (int)META_FIRST_PLAIN_EVENT, "checkEventDefinitions: invalid event definitions!" ); + } + #define DBG_CHECK_EVENTS() checkEventDefinitions() +#else + #define DBG_CHECK_EVENTS() +#endif + + //................................................................ + //. AnyWindowEvent + //................................................................ + struct AnyWindowEvent : public ::comphelper::AnyEvent + { + private: + awt::MouseEvent m_aMouseEvent; + lang::EventObject m_aPlainEvent; + + sal_Int32 m_nEventType; + + public: + AnyWindowEvent( const awt::MouseEvent& _rEvent, MouseEventType _nType ) + :comphelper::AnyEvent() + ,m_aMouseEvent( _rEvent ) + ,m_nEventType( static_cast< sal_Int32 >( _nType ) ) + { + DBG_CHECK_EVENTS(); + } + + AnyWindowEvent( const lang::EventObject& _rEvent, PlainEventType _nType ) + :comphelper::AnyEvent() + ,m_aPlainEvent( _rEvent ) + ,m_nEventType( static_cast< sal_Int32 >( _nType ) ) + { + DBG_CHECK_EVENTS(); + } + + bool isMouseEvent() const + { + return ( META_FIRST_MOUSE_EVENT <= m_nEventType ) && ( m_nEventType <= META_LAST_MOUSE_EVENT ); + } + + bool isPlainEvent() const + { + return ( META_FIRST_PLAIN_EVENT <= m_nEventType ) && ( m_nEventType <= META_LAST_PLAIN_EVENT ); + } + + const awt::MouseEvent& getMouseEvent() const + { + OSL_ENSURE( isMouseEvent(), "AnyWindowEvent::getMouseEvent: no mouse event!" ); + return m_aMouseEvent; + } + + MouseEventType getMouseEventType() const + { + OSL_ENSURE( isMouseEvent(), "AnyWindowEvent::getMouseEventType: no mouse event!" ); + return static_cast< MouseEventType >( m_nEventType ); + } + + const lang::EventObject& getPlainEvent() const + { + OSL_ENSURE( isPlainEvent(), "AnyWindowEvent::getPlainEvent: no plain event!" ); + return m_aPlainEvent; + } + + PlainEventType getPlainEventType() const + { + OSL_ENSURE( isPlainEvent(), "AnyWindowEvent::getPlainEventType: no mouse event!" ); + return static_cast< PlainEventType >( m_nEventType ); + } + }; +} + +//==================================================================== +//= VCLXWindowImpl +//==================================================================== +class SAL_DLLPRIVATE VCLXWindowImpl : public ::comphelper::IEventProcessor +{ +private: + typedef ::std::vector< ::rtl::Reference< ::comphelper::AnyEvent > > + EventArray; + +private: + VCLXWindow& mrAntiImpl; + ::vos::IMutex& mrMutex; + ::toolkit::AccessibilityClient maAccFactory; + bool mbDisposed; + bool mbDrawingOntoParent; // no bit mask, is passed around by reference + sal_Bool mbEnableVisible; + sal_Bool mbDirectVisible; + + ::osl::Mutex maListenerContainerMutex; + ::cppu::OInterfaceContainerHelper maWindow2Listeners; + ::cppu::OInterfaceContainerHelper maDockableWindowListeners; + EventListenerMultiplexer maEventListeners; + FocusListenerMultiplexer maFocusListeners; + WindowListenerMultiplexer maWindowListeners; + KeyListenerMultiplexer maKeyListeners; + MouseListenerMultiplexer maMouseListeners; + MouseMotionListenerMultiplexer maMouseMotionListeners; + PaintListenerMultiplexer maPaintListeners; + VclContainerListenerMultiplexer maContainerListeners; + TopWindowListenerMultiplexer maTopWindowListeners; + + EventArray maEvents; + ULONG mnEventId; + +public: + bool mbDisposing : 1; + bool mbDesignMode : 1; + bool mbSynthesizingVCLEvent : 1; + bool mbWithDefaultProps : 1; + + ULONG mnListenerLockLevel; + sal_Int16 mnWritingMode; + sal_Int16 mnContextWritingMode; + + UnoPropertyArrayHelper* mpPropHelper; + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPointer > + mxPointer; + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > + mxAccessibleContext; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > + mxViewGraphics; + +public: + bool& getDrawingOntoParent_ref() { return mbDrawingOntoParent; } + +public: + /** ctor + @param _pAntiImpl + the <type>VCLXWindow</type> instance which the object belongs to. Must + live longer then the object just being constructed. + */ + VCLXWindowImpl( VCLXWindow& _rAntiImpl, ::vos::IMutex& _rMutex, bool _bWithDefaultProps ); + + /** synchronously mbEnableVisible + */ + void setEnableVisible( sal_Bool bEnableVisible ) { mbEnableVisible = bEnableVisible; } + sal_Bool isEnableVisible() { return mbEnableVisible; } + /** synchronously mbDirectVisible; + */ + void setDirectVisible( sal_Bool bDirectVisible ) { mbDirectVisible = bDirectVisible; } + sal_Bool isDirectVisible() { return mbDirectVisible; } + + /** asynchronously notifies a mouse event to the VCLXWindow's XMouseListeners + */ + void notifyMouseEvent( const awt::MouseEvent& _rMouseEvent, MouseEventType _nType ); + + /** asynchronously notifies an event described by an EventObject to the respective listeners + */ + void notifyPlainEvent( const lang::EventObject& _rPlainEvent, PlainEventType _nType ); + + /** notifies the object that its VCLXWindow is being disposed + */ + void disposing(); + + inline ::toolkit::AccessibilityClient& getAccessibleFactory() + { + return maAccFactory; + } + + /** returns the container of registered XWindowListener2 listeners + */ + inline ::cppu::OInterfaceContainerHelper& getWindow2Listeners() { return maWindow2Listeners; } + inline ::cppu::OInterfaceContainerHelper& getDockableWindowListeners(){ return maDockableWindowListeners; } + inline EventListenerMultiplexer& getEventListeners() { return maEventListeners; } + inline FocusListenerMultiplexer& getFocusListeners() { return maFocusListeners; } + inline WindowListenerMultiplexer& getWindowListeners() { return maWindowListeners; } + inline KeyListenerMultiplexer& getKeyListeners() { return maKeyListeners; } + inline MouseListenerMultiplexer& getMouseListeners() { return maMouseListeners; } + inline MouseMotionListenerMultiplexer& getMouseMotionListeners() { return maMouseMotionListeners; } + inline PaintListenerMultiplexer& getPaintListeners() { return maPaintListeners; } + inline VclContainerListenerMultiplexer& getContainerListeners() { return maContainerListeners; } + inline TopWindowListenerMultiplexer& getTopWindowListeners() { return maTopWindowListeners; } + + virtual ~VCLXWindowImpl(); + +protected: + virtual void SAL_CALL acquire(); + virtual void SAL_CALL release(); + + // IEventProcessor + virtual void processEvent( const ::comphelper::AnyEvent& _rEvent ); + +private: + DECL_LINK( OnProcessEvent, void* ); + +private: + /** notifies an arbitrary event + @param _rEvent + the event to notify + */ + void impl_notifyAnyEvent( + const ::rtl::Reference< ::comphelper::AnyEvent >& _rEvent + ); + +private: + /** determines whether the instance is already disposed + @precond + m_aMutex must be acquired + */ + inline bool impl_isDisposed() + { + return mbDisposed; + } + +private: + VCLXWindowImpl(); // never implemented + VCLXWindowImpl( const VCLXWindowImpl& ); // never implemented + VCLXWindowImpl& operator=( const VCLXWindowImpl& ); // never implemented +}; + +//-------------------------------------------------------------------- +VCLXWindowImpl::VCLXWindowImpl( VCLXWindow& _rAntiImpl, ::vos::IMutex& _rMutex, bool _bWithDefaultProps ) + :mrAntiImpl( _rAntiImpl ) + ,mrMutex( _rMutex ) + ,mbDisposed( false ) + ,mbDrawingOntoParent( false ) + ,mbEnableVisible(sal_True) + ,mbDirectVisible(sal_True) + ,maListenerContainerMutex( ) + ,maWindow2Listeners( maListenerContainerMutex ) + ,maDockableWindowListeners( maListenerContainerMutex ) + ,maEventListeners( _rAntiImpl ) + ,maFocusListeners( _rAntiImpl ) + ,maWindowListeners( _rAntiImpl ) + ,maKeyListeners( _rAntiImpl ) + ,maMouseListeners( _rAntiImpl ) + ,maMouseMotionListeners( _rAntiImpl ) + ,maPaintListeners( _rAntiImpl ) + ,maContainerListeners( _rAntiImpl ) + ,maTopWindowListeners( _rAntiImpl ) + ,mnEventId( 0 ) + ,mbDisposing( false ) + ,mbDesignMode( false ) + ,mbSynthesizingVCLEvent( false ) + ,mbWithDefaultProps( _bWithDefaultProps ) + ,mnListenerLockLevel( 0 ) + ,mnWritingMode( WritingMode2::CONTEXT ) + ,mnContextWritingMode( WritingMode2::CONTEXT ) + ,mpPropHelper( NULL ) +{ +} + +VCLXWindowImpl::~VCLXWindowImpl() +{ + delete mpPropHelper; +} + +//-------------------------------------------------------------------- +void VCLXWindowImpl::disposing() +{ + ::vos::OGuard aGuard( mrMutex ); + if ( mnEventId ) + Application::RemoveUserEvent( mnEventId ); + mnEventId = 0; + mbDisposed= true; + + ::com::sun::star::lang::EventObject aEvent; + aEvent.Source = mrAntiImpl; + + maEventListeners.disposeAndClear( aEvent ); + maFocusListeners.disposeAndClear( aEvent ); + maWindowListeners.disposeAndClear( aEvent ); + maKeyListeners.disposeAndClear( aEvent ); + maMouseListeners.disposeAndClear( aEvent ); + maMouseMotionListeners.disposeAndClear( aEvent ); + maPaintListeners.disposeAndClear( aEvent ); + maContainerListeners.disposeAndClear( aEvent ); + maTopWindowListeners.disposeAndClear( aEvent ); + +} + +//-------------------------------------------------------------------- +void VCLXWindowImpl::impl_notifyAnyEvent( const ::rtl::Reference< ::comphelper::AnyEvent >& _rEvent ) +{ + maEvents.push_back( _rEvent ); + if ( !mnEventId ) + mnEventId = Application::PostUserEvent( LINK( this, VCLXWindowImpl, OnProcessEvent ) ); +} + +//-------------------------------------------------------------------- +void VCLXWindowImpl::notifyMouseEvent( const awt::MouseEvent& _rMouseEvent, MouseEventType _nType ) +{ + ::vos::OClearableGuard aGuard( mrMutex ); + if ( maMouseListeners.getLength() ) + impl_notifyAnyEvent( new AnyWindowEvent( _rMouseEvent, _nType ) ); +} + +//-------------------------------------------------------------------- +void VCLXWindowImpl::notifyPlainEvent( const lang::EventObject& _rPlainEvent, PlainEventType _nType ) +{ + ::vos::OClearableGuard aGuard( mrMutex ); + if ( maWindow2Listeners.getLength() ) + impl_notifyAnyEvent( new AnyWindowEvent( _rPlainEvent, _nType ) ); +} + +//-------------------------------------------------------------------- +IMPL_LINK( VCLXWindowImpl, OnProcessEvent, void*, EMPTYARG ) +{ + // work on a copy of the events array + EventArray aEventsCopy; + { + ::vos::OGuard aGuard( mrMutex ); + aEventsCopy = maEvents; + maEvents.clear(); + + if ( !mnEventId ) + // we were disposed while waiting for the mutex to lock + return 1L; + + mnEventId = 0; + } + + { + ::toolkit::ReleaseSolarMutex aReleaseSolar; + for ( EventArray::const_iterator loop = aEventsCopy.begin(); + loop != aEventsCopy.end(); + ++loop + ) + { + processEvent( *(*loop) ); + } + } + + return 0L; +} + +//-------------------------------------------------------------------- +void VCLXWindowImpl::processEvent( const ::comphelper::AnyEvent& _rEvent ) +{ + ::vos::OGuard aGuard( mrMutex ); + if ( impl_isDisposed() ) + // while we were waiting for our mutex, another thread disposed us + return; + + const AnyWindowEvent& rEventDescriptor( static_cast< const AnyWindowEvent& >( _rEvent ) ); + if ( rEventDescriptor.isMouseEvent() ) + { + const awt::MouseEvent& rEvent( rEventDescriptor.getMouseEvent() ); + switch ( rEventDescriptor.getMouseEventType() ) + { + case EVENT_MOUSE_PRESSED: + maMouseListeners.mousePressed( rEvent ); + break; + case EVENT_MOUSE_RELEASED: + maMouseListeners.mouseReleased( rEvent ); + break; + case EVENT_MOUSE_ENTERED: + maMouseListeners.mouseEntered( rEvent ); + break; + case EVENT_MOUSE_EXITED: + maMouseListeners.mouseExited( rEvent ); + break; + default: + DBG_ERROR( "VCLXWindowImpl::processEvent: what kind of event *is* this (1)?" ); + break; + } + } + else if ( rEventDescriptor.isPlainEvent() ) + { + const lang::EventObject& rEvent( rEventDescriptor.getPlainEvent() ); + switch ( rEventDescriptor.getPlainEventType() ) + { + case EVENT_WINDOW_ENABLED: + maWindow2Listeners.notifyEach( &XWindowListener2::windowEnabled, rEvent ); + break; + case EVENT_WINDOW_DISABLED: + maWindow2Listeners.notifyEach( &XWindowListener2::windowDisabled, rEvent ); + break; + default: + DBG_ERROR( "VCLXWindowImpl::processEvent: what kind of event *is* this (2)?" ); + break; + } + } + else + { + DBG_ERROR( "VCLXWindowImpl::processEvent: what kind of event *is* this (3)?" ); + } +} + +//-------------------------------------------------------------------- +void SAL_CALL VCLXWindowImpl::acquire() +{ + mrAntiImpl.acquire(); +} + +//-------------------------------------------------------------------- +void SAL_CALL VCLXWindowImpl::release() +{ + mrAntiImpl.release(); +} + +//==================================================================== +//==================================================================== + +// Mit Out-Parameter besser als Rueckgabewert, wegen Ref-Objekt... + +void ImplInitWindowEvent( ::com::sun::star::awt::WindowEvent& rEvent, Window* pWindow ) +{ + Point aPos = pWindow->GetPosPixel(); + Size aSz = pWindow->GetSizePixel(); + + rEvent.X = aPos.X(); + rEvent.Y = aPos.Y(); + + rEvent.Width = aSz.Width(); + rEvent.Height = aSz.Height(); + + pWindow->GetBorder( rEvent.LeftInset, rEvent.TopInset, rEvent.RightInset, rEvent.BottomInset ); +} + +// ---------------------------------------------------- +// class VCLXWindow +// ---------------------------------------------------- + +DBG_NAME(VCLXWindow); + +VCLXWindow::VCLXWindow( bool _bWithDefaultProps ) + :mpImpl( NULL ) +{ + DBG_CTOR( VCLXWindow, 0 ); + + mpImpl = new VCLXWindowImpl( *this, GetMutex(), _bWithDefaultProps ); +} + +VCLXWindow::~VCLXWindow() +{ + DBG_DTOR( VCLXWindow, 0 ); + + delete mpImpl; + + if ( GetWindow() ) + { + GetWindow()->RemoveEventListener( LINK( this, VCLXWindow, WindowEventListener ) ); + GetWindow()->SetWindowPeer( NULL, NULL ); + GetWindow()->SetAccessible( NULL ); + } +} + +::toolkit::IAccessibleFactory& VCLXWindow::getAccessibleFactory() +{ + return mpImpl->getAccessibleFactory().getFactory(); +} + +void VCLXWindow::SetWindow( Window* pWindow ) +{ + if ( GetWindow() ) + { + GetWindow()->RemoveEventListener( LINK( this, VCLXWindow, WindowEventListener ) ); +// GetWindow()->DbgAssertNoEventListeners(); + } + + SetOutputDevice( pWindow ); + + if ( GetWindow() ) + { + GetWindow()->AddEventListener( LINK( this, VCLXWindow, WindowEventListener ) ); + sal_Bool bDirectVisible = pWindow ? pWindow->IsVisible() : false; + mpImpl->setDirectVisible( bDirectVisible ); + } + +} + +void VCLXWindow::suspendVclEventListening( ) +{ + ++mpImpl->mnListenerLockLevel; +} + +void VCLXWindow::resumeVclEventListening( ) +{ + DBG_ASSERT( mpImpl->mnListenerLockLevel, "VCLXWindow::resumeVclEventListening: not suspended!" ); + --mpImpl->mnListenerLockLevel; +} + +void VCLXWindow::notifyWindowRemoved( Window& _rWindow ) +{ + if ( mpImpl->getContainerListeners().getLength() ) + { + awt::VclContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Child = static_cast< XWindow* >( _rWindow.GetWindowPeer() ); + mpImpl->getContainerListeners().windowRemoved( aEvent ); + } +} + +IMPL_LINK( VCLXWindow, WindowEventListener, VclSimpleEvent*, pEvent ) +{ + if ( mpImpl->mnListenerLockLevel ) + return 0L; + + DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" ); + if ( pEvent && pEvent->ISA( VclWindowEvent ) ) + { + DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow() && GetWindow(), "Window???" ); + ProcessWindowEvent( *(VclWindowEvent*)pEvent ); + } + return 0; +} + +void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xThis( (::cppu::OWeakObject*)this ); + + switch ( rVclWindowEvent.GetId() ) + { + case VCLEVENT_WINDOW_ENABLED: + case VCLEVENT_WINDOW_DISABLED: + { + bool bEnabled = ( VCLEVENT_WINDOW_ENABLED == rVclWindowEvent.GetId() ); + EventObject aEvent( *this ); + mpImpl->notifyPlainEvent( aEvent, + bEnabled ? EVENT_WINDOW_ENABLED : EVENT_WINDOW_DISABLED ); + } + break; + + case VCLEVENT_WINDOW_PAINT: + { + if ( mpImpl->getPaintListeners().getLength() ) + { + ::com::sun::star::awt::PaintEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.UpdateRect = AWTRectangle( *(Rectangle*)rVclWindowEvent.GetData() ); + aEvent.Count = 0; + mpImpl->getPaintListeners().windowPaint( aEvent ); + } + } + break; + case VCLEVENT_WINDOW_MOVE: + { + if ( mpImpl->getWindowListeners().getLength() ) + { + ::com::sun::star::awt::WindowEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() ); + mpImpl->getWindowListeners().windowMoved( aEvent ); + } + } + break; + case VCLEVENT_WINDOW_RESIZE: + { + if ( mpImpl->getWindowListeners().getLength() ) + { + ::com::sun::star::awt::WindowEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() ); + mpImpl->getWindowListeners().windowResized( aEvent ); + } + } + break; + case VCLEVENT_WINDOW_SHOW: + { + if ( mpImpl->getWindowListeners().getLength() ) + { + ::com::sun::star::awt::WindowEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() ); + mpImpl->getWindowListeners().windowShown( aEvent ); + } + + // For TopWindows this means opened... + if ( mpImpl->getTopWindowListeners().getLength() ) + { + ::com::sun::star::lang::EventObject aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + mpImpl->getTopWindowListeners().windowOpened( aEvent ); + } + } + break; + case VCLEVENT_WINDOW_HIDE: + { + if ( mpImpl->getWindowListeners().getLength() ) + { + ::com::sun::star::awt::WindowEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() ); + mpImpl->getWindowListeners().windowHidden( aEvent ); + } + + // For TopWindows this means closed... + if ( mpImpl->getTopWindowListeners().getLength() ) + { + ::com::sun::star::lang::EventObject aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + mpImpl->getTopWindowListeners().windowClosed( aEvent ); + } + } + break; + case VCLEVENT_WINDOW_ACTIVATE: + { + if ( mpImpl->getTopWindowListeners().getLength() ) + { + ::com::sun::star::lang::EventObject aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + mpImpl->getTopWindowListeners().windowActivated( aEvent ); + } + } + break; + case VCLEVENT_WINDOW_DEACTIVATE: + { + if ( mpImpl->getTopWindowListeners().getLength() ) + { + ::com::sun::star::lang::EventObject aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + mpImpl->getTopWindowListeners().windowDeactivated( aEvent ); + } + } + break; + case VCLEVENT_WINDOW_CLOSE: + { + if ( mpImpl->getDockableWindowListeners().getLength() ) + { + ::com::sun::star::lang::EventObject aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::closed, aEvent ); + } + if ( mpImpl->getTopWindowListeners().getLength() ) + { + ::com::sun::star::lang::EventObject aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + mpImpl->getTopWindowListeners().windowClosing( aEvent ); + } + } + break; + case VCLEVENT_CONTROL_GETFOCUS: + case VCLEVENT_WINDOW_GETFOCUS: + { + if ( ( rVclWindowEvent.GetWindow()->IsCompoundControl() + && rVclWindowEvent.GetId() == VCLEVENT_CONTROL_GETFOCUS + ) + || ( !rVclWindowEvent.GetWindow()->IsCompoundControl() + && rVclWindowEvent.GetId() == VCLEVENT_WINDOW_GETFOCUS + ) + ) + { + if ( mpImpl->getFocusListeners().getLength() ) + { + ::com::sun::star::awt::FocusEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.FocusFlags = rVclWindowEvent.GetWindow()->GetGetFocusFlags(); + aEvent.Temporary = sal_False; + mpImpl->getFocusListeners().focusGained( aEvent ); + } + } + } + break; + case VCLEVENT_CONTROL_LOSEFOCUS: + case VCLEVENT_WINDOW_LOSEFOCUS: + { + if ( ( rVclWindowEvent.GetWindow()->IsCompoundControl() + && rVclWindowEvent.GetId() == VCLEVENT_CONTROL_LOSEFOCUS + ) + || ( !rVclWindowEvent.GetWindow()->IsCompoundControl() + && rVclWindowEvent.GetId() == VCLEVENT_WINDOW_LOSEFOCUS + ) + ) + { + if ( mpImpl->getFocusListeners().getLength() ) + { + ::com::sun::star::awt::FocusEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.FocusFlags = rVclWindowEvent.GetWindow()->GetGetFocusFlags(); + aEvent.Temporary = sal_False; + + Window* pNext = Application::GetFocusWindow(); + if ( pNext ) + { + // Bei zusammengesetzten Controls interessiert sich keiner fuer das Innenleben: + Window* pNextC = pNext; + while ( pNextC && !pNextC->IsCompoundControl() ) + pNextC = pNextC->GetParent(); + if ( pNextC ) + pNext = pNextC; + + pNext->GetComponentInterface( sal_True ); + aEvent.NextFocus = (::cppu::OWeakObject*)pNext->GetWindowPeer(); + } + mpImpl->getFocusListeners().focusLost( aEvent ); + } + } + } + break; + case VCLEVENT_WINDOW_MINIMIZE: + { + if ( mpImpl->getTopWindowListeners().getLength() ) + { + ::com::sun::star::lang::EventObject aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + mpImpl->getTopWindowListeners().windowMinimized( aEvent ); + } + } + break; + case VCLEVENT_WINDOW_NORMALIZE: + { + if ( mpImpl->getTopWindowListeners().getLength() ) + { + ::com::sun::star::lang::EventObject aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + mpImpl->getTopWindowListeners().windowNormalized( aEvent ); + } + } + break; + case VCLEVENT_WINDOW_KEYINPUT: + { + if ( mpImpl->getKeyListeners().getLength() ) + { + ::com::sun::star::awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent( + *(KeyEvent*)rVclWindowEvent.GetData(), *this + ) ); + mpImpl->getKeyListeners().keyPressed( aEvent ); + } + } + break; + case VCLEVENT_WINDOW_KEYUP: + { + if ( mpImpl->getKeyListeners().getLength() ) + { + ::com::sun::star::awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent( + *(KeyEvent*)rVclWindowEvent.GetData(), *this + ) ); + mpImpl->getKeyListeners().keyReleased( aEvent ); + } + } + break; + case VCLEVENT_WINDOW_COMMAND: + { + CommandEvent* pCmdEvt = (CommandEvent*)rVclWindowEvent.GetData(); + if ( mpImpl->getMouseListeners().getLength() && ( pCmdEvt->GetCommand() == COMMAND_CONTEXTMENU ) ) + { + // COMMAND_CONTEXTMENU als mousePressed mit PopupTrigger = sal_True versenden... + Point aWhere = static_cast< CommandEvent* >( rVclWindowEvent.GetData() )->GetMousePosPixel(); + if ( !pCmdEvt->IsMouseEvent() ) + { // for keyboard events, we set the coordinates to -1,-1. This is a slight HACK, but the current API + // handles a context menu command as special case of a mouse event, which is simply wrong. + // Without extending the API, we would not have another chance to notify listeners of a + // keyboard-triggered context menu request + // 102205 - 16.08.2002 - fs@openoffice.org + aWhere = Point( -1, -1 ); + } + + MouseEvent aMEvt( aWhere, 1, MOUSE_SIMPLECLICK, MOUSE_LEFT, 0 ); + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( aMEvt, *this ) ); + aEvent.PopupTrigger = sal_True; + mpImpl->notifyMouseEvent( aEvent, EVENT_MOUSE_PRESSED ); + } + } + break; + case VCLEVENT_WINDOW_MOUSEMOVE: + { + MouseEvent* pMouseEvt = (MouseEvent*)rVclWindowEvent.GetData(); + if ( mpImpl->getMouseListeners().getLength() && ( pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow() ) ) + { + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt, *this ) ); + mpImpl->notifyMouseEvent( + aEvent, + pMouseEvt->IsEnterWindow() ? EVENT_MOUSE_ENTERED : EVENT_MOUSE_EXITED + ); + } + + if ( mpImpl->getMouseMotionListeners().getLength() && !pMouseEvt->IsEnterWindow() && !pMouseEvt->IsLeaveWindow() ) + { + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt, *this ) ); + aEvent.ClickCount = 0; // #92138# + if ( pMouseEvt->GetMode() & MOUSE_SIMPLEMOVE ) + mpImpl->getMouseMotionListeners().mouseMoved( aEvent ); + else + mpImpl->getMouseMotionListeners().mouseDragged( aEvent ); + } + } + break; + case VCLEVENT_WINDOW_MOUSEBUTTONDOWN: + { + if ( mpImpl->getMouseListeners().getLength() ) + { + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *(MouseEvent*)rVclWindowEvent.GetData(), *this ) ); + mpImpl->notifyMouseEvent( aEvent, EVENT_MOUSE_PRESSED ); + } + } + break; + case VCLEVENT_WINDOW_MOUSEBUTTONUP: + { + if ( mpImpl->getMouseListeners().getLength() ) + { + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *(MouseEvent*)rVclWindowEvent.GetData(), *this ) ); + mpImpl->notifyMouseEvent( aEvent, EVENT_MOUSE_RELEASED ); + } + } + break; + case VCLEVENT_WINDOW_STARTDOCKING: + { + if ( mpImpl->getDockableWindowListeners().getLength() ) + { + DockingData *pData = (DockingData*)rVclWindowEvent.GetData(); + + if( pData ) + { + ::com::sun::star::awt::DockingEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.TrackingRectangle = AWTRectangle( pData->maTrackRect ); + aEvent.MousePos.X = pData->maMousePos.X(); + aEvent.MousePos.Y = pData->maMousePos.Y(); + aEvent.bLiveMode = pData->mbLivemode; + aEvent.bInteractive = pData->mbInteractive; + + mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::startDocking, aEvent ); + } + } + } + break; + case VCLEVENT_WINDOW_DOCKING: + { + if ( mpImpl->getDockableWindowListeners().getLength() ) + { + DockingData *pData = (DockingData*)rVclWindowEvent.GetData(); + + if( pData ) + { + ::com::sun::star::awt::DockingEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.TrackingRectangle = AWTRectangle( pData->maTrackRect ); + aEvent.MousePos.X = pData->maMousePos.X(); + aEvent.MousePos.Y = pData->maMousePos.Y(); + aEvent.bLiveMode = pData->mbLivemode; + aEvent.bInteractive = pData->mbInteractive; + + Reference< XDockableWindowListener > xFirstListener; + ::cppu::OInterfaceIteratorHelper aIter( mpImpl->getDockableWindowListeners() ); + while ( aIter.hasMoreElements() && !xFirstListener.is() ) + { + xFirstListener.set( aIter.next(), UNO_QUERY ); + } + + ::com::sun::star::awt::DockingData aDockingData = + xFirstListener->docking( aEvent ); + pData->maTrackRect = VCLRectangle( aDockingData.TrackingRectangle ); + pData->mbFloating = aDockingData.bFloating; + } + } + } + break; + case VCLEVENT_WINDOW_ENDDOCKING: + { + if ( mpImpl->getDockableWindowListeners().getLength() ) + { + EndDockingData *pData = (EndDockingData*)rVclWindowEvent.GetData(); + + if( pData ) + { + ::com::sun::star::awt::EndDockingEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.WindowRectangle = AWTRectangle( pData->maWindowRect ); + aEvent.bFloating = pData->mbFloating; + aEvent.bCancelled = pData->mbCancelled; + mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::endDocking, aEvent ); + } + } + } + break; + case VCLEVENT_WINDOW_PREPARETOGGLEFLOATING: + { + if ( mpImpl->getDockableWindowListeners().getLength() ) + { + BOOL *p_bFloating = (BOOL*)rVclWindowEvent.GetData(); + + ::com::sun::star::lang::EventObject aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + + Reference< XDockableWindowListener > xFirstListener; + ::cppu::OInterfaceIteratorHelper aIter( mpImpl->getDockableWindowListeners() ); + while ( aIter.hasMoreElements() && !xFirstListener.is() ) + { + xFirstListener.set( aIter.next(), UNO_QUERY ); + } + + *p_bFloating = xFirstListener->prepareToggleFloatingMode( aEvent ); + } + } + break; + case VCLEVENT_WINDOW_TOGGLEFLOATING: + { + if ( mpImpl->getDockableWindowListeners().getLength() ) + { + ::com::sun::star::lang::EventObject aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::toggleFloatingMode, aEvent ); + } + } + break; + case VCLEVENT_WINDOW_ENDPOPUPMODE: + { + if ( mpImpl->getDockableWindowListeners().getLength() ) + { + EndPopupModeData *pData = (EndPopupModeData*)rVclWindowEvent.GetData(); + + if( pData ) + { + ::com::sun::star::awt::EndPopupModeEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.FloatingPosition.X = pData->maFloatingPos.X(); + aEvent.FloatingPosition.Y = pData->maFloatingPos.Y(); + aEvent.bTearoff = pData->mbTearoff; + mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::endPopupMode, aEvent ); + } + } + } + break; + + } +} + +uno::Reference< accessibility::XAccessibleContext > VCLXWindow::CreateAccessibleContext() +{ + ::vos::OGuard aGuard( GetMutex() ); + return getAccessibleFactory().createAccessibleContext( this ); +} + +void VCLXWindow::SetSynthesizingVCLEvent( sal_Bool _b ) +{ + mpImpl->mbSynthesizingVCLEvent = _b; +} + +BOOL VCLXWindow::IsSynthesizingVCLEvent() const +{ + return mpImpl->mbSynthesizingVCLEvent; +} + +Size VCLXWindow::ImplCalcWindowSize( const Size& rOutSz ) const +{ + Size aSz = rOutSz; + + Window* pWindow = GetWindow(); + if ( pWindow ) + { + sal_Int32 nLeft, nTop, nRight, nBottom; + pWindow->GetBorder( nLeft, nTop, nRight, nBottom ); + aSz.Width() += nLeft+nRight; + aSz.Height() += nTop+nBottom; + } + return aSz; +} + + +// ::com::sun::star::lang::XUnoTunnel +IMPL_XUNOTUNNEL2( VCLXWindow, VCLXDevice ) + +// ::com::sun::star::lang::Component +void VCLXWindow::dispose( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + mpImpl->mxViewGraphics = NULL; + + if ( !mpImpl->mbDisposing ) + { + mpImpl->mbDisposing = true; + + mpImpl->disposing(); + + if ( GetWindow() ) + { + OutputDevice* pOutDev = GetOutputDevice(); + SetWindow( NULL ); // Damit ggf. Handler abgemeldet werden (virtuell). + SetOutputDevice( pOutDev ); + DestroyOutputDevice(); + } + + // #i14103# dispose the accessible context after the window has been destroyed, + // otherwise the old value in the child event fired in VCLXAccessibleComponent::ProcessWindowEvent() + // for VCLEVENT_WINDOW_CHILDDESTROYED contains a reference to an already disposed accessible object + try + { + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComponent( mpImpl->mxAccessibleContext, ::com::sun::star::uno::UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); + } + catch ( const ::com::sun::star::uno::Exception& ) + { + DBG_ERROR( "VCLXWindow::dispose: could not dispose the accessible context!" ); + } + mpImpl->mxAccessibleContext.clear(); + + mpImpl->mbDisposing = false; + } +} + +void VCLXWindow::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + mpImpl->getEventListeners().addInterface( rxListener ); +} + +void VCLXWindow::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + mpImpl->getEventListeners().removeInterface( rxListener ); +} + + +// ::com::sun::star::awt::XWindow +void VCLXWindow::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { + if( Window::GetDockingManager()->IsDockable( GetWindow() ) ) + Window::GetDockingManager()->SetPosSizePixel( GetWindow() , X, Y, Width, Height, Flags ); + else + GetWindow()->SetPosSizePixel( X, Y, Width, Height, Flags ); + } +} + +::com::sun::star::awt::Rectangle VCLXWindow::getPosSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::awt::Rectangle aBounds; + if ( GetWindow() ) + { + if( Window::GetDockingManager()->IsDockable( GetWindow() ) ) + aBounds = AWTRectangle( Window::GetDockingManager()->GetPosSizePixel( GetWindow() ) ); + else + aBounds = AWTRectangle( Rectangle( GetWindow()->GetPosPixel(), GetWindow()->GetSizePixel() ) ); + } + + return aBounds; +} + +void VCLXWindow::setVisible( sal_Bool bVisible ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + { +/* + if ( bVisible ) + { + // #57167# TopWindows mit unsichtbaren Parent anzeigen... + ::com::sun::star::uno::Any aTest = queryInterface( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTopWindow >*) 0 ) ); + if ( aTest.hasValue() ) + { + Window* pParent = pWindow->GetWindow( WINDOW_PARENTOVERLAP ); + if ( pParent && !pParent->IsReallyVisible() ) + pWindow->SetParent( pWindow->GetWindow( WINDOW_FRAME ) ); + } + } +*/ + mpImpl->setDirectVisible( bVisible ); + pWindow->Show( bVisible && mpImpl->isEnableVisible() ); + } +} + +void VCLXWindow::setEnable( sal_Bool bEnable ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + { + pWindow->Enable( bEnable, FALSE ); // #95824# without children! + pWindow->EnableInput( bEnable ); + } +} + +void VCLXWindow::setFocus( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + GetWindow()->GrabFocus(); +} + +void VCLXWindow::addWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + mpImpl->getWindowListeners().addInterface( rxListener ); + + Reference< XWindowListener2 > xListener2( rxListener, UNO_QUERY ); + if ( xListener2.is() ) + mpImpl->getWindow2Listeners().addInterface( xListener2 ); + + // #100119# Get all resize events, even if height or width 0, or invisible + if ( GetWindow() ) + GetWindow()->EnableAllResize( TRUE ); +} + +void VCLXWindow::removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Reference< XWindowListener2 > xListener2( rxListener, UNO_QUERY ); + if ( xListener2.is() ) + mpImpl->getWindow2Listeners().removeInterface( xListener2 ); + + mpImpl->getWindowListeners().removeInterface( rxListener ); +} + +void VCLXWindow::addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + mpImpl->getFocusListeners().addInterface( rxListener ); +} + +void VCLXWindow::removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + mpImpl->getFocusListeners().removeInterface( rxListener ); +} + +void VCLXWindow::addKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + mpImpl->getKeyListeners().addInterface( rxListener ); +} + +void VCLXWindow::removeKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + mpImpl->getKeyListeners().removeInterface( rxListener ); +} + +void VCLXWindow::addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + mpImpl->getMouseListeners().addInterface( rxListener ); +} + +void VCLXWindow::removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + mpImpl->getMouseListeners().removeInterface( rxListener ); +} + +void VCLXWindow::addMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + mpImpl->getMouseMotionListeners().addInterface( rxListener ); +} + +void VCLXWindow::removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + mpImpl->getMouseMotionListeners().removeInterface( rxListener ); +} + +void VCLXWindow::addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + mpImpl->getPaintListeners().addInterface( rxListener ); +} + +void VCLXWindow::removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + mpImpl->getPaintListeners().removeInterface( rxListener ); +} + +// ::com::sun::star::awt::XWindowPeer +::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > VCLXWindow::getToolkit( ) throw(::com::sun::star::uno::RuntimeException) +{ + // no guard. nothing to guard here. + // 82463 - 12/21/00 - fs + return Application::GetVCLToolkit(); +} + +void VCLXWindow::setPointer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPointer >& rxPointer ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + VCLXPointer* pPointer = VCLXPointer::GetImplementation( rxPointer ); + if ( pPointer ) + { + mpImpl->mxPointer = rxPointer; + if ( GetWindow() ) + GetWindow()->SetPointer( pPointer->GetPointer() ); + } +} + +void VCLXWindow::setBackground( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { + Color aColor( (sal_uInt32)nColor ); + GetWindow()->SetBackground( aColor ); + GetWindow()->SetControlBackground( aColor ); + + WindowType eWinType = GetWindow()->GetType(); + if ( ( eWinType == WINDOW_WINDOW ) || + ( eWinType == WINDOW_WORKWINDOW ) || + ( eWinType == WINDOW_FLOATINGWINDOW ) ) + { + GetWindow()->Invalidate(); + } + } +} + +void VCLXWindow::invalidate( sal_Int16 nInvalidateFlags ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + GetWindow()->Invalidate( (sal_uInt16) nInvalidateFlags ); +} + +void VCLXWindow::invalidateRect( const ::com::sun::star::awt::Rectangle& rRect, sal_Int16 nInvalidateFlags ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + GetWindow()->Invalidate( VCLRectangle(rRect), (sal_uInt16) nInvalidateFlags ); +} + + +// ::com::sun::star::awt::XVclWindowPeer +sal_Bool VCLXWindow::isChild( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& rxPeer ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Bool bIsChild = sal_False; + Window* pWindow = GetWindow(); + if ( pWindow ) + { + Window* pPeerWindow = VCLUnoHelper::GetWindow( rxPeer ); + bIsChild = pPeerWindow && pWindow->IsChild( pPeerWindow ); + } + + return bIsChild; +} + +void VCLXWindow::setDesignMode( sal_Bool bOn ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + mpImpl->mbDesignMode = bOn; +} + +sal_Bool VCLXWindow::isDesignMode( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + return mpImpl->mbDesignMode; +} + +void VCLXWindow::enableClipSiblings( sal_Bool bClip ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + GetWindow()->EnableClipSiblings( bClip ); +} + +void VCLXWindow::setForeground( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { + Color aColor( (sal_uInt32)nColor ); + GetWindow()->SetControlForeground( aColor ); + } +} + +void VCLXWindow::setControlFont( const ::com::sun::star::awt::FontDescriptor& rFont ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + GetWindow()->SetControlFont( VCLUnoHelper::CreateFont( rFont, GetWindow()->GetControlFont() ) ); +} + +void VCLXWindow::getStyles( sal_Int16 nType, ::com::sun::star::awt::FontDescriptor& Font, sal_Int32& ForegroundColor, sal_Int32& BackgroundColor ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { + const StyleSettings& rStyleSettings = GetWindow()->GetSettings().GetStyleSettings(); + + switch ( nType ) + { + case ::com::sun::star::awt::Style::FRAME: + { + Font = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() ); + ForegroundColor = rStyleSettings.GetWindowTextColor().GetColor(); + BackgroundColor = rStyleSettings.GetWindowColor().GetColor(); + } + break; + case ::com::sun::star::awt::Style::DIALOG: + { + Font = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() ); + ForegroundColor = rStyleSettings.GetDialogTextColor().GetColor(); + BackgroundColor = rStyleSettings.GetDialogColor().GetColor(); + } + break; + default: DBG_ERROR( "VCLWindow::getStyles() - unknown Type" ); + } + + } +} + +namespace toolkit +{ + static void setColorSettings( Window* _pWindow, const ::com::sun::star::uno::Any& _rValue, + void (StyleSettings::*pSetter)( const Color& ), const Color& (StyleSettings::*pGetter)( ) const ) + { + sal_Int32 nColor = 0; + if ( !( _rValue >>= nColor ) ) + nColor = (Application::GetSettings().GetStyleSettings().*pGetter)().GetColor(); + + AllSettings aSettings = _pWindow->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + + (aStyleSettings.*pSetter)( Color( nColor ) ); + + aSettings.SetStyleSettings( aStyleSettings ); + _pWindow->SetSettings( aSettings, TRUE ); + } +} + +// Terminated by BASEPROPERTY_NOTFOUND (or 0) +void VCLXWindow::PushPropertyIds( std::list< sal_uInt16 > &rIds, + int nFirstId, ...) +{ + va_list pVarArgs; + va_start( pVarArgs, nFirstId ); + + for ( int nId = nFirstId; nId != BASEPROPERTY_NOTFOUND; + nId = va_arg( pVarArgs, int ) ) + rIds.push_back( (sal_uInt16) nId ); + + va_end( pVarArgs ); +} + +void VCLXWindow::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds, bool bWithDefaults ) +{ + // These are common across ~all VCLXWindow derived classes + if( bWithDefaults ) + PushPropertyIds( rIds, + BASEPROPERTY_ALIGN, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_ENABLED, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_TEXT, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_ENABLEVISIBLE, // for visibility + BASEPROPERTY_TABSTOP, + 0); + + // lovely hack from: + // void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId ) + std::list< sal_uInt16 >::const_iterator iter; + for( iter = rIds.begin(); iter != rIds.end(); iter++) { + if( *iter == BASEPROPERTY_FONTDESCRIPTOR ) + { + // some properties are not included in the FontDescriptor, but everytime + // when we have a FontDescriptor we want to have these properties too. + // => Easier to register the here, istead everywhere where I register the FontDescriptor... + + rIds.push_back( BASEPROPERTY_TEXTCOLOR ); + rIds.push_back( BASEPROPERTY_TEXTLINECOLOR ); + rIds.push_back( BASEPROPERTY_FONTRELIEF ); + rIds.push_back( BASEPROPERTY_FONTEMPHASISMARK ); + break; + } + } +} + +void VCLXWindow::GetPropertyIds( std::list< sal_uInt16 >& _out_rIds ) +{ + return ImplGetPropertyIds( _out_rIds, mpImpl->mbWithDefaultProps ); +} + +::cppu::OInterfaceContainerHelper& VCLXWindow::GetContainerListeners() +{ + return mpImpl->getContainerListeners(); +} + +::cppu::OInterfaceContainerHelper& VCLXWindow::GetTopWindowListeners() +{ + return mpImpl->getTopWindowListeners(); +} + +namespace +{ + void lcl_updateWritingMode( Window& _rWindow, const sal_Int16 _nWritingMode, const sal_Int16 _nContextWritingMode ) + { + BOOL bEnableRTL = FALSE; + switch ( _nWritingMode ) + { + case WritingMode2::LR_TB: bEnableRTL = FALSE; break; + case WritingMode2::RL_TB: bEnableRTL = TRUE; break; + case WritingMode2::CONTEXT: + { + // consult our ContextWritingMode. If it has an explicit RTL/LTR value, then use + // it. If it doesn't (but is CONTEXT itself), then just ask the parent window of our + // own window for its RTL mode + switch ( _nContextWritingMode ) + { + case WritingMode2::LR_TB: bEnableRTL = FALSE; break; + case WritingMode2::RL_TB: bEnableRTL = TRUE; break; + case WritingMode2::CONTEXT: + { + const Window* pParent = _rWindow.GetParent(); + OSL_ENSURE( pParent, "lcl_updateWritingMode: cannot determine context's writing mode!" ); + if ( pParent ) + bEnableRTL = pParent->IsRTLEnabled(); + } + break; + } + } + break; + default: + OSL_ENSURE( false, "lcl_updateWritingMode: unsupported WritingMode!" ); + } // switch ( nWritingMode ) + + _rWindow.EnableRTL( bEnableRTL ); + } +} + +void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( !pWindow ) + return; + + sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; + + WindowType eWinType = pWindow->GetType(); + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_REFERENCE_DEVICE: + { + Control* pControl = dynamic_cast< Control* >( pWindow ); + OSL_ENSURE( pControl, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" ); + if ( !pControl ) + break; + Reference< XDevice > xDevice( Value, UNO_QUERY ); + OutputDevice* pDevice = VCLUnoHelper::GetOutputDevice( xDevice ); + pControl->SetReferenceDevice( pDevice ); + } + break; + + case BASEPROPERTY_CONTEXT_WRITING_MODE: + { + OSL_VERIFY( Value >>= mpImpl->mnContextWritingMode ); + if ( mpImpl->mnWritingMode == WritingMode2::CONTEXT ) + lcl_updateWritingMode( *pWindow, mpImpl->mnWritingMode, mpImpl->mnContextWritingMode ); + } + break; + + case BASEPROPERTY_WRITING_MODE: + { + sal_Bool bProperType = ( Value >>= mpImpl->mnWritingMode ); + OSL_ENSURE( bProperType, "VCLXWindow::setProperty( 'WritingMode' ): illegal value type!" ); + if ( bProperType ) + lcl_updateWritingMode( *pWindow, mpImpl->mnWritingMode, mpImpl->mnContextWritingMode ); + } + break; + + case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR: + { + sal_uInt16 nWheelBehavior( MouseWheelBehavior::SCROLL_FOCUS_ONLY ); + OSL_VERIFY( Value >>= nWheelBehavior ); + + AllSettings aSettings = pWindow->GetSettings(); + MouseSettings aMouseSettings = aSettings.GetMouseSettings(); + + USHORT nVclBehavior( MOUSE_WHEEL_FOCUS_ONLY ); + switch ( nWheelBehavior ) + { + case MouseWheelBehavior::SCROLL_DISABLED: nVclBehavior = MOUSE_WHEEL_DISABLE; break; + case MouseWheelBehavior::SCROLL_FOCUS_ONLY: nVclBehavior = MOUSE_WHEEL_FOCUS_ONLY; break; + case MouseWheelBehavior::SCROLL_ALWAYS: nVclBehavior = MOUSE_WHEEL_ALWAYS; break; + default: + OSL_ENSURE( false, "VCLXWindow::setProperty( 'MouseWheelBehavior' ): illegal property value!" ); + } + + aMouseSettings.SetWheelBehavior( nWheelBehavior ); + aSettings.SetMouseSettings( aMouseSettings ); + pWindow->SetSettings( aSettings, TRUE ); + } + break; + + case BASEPROPERTY_NATIVE_WIDGET_LOOK: + { + sal_Bool bEnable( sal_True ); + OSL_VERIFY( Value >>= bEnable ); + pWindow->EnableNativeWidget( bEnable ); + } + break; + + case BASEPROPERTY_PLUGINPARENT: + { + // set parent handle + SetSystemParent_Impl( Value ); + } + break; + + case BASEPROPERTY_ENABLED: + { + sal_Bool b = sal_Bool(); + if ( Value >>= b ) + setEnable( b ); + } + break; + case BASEPROPERTY_ENABLEVISIBLE: + { + sal_Bool b = sal_False; + if ( Value >>= b ) + { + if( b != mpImpl->isEnableVisible() ) + { + mpImpl->setEnableVisible( b ); + pWindow->Show( b && mpImpl->isDirectVisible() ); + } + } + } + break; + case BASEPROPERTY_TEXT: + case BASEPROPERTY_LABEL: + case BASEPROPERTY_TITLE: + { + ::rtl::OUString aText; + if ( Value >>= aText ) + { + switch (eWinType) + { + case WINDOW_OKBUTTON: + case WINDOW_CANCELBUTTON: + case WINDOW_HELPBUTTON: + // Standard Button: overwrite only if not empty. + if (aText.getLength()) + pWindow->SetText( aText ); + break; + + default: + pWindow->SetText( aText ); + break; + } + } + } + break; + case BASEPROPERTY_ACCESSIBLENAME: + { + ::rtl::OUString aText; + if ( Value >>= aText ) + pWindow->SetAccessibleName( aText ); + } + break; + case BASEPROPERTY_HELPURL: + { + ::rtl::OUString aURL; + if ( Value >>= aURL ) + { + String aHelpURL( aURL ); + String aPattern( RTL_CONSTASCII_USTRINGPARAM( "HID:" ) ); + if ( aHelpURL.CompareIgnoreCaseToAscii( aPattern, aPattern.Len() ) == COMPARE_EQUAL ) + { + String aID = aHelpURL.Copy( aPattern.Len() ); + pWindow->SetHelpId( aID.ToInt32() ); + } + else + { + pWindow->SetSmartHelpId( SmartId( aHelpURL ) ); + } + } + } + break; + case BASEPROPERTY_HELPTEXT: + { + ::rtl::OUString aHelpText; + if ( Value >>= aHelpText ) + { + pWindow->SetQuickHelpText( aHelpText ); + } + } + break; + case BASEPROPERTY_FONTDESCRIPTOR: + { + if ( bVoid ) + pWindow->SetControlFont( Font() ); + else + { + ::com::sun::star::awt::FontDescriptor aFont; + if ( Value >>= aFont ) + pWindow->SetControlFont( VCLUnoHelper::CreateFont( aFont, pWindow->GetControlFont() ) ); + } + } + break; + case BASEPROPERTY_FONTRELIEF: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + { + Font aFont = pWindow->GetControlFont(); + aFont.SetRelief( (FontRelief)n ); + pWindow->SetControlFont( aFont ); + } + } + break; + case BASEPROPERTY_FONTEMPHASISMARK: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + { + Font aFont = pWindow->GetControlFont(); + aFont.SetEmphasisMark( n ); + pWindow->SetControlFont( aFont ); + } + } + break; + case BASEPROPERTY_BACKGROUNDCOLOR: + if ( bVoid ) + { + switch ( eWinType ) + { + // set dialog color for default + case WINDOW_DIALOG: + case WINDOW_MESSBOX: + case WINDOW_INFOBOX: + case WINDOW_WARNINGBOX: + case WINDOW_ERRORBOX: + case WINDOW_QUERYBOX: + case WINDOW_TABPAGE: + { + Color aColor = pWindow->GetSettings().GetStyleSettings().GetDialogColor(); + pWindow->SetBackground( aColor ); + pWindow->SetControlBackground( aColor ); + break; + } + + case WINDOW_FIXEDTEXT: + case WINDOW_CHECKBOX: + case WINDOW_RADIOBUTTON: + case WINDOW_GROUPBOX: + case WINDOW_FIXEDLINE: + { + // support transparency only for special controls + pWindow->SetBackground(); + pWindow->SetControlBackground(); + pWindow->SetPaintTransparent( TRUE ); + break; + } + + default: + { + // default code which enables transparency for + // compound controls. It's not real transparency + // as most of these controls repaint their client + // area completely new. + if ( pWindow->IsCompoundControl() ) + pWindow->SetBackground(); + pWindow->SetControlBackground(); + break; + } + } + } + else + { + sal_Int32 nColor = 0; + if ( Value >>= nColor ) + { + Color aColor( nColor ); + pWindow->SetControlBackground( aColor ); + pWindow->SetBackground( aColor ); + switch ( eWinType ) + { + // reset paint transparent mode + case WINDOW_FIXEDTEXT: + case WINDOW_CHECKBOX: + case WINDOW_RADIOBUTTON: + case WINDOW_GROUPBOX: + case WINDOW_FIXEDLINE: + pWindow->SetPaintTransparent( FALSE ); + default: ; + } + pWindow->Invalidate(); // Falls das Control nicht drauf reagiert + } + } + break; + case BASEPROPERTY_TEXTCOLOR: + if ( bVoid ) + { + pWindow->SetControlForeground(); + } + else + { + sal_Int32 nColor = 0; + if ( Value >>= nColor ) + { + Color aColor( nColor ); + pWindow->SetTextColor( aColor ); + pWindow->SetControlForeground( aColor ); + } + } + break; + case BASEPROPERTY_TEXTLINECOLOR: + if ( bVoid ) + { + pWindow->SetTextLineColor(); + } + else + { + sal_Int32 nColor = 0; + if ( Value >>= nColor ) + { + Color aColor( nColor ); + pWindow->SetTextLineColor( aColor ); + } + } + break; + case BASEPROPERTY_FILLCOLOR: + if ( bVoid ) + pWindow->SetFillColor(); + else + { + sal_Int32 nColor = 0; + if ( Value >>= nColor ) + { + Color aColor( nColor ); + pWindow->SetFillColor( aColor ); + } + } + break; + case BASEPROPERTY_LINECOLOR: + if ( bVoid ) + pWindow->SetLineColor(); + else + { + sal_Int32 nColor = 0; + if ( Value >>= nColor ) + { + Color aColor( nColor ); + pWindow->SetLineColor( aColor ); + } + } + break; + case BASEPROPERTY_BORDER: + { + WinBits nStyle = pWindow->GetStyle(); + sal_uInt16 nBorder = 0; + Value >>= nBorder; + if ( !nBorder ) + { + pWindow->SetStyle( nStyle & ~WB_BORDER ); + } + else + { + pWindow->SetStyle( nStyle | WB_BORDER ); + pWindow->SetBorderStyle( nBorder ); + } + } + break; + case BASEPROPERTY_TABSTOP: + { + WinBits nStyle = pWindow->GetStyle() & ~WB_TABSTOP; + if ( !bVoid ) + { + sal_Bool bTab = false; + Value >>= bTab; + if ( bTab ) + nStyle |= WB_TABSTOP; + else + nStyle |= WB_NOTABSTOP; + } + pWindow->SetStyle( nStyle ); + } + break; + case BASEPROPERTY_VERTICALALIGN: + { + VerticalAlignment eAlign = VerticalAlignment_MAKE_FIXED_SIZE; + WinBits nStyle = pWindow->GetStyle(); + nStyle &= ~(WB_TOP|WB_VCENTER|WB_BOTTOM); + if ( !bVoid ) + Value >>= eAlign; + switch ( eAlign ) + { + case VerticalAlignment_TOP: + nStyle |= WB_TOP; + break; + case VerticalAlignment_MIDDLE: + nStyle |= WB_VCENTER; + break; + case VerticalAlignment_BOTTOM: + nStyle |= WB_BOTTOM; + break; + default: ; // for warning free code, MAKE_FIXED_SIZE + } + pWindow->SetStyle( nStyle ); + } + break; + case BASEPROPERTY_ALIGN: + { + sal_Int16 nAlign = PROPERTY_ALIGN_LEFT; + switch ( eWinType ) + { + case WINDOW_COMBOBOX: + case WINDOW_BUTTON: + case WINDOW_PUSHBUTTON: + case WINDOW_OKBUTTON: + case WINDOW_CANCELBUTTON: + case WINDOW_HELPBUTTON: + nAlign = PROPERTY_ALIGN_CENTER; + // no break here! + case WINDOW_FIXEDTEXT: + case WINDOW_EDIT: + case WINDOW_MULTILINEEDIT: + case WINDOW_CHECKBOX: + case WINDOW_RADIOBUTTON: + case WINDOW_LISTBOX: + { + WinBits nStyle = pWindow->GetStyle(); + nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT); + if ( !bVoid ) + Value >>= nAlign; + if ( nAlign == PROPERTY_ALIGN_LEFT ) + nStyle |= WB_LEFT; + else if ( nAlign == PROPERTY_ALIGN_CENTER ) + nStyle |= WB_CENTER; + else + nStyle |= WB_RIGHT; + pWindow->SetStyle( nStyle ); + } + break; + } + } + break; + case BASEPROPERTY_MULTILINE: + { + if ( ( eWinType == WINDOW_FIXEDTEXT ) + || ( eWinType == WINDOW_CHECKBOX ) + || ( eWinType == WINDOW_RADIOBUTTON ) + || ( eWinType == WINDOW_BUTTON ) + || ( eWinType == WINDOW_PUSHBUTTON ) + || ( eWinType == WINDOW_OKBUTTON ) + || ( eWinType == WINDOW_CANCELBUTTON ) + || ( eWinType == WINDOW_HELPBUTTON ) + ) + { + WinBits nStyle = pWindow->GetStyle(); + sal_Bool bMulti = false; + Value >>= bMulti; + if ( bMulti ) + nStyle |= WB_WORDBREAK; + else + nStyle &= ~WB_WORDBREAK; + pWindow->SetStyle( nStyle ); + } + } + break; + case BASEPROPERTY_ORIENTATION: + { + switch ( eWinType ) + { + case WINDOW_FIXEDLINE: + { + sal_Int32 nOrientation = 0; + if ( Value >>= nOrientation ) + { + WinBits nStyle = pWindow->GetStyle(); + nStyle &= ~(WB_HORZ|WB_VERT); + if ( nOrientation == 0 ) + nStyle |= WB_HORZ; + else + nStyle |= WB_VERT; + + pWindow->SetStyle( nStyle ); + } + } + break; + } + } + break; + case BASEPROPERTY_AUTOMNEMONICS: + { + sal_Bool bAutoMnemonics = false; + Value >>= bAutoMnemonics; + AllSettings aSettings = pWindow->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + if ( aStyleSettings.GetAutoMnemonic() != bAutoMnemonics ) + { + aStyleSettings.SetAutoMnemonic( bAutoMnemonics ); + aSettings.SetStyleSettings( aStyleSettings ); + pWindow->SetSettings( aSettings ); + } + } + break; + case BASEPROPERTY_MOUSETRANSPARENT: + { + sal_Bool bMouseTransparent = false; + Value >>= bMouseTransparent; + pWindow->SetMouseTransparent( bMouseTransparent ); + } + break; + case BASEPROPERTY_PAINTTRANSPARENT: + { + sal_Bool bPaintTransparent = false; + Value >>= bPaintTransparent; + pWindow->SetPaintTransparent( bPaintTransparent ); +// pWindow->SetBackground(); + } + break; + + case BASEPROPERTY_REPEAT: + { + sal_Bool bRepeat( FALSE ); + Value >>= bRepeat; + + WinBits nStyle = pWindow->GetStyle(); + if ( bRepeat ) + nStyle |= WB_REPEAT; + else + nStyle &= ~WB_REPEAT; + pWindow->SetStyle( nStyle ); + } + break; + + case BASEPROPERTY_REPEAT_DELAY: + { + sal_Int32 nRepeatDelay = 0; + if ( Value >>= nRepeatDelay ) + { + AllSettings aSettings = pWindow->GetSettings(); + MouseSettings aMouseSettings = aSettings.GetMouseSettings(); + + aMouseSettings.SetButtonRepeat( nRepeatDelay ); + aSettings.SetMouseSettings( aMouseSettings ); + + pWindow->SetSettings( aSettings, TRUE ); + } + } + break; + + case BASEPROPERTY_SYMBOL_COLOR: + ::toolkit::setColorSettings( pWindow, Value, &StyleSettings::SetButtonTextColor, &StyleSettings::GetButtonTextColor ); + break; + + case BASEPROPERTY_BORDERCOLOR: + ::toolkit::setColorSettings( pWindow, Value, &StyleSettings::SetMonoColor, &StyleSettings::GetMonoColor); + break; + case BASEPROPERTY_DEFAULTCONTROL: + { + rtl::OUString aName; + Value >>= aName; + break; + } + } +} + +::com::sun::star::uno::Any VCLXWindow::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + if ( GetWindow() ) + { + WindowType eWinType = GetWindow()->GetType(); + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_REFERENCE_DEVICE: + { + Control* pControl = dynamic_cast< Control* >( GetWindow() ); + OSL_ENSURE( pControl, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" ); + if ( !pControl ) + break; + + VCLXDevice* pDevice = new VCLXDevice; + pDevice->SetOutputDevice( pControl->GetReferenceDevice() ); + aProp <<= Reference< XDevice >( pDevice ); + } + break; + + case BASEPROPERTY_CONTEXT_WRITING_MODE: + aProp <<= mpImpl->mnContextWritingMode; + break; + + case BASEPROPERTY_WRITING_MODE: + aProp <<= mpImpl->mnWritingMode; + break; + + case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR: + { + USHORT nVclBehavior = GetWindow()->GetSettings().GetMouseSettings().GetWheelBehavior(); + sal_Int16 nBehavior = MouseWheelBehavior::SCROLL_FOCUS_ONLY; + switch ( nVclBehavior ) + { + case MOUSE_WHEEL_DISABLE: nBehavior = MouseWheelBehavior::SCROLL_DISABLED; break; + case MOUSE_WHEEL_FOCUS_ONLY: nBehavior = MouseWheelBehavior::SCROLL_FOCUS_ONLY; break; + case MOUSE_WHEEL_ALWAYS: nBehavior = MouseWheelBehavior::SCROLL_ALWAYS; break; + default: + OSL_ENSURE( false, "VCLXWindow::getProperty( 'MouseWheelBehavior' ): illegal VCL value!" ); + } + aProp <<= nBehavior; + } + break; + + case BASEPROPERTY_NATIVE_WIDGET_LOOK: + aProp <<= (sal_Bool) GetWindow()->IsNativeWidgetEnabled(); + break; + + case BASEPROPERTY_ENABLED: + aProp <<= (sal_Bool) GetWindow()->IsEnabled(); + break; + + case BASEPROPERTY_ENABLEVISIBLE: + aProp <<= (sal_Bool) mpImpl->isEnableVisible(); + break; + + case BASEPROPERTY_HIGHCONTRASTMODE: + aProp <<= (sal_Bool) GetWindow()->GetSettings().GetStyleSettings().GetHighContrastMode(); + break; + + case BASEPROPERTY_TEXT: + case BASEPROPERTY_LABEL: + case BASEPROPERTY_TITLE: + { + ::rtl::OUString aText = GetWindow()->GetText(); + aProp <<= aText; + } + break; + case BASEPROPERTY_ACCESSIBLENAME: + { + ::rtl::OUString aText = GetWindow()->GetAccessibleName(); + aProp <<= aText; + } + break; + case BASEPROPERTY_HELPTEXT: + { + ::rtl::OUString aText = GetWindow()->GetQuickHelpText(); + aProp <<= aText; + } + break; + case BASEPROPERTY_HELPURL: + { + SmartId aSmartId = GetWindow()->GetSmartHelpId(); + if( aSmartId.HasString() ) + { + String aStrHelpId = aSmartId.GetStr(); + aProp <<= ::rtl::OUString( aStrHelpId ); + } + else + { + ::rtl::OUStringBuffer aURL; + aURL.appendAscii( "HID:" ); + aURL.append( (sal_Int32) GetWindow()->GetHelpId() ); + aProp <<= aURL.makeStringAndClear(); + } + } + break; + case BASEPROPERTY_FONTDESCRIPTOR: + { + Font aFont = GetWindow()->GetControlFont(); + ::com::sun::star::awt::FontDescriptor aFD = VCLUnoHelper::CreateFontDescriptor( aFont ); + aProp <<= aFD; + } + break; + case BASEPROPERTY_BACKGROUNDCOLOR: + aProp <<= (sal_Int32) GetWindow()->GetControlBackground().GetColor(); + break; + case BASEPROPERTY_DISPLAYBACKGROUNDCOLOR: + aProp <<= (sal_Int32) GetWindow()->GetDisplayBackground().GetColor().GetColor(); + break; + case BASEPROPERTY_FONTRELIEF: + aProp <<= (sal_Int16) GetWindow()->GetControlFont().GetRelief(); + break; + case BASEPROPERTY_FONTEMPHASISMARK: + aProp <<= (sal_Int16) GetWindow()->GetControlFont().GetEmphasisMark(); + break; + case BASEPROPERTY_TEXTCOLOR: + aProp <<= (sal_Int32) GetWindow()->GetControlForeground().GetColor(); + break; + case BASEPROPERTY_TEXTLINECOLOR: + aProp <<= (sal_Int32) GetWindow()->GetTextLineColor().GetColor(); + break; + case BASEPROPERTY_FILLCOLOR: + aProp <<= (sal_Int32) GetWindow()->GetFillColor().GetColor(); + break; + case BASEPROPERTY_LINECOLOR: + aProp <<= (sal_Int32) GetWindow()->GetLineColor().GetColor(); + break; + case BASEPROPERTY_BORDER: + { + sal_Int16 nBorder = 0; + if ( GetWindow()->GetStyle() & WB_BORDER ) + nBorder = GetWindow()->GetBorderStyle(); + aProp <<= nBorder; + } + break; + case BASEPROPERTY_TABSTOP: + aProp <<= (sal_Bool) ( GetWindow()->GetStyle() & WB_TABSTOP ) ? sal_True : sal_False; + break; + case BASEPROPERTY_VERTICALALIGN: + { + WinBits nStyle = GetWindow()->GetStyle(); + if ( nStyle & WB_TOP ) + aProp <<= VerticalAlignment_TOP; + else if ( nStyle & WB_VCENTER ) + aProp <<= VerticalAlignment_MIDDLE; + else if ( nStyle & WB_BOTTOM ) + aProp <<= VerticalAlignment_BOTTOM; + } + break; + case BASEPROPERTY_ALIGN: + { + switch ( eWinType ) + { + case WINDOW_FIXEDTEXT: + case WINDOW_EDIT: + case WINDOW_MULTILINEEDIT: + case WINDOW_CHECKBOX: + case WINDOW_RADIOBUTTON: + case WINDOW_LISTBOX: + case WINDOW_COMBOBOX: + case WINDOW_BUTTON: + case WINDOW_PUSHBUTTON: + case WINDOW_OKBUTTON: + case WINDOW_CANCELBUTTON: + case WINDOW_HELPBUTTON: + { + WinBits nStyle = GetWindow()->GetStyle(); + if ( nStyle & WB_LEFT ) + aProp <<= (sal_Int16) PROPERTY_ALIGN_LEFT; + else if ( nStyle & WB_CENTER ) + aProp <<= (sal_Int16) PROPERTY_ALIGN_CENTER; + else if ( nStyle & WB_RIGHT ) + aProp <<= (sal_Int16) PROPERTY_ALIGN_RIGHT; + } + break; + } + } + case BASEPROPERTY_MULTILINE: + { + if ( ( eWinType == WINDOW_FIXEDTEXT ) + || ( eWinType == WINDOW_CHECKBOX ) + || ( eWinType == WINDOW_RADIOBUTTON ) + || ( eWinType == WINDOW_BUTTON ) + || ( eWinType == WINDOW_PUSHBUTTON ) + || ( eWinType == WINDOW_OKBUTTON ) + || ( eWinType == WINDOW_CANCELBUTTON ) + || ( eWinType == WINDOW_HELPBUTTON ) + ) + aProp <<= (sal_Bool) ( GetWindow()->GetStyle() & WB_WORDBREAK ) ? sal_True : sal_False; + } + break; + case BASEPROPERTY_AUTOMNEMONICS: + { + sal_Bool bAutoMnemonics = GetWindow()->GetSettings().GetStyleSettings().GetAutoMnemonic(); + aProp <<= bAutoMnemonics; + } + break; + case BASEPROPERTY_MOUSETRANSPARENT: + { + sal_Bool bMouseTransparent = GetWindow()->IsMouseTransparent(); + aProp <<= bMouseTransparent; + } + break; + case BASEPROPERTY_PAINTTRANSPARENT: + { + sal_Bool bPaintTransparent = GetWindow()->IsPaintTransparent(); + aProp <<= bPaintTransparent; + } + break; + + case BASEPROPERTY_REPEAT: + aProp <<= (sal_Bool)( 0 != ( GetWindow()->GetStyle() & WB_REPEAT ) ); + break; + + case BASEPROPERTY_REPEAT_DELAY: + { + sal_Int32 nButtonRepeat = GetWindow()->GetSettings().GetMouseSettings().GetButtonRepeat(); + aProp <<= (sal_Int32)nButtonRepeat; + } + break; + + case BASEPROPERTY_SYMBOL_COLOR: + aProp <<= (sal_Int32)GetWindow()->GetSettings().GetStyleSettings().GetButtonTextColor().GetColor(); + break; + + case BASEPROPERTY_BORDERCOLOR: + aProp <<= (sal_Int32)GetWindow()->GetSettings().GetStyleSettings().GetMonoColor().GetColor(); + break; + } + } + return aProp; +} + + +// ::com::sun::star::awt::XLayoutConstrains +::com::sun::star::awt::Size VCLXWindow::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + // Diese Methode sollte nur fuer Componenten gerufen werden, die zwar + // ueber das ::com::sun::star::awt::Toolkit erzeugt werden koennen, aber fuer die es + // kein Interface gibt. + + Size aSz; + if ( GetWindow() ) + { + WindowType nWinType = GetWindow()->GetType(); + switch ( nWinType ) + { + case WINDOW_CONTROL: + aSz.Width() = GetWindow()->GetTextWidth( GetWindow()->GetText() )+2*12; + aSz.Height() = GetWindow()->GetTextHeight()+2*6; + break; + + case WINDOW_PATTERNBOX: + case WINDOW_NUMERICBOX: + case WINDOW_METRICBOX: + case WINDOW_CURRENCYBOX: + case WINDOW_DATEBOX: + case WINDOW_TIMEBOX: + case WINDOW_LONGCURRENCYBOX: + aSz.Width() = GetWindow()->GetTextWidth( GetWindow()->GetText() )+2*2; + aSz.Height() = GetWindow()->GetTextHeight()+2*2; + break; + case WINDOW_SCROLLBARBOX: + return VCLXScrollBar::implGetMinimumSize( GetWindow() ); + default: + aSz = GetWindow()->GetOptimalSize( WINDOWSIZE_MINIMUM ); + } + } + + return ::com::sun::star::awt::Size( aSz.Width(), aSz.Height() ); +} + +::com::sun::star::awt::Size VCLXWindow::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + return getMinimumSize(); +} + +::com::sun::star::awt::Size VCLXWindow::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::awt::Size aNewSize( rNewSize ); + ::com::sun::star::awt::Size aMinSize = getMinimumSize(); + + if ( aNewSize.Width < aMinSize.Width ) + aNewSize.Width = aMinSize.Width; + if ( aNewSize.Height < aMinSize.Height ) + aNewSize.Height = aMinSize.Height; + + return aNewSize; +} + + +// ::com::sun::star::awt::XView +sal_Bool VCLXWindow::setGraphics( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& rxDevice ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( VCLUnoHelper::GetOutputDevice( rxDevice ) ) + mpImpl->mxViewGraphics = rxDevice; + else + mpImpl->mxViewGraphics = NULL; + + return mpImpl->mxViewGraphics.is(); +} + +::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > VCLXWindow::getGraphics( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + return mpImpl->mxViewGraphics; +} + +::com::sun::star::awt::Size VCLXWindow::getSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + if ( GetWindow() ) + aSz = GetWindow()->GetSizePixel(); + return ::com::sun::star::awt::Size( aSz.Width(), aSz.Height() ); +} + +void VCLXWindow::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( !pWindow ) + return; + + if ( isDesignMode() || mpImpl->isEnableVisible() ) + { + TabPage* pTabPage = dynamic_cast< TabPage* >( pWindow ); + if ( pTabPage ) + { + Point aPos( nX, nY ); + Size aSize = pWindow->GetSizePixel(); + + OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( mpImpl->mxViewGraphics ); + aPos = pDev->PixelToLogic( aPos ); + aSize = pDev->PixelToLogic( aSize ); + + pTabPage->Draw( pDev, aPos, aSize, 0 ); + return; + } + + OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( mpImpl->mxViewGraphics ); + Point aPos( nX, nY ); + + if ( !pDev ) + pDev = pWindow->GetParent(); + + if ( pWindow->GetParent() && !pWindow->IsSystemWindow() && ( pWindow->GetParent() == pDev ) ) + { + // #i40647# don't draw here if this is a recursive call + // sometimes this is called recursively, because the Update call on the parent + // (strangely) triggers another paint. Prevent a stack overflow here + // Yes, this is only fixing symptoms for the moment .... + // #i40647# / 2005-01-18 / frank.schoenheit@sun.com + if ( !mpImpl->getDrawingOntoParent_ref() ) + { + FlagGuard aDrawingflagGuard( mpImpl->getDrawingOntoParent_ref() ); + + BOOL bWasVisible = pWindow->IsVisible(); + Point aOldPos( pWindow->GetPosPixel() ); + + if ( bWasVisible && aOldPos == aPos ) + { + pWindow->Update(); + return; + } + + pWindow->SetPosPixel( aPos ); + + // Erstmal ein Update auf den Parent, damit nicht beim Update + // auf dieses Fenster noch ein Paint vom Parent abgearbeitet wird, + // wo dann ggf. dieses Fenster sofort wieder gehidet wird. + if( pWindow->GetParent() ) + pWindow->GetParent()->Update(); + + pWindow->Show(); + pWindow->Update(); + pWindow->SetParentUpdateMode( sal_False ); + pWindow->Hide(); + pWindow->SetParentUpdateMode( sal_True ); + + pWindow->SetPosPixel( aOldPos ); + if ( bWasVisible ) + pWindow->Show( TRUE ); + } + } + else if ( pDev ) + { + Size aSz = pWindow->GetSizePixel(); + aSz = pDev->PixelToLogic( aSz ); + Point aP = pDev->PixelToLogic( aPos ); + + vcl::PDFExtOutDevData* pPDFExport = dynamic_cast<vcl::PDFExtOutDevData*>(pDev->GetExtOutDevData()); + bool bDrawSimple = ( pDev->GetOutDevType() == OUTDEV_PRINTER ) + || ( pDev->GetOutDevViewType() == OUTDEV_VIEWTYPE_PRINTPREVIEW ) + || ( pPDFExport != NULL ); + if ( bDrawSimple ) + { + pWindow->Draw( pDev, aP, aSz, WINDOW_DRAW_NOCONTROLS ); + } + else + { + BOOL bOldNW =pWindow->IsNativeWidgetEnabled(); + if( bOldNW ) + pWindow->EnableNativeWidget(FALSE); + pWindow->PaintToDevice( pDev, aP, aSz ); + if( bOldNW ) + pWindow->EnableNativeWidget(TRUE); + } + } + } +} + +void VCLXWindow::setZoom( float fZoomX, float /*fZoomY*/ ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { + // Fraction::Fraction takes a double, but we have a float only. + // The implicit conversion from float to double can result in a precision loss, i.e. 1.2 is converted to + // 1.200000000047something. To prevent this, we convert explicitly to double, and round it. + double nZoom( fZoomX ); + nZoom = ::rtl::math::round( nZoom, 4 ); + GetWindow()->SetZoom( Fraction( nZoom ) ); + } +} + +// ::com::sun::star::lang::XEventListener +void SAL_CALL VCLXWindow::disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + // check if it comes from our AccessibleContext + uno::Reference< uno::XInterface > aAC( mpImpl->mxAccessibleContext, uno::UNO_QUERY ); + uno::Reference< uno::XInterface > xSource( _rSource.Source, uno::UNO_QUERY ); + + if ( aAC.get() == xSource.get() ) + { // yep, it does + mpImpl->mxAccessibleContext = uno::Reference< accessibility::XAccessibleContext >(); + } +} + +// ::com::sun::star::accessibility::XAccessible +::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXWindow::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException) +{ + using namespace ::com::sun::star; + + ::vos::OGuard aGuard( GetMutex() ); + + // already disposed + if( ! mpImpl ) + return uno::Reference< accessibility::XAccessibleContext >(); + + if ( !mpImpl->mxAccessibleContext.is() && GetWindow() ) + { + mpImpl->mxAccessibleContext = CreateAccessibleContext(); + + // add as event listener to this component + // in case somebody disposes it, we do not want to have a (though weak) reference to a dead + // object + uno::Reference< lang::XComponent > xComp( mpImpl->mxAccessibleContext, uno::UNO_QUERY ); + if ( xComp.is() ) + xComp->addEventListener( this ); + } + + return mpImpl->mxAccessibleContext; +} + +// ::com::sun::star::awt::XDockable +void SAL_CALL VCLXWindow::addDockableWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDockableWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( xListener.is() ) + mpImpl->getDockableWindowListeners().addInterface( xListener ); + +} + +void SAL_CALL VCLXWindow::removeDockableWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDockableWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + mpImpl->getDockableWindowListeners().removeInterface( xListener ); +} + +void SAL_CALL VCLXWindow::enableDocking( sal_Bool bEnable ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + pWindow->EnableDocking( bEnable ); +} + +sal_Bool SAL_CALL VCLXWindow::isFloating( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if( pWindow ) + return Window::GetDockingManager()->IsFloating( pWindow ); + else + return FALSE; +} + +void SAL_CALL VCLXWindow::setFloatingMode( sal_Bool bFloating ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if( pWindow ) + Window::GetDockingManager()->SetFloatingMode( pWindow, bFloating ); +} + +sal_Bool SAL_CALL VCLXWindow::isLocked( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if( pWindow ) + return Window::GetDockingManager()->IsLocked( pWindow ); + else + return FALSE; +} + +void SAL_CALL VCLXWindow::lock( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if( pWindow && !Window::GetDockingManager()->IsFloating( pWindow ) ) + Window::GetDockingManager()->Lock( pWindow ); +} + +void SAL_CALL VCLXWindow::unlock( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if( pWindow && !Window::GetDockingManager()->IsFloating( pWindow ) ) + Window::GetDockingManager()->Unlock( pWindow ); +} +void SAL_CALL VCLXWindow::startPopupMode( const ::com::sun::star::awt::Rectangle& ) throw (::com::sun::star::uno::RuntimeException) +{ + // TODO: remove interface in the next incompatible build + ::vos::OGuard aGuard( GetMutex() ); + +} + +sal_Bool SAL_CALL VCLXWindow::isInPopupMode( ) throw (::com::sun::star::uno::RuntimeException) +{ + // TODO: remove interface in the next incompatible build + ::vos::OGuard aGuard( GetMutex() ); + return FALSE; +} + + +// ::com::sun::star::awt::XWindow2 + +void SAL_CALL VCLXWindow::setOutputSize( const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + Window *pWindow; + if( (pWindow = GetWindow()) != NULL ) + { + DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >(pWindow); + if( pDockingWindow ) + pDockingWindow->SetOutputSizePixel( VCLSize( aSize ) ); + else + pWindow->SetOutputSizePixel( VCLSize( aSize ) ); + } +} + +::com::sun::star::awt::Size SAL_CALL VCLXWindow::getOutputSize( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + Window *pWindow; + if( (pWindow = GetWindow()) != NULL ) + { + DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >(pWindow); + if( pDockingWindow ) + return AWTSize( pDockingWindow->GetOutputSizePixel() ); + else + return AWTSize( pWindow->GetOutputSizePixel() ); + } + else + return ::com::sun::star::awt::Size(); +} + +sal_Bool SAL_CALL VCLXWindow::isVisible( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + if( GetWindow() ) + return GetWindow()->IsVisible(); + else + return FALSE; +} + +sal_Bool SAL_CALL VCLXWindow::isActive( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + if( GetWindow() ) + return GetWindow()->IsActive(); + else + return FALSE; + +} + +sal_Bool SAL_CALL VCLXWindow::isEnabled( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + if( GetWindow() ) + return GetWindow()->IsEnabled(); + else + return FALSE; +} + +sal_Bool SAL_CALL VCLXWindow::hasFocus( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + if( GetWindow() ) + return GetWindow()->HasFocus(); + else + return FALSE; +} + +// ::com::sun::star::beans::XPropertySetInfo + +UnoPropertyArrayHelper * +VCLXWindow::GetPropHelper() +{ + ::vos::OGuard aGuard( GetMutex() ); + if ( mpImpl->mpPropHelper == NULL ) + { + std::list< sal_uInt16 > aIDs; + GetPropertyIds( aIDs ); + mpImpl->mpPropHelper = new UnoPropertyArrayHelper( aIDs ); + } + return mpImpl->mpPropHelper; +} + +::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL +VCLXWindow::getProperties() throw (::com::sun::star::uno::RuntimeException) +{ + return GetPropHelper()->getProperties(); +} +::com::sun::star::beans::Property SAL_CALL +VCLXWindow::getPropertyByName( const ::rtl::OUString& rName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) +{ + return GetPropHelper()->getPropertyByName( rName ); +} + +::sal_Bool SAL_CALL +VCLXWindow::hasPropertyByName( const ::rtl::OUString& rName ) throw (::com::sun::star::uno::RuntimeException) +{ + return GetPropHelper()->hasPropertyByName( rName ); +} diff --git a/toolkit/source/awt/vclxwindow1.cxx b/toolkit/source/awt/vclxwindow1.cxx new file mode 100644 index 000000000000..daea557d241a --- /dev/null +++ b/toolkit/source/awt/vclxwindow1.cxx @@ -0,0 +1,108 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + +#include <tools/svwin.h> +#include <toolkit/awt/vclxwindow.hxx> +#include <com/sun/star/beans/NamedValue.hpp> +#ifndef _SV_WORKWIN +#include <vcl/wrkwin.hxx> +#endif +#include <vcl/window.hxx> + +#ifdef WNT +#include <tools/prewin.h> +#include <windows.h> +#include <tools/postwin.h> +#elif defined ( QUARTZ ) +#include "premac.h" +#include <Cocoa/Cocoa.h> +#include "postmac.h" +#endif +#include <vcl/sysdata.hxx> + +/// helper method to set a window handle into a SystemParentData struct +void VCLXWindow::SetSystemParent_Impl( const com::sun::star::uno::Any& rHandle ) +{ + // does only work for WorkWindows + Window *pWindow = GetWindow(); + if ( pWindow->GetType() != WINDOW_WORKWINDOW ) + { + ::com::sun::star::uno::Exception *pException = + new ::com::sun::star::uno::RuntimeException; + pException->Message = ::rtl::OUString::createFromAscii( "not a work window" ); + throw pException; + } + + // use sal_Int64 here to accomodate all int types + // uno::Any shift operator whill upcast if necessary + sal_Int64 nHandle = 0; + sal_Bool bXEmbed = sal_False; + bool bThrow = false; + if( ! (rHandle >>= nHandle) ) + { + com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > aProps; + if( rHandle >>= aProps ) + { + const int nProps = aProps.getLength(); + const com::sun::star::beans::NamedValue* pProps = aProps.getConstArray(); + for( int i = 0; i < nProps; i++ ) + { + if( pProps[i].Name.equalsAscii( "WINDOW" ) ) + pProps[i].Value >>= nHandle; + else if( pProps[i].Name.equalsAscii( "XEMBED" ) ) + pProps[i].Value >>= bXEmbed; + } + } + else + bThrow = true; + } + if( bThrow ) + { + ::com::sun::star::uno::Exception *pException = + new ::com::sun::star::uno::RuntimeException; + pException->Message = ::rtl::OUString::createFromAscii( "incorrect window handle type" ); + throw pException; + } + // create system parent data + SystemParentData aSysParentData; + aSysParentData.nSize = sizeof ( SystemParentData ); +#if defined( WIN ) || defined( WNT ) || defined ( OS2 ) + aSysParentData.hWnd = (HWND) nHandle; +#elif defined( QUARTZ ) + aSysParentData.pView = reinterpret_cast<NSView*>(nHandle); +#elif defined( UNX ) + aSysParentData.aWindow = (long)nHandle; + aSysParentData.bXEmbedSupport = bXEmbed; +#endif + + // set system parent + ((WorkWindow*)pWindow)->SetPluginParent( &aSysParentData ); +} + diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx new file mode 100644 index 000000000000..e2fc78421d5e --- /dev/null +++ b/toolkit/source/awt/vclxwindows.cxx @@ -0,0 +1,6036 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" +#include <toolkit/awt/vclxwindows.hxx> +#include <com/sun/star/awt/ScrollBarOrientation.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <toolkit/helper/vclunohelper.hxx> +#include <toolkit/helper/macros.hxx> +#include <toolkit/helper/property.hxx> +#include <toolkit/helper/convert.hxx> +#include <toolkit/helper/imagealign.hxx> +#include <toolkit/helper/accessibilityclient.hxx> +#include <toolkit/helper/fixedhyperbase.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <com/sun/star/awt/VisualEffect.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/system/XSystemShellExecute.hpp> +#include <com/sun/star/system/SystemShellExecuteFlags.hpp> +#include <com/sun/star/awt/ImageScaleMode.hpp> +#include <comphelper/processfactory.hxx> + +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +#include <vcl/lstbox.hxx> +#include <vcl/combobox.hxx> +#include <vcl/field.hxx> +#include <vcl/longcurr.hxx> +#include <vcl/imgctrl.hxx> +#include <vcl/dialog.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/scrbar.hxx> +#include <vcl/svapp.hxx> +#include <vcl/tabpage.hxx> +#include <tools/debug.hxx> + +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::makeAny; +using ::com::sun::star::graphic::XGraphic; + +using namespace ::com::sun::star; +using namespace ::com::sun::star::awt::VisualEffect; +namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode; + +static double ImplCalcLongValue( double nValue, sal_uInt16 nDigits ) +{ + double n = nValue; + for ( sal_uInt16 d = 0; d < nDigits; d++ ) + n *= 10; + return n; +} + +static double ImplCalcDoubleValue( double nValue, sal_uInt16 nDigits ) +{ + double n = nValue; + for ( sal_uInt16 d = 0; d < nDigits; d++ ) + n /= 10; + return n; +} + +namespace toolkit +{ + /** sets the "face color" for button like controls (scroll bar, spin button) + */ + void setButtonLikeFaceColor( Window* _pWindow, const ::com::sun::star::uno::Any& _rColorValue ) + { + AllSettings aSettings = _pWindow->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + + if ( !_rColorValue.hasValue() ) + { + const StyleSettings& aAppStyle = Application::GetSettings().GetStyleSettings(); + aStyleSettings.SetFaceColor( aAppStyle.GetFaceColor( ) ); + aStyleSettings.SetCheckedColor( aAppStyle.GetCheckedColor( ) ); + aStyleSettings.SetLightBorderColor( aAppStyle.GetLightBorderColor() ); + aStyleSettings.SetLightColor( aAppStyle.GetLightColor() ); + aStyleSettings.SetShadowColor( aAppStyle.GetShadowColor() ); + aStyleSettings.SetDarkShadowColor( aAppStyle.GetDarkShadowColor() ); + } + else + { + sal_Int32 nBackgroundColor = 0; + _rColorValue >>= nBackgroundColor; + aStyleSettings.SetFaceColor( nBackgroundColor ); + + // for the real background (everything except the buttons and the thumb), + // use an average between the desired color and "white" + Color aWhite( COL_WHITE ); + Color aBackground( nBackgroundColor ); + aBackground.SetRed( ( aBackground.GetRed() + aWhite.GetRed() ) / 2 ); + aBackground.SetGreen( ( aBackground.GetGreen() + aWhite.GetGreen() ) / 2 ); + aBackground.SetBlue( ( aBackground.GetBlue() + aWhite.GetBlue() ) / 2 ); + aStyleSettings.SetCheckedColor( aBackground ); + + sal_Int32 nBackgroundLuminance = Color( nBackgroundColor ).GetLuminance(); + sal_Int32 nWhiteLuminance = Color( COL_WHITE ).GetLuminance(); + + Color aLightShadow( nBackgroundColor ); + aLightShadow.IncreaseLuminance( (UINT8)( ( nWhiteLuminance - nBackgroundLuminance ) * 2 / 3 ) ); + aStyleSettings.SetLightBorderColor( aLightShadow ); + + Color aLight( nBackgroundColor ); + aLight.IncreaseLuminance( (UINT8)( ( nWhiteLuminance - nBackgroundLuminance ) * 1 / 3 ) ); + aStyleSettings.SetLightColor( aLight ); + + Color aShadow( nBackgroundColor ); + aShadow.DecreaseLuminance( (UINT8)( nBackgroundLuminance * 1 / 3 ) ); + aStyleSettings.SetShadowColor( aShadow ); + + Color aDarkShadow( nBackgroundColor ); + aDarkShadow.DecreaseLuminance( (UINT8)( nBackgroundLuminance * 2 / 3 ) ); + aStyleSettings.SetDarkShadowColor( aDarkShadow ); + } + + aSettings.SetStyleSettings( aStyleSettings ); + _pWindow->SetSettings( aSettings, TRUE ); + } + + Any getButtonLikeFaceColor( const Window* _pWindow ) + { + sal_Int32 nBackgroundColor = _pWindow->GetSettings().GetStyleSettings().GetFaceColor().GetColor(); + return makeAny( nBackgroundColor ); + } + + static void adjustBooleanWindowStyle( const Any& _rValue, Window* _pWindow, WinBits _nBits, sal_Bool _bInverseSemantics ) + { + WinBits nStyle = _pWindow->GetStyle(); + sal_Bool bValue( sal_False ); + OSL_VERIFY( _rValue >>= bValue ); + if ( bValue != _bInverseSemantics ) + nStyle |= _nBits; + else + nStyle &= ~_nBits; + _pWindow->SetStyle( nStyle ); + } + + static void setVisualEffect( const Any& _rValue, Window* _pWindow, void (StyleSettings::*pSetter)( USHORT ), sal_Int16 _nFlatBits, sal_Int16 _n3DBits ) + { + AllSettings aSettings = _pWindow->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + + sal_Int16 nStyle = LOOK3D; + OSL_VERIFY( _rValue >>= nStyle ); + switch ( nStyle ) + { + case FLAT: + (aStyleSettings.*pSetter)( _nFlatBits ); + break; + case LOOK3D: + default: + (aStyleSettings.*pSetter)( _n3DBits ); + } + aSettings.SetStyleSettings( aStyleSettings ); + _pWindow->SetSettings( aSettings ); + } + + static Any getVisualEffect( Window* _pWindow, USHORT (StyleSettings::*pGetter)( ) const, sal_Int16 _nFlatBits ) + { + Any aEffect; + + StyleSettings aStyleSettings = _pWindow->GetSettings().GetStyleSettings(); + if ( (aStyleSettings.*pGetter)() == _nFlatBits ) + aEffect <<= (sal_Int16)FLAT; + else + aEffect <<= (sal_Int16)LOOK3D; + return aEffect; + } +} + +// ---------------------------------------------------- +// class VCLXImageConsumer +// ---------------------------------------------------- + +void VCLXImageConsumer::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + VCLXWindow::ImplGetPropertyIds( rIds ); +} + +void VCLXImageConsumer::ImplSetNewImage() +{ + OSL_PRECOND( GetWindow(), "VCLXImageConsumer::ImplSetNewImage: window is required to be not-NULL!" ); + Button* pButton = static_cast< Button* >( GetWindow() ); + pButton->SetModeBitmap( GetBitmap() ); +} + +void VCLXImageConsumer::ImplUpdateImage( sal_Bool bGetNewImage ) +{ + if ( !GetWindow() ) + return; + + if ( bGetNewImage && !maImageConsumer.GetData( maImage ) ) + return; + + ImplSetNewImage(); +} + +void VCLXImageConsumer::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, short Flags ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { + Size aOldSize = GetWindow()->GetSizePixel(); + VCLXWindow::setPosSize( X, Y, Width, Height, Flags ); + if ( ( aOldSize.Width() != Width ) || ( aOldSize.Height() != Height ) ) + ImplUpdateImage( sal_False ); + } +} + +void VCLXImageConsumer::init( sal_Int32 Width, sal_Int32 Height ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + maImageConsumer.Init( Width, Height ); +} + +void VCLXImageConsumer::setColorModel( sal_Int16 BitCount, const ::com::sun::star::uno::Sequence< sal_Int32 >& RGBAPal, sal_Int32 RedMask, sal_Int32 GreenMask, sal_Int32 BlueMask, sal_Int32 AlphaMask ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + maImageConsumer.SetColorModel( BitCount, RGBAPal.getLength(), (const sal_uInt32*) RGBAPal.getConstArray(), RedMask, GreenMask, BlueMask, AlphaMask ); +} + +void VCLXImageConsumer::setPixelsByBytes( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, const ::com::sun::star::uno::Sequence< sal_Int8 >& ProducerData, sal_Int32 Offset, sal_Int32 Scansize ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + maImageConsumer.SetPixelsByBytes( X, Y, Width, Height, (sal_uInt8*)ProducerData.getConstArray(), Offset, Scansize ); + ImplUpdateImage( sal_True ); +} + +void VCLXImageConsumer::setPixelsByLongs( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, const ::com::sun::star::uno::Sequence< sal_Int32 >& ProducerData, sal_Int32 Offset, sal_Int32 Scansize ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + maImageConsumer.SetPixelsByLongs( X, Y, Width, Height, (const sal_uInt32*) ProducerData.getConstArray(), Offset, Scansize ); + ImplUpdateImage( sal_True ); +} + +void VCLXImageConsumer::complete( sal_Int32 Status, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer > & ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + maImageConsumer.Completed( Status ); + ImplUpdateImage( sal_True ); +} + +void VCLXImageConsumer::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Button* pButton = static_cast< Button* >( GetWindow() ); + if ( !pButton ) + return; + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_GRAPHIC: + { + Reference< XGraphic > xGraphic; + OSL_VERIFY( Value >>= xGraphic ); + maImage = Image( xGraphic ); + ImplSetNewImage(); + } + break; + + case BASEPROPERTY_IMAGEALIGN: + { + WindowType eType = GetWindow()->GetType(); + if ( ( eType == WINDOW_PUSHBUTTON ) + || ( eType == WINDOW_RADIOBUTTON ) + || ( eType == WINDOW_CHECKBOX ) + ) + { + sal_Int16 nAlignment = sal_Int16(); + if ( Value >>= nAlignment ) + pButton->SetImageAlign( static_cast< ImageAlign >( nAlignment ) ); + } + } + break; + case BASEPROPERTY_IMAGEPOSITION: + { + WindowType eType = GetWindow()->GetType(); + if ( ( eType == WINDOW_PUSHBUTTON ) + || ( eType == WINDOW_RADIOBUTTON ) + || ( eType == WINDOW_CHECKBOX ) + ) + { + sal_Int16 nImagePosition = 2; + OSL_VERIFY( Value >>= nImagePosition ); + pButton->SetImageAlign( ::toolkit::translateImagePosition( nImagePosition ) ); + } + } + break; + default: + VCLXWindow::setProperty( PropertyName, Value ); + break; + } +} + +::com::sun::star::uno::Any VCLXImageConsumer::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + if ( !GetWindow() ) + return aProp; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_GRAPHIC: + aProp <<= maImage.GetXGraphic(); + break; + case BASEPROPERTY_IMAGEALIGN: + { + WindowType eType = GetWindow()->GetType(); + if ( ( eType == WINDOW_PUSHBUTTON ) + || ( eType == WINDOW_RADIOBUTTON ) + || ( eType == WINDOW_CHECKBOX ) + ) + { + aProp <<= ::toolkit::getCompatibleImageAlign( static_cast< Button* >( GetWindow() )->GetImageAlign() ); + } + } + break; + case BASEPROPERTY_IMAGEPOSITION: + { + WindowType eType = GetWindow()->GetType(); + if ( ( eType == WINDOW_PUSHBUTTON ) + || ( eType == WINDOW_RADIOBUTTON ) + || ( eType == WINDOW_CHECKBOX ) + ) + { + aProp <<= ::toolkit::translateImagePosition( static_cast< Button* >( GetWindow() )->GetImageAlign() ); + } + } + break; + default: + { + aProp <<= VCLXWindow::getProperty( PropertyName ); + } + break; + } + return aProp; +} + +//-------------------------------------------------------------------- +// class VCLXButton +// ---------------------------------------------------- + +void VCLXButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_DEFAULTBUTTON, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_GRAPHIC, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_IMAGEALIGN, + BASEPROPERTY_IMAGEPOSITION, + BASEPROPERTY_IMAGEURL, + BASEPROPERTY_LABEL, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_PUSHBUTTONTYPE, + BASEPROPERTY_REPEAT, + BASEPROPERTY_REPEAT_DELAY, + BASEPROPERTY_STATE, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_TOGGLE, + BASEPROPERTY_FOCUSONCLICK, + BASEPROPERTY_MULTILINE, + BASEPROPERTY_ALIGN, + BASEPROPERTY_VERTICALALIGN, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_REFERENCE_DEVICE, + 0); + VCLXImageConsumer::ImplGetPropertyIds( rIds ); +} + +VCLXButton::VCLXButton() + :maActionListeners( *this ) + ,maItemListeners( *this ) +{ +} + +VCLXButton::~VCLXButton() +{ +} + +::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXButton::CreateAccessibleContext() +{ + return getAccessibleFactory().createAccessibleContext( this ); +} + +void VCLXButton::dispose() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::lang::EventObject aObj; + aObj.Source = (::cppu::OWeakObject*)this; + maActionListeners.disposeAndClear( aObj ); + maItemListeners.disposeAndClear( aObj ); + VCLXImageConsumer::dispose(); +} + +void VCLXButton::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionListeners.addInterface( l ); +} + +void VCLXButton::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionListeners.removeInterface( l ); +} + +void VCLXButton::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l )throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maItemListeners.addInterface( l ); +} + +void VCLXButton::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maItemListeners.removeInterface( l ); +} + +void VCLXButton::setLabel( const ::rtl::OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + pWindow->SetText( rLabel ); +} + +void VCLXButton::setActionCommand( const ::rtl::OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + maActionCommand = rCommand; +} + +::com::sun::star::awt::Size VCLXButton::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + PushButton* pButton = (PushButton*) GetWindow(); + if ( pButton ) + aSz = pButton->CalcMinimumSize(); + return AWTSize(aSz); +} + +::com::sun::star::awt::Size VCLXButton::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::awt::Size aSz = getMinimumSize(); + aSz.Width += 16; + aSz.Height += 10; + return aSz; +} + +::com::sun::star::awt::Size VCLXButton::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz = VCLSize(rNewSize); + PushButton* pButton = (PushButton*) GetWindow(); + if ( pButton ) + { + Size aMinSz = pButton->CalcMinimumSize(); + // Kein Text, also Image + if ( !pButton->GetText().Len() ) + { + if ( aSz.Width() < aMinSz.Width() ) + aSz.Width() = aMinSz.Width(); + if ( aSz.Height() < aMinSz.Height() ) + aSz.Height() = aMinSz.Height(); + } + else + { + if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) ) + aSz.Height() = aMinSz.Height(); + else + aSz = aMinSz; + } + } + return AWTSize(aSz); +} + +void VCLXButton::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Button* pButton = (Button*)GetWindow(); + if ( pButton ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_FOCUSONCLICK: + ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_NOPOINTERFOCUS, sal_True ); + break; + + case BASEPROPERTY_TOGGLE: + ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_TOGGLE, sal_False ); + break; + + case BASEPROPERTY_DEFAULTBUTTON: + { + WinBits nStyle = pButton->GetStyle() | WB_DEFBUTTON; + sal_Bool b = sal_Bool(); + if ( ( Value >>= b ) && !b ) + nStyle &= ~WB_DEFBUTTON; + pButton->SetStyle( nStyle ); + } + break; + case BASEPROPERTY_STATE: + { + if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON ) + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + ((PushButton*)pButton)->SetState( (TriState)n ); + } + } + break; + default: + { + VCLXImageConsumer::setProperty( PropertyName, Value ); + } + } + } +} + +::com::sun::star::uno::Any VCLXButton::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + Button* pButton = (Button*)GetWindow(); + if ( pButton ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_FOCUSONCLICK: + aProp <<= (sal_Bool)( ( pButton->GetStyle() & WB_NOPOINTERFOCUS ) == 0 ); + break; + + case BASEPROPERTY_TOGGLE: + aProp <<= (sal_Bool)( ( pButton->GetStyle() & WB_TOGGLE ) != 0 ); + break; + + case BASEPROPERTY_DEFAULTBUTTON: + { + aProp <<= (sal_Bool) ( ( pButton->GetStyle() & WB_DEFBUTTON ) ? sal_True : sal_False ); + } + break; + case BASEPROPERTY_STATE: + { + if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON ) + { + aProp <<= (sal_Int16)((PushButton*)pButton)->GetState(); + } + } + break; + default: + { + aProp <<= VCLXImageConsumer::getProperty( PropertyName ); + } + } + } + return aProp; +} + +void VCLXButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + switch ( rVclWindowEvent.GetId() ) + { + case VCLEVENT_BUTTON_CLICK: + { + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); + // since we call listeners below, there is a potential that we will be destroyed + // during the listener call. To prevent the resulting crashs, we keep us + // alive as long as we're here + // #20178# - 2003-10-01 - fs@openoffice.org + + if ( maActionListeners.getLength() ) + { + ::com::sun::star::awt::ActionEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.ActionCommand = maActionCommand; + maActionListeners.actionPerformed( aEvent ); + } + } + break; + + case VCLEVENT_PUSHBUTTON_TOGGLE: + { + PushButton& rButton = dynamic_cast< PushButton& >( *rVclWindowEvent.GetWindow() ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); + if ( maItemListeners.getLength() ) + { + ::com::sun::star::awt::ItemEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.Selected = ( rButton.GetState() == STATE_CHECK ) ? 1 : 0; + maItemListeners.itemStateChanged( aEvent ); + } + } + break; + + default: + VCLXImageConsumer::ProcessWindowEvent( rVclWindowEvent ); + break; + } +} + +// ---------------------------------------------------- +// class VCLXImageControl +// ---------------------------------------------------- + +void VCLXImageControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_GRAPHIC, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_IMAGEURL, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_SCALEIMAGE, + BASEPROPERTY_IMAGE_SCALE_MODE, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + 0); + VCLXImageConsumer::ImplGetPropertyIds( rIds ); +} + +VCLXImageControl::VCLXImageControl() +{ +} + +VCLXImageControl::~VCLXImageControl() +{ +} + +void VCLXImageControl::ImplSetNewImage() +{ + OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" ); + ImageControl* pControl = static_cast< ImageControl* >( GetWindow() ); + pControl->SetBitmap( GetBitmap() ); +} + +::com::sun::star::awt::Size VCLXImageControl::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz = GetBitmap().GetSizePixel(); + aSz = ImplCalcWindowSize( aSz ); + + return AWTSize(aSz); +} + +::com::sun::star::awt::Size VCLXImageControl::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + return getMinimumSize(); +} + +::com::sun::star::awt::Size VCLXImageControl::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::awt::Size aSz = rNewSize; + ::com::sun::star::awt::Size aMinSz = getMinimumSize(); + if ( aSz.Width < aMinSz.Width ) + aSz.Width = aMinSz.Width; + if ( aSz.Height < aMinSz.Height ) + aSz.Height = aMinSz.Height; + return aSz; +} + +void VCLXImageControl::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ImageControl* pImageControl = (ImageControl*)GetWindow(); + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_IMAGE_SCALE_MODE: + { + sal_Int16 nScaleMode( ImageScaleMode::Anisotropic ); + if ( pImageControl && ( Value >>= nScaleMode ) ) + { + pImageControl->SetScaleMode( nScaleMode ); + } + } + break; + + case BASEPROPERTY_SCALEIMAGE: + { + // this is for compatibility only, nowadays, the ImageScaleMode property should be used + sal_Bool bScaleImage = sal_False; + if ( pImageControl && ( Value >>= bScaleImage ) ) + { + pImageControl->SetScaleMode( bScaleImage ? ImageScaleMode::Anisotropic : ImageScaleMode::None ); + } + } + break; + + default: + VCLXImageConsumer::setProperty( PropertyName, Value ); + break; + } +} + +::com::sun::star::uno::Any VCLXImageControl::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + ImageControl* pImageControl = (ImageControl*)GetWindow(); + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + + switch ( nPropType ) + { + case BASEPROPERTY_IMAGE_SCALE_MODE: + aProp <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::Anisotropic ); + break; + + case BASEPROPERTY_SCALEIMAGE: + aProp <<= ( pImageControl && pImageControl->GetScaleMode() != ImageScaleMode::None ) ? sal_True : sal_False; + break; + + default: + aProp = VCLXImageConsumer::getProperty( PropertyName ); + break; + } + return aProp; +} + +// ---------------------------------------------------- +// class VCLXCheckBox +// ---------------------------------------------------- + + +void VCLXCheckBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_GRAPHIC, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_IMAGEPOSITION, + BASEPROPERTY_IMAGEURL, + BASEPROPERTY_LABEL, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_STATE, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_TRISTATE, + BASEPROPERTY_VISUALEFFECT, + BASEPROPERTY_MULTILINE, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_ALIGN, + BASEPROPERTY_VERTICALALIGN, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_REFERENCE_DEVICE, + 0); + VCLXImageConsumer::ImplGetPropertyIds( rIds ); +} + +VCLXCheckBox::VCLXCheckBox() : maActionListeners( *this ), maItemListeners( *this ) +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXCheckBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XButton*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XCheckBox*, this ) ); + return (aRet.hasValue() ? aRet : VCLXImageConsumer::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXCheckBox ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XButton>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCheckBox>* ) NULL ), + VCLXImageConsumer::getTypes() +IMPL_XTYPEPROVIDER_END + +::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXCheckBox::CreateAccessibleContext() +{ + return getAccessibleFactory().createAccessibleContext( this ); +} + +void VCLXCheckBox::dispose() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::lang::EventObject aObj; + aObj.Source = (::cppu::OWeakObject*)this; + maItemListeners.disposeAndClear( aObj ); + VCLXImageConsumer::dispose(); +} + +void VCLXCheckBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maItemListeners.addInterface( l ); +} + +void VCLXCheckBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maItemListeners.removeInterface( l ); +} + +void VCLXCheckBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionListeners.addInterface( l ); +} + +void VCLXCheckBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionListeners.removeInterface( l ); +} + +void VCLXCheckBox::setActionCommand( const ::rtl::OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionCommand = rCommand; +} + +void VCLXCheckBox::setLabel( const ::rtl::OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + pWindow->SetText( rLabel ); +} + +void VCLXCheckBox::setState( short n ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + CheckBox* pCheckBox = (CheckBox*)GetWindow(); + if ( pCheckBox) + { + TriState eState; + switch ( n ) + { + case 0: eState = STATE_NOCHECK; break; + case 1: eState = STATE_CHECK; break; + case 2: eState = STATE_DONTKNOW; break; + default: eState = STATE_NOCHECK; + } + pCheckBox->SetState( eState ); + + // #105198# call C++ click listeners (needed for accessibility) + // pCheckBox->GetClickHdl().Call( pCheckBox ); + + // #107218# Call same virtual methods and listeners like VCL would do after user interaction + SetSynthesizingVCLEvent( sal_True ); + pCheckBox->Toggle(); + pCheckBox->Click(); + SetSynthesizingVCLEvent( sal_False ); + } +} + +short VCLXCheckBox::getState() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + short nState = -1; + CheckBox* pCheckBox = (CheckBox*)GetWindow(); + if ( pCheckBox ) + { + switch ( pCheckBox->GetState() ) + { + case STATE_NOCHECK: nState = 0; break; + case STATE_CHECK: nState = 1; break; + case STATE_DONTKNOW: nState = 2; break; + default: DBG_ERROR( "VCLXCheckBox::getState(): unknown TriState!" ); + } + } + + return nState; +} + +void VCLXCheckBox::enableTriState( sal_Bool b ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + CheckBox* pCheckBox = (CheckBox*)GetWindow(); + if ( pCheckBox) + pCheckBox->EnableTriState( b ); +} + +::com::sun::star::awt::Size VCLXCheckBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + CheckBox* pCheckBox = (CheckBox*) GetWindow(); + if ( pCheckBox ) + aSz = pCheckBox->CalcMinimumSize(); + return AWTSize(aSz); +} + +::com::sun::star::awt::Size VCLXCheckBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + return getMinimumSize(); +} + +::com::sun::star::awt::Size VCLXCheckBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz = VCLSize(rNewSize); + CheckBox* pCheckBox = (CheckBox*) GetWindow(); + if ( pCheckBox ) + { + Size aMinSz = pCheckBox->CalcMinimumSize(); + if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) ) + aSz.Height() = aMinSz.Height(); + else + aSz = aMinSz; + } + return AWTSize(aSz); +} + +void VCLXCheckBox::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + CheckBox* pCheckBox = (CheckBox*)GetWindow(); + if ( pCheckBox ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_VISUALEFFECT: + ::toolkit::setVisualEffect( Value, pCheckBox, &StyleSettings::SetCheckBoxStyle, STYLE_CHECKBOX_MONO, STYLE_CHECKBOX_WIN ); + break; + + case BASEPROPERTY_TRISTATE: + { + sal_Bool b = sal_Bool(); + if ( Value >>= b ) + pCheckBox->EnableTriState( b ); + } + break; + case BASEPROPERTY_STATE: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + setState( n ); + } + break; + default: + { + VCLXImageConsumer::setProperty( PropertyName, Value ); + } + } + } +} + +::com::sun::star::uno::Any VCLXCheckBox::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + CheckBox* pCheckBox = (CheckBox*)GetWindow(); + if ( pCheckBox ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_VISUALEFFECT: + aProp = ::toolkit::getVisualEffect( pCheckBox, &StyleSettings::GetCheckBoxStyle, STYLE_CHECKBOX_MONO ); + break; + case BASEPROPERTY_TRISTATE: + aProp <<= (sal_Bool)pCheckBox->IsTriStateEnabled(); + break; + case BASEPROPERTY_STATE: + aProp <<= (sal_Int16)pCheckBox->GetState(); + break; + default: + { + aProp <<= VCLXImageConsumer::getProperty( PropertyName ); + } + } + } + return aProp; +} + +void VCLXCheckBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + switch ( rVclWindowEvent.GetId() ) + { + case VCLEVENT_CHECKBOX_TOGGLE: + { + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); + // since we call listeners below, there is a potential that we will be destroyed + // in during the listener call. To prevent the resulting crashs, we keep us + // alive as long as we're here + // #20178# - 2003-10-01 - fs@openoffice.org + + CheckBox* pCheckBox = (CheckBox*)GetWindow(); + if ( pCheckBox ) + { + if ( maItemListeners.getLength() ) + { + ::com::sun::star::awt::ItemEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.Highlighted = sal_False; + aEvent.Selected = pCheckBox->GetState(); + maItemListeners.itemStateChanged( aEvent ); + } + if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() ) + { + ::com::sun::star::awt::ActionEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.ActionCommand = maActionCommand; + maActionListeners.actionPerformed( aEvent ); + } + } + } + break; + + default: + VCLXImageConsumer::ProcessWindowEvent( rVclWindowEvent ); + break; + } +} + +// ---------------------------------------------------- +// class VCLXRadioButton +// ---------------------------------------------------- +void VCLXRadioButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_GRAPHIC, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_IMAGEPOSITION, + BASEPROPERTY_IMAGEURL, + BASEPROPERTY_LABEL, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_STATE, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_VISUALEFFECT, + BASEPROPERTY_MULTILINE, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_ALIGN, + BASEPROPERTY_VERTICALALIGN, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_REFERENCE_DEVICE, + 0); + VCLXImageConsumer::ImplGetPropertyIds( rIds ); +} + + +VCLXRadioButton::VCLXRadioButton() : maItemListeners( *this ), maActionListeners( *this ) +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXRadioButton::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XRadioButton*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XButton*, this ) ); + return (aRet.hasValue() ? aRet : VCLXImageConsumer::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXRadioButton ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRadioButton>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XButton>* ) NULL ), + VCLXImageConsumer::getTypes() +IMPL_XTYPEPROVIDER_END + +::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXRadioButton::CreateAccessibleContext() +{ + return getAccessibleFactory().createAccessibleContext( this ); +} + +void VCLXRadioButton::dispose() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::lang::EventObject aObj; + aObj.Source = (::cppu::OWeakObject*)this; + maItemListeners.disposeAndClear( aObj ); + VCLXImageConsumer::dispose(); +} + +void VCLXRadioButton::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + RadioButton* pButton = (RadioButton*)GetWindow(); + if ( pButton ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_VISUALEFFECT: + ::toolkit::setVisualEffect( Value, pButton, &StyleSettings::SetRadioButtonStyle, STYLE_RADIOBUTTON_MONO, STYLE_RADIOBUTTON_WIN ); + break; + + case BASEPROPERTY_STATE: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + { + BOOL b = n ? sal_True : sal_False; + if ( pButton->IsRadioCheckEnabled() ) + pButton->Check( b ); + else + pButton->SetState( b ); + } + } + break; + case BASEPROPERTY_AUTOTOGGLE: + { + sal_Bool b = sal_Bool(); + if ( Value >>= b ) + pButton->EnableRadioCheck( b ); + } + break; + default: + { + VCLXImageConsumer::setProperty( PropertyName, Value ); + } + } + } +} + +::com::sun::star::uno::Any VCLXRadioButton::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + RadioButton* pButton = (RadioButton*)GetWindow(); + if ( pButton ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_VISUALEFFECT: + aProp = ::toolkit::getVisualEffect( pButton, &StyleSettings::GetRadioButtonStyle, STYLE_RADIOBUTTON_MONO ); + break; + case BASEPROPERTY_STATE: + aProp <<= (sal_Int16) ( pButton->IsChecked() ? 1 : 0 ); + break; + case BASEPROPERTY_AUTOTOGGLE: + aProp <<= (sal_Bool) pButton->IsRadioCheckEnabled(); + break; + default: + { + aProp <<= VCLXImageConsumer::getProperty( PropertyName ); + } + } + } + return aProp; +} + +void VCLXRadioButton::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maItemListeners.addInterface( l ); +} + +void VCLXRadioButton::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maItemListeners.removeInterface( l ); +} + +void VCLXRadioButton::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionListeners.addInterface( l ); +} + +void VCLXRadioButton::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionListeners.removeInterface( l ); +} + +void VCLXRadioButton::setLabel( const ::rtl::OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + pWindow->SetText( rLabel ); +} + +void VCLXRadioButton::setActionCommand( const ::rtl::OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionCommand = rCommand; +} + +void VCLXRadioButton::setState( sal_Bool b ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + RadioButton* pRadioButton = (RadioButton*)GetWindow(); + if ( pRadioButton) + { + pRadioButton->Check( b ); + // #102717# item listeners are called, but not C++ click listeners in StarOffice code => call click hdl + // But this is needed in old code because Accessibility API uses it. + // pRadioButton->GetClickHdl().Call( pRadioButton ); + + // #107218# Call same virtual methods and listeners like VCL would do after user interaction + SetSynthesizingVCLEvent( sal_True ); + pRadioButton->Click(); + SetSynthesizingVCLEvent( sal_False ); + } +} + +sal_Bool VCLXRadioButton::getState() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + RadioButton* pRadioButton = (RadioButton*)GetWindow(); + return pRadioButton ? pRadioButton->IsChecked() : sal_False; +} + +::com::sun::star::awt::Size VCLXRadioButton::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + RadioButton* pRadioButton = (RadioButton*) GetWindow(); + if ( pRadioButton ) + aSz = pRadioButton->CalcMinimumSize(); + return AWTSize(aSz); +} + +::com::sun::star::awt::Size VCLXRadioButton::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + return getMinimumSize(); +} + +::com::sun::star::awt::Size VCLXRadioButton::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz = VCLSize(rNewSize); + RadioButton* pRadioButton = (RadioButton*) GetWindow(); + if ( pRadioButton ) + { + Size aMinSz = pRadioButton->CalcMinimumSize(); + if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) ) + aSz.Height() = aMinSz.Height(); + else + aSz = aMinSz; + } + return AWTSize(aSz); +} + +void VCLXRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); + // since we call listeners below, there is a potential that we will be destroyed + // in during the listener call. To prevent the resulting crashs, we keep us + // alive as long as we're here + // #20178# - 2003-10-01 - fs@openoffice.org + + switch ( rVclWindowEvent.GetId() ) + { + case VCLEVENT_BUTTON_CLICK: + if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() ) + { + ::com::sun::star::awt::ActionEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.ActionCommand = maActionCommand; + maActionListeners.actionPerformed( aEvent ); + } + ImplClickedOrToggled( FALSE ); + break; + + case VCLEVENT_RADIOBUTTON_TOGGLE: + ImplClickedOrToggled( TRUE ); + break; + + default: + VCLXImageConsumer::ProcessWindowEvent( rVclWindowEvent ); + break; + } +} + +void VCLXRadioButton::ImplClickedOrToggled( BOOL bToggled ) +{ + // In the formulars, RadioChecked is not enabled, call itemStateChanged only for click + // In the dialog editor, RadioChecked is enabled, call itemStateChanged only for bToggled + RadioButton* pRadioButton = (RadioButton*)GetWindow(); + if ( pRadioButton && ( pRadioButton->IsRadioCheckEnabled() == bToggled ) && ( bToggled || pRadioButton->IsStateChanged() ) && maItemListeners.getLength() ) + { + ::com::sun::star::awt::ItemEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.Highlighted = sal_False; + aEvent.Selected = pRadioButton->IsChecked(); + maItemListeners.itemStateChanged( aEvent ); + } +} + +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > VCLXRadioButton::getFirstActionListener () +{ + if (!maItemListeners.getLength ()) + return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > (); + return maActionListeners.getElements()[0]; +} + +// ---------------------------------------------------- +// class VCLXSpinField +// ---------------------------------------------------- +void VCLXSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, + 0 ); + VCLXEdit::ImplGetPropertyIds( rIds ); +} + +VCLXSpinField::VCLXSpinField() : maSpinListeners( *this ) +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXSpinField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XSpinField*, this ) ); + return (aRet.hasValue() ? aRet : VCLXEdit::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXSpinField ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinField>* ) NULL ), + VCLXEdit::getTypes() +IMPL_XTYPEPROVIDER_END + +void VCLXSpinField::addSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maSpinListeners.addInterface( l ); +} + +void VCLXSpinField::removeSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maSpinListeners.removeInterface( l ); +} + +void VCLXSpinField::up() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + SpinField* pSpinField = (SpinField*) GetWindow(); + if ( pSpinField ) + pSpinField->Up(); +} + +void VCLXSpinField::down() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + SpinField* pSpinField = (SpinField*) GetWindow(); + if ( pSpinField ) + pSpinField->Down(); +} + +void VCLXSpinField::first() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + SpinField* pSpinField = (SpinField*) GetWindow(); + if ( pSpinField ) + pSpinField->First(); +} + +void VCLXSpinField::last() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + SpinField* pSpinField = (SpinField*) GetWindow(); + if ( pSpinField ) + pSpinField->Last(); +} + +void VCLXSpinField::enableRepeat( sal_Bool bRepeat ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + { + WinBits nStyle = pWindow->GetStyle(); + if ( bRepeat ) + nStyle |= WB_REPEAT; + else + nStyle &= ~WB_REPEAT; + pWindow->SetStyle( nStyle ); + } +} + +void VCLXSpinField::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + switch ( rVclWindowEvent.GetId() ) + { + case VCLEVENT_SPINFIELD_UP: + case VCLEVENT_SPINFIELD_DOWN: + case VCLEVENT_SPINFIELD_FIRST: + case VCLEVENT_SPINFIELD_LAST: + { + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); + // since we call listeners below, there is a potential that we will be destroyed + // in during the listener call. To prevent the resulting crashs, we keep us + // alive as long as we're here + // #20178# - 2003-10-01 - fs@openoffice.org + + if ( maSpinListeners.getLength() ) + { + ::com::sun::star::awt::SpinEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + switch ( rVclWindowEvent.GetId() ) + { + case VCLEVENT_SPINFIELD_UP: maSpinListeners.up( aEvent ); + break; + case VCLEVENT_SPINFIELD_DOWN: maSpinListeners.down( aEvent ); + break; + case VCLEVENT_SPINFIELD_FIRST: maSpinListeners.first( aEvent ); + break; + case VCLEVENT_SPINFIELD_LAST: maSpinListeners.last( aEvent ); + break; + } + + } + } + break; + + default: + VCLXEdit::ProcessWindowEvent( rVclWindowEvent ); + break; + } +} + + +// ---------------------------------------------------- +// class VCLXListBox +// ---------------------------------------------------- +void VCLXListBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_DROPDOWN, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_LINECOUNT, + BASEPROPERTY_MULTISELECTION, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_SELECTEDITEMS, + BASEPROPERTY_STRINGITEMLIST, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_READONLY, + BASEPROPERTY_ALIGN, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_REFERENCE_DEVICE, + BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, + 0); + VCLXWindow::ImplGetPropertyIds( rIds ); +} + + +VCLXListBox::VCLXListBox() + : maActionListeners( *this ), + maItemListeners( *this ) +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXListBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XListBox*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XTextLayoutConstrains*, this ) ); + return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXListBox ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XListBox>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextLayoutConstrains>* ) NULL ), + VCLXWindow::getTypes() +IMPL_XTYPEPROVIDER_END + +void VCLXListBox::dispose() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::lang::EventObject aObj; + aObj.Source = (::cppu::OWeakObject*)this; + maItemListeners.disposeAndClear( aObj ); + maActionListeners.disposeAndClear( aObj ); + VCLXWindow::dispose(); +} + +void VCLXListBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maItemListeners.addInterface( l ); +} + +void VCLXListBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maItemListeners.removeInterface( l ); +} + +void VCLXListBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionListeners.addInterface( l ); +} + +void VCLXListBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionListeners.removeInterface( l ); +} + +void VCLXListBox::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + pBox->InsertEntry( aItem, nPos ); +} + +void VCLXListBox::addItems( const ::com::sun::star::uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + { + sal_uInt16 nP = nPos; + const ::rtl::OUString* pItems = aItems.getConstArray(); + const ::rtl::OUString* pItemsEnd = aItems.getConstArray() + aItems.getLength(); + while ( pItems != pItemsEnd ) + { + if ( (sal_uInt16)nP == 0xFFFF ) + { + OSL_ENSURE( false, "VCLXListBox::addItems: too many entries!" ); + // skip remaining entries, list cannot hold them, anyway + break; + } + + pBox->InsertEntry( *pItems++, nP++ ); + } + } +} + +void VCLXListBox::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + { + for ( sal_uInt16 n = nCount; n; ) + pBox->RemoveEntry( nPos + (--n) ); + } +} + +sal_Int16 VCLXListBox::getItemCount() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pBox = (ListBox*) GetWindow(); + return pBox ? pBox->GetEntryCount() : 0; +} + +::rtl::OUString VCLXListBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + String aItem; + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + aItem = pBox->GetEntry( nPos ); + return aItem; +} + +::com::sun::star::uno::Sequence< ::rtl::OUString> VCLXListBox::getItems() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq; + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + { + sal_uInt16 nEntries = pBox->GetEntryCount(); + aSeq = ::com::sun::star::uno::Sequence< ::rtl::OUString>( nEntries ); + for ( sal_uInt16 n = nEntries; n; ) + { + --n; + aSeq.getArray()[n] = ::rtl::OUString( pBox->GetEntry( n ) ); + } + } + return aSeq; +} + +sal_Int16 VCLXListBox::getSelectedItemPos() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pBox = (ListBox*) GetWindow(); + return pBox ? pBox->GetSelectEntryPos() : 0; +} + +::com::sun::star::uno::Sequence<sal_Int16> VCLXListBox::getSelectedItemsPos() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Sequence<sal_Int16> aSeq; + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + { + sal_uInt16 nSelEntries = pBox->GetSelectEntryCount(); + aSeq = ::com::sun::star::uno::Sequence<sal_Int16>( nSelEntries ); + for ( sal_uInt16 n = 0; n < nSelEntries; n++ ) + aSeq.getArray()[n] = pBox->GetSelectEntryPos( n ); + } + return aSeq; +} + +::rtl::OUString VCLXListBox::getSelectedItem() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + String aItem; + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + aItem = pBox->GetSelectEntry(); + return aItem; +} + +::com::sun::star::uno::Sequence< ::rtl::OUString> VCLXListBox::getSelectedItems() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq; + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + { + sal_uInt16 nSelEntries = pBox->GetSelectEntryCount(); + aSeq = ::com::sun::star::uno::Sequence< ::rtl::OUString>( nSelEntries ); + for ( sal_uInt16 n = 0; n < nSelEntries; n++ ) + aSeq.getArray()[n] = ::rtl::OUString( pBox->GetSelectEntry( n ) ); + } + return aSeq; +} + +void VCLXListBox::selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox && ( pBox->IsEntryPosSelected( nPos ) != bSelect ) ) + { + pBox->SelectEntryPos( nPos, bSelect ); + + // VCL doesn't call select handler after API call. + // ImplCallItemListeners(); + + // #107218# Call same listeners like VCL would do after user interaction + SetSynthesizingVCLEvent( sal_True ); + pBox->Select(); + SetSynthesizingVCLEvent( sal_False ); + } +} + +void VCLXListBox::selectItemsPos( const ::com::sun::star::uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + { + BOOL bChanged = FALSE; + for ( sal_uInt16 n = (sal_uInt16)aPositions.getLength(); n; ) + { + USHORT nPos = (USHORT) aPositions.getConstArray()[--n]; + if ( pBox->IsEntryPosSelected( nPos ) != bSelect ) + { + pBox->SelectEntryPos( nPos, bSelect ); + bChanged = TRUE; + } + } + + if ( bChanged ) + { + // VCL doesn't call select handler after API call. + // ImplCallItemListeners(); + + // #107218# Call same listeners like VCL would do after user interaction + SetSynthesizingVCLEvent( sal_True ); + pBox->Select(); + SetSynthesizingVCLEvent( sal_False ); + } + } +} + +void VCLXListBox::selectItem( const ::rtl::OUString& rItemText, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + { + String aItemText( rItemText ); + selectItemPos( pBox->GetEntryPos( aItemText ), bSelect ); + } +} + + +void VCLXListBox::setDropDownLineCount( sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + pBox->SetDropDownLineCount( nLines ); +} + +sal_Int16 VCLXListBox::getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int16 nLines = 0; + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + nLines = pBox->GetDropDownLineCount(); + return nLines; +} + +sal_Bool VCLXListBox::isMutipleMode() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Bool bMulti = sal_False; + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + bMulti = pBox->IsMultiSelectionEnabled(); + return bMulti; +} + +void VCLXListBox::setMultipleMode( sal_Bool bMulti ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + pBox->EnableMultiSelection( bMulti ); +} + +void VCLXListBox::makeVisible( sal_Int16 nEntry ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pBox = (ListBox*) GetWindow(); + if ( pBox ) + pBox->SetTopEntry( nEntry ); +} + +void VCLXListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); + // since we call listeners below, there is a potential that we will be destroyed + // in during the listener call. To prevent the resulting crashs, we keep us + // alive as long as we're here + // #20178# - 2003-10-01 - fs@openoffice.org + + switch ( rVclWindowEvent.GetId() ) + { + case VCLEVENT_LISTBOX_SELECT: + { + ListBox* pListBox = (ListBox*)GetWindow(); + + if( pListBox ) + { + sal_Bool bDropDown = ( pListBox->GetStyle() & WB_DROPDOWN ) ? sal_True : sal_False; + if ( bDropDown && !IsSynthesizingVCLEvent() && maActionListeners.getLength() ) + { + // Bei DropDown den ActionListener rufen... + ::com::sun::star::awt::ActionEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.ActionCommand = pListBox->GetSelectEntry(); + maActionListeners.actionPerformed( aEvent ); + } + + if ( maItemListeners.getLength() ) + { + ImplCallItemListeners(); + } + } + } + break; + + case VCLEVENT_LISTBOX_DOUBLECLICK: + if ( GetWindow() && maActionListeners.getLength() ) + { + ::com::sun::star::awt::ActionEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.ActionCommand = ((ListBox*)GetWindow())->GetSelectEntry(); + maActionListeners.actionPerformed( aEvent ); + } + break; + + default: + VCLXWindow::ProcessWindowEvent( rVclWindowEvent ); + break; + } +} + +::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXListBox::CreateAccessibleContext() +{ + ::vos::OGuard aGuard( GetMutex() ); + + return getAccessibleFactory().createAccessibleContext( this ); +} + +void VCLXListBox::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pListBox = (ListBox*)GetWindow(); + if ( pListBox ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_READONLY: + { + sal_Bool b = sal_Bool(); + if ( Value >>= b ) + pListBox->SetReadOnly( b); + } + break; + case BASEPROPERTY_MULTISELECTION: + { + sal_Bool b = sal_Bool(); + if ( Value >>= b ) + pListBox->EnableMultiSelection( b ); + } + break; + case BASEPROPERTY_LINECOUNT: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + pListBox->SetDropDownLineCount( n ); + } + break; + case BASEPROPERTY_STRINGITEMLIST: + { + ::com::sun::star::uno::Sequence< ::rtl::OUString> aItems; + if ( Value >>= aItems ) + { + pListBox->Clear(); + addItems( aItems, 0 ); + } + } + break; + case BASEPROPERTY_SELECTEDITEMS: + { + ::com::sun::star::uno::Sequence<sal_Int16> aItems; + if ( Value >>= aItems ) + { + for ( sal_uInt16 n = pListBox->GetEntryCount(); n; ) + pListBox->SelectEntryPos( --n, sal_False ); + + if ( aItems.getLength() ) + selectItemsPos( aItems, sal_True ); + else + pListBox->SetNoSelection(); + + if ( !pListBox->GetSelectEntryCount() ) + pListBox->SetTopEntry( 0 ); + } + } + break; + default: + { + VCLXWindow::setProperty( PropertyName, Value ); + } + } + } +} + +::com::sun::star::uno::Any VCLXListBox::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + ListBox* pListBox = (ListBox*)GetWindow(); + if ( pListBox ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_READONLY: + { + aProp <<= (sal_Bool) pListBox->IsReadOnly(); + } + break; + case BASEPROPERTY_MULTISELECTION: + { + aProp <<= (sal_Bool) pListBox->IsMultiSelectionEnabled(); + } + break; + case BASEPROPERTY_LINECOUNT: + { + aProp <<= (sal_Int16) pListBox->GetDropDownLineCount(); + } + break; + case BASEPROPERTY_STRINGITEMLIST: + { + sal_uInt16 nItems = pListBox->GetEntryCount(); + ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq( nItems ); + ::rtl::OUString* pStrings = aSeq.getArray(); + for ( sal_uInt16 n = 0; n < nItems; n++ ) + pStrings[n] = pListBox->GetEntry( n ); + aProp <<= aSeq; + + } + break; + default: + { + aProp <<= VCLXWindow::getProperty( PropertyName ); + } + } + } + return aProp; +} + +::com::sun::star::awt::Size VCLXListBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + ListBox* pListBox = (ListBox*) GetWindow(); + if ( pListBox ) + aSz = pListBox->CalcMinimumSize(); + return AWTSize(aSz); +} + +::com::sun::star::awt::Size VCLXListBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + ListBox* pListBox = (ListBox*) GetWindow(); + if ( pListBox ) + { + aSz = pListBox->CalcMinimumSize(); + if ( pListBox->GetStyle() & WB_DROPDOWN ) + aSz.Height() += 4; + } + return AWTSize(aSz); +} + +::com::sun::star::awt::Size VCLXListBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz = VCLSize(rNewSize); + ListBox* pListBox = (ListBox*) GetWindow(); + if ( pListBox ) + aSz = pListBox->CalcAdjustedSize( aSz ); + return AWTSize(aSz); +} + +::com::sun::star::awt::Size VCLXListBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + ListBox* pListBox = (ListBox*) GetWindow(); + if ( pListBox ) + aSz = pListBox->CalcSize( nCols, nLines ); + return AWTSize(aSz); +} + +void VCLXListBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + nCols = nLines = 0; + ListBox* pListBox = (ListBox*) GetWindow(); + if ( pListBox ) + { + sal_uInt16 nC, nL; + pListBox->GetMaxVisColumnsAndLines( nC, nL ); + nCols = nC; + nLines = nL; + } +} + +void VCLXListBox::ImplCallItemListeners() +{ + ListBox* pListBox = (ListBox*) GetWindow(); + if ( pListBox && maItemListeners.getLength() ) + { + ::com::sun::star::awt::ItemEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.Highlighted = sal_False; + + // Bei Mehrfachselektion 0xFFFF, sonst die ID + aEvent.Selected = (pListBox->GetSelectEntryCount() == 1 ) ? pListBox->GetSelectEntryPos() : 0xFFFF; + + maItemListeners.itemStateChanged( aEvent ); + } +} + + +// ---------------------------------------------------- +// class VCLXMessageBox +// ---------------------------------------------------- + +void VCLXMessageBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + VCLXTopWindow::ImplGetPropertyIds( rIds ); +} + +VCLXMessageBox::VCLXMessageBox() +{ +} + +VCLXMessageBox::~VCLXMessageBox() +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXMessageBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XMessageBox*, this ) ); + return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXMessageBox ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMessageBox>* ) NULL ), + VCLXTopWindow::getTypes() +IMPL_XTYPEPROVIDER_END + +void VCLXMessageBox::setCaptionText( const ::rtl::OUString& rText ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + pWindow->SetText( rText ); +} + +::rtl::OUString VCLXMessageBox::getCaptionText() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + String aText; + Window* pWindow = GetWindow(); + if ( pWindow ) + aText = pWindow->GetText(); + return aText; +} + +void VCLXMessageBox::setMessageText( const ::rtl::OUString& rText ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + MessBox* pBox = (MessBox*)GetWindow(); + if ( pBox ) + pBox->SetMessText( rText ); +} + +::rtl::OUString VCLXMessageBox::getMessageText() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::rtl::OUString aText; + MessBox* pBox = (MessBox*)GetWindow(); + if ( pBox ) + aText = pBox->GetMessText(); + return aText; +} + +sal_Int16 VCLXMessageBox::execute() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + MessBox* pBox = (MessBox*)GetWindow(); + return pBox ? pBox->Execute() : 0; +} + +::com::sun::star::awt::Size SAL_CALL VCLXMessageBox::getMinimumSize() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + return ::com::sun::star::awt::Size( 250, 100 ); +} + +// ---------------------------------------------------- +// class VCLXDialog +// ---------------------------------------------------- +void VCLXDialog::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + VCLXTopWindow::ImplGetPropertyIds( rIds ); +} + +VCLXDialog::VCLXDialog() +{ +} + +VCLXDialog::~VCLXDialog() +{ +#ifndef __SUNPRO_CC + OSL_TRACE ("%s", __FUNCTION__); +#endif +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXDialog::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XDialog*, this ) ); + return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXDialog ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDialog>* ) NULL ), + VCLXTopWindow::getTypes() +IMPL_XTYPEPROVIDER_END + +void VCLXDialog::setTitle( const ::rtl::OUString& Title ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + pWindow->SetText( Title ); +} + +::rtl::OUString VCLXDialog::getTitle() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::rtl::OUString aTitle; + Window* pWindow = GetWindow(); + if ( pWindow ) + aTitle = pWindow->GetText(); + return aTitle; +} + +sal_Int16 VCLXDialog::execute() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int16 nRet = 0; + if ( GetWindow() ) + { + Dialog* pDlg = (Dialog*) GetWindow(); + Window* pParent = pDlg->GetWindow( WINDOW_PARENTOVERLAP ); + Window* pOldParent = NULL; + if ( pParent && !pParent->IsReallyVisible() ) + { + pOldParent = pDlg->GetParent(); + Window* pFrame = pDlg->GetWindow( WINDOW_FRAME ); + if( pFrame != pDlg ) + pDlg->SetParent( pFrame ); + } + nRet = pDlg->Execute(); + if ( pOldParent ) + pDlg->SetParent( pOldParent ); + } + return nRet; +} + +void VCLXDialog::endExecute() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Dialog* pDlg = (Dialog*) GetWindow(); + if ( pDlg ) + pDlg->EndDialog( 0 ); +} + +void SAL_CALL VCLXDialog::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + Window* pWindow = GetWindow(); + + if ( pWindow ) + { + OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); + if ( !pDev ) + pDev = pWindow->GetParent(); + + Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() ); + Point aPos = pDev->PixelToLogic( Point( nX, nY ) ); + + pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS ); + } +} + +::com::sun::star::awt::DeviceInfo VCLXDialog::getInfo() throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo(); + + ::vos::OGuard aGuard( GetMutex() ); + Dialog* pDlg = (Dialog*) GetWindow(); + if ( pDlg ) + pDlg->GetDrawWindowBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset ); + + return aInfo; +} + + +void SAL_CALL VCLXDialog::setProperty( + const ::rtl::OUString& PropertyName, + const ::com::sun::star::uno::Any& Value ) +throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Dialog* pDialog = (Dialog*)GetWindow(); + if ( pDialog ) + { + sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_GRAPHIC: + { + Reference< XGraphic > xGraphic; + if (( Value >>= xGraphic ) && xGraphic.is() ) + { + Image aImage( xGraphic ); + + Wallpaper aWallpaper( aImage.GetBitmapEx()); + aWallpaper.SetStyle( WALLPAPER_SCALE ); + pDialog->SetBackground( aWallpaper ); + } + else if ( bVoid || !xGraphic.is() ) + { + Color aColor = pDialog->GetControlBackground().GetColor(); + if ( aColor == COL_AUTO ) + aColor = pDialog->GetSettings().GetStyleSettings().GetDialogColor(); + + Wallpaper aWallpaper( aColor ); + pDialog->SetBackground( aWallpaper ); + } + } + break; + + default: + { + VCLXWindow::setProperty( PropertyName, Value ); + } + } + } +} + +// ---------------------------------------------------- +// class VCLXTabPage +// ---------------------------------------------------- +VCLXTabPage::VCLXTabPage() +{ +} + +VCLXTabPage::~VCLXTabPage() +{ +} + +::com::sun::star::uno::Any SAL_CALL VCLXTabPage::queryInterface(const ::com::sun::star::uno::Type & rType ) +throw(::com::sun::star::uno::RuntimeException) +{ + return VCLXContainer::queryInterface( rType ); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXTabPage ) + VCLXContainer::getTypes() +IMPL_XTYPEPROVIDER_END + +// ::com::sun::star::awt::XView +void SAL_CALL VCLXTabPage::draw( sal_Int32 nX, sal_Int32 nY ) +throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + Window* pWindow = GetWindow(); + + if ( pWindow ) + { + OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); + if ( !pDev ) + pDev = pWindow->GetParent(); + + Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() ); + Point aPos = pDev->PixelToLogic( Point( nX, nY ) ); + + pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS ); + } +} + +// ::com::sun::star::awt::XDevice, +::com::sun::star::awt::DeviceInfo SAL_CALL VCLXTabPage::getInfo() +throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo(); + return aInfo; +} + +void SAL_CALL VCLXTabPage::setProperty( + const ::rtl::OUString& PropertyName, + const ::com::sun::star::uno::Any& Value ) +throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + TabPage* pTabPage = (TabPage*)GetWindow(); + if ( pTabPage ) + { + sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_GRAPHIC: + { + Reference< XGraphic > xGraphic; + if (( Value >>= xGraphic ) && xGraphic.is() ) + { + Image aImage( xGraphic ); + + Wallpaper aWallpaper( aImage.GetBitmapEx()); + aWallpaper.SetStyle( WALLPAPER_SCALE ); + pTabPage->SetBackground( aWallpaper ); + } + else if ( bVoid || !xGraphic.is() ) + { + Color aColor = pTabPage->GetControlBackground().GetColor(); + if ( aColor == COL_AUTO ) + aColor = pTabPage->GetSettings().GetStyleSettings().GetDialogColor(); + + Wallpaper aWallpaper( aColor ); + pTabPage->SetBackground( aWallpaper ); + } + } + break; + + default: + { + VCLXContainer::setProperty( PropertyName, Value ); + } + } + } +} + +// ---------------------------------------------------- +// class VCLXFixedHyperlink +// ---------------------------------------------------- +VCLXFixedHyperlink::VCLXFixedHyperlink() : + + maActionListeners( *this ) + +{ +} + +VCLXFixedHyperlink::~VCLXFixedHyperlink() +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXFixedHyperlink::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XFixedHyperlink*, this ) ); + return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); +} + +void VCLXFixedHyperlink::dispose() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::lang::EventObject aObj; + aObj.Source = (::cppu::OWeakObject*)this; + maActionListeners.disposeAndClear( aObj ); + VCLXWindow::dispose(); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXFixedHyperlink ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFixedHyperlink>* ) NULL ), + VCLXWindow::getTypes() +IMPL_XTYPEPROVIDER_END + +void VCLXFixedHyperlink::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + switch ( rVclWindowEvent.GetId() ) + { + case VCLEVENT_BUTTON_CLICK: + { + if ( maActionListeners.getLength() ) + { + ::com::sun::star::awt::ActionEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + maActionListeners.actionPerformed( aEvent ); + } + else + { + // open the URL + ::rtl::OUString sURL; + ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow(); + if ( pBase ) + sURL = pBase->GetURL(); + Reference< ::com::sun::star::system::XSystemShellExecute > xSystemShellExecute( + ::comphelper::getProcessServiceFactory()->createInstance( + ::rtl::OUString::createFromAscii( "com.sun.star.system.SystemShellExecute" )), uno::UNO_QUERY ); + if ( sURL.getLength() > 0 && xSystemShellExecute.is() ) + { + try + { + // start browser + xSystemShellExecute->execute( + sURL, ::rtl::OUString(), ::com::sun::star::system::SystemShellExecuteFlags::DEFAULTS ); + } + catch( uno::Exception& ) + { + } + } + } + } + + default: + VCLXWindow::ProcessWindowEvent( rVclWindowEvent ); + break; + } +} + +::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXFixedHyperlink::CreateAccessibleContext() +{ + return getAccessibleFactory().createAccessibleContext( this ); +} + +void VCLXFixedHyperlink::setText( const ::rtl::OUString& Text ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow(); + if ( pBase ) + pBase->SetDescription( Text ); +} + +::rtl::OUString VCLXFixedHyperlink::getText() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::rtl::OUString aText; + Window* pWindow = GetWindow(); + if ( pWindow ) + aText = pWindow->GetText(); + return aText; +} + +void VCLXFixedHyperlink::setURL( const ::rtl::OUString& URL ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow(); + if ( pBase ) + pBase->SetURL( URL ); +} + +::rtl::OUString VCLXFixedHyperlink::getURL( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::rtl::OUString aText; + ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow(); + if ( pBase ) + aText = pBase->GetURL(); + return aText; +} + +void VCLXFixedHyperlink::setAlignment( short nAlign ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + { + WinBits nNewBits = 0; + if ( nAlign == ::com::sun::star::awt::TextAlign::LEFT ) + nNewBits = WB_LEFT; + else if ( nAlign == ::com::sun::star::awt::TextAlign::CENTER ) + nNewBits = WB_CENTER; + else + nNewBits = WB_RIGHT; + + WinBits nStyle = pWindow->GetStyle(); + nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT); + pWindow->SetStyle( nStyle | nNewBits ); + } +} + +short VCLXFixedHyperlink::getAlignment() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + short nAlign = 0; + Window* pWindow = GetWindow(); + if ( pWindow ) + { + WinBits nStyle = pWindow->GetStyle(); + if ( nStyle & WB_LEFT ) + nAlign = ::com::sun::star::awt::TextAlign::LEFT; + else if ( nStyle & WB_CENTER ) + nAlign = ::com::sun::star::awt::TextAlign::CENTER; + else + nAlign = ::com::sun::star::awt::TextAlign::RIGHT; + } + return nAlign; +} + +void VCLXFixedHyperlink::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionListeners.addInterface( l ); +} + +void VCLXFixedHyperlink::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionListeners.removeInterface( l ); +} + +::com::sun::star::awt::Size VCLXFixedHyperlink::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + FixedText* pFixedText = (FixedText*)GetWindow(); + if ( pFixedText ) + aSz = pFixedText->CalcMinimumSize(); + return AWTSize(aSz); +} + +::com::sun::star::awt::Size VCLXFixedHyperlink::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + return getMinimumSize(); +} + +::com::sun::star::awt::Size VCLXFixedHyperlink::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::awt::Size aSz = rNewSize; + ::com::sun::star::awt::Size aMinSz = getMinimumSize(); + if ( aSz.Height != aMinSz.Height ) + aSz.Height = aMinSz.Height; + + return aSz; +} + +void VCLXFixedHyperlink::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow(); + if ( pBase ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_LABEL: + { + ::rtl::OUString sNewLabel; + if ( Value >>= sNewLabel ) + pBase->SetDescription( sNewLabel ); + break; + } + + case BASEPROPERTY_URL: + { + ::rtl::OUString sNewURL; + if ( Value >>= sNewURL ) + pBase->SetURL( sNewURL ); + break; + } + + default: + { + VCLXWindow::setProperty( PropertyName, Value ); + } + } + } +} + +::com::sun::star::uno::Any VCLXFixedHyperlink::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow(); + if ( pBase ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_URL: + { + aProp = makeAny( ::rtl::OUString( pBase->GetURL() ) ); + break; + } + + default: + { + aProp <<= VCLXWindow::getProperty( PropertyName ); + } + } + } + return aProp; +} + +void VCLXFixedHyperlink::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_ALIGN, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_LABEL, + BASEPROPERTY_MULTILINE, + BASEPROPERTY_NOLABEL, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_VERTICALALIGN, + BASEPROPERTY_URL, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + 0); + VCLXWindow::ImplGetPropertyIds( rIds ); +} + +// ---------------------------------------------------- +// class VCLXFixedText +// ---------------------------------------------------- +void VCLXFixedText::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_ALIGN, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_LABEL, + BASEPROPERTY_MULTILINE, + BASEPROPERTY_NOLABEL, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_VERTICALALIGN, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_REFERENCE_DEVICE, + 0); + VCLXWindow::ImplGetPropertyIds( rIds ); +} + +VCLXFixedText::VCLXFixedText() +{ +} + +VCLXFixedText::~VCLXFixedText() +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXFixedText::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XFixedText*, this ) ); + return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXFixedText ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFixedText>* ) NULL ), + VCLXWindow::getTypes() +IMPL_XTYPEPROVIDER_END + +::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXFixedText::CreateAccessibleContext() +{ + return getAccessibleFactory().createAccessibleContext( this ); +} + +void VCLXFixedText::setText( const ::rtl::OUString& Text ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + pWindow->SetText( Text ); +} + +::rtl::OUString VCLXFixedText::getText() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::rtl::OUString aText; + Window* pWindow = GetWindow(); + if ( pWindow ) + aText = pWindow->GetText(); + return aText; +} + +void VCLXFixedText::setAlignment( short nAlign ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + { + WinBits nNewBits = 0; + if ( nAlign == ::com::sun::star::awt::TextAlign::LEFT ) + nNewBits = WB_LEFT; + else if ( nAlign == ::com::sun::star::awt::TextAlign::CENTER ) + nNewBits = WB_CENTER; + else + nNewBits = WB_RIGHT; + + WinBits nStyle = pWindow->GetStyle(); + nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT); + pWindow->SetStyle( nStyle | nNewBits ); + } +} + +short VCLXFixedText::getAlignment() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + short nAlign = 0; + Window* pWindow = GetWindow(); + if ( pWindow ) + { + WinBits nStyle = pWindow->GetStyle(); + if ( nStyle & WB_LEFT ) + nAlign = ::com::sun::star::awt::TextAlign::LEFT; + else if ( nStyle & WB_CENTER ) + nAlign = ::com::sun::star::awt::TextAlign::CENTER; + else + nAlign = ::com::sun::star::awt::TextAlign::RIGHT; + } + return nAlign; +} + +::com::sun::star::awt::Size VCLXFixedText::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + FixedText* pFixedText = (FixedText*)GetWindow(); + if ( pFixedText ) + aSz = pFixedText->CalcMinimumSize(); + return AWTSize(aSz); +} + +::com::sun::star::awt::Size VCLXFixedText::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + return getMinimumSize(); +} + +::com::sun::star::awt::Size VCLXFixedText::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::awt::Size aSz = rNewSize; + ::com::sun::star::awt::Size aMinSz = getMinimumSize(); + if ( aSz.Height != aMinSz.Height ) + aSz.Height = aMinSz.Height; + + return aSz; +} + +// ---------------------------------------------------- +// class VCLXScrollBar +// ---------------------------------------------------- +void VCLXScrollBar::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BLOCKINCREMENT, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_LINEINCREMENT, + BASEPROPERTY_LIVE_SCROLL, + BASEPROPERTY_ORIENTATION, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_REPEAT_DELAY, + BASEPROPERTY_SCROLLVALUE, + BASEPROPERTY_SCROLLVALUE_MAX, + BASEPROPERTY_SCROLLVALUE_MIN, + BASEPROPERTY_SYMBOL_COLOR, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_VISIBLESIZE, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + 0); + VCLXWindow::ImplGetPropertyIds( rIds ); +} + +VCLXScrollBar::VCLXScrollBar() : maAdjustmentListeners( *this ) +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXScrollBar::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XScrollBar*, this ) ); + return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXScrollBar ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XScrollBar>* ) NULL ), + VCLXWindow::getTypes() +IMPL_XTYPEPROVIDER_END + +::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXScrollBar::CreateAccessibleContext() +{ + return getAccessibleFactory().createAccessibleContext( this ); +} + +// ::com::sun::star::lang::XComponent +void VCLXScrollBar::dispose() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::lang::EventObject aObj; + aObj.Source = (::cppu::OWeakObject*)this; + maAdjustmentListeners.disposeAndClear( aObj ); + VCLXWindow::dispose(); +} + +// ::com::sun::star::awt::XScrollbar +void VCLXScrollBar::addAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maAdjustmentListeners.addInterface( l ); +} + +void VCLXScrollBar::removeAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maAdjustmentListeners.removeInterface( l ); +} + +void VCLXScrollBar::setValue( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); + if ( pScrollBar ) + pScrollBar->DoScroll( n ); +} + +void VCLXScrollBar::setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); + if ( pScrollBar ) + { + pScrollBar->SetVisibleSize( nVisible ); + pScrollBar->SetRangeMax( nMax ); + pScrollBar->DoScroll( nValue ); + } +} + +sal_Int32 VCLXScrollBar::getValue() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); + return pScrollBar ? pScrollBar->GetThumbPos() : 0; +} + +void VCLXScrollBar::setMaximum( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); + if ( pScrollBar ) + pScrollBar->SetRangeMax( n ); +} + +sal_Int32 VCLXScrollBar::getMaximum() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); + return pScrollBar ? pScrollBar->GetRangeMax() : 0; +} + +void VCLXScrollBar::setMinimum( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() ); + if ( pScrollBar ) + pScrollBar->SetRangeMin( n ); +} + +sal_Int32 VCLXScrollBar::getMinimum() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() ); + return pScrollBar ? pScrollBar->GetRangeMin() : 0; +} + +void VCLXScrollBar::setLineIncrement( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); + if ( pScrollBar ) + pScrollBar->SetLineSize( n ); +} + +sal_Int32 VCLXScrollBar::getLineIncrement() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); + return pScrollBar ? pScrollBar->GetLineSize() : 0; +} + +void VCLXScrollBar::setBlockIncrement( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); + if ( pScrollBar ) + pScrollBar->SetPageSize( n ); +} + +sal_Int32 VCLXScrollBar::getBlockIncrement() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); + return pScrollBar ? pScrollBar->GetPageSize() : 0; +} + +void VCLXScrollBar::setVisibleSize( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); + if ( pScrollBar ) + pScrollBar->SetVisibleSize( n ); +} + +sal_Int32 VCLXScrollBar::getVisibleSize() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); + return pScrollBar ? pScrollBar->GetVisibleSize() : 0; +} + +void VCLXScrollBar::setOrientation( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Window* pWindow = GetWindow(); + if ( pWindow ) + { + WinBits nStyle = pWindow->GetStyle(); + nStyle &= ~(WB_HORZ|WB_VERT); + if ( n == ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL ) + nStyle |= WB_HORZ; + else + nStyle |= WB_VERT; + + pWindow->SetStyle( nStyle ); + pWindow->Resize(); + } +} + +sal_Int32 VCLXScrollBar::getOrientation() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int32 n = 0; + Window* pWindow = GetWindow(); + if ( pWindow ) + { + WinBits nStyle = pWindow->GetStyle(); + if ( nStyle & WB_HORZ ) + n = ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL; + else + n = ::com::sun::star::awt::ScrollBarOrientation::VERTICAL; + } + return n; + +} + +// ::com::sun::star::awt::VclWindowPeer +void VCLXScrollBar::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ScrollBar* pScrollBar = (ScrollBar*)GetWindow(); + if ( pScrollBar ) + { + sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_LIVE_SCROLL: + { + sal_Bool bDo = sal_False; + if ( !bVoid ) + { + OSL_VERIFY( Value >>= bDo ); + } + AllSettings aSettings( pScrollBar->GetSettings() ); + StyleSettings aStyle( aSettings.GetStyleSettings() ); + ULONG nDragOptions = aStyle.GetDragFullOptions(); + if ( bDo ) + nDragOptions |= DRAGFULL_OPTION_SCROLL; + else + nDragOptions &= ~DRAGFULL_OPTION_SCROLL; + aStyle.SetDragFullOptions( nDragOptions ); + aSettings.SetStyleSettings( aStyle ); + pScrollBar->SetSettings( aSettings ); + } + break; + + case BASEPROPERTY_SCROLLVALUE: + { + if ( !bVoid ) + { + sal_Int32 n = 0; + if ( Value >>= n ) + setValue( n ); + } + } + break; + case BASEPROPERTY_SCROLLVALUE_MAX: + case BASEPROPERTY_SCROLLVALUE_MIN: + { + if ( !bVoid ) + { + sal_Int32 n = 0; + if ( Value >>= n ) + { + if ( nPropType == BASEPROPERTY_SCROLLVALUE_MAX ) + setMaximum( n ); + else + setMinimum( n ); + } + } + } + break; + case BASEPROPERTY_LINEINCREMENT: + { + if ( !bVoid ) + { + sal_Int32 n = 0; + if ( Value >>= n ) + setLineIncrement( n ); + } + } + break; + case BASEPROPERTY_BLOCKINCREMENT: + { + if ( !bVoid ) + { + sal_Int32 n = 0; + if ( Value >>= n ) + setBlockIncrement( n ); + } + } + break; + case BASEPROPERTY_VISIBLESIZE: + { + if ( !bVoid ) + { + sal_Int32 n = 0; + if ( Value >>= n ) + setVisibleSize( n ); + } + } + break; + case BASEPROPERTY_ORIENTATION: + { + if ( !bVoid ) + { + sal_Int32 n = 0; + if ( Value >>= n ) + setOrientation( n ); + } + } + break; + + case BASEPROPERTY_BACKGROUNDCOLOR: + { + // the default implementation of the base class doesn't work here, since our + // interpretation for this property is slightly different + ::toolkit::setButtonLikeFaceColor( pScrollBar, Value); + } + break; + + default: + { + VCLXWindow::setProperty( PropertyName, Value ); + } + } + } +} + +::com::sun::star::uno::Any VCLXScrollBar::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + ScrollBar* pScrollBar = (ScrollBar*)GetWindow(); + if ( pScrollBar ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + + switch ( nPropType ) + { + case BASEPROPERTY_LIVE_SCROLL: + { + aProp <<= (sal_Bool)( 0 != ( pScrollBar->GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_SCROLL ) ); + } + break; + case BASEPROPERTY_SCROLLVALUE: + { + aProp <<= (sal_Int32) getValue(); + } + break; + case BASEPROPERTY_SCROLLVALUE_MAX: + { + aProp <<= (sal_Int32) getMaximum(); + } + break; + case BASEPROPERTY_SCROLLVALUE_MIN: + { + aProp <<= (sal_Int32) getMinimum(); + } + break; + case BASEPROPERTY_LINEINCREMENT: + { + aProp <<= (sal_Int32) getLineIncrement(); + } + break; + case BASEPROPERTY_BLOCKINCREMENT: + { + aProp <<= (sal_Int32) getBlockIncrement(); + } + break; + case BASEPROPERTY_VISIBLESIZE: + { + aProp <<= (sal_Int32) getVisibleSize(); + } + break; + case BASEPROPERTY_ORIENTATION: + { + aProp <<= (sal_Int32) getOrientation(); + } + break; + case BASEPROPERTY_BACKGROUNDCOLOR: + { + // the default implementation of the base class doesn't work here, since our + // interpretation for this property is slightly different + aProp = ::toolkit::getButtonLikeFaceColor( pScrollBar ); + } + break; + + default: + { + aProp <<= VCLXWindow::getProperty( PropertyName ); + } + } + } + return aProp; +} + +void VCLXScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + switch ( rVclWindowEvent.GetId() ) + { + case VCLEVENT_SCROLLBAR_SCROLL: + { + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); + // since we call listeners below, there is a potential that we will be destroyed + // in during the listener call. To prevent the resulting crashs, we keep us + // alive as long as we're here + // #20178# - 2003-10-01 - fs@openoffice.org + + if ( maAdjustmentListeners.getLength() ) + { + ScrollBar* pScrollBar = (ScrollBar*)GetWindow(); + + if( pScrollBar ) + { + ::com::sun::star::awt::AdjustmentEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.Value = pScrollBar->GetThumbPos(); + + // set adjustment type + ScrollType aType = pScrollBar->GetType(); + if ( aType == SCROLL_LINEUP || aType == SCROLL_LINEDOWN ) + { + aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_LINE; + } + else if ( aType == SCROLL_PAGEUP || aType == SCROLL_PAGEDOWN ) + { + aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_PAGE; + } + else if ( aType == SCROLL_DRAG ) + { + aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_ABS; + } + + maAdjustmentListeners.adjustmentValueChanged( aEvent ); + } + } + } + break; + + default: + VCLXWindow::ProcessWindowEvent( rVclWindowEvent ); + break; + } +} + +::com::sun::star::awt::Size SAL_CALL VCLXScrollBar::implGetMinimumSize( Window* p ) throw(::com::sun::star::uno::RuntimeException) +{ + long n = p->GetSettings().GetStyleSettings().GetScrollBarSize(); + return ::com::sun::star::awt::Size( n, n ); +} + +::com::sun::star::awt::Size SAL_CALL VCLXScrollBar::getMinimumSize() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + return implGetMinimumSize( GetWindow() ); +} + + +// ---------------------------------------------------- +// class VCLXEdit +// ---------------------------------------------------- + +void VCLXEdit::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_ALIGN, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_ECHOCHAR, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_HARDLINEBREAKS, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_HSCROLL, + BASEPROPERTY_LINE_END_FORMAT, + BASEPROPERTY_MAXTEXTLEN, + BASEPROPERTY_MULTILINE, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_READONLY, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_TEXT, + BASEPROPERTY_VSCROLL, + BASEPROPERTY_HIDEINACTIVESELECTION, + BASEPROPERTY_PAINTTRANSPARENT, + BASEPROPERTY_AUTOHSCROLL, + BASEPROPERTY_AUTOVSCROLL, + BASEPROPERTY_VERTICALALIGN, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + 0); + VCLXWindow::ImplGetPropertyIds( rIds ); +} + +VCLXEdit::VCLXEdit() : maTextListeners( *this ) +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXEdit::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XTextComponent*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XTextEditField*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XTextLayoutConstrains*, this ) ); + return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXEdit ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextEditField>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextLayoutConstrains>* ) NULL ), + VCLXWindow::getTypes() +IMPL_XTYPEPROVIDER_END + +::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXEdit::CreateAccessibleContext() +{ + return getAccessibleFactory().createAccessibleContext( this ); +} + +void VCLXEdit::dispose() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::lang::EventObject aObj; + aObj.Source = (::cppu::OWeakObject*)this; + maTextListeners.disposeAndClear( aObj ); + VCLXWindow::dispose(); +} + +void VCLXEdit::addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + GetTextListeners().addInterface( l ); +} + +void VCLXEdit::removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + GetTextListeners().removeInterface( l ); +} + +void VCLXEdit::setText( const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Edit* pEdit = (Edit*)GetWindow(); + if ( pEdit ) + { + pEdit->SetText( aText ); + + // #107218# Call same listeners like VCL would do after user interaction + SetSynthesizingVCLEvent( sal_True ); + pEdit->SetModifyFlag(); + pEdit->Modify(); + SetSynthesizingVCLEvent( sal_False ); + } +} + +void VCLXEdit::insertText( const ::com::sun::star::awt::Selection& rSel, const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Edit* pEdit = (Edit*)GetWindow(); + if ( pEdit ) + { + pEdit->SetSelection( Selection( rSel.Min, rSel.Max ) ); + pEdit->ReplaceSelected( aText ); + + // #107218# Call same listeners like VCL would do after user interaction + SetSynthesizingVCLEvent( sal_True ); + pEdit->SetModifyFlag(); + pEdit->Modify(); + SetSynthesizingVCLEvent( sal_False ); + } +} + +::rtl::OUString VCLXEdit::getText() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::rtl::OUString aText; + Window* pWindow = GetWindow(); + if ( pWindow ) + aText = pWindow->GetText(); + return aText; +} + +::rtl::OUString VCLXEdit::getSelectedText() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::rtl::OUString aText; + Edit* pEdit = (Edit*) GetWindow(); + if ( pEdit) + aText = pEdit->GetSelected(); + return aText; + +} + +void VCLXEdit::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Edit* pEdit = (Edit*) GetWindow(); + if ( pEdit ) + pEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) ); +} + +::com::sun::star::awt::Selection VCLXEdit::getSelection() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Selection aSel; + Edit* pEdit = (Edit*) GetWindow(); + if ( pEdit ) + aSel = pEdit->GetSelection(); + return ::com::sun::star::awt::Selection( aSel.Min(), aSel.Max() ); +} + +sal_Bool VCLXEdit::isEditable() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Edit* pEdit = (Edit*) GetWindow(); + return ( pEdit && !pEdit->IsReadOnly() && pEdit->IsEnabled() ) ? sal_True : sal_False; +} + +void VCLXEdit::setEditable( sal_Bool bEditable ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Edit* pEdit = (Edit*) GetWindow(); + if ( pEdit ) + pEdit->SetReadOnly( !bEditable ); +} + + +void VCLXEdit::setMaxTextLen( sal_Int16 nLen ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Edit* pEdit = (Edit*) GetWindow(); + if ( pEdit ) + pEdit->SetMaxTextLen( nLen ); +} + +sal_Int16 VCLXEdit::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Edit* pEdit = (Edit*) GetWindow(); + return pEdit ? pEdit->GetMaxTextLen() : 0; +} + +void VCLXEdit::setEchoChar( sal_Unicode cEcho ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Edit* pEdit = (Edit*) GetWindow(); + if ( pEdit ) + pEdit->SetEchoChar( cEcho ); +} + +void VCLXEdit::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Edit* pEdit = (Edit*)GetWindow(); + if ( pEdit ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_HIDEINACTIVESELECTION: + ::toolkit::adjustBooleanWindowStyle( Value, pEdit, WB_NOHIDESELECTION, sal_True ); + if ( pEdit->GetSubEdit() ) + ::toolkit::adjustBooleanWindowStyle( Value, pEdit->GetSubEdit(), WB_NOHIDESELECTION, sal_True ); + break; + + case BASEPROPERTY_READONLY: + { + sal_Bool b = sal_Bool(); + if ( Value >>= b ) + pEdit->SetReadOnly( b ); + } + break; + case BASEPROPERTY_ECHOCHAR: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + pEdit->SetEchoChar( n ); + } + break; + case BASEPROPERTY_MAXTEXTLEN: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + pEdit->SetMaxTextLen( n ); + } + break; + default: + { + VCLXWindow::setProperty( PropertyName, Value ); + } + } + } +} + +::com::sun::star::uno::Any VCLXEdit::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + Edit* pEdit = (Edit*)GetWindow(); + if ( pEdit ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_HIDEINACTIVESELECTION: + aProp <<= (sal_Bool)( ( pEdit->GetStyle() & WB_NOHIDESELECTION ) == 0 ); + break; + case BASEPROPERTY_READONLY: + aProp <<= (sal_Bool) pEdit->IsReadOnly(); + break; + case BASEPROPERTY_ECHOCHAR: + aProp <<= (sal_Int16) pEdit->GetEchoChar(); + break; + case BASEPROPERTY_MAXTEXTLEN: + aProp <<= (sal_Int16) pEdit->GetMaxTextLen(); + break; + default: + { + aProp = VCLXWindow::getProperty( PropertyName ); + } + } + } + return aProp; +} + +::com::sun::star::awt::Size VCLXEdit::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + Edit* pEdit = (Edit*) GetWindow(); + if ( pEdit ) + aSz = pEdit->CalcMinimumSize(); + return AWTSize(aSz); +} + +::com::sun::star::awt::Size VCLXEdit::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + Edit* pEdit = (Edit*) GetWindow(); + if ( pEdit ) + { + aSz = pEdit->CalcMinimumSize(); + aSz.Height() += 4; + } + return AWTSize(aSz); +} + +::com::sun::star::awt::Size VCLXEdit::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::awt::Size aSz = rNewSize; + ::com::sun::star::awt::Size aMinSz = getMinimumSize(); + if ( aSz.Height != aMinSz.Height ) + aSz.Height = aMinSz.Height; + + return aSz; +} + +::com::sun::star::awt::Size VCLXEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + Edit* pEdit = (Edit*) GetWindow(); + if ( pEdit ) + { + if ( nCols ) + aSz = pEdit->CalcSize( nCols ); + else + aSz = pEdit->CalcMinimumSize(); + } + return AWTSize(aSz); +} + +void VCLXEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + nLines = 1; + nCols = 0; + Edit* pEdit = (Edit*) GetWindow(); + if ( pEdit ) + nCols = pEdit->GetMaxVisChars(); +} + +void VCLXEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + switch ( rVclWindowEvent.GetId() ) + { + case VCLEVENT_EDIT_MODIFY: + { + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); + // since we call listeners below, there is a potential that we will be destroyed + // during the listener call. To prevent the resulting crashs, we keep us + // alive as long as we're here + // #20178# - 2003-10-01 - fs@openoffice.org + + if ( GetTextListeners().getLength() ) + { + ::com::sun::star::awt::TextEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + GetTextListeners().textChanged( aEvent ); + } + } + break; + + default: + VCLXWindow::ProcessWindowEvent( rVclWindowEvent ); + break; + } +} + +// ---------------------------------------------------- +// class VCLXComboBox +// ---------------------------------------------------- + +void VCLXComboBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_AUTOCOMPLETE, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_DROPDOWN, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_LINECOUNT, + BASEPROPERTY_MAXTEXTLEN, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_READONLY, + BASEPROPERTY_STRINGITEMLIST, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_TEXT, + BASEPROPERTY_HIDEINACTIVESELECTION, + BASEPROPERTY_ALIGN, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_REFERENCE_DEVICE, + BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, + 0); + // no, don't call VCLXEdit here - it has properties which we do *not* want to have at at combo box + // #i92690# / 2008-08-12 / frank.schoenheit@sun.com + // VCLXEdit::ImplGetPropertyIds( rIds ); + VCLXWindow::ImplGetPropertyIds( rIds ); +} + +VCLXComboBox::VCLXComboBox() + : maActionListeners( *this ), maItemListeners( *this ) +{ +} + +VCLXComboBox::~VCLXComboBox() +{ +#ifndef __SUNPRO_CC + OSL_TRACE ("%s", __FUNCTION__); +#endif +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXComboBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XComboBox*, this ) ); + return (aRet.hasValue() ? aRet : VCLXEdit::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXComboBox ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XComboBox>* ) NULL ), + VCLXEdit::getTypes() +IMPL_XTYPEPROVIDER_END + +::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXComboBox::CreateAccessibleContext() +{ + ::vos::OGuard aGuard( GetMutex() ); + + return getAccessibleFactory().createAccessibleContext( this ); +} + +void VCLXComboBox::dispose() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::lang::EventObject aObj; + aObj.Source = (::cppu::OWeakObject*)this; + maItemListeners.disposeAndClear( aObj ); + maActionListeners.disposeAndClear( aObj ); + VCLXEdit::dispose(); +} + + +void VCLXComboBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maItemListeners.addInterface( l ); +} + +void VCLXComboBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maItemListeners.removeInterface( l ); +} + +void VCLXComboBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionListeners.addInterface( l ); +} + +void VCLXComboBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionListeners.removeInterface( l ); +} + +void VCLXComboBox::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ComboBox* pBox = (ComboBox*) GetWindow(); + if ( pBox ) + pBox->InsertEntry( aItem, nPos ); +} + +void VCLXComboBox::addItems( const ::com::sun::star::uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ComboBox* pBox = (ComboBox*) GetWindow(); + if ( pBox ) + { + sal_uInt16 nP = nPos; + for ( sal_uInt16 n = 0; n < aItems.getLength(); n++ ) + { + pBox->InsertEntry( aItems.getConstArray()[n], nP ); + if ( (sal_uInt16)nPos < 0xFFFF ) // Nicht wenn 0xFFFF, weil LIST_APPEND + nP++; + } + } +} + +void VCLXComboBox::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ComboBox* pBox = (ComboBox*) GetWindow(); + if ( pBox ) + { + for ( sal_uInt16 n = nCount; n; ) + pBox->RemoveEntry( nPos + (--n) ); + } +} + +sal_Int16 VCLXComboBox::getItemCount() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ComboBox* pBox = (ComboBox*) GetWindow(); + return pBox ? pBox->GetEntryCount() : 0; +} + +::rtl::OUString VCLXComboBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::rtl::OUString aItem; + ComboBox* pBox = (ComboBox*) GetWindow(); + if ( pBox ) + aItem = pBox->GetEntry( nPos ); + return aItem; +} + +::com::sun::star::uno::Sequence< ::rtl::OUString> VCLXComboBox::getItems() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq; + ComboBox* pBox = (ComboBox*) GetWindow(); + if ( pBox ) + { + sal_uInt16 nEntries = pBox->GetEntryCount(); + aSeq = ::com::sun::star::uno::Sequence< ::rtl::OUString>( nEntries ); + for ( sal_uInt16 n = nEntries; n; ) + { + --n; + aSeq.getArray()[n] = pBox->GetEntry( n ); + } + } + return aSeq; +} + +void VCLXComboBox::setDropDownLineCount( sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ComboBox* pBox = (ComboBox*) GetWindow(); + if ( pBox ) + pBox->SetDropDownLineCount( nLines ); +} + +sal_Int16 VCLXComboBox::getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int16 nLines = 0; + ComboBox* pBox = (ComboBox*) GetWindow(); + if ( pBox ) + nLines = pBox->GetDropDownLineCount(); + return nLines; +} + +void VCLXComboBox::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ComboBox* pComboBox = (ComboBox*)GetWindow(); + if ( pComboBox ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_LINECOUNT: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + pComboBox->SetDropDownLineCount( n ); + } + break; + case BASEPROPERTY_AUTOCOMPLETE: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + pComboBox->EnableAutocomplete( n != 0 ); + } + break; + case BASEPROPERTY_STRINGITEMLIST: + { + ::com::sun::star::uno::Sequence< ::rtl::OUString> aItems; + if ( Value >>= aItems ) + { + sal_Bool bUpdate = pComboBox->IsUpdateMode(); + pComboBox->SetUpdateMode( sal_False ); + pComboBox->Clear(); + const ::rtl::OUString* pStrings = aItems.getConstArray(); + sal_Int32 nItems = aItems.getLength(); + for ( sal_Int32 n = 0; n < nItems; n++ ) + pComboBox->InsertEntry( pStrings[n], LISTBOX_APPEND ); + pComboBox->SetUpdateMode( bUpdate ); + } + } + break; + default: + { + VCLXEdit::setProperty( PropertyName, Value ); + + // #109385# SetBorderStyle is not virtual + if ( nPropType == BASEPROPERTY_BORDER ) + { + sal_uInt16 nBorder = sal_uInt16(); + if ( (Value >>= nBorder) && nBorder != 0 ) + pComboBox->SetBorderStyle( nBorder ); + } + } + } + } +} + +::com::sun::star::uno::Any VCLXComboBox::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + ComboBox* pComboBox = (ComboBox*)GetWindow(); + if ( pComboBox ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_LINECOUNT: + { + aProp <<= (sal_Int16) pComboBox->GetDropDownLineCount(); + } + break; + case BASEPROPERTY_AUTOCOMPLETE: + { + aProp <<= (sal_Bool) pComboBox->IsAutocompleteEnabled(); + } + break; + case BASEPROPERTY_STRINGITEMLIST: + { + sal_uInt16 nItems = pComboBox->GetEntryCount(); + ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq( nItems ); + ::rtl::OUString* pStrings = aSeq.getArray(); + for ( sal_uInt16 n = 0; n < nItems; n++ ) + pStrings[n] = pComboBox->GetEntry( n ); + aProp <<= aSeq; + + } + break; + default: + { + aProp <<= VCLXEdit::getProperty( PropertyName ); + } + } + } + return aProp; +} + +void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); + // since we call listeners below, there is a potential that we will be destroyed + // during the listener call. To prevent the resulting crashs, we keep us + // alive as long as we're here + // #20178# - 2003-10-01 - fs@openoffice.org + + switch ( rVclWindowEvent.GetId() ) + { + case VCLEVENT_COMBOBOX_SELECT: + if ( maItemListeners.getLength() ) + { + ComboBox* pComboBox = (ComboBox*)GetWindow(); + if( pComboBox ) + { + if ( !pComboBox->IsTravelSelect() ) + { + ::com::sun::star::awt::ItemEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.Highlighted = sal_False; + + // Bei Mehrfachselektion 0xFFFF, sonst die ID + aEvent.Selected = pComboBox->GetEntryPos( pComboBox->GetText() ); + + maItemListeners.itemStateChanged( aEvent ); + } + } + } + break; + + case VCLEVENT_COMBOBOX_DOUBLECLICK: + if ( maActionListeners.getLength() ) + { + ::com::sun::star::awt::ActionEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; +// aEvent.ActionCommand = ...; + maActionListeners.actionPerformed( aEvent ); + } + break; + + default: + VCLXEdit::ProcessWindowEvent( rVclWindowEvent ); + break; + } +} + +::com::sun::star::awt::Size VCLXComboBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + ComboBox* pComboBox = (ComboBox*) GetWindow(); + if ( pComboBox ) + aSz = pComboBox->CalcMinimumSize(); + return AWTSize(aSz); +} + +::com::sun::star::awt::Size VCLXComboBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + ComboBox* pComboBox = (ComboBox*) GetWindow(); + if ( pComboBox ) + { + aSz = pComboBox->CalcMinimumSize(); + if ( pComboBox->GetStyle() & WB_DROPDOWN ) + aSz.Height() += 4; + } + return AWTSize(aSz); +} + +::com::sun::star::awt::Size VCLXComboBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz = VCLSize(rNewSize); + ComboBox* pComboBox = (ComboBox*) GetWindow(); + if ( pComboBox ) + aSz = pComboBox->CalcAdjustedSize( aSz ); + return AWTSize(aSz); +} + +::com::sun::star::awt::Size VCLXComboBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + Size aSz; + ComboBox* pComboBox = (ComboBox*) GetWindow(); + if ( pComboBox ) + aSz = pComboBox->CalcSize( nCols, nLines ); + return AWTSize(aSz); +} + +void VCLXComboBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + nCols = nLines = 0; + ComboBox* pComboBox = (ComboBox*) GetWindow(); + if ( pComboBox ) + { + sal_uInt16 nC, nL; + pComboBox->GetMaxVisColumnsAndLines( nC, nL ); + nCols = nC; + nLines = nL; + } +} + +// ---------------------------------------------------- +// class VCLXFormattedSpinField +// ---------------------------------------------------- +void VCLXFormattedSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + // Interestingly in the UnoControl API this is + // - not derived from XEdit ultimately, (correct ?) - so cut this here ... +// VCLXSpinField::ImplGetPropertyIds( rIds ); + VCLXWindow::ImplGetPropertyIds( rIds ); +} + +VCLXFormattedSpinField::VCLXFormattedSpinField() +{ +} + +VCLXFormattedSpinField::~VCLXFormattedSpinField() +{ +} + +void VCLXFormattedSpinField::setStrictFormat( sal_Bool bStrict ) +{ + ::vos::OGuard aGuard( GetMutex() ); + + FormatterBase* pFormatter = GetFormatter(); + if ( pFormatter ) + pFormatter->SetStrictFormat( bStrict ); +} + +sal_Bool VCLXFormattedSpinField::isStrictFormat() +{ + FormatterBase* pFormatter = GetFormatter(); + return pFormatter ? pFormatter->IsStrictFormat() : sal_False; +} + + +void VCLXFormattedSpinField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + FormatterBase* pFormatter = GetFormatter(); + if ( pFormatter ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_SPIN: + { + sal_Bool b = sal_Bool(); + if ( Value >>= b ) + { + WinBits nStyle = GetWindow()->GetStyle() | WB_SPIN; + if ( !b ) + nStyle &= ~WB_SPIN; + GetWindow()->SetStyle( nStyle ); + } + } + break; + case BASEPROPERTY_STRICTFORMAT: + { + sal_Bool b = sal_Bool(); + if ( Value >>= b ) + { + pFormatter->SetStrictFormat( b ); + } + } + break; + default: + { + VCLXSpinField::setProperty( PropertyName, Value ); + } + } + } +} + +::com::sun::star::uno::Any VCLXFormattedSpinField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + FormatterBase* pFormatter = GetFormatter(); + if ( pFormatter ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_TABSTOP: + { + aProp <<= (sal_Bool) ( ( GetWindow()->GetStyle() & WB_SPIN ) ? sal_True : sal_False ); + } + break; + case BASEPROPERTY_STRICTFORMAT: + { + aProp <<= (sal_Bool) pFormatter->IsStrictFormat(); + } + break; + default: + { + aProp <<= VCLXSpinField::getProperty( PropertyName ); + } + } + } + return aProp; +} + + +// ---------------------------------------------------- +// class VCLXDateField +// ---------------------------------------------------- + +void VCLXDateField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_ALIGN, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_DATE, + BASEPROPERTY_DATEMAX, + BASEPROPERTY_DATEMIN, + BASEPROPERTY_DATESHOWCENTURY, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_DROPDOWN, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_EXTDATEFORMAT, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_READONLY, + BASEPROPERTY_REPEAT, + BASEPROPERTY_REPEAT_DELAY, + BASEPROPERTY_SPIN, + BASEPROPERTY_STRICTFORMAT, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_ENFORCE_FORMAT, + BASEPROPERTY_TEXT, + BASEPROPERTY_HIDEINACTIVESELECTION, + BASEPROPERTY_VERTICALALIGN, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, + 0); + VCLXFormattedSpinField::ImplGetPropertyIds( rIds ); +} + +VCLXDateField::VCLXDateField() +{ +} + +VCLXDateField::~VCLXDateField() +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXDateField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XDateField*, this ) ); + return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXDateField ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDateField>* ) NULL ), + VCLXFormattedSpinField::getTypes() +IMPL_XTYPEPROVIDER_END + +void VCLXDateField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { + sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_DATE: + { + if ( bVoid ) + { + ((DateField*)GetWindow())->EnableEmptyFieldValue( sal_True ); + ((DateField*)GetWindow())->SetEmptyFieldValue(); + } + else + { + sal_Int32 n = 0; + if ( Value >>= n ) + setDate( n ); + } + } + break; + case BASEPROPERTY_DATEMIN: + { + sal_Int32 n = 0; + if ( Value >>= n ) + setMin( n ); + } + break; + case BASEPROPERTY_DATEMAX: + { + sal_Int32 n = 0; + if ( Value >>= n ) + setMax( n ); + } + break; + case BASEPROPERTY_EXTDATEFORMAT: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + ((DateField*)GetWindow())->SetExtDateFormat( (ExtDateFieldFormat) n ); + } + break; + case BASEPROPERTY_DATESHOWCENTURY: + { + sal_Bool b = sal_Bool(); + if ( Value >>= b ) + ((DateField*)GetWindow())->SetShowDateCentury( b ); + } + break; + case BASEPROPERTY_ENFORCE_FORMAT: + { + sal_Bool bEnforce( sal_True ); + OSL_VERIFY( Value >>= bEnforce ); + static_cast< DateField* >( GetWindow() )->EnforceValidValue( bEnforce ); + } + break; + default: + { + VCLXFormattedSpinField::setProperty( PropertyName, Value ); + } + } + } +} + +::com::sun::star::uno::Any VCLXDateField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + FormatterBase* pFormatter = GetFormatter(); + if ( pFormatter ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_DATE: + { + aProp <<= (sal_Int32) getDate(); + } + break; + case BASEPROPERTY_DATEMIN: + { + aProp <<= (sal_Int32) getMin(); + } + break; + case BASEPROPERTY_DATEMAX: + { + aProp <<= (sal_Int32) getMax(); + } + break; + case BASEPROPERTY_DATESHOWCENTURY: + { + aProp <<= ((DateField*)GetWindow())->IsShowDateCentury(); + } + break; + case BASEPROPERTY_ENFORCE_FORMAT: + { + aProp <<= (sal_Bool)static_cast< DateField* >( GetWindow() )->IsEnforceValidValue( ); + } + break; + default: + { + aProp <<= VCLXFormattedSpinField::getProperty( PropertyName ); + } + } + } + return aProp; +} + + +void VCLXDateField::setDate( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + DateField* pDateField = (DateField*) GetWindow(); + if ( pDateField ) + { + pDateField->SetDate( nDate ); + + // #107218# Call same listeners like VCL would do after user interaction + SetSynthesizingVCLEvent( sal_True ); + pDateField->SetModifyFlag(); + pDateField->Modify(); + SetSynthesizingVCLEvent( sal_False ); + } +} + +sal_Int32 VCLXDateField::getDate() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int32 nDate = 0; + DateField* pDateField = (DateField*) GetWindow(); + if ( pDateField ) + nDate = pDateField->GetDate().GetDate(); + + return nDate; +} + +void VCLXDateField::setMin( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + DateField* pDateField = (DateField*) GetWindow(); + if ( pDateField ) + pDateField->SetMin( nDate ); +} + +sal_Int32 VCLXDateField::getMin() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int32 nDate = 0; + DateField* pDateField = (DateField*) GetWindow(); + if ( pDateField ) + nDate = pDateField->GetMin().GetDate(); + + return nDate; +} + +void VCLXDateField::setMax( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + DateField* pDateField = (DateField*) GetWindow(); + if ( pDateField ) + pDateField->SetMax( nDate ); +} + +sal_Int32 VCLXDateField::getMax() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int32 nDate = 0; + DateField* pDateField = (DateField*) GetWindow(); + if ( pDateField ) + nDate = pDateField->GetMax().GetDate(); + + return nDate; +} + +void VCLXDateField::setFirst( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + DateField* pDateField = (DateField*) GetWindow(); + if ( pDateField ) + pDateField->SetFirst( nDate ); +} + +sal_Int32 VCLXDateField::getFirst() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int32 nDate = 0; + DateField* pDateField = (DateField*) GetWindow(); + if ( pDateField ) + nDate = pDateField->GetFirst().GetDate(); + + return nDate; +} + +void VCLXDateField::setLast( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + DateField* pDateField = (DateField*) GetWindow(); + if ( pDateField ) + pDateField->SetLast( nDate ); +} + +sal_Int32 VCLXDateField::getLast() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int32 nDate = 0; + DateField* pDateField = (DateField*) GetWindow(); + if ( pDateField ) + nDate = pDateField->GetLast().GetDate(); + + return nDate; +} + +void VCLXDateField::setLongFormat( sal_Bool bLong ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + DateField* pDateField = (DateField*) GetWindow(); + if ( pDateField ) + pDateField->SetLongFormat( bLong ); +} + +sal_Bool VCLXDateField::isLongFormat() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + DateField* pDateField = (DateField*) GetWindow(); + return pDateField ? pDateField->IsLongFormat() : sal_False; +} + +void VCLXDateField::setEmpty() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + DateField* pDateField = (DateField*) GetWindow(); + if ( pDateField ) + { + pDateField->SetEmptyDate(); + + // #107218# Call same listeners like VCL would do after user interaction + SetSynthesizingVCLEvent( sal_True ); + pDateField->SetModifyFlag(); + pDateField->Modify(); + SetSynthesizingVCLEvent( sal_False ); + } +} + +sal_Bool VCLXDateField::isEmpty() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + DateField* pDateField = (DateField*) GetWindow(); + return pDateField ? pDateField->IsEmptyDate() : sal_False; +} + +void VCLXDateField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException) +{ + VCLXFormattedSpinField::setStrictFormat( bStrict ); +} + +sal_Bool VCLXDateField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException) +{ + return VCLXFormattedSpinField::isStrictFormat(); +} + + +// ---------------------------------------------------- +// class VCLXTimeField +// ---------------------------------------------------- + +void VCLXTimeField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_ALIGN, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_EXTTIMEFORMAT, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_READONLY, + BASEPROPERTY_REPEAT, + BASEPROPERTY_REPEAT_DELAY, + BASEPROPERTY_SPIN, + BASEPROPERTY_STRICTFORMAT, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_TIME, + BASEPROPERTY_TIMEMAX, + BASEPROPERTY_TIMEMIN, + BASEPROPERTY_ENFORCE_FORMAT, + BASEPROPERTY_TEXT, + BASEPROPERTY_HIDEINACTIVESELECTION, + BASEPROPERTY_VERTICALALIGN, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, + 0); + VCLXFormattedSpinField::ImplGetPropertyIds( rIds ); +} + +VCLXTimeField::VCLXTimeField() +{ +} + +VCLXTimeField::~VCLXTimeField() +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXTimeField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XTimeField*, this ) ); + return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXTimeField ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTimeField>* ) NULL ), + VCLXFormattedSpinField::getTypes() +IMPL_XTYPEPROVIDER_END + +void VCLXTimeField::setTime( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + TimeField* pTimeField = (TimeField*) GetWindow(); + if ( pTimeField ) + { + pTimeField->SetTime( nTime ); + + // #107218# Call same listeners like VCL would do after user interaction + SetSynthesizingVCLEvent( sal_True ); + pTimeField->SetModifyFlag(); + pTimeField->Modify(); + SetSynthesizingVCLEvent( sal_False ); + } +} + +sal_Int32 VCLXTimeField::getTime() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int32 nTime = 0; + TimeField* pTimeField = (TimeField*) GetWindow(); + if ( pTimeField ) + nTime = pTimeField->GetTime().GetTime(); + + return nTime; +} + +void VCLXTimeField::setMin( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + TimeField* pTimeField = (TimeField*) GetWindow(); + if ( pTimeField ) + pTimeField->SetMin( nTime ); +} + +sal_Int32 VCLXTimeField::getMin() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int32 nTime = 0; + TimeField* pTimeField = (TimeField*) GetWindow(); + if ( pTimeField ) + nTime = pTimeField->GetMin().GetTime(); + + return nTime; +} + +void VCLXTimeField::setMax( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + TimeField* pTimeField = (TimeField*) GetWindow(); + if ( pTimeField ) + pTimeField->SetMax( nTime ); +} + +sal_Int32 VCLXTimeField::getMax() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int32 nTime = 0; + TimeField* pTimeField = (TimeField*) GetWindow(); + if ( pTimeField ) + nTime = pTimeField->GetMax().GetTime(); + + return nTime; +} + +void VCLXTimeField::setFirst( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + TimeField* pTimeField = (TimeField*) GetWindow(); + if ( pTimeField ) + pTimeField->SetFirst( nTime ); +} + +sal_Int32 VCLXTimeField::getFirst() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int32 nTime = 0; + TimeField* pTimeField = (TimeField*) GetWindow(); + if ( pTimeField ) + nTime = pTimeField->GetFirst().GetTime(); + + return nTime; +} + +void VCLXTimeField::setLast( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + TimeField* pTimeField = (TimeField*) GetWindow(); + if ( pTimeField ) + pTimeField->SetLast( nTime ); +} + +sal_Int32 VCLXTimeField::getLast() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int32 nTime = 0; + TimeField* pTimeField = (TimeField*) GetWindow(); + if ( pTimeField ) + nTime = pTimeField->GetLast().GetTime(); + + return nTime; +} + +void VCLXTimeField::setEmpty() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + TimeField* pTimeField = (TimeField*) GetWindow(); + if ( pTimeField ) + pTimeField->SetEmptyTime(); +} + +sal_Bool VCLXTimeField::isEmpty() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + TimeField* pTimeField = (TimeField*) GetWindow(); + return pTimeField ? pTimeField->IsEmptyTime() : sal_False; +} + +void VCLXTimeField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException) +{ + VCLXFormattedSpinField::setStrictFormat( bStrict ); +} + +sal_Bool VCLXTimeField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException) +{ + return VCLXFormattedSpinField::isStrictFormat(); +} + + +void VCLXTimeField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { + sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_TIME: + { + if ( bVoid ) + { + ((TimeField*)GetWindow())->EnableEmptyFieldValue( sal_True ); + ((TimeField*)GetWindow())->SetEmptyFieldValue(); + } + else + { + sal_Int32 n = 0; + if ( Value >>= n ) + setTime( n ); + } + } + break; + case BASEPROPERTY_TIMEMIN: + { + sal_Int32 n = 0; + if ( Value >>= n ) + setMin( n ); + } + break; + case BASEPROPERTY_TIMEMAX: + { + sal_Int32 n = 0; + if ( Value >>= n ) + setMax( n ); + } + break; + case BASEPROPERTY_EXTTIMEFORMAT: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + ((TimeField*)GetWindow())->SetExtFormat( (ExtTimeFieldFormat) n ); + } + break; + case BASEPROPERTY_ENFORCE_FORMAT: + { + sal_Bool bEnforce( sal_True ); + OSL_VERIFY( Value >>= bEnforce ); + static_cast< TimeField* >( GetWindow() )->EnforceValidValue( bEnforce ); + } + break; + default: + { + VCLXFormattedSpinField::setProperty( PropertyName, Value ); + } + } + } +} + +::com::sun::star::uno::Any VCLXTimeField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + if ( GetWindow() ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_TIME: + { + aProp <<= (sal_Int32) getTime(); + } + break; + case BASEPROPERTY_TIMEMIN: + { + aProp <<= (sal_Int32) getMin(); + } + break; + case BASEPROPERTY_TIMEMAX: + { + aProp <<= (sal_Int32) getMax(); + } + break; + case BASEPROPERTY_ENFORCE_FORMAT: + { + aProp <<= (sal_Bool)static_cast< TimeField* >( GetWindow() )->IsEnforceValidValue( ); + } + break; + default: + { + aProp <<= VCLXFormattedSpinField::getProperty( PropertyName ); + } + } + } + return aProp; +} + +// ---------------------------------------------------- +// class VCLXNumericField +// ---------------------------------------------------- + +void VCLXNumericField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_ALIGN, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_DECIMALACCURACY, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_NUMSHOWTHOUSANDSEP, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_READONLY, + BASEPROPERTY_REPEAT, + BASEPROPERTY_REPEAT_DELAY, + BASEPROPERTY_SPIN, + BASEPROPERTY_STRICTFORMAT, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_VALUEMAX_DOUBLE, + BASEPROPERTY_VALUEMIN_DOUBLE, + BASEPROPERTY_VALUESTEP_DOUBLE, + BASEPROPERTY_VALUE_DOUBLE, + BASEPROPERTY_ENFORCE_FORMAT, + BASEPROPERTY_HIDEINACTIVESELECTION, + BASEPROPERTY_VERTICALALIGN, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, + 0); + VCLXFormattedSpinField::ImplGetPropertyIds( rIds ); +} + +VCLXNumericField::VCLXNumericField() +{ +} + +VCLXNumericField::~VCLXNumericField() +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXNumericField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XNumericField*, this ) ); + return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXNumericField ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XNumericField>* ) NULL ), + VCLXFormattedSpinField::getTypes() +IMPL_XTYPEPROVIDER_END + +void VCLXNumericField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); + if ( pNumericFormatter ) + { + // z.B. 105, 2 Digits => 1,05 + // ein float 1,05 muss also eine 105 einstellen... + pNumericFormatter->SetValue( + (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) ); + + // #107218# Call same listeners like VCL would do after user interaction + Edit* pEdit = (Edit*)GetWindow(); + if ( pEdit ) + { + SetSynthesizingVCLEvent( sal_True ); + pEdit->SetModifyFlag(); + pEdit->Modify(); + SetSynthesizingVCLEvent( sal_False ); + } + } +} + +double VCLXNumericField::getValue() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); + return pNumericFormatter + ? ImplCalcDoubleValue( (double)pNumericFormatter->GetValue(), pNumericFormatter->GetDecimalDigits() ) + : 0; +} + +void VCLXNumericField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); + if ( pNumericFormatter ) + pNumericFormatter->SetMin( + (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) ); +} + +double VCLXNumericField::getMin() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); + return pNumericFormatter + ? ImplCalcDoubleValue( (double)pNumericFormatter->GetMin(), pNumericFormatter->GetDecimalDigits() ) + : 0; +} + +void VCLXNumericField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); + if ( pNumericFormatter ) + pNumericFormatter->SetMax( + (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) ); +} + +double VCLXNumericField::getMax() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); + return pNumericFormatter + ? ImplCalcDoubleValue( (double)pNumericFormatter->GetMax(), pNumericFormatter->GetDecimalDigits() ) + : 0; +} + +void VCLXNumericField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericField* pNumericField = (NumericField*) GetWindow(); + if ( pNumericField ) + pNumericField->SetFirst( + (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) ); +} + +double VCLXNumericField::getFirst() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericField* pNumericField = (NumericField*) GetWindow(); + return pNumericField + ? ImplCalcDoubleValue( (double)pNumericField->GetFirst(), pNumericField->GetDecimalDigits() ) + : 0; +} + +void VCLXNumericField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericField* pNumericField = (NumericField*) GetWindow(); + if ( pNumericField ) + pNumericField->SetLast( + (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) ); +} + +double VCLXNumericField::getLast() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericField* pNumericField = (NumericField*) GetWindow(); + return pNumericField + ? ImplCalcDoubleValue( (double)pNumericField->GetLast(), pNumericField->GetDecimalDigits() ) + : 0; +} + +void VCLXNumericField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException) +{ + VCLXFormattedSpinField::setStrictFormat( bStrict ); +} + +sal_Bool VCLXNumericField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException) +{ + return VCLXFormattedSpinField::isStrictFormat(); +} + + +void VCLXNumericField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericField* pNumericField = (NumericField*) GetWindow(); + if ( pNumericField ) + pNumericField->SetSpinSize( + (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) ); +} + +double VCLXNumericField::getSpinSize() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericField* pNumericField = (NumericField*) GetWindow(); + return pNumericField + ? ImplCalcDoubleValue( (double)pNumericField->GetSpinSize(), pNumericField->GetDecimalDigits() ) + : 0; +} + +void VCLXNumericField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); + if ( pNumericFormatter ) + { + double n = getValue(); + pNumericFormatter->SetDecimalDigits( Value ); + setValue( n ); + } +} + +sal_Int16 VCLXNumericField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); + return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0; +} + +void VCLXNumericField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { + sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_VALUE_DOUBLE: + { + if ( bVoid ) + { + ((NumericField*)GetWindow())->EnableEmptyFieldValue( sal_True ); + ((NumericField*)GetWindow())->SetEmptyFieldValue(); + } + else + { + double d = 0; + if ( Value >>= d ) + setValue( d ); + } + } + break; + case BASEPROPERTY_VALUEMIN_DOUBLE: + { + double d = 0; + if ( Value >>= d ) + setMin( d ); + } + break; + case BASEPROPERTY_VALUEMAX_DOUBLE: + { + double d = 0; + if ( Value >>= d ) + setMax( d ); + } + break; + case BASEPROPERTY_VALUESTEP_DOUBLE: + { + double d = 0; + if ( Value >>= d ) + setSpinSize( d ); + } + break; + case BASEPROPERTY_DECIMALACCURACY: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + setDecimalDigits( n ); + } + break; + case BASEPROPERTY_NUMSHOWTHOUSANDSEP: + { + sal_Bool b = sal_Bool(); + if ( Value >>= b ) + ((NumericField*)GetWindow())->SetUseThousandSep( b ); + } + break; + default: + { + VCLXFormattedSpinField::setProperty( PropertyName, Value ); + } + } + } +} + +::com::sun::star::uno::Any VCLXNumericField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + FormatterBase* pFormatter = GetFormatter(); + if ( pFormatter ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_VALUE_DOUBLE: + { + aProp <<= (double) getValue(); + } + break; + case BASEPROPERTY_VALUEMIN_DOUBLE: + { + aProp <<= (double) getMin(); + } + break; + case BASEPROPERTY_VALUEMAX_DOUBLE: + { + aProp <<= (double) getMax(); + } + break; + case BASEPROPERTY_VALUESTEP_DOUBLE: + { + aProp <<= (double) getSpinSize(); + } + break; + case BASEPROPERTY_NUMSHOWTHOUSANDSEP: + { + aProp <<= (sal_Bool) ((NumericField*)GetWindow())->IsUseThousandSep(); + } + break; + default: + { + aProp <<= VCLXFormattedSpinField::getProperty( PropertyName ); + } + } + } + return aProp; +} + + +// ---------------------------------------------------- +// class VCLXMetricField +// ---------------------------------------------------- + +void VCLXMetricField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_ALIGN, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_DECIMALACCURACY, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_NUMSHOWTHOUSANDSEP, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_READONLY, + BASEPROPERTY_REPEAT, + BASEPROPERTY_REPEAT_DELAY, + BASEPROPERTY_SPIN, + BASEPROPERTY_STRICTFORMAT, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_ENFORCE_FORMAT, + BASEPROPERTY_HIDEINACTIVESELECTION, + BASEPROPERTY_UNIT, + BASEPROPERTY_CUSTOMUNITTEXT, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, + 0); + VCLXFormattedSpinField::ImplGetPropertyIds( rIds ); +} + +VCLXMetricField::VCLXMetricField() +{ +} + +VCLXMetricField::~VCLXMetricField() +{ +} + +MetricFormatter *VCLXMetricField::GetMetricFormatter() throw(::com::sun::star::uno::RuntimeException) +{ + MetricFormatter *pFormatter = (MetricFormatter *) GetFormatter(); + if (!pFormatter) + throw ::com::sun::star::uno::RuntimeException(); + return pFormatter; +} + +MetricField *VCLXMetricField::GetMetricField() throw(::com::sun::star::uno::RuntimeException) +{ + MetricField *pField = (MetricField *) GetWindow(); + if (!pField) + throw ::com::sun::star::uno::RuntimeException(); + return pField; +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXMetricField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XMetricField*, this ) ); + return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXMetricField ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMetricField>* ) NULL ), + VCLXFormattedSpinField::getTypes() +IMPL_XTYPEPROVIDER_END + +// FIXME: later ... +#define MetricUnitUnoToVcl(a) ((FieldUnit)(a)) + +#define METRIC_MAP_PAIR(method,parent) \ + sal_Int64 VCLXMetricField::get##method( sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) \ + { \ + ::vos::OGuard aGuard( GetMutex() ); \ + return GetMetric##parent()->Get##method( MetricUnitUnoToVcl( nUnit ) ); \ + } \ + void VCLXMetricField::set##method( sal_Int64 nValue, sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) \ + { \ + ::vos::OGuard aGuard( GetMutex() ); \ + GetMetric##parent()->Set##method( nValue, MetricUnitUnoToVcl( nUnit ) ); \ + } + +METRIC_MAP_PAIR(Min, Formatter) +METRIC_MAP_PAIR(Max, Formatter) +METRIC_MAP_PAIR(First, Field) +METRIC_MAP_PAIR(Last, Field) + +#undef METRIC_MAP_PAIR + +::sal_Int64 VCLXMetricField::getValue( ::sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + return GetMetricFormatter()->GetValue( MetricUnitUnoToVcl( nUnit ) ); +} + +::sal_Int64 VCLXMetricField::getCorrectedValue( ::sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + return GetMetricFormatter()->GetCorrectedValue( MetricUnitUnoToVcl( nUnit ) ); +} + +// FIXME: acute cut/paste evilness - move this to the parent Edit class ? +void VCLXMetricField::CallListeners() +{ + // #107218# Call same listeners like VCL would do after user interaction + Edit* pEdit = (Edit*)GetWindow(); + if ( pEdit ) + { + SetSynthesizingVCLEvent( sal_True ); + pEdit->SetModifyFlag(); + pEdit->Modify(); + SetSynthesizingVCLEvent( sal_False ); + } +} + +void VCLXMetricField::setValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + GetMetricFormatter()->SetValue( Value, MetricUnitUnoToVcl( Unit ) ); + CallListeners(); +} + +void VCLXMetricField::setUserValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + GetMetricFormatter()->SetUserValue( Value, MetricUnitUnoToVcl( Unit ) ); + CallListeners(); +} + +void VCLXMetricField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException) +{ + VCLXFormattedSpinField::setStrictFormat( bStrict ); +} + +sal_Bool VCLXMetricField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException) +{ + return VCLXFormattedSpinField::isStrictFormat(); +} + +void VCLXMetricField::setSpinSize( sal_Int64 Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + GetMetricField()->SetSpinSize( Value ); +} + +sal_Int64 VCLXMetricField::getSpinSize() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + return GetMetricField()->GetSpinSize(); +} + +void VCLXMetricField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + GetMetricFormatter()->SetDecimalDigits( Value ); +} + +sal_Int16 VCLXMetricField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); + return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0; +} + +void VCLXMetricField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_DECIMALACCURACY: + { + sal_Int16 n = 0; + if ( Value >>= n ) + setDecimalDigits( n ); + break; + } + case BASEPROPERTY_NUMSHOWTHOUSANDSEP: + { + sal_Bool b = sal_False; + if ( Value >>= b ) + ((NumericField*)GetWindow())->SetUseThousandSep( b ); + } + break; + case BASEPROPERTY_UNIT: + { + sal_uInt16 nVal = 0; + if ( Value >>= nVal ) + ((MetricField*)GetWindow())->SetUnit( (FieldUnit) nVal ); + break; + } + case BASEPROPERTY_CUSTOMUNITTEXT: + { + rtl::OUString aStr; + if ( Value >>= aStr ) + ((MetricField*)GetWindow())->SetCustomUnitText( aStr ); + break; + } + default: + { + VCLXFormattedSpinField::setProperty( PropertyName, Value ); + break; + } + } + } +} + +::com::sun::star::uno::Any VCLXMetricField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + FormatterBase* pFormatter = GetFormatter(); + if ( pFormatter ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_NUMSHOWTHOUSANDSEP: + aProp <<= (sal_Bool) ((NumericField*)GetWindow())->IsUseThousandSep(); + break; + case BASEPROPERTY_UNIT: + aProp <<= (sal_uInt16) ((MetricField*)GetWindow())->GetUnit(); + break; + case BASEPROPERTY_CUSTOMUNITTEXT: + aProp <<= rtl::OUString (((MetricField*)GetWindow())->GetCustomUnitText()); + break; + default: + { + aProp <<= VCLXFormattedSpinField::getProperty( PropertyName ); + break; + } + } + } + return aProp; +} + + +// ---------------------------------------------------- +// class VCLXCurrencyField +// ---------------------------------------------------- + +void VCLXCurrencyField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_ALIGN, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_CURRENCYSYMBOL, + BASEPROPERTY_CURSYM_POSITION, + BASEPROPERTY_DECIMALACCURACY, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_NUMSHOWTHOUSANDSEP, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_READONLY, + BASEPROPERTY_REPEAT, + BASEPROPERTY_REPEAT_DELAY, + BASEPROPERTY_SPIN, + BASEPROPERTY_STRICTFORMAT, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_VALUEMAX_DOUBLE, + BASEPROPERTY_VALUEMIN_DOUBLE, + BASEPROPERTY_VALUESTEP_DOUBLE, + BASEPROPERTY_VALUE_DOUBLE, + BASEPROPERTY_ENFORCE_FORMAT, + BASEPROPERTY_HIDEINACTIVESELECTION, + BASEPROPERTY_VERTICALALIGN, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, + 0); + VCLXFormattedSpinField::ImplGetPropertyIds( rIds ); +} + +VCLXCurrencyField::VCLXCurrencyField() +{ +} + +VCLXCurrencyField::~VCLXCurrencyField() +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXCurrencyField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XCurrencyField*, this ) ); + return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXCurrencyField ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCurrencyField>* ) NULL ), + VCLXFormattedSpinField::getTypes() +IMPL_XTYPEPROVIDER_END + +void VCLXCurrencyField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); + if ( pCurrencyFormatter ) + { + // z.B. 105, 2 Digits => 1,05 + // ein float 1,05 muss also eine 105 einstellen... + pCurrencyFormatter->SetValue( + ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) ); + + // #107218# Call same listeners like VCL would do after user interaction + Edit* pEdit = (Edit*)GetWindow(); + if ( pEdit ) + { + SetSynthesizingVCLEvent( sal_True ); + pEdit->SetModifyFlag(); + pEdit->Modify(); + SetSynthesizingVCLEvent( sal_False ); + } + } +} + +double VCLXCurrencyField::getValue() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); + return pCurrencyFormatter + ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetValue(), pCurrencyFormatter->GetDecimalDigits() ) + : 0; +} + +void VCLXCurrencyField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); + if ( pCurrencyFormatter ) + pCurrencyFormatter->SetMin( + ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) ); +} + +double VCLXCurrencyField::getMin() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); + return pCurrencyFormatter + ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMin(), pCurrencyFormatter->GetDecimalDigits() ) + : 0; +} + +void VCLXCurrencyField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); + if ( pCurrencyFormatter ) + pCurrencyFormatter->SetMax( + ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) ); +} + +double VCLXCurrencyField::getMax() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); + return pCurrencyFormatter + ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMax(), pCurrencyFormatter->GetDecimalDigits() ) + : 0; +} + +void VCLXCurrencyField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow(); + if ( pCurrencyField ) + pCurrencyField->SetFirst( + ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) ); +} + +double VCLXCurrencyField::getFirst() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow(); + return pCurrencyField + ? ImplCalcDoubleValue( (double)pCurrencyField->GetFirst(), pCurrencyField->GetDecimalDigits() ) + : 0; +} + +void VCLXCurrencyField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow(); + if ( pCurrencyField ) + pCurrencyField->SetLast( + ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) ); +} + +double VCLXCurrencyField::getLast() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow(); + return pCurrencyField + ? ImplCalcDoubleValue( (double)pCurrencyField->GetLast(), pCurrencyField->GetDecimalDigits() ) + : 0; +} + +void VCLXCurrencyField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow(); + if ( pCurrencyField ) + pCurrencyField->SetSpinSize( + ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) ); +} + +double VCLXCurrencyField::getSpinSize() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow(); + return pCurrencyField + ? ImplCalcDoubleValue( (double)pCurrencyField->GetSpinSize(), pCurrencyField->GetDecimalDigits() ) + : 0; +} + +void VCLXCurrencyField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException) +{ + VCLXFormattedSpinField::setStrictFormat( bStrict ); +} + +sal_Bool VCLXCurrencyField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException) +{ + return VCLXFormattedSpinField::isStrictFormat(); +} + + +void VCLXCurrencyField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); + if ( pCurrencyFormatter ) + { + double n = getValue(); + pCurrencyFormatter->SetDecimalDigits( Value ); + setValue( n ); + } +} + +sal_Int16 VCLXCurrencyField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); + return pCurrencyFormatter ? pCurrencyFormatter->GetDecimalDigits() : 0; +} + +void VCLXCurrencyField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { + sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_VALUE_DOUBLE: + { + if ( bVoid ) + { + ((LongCurrencyField*)GetWindow())->EnableEmptyFieldValue( sal_True ); + ((LongCurrencyField*)GetWindow())->SetEmptyFieldValue(); + } + else + { + double d = 0; + if ( Value >>= d ) + setValue( d ); + } + } + break; + case BASEPROPERTY_VALUEMIN_DOUBLE: + { + double d = 0; + if ( Value >>= d ) + setMin( d ); + } + break; + case BASEPROPERTY_VALUEMAX_DOUBLE: + { + double d = 0; + if ( Value >>= d ) + setMax( d ); + } + break; + case BASEPROPERTY_VALUESTEP_DOUBLE: + { + double d = 0; + if ( Value >>= d ) + setSpinSize( d ); + } + break; + case BASEPROPERTY_DECIMALACCURACY: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + setDecimalDigits( n ); + } + break; + case BASEPROPERTY_CURRENCYSYMBOL: + { + ::rtl::OUString aString; + if ( Value >>= aString ) + ((LongCurrencyField*)GetWindow())->SetCurrencySymbol( aString ); + } + break; + case BASEPROPERTY_NUMSHOWTHOUSANDSEP: + { + sal_Bool b = sal_Bool(); + if ( Value >>= b ) + ((LongCurrencyField*)GetWindow())->SetUseThousandSep( b ); + } + break; + default: + { + VCLXFormattedSpinField::setProperty( PropertyName, Value ); + } + } + } +} + +::com::sun::star::uno::Any VCLXCurrencyField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + FormatterBase* pFormatter = GetFormatter(); + if ( pFormatter ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_VALUE_DOUBLE: + { + aProp <<= (double) getValue(); + } + break; + case BASEPROPERTY_VALUEMIN_DOUBLE: + { + aProp <<= (double) getMin(); + } + break; + case BASEPROPERTY_VALUEMAX_DOUBLE: + { + aProp <<= (double) getMax(); + } + break; + case BASEPROPERTY_VALUESTEP_DOUBLE: + { + aProp <<= (double) getSpinSize(); + } + break; + case BASEPROPERTY_CURRENCYSYMBOL: + { + aProp <<= ::rtl::OUString( ((LongCurrencyField*)GetWindow())->GetCurrencySymbol() ); + } + break; + case BASEPROPERTY_NUMSHOWTHOUSANDSEP: + { + aProp <<= (sal_Bool) ((LongCurrencyField*)GetWindow())->IsUseThousandSep(); + } + break; + default: + { + aProp <<= VCLXFormattedSpinField::getProperty( PropertyName ); + } + } + } + return aProp; +} + +// ---------------------------------------------------- +// class VCLXPatternField +// ---------------------------------------------------- + +void VCLXPatternField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_ALIGN, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_EDITMASK, + BASEPROPERTY_ENABLED, + BASEPROPERTY_ENABLEVISIBLE, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_LITERALMASK, + BASEPROPERTY_MAXTEXTLEN, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_READONLY, + BASEPROPERTY_STRICTFORMAT, + BASEPROPERTY_TABSTOP, + BASEPROPERTY_TEXT, + BASEPROPERTY_HIDEINACTIVESELECTION, + BASEPROPERTY_VERTICALALIGN, + BASEPROPERTY_WRITING_MODE, + BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, + 0); + VCLXFormattedSpinField::ImplGetPropertyIds( rIds ); +} + +VCLXPatternField::VCLXPatternField() +{ +} + +VCLXPatternField::~VCLXPatternField() +{ +} + +// ::com::sun::star::uno::XInterface +::com::sun::star::uno::Any VCLXPatternField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XPatternField*, this ) ); + return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( VCLXPatternField ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPatternField>* ) NULL ), + VCLXFormattedSpinField::getTypes() +IMPL_XTYPEPROVIDER_END + +void VCLXPatternField::setMasks( const ::rtl::OUString& EditMask, const ::rtl::OUString& LiteralMask ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + PatternField* pPatternField = (PatternField*) GetWindow(); + if ( pPatternField ) + { + pPatternField->SetMask( ByteString( UniString( EditMask ), RTL_TEXTENCODING_ASCII_US ), LiteralMask ); + } +} + +void VCLXPatternField::getMasks( ::rtl::OUString& EditMask, ::rtl::OUString& LiteralMask ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + PatternField* pPatternField = (PatternField*) GetWindow(); + if ( pPatternField ) + { + EditMask = String( pPatternField->GetEditMask(), RTL_TEXTENCODING_ASCII_US ); + LiteralMask = pPatternField->GetLiteralMask(); + } +} + +void VCLXPatternField::setString( const ::rtl::OUString& Str ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + PatternField* pPatternField = (PatternField*) GetWindow(); + if ( pPatternField ) + { + pPatternField->SetString( Str ); + } +} + +::rtl::OUString VCLXPatternField::getString() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::rtl::OUString aString; + PatternField* pPatternField = (PatternField*) GetWindow(); + if ( pPatternField ) + aString = pPatternField->GetString(); + return aString; +} + +void VCLXPatternField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException) +{ + VCLXFormattedSpinField::setStrictFormat( bStrict ); +} + +sal_Bool VCLXPatternField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException) +{ + return VCLXFormattedSpinField::isStrictFormat(); +} + +void VCLXPatternField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_EDITMASK: + case BASEPROPERTY_LITERALMASK: + { + ::rtl::OUString aString; + if ( Value >>= aString ) + { + ::rtl::OUString aEditMask, aLiteralMask; + getMasks( aEditMask, aLiteralMask ); + if ( nPropType == BASEPROPERTY_EDITMASK ) + aEditMask = aString; + else + aLiteralMask = aString; + setMasks( aEditMask, aLiteralMask ); + } + } + break; + default: + { + VCLXFormattedSpinField::setProperty( PropertyName, Value ); + } + } + } +} + +::com::sun::star::uno::Any VCLXPatternField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::uno::Any aProp; + if ( GetWindow() ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_EDITMASK: + case BASEPROPERTY_LITERALMASK: + { + ::rtl::OUString aEditMask, aLiteralMask; + getMasks( aEditMask, aLiteralMask ); + if ( nPropType == BASEPROPERTY_EDITMASK ) + aProp <<= aEditMask; + else + aProp <<= aLiteralMask; + } + break; + default: + { + aProp <<= VCLXFormattedSpinField::getProperty( PropertyName ); + } + } + } + return aProp; +} + +// ---------------------------------------------------- +// class VCLXToolBox +// ---------------------------------------------------- +VCLXToolBox::VCLXToolBox() +{ +} + +VCLXToolBox::~VCLXToolBox() +{ +} + +::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXToolBox::CreateAccessibleContext() +{ + return getAccessibleFactory().createAccessibleContext( this ); +} + diff --git a/toolkit/source/awt/xsimpleanimation.cxx b/toolkit/source/awt/xsimpleanimation.cxx new file mode 100644 index 000000000000..c7ccbde118f4 --- /dev/null +++ b/toolkit/source/awt/xsimpleanimation.cxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" +#include "toolkit/awt/xsimpleanimation.hxx" +#include "toolkit/helper/property.hxx" +#include "toolkit/helper/throbberimpl.hxx" +#include <tools/debug.hxx> + +//........................................................................ +namespace toolkit +{ +//........................................................................ + + using namespace ::com::sun::star; + + //==================================================================== + //= XSimpleAnimation + //==================================================================== + DBG_NAME( XSimpleAnimation ) + + //-------------------------------------------------------------------- + XSimpleAnimation::XSimpleAnimation() + { + DBG_CTOR( XSimpleAnimation, NULL ); + mbRepeat = sal_True; + mnStepTime = 100; + mpThrobber = new Throbber_Impl( this, mnStepTime, mbRepeat ); + } + + //-------------------------------------------------------------------- + XSimpleAnimation::~XSimpleAnimation() + { + DBG_DTOR( XSimpleAnimation, NULL ); + delete mpThrobber; + } + + //-------------------------------------------------------------------- + IMPLEMENT_FORWARD_XINTERFACE2( XSimpleAnimation, VCLXWindow, XSimpleAnimation_Base ) + + //-------------------------------------------------------------------- + IMPLEMENT_FORWARD_XTYPEPROVIDER2( XSimpleAnimation, VCLXWindow, XSimpleAnimation_Base ) + + //-------------------------------------------------------------------- + void SAL_CALL XSimpleAnimation::start() throw ( uno::RuntimeException ) + { + mpThrobber->start(); + } + + //-------------------------------------------------------------------- + void SAL_CALL XSimpleAnimation::stop() throw ( uno::RuntimeException ) + { + mpThrobber->stop(); + } + + //-------------------------------------------------------------------- + void SAL_CALL XSimpleAnimation::setImageList( const uno::Sequence< uno::Reference< graphic::XGraphic > >& rImageList ) + throw ( uno::RuntimeException ) + { + mpThrobber->setImageList( rImageList ); + } + + //-------------------------------------------------------------------- + void XSimpleAnimation::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) + { + // TODO: XSimpleAnimation::ProcessWindowEvent + //::vos::OClearableGuard aGuard( GetMutex() ); + //Reference< XSimpleAnimation > xKeepAlive( this ); + //SpinButton* pSpinButton = static_cast< SpinButton* >( GetWindow() ); + //if ( !pSpinButton ) + // return; + + VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); + } + + //-------------------------------------------------------------------- + void SAL_CALL XSimpleAnimation::setProperty( const ::rtl::OUString& PropertyName, const uno::Any& Value ) + throw( uno::RuntimeException ) + { + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) + { + case BASEPROPERTY_STEP_TIME: { + sal_Int32 nStepTime( 0 ); + if ( Value >>= nStepTime ) + { + mnStepTime = nStepTime; + mpThrobber->setStepTime( mnStepTime ); + } + + break; + } + case BASEPROPERTY_REPEAT: { + sal_Bool bRepeat( sal_True ); + if ( Value >>= bRepeat ) + { + mbRepeat = bRepeat; + mpThrobber->setRepeat( mbRepeat ); + } + break; + } + default: + VCLXWindow::setProperty( PropertyName, Value ); + } + } + } + + //-------------------------------------------------------------------- + uno::Any SAL_CALL XSimpleAnimation::getProperty( const ::rtl::OUString& PropertyName ) + throw( uno::RuntimeException ) + { + ::vos::OGuard aGuard( GetMutex() ); + + uno::Any aReturn; + + if ( GetWindow() ) + { + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) + { + case BASEPROPERTY_STEP_TIME: + aReturn <<= mnStepTime; + break; + case BASEPROPERTY_REPEAT: + aReturn <<= mbRepeat; + break; + default: + aReturn = VCLXWindow::getProperty( PropertyName ); + } + } + return aReturn; + } + +//........................................................................ +} // namespace toolkit +//........................................................................ diff --git a/toolkit/source/awt/xthrobber.cxx b/toolkit/source/awt/xthrobber.cxx new file mode 100644 index 000000000000..439fb49c1cbe --- /dev/null +++ b/toolkit/source/awt/xthrobber.cxx @@ -0,0 +1,158 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" +#include "toolkit/awt/xthrobber.hxx" +#include "toolkit/helper/property.hxx" +#include <toolkit/helper/tkresmgr.hxx> +#include <toolkit/helper/throbberimpl.hxx> + +#ifndef _TOOLKIT_AWT_XTHROBBER_HRC_ +#include "xthrobber.hrc" +#endif +#include <tools/debug.hxx> +#include <vcl/fixed.hxx> +#include <vcl/timer.hxx> + +//........................................................................ +namespace toolkit +{ +//........................................................................ + + using namespace ::com::sun::star; + + //==================================================================== + //= XThrobber + //==================================================================== + DBG_NAME( XThrobber ) + + //-------------------------------------------------------------------- + XThrobber::XThrobber() + { + DBG_CTOR( XThrobber, NULL ); + + mpThrobber = new Throbber_Impl( this, 100, sal_True ); + + InitImageList(); + } + + //-------------------------------------------------------------------- + XThrobber::~XThrobber() + { + DBG_DTOR( XThrobber, NULL ); + delete mpThrobber; + } + + //-------------------------------------------------------------------- + IMPLEMENT_FORWARD_XINTERFACE2( XThrobber, VCLXWindow, XThrobber_Base ) + + //-------------------------------------------------------------------- + IMPLEMENT_FORWARD_XTYPEPROVIDER2( XThrobber, VCLXWindow, XThrobber_Base ) + + //-------------------------------------------------------------------- + void SAL_CALL XThrobber::start() throw ( uno::RuntimeException ) + { + mpThrobber->start(); + } + + //-------------------------------------------------------------------- + void SAL_CALL XThrobber::stop() throw ( uno::RuntimeException ) + { + mpThrobber->stop(); + } + + //-------------------------------------------------------------------- + void XThrobber::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) + { + static bool bInit = false; + if ( !bInit ) + { + // Images won't be shown if set too early + mpThrobber->initImage(); + bInit = true; + } + // TODO: XSimpleAnimation::ProcessWindowEvent + //::vos::OClearableGuard aGuard( GetMutex() ); + //Reference< XSimpleAnimation > xKeepAlive( this ); + //SpinButton* pSpinButton = static_cast< SpinButton* >( GetWindow() ); + //if ( !pSpinButton ) + // return; + + VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); + } + + //-------------------------------------------------------------------- + void SAL_CALL XThrobber::setProperty( const ::rtl::OUString& PropertyName, const uno::Any& Value ) + throw( uno::RuntimeException ) + { + ::vos::OGuard aGuard( GetMutex() ); + + if ( GetWindow() ) + { + VCLXWindow::setProperty( PropertyName, Value ); + } + } + + //-------------------------------------------------------------------- + uno::Any SAL_CALL XThrobber::getProperty( const ::rtl::OUString& PropertyName ) + throw( uno::RuntimeException ) + { + ::vos::OGuard aGuard( GetMutex() ); + + uno::Any aReturn; + + if ( GetWindow() ) + { + aReturn = VCLXWindow::getProperty( PropertyName ); + } + return aReturn; + } + + //-------------------------------------------------------------------- + void SAL_CALL XThrobber::InitImageList() + throw( uno::RuntimeException ) + { + ::vos::OGuard aGuard( GetMutex() ); + uno::Sequence< uno::Reference< graphic::XGraphic > > aImageList(12); + sal_uInt16 nIconIdStart = RID_TK_ICON_THROBBER_START; + + if ( mpThrobber->isHCMode() ) + nIconIdStart = RID_TK_HC_ICON_THROBBER_START; + + for ( sal_uInt16 i=0; i<12; i++ ) + { + Image aImage = TK_RES_IMAGE( nIconIdStart + i ); + aImageList[i] = aImage.GetXGraphic(); + } + + mpThrobber->setImageList( aImageList ); + } + +//........................................................................ +} // namespace toolkit +//........................................................................ diff --git a/toolkit/source/awt/xthrobber.hrc b/toolkit/source/awt/xthrobber.hrc new file mode 100644 index 000000000000..32c068ff8a85 --- /dev/null +++ b/toolkit/source/awt/xthrobber.hrc @@ -0,0 +1,39 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifndef _TOOLKIT_AWT_XTHROBBER_HRC_ +#define _TOOLKIT_AWT_XTHROBBER_HRC_ + + +//------------------------------------------------------------------------------ + +#define RID_TK_ICON_THROBBER_START 1000 +#define RID_TK_HC_ICON_THROBBER_START 1020 + +// ----------------------------------------------------------------------------- + +#endif // _TOOLKIT_AWT_XTHROBBER_HRC_ diff --git a/toolkit/source/awt/xthrobber.src b/toolkit/source/awt/xthrobber.src new file mode 100644 index 000000000000..199b25015056 --- /dev/null +++ b/toolkit/source/awt/xthrobber.src @@ -0,0 +1,177 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifndef _TOOLKIT_AWT_XTHROBBER_HRC_ +#include <xthrobber.hrc> +#endif + +#define STD_MASK_COLOR MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; }; + +Image RID_TK_ICON_THROBBER_START +{ + ImageBitmap = Bitmap{ file = "spinner03-grey_01.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_ICON_THROBBER_START + 1 +{ + ImageBitmap = Bitmap{ file = "spinner03-grey_02.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_ICON_THROBBER_START + 2 +{ + ImageBitmap = Bitmap{ file = "spinner03-grey_03.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_ICON_THROBBER_START + 3 +{ + ImageBitmap = Bitmap{ file = "spinner03-grey_04.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_ICON_THROBBER_START + 4 +{ + ImageBitmap = Bitmap{ file = "spinner03-grey_05.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_ICON_THROBBER_START + 5 +{ + ImageBitmap = Bitmap{ file = "spinner03-grey_06.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_ICON_THROBBER_START + 6 +{ + ImageBitmap = Bitmap{ file = "spinner03-grey_07.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_ICON_THROBBER_START + 7 +{ + ImageBitmap = Bitmap{ file = "spinner03-grey_08.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_ICON_THROBBER_START + 8 +{ + ImageBitmap = Bitmap{ file = "spinner03-grey_09.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_ICON_THROBBER_START + 9 +{ + ImageBitmap = Bitmap{ file = "spinner03-grey_10.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_ICON_THROBBER_START + 10 +{ + ImageBitmap = Bitmap{ file = "spinner03-grey_11.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_ICON_THROBBER_START + 11 +{ + ImageBitmap = Bitmap{ file = "spinner03-grey_12.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_HC_ICON_THROBBER_START +{ + ImageBitmap = Bitmap{ file = "spinner03-32-hc_01.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_HC_ICON_THROBBER_START + 1 +{ + ImageBitmap = Bitmap{ file = "spinner03-32-hc_02.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_HC_ICON_THROBBER_START + 2 +{ + ImageBitmap = Bitmap{ file = "spinner03-32-hc_03.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_HC_ICON_THROBBER_START + 3 +{ + ImageBitmap = Bitmap{ file = "spinner03-32-hc_04.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_HC_ICON_THROBBER_START + 4 +{ + ImageBitmap = Bitmap{ file = "spinner03-32-hc_05.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_HC_ICON_THROBBER_START + 5 +{ + ImageBitmap = Bitmap{ file = "spinner03-32-hc_06.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_HC_ICON_THROBBER_START + 6 +{ + ImageBitmap = Bitmap{ file = "spinner03-32-hc_07.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_HC_ICON_THROBBER_START + 7 +{ + ImageBitmap = Bitmap{ file = "spinner03-32-hc_08.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_HC_ICON_THROBBER_START + 8 +{ + ImageBitmap = Bitmap{ file = "spinner03-32-hc_09.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_HC_ICON_THROBBER_START + 9 +{ + ImageBitmap = Bitmap{ file = "spinner03-32-hc_10.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_HC_ICON_THROBBER_START + 10 +{ + ImageBitmap = Bitmap{ file = "spinner03-32-hc_11.png"; }; + STD_MASK_COLOR +}; + +Image RID_TK_HC_ICON_THROBBER_START + 11 +{ + ImageBitmap = Bitmap{ file = "spinner03-32-hc_12.png"; }; + STD_MASK_COLOR +}; + |