2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-10-02 14:13:40 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2002-07-11 10:07:56 +00:00
|
|
|
|
2014-01-24 16:38:52 +01:00
|
|
|
#include <boost/ptr_container/ptr_vector.hpp>
|
|
|
|
|
2001-02-05 08:33:16 +00:00
|
|
|
#include <stdio.h>
|
2011-03-28 01:31:21 -06:00
|
|
|
#ifdef WNT
|
|
|
|
#include <prewin.h>
|
|
|
|
#include <postwin.h>
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <com/sun/star/awt/WindowAttribute.hpp>
|
|
|
|
#include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
|
|
|
|
#include <com/sun/star/awt/WindowClass.hpp>
|
2006-12-01 14:09:13 +00:00
|
|
|
#include <com/sun/star/awt/MessageBoxButtons.hpp>
|
2001-02-21 14:24:30 +00:00
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
2001-02-05 08:33:16 +00:00
|
|
|
#include <com/sun/star/lang/SystemDependent.hpp>
|
2003-12-11 10:56:46 +00:00
|
|
|
#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>
|
2014-08-07 18:42:35 +02:00
|
|
|
#include <com/sun/star/uno/XComponentContext.hpp>
|
2003-12-11 10:56:46 +00:00
|
|
|
#include <com/sun/star/uno/XInterface.hpp>
|
2007-12-07 10:59:06 +00:00
|
|
|
#include <com/sun/star/beans/NamedValue.hpp>
|
2013-01-14 16:05:07 +02:00
|
|
|
#include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp>
|
2014-01-23 09:41:03 +01:00
|
|
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
|
|
|
#include <com/sun/star/awt/XToolkitExperimental.hpp>
|
|
|
|
#include <com/sun/star/awt/XMessageBoxFactory.hpp>
|
|
|
|
|
|
|
|
#include <cppuhelper/compbase2.hxx>
|
|
|
|
#include <cppuhelper/interfacecontainer.hxx>
|
2013-10-21 19:04:05 -02:00
|
|
|
#include <cppuhelper/supportsservice.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
2001-02-22 17:22:48 +00:00
|
|
|
#include <osl/conditn.hxx>
|
2014-01-23 09:41:03 +01:00
|
|
|
#include <osl/module.h>
|
2014-08-22 23:51:08 +02:00
|
|
|
#include <osl/thread.h>
|
2014-01-23 09:41:03 +01:00
|
|
|
#include <osl/mutex.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <rtl/uuid.h>
|
2001-02-05 08:33:16 +00:00
|
|
|
#include <rtl/process.h>
|
2014-01-23 09:41:03 +01:00
|
|
|
#include <tools/link.hxx>
|
|
|
|
#include <tools/wintypes.hxx>
|
2009-05-18 12:01:49 +00:00
|
|
|
|
2013-01-11 11:07:23 +02:00
|
|
|
#ifdef MACOSX
|
2009-05-18 12:01:49 +00:00
|
|
|
#include "premac.h"
|
|
|
|
#include <Cocoa/Cocoa.h>
|
|
|
|
#include "postmac.h"
|
|
|
|
#endif
|
2011-07-15 01:40:22 +03:00
|
|
|
|
2012-06-11 20:02:11 +03:00
|
|
|
#ifdef ANDROID
|
|
|
|
#include <sal/ByteBufferWrapper.hxx>
|
|
|
|
using org::libreoffice::touch::ByteBufferWrapper;
|
|
|
|
#endif
|
|
|
|
|
2009-05-18 12:01:49 +00:00
|
|
|
#include <vcl/sysdata.hxx>
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <toolkit/awt/vclxwindows.hxx>
|
|
|
|
#include <toolkit/awt/vclxsystemdependentwindow.hxx>
|
|
|
|
#include <toolkit/awt/vclxregion.hxx>
|
2010-08-12 17:36:53 +02:00
|
|
|
#include <toolkit/awt/vclxtabpagecontainer.hxx>
|
2006-12-20 12:52:30 +00:00
|
|
|
|
2010-10-06 14:21:47 +02:00
|
|
|
#include <toolkit/awt/animatedimagespeer.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <toolkit/awt/vclxtopwindow.hxx>
|
|
|
|
#include <toolkit/awt/vclxwindow.hxx>
|
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
2001-09-04 05:50:36 +00:00
|
|
|
#include <toolkit/helper/servicenames.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#include <toolkit/helper/macros.hxx>
|
|
|
|
#include <toolkit/helper/convert.hxx>
|
2001-03-15 10:44:20 +00:00
|
|
|
#include <vcl/unohelp.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <vcl/button.hxx>
|
|
|
|
#include <vcl/combobox.hxx>
|
|
|
|
#include <vcl/ctrl.hxx>
|
|
|
|
#include <vcl/dialog.hxx>
|
2004-11-16 13:08:49 +00:00
|
|
|
#include <vcl/dockingarea.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#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>
|
2010-10-07 13:22:07 +02:00
|
|
|
#include <vcl/throbber.hxx>
|
2003-12-11 10:56:46 +00:00
|
|
|
#include "toolkit/awt/vclxspinbutton.hxx"
|
2012-09-03 15:03:03 +01:00
|
|
|
#include "toolkit/awt/scrollabledialog.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <tools/debug.hxx>
|
2001-02-21 14:24:30 +00:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2012-09-03 15:03:03 +01:00
|
|
|
#include <toolkit/awt/scrollabledialog.hxx>
|
2001-02-21 14:24:30 +00:00
|
|
|
|
2014-04-19 11:24:35 +03:00
|
|
|
#include "helper/unowrapper.hxx"
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#define VCLWINDOW_FRAMEWINDOW 0x1000
|
|
|
|
#define VCLWINDOW_SYSTEMCHILDWINDOW 0x1001
|
|
|
|
|
2007-07-05 07:03:46 +00:00
|
|
|
#if (defined WNT)
|
2001-02-05 08:33:16 +00:00
|
|
|
#define SYSTEM_DEPENDENT_TYPE ::com::sun::star::lang::SystemDependent::SYSTEM_WIN32
|
2013-01-11 11:07:23 +02:00
|
|
|
#elif (defined MACOSX)
|
2007-07-05 07:03:46 +00:00
|
|
|
#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
|
2001-02-05 08:33:16 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-01-23 09:41:03 +01:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
extern "C" typedef Window* (SAL_CALL *FN_SvtCreateWindow)(
|
|
|
|
VCLXWindow** ppNewComp,
|
|
|
|
const css::awt::WindowDescriptor* pDescriptor,
|
|
|
|
Window* pParent,
|
|
|
|
WinBits nWinBits );
|
|
|
|
|
|
|
|
class VCLXToolkit_Impl
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
::osl::Mutex maMutex;
|
|
|
|
};
|
|
|
|
|
|
|
|
class VCLXToolkit : public VCLXToolkit_Impl,
|
|
|
|
public cppu::WeakComponentImplHelper2<
|
|
|
|
css::awt::XToolkitExperimental,
|
|
|
|
css::lang::XServiceInfo >
|
|
|
|
{
|
|
|
|
css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxClipboard;
|
|
|
|
css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxSelection;
|
|
|
|
|
|
|
|
oslModule hSvToolsLib;
|
|
|
|
FN_SvtCreateWindow fnSvtCreateWindow;
|
|
|
|
|
|
|
|
::cppu::OInterfaceContainerHelper m_aTopWindowListeners;
|
|
|
|
::cppu::OInterfaceContainerHelper m_aKeyHandlers;
|
|
|
|
::cppu::OInterfaceContainerHelper m_aFocusListeners;
|
|
|
|
::Link m_aEventListenerLink;
|
|
|
|
::Link m_aKeyListenerLink;
|
|
|
|
bool m_bEventListener;
|
|
|
|
bool m_bKeyListener;
|
|
|
|
|
|
|
|
DECL_LINK(eventListenerHandler, ::VclSimpleEvent const *);
|
|
|
|
|
|
|
|
DECL_LINK(keyListenerHandler, ::VclSimpleEvent const *);
|
|
|
|
|
|
|
|
void callTopWindowListeners(
|
|
|
|
::VclSimpleEvent const * pEvent,
|
|
|
|
void (SAL_CALL css::awt::XTopWindowListener::* pFn)(
|
|
|
|
css::lang::EventObject const &));
|
|
|
|
|
|
|
|
long callKeyHandlers(::VclSimpleEvent const * pEvent, bool bPressed);
|
|
|
|
|
|
|
|
void callFocusListeners(::VclSimpleEvent const * pEvent, bool bGained);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
::osl::Mutex& GetMutex() { return maMutex; }
|
|
|
|
|
2014-03-26 16:37:00 +01:00
|
|
|
virtual void SAL_CALL disposing() SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
Window* ImplCreateWindow( VCLXWindow** ppNewComp, const css::awt::WindowDescriptor& rDescriptor, Window* pParent, WinBits nWinBits );
|
|
|
|
css::uno::Reference< css::awt::XWindowPeer > ImplCreateWindow( const css::awt::WindowDescriptor& Descriptor, WinBits nWinBits );
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
VCLXToolkit();
|
2014-04-01 19:18:35 +02:00
|
|
|
virtual ~VCLXToolkit();
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
// css::awt::XToolkitExperimental
|
|
|
|
css::uno::Reference< css::awt::XDevice > SAL_CALL createScreenCompatibleDeviceUsingBuffer( sal_Int32 Width, sal_Int32 Height, sal_Int32 ScaleNumerator, sal_Int32 ScaleDenominator, sal_Int32 XOffset, sal_Int32 YOffset, sal_Int64 AddressOfMemoryBufferForSharedArrayWrapper ) throw
|
2014-03-26 16:37:00 +01:00
|
|
|
(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
// css::awt::XToolkit
|
2014-03-26 16:37:00 +01:00
|
|
|
css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getDesktopWindow( ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
css::awt::Rectangle SAL_CALL getWorkArea( ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
css::uno::Reference< css::awt::XWindowPeer > SAL_CALL createWindow( const css::awt::WindowDescriptor& Descriptor ) throw(css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
css::uno::Sequence< css::uno::Reference< css::awt::XWindowPeer > > SAL_CALL createWindows( const css::uno::Sequence< css::awt::WindowDescriptor >& Descriptors ) throw(css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
css::uno::Reference< css::awt::XDevice > SAL_CALL createScreenCompatibleDevice( sal_Int32 Width, sal_Int32 Height ) throw
|
2014-03-26 16:37:00 +01:00
|
|
|
(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
css::uno::Reference< css::awt::XRegion > SAL_CALL createRegion( ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
// css::awt::XSystemChildFactory
|
2014-03-26 16:37:00 +01:00
|
|
|
css::uno::Reference< css::awt::XWindowPeer > SAL_CALL createSystemChild( const css::uno::Any& Parent, const css::uno::Sequence< sal_Int8 >& ProcessId, sal_Int16 SystemType ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
// css::awt::XMessageBoxFactory
|
2014-03-26 16:37:00 +01:00
|
|
|
virtual css::uno::Reference< css::awt::XMessageBox > SAL_CALL createMessageBox( const css::uno::Reference< css::awt::XWindowPeer >& aParent, css::awt::MessageBoxType eType, ::sal_Int32 aButtons, const OUString& aTitle, const OUString& aMessage ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
// css::awt::XDataTransfer
|
2014-03-26 16:37:00 +01:00
|
|
|
css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer > SAL_CALL getDragGestureRecognizer( const css::uno::Reference< css::awt::XWindow >& window ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
css::uno::Reference< css::datatransfer::dnd::XDragSource > SAL_CALL getDragSource( const css::uno::Reference< css::awt::XWindow >& window ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
css::uno::Reference< css::datatransfer::dnd::XDropTarget > SAL_CALL getDropTarget( const css::uno::Reference< css::awt::XWindow >& window ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
css::uno::Reference< css::datatransfer::clipboard::XClipboard > SAL_CALL getClipboard( const OUString& clipboardName ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
// css::lang::XServiceInfo
|
2014-03-26 16:37:00 +01:00
|
|
|
OUString SAL_CALL getImplementationName( ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
// css::awt::XExtendedToolkit:
|
|
|
|
|
|
|
|
virtual ::sal_Int32 SAL_CALL getTopWindowCount()
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
virtual css::uno::Reference< css::awt::XTopWindow >
|
|
|
|
SAL_CALL getTopWindow(::sal_Int32 nIndex)
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
virtual css::uno::Reference< css::awt::XTopWindow >
|
|
|
|
SAL_CALL getActiveTopWindow()
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
virtual void SAL_CALL addTopWindowListener(
|
|
|
|
css::uno::Reference<
|
|
|
|
css::awt::XTopWindowListener > const & rListener)
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
virtual void SAL_CALL removeTopWindowListener(
|
|
|
|
css::uno::Reference<
|
|
|
|
css::awt::XTopWindowListener > const & rListener)
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
virtual void SAL_CALL addKeyHandler(
|
|
|
|
css::uno::Reference<
|
|
|
|
css::awt::XKeyHandler > const & rHandler)
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
virtual void SAL_CALL removeKeyHandler(
|
|
|
|
css::uno::Reference<
|
|
|
|
css::awt::XKeyHandler > const & rHandler)
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
virtual void SAL_CALL addFocusListener(
|
|
|
|
css::uno::Reference<
|
|
|
|
css::awt::XFocusListener > const & rListener)
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
virtual void SAL_CALL removeFocusListener(
|
|
|
|
css::uno::Reference<
|
|
|
|
css::awt::XFocusListener > const & rListener)
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
virtual void SAL_CALL fireFocusGained(
|
|
|
|
css::uno::Reference<
|
|
|
|
css::uno::XInterface > const & source)
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
virtual void SAL_CALL fireFocusLost(
|
|
|
|
css::uno::Reference<
|
|
|
|
css::uno::XInterface > const & source)
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
|
|
|
|
// css::awt::XReschedule:
|
|
|
|
virtual void SAL_CALL reschedule()
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2014-01-23 09:41:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
WinBits ImplGetWinBits( sal_uInt32 nComponentAttribs, sal_uInt16 nCompType )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:55:06 +00:00
|
|
|
WinBits nWinBits = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-08-28 04:53:40 +09:00
|
|
|
bool bMessBox = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( ( nCompType == WINDOW_INFOBOX ) ||
|
|
|
|
( nCompType == WINDOW_MESSBOX ) ||
|
|
|
|
( nCompType == WINDOW_QUERYBOX ) ||
|
|
|
|
( nCompType == WINDOW_WARNINGBOX ) ||
|
|
|
|
( nCompType == WINDOW_ERRORBOX ) )
|
|
|
|
{
|
2013-08-28 04:53:40 +09:00
|
|
|
bMessBox = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2008-12-01 12:31:27 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
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;
|
2007-11-27 10:57:07 +00:00
|
|
|
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;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
2013-03-03 03:55:35 +01:00
|
|
|
if ( nCompType == WINDOW_MULTILINEEDIT || nCompType == WINDOW_DIALOG || nCompType == WINDOW_GROUPBOX )
|
2007-07-06 13:26:42 +00:00
|
|
|
{
|
|
|
|
if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::AUTOHSCROLL )
|
|
|
|
nWinBits |= WB_AUTOHSCROLL;
|
|
|
|
if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::AUTOVSCROLL )
|
|
|
|
nWinBits |= WB_AUTOVSCROLL;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2008-12-01 12:31:27 +00:00
|
|
|
if ( bDecoratedWindow )
|
2007-06-20 09:25:08 +00:00
|
|
|
{
|
2008-12-01 12:31:27 +00:00
|
|
|
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;
|
|
|
|
}
|
2007-06-20 09:25:08 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
return nWinBits;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ComponentInfo
|
|
|
|
{
|
|
|
|
const char* pName;
|
|
|
|
WindowType nWinType;
|
|
|
|
};
|
|
|
|
|
2010-12-06 10:36:19 +00:00
|
|
|
static ComponentInfo aComponentInfos [] =
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
{ "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 },
|
2004-11-16 13:08:49 +00:00
|
|
|
{ "dockingarea", WINDOW_DOCKINGAREA },
|
2000-09-18 16:07:07 +00:00
|
|
|
{ "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 },
|
2010-11-02 16:55:17 +00:00
|
|
|
{ "frame", WINDOW_GROUPBOX },
|
2000-09-18 16:07:07 +00:00
|
|
|
{ "helpbutton", WINDOW_HELPBUTTON },
|
|
|
|
{ "imagebutton", WINDOW_IMAGEBUTTON },
|
|
|
|
{ "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 },
|
2007-07-06 13:26:42 +00:00
|
|
|
{ "multilineedit", WINDOW_MULTILINEEDIT },
|
2000-09-18 16:07:07 +00:00
|
|
|
{ "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 },
|
2010-10-06 14:21:47 +02:00
|
|
|
{ "animatedimages", WINDOW_CONTROL },
|
2000-09-18 16:07:07 +00:00
|
|
|
{ "spinbutton", WINDOW_SPINBUTTON },
|
|
|
|
{ "spinfield", WINDOW_SPINFIELD },
|
|
|
|
{ "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 },
|
2010-08-12 17:36:53 +02:00
|
|
|
{ "workwindow", WINDOW_WORKWINDOW },
|
|
|
|
{ "tabpagecontainer", WINDOW_CONTROL },
|
2010-08-27 12:13:59 +02:00
|
|
|
{ "tabpagemodel", WINDOW_TABPAGE }
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
2006-06-19 22:01:53 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
2011-05-26 15:02:42 +02:00
|
|
|
static int SAL_CALL ComponentInfoCompare( const void* pFirst, const void* pSecond)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return( strcmp( ((ComponentInfo*)pFirst)->pName,
|
|
|
|
((ComponentInfo*)pSecond)->pName ) );
|
|
|
|
}
|
2006-06-19 22:01:53 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-09-16 08:58:50 +02:00
|
|
|
sal_uInt16 ImplGetComponentType( const OUString& rServiceName )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-08-28 04:53:40 +09:00
|
|
|
static bool bSorted = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
if( !bSorted )
|
|
|
|
{
|
|
|
|
qsort( (void*) aComponentInfos,
|
|
|
|
sizeof( aComponentInfos ) / sizeof( ComponentInfo ),
|
|
|
|
sizeof( ComponentInfo ),
|
|
|
|
ComponentInfoCompare );
|
2013-08-28 04:53:40 +09:00
|
|
|
bSorted = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ComponentInfo aSearch;
|
2013-04-07 12:06:47 +02:00
|
|
|
OString aServiceName(OUStringToOString(rServiceName, osl_getThreadTextEncoding()).toAsciiLowerCase());
|
2012-01-16 15:46:57 -02:00
|
|
|
if ( !aServiceName.isEmpty() )
|
2011-11-27 20:37:42 +00:00
|
|
|
aSearch.pName = aServiceName.getStr();
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
aSearch.pName = "window";
|
|
|
|
|
|
|
|
ComponentInfo* pInf = (ComponentInfo*) bsearch( &aSearch,
|
|
|
|
(void*) aComponentInfos,
|
|
|
|
sizeof( aComponentInfos ) / sizeof( ComponentInfo ),
|
|
|
|
sizeof( ComponentInfo ),
|
|
|
|
ComponentInfoCompare );
|
|
|
|
|
|
|
|
return pInf ? pInf->nWinType : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-24 08:07:25 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
struct MessageBoxTypeInfo
|
|
|
|
{
|
|
|
|
css::awt::MessageBoxType eType;
|
|
|
|
const sal_Char *pName;
|
|
|
|
sal_Int32 nLen;
|
|
|
|
};
|
|
|
|
|
2013-07-17 14:58:15 +09:00
|
|
|
static const MessageBoxTypeInfo aMessageBoxTypeInfo[] =
|
2012-12-24 08:07:25 +00:00
|
|
|
{
|
|
|
|
{ css::awt::MessageBoxType_MESSAGEBOX, RTL_CONSTASCII_STRINGPARAM("messbox") },
|
|
|
|
{ css::awt::MessageBoxType_INFOBOX, RTL_CONSTASCII_STRINGPARAM("infobox") },
|
|
|
|
{ css::awt::MessageBoxType_WARNINGBOX, RTL_CONSTASCII_STRINGPARAM("warningbox") },
|
|
|
|
{ css::awt::MessageBoxType_ERRORBOX, RTL_CONSTASCII_STRINGPARAM("errorbox") },
|
|
|
|
{ css::awt::MessageBoxType_QUERYBOX, RTL_CONSTASCII_STRINGPARAM("querybox") },
|
|
|
|
{ css::awt::MessageBoxType_MAKE_FIXED_SIZE, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool lcl_convertMessageBoxType(
|
|
|
|
rtl::OUString &sType,
|
|
|
|
css::awt::MessageBoxType eType )
|
|
|
|
{
|
|
|
|
const MessageBoxTypeInfo *pMap = aMessageBoxTypeInfo;
|
|
|
|
css::awt::MessageBoxType eVal = css::awt::MessageBoxType_MAKE_FIXED_SIZE;
|
|
|
|
|
|
|
|
while ( pMap->pName )
|
|
|
|
{
|
|
|
|
if ( pMap->eType == eType )
|
|
|
|
{
|
|
|
|
eVal = eType;
|
|
|
|
sType = rtl::OUString( pMap->pName, pMap->nLen, RTL_TEXTENCODING_ASCII_US );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pMap++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ( eVal != css::awt::MessageBoxType_MAKE_FIXED_SIZE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-23 14:16:08 +00:00
|
|
|
static sal_Int32 nVCLToolkitInstanceCount = 0;
|
2013-08-28 04:53:40 +09:00
|
|
|
static bool bInitedByVCLToolkit = false;
|
2001-02-22 17:22:48 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-06-19 22:01:53 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
2001-02-22 17:22:48 +00:00
|
|
|
static void SAL_CALL ToolkitWorkerFunction( void* pArgs )
|
|
|
|
{
|
2014-08-22 23:51:08 +02:00
|
|
|
osl_setThreadName("VCLXToolkit VCL main thread");
|
|
|
|
|
2012-10-31 09:22:53 +01:00
|
|
|
VCLXToolkit * pTk = (VCLXToolkit *)pArgs;
|
|
|
|
bInitedByVCLToolkit = InitVCL();
|
2001-02-22 17:22:48 +00:00
|
|
|
if( bInitedByVCLToolkit )
|
|
|
|
{
|
2012-10-31 09:22:53 +01:00
|
|
|
UnoWrapper* pUnoWrapper = new UnoWrapper( pTk );
|
2001-02-22 17:22:48 +00:00
|
|
|
Application::SetUnoWrapper( pUnoWrapper );
|
|
|
|
}
|
|
|
|
getInitCondition().set();
|
|
|
|
if( bInitedByVCLToolkit )
|
|
|
|
{
|
|
|
|
{
|
2010-10-14 16:43:53 -05:00
|
|
|
SolarMutexGuard aGuard;
|
|
|
|
Application::Execute();
|
2001-02-22 17:22:48 +00:00
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
2012-10-31 09:22:53 +01:00
|
|
|
pTk->dispose();
|
2001-02-22 17:22:48 +00:00
|
|
|
}
|
|
|
|
catch( com::sun::star::uno::Exception & )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
DeInitVCL();
|
|
|
|
}
|
2001-08-23 14:16:08 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
JoinMainLoopThread();
|
|
|
|
}
|
2001-02-22 17:22:48 +00:00
|
|
|
}
|
2006-06-19 22:01:53 +00:00
|
|
|
}
|
2001-02-22 17:22:48 +00:00
|
|
|
|
|
|
|
// contructor, which might initialize VCL
|
2012-10-31 09:22:53 +01:00
|
|
|
VCLXToolkit::VCLXToolkit():
|
2012-10-17 10:52:52 +02:00
|
|
|
cppu::WeakComponentImplHelper2<
|
2012-10-16 15:45:22 +02:00
|
|
|
::com::sun::star::awt::XToolkitExperimental,
|
2012-10-17 10:52:52 +02:00
|
|
|
::com::sun::star::lang::XServiceInfo>( GetMutex() ),
|
2002-07-11 10:07:56 +00:00
|
|
|
m_aTopWindowListeners(rBHelper.rMutex),
|
|
|
|
m_aKeyHandlers(rBHelper.rMutex),
|
|
|
|
m_aFocusListeners(rBHelper.rMutex),
|
2002-07-22 12:30:00 +00:00
|
|
|
m_aEventListenerLink(LINK(this, VCLXToolkit, eventListenerHandler)),
|
|
|
|
m_aKeyListenerLink(LINK(this, VCLXToolkit, keyListenerHandler)),
|
|
|
|
m_bEventListener(false),
|
|
|
|
m_bKeyListener(false)
|
2001-02-22 17:22:48 +00:00
|
|
|
{
|
2001-03-15 10:44:20 +00:00
|
|
|
hSvToolsLib = NULL;
|
|
|
|
fnSvtCreateWindow = NULL;
|
|
|
|
|
2001-02-22 17:22:48 +00:00
|
|
|
osl::Guard< osl::Mutex > aGuard( getInitMutex() );
|
2001-08-23 14:16:08 +00:00
|
|
|
nVCLToolkitInstanceCount++;
|
|
|
|
if( ( nVCLToolkitInstanceCount == 1 ) && ( !Application::IsInMain() ) )
|
2001-02-22 17:22:48 +00:00
|
|
|
{
|
|
|
|
// setup execute thread
|
2012-10-31 09:22:53 +01:00
|
|
|
CreateMainLoopThread( ToolkitWorkerFunction, this );
|
2001-02-22 17:22:48 +00:00
|
|
|
getInitCondition().wait();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VCLXToolkit::~VCLXToolkit()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SAL_CALL VCLXToolkit::disposing()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-10-04 07:08:51 +03:00
|
|
|
#ifndef DISABLE_DYNLOADING
|
2001-03-15 10:44:20 +00:00
|
|
|
if ( hSvToolsLib )
|
|
|
|
{
|
|
|
|
osl_unloadModule( hSvToolsLib );
|
|
|
|
hSvToolsLib = NULL;
|
|
|
|
fnSvtCreateWindow = NULL;
|
|
|
|
}
|
2012-10-04 07:08:51 +03:00
|
|
|
#endif
|
2001-03-15 10:44:20 +00:00
|
|
|
|
2001-02-22 17:22:48 +00:00
|
|
|
{
|
2002-07-11 10:07:56 +00:00
|
|
|
osl::Guard< osl::Mutex > aGuard( getInitMutex() );
|
|
|
|
if( --nVCLToolkitInstanceCount == 0 )
|
2001-02-22 17:22:48 +00:00
|
|
|
{
|
2002-07-11 10:07:56 +00:00
|
|
|
if( bInitedByVCLToolkit )
|
|
|
|
{
|
|
|
|
Application::Quit();
|
|
|
|
JoinMainLoopThread();
|
2013-08-28 04:53:40 +09:00
|
|
|
bInitedByVCLToolkit = false;
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
2001-02-22 17:22:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-22 12:30:00 +00:00
|
|
|
if (m_bEventListener)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
::Application::RemoveEventListener(m_aEventListenerLink);
|
|
|
|
m_bEventListener = false;
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
2002-07-22 12:30:00 +00:00
|
|
|
if (m_bKeyListener)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
::Application::RemoveKeyListener(m_aKeyListenerLink);
|
|
|
|
m_bKeyListener = false;
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
2013-04-02 09:01:37 +02:00
|
|
|
css::lang::EventObject aEvent(
|
2002-07-11 10:07:56 +00:00
|
|
|
static_cast< ::cppu::OWeakObject * >(this));
|
|
|
|
m_aTopWindowListeners.disposeAndClear(aEvent);
|
|
|
|
m_aKeyHandlers.disposeAndClear(aEvent);
|
|
|
|
m_aFocusListeners.disposeAndClear(aEvent);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > VCLXToolkit::getDesktopWindow( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xRef;
|
|
|
|
// 07/00: AppWindow doesn't exist anymore...
|
|
|
|
return xRef;
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::com::sun::star::awt::Rectangle VCLXToolkit::getWorkArea( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
fdo#66762 - Other: com.sun.star.awt.DisplayAccess removed
API_CHANGE:
I removed the undocumented internal API
"com.sun.star.awt.DisplayAccess"
in commit dde234b6955a421d51d2b37e4fc3972c660146f0
"fdo#46808, remove awt::DisplayAccess service."
However, it appears someone was actually using this.
Now, at the same time, we have a method in XToolkit, getWorkArea(),
which looks like it was designed to return this exact information,
but which has been returning zero for as far back as our commit
history goes.
So, to kill two birds with one stone, this commit changes
getWorkArea() to return the information the customer needs, to wit,
the size and position of the primary display.
Change-Id: I76300bac604e9e4b7be95b0872a7f95cb6781903
Reviewed-on: https://gerrit.libreoffice.org/4919
Reviewed-by: Michael Meeks <michael.meeks@suse.com>
Tested-by: Michael Meeks <michael.meeks@suse.com>
2013-07-15 14:49:01 +02:00
|
|
|
sal_Int32 nDisplay = Application::GetDisplayBuiltInScreen();
|
|
|
|
Rectangle aWorkRect = Application::GetScreenPosSizePixel( nDisplay );
|
|
|
|
com::sun::star::awt::Rectangle aNotherRect;
|
|
|
|
aNotherRect.X = aWorkRect.getX();
|
|
|
|
aNotherRect.Y = aWorkRect.getY();
|
|
|
|
aNotherRect.Width = aWorkRect.getWidth();
|
|
|
|
aNotherRect.Height = aWorkRect.getHeight();
|
|
|
|
return aNotherRect;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::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, std::exception)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2006-12-01 14:09:13 +00:00
|
|
|
return ImplCreateWindow( rDescriptor, WinBits(0) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXToolkit::createScreenCompatibleDevice( sal_Int32 Width, sal_Int32 Height ) throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2012-06-11 20:02:11 +03:00
|
|
|
{
|
2012-06-18 22:32:35 +03:00
|
|
|
return createScreenCompatibleDeviceUsingBuffer( Width, Height, 1, 1, 0, 0, 0 );
|
2012-06-11 20:02:11 +03:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXToolkit::createScreenCompatibleDeviceUsingBuffer( sal_Int32 Width, sal_Int32 Height, sal_Int32 ScaleNumerator, sal_Int32 ScaleDenominator, sal_Int32 XOffset, sal_Int32 YOffset, sal_Int64 addressOfMemoryBufferForSharedArrayWrapper ) throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
|
|
|
|
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > xRef;
|
|
|
|
VCLXVirtualDevice* pVDev = new VCLXVirtualDevice;
|
2001-04-11 12:55:47 +00:00
|
|
|
|
2010-10-14 16:43:53 -05:00
|
|
|
SolarMutexGuard aSolarGuard;
|
2001-04-11 12:55:47 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
VirtualDevice* pV = new VirtualDevice;
|
2012-06-11 20:02:11 +03:00
|
|
|
if ( addressOfMemoryBufferForSharedArrayWrapper != 0 ) {
|
|
|
|
#if defined(ANDROID)
|
|
|
|
ByteBufferWrapper *bbw = (ByteBufferWrapper *) (intptr_t) addressOfMemoryBufferForSharedArrayWrapper;
|
2012-06-18 22:32:35 +03:00
|
|
|
pV->SetOutputSizePixelScaleOffsetAndBuffer( Size( Width, Height ), Fraction(ScaleNumerator, ScaleDenominator), Point( XOffset, YOffset), basebmp::RawMemorySharedArray( bbw->pointer(), *bbw ));
|
|
|
|
#else
|
2013-01-07 00:35:54 +02:00
|
|
|
pV->SetOutputSizePixelScaleOffsetAndBuffer( Size( Width, Height ), Fraction(ScaleNumerator, ScaleDenominator), Point( XOffset, YOffset), basebmp::RawMemorySharedArray( (sal_uInt8*) (sal_uIntPtr) addressOfMemoryBufferForSharedArrayWrapper ));
|
2012-06-11 20:02:11 +03:00
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
pV->SetOutputSizePixel( Size( Width, Height ) );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
pVDev->SetVirtualDevice( pV );
|
|
|
|
|
|
|
|
xRef = pVDev;
|
|
|
|
return xRef;
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion > VCLXToolkit::createRegion( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
|
|
|
|
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion > xRef = new VCLXRegion;
|
|
|
|
return xRef;
|
|
|
|
}
|
|
|
|
|
2001-03-15 10:44:20 +00:00
|
|
|
Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp,
|
2004-07-05 14:55:06 +00:00
|
|
|
const ::com::sun::star::awt::WindowDescriptor& rDescriptor,
|
|
|
|
Window* pParent, WinBits nWinBits )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-09-09 23:35:25 +02:00
|
|
|
OUString aServiceName( rDescriptor.WindowServiceName );
|
|
|
|
aServiceName = aServiceName.toAsciiLowerCase();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
Window* pNewWindow = NULL;
|
|
|
|
sal_uInt16 nType = ImplGetComponentType( aServiceName );
|
2010-11-02 16:55:17 +00:00
|
|
|
bool bFrameControl = false;
|
2013-09-09 23:35:25 +02:00
|
|
|
if ( aServiceName == "frame" )
|
2010-11-02 16:55:17 +00:00
|
|
|
bFrameControl = true;
|
2013-09-09 23:35:25 +02:00
|
|
|
if ( aServiceName == "tabcontrolnotabs" )
|
2010-11-02 16:55:17 +00:00
|
|
|
{
|
|
|
|
nWinBits |= WB_NOBORDER;
|
2013-09-16 08:58:50 +02:00
|
|
|
nType = ImplGetComponentType( OUString( "tabcontrol" ) );
|
2010-11-02 16:55:17 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !pParent )
|
|
|
|
{
|
|
|
|
// Wenn die Component einen Parent braucht, dann NULL zurueckgeben,
|
|
|
|
// spaeter mal ::com::sun::star::uno::Exception...
|
2013-08-28 04:53:40 +09:00
|
|
|
bool bException = true;
|
2010-05-28 15:23:19 +02:00
|
|
|
if ( ( nType == WINDOW_DIALOG )
|
|
|
|
|| ( nType == WINDOW_MODALDIALOG )
|
|
|
|
|| ( nType == WINDOW_MODELESSDIALOG )
|
|
|
|
|| ( nType == WINDOW_MESSBOX )
|
|
|
|
|| ( nType == WINDOW_INFOBOX )
|
|
|
|
|| ( nType == WINDOW_WARNINGBOX )
|
|
|
|
|| ( nType == WINDOW_ERRORBOX )
|
|
|
|
|| ( nType == WINDOW_QUERYBOX )
|
|
|
|
)
|
2013-08-28 04:53:40 +09:00
|
|
|
bException = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
else if ( ( nType == WINDOW_WINDOW ) ||
|
|
|
|
( nType == WINDOW_WORKWINDOW ) ||
|
|
|
|
( nType == VCLWINDOW_FRAMEWINDOW ) )
|
|
|
|
{
|
|
|
|
if ( rDescriptor.Type == ::com::sun::star::awt::WindowClass_TOP )
|
2013-08-28 04:53:40 +09:00
|
|
|
bException = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( bException )
|
|
|
|
{
|
|
|
|
*ppNewComp = NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nType )
|
|
|
|
{
|
2010-10-14 16:43:53 -05:00
|
|
|
SolarMutexGuard aVclGuard;
|
2000-09-18 16:07:07 +00:00
|
|
|
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:
|
2002-07-01 13:11:13 +00:00
|
|
|
pNewWindow = new ComboBox( pParent, nWinBits|WB_AUTOHSCROLL );
|
2013-05-20 12:15:51 +01:00
|
|
|
((ComboBox*)pNewWindow)->EnableAutoSize( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
*ppNewComp = new VCLXComboBox;
|
|
|
|
break;
|
|
|
|
case WINDOW_CURRENCYBOX:
|
|
|
|
pNewWindow = new CurrencyBox( pParent, nWinBits );
|
|
|
|
break;
|
|
|
|
case WINDOW_CURRENCYFIELD:
|
|
|
|
pNewWindow = new CurrencyField( pParent, nWinBits );
|
2014-02-21 12:53:51 +01:00
|
|
|
static_cast<CurrencyField*>(pNewWindow)->EnableEmptyFieldValue( true );
|
2000-09-18 16:07:07 +00:00
|
|
|
*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 );
|
2014-02-21 12:53:51 +01:00
|
|
|
static_cast<DateField*>(pNewWindow)->EnableEmptyFieldValue( true );
|
2000-09-18 16:07:07 +00:00
|
|
|
*ppNewComp = new VCLXDateField;
|
|
|
|
((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(DateField*)pNewWindow );
|
|
|
|
break;
|
2004-11-16 13:08:49 +00:00
|
|
|
case WINDOW_DOCKINGAREA:
|
|
|
|
pNewWindow = new DockingAreaWindow( pParent );
|
|
|
|
break;
|
2007-07-06 13:26:42 +00:00
|
|
|
case WINDOW_MULTILINEEDIT:
|
2000-09-18 16:07:07 +00:00
|
|
|
case WINDOW_EDIT:
|
|
|
|
pNewWindow = new Edit( pParent, nWinBits );
|
|
|
|
*ppNewComp = new VCLXEdit;
|
|
|
|
break;
|
|
|
|
case WINDOW_ERRORBOX:
|
2013-09-16 08:58:50 +02:00
|
|
|
pNewWindow = new ErrorBox( pParent, nWinBits, OUString() );
|
2000-09-18 16:07:07 +00:00
|
|
|
*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:
|
2014-04-04 15:00:13 +02:00
|
|
|
pNewWindow = new GroupBox( pParent, nWinBits );
|
|
|
|
if ( bFrameControl )
|
|
|
|
{
|
|
|
|
GroupBox* pGroupBox = static_cast< GroupBox* >( pNewWindow );
|
|
|
|
*ppNewComp = new VCLXFrame;
|
|
|
|
// Frame control needs to receive
|
|
|
|
// Mouse events
|
|
|
|
pGroupBox->SetMouseTransparent( false );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
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_INFOBOX:
|
2013-09-16 08:58:50 +02:00
|
|
|
pNewWindow = new InfoBox( pParent, OUString() );
|
2000-09-18 16:07:07 +00:00
|
|
|
*ppNewComp = new VCLXMessageBox;
|
|
|
|
break;
|
|
|
|
case WINDOW_LISTBOX:
|
2002-07-01 13:11:13 +00:00
|
|
|
pNewWindow = new ListBox( pParent, nWinBits|WB_SIMPLEMODE|WB_AUTOHSCROLL );
|
2013-05-20 12:15:51 +01:00
|
|
|
((ListBox*)pNewWindow)->EnableAutoSize( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
*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:
|
2013-09-16 08:58:50 +02:00
|
|
|
pNewWindow = new MessBox( pParent, nWinBits, OUString(), OUString() );
|
2000-09-18 16:07:07 +00:00
|
|
|
*ppNewComp = new VCLXMessageBox;
|
|
|
|
break;
|
|
|
|
case WINDOW_METRICBOX:
|
|
|
|
pNewWindow = new MetricBox( pParent, nWinBits );
|
|
|
|
break;
|
|
|
|
case WINDOW_METRICFIELD:
|
|
|
|
pNewWindow = new MetricField( pParent, nWinBits );
|
2008-01-14 11:56:48 +00:00
|
|
|
*ppNewComp = new VCLXMetricField;
|
|
|
|
((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(MetricField*)pNewWindow );
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
2001-07-27 08:31:30 +00:00
|
|
|
case WINDOW_DIALOG:
|
2000-09-18 16:07:07 +00:00
|
|
|
case WINDOW_MODALDIALOG:
|
|
|
|
case WINDOW_MODELESSDIALOG:
|
2007-06-20 09:25:08 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
// Modal/Modeless nur durch Show/Execute
|
2007-07-06 13:26:42 +00:00
|
|
|
if ( (pParent == NULL ) && ( rDescriptor.ParentIndex == -1 ) )
|
|
|
|
pParent = DIALOG_NO_PARENT;
|
2012-09-06 19:25:12 +01:00
|
|
|
pNewWindow = new toolkit::ScrollableWrapper<Dialog>( pParent, nWinBits );
|
2011-02-28 10:00:23 +01:00
|
|
|
// #i70217# Don't always create a new component object. It's possible that VCL has called
|
|
|
|
// GetComponentInterface( sal_True ) in the Dialog ctor itself (see Window::IsTopWindow() )
|
|
|
|
// which creates a component object.
|
|
|
|
css::uno::Reference< css::awt::XWindowPeer > xWinPeer = pNewWindow->GetComponentInterface( sal_False );
|
|
|
|
if ( xWinPeer.is() )
|
|
|
|
*ppNewComp = dynamic_cast< VCLXDialog* >( xWinPeer.get() );
|
|
|
|
else
|
|
|
|
*ppNewComp = new VCLXDialog;
|
2007-06-20 09:25:08 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
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 );
|
2014-02-21 12:53:51 +01:00
|
|
|
static_cast<NumericField*>(pNewWindow)->EnableEmptyFieldValue( true );
|
2000-09-18 16:07:07 +00:00
|
|
|
*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:
|
2013-09-16 08:58:50 +02:00
|
|
|
pNewWindow = new QueryBox( pParent, nWinBits, OUString() );
|
2000-09-18 16:07:07 +00:00
|
|
|
*ppNewComp = new VCLXMessageBox;
|
|
|
|
break;
|
|
|
|
case WINDOW_RADIOBUTTON:
|
|
|
|
pNewWindow = new RadioButton( pParent, nWinBits );
|
|
|
|
*ppNewComp = new VCLXRadioButton;
|
2001-08-07 10:15:51 +00:00
|
|
|
|
|
|
|
// 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
|
2010-11-05 10:31:15 +08:00
|
|
|
// state to "checked", the RadioButton::Check (called because RadioCheck=sal_True) will uncheck
|
2001-08-07 10:15:51 +00:00
|
|
|
// _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
|
2014-02-21 12:53:51 +01:00
|
|
|
static_cast<RadioButton*>(pNewWindow)->EnableRadioCheck( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
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 );
|
2003-12-11 10:56:46 +00:00
|
|
|
*ppNewComp = new ::toolkit::VCLXSpinButton;
|
2000-09-18 16:07:07 +00:00
|
|
|
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 );
|
2010-11-02 16:55:17 +00:00
|
|
|
*ppNewComp = new VCLXMultiPage;
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
|
|
|
case WINDOW_TABDIALOG:
|
|
|
|
pNewWindow = new TabDialog( pParent, nWinBits );
|
|
|
|
break;
|
|
|
|
case WINDOW_TABPAGE:
|
2010-08-12 17:36:53 +02:00
|
|
|
{
|
|
|
|
pNewWindow = new TabPage( pParent, nWinBits );
|
|
|
|
*ppNewComp = new VCLXTabPage;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
|
|
|
case WINDOW_TIMEBOX:
|
|
|
|
pNewWindow = new TimeBox( pParent, nWinBits );
|
|
|
|
break;
|
|
|
|
case WINDOW_TIMEFIELD:
|
|
|
|
pNewWindow = new TimeField( pParent, nWinBits );
|
2014-02-21 12:53:51 +01:00
|
|
|
static_cast<TimeField*>(pNewWindow)->EnableEmptyFieldValue( true );
|
2000-09-18 16:07:07 +00:00
|
|
|
*ppNewComp = new VCLXTimeField;
|
|
|
|
((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(TimeField*)pNewWindow );
|
|
|
|
break;
|
|
|
|
case WINDOW_TOOLBOX:
|
|
|
|
pNewWindow = new ToolBox( pParent, nWinBits );
|
2002-05-30 12:16:56 +00:00
|
|
|
*ppNewComp = new VCLXToolBox;
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
|
|
|
case WINDOW_TRISTATEBOX:
|
|
|
|
pNewWindow = new TriStateBox( pParent, nWinBits );
|
|
|
|
break;
|
|
|
|
case WINDOW_WARNINGBOX:
|
2013-09-16 08:58:50 +02:00
|
|
|
pNewWindow = new WarningBox( pParent, nWinBits, OUString() );
|
2000-09-18 16:07:07 +00:00
|
|
|
*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
|
2001-02-05 08:33:16 +00:00
|
|
|
{
|
|
|
|
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 );
|
|
|
|
|
2013-02-18 20:35:25 -06:00
|
|
|
::com::sun::star::uno::Sequence<sal_Int8> processIdSeq((sal_Int8*)processID, 16);
|
2001-02-05 08:33:16 +00:00
|
|
|
|
|
|
|
::com::sun::star::uno::Any anyHandle = xSystemDepParent->getWindowHandle(processIdSeq, SYSTEM_DEPENDENT_TYPE);
|
|
|
|
|
2013-03-03 17:11:39 +01:00
|
|
|
// use sal_Int64 here to accommodate all int types
|
2007-12-07 10:59:06 +00:00
|
|
|
// uno::Any shift operator whill upcast if necessary
|
|
|
|
sal_Int64 nWindowHandle = 0;
|
2014-02-24 11:13:09 +01:00
|
|
|
bool bXEmbed = false;
|
2007-11-27 10:57:07 +00:00
|
|
|
|
2007-12-07 10:59:06 +00:00
|
|
|
bool bUseParentData = true;
|
|
|
|
if( ! (anyHandle >>= nWindowHandle) )
|
2007-07-06 13:26:42 +00:00
|
|
|
{
|
2007-12-07 10:59:06 +00:00
|
|
|
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++ )
|
|
|
|
{
|
2012-04-06 14:28:18 +02:00
|
|
|
if ( pProps[i].Name == "WINDOW" )
|
2007-12-07 10:59:06 +00:00
|
|
|
pProps[i].Value >>= nWindowHandle;
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( pProps[i].Name == "XEMBED" )
|
2007-12-07 10:59:06 +00:00
|
|
|
pProps[i].Value >>= bXEmbed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bUseParentData = false;
|
2007-07-06 13:26:42 +00:00
|
|
|
}
|
2007-11-27 10:57:07 +00:00
|
|
|
|
2007-12-07 10:59:06 +00:00
|
|
|
if( bUseParentData )
|
2007-11-27 10:57:07 +00:00
|
|
|
{
|
|
|
|
SystemParentData aParentData;
|
|
|
|
aParentData.nSize = sizeof( aParentData );
|
2013-01-11 11:07:23 +02:00
|
|
|
#if defined MACOSX
|
2007-12-07 10:59:06 +00:00
|
|
|
aParentData.pView = reinterpret_cast<NSView*>(nWindowHandle);
|
2013-03-27 02:11:39 +02:00
|
|
|
#elif defined ANDROID
|
|
|
|
// Nothing
|
2013-03-27 00:38:36 +02:00
|
|
|
#elif defined IOS
|
|
|
|
// Nothing
|
2007-12-07 10:59:06 +00:00
|
|
|
#elif defined UNX
|
|
|
|
aParentData.aWindow = nWindowHandle;
|
|
|
|
aParentData.bXEmbedSupport = bXEmbed;
|
2008-07-22 15:40:29 +00:00
|
|
|
#elif defined WNT
|
2007-12-07 10:59:06 +00:00
|
|
|
aParentData.hWnd = reinterpret_cast<HWND>(nWindowHandle);
|
|
|
|
#endif
|
2007-11-27 10:57:07 +00:00
|
|
|
pNewWindow = new WorkWindow( &aParentData );
|
|
|
|
}
|
2001-02-05 08:33:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pNewWindow)
|
|
|
|
pNewWindow = new WorkWindow( pParent, nWinBits );
|
|
|
|
}
|
2005-07-20 11:22:20 +00:00
|
|
|
|
|
|
|
*ppNewComp = new VCLXTopWindow( pNewWindow->GetType() == WINDOW_WORKWINDOW );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
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;
|
2006-12-20 12:52:30 +00:00
|
|
|
case WINDOW_CONTROL:
|
2012-12-20 03:56:35 +00:00
|
|
|
if ( rDescriptor.WindowServiceName.equalsIgnoreAsciiCase(
|
2013-03-19 11:32:06 +01:00
|
|
|
"tabpagecontainer" ) )
|
2010-08-12 17:36:53 +02:00
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
pNewWindow = new TabControl( pParent, nWinBits );
|
2010-08-12 17:36:53 +02:00
|
|
|
*ppNewComp = new VCLXTabPageContainer;
|
|
|
|
}
|
2013-09-09 23:35:25 +02:00
|
|
|
else if ( aServiceName == "animatedimages" )
|
2010-10-06 14:21:47 +02:00
|
|
|
{
|
2010-10-07 13:22:07 +02:00
|
|
|
pNewWindow = new Throbber( pParent, nWinBits );
|
2010-10-06 14:21:47 +02:00
|
|
|
*ppNewComp = new ::toolkit::AnimatedImagesPeer;
|
|
|
|
}
|
2006-12-20 12:52:30 +00:00
|
|
|
break;
|
2010-10-06 14:21:47 +02:00
|
|
|
default:
|
|
|
|
OSL_ENSURE( false, "VCLXToolkit::ImplCreateWindow: unknown window type!" );
|
|
|
|
break;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pNewWindow;
|
|
|
|
}
|
|
|
|
|
2012-10-04 07:08:51 +03:00
|
|
|
#ifndef DISABLE_DYNLOADING
|
|
|
|
|
2007-12-07 10:59:06 +00:00
|
|
|
extern "C" { static void SAL_CALL thisModule() {} }
|
|
|
|
|
2012-10-04 07:08:51 +03:00
|
|
|
#else
|
|
|
|
|
|
|
|
extern "C" Window* SAL_CALL CreateWindow( VCLXWindow** ppNewComp, const ::com::sun::star::awt::WindowDescriptor* pDescriptor, Window* pParent, WinBits nWinBits );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2006-12-01 14:09:13 +00:00
|
|
|
css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow(
|
|
|
|
const css::awt::WindowDescriptor& rDescriptor,
|
|
|
|
WinBits nForceWinBits )
|
|
|
|
{
|
|
|
|
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
|
|
|
|
|
2010-10-14 16:43:53 -05:00
|
|
|
SolarMutexGuard aSolarGuard;
|
2006-12-01 14:09:13 +00:00
|
|
|
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xRef;
|
|
|
|
|
|
|
|
Window* pParent = NULL;
|
|
|
|
if ( rDescriptor.Parent.is() )
|
|
|
|
{
|
|
|
|
VCLXWindow* pParentComponent = VCLXWindow::GetImplementation( rDescriptor.Parent );
|
|
|
|
|
2014-04-09 12:44:22 +02:00
|
|
|
// #103939# Don't throw assertion, may be it's a system dependent window, used in ImplCreateWindow.
|
2006-12-01 14:09:13 +00:00
|
|
|
// 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
|
2012-10-04 07:08:51 +03:00
|
|
|
if ( !fnSvtCreateWindow
|
|
|
|
#ifndef DISABLE_DYNLOADING
|
|
|
|
&& !hSvToolsLib
|
|
|
|
#endif
|
|
|
|
)
|
2006-12-01 14:09:13 +00:00
|
|
|
{
|
2012-10-04 07:08:51 +03:00
|
|
|
#ifndef DISABLE_DYNLOADING
|
2014-06-04 16:11:19 +02:00
|
|
|
OUString aLibName(SVT_DLL_NAME);
|
2007-12-07 10:59:06 +00:00
|
|
|
hSvToolsLib = osl_loadModuleRelative(
|
|
|
|
&thisModule, aLibName.pData, SAL_LOADMODULE_DEFAULT );
|
2006-12-01 14:09:13 +00:00
|
|
|
if ( hSvToolsLib )
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aFunctionName( "CreateWindow" );
|
2006-12-01 14:09:13 +00:00
|
|
|
fnSvtCreateWindow = (FN_SvtCreateWindow)osl_getFunctionSymbol( hSvToolsLib, aFunctionName.pData );
|
|
|
|
}
|
2012-10-04 07:08:51 +03:00
|
|
|
#else
|
|
|
|
fnSvtCreateWindow = CreateWindow;
|
|
|
|
#endif
|
2006-12-01 14:09:13 +00:00
|
|
|
}
|
|
|
|
// 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 )
|
|
|
|
{
|
2014-02-21 12:53:51 +01:00
|
|
|
pNewWindow->SetCreatedWithToolkit( true );
|
2006-12-01 14:09:13 +00:00
|
|
|
//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
|
|
|
|
{
|
2014-02-24 11:13:09 +01:00
|
|
|
pNewComp->SetCreatedWithToolkit( true );
|
2006-12-01 14:09:13 +00:00
|
|
|
xRef = pNewComp;
|
|
|
|
pNewWindow->SetComponentInterface( xRef );
|
|
|
|
}
|
2010-11-05 10:31:15 +08:00
|
|
|
DBG_ASSERT( pNewWindow->GetComponentInterface( sal_False ) == xRef,
|
2006-12-01 14:09:13 +00:00
|
|
|
"VCLXToolkit::createWindow: did #133706# resurge?" );
|
|
|
|
|
|
|
|
if ( rDescriptor.WindowAttributes & ::com::sun::star::awt::WindowAttribute::SHOW )
|
|
|
|
pNewWindow->Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
return xRef;
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::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, std::exception)
|
2006-12-01 14:09:13 +00:00
|
|
|
{
|
|
|
|
::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;
|
|
|
|
}
|
|
|
|
|
2001-03-16 13:45:13 +00:00
|
|
|
// ::com::sun::star::awt::XSystemChildFactory
|
2014-02-25 21:31:58 +01:00
|
|
|
::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, std::exception)
|
2001-03-16 13:45:13 +00:00
|
|
|
{
|
|
|
|
Window* pChildWindow = NULL;
|
|
|
|
if ( nSystemType == SYSTEM_DEPENDENT_TYPE )
|
|
|
|
{
|
2013-03-03 17:11:39 +01:00
|
|
|
// use sal_Int64 here to accommodate all int types
|
2007-12-07 10:59:06 +00:00
|
|
|
// uno::Any shift operator whill upcast if necessary
|
|
|
|
sal_Int64 nWindowHandle = 0;
|
2014-02-24 11:13:09 +01:00
|
|
|
bool bXEmbed = false;
|
2007-12-07 10:59:06 +00:00
|
|
|
|
|
|
|
bool bUseParentData = true;
|
|
|
|
if( ! (Parent >>= nWindowHandle) )
|
|
|
|
{
|
|
|
|
css::uno::Sequence< css::beans::NamedValue > aProps;
|
|
|
|
if( Parent >>= aProps )
|
2001-03-16 13:45:13 +00:00
|
|
|
{
|
2007-12-07 10:59:06 +00:00
|
|
|
const int nProps = aProps.getLength();
|
|
|
|
const css::beans::NamedValue* pProps = aProps.getConstArray();
|
|
|
|
for( int i = 0; i < nProps; i++ )
|
2007-11-27 10:57:07 +00:00
|
|
|
{
|
2012-04-06 14:28:18 +02:00
|
|
|
if ( pProps[i].Name == "WINDOW" )
|
2007-12-07 10:59:06 +00:00
|
|
|
pProps[i].Value >>= nWindowHandle;
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( pProps[i].Name == "XEMBED" )
|
2007-12-07 10:59:06 +00:00
|
|
|
pProps[i].Value >>= bXEmbed;
|
2005-01-31 12:10:04 +00:00
|
|
|
}
|
2001-03-16 13:45:13 +00:00
|
|
|
}
|
2007-12-07 10:59:06 +00:00
|
|
|
else
|
|
|
|
bUseParentData = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bUseParentData )
|
|
|
|
{
|
|
|
|
SystemParentData aParentData;
|
|
|
|
aParentData.nSize = sizeof( aParentData );
|
2013-01-11 11:07:23 +02:00
|
|
|
#if defined MACOSX
|
2007-12-10 08:46:08 +00:00
|
|
|
aParentData.pView = reinterpret_cast<NSView*>(nWindowHandle);
|
2013-03-27 02:11:39 +02:00
|
|
|
#elif defined ANDROID
|
|
|
|
// Nothing
|
2013-03-27 00:38:36 +02:00
|
|
|
#elif defined IOS
|
|
|
|
// Nothing
|
2007-12-07 10:59:06 +00:00
|
|
|
#elif defined UNX
|
|
|
|
aParentData.aWindow = nWindowHandle;
|
|
|
|
aParentData.bXEmbedSupport = bXEmbed;
|
2008-07-22 15:40:29 +00:00
|
|
|
#elif defined WNT
|
2007-12-07 10:59:06 +00:00
|
|
|
aParentData.hWnd = reinterpret_cast<HWND>(nWindowHandle);
|
|
|
|
#endif
|
2010-10-14 16:43:53 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2007-12-07 10:59:06 +00:00
|
|
|
try
|
2001-03-16 13:45:13 +00:00
|
|
|
{
|
2007-12-07 10:59:06 +00:00
|
|
|
pChildWindow = new WorkWindow( &aParentData );
|
2007-07-05 07:03:46 +00:00
|
|
|
}
|
2012-01-07 15:50:41 +09:00
|
|
|
catch ( const ::com::sun::star::uno::RuntimeException & rEx )
|
2007-07-05 07:03:46 +00:00
|
|
|
{
|
2007-12-07 10:59:06 +00:00
|
|
|
// system child window could not be created
|
|
|
|
OSL_TRACE(
|
|
|
|
"VCLXToolkit::createSystemChild: caught %s\n",
|
2013-04-07 12:06:47 +02:00
|
|
|
OUStringToOString(
|
2007-12-07 10:59:06 +00:00
|
|
|
rEx.Message, RTL_TEXTENCODING_UTF8).getStr());
|
|
|
|
pChildWindow = NULL;
|
2001-03-16 13:45:13 +00:00
|
|
|
}
|
2007-12-07 10:59:06 +00:00
|
|
|
}
|
2001-03-16 13:45:13 +00:00
|
|
|
}
|
2002-04-09 07:28:42 +00:00
|
|
|
else if (nSystemType == com::sun::star::lang::SystemDependent::SYSTEM_JAVA)
|
|
|
|
{
|
2010-10-14 16:43:53 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2002-04-09 07:28:42 +00:00
|
|
|
pChildWindow = new WorkWindow(0, Parent);
|
|
|
|
}
|
2001-03-16 13:45:13 +00:00
|
|
|
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xPeer;
|
|
|
|
if ( pChildWindow )
|
|
|
|
{
|
2004-02-25 16:57:58 +00:00
|
|
|
VCLXTopWindow* pPeer = new VCLXTopWindow(true);
|
2010-10-14 16:43:53 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2001-03-16 13:45:13 +00:00
|
|
|
pPeer->SetWindow( pChildWindow );
|
|
|
|
xPeer = pPeer;
|
|
|
|
}
|
|
|
|
|
|
|
|
return xPeer;
|
|
|
|
}
|
|
|
|
|
2006-12-01 14:09:13 +00:00
|
|
|
// ::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,
|
2012-12-24 08:07:25 +00:00
|
|
|
::com::sun::star::awt::MessageBoxType eType,
|
2006-12-01 14:09:13 +00:00
|
|
|
::sal_Int32 aButtons,
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString& aTitle,
|
2014-02-25 21:31:58 +01:00
|
|
|
const OUString& aMessage ) throw (::com::sun::star::uno::RuntimeException, std::exception)
|
2006-12-01 14:09:13 +00:00
|
|
|
{
|
|
|
|
::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;
|
2008-01-29 14:05:25 +00:00
|
|
|
if ( sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_IGNORE )
|
|
|
|
nAddWinBits |= WB_DEF_IGNORE;
|
2006-12-01 14:09:13 +00:00
|
|
|
|
2012-12-24 08:07:25 +00:00
|
|
|
rtl::OUString aType;
|
|
|
|
lcl_convertMessageBoxType( aType, eType );
|
|
|
|
|
2006-12-01 14:09:13 +00:00
|
|
|
aDescriptor.Type = css::awt::WindowClass_MODALTOP;
|
|
|
|
aDescriptor.WindowServiceName = aType;
|
|
|
|
aDescriptor.ParentIndex = -1;
|
|
|
|
aDescriptor.Parent = aParent;
|
|
|
|
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 )
|
|
|
|
{
|
2010-10-14 16:43:53 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2006-12-01 14:09:13 +00:00
|
|
|
xMsgBox->setCaptionText( aTitle );
|
|
|
|
xMsgBox->setMessageText( aMessage );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return xMsgBox;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::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, std::exception)
|
2001-02-21 14:24:30 +00:00
|
|
|
{
|
|
|
|
Window * pWindow = VCLUnoHelper::GetWindow( window );
|
|
|
|
|
|
|
|
if( pWindow )
|
|
|
|
return pWindow->GetDragGestureRecognizer();
|
|
|
|
|
|
|
|
return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer >();
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::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, std::exception)
|
2001-02-21 14:24:30 +00:00
|
|
|
{
|
2014-06-18 15:50:02 +02:00
|
|
|
SolarMutexGuard g;
|
|
|
|
|
2001-02-21 14:24:30 +00:00
|
|
|
Window * pWindow = VCLUnoHelper::GetWindow( window );
|
|
|
|
|
|
|
|
if( pWindow )
|
|
|
|
return pWindow->GetDragSource();
|
|
|
|
|
|
|
|
return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource >();
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::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, std::exception)
|
2001-02-21 14:24:30 +00:00
|
|
|
{
|
2014-06-18 15:50:02 +02:00
|
|
|
SolarMutexGuard g;
|
|
|
|
|
2001-02-21 14:24:30 +00:00
|
|
|
Window * pWindow = VCLUnoHelper::GetWindow( window );
|
|
|
|
|
|
|
|
if( pWindow )
|
|
|
|
return pWindow->GetDropTarget();
|
|
|
|
|
|
|
|
return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTarget >();
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > SAL_CALL VCLXToolkit::getClipboard( const OUString& clipboardName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2001-02-21 14:24:30 +00:00
|
|
|
{
|
2012-01-16 15:46:57 -02:00
|
|
|
if( clipboardName.isEmpty() )
|
2001-02-21 14:24:30 +00:00
|
|
|
{
|
|
|
|
if( !mxClipboard.is() )
|
|
|
|
{
|
2013-01-14 16:05:07 +02:00
|
|
|
// remember clipboard here
|
2013-07-11 10:21:15 +02:00
|
|
|
mxClipboard = css::datatransfer::clipboard::SystemClipboard::create(
|
|
|
|
comphelper::getProcessComponentContext());
|
2001-02-21 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return mxClipboard;
|
|
|
|
}
|
|
|
|
|
2012-04-06 14:09:04 +02:00
|
|
|
else if( clipboardName == "Selection" )
|
2001-02-21 14:24:30 +00:00
|
|
|
{
|
|
|
|
return mxSelection;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-09-04 05:50:36 +00:00
|
|
|
// XServiceInfo
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString VCLXToolkit::getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2001-09-04 05:50:36 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
return OUString("stardiv.Toolkit.VCLXToolkit");
|
2001-09-04 05:50:36 +00:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Bool VCLXToolkit::supportsService( const OUString& rServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2001-09-04 05:50:36 +00:00
|
|
|
{
|
2013-10-21 19:04:05 -02:00
|
|
|
return cppu::supportsService(this, rServiceName);
|
2001-09-04 05:50:36 +00:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::com::sun::star::uno::Sequence< OUString > VCLXToolkit::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2001-09-04 05:50:36 +00:00
|
|
|
{
|
2014-01-23 09:41:03 +01:00
|
|
|
OUString aServiceName("com.sun.star.awt.Toolkit");
|
2013-04-07 12:06:47 +02:00
|
|
|
return ::com::sun::star::uno::Sequence< OUString >( &aServiceName, 1);
|
2001-09-04 05:50:36 +00:00
|
|
|
}
|
2002-07-11 10:07:56 +00:00
|
|
|
|
2003-04-24 14:09:51 +00:00
|
|
|
// css::awt::XExtendedToolkit:
|
2002-07-11 10:07:56 +00:00
|
|
|
|
|
|
|
// virtual
|
|
|
|
::sal_Int32 SAL_CALL VCLXToolkit::getTopWindowCount()
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
return static_cast< ::sal_Int32 >(::Application::GetTopWindowCount());
|
|
|
|
// XXX numeric overflow
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// virtual
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Reference< css::awt::XTopWindow > SAL_CALL
|
2002-07-11 10:07:56 +00:00
|
|
|
VCLXToolkit::getTopWindow(::sal_Int32 nIndex)
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
::Window * p = ::Application::GetTopWindow(static_cast< long >(nIndex));
|
|
|
|
// XXX numeric overflow
|
2013-04-02 09:01:37 +02:00
|
|
|
return css::uno::Reference< css::awt::XTopWindow >(
|
|
|
|
p == 0 ? 0 : static_cast< css::awt::XWindow * >(p->GetWindowPeer()),
|
|
|
|
css::uno::UNO_QUERY);
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// virtual
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Reference< css::awt::XTopWindow > SAL_CALL
|
2014-02-25 21:31:58 +01:00
|
|
|
VCLXToolkit::getActiveTopWindow() throw (css::uno::RuntimeException, std::exception)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
::Window * p = ::Application::GetActiveTopWindow();
|
2013-04-02 09:01:37 +02:00
|
|
|
return css::uno::Reference< css::awt::XTopWindow >(
|
|
|
|
p == 0 ? 0 : static_cast< css::awt::XWindow * >(p->GetWindowPeer()),
|
|
|
|
css::uno::UNO_QUERY);
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// virtual
|
|
|
|
void SAL_CALL VCLXToolkit::addTopWindowListener(
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Reference< css::awt::XTopWindowListener > const & rListener)
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
|
|
|
OSL_ENSURE(rListener.is(), "Null rListener");
|
|
|
|
::osl::ClearableMutexGuard aGuard(rBHelper.rMutex);
|
|
|
|
if (rBHelper.bDisposed || rBHelper.bInDispose)
|
|
|
|
{
|
|
|
|
aGuard.clear();
|
|
|
|
rListener->disposing(
|
2013-04-02 09:01:37 +02:00
|
|
|
css::lang::EventObject(
|
2002-07-11 10:07:56 +00:00
|
|
|
static_cast< ::cppu::OWeakObject * >(this)));
|
|
|
|
}
|
|
|
|
else if (m_aTopWindowListeners.addInterface(rListener) == 1
|
2002-07-22 12:30:00 +00:00
|
|
|
&& !m_bEventListener)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
m_bEventListener = true;
|
|
|
|
::Application::AddEventListener(m_aEventListenerLink);
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// virtual
|
|
|
|
void SAL_CALL VCLXToolkit::removeTopWindowListener(
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Reference< css::awt::XTopWindowListener > const & rListener)
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard(rBHelper.rMutex);
|
|
|
|
if (!(rBHelper.bDisposed || rBHelper.bInDispose)
|
|
|
|
&& m_aTopWindowListeners.removeInterface(rListener) == 0
|
2002-07-22 12:30:00 +00:00
|
|
|
&& m_aFocusListeners.getLength() == 0 && m_bEventListener)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
::Application::RemoveEventListener(m_aEventListenerLink);
|
|
|
|
m_bEventListener = false;
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// virtual
|
|
|
|
void SAL_CALL VCLXToolkit::addKeyHandler(
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Reference< css::awt::XKeyHandler > const & rHandler)
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
|
|
|
OSL_ENSURE(rHandler.is(), "Null rHandler");
|
|
|
|
::osl::ClearableMutexGuard aGuard(rBHelper.rMutex);
|
|
|
|
if (rBHelper.bDisposed || rBHelper.bInDispose)
|
|
|
|
{
|
|
|
|
aGuard.clear();
|
|
|
|
rHandler->disposing(
|
2013-04-02 09:01:37 +02:00
|
|
|
css::lang::EventObject(
|
2002-07-11 10:07:56 +00:00
|
|
|
static_cast< ::cppu::OWeakObject * >(this)));
|
|
|
|
}
|
2002-07-22 12:30:00 +00:00
|
|
|
else if (m_aKeyHandlers.addInterface(rHandler) == 1 && !m_bKeyListener)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
m_bKeyListener = true;
|
|
|
|
::Application::AddKeyListener(m_aKeyListenerLink);
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// virtual
|
|
|
|
void SAL_CALL VCLXToolkit::removeKeyHandler(
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Reference< css::awt::XKeyHandler > const & rHandler)
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard(rBHelper.rMutex);
|
|
|
|
if (!(rBHelper.bDisposed || rBHelper.bInDispose)
|
2002-07-22 12:30:00 +00:00
|
|
|
&& m_aKeyHandlers.removeInterface(rHandler) == 0 && m_bKeyListener)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
::Application::RemoveKeyListener(m_aKeyListenerLink);
|
|
|
|
m_bKeyListener = false;
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// virtual
|
|
|
|
void SAL_CALL VCLXToolkit::addFocusListener(
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Reference< css::awt::XFocusListener > const & rListener)
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
|
|
|
OSL_ENSURE(rListener.is(), "Null rListener");
|
|
|
|
::osl::ClearableMutexGuard aGuard(rBHelper.rMutex);
|
|
|
|
if (rBHelper.bDisposed || rBHelper.bInDispose)
|
|
|
|
{
|
|
|
|
aGuard.clear();
|
|
|
|
rListener->disposing(
|
2013-04-02 09:01:37 +02:00
|
|
|
css::lang::EventObject(
|
2002-07-11 10:07:56 +00:00
|
|
|
static_cast< ::cppu::OWeakObject * >(this)));
|
|
|
|
}
|
|
|
|
else if (m_aFocusListeners.addInterface(rListener) == 1
|
2002-07-22 12:30:00 +00:00
|
|
|
&& !m_bEventListener)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
m_bEventListener = true;
|
|
|
|
::Application::AddEventListener(m_aEventListenerLink);
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// virtual
|
|
|
|
void SAL_CALL VCLXToolkit::removeFocusListener(
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Reference< css::awt::XFocusListener > const & rListener)
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (css::uno::RuntimeException, std::exception)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard(rBHelper.rMutex);
|
|
|
|
if (!(rBHelper.bDisposed || rBHelper.bInDispose)
|
|
|
|
&& m_aFocusListeners.removeInterface(rListener) == 0
|
2002-07-22 12:30:00 +00:00
|
|
|
&& m_aTopWindowListeners.getLength() == 0 && m_bEventListener)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
::Application::RemoveEventListener(m_aEventListenerLink);
|
|
|
|
m_bEventListener = false;
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-21 10:41:31 +00:00
|
|
|
// virtual
|
|
|
|
void SAL_CALL VCLXToolkit::fireFocusGained(
|
|
|
|
::com::sun::star::uno::Reference<
|
2006-06-19 22:01:53 +00:00
|
|
|
::com::sun::star::uno::XInterface > const &)
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (::com::sun::star::uno::RuntimeException, std::exception)
|
2002-08-21 10:41:31 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// virtual
|
2002-08-23 11:44:15 +00:00
|
|
|
void SAL_CALL VCLXToolkit::fireFocusLost(
|
2002-08-21 10:41:31 +00:00
|
|
|
::com::sun::star::uno::Reference<
|
2006-06-19 22:01:53 +00:00
|
|
|
::com::sun::star::uno::XInterface > const &)
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (::com::sun::star::uno::RuntimeException, std::exception)
|
2002-08-21 10:41:31 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-22 12:30:00 +00:00
|
|
|
IMPL_LINK(VCLXToolkit, eventListenerHandler, ::VclSimpleEvent const *, pEvent)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
switch (pEvent->GetId())
|
2002-07-16 08:40:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
case VCLEVENT_WINDOW_SHOW:
|
|
|
|
callTopWindowListeners(
|
2013-04-02 09:01:37 +02:00
|
|
|
pEvent, &css::awt::XTopWindowListener::windowOpened);
|
2002-07-22 12:30:00 +00:00
|
|
|
break;
|
|
|
|
case VCLEVENT_WINDOW_HIDE:
|
|
|
|
callTopWindowListeners(
|
2013-04-02 09:01:37 +02:00
|
|
|
pEvent, &css::awt::XTopWindowListener::windowClosed);
|
2002-07-22 12:30:00 +00:00
|
|
|
break;
|
|
|
|
case VCLEVENT_WINDOW_ACTIVATE:
|
|
|
|
callTopWindowListeners(
|
2013-04-02 09:01:37 +02:00
|
|
|
pEvent, &css::awt::XTopWindowListener::windowActivated);
|
2002-07-22 12:30:00 +00:00
|
|
|
break;
|
|
|
|
case VCLEVENT_WINDOW_DEACTIVATE:
|
|
|
|
callTopWindowListeners(
|
2013-04-02 09:01:37 +02:00
|
|
|
pEvent, &css::awt::XTopWindowListener::windowDeactivated);
|
2002-07-22 12:30:00 +00:00
|
|
|
break;
|
|
|
|
case VCLEVENT_WINDOW_CLOSE:
|
|
|
|
callTopWindowListeners(
|
2013-04-02 09:01:37 +02:00
|
|
|
pEvent, &css::awt::XTopWindowListener::windowClosing);
|
2002-07-22 12:30:00 +00:00
|
|
|
break;
|
|
|
|
case VCLEVENT_WINDOW_GETFOCUS:
|
|
|
|
callFocusListeners(pEvent, true);
|
|
|
|
break;
|
|
|
|
case VCLEVENT_WINDOW_LOSEFOCUS:
|
|
|
|
callFocusListeners(pEvent, false);
|
|
|
|
break;
|
|
|
|
case VCLEVENT_WINDOW_MINIMIZE:
|
|
|
|
callTopWindowListeners(
|
2013-04-02 09:01:37 +02:00
|
|
|
pEvent, &css::awt::XTopWindowListener::windowMinimized);
|
2002-07-22 12:30:00 +00:00
|
|
|
break;
|
|
|
|
case VCLEVENT_WINDOW_NORMALIZE:
|
|
|
|
callTopWindowListeners(
|
2013-04-02 09:01:37 +02:00
|
|
|
pEvent, &css::awt::XTopWindowListener::windowNormalized);
|
2002-07-22 12:30:00 +00:00
|
|
|
break;
|
2002-07-16 08:40:56 +00:00
|
|
|
}
|
2002-07-22 12:30:00 +00:00
|
|
|
return 0;
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
|
|
|
|
2002-07-22 12:30:00 +00:00
|
|
|
IMPL_LINK(VCLXToolkit, keyListenerHandler, ::VclSimpleEvent const *, pEvent)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
switch (pEvent->GetId())
|
2002-07-16 08:40:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
case VCLEVENT_WINDOW_KEYINPUT:
|
|
|
|
return callKeyHandlers(pEvent, true);
|
|
|
|
case VCLEVENT_WINDOW_KEYUP:
|
|
|
|
return callKeyHandlers(pEvent, false);
|
2002-07-16 08:40:56 +00:00
|
|
|
}
|
2002-07-22 12:30:00 +00:00
|
|
|
return 0;
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
|
|
|
|
2002-07-22 12:30:00 +00:00
|
|
|
void VCLXToolkit::callTopWindowListeners(
|
|
|
|
::VclSimpleEvent const * pEvent,
|
2013-04-02 09:01:37 +02:00
|
|
|
void (SAL_CALL css::awt::XTopWindowListener::* pFn)(
|
|
|
|
css::lang::EventObject const &))
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
::Window * pWindow
|
|
|
|
= static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow();
|
|
|
|
if (pWindow->IsTopWindow())
|
2002-07-16 08:40:56 +00:00
|
|
|
{
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >
|
2002-07-11 10:07:56 +00:00
|
|
|
aListeners(m_aTopWindowListeners.getElements());
|
2002-07-22 12:30:00 +00:00
|
|
|
if (aListeners.hasElements())
|
|
|
|
{
|
2013-04-02 09:01:37 +02:00
|
|
|
css::lang::EventObject aAwtEvent(
|
|
|
|
static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()));
|
2002-07-22 12:30:00 +00:00
|
|
|
for (::sal_Int32 i = 0; i < aListeners.getLength(); ++i)
|
|
|
|
{
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Reference< css::awt::XTopWindowListener >
|
|
|
|
xListener(aListeners[i], css::uno::UNO_QUERY);
|
2002-07-22 12:30:00 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
(xListener.get()->*pFn)(aAwtEvent);
|
|
|
|
}
|
2013-04-02 09:01:37 +02:00
|
|
|
catch (const css::uno::RuntimeException & rEx)
|
2002-07-22 12:30:00 +00:00
|
|
|
{
|
|
|
|
OSL_TRACE(
|
|
|
|
"VCLXToolkit::callTopWindowListeners: caught %s\n",
|
2013-04-07 12:06:47 +02:00
|
|
|
OUStringToOString(
|
2002-07-22 12:30:00 +00:00
|
|
|
rEx.Message, RTL_TEXTENCODING_UTF8).getStr());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-07-16 08:40:56 +00:00
|
|
|
}
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
|
|
|
|
2002-07-22 12:30:00 +00:00
|
|
|
long VCLXToolkit::callKeyHandlers(::VclSimpleEvent const * pEvent,
|
|
|
|
bool bPressed)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >
|
2002-08-23 09:21:28 +00:00
|
|
|
aHandlers(m_aKeyHandlers.getElements());
|
|
|
|
|
|
|
|
if (aHandlers.hasElements())
|
2002-07-16 08:40:56 +00:00
|
|
|
{
|
2002-08-23 09:21:28 +00:00
|
|
|
::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());
|
2013-04-02 09:01:37 +02:00
|
|
|
css::awt::KeyEvent aAwtEvent(
|
|
|
|
static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()),
|
2002-08-23 09:21:28 +00:00
|
|
|
(pKeyEvent->GetKeyCode().IsShift()
|
2013-04-02 09:01:37 +02:00
|
|
|
? css::awt::KeyModifier::SHIFT : 0)
|
2002-08-23 09:21:28 +00:00
|
|
|
| (pKeyEvent->GetKeyCode().IsMod1()
|
2013-04-02 09:01:37 +02:00
|
|
|
? css::awt::KeyModifier::MOD1 : 0)
|
2002-08-23 09:21:28 +00:00
|
|
|
| (pKeyEvent->GetKeyCode().IsMod2()
|
2013-04-02 09:01:37 +02:00
|
|
|
? css::awt::KeyModifier::MOD2 : 0)
|
2009-04-12 04:24:43 +00:00
|
|
|
| (pKeyEvent->GetKeyCode().IsMod3()
|
2013-04-02 09:01:37 +02:00
|
|
|
? css::awt::KeyModifier::MOD3 : 0),
|
2002-08-23 09:21:28 +00:00
|
|
|
pKeyEvent->GetKeyCode().GetCode(), pKeyEvent->GetCharCode(),
|
2006-10-12 09:31:38 +00:00
|
|
|
sal::static_int_cast< sal_Int16 >(
|
|
|
|
pKeyEvent->GetKeyCode().GetFunction()));
|
2002-08-23 09:21:28 +00:00
|
|
|
for (::sal_Int32 i = 0; i < aHandlers.getLength(); ++i)
|
2002-07-22 12:30:00 +00:00
|
|
|
{
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Reference< css::awt::XKeyHandler > xHandler(
|
|
|
|
aHandlers[i], css::uno::UNO_QUERY);
|
2002-08-23 09:21:28 +00:00
|
|
|
try
|
2002-07-22 12:30:00 +00:00
|
|
|
{
|
2002-08-23 09:21:28 +00:00
|
|
|
if ((bPressed ? xHandler->keyPressed(aAwtEvent)
|
|
|
|
: xHandler->keyReleased(aAwtEvent)))
|
|
|
|
return 1;
|
|
|
|
}
|
2013-04-02 09:01:37 +02:00
|
|
|
catch (const css::uno::RuntimeException & rEx)
|
2002-08-23 09:21:28 +00:00
|
|
|
{
|
|
|
|
OSL_TRACE(
|
|
|
|
"VCLXToolkit::callKeyHandlers: caught %s\n",
|
2013-04-07 12:06:47 +02:00
|
|
|
OUStringToOString(
|
2002-08-23 09:21:28 +00:00
|
|
|
rEx.Message, RTL_TEXTENCODING_UTF8).getStr());
|
2002-07-22 12:30:00 +00:00
|
|
|
}
|
|
|
|
}
|
2002-07-16 08:40:56 +00:00
|
|
|
}
|
2002-07-22 12:30:00 +00:00
|
|
|
return 0;
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
|
|
|
|
2002-07-22 12:30:00 +00:00
|
|
|
void VCLXToolkit::callFocusListeners(::VclSimpleEvent const * pEvent,
|
|
|
|
bool bGained)
|
2002-07-11 10:07:56 +00:00
|
|
|
{
|
2002-07-22 12:30:00 +00:00
|
|
|
::Window * pWindow
|
|
|
|
= static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow();
|
|
|
|
if (pWindow->IsTopWindow())
|
2002-07-16 08:40:56 +00:00
|
|
|
{
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >
|
2002-07-11 10:07:56 +00:00
|
|
|
aListeners(m_aFocusListeners.getElements());
|
2002-07-22 12:30:00 +00:00
|
|
|
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):
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Reference< css::uno::XInterface > xNext;
|
2002-07-22 12:30:00 +00:00
|
|
|
::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);
|
2013-04-02 09:01:37 +02:00
|
|
|
css::awt::FocusEvent aAwtEvent(
|
|
|
|
static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()),
|
2002-07-22 12:30:00 +00:00
|
|
|
pWindow->GetGetFocusFlags(), xNext, false);
|
|
|
|
for (::sal_Int32 i = 0; i < aListeners.getLength(); ++i)
|
|
|
|
{
|
2013-04-02 09:01:37 +02:00
|
|
|
css::uno::Reference< css::awt::XFocusListener > xListener(
|
|
|
|
aListeners[i], css::uno::UNO_QUERY);
|
2002-07-22 12:30:00 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
bGained ? xListener->focusGained(aAwtEvent)
|
|
|
|
: xListener->focusLost(aAwtEvent);
|
|
|
|
}
|
2013-04-02 09:01:37 +02:00
|
|
|
catch (const css::uno::RuntimeException & rEx)
|
2002-07-22 12:30:00 +00:00
|
|
|
{
|
|
|
|
OSL_TRACE(
|
|
|
|
"VCLXToolkit::callFocusListeners: caught %s\n",
|
2013-04-07 12:06:47 +02:00
|
|
|
OUStringToOString(
|
2002-07-22 12:30:00 +00:00
|
|
|
rEx.Message, RTL_TEXTENCODING_UTF8).getStr());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-07-16 08:40:56 +00:00
|
|
|
}
|
2002-07-11 10:07:56 +00:00
|
|
|
}
|
2005-03-08 14:31:42 +00:00
|
|
|
|
|
|
|
// css::awt::XReschedule:
|
|
|
|
|
|
|
|
void SAL_CALL VCLXToolkit::reschedule()
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (::com::sun::star::uno::RuntimeException, std::exception)
|
2005-03-08 14:31:42 +00:00
|
|
|
{
|
2013-10-03 22:37:47 +02:00
|
|
|
SolarMutexGuard aSolarGuard;
|
2006-07-10 15:28:52 +00:00
|
|
|
Application::Reschedule(true);
|
2005-03-08 14:31:42 +00:00
|
|
|
}
|
|
|
|
|
2014-01-23 09:41:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
|
|
|
|
stardiv_Toolkit_VCLXToolkit_get_implementation(
|
|
|
|
css::uno::XComponentContext *,
|
|
|
|
css::uno::Sequence<css::uno::Any> const &)
|
|
|
|
{
|
|
|
|
return cppu::acquire(new VCLXToolkit());
|
|
|
|
}
|
|
|
|
|
2010-10-14 08:27:31 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|