diff options
Diffstat (limited to '')
20 files changed, 4639 insertions, 0 deletions
diff --git a/include/toolkit/awt/vclxaccessiblecomponent.hxx b/include/toolkit/awt/vclxaccessiblecomponent.hxx new file mode 100644 index 000000000..b1735f3f2 --- /dev/null +++ b/include/toolkit/awt/vclxaccessiblecomponent.hxx @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX +#define INCLUDED_TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX + +#include <toolkit/dllapi.h> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/implbase1.hxx> +#include <comphelper/accimplaccess.hxx> +#include <comphelper/accessiblecomponenthelper.hxx> + + +#include <tools/link.hxx> +#include <vcl/vclptr.hxx> + +namespace com::sun::star::accessibility { class XAccessible; } + +namespace vcl { class Window; } +class VCLXWindow; +class VclWindowEvent; + +namespace utl { +class AccessibleRelationSetHelper; +class AccessibleStateSetHelper; +} + + + +typedef ::cppu::ImplHelper1< + css::lang::XServiceInfo > VCLXAccessibleComponent_BASE; + +class TOOLKIT_DLLPUBLIC VCLXAccessibleComponent + :public comphelper::OAccessibleExtendedComponentHelper + ,public ::comphelper::OAccessibleImplementationAccess + ,public VCLXAccessibleComponent_BASE +{ +private: + rtl::Reference<VCLXWindow> m_xVCLXWindow; + VclPtr<vcl::Window> m_xEventSource; + + DECL_DLLPRIVATE_LINK( WindowEventListener, VclWindowEvent&, void ); + DECL_DLLPRIVATE_LINK( WindowChildEventListener, VclWindowEvent&, void ); + void DisconnectEvents(); + +protected: + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ); + virtual void ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent ); + virtual void FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet ); + virtual void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ); + + virtual css::uno::Reference< css::accessibility::XAccessible > GetChildAccessible( const VclWindowEvent& rVclWindowEvent ); + +public: + VCLXAccessibleComponent( VCLXWindow* pVCLXWindow ); + virtual ~VCLXAccessibleComponent() override; + + VCLXWindow* GetVCLXWindow() const; + vcl::Window* GetWindow() const; + template< class derived_type > derived_type* GetAs() const { + return static_cast< derived_type * >( GetWindow() ); } + template< class derived_type > derived_type* GetAsDynamic() const { + return dynamic_cast< derived_type * >( GetWindow() ); } + + virtual void SAL_CALL disposing() override; + + // css::uno::XInterface + DECLARE_XINTERFACE() + // css::lang::XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // css::accessibility::XAccessibleContext + sal_Int32 SAL_CALL getAccessibleChildCount( ) override; + css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override; + css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + sal_Int32 SAL_CALL getAccessibleIndexInParent( ) override; + sal_Int16 SAL_CALL getAccessibleRole( ) override; + OUString SAL_CALL getAccessibleDescription( ) override; + OUString SAL_CALL getAccessibleName( ) override; + OUString SAL_CALL getAccessibleId( ) override; + css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override; + css::lang::Locale SAL_CALL getLocale( ) override; + + // css::accessibility::XAccessibleComponent + css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + css::awt::Point SAL_CALL getLocationOnScreen( ) override; + void SAL_CALL grabFocus( ) override; + virtual sal_Int32 SAL_CALL getForeground( ) override; + virtual sal_Int32 SAL_CALL getBackground( ) override; + + // css::accessibility::XAccessibleExtendedComponent + virtual css::uno::Reference< css::awt::XFont > SAL_CALL getFont( ) override; + virtual OUString SAL_CALL getTitledBorderText( ) override; + virtual OUString SAL_CALL getToolTipText( ) override; + +protected: + // base class overridables + css::awt::Rectangle implGetBounds( ) override; + +private: + /** we may be reparented (if external components use OAccessibleImplementationAccess base class), + so this method here returns the parent in the VCL world, in opposite to the parent + an external component gave us + @precond + the caller must ensure thread safety, i.e. our mutex must be locked + */ + css::uno::Reference< css::accessibility::XAccessible > + getVclParent() const; +}; + +/* ---------------------------------------------------------- + Accessibility only for the Window hierarchy! + Maybe derived classes must overwrite these Accessibility interfaces: + + // XAccessibleContext: + sal_Int16 getAccessibleRole() => VCL Window::GetAccessibleRole() + OUString getAccessibleDescription() => VCL Window::GetAccessibleDescription + OUString getAccessibleName() => VCL Window::GetAccessibleText() => Most windows return Window::GetText() + OUString getAccessibleId() => VCL Window::get_id() + Reference< XAccessibleRelationSet > getAccessibleRelationSet() + Reference< XAccessibleStateSet > getAccessibleStateSet() => override FillAccessibleStateSet( ... ) + +---------------------------------------------------------- */ + + +#endif // INCLUDED_TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/awt/vclxdevice.hxx b/include/toolkit/awt/vclxdevice.hxx new file mode 100644 index 000000000..c24b79be1 --- /dev/null +++ b/include/toolkit/awt/vclxdevice.hxx @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_AWT_VCLXDEVICE_HXX +#define INCLUDED_TOOLKIT_AWT_VCLXDEVICE_HXX + +#include <toolkit/dllapi.h> +#include <com/sun/star/awt/XDevice.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <comphelper/servicehelper.hxx> +#include <cppuhelper/implbase.hxx> +#include <vcl/virdev.hxx> +#include <vcl/vclptr.hxx> + +#include <com/sun/star/awt/XUnitConversion.hpp> + +/// A UNO wrapper for the VCL OutputDevice +class TOOLKIT_DLLPUBLIC VCLXDevice : + public cppu::WeakImplHelper< + css::awt::XDevice, + css::lang::XUnoTunnel, + css::awt::XUnitConversion> +{ + friend class VCLXGraphics; + friend class VCLXVirtualDevice; + +private: + VclPtr<OutputDevice> mpOutputDevice; + +public: + VCLXDevice(); + virtual ~VCLXDevice() override; + + void SetOutputDevice( const VclPtr<OutputDevice> &pOutDev ) { mpOutputDevice = pOutDev; } + const VclPtr<OutputDevice>& GetOutputDevice() const { return mpOutputDevice; } + + // css::lang::XUnoTunnel + UNO3_GETIMPLEMENTATION_DECL(VCLXDevice) + + // css::awt::XDevice, + css::uno::Reference< css::awt::XGraphics > SAL_CALL createGraphics( ) override; + css::uno::Reference< css::awt::XDevice > SAL_CALL createDevice( sal_Int32 nWidth, sal_Int32 nHeight ) override; + css::awt::DeviceInfo SAL_CALL getInfo() override; + css::uno::Sequence< css::awt::FontDescriptor > SAL_CALL getFontDescriptors( ) override; + css::uno::Reference< css::awt::XFont > SAL_CALL getFont( const css::awt::FontDescriptor& aDescriptor ) override; + css::uno::Reference< css::awt::XBitmap > SAL_CALL createBitmap( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight ) override; + css::uno::Reference< css::awt::XDisplayBitmap > SAL_CALL createDisplayBitmap( const css::uno::Reference< css::awt::XBitmap >& Bitmap ) override; + + // css::awt::XUnitConversion + css::awt::Point SAL_CALL convertPointToLogic( const css::awt::Point& aPoint, ::sal_Int16 TargetUnit ) override; + css::awt::Point SAL_CALL convertPointToPixel( const css::awt::Point& aPoint, ::sal_Int16 SourceUnit ) override; + css::awt::Size SAL_CALL convertSizeToLogic( const css::awt::Size& aSize, ::sal_Int16 TargetUnit ) override; + css::awt::Size SAL_CALL convertSizeToPixel( const css::awt::Size& aSize, ::sal_Int16 SourceUnit ) override; + + +}; + + + + +class VCLXVirtualDevice final : public VCLXDevice +{ +public: + virtual ~VCLXVirtualDevice() override; + + void SetVirtualDevice( VirtualDevice* pVDev ) { SetOutputDevice( pVDev ); } +}; + + +#endif // INCLUDED_TOOLKIT_AWT_VCLXDEVICE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/awt/vclxfont.hxx b/include/toolkit/awt/vclxfont.hxx new file mode 100644 index 000000000..efad4b590 --- /dev/null +++ b/include/toolkit/awt/vclxfont.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_AWT_VCLXFONT_HXX +#define INCLUDED_TOOLKIT_AWT_VCLXFONT_HXX + +#include <memory> +#include <toolkit/dllapi.h> +#include <com/sun/star/awt/XFont2.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <comphelper/servicehelper.hxx> +#include <cppuhelper/implbase.hxx> +#include <mutex> +#include <vcl/font.hxx> + +namespace com::sun::star::awt { class XDevice; } + +class FontMetric; + + + + +class TOOLKIT_DLLPUBLIC VCLXFont final : + public cppu::WeakImplHelper< + css::awt::XFont2, + css::lang::XUnoTunnel> +{ + std::mutex maMutex; + css::uno::Reference< css::awt::XDevice> mxDevice; + vcl::Font maFont; + std::unique_ptr<FontMetric> + mpFontMetric; + + bool ImplAssertValidFontMetric(); + +public: + VCLXFont(); + virtual ~VCLXFont() override; + + void Init( css::awt::XDevice& rxDev, const vcl::Font& rFont ); + const vcl::Font& GetFont() const { return maFont; } + + // css::lang::XUnoTunnel + UNO3_GETIMPLEMENTATION_DECL(VCLXFont) + + // css::lang::XFont + css::awt::FontDescriptor SAL_CALL getFontDescriptor( ) override; + css::awt::SimpleFontMetric SAL_CALL getFontMetric( ) override; + sal_Int16 SAL_CALL getCharWidth( sal_Unicode c ) override; + css::uno::Sequence< sal_Int16 > SAL_CALL getCharWidths( sal_Unicode nFirst, sal_Unicode nLast ) override; + sal_Int32 SAL_CALL getStringWidth( const OUString& str ) override; + sal_Int32 SAL_CALL getStringWidthArray( const OUString& str, css::uno::Sequence< sal_Int32 >& rDXArray ) override; + void SAL_CALL getKernPairs( css::uno::Sequence< sal_Unicode >& rnChars1, css::uno::Sequence< sal_Unicode >& rnChars2, css::uno::Sequence< sal_Int16 >& rnKerns ) override; + + // css::lang::XFont2 + sal_Bool SAL_CALL hasGlyphs( const OUString& aText ) override; +}; + + +#endif // INCLUDED_TOOLKIT_AWT_VCLXFONT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/awt/vclxmenu.hxx b/include/toolkit/awt/vclxmenu.hxx new file mode 100644 index 000000000..096c370bc --- /dev/null +++ b/include/toolkit/awt/vclxmenu.hxx @@ -0,0 +1,162 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_AWT_VCLXMENU_HXX +#define INCLUDED_TOOLKIT_AWT_VCLXMENU_HXX + +#include <config_options.h> +#include <toolkit/dllapi.h> +#include <toolkit/helper/listenermultiplexer.hxx> + +#include <com/sun/star/awt/XMenuBar.hpp> +#include <com/sun/star/awt/XPopupMenu.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> + +#include <comphelper/servicehelper.hxx> +#include <cppuhelper/weak.hxx> +#include <mutex> + +#include <tools/link.hxx> +#include <vcl/vclptr.hxx> + +#include <vector> + +class Menu; +class MenuBar; +class PopupMenu; +class VclMenuEvent; + +typedef ::std::vector< + css::uno::Reference< css::awt::XPopupMenu > +> PopupMenuRefList; + +typedef void (*MenuUserDataReleaseFunction)(void*); + +class TOOLKIT_DLLPUBLIC VCLXMenu : public css::awt::XMenuBar, + public css::awt::XPopupMenu, + public css::lang::XServiceInfo, + public css::lang::XTypeProvider, + public css::lang::XUnoTunnel, + public ::cppu::OWeakObject +{ +private: + std::mutex maMutex; + VclPtr<Menu> mpMenu; + MenuListenerMultiplexer maMenuListeners; + PopupMenuRefList maPopupMenuRefs; + sal_Int16 mnDefaultItem; + +protected: + + DECL_DLLPRIVATE_LINK( MenuEventListener, VclMenuEvent&, void ); + + void ImplCreateMenu( bool bPopup ); + void ImplAddListener(); + +public: + VCLXMenu(); + VCLXMenu( Menu* pMenu ); + virtual ~VCLXMenu() override; + + + Menu* GetMenu() const { return mpMenu; } + bool IsPopupMenu() const; + void setUserValue(sal_uInt16 nItemId, void* nUserValue, MenuUserDataReleaseFunction aFunc); + void* getUserValue(sal_uInt16 nItemId); + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XUnoTunnel + UNO3_GETIMPLEMENTATION_DECL(VCLXMenu) + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XMenu + virtual void SAL_CALL addMenuListener( const css::uno::Reference< css::awt::XMenuListener >& xListener ) override; + virtual void SAL_CALL removeMenuListener( const css::uno::Reference< css::awt::XMenuListener >& xListener ) override; + virtual void SAL_CALL insertItem( sal_Int16 nItemId, const OUString& aText, sal_Int16 nItemStyle, sal_Int16 nPos ) override; + virtual void SAL_CALL removeItem( sal_Int16 nPos, sal_Int16 nCount ) override; + virtual void SAL_CALL clear( ) override; + virtual sal_Int16 SAL_CALL getItemCount( ) override; + virtual sal_Int16 SAL_CALL getItemId( sal_Int16 nPos ) override; + virtual sal_Int16 SAL_CALL getItemPos( sal_Int16 nId ) override; + virtual css::awt::MenuItemType SAL_CALL getItemType( ::sal_Int16 nItemPos ) override; + virtual void SAL_CALL enableItem( sal_Int16 nItemId, sal_Bool bEnable ) override; + virtual sal_Bool SAL_CALL isItemEnabled( sal_Int16 nItemId ) override; + virtual void SAL_CALL hideDisabledEntries( sal_Bool bHide ) override; + virtual void SAL_CALL enableAutoMnemonics( sal_Bool bEnable ) override; + virtual void SAL_CALL setItemText( sal_Int16 nItemId, const OUString& aText ) override; + virtual OUString SAL_CALL getItemText( sal_Int16 nItemId ) override; + virtual void SAL_CALL setCommand( sal_Int16 nItemId, const OUString& aCommand ) override; + virtual OUString SAL_CALL getCommand( sal_Int16 nItemId ) override; + virtual void SAL_CALL setHelpCommand( sal_Int16 nItemId, const OUString& aHelp ) override; + virtual OUString SAL_CALL getHelpCommand( sal_Int16 nItemId ) override; + virtual void SAL_CALL setHelpText( ::sal_Int16 nItemId, const OUString& sHelpText ) override; + virtual OUString SAL_CALL getHelpText( ::sal_Int16 nItemId ) override; + virtual void SAL_CALL setTipHelpText( ::sal_Int16 nItemId, const OUString& sTipHelpText ) override; + virtual OUString SAL_CALL getTipHelpText( ::sal_Int16 nItemId ) override; + + virtual sal_Bool SAL_CALL isPopupMenu( ) override; + virtual void SAL_CALL setPopupMenu( sal_Int16 nItemId, const css::uno::Reference< css::awt::XPopupMenu >& aPopupMenu ) override; + virtual css::uno::Reference< css::awt::XPopupMenu > SAL_CALL getPopupMenu( sal_Int16 nItemId ) override; + + // css::awt::XPopupMenu + virtual void SAL_CALL insertSeparator( sal_Int16 nPos ) override; + virtual void SAL_CALL setDefaultItem( sal_Int16 nItemId ) override; + virtual sal_Int16 SAL_CALL getDefaultItem( ) override; + virtual void SAL_CALL checkItem( sal_Int16 nItemId, sal_Bool bCheck ) override; + virtual sal_Bool SAL_CALL isItemChecked( sal_Int16 nItemId ) override; + virtual ::sal_Int16 SAL_CALL execute( const css::uno::Reference< css::awt::XWindowPeer >& Parent, const css::awt::Rectangle& Position, ::sal_Int16 Direction ) override; + virtual sal_Bool SAL_CALL isInExecute( ) override; + virtual void SAL_CALL endExecute( ) override; + virtual void SAL_CALL setAcceleratorKeyEvent( ::sal_Int16 nItemId, const css::awt::KeyEvent& aKeyEvent ) override; + virtual css::awt::KeyEvent SAL_CALL getAcceleratorKeyEvent( ::sal_Int16 nItemId ) override; + virtual void SAL_CALL setItemImage( ::sal_Int16 nItemId, const css::uno::Reference< css::graphic::XGraphic >& xGraphic, sal_Bool bScale ) override; + virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getItemImage( ::sal_Int16 nItemId ) override; + + // css::lang::XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; +}; + +class UNLESS_MERGELIBS(TOOLKIT_DLLPUBLIC) VCLXMenuBar final : public VCLXMenu +{ +public: + VCLXMenuBar(); + VCLXMenuBar( MenuBar* pMenuBar ); +}; + +class TOOLKIT_DLLPUBLIC VCLXPopupMenu final : public VCLXMenu +{ +public: + VCLXPopupMenu(); + VCLXPopupMenu( PopupMenu* pPopMenu ); +}; + +#endif // INCLUDED_TOOLKIT_AWT_VCLXMENU_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/awt/vclxwindow.hxx b/include/toolkit/awt/vclxwindow.hxx new file mode 100644 index 000000000..9f3226ee6 --- /dev/null +++ b/include/toolkit/awt/vclxwindow.hxx @@ -0,0 +1,236 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#pragma once + +#include <toolkit/dllapi.h> +#include <toolkit/awt/vclxdevice.hxx> +#include <vcl/vclptr.hxx> + +#include <com/sun/star/awt/XWindow2.hpp> +#include <com/sun/star/awt/XVclWindowPeer.hpp> +#include <com/sun/star/awt/XLayoutConstrains.hpp> +#include <com/sun/star/awt/XView.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/awt/XDockableWindow.hpp> +#include <com/sun/star/awt/XStyleSettingsSupplier.hpp> + +#include <comphelper/servicehelper.hxx> +#include <cppuhelper/implbase.hxx> + +#include <tools/gen.hxx> +#include <tools/link.hxx> + +#include <memory> +#include <vector> +#include <functional> + +namespace comphelper { template <class ListenerT> class OInterfaceContainerHelper3; } +namespace com::sun::star::accessibility { class XAccessibleContext; } +namespace com::sun::star::awt { class XTopWindowListener; } +namespace com::sun::star::awt { class XVclContainerListener; } +namespace vcl { class Window; } + +class VclWindowEvent; + +namespace toolkit +{ + class IAccessibleFactory; +} + + +class UnoPropertyArrayHelper; +class VCLXWindowImpl; +typedef cppu::ImplInheritanceHelper< VCLXDevice, + css::awt::XWindow2, + css::awt::XVclWindowPeer, + css::awt::XLayoutConstrains, + css::awt::XView, + css::awt::XDockableWindow, + css::accessibility::XAccessible, + css::lang::XEventListener, + css::beans::XPropertySetInfo, + css::awt::XStyleSettingsSupplier + > VCLXWindow_Base; + +class TOOLKIT_DLLPUBLIC VCLXWindow : public VCLXWindow_Base +{ +private: + std::unique_ptr<VCLXWindowImpl> mpImpl; + + UnoPropertyArrayHelper *GetPropHelper(); + +protected: + Size ImplCalcWindowSize( const Size& rOutSz ) const; + DECL_DLLPRIVATE_LINK(WindowEventListener, VclWindowEvent&, void ); + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ); + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + CreateAccessibleContext(); + + void SetSynthesizingVCLEvent( bool b ); + bool IsSynthesizingVCLEvent() const; + + void SetSystemParent_Impl( const css::uno::Any& rHandle ); + + ::toolkit::IAccessibleFactory& getAccessibleFactory(); + + // helper ... + static void PushPropertyIds( std::vector< sal_uInt16 > &aIds, int nFirstId, ...); + // for use in controls/ + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds, + bool bWithDefaults = false ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ); + + ::comphelper::OInterfaceContainerHelper3<css::awt::XVclContainerListener>& GetContainerListeners(); + ::comphelper::OInterfaceContainerHelper3<css::awt::XTopWindowListener>& GetTopWindowListeners(); + +public: + typedef ::std::function<void ()> Callback; + +protected: + /** executes the given callback asynchronously + + At the moment the callback is called, the Solar Mutex is not locked. In particular, this implies that + you cannot rely on |this| not being disposed. However, you *can* rely on |this| being still alive (i.e. + having a ref count > 0). + + As a consequence, this can be used for doing listener notifications, using event multiplexers. Those multiplexers + care for the disposed state themself, and are alive as long as |this| is alive. + */ + void ImplExecuteAsyncWithoutSolarLock( + const Callback& i_callback + ); + +public: + VCLXWindow( bool bWithDefaultProps = false ); + virtual ~VCLXWindow() override; + + virtual void SetWindow( const VclPtr< vcl::Window > &pWindow ); + template< class derived_type > derived_type* GetAs() const { + return static_cast< derived_type * >( GetWindow() ); } + template< class derived_type > derived_type* GetAsDynamic() const { + return dynamic_cast< derived_type * >( GetWindow() ); } + vcl::Window* GetWindow() const + { + auto p = GetOutputDevice().get(); + return p ? p->GetOwnerWindow() : nullptr; + } + + void suspendVclEventListening( ); + void resumeVclEventListening( ); + + void notifyWindowRemoved( vcl::Window const & _rWindow ); + + bool IsDisposed() const; + + // css::lang::XUnoTunnel + UNO3_GETIMPLEMENTATION_DECL(VCLXWindow) + + // css::lang::XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // css::lang::XComponent + void SAL_CALL dispose( ) override; + void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& rxListener ) override; + void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& rxListener ) override; + + // css::awt::XWindow + void SAL_CALL setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) override; + css::awt::Rectangle SAL_CALL getPosSize( ) override; + void SAL_CALL setVisible( sal_Bool Visible ) override; + void SAL_CALL setEnable( sal_Bool Enable ) override; + void SAL_CALL setFocus( ) override; + void SAL_CALL addWindowListener( const css::uno::Reference< css::awt::XWindowListener >& rrxListener ) override; + void SAL_CALL removeWindowListener( const css::uno::Reference< css::awt::XWindowListener >& rrxListener ) override; + void SAL_CALL addFocusListener( const css::uno::Reference< css::awt::XFocusListener >& rrxListener ) override; + void SAL_CALL removeFocusListener( const css::uno::Reference< css::awt::XFocusListener >& rrxListener ) override; + void SAL_CALL addKeyListener( const css::uno::Reference< css::awt::XKeyListener >& rrxListener ) override; + void SAL_CALL removeKeyListener( const css::uno::Reference< css::awt::XKeyListener >& rrxListener ) override; + void SAL_CALL addMouseListener( const css::uno::Reference< css::awt::XMouseListener >& rrxListener ) override; + void SAL_CALL removeMouseListener( const css::uno::Reference< css::awt::XMouseListener >& rrxListener ) override; + void SAL_CALL addMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener >& rrxListener ) override; + void SAL_CALL removeMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener >& rrxListener ) override; + void SAL_CALL addPaintListener( const css::uno::Reference< css::awt::XPaintListener >& rrxListener ) override; + void SAL_CALL removePaintListener( const css::uno::Reference< css::awt::XPaintListener >& rrxListener ) override; + + // css::awt::XWindowPeer + css::uno::Reference< css::awt::XToolkit > SAL_CALL getToolkit( ) override; + void SAL_CALL setPointer( const css::uno::Reference< css::awt::XPointer >& Pointer ) override; + void SAL_CALL setBackground( sal_Int32 Color ) override; + void SAL_CALL invalidate( sal_Int16 Flags ) override; + void SAL_CALL invalidateRect( const css::awt::Rectangle& Rect, sal_Int16 Flags ) override; + + // css::awt::XVclWindowPeer + sal_Bool SAL_CALL isChild( const css::uno::Reference< css::awt::XWindowPeer >& Peer ) override; + void SAL_CALL setDesignMode( sal_Bool bOn ) override; + sal_Bool SAL_CALL isDesignMode( ) override; + void SAL_CALL enableClipSiblings( sal_Bool bClip ) override; + void SAL_CALL setForeground( sal_Int32 Color ) override; + void SAL_CALL setControlFont( const css::awt::FontDescriptor& aFont ) override; + void SAL_CALL getStyles( sal_Int16 nType, css::awt::FontDescriptor& Font, sal_Int32& ForegroundColor, sal_Int32& BackgroundColor ) override; + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; + + // css::awt::XView + sal_Bool SAL_CALL setGraphics( const css::uno::Reference< css::awt::XGraphics >& aDevice ) override; + css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics( ) override; + css::awt::Size SAL_CALL getSize( ) override; + void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) override; + void SAL_CALL setZoom( float fZoomX, float fZoomY ) override; + + // css::accessibility::XAccessible + css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + // css::awt::XDockableWindow + void SAL_CALL addDockableWindowListener( const css::uno::Reference< css::awt::XDockableWindowListener >& xListener ) override; + void SAL_CALL removeDockableWindowListener( const css::uno::Reference< css::awt::XDockableWindowListener >& xListener ) override; + void SAL_CALL enableDocking( sal_Bool bEnable ) override; + sal_Bool SAL_CALL isFloating( ) override; + void SAL_CALL setFloatingMode( sal_Bool bFloating ) override; + void SAL_CALL lock( ) override; + void SAL_CALL unlock( ) override; + sal_Bool SAL_CALL isLocked( ) override; + void SAL_CALL startPopupMode( const css::awt::Rectangle& WindowRect ) override; + sal_Bool SAL_CALL isInPopupMode( ) override; + + // css::awt::XWindow2 + void SAL_CALL setOutputSize( const css::awt::Size& aSize ) override; + css::awt::Size SAL_CALL getOutputSize( ) override; + sal_Bool SAL_CALL isVisible( ) override; + sal_Bool SAL_CALL isActive( ) override; + sal_Bool SAL_CALL isEnabled( ) override; + sal_Bool SAL_CALL hasFocus( ) override; + + // css::beans::XPropertySetInfo + css::uno::Sequence< css::beans::Property > SAL_CALL getProperties( ) override; + css::beans::Property SAL_CALL getPropertyByName( const OUString& aName ) override; + sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override; + + // XStyleSettingsSupplier + virtual css::uno::Reference< css::awt::XStyleSettings > SAL_CALL getStyleSettings() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/awt/vclxwindows.hxx b/include/toolkit/awt/vclxwindows.hxx new file mode 100644 index 000000000..e67f6b619 --- /dev/null +++ b/include/toolkit/awt/vclxwindows.hxx @@ -0,0 +1,743 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#pragma once + +#include <toolkit/dllapi.h> + +#include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/awt/XListBox.hpp> +#include <com/sun/star/awt/XNumericField.hpp> +#include <com/sun/star/awt/XScrollBar.hpp> +#include <com/sun/star/awt/XTextEditField.hpp> +#include <com/sun/star/awt/XSpinField.hpp> +#include <com/sun/star/awt/XTextLayoutConstrains.hpp> +#include <com/sun/star/awt/XButton.hpp> +#include <com/sun/star/awt/XToggleButton.hpp> +#include <com/sun/star/awt/XFixedHyperlink.hpp> +#include <com/sun/star/awt/XFixedText.hpp> +#include <com/sun/star/awt/XRadioButton.hpp> +#include <com/sun/star/awt/XComboBox.hpp> +#include <com/sun/star/awt/XCheckBox.hpp> +#include <com/sun/star/awt/XItemListListener.hpp> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weak.hxx> + +#include <svl/numuno.hxx> +#include <toolkit/awt/vclxwindow.hxx> +#include <toolkit/helper/listenermultiplexer.hxx> + +#include <vcl/image.hxx> + +// class VCLXGraphicControl +// deriving from VCLXWindow, drawing the graphic which exists as "Graphic" at the model + +class VCLXGraphicControl : public VCLXWindow +{ +private: + /// the image we currently display + Image maImage; + +protected: + const Image& GetImage() const { return maImage; } + +protected: + // css::awt::XWindow + void SAL_CALL setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + +protected: + /** forward our bitmap to our window + @precond + our mutex is locked + @precond + GetWindow is not <NULL/> + @see GetBitmap + */ + virtual void ImplSetNewImage(); + +public: + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } + +}; + + +// class VCLXButton + +typedef cppu::ImplInheritanceHelper< VCLXGraphicControl, + css::awt::XButton, + css::awt::XToggleButton + > VCLXButton_Base; +class VCLXButton final : public VCLXButton_Base +{ +private: + OUString maActionCommand; + ActionListenerMultiplexer maActionListeners; + ItemListenerMultiplexer maItemListeners; + + void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > CreateAccessibleContext() override; + +public: + VCLXButton(); + virtual ~VCLXButton() override; + + // css::lang::XComponent + void SAL_CALL dispose( ) override; + + // css::awt::XButton + void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL setLabel( const OUString& Label ) override; + void SAL_CALL setActionCommand( const OUString& Command ) override; + + // css::awt::XToggleButton + // css::awt::XItemEventBroadcaster + void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& rNewSize ) override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + +// class VCLXCheckBox + +class TOOLKIT_DLLPUBLIC VCLXCheckBox final : public css::awt::XCheckBox, + public css::awt::XButton, + public VCLXGraphicControl +{ +private: + ActionListenerMultiplexer maActionListeners; + OUString maActionCommand; + ItemListenerMultiplexer maItemListeners; + + void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > CreateAccessibleContext() override; + +public: + VCLXCheckBox(); + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + + // css::lang::XComponent + void SAL_CALL dispose( ) override; + + // css::awt::XCheckBox + void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + sal_Int16 SAL_CALL getState( ) override; + void SAL_CALL setState( sal_Int16 n ) override; + void SAL_CALL setLabel( const OUString& Label ) override; + void SAL_CALL enableTriState( sal_Bool b ) override; + + // css::awt::XButton: + void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL setActionCommand( const OUString& Command ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& rNewSize ) override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + + +// class VCLXRadioButton + +class TOOLKIT_DLLPUBLIC VCLXRadioButton final : public css::awt::XRadioButton, + public css::awt::XButton, + public VCLXGraphicControl +{ +private: + ItemListenerMultiplexer maItemListeners; + ActionListenerMultiplexer maActionListeners; + OUString maActionCommand; + + void ImplClickedOrToggled( bool bToggled ); + void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > CreateAccessibleContext() override; + +public: + VCLXRadioButton(); + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::lang::XComponent + void SAL_CALL dispose( ) override; + + // css::awt::XRadioButton + void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + sal_Bool SAL_CALL getState( ) override; + void SAL_CALL setState( sal_Bool b ) override; + void SAL_CALL setLabel( const OUString& Label ) override; + + // css::awt::XButton: + void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL setActionCommand( const OUString& Command ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& rNewSize ) override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } + +}; + +// class VCLXFixedHyperlink +class VCLXFixedHyperlink final : + public css::awt::XFixedHyperlink, + public VCLXWindow +{ +private: + ActionListenerMultiplexer maActionListeners; + + void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + CreateAccessibleContext() override; + +public: + VCLXFixedHyperlink(); + virtual ~VCLXFixedHyperlink() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XComponent + void SAL_CALL dispose( ) override; + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XFixedHyperlink + void SAL_CALL setText( const OUString& Text ) override; + OUString SAL_CALL getText( ) override; + void SAL_CALL setURL( const OUString& URL ) override; + OUString SAL_CALL getURL( ) override; + void SAL_CALL setAlignment( sal_Int16 nAlign ) override; + sal_Int16 SAL_CALL getAlignment( ) override; + void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& rNewSize ) override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + + +// class VCLXFixedText + +class VCLXFixedText final : public css::awt::XFixedText, + public VCLXWindow +{ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > CreateAccessibleContext() override; + +public: + VCLXFixedText(); + virtual ~VCLXFixedText() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XFixedText + void SAL_CALL setText( const OUString& Text ) override; + OUString SAL_CALL getText( ) override; + void SAL_CALL setAlignment( sal_Int16 nAlign ) override; + sal_Int16 SAL_CALL getAlignment( ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& rNewSize ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + + +// class VCLXScrollBar + +class TOOLKIT_DLLPUBLIC VCLXScrollBar final : public css::awt::XScrollBar, + public VCLXWindow +{ +private: + AdjustmentListenerMultiplexer maAdjustmentListeners; + + void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > CreateAccessibleContext() override; + +public: + VCLXScrollBar(); + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + + // css::lang::XComponent + void SAL_CALL dispose( ) override; + + // css::awt::XScrollbar + void SAL_CALL addAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener >& l ) override; + void SAL_CALL removeAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener >& l ) override; + void SAL_CALL setValue( sal_Int32 n ) override; + void SAL_CALL setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax ) override; + sal_Int32 SAL_CALL getValue( ) override; + void SAL_CALL setMaximum( sal_Int32 n ) override; + sal_Int32 SAL_CALL getMaximum( ) override; + void SAL_CALL setLineIncrement( sal_Int32 n ) override; + sal_Int32 SAL_CALL getLineIncrement( ) override; + void SAL_CALL setBlockIncrement( sal_Int32 n ) override; + sal_Int32 SAL_CALL getBlockIncrement( ) override; + void SAL_CALL setVisibleSize( sal_Int32 n ) override; + sal_Int32 SAL_CALL getVisibleSize( ) override; + void SAL_CALL setOrientation( sal_Int32 n ) override; + sal_Int32 SAL_CALL getOrientation( ) override; + + // why isn't this part of the XScrollbar? + /// @throws css::uno::RuntimeException + void setMinimum( sal_Int32 n ); + /// @throws css::uno::RuntimeException + sal_Int32 getMinimum( ) const; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize() override; + /// @throws css::uno::RuntimeException + static css::awt::Size implGetMinimumSize( vcl::Window const * p ); + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + + +// class VCLXEdit + +class SAL_DLLPUBLIC_RTTI VCLXEdit : public css::awt::XTextComponent, + public css::awt::XTextEditField, + public css::awt::XTextLayoutConstrains, + public VCLXWindow +{ +private: + TextListenerMultiplexer maTextListeners; + +protected: + void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > CreateAccessibleContext() override; + + +public: + VCLXEdit(); + + TextListenerMultiplexer& GetTextListeners() { return maTextListeners; } + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + + // css::lang::XComponent + void SAL_CALL dispose( ) override; + + // css::awt::XTextComponent + void SAL_CALL addTextListener( const css::uno::Reference< css::awt::XTextListener >& l ) override; + void SAL_CALL removeTextListener( const css::uno::Reference< css::awt::XTextListener >& l ) override; + void SAL_CALL setText( const OUString& aText ) override; + void SAL_CALL insertText( const css::awt::Selection& Sel, const OUString& Text ) override; + OUString SAL_CALL getText( ) override; + OUString SAL_CALL getSelectedText( ) override; + void SAL_CALL setSelection( const css::awt::Selection& aSelection ) override; + css::awt::Selection SAL_CALL getSelection( ) override; + sal_Bool SAL_CALL isEditable( ) override; + void SAL_CALL setEditable( sal_Bool bEditable ) override; + void SAL_CALL setMaxTextLen( sal_Int16 nLen ) override; + sal_Int16 SAL_CALL getMaxTextLen( ) override; + + // css::awt::XTextEditField: + void SAL_CALL setEchoChar( sal_Unicode cEcho ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& rNewSize ) override; + + // css::awt::XTextLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) override; + void SAL_CALL getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + + +// class VCLXSpinField +class VCLXSpinField : public css::awt::XSpinField, public VCLXEdit +{ +private: + SpinListenerMultiplexer maSpinListeners; + +protected: + void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + +public: + VCLXSpinField(); + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + + // css::awt::XSpinField + void SAL_CALL addSpinListener( const css::uno::Reference< css::awt::XSpinListener >& l ) override; + void SAL_CALL removeSpinListener( const css::uno::Reference< css::awt::XSpinListener >& l ) override; + void SAL_CALL up( ) override; + void SAL_CALL down( ) override; + void SAL_CALL first( ) override; + void SAL_CALL last( ) override; + void SAL_CALL enableRepeat( sal_Bool bRepeat ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + +class SVTXFormattedField : public VCLXSpinField +{ +protected: + rtl::Reference<SvNumberFormatsSupplierObj> m_xCurrentSupplier; + bool bIsStandardSupplier; + + sal_Int32 nKeyToSetDelayed; + +public: + SVTXFormattedField(); + virtual ~SVTXFormattedField() override; + + // css::awt::XVclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + +protected: + void setFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier > & xSupplier); + sal_Int32 getFormatKey() const; + void setFormatKey(sal_Int32 nKey); + + void SetValue(const css::uno::Any& rValue); + css::uno::Any GetValue() const; + + void SetTreatAsNumber(bool bSet); + bool GetTreatAsNumber() const; + + void SetDefaultValue(const css::uno::Any& rValue); + css::uno::Any GetDefaultValue() const; + + void SetMinValue(const css::uno::Any& rValue); + css::uno::Any GetMinValue() const; + + void SetMaxValue(const css::uno::Any& rValue); + css::uno::Any GetMaxValue() const; + + void NotifyTextListeners(); + css::uno::Any convertEffectiveValue(const css::uno::Any& rValue) const; + + virtual void SetWindow( const VclPtr< vcl::Window > &_pWindow) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + +class TOOLKIT_DLLPUBLIC SVTXNumericField final : public css::awt::XNumericField, public SVTXFormattedField +{ +public: + SVTXNumericField(); + virtual ~SVTXNumericField() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { SVTXFormattedField::acquire(); } + void SAL_CALL release() noexcept override { SVTXFormattedField::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XNumericField + void SAL_CALL setValue( double Value ) override; + double SAL_CALL getValue( ) override; + void SAL_CALL setMin( double Value ) override; + double SAL_CALL getMin( ) override; + void SAL_CALL setMax( double Value ) override; + double SAL_CALL getMax( ) override; + void SAL_CALL setFirst( double Value ) override; + double SAL_CALL getFirst( ) override; + void SAL_CALL setLast( double Value ) override; + double SAL_CALL getLast( ) override; + void SAL_CALL setSpinSize( double Value ) override; + double SAL_CALL getSpinSize( ) override; + void SAL_CALL setDecimalDigits( sal_Int16 nDigits ) override; + sal_Int16 SAL_CALL getDecimalDigits( ) override; + void SAL_CALL setStrictFormat( sal_Bool bStrict ) override; + sal_Bool SAL_CALL isStrictFormat( ) override; + + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override; + + virtual css::uno::Reference< css::accessibility::XAccessibleContext > CreateAccessibleContext() override; +}; + +// class VCLXListBox + +typedef cppu::ImplInheritanceHelper< VCLXWindow, + css::awt::XListBox, + css::awt::XTextLayoutConstrains, + css::awt::XItemListListener + > VCLXListBox_Base; +class VCLXListBox final : public VCLXListBox_Base +{ +private: + ActionListenerMultiplexer maActionListeners; + ItemListenerMultiplexer maItemListeners; + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + CreateAccessibleContext() override; + void ImplCallItemListeners(); + +public: + VCLXListBox(); + + // css::lang::XComponent + void SAL_CALL dispose( ) override; + + // css::awt::XListBox + void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL addItem( const OUString& aItem, sal_Int16 nPos ) override; + void SAL_CALL addItems( const css::uno::Sequence< OUString >& aItems, sal_Int16 nPos ) override; + void SAL_CALL removeItems( sal_Int16 nPos, sal_Int16 nCount ) override; + sal_Int16 SAL_CALL getItemCount( ) override; + OUString SAL_CALL getItem( sal_Int16 nPos ) override; + css::uno::Sequence< OUString > SAL_CALL getItems( ) override; + sal_Int16 SAL_CALL getSelectedItemPos( ) override; + css::uno::Sequence< sal_Int16 > SAL_CALL getSelectedItemsPos( ) override; + OUString SAL_CALL getSelectedItem( ) override; + css::uno::Sequence< OUString > SAL_CALL getSelectedItems( ) override; + void SAL_CALL selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) override; + void SAL_CALL selectItemsPos( const css::uno::Sequence< sal_Int16 >& aPositions, sal_Bool bSelect ) override; + void SAL_CALL selectItem( const OUString& aItem, sal_Bool bSelect ) override; + sal_Bool SAL_CALL isMutipleMode( ) override; + void SAL_CALL setMultipleMode( sal_Bool bMulti ) override; + sal_Int16 SAL_CALL getDropDownLineCount( ) override; + void SAL_CALL setDropDownLineCount( sal_Int16 nLines ) override; + void SAL_CALL makeVisible( sal_Int16 nEntry ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& rNewSize ) override; + + // css::awt::XTextLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) override; + void SAL_CALL getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + // XItemListListener + virtual void SAL_CALL listItemInserted( const css::awt::ItemListEvent& Event ) override; + virtual void SAL_CALL listItemRemoved( const css::awt::ItemListEvent& Event ) override; + virtual void SAL_CALL listItemModified( const css::awt::ItemListEvent& Event ) override; + virtual void SAL_CALL allItemsRemoved( const css::lang::EventObject& Event ) override; + virtual void SAL_CALL itemListChanged( const css::lang::EventObject& Event ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& i_rEvent ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + + +// class VCLXComboBox + +typedef cppu::ImplInheritanceHelper< VCLXEdit, + css::awt::XComboBox, + css::awt::XItemListListener + > VCLXComboBox_Base; +class VCLXComboBox final : public VCLXComboBox_Base +{ +private: + ActionListenerMultiplexer maActionListeners; + ItemListenerMultiplexer maItemListeners; + + void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > CreateAccessibleContext() override; + + +public: + VCLXComboBox(); + virtual ~VCLXComboBox() override; + + // css::lang::XComponent + void SAL_CALL dispose( ) override; + + // css::awt::XComboBox + void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL addItem( const OUString& aItem, sal_Int16 nPos ) override; + void SAL_CALL addItems( const css::uno::Sequence< OUString >& aItems, sal_Int16 nPos ) override; + void SAL_CALL removeItems( sal_Int16 nPos, sal_Int16 nCount ) override; + sal_Int16 SAL_CALL getItemCount( ) override; + OUString SAL_CALL getItem( sal_Int16 nPos ) override; + css::uno::Sequence< OUString > SAL_CALL getItems( ) override; + sal_Int16 SAL_CALL getDropDownLineCount( ) override; + void SAL_CALL setDropDownLineCount( sal_Int16 nLines ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& rNewSize ) override; + + // css::awt::XTextLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) override; + void SAL_CALL getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + // XItemListListener + virtual void SAL_CALL listItemInserted( const css::awt::ItemListEvent& Event ) override; + virtual void SAL_CALL listItemRemoved( const css::awt::ItemListEvent& Event ) override; + virtual void SAL_CALL listItemModified( const css::awt::ItemListEvent& Event ) override; + virtual void SAL_CALL allItemsRemoved( const css::lang::EventObject& Event ) override; + virtual void SAL_CALL itemListChanged( const css::lang::EventObject& Event ) override; + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& i_rEvent ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + +// class VCLXToolBox +class VCLXToolBox final : public VCLXWindow +{ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + CreateAccessibleContext() override; + +public: + VCLXToolBox(); + virtual ~VCLXToolBox() override; +}; + +class VCLXHeaderBar final : public VCLXWindow +{ +public: + VCLXHeaderBar(); + virtual ~VCLXHeaderBar() override; + + virtual css::uno::Reference< css::accessibility::XAccessibleContext > CreateAccessibleContext() override; + +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/controls/unocontrol.hxx b/include/toolkit/controls/unocontrol.hxx new file mode 100644 index 000000000..cbde0b659 --- /dev/null +++ b/include/toolkit/controls/unocontrol.hxx @@ -0,0 +1,231 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_CONTROLS_UNOCONTROL_HXX +#define INCLUDED_TOOLKIT_CONTROLS_UNOCONTROL_HXX + +#include <toolkit/dllapi.h> +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XWindow2.hpp> +#include <com/sun/star/awt/XView.hpp> +#include <com/sun/star/beans/XPropertiesChangeListener.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/awt/XUnitConversion.hpp> +#include <com/sun/star/awt/XStyleSettingsSupplier.hpp> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <osl/mutex.hxx> +#include <toolkit/helper/listenermultiplexer.hxx> +#include <tools/long.hxx> +#include <comphelper/interfacecontainer3.hxx> +#include <cppuhelper/weakref.hxx> +#include <cppuhelper/implbase9.hxx> +#include <com/sun/star/util/XModeChangeBroadcaster.hpp> +#include <com/sun/star/awt/XVclWindowPeer.hpp> +#include <memory> + + +struct UnoControlComponentInfos +{ + bool bVisible; + bool bEnable; + tools::Long nX, nY, nWidth, nHeight; + sal_uInt16 nFlags; + float nZoomX, nZoomY; + + UnoControlComponentInfos() + { + bVisible = true; + bEnable = true; + nX = nY = nWidth = nHeight = 0; + nFlags = 0; // POSSIZE_POSSIZE; + nZoomX = nZoomY = 1.0f; + } +}; + +struct UnoControl_Data; + + +typedef ::cppu::WeakAggImplHelper9 < css::awt::XControl + , css::awt::XWindow2 + , css::awt::XView + , css::beans::XPropertiesChangeListener + , css::lang::XServiceInfo + , css::accessibility::XAccessible + , css::util::XModeChangeBroadcaster + , css::awt::XUnitConversion + , css::awt::XStyleSettingsSupplier + > UnoControl_Base; + +class TOOLKIT_DLLPUBLIC UnoControl : public UnoControl_Base +{ +private: + ::osl::Mutex maMutex; + + css::uno::Reference< css::awt::XWindowPeer > mxPeer; + css::uno::Reference< css::awt::XVclWindowPeer > mxVclWindowPeer; // just to avoid the query_interface thing + +protected: + EventListenerMultiplexer maDisposeListeners; + WindowListenerMultiplexer maWindowListeners; + FocusListenerMultiplexer maFocusListeners; + KeyListenerMultiplexer maKeyListeners; + MouseListenerMultiplexer maMouseListeners; + MouseMotionListenerMultiplexer maMouseMotionListeners; + PaintListenerMultiplexer maPaintListeners; + ::comphelper::OInterfaceContainerHelper3<css::util::XModeChangeListener> maModeChangeListeners; + + css::uno::Reference< css::uno::XInterface > mxContext; + css::uno::Reference< css::awt::XControlModel > mxModel; + css::uno::Reference< css::awt::XGraphics > mxGraphics; + + css::uno::WeakReferenceHelper + maAccessibleContext; /// our most recent XAccessibleContext instance + + bool mbDisposePeer; + bool mbRefreshingPeer; + bool mbCreatingPeer; + bool mbCreatingCompatiblePeer; + bool mbDesignMode; + + UnoControlComponentInfos maComponentInfos; + std::unique_ptr<UnoControl_Data> mpData; + + ::osl::Mutex& GetMutex() { return maMutex; } + + css::uno::Reference< css::awt::XWindow > getParentPeer() const; + virtual void updateFromModel(); + void peerCreated(); + bool ImplCheckLocalize( OUString& _rPossiblyLocalizable ); + css::uno::Reference< css::awt::XWindowPeer > ImplGetCompatiblePeer(); + virtual void ImplSetPeerProperty( const OUString& rPropName, const css::uno::Any& rVal ); + virtual void PrepareWindowDescriptor( css::awt::WindowDescriptor& rDesc ); + virtual void ImplModelPropertiesChanged( const css::uno::Sequence< css::beans::PropertyChangeEvent >& rEvents ); + + void ImplLockPropertyChangeNotification( const OUString& rPropertyName, bool bLock ); + void ImplLockPropertyChangeNotifications( const css::uno::Sequence< OUString >& rPropertyNames, bool bLock ); + + void DisposeAccessibleContext(css::uno::Reference< + css::lang::XComponent> const& xContext); + + void setPeer( const css::uno::Reference< css::awt::XWindowPeer >& _xPeer) + { + mxPeer = _xPeer; + mxVclWindowPeer = css::uno::Reference< css::awt::XVclWindowPeer >(mxPeer,css::uno::UNO_QUERY); // just to avoid the query_interface thing + } + + virtual bool requiresNewPeer( const OUString& _rPropertyName ) const; + +public: + UnoControl(); + virtual ~UnoControl() override; + + UnoControlComponentInfos& GetComponentInfos() { return maComponentInfos; } + + + virtual OUString GetComponentServiceName() const; + + // css::lang::XTypeProvider + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::lang::XComponent + void SAL_CALL dispose( ) override; + void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; + void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + + // XEventListener + void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // css::awt::XWindow2 + virtual void SAL_CALL setOutputSize( const css::awt::Size& aSize ) override; + virtual css::awt::Size SAL_CALL getOutputSize( ) override; + virtual sal_Bool SAL_CALL isVisible( ) override; + virtual sal_Bool SAL_CALL isActive( ) override; + virtual sal_Bool SAL_CALL isEnabled( ) override; + virtual sal_Bool SAL_CALL hasFocus( ) override; + + // css::awt::XWindow + void SAL_CALL setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) override; + css::awt::Rectangle SAL_CALL getPosSize( ) override; + void SAL_CALL setVisible( sal_Bool Visible ) override; + void SAL_CALL setEnable( sal_Bool Enable ) override; + void SAL_CALL setFocus( ) override; + void SAL_CALL addWindowListener( const css::uno::Reference< css::awt::XWindowListener >& xListener ) override; + void SAL_CALL removeWindowListener( const css::uno::Reference< css::awt::XWindowListener >& xListener ) override; + void SAL_CALL addFocusListener( const css::uno::Reference< css::awt::XFocusListener >& xListener ) override; + void SAL_CALL removeFocusListener( const css::uno::Reference< css::awt::XFocusListener >& xListener ) override; + void SAL_CALL addKeyListener( const css::uno::Reference< css::awt::XKeyListener >& xListener ) override; + void SAL_CALL removeKeyListener( const css::uno::Reference< css::awt::XKeyListener >& xListener ) override; + void SAL_CALL addMouseListener( const css::uno::Reference< css::awt::XMouseListener >& xListener ) override; + void SAL_CALL removeMouseListener( const css::uno::Reference< css::awt::XMouseListener >& xListener ) override; + void SAL_CALL addMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener >& xListener ) override; + void SAL_CALL removeMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener >& xListener ) override; + void SAL_CALL addPaintListener( const css::uno::Reference< css::awt::XPaintListener >& xListener ) override; + void SAL_CALL removePaintListener( const css::uno::Reference< css::awt::XPaintListener >& xListener ) override; + + // css::awt::XView + sal_Bool SAL_CALL setGraphics( const css::uno::Reference< css::awt::XGraphics >& aDevice ) override; + css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics( ) override; + css::awt::Size SAL_CALL getSize( ) override; + void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) override; + void SAL_CALL setZoom( float fZoomX, float fZoomY ) override; + + // css::awt::XControl + void SAL_CALL setContext( const css::uno::Reference< css::uno::XInterface >& Context ) override; + css::uno::Reference< css::uno::XInterface > SAL_CALL getContext( ) override; + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getPeer( ) override; + sal_Bool SAL_CALL setModel( const css::uno::Reference< css::awt::XControlModel >& Model ) override; + css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel( ) override; + css::uno::Reference< css::awt::XView > SAL_CALL getView( ) override; + void SAL_CALL setDesignMode( sal_Bool bOn ) override; + sal_Bool SAL_CALL isDesignMode( ) override; + sal_Bool SAL_CALL isTransparent( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName( ) override; + sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + // XModeChangeBroadcaster + virtual void SAL_CALL addModeChangeListener( const css::uno::Reference< css::util::XModeChangeListener >& _rxListener ) override; + virtual void SAL_CALL removeModeChangeListener( const css::uno::Reference< css::util::XModeChangeListener >& _rxListener ) override; + virtual void SAL_CALL addModeChangeApproveListener( const css::uno::Reference< css::util::XModeChangeApproveListener >& _rxListener ) override; + virtual void SAL_CALL removeModeChangeApproveListener( const css::uno::Reference< css::util::XModeChangeApproveListener >& _rxListener ) override; + + // XUnitConversion + virtual css::awt::Point SAL_CALL convertPointToLogic( const css::awt::Point& Point, ::sal_Int16 TargetUnit ) override; + virtual css::awt::Point SAL_CALL convertPointToPixel( const css::awt::Point& aPoint, ::sal_Int16 SourceUnit ) override; + virtual css::awt::Size SAL_CALL convertSizeToLogic( const css::awt::Size& aSize, ::sal_Int16 TargetUnit ) override; + virtual css::awt::Size SAL_CALL convertSizeToPixel( const css::awt::Size& aSize, ::sal_Int16 SourceUnit ) override; + + // XStyleSettingsSupplier + virtual css::uno::Reference< css::awt::XStyleSettings > SAL_CALL getStyleSettings() override; + +protected: + // css::beans::XPropertiesChangeListener + void SAL_CALL propertiesChange( const css::uno::Sequence< css::beans::PropertyChangeEvent >& evt ) override; +}; + + +#endif // INCLUDED_TOOLKIT_CONTROLS_UNOCONTROL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/controls/unocontrolbase.hxx b/include/toolkit/controls/unocontrolbase.hxx new file mode 100644 index 000000000..06e57067d --- /dev/null +++ b/include/toolkit/controls/unocontrolbase.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLBASE_HXX +#define INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLBASE_HXX + +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/util/Date.hpp> +#include <com/sun/star/util/Time.hpp> + +#include <toolkit/controls/unocontrol.hxx> + + + + +class UnoControlBase : public UnoControl +{ +protected: + UnoControlBase() {} + + bool ImplHasProperty( sal_uInt16 nProp ); + bool ImplHasProperty( const OUString& aPropertyName ); + void ImplSetPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue, bool bUpdateThis ); + void ImplSetPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues, bool bUpdateThis ); + css::uno::Any ImplGetPropertyValue( const OUString& aPropertyName ) const; + + template <typename T> T ImplGetPropertyValuePOD( sal_uInt16 nProp ); + template <typename T> T ImplGetPropertyValueClass( sal_uInt16 nProp ); + bool ImplGetPropertyValue_BOOL( sal_uInt16 nProp ); + sal_Int16 ImplGetPropertyValue_INT16( sal_uInt16 nProp ); + sal_Int32 ImplGetPropertyValue_INT32( sal_uInt16 nProp ); + double ImplGetPropertyValue_DOUBLE( sal_uInt16 nProp ); + OUString ImplGetPropertyValue_UString( sal_uInt16 nProp ); + css::util::Date ImplGetPropertyValue_Date( sal_uInt16 nProp ); + css::util::Time ImplGetPropertyValue_Time( sal_uInt16 nProp ); + + // XLayoutConstrains (only when the Control supporting it) + css::awt::Size Impl_getMinimumSize(); + css::awt::Size Impl_getPreferredSize(); + css::awt::Size Impl_calcAdjustedSize( const css::awt::Size& rNewSize ); + + // XTextLayoutConstrains (only when the Control supporting it) + css::awt::Size Impl_getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ); + void Impl_getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ); +}; + + +#endif // INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLBASE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/controls/unocontrolmodel.hxx b/include/toolkit/controls/unocontrolmodel.hxx new file mode 100644 index 000000000..fb22dc3e4 --- /dev/null +++ b/include/toolkit/controls/unocontrolmodel.hxx @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLMODEL_HXX +#define INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLMODEL_HXX + +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/io/XPersistObject.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <cppuhelper/weakagg.hxx> + +#include <toolkit/helper/mutexandbroadcasthelper.hxx> +#include <toolkit/helper/listenermultiplexer.hxx> + +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/implbase7.hxx> +#include <comphelper/uno3.hxx> +#include <rtl/ref.hxx> + +#include <vector> +#include <map> + +namespace com::sun::star::uno { class XComponentContext; } + +typedef std::map<sal_uInt16, css::uno::Any> ImplPropertyTable; + + + + +typedef ::cppu::WeakAggImplHelper7 < css::awt::XControlModel + , css::beans::XPropertyState + , css::io::XPersistObject + , css::lang::XComponent + , css::lang::XServiceInfo + , css::lang::XUnoTunnel + , css::util::XCloneable + > UnoControlModel_Base; + +class UnoControlModel :public UnoControlModel_Base + ,public MutexAndBroadcastHelper + ,public ::cppu::OPropertySetHelper +{ +private: + ImplPropertyTable maData; + EventListenerMultiplexer maDisposeListeners; + +protected: + css::uno::Reference< css::uno::XComponentContext > m_xContext; + +protected: + void ImplRegisterProperty( sal_uInt16 nPropType ); + void ImplRegisterProperties( const std::vector< sal_uInt16 > &rIds ); + void ImplRegisterProperty( sal_uInt16 nPropId, const css::uno::Any& rDefault ); + css::uno::Sequence<sal_Int32> ImplGetPropertyIds() const; + virtual css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; + bool ImplHasProperty( sal_uInt16 nPropId ) const; + + /** called before setting multiple properties, allows to care for property dependencies + + <p>When multiple property values are set (e.g. XPropertySet::setPropertyValues), it may happen that some + of them are dependent. For this, derivees which know such dependencies can affect the order in which + the properties are internally really set.</p> + */ + virtual void ImplNormalizePropertySequence( + const sal_Int32 _nCount, /// the number of entries in the arrays + sal_Int32* _pHandles, /// the handles of the properties to set + css::uno::Any* _pValues, /// the values of the properties to set + sal_Int32* _pValidHandles /// pointer to the valid handles, allowed to be adjusted + ) const; + + /// ensures that two property values in a sequence have a certain order + static void ImplEnsureHandleOrder( + const sal_Int32 _nCount, /// number of entries in the array + sal_Int32* _pHandles, /// pointer to the handles + css::uno::Any* _pValues, /// pointer to the values + sal_Int32 _nFirstHandle, /// first handle, which should precede _nSecondHandle in the sequence + sal_Int32 _nSecondHandle /// second handle, which should supersede _nFirstHandle in the sequence + ); + + template<typename T> void UNO_CONTROL_MODEL_REGISTER_PROPERTIES() { + std::vector< sal_uInt16 > aIds; + T::ImplGetPropertyIds( aIds ); + ImplRegisterProperties( aIds ); + } + +protected: +#ifdef _MSC_VER + UnoControlModel() //do not use! needed by MSVC at compile time to satisfy WeakAggImplHelper7 + : UnoControlModel_Base() + , MutexAndBroadcastHelper() + , OPropertySetHelper( BrdcstHelper ) + , maDisposeListeners( *this ) + , m_xContext( css::uno::Reference< css::uno::XComponentContext >() ) + { + assert(false); + } +#endif + +public: + UnoControlModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlModel( const UnoControlModel& rModel ); + + virtual rtl::Reference<UnoControlModel> Clone() const = 0; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return OWeakAggObject::queryInterface(rType); } + void SAL_CALL acquire() noexcept override; + void SAL_CALL release() noexcept override; + + // css::uno::XAggregation + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + + // css::lang::XUnoTunnel + static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId() noexcept; + sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier ) override; + + // css::util::XCloneable + css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + // css::lang::XTypeProvider + DECLARE_XTYPEPROVIDER() + + // css::lang::XComponent + void SAL_CALL dispose( ) override; + void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; + void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + + // css::beans::XPropertyState + css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override; + css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override; + void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override; + css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override; + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + void SAL_CALL write( const css::uno::Reference< css::io::XObjectOutputStream >& OutStream ) override; + void SAL_CALL read( const css::uno::Reference< css::io::XObjectInputStream >& InStream ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName( ) override; + sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // ::cppu::OPropertySetHelper + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override = 0; + sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any & rConvertedValue, css::uno::Any & rOldValue, sal_Int32 nHandle, const css::uno::Any& rValue ) override; + void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override; + using cppu::OPropertySetHelper::getFastPropertyValue; + void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override; + + // override setValue methods to handle properties of FontDescriptor + // css::beans::XPropertySet + void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; + // css::beans::XFastPropertySet + void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const css::uno::Any& aValue ) override; + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& PropertyNames, const css::uno::Sequence< css::uno::Any >& Values ) override; +}; + +#endif // INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLMODEL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/controls/unocontrols.hxx b/include/toolkit/controls/unocontrols.hxx new file mode 100644 index 000000000..121bdec42 --- /dev/null +++ b/include/toolkit/controls/unocontrols.hxx @@ -0,0 +1,1490 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLS_HXX +#define INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLS_HXX + +#include <config_options.h> +#include <toolkit/dllapi.h> +#include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/awt/XTextListener.hpp> +#include <com/sun/star/awt/XLayoutConstrains.hpp> +#include <com/sun/star/awt/XTextLayoutConstrains.hpp> +#include <com/sun/star/awt/XButton.hpp> +#include <com/sun/star/awt/XToggleButton.hpp> +#include <com/sun/star/awt/XRadioButton.hpp> +#include <com/sun/star/awt/XItemListener.hpp> +#include <com/sun/star/awt/XCheckBox.hpp> +#include <com/sun/star/awt/XFixedHyperlink.hpp> +#include <com/sun/star/awt/XFixedText.hpp> +#include <com/sun/star/awt/XListBox.hpp> +#include <com/sun/star/awt/XComboBox.hpp> +#include <com/sun/star/awt/XDateField.hpp> +#include <com/sun/star/awt/XSpinField.hpp> +#include <com/sun/star/awt/XTimeField.hpp> +#include <com/sun/star/awt/XNumericField.hpp> +#include <com/sun/star/awt/XCurrencyField.hpp> +#include <com/sun/star/awt/XPatternField.hpp> +#include <com/sun/star/awt/XProgressBar.hpp> +#include <com/sun/star/awt/XItemList.hpp> +#include <toolkit/controls/unocontrolmodel.hxx> +#include <toolkit/controls/unocontrolbase.hxx> +#include <toolkit/helper/macros.hxx> +#include <cppuhelper/implbase5.hxx> +#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/implbase1.hxx> +#include <comphelper/interfacecontainer3.hxx> +#include <comphelper/uno3.hxx> +#include <tools/gen.hxx> + +#include <memory> +#include <vector> + +#include <optional> + +namespace com::sun::star::graphic { class XGraphic; } +namespace com::sun::star::graphic { class XGraphicObject; } + +class ImageHelper +{ +public: + // The routine will always attempt to return a valid XGraphic for the + // passed _rURL, additionally xOutGraphicObject will contain the + // associated XGraphicObject ( if url is valid for that ) and is set + // appropriately ( e.g. NULL if non GraphicObject scheme ) or a valid + // object if the rURL points to a valid object + static css::uno::Reference< css::graphic::XGraphic > getGraphicAndGraphicObjectFromURL_nothrow( css::uno::Reference< css::graphic::XGraphicObject >& xOutGraphicObject, const OUString& _rURL ); + static css::uno::Reference< css::graphic::XGraphic > getGraphicFromURL_nothrow( const OUString& _rURL ); + +}; + + + +class UnoControlEditModel final : public UnoControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlEditModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlEditModel( const UnoControlEditModel& rModel ) : UnoControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlEditModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + + // XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +typedef ::cppu::ImplHelper4 < css::awt::XTextComponent + , css::awt::XTextListener + , css::awt::XLayoutConstrains + , css::awt::XTextLayoutConstrains + > UnoEditControl_Base; +class UNLESS_MERGELIBS(TOOLKIT_DLLPUBLIC) UnoEditControl :public UnoControlBase + ,public UnoEditControl_Base +{ +private: + TextListenerMultiplexer maTextListeners; + + // Not all fields derived from UnoEditCOntrol have the property "Text" + // They only support XTextComponent, so keep the text + // here, maybe there is no Peer when calling setText()... + OUString maText; + sal_uInt16 mnMaxTextLen; + + bool mbSetTextInPeer; + bool mbSetMaxTextLenInPeer; + bool mbHasTextProperty; + +public: + + UnoEditControl(); + OUString GetComponentServiceName() const override; + TextListenerMultiplexer& GetTextListeners() { return maTextListeners; } + + void ImplSetPeerProperty( const OUString& rPropName, const css::uno::Any& rVal ) override; + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + void SAL_CALL disposing( const css::lang::EventObject& Source ) override { UnoControlBase::disposing( Source ); } + void SAL_CALL dispose( ) override; + + // disambiguate XInterface + DECLARE_XINTERFACE() + + // XAggregation + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XTextListener + void SAL_CALL textChanged( const css::awt::TextEvent& rEvent ) override; + + // XTextComponent + void SAL_CALL addTextListener( const css::uno::Reference< css::awt::XTextListener >& l ) override; + void SAL_CALL removeTextListener( const css::uno::Reference< css::awt::XTextListener >& l ) override; + void SAL_CALL setText( const OUString& aText ) override; + void SAL_CALL insertText( const css::awt::Selection& Sel, const OUString& Text ) override; + OUString SAL_CALL getText( ) override; + OUString SAL_CALL getSelectedText( ) override; + void SAL_CALL setSelection( const css::awt::Selection& aSelection ) override; + css::awt::Selection SAL_CALL getSelection( ) override; + sal_Bool SAL_CALL isEditable( ) override; + void SAL_CALL setEditable( sal_Bool bEditable ) override; + void SAL_CALL setMaxTextLen( sal_Int16 nLen ) override; + sal_Int16 SAL_CALL getMaxTextLen( ) override; + + // XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; + + // XTextLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) override; + void SAL_CALL getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) override; + + // XServiceInfo + OUString SAL_CALL getImplementationName( ) override; + css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + sal_Bool SAL_CALL setModel(const css::uno::Reference< css::awt::XControlModel >& Model) override; +}; + + + +class UnoControlFileControlModel final : public UnoControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlFileControlModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlFileControlModel( const UnoControlFileControlModel& rModel ) : UnoControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlFileControlModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoFileControl final : public UnoEditControl +{ +public: + UnoFileControl(); + OUString GetComponentServiceName() const override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class GraphicControlModel : public UnoControlModel +{ +private: + bool mbAdjustingImagePosition; + bool mbAdjustingGraphic; + +protected: + GraphicControlModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) + :UnoControlModel( rxContext ) + ,mbAdjustingImagePosition( false ) + ,mbAdjustingGraphic( false ) + { + } + GraphicControlModel( const GraphicControlModel& _rSource ) : UnoControlModel( _rSource ), mbAdjustingImagePosition( false ), mbAdjustingGraphic( false ) { } + + // ::cppu::OPropertySetHelper + void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override; + + // UnoControlModel + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + +private: + GraphicControlModel& operator=( const GraphicControlModel& ) = delete; +}; + + + +class UnoControlButtonModel final : public GraphicControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlButtonModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlButtonModel( const UnoControlButtonModel& rModel ) : GraphicControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlButtonModel( *this ); } + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +typedef ::cppu::AggImplInheritanceHelper4 < UnoControlBase + , css::awt::XButton + , css::awt::XToggleButton + , css::awt::XLayoutConstrains + , css::awt::XItemListener + > UnoButtonControl_Base; +class UnoButtonControl final : public UnoButtonControl_Base +{ +private: + ActionListenerMultiplexer maActionListeners; + ItemListenerMultiplexer maItemListeners; + OUString maActionCommand; + +public: + + UnoButtonControl(); + OUString GetComponentServiceName() const override; + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + void SAL_CALL dispose( ) override; + + // css::awt::XButton + void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL setLabel( const OUString& Label ) override; + void SAL_CALL setActionCommand( const OUString& Command ) override; + + // css::awt::XToggleButton + // css::awt::XItemEventBroadcaster + void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + + // css::lang::XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // XItemListener + virtual void SAL_CALL itemStateChanged( const css::awt::ItemEvent& rEvent ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoControlImageControlModel final : public GraphicControlModel +{ +private: + bool mbAdjustingImageScaleMode; + + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlImageControlModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlImageControlModel( const UnoControlImageControlModel& rModel ) : GraphicControlModel( rModel ), mbAdjustingImageScaleMode( false ) { } + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlImageControlModel( *this ); } + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + // ::cppu::OPropertySetHelper + void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override; +}; + + + +typedef ::cppu::AggImplInheritanceHelper1 < UnoControlBase + , css::awt::XLayoutConstrains + > UnoImageControlControl_Base; +class UnoImageControlControl final : public UnoImageControlControl_Base +{ +private: + ActionListenerMultiplexer maActionListeners; + +public: + + UnoImageControlControl(); + OUString GetComponentServiceName() const override; + + void SAL_CALL dispose( ) override; + + // css::awt::XControl + sal_Bool SAL_CALL isTransparent( ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoControlRadioButtonModel final : public GraphicControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlRadioButtonModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlRadioButtonModel( const UnoControlRadioButtonModel& rModel ) : GraphicControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlRadioButtonModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +typedef ::cppu::AggImplInheritanceHelper4 < UnoControlBase + , css::awt::XButton + , css::awt::XRadioButton + , css::awt::XItemListener + , css::awt::XLayoutConstrains + > UnoRadioButtonControl_Base; +class UnoRadioButtonControl final : public UnoRadioButtonControl_Base +{ +private: + ItemListenerMultiplexer maItemListeners; + ActionListenerMultiplexer maActionListeners; + OUString maActionCommand; + +public: + + UnoRadioButtonControl(); + OUString GetComponentServiceName() const override; + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + void SAL_CALL dispose( ) override; + void SAL_CALL disposing( const css::lang::EventObject& Source ) override { UnoControlBase::disposing( Source ); } + + // css::awt::XControl + sal_Bool SAL_CALL isTransparent( ) override; + + // css::awt::XButton + void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL setActionCommand( const OUString& Command ) override; + + // css::awt::XRadioButton + void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + sal_Bool SAL_CALL getState( ) override; + void SAL_CALL setState( sal_Bool b ) override; + void SAL_CALL setLabel( const OUString& Label ) override; + + // css::awt::XItemListener + void SAL_CALL itemStateChanged( const css::awt::ItemEvent& rEvent ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoControlCheckBoxModel final : public GraphicControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlCheckBoxModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlCheckBoxModel( const UnoControlCheckBoxModel& rModel ) : GraphicControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlCheckBoxModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +typedef ::cppu::AggImplInheritanceHelper4 < UnoControlBase + , css::awt::XButton + , css::awt::XCheckBox + , css::awt::XItemListener + , css::awt::XLayoutConstrains + > UnoCheckBoxControl_Base; +class UnoCheckBoxControl final : public UnoCheckBoxControl_Base +{ +private: + ItemListenerMultiplexer maItemListeners; + ActionListenerMultiplexer maActionListeners; + OUString maActionCommand; + +public: + + UnoCheckBoxControl(); + OUString GetComponentServiceName() const override; + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + void SAL_CALL dispose( ) override; + void SAL_CALL disposing( const css::lang::EventObject& Source ) override { UnoControlBase::disposing( Source ); } + + // css::awt::XControl + sal_Bool SAL_CALL isTransparent( ) override; + + // css::awt::XButton + void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL setActionCommand( const OUString& Command ) override; + + virtual void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + virtual void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + + + sal_Int16 SAL_CALL getState( ) override; + void SAL_CALL setState( sal_Int16 n ) override; + void SAL_CALL setLabel( const OUString& Label ) override; + void SAL_CALL enableTriState( sal_Bool b ) override; + + // css::awt::XItemListener + void SAL_CALL itemStateChanged( const css::awt::ItemEvent& rEvent ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoControlFixedHyperlinkModel final : public UnoControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlFixedHyperlinkModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlFixedHyperlinkModel( const UnoControlFixedHyperlinkModel& rModel ) : UnoControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlFixedHyperlinkModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::lang::XServiceInfo + DECLIMPL_SERVICEINFO_DERIVED( UnoControlFixedHyperlinkModel, UnoControlModel, "com.sun.star.awt.UnoControlFixedHyperlinkModel" ) +}; + + + +class UnoFixedHyperlinkControl final : public UnoControlBase, + public css::awt::XFixedHyperlink, + public css::awt::XLayoutConstrains +{ +private: + ActionListenerMultiplexer maActionListeners; + +public: + UnoFixedHyperlinkControl(); + + OUString GetComponentServiceName() const override; + + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return UnoControlBase::queryInterface(rType); } + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakAggObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakAggObject::release(); } + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + void SAL_CALL dispose( ) override; + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XControl + sal_Bool SAL_CALL isTransparent( ) override; + + // css::awt::XFixedHyperlink + void SAL_CALL setText( const OUString& Text ) override; + OUString SAL_CALL getText( ) override; + void SAL_CALL setURL( const OUString& URL ) override; + OUString SAL_CALL getURL( ) override; + void SAL_CALL setAlignment( sal_Int16 nAlign ) override; + sal_Int16 SAL_CALL getAlignment( ) override; + void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; + + // css::lang::XServiceInfo + DECLIMPL_SERVICEINFO_DERIVED( UnoFixedHyperlinkControl, UnoControlBase, "com.sun.star.awt.UnoControlFixedHyperlink" ) +}; + + + +class UnoControlFixedTextModel final : public UnoControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlFixedTextModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlFixedTextModel( const UnoControlFixedTextModel& rModel ) : UnoControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlFixedTextModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoFixedTextControl final : public UnoControlBase, + public css::awt::XFixedText, + public css::awt::XLayoutConstrains +{ +public: + UnoFixedTextControl(); + OUString GetComponentServiceName() const override; + + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return UnoControlBase::queryInterface(rType); } + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakAggObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakAggObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XControl + sal_Bool SAL_CALL isTransparent( ) override; + + // css::awt::XFixedText + void SAL_CALL setText( const OUString& Text ) override; + OUString SAL_CALL getText( ) override; + void SAL_CALL setAlignment( sal_Int16 nAlign ) override; + sal_Int16 SAL_CALL getAlignment( ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoControlGroupBoxModel final : public UnoControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlGroupBoxModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlGroupBoxModel( const UnoControlGroupBoxModel& rModel ) : UnoControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlGroupBoxModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoGroupBoxControl final : public UnoControlBase +{ +public: + UnoGroupBoxControl(); + OUString GetComponentServiceName() const override; + + sal_Bool SAL_CALL isTransparent( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +struct UnoControlListBoxModel_Data; +typedef ::cppu::AggImplInheritanceHelper1 < UnoControlModel + , css::awt::XItemList + > UnoControlListBoxModel_Base; +class UnoControlListBoxModel : public UnoControlListBoxModel_Base +{ +protected: + enum ConstructorMode + { + ConstructDefault, + ConstructWithoutProperties + }; + +public: + UnoControlListBoxModel( + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + ConstructorMode const i_mode = ConstructDefault + ); + UnoControlListBoxModel( const UnoControlListBoxModel& i_rSource ); + virtual ~UnoControlListBoxModel() override; + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlListBoxModel( *this ); } + + virtual void ImplNormalizePropertySequence( + const sal_Int32 _nCount, /// the number of entries in the arrays + sal_Int32* _pHandles, /// the handles of the properties to set + css::uno::Any* _pValues, /// the values of the properties to set + sal_Int32* _pValidHandles /// pointer to the valid handles, allowed to be adjusted + ) const override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName( ) override; + css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // css::awt::XItemList + virtual ::sal_Int32 SAL_CALL getItemCount() override; + virtual void SAL_CALL insertItem( ::sal_Int32 Position, const OUString& ItemText, const OUString& ItemImageURL ) override; + virtual void SAL_CALL insertItemText( ::sal_Int32 Position, const OUString& ItemText ) override; + virtual void SAL_CALL insertItemImage( ::sal_Int32 Position, const OUString& ItemImageURL ) override; + virtual void SAL_CALL removeItem( ::sal_Int32 Position ) override; + virtual void SAL_CALL removeAllItems( ) override; + virtual void SAL_CALL setItemText( ::sal_Int32 Position, const OUString& ItemText ) override; + virtual void SAL_CALL setItemImage( ::sal_Int32 Position, const OUString& ItemImageURL ) override; + virtual void SAL_CALL setItemTextAndImage( ::sal_Int32 Position, const OUString& ItemText, const OUString& ItemImageURL ) override; + virtual void SAL_CALL setItemData( ::sal_Int32 Position, const css::uno::Any& DataValue ) override; + virtual OUString SAL_CALL getItemText( ::sal_Int32 Position ) override; + virtual OUString SAL_CALL getItemImage( ::sal_Int32 Position ) override; + virtual css::beans::Pair< OUString, OUString > SAL_CALL getItemTextAndImage( ::sal_Int32 Position ) override; + virtual css::uno::Any SAL_CALL getItemData( ::sal_Int32 Position ) override; + virtual css::uno::Sequence< css::beans::Pair< OUString, OUString > > SAL_CALL getAllItems( ) override; + virtual void SAL_CALL addItemListListener( const css::uno::Reference< css::awt::XItemListListener >& Listener ) override; + virtual void SAL_CALL removeItemListListener( const css::uno::Reference< css::awt::XItemListListener >& Listener ) override; + + // OPropertySetHelper + void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override; + +protected: + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +private: + void impl_notifyItemListEvent_nolck( + const sal_Int32 i_nItemPosition, + const ::std::optional< OUString >& i_rItemText, + const ::std::optional< OUString >& i_rItemImageURL, + void ( SAL_CALL css::awt::XItemListListener::*NotificationMethod )( const css::awt::ItemListEvent& ) + ); + + void impl_handleInsert( + const sal_Int32 i_nItemPosition, + const ::std::optional< OUString >& i_rItemText, + const ::std::optional< OUString >& i_rItemImageURL, + ::osl::ClearableMutexGuard& i_rClearBeforeNotify + ); + + void impl_handleRemove( + const sal_Int32 i_nItemPosition, + ::osl::ClearableMutexGuard& i_rClearBeforeNotify + ); + + void impl_handleModify( + const sal_Int32 i_nItemPosition, + const ::std::optional< OUString >& i_rItemText, + const ::std::optional< OUString >& i_rItemImageURL, + ::osl::ClearableMutexGuard& i_rClearBeforeNotify + ); + + void impl_getStringItemList( ::std::vector< OUString >& o_rStringItems ) const; + void impl_setStringItemList_nolck( const ::std::vector< OUString >& i_rStringItems ); + +protected: + std::unique_ptr<UnoControlListBoxModel_Data> m_xData; + ::comphelper::OInterfaceContainerHelper3<css::awt::XItemListListener> m_aItemListListeners; +}; + + + +typedef ::cppu::AggImplInheritanceHelper5 < UnoControlBase + , css::awt::XListBox + , css::awt::XItemListener + , css::awt::XLayoutConstrains + , css::awt::XTextLayoutConstrains + , css::awt::XItemListListener + > UnoListBoxControl_Base; +class UnoListBoxControl final : public UnoListBoxControl_Base +{ +public: + UnoListBoxControl(); + OUString GetComponentServiceName() const override; + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + void SAL_CALL dispose( ) override; + void SAL_CALL disposing( const css::lang::EventObject& Source ) override { UnoControlBase::disposing( Source ); } + + // css::awt::XListBox + void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL addItem( const OUString& aItem, sal_Int16 nPos ) override; + void SAL_CALL addItems( const css::uno::Sequence< OUString >& aItems, sal_Int16 nPos ) override; + void SAL_CALL removeItems( sal_Int16 nPos, sal_Int16 nCount ) override; + sal_Int16 SAL_CALL getItemCount( ) override; + OUString SAL_CALL getItem( sal_Int16 nPos ) override; + css::uno::Sequence< OUString > SAL_CALL getItems( ) override; + sal_Int16 SAL_CALL getSelectedItemPos( ) override; + css::uno::Sequence< sal_Int16 > SAL_CALL getSelectedItemsPos( ) override; + OUString SAL_CALL getSelectedItem( ) override; + css::uno::Sequence< OUString > SAL_CALL getSelectedItems( ) override; + void SAL_CALL selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) override; + void SAL_CALL selectItemsPos( const css::uno::Sequence< sal_Int16 >& aPositions, sal_Bool bSelect ) override; + void SAL_CALL selectItem( const OUString& aItem, sal_Bool bSelect ) override; + sal_Bool SAL_CALL isMutipleMode( ) override; + void SAL_CALL setMultipleMode( sal_Bool bMulti ) override; + sal_Int16 SAL_CALL getDropDownLineCount( ) override; + void SAL_CALL setDropDownLineCount( sal_Int16 nLines ) override; + void SAL_CALL makeVisible( sal_Int16 nEntry ) override; + + // css::awt::XItemListener + void SAL_CALL itemStateChanged( const css::awt::ItemEvent& rEvent ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; + + // css::awt::XTextLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) override; + void SAL_CALL getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) override; + + // XUnoControl + sal_Bool SAL_CALL setModel(const css::uno::Reference< css::awt::XControlModel >& Model) override; + + // XItemListListener + virtual void SAL_CALL listItemInserted( const css::awt::ItemListEvent& Event ) override; + virtual void SAL_CALL listItemRemoved( const css::awt::ItemListEvent& Event ) override; + virtual void SAL_CALL listItemModified( const css::awt::ItemListEvent& Event ) override; + virtual void SAL_CALL allItemsRemoved( const css::lang::EventObject& Event ) override; + virtual void SAL_CALL itemListChanged( const css::lang::EventObject& Event ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName( ) override; + css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + +private: + void ImplUpdateSelectedItemsProperty(); + virtual void ImplSetPeerProperty( const OUString& rPropName, const css::uno::Any& rVal ) override; + virtual void updateFromModel() override; + + ActionListenerMultiplexer maActionListeners; + ItemListenerMultiplexer maItemListeners; +}; + + + +class UnoControlComboBoxModel final : public UnoControlListBoxModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlComboBoxModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlComboBoxModel( const UnoControlComboBoxModel& rModel ) : UnoControlListBoxModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlComboBoxModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + // OPropertySetHelper + void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName( ) override; + css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + +}; + + + +class UnoComboBoxControl final : public UnoEditControl + , public css::awt::XComboBox + , public css::awt::XItemListener + , public css::awt::XItemListListener +{ +private: + ActionListenerMultiplexer maActionListeners; + ItemListenerMultiplexer maItemListeners; + +public: + + UnoComboBoxControl(); + OUString GetComponentServiceName() const override; + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + void SAL_CALL disposing( const css::lang::EventObject& Source ) override { UnoEditControl::disposing( Source ); } + void SAL_CALL dispose( ) override; + + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return UnoEditControl::queryInterface(rType); } + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakAggObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakAggObject::release(); } + + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XComboBox + void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + void SAL_CALL addItem( const OUString& aItem, sal_Int16 nPos ) override; + void SAL_CALL addItems( const css::uno::Sequence< OUString >& aItems, sal_Int16 nPos ) override; + void SAL_CALL removeItems( sal_Int16 nPos, sal_Int16 nCount ) override; + sal_Int16 SAL_CALL getItemCount( ) override; + OUString SAL_CALL getItem( sal_Int16 nPos ) override; + css::uno::Sequence< OUString > SAL_CALL getItems( ) override; + sal_Int16 SAL_CALL getDropDownLineCount( ) override; + void SAL_CALL setDropDownLineCount( sal_Int16 nLines ) override; + + // XUnoControl + virtual sal_Bool SAL_CALL setModel(const css::uno::Reference< css::awt::XControlModel >& Model) override; + + // XItemListListener + virtual void SAL_CALL listItemInserted( const css::awt::ItemListEvent& Event ) override; + virtual void SAL_CALL listItemRemoved( const css::awt::ItemListEvent& Event ) override; + virtual void SAL_CALL listItemModified( const css::awt::ItemListEvent& Event ) override; + virtual void SAL_CALL allItemsRemoved( const css::lang::EventObject& Event ) override; + virtual void SAL_CALL itemListChanged( const css::lang::EventObject& Event ) override; + + // XItemListener + virtual void SAL_CALL itemStateChanged( const css::awt::ItemEvent& rEvent ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName( ) override; + css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; +private: + virtual void ImplSetPeerProperty( const OUString& rPropName, const css::uno::Any& rVal ) override; + virtual void updateFromModel() override; + +}; + + + +class UnoSpinFieldControl : public UnoEditControl, + public css::awt::XSpinField +{ +private: + SpinListenerMultiplexer maSpinListeners; + bool mbRepeat; + +public: + UnoSpinFieldControl(); + + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return UnoEditControl::queryInterface(rType); } + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakAggObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakAggObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + + // css::awt::XSpinField + void SAL_CALL addSpinListener( const css::uno::Reference< css::awt::XSpinListener >& l ) override; + void SAL_CALL removeSpinListener( const css::uno::Reference< css::awt::XSpinListener >& l ) override; + void SAL_CALL up() override; + void SAL_CALL down() override; + void SAL_CALL first() override; + void SAL_CALL last() override; + void SAL_CALL enableRepeat( sal_Bool bRepeat ) override; + + + // css::lang::XServiceInfo + // No service info, only base class for other fields. +}; + + + +class UnoControlDateFieldModel final : public UnoControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlDateFieldModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlDateFieldModel( const UnoControlDateFieldModel& rModel ) : UnoControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlDateFieldModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoDateFieldControl final : public UnoSpinFieldControl, + public css::awt::XDateField +{ +private: + css::util::Date mnFirst; + css::util::Date mnLast; + TriState mbLongFormat; +public: + UnoDateFieldControl(); + OUString GetComponentServiceName() const override; + + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return UnoSpinFieldControl::queryInterface(rType); } + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakAggObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakAggObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + + // css::awt::XTextListener + void SAL_CALL textChanged( const css::awt::TextEvent& rEvent ) override; + + //XDateField + void SAL_CALL setDate( const css::util::Date& Date ) override; + css::util::Date SAL_CALL getDate( ) override; + void SAL_CALL setMin( const css::util::Date& Date ) override; + css::util::Date SAL_CALL getMin( ) override; + void SAL_CALL setMax( const css::util::Date& Date ) override; + css::util::Date SAL_CALL getMax( ) override; + void SAL_CALL setFirst( const css::util::Date& Date ) override; + css::util::Date SAL_CALL getFirst( ) override; + void SAL_CALL setLast( const css::util::Date& Date ) override; + css::util::Date SAL_CALL getLast( ) override; + void SAL_CALL setLongFormat( sal_Bool bLong ) override; + sal_Bool SAL_CALL isLongFormat( ) override; + void SAL_CALL setEmpty( ) override; + sal_Bool SAL_CALL isEmpty( ) override; + void SAL_CALL setStrictFormat( sal_Bool bStrict ) override; + sal_Bool SAL_CALL isStrictFormat( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoControlTimeFieldModel final : public UnoControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlTimeFieldModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlTimeFieldModel( const UnoControlTimeFieldModel& rModel ) : UnoControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlTimeFieldModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoTimeFieldControl final : public UnoSpinFieldControl, + public css::awt::XTimeField +{ +private: + css::util::Time mnFirst; + css::util::Time mnLast; + +public: + UnoTimeFieldControl(); + OUString GetComponentServiceName() const override; + + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return UnoSpinFieldControl::queryInterface(rType); } + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakAggObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakAggObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + + // css::awt::XTextListener + void SAL_CALL textChanged( const css::awt::TextEvent& rEvent ) override; + + //XTimeField + void SAL_CALL setTime( const css::util::Time& Time ) override; + css::util::Time SAL_CALL getTime( ) override; + void SAL_CALL setMin( const css::util::Time& Time ) override; + css::util::Time SAL_CALL getMin( ) override; + void SAL_CALL setMax( const css::util::Time& Time ) override; + css::util::Time SAL_CALL getMax( ) override; + void SAL_CALL setFirst( const css::util::Time& Time ) override; + css::util::Time SAL_CALL getFirst( ) override; + void SAL_CALL setLast( const css::util::Time& Time ) override; + css::util::Time SAL_CALL getLast( ) override; + void SAL_CALL setEmpty( ) override; + sal_Bool SAL_CALL isEmpty( ) override; + void SAL_CALL setStrictFormat( sal_Bool bStrict ) override; + sal_Bool SAL_CALL isStrictFormat( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoControlNumericFieldModel final : public UnoControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlNumericFieldModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlNumericFieldModel( const UnoControlNumericFieldModel& rModel ) : UnoControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlNumericFieldModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoNumericFieldControl final : public UnoSpinFieldControl, + public css::awt::XNumericField +{ +private: + double mnFirst; + double mnLast; + +public: + UnoNumericFieldControl(); + OUString GetComponentServiceName() const override; + + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return UnoSpinFieldControl::queryInterface(rType); } + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakAggObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakAggObject::release(); } + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XTextListener + void SAL_CALL textChanged( const css::awt::TextEvent& rEvent ) override; + + // css::awt::XNumericField + void SAL_CALL setValue( double Value ) override; + double SAL_CALL getValue( ) override; + void SAL_CALL setMin( double Value ) override; + double SAL_CALL getMin( ) override; + void SAL_CALL setMax( double Value ) override; + double SAL_CALL getMax( ) override; + void SAL_CALL setFirst( double Value ) override; + double SAL_CALL getFirst( ) override; + void SAL_CALL setLast( double Value ) override; + double SAL_CALL getLast( ) override; + void SAL_CALL setSpinSize( double Value ) override; + double SAL_CALL getSpinSize( ) override; + void SAL_CALL setDecimalDigits( sal_Int16 nDigits ) override; + sal_Int16 SAL_CALL getDecimalDigits( ) override; + void SAL_CALL setStrictFormat( sal_Bool bStrict ) override; + sal_Bool SAL_CALL isStrictFormat( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoControlCurrencyFieldModel final : public UnoControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlCurrencyFieldModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlCurrencyFieldModel( const UnoControlCurrencyFieldModel& rModel ) : UnoControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlCurrencyFieldModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoCurrencyFieldControl final : public UnoSpinFieldControl, + public css::awt::XCurrencyField +{ +private: + double mnFirst; + double mnLast; + +public: + UnoCurrencyFieldControl(); + OUString GetComponentServiceName() const override; + + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return UnoSpinFieldControl::queryInterface(rType); } + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakAggObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakAggObject::release(); } + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XTextListener + void SAL_CALL textChanged( const css::awt::TextEvent& rEvent ) override; + + // css::awt::XCurrencyField + void SAL_CALL setValue( double Value ) override; + double SAL_CALL getValue( ) override; + void SAL_CALL setMin( double Value ) override; + double SAL_CALL getMin( ) override; + void SAL_CALL setMax( double Value ) override; + double SAL_CALL getMax( ) override; + void SAL_CALL setFirst( double Value ) override; + double SAL_CALL getFirst( ) override; + void SAL_CALL setLast( double Value ) override; + double SAL_CALL getLast( ) override; + void SAL_CALL setSpinSize( double Value ) override; + double SAL_CALL getSpinSize( ) override; + void SAL_CALL setDecimalDigits( sal_Int16 nDigits ) override; + sal_Int16 SAL_CALL getDecimalDigits( ) override; + void SAL_CALL setStrictFormat( sal_Bool bStrict ) override; + sal_Bool SAL_CALL isStrictFormat( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoControlPatternFieldModel final : public UnoControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlPatternFieldModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlPatternFieldModel( const UnoControlPatternFieldModel& rModel ) : UnoControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlPatternFieldModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoPatternFieldControl final : public UnoSpinFieldControl, + public css::awt::XPatternField +{ + void ImplSetPeerProperty( const OUString& rPropName, const css::uno::Any& rVal ) override; + +public: + UnoPatternFieldControl(); + OUString GetComponentServiceName() const override; + + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return UnoSpinFieldControl::queryInterface(rType); } + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakAggObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakAggObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XPatternField + void SAL_CALL setMasks( const OUString& EditMask, const OUString& LiteralMask ) override; + void SAL_CALL getMasks( OUString& EditMask, OUString& LiteralMask ) override; + void SAL_CALL setString( const OUString& Str ) override; + OUString SAL_CALL getString( ) override; + void SAL_CALL setStrictFormat( sal_Bool bStrict ) override; + sal_Bool SAL_CALL isStrictFormat( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoControlProgressBarModel final : public UnoControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlProgressBarModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlProgressBarModel( const UnoControlProgressBarModel& rModel ) : UnoControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlProgressBarModel( *this ); } + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoProgressBarControl final : public UnoControlBase, + public css::awt::XProgressBar +{ +public: + UnoProgressBarControl(); + OUString GetComponentServiceName() const override; + + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return UnoControlBase::queryInterface(rType); } + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakAggObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakAggObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XProgressBar + void SAL_CALL setForegroundColor( sal_Int32 nColor ) override; + void SAL_CALL setBackgroundColor( sal_Int32 nColor ) override; + void SAL_CALL setValue( sal_Int32 nValue ) override; + void SAL_CALL setRange( sal_Int32 nMin, sal_Int32 nMax ) override; + sal_Int32 SAL_CALL getValue() override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoControlFixedLineModel final : public UnoControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlFixedLineModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlFixedLineModel( const UnoControlFixedLineModel& rModel ) : UnoControlModel( rModel ) {} + + rtl::Reference<UnoControlModel> Clone() const override { return new UnoControlFixedLineModel( *this ); } + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + + +class UnoFixedLineControl final : public UnoControlBase +{ +public: + UnoFixedLineControl(); + OUString GetComponentServiceName() const override; + + sal_Bool SAL_CALL isTransparent( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + + +#endif // INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/dllapi.h b/include/toolkit/dllapi.h new file mode 100644 index 000000000..3b61a68c5 --- /dev/null +++ b/include/toolkit/dllapi.h @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_DLLAPI_H +#define INCLUDED_TOOLKIT_DLLAPI_H + +#include <sal/config.h> +#include <sal/types.h> + +#if defined TOOLKIT_DLLIMPLEMENTATION +#define TOOLKIT_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define TOOLKIT_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/helper/accessiblefactory.hxx b/include/toolkit/helper/accessiblefactory.hxx new file mode 100644 index 000000000..bd7ae9097 --- /dev/null +++ b/include/toolkit/helper/accessiblefactory.hxx @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_HELPER_ACCESSIBLEFACTORY_HXX +#define INCLUDED_TOOLKIT_HELPER_ACCESSIBLEFACTORY_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <salhelper/simplereferenceobject.hxx> + +namespace com::sun::star::accessibility { + class XAccessible; + class XAccessibleContext; +} +class SVTXNumericField; +class VCLXButton; +class VCLXCheckBox; +class VCLXRadioButton; +class VCLXListBox; +class VCLXFixedHyperlink; +class VCLXFixedText; +class VCLXScrollBar; +class VCLXEdit; +class VCLXComboBox; +class VCLXToolBox; +class VCLXHeaderBar; +class VCLXWindow; +class Menu; + + +namespace toolkit +{ + + + /** a function which is able to create a factory for the standard Accessible/Context + components needed for standard toolkit controls + + The returned pointer denotes an instance of the IAccessibleFactory, which has been acquired + <em>once</em>. The caller is responsible for holding this reference as long as it needs the + factory, and release it afterwards. + */ + typedef void* (* GetStandardAccComponentFactory)( ); + + + //= IAccessibleFactory + + class IAccessibleFactory : public virtual salhelper::SimpleReferenceObject + { + public: + /** creates an accessible context for a button window + */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXButton* _pXWindow ) = 0; + + /** creates an accessible context for a checkbox window + */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXCheckBox* _pXWindow ) = 0; + + /** creates an accessible context for a radio button window + */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXRadioButton* _pXWindow ) = 0; + + /** creates an accessible context for a listbox window + */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXListBox* _pXWindow ) = 0; + + /** creates an accessible context for a fixed hyperlink window + */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXFixedHyperlink* _pXWindow ) = 0; + + /** creates an accessible context for a fixed text window + */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXFixedText* _pXWindow ) = 0; + + /** creates an accessible context for a scrollbar window + */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXScrollBar* _pXWindow ) = 0; + + /** creates an accessible context for an edit window + */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXEdit* _pXWindow ) = 0; + + /** creates an accessible context for a combo box window + */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXComboBox* _pXWindow ) = 0; + + /** creates an accessible context for a toolbox window + */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXToolBox* _pXWindow ) = 0; + + /** creates an accessible context for a headerbar window + */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXHeaderBar* _pXWindow ) = 0; + + /** creates an accessible context for a numeric field + */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( SVTXNumericField* _pXWindow ) = 0; + + /** creates an accessible context for a generic window + */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXWindow* _pXWindow ) = 0; + + /** creates an accessible component for the given menu + */ + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessible( Menu* _pMenu, bool _bIsMenuBar ) = 0; + + protected: + virtual ~IAccessibleFactory() override {} + }; + + +} // namespace toolkit + + +#endif // INCLUDED_TOOLKIT_HELPER_ACCESSIBLEFACTORY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/helper/convert.hxx b/include/toolkit/helper/convert.hxx new file mode 100644 index 000000000..3e4d23696 --- /dev/null +++ b/include/toolkit/helper/convert.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_HELPER_CONVERT_HXX +#define INCLUDED_TOOLKIT_HELPER_CONVERT_HXX + +#include <com/sun/star/awt/Rectangle.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/awt/Point.hpp> + +#include <tools/gen.hxx> + +inline css::awt::Size AWTSize( const Size& rVCLSize ) +{ + return css::awt::Size( rVCLSize.Width(), rVCLSize.Height() ); +} + +inline ::Size VCLSize( const css::awt::Size& rAWTSize ) +{ + return ::Size( rAWTSize.Width, rAWTSize.Height ); +} + +inline css::awt::Point AWTPoint( const ::Point& rVCLPoint ) +{ + return css::awt::Point( rVCLPoint.X(), rVCLPoint.Y() ); +} + +inline ::Point VCLPoint( const css::awt::Point& rAWTPoint ) +{ + return ::Point( rAWTPoint.X, rAWTPoint.Y ); +} + +inline css::awt::Rectangle AWTRectangle( const ::tools::Rectangle& rVCLRect ) +{ + return css::awt::Rectangle( rVCLRect.Left(), rVCLRect.Top(), rVCLRect.GetWidth(), rVCLRect.GetHeight() ); +} + +inline ::tools::Rectangle VCLRectangle( const css::awt::Rectangle& rAWTRect ) +{ + return ::tools::Rectangle( ::Point( rAWTRect.X, rAWTRect.Y ), ::Size( rAWTRect.Width, rAWTRect.Height ) ); +} + +#endif // INCLUDED_TOOLKIT_HELPER_CONVERT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/helper/emptyfontdescriptor.hxx b/include/toolkit/helper/emptyfontdescriptor.hxx new file mode 100644 index 000000000..77ac9a1d1 --- /dev/null +++ b/include/toolkit/helper/emptyfontdescriptor.hxx @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#pragma once + +#include <com/sun/star/awt/FontDescriptor.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <com/sun/star/awt/FontUnderline.hpp> +#include <com/sun/star/awt/FontStrikeout.hpp> + +class EmptyFontDescriptor : public css::awt::FontDescriptor +{ +public: + EmptyFontDescriptor() + { + // Not all enums are initialized correctly in FontDescriptor-CTOR because + // they are set to the first enum value, this is not always the default value. + Slant = css::awt::FontSlant_DONTKNOW; + Underline = css::awt::FontUnderline::DONTKNOW; + Strikeout = css::awt::FontStrikeout::DONTKNOW; + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/helper/formpdfexport.hxx b/include/toolkit/helper/formpdfexport.hxx new file mode 100644 index 000000000..d1aa35ebf --- /dev/null +++ b/include/toolkit/helper/formpdfexport.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_HELPER_FORMPDFEXPORT_HXX +#define INCLUDED_TOOLKIT_HELPER_FORMPDFEXPORT_HXX + +#include <toolkit/dllapi.h> + +#include <vcl/pdfwriter.hxx> + +#include <memory> + +namespace com::sun::star::awt { class XControl; } +namespace com::sun::star::uno { template <class interface_type> class Reference; } + +namespace vcl +{ + class PDFExtOutDevData; +} + + +namespace toolkitform +{ + + + /** creates a PDF compatible control descriptor for the given control + */ + std::unique_ptr<vcl::PDFWriter::AnyWidget> TOOLKIT_DLLPUBLIC describePDFControl( + const css::uno::Reference< css::awt::XControl >& _rxControl, + vcl::PDFExtOutDevData& i_pdfExportData + ); + + +} // namespace toolkitform + + +#endif // INCLUDED_TOOLKIT_HELPER_FORMPDFEXPORT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/helper/listenermultiplexer.hxx b/include/toolkit/helper/listenermultiplexer.hxx new file mode 100644 index 000000000..b562e9e28 --- /dev/null +++ b/include/toolkit/helper/listenermultiplexer.hxx @@ -0,0 +1,273 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_HELPER_LISTENERMULTIPLEXER_HXX +#define INCLUDED_TOOLKIT_HELPER_LISTENERMULTIPLEXER_HXX + +#include <config_options.h> +#include <toolkit/dllapi.h> +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/awt/XFocusListener.hpp> +#include <com/sun/star/awt/XWindowListener.hpp> +#include <com/sun/star/awt/XVclContainerListener.hpp> +#include <com/sun/star/awt/XKeyListener.hpp> +#include <com/sun/star/awt/XMouseListener.hpp> +#include <com/sun/star/awt/XMouseMotionListener.hpp> +#include <com/sun/star/awt/XPaintListener.hpp> +#include <com/sun/star/awt/XTopWindowListener.hpp> +#include <com/sun/star/awt/XTextListener.hpp> +#include <com/sun/star/awt/XActionListener.hpp> +#include <com/sun/star/awt/XItemListener.hpp> +#include <com/sun/star/awt/XTabListener.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/awt/XSpinListener.hpp> +#include <com/sun/star/awt/XAdjustmentListener.hpp> +#include <com/sun/star/awt/XMenuListener.hpp> +#include <com/sun/star/awt/tree/XTreeExpansionListener.hpp> +#include <com/sun/star/awt/tree/XTreeEditListener.hpp> +#include <com/sun/star/view/XSelectionChangeListener.hpp> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/queryinterface.hxx> +#include <cppuhelper/weak.hxx> +#include <comphelper/interfacecontainer3.hxx> +#include <toolkit/helper/macros.hxx> +#include <com/sun/star/awt/grid/XGridSelectionListener.hpp> +#include <com/sun/star/awt/tab/XTabPageContainerListener.hpp> + +// class ListenerMultiplexerBase + +template <class ListenerT> +class UNLESS_MERGELIBS(TOOLKIT_DLLPUBLIC) ListenerMultiplexerBase : public cppu::BaseMutex, + public ::comphelper::OInterfaceContainerHelper3<ListenerT>, + public css::uno::XInterface +{ +private: + ::cppu::OWeakObject& mrContext; + +protected: + ::cppu::OWeakObject& GetContext() { return mrContext; } + +public: + ListenerMultiplexerBase( ::cppu::OWeakObject& rSource ) + : ::comphelper::OInterfaceContainerHelper3<ListenerT>(m_aMutex), mrContext(rSource) + { + } + + virtual ~ListenerMultiplexerBase() + { + } + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface(const css::uno::Type & rType) override + { + return ::cppu::queryInterface(rType, static_cast<css::uno::XInterface*>(this)); + } + + void SAL_CALL acquire() noexcept override { mrContext.acquire(); } + void SAL_CALL release() noexcept override { mrContext.release(); } +}; + +// class EventListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START( EventListenerMultiplexer, css::lang::XEventListener ) +DECL_LISTENERMULTIPLEXER_END + + +// class FocusListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START_DLLPUB( FocusListenerMultiplexer, css::awt::XFocusListener ) + void SAL_CALL focusGained( const css::awt::FocusEvent& e ) override; + void SAL_CALL focusLost( const css::awt::FocusEvent& e ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class WindowListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START_DLLPUB( WindowListenerMultiplexer, css::awt::XWindowListener ) + void SAL_CALL windowResized( const css::awt::WindowEvent& e ) override; + void SAL_CALL windowMoved( const css::awt::WindowEvent& e ) override; + void SAL_CALL windowShown( const css::lang::EventObject& e ) override; + void SAL_CALL windowHidden( const css::lang::EventObject& e ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class VclContainerListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START( VclContainerListenerMultiplexer, css::awt::XVclContainerListener ) + void SAL_CALL windowAdded( const css::awt::VclContainerEvent& e ) override; + void SAL_CALL windowRemoved( const css::awt::VclContainerEvent& e ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class KeyListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START_DLLPUB( KeyListenerMultiplexer, css::awt::XKeyListener ) + void SAL_CALL keyPressed( const css::awt::KeyEvent& e ) override; + void SAL_CALL keyReleased( const css::awt::KeyEvent& e ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class MouseListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START_DLLPUB( MouseListenerMultiplexer, css::awt::XMouseListener ) + void SAL_CALL mousePressed( const css::awt::MouseEvent& e ) override; + void SAL_CALL mouseReleased( const css::awt::MouseEvent& e ) override; + void SAL_CALL mouseEntered( const css::awt::MouseEvent& e ) override; + void SAL_CALL mouseExited( const css::awt::MouseEvent& e ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class MouseMotionListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START_DLLPUB( MouseMotionListenerMultiplexer, css::awt::XMouseMotionListener ) + void SAL_CALL mouseDragged( const css::awt::MouseEvent& e ) override; + void SAL_CALL mouseMoved( const css::awt::MouseEvent& e ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class PaintListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START_DLLPUB( PaintListenerMultiplexer, css::awt::XPaintListener ) + void SAL_CALL windowPaint( const css::awt::PaintEvent& e ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class TopWindowListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START( TopWindowListenerMultiplexer, css::awt::XTopWindowListener ) + void SAL_CALL windowOpened( const css::lang::EventObject& e ) override; + void SAL_CALL windowClosing( const css::lang::EventObject& e ) override; + void SAL_CALL windowClosed( const css::lang::EventObject& e ) override; + void SAL_CALL windowMinimized( const css::lang::EventObject& e ) override; + void SAL_CALL windowNormalized( const css::lang::EventObject& e ) override; + void SAL_CALL windowActivated( const css::lang::EventObject& e ) override; + void SAL_CALL windowDeactivated( const css::lang::EventObject& e ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class TextListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START_DLLPUB( TextListenerMultiplexer, css::awt::XTextListener ) + void SAL_CALL textChanged( const css::awt::TextEvent& rEvent ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class ActionListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START( ActionListenerMultiplexer, css::awt::XActionListener ) + void SAL_CALL actionPerformed( const css::awt::ActionEvent& rEvent ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class ItemListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START( ItemListenerMultiplexer, css::awt::XItemListener ) + void SAL_CALL itemStateChanged( const css::awt::ItemEvent& rEvent ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class TabListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START( TabListenerMultiplexer, css::awt::XTabListener ) + void SAL_CALL inserted( ::sal_Int32 ID ) override; + void SAL_CALL removed( ::sal_Int32 ID ) override; + void SAL_CALL changed( ::sal_Int32 ID, const css::uno::Sequence< css::beans::NamedValue >& Properties ) override; + void SAL_CALL activated( ::sal_Int32 ID ) override; + void SAL_CALL deactivated( ::sal_Int32 ID ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class ContainerListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START( ContainerListenerMultiplexer, css::container::XContainerListener ) + void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override; + void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override; + void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class SpinListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START_DLLPUB( SpinListenerMultiplexer, css::awt::XSpinListener ) + void SAL_CALL up( const css::awt::SpinEvent& rEvent ) override; + void SAL_CALL down( const css::awt::SpinEvent& rEvent ) override; + void SAL_CALL first( const css::awt::SpinEvent& rEvent ) override; + void SAL_CALL last( const css::awt::SpinEvent& rEvent ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class AdjustmentListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START( AdjustmentListenerMultiplexer, css::awt::XAdjustmentListener ) + void SAL_CALL adjustmentValueChanged( const css::awt::AdjustmentEvent& rEvent ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class MenuListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START( MenuListenerMultiplexer, css::awt::XMenuListener ) + void SAL_CALL itemHighlighted( const css::awt::MenuEvent& rEvent ) override; + void SAL_CALL itemSelected( const css::awt::MenuEvent& rEvent ) override; + void SAL_CALL itemActivated( const css::awt::MenuEvent& rEvent ) override; + void SAL_CALL itemDeactivated( const css::awt::MenuEvent& rEvent ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class TreeSelectionListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START( TreeSelectionListenerMultiplexer, css::view::XSelectionChangeListener ) + virtual void SAL_CALL selectionChanged( const css::lang::EventObject& aEvent ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class TreeExpansionListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START( TreeExpansionListenerMultiplexer, css::awt::tree::XTreeExpansionListener ) + virtual void SAL_CALL requestChildNodes( const css::awt::tree::TreeExpansionEvent& aEvent ) override; + virtual void SAL_CALL treeExpanding( const css::awt::tree::TreeExpansionEvent& aEvent ) override; + virtual void SAL_CALL treeCollapsing( const css::awt::tree::TreeExpansionEvent& aEvent ) override; + virtual void SAL_CALL treeExpanded( const css::awt::tree::TreeExpansionEvent& aEvent ) override; + virtual void SAL_CALL treeCollapsed( const css::awt::tree::TreeExpansionEvent& aEvent ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class TreeEditListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START( TreeEditListenerMultiplexer, css::awt::tree::XTreeEditListener ) + virtual void SAL_CALL nodeEditing( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) override; + virtual void SAL_CALL nodeEdited( const css::uno::Reference< css::awt::tree::XTreeNode >& Node, const OUString& NewText ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class SelectionListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START_DLLPUB( SelectionListenerMultiplexer, css::awt::grid::XGridSelectionListener ) + void SAL_CALL selectionChanged( const css::awt::grid::GridSelectionEvent& aEvent ) override; +DECL_LISTENERMULTIPLEXER_END + + +// class TabPageListenerMultiplexer + +DECL_LISTENERMULTIPLEXER_START( TabPageListenerMultiplexer, css::awt::tab::XTabPageContainerListener ) + void SAL_CALL tabPageActivated( const css::awt::tab::TabPageActivatedEvent& aEvent ) override; +DECL_LISTENERMULTIPLEXER_END + +#endif // INCLUDED_TOOLKIT_HELPER_LISTENERMULTIPLEXER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/helper/macros.hxx b/include/toolkit/helper/macros.hxx new file mode 100644 index 000000000..225178c71 --- /dev/null +++ b/include/toolkit/helper/macros.hxx @@ -0,0 +1,156 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_HELPER_MACROS_HXX +#define INCLUDED_TOOLKIT_HELPER_MACROS_HXX + +#include <sal/log.hxx> +#include <osl/diagnose.h> +#include <tools/diagnose_ex.h> + +#define IMPL_IMPLEMENTATION_ID( ClassName ) \ +css::uno::Sequence< sal_Int8 > ClassName::getImplementationId() \ +{ \ + return css::uno::Sequence<sal_Int8>(); \ +} + + +#define DECL_LISTENERMULTIPLEXER_START( ClassName, InterfaceName ) \ +class ClassName final : public ListenerMultiplexerBase<InterfaceName>, public InterfaceName \ +{ \ +public: \ + ClassName( ::cppu::OWeakObject& rSource ); \ + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; \ + void SAL_CALL acquire() noexcept override; \ + void SAL_CALL release() noexcept override; \ + void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + +#define DECL_LISTENERMULTIPLEXER_START_DLLPUB( ClassName, InterfaceName ) \ +class TOOLKIT_DLLPUBLIC ClassName final : public ListenerMultiplexerBase<InterfaceName>, public InterfaceName \ +{ \ +public: \ + ClassName( ::cppu::OWeakObject& rSource ); \ + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; \ + void SAL_CALL acquire() noexcept override; \ + void SAL_CALL release() noexcept override; \ + void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + +#define DECL_LISTENERMULTIPLEXER_END \ +}; + + +#define IMPL_LISTENERMULTIPLEXER_BASEMETHODS( ClassName, InterfaceName ) \ +ClassName::ClassName( ::cppu::OWeakObject& rSource ) \ + : ListenerMultiplexerBase<InterfaceName>(rSource) \ +{ \ +} \ +void SAL_CALL ClassName::acquire() noexcept { ListenerMultiplexerBase::acquire(); } \ +void SAL_CALL ClassName::release() noexcept { ListenerMultiplexerBase::release(); } \ +css::uno::Any ClassName::queryInterface( const css::uno::Type & rType ) \ +{ \ + css::uno::Any aRet = ::cppu::queryInterface( rType, \ + (static_cast< css::lang::XEventListener* >(this)), \ + (static_cast< InterfaceName* >(this)) ); \ + return (aRet.hasValue() ? aRet : ListenerMultiplexerBase::queryInterface( rType )); \ +} \ +void ClassName::disposing( const css::lang::EventObject& ) \ +{ \ +} + + +#if OSL_DEBUG_LEVEL > 0 + #define DISPLAY_EXCEPTION( ClassName, MethodName ) \ + css::uno::Any ex( cppu::getCaughtException() ); \ + SAL_WARN( "toolkit", #ClassName "::" #MethodName ": caught an exception! " << exceptionToString(ex)); +#else + #define DISPLAY_EXCEPTION( ClassName, MethodName ) +#endif + +#define IMPL_TABLISTENERMULTIPLEXER_LISTENERMETHOD_BODY_1PARAM( ClassName, InterfaceName, MethodName, ParamType1 ) \ +{ \ + ParamType1 aMulti( evt ); \ + ::comphelper::OInterfaceIteratorHelper3 aIt(*this); \ + while( aIt.hasMoreElements() ) \ + { \ + css::uno::Reference<InterfaceName> xListener(aIt.next()); \ + try \ + { \ + xListener->MethodName( aMulti ); \ + } \ + catch(const css::lang::DisposedException& e) \ + { \ + OSL_ENSURE( e.Context.is(), "caught DisposedException with empty Context field" ); \ + if ( e.Context == xListener || !e.Context.is() ) \ + aIt.remove(); \ + } \ + catch(const css::uno::RuntimeException&) \ + { \ + DISPLAY_EXCEPTION( ClassName, MethodName ) \ + } \ + } \ +} + +#define IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD_BODY( ClassName, InterfaceName, MethodName, EventType ) \ +{ \ + EventType aMulti( evt ); \ + aMulti.Source = &GetContext(); \ + ::comphelper::OInterfaceIteratorHelper3 aIt(*this); \ + while( aIt.hasMoreElements() ) \ + { \ + css::uno::Reference<InterfaceName> xListener(aIt.next()); \ + try \ + { \ + xListener->MethodName( aMulti ); \ + } \ + catch(const css::lang::DisposedException& e) \ + { \ + OSL_ENSURE( e.Context.is(), "caught DisposedException with empty Context field" ); \ + if ( e.Context == xListener || !e.Context.is() ) \ + aIt.remove(); \ + } \ + catch(const css::uno::RuntimeException&) \ + { \ + DISPLAY_EXCEPTION( ClassName, MethodName ) \ + } \ + } \ +} + +#define IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD_EXCEPTION( ClassName, InterfaceName, MethodName, EventType, Exception ) \ +void ClassName::MethodName( const EventType& evt ) \ +IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD_BODY( ClassName, InterfaceName, MethodName, EventType ) + +#define IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( ClassName, InterfaceName, MethodName, EventType ) \ +void ClassName::MethodName( const EventType& evt ) \ +IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD_BODY( ClassName, InterfaceName, MethodName, EventType ) + +#define DECLIMPL_SERVICEINFO_DERIVED( ImplName, BaseClass, ServiceName ) \ + OUString SAL_CALL getImplementationName( ) override { return "stardiv.Toolkit." #ImplName; } \ + css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override \ + { \ + css::uno::Sequence< OUString > aNames = BaseClass::getSupportedServiceNames( ); \ + aNames.realloc( aNames.getLength() + 1 ); \ + aNames.getArray()[ aNames.getLength() - 1 ] = ServiceName; \ + return aNames; \ + } \ + +#endif // INCLUDED_TOOLKIT_HELPER_MACROS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/helper/mutexandbroadcasthelper.hxx b/include/toolkit/helper/mutexandbroadcasthelper.hxx new file mode 100644 index 000000000..4cc98e6a9 --- /dev/null +++ b/include/toolkit/helper/mutexandbroadcasthelper.hxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_HELPER_MUTEXANDBROADCASTHELPER_HXX +#define INCLUDED_TOOLKIT_HELPER_MUTEXANDBROADCASTHELPER_HXX + +#include <cppuhelper/interfacecontainer.h> + + +// Helper class with Mutex and BroadcastHelper, because they must be +// initialized before calling the OPropertySetHelper-CTOR + +class MutexAndBroadcastHelper +{ +public: + MutexAndBroadcastHelper() : BrdcstHelper( Mutex ) {} + + ::osl::Mutex Mutex; + ::cppu::OBroadcastHelper BrdcstHelper; + + ::osl::Mutex& GetMutex() { return Mutex; } + ::cppu::OBroadcastHelper& GetBroadcastHelper() { return BrdcstHelper; } +}; + +#endif // _TOOLKIT_HELPER_MUTEXANDBROADCASTHELPER_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/helper/property.hxx b/include/toolkit/helper/property.hxx new file mode 100644 index 000000000..4a8fe2385 --- /dev/null +++ b/include/toolkit/helper/property.hxx @@ -0,0 +1,247 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_HELPER_PROPERTY_HXX +#define INCLUDED_TOOLKIT_HELPER_PROPERTY_HXX + +#include <toolkit/dllapi.h> + +#include <sal/types.h> +#include <rtl/ustring.hxx> + +namespace com::sun::star::uno { + class Type; + class Any; +} + + +#define BASEPROPERTY_NOTFOUND 0 + +#define BASEPROPERTY_TEXT 1 // OUString +#define BASEPROPERTY_BACKGROUNDCOLOR 2 // sal_Int32 +#define BASEPROPERTY_FILLCOLOR 3 // sal_Int32 +#define BASEPROPERTY_TEXTCOLOR 4 // sal_Int32 +#define BASEPROPERTY_LINECOLOR 5 // sal_Int32 +#define BASEPROPERTY_BORDER 6 // sal_Int16 +#define BASEPROPERTY_ALIGN 7 // sal_Int16 +#define BASEPROPERTY_FONTDESCRIPTOR 8 // css::awt::FontDescriptor +#define BASEPROPERTY_DROPDOWN 9 // sal_Bool +#define BASEPROPERTY_MULTILINE 10 // sal_Bool +#define BASEPROPERTY_STRINGITEMLIST 11 // UStringSequence +#define BASEPROPERTY_HSCROLL 12 // sal_Bool +#define BASEPROPERTY_VSCROLL 13 // sal_Bool +#define BASEPROPERTY_TABSTOP 14 // sal_Bool +#define BASEPROPERTY_STATE 15 // sal_Int16 +#define BASEPROPERTY_FONT_TYPE 16 // OLD: Font_Type +#define BASEPROPERTY_FONT_SIZE 17 // OLD: Font_Size +#define BASEPROPERTY_FONT_ATTRIBS 18 // OLD: Font_Attribs +#define BASEPROPERTY_DEFAULTCONTROL 19 // OUString (ServiceName) +#define BASEPROPERTY_LABEL 20 // OUString +#define BASEPROPERTY_LINECOUNT 21 // sal_Int16 +#define BASEPROPERTY_EXTDATEFORMAT 22 // sal_Int16 +#define BASEPROPERTY_DATESHOWCENTURY 23 // sal_Bool +#define BASEPROPERTY_EXTTIMEFORMAT 24 // sal_Int16 +#define BASEPROPERTY_NUMSHOWTHOUSANDSEP 25 // sal_Bool +#define BASEPROPERTY_CURRENCYSYMBOL 26 // OUString +#define BASEPROPERTY_SPIN 27 // sal_Bool +#define BASEPROPERTY_STRICTFORMAT 28 // sal_Bool +#define BASEPROPERTY_DECIMALACCURACY 29 // sal_Int16 +#define BASEPROPERTY_DATE 30 // css::util::Date +#define BASEPROPERTY_DATEMIN 31 // css::util::Date +#define BASEPROPERTY_DATEMAX 32 // css::util::Date +#define BASEPROPERTY_TIME 33 // css::util::Time +#define BASEPROPERTY_TIMEMIN 34 // css::util::Time +#define BASEPROPERTY_TIMEMAX 35 // css::util::Time +#define BASEPROPERTY_VALUE_INT32 36 // sal_Int32 +#define BASEPROPERTY_VALUEMIN_INT32 37 // sal_Int32 +#define BASEPROPERTY_VALUEMAX_INT32 38 // sal_Int32 +#define BASEPROPERTY_VALUESTEP_INT32 39 // sal_Int32 +#define BASEPROPERTY_EDITMASK 40 // OUString +#define BASEPROPERTY_LITERALMASK 41 // OUString +#define BASEPROPERTY_IMAGEURL 42 // OUString +#define BASEPROPERTY_READONLY 43 // sal_Bool +#define BASEPROPERTY_ENABLED 44 // sal_Bool +#define BASEPROPERTY_PRINTABLE 45 // sal_Bool +#define BASEPROPERTY_ECHOCHAR 46 // sal_Int16 +#define BASEPROPERTY_MAXTEXTLEN 47 // sal_Int16 +#define BASEPROPERTY_HARDLINEBREAKS 48 // sal_Int16 +#define BASEPROPERTY_AUTOCOMPLETE 49 // sal_Bool +#define BASEPROPERTY_MULTISELECTION 50 // sal_Bool +#define BASEPROPERTY_SELECTEDITEMS 51 // INT16Sequence +#define BASEPROPERTY_VALUE_DOUBLE 52 // DOUBLE +#define BASEPROPERTY_VALUEMIN_DOUBLE 53 // DOUBLE +#define BASEPROPERTY_VALUEMAX_DOUBLE 54 // DOUBLE +#define BASEPROPERTY_VALUESTEP_DOUBLE 55 // DOUBLE +#define BASEPROPERTY_TRISTATE 56 // sal_Bool +#define BASEPROPERTY_DEFAULTBUTTON 57 // sal_Bool +#define BASEPROPERTY_HELPURL 58 // OUString +#define BASEPROPERTY_AUTOTOGGLE 59 // sal_Bool +//#define BASEPROPERTY_FOCUSSELECTIONHIDE 60 // sal_Bool +#define BASEPROPERTY_FORMATKEY 61 // sal_Bool +#define BASEPROPERTY_FORMATSSUPPLIER 62 // css::util::XNumberFormatsSupplier +#define BASEPROPERTY_EFFECTIVE_VALUE 63 // Any (double or string) +#define BASEPROPERTY_TREATASNUMBER 64 // sal_Bool +#define BASEPROPERTY_EFFECTIVE_DEFAULT 65 // Any (double or string) +#define BASEPROPERTY_EFFECTIVE_MIN 66 // Double +#define BASEPROPERTY_EFFECTIVE_MAX 67 // Double +#define BASEPROPERTY_CURSYM_POSITION 68 // sal_Bool +#define BASEPROPERTY_TITLE 69 // OUString +#define BASEPROPERTY_MOVEABLE 70 // sal_Bool +#define BASEPROPERTY_CLOSEABLE 71 // sal_Bool +#define BASEPROPERTY_SIZEABLE 72 // sal_Bool +#define BASEPROPERTY_HELPTEXT 73 // OUString +#define BASEPROPERTY_PROGRESSVALUE 74 // sal_Int32 +#define BASEPROPERTY_PROGRESSVALUE_MIN 75 // sal_Int32 +#define BASEPROPERTY_PROGRESSVALUE_MAX 76 // sal_Int32 +#define BASEPROPERTY_SCROLLVALUE 77 // sal_Int32 +#define BASEPROPERTY_SCROLLVALUE_MAX 78 // sal_Int32 +#define BASEPROPERTY_LINEINCREMENT 79 // sal_Int32 +#define BASEPROPERTY_BLOCKINCREMENT 80 // sal_Int32 +#define BASEPROPERTY_VISIBLESIZE 81 // sal_Int32 +#define BASEPROPERTY_ORIENTATION 82 // sal_Int32 +#define BASEPROPERTY_FONTRELIEF 83 // sal_Int16 +#define BASEPROPERTY_FONTEMPHASISMARK 84 // sal_Int16 +#define BASEPROPERTY_TEXTLINECOLOR 85 // sal_Int32 +#define BASEPROPERTY_IMAGEALIGN 86 // sal_Int16 +#define BASEPROPERTY_SCALEIMAGE 87 // sal_Bool +#define BASEPROPERTY_PUSHBUTTONTYPE 88 // sal_Int16 +#define BASEPROPERTY_DISPLAYBACKGROUNDCOLOR 89 // sal_Int32 +#define BASEPROPERTY_AUTOMNEMONICS 90 // sal_Bool +#define BASEPROPERTY_MOUSETRANSPARENT 91 // sal_Bool +#define BASEPROPERTY_ACCESSIBLENAME 92 // OUString +#define BASEPROPERTY_PLUGINPARENT 93 // sal_Int64 +#define BASEPROPERTY_SCROLLVALUE_MIN 94 // sal_Int32 +#define BASEPROPERTY_REPEAT_DELAY 95 // sal_Int32 +#define BASEPROPERTY_SYMBOL_COLOR 96 // sal_Int32 +#define BASEPROPERTY_SPINVALUE 97 // sal_Int32 +#define BASEPROPERTY_SPINVALUE_MIN 98 // sal_Int32 +#define BASEPROPERTY_SPINVALUE_MAX 99 // sal_Int32 +#define BASEPROPERTY_SPININCREMENT 100 // sal_Int32 +#define BASEPROPERTY_REPEAT 101 // sal_Bool +#define BASEPROPERTY_ENFORCE_FORMAT 102 // sal_Bool +#define BASEPROPERTY_LIVE_SCROLL 103 // sal_Bool +#define BASEPROPERTY_LINE_END_FORMAT 104 // sal_Int16 +#define BASEPROPERTY_ACTIVATED 105 // sal Bool +#define BASEPROPERTY_COMPLETE 106 // sal_Bool +#define BASEPROPERTY_CURRENTITEMID 107 // sal_Int16 +#define BASEPROPERTY_TOGGLE 108 // sal_Bool +#define BASEPROPERTY_FOCUSONCLICK 109 // sal_Bool +#define BASEPROPERTY_HIDEINACTIVESELECTION 110 // sal_Bool +#define BASEPROPERTY_VISUALEFFECT 111 // sal_Int16 +#define BASEPROPERTY_BORDERCOLOR 112 // sal_Int32 +#define BASEPROPERTY_IMAGEPOSITION 113 // sal_Int16 +#define BASEPROPERTY_NATIVE_WIDGET_LOOK 114 // sal_Bool +#define BASEPROPERTY_VERTICALALIGN 115 // VerticalAlignment +#define BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR 116 // sal_Int16 +#define BASEPROPERTY_GRAPHIC 117 // css.graphic.XGraphic +#define BASEPROPERTY_STEP_TIME 118 // sal_Int32 +#define BASEPROPERTY_DECORATION 119 // sal_Bool +#define BASEPROPERTY_PAINTTRANSPARENT 120 // sal_Bool +#define BASEPROPERTY_AUTOHSCROLL 121 // sal_Bool +#define BASEPROPERTY_AUTOVSCROLL 122 // sal_Bool +#define BASEPROPERTY_DESKTOP_AS_PARENT 123 // sal_Bool +#define BASEPROPERTY_TREE_START 124 +#define BASEPROPERTY_TREE_SELECTIONTYPE 124 +#define BASEPROPERTY_TREE_EDITABLE 125 +#define BASEPROPERTY_TREE_DATAMODEL 126 +#define BASEPROPERTY_TREE_ROOTDISPLAYED 127 +#define BASEPROPERTY_TREE_SHOWSHANDLES 128 +#define BASEPROPERTY_TREE_SHOWSROOTHANDLES 129 +#define BASEPROPERTY_ROW_HEIGHT 130 +#define BASEPROPERTY_TREE_INVOKESSTOPNODEEDITING 131 +#define BASEPROPERTY_TREE_END 131 +#define BASEPROPERTY_DIALOGSOURCEURL 132 +#define BASEPROPERTY_NOLABEL 133 // OUString added for issue79712 +#define BASEPROPERTY_URL 134 // OUString +#define BASEPROPERTY_UNIT 135 // ::awt::FieldUnit +#define BASEPROPERTY_CUSTOMUNITTEXT 136 // OUString +#define BASEPROPERTY_IMAGE_SCALE_MODE 137 +#define BASEPROPERTY_WRITING_MODE 138 +#define BASEPROPERTY_CONTEXT_WRITING_MODE 139 +#define BASEPROPERTY_GRID_SHOWROWHEADER 140 +#define BASEPROPERTY_GRID_SHOWCOLUMNHEADER 141 +#define BASEPROPERTY_GRID_DATAMODEL 142 +#define BASEPROPERTY_GRID_COLUMNMODEL 143 +#define BASEPROPERTY_GRID_SELECTIONMODE 144 +#define BASEPROPERTY_ENABLEVISIBLE 145 // sal_Bool +#define BASEPROPERTY_REFERENCE_DEVICE 146 + +#define BASEPROPERTY_HIGHCONTRASTMODE 147 +#define BASEPROPERTY_GRID_HEADER_BACKGROUND 148 +#define BASEPROPERTY_GRID_HEADER_TEXT_COLOR 149 +#define BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS 150 +#define BASEPROPERTY_GRID_LINE_COLOR 151 +#define BASEPROPERTY_MULTISELECTION_SIMPLEMODE 152 +#define BASEPROPERTY_ITEM_SEPARATOR_POS 153 +#define BASEPROPERTY_GROUPNAME 154 // OUString +#define BASEPROPERTY_MULTIPAGEVALUE 155 // sal_Int32 +#define BASEPROPERTY_USERFORMCONTAINEES 156 // css::container::XNameContainer +#define BASEPROPERTY_AUTO_REPEAT 157 +#define BASEPROPERTY_ROW_HEADER_WIDTH 158 +#define BASEPROPERTY_COLUMN_HEADER_HEIGHT 159 +#define BASEPROPERTY_USE_GRID_LINES 160 +#define BASEPROPERTY_SCROLLWIDTH 161 +#define BASEPROPERTY_SCROLLHEIGHT 162 +#define BASEPROPERTY_SCROLLTOP 163 +#define BASEPROPERTY_SCROLLLEFT 164 +#define BASEPROPERTY_ACTIVE_SEL_BACKGROUND_COLOR 165 +#define BASEPROPERTY_INACTIVE_SEL_BACKGROUND_COLOR 166 +#define BASEPROPERTY_ACTIVE_SEL_TEXT_COLOR 167 +#define BASEPROPERTY_INACTIVE_SEL_TEXT_COLOR 168 +#define BASEPROPERTY_TYPEDITEMLIST 169 // AnySequence + + +// These properties are not bound, they are always extracted from the BASEPROPERTY_FONTDESCRIPTOR property +#define BASEPROPERTY_FONTDESCRIPTORPART_START 1000 +#define BASEPROPERTY_FONTDESCRIPTORPART_NAME 1000 // OUString, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_STYLENAME 1001 // OUString, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_FAMILY 1002 // sal_Int16, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_CHARSET 1003 // sal_Int16, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_HEIGHT 1004 // sal_Int16, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_WEIGHT 1005 // Float, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_SLANT 1006 // sal_Int16, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_UNDERLINE 1007 // sal_Int16, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_STRIKEOUT 1008 // sal_Int16, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_WIDTH 1009 // sal_Int16, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_PITCH 1010 // sal_Int16, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_CHARWIDTH 1011 // Float, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_ORIENTATION 1012 // Float, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_KERNING 1013 // sal_Bool, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_WORDLINEMODE 1014 // sal_Bool, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_TYPE 1015 // sal_Int16, not bound +#define BASEPROPERTY_FONTDESCRIPTORPART_END 1015 + +#define PROPERTY_ALIGN_LEFT 0 +#define PROPERTY_ALIGN_CENTER 1 +#define PROPERTY_ALIGN_RIGHT 2 + + +TOOLKIT_DLLPUBLIC sal_uInt16 GetPropertyId( const OUString& rPropertyName ); +const css::uno::Type* GetPropertyType( sal_uInt16 nPropertyId ); +const OUString& GetPropertyName( sal_uInt16 nPropertyId ); +sal_Int16 GetPropertyAttribs( sal_uInt16 nPropertyId ); +sal_uInt16 GetPropertyOrderNr( sal_uInt16 nPropertyId ); +bool DoesDependOnOthers( sal_uInt16 nPropertyId ); +bool CompareProperties( const css::uno::Any& r1, const css::uno::Any& r2 ); + + +#endif // INCLUDED_TOOLKIT_HELPER_PROPERTY_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/helper/vclunohelper.hxx b/include/toolkit/helper/vclunohelper.hxx new file mode 100644 index 000000000..6066a8b72 --- /dev/null +++ b/include/toolkit/helper/vclunohelper.hxx @@ -0,0 +1,157 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_TOOLKIT_HELPER_VCLUNOHELPER_HXX +#define INCLUDED_TOOLKIT_HELPER_VCLUNOHELPER_HXX + +#include <toolkit/dllapi.h> +#include <com/sun/star/uno/Reference.h> + +#include <com/sun/star/awt/MouseEvent.hpp> + +#include <vcl/bitmapex.hxx> +#include <vcl/font.hxx> +#include <vcl/region.hxx> +#include <tools/mapunit.hxx> +#include <tools/fldunit.hxx> +#include <tools/poly.hxx> + + +namespace com::sun::star::uno { template <typename > class Sequence; } + +namespace com::sun::star::uno { + class XInterface; +} + +namespace com::sun::star::awt { + class XBitmap; + class XWindow; + class XWindow2; + class XWindowPeer; + class XGraphics; + class XRegion; + class XDevice; + class XToolkit; + class XFont; + class XControlContainer; + struct Size; + struct Point; + struct SimpleFontMetric; + struct FontDescriptor; + struct Rectangle; + struct KeyEvent; +} + + +enum class PointerStyle; + +class FontMetric; +class OutputDevice; +class MouseEvent; +class KeyEvent; + +class TOOLKIT_DLLPUBLIC VCLUnoHelper +{ +public: + // Toolkit + static css::uno::Reference< css::awt::XToolkit> CreateToolkit(); + + // Bitmap + static BitmapEx GetBitmap( const css::uno::Reference< css::awt::XBitmap>& rxBitmap ); + static css::uno::Reference< css::awt::XBitmap> CreateBitmap( const BitmapEx& rBitmap ); + static css::uno::Reference< css::awt::XBitmap> CreateVCLXBitmap( const BitmapEx& rBitmap ); + + // Window + static vcl::Window* GetWindow( const css::uno::Reference< css::awt::XWindow>& rxWindow ); + static vcl::Window* GetWindow( const css::uno::Reference< css::awt::XWindow2>& rxWindow2 ); + static vcl::Window* GetWindow( const css::uno::Reference< css::awt::XWindowPeer>& rxWindowPeer ); + static css::uno::Reference< css::awt::XWindow> GetInterface( vcl::Window* pWindow ); + + // OutputDevice + static OutputDevice* GetOutputDevice( const css::uno::Reference< css::awt::XDevice>& rxDevice ); + static OutputDevice* GetOutputDevice( const css::uno::Reference< css::awt::XGraphics>& rxGraphics ); + + // Region + static vcl::Region GetRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion ); + + // Polygon + static tools::Polygon CreatePolygon( const css::uno::Sequence< sal_Int32 >& DataX, const css::uno::Sequence< sal_Int32 >& DataY ); + + /** convert Font to css::awt::FontDescriptor + @param rFont Font to be converted + @return the new FontDescriptor + */ + static css::awt::FontDescriptor CreateFontDescriptor( const vcl::Font& rFont ); + static vcl::Font CreateFont( const css::awt::FontDescriptor& rDescr, const vcl::Font& rInitFont ); + static vcl::Font CreateFont( const css::uno::Reference< css::awt::XFont >& rxFont ); + static css::awt::SimpleFontMetric CreateFontMetric( const FontMetric& rFontMetric ); + + // Rectangle + static bool IsZero(const css::awt::Rectangle& rRect); + + static css::uno::Reference< css::awt::XControlContainer> CreateControlContainer( vcl::Window* pWindow ); + + // MapUnits + static MapUnit UnoEmbed2VCLMapUnit( sal_Int32 nUnoEmbedMapUnit ); + static sal_Int32 VCL2UnoEmbedMapUnit( MapUnit nVCLMapUnit ); + + + //= MeasurementUnitConversion + + /** small helper to convert between MeasurementUnit and + FieldUnit + */ + static sal_Int16 ConvertToMeasurementUnit( FieldUnit _nFieldUnit, sal_Int16 _rFieldToUNOValueFactor ); + static FieldUnit ConvertToFieldUnit( sal_Int16 _nMeasurementUnit, sal_Int16& _rFieldToUNOValueFactor ); + + /// @throws css::lang::IllegalArgumentException + static MapUnit /* MapModeUnit */ ConvertToMapModeUnit(sal_Int16 /* com.sun.star.util.MeasureUnit.* */ _nMeasureUnit); + + static ::Size /* VCLSize */ ConvertToVCLSize(css::awt::Size const& _aSize); + static css::awt::Size ConvertToAWTSize(::Size /* VCLSize */ const& _aSize); + + static ::Point /* VCLPoint */ ConvertToVCLPoint(css::awt::Point const& _aPoint); + static css::awt::Point ConvertToAWTPoint(::Point /* VCLPoint */ const& _aPoint); + + static ::tools::Rectangle ConvertToVCLRect( css::awt::Rectangle const & _rRect ); + static css::awt::Rectangle ConvertToAWTRect( ::tools::Rectangle const & _rRect ); + + static css::awt::MouseEvent + createMouseEvent( + const ::MouseEvent& _rVclEvent, + const css::uno::Reference< css::uno::XInterface >& _rxContext + ); + + static ::MouseEvent createVCLMouseEvent( const css::awt::MouseEvent& _rAwtEvent ); + + static css::awt::KeyEvent + createKeyEvent( + const ::KeyEvent& _rVclEvent, + const css::uno::Reference< css::uno::XInterface >& _rxContext + ); + + static ::KeyEvent createVCLKeyEvent( const css::awt::KeyEvent& _rAwtEvent ); + + static ::PointerStyle getMousePointer(const css::uno::Reference<css::awt::XWindowPeer>& rWindowPeer); + static void setMousePointer(const css::uno::Reference<css::awt::XWindowPeer>& rWindowPeer, ::PointerStyle mousepointer); +}; + +#endif // INCLUDED_TOOLKIT_HELPER_VCLUNOHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |