diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
commit | 267c6f2ac71f92999e969232431ba04678e7437e (patch) | |
tree | 358c9467650e1d0a1d7227a21dac2e3d08b622b2 /UnoControls/inc | |
parent | Initial commit. (diff) | |
download | libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip |
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'UnoControls/inc')
-rw-r--r-- | UnoControls/inc/basecontainercontrol.hxx | 148 | ||||
-rw-r--r-- | UnoControls/inc/basecontrol.hxx | 312 | ||||
-rw-r--r-- | UnoControls/inc/multiplexer.hxx | 233 |
3 files changed, 693 insertions, 0 deletions
diff --git a/UnoControls/inc/basecontainercontrol.hxx b/UnoControls/inc/basecontainercontrol.hxx new file mode 100644 index 0000000000..18e027cc43 --- /dev/null +++ b/UnoControls/inc/basecontainercontrol.hxx @@ -0,0 +1,148 @@ +/* -*- 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 <vector> + +#include "basecontrol.hxx" +#include <com/sun/star/awt/XControlContainer.hpp> +#include <comphelper/multicontainer2.hxx> + +namespace unocontrols { + +struct IMPL_ControlInfo +{ + css::uno::Reference< css::awt::XControl > xControl; + OUString sName; +}; + +class BaseContainerControl : public css::awt::XControlModel + , public css::awt::XControlContainer + , public BaseControl +{ +public: + + BaseContainerControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + + virtual ~BaseContainerControl() override; + + // XInterface + + /** + @short give answer, if interface is supported + @descr The interfaces are searched by type. + + @seealso XInterface + + @param "rType" is the type of searched interface. + + @return Any information about found interface + + @onerror A RuntimeException is thrown. + */ + + virtual css::uno::Any SAL_CALL queryInterface( + const css::uno::Type& aType + ) override; + + // XTypeProvider + + /** + @short get information about supported interfaces + @seealso XTypeProvider + @return Sequence of types of all supported interfaces + + @onerror A RuntimeException is thrown. + */ + + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + + // XControl + + virtual void SAL_CALL createPeer( + const css::uno::Reference< css::awt::XToolkit >& xToolkit , + const css::uno::Reference< css::awt::XWindowPeer >& xParent + ) override; + + virtual sal_Bool SAL_CALL setModel( + const css::uno::Reference< css::awt::XControlModel >& xModel + ) override; + + virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override; + + // XComponent + + virtual void SAL_CALL dispose() override; + + // XEventListener + + virtual void SAL_CALL disposing( const css::lang::EventObject& rEvent ) override; + + // XControlContainer + + virtual void SAL_CALL addControl( + const OUString& sName , + const css::uno::Reference< css::awt::XControl >& xControl + ) override; + + virtual void SAL_CALL removeControl( + const css::uno::Reference< css::awt::XControl >& xControl + ) override; + + virtual void SAL_CALL setStatusText( + const OUString& sStatusText + ) override; + + virtual css::uno::Reference< css::awt::XControl > SAL_CALL getControl( + const OUString& sName + ) override; + + virtual css::uno::Sequence< css::uno::Reference< css::awt::XControl > > SAL_CALL getControls() override; + + // XWindow + + virtual void SAL_CALL setVisible( sal_Bool bVisible ) override; + +protected: + using WeakComponentImplHelper::disposing; + + virtual css::awt::WindowDescriptor impl_getWindowDescriptor( + const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer + ) override; + + + virtual void impl_paint( + sal_Int32 nX , + sal_Int32 nY , + const css::uno::Reference< css::awt::XGraphics >& xGraphics + ) override; + +private: + // list of pointer of "struct IMPL_ControlInfo" to hold child-controls + ::std::vector< IMPL_ControlInfo > maControlInfoList; + + comphelper::OMultiTypeInterfaceContainerHelper2 m_aListeners; + +}; + +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/inc/basecontrol.hxx b/UnoControls/inc/basecontrol.hxx new file mode 100644 index 0000000000..9f60537bb7 --- /dev/null +++ b/UnoControls/inc/basecontrol.hxx @@ -0,0 +1,312 @@ +/* -*- 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/XPaintListener.hpp> +#include <com/sun/star/awt/XWindowListener.hpp> +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/awt/XView.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include <rtl/ref.hxx> + +namespace com::sun::star::uno { class XComponentContext; } +namespace com::sun::star::awt { class XFocusListener; } +namespace com::sun::star::awt { class XMouseListener; } +namespace com::sun::star::awt { class XMouseMotionListener; } +namespace com::sun::star::awt { struct PaintEvent; } +namespace com::sun::star::awt { struct WindowEvent; } +namespace unocontrols { class OMRCListenerMultiplexerHelper; } + +namespace unocontrols { + +class BaseControl : public css::lang::XServiceInfo + , public css::awt::XPaintListener + , public css::awt::XWindowListener + , public css::awt::XView + , public css::awt::XWindow + , public css::awt::XControl + , public cppu::BaseMutex + , public ::cppu::WeakComponentImplHelper<> +{ +public: + BaseControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + + virtual ~BaseControl() override; + + // XInterface + + /** + @short give answer, if interface is supported + @descr The interfaces are searched by type. + + @seealso XInterface + + @param "rType" is the type of searched interface. + + @return Any information about found interface + + @onerror A RuntimeException is thrown. + */ + + virtual css::uno::Any SAL_CALL queryInterface( + const css::uno::Type& aType + ) override; + + /** + @short increment refcount + @seealso XInterface + @seealso release() + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL acquire() noexcept override; + + /** + @short decrement refcount + @seealso XInterface + @seealso acquire() + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL release() noexcept override; + + // XTypeProvider + + /** + @short get information about supported interfaces + @seealso XTypeProvider + @return Sequence of types of all supported interfaces + + @onerror A RuntimeException is thrown. + */ + + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + + /** + @short get implementation id + @descr This ID is necessary for UNO-caching. If there no ID, cache is disabled. + Another way, cache is enabled. + + @seealso XTypeProvider + @return ID as Sequence of byte + + @onerror A RuntimeException is thrown. + */ + + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // XServiceInfo + + virtual sal_Bool SAL_CALL supportsService( + const OUString& sServiceName + ) override; + + virtual OUString SAL_CALL getImplementationName() override; + + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XComponent + + virtual void SAL_CALL dispose() override; + + virtual void SAL_CALL addEventListener( + const css::uno::Reference< css::lang::XEventListener >& xListener + ) override; + + virtual void SAL_CALL removeEventListener( + const css::uno::Reference< css::lang::XEventListener >& xListener + ) override; + + // XControl + + virtual void SAL_CALL createPeer( + const css::uno::Reference< css::awt::XToolkit >& xToolkit, + const css::uno::Reference< css::awt::XWindowPeer >& xParent + ) override; + + virtual void SAL_CALL setContext( + const css::uno::Reference< css::uno::XInterface >& xContext + ) override; + + virtual sal_Bool SAL_CALL setModel( + const css::uno::Reference< css::awt::XControlModel >& xModel + ) override = 0; + + virtual void SAL_CALL setDesignMode( sal_Bool bOn ) override; + + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getContext() override; + + virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override = 0; + + virtual css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getPeer() override; + + virtual css::uno::Reference< css::awt::XView > SAL_CALL getView() override; + + virtual sal_Bool SAL_CALL isDesignMode() override; + + virtual sal_Bool SAL_CALL isTransparent() override; + + // XWindow + + virtual void SAL_CALL setPosSize( sal_Int32 nX , + sal_Int32 nY , + sal_Int32 nWidth , + sal_Int32 nHeight , + sal_Int16 nFlags ) override; + + virtual void SAL_CALL setVisible( sal_Bool bVisible ) override; + + virtual void SAL_CALL setEnable( sal_Bool bEnable ) override; + + virtual void SAL_CALL setFocus() override; + + virtual css::awt::Rectangle SAL_CALL getPosSize() override; + + virtual void SAL_CALL addWindowListener( + const css::uno::Reference< css::awt::XWindowListener >& xListener + ) override; + + virtual void SAL_CALL addFocusListener( + const css::uno::Reference< css::awt::XFocusListener >& xListener + ) override; + + virtual void SAL_CALL addKeyListener( + const css::uno::Reference< css::awt::XKeyListener >& xListener ) override; + + virtual void SAL_CALL addMouseListener( + const css::uno::Reference< css::awt::XMouseListener >& xListener + ) override; + + virtual void SAL_CALL addMouseMotionListener( + const css::uno::Reference< css::awt::XMouseMotionListener >& xListener + ) override; + + virtual void SAL_CALL addPaintListener( + const css::uno::Reference< css::awt::XPaintListener >& xListener + ) override; + + virtual void SAL_CALL removeWindowListener( + const css::uno::Reference< css::awt::XWindowListener >& xListener + ) override; + + virtual void SAL_CALL removeFocusListener( + const css::uno::Reference< css::awt::XFocusListener >& xListener + ) override; + + virtual void SAL_CALL removeKeyListener( + const css::uno::Reference< css::awt::XKeyListener >& xListener + ) override; + + virtual void SAL_CALL removeMouseListener( + const css::uno::Reference< css::awt::XMouseListener >& xListener + ) override; + + virtual void SAL_CALL removeMouseMotionListener( + const css::uno::Reference< css::awt::XMouseMotionListener >& xListener + ) override; + + virtual void SAL_CALL removePaintListener( + const css::uno::Reference< css::awt::XPaintListener >& xListener + ) override; + + // XView + + virtual void SAL_CALL draw( sal_Int32 nX , + sal_Int32 nY ) override; + + virtual sal_Bool SAL_CALL setGraphics( + const css::uno::Reference< css::awt::XGraphics >& xDevice + ) override; + + virtual void SAL_CALL setZoom( float fZoomX , + float fZoomY ) override; + + virtual css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics() override; + + virtual css::awt::Size SAL_CALL getSize() override; + + // css::lang::XEventListener + + virtual void SAL_CALL disposing( + const css::lang::EventObject& rSource + ) override; + + // XPaintListener + + virtual void SAL_CALL windowPaint( + const css::awt::PaintEvent& rEvent + ) override; + + // XWindowListener + + virtual void SAL_CALL windowResized( const css::awt::WindowEvent& aEvent ) override; + virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& aEvent ) override; + virtual void SAL_CALL windowShown( const css::lang::EventObject& aEvent ) override; + virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) override; + +protected: + using WeakComponentImplHelper::disposing; + + const css::uno::Reference< css::uno::XComponentContext >& impl_getComponentContext() const { return m_xComponentContext;} + + const css::uno::Reference< css::awt::XWindow >& impl_getPeerWindow() const { return m_xPeerWindow;} + + const css::uno::Reference< css::awt::XGraphics >& impl_getGraphicsPeer() const { return m_xGraphicsPeer;} + + sal_Int32 impl_getWidth() const { return m_nWidth;} + + sal_Int32 impl_getHeight() const { return m_nHeight;} + + virtual css::awt::WindowDescriptor impl_getWindowDescriptor( + const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer + ); + + virtual void impl_paint( sal_Int32 nX , + sal_Int32 nY , + const css::uno::Reference< css::awt::XGraphics >& xGraphics ); + + virtual void impl_recalcLayout( const css::awt::WindowEvent& aEvent ); + +private: + OMRCListenerMultiplexerHelper* impl_getMultiplexer(); + + css::uno::Reference< css::uno::XComponentContext > m_xComponentContext; + rtl::Reference<OMRCListenerMultiplexerHelper> m_xMultiplexer; // multiplex events + css::uno::Reference< css::uno::XInterface > m_xContext; + css::uno::Reference< css::awt::XWindowPeer > m_xPeer; + css::uno::Reference< css::awt::XWindow > m_xPeerWindow; + css::uno::Reference< css::awt::XGraphics > m_xGraphicsView; // graphics for css::awt::XView-operations + css::uno::Reference< css::awt::XGraphics > m_xGraphicsPeer; // graphics for painting on a peer + sal_Int32 m_nX; // Position ... + sal_Int32 m_nY; + sal_Int32 m_nWidth; // ... and size of window + sal_Int32 m_nHeight; + bool m_bVisible; // Some state flags + bool m_bInDesignMode; + bool m_bEnable; +}; + +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/inc/multiplexer.hxx b/UnoControls/inc/multiplexer.hxx new file mode 100644 index 0000000000..58bd1563fb --- /dev/null +++ b/UnoControls/inc/multiplexer.hxx @@ -0,0 +1,233 @@ +/* -*- 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/XKeyListener.hpp> +#include <com/sun/star/awt/XPaintListener.hpp> +#include <com/sun/star/awt/XMouseMotionListener.hpp> +#include <com/sun/star/awt/XWindowListener.hpp> +#include <com/sun/star/awt/XTopWindowListener.hpp> +#include <com/sun/star/awt/XMouseListener.hpp> +#include <com/sun/star/awt/XFocusListener.hpp> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/weakref.hxx> +#include <comphelper/multicontainer2.hxx> + +namespace com::sun::star::awt { class XWindow; } +namespace com::sun::star::awt { struct KeyEvent; } +namespace com::sun::star::awt { struct MouseEvent; } +namespace com::sun::star::awt { struct PaintEvent; } +namespace com::sun::star::awt { struct WindowEvent; } + +namespace unocontrols { + +class OMRCListenerMultiplexerHelper final : public css::awt::XFocusListener + , public css::awt::XWindowListener + , public css::awt::XKeyListener + , public css::awt::XMouseListener + , public css::awt::XMouseMotionListener + , public css::awt::XPaintListener + , public css::awt::XTopWindowListener + , public ::cppu::OWeakObject +{ +public: + + /** + @short constructor + @descr Create a Multiplexer of XWindowEvents. + @param rControl The control. All listeners think that this is the original broadcaster. + @param rPeer The peer from which the original events are dispatched. Null is allowed. + */ + + OMRCListenerMultiplexerHelper( const css::uno::Reference< css::awt::XWindow >& xControl , + const css::uno::Reference< css::awt::XWindow >& xPeer ); + + /** + @short copy-constructor + @descr + @param rCopyInstance C++-Reference to instance to make copy from. + */ + + OMRCListenerMultiplexerHelper( const OMRCListenerMultiplexerHelper& aCopyInstance ); + + virtual ~OMRCListenerMultiplexerHelper() override; + + // XInterface + + /** + @short give answer, if interface is supported + @descr The interfaces are searched by type. + + @seealso XInterface + + @param "rType" is the type of searched interface. + + @return Any information about found interface + + @onerror A RuntimeException is thrown. + */ + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; + + /** + @short increment refcount + @seealso XInterface + @seealso release() + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL acquire() noexcept override; + + /** + @short decrement refcount + @seealso XInterface + @seealso acquire() + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL release() noexcept override; + + OMRCListenerMultiplexerHelper& operator= ( const OMRCListenerMultiplexerHelper& aCopyInstance ); + + // container methods + + /** + @short Remove all listeners from the previous set peer and add the needed listeners to rPeer. + @param rPeer The peer from which the original events are dispatched. Null is allowed. + */ + + void setPeer( const css::uno::Reference< css::awt::XWindow >& xPeer ); + + /** + @short Remove all listeners and send a disposing message. + */ + + void disposeAndClear(); + + /** + @short Add the specified listener to the source. + */ + + void advise( const css::uno::Type& aType , + const css::uno::Reference< css::uno::XInterface >& xListener ); + + /** + @short Remove the specified listener from the source. + */ + + void unadvise( const css::uno::Type& aType , + const css::uno::Reference< css::uno::XInterface >& xListener ); + + // XEventListener + + virtual void SAL_CALL disposing(const css::lang::EventObject& aSource) override; + + // XFocusListener + + virtual void SAL_CALL focusGained(const css::awt::FocusEvent& aEvent ) override; + + virtual void SAL_CALL focusLost(const css::awt::FocusEvent& aEvent ) override; + + // XWindowListener + + virtual void SAL_CALL windowResized(const css::awt::WindowEvent& aEvent ) override; + + virtual void SAL_CALL windowMoved(const css::awt::WindowEvent& aEvent ) override; + + virtual void SAL_CALL windowShown(const css::lang::EventObject& aEvent ) override; + + virtual void SAL_CALL windowHidden(const css::lang::EventObject& aEvent ) override; + + // XKeyListener + + virtual void SAL_CALL keyPressed( const css::awt::KeyEvent& aEvent ) override; + + virtual void SAL_CALL keyReleased( const css::awt::KeyEvent& aEvent ) override; + + // XMouseListener + + virtual void SAL_CALL mousePressed(const css::awt::MouseEvent& aEvent ) override; + + virtual void SAL_CALL mouseReleased(const css::awt::MouseEvent& aEvent ) override; + + virtual void SAL_CALL mouseEntered(const css::awt::MouseEvent& aEvent ) override; + + virtual void SAL_CALL mouseExited(const css::awt::MouseEvent& aEvent ) override; + + // XMouseMotionListener + + virtual void SAL_CALL mouseDragged(const css::awt::MouseEvent& aEvent ) override; + + virtual void SAL_CALL mouseMoved(const css::awt::MouseEvent& aEvent ) override; + + // XPaintListener + + virtual void SAL_CALL windowPaint(const css::awt::PaintEvent& aEvent ) override; + + // XTopWindowListener + + virtual void SAL_CALL windowOpened( const css::lang::EventObject& aEvent ) override; + + virtual void SAL_CALL windowClosing( const css::lang::EventObject& aEvent ) override; + + virtual void SAL_CALL windowClosed( const css::lang::EventObject& aEvent ) override; + + virtual void SAL_CALL windowMinimized( const css::lang::EventObject& aEvent ) override; + + virtual void SAL_CALL windowNormalized( const css::lang::EventObject& aEvent ) override; + + virtual void SAL_CALL windowActivated( const css::lang::EventObject& aEvent ) override; + + virtual void SAL_CALL windowDeactivated( const css::lang::EventObject& aEvent ) override; + +private: + + /** + @short Remove the listener from the peer. + @param xPeer The peer from which the listener is removed. + @param rType The listener type, which specify the type of the listener. + */ + + void impl_adviseToPeer( const css::uno::Reference< css::awt::XWindow >& xPeer , + const css::uno::Type& aType ); + + /** + @short Add the listener to the peer. + @param xPeer The peer to which the listener is added. + @param rType The listener type, which specify the type of the listener. + */ + + void impl_unadviseFromPeer( const css::uno::Reference< css::awt::XWindow >& xPeer , + const css::uno::Type& aType ); + +// private variables + +private: + ::osl::Mutex m_aMutex; + css::uno::Reference< css::awt::XWindow > m_xPeer; /// The source of the events. Normally this is the peer object. + css::uno::WeakReference< css::awt::XWindow > m_xControl; + comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerHolder; + +}; + +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |