diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /UnoControls | |
parent | Initial commit. (diff) | |
download | libreoffice-upstream.tar.xz libreoffice-upstream.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'UnoControls')
24 files changed, 5912 insertions, 0 deletions
diff --git a/UnoControls/IwyuFilter_UnoControls.yaml b/UnoControls/IwyuFilter_UnoControls.yaml new file mode 100644 index 000000000..7f18b3662 --- /dev/null +++ b/UnoControls/IwyuFilter_UnoControls.yaml @@ -0,0 +1,18 @@ +--- +assumeFilename: UnoControls/source/base/basecontrol.cxx +excludelist: + UnoControls/inc/multiplexer.hxx: + # Don't propose hxx -> h change in URE libs + - cppuhelper/interfacecontainer.hxx + UnoControls/source/inc/OConnectionPointContainerHelper.hxx: + # Don't propose hxx -> h change in URE libs + - cppuhelper/interfacecontainer.hxx + UnoControls/source/controls/framecontrol.cxx: + # Needed for use in cppu::UnoType template + - com/sun/star/awt/XControlContainer.hpp + UnoControls/source/controls/progressbar.cxx: + # Actually used + - com/sun/star/awt/XGraphics.hpp + UnoControls/source/controls/progressmonitor.cxx: + # Actually used + - com/sun/star/awt/XGraphics.hpp diff --git a/UnoControls/Library_ctl.mk b/UnoControls/Library_ctl.mk new file mode 100644 index 000000000..e123a4a59 --- /dev/null +++ b/UnoControls/Library_ctl.mk @@ -0,0 +1,42 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_Library_Library,ctl)) + +$(eval $(call gb_Library_set_include,ctl,\ + $$(INCLUDE) \ + -I$(SRCDIR)/UnoControls/inc \ + -I$(SRCDIR)/UnoControls/source/inc \ +)) + +$(eval $(call gb_Library_use_sdk_api,ctl)) + +$(eval $(call gb_Library_use_libraries,ctl,\ + comphelper \ + cppu \ + cppuhelper \ + sal \ + tl \ +)) + +$(eval $(call gb_Library_set_componentfile,ctl,UnoControls/util/ctl,services)) + +$(eval $(call gb_Library_add_exception_objects,ctl,\ + UnoControls/source/base/basecontainercontrol \ + UnoControls/source/base/basecontrol \ + UnoControls/source/base/multiplexer \ + UnoControls/source/controls/OConnectionPointContainerHelper \ + UnoControls/source/controls/OConnectionPointHelper \ + UnoControls/source/controls/framecontrol \ + UnoControls/source/controls/progressbar \ + UnoControls/source/controls/progressmonitor \ + UnoControls/source/controls/statusindicator \ +)) + +# vim:set noet sw=4 ts=4: diff --git a/UnoControls/Makefile b/UnoControls/Makefile new file mode 100644 index 000000000..d22b9aca9 --- /dev/null +++ b/UnoControls/Makefile @@ -0,0 +1,24 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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 . +# + +module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST)))) + +include $(module_directory)/../solenv/gbuild/partial_build.mk + +# vim: set noet sw=4 ts=4: diff --git a/UnoControls/Module_UnoControls.mk b/UnoControls/Module_UnoControls.mk new file mode 100644 index 000000000..ce9fdb380 --- /dev/null +++ b/UnoControls/Module_UnoControls.mk @@ -0,0 +1,16 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_Module_Module,UnoControls)) + +$(eval $(call gb_Module_add_targets,UnoControls,\ + Library_ctl \ +)) + +# vim:set noet sw=4 ts=4: diff --git a/UnoControls/README.md b/UnoControls/README.md new file mode 100644 index 000000000..2a5d79a2e --- /dev/null +++ b/UnoControls/README.md @@ -0,0 +1,3 @@ +# UNO Controls + +Separate process and thread for progress bars, etc. diff --git a/UnoControls/inc/basecontainercontrol.hxx b/UnoControls/inc/basecontainercontrol.hxx new file mode 100644 index 000000000..3d5b08f81 --- /dev/null +++ b/UnoControls/inc/basecontainercontrol.hxx @@ -0,0 +1,154 @@ +/* -*- 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; + + // XAggregation + + virtual css::uno::Any SAL_CALL queryAggregation( + const css::uno::Type& aType + ) 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 OComponentHelper::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 000000000..30f2dd441 --- /dev/null +++ b/UnoControls/inc/basecontrol.hxx @@ -0,0 +1,325 @@ +/* -*- 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/component.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::OComponentHelper +{ +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; + + // XAggregation + + virtual void SAL_CALL setDelegator( + const css::uno::Reference< css::uno::XInterface >& xDelegator + ) override; + + virtual css::uno::Any SAL_CALL queryAggregation( + const css::uno::Type& aType + ) 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 OComponentHelper::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 ); + + const css::uno::Reference< css::uno::XInterface >& impl_getDelegator() const { return m_xDelegator;} + +private: + OMRCListenerMultiplexerHelper* impl_getMultiplexer(); + + css::uno::Reference< css::uno::XComponentContext > m_xComponentContext; + css::uno::Reference< css::uno::XInterface > m_xDelegator; + 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 000000000..58bd1563f --- /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: */ diff --git a/UnoControls/source/base/basecontainercontrol.cxx b/UnoControls/source/base/basecontainercontrol.cxx new file mode 100644 index 000000000..20eea9eb3 --- /dev/null +++ b/UnoControls/source/base/basecontainercontrol.cxx @@ -0,0 +1,387 @@ +/* -*- 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 . + */ + +#include <basecontainercontrol.hxx> + +#include <cppuhelper/queryinterface.hxx> +#include <cppuhelper/typeprovider.hxx> + +#include <com/sun/star/container/ContainerEvent.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/awt/XControlContainer.hpp> + +// namespaces + +using namespace ::cppu; +using namespace ::osl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::container; + +namespace unocontrols { + +// construct/destruct + +BaseContainerControl::BaseContainerControl( const Reference< XComponentContext >& rxContext ) + : BaseControl ( rxContext ) + , m_aListeners ( m_aMutex ) +{ +} + +BaseContainerControl::~BaseContainerControl() +{ +} + +// XInterface + +Any SAL_CALL BaseContainerControl::queryInterface( const Type& rType ) +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + Any aReturn; + Reference< XInterface > xDel = BaseControl::impl_getDelegator(); + if ( xDel.is() ) + { + // If a delegator exists, forward question to its queryInterface. + // Delegator will ask its own queryAggregation! + aReturn = xDel->queryInterface( rType ); + } + else + { + // If a delegator is unknown, forward question to own queryAggregation. + aReturn = queryAggregation( rType ); + } + + return aReturn; +} + +// XTypeProvider + +Sequence< Type > SAL_CALL BaseContainerControl::getTypes() +{ + static OTypeCollection ourTypeCollection( + cppu::UnoType<XControlModel>::get(), + cppu::UnoType<XControlContainer>::get(), + BaseControl::getTypes() ); + + return ourTypeCollection.getTypes(); +} + +// XAggregation + +Any SAL_CALL BaseContainerControl::queryAggregation( const Type& aType ) +{ + // Ask for my own supported interfaces ... + // Attention: XTypeProvider and XInterface are supported by OComponentHelper! + Any aReturn ( ::cppu::queryInterface( aType , + static_cast< XControlModel* > ( this ) , + static_cast< XControlContainer* > ( this ) + ) + ); + + // If searched interface supported by this class ... + if ( aReturn.hasValue() ) + { + // ... return this information. + return aReturn; + } + else + { + // Else; ... ask baseclass for interfaces! + return BaseControl::queryAggregation( aType ); + } +} + +// XControl + +void SAL_CALL BaseContainerControl::createPeer( const Reference< XToolkit >& xToolkit , + const Reference< XWindowPeer >& xParent ) +{ + if ( getPeer().is() ) + return; + + // create own peer + BaseControl::createPeer( xToolkit, xParent ); + + // create peers at all children + Sequence< Reference< XControl > > seqControlList = getControls(); + + for ( auto& rxControl : asNonConstRange(seqControlList) ) + { + rxControl->createPeer( xToolkit, getPeer() ); + } +} + +// XControl + +sal_Bool SAL_CALL BaseContainerControl::setModel( const Reference< XControlModel >& ) +{ + // This object has NO model. + return false; +} + +// XControl + +Reference< XControlModel > SAL_CALL BaseContainerControl::getModel() +{ + // This object has NO model. + // return (XControlModel*)this; + return Reference< XControlModel >(); +} + +// XComponent + +void SAL_CALL BaseContainerControl::dispose() +{ + // Tell everything that this container is now gone. + // It's faster if you listen to both the control and the container. + + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // remove listeners + EventObject aObject; + + aObject.Source.set( static_cast<XControlContainer*>(this), UNO_QUERY ); + m_aListeners.disposeAndClear( aObject ); + + // remove controls + const Sequence< Reference< XControl > > seqCtrls = getControls(); + + maControlInfoList.clear(); + + for ( Reference< XControl > const & control : seqCtrls ) + { + control->removeEventListener ( static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) ) ); + control->dispose ( ); + } + + // call baseclass + BaseControl::dispose(); +} + +// XEventListener + +void SAL_CALL BaseContainerControl::disposing( const EventObject& rEvent ) +{ + Reference< XControl > xControl( rEvent.Source, UNO_QUERY ); + + // "removeControl" remove only, when control is an active control + removeControl( xControl ); +} + +// XControlContainer + +void SAL_CALL BaseContainerControl::addControl ( const OUString& rName, const Reference< XControl > & rControl ) +{ + if ( !rControl.is () ) + return; + + // take memory for new item + IMPL_ControlInfo aNewControl; + + // Ready for multithreading + MutexGuard aGuard (m_aMutex); + + // set control + aNewControl.sName = rName; + aNewControl.xControl = rControl; + + // and insert in list + maControlInfoList.emplace_back( aNewControl ); + + // initialize new control + aNewControl.xControl->setContext ( static_cast<OWeakObject*>(this) ); + aNewControl.xControl->addEventListener ( static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) ) ); + + // when container has a peer... + if (getPeer().is()) + { + // ... then create a peer on child + aNewControl.xControl->createPeer ( getPeer()->getToolkit(), getPeer() ); + } + + // Send message to all listener + comphelper::OInterfaceContainerHelper2* pInterfaceContainer = m_aListeners.getContainer( cppu::UnoType<XContainerListener>::get()); + + if (!pInterfaceContainer) + return; + + // Build event + ContainerEvent aEvent; + + aEvent.Source = *this; + aEvent.Element <<= rControl; + + // Get all listener + comphelper::OInterfaceIteratorHelper2 aIterator (*pInterfaceContainer); + + // Send event + while ( aIterator.hasMoreElements() ) + { + static_cast<XContainerListener*>(aIterator.next())->elementInserted (aEvent); + } +} + +// XControlContainer + +void SAL_CALL BaseContainerControl::removeControl ( const Reference< XControl > & rControl ) +{ + if ( !rControl.is() ) + return; + + // Ready for multithreading + MutexGuard aGuard (m_aMutex); + + size_t nControls = maControlInfoList.size(); + + for ( size_t n = 0; n < nControls; n++ ) + { + // Search for right control + IMPL_ControlInfo* pControl = &maControlInfoList[ n ]; + if ( rControl == pControl->xControl ) + { + //.is it found ... remove listener from control + pControl->xControl->removeEventListener (static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) )); + pControl->xControl->setContext ( Reference< XInterface > () ); + + // ... free memory + maControlInfoList.erase(maControlInfoList.begin() + n); + + // Send message to all other listener + comphelper::OInterfaceContainerHelper2 * pInterfaceContainer = m_aListeners.getContainer( cppu::UnoType<XContainerListener>::get()); + + if (pInterfaceContainer) + { + ContainerEvent aEvent; + + aEvent.Source = *this; + aEvent.Element <<= rControl; + + comphelper::OInterfaceIteratorHelper2 aIterator (*pInterfaceContainer); + + while ( aIterator.hasMoreElements() ) + { + static_cast<XContainerListener*>(aIterator.next())->elementRemoved (aEvent); + } + } + // Break "for" ! + break; + } + } +} + +// XControlContainer + +void SAL_CALL BaseContainerControl::setStatusText ( const OUString& rStatusText ) +{ + // go down to each parent + Reference< XControlContainer > xContainer ( getContext(), UNO_QUERY ); + + if ( xContainer.is () ) + { + xContainer->setStatusText ( rStatusText ); + } +} + +// XControlContainer + +Reference< XControl > SAL_CALL BaseContainerControl::getControl ( const OUString& rName ) +{ + // Ready for multithreading + MutexGuard aGuard ( Mutex::getGlobalMutex() ); + + // Search for right control + for( const IMPL_ControlInfo& rSearchControl : maControlInfoList ) + { + if ( rSearchControl.sName == rName ) + { + // We have found it ... + // Break operation and return. + return rSearchControl.xControl; + } + } + + // We have not found it ... return NULL. + return Reference< XControl > (); +} + +// XControlContainer + +Sequence< Reference< XControl > > SAL_CALL BaseContainerControl::getControls () +{ + // Ready for multithreading + MutexGuard aGuard ( Mutex::getGlobalMutex() ); + + size_t nControls = maControlInfoList.size(); + size_t nCount = 0; + Sequence< Reference< XControl > > aDescriptor ( nControls ); + Reference< XControl > * pDestination = aDescriptor.getArray (); + + // Copy controls to sequence + for( const IMPL_ControlInfo& rCopyControl : maControlInfoList ) + { + pDestination [ nCount++ ] = rCopyControl.xControl; + } + + // Return sequence + return aDescriptor; +} + +// XWindow + +void SAL_CALL BaseContainerControl::setVisible ( sal_Bool bVisible ) +{ + // override baseclass definition + BaseControl::setVisible ( bVisible ); + + // is it a top window ? + if ( !getContext().is() && bVisible ) + { + // then show it automatically + createPeer ( Reference< XToolkit > (), Reference< XWindowPeer > () ); + } +} + +// protected method + +WindowDescriptor BaseContainerControl::impl_getWindowDescriptor ( const Reference< XWindowPeer > & rParentPeer ) +{ + WindowDescriptor aDescriptor; + + aDescriptor.Type = WindowClass_CONTAINER; + aDescriptor.WindowServiceName = "window"; + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = rParentPeer; + aDescriptor.Bounds = getPosSize (); + aDescriptor.WindowAttributes = 0; + + return aDescriptor; +} + +// protected method + +void BaseContainerControl::impl_paint ( sal_Int32 /*nX*/, sal_Int32 /*nY*/, const Reference< XGraphics > & /*rGraphics*/ ) +{ +} + +} // namespace unocontrols + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/base/basecontrol.cxx b/UnoControls/source/base/basecontrol.cxx new file mode 100644 index 000000000..c2e2f23b1 --- /dev/null +++ b/UnoControls/source/base/basecontrol.cxx @@ -0,0 +1,749 @@ +/* -*- 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 . + */ + +#include <basecontrol.hxx> +#include <multiplexer.hxx> + +#include <com/sun/star/awt/XDevice.hpp> +#include <com/sun/star/awt/WindowAttribute.hpp> +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/awt/Toolkit.hpp> +#include <cppuhelper/supportsservice.hxx> +#include <cppuhelper/queryinterface.hxx> +#include <cppuhelper/typeprovider.hxx> + +// namespaces + +using namespace ::cppu; +using namespace ::osl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::awt; + +namespace unocontrols { + +constexpr sal_Int32 DEFAULT_X = 0; +constexpr sal_Int32 DEFAULT_Y = 0; +constexpr sal_Int32 DEFAULT_WIDTH = 100; +constexpr sal_Int32 DEFAULT_HEIGHT = 100; +constexpr bool DEFAULT_VISIBLE = false; +constexpr bool DEFAULT_INDESIGNMODE = false; +constexpr bool DEFAULT_ENABLE = true; + +// construct/destruct + +BaseControl::BaseControl( const Reference< XComponentContext >& rxContext ) + : OComponentHelper ( m_aMutex ) + , m_xComponentContext ( rxContext ) + , m_nX ( DEFAULT_X ) + , m_nY ( DEFAULT_Y ) + , m_nWidth ( DEFAULT_WIDTH ) + , m_nHeight ( DEFAULT_HEIGHT ) + , m_bVisible ( DEFAULT_VISIBLE ) + , m_bInDesignMode ( DEFAULT_INDESIGNMODE ) + , m_bEnable ( DEFAULT_ENABLE ) +{ +} + +BaseControl::~BaseControl() +{ +} + +// XInterface + +Any SAL_CALL BaseControl::queryInterface( const Type& rType ) +{ + Any aReturn; + if ( m_xDelegator.is() ) + { + // If a delegator exists, forward question to its queryInterface. + // Delegator will ask its own queryAggregation! + aReturn = m_xDelegator->queryInterface( rType ); + } + else + { + // If a delegator is unknown, forward question to own queryAggregation. + aReturn = queryAggregation( rType ); + } + + return aReturn; +} + +// XInterface + +void SAL_CALL BaseControl::acquire() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + OComponentHelper::acquire(); +} + +// XInterface + +void SAL_CALL BaseControl::release() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + OComponentHelper::release(); +} + +// XTypeProvider + +Sequence< Type > SAL_CALL BaseControl::getTypes() +{ + static OTypeCollection ourTypeCollection( + cppu::UnoType<XPaintListener>::get(), + cppu::UnoType<XWindowListener>::get(), + cppu::UnoType<XView>::get(), + cppu::UnoType<XWindow>::get(), + cppu::UnoType<XServiceInfo>::get(), + cppu::UnoType<XControl>::get(), + OComponentHelper::getTypes() ); + + return ourTypeCollection.getTypes(); +} + +// XTypeProvider + +Sequence< sal_Int8 > SAL_CALL BaseControl::getImplementationId() +{ + return css::uno::Sequence<sal_Int8>(); +} + +// XAggregation + +void SAL_CALL BaseControl::setDelegator( const Reference< XInterface >& xDel ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + m_xDelegator = xDel; +} + +// XAggregation + +Any SAL_CALL BaseControl::queryAggregation( const Type& aType ) +{ + // Ask for my own supported interfaces ... + // Attention: XTypeProvider and XInterface are supported by OComponentHelper! + Any aReturn ( ::cppu::queryInterface( aType , + static_cast< XPaintListener*> ( this ) , + static_cast< XWindowListener*> ( this ) , + static_cast< XView* > ( this ) , + static_cast< XWindow* > ( this ) , + static_cast< XServiceInfo* > ( this ) , + static_cast< XControl* > ( this ) + ) + ); + + // If searched interface supported by this class ... + if ( aReturn.hasValue() ) + { + // ... return this information. + return aReturn; + } + else + { + // Else; ... ask baseclass for interfaces! + return OComponentHelper::queryAggregation( aType ); + } +} + +// XServiceInfo + +OUString SAL_CALL BaseControl::getImplementationName() +{ + return OUString(); +} + +// XServiceInfo + +sal_Bool SAL_CALL BaseControl::supportsService( const OUString& sServiceName ) +{ + return cppu::supportsService(this, sServiceName); +} + +// XServiceInfo + +Sequence< OUString > SAL_CALL BaseControl::getSupportedServiceNames() +{ + return Sequence< OUString >(); +} + +// XComponent + +void SAL_CALL BaseControl::dispose() +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + if ( m_xMultiplexer.is() ) + { + // to all other paint, focus, etc. + m_xMultiplexer->disposeAndClear(); + } + + // set the service manager to disposed + OComponentHelper::dispose(); + + // release context and peer + m_xContext.clear(); + if ( m_xPeer.is() ) + { + if ( m_xGraphicsPeer.is() ) + { + removePaintListener( this ); + removeWindowListener( this ); + m_xGraphicsPeer.clear(); + } + + m_xPeer->dispose(); + m_xPeerWindow.clear(); + m_xPeer.clear(); + + if ( m_xMultiplexer.is() ) + { + // take changes on multiplexer + m_xMultiplexer->setPeer( Reference< XWindow >() ); + } + } + + // release view + if ( m_xGraphicsView.is() ) + { + m_xGraphicsView.clear(); + } +} + +// XComponent + +void SAL_CALL BaseControl::addEventListener( const Reference< XEventListener >& xListener ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + OComponentHelper::addEventListener( xListener ); +} + +// XComponent + +void SAL_CALL BaseControl::removeEventListener( const Reference< XEventListener >& xListener ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + OComponentHelper::removeEventListener( xListener ); +} + +// XControl + +void SAL_CALL BaseControl::createPeer( const Reference< XToolkit >& xToolkit , + const Reference< XWindowPeer >& xParentPeer ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + if ( m_xPeer.is() ) + return; + + // use method "BaseControl::getWindowDescriptor()" to change window attributes! + WindowDescriptor aDescriptor = impl_getWindowDescriptor( xParentPeer ); + + if ( m_bVisible ) + { + aDescriptor.WindowAttributes |= WindowAttribute::SHOW; + } + + // very slow under remote conditions! + // create the window on the server + Reference< XToolkit > xLocalToolkit = xToolkit; + if ( !xLocalToolkit.is() ) + { + // but first create well known toolkit, if it not exist + xLocalToolkit.set( Toolkit::create(m_xComponentContext), UNO_QUERY_THROW ); + } + m_xPeer = xLocalToolkit->createWindow( aDescriptor ); + m_xPeerWindow.set( m_xPeer, UNO_QUERY ); + + if ( !m_xPeerWindow.is() ) + return; + + if ( m_xMultiplexer.is() ) + { + m_xMultiplexer->setPeer( m_xPeerWindow ); + } + + // create new reference to xgraphics for painting on a peer + // and add a paint listener + Reference< XDevice > xDevice( m_xPeerWindow, UNO_QUERY ); + + if ( xDevice.is() ) + { + m_xGraphicsPeer = xDevice->createGraphics(); + } + + if ( m_xGraphicsPeer.is() ) + { + addPaintListener( this ); + addWindowListener( this ); + } + + m_xPeerWindow->setPosSize( m_nX, m_nY, m_nWidth, m_nHeight, PosSize::POSSIZE ); + m_xPeerWindow->setEnable( m_bEnable ); + m_xPeerWindow->setVisible( m_bVisible && !m_bInDesignMode ); +} + +// XControl + +void SAL_CALL BaseControl::setContext( const Reference< XInterface >& xContext ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + m_xContext = xContext; +} + +// XControl + +void SAL_CALL BaseControl::setDesignMode( sal_Bool bOn ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + m_bInDesignMode = bOn; +} + +// XControl + +Reference< XInterface > SAL_CALL BaseControl::getContext() +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + return m_xContext; +} + +// XControl + +Reference< XWindowPeer > SAL_CALL BaseControl::getPeer() +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + return m_xPeer; +} + +// XControl + +Reference< XView > SAL_CALL BaseControl::getView() +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + return this; +} + +// XControl + +sal_Bool SAL_CALL BaseControl::isDesignMode() +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + return m_bInDesignMode; +} + +// XControl + +sal_Bool SAL_CALL BaseControl::isTransparent() +{ + return false; +} + +// XWindow + +void SAL_CALL BaseControl::setPosSize( sal_Int32 nX , + sal_Int32 nY , + sal_Int32 nWidth , + sal_Int32 nHeight , + sal_Int16 nFlags ) +{ + // - change size and position of window and save the values + + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + bool bChanged = false; + + if ( nFlags & PosSize::X ) + { + bChanged |= m_nX != nX; + m_nX = nX; + } + + if ( nFlags & PosSize::Y ) + { + bChanged |= m_nY != nY; + m_nY = nY; + } + + if ( nFlags & PosSize::WIDTH ) + { + bChanged |= m_nWidth != nWidth; + m_nWidth = nWidth; + } + + if ( nFlags & PosSize::HEIGHT ) + { + bChanged |= m_nHeight != nHeight; + m_nHeight = nHeight; + } + + if ( bChanged && m_xPeerWindow.is() ) + { + m_xPeerWindow->setPosSize( m_nX, m_nY, m_nWidth, m_nHeight, nFlags ); + } +} + +// XWindow + +void SAL_CALL BaseControl::setVisible( sal_Bool bVisible ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // Set new state of flag + m_bVisible = bVisible; + + if ( m_xPeerWindow.is() ) + { + // Set it also on peerwindow + m_xPeerWindow->setVisible( m_bVisible ); + } +} + +// XWindow + +void SAL_CALL BaseControl::setEnable( sal_Bool bEnable ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // Set new state of flag + m_bEnable = bEnable; + + if ( m_xPeerWindow.is() ) + { + // Set it also on peerwindow + m_xPeerWindow->setEnable( m_bEnable ); + } +} + +// XWindow + +void SAL_CALL BaseControl::setFocus() +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + if ( m_xPeerWindow.is() ) + { + m_xPeerWindow->setFocus(); + } +} + +// XWindow + +Rectangle SAL_CALL BaseControl::getPosSize() +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + return Rectangle( m_nX, m_nY , m_nWidth, m_nHeight ); +} + +// XWindow + +void SAL_CALL BaseControl::addWindowListener( const Reference< XWindowListener >& xListener ) +{ + impl_getMultiplexer()->advise( cppu::UnoType<XWindowListener>::get(), xListener ); +} + +// XWindow + +void SAL_CALL BaseControl::addFocusListener( const Reference< XFocusListener >& xListener ) +{ + impl_getMultiplexer()->advise( cppu::UnoType<XFocusListener>::get(), xListener ); +} + +// XWindow + +void SAL_CALL BaseControl::addKeyListener( const Reference< XKeyListener >& xListener ) +{ + impl_getMultiplexer()->advise( cppu::UnoType<XKeyListener>::get(), xListener ); +} + +// XWindow + +void SAL_CALL BaseControl::addMouseListener( const Reference< XMouseListener >& xListener ) +{ + impl_getMultiplexer()->advise( cppu::UnoType<XMouseListener>::get(), xListener ); +} + +// XWindow + +void SAL_CALL BaseControl::addMouseMotionListener( const Reference< XMouseMotionListener >& xListener ) +{ + impl_getMultiplexer()->advise( cppu::UnoType<XMouseMotionListener>::get(), xListener ); +} + +// XWindow + +void SAL_CALL BaseControl::addPaintListener( const Reference< XPaintListener >& xListener ) +{ + impl_getMultiplexer()->advise( cppu::UnoType<XPaintListener>::get(), xListener ); +} + +// XWindow + +void SAL_CALL BaseControl::removeWindowListener( const Reference< XWindowListener >& xListener ) +{ + impl_getMultiplexer()->unadvise( cppu::UnoType<XWindowListener>::get(), xListener ); +} + +// XWindow + +void SAL_CALL BaseControl::removeFocusListener( const Reference< XFocusListener >& xListener ) +{ + impl_getMultiplexer()->unadvise( cppu::UnoType<XFocusListener>::get(), xListener ); +} + +// XWindow + +void SAL_CALL BaseControl::removeKeyListener( const Reference< XKeyListener >& xListener ) +{ + impl_getMultiplexer()->unadvise( cppu::UnoType<XKeyListener>::get(), xListener ); +} + +// XWindow + +void SAL_CALL BaseControl::removeMouseListener( const Reference< XMouseListener >& xListener ) +{ + impl_getMultiplexer()->unadvise( cppu::UnoType<XMouseListener>::get(), xListener ); +} + +// XWindow + +void SAL_CALL BaseControl::removeMouseMotionListener( const Reference< XMouseMotionListener >& xListener ) +{ + impl_getMultiplexer()->unadvise( cppu::UnoType<XMouseMotionListener>::get(), xListener ); +} + +// XWindow + +void SAL_CALL BaseControl::removePaintListener( const Reference< XPaintListener >& xListener ) +{ + impl_getMultiplexer()->unadvise( cppu::UnoType<XPaintListener>::get(), xListener ); +} + +// XView + +void SAL_CALL BaseControl::draw( sal_Int32 nX , + sal_Int32 nY ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // - paint to a view + // - use the method "paint()" + // - see also "windowPaint()" + impl_paint( nX, nY, m_xGraphicsView ); +} + +// XView + +sal_Bool SAL_CALL BaseControl::setGraphics( const Reference< XGraphics >& xDevice ) +{ + // - set the graphics for a view + // - in this class exist 2 graphics-member ... one for peer[_xGraphicsPeer] and one for view[_xGraphicsView] + // - they are used by "windowPaint() and draw()", forwarded to "paint ()" + bool bReturn = false; + if ( xDevice.is() ) + { + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + m_xGraphicsView = xDevice; + bReturn = true; + } + + return bReturn; +} + +// XView + +void SAL_CALL BaseControl::setZoom( float /*fZoomX*/ , + float /*fZoomY*/ ) +{ + // Not implemented yet +} + +// XView + +Reference< XGraphics > SAL_CALL BaseControl::getGraphics() +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + return m_xGraphicsView; +} + +// XView + +Size SAL_CALL BaseControl::getSize() +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + return Size( m_nWidth, m_nHeight ); +} + +// XEventListener + +void SAL_CALL BaseControl::disposing( const EventObject& /*aSource*/ ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // - release ALL references + // - it must be !!! + if ( m_xGraphicsPeer.is() ) + { + removePaintListener( this ); + removeWindowListener( this ); + m_xGraphicsPeer.clear(); + } + + if ( m_xGraphicsView.is() ) + { + m_xGraphicsView.clear(); + } +} + +// XPaintListener + +void SAL_CALL BaseControl::windowPaint( const PaintEvent& /*aEvent*/ ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // - repaint the peer + // - use the method "paint ()" for painting on a peer and a print device !!! + // - see also "draw ()" + impl_paint( 0, 0, m_xGraphicsPeer ); +} + +// XWindowListener + +void SAL_CALL BaseControl::windowResized( const WindowEvent& aEvent ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + m_nWidth = aEvent.Width; + m_nHeight = aEvent.Height; + WindowEvent aMappedEvent = aEvent; + aMappedEvent.X = 0; + aMappedEvent.Y = 0; + impl_recalcLayout( aMappedEvent ); +} + +// XWindowListener + +void SAL_CALL BaseControl::windowMoved( const WindowEvent& aEvent ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + m_nWidth = aEvent.Width; + m_nHeight = aEvent.Height; + WindowEvent aMappedEvent = aEvent; + aMappedEvent.X = 0; + aMappedEvent.Y = 0; + impl_recalcLayout( aMappedEvent ); +} + +// XWindowListener + +void SAL_CALL BaseControl::windowShown( const EventObject& /*aEvent*/ ) +{ +} + +// XWindowListener + +void SAL_CALL BaseControl::windowHidden( const EventObject& /*aEvent*/ ) +{ +} + +// protected method + +WindowDescriptor BaseControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer ) +{ + // - used from "createPeer()" to set the values of a css::awt::WindowDescriptor !!! + // - if you will change the descriptor-values, you must override this virtual function + // - the caller must release the memory for this dynamical descriptor !!! + + WindowDescriptor aDescriptor; + + aDescriptor.Type = WindowClass_SIMPLE; + aDescriptor.WindowServiceName = "window"; + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = xParentPeer; + aDescriptor.Bounds = getPosSize (); + aDescriptor.WindowAttributes = 0; + + return aDescriptor; +} + +// protected method + +void BaseControl::impl_paint( sal_Int32 /*nX*/ , + sal_Int32 /*nY*/ , + const Reference< XGraphics >& /*xGraphics*/ ) +{ + // - one paint method for peer AND view !!! + // (see also => "windowPaint()" and "draw()") + // - not used in this implementation, but it's not necessary to make it pure virtual !!! +} + +// protected method + +void BaseControl::impl_recalcLayout( const WindowEvent& /*aEvent*/ ) +{ + // We need as virtual function to support automatically resizing of derived controls! + // But we make it not pure virtual because it's not necessary for all derived classes! +} + +// private method + +OMRCListenerMultiplexerHelper* BaseControl::impl_getMultiplexer() +{ + if ( !m_xMultiplexer.is() ) + { + m_xMultiplexer = new OMRCListenerMultiplexerHelper( static_cast<XWindow*>(this), m_xPeerWindow ); + } + + return m_xMultiplexer.get(); +} + +} // namespace unocontrols + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/base/multiplexer.cxx b/UnoControls/source/base/multiplexer.cxx new file mode 100644 index 000000000..c7bf65c17 --- /dev/null +++ b/UnoControls/source/base/multiplexer.cxx @@ -0,0 +1,441 @@ +/* -*- 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 . + */ + +#include <multiplexer.hxx> + +#include <osl/diagnose.h> +#include <cppuhelper/queryinterface.hxx> + +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/awt/XTopWindow.hpp> + +using namespace ::cppu; +using namespace ::osl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::lang; + +namespace unocontrols { + +// macros + +#define MULTIPLEX( INTERFACE, METHOD, EVENTTYP, EVENT ) \ + \ + /* First get all interfaces from container with right type.*/ \ + comphelper::OInterfaceContainerHelper2* pContainer = m_aListenerHolder.getContainer( cppu::UnoType<INTERFACE>::get() ); \ + /* Do the follow only, if elements in container exist.*/ \ + if( !pContainer ) \ + return; \ + comphelper::OInterfaceIteratorHelper2 aIterator( *pContainer ); \ + EVENTTYP aLocalEvent = EVENT; \ + /* Remark: The control is the event source not the peer.*/ \ + /* We must change the source of the event. */ \ + aLocalEvent.Source = m_xControl; \ + /* Is the control not destroyed? */ \ + if( !aLocalEvent.Source ) \ + return; \ + if( !aIterator.hasMoreElements() ) \ + return; \ + INTERFACE * pListener = static_cast<INTERFACE *>(aIterator.next()); \ + try \ + { \ + pListener->METHOD( aLocalEvent ); \ + } \ + catch(const RuntimeException& ) \ + { \ + /* Ignore all system exceptions from the listener! */ \ + } + +// construct/destruct + +OMRCListenerMultiplexerHelper::OMRCListenerMultiplexerHelper( const Reference< XWindow >& xControl , + const Reference< XWindow >& xPeer ) + : m_xPeer ( xPeer ) + , m_xControl ( xControl ) + , m_aListenerHolder ( m_aMutex ) +{ +} + +OMRCListenerMultiplexerHelper::OMRCListenerMultiplexerHelper( const OMRCListenerMultiplexerHelper& aCopyInstance ) + : XFocusListener() + , XWindowListener() + , XKeyListener() + , XMouseListener() + , XMouseMotionListener() + , XPaintListener() + , XTopWindowListener() + , OWeakObject(aCopyInstance) + , m_aListenerHolder ( m_aMutex ) +{ +} + +OMRCListenerMultiplexerHelper::~OMRCListenerMultiplexerHelper() +{ +} + +// XInterface + +Any SAL_CALL OMRCListenerMultiplexerHelper::queryInterface( const Type& rType ) +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Ask for my own supported interfaces ... + // Attention: XTypeProvider and XInterface are supported by OComponentHelper! + Any aReturn ( ::cppu::queryInterface( rType , + static_cast< XWindowListener* > ( this ) , + static_cast< XKeyListener* > ( this ) , + static_cast< XFocusListener* > ( this ) , + static_cast< XMouseListener* > ( this ) , + static_cast< XMouseMotionListener* > ( this ) , + static_cast< XPaintListener* > ( this ) , + static_cast< XTopWindowListener* > ( this ) , + static_cast< XTopWindowListener* > ( this ) + ) + ); + + // If searched interface supported by this class ... + if ( aReturn.hasValue() ) + { + // ... return this information. + return aReturn; + } + else + { + // Else; ... ask baseclass for interfaces! + return OWeakObject::queryInterface( rType ); + } +} + +// XInterface + +void SAL_CALL OMRCListenerMultiplexerHelper::acquire() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + OWeakObject::acquire(); +} + +// XInterface + +void SAL_CALL OMRCListenerMultiplexerHelper::release() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + OWeakObject::release(); +} + +// container method + +void OMRCListenerMultiplexerHelper::setPeer( const Reference< XWindow >& xPeer ) +{ + MutexGuard aGuard( m_aMutex ); + if( m_xPeer == xPeer ) + return; + + if( m_xPeer.is() ) + { + // get all types from the listener added to the peer + const std::vector< Type > aContainedTypes = m_aListenerHolder.getContainedTypes(); + // loop over all listener types and remove the listeners from the peer + for( const auto& rContainedType : aContainedTypes ) + impl_unadviseFromPeer( m_xPeer, rContainedType ); + } + m_xPeer = xPeer; + if( m_xPeer.is() ) + { + // get all types from the listener added to the peer + const std::vector< Type > aContainedTypes = m_aListenerHolder.getContainedTypes(); + // loop over all listener types and add the listeners to the peer + for( const auto& rContainedType : aContainedTypes ) + impl_adviseToPeer( m_xPeer, rContainedType ); + } +} + +// container method + +void OMRCListenerMultiplexerHelper::disposeAndClear() +{ + EventObject aEvent; + aEvent.Source = m_xControl; + m_aListenerHolder.disposeAndClear( aEvent ); +} + +// container method + +void OMRCListenerMultiplexerHelper::advise( const Type& aType , + const Reference< XInterface >& xListener ) +{ + MutexGuard aGuard( m_aMutex ); + if( m_aListenerHolder.addInterface( aType, xListener ) == 1 ) + { + // the first listener is added + if( m_xPeer.is() ) + { + impl_adviseToPeer( m_xPeer, aType ); + } + } +} + +// container method + +void OMRCListenerMultiplexerHelper::unadvise( const Type& aType , + const Reference< XInterface >& xListener ) +{ + MutexGuard aGuard( m_aMutex ); + if( m_aListenerHolder.removeInterface( aType, xListener ) == 0 ) + { + // the last listener is removed + if ( m_xPeer.is() ) + { + impl_unadviseFromPeer( m_xPeer, aType ); + } + } +} + +// XEventListener + +void SAL_CALL OMRCListenerMultiplexerHelper::disposing( const EventObject& /*aSource*/ ) +{ + MutexGuard aGuard( m_aMutex ); + // peer is disposed, clear the reference + m_xPeer.clear(); +} + +// XFcousListener + +void OMRCListenerMultiplexerHelper::focusGained(const FocusEvent& aEvent ) +{ + MULTIPLEX( XFocusListener, focusGained, FocusEvent, aEvent ) +} + +// XFcousListener + +void OMRCListenerMultiplexerHelper::focusLost(const FocusEvent& aEvent ) +{ + MULTIPLEX( XFocusListener, focusLost, FocusEvent, aEvent ) +} + +// XWindowListener + +void OMRCListenerMultiplexerHelper::windowResized(const WindowEvent& aEvent ) +{ + MULTIPLEX( XWindowListener, windowResized, WindowEvent, aEvent ) +} + +// XWindowListener + +void OMRCListenerMultiplexerHelper::windowMoved(const WindowEvent& aEvent ) +{ + MULTIPLEX( XWindowListener, windowMoved, WindowEvent, aEvent ) +} + +// XWindowListener + +void OMRCListenerMultiplexerHelper::windowShown(const EventObject& aEvent ) +{ + MULTIPLEX( XWindowListener, windowShown, EventObject, aEvent ) +} + +// XWindowListener + +void OMRCListenerMultiplexerHelper::windowHidden(const EventObject& aEvent ) +{ + MULTIPLEX( XWindowListener, windowHidden, EventObject, aEvent ) +} + +// XKeyListener + +void OMRCListenerMultiplexerHelper::keyPressed(const KeyEvent& aEvent) +{ + MULTIPLEX( XKeyListener, keyPressed, KeyEvent, aEvent ) +} + +// XKeyListener + +void OMRCListenerMultiplexerHelper::keyReleased(const KeyEvent& aEvent) +{ + MULTIPLEX( XKeyListener, keyReleased, KeyEvent, aEvent ) +} + +// XMouseListener + +void OMRCListenerMultiplexerHelper::mousePressed(const MouseEvent& aEvent) +{ + MULTIPLEX( XMouseListener, mousePressed, MouseEvent, aEvent ) +} + +// XMouseListener + +void OMRCListenerMultiplexerHelper::mouseReleased(const MouseEvent& aEvent) +{ + MULTIPLEX( XMouseListener, mouseReleased, MouseEvent, aEvent ) +} + +// XMouseListener + +void OMRCListenerMultiplexerHelper::mouseEntered(const MouseEvent& aEvent) +{ + MULTIPLEX( XMouseListener, mouseEntered, MouseEvent, aEvent ) +} + +// XMouseListener + +void OMRCListenerMultiplexerHelper::mouseExited(const MouseEvent& aEvent) +{ + MULTIPLEX( XMouseListener, mouseExited, MouseEvent, aEvent ) +} + +// XMouseMotionListener + +void OMRCListenerMultiplexerHelper::mouseDragged(const MouseEvent& aEvent) +{ + MULTIPLEX( XMouseMotionListener, mouseDragged, MouseEvent, aEvent ) +} + +// XMouseMotionListener + +void OMRCListenerMultiplexerHelper::mouseMoved(const MouseEvent& aEvent) +{ + MULTIPLEX( XMouseMotionListener, mouseMoved, MouseEvent, aEvent ) +} + +// XPaintListener + +void OMRCListenerMultiplexerHelper::windowPaint(const PaintEvent& aEvent) +{ + MULTIPLEX( XPaintListener, windowPaint, PaintEvent, aEvent ) +} + +// XTopWindowListener + +void OMRCListenerMultiplexerHelper::windowOpened(const EventObject& aEvent) +{ + MULTIPLEX( XTopWindowListener, windowOpened, EventObject, aEvent ) +} + +// XTopWindowListener + +void OMRCListenerMultiplexerHelper::windowClosing( const EventObject& aEvent ) +{ + MULTIPLEX( XTopWindowListener, windowClosing, EventObject, aEvent ) +} + +// XTopWindowListener + +void OMRCListenerMultiplexerHelper::windowClosed( const EventObject& aEvent ) +{ + MULTIPLEX( XTopWindowListener, windowClosed, EventObject, aEvent ) +} + +// XTopWindowListener + +void OMRCListenerMultiplexerHelper::windowMinimized( const EventObject& aEvent ) +{ + MULTIPLEX( XTopWindowListener, windowMinimized, EventObject, aEvent ) +} + +// XTopWindowListener + +void OMRCListenerMultiplexerHelper::windowNormalized( const EventObject& aEvent ) +{ + MULTIPLEX( XTopWindowListener, windowNormalized, EventObject, aEvent ) +} + +// XTopWindowListener + +void OMRCListenerMultiplexerHelper::windowActivated( const EventObject& aEvent ) +{ + MULTIPLEX( XTopWindowListener, windowActivated, EventObject, aEvent ) +} + +// XTopWindowListener + +void OMRCListenerMultiplexerHelper::windowDeactivated( const EventObject& aEvent ) +{ + MULTIPLEX( XTopWindowListener, windowDeactivated, EventObject, aEvent ) +} + +// protected method + +void OMRCListenerMultiplexerHelper::impl_adviseToPeer( const Reference< XWindow >& xPeer , + const Type& aType ) +{ + // add a listener to the source (peer) + if( aType == cppu::UnoType<XWindowListener>::get()) + xPeer->addWindowListener( this ); + else if( aType == cppu::UnoType<XKeyListener>::get()) + xPeer->addKeyListener( this ); + else if( aType == cppu::UnoType<XFocusListener>::get()) + xPeer->addFocusListener( this ); + else if( aType == cppu::UnoType<XMouseListener>::get()) + xPeer->addMouseListener( this ); + else if( aType == cppu::UnoType<XMouseMotionListener>::get()) + xPeer->addMouseMotionListener( this ); + else if( aType == cppu::UnoType<XPaintListener>::get()) + xPeer->addPaintListener( this ); + else if( aType == cppu::UnoType<XTopWindowListener>::get()) + { + Reference< XTopWindow > xTop( xPeer, UNO_QUERY ); + if( xTop.is() ) + xTop->addTopWindowListener( this ); + } + else + { + OSL_FAIL( "unknown listener" ); + } +} + +// protected method + +void OMRCListenerMultiplexerHelper::impl_unadviseFromPeer( const Reference< XWindow >& xPeer , + const Type& aType ) +{ + // the last listener is removed, remove the listener from the source (peer) + if( aType == cppu::UnoType<XWindowListener>::get()) + xPeer->removeWindowListener( this ); + else if( aType == cppu::UnoType<XKeyListener>::get()) + xPeer->removeKeyListener( this ); + else if( aType == cppu::UnoType<XFocusListener>::get()) + xPeer->removeFocusListener( this ); + else if( aType == cppu::UnoType<XMouseListener>::get()) + xPeer->removeMouseListener( this ); + else if( aType == cppu::UnoType<XMouseMotionListener>::get()) + xPeer->removeMouseMotionListener( this ); + else if( aType == cppu::UnoType<XPaintListener>::get()) + xPeer->removePaintListener( this ); + else if( aType == cppu::UnoType<XTopWindowListener>::get()) + { + Reference< XTopWindow > xTop( xPeer, UNO_QUERY ); + if( xTop.is() ) + xTop->removeTopWindowListener( this ); + } + else + { + OSL_FAIL( "unknown listener" ); + } +} + +} // namespace unocontrols + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/OConnectionPointContainerHelper.cxx b/UnoControls/source/controls/OConnectionPointContainerHelper.cxx new file mode 100644 index 000000000..bf687a0df --- /dev/null +++ b/UnoControls/source/controls/OConnectionPointContainerHelper.cxx @@ -0,0 +1,141 @@ +/* -*- 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 . + */ + +#include <OConnectionPointContainerHelper.hxx> + +#include <OConnectionPointHelper.hxx> + +#include <cppuhelper/queryinterface.hxx> +#include <comphelper/sequence.hxx> + +// namespaces + +using namespace ::osl; +using namespace ::cppu; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; + +namespace unocontrols { + +// construct/destruct + +OConnectionPointContainerHelper::OConnectionPointContainerHelper( Mutex& aMutex ) + : m_aSharedMutex ( aMutex ) + , m_aMultiTypeContainer ( aMutex ) +{ +} + +OConnectionPointContainerHelper::~OConnectionPointContainerHelper() +{ +} + +// XInterface + +Any SAL_CALL OConnectionPointContainerHelper::queryInterface( const Type& aType ) +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Ask for my own supported interfaces ... + Any aReturn ( ::cppu::queryInterface( aType , + static_cast< XConnectionPointContainer* > ( this ) + ) + ); + + // If searched interface not supported by this class ... + if ( !aReturn.hasValue() ) + { + // ... ask baseclasses. + aReturn = OWeakObject::queryInterface( aType ); + } + + return aReturn; +} + +// XInterface + +void SAL_CALL OConnectionPointContainerHelper::acquire() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + OWeakObject::acquire(); +} + +// XInterface + +void SAL_CALL OConnectionPointContainerHelper::release() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + OWeakObject::release(); +} + +// XConnectionPointContainer + +Sequence< Type > SAL_CALL OConnectionPointContainerHelper::getConnectionPointTypes() +{ + // Container is threadsafe himself ! + return comphelper::containerToSequence(m_aMultiTypeContainer.getContainedTypes()); +} + +// XConnectionPointContainer + +Reference< XConnectionPoint > SAL_CALL OConnectionPointContainerHelper::queryConnectionPoint( const Type& aType ) +{ + // Set default return value, if method failed. + Reference< XConnectionPoint > xConnectionPoint; + + // Get all elements of the container, which have the searched type. + comphelper::OInterfaceContainerHelper2* pSpecialContainer = m_aMultiTypeContainer.getContainer( aType ); + if ( pSpecialContainer && pSpecialContainer->getLength() > 0 ) + { + // Ready for multithreading + MutexGuard aGuard( m_aSharedMutex ); + // If this container contains elements, build a connectionpoint-instance. + xConnectionPoint = new OConnectionPointHelper( m_aSharedMutex, this, aType ); + } + + return xConnectionPoint; +} + +// XConnectionPointContainer + +void SAL_CALL OConnectionPointContainerHelper::advise( const Type& aType , + const Reference< XInterface >& xListener ) +{ + // Container is threadsafe himself ! + m_aMultiTypeContainer.addInterface( aType, xListener ); +} + +// XConnectionPointContainer + +void SAL_CALL OConnectionPointContainerHelper::unadvise( const Type& aType , + const Reference< XInterface >& xListener ) +{ + // Container is threadsafe himself ! + m_aMultiTypeContainer.removeInterface( aType, xListener ); +} + +} // namespace unocontrols + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/OConnectionPointHelper.cxx b/UnoControls/source/controls/OConnectionPointHelper.cxx new file mode 100644 index 000000000..b6ddaaa51 --- /dev/null +++ b/UnoControls/source/controls/OConnectionPointHelper.cxx @@ -0,0 +1,228 @@ +/* -*- 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 . + */ + +#include <OConnectionPointHelper.hxx> + +#include <OConnectionPointContainerHelper.hxx> + +#include <com/sun/star/lang/InvalidListenerException.hpp> +#include <cppuhelper/queryinterface.hxx> +#include <comphelper/sequence.hxx> + +// namespaces + +using namespace ::osl; +using namespace ::cppu; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; + +namespace unocontrols { + +// construct/destruct + +OConnectionPointHelper::OConnectionPointHelper( + Mutex& aMutex , + OConnectionPointContainerHelper* pContainerImplementation , + Type const & aType +) : m_aSharedMutex ( aMutex ) + , m_oContainerWeakReference ( pContainerImplementation ) + , m_pContainerImplementation ( pContainerImplementation ) + , m_aInterfaceType ( aType ) +{ +} + +OConnectionPointHelper::~OConnectionPointHelper() +{ +} + +// XInterface + +Any SAL_CALL OConnectionPointHelper::queryInterface( const Type& aType ) +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Ask for my own supported interfaces ... + Any aReturn ( ::cppu::queryInterface( aType , + static_cast< XConnectionPoint* > ( this ) + ) + ); + + // If searched interface not supported by this class ... + if ( !aReturn.hasValue() ) + { + // ... ask baseclasses. + aReturn = OWeakObject::queryInterface( aType ); + } + + return aReturn; +} + +// XInterface + +void SAL_CALL OConnectionPointHelper::acquire() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + OWeakObject::acquire(); +} + +// XInterface + +void SAL_CALL OConnectionPointHelper::release() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + OWeakObject::release(); +} + +// XConnectionPoint + +Type SAL_CALL OConnectionPointHelper::getConnectionType() +{ + // Ready for multithreading + MutexGuard aGuard( m_aSharedMutex ); + + // Set default return value, if method failed. + if ( !impl_LockContainer() ) + { + throw RuntimeException("Container does not exist!"); + } + + // If container reference valid, return right type of supported interfaces of THIS connectionpoint. + Type aReturnType = m_aInterfaceType; + // Don't forget this! + impl_UnlockContainer(); + + return aReturnType; +} + +// XConnectionPoint + +Reference< XConnectionPointContainer > SAL_CALL OConnectionPointHelper::getConnectionPointContainer() +{ + // Ready for multithreading + MutexGuard aGuard( m_aSharedMutex ); + // Convert weakreference to correct uno3-reference and return value. It can be NULL, if container destroyed! + return Reference< XConnectionPointContainer >( m_oContainerWeakReference.get(), UNO_QUERY ); +} + +// XConnectionPoint + +void SAL_CALL OConnectionPointHelper::advise( const Reference< XInterface >& xListener ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aSharedMutex ); + + // If type of listener not the same for this special container ... + Any aCheckType = xListener->queryInterface( m_aInterfaceType ); + if ( aCheckType.hasValue() ) + { + // ... throw an exception. + throw InvalidListenerException(); + } + + // ListenerExistException is obsolete!? + // It's the same container for XConnectionPointContainer and XConnectionPoint. But only here we must control, if a listener already exist!? + // You can add a listener more than one time at XConnectionPointContainer, but here only one ... + + // Operation is permitted only, if reference to container is valid! + if ( !impl_LockContainer() ) + { + throw RuntimeException("Container does not exist!"); + } + // Forward it to OConnectionPointHelperContainer! + m_pContainerImplementation->advise( m_aInterfaceType, xListener ); + // Don't forget this! + impl_UnlockContainer(); +} + +// XConnectionPoint + +void SAL_CALL OConnectionPointHelper::unadvise( const Reference< XInterface >& xListener ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aSharedMutex ); + // Operation is permitted only, if reference to container is valid! + if ( !impl_LockContainer() ) + { + throw RuntimeException("Container does not exist!"); + + } + // Forward it to OConnectionPointHelperContainer! + m_pContainerImplementation->unadvise( m_aInterfaceType, xListener ); + // Don't forget this! + impl_UnlockContainer(); +} + +// XConnectionPoint + +Sequence< Reference< XInterface > > SAL_CALL OConnectionPointHelper::getConnections() +{ + // Ready for multithreading + MutexGuard aGuard( m_aSharedMutex ); + // Operation is permitted only, if reference to container is valid! + if ( !impl_LockContainer() ) + { + throw RuntimeException("Container does not exist!"); + } + // Set default return value, if method failed. + Sequence< Reference< XInterface > > seqReturnConnections; + // Get reference to private member of OConnectionPointHelperContainer! + comphelper::OMultiTypeInterfaceContainerHelper2& aSharedContainer = m_pContainerImplementation->impl_getMultiTypeContainer(); + // Get pointer to specialized container which hold all interfaces of searched type. + comphelper::OInterfaceContainerHelper2* pSpecialContainer = aSharedContainer.getContainer( m_aInterfaceType ); + // Get elements of searched type, if some else exist. + if ( pSpecialContainer != nullptr ) + { + seqReturnConnections = comphelper::containerToSequence(pSpecialContainer->getElements()); + } + // Don't forget this! + impl_UnlockContainer(); + + return seqReturnConnections; +} + +// private method + +bool OConnectionPointHelper::impl_LockContainer() +{ + // Convert weakreference to hard uno3-reference and return state. + // If this reference different from NULL, there exist a hard reference to container. Container-instance can't be destroyed. + // Don't forget to "unlock" this reference! + m_xLock = m_oContainerWeakReference.get(); + return m_xLock.is(); +} + +// private method + +void OConnectionPointHelper::impl_UnlockContainer() +{ + // Free hard uno3-reference to container. + // see also "impl_LockContainer()" + m_xLock.clear(); +} + +} // namespace unocontrols + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/framecontrol.cxx b/UnoControls/source/controls/framecontrol.cxx new file mode 100644 index 000000000..73decca46 --- /dev/null +++ b/UnoControls/source/controls/framecontrol.cxx @@ -0,0 +1,462 @@ +/* -*- 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 . + */ + +#include <framecontrol.hxx> +#include <OConnectionPointContainerHelper.hxx> + +#include <com/sun/star/awt/XControlContainer.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/frame/Frame.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/util/URLTransformer.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> +#include <cppuhelper/queryinterface.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <osl/diagnose.h> + +// namespaces + +using namespace ::osl; +using namespace ::cppu; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::util; + +namespace unocontrols { + +namespace { + +enum PropertyHandle // values represent index in PropertyArray +{ // for FrameControl + Componenturl = 0, + Frame = 1, + Loaderarguments = 2 +}; + +} + +// construct/destruct + +FrameControl::FrameControl( const Reference< XComponentContext >& rxContext) + : BaseControl ( rxContext ) + , OBroadcastHelper ( m_aMutex ) + , OPropertySetHelper ( *static_cast< OBroadcastHelper * >(this) ) + , m_aConnectionPointContainer ( new OConnectionPointContainerHelper(m_aMutex) ) +{ +} + +FrameControl::~FrameControl() +{ +} + +// XInterface + +Any SAL_CALL FrameControl::queryInterface( const Type& rType ) +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + Any aReturn; + Reference< XInterface > xDel = BaseControl::impl_getDelegator(); + if ( xDel.is() ) + { + // If a delegator exists, forward question to its queryInterface. + // Delegator will ask its own queryAggregation! + aReturn = xDel->queryInterface( rType ); + } + else + { + // If a delegator is unknown, forward question to own queryAggregation. + aReturn = queryAggregation( rType ); + } + + return aReturn; +} + +// XInterface + +void SAL_CALL FrameControl::acquire() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + BaseControl::acquire(); +} + +// XInterface + +void SAL_CALL FrameControl::release() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + BaseControl::release(); +} + +// XTypeProvider + +Sequence< Type > SAL_CALL FrameControl::getTypes() +{ + static OTypeCollection ourTypeCollection( + cppu::UnoType<XControlModel>::get(), + cppu::UnoType<XControlContainer>::get(), + cppu::UnoType<XConnectionPointContainer>::get(), + BaseControl::getTypes() ); + + return ourTypeCollection.getTypes(); +} + +// XAggregation + +Any SAL_CALL FrameControl::queryAggregation( const Type& aType ) +{ + // Ask for my own supported interfaces ... + // Attention: XTypeProvider and XInterface are supported by OComponentHelper! + Any aReturn ( ::cppu::queryInterface( aType , + static_cast< XControlModel* > ( this ) , + static_cast< XConnectionPointContainer* > ( this ) + ) + ); + + // If searched interface not supported by this class ... + if ( !aReturn.hasValue() ) + { + // ... ask baseclasses. + aReturn = OPropertySetHelper::queryInterface( aType ); + if ( !aReturn.hasValue() ) + { + aReturn = BaseControl::queryAggregation( aType ); + } + } + + return aReturn; +} + +OUString FrameControl::getImplementationName() +{ + return "stardiv.UnoControls.FrameControl"; +} + +css::uno::Sequence<OUString> FrameControl::getSupportedServiceNames() +{ + return { "com.sun.star.frame.FrameControl" }; +} + +// XControl + +void SAL_CALL FrameControl::createPeer( const Reference< XToolkit >& xToolkit , + const Reference< XWindowPeer >& xParentPeer ) +{ + BaseControl::createPeer( xToolkit, xParentPeer ); + if ( impl_getPeerWindow().is() ) + { + if( !m_sComponentURL.isEmpty() ) + { + impl_createFrame( getPeer(), m_sComponentURL, m_seqLoaderArguments ); + } + } +} + +// XControl + +sal_Bool SAL_CALL FrameControl::setModel( const Reference< XControlModel >& /*xModel*/ ) +{ + // We have no model. + return false; +} + +// XControl + +Reference< XControlModel > SAL_CALL FrameControl::getModel() +{ + // We have no model. + return Reference< XControlModel >(); +} + +// XControl + +void SAL_CALL FrameControl::dispose() +{ + impl_deleteFrame(); + BaseControl::dispose(); +} + +// XView + +sal_Bool SAL_CALL FrameControl::setGraphics( const Reference< XGraphics >& /*xDevice*/ ) +{ + // it is not possible to print this control + return false; +} + +// XView + +Reference< XGraphics > SAL_CALL FrameControl::getGraphics() +{ + // when it's not possible to set graphics ! then it's possible to return null + return Reference< XGraphics >(); +} + +// XConnectionPointContainer + +Sequence< Type > SAL_CALL FrameControl::getConnectionPointTypes() +{ + // Forwarded to helper class + return m_aConnectionPointContainer->getConnectionPointTypes(); +} + +// XConnectionPointContainer + +Reference< XConnectionPoint > SAL_CALL FrameControl::queryConnectionPoint( const Type& aType ) +{ + // Forwarded to helper class + return m_aConnectionPointContainer->queryConnectionPoint( aType ); +} + +// XConnectionPointContainer + +void SAL_CALL FrameControl::advise( const Type& aType , + const Reference< XInterface >& xListener ) +{ + // Forwarded to helper class + m_aConnectionPointContainer->advise( aType, xListener ); +} + +// XConnectionPointContainer + +void SAL_CALL FrameControl::unadvise( const Type& aType , + const Reference< XInterface >& xListener ) +{ + // Forwarded to helper class + m_aConnectionPointContainer->unadvise( aType, xListener ); +} + +// OPropertySetHelper + +sal_Bool FrameControl::convertFastPropertyValue( Any& rConvertedValue , + Any& rOldValue , + sal_Int32 nHandle , + const Any& rValue ) +{ + bool bReturn = false; + switch (nHandle) + { + case PropertyHandle::Componenturl : rConvertedValue = rValue; + rOldValue <<= m_sComponentURL; + bReturn = true; + break; + + case PropertyHandle::Loaderarguments : rConvertedValue = rValue; + rOldValue <<= m_seqLoaderArguments; + bReturn = true; + break; + } + + if ( !bReturn ) + { + throw IllegalArgumentException("unknown handle " + OUString::number(nHandle), static_cast<cppu::OWeakObject*>(this), 1); + } + + return bReturn; +} + +// OPropertySetHelper + +void FrameControl::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , + const Any& rValue ) +{ + // this method only set the value + MutexGuard aGuard (m_aMutex); + switch (nHandle) + { + case PropertyHandle::Componenturl : rValue >>= m_sComponentURL; + if (getPeer().is()) + { + impl_createFrame ( getPeer(), m_sComponentURL, m_seqLoaderArguments ); + } + break; + + case PropertyHandle::Loaderarguments : rValue >>= m_seqLoaderArguments; + break; + + default : OSL_ENSURE ( nHandle == -1, "This is an invalid property handle." ); + } +} + +// OPropertySetHelper + +void FrameControl::getFastPropertyValue( Any& rRet , + sal_Int32 nHandle ) const +{ + MutexGuard aGuard ( Mutex::getGlobalMutex() ); + + switch (nHandle) + { + case PropertyHandle::Componenturl : rRet <<= m_sComponentURL; + break; + + case PropertyHandle::Loaderarguments : rRet <<= m_seqLoaderArguments; + break; + + case PropertyHandle::Frame : rRet <<= m_xFrame; + break; + + default : OSL_ENSURE ( nHandle == -1, "This is an invalid property handle." ); + } +} + +// OPropertySetHelper + +IPropertyArrayHelper& FrameControl::getInfoHelper() +{ + // Create a table that map names to index values. + // attention: properties need to be sorted by name! + static OPropertyArrayHelper ourPropertyInfo( + { + Property( "ComponentUrl", PropertyHandle::Componenturl, cppu::UnoType<OUString>::get(), + PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED ), + Property( "Frame", PropertyHandle::Frame, cppu::UnoType<XFrame>::get(), + PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT ), + Property( "LoaderArguments", PropertyHandle::Loaderarguments, cppu::UnoType<Sequence<PropertyValue>>::get(), + PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED ) + }, + true ); + + return ourPropertyInfo; +} + +// OPropertySetHelper + +Reference< XPropertySetInfo > SAL_CALL FrameControl::getPropertySetInfo() +{ + // Create structure of propertysetinfo for baseclass "OPropertySetHelper". + // (Use method "getInfoHelper()".) + static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + + return xInfo; +} + +// BaseControl + +WindowDescriptor FrameControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer ) +{ + WindowDescriptor aDescriptor; + + aDescriptor.Type = WindowClass_CONTAINER; + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = xParentPeer; + aDescriptor.Bounds = getPosSize (); + aDescriptor.WindowAttributes = 0; + + return aDescriptor; +} + +// private method + +void FrameControl::impl_createFrame( const Reference< XWindowPeer >& xPeer , + const OUString& rURL , + const Sequence< PropertyValue >& rArguments ) +{ + Reference< XFrame2 > xOldFrame; + Reference< XFrame2 > xNewFrame; + + { + MutexGuard aGuard ( m_aMutex ); + xOldFrame = m_xFrame; + } + + xNewFrame = Frame::create( impl_getComponentContext() ); + + Reference< XWindow > xWP ( xPeer, UNO_QUERY ); + xNewFrame->initialize ( xWP ); + + // option + //xFrame->setName( "WhatYouWant" ); + + Reference< XURLTransformer > xTrans = URLTransformer::create( impl_getComponentContext() ); + // load file + URL aURL; + aURL.Complete = rURL; + xTrans->parseStrict( aURL ); + + Reference< XDispatch > xDisp = xNewFrame->queryDispatch ( aURL, OUString (), FrameSearchFlag::SELF ); + if (xDisp.is()) + { + xDisp->dispatch ( aURL, rArguments ); + } + + // set the frame + { + MutexGuard aGuard ( m_aMutex ); + m_xFrame = xNewFrame; + } + + // notify the listeners + sal_Int32 nFrameId = PropertyHandle::Frame; + Any aNewFrame ( &xNewFrame, cppu::UnoType<XFrame>::get()); + Any aOldFrame ( &xOldFrame, cppu::UnoType<XFrame>::get()); + + fire ( &nFrameId, &aNewFrame, &aOldFrame, 1, false ); + + if (xOldFrame.is()) + { + xOldFrame->dispose (); + } +} + +// private method + +void FrameControl::impl_deleteFrame() +{ + Reference< XFrame2 > xOldFrame; + Reference< XFrame2 > xNullFrame; + + { + // do not dispose the frame in this guarded section (deadlock?) + MutexGuard aGuard( m_aMutex ); + xOldFrame = m_xFrame; + m_xFrame.clear(); + } + + // notify the listeners + sal_Int32 nFrameId = PropertyHandle::Frame; + Any aNewFrame( &xNullFrame, cppu::UnoType<XFrame2>::get()); + Any aOldFrame( &xOldFrame, cppu::UnoType<XFrame2>::get()); + fire( &nFrameId, &aNewFrame, &aOldFrame, 1, false ); + + // dispose the frame + if( xOldFrame.is() ) + xOldFrame->dispose(); +} + + +} // namespace unocontrols + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +stardiv_UnoControls_FrameControl_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new unocontrols::FrameControl(context)); +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/progressbar.cxx b/UnoControls/source/controls/progressbar.cxx new file mode 100644 index 000000000..fbb0b1342 --- /dev/null +++ b/UnoControls/source/controls/progressbar.cxx @@ -0,0 +1,400 @@ +/* -*- 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 . + */ + +#include <progressbar.hxx> + +#include <com/sun/star/awt/XGraphics.hpp> +#include <tools/debug.hxx> +#include <cppuhelper/queryinterface.hxx> +#include <cppuhelper/typeprovider.hxx> + +using namespace ::cppu; +using namespace ::osl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::awt; + +namespace unocontrols { + +// construct/destruct + +ProgressBar::ProgressBar( const Reference< XComponentContext >& rxContext ) + : BaseControl ( rxContext ) + , m_bHorizontal ( PROGRESSBAR_DEFAULT_HORIZONTAL ) + , m_aBlockSize ( PROGRESSBAR_DEFAULT_BLOCKDIMENSION ) + , m_nForegroundColor ( PROGRESSBAR_DEFAULT_FOREGROUNDCOLOR ) + , m_nBackgroundColor ( PROGRESSBAR_DEFAULT_BACKGROUNDCOLOR ) + , m_nMinRange ( PROGRESSBAR_DEFAULT_MINRANGE ) + , m_nMaxRange ( PROGRESSBAR_DEFAULT_MAXRANGE ) + , m_nBlockValue ( PROGRESSBAR_DEFAULT_BLOCKVALUE ) + , m_nValue ( PROGRESSBAR_DEFAULT_VALUE ) +{ +} + +ProgressBar::~ProgressBar() +{ +} + +// XInterface + +Any SAL_CALL ProgressBar::queryInterface( const Type& rType ) +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + Any aReturn; + Reference< XInterface > xDel = BaseControl::impl_getDelegator(); + if ( xDel.is() ) + { + // If a delegator exists, forward question to its queryInterface. + // Delegator will ask its own queryAggregation! + aReturn = xDel->queryInterface( rType ); + } + else + { + // If a delegator is unknown, forward question to own queryAggregation. + aReturn = queryAggregation( rType ); + } + + return aReturn; +} + +// XInterface + +void SAL_CALL ProgressBar::acquire() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + BaseControl::acquire(); +} + +// XInterface + +void SAL_CALL ProgressBar::release() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + BaseControl::release(); +} + +// XTypeProvider + +Sequence< Type > SAL_CALL ProgressBar::getTypes() +{ + static OTypeCollection ourTypeCollection( + cppu::UnoType<XControlModel>::get(), + cppu::UnoType<XProgressBar>::get(), + BaseControl::getTypes() ); + + return ourTypeCollection.getTypes(); +} + +// XAggregation + +Any SAL_CALL ProgressBar::queryAggregation( const Type& aType ) +{ + // Ask for my own supported interfaces ... + // Attention: XTypeProvider and XInterface are supported by OComponentHelper! + Any aReturn ( ::cppu::queryInterface( aType , + static_cast< XControlModel* > ( this ) , + static_cast< XProgressBar* > ( this ) + ) + ); + + // If searched interface not supported by this class ... + if ( !aReturn.hasValue() ) + { + // ... ask baseclasses. + aReturn = BaseControl::queryAggregation( aType ); + } + + return aReturn; +} + +// XProgressBar + +void SAL_CALL ProgressBar::setForegroundColor( sal_Int32 nColor ) +{ + // Ready for multithreading + MutexGuard aGuard (m_aMutex); + + // Safe color for later use. + m_nForegroundColor = Color(ColorTransparency, nColor); + + // Repaint control + impl_paint ( 0, 0, impl_getGraphicsPeer() ); +} + +// XProgressBar + +void SAL_CALL ProgressBar::setBackgroundColor ( sal_Int32 nColor ) +{ + // Ready for multithreading + MutexGuard aGuard (m_aMutex); + + // Safe color for later use. + m_nBackgroundColor = Color(ColorTransparency, nColor); + + // Repaint control + impl_paint ( 0, 0, impl_getGraphicsPeer() ); +} + +// XProgressBar + +void SAL_CALL ProgressBar::setValue ( sal_Int32 nValue ) +{ + // This method is defined for follow things: + // 1) Values >= _nMinRange + // 2) Values <= _nMaxRange + + // Ready for multithreading + MutexGuard aGuard (m_aMutex); + + // save impossible cases + // This method is only defined for valid values + DBG_ASSERT ( (( nValue >= m_nMinRange ) && ( nValue <= m_nMaxRange )), "ProgressBar::setValue()\nNot valid value.\n" ); + + // If new value not valid ... do nothing in release version! + if ( + ( nValue >= m_nMinRange ) && + ( nValue <= m_nMaxRange ) + ) + { + // New value is ok => save this + m_nValue = nValue; + + // Repaint to display changes + impl_paint ( 0, 0, impl_getGraphicsPeer() ); + } +} + +// XProgressBar + +void SAL_CALL ProgressBar::setRange ( sal_Int32 nMin, sal_Int32 nMax ) +{ + // This method is defined for follow things: + // 1) All values of sal_Int32 + // 2) Min < Max + // 3) Min > Max + + // save impossible cases + // This method is only defined for valid values + // If you ignore this, the release version will produce an error "division by zero" in "ProgressBar::setValue()"! + DBG_ASSERT ( ( nMin != nMax ) , "ProgressBar::setRange()\nValues for MIN and MAX are the same. This is not allowed!\n" ); + + // Ready for multithreading + MutexGuard aGuard (m_aMutex); + + // control the values for min and max + if ( nMin < nMax ) + { + // Take correct Min and Max + m_nMinRange = nMin; + m_nMaxRange = nMax; + } + else + { + // Change Min and Max automatically + m_nMinRange = nMax; + m_nMaxRange = nMin; + } + + // assure that m_nValue is within the range + if (m_nMinRange >= m_nValue || m_nValue >= m_nMaxRange) + m_nValue = m_nMinRange; + + impl_recalcRange (); + + // Do not repaint the control at this place!!! + // An old "m_nValue" is set and can not be correct for this new range. + // Next call of "ProgressBar::setValue()" do this. +} + +// XProgressBar + +sal_Int32 SAL_CALL ProgressBar::getValue () +{ + // Ready for multithreading + MutexGuard aGuard (m_aMutex); + + return m_nValue; +} + +// XWindow + +void SAL_CALL ProgressBar::setPosSize ( + sal_Int32 nX, + sal_Int32 nY, + sal_Int32 nWidth, + sal_Int32 nHeight, + sal_Int16 nFlags +) +{ + // Take old size BEFORE you set the new values at baseclass! + // You will control changes. At the other way, the values are the same! + Rectangle aBasePosSize = getPosSize (); + BaseControl::setPosSize (nX, nY, nWidth, nHeight, nFlags); + + // Do only, if size has changed. + if ( + ( nWidth != aBasePosSize.Width ) || + ( nHeight != aBasePosSize.Height ) + ) + { + impl_recalcRange ( ); + impl_paint ( 0, 0, impl_getGraphicsPeer () ); + } +} + +// XControl + +sal_Bool SAL_CALL ProgressBar::setModel( const Reference< XControlModel >& /*xModel*/ ) +{ + // A model is not possible for this control. + return false; +} + +// XControl + +Reference< XControlModel > SAL_CALL ProgressBar::getModel() +{ + // A model is not possible for this control. + return Reference< XControlModel >(); +} + +// protected method + +void ProgressBar::impl_paint ( sal_Int32 nX, sal_Int32 nY, const Reference< XGraphics > & rGraphics ) +{ + // save impossible cases + DBG_ASSERT ( rGraphics.is(), "ProgressBar::paint()\nCalled with invalid Reference< XGraphics > ." ); + + // This paint method is not buffered !! + // Every request paint the completely control. ( but only, if peer exist ) + if ( !rGraphics.is () ) + return; + + MutexGuard aGuard (m_aMutex); + + // Clear background + // (same color for line and fill) + rGraphics->setFillColor ( sal_Int32(m_nBackgroundColor) ); + rGraphics->setLineColor ( sal_Int32(m_nBackgroundColor) ); + rGraphics->drawRect ( nX, nY, impl_getWidth(), impl_getHeight() ); + + // same color for line and fill for blocks + rGraphics->setFillColor ( sal_Int32(m_nForegroundColor) ); + rGraphics->setLineColor ( sal_Int32(m_nForegroundColor) ); + + sal_Int32 nBlockStart = 0; // = left site of new block + sal_Int32 nBlockCount = m_nBlockValue!=0.00 ? static_cast<sal_Int32>((m_nValue-m_nMinRange)/m_nBlockValue) : 0; // = number of next block + + // Draw horizontal progressbar + // decision in "recalcRange()" + if (m_bHorizontal) + { + // Step to left side of window + nBlockStart = nX; + + for ( sal_Int32 i=1; i<=nBlockCount; ++i ) + { + // step free field + nBlockStart += PROGRESSBAR_FREESPACE; + // paint block + rGraphics->drawRect (nBlockStart, nY+PROGRESSBAR_FREESPACE, m_aBlockSize.Width, m_aBlockSize.Height); + // step next free field + nBlockStart += m_aBlockSize.Width; + } + } + // draw vertical progressbar + // decision in "recalcRange()" + else + { + // step to bottom side of window + nBlockStart = nY+impl_getHeight(); + nBlockStart -= m_aBlockSize.Height; + + for ( sal_Int32 i=1; i<=nBlockCount; ++i ) + { + // step free field + nBlockStart -= PROGRESSBAR_FREESPACE; + // paint block + rGraphics->drawRect (nX+PROGRESSBAR_FREESPACE, nBlockStart, m_aBlockSize.Width, m_aBlockSize.Height); + // step next free field + nBlockStart -= m_aBlockSize.Height; + } + } + + // Paint shadow border around the progressbar + rGraphics->setLineColor ( PROGRESSBAR_LINECOLOR_SHADOW ); + rGraphics->drawLine ( nX, nY, impl_getWidth(), nY ); + rGraphics->drawLine ( nX, nY, nX , impl_getHeight() ); + + rGraphics->setLineColor ( PROGRESSBAR_LINECOLOR_BRIGHT ); + rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, impl_getWidth()-1, nY ); + rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, nX , impl_getHeight()-1 ); +} + +// protected method + +void ProgressBar::impl_recalcRange () +{ + MutexGuard aGuard (m_aMutex); + + sal_Int32 nWindowWidth = impl_getWidth(); + sal_Int32 nWindowHeight = impl_getHeight(); + double fBlockHeight; + double fBlockWidth; + double fMaxBlocks; + + if( nWindowWidth > nWindowHeight ) + { + m_bHorizontal = true; + fBlockHeight = (nWindowHeight-(2*PROGRESSBAR_FREESPACE)); + fBlockWidth = fBlockHeight; + fMaxBlocks = nWindowWidth/(fBlockWidth+PROGRESSBAR_FREESPACE); + } + else + { + m_bHorizontal = false; + fBlockWidth = (nWindowWidth-(2*PROGRESSBAR_FREESPACE)); + fBlockHeight = fBlockWidth; + fMaxBlocks = nWindowHeight/(fBlockHeight+PROGRESSBAR_FREESPACE); + } + + double fRange = m_nMaxRange-m_nMinRange; + double fBlockValue = fRange/fMaxBlocks; + + m_nBlockValue = fBlockValue; + m_aBlockSize.Height = static_cast<sal_Int32>(fBlockHeight); + m_aBlockSize.Width = static_cast<sal_Int32>(fBlockWidth); +} + +} // namespace unocontrols + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +stardiv_UnoControls_ProgressBar_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new unocontrols::ProgressBar(context)); +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/progressmonitor.cxx b/UnoControls/source/controls/progressmonitor.cxx new file mode 100644 index 000000000..cf9160ee4 --- /dev/null +++ b/UnoControls/source/controls/progressmonitor.cxx @@ -0,0 +1,854 @@ +/* -*- 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 . + */ + +#include <progressmonitor.hxx> + +#include <com/sun/star/awt/XFixedText.hpp> +#include <com/sun/star/awt/XGraphics.hpp> +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <cppuhelper/typeprovider.hxx> +#include <cppuhelper/queryinterface.hxx> +#include <rtl/ustrbuf.hxx> +#include <tools/debug.hxx> +#include <algorithm> + +#include <progressbar.hxx> + +using namespace ::cppu; +using namespace ::osl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::awt; + +using ::std::vector; + +constexpr OUStringLiteral FIXEDTEXT_SERVICENAME = u"com.sun.star.awt.UnoControlFixedText"; +constexpr OUStringLiteral FIXEDTEXT_MODELNAME = u"com.sun.star.awt.UnoControlFixedTextModel"; +constexpr OUStringLiteral CONTROLNAME_TEXT = u"Text"; // identifier the control in container +constexpr OUStringLiteral CONTROLNAME_PROGRESSBAR = u"ProgressBar"; +constexpr OUStringLiteral BUTTON_SERVICENAME = u"com.sun.star.awt.UnoControlButton"; +constexpr OUStringLiteral CONTROLNAME_BUTTON = u"Button"; +constexpr OUStringLiteral BUTTON_MODELNAME = u"com.sun.star.awt.UnoControlButtonModel"; +constexpr OUStringLiteral DEFAULT_BUTTONLABEL = u"Abbrechen"; + +namespace unocontrols { + +ProgressMonitor::ProgressMonitor( const css::uno::Reference< XComponentContext >& rxContext ) + : BaseContainerControl ( rxContext ) +{ + // It's not allowed to work with member in this method (refcounter !!!) + // But with a HACK (++refcount) its "OK" :-( + osl_atomic_increment(&m_refCount); + + // Create instances for fixedtext, button and progress ... + + m_xTopic_Top.set ( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME, rxContext ), UNO_QUERY ); + m_xText_Top.set ( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME, rxContext ), UNO_QUERY ); + m_xTopic_Bottom.set( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME, rxContext ), UNO_QUERY ); + m_xText_Bottom.set ( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME, rxContext ), UNO_QUERY ); + m_xButton.set ( rxContext->getServiceManager()->createInstanceWithContext( BUTTON_SERVICENAME, rxContext ), UNO_QUERY ); + m_xProgressBar = new ProgressBar(rxContext); + + // ... cast controls to Reference< XControl > (for "setModel"!) ... + css::uno::Reference< XControl > xRef_Topic_Top ( m_xTopic_Top , UNO_QUERY ); + css::uno::Reference< XControl > xRef_Text_Top ( m_xText_Top , UNO_QUERY ); + css::uno::Reference< XControl > xRef_Topic_Bottom ( m_xTopic_Bottom , UNO_QUERY ); + css::uno::Reference< XControl > xRef_Text_Bottom ( m_xText_Bottom , UNO_QUERY ); + css::uno::Reference< XControl > xRef_Button ( m_xButton , UNO_QUERY ); + + // ... set models ... + xRef_Topic_Top->setModel ( css::uno::Reference< XControlModel > ( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_MODELNAME, rxContext ), UNO_QUERY ) ); + xRef_Text_Top->setModel ( css::uno::Reference< XControlModel > ( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_MODELNAME, rxContext ), UNO_QUERY ) ); + xRef_Topic_Bottom->setModel ( css::uno::Reference< XControlModel > ( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_MODELNAME, rxContext ), UNO_QUERY ) ); + xRef_Text_Bottom->setModel ( css::uno::Reference< XControlModel > ( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_MODELNAME, rxContext ), UNO_QUERY ) ); + xRef_Button->setModel ( css::uno::Reference< XControlModel > ( rxContext->getServiceManager()->createInstanceWithContext( BUTTON_MODELNAME, rxContext ), UNO_QUERY ) ); + // ProgressBar has no model !!! + + // ... and add controls to basecontainercontrol! + addControl ( CONTROLNAME_TEXT, xRef_Topic_Top ); + addControl ( CONTROLNAME_TEXT, xRef_Text_Top ); + addControl ( CONTROLNAME_TEXT, xRef_Topic_Bottom ); + addControl ( CONTROLNAME_TEXT, xRef_Text_Bottom ); + addControl ( CONTROLNAME_BUTTON, xRef_Button ); + addControl ( CONTROLNAME_PROGRESSBAR, m_xProgressBar ); + + // FixedText make it automatically visible by himself ... but not the progressbar !!! + // it must be set explicitly + m_xProgressBar->setVisible( true ); + + // Reset to defaults !!! + // (progressbar take automatically its own defaults) + m_xButton->setLabel ( DEFAULT_BUTTONLABEL ); + m_xTopic_Top->setText ( PROGRESSMONITOR_DEFAULT_TOPIC ); + m_xText_Top->setText ( PROGRESSMONITOR_DEFAULT_TEXT ); + m_xTopic_Bottom->setText ( PROGRESSMONITOR_DEFAULT_TOPIC ); + m_xText_Bottom->setText ( PROGRESSMONITOR_DEFAULT_TEXT ); + + osl_atomic_decrement(&m_refCount); +} + +ProgressMonitor::~ProgressMonitor() +{ + impl_cleanMemory (); +} + +// XInterface +Any SAL_CALL ProgressMonitor::queryInterface( const Type& rType ) +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + Any aReturn; + css::uno::Reference< XInterface > xDel = BaseContainerControl::impl_getDelegator(); + if ( xDel.is() ) + { + // If a delegator exists, forward question to its queryInterface. + // Delegator will ask its own queryAggregation! + aReturn = xDel->queryInterface( rType ); + } + else + { + // If a delegator is unknown, forward question to own queryAggregation. + aReturn = queryAggregation( rType ); + } + + return aReturn; +} + +// XInterface +void SAL_CALL ProgressMonitor::acquire() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + BaseControl::acquire(); +} + +// XInterface +void SAL_CALL ProgressMonitor::release() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + BaseControl::release(); +} + +// XTypeProvider +Sequence< Type > SAL_CALL ProgressMonitor::getTypes() +{ + static OTypeCollection ourTypeCollection( + cppu::UnoType<XLayoutConstrains>::get(), + cppu::UnoType<XButton>::get(), + cppu::UnoType<XProgressMonitor>::get(), + BaseContainerControl::getTypes() ); + + return ourTypeCollection.getTypes(); +} + +// XAggregation +Any SAL_CALL ProgressMonitor::queryAggregation( const Type& aType ) +{ + // Ask for my own supported interfaces ... + // Attention: XTypeProvider and XInterface are supported by OComponentHelper! + Any aReturn ( ::cppu::queryInterface( aType , + static_cast< XLayoutConstrains* > ( this ) , + static_cast< XButton* > ( this ) , + static_cast< XProgressMonitor* > ( this ) + ) + ); + + // If searched interface not supported by this class ... + if ( !aReturn.hasValue() ) + { + // ... ask baseclasses. + aReturn = BaseControl::queryAggregation( aType ); + } + + return aReturn; +} + +// XProgressMonitor +void SAL_CALL ProgressMonitor::addText( + const OUString& rTopic, + const OUString& rText, + sal_Bool bbeforeProgress +) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + // Safe impossible cases + // Check valid call of this method. + DBG_ASSERT ( impl_debug_checkParameter ( rTopic, rText ), "ProgressMonitor::addText()\nCall without valid parameters!\n"); + DBG_ASSERT ( !(impl_searchTopic ( rTopic, bbeforeProgress ) != nullptr ), "ProgressMonitor::addText()\nThe text already exist.\n" ); + + // Do nothing (in Release), if topic already exist. + if ( impl_searchTopic ( rTopic, bbeforeProgress ) != nullptr ) + { + return; + } + + // Else ... take memory for new item ... + IMPL_TextlistItem aTextItem; + + // Set values ... + aTextItem.sTopic = rTopic; + aTextItem.sText = rText; + + // ... and insert it in right list. + if ( bbeforeProgress ) + { + maTextlist_Top.push_back( aTextItem ); + } + else + { + maTextlist_Bottom.push_back( aTextItem ); + } + + // ... update window + impl_rebuildFixedText (); + impl_recalcLayout (); +} + +// XProgressMonitor +void SAL_CALL ProgressMonitor::removeText ( const OUString& rTopic, sal_Bool bbeforeProgress ) +{ + // Safe impossible cases + // Check valid call of this method. + DBG_ASSERT ( impl_debug_checkParameter ( rTopic ), "ProgressMonitor::removeText()\nCall without valid parameters!" ); + + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + // Search the topic ... + IMPL_TextlistItem* pSearchItem = impl_searchTopic ( rTopic, bbeforeProgress ); + + if ( pSearchItem == nullptr ) + return; + + // ... delete item from right list ... + if ( bbeforeProgress ) + { + auto itr = std::find_if( maTextlist_Top.begin(), maTextlist_Top.end(), + [&] (IMPL_TextlistItem const &p) + { return &p == pSearchItem; } ); + if (itr != maTextlist_Top.end()) + maTextlist_Top.erase(itr); + } + else + { + auto itr = std::find_if( maTextlist_Bottom.begin(), maTextlist_Bottom.end(), + [&] (IMPL_TextlistItem const &p) + { return &p == pSearchItem; } ); + if (itr != maTextlist_Bottom.end()) + maTextlist_Bottom.erase(itr); + } + + // ... and update window. + impl_rebuildFixedText (); + impl_recalcLayout (); +} + +// XProgressMonitor +void SAL_CALL ProgressMonitor::updateText ( + const OUString& rTopic, + const OUString& rText, + sal_Bool bbeforeProgress +) +{ + // Safe impossible cases + // Check valid call of this method. + DBG_ASSERT ( impl_debug_checkParameter ( rTopic, rText ), "ProgressMonitor::updateText()\nCall without valid parameters!\n" ); + + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + // Search topic ... + IMPL_TextlistItem* pSearchItem = impl_searchTopic ( rTopic, bbeforeProgress ); + + if ( pSearchItem != nullptr ) + { + // ... update text ... + pSearchItem->sText = rText; + + // ... and update window. + impl_rebuildFixedText (); + impl_recalcLayout (); + } +} + +// XProgressBar +void SAL_CALL ProgressMonitor::setForegroundColor ( sal_Int32 nColor ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + m_xProgressBar->setForegroundColor ( nColor ); +} + +// XProgressBar +void SAL_CALL ProgressMonitor::setBackgroundColor ( sal_Int32 nColor ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + m_xProgressBar->setBackgroundColor ( nColor ); +} + +// XProgressBar +void SAL_CALL ProgressMonitor::setValue ( sal_Int32 nValue ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + m_xProgressBar->setValue ( nValue ); +} + +// XProgressBar +void SAL_CALL ProgressMonitor::setRange ( sal_Int32 nMin, sal_Int32 nMax ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + m_xProgressBar->setRange ( nMin, nMax ); +} + +// XProgressBar +sal_Int32 SAL_CALL ProgressMonitor::getValue () +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + return m_xProgressBar->getValue (); +} + +// XButton +void SAL_CALL ProgressMonitor::addActionListener ( const css::uno::Reference< XActionListener > & rListener ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + if ( m_xButton.is () ) + { + m_xButton->addActionListener ( rListener ); + } +} + +// XButton +void SAL_CALL ProgressMonitor::removeActionListener ( const css::uno::Reference< XActionListener > & rListener ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + if ( m_xButton.is () ) + { + m_xButton->removeActionListener ( rListener ); + } +} + +// XButton +void SAL_CALL ProgressMonitor::setLabel ( const OUString& rLabel ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + if ( m_xButton.is () ) + { + m_xButton->setLabel ( rLabel ); + } +} + +// XButton +void SAL_CALL ProgressMonitor::setActionCommand ( const OUString& rCommand ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + if ( m_xButton.is () ) + { + m_xButton->setActionCommand ( rCommand ); + } +} + +// XLayoutConstrains +Size SAL_CALL ProgressMonitor::getMinimumSize () +{ + return Size (PROGRESSMONITOR_DEFAULT_WIDTH, PROGRESSMONITOR_DEFAULT_HEIGHT); +} + +// XLayoutConstrains +Size SAL_CALL ProgressMonitor::getPreferredSize () +{ + // Ready for multithreading + ClearableMutexGuard aGuard ( m_aMutex ); + + // get information about required place of child controls + css::uno::Reference< XLayoutConstrains > xTopicLayout_Top ( m_xTopic_Top , UNO_QUERY ); + css::uno::Reference< XLayoutConstrains > xTopicLayout_Bottom ( m_xTopic_Bottom , UNO_QUERY ); + css::uno::Reference< XLayoutConstrains > xButtonLayout ( m_xButton , UNO_QUERY ); + + Size aTopicSize_Top = xTopicLayout_Top->getPreferredSize (); + Size aTopicSize_Bottom = xTopicLayout_Bottom->getPreferredSize (); + Size aButtonSize = xButtonLayout->getPreferredSize (); + Rectangle aTempRectangle = m_xProgressBar->getPosSize(); + Size aProgressBarSize( aTempRectangle.Width, aTempRectangle.Height ); + + aGuard.clear (); + + // calc preferred size of progressmonitor + sal_Int32 nWidth = 3 * PROGRESSMONITOR_FREEBORDER; + nWidth += aProgressBarSize.Width; + + sal_Int32 nHeight = 6 * PROGRESSMONITOR_FREEBORDER; + nHeight += aTopicSize_Top.Height; + nHeight += aProgressBarSize.Height; + nHeight += aTopicSize_Bottom.Height; + nHeight += 2; // 1 for black line, 1 for white line = 3D-Line! + nHeight += aButtonSize.Height; + + // norm to minimum + if ( nWidth < PROGRESSMONITOR_DEFAULT_WIDTH ) + { + nWidth = PROGRESSMONITOR_DEFAULT_WIDTH; + } + if ( nHeight < PROGRESSMONITOR_DEFAULT_HEIGHT ) + { + nHeight = PROGRESSMONITOR_DEFAULT_HEIGHT; + } + + // return to caller + return Size ( nWidth, nHeight ); +} + +// XLayoutConstrains +Size SAL_CALL ProgressMonitor::calcAdjustedSize ( const Size& /*rNewSize*/ ) +{ + return getPreferredSize (); +} + +// XControl +void SAL_CALL ProgressMonitor::createPeer ( const css::uno::Reference< XToolkit > & rToolkit, const css::uno::Reference< XWindowPeer > & rParent ) +{ + if (!getPeer().is()) + { + BaseContainerControl::createPeer ( rToolkit, rParent ); + + // If user forget to call "setPosSize()", we have still a correct size. + // And a "MinimumSize" IS A "MinimumSize"! + // We change not the position of control at this point. + Size aDefaultSize = getMinimumSize (); + setPosSize ( 0, 0, aDefaultSize.Width, aDefaultSize.Height, PosSize::SIZE ); + } +} + +// XControl +sal_Bool SAL_CALL ProgressMonitor::setModel ( const css::uno::Reference< XControlModel > & /*rModel*/ ) +{ + // We have no model. + return false; +} + +// XControl +css::uno::Reference< XControlModel > SAL_CALL ProgressMonitor::getModel () +{ + // We have no model. + // return (XControlModel*)this; + return css::uno::Reference< XControlModel > (); +} + +// XComponent +void SAL_CALL ProgressMonitor::dispose () +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + // "removeControl()" control the state of a reference + css::uno::Reference< XControl > xRef_Topic_Top ( m_xTopic_Top , UNO_QUERY ); + css::uno::Reference< XControl > xRef_Text_Top ( m_xText_Top , UNO_QUERY ); + css::uno::Reference< XControl > xRef_Topic_Bottom ( m_xTopic_Bottom , UNO_QUERY ); + css::uno::Reference< XControl > xRef_Text_Bottom ( m_xText_Bottom , UNO_QUERY ); + css::uno::Reference< XControl > xRef_Button ( m_xButton , UNO_QUERY ); + + removeControl ( xRef_Topic_Top ); + removeControl ( xRef_Text_Top ); + removeControl ( xRef_Topic_Bottom ); + removeControl ( xRef_Text_Bottom ); + removeControl ( xRef_Button ); + removeControl ( m_xProgressBar ); + + // don't use "...->clear ()" or "... = XFixedText ()" + // when other hold a reference at this object !!! + xRef_Topic_Top->dispose (); + xRef_Text_Top->dispose (); + xRef_Topic_Bottom->dispose (); + xRef_Text_Bottom->dispose (); + xRef_Button->dispose (); + m_xProgressBar->dispose(); + + BaseContainerControl::dispose (); +} + +// XWindow +void SAL_CALL ProgressMonitor::setPosSize ( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nFlags ) +{ + Rectangle aBasePosSize = getPosSize (); + BaseContainerControl::setPosSize (nX, nY, nWidth, nHeight, nFlags); + + // if position or size changed + if ( + ( nWidth != aBasePosSize.Width ) || + ( nHeight != aBasePosSize.Height) + ) + { + // calc new layout for controls + impl_recalcLayout (); + // clear background (!) + // [Children were repainted in "recalcLayout" by setPosSize() automatically!] + getPeer()->invalidate(2); + // and repaint the control + impl_paint ( 0, 0, impl_getGraphicsPeer() ); + } +} + +// protected method +void ProgressMonitor::impl_paint ( sal_Int32 nX, sal_Int32 nY, const css::uno::Reference< XGraphics > & rGraphics ) +{ + if (!rGraphics.is()) + return; + + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + // paint shadowed border around the progressmonitor + rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_SHADOW ); + rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, impl_getWidth()-1, nY ); + rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, nX , impl_getHeight()-1 ); + + rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT ); + rGraphics->drawLine ( nX, nY, impl_getWidth(), nY ); + rGraphics->drawLine ( nX, nY, nX , impl_getHeight() ); + + // Paint 3D-line + rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_SHADOW ); + rGraphics->drawLine ( m_a3DLine.X, m_a3DLine.Y, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y ); + + rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT ); + rGraphics->drawLine ( m_a3DLine.X, m_a3DLine.Y+1, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y+1 ); +} + +// private method +void ProgressMonitor::impl_recalcLayout () +{ + sal_Int32 nX_Button; + sal_Int32 nY_Button; + sal_Int32 nWidth_Button; + sal_Int32 nHeight_Button; + + sal_Int32 nX_ProgressBar; + sal_Int32 nY_ProgressBar; + sal_Int32 nWidth_ProgressBar; + sal_Int32 nHeight_ProgressBar; + + sal_Int32 nX_Text_Top; + sal_Int32 nY_Text_Top; + sal_Int32 nWidth_Text_Top; + sal_Int32 nHeight_Text_Top; + + sal_Int32 nX_Topic_Top; + sal_Int32 nY_Topic_Top; + sal_Int32 nWidth_Topic_Top; + sal_Int32 nHeight_Topic_Top; + + sal_Int32 nX_Text_Bottom; + sal_Int32 nY_Text_Bottom; + sal_Int32 nWidth_Text_Bottom; + sal_Int32 nHeight_Text_Bottom; + + sal_Int32 nX_Topic_Bottom; + sal_Int32 nY_Topic_Bottom; + sal_Int32 nWidth_Topic_Bottom; + sal_Int32 nHeight_Topic_Bottom; + + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + // get information about required place of child controls + css::uno::Reference< XLayoutConstrains > xTopicLayout_Top ( m_xTopic_Top , UNO_QUERY ); + css::uno::Reference< XLayoutConstrains > xTextLayout_Top ( m_xText_Top , UNO_QUERY ); + css::uno::Reference< XLayoutConstrains > xTopicLayout_Bottom ( m_xTopic_Bottom , UNO_QUERY ); + css::uno::Reference< XLayoutConstrains > xTextLayout_Bottom ( m_xText_Bottom , UNO_QUERY ); + css::uno::Reference< XLayoutConstrains > xButtonLayout ( m_xButton , UNO_QUERY ); + + Size aTopicSize_Top = xTopicLayout_Top->getPreferredSize (); + Size aTextSize_Top = xTextLayout_Top->getPreferredSize (); + Size aTopicSize_Bottom = xTopicLayout_Bottom->getPreferredSize (); + Size aTextSize_Bottom = xTextLayout_Bottom->getPreferredSize (); + Size aButtonSize = xButtonLayout->getPreferredSize (); + + // calc position and size of child controls + // Button has preferred size! + nWidth_Button = aButtonSize.Width; + nHeight_Button = aButtonSize.Height; + + // Left column before progressbar has preferred size and fixed position. + // But "Width" is oriented on left column below progressbar to!!! "max(...)" + nX_Topic_Top = PROGRESSMONITOR_FREEBORDER; + nY_Topic_Top = PROGRESSMONITOR_FREEBORDER; + nWidth_Topic_Top = std::max( aTopicSize_Top.Width, aTopicSize_Bottom.Width ); + nHeight_Topic_Top = aTopicSize_Top.Height; + + // Right column before progressbar has relative position to left column ... + // ... and a size as rest of dialog size! + nX_Text_Top = nX_Topic_Top+nWidth_Topic_Top+PROGRESSMONITOR_FREEBORDER; + nY_Text_Top = nY_Topic_Top; + nWidth_Text_Top = std::max ( aTextSize_Top.Width, aTextSize_Bottom.Width ); + // Fix size of this column to minimum! + sal_Int32 nSummaryWidth = nWidth_Text_Top+nWidth_Topic_Top+(3*PROGRESSMONITOR_FREEBORDER); + if ( nSummaryWidth < PROGRESSMONITOR_DEFAULT_WIDTH ) + nWidth_Text_Top = PROGRESSMONITOR_DEFAULT_WIDTH-nWidth_Topic_Top-(3*PROGRESSMONITOR_FREEBORDER); + // Fix size of column to maximum! + if ( nSummaryWidth > impl_getWidth() ) + nWidth_Text_Top = impl_getWidth()-nWidth_Topic_Top-(3*PROGRESSMONITOR_FREEBORDER); + nHeight_Text_Top = nHeight_Topic_Top; + + // Position of progressbar is relative to columns before. + // Progressbar.Width = Dialog.Width !!! + // Progressbar.Height = Button.Height + nX_ProgressBar = nX_Topic_Top; + nY_ProgressBar = nY_Topic_Top+nHeight_Topic_Top+PROGRESSMONITOR_FREEBORDER; + nWidth_ProgressBar = PROGRESSMONITOR_FREEBORDER+nWidth_Topic_Top+nWidth_Text_Top; + nHeight_ProgressBar = nHeight_Button; + + // Oriented by left column before progressbar. + nX_Topic_Bottom = nX_Topic_Top; + nY_Topic_Bottom = nY_ProgressBar+nHeight_ProgressBar+PROGRESSMONITOR_FREEBORDER; + nWidth_Topic_Bottom = nWidth_Topic_Top; + nHeight_Topic_Bottom = aTopicSize_Bottom.Height; + + // Oriented by right column before progressbar. + nX_Text_Bottom = nX_Topic_Bottom+nWidth_Topic_Bottom+PROGRESSMONITOR_FREEBORDER; + nY_Text_Bottom = nY_Topic_Bottom; + nWidth_Text_Bottom = nWidth_Text_Top; + nHeight_Text_Bottom = nHeight_Topic_Bottom; + + // Oriented by progressbar. + nX_Button = nX_ProgressBar+nWidth_ProgressBar-nWidth_Button; + nY_Button = nY_Topic_Bottom+nHeight_Topic_Bottom+PROGRESSMONITOR_FREEBORDER; + + // Calc offsets to center controls + sal_Int32 nDx; + sal_Int32 nDy; + + nDx = ( (2*PROGRESSMONITOR_FREEBORDER)+nWidth_ProgressBar ); + nDy = ( (6*PROGRESSMONITOR_FREEBORDER)+nHeight_Topic_Top+nHeight_ProgressBar+nHeight_Topic_Bottom+2+nHeight_Button ); + + // At this point use original dialog size to center controls! + nDx = (impl_getWidth ()/2)-(nDx/2); + nDy = (impl_getHeight()/2)-(nDy/2); + + if ( nDx<0 ) + { + nDx=0; + } + if ( nDy<0 ) + { + nDy=0; + } + + // Set new position and size on all controls + css::uno::Reference< XWindow > xRef_Topic_Top ( m_xTopic_Top , UNO_QUERY ); + css::uno::Reference< XWindow > xRef_Text_Top ( m_xText_Top , UNO_QUERY ); + css::uno::Reference< XWindow > xRef_Topic_Bottom ( m_xTopic_Bottom , UNO_QUERY ); + css::uno::Reference< XWindow > xRef_Text_Bottom ( m_xText_Bottom , UNO_QUERY ); + css::uno::Reference< XWindow > xRef_Button ( m_xButton , UNO_QUERY ); + + xRef_Topic_Top->setPosSize ( nDx+nX_Topic_Top , nDy+nY_Topic_Top , nWidth_Topic_Top , nHeight_Topic_Top , 15 ); + xRef_Text_Top->setPosSize ( nDx+nX_Text_Top , nDy+nY_Text_Top , nWidth_Text_Top , nHeight_Text_Top , 15 ); + xRef_Topic_Bottom->setPosSize ( nDx+nX_Topic_Bottom , nDy+nY_Topic_Bottom , nWidth_Topic_Bottom , nHeight_Topic_Bottom , 15 ); + xRef_Text_Bottom->setPosSize ( nDx+nX_Text_Bottom , nDy+nY_Text_Bottom , nWidth_Text_Bottom , nHeight_Text_Bottom , 15 ); + xRef_Button->setPosSize ( nDx+nX_Button , nDy+nY_Button , nWidth_Button , nHeight_Button , 15 ); + m_xProgressBar->setPosSize( nDx+nX_ProgressBar, nDy+nY_ProgressBar, nWidth_ProgressBar, nHeight_ProgressBar, 15 ); + + m_a3DLine.X = nDx+nX_Topic_Top; + m_a3DLine.Y = nDy+nY_Topic_Bottom+nHeight_Topic_Bottom+(PROGRESSMONITOR_FREEBORDER/2); + m_a3DLine.Width = nWidth_ProgressBar; + m_a3DLine.Height = nHeight_ProgressBar; + + // All childcontrols make an implicit repaint in setPosSize()! + // Make it also for this 3D-line ... + css::uno::Reference< XGraphics > xGraphics = impl_getGraphicsPeer (); + + xGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_SHADOW ); + xGraphics->drawLine ( m_a3DLine.X, m_a3DLine.Y, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y ); + + xGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT ); + xGraphics->drawLine ( m_a3DLine.X, m_a3DLine.Y+1, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y+1 ); +} + +// private method +void ProgressMonitor::impl_rebuildFixedText () +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + // Rebuild fixedtext before progress + + // Rebuild left site of text + if (m_xTopic_Top.is()) + { + OUStringBuffer aCollectString; + + // Collect all topics from list and format text. + // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!! + for (auto const & rSearchItem : maTextlist_Top) + { + aCollectString.append(rSearchItem.sTopic + "\n"); + } + + m_xTopic_Top->setText ( aCollectString.makeStringAndClear() ); + } + + // Rebuild right site of text + if (m_xText_Top.is()) + { + OUStringBuffer aCollectString; + + // Collect all topics from list and format text. + // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!! + for (auto const & rSearchItem : maTextlist_Top) + { + aCollectString.append(rSearchItem.sText + "\n"); + } + + m_xText_Top->setText ( aCollectString.makeStringAndClear() ); + } + + // Rebuild fixedtext below progress + + // Rebuild left site of text + if (m_xTopic_Bottom.is()) + { + OUStringBuffer aCollectString; + + // Collect all topics from list and format text. + // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!! + for (auto const & rSearchItem : maTextlist_Bottom) + { + aCollectString.append(rSearchItem.sTopic + "\n"); + } + + m_xTopic_Bottom->setText ( aCollectString.makeStringAndClear() ); + } + + // Rebuild right site of text + if (!m_xText_Bottom.is()) + return; + + OUStringBuffer aCollectString; + + // Collect all topics from list and format text. + // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!! + for (auto const & rSearchItem : maTextlist_Bottom) + { + aCollectString.append(rSearchItem.sText + "\n"); + } + + m_xText_Bottom->setText ( aCollectString.makeStringAndClear() ); +} + +// private method +void ProgressMonitor::impl_cleanMemory () +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + // Delete all of lists. + maTextlist_Top.clear(); + maTextlist_Bottom.clear(); +} + +// private method +IMPL_TextlistItem* ProgressMonitor::impl_searchTopic ( std::u16string_view rTopic, bool bbeforeProgress ) +{ + // Get right textlist for following operations. + ::std::vector< IMPL_TextlistItem >* pTextList; + + if (bbeforeProgress) + { + pTextList = &maTextlist_Top; + } + else + { + pTextList = &maTextlist_Bottom; + } + + // Search the topic in textlist. + size_t nPosition = 0; + size_t nCount = pTextList->size(); + + for ( nPosition = 0; nPosition < nCount; ++nPosition ) + { + auto& rSearchItem = pTextList->at( nPosition ); + + if ( rSearchItem.sTopic == rTopic ) + { + // We have found this topic... return a valid pointer. + return &rSearchItem; + } + } + + // We haven't found this topic... return a nonvalid pointer. + return nullptr; +} + +// debug methods + +// addText, updateText +bool ProgressMonitor::impl_debug_checkParameter ( + std::u16string_view rTopic, + std::u16string_view rText +) { + if ( rTopic.empty() ) return false; // "" + + if ( rText.empty() ) return false; // "" + + // Parameter OK ... return true. + return true; +} + +// removeText +bool ProgressMonitor::impl_debug_checkParameter ( std::u16string_view rTopic ) +{ + if ( rTopic.empty() ) return false; // "" + + // Parameter OK ... return true. + return true; +} + +} // namespace unocontrols + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +stardiv_UnoControls_ProgressMonitor_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new unocontrols::ProgressMonitor(context)); +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/statusindicator.cxx b/UnoControls/source/controls/statusindicator.cxx new file mode 100644 index 000000000..6e5f09798 --- /dev/null +++ b/UnoControls/source/controls/statusindicator.cxx @@ -0,0 +1,455 @@ +/* -*- 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 . + */ + +#include <statusindicator.hxx> + +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/awt/XFixedText.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <cppuhelper/queryinterface.hxx> +#include <cppuhelper/typeprovider.hxx> + +#include <progressbar.hxx> + +using namespace ::cppu; +using namespace ::osl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::task; + +constexpr OUStringLiteral FIXEDTEXT_SERVICENAME = u"com.sun.star.awt.UnoControlFixedText"; +constexpr OUStringLiteral FIXEDTEXT_MODELNAME = u"com.sun.star.awt.UnoControlFixedTextModel"; +constexpr OUStringLiteral CONTROLNAME_TEXT = u"Text"; // identifier the control in container +constexpr OUStringLiteral CONTROLNAME_PROGRESSBAR = u"ProgressBar"; // -||- + +namespace unocontrols { + +// construct/destruct + +StatusIndicator::StatusIndicator( const css::uno::Reference< XComponentContext >& rxContext ) + : BaseContainerControl ( rxContext ) +{ + // It's not allowed to work with member in this method (refcounter !!!) + // But with a HACK (++refcount) its "OK" :-( + osl_atomic_increment(&m_refCount); + + // Create instances for fixedtext and progress ... + m_xText.set( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME, rxContext ), UNO_QUERY ); + m_xProgressBar = new ProgressBar(rxContext); + // ... cast controls to css::uno::Reference< XControl > and set model ... + // ( ProgressBar has no model !!! ) + css::uno::Reference< XControl > xTextControl ( m_xText , UNO_QUERY ); + xTextControl->setModel( css::uno::Reference< XControlModel >( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_MODELNAME, rxContext ), UNO_QUERY ) ); + // ... and add controls to basecontainercontrol! + addControl( CONTROLNAME_TEXT, xTextControl ); + addControl( CONTROLNAME_PROGRESSBAR, m_xProgressBar ); + // FixedText make it automatically visible by himself ... but not the progressbar !!! + // it must be set explicitly + m_xProgressBar->setVisible( true ); + // Reset to defaults !!! + // (progressbar take automatically its own defaults) + m_xText->setText( "" ); + + osl_atomic_decrement(&m_refCount); +} + +StatusIndicator::~StatusIndicator() {} + +// XInterface + +Any SAL_CALL StatusIndicator::queryInterface( const Type& rType ) +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + Any aReturn; + css::uno::Reference< XInterface > xDel = BaseContainerControl::impl_getDelegator(); + if ( xDel.is() ) + { + // If a delegator exists, forward question to its queryInterface. + // Delegator will ask its own queryAggregation! + aReturn = xDel->queryInterface( rType ); + } + else + { + // If a delegator is unknown, forward question to own queryAggregation. + aReturn = queryAggregation( rType ); + } + + return aReturn; +} + +// XInterface + +void SAL_CALL StatusIndicator::acquire() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + BaseControl::acquire(); +} + +// XInterface + +void SAL_CALL StatusIndicator::release() noexcept +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + BaseControl::release(); +} + +// XTypeProvider + +Sequence< Type > SAL_CALL StatusIndicator::getTypes() +{ + static OTypeCollection ourTypeCollection( + cppu::UnoType<XLayoutConstrains>::get(), + cppu::UnoType<XStatusIndicator>::get(), + BaseContainerControl::getTypes() ); + + return ourTypeCollection.getTypes(); +} + +// XAggregation + +Any SAL_CALL StatusIndicator::queryAggregation( const Type& aType ) +{ + // Ask for my own supported interfaces ... + // Attention: XTypeProvider and XInterface are supported by OComponentHelper! + Any aReturn ( ::cppu::queryInterface( aType , + static_cast< XLayoutConstrains* > ( this ) , + static_cast< XStatusIndicator* > ( this ) + ) + ); + + // If searched interface not supported by this class ... + if ( !aReturn.hasValue() ) + { + // ... ask baseclasses. + aReturn = BaseControl::queryAggregation( aType ); + } + + return aReturn; +} + +// XStatusIndicator + +void SAL_CALL StatusIndicator::start( const OUString& sText, sal_Int32 nRange ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // Initialize status controls with given values. + m_xText->setText( sText ); + m_xProgressBar->setRange( 0, nRange ); + // force repaint ... fixedtext has changed ! + impl_recalcLayout ( WindowEvent(static_cast< OWeakObject* >(this),0,0,impl_getWidth(),impl_getHeight(),0,0,0,0) ); +} + +// XStatusIndicator + +void SAL_CALL StatusIndicator::end() +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // Clear values of status controls. + m_xText->setText( OUString() ); + m_xProgressBar->setValue( 0 ); + setVisible( false ); +} + +// XStatusIndicator + +void SAL_CALL StatusIndicator::setText( const OUString& sText ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // Take text on right control + m_xText->setText( sText ); +} + +// XStatusIndicator + +void SAL_CALL StatusIndicator::setValue( sal_Int32 nValue ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // Take value on right control + m_xProgressBar->setValue( nValue ); +} + +// XStatusIndicator + +void SAL_CALL StatusIndicator::reset() +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // Clear values of status controls. + // (Don't hide the window! User will reset current values ... but he will not finish using of indicator!) + m_xText->setText( OUString() ); + m_xProgressBar->setValue( 0 ); +} + +// XLayoutConstrains + +Size SAL_CALL StatusIndicator::getMinimumSize () +{ + return Size (STATUSINDICATOR_DEFAULT_WIDTH, STATUSINDICATOR_DEFAULT_HEIGHT); +} + +// XLayoutConstrains + +Size SAL_CALL StatusIndicator::getPreferredSize () +{ + // Ready for multithreading + ClearableMutexGuard aGuard ( m_aMutex ); + + // get information about required place of child controls + css::uno::Reference< XLayoutConstrains > xTextLayout ( m_xText, UNO_QUERY ); + Size aTextSize = xTextLayout->getPreferredSize(); + + aGuard.clear (); + + // calc preferred size of status indicator + sal_Int32 nWidth = impl_getWidth(); + sal_Int32 nHeight = (2*STATUSINDICATOR_FREEBORDER)+aTextSize.Height; + + // norm to minimum + if ( nWidth<STATUSINDICATOR_DEFAULT_WIDTH ) + { + nWidth = STATUSINDICATOR_DEFAULT_WIDTH; + } + if ( nHeight<STATUSINDICATOR_DEFAULT_HEIGHT ) + { + nHeight = STATUSINDICATOR_DEFAULT_HEIGHT; + } + + // return to caller + return Size ( nWidth, nHeight ); +} + +// XLayoutConstrains + +Size SAL_CALL StatusIndicator::calcAdjustedSize ( const Size& /*rNewSize*/ ) +{ + return getPreferredSize (); +} + +// XControl + +void SAL_CALL StatusIndicator::createPeer ( + const css::uno::Reference< XToolkit > & rToolkit, + const css::uno::Reference< XWindowPeer > & rParent +) +{ + if( !getPeer().is() ) + { + BaseContainerControl::createPeer( rToolkit, rParent ); + + // If user forget to call "setPosSize()", we have still a correct size. + // And a "MinimumSize" IS A "MinimumSize"! + // We change not the position of control at this point. + Size aDefaultSize = getMinimumSize (); + setPosSize ( 0, 0, aDefaultSize.Width, aDefaultSize.Height, PosSize::SIZE ); + } +} + +// XControl + +sal_Bool SAL_CALL StatusIndicator::setModel ( const css::uno::Reference< XControlModel > & /*rModel*/ ) +{ + // We have no model. + return false; +} + +// XControl + +css::uno::Reference< XControlModel > SAL_CALL StatusIndicator::getModel () +{ + // We have no model. + // return (XControlModel*)this; + return css::uno::Reference< XControlModel > (); +} + +// XComponent + +void SAL_CALL StatusIndicator::dispose () +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + // "removeControl()" control the state of a reference + css::uno::Reference< XControl > xTextControl ( m_xText , UNO_QUERY ); + + removeControl( xTextControl ); + removeControl( m_xProgressBar ); + + // don't use "...->clear ()" or "... = XFixedText ()" + // when other hold a reference at this object !!! + xTextControl->dispose(); + m_xProgressBar->dispose(); + BaseContainerControl::dispose(); +} + +// XWindow + +void SAL_CALL StatusIndicator::setPosSize ( + sal_Int32 nX, + sal_Int32 nY, + sal_Int32 nWidth, + sal_Int32 nHeight, + sal_Int16 nFlags +) +{ + Rectangle aBasePosSize = getPosSize (); + BaseContainerControl::setPosSize (nX, nY, nWidth, nHeight, nFlags); + + // if position or size changed + if ( + ( nWidth != aBasePosSize.Width ) || + ( nHeight != aBasePosSize.Height) + ) + { + // calc new layout for controls + impl_recalcLayout ( WindowEvent(static_cast< OWeakObject* >(this),0,0,nWidth,nHeight,0,0,0,0) ); + // clear background (!) + // [Children were repainted in "recalcLayout" by setPosSize() automatically!] + getPeer()->invalidate(2); + // and repaint the control + impl_paint ( 0, 0, impl_getGraphicsPeer() ); + } +} + +// protected method + +WindowDescriptor StatusIndicator::impl_getWindowDescriptor( const css::uno::Reference< XWindowPeer >& xParentPeer ) +{ + WindowDescriptor aDescriptor; + + aDescriptor.Type = WindowClass_SIMPLE; + aDescriptor.WindowServiceName = "floatingwindow"; + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = xParentPeer; + aDescriptor.Bounds = getPosSize (); + + return aDescriptor; +} + +// protected method + +void StatusIndicator::impl_paint ( sal_Int32 nX, sal_Int32 nY, const css::uno::Reference< XGraphics > & rGraphics ) +{ + // This paint method is not buffered! + // Every request paint the completely control. (But only, if peer exist) + if ( !rGraphics.is () ) + return; + + MutexGuard aGuard (m_aMutex); + + // background = gray + css::uno::Reference< XWindowPeer > xPeer( impl_getPeerWindow(), UNO_QUERY ); + if( xPeer.is() ) + xPeer->setBackground( STATUSINDICATOR_BACKGROUNDCOLOR ); + + // FixedText background = gray + css::uno::Reference< XControl > xTextControl( m_xText, UNO_QUERY ); + xPeer = xTextControl->getPeer(); + if( xPeer.is() ) + xPeer->setBackground( STATUSINDICATOR_BACKGROUNDCOLOR ); + + // Progress background = gray + xPeer = m_xProgressBar->getPeer(); + if( xPeer.is() ) + xPeer->setBackground( STATUSINDICATOR_BACKGROUNDCOLOR ); + + // paint shadow border + rGraphics->setLineColor ( STATUSINDICATOR_LINECOLOR_BRIGHT ); + rGraphics->drawLine ( nX, nY, impl_getWidth(), nY ); + rGraphics->drawLine ( nX, nY, nX , impl_getHeight() ); + + rGraphics->setLineColor ( STATUSINDICATOR_LINECOLOR_SHADOW ); + rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, impl_getWidth()-1, nY ); + rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, nX , impl_getHeight()-1 ); +} + +// protected method + +void StatusIndicator::impl_recalcLayout ( const WindowEvent& aEvent ) +{ + sal_Int32 nX_ProgressBar; + sal_Int32 nY_ProgressBar; + sal_Int32 nWidth_ProgressBar; + sal_Int32 nHeight_ProgressBar; + sal_Int32 nX_Text; + sal_Int32 nY_Text; + sal_Int32 nWidth_Text; + sal_Int32 nHeight_Text; + + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ); + + // get information about required place of child controls + Size aWindowSize ( aEvent.Width, aEvent.Height ); + css::uno::Reference< XLayoutConstrains > xTextLayout ( m_xText, UNO_QUERY ); + Size aTextSize = xTextLayout->getPreferredSize(); + + if( aWindowSize.Width < STATUSINDICATOR_DEFAULT_WIDTH ) + { + aWindowSize.Width = STATUSINDICATOR_DEFAULT_WIDTH; + } + if( aWindowSize.Height < STATUSINDICATOR_DEFAULT_HEIGHT ) + { + aWindowSize.Height = STATUSINDICATOR_DEFAULT_HEIGHT; + } + + // calc position and size of child controls + nX_Text = STATUSINDICATOR_FREEBORDER; + nY_Text = STATUSINDICATOR_FREEBORDER; + nWidth_Text = aTextSize.Width; + nHeight_Text = aTextSize.Height; + + nX_ProgressBar = nX_Text+nWidth_Text+STATUSINDICATOR_FREEBORDER; + nY_ProgressBar = nY_Text; + nWidth_ProgressBar = aWindowSize.Width-nWidth_Text-(3*STATUSINDICATOR_FREEBORDER); + nHeight_ProgressBar = nHeight_Text; + + // Set new position and size on all controls + css::uno::Reference< XWindow > xTextWindow ( m_xText , UNO_QUERY ); + + xTextWindow->setPosSize ( nX_Text , nY_Text , nWidth_Text , nHeight_Text , 15 ); + m_xProgressBar->setPosSize( nX_ProgressBar, nY_ProgressBar, nWidth_ProgressBar, nHeight_ProgressBar, 15 ); +} + +} // namespace unocontrols + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +stardiv_UnoControls_StatusIndicator_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new unocontrols::StatusIndicator(context)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/inc/OConnectionPointContainerHelper.hxx b/UnoControls/source/inc/OConnectionPointContainerHelper.hxx new file mode 100644 index 000000000..c1e46b457 --- /dev/null +++ b/UnoControls/source/inc/OConnectionPointContainerHelper.hxx @@ -0,0 +1,105 @@ +/* -*- 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/lang/XConnectionPointContainer.hpp> +#include <cppuhelper/weak.hxx> +#include <comphelper/multicontainer2.hxx> + +namespace com::sun::star::lang { class XConnectionPoint; } + +namespace unocontrols { + +class OConnectionPointContainerHelper final : public css::lang::XConnectionPointContainer + , public ::cppu::OWeakObject +{ +public: + OConnectionPointContainerHelper( ::osl::Mutex& aMutex ); + + virtual ~OConnectionPointContainerHelper() 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; + + // XConnectionPointContainer + + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getConnectionPointTypes() override; + + virtual css::uno::Reference< css::lang::XConnectionPoint > SAL_CALL queryConnectionPoint( + const css::uno::Type& aType + ) override; + + virtual void SAL_CALL advise( + const css::uno::Type& aType , + const css::uno::Reference< css::uno::XInterface >& xListener + ) override; + + virtual void SAL_CALL unadvise( + const css::uno::Type& aType , + const css::uno::Reference< css::uno::XInterface >& xListener + ) override; + + // public but impl method! + // Is necessary to get container member at OConnectionPoint-instance. + // Impl methods are not threadsafe! + // "Parent" function must do this. + comphelper::OMultiTypeInterfaceContainerHelper2& impl_getMultiTypeContainer() { return m_aMultiTypeContainer; } + +private: + ::osl::Mutex& m_aSharedMutex; + comphelper::OMultiTypeInterfaceContainerHelper2 m_aMultiTypeContainer; // Container to hold listener +}; + +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/inc/OConnectionPointHelper.hxx b/UnoControls/source/inc/OConnectionPointHelper.hxx new file mode 100644 index 000000000..96529b20e --- /dev/null +++ b/UnoControls/source/inc/OConnectionPointHelper.hxx @@ -0,0 +1,108 @@ +/* -*- 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/lang/XConnectionPoint.hpp> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/weakref.hxx> + +namespace com::sun::star::lang { class XConnectionPointContainer; } +namespace unocontrols { class OConnectionPointContainerHelper; } + +namespace unocontrols { + +class OConnectionPointHelper final : public css::lang::XConnectionPoint + , public ::cppu::OWeakObject +{ +public: + OConnectionPointHelper( ::osl::Mutex& aMutex , + OConnectionPointContainerHelper* pContainerImplementation , + css::uno::Type const & aType ); + + virtual ~OConnectionPointHelper() 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; + + // XConnectionPoint + + virtual css::uno::Type SAL_CALL getConnectionType() override; + + virtual css::uno::Reference< css::lang::XConnectionPointContainer > SAL_CALL getConnectionPointContainer() override; + + virtual void SAL_CALL advise( + const css::uno::Reference< css::uno::XInterface >& xListener + ) override; + + virtual void SAL_CALL unadvise( const css::uno::Reference< css::uno::XInterface >& xListener ) override; + + virtual css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > SAL_CALL getConnections() override; + +private: + bool impl_LockContainer(); + + void impl_UnlockContainer(); + +private: + + ::osl::Mutex& m_aSharedMutex; + css::uno::WeakReference< css::lang::XConnectionPointContainer > m_oContainerWeakReference; // Reference to container-class!. Don't use Reference<...> + // It is a ring-reference => and must be a wekreference! + OConnectionPointContainerHelper* m_pContainerImplementation; + css::uno::Type m_aInterfaceType; + css::uno::Reference< css::uno::XInterface > m_xLock; +}; + +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/inc/framecontrol.hxx b/UnoControls/source/inc/framecontrol.hxx new file mode 100644 index 000000000..790aae1aa --- /dev/null +++ b/UnoControls/source/inc/framecontrol.hxx @@ -0,0 +1,176 @@ +/* -*- 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/lang/XConnectionPointContainer.hpp> +#include <cppuhelper/propshlp.hxx> +#include <rtl/ref.hxx> + +#include <basecontrol.hxx> + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::frame { class XFrame2; } +namespace unocontrols { class OConnectionPointContainerHelper; } + +namespace unocontrols { + +class FrameControl final : public css::awt::XControlModel + , public css::lang::XConnectionPointContainer + , public BaseControl // This order is necessary for right initialization of m_aMutex! + , public ::cppu::OBroadcastHelper + , public ::cppu::OPropertySetHelper +{ +public: + + FrameControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + + virtual ~FrameControl() override; + + // XInterface + + 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 + + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + + // XAggregation + + css::uno::Any SAL_CALL queryAggregation( + const css::uno::Type& aType + ) override; + + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() 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; + + // XView + + virtual sal_Bool SAL_CALL setGraphics( + const css::uno::Reference< css::awt::XGraphics >& xDevice + ) override; + + virtual css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics() override; + + // XConnectionPointContainer + + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getConnectionPointTypes() override; + + virtual css::uno::Reference< css::lang::XConnectionPoint > SAL_CALL queryConnectionPoint( + const css::uno::Type& aType + ) override; + + virtual void SAL_CALL advise( + const css::uno::Type& aType , + const css::uno::Reference< css::uno::XInterface >& xListener + ) override; + + virtual void SAL_CALL unadvise( + const css::uno::Type& aType , + const css::uno::Reference< css::uno::XInterface >& xListener + ) override; + +private: + + using OPropertySetHelper::getFastPropertyValue; + + // OPropertySetHelper + + virtual sal_Bool SAL_CALL convertFastPropertyValue( + css::uno::Any& rConvertedValue , + css::uno::Any& rOldValue , + sal_Int32 nHandle , + const css::uno::Any& rValue + ) override; + + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle , + const css::uno::Any& rValue + ) override; + + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue , + sal_Int32 nHandle ) const override; + + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + // XPropertySet + + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + + // BaseControl + + virtual css::awt::WindowDescriptor impl_getWindowDescriptor( + const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer + ) override; + + void impl_createFrame( const css::uno::Reference< css::awt::XWindowPeer >& xPeer , + const OUString& sURL , + const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ); + + void impl_deleteFrame(); + + css::uno::Reference< css::frame::XFrame2 > m_xFrame; + OUString m_sComponentURL; + css::uno::Sequence< css::beans::PropertyValue > m_seqLoaderArguments; + rtl::Reference<OConnectionPointContainerHelper> m_aConnectionPointContainer; + +}; + +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/inc/progressbar.hxx b/UnoControls/source/inc/progressbar.hxx new file mode 100644 index 000000000..d31758b1c --- /dev/null +++ b/UnoControls/source/inc/progressbar.hxx @@ -0,0 +1,140 @@ +/* -*- 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/XProgressBar.hpp> + +#include <climits> + +#include <tools/color.hxx> + +#include <basecontrol.hxx> + +namespace unocontrols { + +#define PROGRESSBAR_DEFAULT_BLOCKDIMENSION Size(1,1) +constexpr Color PROGRESSBAR_DEFAULT_FOREGROUNDCOLOR = COL_BLUE; +constexpr Color PROGRESSBAR_DEFAULT_BACKGROUNDCOLOR = COL_LIGHTGRAY; +constexpr bool PROGRESSBAR_DEFAULT_HORIZONTAL = true; +constexpr auto PROGRESSBAR_FREESPACE = 4; +constexpr auto PROGRESSBAR_DEFAULT_MINRANGE = INT_MIN; +constexpr auto PROGRESSBAR_DEFAULT_MAXRANGE = INT_MAX; +constexpr auto PROGRESSBAR_DEFAULT_VALUE = INT_MIN; +constexpr auto PROGRESSBAR_DEFAULT_BLOCKVALUE = 1; +constexpr sal_Int32 PROGRESSBAR_LINECOLOR_BRIGHT = sal_Int32(COL_WHITE); +constexpr sal_Int32 PROGRESSBAR_LINECOLOR_SHADOW = sal_Int32(COL_BLACK); + +class ProgressBar final : public css::awt::XControlModel + , public css::awt::XProgressBar + , public BaseControl +{ +public: + + ProgressBar( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + + virtual ~ProgressBar() override; + + // XInterface + + 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 + + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + + // XAggregation + + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& aType ) override; + + // XProgressBar + + virtual void SAL_CALL setForegroundColor( sal_Int32 nColor ) override; + + virtual void SAL_CALL setBackgroundColor( sal_Int32 nColor ) override; + + virtual void SAL_CALL setValue( sal_Int32 nValue ) override; + + virtual void SAL_CALL setRange( + sal_Int32 nMin , + sal_Int32 nMax + ) override; + + virtual sal_Int32 SAL_CALL getValue() override; + + // XWindow + + virtual void SAL_CALL setPosSize( + sal_Int32 nX , + sal_Int32 nY , + sal_Int32 nWidth , + sal_Int32 nHeight , + sal_Int16 nFlags + ) override; + + // XControl + + 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; + +private: + virtual void impl_paint( + sal_Int32 nX , + sal_Int32 nY , + const css::uno::Reference< css::awt::XGraphics >& xGraphics + ) override; + + void impl_recalcRange(); + + bool m_bHorizontal; // orientation for steps [true=horizontal/false=vertical] + css::awt::Size m_aBlockSize; // width and height of a block [>=0,0] + Color m_nForegroundColor; // (alpha,r,g,b) + Color m_nBackgroundColor; // (alpha,r,g,b) + sal_Int32 m_nMinRange; // lowest value = 0% [long, <_nMaxRange] + sal_Int32 m_nMaxRange; // highest value = 100% [long, >_nMinRange] + double m_nBlockValue; // value for one block [long, >0] + sal_Int32 m_nValue; // value for progress [long] + +}; + +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/inc/progressmonitor.hxx b/UnoControls/source/inc/progressmonitor.hxx new file mode 100644 index 000000000..90d1ffa18 --- /dev/null +++ b/UnoControls/source/inc/progressmonitor.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 . + */ + +#pragma once + +#include <com/sun/star/awt/XProgressMonitor.hpp> +#include <com/sun/star/awt/XButton.hpp> +#include <com/sun/star/awt/XLayoutConstrains.hpp> +#include <rtl/ref.hxx> + +#include <vector> + +#include <basecontainercontrol.hxx> + +namespace com::sun::star::awt { class XFixedText; } +namespace com::sun::star::awt { class XControlModel; } + +namespace unocontrols { + +class ProgressBar; + +#define PROGRESSMONITOR_FREEBORDER 10 // border around and between the controls +inline constexpr OUStringLiteral PROGRESSMONITOR_DEFAULT_TOPIC = u""; +inline constexpr OUStringLiteral PROGRESSMONITOR_DEFAULT_TEXT = u""; +#define PROGRESSMONITOR_LINECOLOR_BRIGHT sal_Int32(Color( 0xFF, 0xFF, 0xFF )) // white +#define PROGRESSMONITOR_LINECOLOR_SHADOW sal_Int32(Color( 0x00, 0x00, 0x00 )) // black +#define PROGRESSMONITOR_DEFAULT_WIDTH 350 +#define PROGRESSMONITOR_DEFAULT_HEIGHT 100 + +/// Item of TextList +struct IMPL_TextlistItem +{ + OUString sTopic; /// Left site of textline in dialog + OUString sText; /// Right site of textline in dialog +}; + +class ProgressMonitor final : public css::awt::XLayoutConstrains + , public css::awt::XButton + , public css::awt::XProgressMonitor + , public BaseContainerControl +{ +public: + ProgressMonitor( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + + virtual ~ProgressMonitor() 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; + + // XAggregation + + virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& aType ) override; + + // XProgressMonitor + + /** + @short add topic to dialog + @descr Add a topic with a text in right textlist (used for FixedText-member).<BR> + ( "beforeProgress" fix the right list ). The dialog metric is recalculated. + + @seealso removeText(), updateText() + + @param sTopic Name of topic<BR> + [sTopic != "" && sTopic != NULL] + @param sText Value of topic<BR> + [sText != "" && sText != NULL] + @param bbeforeProgress Position of topic<BR> + [True => before progressbar / False => below progressbar] + @onerror DEBUG = Assertion<BR> + RELEASE = nothing + */ + + virtual void SAL_CALL addText( + const OUString& sTopic , + const OUString& sText , + sal_Bool bbeforeProgress + ) override; + + virtual void SAL_CALL removeText( + const OUString& sTopic , + sal_Bool bbeforeProgress + ) override; + + virtual void SAL_CALL updateText( + const OUString& sTopic , + const OUString& sText , + sal_Bool bbeforeProgress + ) override; + + // XProgressBar + + virtual void SAL_CALL setForegroundColor( sal_Int32 nColor ) override; + + virtual void SAL_CALL setBackgroundColor( sal_Int32 nColor ) override; + + virtual void SAL_CALL setValue( sal_Int32 nValue ) override; + + virtual void SAL_CALL setRange( sal_Int32 nMin , + sal_Int32 nMax ) override; + + virtual sal_Int32 SAL_CALL getValue() override; + + // XButton + + virtual void SAL_CALL addActionListener( + const css::uno::Reference< css::awt::XActionListener >& xListener + ) override; + + virtual void SAL_CALL removeActionListener( + const css::uno::Reference< css::awt::XActionListener >& xListener + ) override; + + virtual void SAL_CALL setLabel( const OUString& sLabel ) override; + + virtual void SAL_CALL setActionCommand( const OUString& sCommand ) override; + + // XLayoutConstrains + + virtual css::awt::Size SAL_CALL getMinimumSize() override; + + virtual css::awt::Size SAL_CALL getPreferredSize() override; + + virtual css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) 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; + + // XWindow + + virtual void SAL_CALL setPosSize( sal_Int32 nX , + sal_Int32 nY , + sal_Int32 nWidth , + sal_Int32 nHeight , + sal_Int16 nFlags ) override; + +private: + virtual void impl_paint( sal_Int32 nX , + sal_Int32 nY , + const css::uno::Reference< css::awt::XGraphics >& xGraphics ) override; + + using BaseControl::impl_recalcLayout; + + void impl_recalcLayout(); + + void impl_rebuildFixedText(); + + void impl_cleanMemory(); + + IMPL_TextlistItem* impl_searchTopic( std::u16string_view sTopic , bool bbeforeProgress ); + +// debug methods + + static bool impl_debug_checkParameter( std::u16string_view sTopic, std::u16string_view sText ); // addText, updateText + static bool impl_debug_checkParameter( std::u16string_view rTopic ); // removeText + +// private variables + +private: + ::std::vector < IMPL_TextlistItem > maTextlist_Top; // Elements before progress + css::uno::Reference< css::awt::XFixedText > m_xTopic_Top; // (used, if parameter "beforeProgress"=true in "addText, updateText, removeText") + css::uno::Reference< css::awt::XFixedText > m_xText_Top; + + ::std::vector < IMPL_TextlistItem > maTextlist_Bottom; // Elements below of progress + css::uno::Reference< css::awt::XFixedText > m_xTopic_Bottom; // (used, if parameter "beforeProgress"=false in "addText, updateText, removeText") + css::uno::Reference< css::awt::XFixedText > m_xText_Bottom; + + rtl::Reference<ProgressBar> m_xProgressBar; + css::uno::Reference< css::awt::XButton > m_xButton; + css::awt::Rectangle m_a3DLine; +}; + +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/inc/statusindicator.hxx b/UnoControls/source/inc/statusindicator.hxx new file mode 100644 index 000000000..34bce92be --- /dev/null +++ b/UnoControls/source/inc/statusindicator.hxx @@ -0,0 +1,172 @@ +/* -*- 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/XLayoutConstrains.hpp> +#include <com/sun/star/task/XStatusIndicator.hpp> +#include <rtl/ref.hxx> +#include <tools/color.hxx> +#include <basecontainercontrol.hxx> + +namespace com::sun::star::awt { class XControlModel; } +namespace com::sun::star::awt { class XFixedText; } +namespace com::sun::star::awt { class XGraphics; } +namespace com::sun::star::awt { class XToolkit; } +namespace com::sun::star::awt { class XWindowPeer; } + +namespace unocontrols { + +class ProgressBar; + +constexpr auto STATUSINDICATOR_FREEBORDER = 5; // border around and between the controls +constexpr auto STATUSINDICATOR_DEFAULT_WIDTH = 300; +constexpr auto STATUSINDICATOR_DEFAULT_HEIGHT = 25; +constexpr sal_Int32 STATUSINDICATOR_BACKGROUNDCOLOR = sal_Int32(COL_LIGHTGRAY); +constexpr sal_Int32 STATUSINDICATOR_LINECOLOR_BRIGHT = sal_Int32(COL_WHITE); +constexpr sal_Int32 STATUSINDICATOR_LINECOLOR_SHADOW = sal_Int32(COL_BLACK); + +class StatusIndicator final : public css::awt::XLayoutConstrains + , public css::task::XStatusIndicator + , public BaseContainerControl +{ +public: + StatusIndicator( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + + virtual ~StatusIndicator() 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; + + // XAggregation + + virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& aType ) override; + + // XStatusIndicator + + virtual void SAL_CALL start( + const OUString& sText , + sal_Int32 nRange + ) override; + + virtual void SAL_CALL end() override; + + virtual void SAL_CALL reset() override; + + virtual void SAL_CALL setText( const OUString& sText ) override; + + virtual void SAL_CALL setValue( sal_Int32 nValue ) override; + + // XLayoutConstrains + + virtual css::awt::Size SAL_CALL getMinimumSize() override; + + virtual css::awt::Size SAL_CALL getPreferredSize() override; + + virtual css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) 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; + + // XWindow + + virtual void SAL_CALL setPosSize( sal_Int32 nX , + sal_Int32 nY , + sal_Int32 nWidth , + sal_Int32 nHeight , + sal_Int16 nFlags ) override; + +private: + 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 > & rGraphics + ) override; + + virtual void impl_recalcLayout( const css::awt::WindowEvent& aEvent ) override; + + css::uno::Reference< css::awt::XFixedText > m_xText; + rtl::Reference<ProgressBar> m_xProgressBar; + +}; + +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/util/ctl.component b/UnoControls/util/ctl.component new file mode 100644 index 000000000..43c978bfb --- /dev/null +++ b/UnoControls/util/ctl.component @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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 . + --> + +<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="stardiv.UnoControls.FrameControl" + constructor="stardiv_UnoControls_FrameControl_get_implementation"> + <service name="com.sun.star.frame.FrameControl" /> + </implementation> + <implementation name="stardiv.UnoControls.ProgressBar" + constructor="stardiv_UnoControls_ProgressBar_get_implementation"/> + <implementation name="stardiv.UnoControls.ProgressMonitor" + constructor="stardiv_UnoControls_ProgressMonitor_get_implementation"/> + <implementation name="stardiv.UnoControls.StatusIndicator" + constructor="stardiv_UnoControls_StatusIndicator_get_implementation"/> +</component> |