diff options
Diffstat (limited to 'UnoControls')
28 files changed, 11733 insertions, 0 deletions
diff --git a/UnoControls/inc/basecontainercontrol.hxx b/UnoControls/inc/basecontainercontrol.hxx new file mode 100644 index 000000000000..34563ec3441d --- /dev/null +++ b/UnoControls/inc/basecontainercontrol.hxx @@ -0,0 +1,567 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _UNOCONTROLS_BASECONTAINERCONTROL_CTRL_HXX +#define _UNOCONTROLS_BASECONTAINERCONTROL_CTRL_HXX + +//____________________________________________________________________________________________________________ +// includes of other projects +//____________________________________________________________________________________________________________ + +#include <com/sun/star/lang/XServiceName.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XContainer.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/container/XNameReplace.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/container/XSet.hpp> +#include <com/sun/star/container/ContainerEvent.hpp> +#include <com/sun/star/container/XIndexReplace.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <tools/list.hxx> + +//____________________________________________________________________________________________________________ +// includes of my own project +//____________________________________________________________________________________________________________ +#include "basecontrol.hxx" + +//____________________________________________________________________________________________________________ +// "namespaces" +//____________________________________________________________________________________________________________ + +namespace unocontrols{ + +#define UNO3_REFERENCE ::com::sun::star::uno::Reference +#define UNO3_XCONTROL ::com::sun::star::awt::XControl +#define UNO3_OUSTRING ::rtl::OUString +#define UNO3_XCONTROLMODEL ::com::sun::star::awt::XControlModel +#define UNO3_XCONTROLCONTAINER ::com::sun::star::awt::XControlContainer +#define UNO3_XMULTISERVICEFACTORY ::com::sun::star::lang::XMultiServiceFactory +#define UNO3_TYPE ::com::sun::star::uno::Type +#define UNO3_RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException +#define UNO3_XTOOLKIT ::com::sun::star::awt::XToolkit +#define UNO3_XWINDOWPEER ::com::sun::star::awt::XWindowPeer +#define UNO3_EVENTOBJECT ::com::sun::star::lang::EventObject +#define UNO3_SEQUENCE ::com::sun::star::uno::Sequence +#define UNO3_XCONTAINERLISTENER ::com::sun::star::container::XContainerListener +#define UNO3_ANY ::com::sun::star::uno::Any +#define UNO3_XTABCONTROLLER ::com::sun::star::awt::XTabController +#define UNO3_WINDOWDESCRIPTOR ::com::sun::star::awt::WindowDescriptor +#define UNO3_XGRAPHICS ::com::sun::star::awt::XGraphics +#define UNO3_OMULTITYPEINTERFACECONTAINERHELPER ::cppu::OMultiTypeInterfaceContainerHelper +#define UNO3_ILLEGALARGUMENTEXCEPTION ::com::sun::star::lang::IllegalArgumentException + +//____________________________________________________________________________________________________________ +// structs, types, forwards +//____________________________________________________________________________________________________________ + +struct IMPL_ControlInfo +{ + UNO3_REFERENCE< UNO3_XCONTROL > xControl ; + UNO3_OUSTRING sName ; +}; + +// makro define a list-class for struct IMPL_ControlInfo! +class IMPL_ControlInfoList ; +DECLARE_LIST( IMPL_ControlInfoList, IMPL_ControlInfo* ) + +//____________________________________________________________________________________________________________ +// classes +//____________________________________________________________________________________________________________ + +class BaseContainerControl : public UNO3_XCONTROLMODEL + , public UNO3_XCONTROLCONTAINER + , public BaseControl +{ + +//____________________________________________________________________________________________________________ +// public methods +//____________________________________________________________________________________________________________ + +public: + + //________________________________________________________________________________________________________ + // construct/destruct + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + BaseContainerControl( const UNO3_REFERENCE< UNO3_XMULTISERVICEFACTORY >& xFactory ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual ~BaseContainerControl(); + + //________________________________________________________________________________________________________ + // 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 UNO3_ANY SAL_CALL queryInterface( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XTypeProvider + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short get information about supported interfaces + @descr - + + @seealso XTypeProvider + + @param - + + @return Sequence of types of all supported interfaces + + @onerror A RuntimeException is thrown. + */ + + virtual UNO3_SEQUENCE< UNO3_TYPE > SAL_CALL getTypes() throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XAggregation + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_ANY SAL_CALL queryAggregation( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XControl + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL createPeer( const UNO3_REFERENCE< UNO3_XTOOLKIT >& xToolkit , + const UNO3_REFERENCE< UNO3_XWINDOWPEER >& xParent ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL setModel( const UNO3_REFERENCE< UNO3_XCONTROLMODEL >& xModel ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_REFERENCE< UNO3_XCONTROLMODEL > SAL_CALL getModel() throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XComponent + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL dispose() throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XEventListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL disposing( const UNO3_EVENTOBJECT& rEvent ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XControlContainer + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addControl( const UNO3_OUSTRING& sName , + const UNO3_REFERENCE< UNO3_XCONTROL >& xControl ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addContainerListener( const UNO3_REFERENCE< UNO3_XCONTAINERLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeControl( const UNO3_REFERENCE< UNO3_XCONTROL >& xControl ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeContainerListener( const UNO3_REFERENCE< UNO3_XCONTAINERLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setStatusText( const UNO3_OUSTRING& sStatusText ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_REFERENCE< UNO3_XCONTROL > SAL_CALL getControl( const UNO3_OUSTRING& sName) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_SEQUENCE< UNO3_REFERENCE< UNO3_XCONTROL > > SAL_CALL getControls() throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XUnoControlContainer + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addTabController( const UNO3_REFERENCE< UNO3_XTABCONTROLLER >& xTabController ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeTabController( const UNO3_REFERENCE< UNO3_XTABCONTROLLER >& xTabController ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setTabControllers( const UNO3_SEQUENCE< UNO3_REFERENCE< UNO3_XTABCONTROLLER > >& xTabControllers ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_SEQUENCE< UNO3_REFERENCE< UNO3_XTABCONTROLLER > > SAL_CALL getTabControllers() throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XWindow + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw( UNO3_RUNTIMEEXCEPTION ); + +//____________________________________________________________________________________________________________ +// protected methods +//____________________________________________________________________________________________________________ + +protected: + using OComponentHelper::disposing; + /**_______________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_WINDOWDESCRIPTOR* impl_getWindowDescriptor( const UNO3_REFERENCE< UNO3_XWINDOWPEER >& xParentPeer ); + + /**_______________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void impl_paint( sal_Int32 nX , + sal_Int32 nY , + const UNO3_REFERENCE< UNO3_XGRAPHICS >& xGraphics ); + +//____________________________________________________________________________________________________________ +// private methods +//____________________________________________________________________________________________________________ + +private: + + /**_______________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + void impl_activateTabControllers(); + + /**_______________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + void impl_cleanMemory(); + +//____________________________________________________________________________________________________________ +// private variables +//____________________________________________________________________________________________________________ + +private: + + IMPL_ControlInfoList* m_pControlInfoList ; /// list of pointer of "struct IMPL_ControlInfo" to hold child-controls + UNO3_SEQUENCE< UNO3_REFERENCE< UNO3_XTABCONTROLLER > > m_xTabControllerList ; /// list of references of XTabController to hold tab-order in this container + UNO3_OMULTITYPEINTERFACECONTAINERHELPER m_aListeners ; + +}; // class BaseContainerControl + +} // namespace unocontrols + +#endif // ifndef _UNOCONTROLS_BASECONTAINERCONTROL_CTRL_HXX diff --git a/UnoControls/inc/basecontrol.hxx b/UnoControls/inc/basecontrol.hxx new file mode 100644 index 000000000000..050fd10fa2cc --- /dev/null +++ b/UnoControls/inc/basecontrol.hxx @@ -0,0 +1,1231 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _UNOCONTROLS_BASECONTROL_CTRL_HXX +#define _UNOCONTROLS_BASECONTROL_CTRL_HXX + +//____________________________________________________________________________________________________________ +// includes of other projects +//____________________________________________________________________________________________________________ + +#include <com/sun/star/awt/XKeyListener.hpp> +#include <com/sun/star/awt/XPaintListener.hpp> +#include <com/sun/star/awt/KeyEvent.hpp> +#include <com/sun/star/awt/KeyModifier.hpp> +#include <com/sun/star/awt/XMouseMotionListener.hpp> +#include <com/sun/star/awt/FocusEvent.hpp> +#include <com/sun/star/awt/XWindowListener.hpp> +#include <com/sun/star/awt/XActivateListener.hpp> +#include <com/sun/star/awt/MouseEvent.hpp> +#include <com/sun/star/awt/XTopWindowListener.hpp> +#include <com/sun/star/awt/PaintEvent.hpp> +#include <com/sun/star/awt/InputEvent.hpp> +#include <com/sun/star/awt/KeyGroup.hpp> +#include <com/sun/star/awt/Key.hpp> +#include <com/sun/star/awt/WindowEvent.hpp> +#include <com/sun/star/awt/XMouseListener.hpp> +#include <com/sun/star/awt/KeyFunction.hpp> +#include <com/sun/star/awt/FocusChangeReason.hpp> +#include <com/sun/star/awt/MouseButton.hpp> +#include <com/sun/star/awt/XFocusListener.hpp> +#include <com/sun/star/awt/XFileDialog.hpp> +#include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/awt/XListBox.hpp> +#include <com/sun/star/awt/XProgressMonitor.hpp> +#include <com/sun/star/awt/TextAlign.hpp> +#include <com/sun/star/awt/XScrollBar.hpp> +#include <com/sun/star/awt/XVclContainerPeer.hpp> +#include <com/sun/star/awt/XTabControllerModel.hpp> +#include <com/sun/star/awt/XMessageBox.hpp> +#include <com/sun/star/awt/XTextEditField.hpp> +#include <com/sun/star/awt/Style.hpp> +#include <com/sun/star/awt/XTimeField.hpp> +#include <com/sun/star/awt/XVclWindowPeer.hpp> +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/awt/XSpinField.hpp> +#include <com/sun/star/awt/XUnoControlContainer.hpp> +#include <com/sun/star/awt/XTextLayoutConstrains.hpp> +#include <com/sun/star/awt/XNumericField.hpp> +#include <com/sun/star/awt/XButton.hpp> +#include <com/sun/star/awt/XTextArea.hpp> +#include <com/sun/star/awt/XImageButton.hpp> +#include <com/sun/star/awt/XFixedText.hpp> +#include <com/sun/star/awt/XControlContainer.hpp> +#include <com/sun/star/awt/XDialog.hpp> +#include <com/sun/star/awt/ScrollBarOrientation.hpp> +#include <com/sun/star/awt/XRadioButton.hpp> +#include <com/sun/star/awt/XCurrencyField.hpp> +#include <com/sun/star/awt/XPatternField.hpp> +#include <com/sun/star/awt/VclWindowPeerAttribute.hpp> +#include <com/sun/star/awt/XTabController.hpp> +#include <com/sun/star/awt/XVclContainer.hpp> +#include <com/sun/star/awt/XDateField.hpp> +#include <com/sun/star/awt/XComboBox.hpp> +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XCheckBox.hpp> +#include <com/sun/star/awt/MessageBoxCommand.hpp> +#include <com/sun/star/awt/XLayoutConstrains.hpp> +#include <com/sun/star/awt/XProgressBar.hpp> +#include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/awt/XView.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <osl/mutex.hxx> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/component.hxx> + +//____________________________________________________________________________________________________________ +// includes of my project +//____________________________________________________________________________________________________________ +#include "multiplexer.hxx" + +//____________________________________________________________________________________________________________ +// "namespaces" +//____________________________________________________________________________________________________________ + +namespace unocontrols{ + +#define UNO3_ANY ::com::sun::star::uno::Any +#define UNO3_EVENTOBJECT ::com::sun::star::lang::EventObject +#define UNO3_MUTEX ::osl::Mutex +#define UNO3_OCOMPONENTHELPER ::cppu::OComponentHelper +#define UNO3_OUSTRING ::rtl::OUString +#define UNO3_PAINTEVENT ::com::sun::star::awt::PaintEvent +#define UNO3_RECTANGLE ::com::sun::star::awt::Rectangle +#define UNO3_REFERENCE ::com::sun::star::uno::Reference +#define UNO3_RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException +#define UNO3_SEQUENCE ::com::sun::star::uno::Sequence +#define UNO3_SIZE ::com::sun::star::awt::Size +#define UNO3_TYPE ::com::sun::star::uno::Type +#define UNO3_WINDOWDESCRIPTOR ::com::sun::star::awt::WindowDescriptor +#define UNO3_XCONTROL ::com::sun::star::awt::XControl +#define UNO3_XCONTROLMODEL ::com::sun::star::awt::XControlModel +#define UNO3_XEVENTLISTENER ::com::sun::star::lang::XEventListener +#define UNO3_XFOCUSLISTENER ::com::sun::star::awt::XFocusListener +#define UNO3_XGRAPHICS ::com::sun::star::awt::XGraphics +#define UNO3_XKEYLISTENER ::com::sun::star::awt::XKeyListener +#define UNO3_XMOUSELISTENER ::com::sun::star::awt::XMouseListener +#define UNO3_XMOUSEMOTIONLISTENER ::com::sun::star::awt::XMouseMotionListener +#define UNO3_XMULTISERVICEFACTORY ::com::sun::star::lang::XMultiServiceFactory +#define UNO3_XPAINTLISTENER ::com::sun::star::awt::XPaintListener +#define UNO3_XSERVICEINFO ::com::sun::star::lang::XServiceInfo +#define UNO3_XTOOLKIT ::com::sun::star::awt::XToolkit +#define UNO3_XVIEW ::com::sun::star::awt::XView +#define UNO3_XWINDOW ::com::sun::star::awt::XWindow +#define UNO3_XWINDOWLISTENER ::com::sun::star::awt::XWindowListener +#define UNO3_XWINDOWPEER ::com::sun::star::awt::XWindowPeer +#define UNO3_XINTERFACE ::com::sun::star::uno::XInterface + +//____________________________________________________________________________________________________________ +// macros +//____________________________________________________________________________________________________________ + +#define TRGB_COLORDATA(TRANSPARENCE,RED,GREEN,BLUE) \ + ((sal_Int32)(((sal_uInt32)((sal_uInt8)(BLUE))))|(((sal_uInt32)((sal_uInt8)(GREEN)))<<8)|(((sal_uInt32)((sal_uInt8)(RED)))<<16)|(((sal_uInt32)((sal_uInt8)(TRANSPARENCE)))<<24)) + +//____________________________________________________________________________________________________________ +// structs +//____________________________________________________________________________________________________________ + +struct IMPL_MutexContainer +{ + // Is necassery to initialize "BaseControl" and make this class thread-safe. + UNO3_MUTEX m_aMutex ; +}; + +//____________________________________________________________________________________________________________ +// classes +//____________________________________________________________________________________________________________ + +class BaseControl : public UNO3_XSERVICEINFO + , public UNO3_XPAINTLISTENER + , public UNO3_XWINDOWLISTENER + , public UNO3_XVIEW + , public UNO3_XWINDOW + , public UNO3_XCONTROL + , public IMPL_MutexContainer + , public UNO3_OCOMPONENTHELPER +{ +//____________________________________________________________________________________________________________ +// public methods +//____________________________________________________________________________________________________________ + +public: + + //________________________________________________________________________________________________________ + // construct/destruct + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + BaseControl( const UNO3_REFERENCE< UNO3_XMULTISERVICEFACTORY >& xFactory ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual ~BaseControl(); + + //________________________________________________________________________________________________________ + // 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 UNO3_ANY SAL_CALL queryInterface( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short increment refcount + @descr - + + @seealso XInterface + @seealso release() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL acquire() throw(); + + /**_______________________________________________________________________________________________________ + @short decrement refcount + @descr - + + @seealso XInterface + @seealso acquire() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL release() throw(); + + //________________________________________________________________________________________________________ + // XTypeProvider + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short get information about supported interfaces + @descr - + + @seealso XTypeProvider + + @param - + + @return Sequence of types of all supported interfaces + + @onerror A RuntimeException is thrown. + */ + + virtual UNO3_SEQUENCE< UNO3_TYPE > SAL_CALL getTypes() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short get implementation id + @descr This ID is neccessary for UNO-caching. If there no ID, cache is disabled. + Another way, cache is enabled. + + @seealso XTypeProvider + + @param - + + @return ID as Sequence of byte + + @onerror A RuntimeException is thrown. + */ + + virtual UNO3_SEQUENCE< sal_Int8 > SAL_CALL getImplementationId() throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XAggregation + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setDelegator( const UNO3_REFERENCE< UNO3_XINTERFACE >& xDelegator ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_ANY SAL_CALL queryAggregation( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XServiceInfo + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL supportsService( const UNO3_OUSTRING& sServiceName ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_OUSTRING SAL_CALL getImplementationName() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_SEQUENCE< UNO3_OUSTRING > SAL_CALL getSupportedServiceNames() throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XComponent + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL dispose() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addEventListener( const UNO3_REFERENCE< UNO3_XEVENTLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeEventListener( const UNO3_REFERENCE< UNO3_XEVENTLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XControl + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL createPeer( const UNO3_REFERENCE< UNO3_XTOOLKIT >& xToolkit, const UNO3_REFERENCE< UNO3_XWINDOWPEER >& xParent ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setContext( const UNO3_REFERENCE< UNO3_XINTERFACE >& xContext ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL setModel( const UNO3_REFERENCE< UNO3_XCONTROLMODEL >& xModel ) throw( UNO3_RUNTIMEEXCEPTION ) = 0 ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setDesignMode( sal_Bool bOn ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_REFERENCE< UNO3_XINTERFACE > SAL_CALL getContext() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_REFERENCE< UNO3_XCONTROLMODEL > SAL_CALL getModel() throw( UNO3_RUNTIMEEXCEPTION ) = 0; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_REFERENCE< UNO3_XWINDOWPEER > SAL_CALL getPeer() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_REFERENCE< UNO3_XVIEW > SAL_CALL getView() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL isDesignMode() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL isTransparent() throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XWindow + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setPosSize( sal_Int32 nX , + sal_Int32 nY , + sal_Int32 nWidth , + sal_Int32 nHeight , + sal_Int16 nFlags ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setEnable( sal_Bool bEnable ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setFocus() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_RECTANGLE SAL_CALL getPosSize() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addWindowListener( const UNO3_REFERENCE< UNO3_XWINDOWLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addFocusListener( const UNO3_REFERENCE< UNO3_XFOCUSLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addKeyListener( const UNO3_REFERENCE< UNO3_XKEYLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addMouseListener( const UNO3_REFERENCE< UNO3_XMOUSELISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addMouseMotionListener( const UNO3_REFERENCE< UNO3_XMOUSEMOTIONLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addPaintListener( const UNO3_REFERENCE< UNO3_XPAINTLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeWindowListener( const UNO3_REFERENCE< UNO3_XWINDOWLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeFocusListener( const UNO3_REFERENCE< UNO3_XFOCUSLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeKeyListener( const UNO3_REFERENCE< UNO3_XKEYLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeMouseListener( const UNO3_REFERENCE< UNO3_XMOUSELISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeMouseMotionListener( const UNO3_REFERENCE< UNO3_XMOUSEMOTIONLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removePaintListener( const UNO3_REFERENCE< UNO3_XPAINTLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XView + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL draw( sal_Int32 nX , + sal_Int32 nY ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL setGraphics( const UNO3_REFERENCE< UNO3_XGRAPHICS >& xDevice ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setZoom( float fZoomX , + float fZoomY ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_REFERENCE< UNO3_XGRAPHICS > SAL_CALL getGraphics() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_SIZE SAL_CALL getSize() throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // UNO3_XEVENTLISTENER + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL disposing( const UNO3_EVENTOBJECT& rSource ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XPaintListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowPaint( const UNO3_PAINTEVENT& rEvent ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XWindowListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowResized( const UNO3_WINDOWEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ); + virtual void SAL_CALL windowMoved( const UNO3_WINDOWEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ); + virtual void SAL_CALL windowShown( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ); + virtual void SAL_CALL windowHidden( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // impl but public method to register service + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + static const UNO3_SEQUENCE< UNO3_OUSTRING > impl_getStaticSupportedServiceNames(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + static const UNO3_OUSTRING impl_getStaticImplementationName(); + +//____________________________________________________________________________________________________________ +// protected methods +//____________________________________________________________________________________________________________ + +protected: + using OComponentHelper::disposing; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + const UNO3_REFERENCE< UNO3_XMULTISERVICEFACTORY > impl_getMultiServiceFactory(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + const UNO3_REFERENCE< UNO3_XWINDOW > impl_getPeerWindow(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + const UNO3_REFERENCE< UNO3_XGRAPHICS > impl_getGraphicsPeer(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + const sal_Int32& impl_getWidth(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + const sal_Int32& impl_getHeight(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_WINDOWDESCRIPTOR* impl_getWindowDescriptor( const UNO3_REFERENCE< UNO3_XWINDOWPEER >& xParentPeer ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void impl_paint( sal_Int32 nX , + sal_Int32 nY , + const UNO3_REFERENCE< UNO3_XGRAPHICS >& xGraphics ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void impl_recalcLayout( const UNO3_WINDOWEVENT& aEvent ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + UNO3_REFERENCE< UNO3_XINTERFACE > impl_getDelegator(); + +//____________________________________________________________________________________________________________ +// private methods +//____________________________________________________________________________________________________________ + +private: + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + void impl_releasePeer(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + OMRCListenerMultiplexerHelper* impl_getMultiplexer(); + +//____________________________________________________________________________________________________________ +// private variables +//____________________________________________________________________________________________________________ + +private: + + UNO3_REFERENCE< UNO3_XMULTISERVICEFACTORY > m_xFactory ; + UNO3_REFERENCE< UNO3_XINTERFACE > m_xDelegator ; + OMRCListenerMultiplexerHelper* m_pMultiplexer ; // multiplex events + UNO3_REFERENCE< UNO3_XINTERFACE > m_xMultiplexer ; + UNO3_REFERENCE< UNO3_XINTERFACE > m_xContext ; + UNO3_REFERENCE< UNO3_XWINDOWPEER > m_xPeer ; + UNO3_REFERENCE< UNO3_XWINDOW > m_xPeerWindow ; + UNO3_REFERENCE< UNO3_XGRAPHICS > m_xGraphicsView ; // graphics for ::com::sun::star::awt::XView-operations + UNO3_REFERENCE< UNO3_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 ; + sal_Bool m_bVisible ; // Some state flags + sal_Bool m_bInDesignMode ; + sal_Bool m_bEnable ; + +}; // class BaseControl + +} // namespace unocontrols + +#endif // ifndef _UNOCONTROLS_BASECONTROL_CTRL_HXX diff --git a/UnoControls/inc/definesunocontrols.hxx b/UnoControls/inc/definesunocontrols.hxx new file mode 100644 index 000000000000..cf072736c4b5 --- /dev/null +++ b/UnoControls/inc/definesunocontrols.hxx @@ -0,0 +1,135 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _UNOCONTROLS_DEFINES_CTRL_HXX +#define _UNOCONTROLS_DEFINES_CTRL_HXX + +//------------------------------------------------------------------------------------------------------------------- +// includes +#include <limits.h> // defines for min/max of INT + +namespace unocontrols{ + +//------------------------------------------------------------------------------------------------------------------- +// global defines for all UnoControls +//------------------------------------------------------------------------------------------------------------------- +#define UNOCONTROLS_TRGB_COLORDATA( t,r,g,b ) ((INT32)(((UINT32)((UINT8)(b))))|(((UINT32)((UINT8)(g)))<<8)|(((UINT32)((UINT8)(r)))<<16)|(((UINT32)((UINT8)(t)))<<24)) +//------------------------------------------------------------------------------------------------------------------- + +// defines for BaseControl +#ifdef _UNOCONTROLS_BASECONTROL_CTRL_HXX + #define BASECONTROL_IDLCLASSNAME "BaseControl" + #define BASECONTROL_DEFAULT_PMULTIPLEXER NULL + #define BASECONTROL_DEFAULT_X 0 + #define BASECONTROL_DEFAULT_Y 0 + #define BASECONTROL_DEFAULT_WIDTH 100 + #define BASECONTROL_DEFAULT_HEIGHT 100 + #define BASECONTROL_DEFAULT_VISIBLE FALSE + #define BASECONTROL_DEFAULT_INDESIGNMODE FALSE + #define BASECONTROL_DEFAULT_ENABLE TRUE + #define BASECONTROL_SERVICE_VCLTOOLKIT "com.sun.star.awt.VclToolkit" +#endif +//------------------------------------------------------------------------------------------------------------------- + +//------------------------------------------------------------------------------------------------------------------- +// defines for BaseContainerControl +#ifdef _UNOCONTROLS_BASECONTAINERCONTROL_CTRL_HXX + #define BASECONTAINERCONTROL_IDLCLASSNAME "BaseContainerControl" +#endif +//------------------------------------------------------------------------------------------------------------------- + +//------------------------------------------------------------------------------------------------------------------- +// defines for ProgressBar +#ifdef _UNOCONTROLS_PROGRESSBAR_CTRL_HXX + #define PROGRESSBAR_IDLCLASSNAME "XProgressbar" + #define PROGRESSBAR_SERVICENAME "com.sun.star.awt.XProgressBar" + #define PROGRESSBAR_IMPLEMENTATIONNAME "stardiv.UnoControls.ProgressBar" + #define PROGRESSBAR_FREEBORDER 2 + #define PROGRESSBAR_DEFAULT_HORIZONTAL TRUE + #define PROGRESSBAR_DEFAULT_BLOCKDIMENSION Size(1,1) + #define PROGRESSBAR_DEFAULT_BACKGROUNDCOLOR UNOCONTROLS_TRGB_COLORDATA( 0x00, 0xC0, 0xC0, 0xC0 ) // lightgray + #define PROGRESSBAR_DEFAULT_FOREGROUNDCOLOR UNOCONTROLS_TRGB_COLORDATA( 0x00, 0x00, 0x00, 0x80 ) // blue + #define PROGRESSBAR_DEFAULT_MINRANGE INT_MIN + #define PROGRESSBAR_DEFAULT_MAXRANGE INT_MAX + #define PROGRESSBAR_DEFAULT_BLOCKVALUE 1 + #define PROGRESSBAR_DEFAULT_VALUE PROGRESSBAR_DEFAULT_MINRANGE + #define PROGRESSBAR_LINECOLOR_BRIGHT UNOCONTROLS_TRGB_COLORDATA( 0x00, 0xFF, 0xFF, 0xFF ) // white + #define PROGRESSBAR_LINECOLOR_SHADOW UNOCONTROLS_TRGB_COLORDATA( 0x00, 0x00, 0x00, 0x00 ) // black +#endif +//------------------------------------------------------------------------------------------------------------------- + +//------------------------------------------------------------------------------------------------------------------- +// defines for FrameControl +#ifdef _UNOCONTROLS_FRAMECONTROL_CTRL_HXX + #define FRAMECONTROL_IDLCLASSNAME "FrameControl" + #define FRAMECONTROL_SERVICENAME "com.sun.star.frame.FrameControl" + #define FRAMECONTROL_IMPLEMENTATIONNAME "stardiv.UnoControls.FrameControl" + #define FRAMECONTROL_DEFAULT_COMPONENTURL "private:factory/swriter" + #define FRAMECONTROL_PROPERTYNAME_LOADERARGUMENTS "LoaderArguments" + #define FRAMECONTROL_PROPERTYNAME_COMPONENTURL "ComponentURL" + #define FRAMECONTROL_PROPERTYNAME_FRAME "Frame" + #define FRAMECONTROL_PROPERTYNAME_IDLCLASSES "IDLClasses" + #define FRAMECONTROL_ERRORTEXT_VOSENSHURE "This is an invalid property handle." + #define FRAMECONTROL_PROPERTY_COUNT 4 // you must count the propertys + #define FRAMECONTROL_PROPERTY_COMPONENTURL 0 // Id must be the index into the array + #define FRAMECONTROL_PROPERTY_FRAME 1 + #define FRAMECONTROL_PROPERTY_IDLCLASSES 2 + #define FRAMECONTROL_PROPERTY_LOADERARGUMENTS 3 +#endif +//------------------------------------------------------------------------------------------------------------------- + +//------------------------------------------------------------------------------------------------------------------- +// defines for ProgressMonitor +#ifdef _UNOCONTROLS_PROGRESSMONITOR_CTRL_HXX + #define PROGRESSMONITOR_IDLCLASSNAME "XProgressMonitor" + #define PROGRESSMONITOR_SERVICENAME "com.sun.star.awt.XProgressMonitor" + #define PROGRESSMONITOR_IMPLEMENTATIONNAME "stardiv.UnoControls.ProgressMonitor" + #define PROGRESSMONITOR_FREEBORDER 10 // border around and between the controls + #define PROGRESSMONITOR_WIDTH_RELATION 4 // reserve 1/4 for button width and rest for progressbar width + #define PROGRESSMONITOR_HEIGHT_RELATION 5 // reserve 1/5 for button and progressbar heigth and rest for text height + #define PROGRESSMONITOR_FIXEDTEXT_SERVICENAME "com.sun.star.awt.UnoControlFixedText" + #define PROGRESSMONITOR_BUTTON_SERVICENAME "com.sun.star.awt.UnoControlButton" + #define PROGRESSMONITOR_FIXEDTEXT_MODELNAME "com.sun.star.awt.UnoControlFixedTextModel" + #define PROGRESSMONITOR_BUTTON_MODELNAME "com.sun.star.awt.UnoControlButtonModel" + #define PROGRESSMONITOR_CONTROLNAME_TEXT "Text" // identifier the control in container + #define PROGRESSMONITOR_CONTROLNAME_BUTTON "Button" // -||- + #define PROGRESSMONITOR_CONTROLNAME_PROGRESSBAR "ProgressBar" // -||- + #define PROGRESSMONITOR_DEFAULT_BUTTONLABEL "Abbrechen" + #define PROGRESSMONITOR_DEFAULT_TOPIC "\0" + #define PROGRESSMONITOR_DEFAULT_TEXT "\0" + #define PROGRESSMONITOR_BACKGROUNDCOLOR UNOCONTROLS_TRGB_COLORDATA( 0x00, 0xC0, 0xC0, 0xC0 ) // lighgray + #define PROGRESSMONITOR_LINECOLOR_BRIGHT UNOCONTROLS_TRGB_COLORDATA( 0x00, 0xFF, 0xFF, 0xFF ) // white + #define PROGRESSMONITOR_LINECOLOR_SHADOW UNOCONTROLS_TRGB_COLORDATA( 0x00, 0x00, 0x00, 0x00 ) // black + #define PROGRESSMONITOR_HEIGHT_PROGRESSBAR 15 + #define PROGRESSMONITOR_DEFAULT_WIDTH 350 + #define PROGRESSMONITOR_DEFAULT_HEIGHT 100 +#endif +//------------------------------------------------------------------------------------------------------------------- + +} // namespace unocontrols + +#endif // #ifndef _UNOCONTROLS_DEFINES_CTRL_HXX diff --git a/UnoControls/inc/multiplexer.hxx b/UnoControls/inc/multiplexer.hxx new file mode 100644 index 000000000000..b22513e5f16c --- /dev/null +++ b/UnoControls/inc/multiplexer.hxx @@ -0,0 +1,771 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _UNOCONTROLS_MULTIPLEXER_HXX +#define _UNOCONTROLS_MULTIPLEXER_HXX + +//____________________________________________________________________________________________________________ +// includes of other projects +//____________________________________________________________________________________________________________ + +#include <com/sun/star/awt/XKeyListener.hpp> +#include <com/sun/star/awt/XPaintListener.hpp> +#include <com/sun/star/awt/KeyEvent.hpp> +#include <com/sun/star/awt/KeyModifier.hpp> +#include <com/sun/star/awt/XMouseMotionListener.hpp> +#include <com/sun/star/awt/FocusEvent.hpp> +#include <com/sun/star/awt/XWindowListener.hpp> +#include <com/sun/star/awt/XActivateListener.hpp> +#include <com/sun/star/awt/MouseEvent.hpp> +#include <com/sun/star/awt/XTopWindowListener.hpp> +#include <com/sun/star/awt/PaintEvent.hpp> +#include <com/sun/star/awt/InputEvent.hpp> +#include <com/sun/star/awt/KeyGroup.hpp> +#include <com/sun/star/awt/Key.hpp> +#include <com/sun/star/awt/WindowEvent.hpp> +#include <com/sun/star/awt/XMouseListener.hpp> +#include <com/sun/star/awt/KeyFunction.hpp> +#include <com/sun/star/awt/FocusChangeReason.hpp> +#include <com/sun/star/awt/MouseButton.hpp> +#include <com/sun/star/awt/XFocusListener.hpp> +#include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/awt/PosSize.hpp> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/interfacecontainer.hxx> +//____________________________________________________________________________________________________________ +// includes of my own project +//____________________________________________________________________________________________________________ + +//____________________________________________________________________________________________________________ +// "namespaces" +//____________________________________________________________________________________________________________ + +namespace unocontrols{ + +#define UNO3_OWEAKOBJECT ::cppu::OWeakObject +#define UNO3_XWINDOW ::com::sun::star::awt::XWindow +#define UNO3_REFERENCE ::com::sun::star::uno::Reference +#define UNO3_WEAKREFERENCE ::com::sun::star::uno::WeakReference +#define UNO3_MUTEX ::osl::Mutex +#define UNO3_XWINDOWLISTENER ::com::sun::star::awt::XWindowListener +#define UNO3_XKEYLISTENER ::com::sun::star::awt::XKeyListener +#define UNO3_XMOUSELISTENER ::com::sun::star::awt::XMouseListener +#define UNO3_XMOUSEMOTIONLISTENER ::com::sun::star::awt::XMouseMotionListener +#define UNO3_XPAINTLISTENER ::com::sun::star::awt::XPaintListener +#define UNO3_XTOPWINDOWLISTENER ::com::sun::star::awt::XTopWindowListener +#define UNO3_XFOCUSLISTENER ::com::sun::star::awt::XFocusListener +#define UNO3_ANY ::com::sun::star::uno::Any +#define UNO3_TYPE ::com::sun::star::uno::Type +#define UNO3_RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException +#define UNO3_XINTERFACE ::com::sun::star::uno::XInterface +#define UNO3_EVENTOBJECT ::com::sun::star::lang::EventObject +#define UNO3_FOCUSEVENT ::com::sun::star::awt::FocusEvent +#define UNO3_WINDOWEVENT ::com::sun::star::awt::WindowEvent +#define UNO3_KEYEVENT ::com::sun::star::awt::KeyEvent +#define UNO3_MOUSEEVENT ::com::sun::star::awt::MouseEvent +#define UNO3_PAINTEVENT ::com::sun::star::awt::PaintEvent +#define UNO3_OMULTITYPEINTERFACECONTAINERHELPER ::cppu::OMultiTypeInterfaceContainerHelper + +//____________________________________________________________________________________________________________ +// class +//____________________________________________________________________________________________________________ + +class OMRCListenerMultiplexerHelper : public UNO3_XFOCUSLISTENER + , public UNO3_XWINDOWLISTENER + , public UNO3_XKEYLISTENER + , public UNO3_XMOUSELISTENER + , public UNO3_XMOUSEMOTIONLISTENER + , public UNO3_XPAINTLISTENER + , public UNO3_XTOPWINDOWLISTENER + , public UNO3_OWEAKOBJECT +{ + +//____________________________________________________________________________________________________________ +// public methods +//____________________________________________________________________________________________________________ + +public: + + //________________________________________________________________________________________________________ + // construct/destruct + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short constructor + @descr Create a Multiplexer of XWindowEvents. + + @seealso - + + @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. + + @return - + + @onerror - + */ + + OMRCListenerMultiplexerHelper( const UNO3_REFERENCE< UNO3_XWINDOW >& xControl , + const UNO3_REFERENCE< UNO3_XWINDOW >& xPeer ); + + /**_______________________________________________________________________________________________________ + @short copy-constructor + @descr + + @seealso - + + @param rCopyInstance C++-Reference to instance to make copy from. + + @return - + + @onerror - + */ + + OMRCListenerMultiplexerHelper( const OMRCListenerMultiplexerHelper& aCopyInstance ); + + /**_______________________________________________________________________________________________________ + @short destructor + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + ~OMRCListenerMultiplexerHelper(); + + //________________________________________________________________________________________________________ + // 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 UNO3_ANY SAL_CALL queryInterface( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short increment refcount + @descr - + + @seealso XInterface + @seealso release() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL acquire() throw(); + + /**_______________________________________________________________________________________________________ + @short decrement refcount + @descr - + + @seealso XInterface + @seealso acquire() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL release() throw(); + + //________________________________________________________________________________________________________ + // operator + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + operator UNO3_REFERENCE< UNO3_XINTERFACE >() const; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + OMRCListenerMultiplexerHelper& operator= ( const OMRCListenerMultiplexerHelper& aCopyInstance ); + + //________________________________________________________________________________________________________ + // container methods + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short Remove all listeners from the previous set peer and add the needed listeners to rPeer. + @descr - + + @seealso - + + @param rPeer The peer from which the original events are dispatched. Null is allowed. + + @return - + + @onerror - + */ + + void setPeer( const UNO3_REFERENCE< UNO3_XWINDOW >& xPeer ); + + /**_______________________________________________________________________________________________________ + @short Remove all listeners and send a disposing message. + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + void disposeAndClear(); + + /**_______________________________________________________________________________________________________ + @short Add the specified listener to the source. + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + void advise( const UNO3_TYPE& aType , + const UNO3_REFERENCE< UNO3_XINTERFACE >& xListener ); + + /**_______________________________________________________________________________________________________ + @short Remove the specified listener from the source. + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + void unadvise( const UNO3_TYPE& aType , + const UNO3_REFERENCE< UNO3_XINTERFACE >& xListener ); + + //________________________________________________________________________________________________________ + // XEventListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL disposing(const UNO3_EVENTOBJECT& aSource) throw( UNO3_RUNTIMEEXCEPTION ) ; + + //________________________________________________________________________________________________________ + // XFocusListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL focusGained(const UNO3_FOCUSEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL focusLost(const UNO3_FOCUSEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + //________________________________________________________________________________________________________ + // XWindowListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowResized(const UNO3_WINDOWEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowMoved(const UNO3_WINDOWEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowShown(const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowHidden(const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + //________________________________________________________________________________________________________ + // XKeyListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL keyPressed( const UNO3_KEYEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL keyReleased( const UNO3_KEYEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + //________________________________________________________________________________________________________ + // XMouseListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL mousePressed(const UNO3_MOUSEEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL mouseReleased(const UNO3_MOUSEEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL mouseEntered(const UNO3_MOUSEEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL mouseExited(const UNO3_MOUSEEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + //________________________________________________________________________________________________________ + // XMouseMotionListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL mouseDragged(const UNO3_MOUSEEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL mouseMoved(const UNO3_MOUSEEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + //________________________________________________________________________________________________________ + // XPaintListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowPaint(const UNO3_PAINTEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + //________________________________________________________________________________________________________ + // XTopWindowListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowOpened( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowClosing( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowClosed( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowMinimized( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowNormalized( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowActivated( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowDeactivated( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ; + +//____________________________________________________________________________________________________________ +// protected methods +//____________________________________________________________________________________________________________ + +protected: + + /**_______________________________________________________________________________________________________ + @short Remove the listener from the peer. + @descr - + + @seealso - + + @param xPeer The peer from which the listener is removed. + @param rType The listener type, which specify the type of the listener. + + @return - + + @onerror - + */ + + void impl_adviseToPeer( const UNO3_REFERENCE< UNO3_XWINDOW >& xPeer , + const UNO3_TYPE& aType ); + + /**_______________________________________________________________________________________________________ + @short Add the listener to the peer. + @descr - + + @seealso - + + @param xPeer The peer to which the listener is added. + @param rType The listener type, which specify the type of the listener. + + @return - + + @onerror - + */ + + void impl_unadviseFromPeer( const UNO3_REFERENCE< UNO3_XWINDOW >& xPeer , + const UNO3_TYPE& aType ); + +//____________________________________________________________________________________________________________ +// private variables +//____________________________________________________________________________________________________________ + +private: + + UNO3_MUTEX m_aMutex ; + UNO3_REFERENCE< UNO3_XWINDOW > m_xPeer ; /// The source of the events. Normally this is the peer object. + UNO3_WEAKREFERENCE< UNO3_XWINDOW > m_xControl ; + UNO3_OMULTITYPEINTERFACECONTAINERHELPER m_aListenerHolder ; + +}; // class OMRCListenerMultiplexerHelper + +} // namespace unocontrols + +#endif // ifndef _UNOCONTROLS_MULTIPLEXER_HXX diff --git a/UnoControls/prj/build.lst b/UnoControls/prj/build.lst new file mode 100644 index 000000000000..de5d7fd81d33 --- /dev/null +++ b/UnoControls/prj/build.lst @@ -0,0 +1,5 @@ +us UnoControls : cppuhelper offuh tools NULL +us UnoControls usr1 - all us_mkout NULL +us UnoControls\source\base nmake - all us_base NULL +us UnoControls\source\controls nmake - all us_ctrls NULL +us UnoControls\util nmake - all us_util us_base us_ctrls NULL diff --git a/UnoControls/prj/d.lst b/UnoControls/prj/d.lst new file mode 100644 index 000000000000..370fc0c9fc46 --- /dev/null +++ b/UnoControls/prj/d.lst @@ -0,0 +1,6 @@ +..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*.dll +..\%__SRC%\lib\lib*.so %_DEST%\lib%_EXT% +..\%__SRC%\lib\*.sl %_DEST%\lib%_EXT%\*.sl +..\%__SRC%\bin\*.res %_DEST%\bin%_EXT%\*.res +..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib +..\%__SRC%\misc\ctl.component %_DEST%\xml%_EXT%\ctl.component diff --git a/UnoControls/source/base/basecontainercontrol.cxx b/UnoControls/source/base/basecontainercontrol.cxx new file mode 100644 index 000000000000..68ed6287c2b4 --- /dev/null +++ b/UnoControls/source/base/basecontainercontrol.cxx @@ -0,0 +1,642 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +//____________________________________________________________________________________________________________ +// my own includes +//____________________________________________________________________________________________________________ + +#include "basecontainercontrol.hxx" + +//____________________________________________________________________________________________________________ +// includes of other projects +//____________________________________________________________________________________________________________ +#include <cppuhelper/typeprovider.hxx> + +//____________________________________________________________________________________________________________ +// includes of my own project +//____________________________________________________________________________________________________________ + +//____________________________________________________________________________________________________________ +// namespaces +//____________________________________________________________________________________________________________ + +using namespace ::cppu ; +using namespace ::osl ; +using namespace ::rtl ; +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< XMultiServiceFactory >& xFactory ) + : BaseControl ( xFactory ) + , m_aListeners ( m_aMutex ) +{ + // initialize info list for controls + m_pControlInfoList = new IMPL_ControlInfoList ; +} + +BaseContainerControl::~BaseContainerControl() +{ + impl_cleanMemory(); +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +Any SAL_CALL BaseContainerControl::queryInterface( const Type& rType ) throw( RuntimeException ) +{ + // 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() == sal_True ) + { + // If an delegator exist, forward question to his queryInterface. + // Delegator will ask his own queryAggregation! + aReturn = xDel->queryInterface( rType ); + } + else + { + // If an delegator unknown, forward question to own queryAggregation. + aReturn = queryAggregation( rType ); + } + + return aReturn ; +} + +//____________________________________________________________________________________________________________ +// XTypeProvider +//____________________________________________________________________________________________________________ + +Sequence< Type > SAL_CALL BaseContainerControl::getTypes() throw( RuntimeException ) +{ + // Optimize this method ! + // We initialize a static variable only one time. And we don't must use a mutex at every call! + // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL! + static OTypeCollection* pTypeCollection = NULL ; + + if ( pTypeCollection == NULL ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( Mutex::getGlobalMutex() ); + + // Control these pointer again ... it can be, that another instance will be faster then these! + if ( pTypeCollection == NULL ) + { + // Create a static typecollection ... + static OTypeCollection aTypeCollection ( ::getCppuType(( const Reference< XControlModel >*)NULL ) , + ::getCppuType(( const Reference< XControlContainer >*)NULL ) , + BaseControl::getTypes() + ); + // ... and set his address to static pointer! + pTypeCollection = &aTypeCollection ; + } + } + + return pTypeCollection->getTypes(); +} + +//____________________________________________________________________________________________________________ +// XAggregation +//____________________________________________________________________________________________________________ + +Any SAL_CALL BaseContainerControl::queryAggregation( const Type& aType ) throw( RuntimeException ) +{ + // 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() == sal_True ) + { + // ... 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 ) throw( RuntimeException ) +{ + if ( getPeer().is() == sal_False ) + { + // create own peer + BaseControl::createPeer( xToolkit, xParent ); + + // create peers at all childs + Sequence< Reference< XControl > > seqControlList = getControls(); + sal_uInt32 nControls = seqControlList.getLength(); + + for ( sal_uInt32 n=0; n<nControls; n++ ) + { + seqControlList.getArray()[n]->createPeer( xToolkit, getPeer() ); + } + + // activate new tab order + impl_activateTabControllers(); + +/* + Reference< XVclContainerPeer > xC; + mxPeer->queryInterface( ::getCppuType((const Reference< XVclContainerPeer >*)0), xC ); + xC->enableDialogControl( sal_True ); +*/ + + } +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +sal_Bool SAL_CALL BaseContainerControl::setModel( const Reference< XControlModel >& ) throw( RuntimeException ) +{ + // This object has NO model. + return sal_False ; +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +Reference< XControlModel > SAL_CALL BaseContainerControl::getModel() throw( RuntimeException ) +{ + // This object has NO model. + // return (XControlModel*)this ; + return Reference< XControlModel >(); +} + +//____________________________________________________________________________________________________________ +// XComponent +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseContainerControl::dispose() throw( RuntimeException ) +{ + // Zuerst der Welt mitteilen, da� der Container wegfliegt. Dieses ist um einiges + // schneller wenn die Welt sowohl an den Controls als auch am Container horcht + + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // remove listeners + EventObject aObject ; + + aObject.Source = Reference< XComponent > ( (XControlContainer*)this, UNO_QUERY ); + m_aListeners.disposeAndClear( aObject ); + + // remove controls + Sequence< Reference< XControl > > seqCtrls = getControls(); + Reference< XControl > * pCtrls = seqCtrls.getArray(); + sal_uInt32 nCtrls = seqCtrls.getLength(); + sal_uInt32 nMaxCount = m_pControlInfoList->Count(); + sal_uInt32 nCount = 0; + + for ( nCount = 0; nCount < nMaxCount; ++nCount ) + { + delete m_pControlInfoList->GetObject( 0 ); + } + m_pControlInfoList->Clear(); + + + for ( nCount = 0; nCount < nCtrls; ++nCount ) + { + pCtrls [ nCount ] -> removeEventListener ( static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) ) ) ; + pCtrls [ nCount ] -> dispose ( ) ; + } + + // call baseclass + BaseControl::dispose(); +} + +//____________________________________________________________________________________________________________ +// XEventListener +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseContainerControl::disposing( const EventObject& rEvent ) throw( RuntimeException ) +{ + 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 ) throw( RuntimeException ) +{ + if ( !rControl.is () ) + return; + + // take memory for new item + IMPL_ControlInfo* pNewControl = new IMPL_ControlInfo ; + + if (pNewControl!=(IMPL_ControlInfo*)0) + { + // Ready for multithreading + MutexGuard aGuard (m_aMutex) ; + + // set control + pNewControl->sName = rName ; + pNewControl->xControl = rControl ; + + // and insert in list + m_pControlInfoList->Insert ( pNewControl, LIST_APPEND ) ; + + // initialize new control + pNewControl->xControl->setContext ( (OWeakObject*)this ) ; + pNewControl->xControl->addEventListener ( static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) ) ) ; + + // when container has a peer ... + if (getPeer().is()) + { + // .. then create a peer on child + pNewControl->xControl->createPeer ( getPeer()->getToolkit(), getPeer() ) ; + impl_activateTabControllers () ; + } + + // Send message to all listener + OInterfaceContainerHelper* pInterfaceContainer = m_aListeners.getContainer( ::getCppuType((const Reference< XContainerListener >*)0) ) ; + + if (pInterfaceContainer) + { + // Build event + ContainerEvent aEvent ; + + aEvent.Source = *this ; + aEvent.Element <<= rControl ; + + // Get all listener + OInterfaceIteratorHelper aIterator (*pInterfaceContainer) ; + + // Send event + while ( aIterator.hasMoreElements() ) + { + ((XContainerListener*)aIterator.next())->elementInserted (aEvent) ; + } + } + } +} + +//____________________________________________________________________________________________________________ +// XControlContainer +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseContainerControl::addContainerListener ( const Reference< XContainerListener > & rListener ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + m_aListeners.addInterface ( ::getCppuType((const Reference< XContainerListener >*)0), rListener ) ; +} + +//____________________________________________________________________________________________________________ +// XControlContainer +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseContainerControl::removeControl ( const Reference< XControl > & rControl ) throw( RuntimeException ) +{ + if ( rControl.is() ) + { + // Ready for multithreading + MutexGuard aGuard (m_aMutex) ; + + sal_uInt32 nControls = m_pControlInfoList->Count () ; + + for ( sal_uInt32 n=0; n<nControls; n++ ) + { + // Search for right control + IMPL_ControlInfo* pControl = m_pControlInfoList->GetObject (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 + delete pControl ; + m_pControlInfoList->Remove (n) ; + + // Send message to all other listener + OInterfaceContainerHelper * pInterfaceContainer = m_aListeners.getContainer( ::getCppuType((const Reference< XContainerListener >*)0) ) ; + + if (pInterfaceContainer) + { + ContainerEvent aEvent ; + + aEvent.Source = *this ; + aEvent.Element <<= rControl ; + + OInterfaceIteratorHelper aIterator (*pInterfaceContainer) ; + + while ( aIterator.hasMoreElements() ) + { + ((XContainerListener*)aIterator.next())->elementRemoved (aEvent) ; + } + } + // Break "for" ! + break ; + } + } + } +} + +//____________________________________________________________________________________________________________ +// XControlContainer +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseContainerControl::removeContainerListener ( const Reference< XContainerListener > & rListener ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + m_aListeners.removeInterface ( ::getCppuType((const Reference< XContainerListener >*)0), rListener ) ; +} + +//____________________________________________________________________________________________________________ +// XControlContainer +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseContainerControl::setStatusText ( const OUString& rStatusText ) throw( RuntimeException ) +{ + // 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 ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( Mutex::getGlobalMutex() ) ; + + Reference< XControl > xRetControl = Reference< XControl > () ; + sal_uInt32 nControls = m_pControlInfoList->Count () ; + + // Search for right control + for( sal_uInt32 nCount = 0; nCount < nControls; ++nCount ) + { + IMPL_ControlInfo* pSearchControl = m_pControlInfoList->GetObject ( nCount ) ; + + if ( pSearchControl->sName == rName ) + { + // We have found it ... + // Break operation and return. + return pSearchControl->xControl ; + } + } + + // We have not found it ... return NULL. + return Reference< XControl > () ; +} + +//____________________________________________________________________________________________________________ +// XControlContainer +//____________________________________________________________________________________________________________ + +Sequence< Reference< XControl > > SAL_CALL BaseContainerControl::getControls () throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( Mutex::getGlobalMutex() ) ; + + sal_uInt32 nControls = m_pControlInfoList->Count () ; + Sequence< Reference< XControl > > aDescriptor ( nControls ) ; + Reference< XControl > * pDestination = aDescriptor.getArray () ; + sal_uInt32 nCount = 0 ; + + // Copy controls to sequence + for( nCount = 0; nCount < nControls; ++nCount ) + { + IMPL_ControlInfo* pCopyControl = m_pControlInfoList->GetObject ( nCount ) ; + pDestination [ nCount ] = pCopyControl->xControl ; + } + + // Return sequence + return aDescriptor ; +} + +//____________________________________________________________________________________________________________ +// XUnoControlContainer +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseContainerControl::addTabController ( const Reference< XTabController > & rTabController ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard (m_aMutex) ; + + sal_uInt32 nOldCount = m_xTabControllerList.getLength () ; + Sequence< Reference< XTabController > > aNewList ( nOldCount + 1 ) ; + sal_uInt32 nCount = 0 ; + + // Copy old elements of sequence to new list. + for ( nCount = 0; nCount < nOldCount; ++nCount ) + { + aNewList.getArray () [nCount] = m_xTabControllerList.getConstArray () [nCount] ; + } + + // Add new controller + aNewList.getArray () [nOldCount] = rTabController ; + + // change old and new list + m_xTabControllerList = aNewList ; +} + +//____________________________________________________________________________________________________________ +// XUnoControlContainer +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseContainerControl::removeTabController ( const Reference< XTabController > & rTabController ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard (m_aMutex) ; + + sal_uInt32 nMaxCount = m_xTabControllerList.getLength () ; + sal_uInt32 nCount = 0 ; + + // Search right tabcontroller ... + for ( nCount = 0; nCount < nMaxCount; ++nCount ) + { + if ( m_xTabControllerList.getConstArray () [nCount] == rTabController ) + { + // ... if is it found ... remove it from list. + m_xTabControllerList.getArray()[ nCount ] = Reference< XTabController >() ; + break ; + } + } +} + +//____________________________________________________________________________________________________________ +// XUnoControlContainer +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseContainerControl::setTabControllers ( const Sequence< Reference< XTabController > >& rTabControllers ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard (m_aMutex) ; + + m_xTabControllerList = rTabControllers ; +} + +Sequence<Reference< XTabController > > SAL_CALL BaseContainerControl::getTabControllers () throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard (m_aMutex) ; + + return m_xTabControllerList ; +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseContainerControl::setVisible ( sal_Bool bVisible ) throw( RuntimeException ) +{ + // override baseclass definition + BaseControl::setVisible ( bVisible ) ; + + // is it a top window ? + if ( !getContext().is() && bVisible ) + { + // then show it automaticly + createPeer ( Reference< XToolkit > (), Reference< XWindowPeer > () ) ; + } +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + +WindowDescriptor* BaseContainerControl::impl_getWindowDescriptor ( const Reference< XWindowPeer > & rParentPeer ) +{ + // - used from "createPeer()" to set the values of an WindowDescriptor !!! + // - if you will change the descriptor-values, you must override thid virtuell function + // - the caller must release the memory for this dynamical descriptor !!! + + WindowDescriptor * aDescriptor = new WindowDescriptor ; + + aDescriptor->Type = WindowClass_CONTAINER ; + aDescriptor->WindowServiceName = OUString(RTL_CONSTASCII_USTRINGPARAM("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*/ ) +{ +/* + if (rGraphics.is()) + { + for ( sal_uInt32 n=m_pControlInfoList->Count(); n; ) + { + ControlInfo* pSearchControl = m_pControlInfoList->GetObject (--n) ; + + pSearchControl->xControl->paint ( nX, nY, rGraphics ) ; + } + } +*/ +} + +//____________________________________________________________________________________________________________ +// private method +//____________________________________________________________________________________________________________ + +void BaseContainerControl::impl_activateTabControllers () +{ + // Ready for multithreading + MutexGuard aGuard (m_aMutex) ; + + sal_uInt32 nMaxCount = m_xTabControllerList.getLength () ; + sal_uInt32 nCount = 0 ; + + for ( nCount = 0; nCount < nMaxCount; ++nCount ) + { + m_xTabControllerList.getArray () [nCount]->setContainer ( this ) ; + m_xTabControllerList.getArray () [nCount]->activateTabOrder ( ) ; + } +} + +//____________________________________________________________________________________________________________ +// private method +//____________________________________________________________________________________________________________ + +void BaseContainerControl::impl_cleanMemory () +{ + // Get count of listitems. + sal_uInt32 nMaxCount = m_pControlInfoList->Count () ; + sal_uInt32 nCount = 0 ; + + // Delete all items. + for ( nCount = 0; nCount < nMaxCount; ++nCount ) + { + // Delete everytime first element of list! + // We count from 0 to MAX, where "MAX=count of items" BEFORE we delete some elements! + // If we use "GetObject ( nCount )" ... it can be, that we have an index greater then count of current elements! + + IMPL_ControlInfo* pSearchControl = m_pControlInfoList->GetObject ( 0 ) ; + delete pSearchControl ; + } + + // Delete list himself. + m_pControlInfoList->Clear () ; + delete m_pControlInfoList ; +} + +} // namespace unocontrols diff --git a/UnoControls/source/base/basecontrol.cxx b/UnoControls/source/base/basecontrol.cxx new file mode 100644 index 000000000000..030f19d6d452 --- /dev/null +++ b/UnoControls/source/base/basecontrol.cxx @@ -0,0 +1,1019 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +//____________________________________________________________________________________________________________ +// my own include +//____________________________________________________________________________________________________________ + +#include "basecontrol.hxx" + +//____________________________________________________________________________________________________________ +// includes of other projects +//____________________________________________________________________________________________________________ +#include <com/sun/star/awt/XDevice.hpp> +#include <com/sun/star/awt/XDisplayBitmap.hpp> +#include <com/sun/star/awt/DeviceInfo.hpp> +#include <com/sun/star/awt/WindowAttribute.hpp> +#include <com/sun/star/awt/PosSize.hpp> +#include <cppuhelper/typeprovider.hxx> + +//____________________________________________________________________________________________________________ +// includes of my own project +//____________________________________________________________________________________________________________ + +//____________________________________________________________________________________________________________ +// namespaces +//____________________________________________________________________________________________________________ + +using namespace ::cppu ; +using namespace ::osl ; +using namespace ::rtl ; +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using namespace ::com::sun::star::awt ; + +namespace unocontrols{ + +//____________________________________________________________________________________________________________ +// defines +//____________________________________________________________________________________________________________ + +#define DEFAULT_PMULTIPLEXER NULL +#define DEFAULT_X 0 +#define DEFAULT_Y 0 +#define DEFAULT_WIDTH 100 +#define DEFAULT_HEIGHT 100 +#define DEFAULT_VISIBLE sal_False +#define DEFAULT_INDESIGNMODE sal_False +#define DEFAULT_ENABLE sal_True +#define SERVICE_VCLTOOLKIT "com.sun.star.awt.Toolkit" + +//____________________________________________________________________________________________________________ +// construct/destruct +//____________________________________________________________________________________________________________ + +BaseControl::BaseControl( const Reference< XMultiServiceFactory >& xFactory ) + : IMPL_MutexContainer ( ) + , OComponentHelper ( m_aMutex ) + , m_xFactory ( xFactory ) + , m_pMultiplexer ( DEFAULT_PMULTIPLEXER ) + , 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 ) throw( RuntimeException ) +{ + Any aReturn ; + if ( m_xDelegator.is() == sal_True ) + { + // If an delegator exist, forward question to his queryInterface. + // Delegator will ask his own queryAggregation! + aReturn = m_xDelegator->queryInterface( rType ); + } + else + { + // If an delegator unknown, forward question to own queryAggregation. + aReturn = queryAggregation( rType ); + } + + return aReturn ; +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::acquire() throw() +{ + // 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() throw() +{ + // 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() throw( RuntimeException ) +{ + // Optimize this method ! + // We initialize a static variable only one time. And we don't must use a mutex at every call! + // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL! + static OTypeCollection* pTypeCollection = NULL ; + + if ( pTypeCollection == NULL ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( Mutex::getGlobalMutex() ); + + // Control these pointer again ... it can be, that another instance will be faster then these! + if ( pTypeCollection == NULL ) + { + // Create a static typecollection ... + static OTypeCollection aTypeCollection ( ::getCppuType(( const Reference< XPaintListener >*)NULL ) , + ::getCppuType(( const Reference< XWindowListener>*)NULL ) , + ::getCppuType(( const Reference< XView >*)NULL ) , + ::getCppuType(( const Reference< XWindow >*)NULL ) , + ::getCppuType(( const Reference< XServiceInfo >*)NULL ) , + ::getCppuType(( const Reference< XControl >*)NULL ) , + OComponentHelper::getTypes() + ); + + // ... and set his address to static pointer! + pTypeCollection = &aTypeCollection ; + } + } + + return pTypeCollection->getTypes(); +} + +//____________________________________________________________________________________________________________ +// XTypeProvider +//____________________________________________________________________________________________________________ + +Sequence< sal_Int8 > SAL_CALL BaseControl::getImplementationId() throw( RuntimeException ) +{ + // Create one Id for all instances of this class. + // Use ethernet address to do this! (sal_True) + + // Optimize this method + // We initialize a static variable only one time. And we don't must use a mutex at every call! + // For the first call; pID is NULL - for the second call pID is different from NULL! + static OImplementationId* pID = NULL ; + + if ( pID == NULL ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( Mutex::getGlobalMutex() ); + + // Control these pointer again ... it can be, that another instance will be faster then these! + if ( pID == NULL ) + { + // Create a new static ID ... + static OImplementationId aID( sal_False ); + // ... and set his address to static pointer! + pID = &aID ; + } + } + + return pID->getImplementationId(); +} + +//____________________________________________________________________________________________________________ +// XAggregation +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::setDelegator( const Reference< XInterface >& xDel ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + m_xDelegator = xDel; +} + +//____________________________________________________________________________________________________________ +// XAggregation +//____________________________________________________________________________________________________________ + +Any SAL_CALL BaseControl::queryAggregation( const Type& aType ) throw( RuntimeException ) +{ + // 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() == sal_True ) + { + // ... return this information. + return aReturn ; + } + else + { + // Else; ... ask baseclass for interfaces! + return OComponentHelper::queryAggregation( aType ); + } +} + +//____________________________________________________________________________________________________________ +// XServiceInfo +//____________________________________________________________________________________________________________ + +OUString SAL_CALL BaseControl::getImplementationName() throw( RuntimeException ) +{ + return impl_getStaticImplementationName(); +} + +//____________________________________________________________________________________________________________ +// XServiceInfo +//____________________________________________________________________________________________________________ + +sal_Bool SAL_CALL BaseControl::supportsService( const OUString& sServiceName ) throw( RuntimeException ) +{ + Sequence< OUString > seqServiceNames = getSupportedServiceNames(); + const OUString* pArray = seqServiceNames.getConstArray(); + for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ ) + { + if ( pArray[nCounter] == sServiceName ) + { + return sal_True ; + } + } + return sal_False ; +} + +//____________________________________________________________________________________________________________ +// XServiceInfo +//____________________________________________________________________________________________________________ + +Sequence< OUString > SAL_CALL BaseControl::getSupportedServiceNames() throw( RuntimeException ) +{ + return impl_getStaticSupportedServiceNames(); +} + +//____________________________________________________________________________________________________________ +// XComponent +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::dispose() throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + if ( m_pMultiplexer != NULL ) + { + // to all other paint, focus, etc. + m_pMultiplexer->disposeAndClear(); + } + + // set the service manager to disposed + OComponentHelper::dispose(); + + // release context and peer + m_xContext = Reference< XInterface >(); + impl_releasePeer(); + + // release view + if ( m_xGraphicsView.is() == sal_True ) + { + m_xGraphicsView = Reference< XGraphics >(); + } +} + +//____________________________________________________________________________________________________________ +// XComponent +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::addEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + OComponentHelper::addEventListener( xListener ); +} + +//____________________________________________________________________________________________________________ +// XComponent +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::removeEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + OComponentHelper::removeEventListener( xListener ); +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::createPeer( const Reference< XToolkit >& xToolkit , + const Reference< XWindowPeer >& xParentPeer ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + if ( m_xPeer.is() == sal_False ) + { + // use method "BaseControl::getWindowDescriptor()" fot change window attributes !!! + WindowDescriptor* pDescriptor = impl_getWindowDescriptor( xParentPeer ); + + if ( m_bVisible == sal_True ) + { + pDescriptor->WindowAttributes |= WindowAttribute::SHOW ; + } + + // very slow under remote conditions! + // create the window on the server + Reference< XToolkit > xLocalToolkit = xToolkit ; + if ( xLocalToolkit.is() == sal_False ) + { + // but first create wellknown toolkit, if it not exist + xLocalToolkit = Reference< XToolkit > ( m_xFactory->createInstance( OUString::createFromAscii( SERVICE_VCLTOOLKIT ) ), UNO_QUERY ); + } + m_xPeer = xLocalToolkit->createWindow( *pDescriptor ); + m_xPeerWindow = Reference< XWindow >( m_xPeer, UNO_QUERY ); + + // don't forget to release the memory! + delete pDescriptor ; + + if ( m_xPeerWindow.is() == sal_True ) + { + if ( m_pMultiplexer != NULL ) + { + m_pMultiplexer->setPeer( m_xPeerWindow ); + } + + // create new referenz to xgraphics for painting on a peer + // and add a paint listener + Reference< XDevice > xDevice( m_xPeerWindow, UNO_QUERY ); + + if ( xDevice.is() == sal_True ) + { + m_xGraphicsPeer = xDevice->createGraphics(); + } + + if ( m_xGraphicsPeer.is() == sal_True ) + { + addPaintListener( this ); + addWindowListener( this ); + } + + // PosSize_POSSIZE defined in <stardiv/uno/awt/window.hxx> + 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 ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + m_xContext = xContext ; +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::setDesignMode( sal_Bool bOn ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + m_bInDesignMode = bOn ; +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +Reference< XInterface > SAL_CALL BaseControl::getContext() throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + return m_xContext ; +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +Reference< XWindowPeer > SAL_CALL BaseControl::getPeer() throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + return m_xPeer ; +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +Reference< XView > SAL_CALL BaseControl::getView() throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + return Reference< XView >( (OWeakObject*)this, UNO_QUERY ); +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +sal_Bool SAL_CALL BaseControl::isDesignMode() throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + return m_bInDesignMode ; +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +sal_Bool SAL_CALL BaseControl::isTransparent() throw( RuntimeException ) +{ + return sal_False ; +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::setPosSize( sal_Int32 nX , + sal_Int32 nY , + sal_Int32 nWidth , + sal_Int32 nHeight , + sal_Int16 nFlags ) throw( RuntimeException ) +{ + // - change size and position of window and save the values + // - "nFlags" declared in <stardiv/uno/awt/window.hxx> ("#define PosSize_X .....") + + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + sal_Bool bChanged = sal_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 ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // Set new state of flag + m_bVisible = bVisible ; + + if ( m_xPeerWindow.is() == sal_True ) + { + // Set it also on peerwindow + m_xPeerWindow->setVisible( m_bVisible ); + } +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::setEnable( sal_Bool bEnable ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // Set new state of flag + m_bEnable = bEnable ; + + if ( m_xPeerWindow.is() == sal_True ) + { + // Set it also on peerwindow + m_xPeerWindow->setEnable( m_bEnable ); + } +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::setFocus() throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + if ( m_xPeerWindow.is() == sal_True ) + { + m_xPeerWindow->setFocus(); + } +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +Rectangle SAL_CALL BaseControl::getPosSize() throw( RuntimeException ) +{ + // 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 ) throw( RuntimeException ) +{ + impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XWindowListener >*)0), xListener ); +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::addFocusListener( const Reference< XFocusListener >& xListener ) throw( RuntimeException ) +{ + impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XFocusListener >*)0), xListener ); +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::addKeyListener( const Reference< XKeyListener >& xListener ) throw( RuntimeException ) +{ + impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XKeyListener >*)0), xListener ); +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::addMouseListener( const Reference< XMouseListener >& xListener ) throw( RuntimeException ) +{ + impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XMouseListener >*)0), xListener ); +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::addMouseMotionListener( const Reference< XMouseMotionListener >& xListener ) throw( RuntimeException ) +{ + impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XMouseMotionListener >*)0), xListener ); +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::addPaintListener( const Reference< XPaintListener >& xListener ) throw( RuntimeException ) +{ + impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XPaintListener >*)0), xListener ); +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::removeWindowListener( const Reference< XWindowListener >& xListener ) throw( RuntimeException ) +{ + impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XWindowListener >*)0), xListener ); +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::removeFocusListener( const Reference< XFocusListener >& xListener ) throw( RuntimeException ) +{ + impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XFocusListener >*)0), xListener ); +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::removeKeyListener( const Reference< XKeyListener >& xListener ) throw( RuntimeException ) +{ + impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XKeyListener >*)0), xListener ); +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::removeMouseListener( const Reference< XMouseListener >& xListener ) throw( RuntimeException ) +{ + impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XMouseListener >*)0), xListener ); +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::removeMouseMotionListener( const Reference< XMouseMotionListener >& xListener ) throw( RuntimeException ) +{ + impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XMouseMotionListener >*)0), xListener ); +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::removePaintListener( const Reference< XPaintListener >& xListener ) throw( RuntimeException ) +{ + impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XPaintListener >*)0), xListener ); +} + +//____________________________________________________________________________________________________________ +// XView +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::draw( sal_Int32 nX , + sal_Int32 nY ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // - paint to an 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 ) throw( RuntimeException ) +{ + // - set the graphics for an 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 ()" + sal_Bool bReturn = sal_False ; + if ( xDevice.is() == sal_True ) + { + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + m_xGraphicsView = xDevice ; + bReturn = sal_True ; + } + + return bReturn ; +} + +//____________________________________________________________________________________________________________ +// XView +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::setZoom( float /*fZoomX*/ , + float /*fZoomY*/ ) throw( RuntimeException ) +{ + // Not implemented yet +} + +//____________________________________________________________________________________________________________ +// XView +//____________________________________________________________________________________________________________ + +Reference< XGraphics > SAL_CALL BaseControl::getGraphics() throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + return m_xGraphicsView ; +} + +//____________________________________________________________________________________________________________ +// XView +//____________________________________________________________________________________________________________ + +Size SAL_CALL BaseControl::getSize() throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + return Size( m_nWidth, m_nHeight ); +} + +//____________________________________________________________________________________________________________ +// XEventListener +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::disposing( const EventObject& /*aSource*/ ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // - release ALL references + // - it must be !!! + if ( m_xGraphicsPeer.is() == sal_True ) + { + removePaintListener( this ); + removeWindowListener( this ); + m_xGraphicsPeer = Reference< XGraphics >(); + } + + if ( m_xGraphicsView.is() == sal_True ) + { + m_xGraphicsView = Reference< XGraphics >(); + } +} + +//____________________________________________________________________________________________________________ +// XPaintListener +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::windowPaint( const PaintEvent& /*aEvent*/ ) throw( RuntimeException ) +{ + // 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 ) throw( RuntimeException ) +{ + // 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 ) throw( RuntimeException ) +{ + // 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*/ ) throw( RuntimeException ) +{ +} + +//____________________________________________________________________________________________________________ +// XWindowListener +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::windowHidden( const EventObject& /*aEvent*/ ) throw( RuntimeException ) +{ +} + +//____________________________________________________________________________________________________________ +// impl but public method to register service in DLL +// (In this BASE-implementation not implemented! Overwrite it in derived classes.) +//____________________________________________________________________________________________________________ + +const Sequence< OUString > BaseControl::impl_getStaticSupportedServiceNames() +{ + return Sequence< OUString >(); +} + +//____________________________________________________________________________________________________________ +// impl but public method to register service in DLL +// (In this BASE-implementation not implemented! Overwrite it in derived classes.) +//____________________________________________________________________________________________________________ + +const OUString BaseControl::impl_getStaticImplementationName() +{ + return OUString(); +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + +const Reference< XMultiServiceFactory > BaseControl::impl_getMultiServiceFactory() +{ + return m_xFactory ; +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + +const Reference< XWindow > BaseControl::impl_getPeerWindow() +{ + return m_xPeerWindow ; +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + +const Reference< XGraphics > BaseControl::impl_getGraphicsPeer() +{ + return m_xGraphicsPeer ; +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + +const sal_Int32& BaseControl::impl_getWidth() +{ + return m_nWidth ; +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + +const sal_Int32& BaseControl::impl_getHeight() +{ + return m_nHeight ; +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + +WindowDescriptor* BaseControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer ) +{ + // - used from "createPeer()" to set the values of an ::com::sun::star::awt::WindowDescriptor !!! + // - if you will change the descriptor-values, you must override this virtuell function + // - the caller must release the memory for this dynamical descriptor !!! + + WindowDescriptor* pDescriptor = new WindowDescriptor ; + + pDescriptor->Type = WindowClass_SIMPLE ; + pDescriptor->WindowServiceName = OUString::createFromAscii( "window" ) ; + pDescriptor->ParentIndex = -1 ; + pDescriptor->Parent = xParentPeer ; + pDescriptor->Bounds = getPosSize () ; + pDescriptor->WindowAttributes = 0 ; + + return pDescriptor ; +} + +//____________________________________________________________________________________________________________ +// 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 its not necessary to make it pure virtual !!! +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + +void BaseControl::impl_recalcLayout( const WindowEvent& /*aEvent*/ ) +{ + // We need as virtual function to support automaticly resizing of derived controls! + // But we make it not pure virtual because it's not neccessary for all derived classes! +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + +Reference< XInterface > BaseControl::impl_getDelegator() +{ + return m_xDelegator ; +} + +//____________________________________________________________________________________________________________ +// private method +//____________________________________________________________________________________________________________ + +void BaseControl::impl_releasePeer() +{ + if ( m_xPeer.is() == sal_True ) + { + if ( m_xGraphicsPeer.is() == sal_True ) + { + removePaintListener( this ); + removeWindowListener( this ); + m_xGraphicsPeer = Reference< XGraphics >(); + } + + m_xPeer->dispose(); + m_xPeerWindow = Reference< XWindow >(); + m_xPeer = Reference< XWindowPeer >(); + + if ( m_pMultiplexer != NULL ) + { + // take changes on multiplexer + m_pMultiplexer->setPeer( Reference< XWindow >() ); + } + } +} + +//____________________________________________________________________________________________________________ +// private method +//____________________________________________________________________________________________________________ + +OMRCListenerMultiplexerHelper* BaseControl::impl_getMultiplexer() +{ + if ( m_pMultiplexer == NULL ) + { + m_pMultiplexer = new OMRCListenerMultiplexerHelper( (XWindow*)this, m_xPeerWindow ); + m_xMultiplexer = Reference< XInterface >( (OWeakObject*)m_pMultiplexer, UNO_QUERY ); + } + + return m_pMultiplexer ; +} + +} // namespace unocontrols diff --git a/UnoControls/source/base/makefile.mk b/UnoControls/source/base/makefile.mk new file mode 100644 index 000000000000..74c6d4d43656 --- /dev/null +++ b/UnoControls/source/base/makefile.mk @@ -0,0 +1,69 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +PRJ=..$/.. + +PRJNAME=UnoControls +TARGET=base +ENABLE_EXCEPTIONS=TRUE +#LIBTARGET=NO +#USE_LDUMP2=TRUE +#USE_DEFFILE=TRUE + +# --- Settings ----------------------------------------------------- +.INCLUDE : $(PRJ)$/util$/makefile.pmk + + +# --- Files -------------------------------------------------------- +SLOFILES= $(SLO)$/multiplexer.obj \ + $(SLO)$/basecontrol.obj \ + $(SLO)$/basecontainercontrol.obj \ + $(SLO)$/registercontrols.obj + +#LIB1TARGET= $(SLB)$/$(TARGET).lib +#LIB1OBJFILES= $(SLOFILES) + +#SHL1TARGET= $(TARGET)$(DLLPOSTFIX) + +#SHL1STDLIBS=\ +# $(ONELIB) \ +# $(USRLIB) \ +# $(UNOLIB) \ +# $(VOSLIB) \ +# $(OSLLIB) \ +# $(TOOLSLIB) \ +# $(RTLLIB) + +#SHL1DEPN= makefile.mk +#SHL1LIBS= $(LIB1TARGET) +#SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +#DEF1NAME= $(SHL1TARGET) +#DEF1EXPORTFILE= exports.dxp + +# --- Targets ------------------------------------------------------ +.INCLUDE : target.mk +#.INCLUDE : $(PRJ)$/util$/target.pmk diff --git a/UnoControls/source/base/multiplexer.cxx b/UnoControls/source/base/multiplexer.cxx new file mode 100644 index 000000000000..0c1ded49694e --- /dev/null +++ b/UnoControls/source/base/multiplexer.cxx @@ -0,0 +1,577 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +//____________________________________________________________________________________________________________ +// my own include +//____________________________________________________________________________________________________________ + +#include "multiplexer.hxx" + +//____________________________________________________________________________________________________________ +// includes of other projects +//____________________________________________________________________________________________________________ +#include <vos/diagnose.hxx> + +//____________________________________________________________________________________________________________ +// includes of my own project +//____________________________________________________________________________________________________________ + +//____________________________________________________________________________________________________________ +// namespaces +//____________________________________________________________________________________________________________ + +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.*/ \ + OInterfaceContainerHelper* pContainer = m_aListenerHolder.getContainer( ::getCppuType((const Reference< INTERFACE >*)0) ); \ + /* Do the follow only, if elements in container exist.*/ \ + if( pContainer != NULL ) \ + { \ + OInterfaceIteratorHelper 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.is() == sal_True ) \ + { \ + if( aIterator.hasMoreElements() ) \ + { \ + INTERFACE * pListener = (INTERFACE *)aIterator.next(); \ + try \ + { \ + pListener->METHOD( aLocalEvent ); \ + } \ + catch( 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() + , m_aListenerHolder ( m_aMutex ) +{ +} + +OMRCListenerMultiplexerHelper::~OMRCListenerMultiplexerHelper() +{ +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +Any SAL_CALL OMRCListenerMultiplexerHelper::queryInterface( const Type& rType ) throw( RuntimeException ) +{ + // 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() == sal_True ) + { + // ... return this information. + return aReturn ; + } + else + { + // Else; ... ask baseclass for interfaces! + return OWeakObject::queryInterface( rType ); + } +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +void SAL_CALL OMRCListenerMultiplexerHelper::acquire() throw() +{ + // 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() throw() +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + + // Forward to baseclass + OWeakObject::release(); +} + +//____________________________________________________________________________________________________________ +// operator +//____________________________________________________________________________________________________________ + +OMRCListenerMultiplexerHelper::operator Reference< XInterface >() const +{ + return ((OWeakObject*)this) ; +} + +//____________________________________________________________________________________________________________ +// operator +//____________________________________________________________________________________________________________ + +//OMRCListenerMultiplexerHelper& OMRCListenerMultiplexerHelper::operator= ( const OMRCListenerMultiplexerHelper& aCopyInstance ) +//{ +// return this ; +//} + +//____________________________________________________________________________________________________________ +// container method +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::setPeer( const Reference< XWindow >& xPeer ) +{ + MutexGuard aGuard( m_aMutex ); + if( m_xPeer != xPeer ) + { + if( m_xPeer.is() ) + { + // get all types from the listener added to the peer + Sequence< Type > aContainedTypes = m_aListenerHolder.getContainedTypes(); + const Type* pArray = aContainedTypes.getConstArray(); + sal_Int32 nCount = aContainedTypes.getLength(); + // loop over all listener types and remove the listeners from the peer + for( sal_Int32 i=0; i<nCount; i++ ) + impl_unadviseFromPeer( m_xPeer, pArray[i] ); + } + m_xPeer = xPeer; + if( m_xPeer.is() ) + { + // get all types from the listener added to the peer + Sequence< Type > aContainedTypes = m_aListenerHolder.getContainedTypes(); + const Type* pArray = aContainedTypes.getConstArray(); + sal_Int32 nCount = aContainedTypes.getLength(); + // loop over all listener types and add the listeners to the peer + for( sal_Int32 i = 0; i < nCount; i++ ) + impl_adviseToPeer( m_xPeer, pArray[i] ); + } + } +} + +//____________________________________________________________________________________________________________ +// 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*/ ) throw( RuntimeException ) +{ + MutexGuard aGuard( m_aMutex ); + // peer is disposed, clear the reference + m_xPeer = Reference< XWindow >(); +} + +//____________________________________________________________________________________________________________ +// XFcousListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::focusGained(const FocusEvent& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) +{ +/* + OInterfaceContainerHelper * pCont = aListenerHolder.getContainer( ::getCppuType((const Reference< XFocusListener >*)0) ); + if( pCont ) + { + OInterfaceIteratorHelper aIt( *pCont ); + FocusEvent aEvt = e; + // Reamark: The control is the event source not the peer. We must change + // the source of the event + xControl.queryHardRef( ((XInterface*)NULL)->getSmartUik(), aEvt.Source ); + //.is the control not destroyed + if( aEvt.Source.is() ) + { + if( aIt.hasMoreElements() ) + { + XFocusListener * pListener = (XFocusListener *)aIt.next(); + try + { + pListener->focusGained( aEvt ); + } + catch( RuntimeException, e ) + { + // ignore all usr system exceptions from the listener + } + } + } + } +*/ + MULTIPLEX( XFocusListener, focusGained, FocusEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XFcousListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::focusLost(const FocusEvent& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XFocusListener, focusLost, FocusEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowResized(const WindowEvent& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XWindowListener, windowResized, WindowEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowMoved(const WindowEvent& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XWindowListener, windowMoved, WindowEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowShown(const EventObject& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XWindowListener, windowShown, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowHidden(const EventObject& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XWindowListener, windowHidden, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XKeyListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::keyPressed(const KeyEvent& aEvent) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XKeyListener, keyPressed, KeyEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XKeyListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::keyReleased(const KeyEvent& aEvent) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XKeyListener, keyReleased, KeyEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XMouseListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::mousePressed(const MouseEvent& aEvent) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XMouseListener, mousePressed, MouseEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XMouseListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::mouseReleased(const MouseEvent& aEvent) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XMouseListener, mouseReleased, MouseEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XMouseListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::mouseEntered(const MouseEvent& aEvent) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XMouseListener, mouseEntered, MouseEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XMouseListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::mouseExited(const MouseEvent& aEvent) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XMouseListener, mouseExited, MouseEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XMouseMotionListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::mouseDragged(const MouseEvent& aEvent) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XMouseMotionListener, mouseDragged, MouseEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XMouseMotionListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::mouseMoved(const MouseEvent& aEvent) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XMouseMotionListener, mouseMoved, MouseEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XPaintListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowPaint(const PaintEvent& aEvent) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XPaintListener, windowPaint, PaintEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XTopWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowOpened(const EventObject& aEvent) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XTopWindowListener, windowOpened, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XTopWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowClosing( const EventObject& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XTopWindowListener, windowClosing, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XTopWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowClosed( const EventObject& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XTopWindowListener, windowClosed, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XTopWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowMinimized( const EventObject& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XTopWindowListener, windowMinimized, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XTopWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowNormalized( const EventObject& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XTopWindowListener, windowNormalized, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XTopWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowActivated( const EventObject& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) +{ + MULTIPLEX( XTopWindowListener, windowActivated, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XTopWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowDeactivated( const EventObject& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) +{ + 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 == ::getCppuType((const Reference< XWindowListener >*)0) ) + xPeer->addWindowListener( this ); + else if( aType == ::getCppuType((const Reference< XKeyListener >*)0) ) + xPeer->addKeyListener( this ); + else if( aType == ::getCppuType((const Reference< XFocusListener >*)0) ) + xPeer->addFocusListener( this ); + else if( aType == ::getCppuType((const Reference< XMouseListener >*)0) ) + xPeer->addMouseListener( this ); + else if( aType == ::getCppuType((const Reference< XMouseMotionListener >*)0) ) + xPeer->addMouseMotionListener( this ); + else if( aType == ::getCppuType((const Reference< XPaintListener >*)0) ) + xPeer->addPaintListener( this ); + else if( aType == ::getCppuType((const Reference< XTopWindowListener >*)0) ) + { + Reference< XTopWindow > xTop( xPeer, UNO_QUERY ); + if( xTop.is() ) + xTop->addTopWindowListener( this ); + } + else + { + VOS_ENSHURE( sal_False, "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 == ::getCppuType((const Reference< XWindowListener >*)0) ) + xPeer->removeWindowListener( this ); + else if( aType == ::getCppuType((const Reference< XKeyListener >*)0) ) + xPeer->removeKeyListener( this ); + else if( aType == ::getCppuType((const Reference< XFocusListener >*)0) ) + xPeer->removeFocusListener( this ); + else if( aType == ::getCppuType((const Reference< XMouseListener >*)0) ) + xPeer->removeMouseListener( this ); + else if( aType == ::getCppuType((const Reference< XMouseMotionListener >*)0) ) + xPeer->removeMouseMotionListener( this ); + else if( aType == ::getCppuType((const Reference< XPaintListener >*)0) ) + xPeer->removePaintListener( this ); + else if( aType == ::getCppuType((const Reference< XTopWindowListener >*)0) ) + { + Reference< XTopWindow > xTop( xPeer, UNO_QUERY ); + if( xTop.is() ) + xTop->removeTopWindowListener( this ); + } + else + { + VOS_ENSHURE( sal_False, "unknown listener" ); + } +} + +} // namespace unocontrols diff --git a/UnoControls/source/base/registercontrols.cxx b/UnoControls/source/base/registercontrols.cxx new file mode 100644 index 000000000000..6a10f42b8fb8 --- /dev/null +++ b/UnoControls/source/base/registercontrols.cxx @@ -0,0 +1,222 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +//______________________________________________________________________________________________________________ +// includes of other projects +//______________________________________________________________________________________________________________ + +#include <cppuhelper/factory.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/registry/XRegistryKey.hpp> +#include <com/sun/star/container/XSet.hpp> + +#include <stdio.h> + +//______________________________________________________________________________________________________________ +// includes of my own project +//______________________________________________________________________________________________________________ + +//============================================================================= +// Add new include line to use new services. +//============================================================================= +#include "framecontrol.hxx" +#include "progressbar.hxx" +#include "progressmonitor.hxx" +#include "statusindicator.hxx" +//============================================================================= + +//______________________________________________________________________________________________________________ +// defines +//______________________________________________________________________________________________________________ + +// If you will debug macros of this file ... you must define follow constant! +// Ths switch on another macro AS_DBG_OUT(...), which will print text to "stdout". + +//#define AS_DBG_SWITCH + +//______________________________________________________________________________________________________________ +// namespaces +//______________________________________________________________________________________________________________ + +using namespace ::rtl ; +using namespace ::cppu ; +using namespace ::unocontrols ; +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::container ; +using namespace ::com::sun::star::lang ; +using namespace ::com::sun::star::registry ; + +//______________________________________________________________________________________________________________ +// macros +//______________________________________________________________________________________________________________ + +//****************************************************************************************************************************** +// See AS_DBG_SWITCH below !!! +#ifdef AS_DBG_SWITCH + #define AS_DBG_OUT(OUTPUT) printf( OUTPUT ); +#else + #define AS_DBG_OUT(OUTPUT) +#endif + +//****************************************************************************************************************************** +#define CREATEINSTANCE(CLASS) \ + \ + static Reference< XInterface > SAL_CALL CLASS##_createInstance ( const Reference< XMultiServiceFactory >& rServiceManager ) throw ( Exception ) \ + { \ + AS_DBG_OUT ( "\tCREATEINSTANCE():\tOK\n" ) \ + return Reference< XInterface >( *(OWeakObject*)(new CLASS( rServiceManager )) ); \ + } + +//****************************************************************************************************************************** +#define CREATEFACTORY_ONEINSTANCE(CLASS) \ + \ + AS_DBG_OUT ( "\tCREATEFACTORY_ONEINSTANCE():\t[start]\n" ) \ + /* Create right factory ... */ \ + xFactory = Reference< XSingleServiceFactory > \ + ( \ + cppu::createOneInstanceFactory ( xServiceManager , \ + CLASS::impl_getStaticImplementationName () , \ + CLASS##_createInstance , \ + CLASS::impl_getStaticSupportedServiceNames () ) \ + ) ; \ + AS_DBG_OUT ( "\tCREATEFACTORY_ONEINSTANCE():\t[end]\n" ) + +//****************************************************************************************************************************** +#define CREATEFACTORY_SINGLE(CLASS) \ + \ + AS_DBG_OUT ( "\tCREATEFACTORY_SINGLE():\t[start]\n" ) \ + /* Create right factory ... */ \ + xFactory = Reference< XSingleServiceFactory > \ + ( \ + cppu::createSingleFactory ( xServiceManager , \ + CLASS::impl_getStaticImplementationName () , \ + CLASS##_createInstance , \ + CLASS::impl_getStaticSupportedServiceNames () ) \ + ) ; \ + AS_DBG_OUT ( "\tCREATEFACTORY_SINGLE():\t[end]\n" ) + +//****************************************************************************************************************************** +#define IF_NAME_CREATECOMPONENTFACTORY_ONEINSTANCE(CLASS) \ + \ + if ( CLASS::impl_getStaticImplementationName().equals( OUString::createFromAscii( pImplementationName ) ) ) \ + { \ + AS_DBG_OUT ( "\tIF_NAME_CREATECOMPONENTFACTORY_ONEINSTANCE():\timplementationname found\n" ) \ + CREATEFACTORY_ONEINSTANCE ( CLASS ) \ + } + +//****************************************************************************************************************************** +#define IF_NAME_CREATECOMPONENTFACTORY_SINGLE(CLASS) \ + \ + if ( CLASS::impl_getStaticImplementationName().equals( OUString::createFromAscii( pImplementationName ) ) ) \ + { \ + AS_DBG_OUT ( "\tIF_NAME_CREATECOMPONENTFACTORY_SINGLE():\timplementationname found\n" ) \ + CREATEFACTORY_SINGLE ( CLASS ) \ + } + +//______________________________________________________________________________________________________________ +// declare functions to create a new instance of service +//______________________________________________________________________________________________________________ + +//============================================================================= +// Add new macro line to use new services. +// +// !!! ATTENTION !!! +// Write no ";" at end of line! (see macro) +//============================================================================= +CREATEINSTANCE ( FrameControl ) +CREATEINSTANCE ( ProgressBar ) +CREATEINSTANCE ( ProgressMonitor ) +CREATEINSTANCE ( StatusIndicator ) +//============================================================================= + +//______________________________________________________________________________________________________________ +// return environment +//______________________________________________________________________________________________________________ + +extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char** ppEnvironmentTypeName , + uno_Environment** /*ppEnvironment*/ ) +{ + *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ; +} + +//______________________________________________________________________________________________________________ +// create right component factory +//______________________________________________________________________________________________________________ + +extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplementationName , + void* pServiceManager , + void* /*pRegistryKey*/ ) +{ + AS_DBG_OUT( "component_getFactory():\t[start]\n" ) + + // Set default return value for this operation - if it failed. + void* pReturn = NULL ; + + if ( + ( pImplementationName != NULL ) && + ( pServiceManager != NULL ) + ) + { + AS_DBG_OUT( "component_getFactory():\t\t... enter scope - pointer are valid\n" ) + + // Define variables which are used in following macros. + Reference< XSingleServiceFactory > xFactory ; + Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; + + //============================================================================= + // Add new macro line to handle new service. + // + // !!! ATTENTION !!! + // Write no ";" at end of line and dont forget "else" ! (see macro) + //============================================================================= + IF_NAME_CREATECOMPONENTFACTORY_SINGLE( FrameControl ) + else + IF_NAME_CREATECOMPONENTFACTORY_SINGLE( ProgressBar ) + else + IF_NAME_CREATECOMPONENTFACTORY_SINGLE( ProgressMonitor ) + else + IF_NAME_CREATECOMPONENTFACTORY_SINGLE( StatusIndicator ) + //============================================================================= + + // Factory is valid - service was found. + if ( xFactory.is() ) + { + AS_DBG_OUT( "component_getFactory():\t\t\t... xFactory valid - service was found\n" ) + + xFactory->acquire(); + pReturn = xFactory.get(); + } + + AS_DBG_OUT( "component_getFactory():\t\t... leave scope\n" ) + } + + AS_DBG_OUT ( "component_getFactory():\t[end]\n" ) + + // Return with result of this operation. + return pReturn ; +} diff --git a/UnoControls/source/controls/OConnectionPointContainerHelper.cxx b/UnoControls/source/controls/OConnectionPointContainerHelper.cxx new file mode 100644 index 000000000000..56f336124a7d --- /dev/null +++ b/UnoControls/source/controls/OConnectionPointContainerHelper.cxx @@ -0,0 +1,187 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +//______________________________________________________________________________________________________________ +// my own include +//______________________________________________________________________________________________________________ + +#include "OConnectionPointContainerHelper.hxx" + +//______________________________________________________________________________________________________________ +// includes of other projects +//______________________________________________________________________________________________________________ + +//______________________________________________________________________________________________________________ +// include of my own project +//______________________________________________________________________________________________________________ +#include "OConnectionPointHelper.hxx" + +//______________________________________________________________________________________________________________ +// namespaces +//______________________________________________________________________________________________________________ + +using namespace ::rtl ; +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 ) throw( RuntimeException ) +{ + // 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() == sal_False ) + { + // ... ask baseclasses. + aReturn = OWeakObject::queryInterface( aType ); + } + + return aReturn ; +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +void SAL_CALL OConnectionPointContainerHelper::acquire() throw() +{ + // 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() throw() +{ + // 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() throw( RuntimeException ) +{ + // Container is threadsafe himself ! + return m_aMultiTypeContainer.getContainedTypes(); +} + +//______________________________________________________________________________________________________________ +// XConnectionPointContainer +//______________________________________________________________________________________________________________ + +Reference< XConnectionPoint > SAL_CALL OConnectionPointContainerHelper::queryConnectionPoint( const Type& aType ) throw( RuntimeException ) +{ + // Set default return value, if method failed. + Reference< XConnectionPoint > xConnectionPoint = Reference< XConnectionPoint >(); + + // Get all elements of the container, which have the searched type. + OInterfaceContainerHelper* 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. + OConnectionPointHelper* pNewConnectionPoint = new OConnectionPointHelper( m_aSharedMutex, this, aType ); + xConnectionPoint = Reference< XConnectionPoint >( (OWeakObject*)pNewConnectionPoint, UNO_QUERY ); + } + + return xConnectionPoint ; +} + +//______________________________________________________________________________________________________________ +// XConnectionPointContainer +//______________________________________________________________________________________________________________ + +void SAL_CALL OConnectionPointContainerHelper::advise( const Type& aType , + const Reference< XInterface >& xListener ) throw( RuntimeException ) +{ + // Container is threadsafe himself ! + m_aMultiTypeContainer.addInterface( aType, xListener ); +} + +//______________________________________________________________________________________________________________ +// XConnectionPointContainer +//______________________________________________________________________________________________________________ + +void SAL_CALL OConnectionPointContainerHelper::unadvise( const Type& aType , + const Reference< XInterface >& xListener ) throw( RuntimeException ) +{ + // Container is threadsafe himself ! + m_aMultiTypeContainer.removeInterface( aType, xListener ); +} + +//______________________________________________________________________________________________________________ +// public but impl method! +// Is neccessary to get container member at OConnectionPoint-instance. +//______________________________________________________________________________________________________________ + +OMultiTypeInterfaceContainerHelper& OConnectionPointContainerHelper::impl_getMultiTypeContainer() +{ + // Impl methods are not threadsafe! + // "Parent" function must do this. + return m_aMultiTypeContainer; +} + +} // namespace unocontrols diff --git a/UnoControls/source/controls/OConnectionPointHelper.cxx b/UnoControls/source/controls/OConnectionPointHelper.cxx new file mode 100644 index 000000000000..24b08f6a4937 --- /dev/null +++ b/UnoControls/source/controls/OConnectionPointHelper.cxx @@ -0,0 +1,271 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +//______________________________________________________________________________________________________________ +// my own include +//______________________________________________________________________________________________________________ + +#include "OConnectionPointHelper.hxx" + +//______________________________________________________________________________________________________________ +// includes of other projects +//______________________________________________________________________________________________________________ + +//______________________________________________________________________________________________________________ +// include of my own project +//______________________________________________________________________________________________________________ +#include "OConnectionPointContainerHelper.hxx" + +//______________________________________________________________________________________________________________ +// namespaces +//______________________________________________________________________________________________________________ + +using namespace ::rtl ; +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 , + UNO3_TYPE aType ) + : m_aSharedMutex ( aMutex ) + , m_oContainerWeakReference ( pContainerImplementation ) + , m_pContainerImplementation ( pContainerImplementation ) + , m_aInterfaceType ( aType ) +{ +} + +OConnectionPointHelper::~OConnectionPointHelper() +{ +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +Any SAL_CALL OConnectionPointHelper::queryInterface( const Type& aType ) throw( RuntimeException ) +{ + // 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() == sal_False ) + { + // ... ask baseclasses. + aReturn = OWeakObject::queryInterface( aType ); + } + + return aReturn ; +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +void SAL_CALL OConnectionPointHelper::acquire() throw() +{ + // 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() throw() +{ + // 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() throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aSharedMutex ); + + // Set default return value, if method failed. + if ( impl_LockContainer() == sal_False ) + { + // Container not exist! Its an runtime error. + throw RuntimeException(); + } + + // 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() throw( RuntimeException ) +{ + // 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 ) throw( ListenerExistException , + InvalidListenerException , + RuntimeException ) +{ + // 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!? + // Its the same container for XConnectionPointContainer and XConnectionPoint. But only here we must control, if a listener already exist!? + // You can add a listener more then one time at XConnectionPointContainer, but here only one ... + + // Operation is permitted only, if reference to container is valid! + if ( impl_LockContainer() == sal_False ) + { + // Container not exist! Its an runtime error. + throw RuntimeException(); + } + // 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 ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aSharedMutex ); + // Operation is permitted only, if reference to container is valid! + if ( impl_LockContainer() == sal_False ) + { + // Container not exist! Its an runtime error. + throw RuntimeException(); + + } + // Forward it to OConnectionPointHelperContainer! + m_pContainerImplementation->unadvise( m_aInterfaceType, xListener ); + // Don't forget this! + impl_UnlockContainer(); +} + +//______________________________________________________________________________________________________________ +// XConnectionPoint +//______________________________________________________________________________________________________________ + +Sequence< Reference< XInterface > > SAL_CALL OConnectionPointHelper::getConnections() throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aSharedMutex ); + // Operation is permitted only, if reference to container is valid! + if ( impl_LockContainer() == sal_False ) + { + // Container not exist! Its an runtime error. + throw RuntimeException(); + } + // Set default return value, if method failed. + Sequence< Reference< XInterface > > seqReturnConnections = Sequence< Reference< XInterface > >(); + // Get reference to private member of OConnectionPointHelperContainer! + OMultiTypeInterfaceContainerHelper& aSharedContainer = m_pContainerImplementation->impl_getMultiTypeContainer(); + // Get pointer to specialized container which hold all interfaces of searched type. + OInterfaceContainerHelper* pSpecialContainer = aSharedContainer.getContainer( m_aInterfaceType ); + // Get elements of searched type, if somelse exist. + if ( pSpecialContainer != NULL ) + { + seqReturnConnections = pSpecialContainer->getElements(); + } + // Don't forget this! + impl_UnlockContainer(); + + return seqReturnConnections; +} + +//______________________________________________________________________________________________________________ +// private method +//______________________________________________________________________________________________________________ + +sal_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 = Reference< XInterface >(); +} + +} // namespace unocontrols diff --git a/UnoControls/source/controls/framecontrol.cxx b/UnoControls/source/controls/framecontrol.cxx new file mode 100644 index 000000000000..2ae0e27dc56c --- /dev/null +++ b/UnoControls/source/controls/framecontrol.cxx @@ -0,0 +1,604 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +//______________________________________________________________________________________________________________ +// my own include +//______________________________________________________________________________________________________________ + +#include "framecontrol.hxx" + +//______________________________________________________________________________________________________________ +// includes of other projects +//______________________________________________________________________________________________________________ +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <cppuhelper/typeprovider.hxx> +#include <vos/diagnose.hxx> + +//______________________________________________________________________________________________________________ +// include of my own project +//______________________________________________________________________________________________________________ + +//______________________________________________________________________________________________________________ +// namespaces +//______________________________________________________________________________________________________________ + +using namespace ::rtl ; +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{ + +//______________________________________________________________________________________________________________ +// construct/destruct +//______________________________________________________________________________________________________________ + +FrameControl::FrameControl( const Reference< XMultiServiceFactory >& xFactory ) + : BaseControl ( xFactory ) + , OBroadcastHelper ( m_aMutex ) + , OPropertySetHelper ( *SAL_STATIC_CAST( OBroadcastHelper *, this ) ) + , m_aInterfaceContainer ( m_aMutex ) + , m_aConnectionPointContainer ( m_aMutex ) +{ +} + +FrameControl::~FrameControl() +{ +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +Any SAL_CALL FrameControl::queryInterface( const Type& rType ) throw( RuntimeException ) +{ + // 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 an delegator exist, forward question to his queryInterface. + // Delegator will ask his own queryAggregation! + aReturn = xDel->queryInterface( rType ); + } + else + { + // If an delegator unknown, forward question to own queryAggregation. + aReturn = queryAggregation( rType ); + } + + return aReturn ; +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +void SAL_CALL FrameControl::acquire() throw() +{ + // 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() throw() +{ + // 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() throw( RuntimeException ) +{ + // Optimize this method ! + // We initialize a static variable only one time. And we don't must use a mutex at every call! + // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL! + static OTypeCollection* pTypeCollection = NULL ; + + if ( pTypeCollection == NULL ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( Mutex::getGlobalMutex() ); + + // Control these pointer again ... it can be, that another instance will be faster then these! + if ( pTypeCollection == NULL ) + { + // Create a static typecollection ... + static OTypeCollection aTypeCollection ( ::getCppuType(( const Reference< XControlModel >*)NULL ) , + ::getCppuType(( const Reference< XControlContainer >*)NULL ) , + ::getCppuType(( const Reference< XConnectionPointContainer >*)NULL ) , + BaseControl::getTypes() + ); + // ... and set his address to static pointer! + pTypeCollection = &aTypeCollection ; + } + } + + return pTypeCollection->getTypes(); +} + +//____________________________________________________________________________________________________________ +// XAggregation +//____________________________________________________________________________________________________________ + +Any SAL_CALL FrameControl::queryAggregation( const Type& aType ) throw( RuntimeException ) +{ + // 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() == sal_False ) + { + // ... ask baseclasses. + aReturn = OPropertySetHelper::queryInterface( aType ); + if ( aReturn.hasValue() == sal_False ) + { + aReturn = BaseControl::queryAggregation( aType ); + } + } + + return aReturn ; +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +void SAL_CALL FrameControl::createPeer( const Reference< XToolkit >& xToolkit , + const Reference< XWindowPeer >& xParentPeer ) throw( RuntimeException ) +{ + BaseControl::createPeer( xToolkit, xParentPeer ); + if ( impl_getPeerWindow().is() ) + { + if( m_sComponentURL.getLength() > 0 ) + { + impl_createFrame( getPeer(), m_sComponentURL, m_seqLoaderArguments ); + } + } +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +sal_Bool SAL_CALL FrameControl::setModel( const Reference< XControlModel >& /*xModel*/ ) throw( RuntimeException ) +{ + // We have no model. + return sal_False ; +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +Reference< XControlModel > SAL_CALL FrameControl::getModel() throw( RuntimeException ) +{ + // We have no model. + return Reference< XControlModel >(); +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +void SAL_CALL FrameControl::dispose() throw( RuntimeException ) +{ + impl_deleteFrame(); + BaseControl::dispose(); +} + +//____________________________________________________________________________________________________________ +// XView +//____________________________________________________________________________________________________________ + +sal_Bool SAL_CALL FrameControl::setGraphics( const Reference< XGraphics >& /*xDevice*/ ) throw( RuntimeException ) +{ + // it is not possible to print this control + return sal_False ; +} + +//____________________________________________________________________________________________________________ +// XView +//____________________________________________________________________________________________________________ + +Reference< XGraphics > SAL_CALL FrameControl::getGraphics() throw( RuntimeException ) +{ + // when its not posible to set graphics ! then its possible to return null + return Reference< XGraphics >(); +} + +//____________________________________________________________________________________________________________ +// XConnectionPointContainer +//____________________________________________________________________________________________________________ + +Sequence< Type > SAL_CALL FrameControl::getConnectionPointTypes() throw( RuntimeException ) +{ + // Forwarded to helper class + return m_aConnectionPointContainer.getConnectionPointTypes(); +} + +//____________________________________________________________________________________________________________ +// XConnectionPointContainer +//____________________________________________________________________________________________________________ + +Reference< XConnectionPoint > SAL_CALL FrameControl::queryConnectionPoint( const Type& aType ) throw( RuntimeException ) +{ + // Forwarded to helper class + return m_aConnectionPointContainer.queryConnectionPoint( aType ); +} + +//____________________________________________________________________________________________________________ +// XConnectionPointContainer +//____________________________________________________________________________________________________________ + +void SAL_CALL FrameControl::advise( const Type& aType , + const Reference< XInterface >& xListener ) throw( RuntimeException ) +{ + // Forwarded to helper class + m_aConnectionPointContainer.advise( aType, xListener ); +} + +//____________________________________________________________________________________________________________ +// XConnectionPointContainer +//____________________________________________________________________________________________________________ + +void SAL_CALL FrameControl::unadvise( const Type& aType , + const Reference< XInterface >& xListener ) throw( RuntimeException ) +{ + // Forwarded to helper class + m_aConnectionPointContainer.unadvise( aType, xListener ); +} + +//____________________________________________________________________________________________________________ +// impl but public method to register service +//____________________________________________________________________________________________________________ + +const Sequence< OUString > FrameControl::impl_getStaticSupportedServiceNames() +{ + MutexGuard aGuard( Mutex::getGlobalMutex() ); + Sequence< OUString > seqServiceNames( 1 ); + seqServiceNames.getArray() [0] = OUString::createFromAscii( SERVICENAME_FRAMECONTROL ); + return seqServiceNames ; +} + +//____________________________________________________________________________________________________________ +// impl but public method to register service +//____________________________________________________________________________________________________________ + +const OUString FrameControl::impl_getStaticImplementationName() +{ + return OUString::createFromAscii( IMPLEMENTATIONNAME_FRAMECONTROL ); +} + +//____________________________________________________________________________________________________________ +// OPropertySetHelper +//____________________________________________________________________________________________________________ + +sal_Bool FrameControl::convertFastPropertyValue( Any& rConvertedValue , + Any& rOldValue , + sal_Int32 nHandle , + const Any& rValue ) throw( IllegalArgumentException ) +{ + sal_Bool bReturn = sal_False ; + switch (nHandle) + { + case PROPERTYHANDLE_COMPONENTURL : rConvertedValue = rValue ; + rOldValue <<= m_sComponentURL ; + bReturn = sal_True ; + break ; + + case PROPERTYHANDLE_LOADERARGUMENTS : rConvertedValue = rValue ; + rOldValue <<= m_seqLoaderArguments ; + bReturn = sal_True ; + break ; + } + + if ( bReturn == sal_False ) + { + throw IllegalArgumentException(); + } + + return bReturn ; +} + +//____________________________________________________________________________________________________________ +// OPropertySetHelper +//____________________________________________________________________________________________________________ + +void FrameControl::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , + const Any& rValue ) + throw ( ::com::sun::star::uno::Exception ) +{ + // 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 : VOS_ENSHURE ( nHandle == -1, ERRORTEXT_VOSENSHURE ) ; + } +} + +//____________________________________________________________________________________________________________ +// 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 : VOS_ENSHURE ( nHandle == -1, ERRORTEXT_VOSENSHURE ) ; + } +} + +//____________________________________________________________________________________________________________ +// OPropertySetHelper +//____________________________________________________________________________________________________________ + +IPropertyArrayHelper& FrameControl::getInfoHelper() +{ + // Create a table that map names to index values. + static OPropertyArrayHelper* pInfo ; + + if (!pInfo) + { + // global method must be guarded + MutexGuard aGuard ( Mutex::getGlobalMutex() ) ; + + if (!pInfo) + { + pInfo = new OPropertyArrayHelper( impl_getStaticPropertyDescriptor(), sal_True ); + } + } + + return *pInfo ; +} +/* +//-------------------------------------------------------------------------------------------------- +// start OConnectionPointContainerHelper +//-------------------------------------------------------------------------------------------------- +Uik* FrameControl::getConnectionPointUiks ( sal_Int32* pCount ) const +{ + static Uik szUiks[] = + { + ((XEventListener*)NULL)->getSmartUik (), + ::getCppuType((const Reference< XPropertyChangeListener >*)0), + ::getCppuType((const Reference< XVetoableChangeListener >*)0), + ::getCppuType((const Reference< XPropertiesChangeListener >*)0) + } ; + + *pCount = 4 ; + + return szUiks ; +} +//-------------------------------------------------------------------------------------------------- +// end OConnectionPointContainerHelper +//-------------------------------------------------------------------------------------------------- +*/ + +//____________________________________________________________________________________________________________ +// OPropertySetHelper +//____________________________________________________________________________________________________________ + +Reference< XPropertySetInfo > SAL_CALL FrameControl::getPropertySetInfo() throw( RuntimeException ) +{ + // Optimize this method ! + // We initialize a static variable only one time. And we don't must use a mutex at every call! + // For the first call; pInfo is NULL - for the second call pInfo is different from NULL! + static Reference< XPropertySetInfo >* pInfo = (Reference< XPropertySetInfo >*)0 ; + if ( pInfo == (Reference< XPropertySetInfo >*)0 ) + { + // Ready for multithreading + MutexGuard aGuard ( Mutex::getGlobalMutex () ) ; + // Control this pointer again, another instance can be faster then these! + if ( pInfo == (Reference< XPropertySetInfo >*)0 ) + { + // Create structure of propertysetinfo for baseclass "OPropertySetHelper". + // (Use method "getInfoHelper()".) + static Reference< XPropertySetInfo > xInfo ( createPropertySetInfo ( getInfoHelper () ) ) ; + pInfo = &xInfo ; + } + } + return ( *pInfo ) ; +} + +//____________________________________________________________________________________________________________ +// BaseControl +//____________________________________________________________________________________________________________ + +WindowDescriptor* FrameControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer ) +{ + WindowDescriptor* pDescriptor = new WindowDescriptor ; + + pDescriptor->Type = WindowClass_CONTAINER ; + pDescriptor->ParentIndex = -1 ; + pDescriptor->Parent = xParentPeer ; + pDescriptor->Bounds = getPosSize () ; + pDescriptor->WindowAttributes = 0 ; + + return pDescriptor ; +} + +//____________________________________________________________________________________________________________ +// private method +//____________________________________________________________________________________________________________ + +void FrameControl::impl_createFrame( const Reference< XWindowPeer >& xPeer , + const OUString& rURL , + const Sequence< PropertyValue >& rArguments ) +{ + Reference< XFrame > xOldFrame ; + Reference< XFrame > xNewFrame ; + + { + MutexGuard aGuard ( m_aMutex ) ; + xOldFrame = m_xFrame ; + } + + xNewFrame = Reference< XFrame > ( impl_getMultiServiceFactory()->createInstance ( OUString::createFromAscii( "com.sun.star.frame.Frame" ) ), UNO_QUERY ) ; + Reference< XDispatchProvider > xDSP ( xNewFrame, UNO_QUERY ) ; + + if (xDSP.is()) + { + Reference< XWindow > xWP ( xPeer, UNO_QUERY ) ; + xNewFrame->initialize ( xWP ) ; + + // option + //xFrame->setName( "WhatYouWant" ); + + Reference< XURLTransformer > xTrans ( impl_getMultiServiceFactory()->createInstance ( OUString::createFromAscii( "com.sun.star.util.URLTransformer" ) ), UNO_QUERY ) ; + if(xTrans.is()) + { + // load file + URL aURL ; + + aURL.Complete = rURL ; + xTrans->parseStrict( aURL ) ; + + Reference< XDispatch > xDisp = xDSP->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, ::getCppuType((const Reference< XFrame >*)0) ) ; + Any aOldFrame ( &xOldFrame, ::getCppuType((const Reference< XFrame >*)0) ) ; + + fire ( &nFrameId, &aNewFrame, &aOldFrame, 1, sal_False ) ; + + if (xOldFrame.is()) + { + xOldFrame->dispose () ; + } +} + +//____________________________________________________________________________________________________________ +// private method +//____________________________________________________________________________________________________________ + +void FrameControl::impl_deleteFrame() +{ + Reference< XFrame > xOldFrame; + Reference< XFrame > xNullFrame; + + { + // do not dispose the frame in this guarded section (deadlock?) + MutexGuard aGuard( m_aMutex ); + xOldFrame = m_xFrame; + m_xFrame = Reference< XFrame > (); + } + + // notify the listeners + sal_Int32 nFrameId = PROPERTYHANDLE_FRAME; + Any aNewFrame( &xNullFrame, ::getCppuType((const Reference< XFrame >*)0) ); + Any aOldFrame( &xOldFrame, ::getCppuType((const Reference< XFrame >*)0) ); + fire( &nFrameId, &aNewFrame, &aOldFrame, 1, sal_False ); + + // dispose the frame + if( xOldFrame.is() ) + xOldFrame->dispose(); +} + +//____________________________________________________________________________________________________________ +// private method +//____________________________________________________________________________________________________________ + +const Sequence< Property > FrameControl::impl_getStaticPropertyDescriptor() +{ + // All Properties of this implementation. The array must be sorted! + static const Property pPropertys[PROPERTY_COUNT] = + { + Property( OUString::createFromAscii( PROPERTYNAME_COMPONENTURL ), PROPERTYHANDLE_COMPONENTURL , ::getCppuType((const OUString*)0) , PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED ), + Property( OUString::createFromAscii( PROPERTYNAME_FRAME ), PROPERTYHANDLE_FRAME , ::getCppuType((const Reference< XFrame >*)0) , PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT ), + Property( OUString::createFromAscii( PROPERTYNAME_LOADERARGUMENTS ), PROPERTYHANDLE_LOADERARGUMENTS , ::getCppuType((const Sequence< PropertyValue >*)0), PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED ) + }; + + static const Sequence< Property > seqPropertys( pPropertys, PROPERTY_COUNT ); + + return seqPropertys ; +} + +} // namespace unocontrols diff --git a/UnoControls/source/controls/makefile.mk b/UnoControls/source/controls/makefile.mk new file mode 100644 index 000000000000..20314ea8e321 --- /dev/null +++ b/UnoControls/source/controls/makefile.mk @@ -0,0 +1,49 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +PRJ=..$/.. + +PRJNAME=UnoControls +TARGET=controls +ENABLE_EXCEPTIONS=TRUE +.IF "$(L10N_framework)"=="" + +# --- Settings ----------------------------------------------------- +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- +SLOFILES=\ + $(SLO)$/progressbar.obj \ + $(SLO)$/framecontrol.obj \ + $(SLO)$/progressmonitor.obj \ + $(SLO)$/OConnectionPointHelper.obj \ + $(SLO)$/OConnectionPointContainerHelper.obj \ + $(SLO)$/statusindicator.obj + +# --- Targets ------------------------------------------------------ +.ENDIF # L10N_framework + +.INCLUDE : target.mk diff --git a/UnoControls/source/controls/progressbar.cxx b/UnoControls/source/controls/progressbar.cxx new file mode 100644 index 000000000000..842affed16da --- /dev/null +++ b/UnoControls/source/controls/progressbar.cxx @@ -0,0 +1,558 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +//____________________________________________________________________________________________________________ +// my own includes +//____________________________________________________________________________________________________________ + +#include "progressbar.hxx" + +//____________________________________________________________________________________________________________ +// includes of other projects +//____________________________________________________________________________________________________________ +#include <com/sun/star/awt/GradientStyle.hpp> +#include <com/sun/star/awt/RasterOperation.hpp> +#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/awt/XGraphics.hpp> +#include <tools/debug.hxx> +#include <cppuhelper/typeprovider.hxx> + +#include <math.h> +#include <limits.h> + +//____________________________________________________________________________________________________________ +// includes of my project +//____________________________________________________________________________________________________________ + +//____________________________________________________________________________________________________________ +// namespace +//____________________________________________________________________________________________________________ + +using namespace ::cppu ; +using namespace ::osl ; +using namespace ::rtl ; +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< XMultiServiceFactory >& xFactory ) + : BaseControl ( xFactory ) + , m_bHorizontal ( DEFAULT_HORIZONTAL ) + , m_aBlockSize ( DEFAULT_BLOCKDIMENSION ) + , m_nForegroundColor ( DEFAULT_FOREGROUNDCOLOR ) + , m_nBackgroundColor ( DEFAULT_BACKGROUNDCOLOR ) + , m_nMinRange ( DEFAULT_MINRANGE ) + , m_nMaxRange ( DEFAULT_MAXRANGE ) + , m_nBlockValue ( DEFAULT_BLOCKVALUE ) + , m_nValue ( DEFAULT_VALUE ) +{ +} + +ProgressBar::~ProgressBar() +{ +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +Any SAL_CALL ProgressBar::queryInterface( const Type& rType ) throw( RuntimeException ) +{ + // 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 an delegator exist, forward question to his queryInterface. + // Delegator will ask his own queryAggregation! + aReturn = xDel->queryInterface( rType ); + } + else + { + // If an delegator unknown, forward question to own queryAggregation. + aReturn = queryAggregation( rType ); + } + + return aReturn ; +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressBar::acquire() throw() +{ + // 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() throw() +{ + // 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() throw( RuntimeException ) +{ + // Optimize this method ! + // We initialize a static variable only one time. And we don't must use a mutex at every call! + // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL! + static OTypeCollection* pTypeCollection = NULL ; + + if ( pTypeCollection == NULL ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( Mutex::getGlobalMutex() ); + + // Control these pointer again ... it can be, that another instance will be faster then these! + if ( pTypeCollection == NULL ) + { + // Create a static typecollection ... + static OTypeCollection aTypeCollection ( ::getCppuType(( const Reference< XControlModel >*)NULL ) , + ::getCppuType(( const Reference< XProgressBar >*)NULL ) , + BaseControl::getTypes() + ); + // ... and set his address to static pointer! + pTypeCollection = &aTypeCollection ; + } + } + + return pTypeCollection->getTypes(); +} + +//____________________________________________________________________________________________________________ +// XAggregation +//____________________________________________________________________________________________________________ + +Any SAL_CALL ProgressBar::queryAggregation( const Type& aType ) throw( RuntimeException ) +{ + // 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() == sal_False ) + { + // ... ask baseclasses. + aReturn = BaseControl::queryAggregation( aType ); + } + + return aReturn ; +} + +//____________________________________________________________________________________________________________ +// XProgressBar +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressBar::setForegroundColor( sal_Int32 nColor ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard (m_aMutex) ; + + // Safe color for later use. + m_nForegroundColor = nColor ; + + // Repaint control + impl_paint ( 0, 0, impl_getGraphicsPeer() ) ; +} + +//____________________________________________________________________________________________________________ +// XProgressBar +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressBar::setBackgroundColor ( sal_Int32 nColor ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard (m_aMutex) ; + + // Safe color for later use. + m_nBackgroundColor = nColor ; + + // Repaint control + impl_paint ( 0, 0, impl_getGraphicsPeer() ) ; +} + +//____________________________________________________________________________________________________________ +// XProgressBar +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressBar::setValue ( sal_Int32 nValue ) throw( RuntimeException ) +{ + // 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 ) throw( RuntimeException ) +{ + // 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 wil 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 automaticly + 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 () throw( RuntimeException ) +{ + // 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 ) throw( RuntimeException ) +{ + // 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*/ ) throw( RuntimeException ) +{ + // A model is not possible for this control. + return sal_False ; +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +Reference< XControlModel > SAL_CALL ProgressBar::getModel() throw( RuntimeException ) +{ + // A model is not possible for this control. + return Reference< XControlModel >(); +} + +//____________________________________________________________________________________________________________ +// impl but public method to register service +//____________________________________________________________________________________________________________ + +const Sequence< OUString > ProgressBar::impl_getStaticSupportedServiceNames() +{ + MutexGuard aGuard( Mutex::getGlobalMutex() ); + Sequence< OUString > seqServiceNames( 1 ); + seqServiceNames.getArray() [0] = OUString::createFromAscii( SERVICENAME_PROGRESSBAR ); + return seqServiceNames ; +} + +//____________________________________________________________________________________________________________ +// impl but public method to register service +//____________________________________________________________________________________________________________ + +const OUString ProgressBar::impl_getStaticImplementationName() +{ + return OUString::createFromAscii( IMPLEMENTATIONNAME_PROGRESSBAR ); +} + +//____________________________________________________________________________________________________________ +// 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 ist not buffered !! + // Every request paint the completely control. ( but only, if peer exist ) + if ( rGraphics.is () ) + { + MutexGuard aGuard (m_aMutex) ; + + // Clear background + // (same color for line and fill) + rGraphics->setFillColor ( m_nBackgroundColor ) ; + rGraphics->setLineColor ( m_nBackgroundColor ) ; + rGraphics->drawRect ( nX, nY, impl_getWidth(), impl_getHeight() ) ; + + // same color for line and fill for blocks + rGraphics->setFillColor ( m_nForegroundColor ) ; + rGraphics->setLineColor ( m_nForegroundColor ) ; + + sal_Int32 nBlockStart = 0 ; // = left site of new block + sal_Int32 nBlockCount = m_nBlockValue!=0.00 ? (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_Int16 i=1; i<=nBlockCount; ++i ) + { + // step free field + nBlockStart += FREESPACE ; + // paint block + rGraphics->drawRect (nBlockStart, nY+FREESPACE, m_aBlockSize.Width, m_aBlockSize.Height) ; + // step next free field + nBlockStart += m_aBlockSize.Width ; + } + } + // draw vertikal progressbar + // decision in "recalcRange()" + else + { + // step to bottom side of window + nBlockStart = nY+impl_getHeight() ; + nBlockStart -= m_aBlockSize.Height ; + + for ( sal_Int16 i=1; i<=nBlockCount; ++i ) + { + // step free field + nBlockStart -= FREESPACE ; + // paint block + rGraphics->drawRect (nX+FREESPACE, nBlockStart, m_aBlockSize.Width, m_aBlockSize.Height) ; + // step next free field + nBlockStart -= m_aBlockSize.Height; + } + } + + // Paint shadow border around the progressbar + rGraphics->setLineColor ( LINECOLOR_SHADOW ) ; + rGraphics->drawLine ( nX, nY, impl_getWidth(), nY ) ; + rGraphics->drawLine ( nX, nY, nX , impl_getHeight() ) ; + + rGraphics->setLineColor ( 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 = sal_True ; + fBlockHeight = (nWindowHeight-(2*FREESPACE)) ; + fBlockWidth = fBlockHeight ; + fMaxBlocks = nWindowWidth/(fBlockWidth+FREESPACE); + } + else + { + m_bHorizontal = sal_False ; + fBlockWidth = (nWindowWidth-(2*FREESPACE)) ; + fBlockHeight = fBlockWidth ; + fMaxBlocks = nWindowHeight/(fBlockHeight+FREESPACE); + } + + double fRange = m_nMaxRange-m_nMinRange ; + double fBlockValue = fRange/fMaxBlocks ; + + m_nBlockValue = fBlockValue ; + m_aBlockSize.Height = (sal_Int32)fBlockHeight; + m_aBlockSize.Width = (sal_Int32)fBlockWidth ; +/* + // Calculate count of blocks for actual size + // (prevent error "division by zero") + if ( nHeight == 0 ) + { + nHeight = 1 ; + } + + nMaxBlock = nWidth / nHeight ; + nMaxBlock *= 2 ; + + // prevent error "division by zero" + if ( nMaxBlock == 0 ) + { + nMaxBlock = 1 ; + } + + // Calculate new value and new size for ONE block. + + // Do not a calculation like this: "m_nBlockValue=(m_nMaxRange-m_nMinRange)/nMaxBlock" ! + // If difference between m_nMaxRange and m_nMinRange to large, it give an overflow and a + // following error "division by zero" in method "paint() ... nBlockCount=nDifference/m_nBlockValue ..." + + // Overflow ? => example: _I32_MAX - _I32_MIN = -1 and not _UI32_MAX !!! + + m_nBlockValue = ( m_nMaxRange / nMaxBlock ) - ( m_nMinRange / nMaxBlock ) ; + m_aBlockSize.Height = ( nHeight - ( FREESPACE * 2 ) ) ; + m_aBlockSize.Width = ( ( nWidth / nMaxBlock ) - FREESPACE ) ; + } + else + { + // Don't forget to save this state! Used in "ProgressBar::paint()" + m_bHorizontal = sal_False ; + + double fBlockWidth = (nHeight-(2*FREESPACE)) ; + double fBlockHeight = fBlockWidth ; + double fRange = m_nMaxRange-m_nMinRange ; + double fBlockValue = fRange/(fBlockWidth+FREESPACE); + + m_nBlockValue = fBlockValue ; + m_aBlockSize.Height = (sal_Int32)fBlockHeight; + m_aBlockSize.Width = (sal_Int32)fBlockWidth ; + + // Calculate count of blocks for actual size + // (prevent error "division by zero") + if ( nWidth == 0 ) + { + nWidth = 1 ; + } + + nMaxBlock = nHeight / nWidth ; + nMaxBlock *= 2 ; + + // prevent error "division by zero" + if ( nMaxBlock == 0 ) + { + nMaxBlock = 1 ; + } + + // Calculate new value and new size for ONE block. + + // Do not a calculation like this: "m_nBlockValue=(m_nMaxRange-m_nMinRange)/nMaxBlock" ! + // If difference between m_nMaxRange and m_nMinRange to large, it give an overflow and a + // following error "division by zero" in method "paint() ... nBlockCount=nDifference/m_nBlockValue ..." + + // Overflow ? => example: _I32_MAX - _I32_MIN = -1 and not _UI32_MAX !!! + + m_nBlockValue = ( m_nMaxRange / nMaxBlock ) - ( m_nMinRange / nMaxBlock ) ; + m_aBlockSize.Height = ( ( nHeight / nMaxBlock ) - FREESPACE ) ; + m_aBlockSize.Width = ( nWidth - ( FREESPACE * 2 ) ) ; + + } +*/ +} + +} // namespace unocontrols diff --git a/UnoControls/source/controls/progressmonitor.cxx b/UnoControls/source/controls/progressmonitor.cxx new file mode 100644 index 000000000000..39bf4d84f8b9 --- /dev/null +++ b/UnoControls/source/controls/progressmonitor.cxx @@ -0,0 +1,1066 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +//____________________________________________________________________________________________________________ +// my own includes +//____________________________________________________________________________________________________________ + +#include "progressmonitor.hxx" + +//____________________________________________________________________________________________________________ +// includes of other projects +//____________________________________________________________________________________________________________ +#include <com/sun/star/awt/GradientStyle.hpp> +#include <com/sun/star/awt/RasterOperation.hpp> +#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/awt/XGraphics.hpp> +#include <com/sun/star/awt/PosSize.hpp> +#include <cppuhelper/typeprovider.hxx> +#include <tools/debug.hxx> +#include <tools/solar.h> + +//____________________________________________________________________________________________________________ +// includes of my project +//____________________________________________________________________________________________________________ +#include "progressbar.hxx" + +//____________________________________________________________________________________________________________ +// namespace +//____________________________________________________________________________________________________________ + +using namespace ::cppu ; +using namespace ::osl ; +using namespace ::rtl ; +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using namespace ::com::sun::star::awt ; + +namespace unocontrols{ + +//____________________________________________________________________________________________________________ +// construct/destruct +//____________________________________________________________________________________________________________ + +ProgressMonitor::ProgressMonitor( const Reference< XMultiServiceFactory >& xFactory ) + : BaseContainerControl ( xFactory ) +{ + // Its not allowed to work with member in this method (refcounter !!!) + // But with a HACK (++refcount) its "OK" :-( + ++m_refCount ; + + // Create instances for fixedtext, button and progress ... + m_xTopic_Top = Reference< XFixedText > ( xFactory->createInstance ( OUString::createFromAscii( FIXEDTEXT_SERVICENAME ) ), UNO_QUERY ) ; + m_xText_Top = Reference< XFixedText > ( xFactory->createInstance ( OUString::createFromAscii( FIXEDTEXT_SERVICENAME ) ), UNO_QUERY ) ; + m_xTopic_Bottom = Reference< XFixedText > ( xFactory->createInstance ( OUString::createFromAscii( FIXEDTEXT_SERVICENAME ) ), UNO_QUERY ) ; + m_xText_Bottom = Reference< XFixedText > ( xFactory->createInstance ( OUString::createFromAscii( FIXEDTEXT_SERVICENAME ) ), UNO_QUERY ) ; + m_xButton = Reference< XButton > ( xFactory->createInstance ( OUString::createFromAscii( BUTTON_SERVICENAME ) ), UNO_QUERY ) ; + m_xProgressBar = Reference< XProgressBar > ( xFactory->createInstance ( OUString::createFromAscii( SERVICENAME_PROGRESSBAR ) ), UNO_QUERY ) ; + + // ... cast controls to Reference< XControl > (for "setModel"!) ... + Reference< XControl > xRef_Topic_Top ( m_xTopic_Top , UNO_QUERY ) ; + Reference< XControl > xRef_Text_Top ( m_xText_Top , UNO_QUERY ) ; + Reference< XControl > xRef_Topic_Bottom ( m_xTopic_Bottom , UNO_QUERY ) ; + Reference< XControl > xRef_Text_Bottom ( m_xText_Bottom , UNO_QUERY ) ; + Reference< XControl > xRef_Button ( m_xButton , UNO_QUERY ) ; + Reference< XControl > xRef_ProgressBar ( m_xProgressBar , UNO_QUERY ) ; + + // ... set models ... + xRef_Topic_Top->setModel ( Reference< XControlModel > ( xFactory->createInstance ( OUString::createFromAscii( FIXEDTEXT_MODELNAME ) ), UNO_QUERY ) ) ; + xRef_Text_Top->setModel ( Reference< XControlModel > ( xFactory->createInstance ( OUString::createFromAscii( FIXEDTEXT_MODELNAME ) ), UNO_QUERY ) ) ; + xRef_Topic_Bottom->setModel ( Reference< XControlModel > ( xFactory->createInstance ( OUString::createFromAscii( FIXEDTEXT_MODELNAME ) ), UNO_QUERY ) ) ; + xRef_Text_Bottom->setModel ( Reference< XControlModel > ( xFactory->createInstance ( OUString::createFromAscii( FIXEDTEXT_MODELNAME ) ), UNO_QUERY ) ) ; + xRef_Button->setModel ( Reference< XControlModel > ( xFactory->createInstance ( OUString::createFromAscii( BUTTON_MODELNAME ) ), UNO_QUERY ) ) ; + // ProgressBar has no model !!! + + // ... and add controls to basecontainercontrol! + addControl ( OUString::createFromAscii( CONTROLNAME_TEXT ) , xRef_Topic_Top ) ; + addControl ( OUString::createFromAscii( CONTROLNAME_TEXT ) , xRef_Text_Top ) ; + addControl ( OUString::createFromAscii( CONTROLNAME_TEXT ) , xRef_Topic_Bottom ) ; + addControl ( OUString::createFromAscii( CONTROLNAME_TEXT ) , xRef_Text_Bottom ) ; + addControl ( OUString::createFromAscii( CONTROLNAME_BUTTON ) , xRef_Button ) ; + addControl ( OUString::createFromAscii( CONTROLNAME_PROGRESSBAR ) , xRef_ProgressBar ) ; + + // FixedText make it automaticly visible by himself ... but not the progressbar !!! + // it must be set explicitly + Reference< XWindow > xWindowRef_ProgressBar( m_xProgressBar, UNO_QUERY ); + xWindowRef_ProgressBar->setVisible( sal_True ); + + // Reset to defaults !!! + // (progressbar take automaticly its own defaults) + m_xButton->setLabel ( OUString::createFromAscii( DEFAULT_BUTTONLABEL ) ) ; + m_xTopic_Top->setText ( OUString::createFromAscii( DEFAULT_TOPIC ) ) ; + m_xText_Top->setText ( OUString::createFromAscii( DEFAULT_TEXT ) ) ; + m_xTopic_Bottom->setText ( OUString::createFromAscii( DEFAULT_TOPIC ) ) ; + m_xText_Bottom->setText ( OUString::createFromAscii( DEFAULT_TEXT ) ) ; + + --m_refCount ; + + // Initialize info lists for fixedtext's + m_pTextlist_Top = new IMPL_Textlist ; + m_pTextlist_Bottom = new IMPL_Textlist ; +} + +ProgressMonitor::~ProgressMonitor() +{ + impl_cleanMemory () ; +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +Any SAL_CALL ProgressMonitor::queryInterface( const Type& rType ) throw( RuntimeException ) +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + Any aReturn ; + Reference< XInterface > xDel = BaseContainerControl::impl_getDelegator(); + if ( xDel.is() ) + { + // If an delegator exist, forward question to his queryInterface. + // Delegator will ask his own queryAggregation! + aReturn = xDel->queryInterface( rType ); + } + else + { + // If an delegator unknown, forward question to own queryAggregation. + aReturn = queryAggregation( rType ); + } + + return aReturn ; +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::acquire() throw() +{ + // 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() throw() +{ + // 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() throw( RuntimeException ) +{ + // Optimize this method ! + // We initialize a static variable only one time. And we don't must use a mutex at every call! + // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL! + static OTypeCollection* pTypeCollection = NULL ; + + if ( pTypeCollection == NULL ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( Mutex::getGlobalMutex() ); + + // Control these pointer again ... it can be, that another instance will be faster then these! + if ( pTypeCollection == NULL ) + { + // Create a static typecollection ... + static OTypeCollection aTypeCollection ( ::getCppuType(( const Reference< XLayoutConstrains >*)NULL ) , + ::getCppuType(( const Reference< XButton >*)NULL ) , + ::getCppuType(( const Reference< XProgressMonitor >*)NULL ) , + BaseContainerControl::getTypes() + ); + // ... and set his address to static pointer! + pTypeCollection = &aTypeCollection ; + } + } + + return pTypeCollection->getTypes(); +} + +//____________________________________________________________________________________________________________ +// XAggregation +//____________________________________________________________________________________________________________ + +Any SAL_CALL ProgressMonitor::queryAggregation( const Type& aType ) throw( RuntimeException ) +{ + // 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() == sal_False ) + { + // ... ask baseclasses. + aReturn = BaseControl::queryAggregation( aType ); + } + + return aReturn ; +} + +//____________________________________________________________________________________________________________ +// XProgressMonitor +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::addText( const OUString& rTopic, const OUString& rText, sal_Bool bbeforeProgress ) throw( RuntimeException ) +{ + // Safe impossible cases + // Check valid call of this method. + DBG_ASSERT ( impl_debug_checkParameter ( rTopic, rText, bbeforeProgress ) , "ProgressMonitor::addText()\nCall without valid parameters!\n") ; + DBG_ASSERT ( !(impl_searchTopic ( rTopic, bbeforeProgress ) != NULL ) , "ProgresMonitor::addText()\nThe text already exist.\n" ) ; + + // Do nothing (in Release), if topic already exist. + if ( impl_searchTopic ( rTopic, bbeforeProgress ) != NULL ) + { + return ; + } + + // Else ... take memory for new item ... + IMPL_TextlistItem* pTextItem = new IMPL_TextlistItem ; + + if ( pTextItem != NULL ) + { + // Set values ... + pTextItem->sTopic = rTopic ; + pTextItem->sText = rText ; + + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + // ... and insert it in right list. + if ( bbeforeProgress == sal_True ) + { + m_pTextlist_Top->Insert ( pTextItem, LIST_APPEND ) ; + } + else + { + m_pTextlist_Bottom->Insert ( pTextItem, LIST_APPEND ) ; + } + } + + // ... update window + impl_rebuildFixedText () ; + impl_recalcLayout () ; +} + +//____________________________________________________________________________________________________________ +// XProgressMonitor +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::removeText ( const OUString& rTopic, sal_Bool bbeforeProgress ) throw( RuntimeException ) +{ + // Safe impossible cases + // Check valid call of this method. + DBG_ASSERT ( impl_debug_checkParameter ( rTopic, bbeforeProgress ), "ProgressMonitor::removeText()\nCall without valid parameters!\n" ) ; + + // Search the topic ... + IMPL_TextlistItem* pSearchItem = impl_searchTopic ( rTopic, bbeforeProgress ) ; + + if ( pSearchItem != NULL ) + { + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + // ... delete item from right list ... + if ( bbeforeProgress == sal_True ) + { + m_pTextlist_Top->Remove ( pSearchItem ) ; + } + else + { + m_pTextlist_Bottom->Remove ( pSearchItem ) ; + } + + delete pSearchItem ; + + // ... and update window. + impl_rebuildFixedText () ; + impl_recalcLayout () ; + } +} + +//____________________________________________________________________________________________________________ +// XProgressMonitor +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::updateText ( const OUString& rTopic, const OUString& rText, sal_Bool bbeforeProgress ) throw( RuntimeException ) +{ + // Safe impossible cases + // Check valid call of this method. + DBG_ASSERT ( impl_debug_checkParameter ( rTopic, rText, bbeforeProgress ), "ProgressMonitor::updateText()\nCall without valid parameters!\n" ) ; + + // Search topic ... + IMPL_TextlistItem* pSearchItem = impl_searchTopic ( rTopic, bbeforeProgress ) ; + + if ( pSearchItem != NULL ) + { + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + // ... update text ... + pSearchItem->sText = rText ; + + // ... and update window. + impl_rebuildFixedText () ; + impl_recalcLayout () ; + } +} + +//____________________________________________________________________________________________________________ +// XProgressBar +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::setForegroundColor ( sal_Int32 nColor ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + if ( m_xProgressBar.is () ) + { + m_xProgressBar->setForegroundColor ( nColor ) ; + } +} + +//____________________________________________________________________________________________________________ +// XProgressBar +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::setBackgroundColor ( sal_Int32 nColor ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + if ( m_xProgressBar.is () ) + { + m_xProgressBar->setBackgroundColor ( nColor ) ; + } +} + +//____________________________________________________________________________________________________________ +// XProgressBar +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::setValue ( sal_Int32 nValue ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + if ( m_xProgressBar.is () ) + { + m_xProgressBar->setValue ( nValue ) ; + } +} + +//____________________________________________________________________________________________________________ +// XProgressBar +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::setRange ( sal_Int32 nMin, sal_Int32 nMax ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + if ( m_xProgressBar.is () ) + { + m_xProgressBar->setRange ( nMin, nMax ) ; + } +} + +//____________________________________________________________________________________________________________ +// XProgressBar +//____________________________________________________________________________________________________________ + +sal_Int32 SAL_CALL ProgressMonitor::getValue () throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + if (m_xProgressBar.is()) + { + return m_xProgressBar->getValue () ; + } + + return 0 ; +} + +//____________________________________________________________________________________________________________ +// XButton +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::addActionListener ( const Reference< XActionListener > & rListener ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + if ( m_xButton.is () ) + { + m_xButton->addActionListener ( rListener ) ; + } +} + +//____________________________________________________________________________________________________________ +// XButton +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::removeActionListener ( const Reference< XActionListener > & rListener ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + if ( m_xButton.is () ) + { + m_xButton->removeActionListener ( rListener ) ; + } +} + +//____________________________________________________________________________________________________________ +// XButton +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::setLabel ( const OUString& rLabel ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + if ( m_xButton.is () ) + { + m_xButton->setLabel ( rLabel ) ; + } +} + +//____________________________________________________________________________________________________________ +// XButton +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::setActionCommand ( const OUString& rCommand ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + if ( m_xButton.is () ) + { + m_xButton->setActionCommand ( rCommand ) ; + } +} + +//____________________________________________________________________________________________________________ +// XLayoutConstrains +//____________________________________________________________________________________________________________ + +Size SAL_CALL ProgressMonitor::getMinimumSize () throw( RuntimeException ) +{ + return Size (DEFAULT_WIDTH, DEFAULT_HEIGHT) ; +} + +//____________________________________________________________________________________________________________ +// XLayoutConstrains +//____________________________________________________________________________________________________________ + +Size SAL_CALL ProgressMonitor::getPreferredSize () throw( RuntimeException ) +{ + // Ready for multithreading + ClearableMutexGuard aGuard ( m_aMutex ) ; + + // get information about required place of child controls + Reference< XLayoutConstrains > xTopicLayout_Top ( m_xTopic_Top , UNO_QUERY ) ; + Reference< XLayoutConstrains > xTopicLayout_Bottom ( m_xTopic_Bottom , UNO_QUERY ) ; + Reference< XLayoutConstrains > xButtonLayout ( m_xButton , UNO_QUERY ) ; + Reference< XWindow > xProgressBarWindow ( m_xProgressBar , UNO_QUERY ) ; + + Size aTopicSize_Top = xTopicLayout_Top->getPreferredSize (); + Size aTopicSize_Bottom = xTopicLayout_Bottom->getPreferredSize (); + Size aButtonSize = xButtonLayout->getPreferredSize (); + Rectangle aTempRectangle = xProgressBarWindow->getPosSize (); + Size aProgressBarSize = Size( aTempRectangle.Width, aTempRectangle.Height ); + + aGuard.clear () ; + + // calc preferred size of progressmonitor + sal_Int32 nWidth = 0 ; + sal_Int32 nHeight = 0 ; + + nWidth = 3 * FREEBORDER ; + nWidth += aProgressBarSize.Width ; + + nHeight = 6 * 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<DEFAULT_WIDTH ) + { + nWidth = DEFAULT_WIDTH ; + } + if ( nHeight<DEFAULT_HEIGHT ) + { + nHeight = DEFAULT_HEIGHT ; + } + + // return to caller + return Size ( nWidth, nHeight ) ; +} + +//____________________________________________________________________________________________________________ +// XLayoutConstrains +//____________________________________________________________________________________________________________ + +Size SAL_CALL ProgressMonitor::calcAdjustedSize ( const Size& /*rNewSize*/ ) throw( RuntimeException ) +{ + return getPreferredSize () ; +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::createPeer ( const Reference< XToolkit > & rToolkit, const Reference< XWindowPeer > & rParent ) throw( RuntimeException ) +{ + 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 Reference< XControlModel > & /*rModel*/ ) throw( RuntimeException ) +{ + // We have no model. + return sal_False ; +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +Reference< XControlModel > SAL_CALL ProgressMonitor::getModel () throw( RuntimeException ) +{ + // We have no model. + // return (XControlModel*)this ; + return Reference< XControlModel > () ; +} + +//____________________________________________________________________________________________________________ +// XComponent +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::dispose () throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + // "removeControl()" control the state of a reference + Reference< XControl > xRef_Topic_Top ( m_xTopic_Top , UNO_QUERY ) ; + Reference< XControl > xRef_Text_Top ( m_xText_Top , UNO_QUERY ) ; + Reference< XControl > xRef_Topic_Bottom ( m_xTopic_Bottom , UNO_QUERY ) ; + Reference< XControl > xRef_Text_Bottom ( m_xText_Bottom , UNO_QUERY ) ; + Reference< XControl > xRef_Button ( m_xButton , UNO_QUERY ) ; + Reference< XControl > xRef_ProgressBar ( m_xProgressBar , UNO_QUERY ) ; + + removeControl ( xRef_Topic_Top ) ; + removeControl ( xRef_Text_Top ) ; + removeControl ( xRef_Topic_Bottom ) ; + removeControl ( xRef_Text_Bottom ) ; + removeControl ( xRef_Button ) ; + removeControl ( xRef_ProgressBar ) ; + + // do'nt 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 () ; + xRef_ProgressBar->dispose () ; + + BaseContainerControl::dispose () ; +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL ProgressMonitor::setPosSize ( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nFlags ) throw( RuntimeException ) +{ + 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 (!) + // [Childs was repainted in "recalcLayout" by setPosSize() automaticly!] + getPeer()->invalidate(2); + // and repaint the control + impl_paint ( 0, 0, impl_getGraphicsPeer() ) ; + } +} + +//____________________________________________________________________________________________________________ +// impl but public method to register service +//____________________________________________________________________________________________________________ + +const Sequence< OUString > ProgressMonitor::impl_getStaticSupportedServiceNames() +{ + MutexGuard aGuard( Mutex::getGlobalMutex() ); + Sequence< OUString > seqServiceNames( 1 ); + seqServiceNames.getArray() [0] = OUString::createFromAscii( SERVICENAME_PROGRESSMONITOR ); + return seqServiceNames ; +} + +//____________________________________________________________________________________________________________ +// impl but public method to register service +//____________________________________________________________________________________________________________ + +const OUString ProgressMonitor::impl_getStaticImplementationName() +{ + return OUString::createFromAscii( IMPLEMENTATIONNAME_PROGRESSMONITOR ); +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + +void ProgressMonitor::impl_paint ( sal_Int32 nX, sal_Int32 nY, const Reference< XGraphics > & rGraphics ) +{ + if (rGraphics.is()) + { + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + // paint shadowed border around the progressmonitor + rGraphics->setLineColor ( 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 ( LINECOLOR_BRIGHT ) ; + rGraphics->drawLine ( nX, nY, impl_getWidth(), nY ) ; + rGraphics->drawLine ( nX, nY, nX , impl_getHeight() ) ; + + // Paint 3D-line + rGraphics->setLineColor ( LINECOLOR_SHADOW ) ; + rGraphics->drawLine ( m_a3DLine.X, m_a3DLine.Y, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y ) ; + + rGraphics->setLineColor ( 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_3DLine ; + sal_Int32 nY_3DLine ; + sal_Int32 nWidth_3DLine ; + sal_Int32 nHeight_3DLine ; + + 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 + Reference< XLayoutConstrains > xTopicLayout_Top ( m_xTopic_Top , UNO_QUERY ) ; + Reference< XLayoutConstrains > xTextLayout_Top ( m_xText_Top , UNO_QUERY ) ; + Reference< XLayoutConstrains > xTopicLayout_Bottom ( m_xTopic_Bottom , UNO_QUERY ) ; + Reference< XLayoutConstrains > xTextLayout_Bottom ( m_xText_Bottom , UNO_QUERY ) ; + 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 = FREEBORDER ; + nY_Topic_Top = FREEBORDER ; + nWidth_Topic_Top = Max ( aTopicSize_Top.Width, aTopicSize_Bottom.Width ) ; + nHeight_Topic_Top = aTopicSize_Top.Height ; + + // Right column before progressbar has relativ position to left column ... + // ... and a size as rest of dialog size! + nX_Text_Top = nX_Topic_Top+nWidth_Topic_Top+FREEBORDER ; + nY_Text_Top = nY_Topic_Top ; + nWidth_Text_Top = Max ( aTextSize_Top.Width, aTextSize_Bottom.Width ) ; + // Fix size of this column to minimum! + sal_Int32 nSummaryWidth = nWidth_Text_Top+nWidth_Topic_Top+(3*FREEBORDER) ; + if ( nSummaryWidth < DEFAULT_WIDTH ) + nWidth_Text_Top = DEFAULT_WIDTH-nWidth_Topic_Top-(3*FREEBORDER); + // Fix size of column to maximum! + if ( nSummaryWidth > impl_getWidth() ) + nWidth_Text_Top = impl_getWidth()-nWidth_Topic_Top-(3*FREEBORDER) ; + nHeight_Text_Top = nHeight_Topic_Top ; + + // Position of progressbar is relativ to columns before. + // Progressbar.Width = Dialog.Width !!! + // Progressbar.Height = Button.Height + nX_ProgressBar = nX_Topic_Top ; + nY_ProgressBar = nY_Topic_Top+nHeight_Topic_Top+FREEBORDER ; + nWidth_ProgressBar = 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+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+FREEBORDER ; + nY_Text_Bottom = nY_Topic_Bottom ; + nWidth_Text_Bottom = nWidth_Text_Top ; + nHeight_Text_Bottom = nHeight_Topic_Bottom ; + + // Oriented by progressbar. + nX_3DLine = nX_Topic_Top ; + nY_3DLine = nY_Topic_Bottom+nHeight_Topic_Bottom+(FREEBORDER/2) ; + nWidth_3DLine = nWidth_ProgressBar ; + nHeight_3DLine = 1 ; // Height for ONE line ! (But we paint two lines!) + + // Oriented by progressbar. + nX_Button = nX_ProgressBar+nWidth_ProgressBar-nWidth_Button ; + nY_Button = nY_Topic_Bottom+nHeight_Topic_Bottom+FREEBORDER ; + + // Calc offsets to center controls + sal_Int32 nDx ; + sal_Int32 nDy ; + + nDx = ( (2*FREEBORDER)+nWidth_ProgressBar ) ; + nDy = ( (6*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 + Reference< XWindow > xRef_Topic_Top ( m_xTopic_Top , UNO_QUERY ) ; + Reference< XWindow > xRef_Text_Top ( m_xText_Top , UNO_QUERY ) ; + Reference< XWindow > xRef_Topic_Bottom ( m_xTopic_Bottom , UNO_QUERY ) ; + Reference< XWindow > xRef_Text_Bottom ( m_xText_Bottom , UNO_QUERY ) ; + Reference< XWindow > xRef_Button ( m_xButton , UNO_QUERY ) ; + Reference< XWindow > xRef_ProgressBar ( m_xProgressBar , 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 ) ; + xRef_ProgressBar->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+(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 ... + Reference< XGraphics > xGraphics = impl_getGraphicsPeer () ; + + xGraphics->setLineColor ( LINECOLOR_SHADOW ) ; + xGraphics->drawLine ( m_a3DLine.X, m_a3DLine.Y, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y ) ; + + xGraphics->setLineColor ( 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()) + { + OUString 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 ( sal_uInt32 n=0; n<m_pTextlist_Top->Count(); ++n ) + { + IMPL_TextlistItem* pSearchItem = m_pTextlist_Top->GetObject (n) ; + aCollectString += pSearchItem->sTopic ; + aCollectString += OUString::createFromAscii("\n") ; + } + aCollectString += OUString::createFromAscii("\0") ; // It's better :-) + + m_xTopic_Top->setText ( aCollectString ) ; + } + + // Rebuild right site of text + if (m_xText_Top.is()) + { + OUString 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 ( sal_uInt32 n=0; n<m_pTextlist_Top->Count(); ++n ) + { + IMPL_TextlistItem* pSearchItem = m_pTextlist_Top->GetObject (n) ; + aCollectString += pSearchItem->sText ; + aCollectString += OUString::createFromAscii("\n") ; + } + aCollectString += OUString::createFromAscii("\0") ; // It's better :-) + + m_xText_Top->setText ( aCollectString ) ; + } + + // Rebuild fixedtext below progress + + // Rebuild left site of text + if (m_xTopic_Bottom.is()) + { + OUString 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 ( sal_uInt32 n=0; n<m_pTextlist_Bottom->Count(); ++n ) + { + IMPL_TextlistItem* pSearchItem = m_pTextlist_Bottom->GetObject (n) ; + aCollectString += pSearchItem->sTopic ; + aCollectString += OUString::createFromAscii("\n") ; + } + aCollectString += OUString::createFromAscii("\0") ; // It's better :-) + + m_xTopic_Bottom->setText ( aCollectString ) ; + } + + // Rebuild right site of text + if (m_xText_Bottom.is()) + { + OUString 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 ( sal_uInt32 n=0; n<m_pTextlist_Bottom->Count(); ++n ) + { + IMPL_TextlistItem* pSearchItem = m_pTextlist_Bottom->GetObject (n) ; + aCollectString += pSearchItem->sText ; + aCollectString += OUString::createFromAscii("\n") ; + } + aCollectString += OUString::createFromAscii("\0") ; // It's better :-) + + m_xText_Bottom->setText ( aCollectString ) ; + } +} + +//____________________________________________________________________________________________________________ +// private method +//____________________________________________________________________________________________________________ + +void ProgressMonitor::impl_cleanMemory () +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + // Delete all of lists. + + sal_uInt32 nPosition ; + + for ( nPosition = 0; nPosition < m_pTextlist_Top->Count () ; ++nPosition ) + { + IMPL_TextlistItem* pSearchItem = m_pTextlist_Top->GetObject ( nPosition ) ; + delete pSearchItem ; + } + m_pTextlist_Top->Clear () ; + delete m_pTextlist_Top ; + + for ( nPosition = 0; nPosition < m_pTextlist_Bottom->Count () ; ++nPosition ) + { + IMPL_TextlistItem* pSearchItem = m_pTextlist_Bottom->GetObject ( nPosition ) ; + delete pSearchItem ; + } + m_pTextlist_Bottom->Clear () ; + delete m_pTextlist_Bottom ; +} + +//____________________________________________________________________________________________________________ +// private method +//____________________________________________________________________________________________________________ + +IMPL_TextlistItem* ProgressMonitor::impl_searchTopic ( const OUString& rTopic, sal_Bool bbeforeProgress ) +{ + // Get right textlist for following operations. + IMPL_Textlist* pTextList ; + + // Ready for multithreading + ClearableMutexGuard aGuard ( m_aMutex ) ; + + if ( bbeforeProgress == sal_True ) + { + pTextList = m_pTextlist_Top ; + } + else + { + pTextList = m_pTextlist_Bottom ; + } + + // Switch off guard. + aGuard.clear () ; + + // Search the topic in textlist. + sal_uInt32 nPosition = 0 ; + sal_uInt32 nCount = pTextList->Count () ; + + for ( nPosition = 0; nPosition < nCount ; ++nPosition ) + { + IMPL_TextlistItem* pSearchItem = pTextList->GetObject ( nPosition ) ; + + if ( pSearchItem->sTopic == rTopic ) + { + // We have found this topic ... return a valid pointer. + return pSearchItem ; + } + } + + // We have'nt found this topic ... return a nonvalid pointer. + return NULL ; +} + +//____________________________________________________________________________________________________________ +// debug methods +//____________________________________________________________________________________________________________ + +#ifdef DBG_UTIL + +// addText, updateText +sal_Bool ProgressMonitor::impl_debug_checkParameter ( const OUString& rTopic, const OUString& rText, sal_Bool /*bbeforeProgress*/ ) +{ + // Check "rTopic" + if ( &rTopic == NULL ) return sal_False ; // NULL-pointer for reference ???!!! + if ( rTopic.getLength () < 1 ) return sal_False ; // "" + + // Check "rText" + if ( &rText == NULL ) return sal_False ; // NULL-pointer for reference ???!!! + if ( rText.getLength () < 1 ) return sal_False ; // "" + + // "bbeforeProgress" is valid in everyway! + + // Parameter OK ... return sal_True. + return sal_True ; +} + +// removeText +sal_Bool ProgressMonitor::impl_debug_checkParameter ( const OUString& rTopic, sal_Bool /*bbeforeProgress*/ ) +{ + // Check "rTopic" + if ( &rTopic == NULL ) return sal_False ; // NULL-pointer for reference ???!!! + if ( rTopic.getLength () < 1 ) return sal_False ; // "" + + // "bbeforeProgress" is valid in everyway! + + // Parameter OK ... return sal_True. + return sal_True ; +} + +#endif // #ifdef DBG_UTIL + +} // namespace unocontrols diff --git a/UnoControls/source/controls/statusindicator.cxx b/UnoControls/source/controls/statusindicator.cxx new file mode 100644 index 000000000000..5dd5bd647017 --- /dev/null +++ b/UnoControls/source/controls/statusindicator.cxx @@ -0,0 +1,558 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +//____________________________________________________________________________________________________________ +// my own includes +//____________________________________________________________________________________________________________ + +#include "statusindicator.hxx" + +//____________________________________________________________________________________________________________ +// includes of other projects +//____________________________________________________________________________________________________________ +#include <com/sun/star/awt/InvalidateStyle.hpp> +#include <com/sun/star/awt/WindowAttribute.hpp> +#include <cppuhelper/typeprovider.hxx> +#include <tools/debug.hxx> + +//____________________________________________________________________________________________________________ +// includes of my project +//____________________________________________________________________________________________________________ +#include "progressbar.hxx" + +//____________________________________________________________________________________________________________ +// namespace +//____________________________________________________________________________________________________________ + +using namespace ::cppu ; +using namespace ::osl ; +using namespace ::rtl ; +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using namespace ::com::sun::star::awt ; +using namespace ::com::sun::star::task ; + +namespace unocontrols{ + +//____________________________________________________________________________________________________________ +// construct/destruct +//____________________________________________________________________________________________________________ + +StatusIndicator::StatusIndicator( const Reference< XMultiServiceFactory >& xFactory ) + : BaseContainerControl ( xFactory ) +{ + // Its not allowed to work with member in this method (refcounter !!!) + // But with a HACK (++refcount) its "OK" :-( + ++m_refCount ; + + // Create instances for fixedtext and progress ... + m_xText = Reference< XFixedText > ( xFactory->createInstance( OUString::createFromAscii( FIXEDTEXT_SERVICENAME ) ), UNO_QUERY ); + m_xProgressBar = Reference< XProgressBar > ( xFactory->createInstance( OUString::createFromAscii( SERVICENAME_PROGRESSBAR ) ), UNO_QUERY ); + // ... cast controls to Reference< XControl > and set model ... + // ( ProgressBar has no model !!! ) + Reference< XControl > xTextControl ( m_xText , UNO_QUERY ); + Reference< XControl > xProgressControl ( m_xProgressBar, UNO_QUERY ); + xTextControl->setModel( Reference< XControlModel >( xFactory->createInstance( OUString::createFromAscii( FIXEDTEXT_MODELNAME ) ), UNO_QUERY ) ); + // ... and add controls to basecontainercontrol! + addControl( OUString::createFromAscii( CONTROLNAME_TEXT ), xTextControl ); + addControl( OUString::createFromAscii( CONTROLNAME_PROGRESSBAR ), xProgressControl ); + // FixedText make it automaticly visible by himself ... but not the progressbar !!! + // it must be set explicitly + Reference< XWindow > xProgressWindow( m_xProgressBar, UNO_QUERY ); + xProgressWindow->setVisible( sal_True ); + // Reset to defaults !!! + // (progressbar take automaticly its own defaults) + m_xText->setText( OUString::createFromAscii( DEFAULT_TEXT ) ); + + --m_refCount ; +} + +StatusIndicator::~StatusIndicator() +{ + // Release all references + m_xText = Reference< XFixedText >(); + m_xProgressBar = Reference< XProgressBar >(); +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +Any SAL_CALL StatusIndicator::queryInterface( const Type& rType ) throw( RuntimeException ) +{ + // Attention: + // Don't use mutex or guard in this method!!! Is a method of XInterface. + Any aReturn ; + Reference< XInterface > xDel = BaseContainerControl::impl_getDelegator(); + if ( xDel.is() ) + { + // If an delegator exist, forward question to his queryInterface. + // Delegator will ask his own queryAggregation! + aReturn = xDel->queryInterface( rType ); + } + else + { + // If an delegator unknown, forward question to own queryAggregation. + aReturn = queryAggregation( rType ); + } + + return aReturn ; +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +void SAL_CALL StatusIndicator::acquire() throw() +{ + // 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() throw() +{ + // 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() throw( RuntimeException ) +{ + // Optimize this method ! + // We initialize a static variable only one time. And we don't must use a mutex at every call! + // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL! + static OTypeCollection* pTypeCollection = NULL ; + + if ( pTypeCollection == NULL ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( Mutex::getGlobalMutex() ); + + // Control these pointer again ... it can be, that another instance will be faster then these! + if ( pTypeCollection == NULL ) + { + // Create a static typecollection ... + static OTypeCollection aTypeCollection ( ::getCppuType(( const Reference< XLayoutConstrains >*)NULL ) , + ::getCppuType(( const Reference< XStatusIndicator >*)NULL ) , + BaseContainerControl::getTypes() + ); + // ... and set his address to static pointer! + pTypeCollection = &aTypeCollection ; + } + } + + return pTypeCollection->getTypes(); +} + +//____________________________________________________________________________________________________________ +// XAggregation +//____________________________________________________________________________________________________________ + +Any SAL_CALL StatusIndicator::queryAggregation( const Type& aType ) throw( RuntimeException ) +{ + // 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() == sal_False ) + { + // ... ask baseclasses. + aReturn = BaseControl::queryAggregation( aType ); + } + + return aReturn ; +} + +//____________________________________________________________________________________________________________ +// XStatusIndicator +//____________________________________________________________________________________________________________ + +void SAL_CALL StatusIndicator::start( const OUString& sText, sal_Int32 nRange ) throw( RuntimeException ) +{ + // 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() throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // Clear values of status controls. + m_xText->setText( OUString() ); + m_xProgressBar->setValue( 0 ); + setVisible( sal_False ); +} + +//____________________________________________________________________________________________________________ +// XStatusIndicator +//____________________________________________________________________________________________________________ + +void SAL_CALL StatusIndicator::setText( const OUString& sText ) throw( RuntimeException ) +{ + // 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 ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + // Take value on right control + m_xProgressBar->setValue( nValue ); +} + +//____________________________________________________________________________________________________________ +// XStatusIndicator +//____________________________________________________________________________________________________________ + +void SAL_CALL StatusIndicator::reset() throw( RuntimeException ) +{ + // 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 () throw( RuntimeException ) +{ + return Size (DEFAULT_WIDTH, DEFAULT_HEIGHT) ; +} + +//____________________________________________________________________________________________________________ +// XLayoutConstrains +//____________________________________________________________________________________________________________ + +Size SAL_CALL StatusIndicator::getPreferredSize () throw( RuntimeException ) +{ + // Ready for multithreading + ClearableMutexGuard aGuard ( m_aMutex ) ; + + // get information about required place of child controls + 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*FREEBORDER)+aTextSize.Height ; + + // norm to minimum + if ( nWidth<DEFAULT_WIDTH ) + { + nWidth = DEFAULT_WIDTH ; + } + if ( nHeight<DEFAULT_HEIGHT ) + { + nHeight = DEFAULT_HEIGHT ; + } + + // return to caller + return Size ( nWidth, nHeight ) ; +} + +//____________________________________________________________________________________________________________ +// XLayoutConstrains +//____________________________________________________________________________________________________________ + +Size SAL_CALL StatusIndicator::calcAdjustedSize ( const Size& /*rNewSize*/ ) throw( RuntimeException ) +{ + return getPreferredSize () ; +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +void SAL_CALL StatusIndicator::createPeer ( const Reference< XToolkit > & rToolkit, const Reference< XWindowPeer > & rParent ) throw( RuntimeException ) +{ + if( getPeer().is() == sal_False ) + { + 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 Reference< XControlModel > & /*rModel*/ ) throw( RuntimeException ) +{ + // We have no model. + return sal_False ; +} + +//____________________________________________________________________________________________________________ +// XControl +//____________________________________________________________________________________________________________ + +Reference< XControlModel > SAL_CALL StatusIndicator::getModel () throw( RuntimeException ) +{ + // We have no model. + // return (XControlModel*)this ; + return Reference< XControlModel > () ; +} + +//____________________________________________________________________________________________________________ +// XComponent +//____________________________________________________________________________________________________________ + +void SAL_CALL StatusIndicator::dispose () throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + // "removeControl()" control the state of a reference + Reference< XControl > xTextControl ( m_xText , UNO_QUERY ); + Reference< XControl > xProgressControl ( m_xProgressBar, UNO_QUERY ); + + removeControl( xTextControl ); + removeControl( xProgressControl ); + + // do'nt use "...->clear ()" or "... = XFixedText ()" + // when other hold a reference at this object !!! + xTextControl->dispose(); + xProgressControl->dispose(); + BaseContainerControl::dispose(); +} + +//____________________________________________________________________________________________________________ +// XWindow +//____________________________________________________________________________________________________________ + +void SAL_CALL StatusIndicator::setPosSize ( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nFlags ) throw( RuntimeException ) +{ + 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 (!) + // [Childs was repainted in "recalcLayout" by setPosSize() automaticly!] + getPeer()->invalidate(2); + // and repaint the control + impl_paint ( 0, 0, impl_getGraphicsPeer() ) ; + } +} + +//____________________________________________________________________________________________________________ +// impl but public method to register service +//____________________________________________________________________________________________________________ + +const Sequence< OUString > StatusIndicator::impl_getStaticSupportedServiceNames() +{ + MutexGuard aGuard( Mutex::getGlobalMutex() ); + Sequence< OUString > seqServiceNames( 1 ); + seqServiceNames.getArray() [0] = OUString::createFromAscii( SERVICENAME_STATUSINDICATOR ); + return seqServiceNames ; +} + +//____________________________________________________________________________________________________________ +// impl but public method to register service +//____________________________________________________________________________________________________________ + +const OUString StatusIndicator::impl_getStaticImplementationName() +{ + return OUString::createFromAscii( IMPLEMENTATIONNAME_STATUSINDICATOR ); +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + +WindowDescriptor* StatusIndicator::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer ) +{ + // - used from "createPeer()" to set the values of an ::com::sun::star::awt::WindowDescriptor !!! + // - if you will change the descriptor-values, you must override this virtuell function + // - the caller must release the memory for this dynamical descriptor !!! + + WindowDescriptor* pDescriptor = new WindowDescriptor ; + + pDescriptor->Type = WindowClass_SIMPLE ; + pDescriptor->WindowServiceName = OUString::createFromAscii( "floatingwindow" ) ; + pDescriptor->ParentIndex = -1 ; + pDescriptor->Parent = xParentPeer ; + pDescriptor->Bounds = getPosSize () ; + + return pDescriptor ; +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + +void StatusIndicator::impl_paint ( sal_Int32 nX, sal_Int32 nY, const Reference< XGraphics > & rGraphics ) +{ + // This paint method ist not buffered !! + // Every request paint the completely control. ( but only, if peer exist ) + if ( rGraphics.is () ) + { + MutexGuard aGuard (m_aMutex) ; + + // background = gray + Reference< XWindowPeer > xPeer( impl_getPeerWindow(), UNO_QUERY ); + if( xPeer.is() == sal_True ) + xPeer->setBackground( BACKGROUNDCOLOR ); + + // FixedText background = gray + Reference< XControl > xTextControl( m_xText, UNO_QUERY ); + xPeer = xTextControl->getPeer(); + if( xPeer.is() == sal_True ) + xPeer->setBackground( BACKGROUNDCOLOR ); + + // Progress background = gray + xPeer = Reference< XWindowPeer >( m_xProgressBar, UNO_QUERY ); + if( xPeer.is() == sal_True ) + xPeer->setBackground( BACKGROUNDCOLOR ); + + // paint shadow border + rGraphics->setLineColor ( LINECOLOR_BRIGHT ); + rGraphics->drawLine ( nX, nY, impl_getWidth(), nY ); + rGraphics->drawLine ( nX, nY, nX , impl_getHeight() ); + + rGraphics->setLineColor ( 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 ); + Reference< XLayoutConstrains > xTextLayout ( m_xText, UNO_QUERY ); + Size aTextSize = xTextLayout->getPreferredSize(); + + if( aWindowSize.Width < DEFAULT_WIDTH ) + { + aWindowSize.Width = DEFAULT_WIDTH; + } + if( aWindowSize.Height < DEFAULT_HEIGHT ) + { + aWindowSize.Height = DEFAULT_HEIGHT; + } + + // calc position and size of child controls + nX_Text = FREEBORDER ; + nY_Text = FREEBORDER ; + nWidth_Text = aTextSize.Width ; + nHeight_Text = aTextSize.Height ; + + nX_ProgressBar = nX_Text+nWidth_Text+FREEBORDER ; + nY_ProgressBar = nY_Text ; + nWidth_ProgressBar = aWindowSize.Width-nWidth_Text-(3*FREEBORDER) ; + nHeight_ProgressBar = nHeight_Text ; + + // Set new position and size on all controls + Reference< XWindow > xTextWindow ( m_xText , UNO_QUERY ); + Reference< XWindow > xProgressWindow ( m_xProgressBar, UNO_QUERY ); + + xTextWindow->setPosSize ( nX_Text , nY_Text , nWidth_Text , nHeight_Text , 15 ) ; + xProgressWindow->setPosSize ( nX_ProgressBar, nY_ProgressBar, nWidth_ProgressBar, nHeight_ProgressBar , 15 ) ; +} + +//____________________________________________________________________________________________________________ +// debug methods +//____________________________________________________________________________________________________________ + +#if OSL_DEBUG_LEVEL > 1 + +#endif // #if OSL_DEBUG_LEVEL > 1 + +} // namespace unocontrols diff --git a/UnoControls/source/inc/OConnectionPointContainerHelper.hxx b/UnoControls/source/inc/OConnectionPointContainerHelper.hxx new file mode 100644 index 000000000000..92e7e7df0fe2 --- /dev/null +++ b/UnoControls/source/inc/OConnectionPointContainerHelper.hxx @@ -0,0 +1,262 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _OCONNECTIONPOINTCONTAINERHELPER_HXX +#define _OCONNECTIONPOINTCONTAINERHELPER_HXX + +//______________________________________________________________________________________________________________ +// includes of other projects +//______________________________________________________________________________________________________________ + +#include <com/sun/star/lang/XConnectionPointContainer.hpp> +#include <com/sun/star/lang/XConnectionPoint.hpp> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/propshlp.hxx> + +//______________________________________________________________________________________________________________ +// includes of my own project +//______________________________________________________________________________________________________________ + +//______________________________________________________________________________________________________________ +// namespaces +//______________________________________________________________________________________________________________ + +namespace unocontrols{ + +#define UNO3_ANY ::com::sun::star::uno::Any +#define UNO3_SEQUENCE ::com::sun::star::uno::Sequence +#define UNO3_TYPE ::com::sun::star::uno::Type +#define UNO3_REFERENCE ::com::sun::star::uno::Reference +#define UNO3_XCONNECTIONPOINTCONTAINER ::com::sun::star::lang::XConnectionPointContainer +#define UNO3_XCONNECTIONPOINT ::com::sun::star::lang::XConnectionPoint +#define UNO3_MUTEX ::osl::Mutex +#define UNO3_RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException +#define UNO3_XINTERFACE ::com::sun::star::uno::XInterface +#define UNO3_OMULTITYPEINTERFACECONTAINERHELPER ::cppu::OMultiTypeInterfaceContainerHelper +#define UNO3_LISTENEREXISTEXCEPTION ::com::sun::star::lang::ListenerExistException +#define UNO3_INVALIDLISTENEREXCEPTION ::com::sun::star::lang::InvalidListenerException +#define UNO3_WEAKREFERENCE ::com::sun::star::uno::WeakReference +#define UNO3_OWEAKOBJECT ::cppu::OWeakObject + +//______________________________________________________________________________________________________________ +// defines +//______________________________________________________________________________________________________________ + +//______________________________________________________________________________________________________________ +// class declaration OConnectionPointContainerHelper +//______________________________________________________________________________________________________________ + +class OConnectionPointContainerHelper : public UNO3_XCONNECTIONPOINTCONTAINER + , public UNO3_OWEAKOBJECT +{ + +//______________________________________________________________________________________________________________ +// public methods +//______________________________________________________________________________________________________________ + +public: + + //__________________________________________________________________________________________________________ + // construct/destruct + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + OConnectionPointContainerHelper( UNO3_MUTEX& aMutex ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual ~OConnectionPointContainerHelper(); + + //________________________________________________________________________________________________________ + // 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 UNO3_ANY SAL_CALL queryInterface( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short increment refcount + @descr - + + @seealso XInterface + @seealso release() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL acquire() throw(); + + /**_______________________________________________________________________________________________________ + @short decrement refcount + @descr - + + @seealso XInterface + @seealso acquire() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL release() throw(); + + //__________________________________________________________________________________________________________ + // XConnectionPointContainer + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_SEQUENCE< UNO3_TYPE > SAL_CALL getConnectionPointTypes() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_REFERENCE< UNO3_XCONNECTIONPOINT > SAL_CALL queryConnectionPoint( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL advise( const UNO3_TYPE& aType , + const UNO3_REFERENCE< UNO3_XINTERFACE >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL unadvise( const UNO3_TYPE& aType , + const UNO3_REFERENCE< UNO3_XINTERFACE >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + UNO3_OMULTITYPEINTERFACECONTAINERHELPER& impl_getMultiTypeContainer(); + +//______________________________________________________________________________________________________________ +// private variables +//______________________________________________________________________________________________________________ + +private: + + UNO3_MUTEX& m_aSharedMutex ; + UNO3_OMULTITYPEINTERFACECONTAINERHELPER m_aMultiTypeContainer ; // Container to hold listener + +}; // class OConnectionPointContainerHelper + +} // namespace unocontrols + +#endif // #ifndef _OCONNECTIONPOINTCONTAINERHELPER_HXX diff --git a/UnoControls/source/inc/OConnectionPointHelper.hxx b/UnoControls/source/inc/OConnectionPointHelper.hxx new file mode 100644 index 000000000000..0856db8027f4 --- /dev/null +++ b/UnoControls/source/inc/OConnectionPointHelper.hxx @@ -0,0 +1,306 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _OCONNECTIONPOINTHELPER_HXX +#define _OCONNECTIONPOINTHELPER_HXX + +//______________________________________________________________________________________________________________ +// includes of other projects +//______________________________________________________________________________________________________________ + +#include <com/sun/star/lang/XConnectionPointContainer.hpp> +#include <com/sun/star/lang/XConnectionPoint.hpp> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/propshlp.hxx> + +//______________________________________________________________________________________________________________ +// includes of my own project +//______________________________________________________________________________________________________________ +#include "OConnectionPointContainerHelper.hxx" + +//______________________________________________________________________________________________________________ +// namespaces +//______________________________________________________________________________________________________________ + +namespace unocontrols{ + +#define UNO3_ANY ::com::sun::star::uno::Any +#define UNO3_SEQUENCE ::com::sun::star::uno::Sequence +#define UNO3_TYPE ::com::sun::star::uno::Type +#define UNO3_REFERENCE ::com::sun::star::uno::Reference +#define UNO3_XCONNECTIONPOINTCONTAINER ::com::sun::star::lang::XConnectionPointContainer +#define UNO3_XCONNECTIONPOINT ::com::sun::star::lang::XConnectionPoint +#define UNO3_MUTEX ::osl::Mutex +#define UNO3_RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException +#define UNO3_XINTERFACE ::com::sun::star::uno::XInterface +#define UNO3_OMULTITYPEINTERFACECONTAINERHELPER ::cppu::OMultiTypeInterfaceContainerHelper +#define UNO3_LISTENEREXISTEXCEPTION ::com::sun::star::lang::ListenerExistException +#define UNO3_INVALIDLISTENEREXCEPTION ::com::sun::star::lang::InvalidListenerException +#define UNO3_WEAKREFERENCE ::com::sun::star::uno::WeakReference +#define UNO3_OWEAKOBJECT ::cppu::OWeakObject +#define UNO3_OCONNECTIONPOINTCONTAINERHELPER OConnectionPointContainerHelper + +//______________________________________________________________________________________________________________ +// defines +//______________________________________________________________________________________________________________ + +//______________________________________________________________________________________________________________ +// class declaration OConnectionPointHelper +//______________________________________________________________________________________________________________ + +class OConnectionPointHelper : public UNO3_XCONNECTIONPOINT + , public UNO3_OWEAKOBJECT +{ + +//______________________________________________________________________________________________________________ +// public methods +//______________________________________________________________________________________________________________ + +public: + + //__________________________________________________________________________________________________________ + // construct/destruct + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + OConnectionPointHelper( UNO3_MUTEX& aMutex , + UNO3_OCONNECTIONPOINTCONTAINERHELPER* pContainerImplementation , + UNO3_TYPE aType ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual ~OConnectionPointHelper(); + + //________________________________________________________________________________________________________ + // 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 UNO3_ANY SAL_CALL queryInterface( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short increment refcount + @descr - + + @seealso XInterface + @seealso release() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL acquire() throw(); + + /**_______________________________________________________________________________________________________ + @short decrement refcount + @descr - + + @seealso XInterface + @seealso acquire() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL release() throw(); + + //__________________________________________________________________________________________________________ + // XConnectionPoint + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_TYPE SAL_CALL getConnectionType() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_REFERENCE< UNO3_XCONNECTIONPOINTCONTAINER > SAL_CALL getConnectionPointContainer() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL advise( const UNO3_REFERENCE< UNO3_XINTERFACE >& xListener ) throw( UNO3_LISTENEREXISTEXCEPTION , + UNO3_INVALIDLISTENEREXCEPTION , + UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL unadvise( const UNO3_REFERENCE< UNO3_XINTERFACE >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_SEQUENCE< UNO3_REFERENCE< UNO3_XINTERFACE > > SAL_CALL getConnections() throw( UNO3_RUNTIMEEXCEPTION ); + +//______________________________________________________________________________________________________________ +// private methods +//______________________________________________________________________________________________________________ + +private: + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + sal_Bool impl_LockContainer(); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + void impl_UnlockContainer(); + +//______________________________________________________________________________________________________________ +// private variables +//______________________________________________________________________________________________________________ + +private: + + UNO3_MUTEX& m_aSharedMutex ; + UNO3_WEAKREFERENCE< UNO3_XCONNECTIONPOINTCONTAINER > m_oContainerWeakReference ; // Reference to container-class!. Don't use Reference<...> + // It is a ring-reference => and must be a wekreference! + UNO3_OCONNECTIONPOINTCONTAINERHELPER* m_pContainerImplementation ; + UNO3_TYPE m_aInterfaceType ; + UNO3_REFERENCE< UNO3_XINTERFACE > m_xLock ; + +}; // class OConnectionPointHelper + +} // namespace unocontrols + +#endif // #ifndef _OCONNECTIONPOINTHELPER_HXX diff --git a/UnoControls/source/inc/framecontrol.hxx b/UnoControls/source/inc/framecontrol.hxx new file mode 100644 index 000000000000..4ec2683e1ba6 --- /dev/null +++ b/UnoControls/source/inc/framecontrol.hxx @@ -0,0 +1,624 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _UNOCONTROLS_FRAMECONTROL_CTRL_HXX +#define _UNOCONTROLS_FRAMECONTROL_CTRL_HXX + +//______________________________________________________________________________________________________________ +// includes of other projects +//______________________________________________________________________________________________________________ + +#include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/FrameActionEvent.hpp> +#include <com/sun/star/frame/FrameAction.hpp> +#include <com/sun/star/lang/XServiceName.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XConnectionPointContainer.hpp> +#include <cppuhelper/propshlp.hxx> + +//______________________________________________________________________________________________________________ +// includes of my own project +//______________________________________________________________________________________________________________ +#include "basecontrol.hxx" +#include "OConnectionPointContainerHelper.hxx" + +//______________________________________________________________________________________________________________ +// namespaces +//______________________________________________________________________________________________________________ + +namespace unocontrols{ + +#define UNO3_ANY ::com::sun::star::uno::Any +#define UNO3_ILLEGALARGUMENTEXCEPTION ::com::sun::star::lang::IllegalArgumentException +#define UNO3_IPROPERTYARRAYHELPER ::cppu::IPropertyArrayHelper +#define UNO3_OBROADCASTHELPER ::cppu::OBroadcastHelper +#define UNO3_OCONNECTIONPOINTCONTAINERHELPER OConnectionPointContainerHelper +#define UNO3_OMULTITYPEINTERFACECONTAINERHELPER ::cppu::OMultiTypeInterfaceContainerHelper +#define UNO3_OPROPERTYSETHELPER ::cppu::OPropertySetHelper +#define UNO3_OUSTRING ::rtl::OUString +#define UNO3_PROPERTY ::com::sun::star::beans::Property +#define UNO3_PROPERTYVALUE ::com::sun::star::beans::PropertyValue +#define UNO3_REFERENCE ::com::sun::star::uno::Reference +#define UNO3_RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException +#define UNO3_SEQUENCE ::com::sun::star::uno::Sequence +#define UNO3_TYPE ::com::sun::star::uno::Type +#define UNO3_WINDOWDESCRIPTOR ::com::sun::star::awt::WindowDescriptor +#define UNO3_XCONNECTIONPOINT ::com::sun::star::lang::XConnectionPoint +#define UNO3_XCONNECTIONPOINTCONTAINER ::com::sun::star::lang::XConnectionPointContainer +#define UNO3_XCONTROLMODEL ::com::sun::star::awt::XControlModel +#define UNO3_XFRAME ::com::sun::star::frame::XFrame +#define UNO3_XGRAPHICS ::com::sun::star::awt::XGraphics +#define UNO3_XINTERFACE ::com::sun::star::uno::XInterface +#define UNO3_XMULTISERVICEFACTORY ::com::sun::star::lang::XMultiServiceFactory +#define UNO3_XPROPERTYSETINFO ::com::sun::star::beans::XPropertySetInfo +#define UNO3_XTOOLKIT ::com::sun::star::awt::XToolkit +#define UNO3_XWINDOWPEER ::com::sun::star::awt::XWindowPeer + +//______________________________________________________________________________________________________________ +// defines +//______________________________________________________________________________________________________________ + +#define SERVICENAME_FRAMECONTROL "com.sun.star.frame.FrameControl" +#define IMPLEMENTATIONNAME_FRAMECONTROL "stardiv.UnoControls.FrameControl" +#define PROPERTYNAME_LOADERARGUMENTS "LoaderArguments" +#define PROPERTYNAME_COMPONENTURL "ComponentURL" +#define PROPERTYNAME_FRAME "Frame" +#define ERRORTEXT_VOSENSHURE "This is an invalid property handle." +#define PROPERTY_COUNT 3 // you must count the propertys +#define PROPERTYHANDLE_COMPONENTURL 0 // Id must be the index into the array +#define PROPERTYHANDLE_FRAME 1 +#define PROPERTYHANDLE_LOADERARGUMENTS 2 + +//______________________________________________________________________________________________________________ +// class +//______________________________________________________________________________________________________________ + +class FrameControl : public UNO3_XCONTROLMODEL + , public UNO3_XCONNECTIONPOINTCONTAINER + , public BaseControl // This order is neccessary for right initialization of m_aMutex! + , public UNO3_OBROADCASTHELPER + , public UNO3_OPROPERTYSETHELPER +{ + +//______________________________________________________________________________________________________________ +// public methods +//______________________________________________________________________________________________________________ + +public: + + //__________________________________________________________________________________________________________ + // construct/destruct + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + FrameControl( const UNO3_REFERENCE< UNO3_XMULTISERVICEFACTORY >& xFactory ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual ~FrameControl(); + + //__________________________________________________________________________________________________________ + // XInterface + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_ANY SAL_CALL queryInterface( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short increment refcount + @descr - + + @seealso XInterface + @seealso release() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL acquire() throw(); + + /**_______________________________________________________________________________________________________ + @short decrement refcount + @descr - + + @seealso XInterface + @seealso acquire() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL release() throw(); + + //__________________________________________________________________________________________________________ + // XTypeProvider + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_SEQUENCE< UNO3_TYPE > SAL_CALL getTypes() throw( UNO3_RUNTIMEEXCEPTION ); + + //__________________________________________________________________________________________________________ + // XAggregation + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + UNO3_ANY SAL_CALL queryAggregation( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + //__________________________________________________________________________________________________________ + // XControl + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL createPeer( const UNO3_REFERENCE< UNO3_XTOOLKIT >& xToolkit , + const UNO3_REFERENCE< UNO3_XWINDOWPEER >& xParent ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual sal_Bool SAL_CALL setModel( const UNO3_REFERENCE< UNO3_XCONTROLMODEL >& xModel ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_REFERENCE< UNO3_XCONTROLMODEL > SAL_CALL getModel() throw( UNO3_RUNTIMEEXCEPTION ); + + //__________________________________________________________________________________________________________ + // XComponent + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL dispose() throw( UNO3_RUNTIMEEXCEPTION ); + + //__________________________________________________________________________________________________________ + // XView + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual sal_Bool SAL_CALL setGraphics( const UNO3_REFERENCE< UNO3_XGRAPHICS >& xDevice ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_REFERENCE< UNO3_XGRAPHICS > SAL_CALL getGraphics() throw( UNO3_RUNTIMEEXCEPTION ); + + //__________________________________________________________________________________________________________ + // XConnectionPointContainer + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_SEQUENCE< UNO3_TYPE > SAL_CALL getConnectionPointTypes() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_REFERENCE< UNO3_XCONNECTIONPOINT > SAL_CALL queryConnectionPoint( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL advise( const UNO3_TYPE& aType , + const UNO3_REFERENCE< UNO3_XINTERFACE >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL unadvise( const UNO3_TYPE& aType , + const UNO3_REFERENCE< UNO3_XINTERFACE >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + //__________________________________________________________________________________________________________ + // impl but public methods to register service! + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + static const UNO3_SEQUENCE< UNO3_OUSTRING > impl_getStaticSupportedServiceNames(); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + static const UNO3_OUSTRING impl_getStaticImplementationName(); + +//______________________________________________________________________________________________________________ +// protected methods +//______________________________________________________________________________________________________________ + +protected: + using OPropertySetHelper::getFastPropertyValue; + //__________________________________________________________________________________________________________ + // OPropertySetHelper + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual sal_Bool SAL_CALL convertFastPropertyValue( UNO3_ANY& rConvertedValue , + UNO3_ANY& rOldValue , + sal_Int32 nHandle , + const UNO3_ANY& rValue ) throw( UNO3_ILLEGALARGUMENTEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , + const UNO3_ANY& rValue ) throw ( ::com::sun::star::uno::Exception ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL getFastPropertyValue( UNO3_ANY& rValue , + sal_Int32 nHandle ) const ; + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_IPROPERTYARRAYHELPER& SAL_CALL getInfoHelper(); + + //__________________________________________________________________________________________________________ + // XPropertySet + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + UNO3_REFERENCE< UNO3_XPROPERTYSETINFO > SAL_CALL getPropertySetInfo() throw( UNO3_RUNTIMEEXCEPTION ); + + //__________________________________________________________________________________________________________ + // BaseControl + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_WINDOWDESCRIPTOR* impl_getWindowDescriptor( const UNO3_REFERENCE< UNO3_XWINDOWPEER >& xParentPeer ); + +//______________________________________________________________________________________________________________ +// private methods +//______________________________________________________________________________________________________________ + +private: + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + void impl_createFrame( const UNO3_REFERENCE< UNO3_XWINDOWPEER >& xPeer , + const UNO3_OUSTRING& sURL , + const UNO3_SEQUENCE< UNO3_PROPERTYVALUE >& seqArguments ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + void impl_deleteFrame(); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + static const UNO3_SEQUENCE< UNO3_PROPERTY > impl_getStaticPropertyDescriptor(); + + +//______________________________________________________________________________________________________________ +// private variables +//______________________________________________________________________________________________________________ + +private: + + UNO3_REFERENCE< UNO3_XFRAME > m_xFrame ; + UNO3_OUSTRING m_sComponentURL ; + UNO3_SEQUENCE< UNO3_PROPERTYVALUE > m_seqLoaderArguments ; + UNO3_OMULTITYPEINTERFACECONTAINERHELPER m_aInterfaceContainer ; + UNO3_OCONNECTIONPOINTCONTAINERHELPER m_aConnectionPointContainer ; + +}; // class FrameControl + +} // namespace unocontrols + +#endif // #ifndef _UNOCONTROLS_FRAMECONTROL_CTRL_HXX diff --git a/UnoControls/source/inc/progressbar.hxx b/UnoControls/source/inc/progressbar.hxx new file mode 100644 index 000000000000..743d0568f879 --- /dev/null +++ b/UnoControls/source/inc/progressbar.hxx @@ -0,0 +1,445 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _UNOCONTROLS_PROGRESSBAR_CTRL_HXX +#define _UNOCONTROLS_PROGRESSBAR_CTRL_HXX + +//____________________________________________________________________________________________________________ +// includes of other projects +//____________________________________________________________________________________________________________ + +#include <com/sun/star/lang/XServiceName.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +//____________________________________________________________________________________________________________ +// includes of my own project +//____________________________________________________________________________________________________________ +#include "basecontrol.hxx" + +//____________________________________________________________________________________________________________ +// namespaces +//____________________________________________________________________________________________________________ + +namespace unocontrols{ + +#define UNO3_REFERENCE ::com::sun::star::uno::Reference +#define UNO3_XMULTISERVICEFACTORY ::com::sun::star::lang::XMultiServiceFactory +#define UNO3_RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException +#define UNO3_XCONTROLMODEL ::com::sun::star::awt::XControlModel +#define UNO3_XPROGRESSBAR ::com::sun::star::awt::XProgressBar +#define UNO3_ANY ::com::sun::star::uno::Any +#define UNO3_TYPE ::com::sun::star::uno::Type +#define UNO3_SEQUENCE ::com::sun::star::uno::Sequence +#define UNO3_XGRAPHICS ::com::sun::star::awt::XGraphics +#define UNO3_OUSTRING ::rtl::OUString +#define UNO3_SIZE ::com::sun::star::awt::Size + +//____________________________________________________________________________________________________________ +// defines +//____________________________________________________________________________________________________________ + +#define SERVICENAME_PROGRESSBAR "com.sun.star.awt.XProgressBar" +#define IMPLEMENTATIONNAME_PROGRESSBAR "stardiv.UnoControls.ProgressBar" +#define FREESPACE 4 +#define DEFAULT_HORIZONTAL sal_True +#define DEFAULT_BLOCKDIMENSION Size(1,1) +#define DEFAULT_BACKGROUNDCOLOR TRGB_COLORDATA( 0x00, 0xC0, 0xC0, 0xC0 ) // lightgray +#define DEFAULT_FOREGROUNDCOLOR TRGB_COLORDATA( 0x00, 0x00, 0x00, 0x80 ) // blue +#define DEFAULT_MINRANGE INT_MIN +#define DEFAULT_MAXRANGE INT_MAX +#define DEFAULT_BLOCKVALUE 1 +#define DEFAULT_VALUE DEFAULT_MINRANGE +#define LINECOLOR_BRIGHT TRGB_COLORDATA( 0x00, 0xFF, 0xFF, 0xFF ) // white +#define LINECOLOR_SHADOW TRGB_COLORDATA( 0x00, 0x00, 0x00, 0x00 ) // black + +//____________________________________________________________________________________________________________ +// classes +//____________________________________________________________________________________________________________ + +class ProgressBar : public UNO3_XCONTROLMODEL + , public UNO3_XPROGRESSBAR + , public BaseControl +{ + +//____________________________________________________________________________________________________________ +// public methods +//____________________________________________________________________________________________________________ + +public: + + //________________________________________________________________________________________________________ + // construct/destruct + //________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + ProgressBar( const UNO3_REFERENCE< UNO3_XMULTISERVICEFACTORY >& xFactory ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual ~ProgressBar(); + + //__________________________________________________________________________________________________________ + // XInterface + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_ANY SAL_CALL queryInterface( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short increment refcount + @descr - + + @seealso XInterface + @seealso release() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL acquire() throw(); + + /**_______________________________________________________________________________________________________ + @short decrement refcount + @descr - + + @seealso XInterface + @seealso acquire() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL release() throw(); + + //__________________________________________________________________________________________________________ + // XTypeProvider + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_SEQUENCE< UNO3_TYPE > SAL_CALL getTypes() throw( UNO3_RUNTIMEEXCEPTION ); + + //__________________________________________________________________________________________________________ + // XAggregation + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + UNO3_ANY SAL_CALL queryAggregation( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XProgressBar + //________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL setForegroundColor( sal_Int32 nColor ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL setBackgroundColor( sal_Int32 nColor ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL setValue( sal_Int32 nValue ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL setRange( sal_Int32 nMin , + sal_Int32 nMax ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual sal_Int32 SAL_CALL getValue() throw( UNO3_RUNTIMEEXCEPTION ); + + //__________________________________________________________________________________________________________ + // XWindow + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL setPosSize( sal_Int32 nX , + sal_Int32 nY , + sal_Int32 nWidth , + sal_Int32 nHeight , + sal_Int16 nFlags ) throw( UNO3_RUNTIMEEXCEPTION ); + + //__________________________________________________________________________________________________________ + // XControl + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual sal_Bool SAL_CALL setModel( const UNO3_REFERENCE< UNO3_XCONTROLMODEL >& xModel ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual UNO3_REFERENCE< UNO3_XCONTROLMODEL > SAL_CALL getModel() throw( UNO3_RUNTIMEEXCEPTION ); + + //__________________________________________________________________________________________________________ + // BaseControl + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + static const UNO3_SEQUENCE< UNO3_OUSTRING > impl_getStaticSupportedServiceNames(); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + static const UNO3_OUSTRING impl_getStaticImplementationName(); + +//____________________________________________________________________________________________________________ +// protected methods +//____________________________________________________________________________________________________________ + +protected: + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void impl_paint( sal_Int32 nX , + sal_Int32 nY , + const UNO3_REFERENCE< UNO3_XGRAPHICS >& xGraphics ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + void impl_recalcRange(); + +//____________________________________________________________________________________________________________ +// private variables +//____________________________________________________________________________________________________________ + +private: + + sal_Bool m_bHorizontal ; // orientation for steps [true=horizontal/false=vertikal] + UNO3_SIZE m_aBlockSize ; // width and height of a block [>=0,0] + sal_Int32 m_nForegroundColor ; // (alpha,r,g,b) + sal_Int32 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] + +}; // class ProgressBar + +} // namespace unocontrols + +#endif // #ifndef _UNOCONTROLS_PROGRESSBAR_CTRL_HXX diff --git a/UnoControls/source/inc/progressmonitor.hxx b/UnoControls/source/inc/progressmonitor.hxx new file mode 100644 index 000000000000..dfb6a1ae9fb9 --- /dev/null +++ b/UnoControls/source/inc/progressmonitor.hxx @@ -0,0 +1,805 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _UNOCONTROLS_PROGRESSMONITOR_CTRL_HXX +#define _UNOCONTROLS_PROGRESSMONITOR_CTRL_HXX + +//____________________________________________________________________________________________________________ +// includes of other projects +//____________________________________________________________________________________________________________ + +#include <com/sun/star/awt/XFileDialog.hpp> +#include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/awt/XListBox.hpp> +#include <com/sun/star/awt/XProgressMonitor.hpp> +#include <com/sun/star/awt/TextAlign.hpp> +#include <com/sun/star/awt/XScrollBar.hpp> +#include <com/sun/star/awt/XVclContainerPeer.hpp> +#include <com/sun/star/awt/XTabControllerModel.hpp> +#include <com/sun/star/awt/XMessageBox.hpp> +#include <com/sun/star/awt/XTextEditField.hpp> +#include <com/sun/star/awt/Style.hpp> +#include <com/sun/star/awt/XTimeField.hpp> +#include <com/sun/star/awt/XVclWindowPeer.hpp> +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/awt/XSpinField.hpp> +#include <com/sun/star/awt/XUnoControlContainer.hpp> +#include <com/sun/star/awt/XTextLayoutConstrains.hpp> +#include <com/sun/star/awt/XNumericField.hpp> +#include <com/sun/star/awt/XButton.hpp> +#include <com/sun/star/awt/XTextArea.hpp> +#include <com/sun/star/awt/XImageButton.hpp> +#include <com/sun/star/awt/XFixedText.hpp> +#include <com/sun/star/awt/XControlContainer.hpp> +#include <com/sun/star/awt/XDialog.hpp> +#include <com/sun/star/awt/ScrollBarOrientation.hpp> +#include <com/sun/star/awt/XRadioButton.hpp> +#include <com/sun/star/awt/XCurrencyField.hpp> +#include <com/sun/star/awt/XPatternField.hpp> +#include <com/sun/star/awt/VclWindowPeerAttribute.hpp> +#include <com/sun/star/awt/XTabController.hpp> +#include <com/sun/star/awt/XVclContainer.hpp> +#include <com/sun/star/awt/XDateField.hpp> +#include <com/sun/star/awt/XComboBox.hpp> +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XCheckBox.hpp> +#include <com/sun/star/awt/MessageBoxCommand.hpp> +#include <com/sun/star/awt/XLayoutConstrains.hpp> +#include <com/sun/star/awt/XProgressBar.hpp> + +//____________________________________________________________________________________________________________ +// includes of my own project +//____________________________________________________________________________________________________________ +#include "basecontainercontrol.hxx" + +//____________________________________________________________________________________________________________ +// namespace +//____________________________________________________________________________________________________________ + +namespace unocontrols{ + +#define UNO3_ANY ::com::sun::star::uno::Any +#define UNO3_OUSTRING ::rtl::OUString +#define UNO3_RECTANGLE ::com::sun::star::awt::Rectangle +#define UNO3_REFERENCE ::com::sun::star::uno::Reference +#define UNO3_RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException +#define UNO3_SEQUENCE ::com::sun::star::uno::Sequence +#define UNO3_SIZE ::com::sun::star::awt::Size +#define UNO3_TYPE ::com::sun::star::uno::Type +#define UNO3_XACTIONLISTENER ::com::sun::star::awt::XActionListener +#define UNO3_XBUTTON ::com::sun::star::awt::XButton +#define UNO3_XCONTROLMODEL ::com::sun::star::awt::XControlModel +#define UNO3_XFIXEDTEXT ::com::sun::star::awt::XFixedText +#define UNO3_XGRAPHICS ::com::sun::star::awt::XGraphics +#define UNO3_XLAYOUTCONSTRAINS ::com::sun::star::awt::XLayoutConstrains +#define UNO3_XMULTISERVICEFACTORY ::com::sun::star::lang::XMultiServiceFactory +#define UNO3_XPROGRESSBAR ::com::sun::star::awt::XProgressBar +#define UNO3_XPROGRESSMONITOR ::com::sun::star::awt::XProgressMonitor +#define UNO3_XTOOLKIT ::com::sun::star::awt::XToolkit +#define UNO3_XWINDOWPEER ::com::sun::star::awt::XWindowPeer + +//____________________________________________________________________________________________________________ +// defines +//____________________________________________________________________________________________________________ + +#define SERVICENAME_PROGRESSMONITOR "com.sun.star.awt.XProgressMonitor" +#define IMPLEMENTATIONNAME_PROGRESSMONITOR "stardiv.UnoControls.ProgressMonitor" +#define FREEBORDER 10 // border around and between the controls +#define WIDTH_RELATION 4 // reserve 1/4 for button width and rest for progressbar width +#define HEIGHT_RELATION 5 // reserve 1/5 for button and progressbar heigth and rest for text height +#define FIXEDTEXT_SERVICENAME "com.sun.star.awt.UnoControlFixedText" +#define BUTTON_SERVICENAME "com.sun.star.awt.UnoControlButton" +#define FIXEDTEXT_MODELNAME "com.sun.star.awt.UnoControlFixedTextModel" +#define BUTTON_MODELNAME "com.sun.star.awt.UnoControlButtonModel" +#define CONTROLNAME_TEXT "Text" // identifier the control in container +#define CONTROLNAME_BUTTON "Button" // -||- +#define CONTROLNAME_PROGRESSBAR "ProgressBar" // -||- +#define DEFAULT_BUTTONLABEL "Abbrechen" +#define DEFAULT_TOPIC "\0" +#define DEFAULT_TEXT "\0" +#define BACKGROUNDCOLOR TRGB_COLORDATA( 0x00, 0xC0, 0xC0, 0xC0 ) // lighgray +#define LINECOLOR_BRIGHT TRGB_COLORDATA( 0x00, 0xFF, 0xFF, 0xFF ) // white +#define LINECOLOR_SHADOW TRGB_COLORDATA( 0x00, 0x00, 0x00, 0x00 ) // black +#define HEIGHT_PROGRESSBAR 15 +// Overwrite defines from basecontrol.hxx!!! +#undef DEFAULT_WIDTH +#undef DEFAULT_HEIGHT +#define DEFAULT_WIDTH 350 +#define DEFAULT_HEIGHT 100 + +//____________________________________________________________________________________________________________ +// structs, types +//____________________________________________________________________________________________________________ + +/// Item of TextList +struct IMPL_TextlistItem +{ + UNO3_OUSTRING sTopic ; /// Left site of textline in dialog + UNO3_OUSTRING sText ; /// Right site of textline in dialog +}; + +/// Define a list-class for struct IMPL_TextlistItem +class IMPL_Textlist ; +DECLARE_LIST( IMPL_Textlist, IMPL_TextlistItem* ) + +//____________________________________________________________________________________________________________ +// class declaration +//____________________________________________________________________________________________________________ + +class ProgressMonitor : public UNO3_XLAYOUTCONSTRAINS + , public UNO3_XBUTTON + , public UNO3_XPROGRESSMONITOR + , public BaseContainerControl +{ + +//____________________________________________________________________________________________________________ +// public methods +//____________________________________________________________________________________________________________ + +public: + + //________________________________________________________________________________________________________ + // construct/destruct + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + ProgressMonitor( const UNO3_REFERENCE< UNO3_XMULTISERVICEFACTORY >& xFactory ); + + /**_______________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual ~ProgressMonitor(); + + //________________________________________________________________________________________________________ + // 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 UNO3_ANY SAL_CALL queryInterface( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short increment refcount + @descr - + + @seealso XInterface + @seealso release() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL acquire() throw(); + + /**_______________________________________________________________________________________________________ + @short decrement refcount + @descr - + + @seealso XInterface + @seealso acquire() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL release() throw(); + + //________________________________________________________________________________________________________ + // XTypeProvider + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short get information about supported interfaces + @descr - + + @seealso XTypeProvider + + @param - + + @return Sequence of types of all supported interfaces + + @onerror A RuntimeException is thrown. + */ + + virtual UNO3_SEQUENCE< UNO3_TYPE > SAL_CALL getTypes() throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XAggregation + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_ANY SAL_CALL queryAggregation( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // 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] + + @return - + + @onerror DEBUG = Assertion<BR> + RELEASE = nothing + */ + + virtual void SAL_CALL addText( const UNO3_OUSTRING& sTopic , + const UNO3_OUSTRING& sText , + sal_Bool bbeforeProgress ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeText( const UNO3_OUSTRING& sTopic , + sal_Bool bbeforeProgress ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL updateText( const UNO3_OUSTRING& sTopic , + const UNO3_OUSTRING& sText , + sal_Bool bbeforeProgress ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XProgressBar + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setForegroundColor( sal_Int32 nColor ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setBackgroundColor( sal_Int32 nColor ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setValue( sal_Int32 nValue ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setRange( sal_Int32 nMin , + sal_Int32 nMax ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Int32 SAL_CALL getValue() throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XButton + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addActionListener( const UNO3_REFERENCE< UNO3_XACTIONLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeActionListener( const UNO3_REFERENCE< UNO3_XACTIONLISTENER >& xListener ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setLabel( const UNO3_OUSTRING& sLabel ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setActionCommand( const UNO3_OUSTRING& sCommand ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XLayoutConstrains + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_SIZE SAL_CALL getMinimumSize() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_SIZE SAL_CALL getPreferredSize() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_SIZE SAL_CALL calcAdjustedSize( const UNO3_SIZE& aNewSize ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XControl + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL createPeer( const UNO3_REFERENCE< UNO3_XTOOLKIT >& xToolkit , + const UNO3_REFERENCE< UNO3_XWINDOWPEER >& xParent ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL setModel( const UNO3_REFERENCE< UNO3_XCONTROLMODEL >& xModel ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_REFERENCE< UNO3_XCONTROLMODEL > SAL_CALL getModel() throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XComponent + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL dispose() throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // XWindow + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setPosSize( sal_Int32 nX , + sal_Int32 nY , + sal_Int32 nWidth , + sal_Int32 nHeight , + sal_Int16 nFlags ) throw( UNO3_RUNTIMEEXCEPTION ); + + //________________________________________________________________________________________________________ + // BaseControl + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + static const UNO3_SEQUENCE< UNO3_OUSTRING > impl_getStaticSupportedServiceNames(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + static const UNO3_OUSTRING impl_getStaticImplementationName(); + +//____________________________________________________________________________________________________________ +// protected methods +//____________________________________________________________________________________________________________ + +protected: + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void impl_paint( sal_Int32 nX , + sal_Int32 nY , + const UNO3_REFERENCE< UNO3_XGRAPHICS >& xGraphics ); + +//____________________________________________________________________________________________________________ +// private methods +//____________________________________________________________________________________________________________ + +private: + using BaseControl::impl_recalcLayout; + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + void impl_recalcLayout(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + void impl_rebuildFixedText(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + void impl_cleanMemory(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + IMPL_TextlistItem* impl_searchTopic( const UNO3_OUSTRING& sTopic , + sal_Bool bbeforeProgress ); + +//____________________________________________________________________________________________________________ +// debug methods +//____________________________________________________________________________________________________________ + +private: + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + #ifdef DBG_UTIL + + sal_Bool impl_debug_checkParameter( const UNO3_OUSTRING& sTopic, const UNO3_OUSTRING& sText, sal_Bool bbeforeProgress ); // addText, updateText + sal_Bool impl_debug_checkParameter( const UNO3_OUSTRING& rTopic, sal_Bool bbeforeProgress ); // removeText + + #endif +//____________________________________________________________________________________________________________ +// private variables +//____________________________________________________________________________________________________________ + +private: + + IMPL_Textlist* m_pTextlist_Top ; // Elements before progress + UNO3_REFERENCE< UNO3_XFIXEDTEXT > m_xTopic_Top ; // (used, if parameter "beforeProgress"=sal_True in "addText, updateText, removeText") + UNO3_REFERENCE< UNO3_XFIXEDTEXT > m_xText_Top ; + + IMPL_Textlist* m_pTextlist_Bottom ; // Elements below of progress + UNO3_REFERENCE< UNO3_XFIXEDTEXT > m_xTopic_Bottom ; // (used, if parameter "beforeProgress"=sal_False in "addText, updateText, removeText") + UNO3_REFERENCE< UNO3_XFIXEDTEXT > m_xText_Bottom ; + + UNO3_REFERENCE< UNO3_XPROGRESSBAR > m_xProgressBar ; + UNO3_REFERENCE< UNO3_XBUTTON > m_xButton ; + UNO3_RECTANGLE m_a3DLine ; + +}; // class ProgressMonitor + +} // namespace unocontrols + +#endif // #ifndef _UNOCONTROLS_PROGRESSMONITOR_CTRL_HXX diff --git a/UnoControls/source/inc/statusindicator.hxx b/UnoControls/source/inc/statusindicator.hxx new file mode 100644 index 000000000000..3ea07a4e0d0b --- /dev/null +++ b/UnoControls/source/inc/statusindicator.hxx @@ -0,0 +1,580 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _UNOCONTROLS_STATUSINDICATOR_CTRL_HXX +#define _UNOCONTROLS_STATUSINDICATOR_CTRL_HXX + +//____________________________________________________________________________________________________________ +// includes of other projects +//____________________________________________________________________________________________________________ + +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/awt/XFixedText.hpp> +#include <com/sun/star/awt/XGraphics.hpp> +#include <com/sun/star/awt/XLayoutConstrains.hpp> +#include <com/sun/star/awt/XProgressBar.hpp> +#include <com/sun/star/task/XStatusIndicator.hpp> +#include <com/sun/star/awt/XToolkit.hpp> +#include <com/sun/star/awt/XWindowPeer.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +//____________________________________________________________________________________________________________ +// includes of my own project +//____________________________________________________________________________________________________________ +#include "basecontainercontrol.hxx" + +//____________________________________________________________________________________________________________ +// namespace +//____________________________________________________________________________________________________________ + +namespace unocontrols{ + +#define UNO3_ANY ::com::sun::star::uno::Any +#define UNO3_OUSTRING ::rtl::OUString +#define UNO3_RECTANGLE ::com::sun::star::awt::Rectangle +#define UNO3_REFERENCE ::com::sun::star::uno::Reference +#define UNO3_RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException +#define UNO3_SEQUENCE ::com::sun::star::uno::Sequence +#define UNO3_SIZE ::com::sun::star::awt::Size +#define UNO3_TYPE ::com::sun::star::uno::Type +#define UNO3_XCONTROLMODEL ::com::sun::star::awt::XControlModel +#define UNO3_XFIXEDTEXT ::com::sun::star::awt::XFixedText +#define UNO3_XGRAPHICS ::com::sun::star::awt::XGraphics +#define UNO3_XLAYOUTCONSTRAINS ::com::sun::star::awt::XLayoutConstrains +#define UNO3_XMULTISERVICEFACTORY ::com::sun::star::lang::XMultiServiceFactory +#define UNO3_XPROGRESSBAR ::com::sun::star::awt::XProgressBar +#define UNO3_XSTATUSINDICATOR ::com::sun::star::task::XStatusIndicator +#define UNO3_XTOOLKIT ::com::sun::star::awt::XToolkit +#define UNO3_XWINDOWPEER ::com::sun::star::awt::XWindowPeer + +//____________________________________________________________________________________________________________ +// defines +//____________________________________________________________________________________________________________ + +#define SERVICENAME_STATUSINDICATOR "com.sun.star.task.XStatusIndicator" +#define IMPLEMENTATIONNAME_STATUSINDICATOR "stardiv.UnoControls.StatusIndicator" +#undef FREEBORDER +#define FREEBORDER 5 // border around and between the controls +#define FIXEDTEXT_SERVICENAME "com.sun.star.awt.UnoControlFixedText" +#define FIXEDTEXT_MODELNAME "com.sun.star.awt.UnoControlFixedTextModel" +#define CONTROLNAME_TEXT "Text" // identifier the control in container +#define CONTROLNAME_PROGRESSBAR "ProgressBar" // -||- +#define DEFAULT_TEXT "\0" +#define BACKGROUNDCOLOR TRGB_COLORDATA( 0x00, 0xC0, 0xC0, 0xC0 ) // lighgray +#define LINECOLOR_BRIGHT TRGB_COLORDATA( 0x00, 0xFF, 0xFF, 0xFF ) // white +#define LINECOLOR_SHADOW TRGB_COLORDATA( 0x00, 0x00, 0x00, 0x00 ) // black +// Overwrite defines from basecontrol.hxx!!! +#undef DEFAULT_WIDTH +#undef DEFAULT_HEIGHT +#define DEFAULT_WIDTH 300 +#define DEFAULT_HEIGHT 25 + +//____________________________________________________________________________________________________________ +// structs, types +//____________________________________________________________________________________________________________ + +//____________________________________________________________________________________________________________ +// class declaration +//____________________________________________________________________________________________________________ + +class StatusIndicator : public UNO3_XLAYOUTCONSTRAINS + , public UNO3_XSTATUSINDICATOR + , public BaseContainerControl +{ + + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + + public: + + //--------------------------------------------------------------------------------------------------------- + // construct/destruct + //--------------------------------------------------------------------------------------------------------- + + /**_______________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + StatusIndicator( const UNO3_REFERENCE< UNO3_XMULTISERVICEFACTORY >& xFactory ); + + /**_______________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual ~StatusIndicator(); + + //--------------------------------------------------------------------------------------------------------- + // 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 UNO3_ANY SAL_CALL queryInterface( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short increment refcount + @descr - + + @seealso XInterface + @seealso release() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL acquire() throw(); + + /**_______________________________________________________________________________________________________ + @short decrement refcount + @descr - + + @seealso XInterface + @seealso acquire() + + @param - + + @return - + + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL release() throw(); + + //--------------------------------------------------------------------------------------------------------- + // XTypeProvider + //--------------------------------------------------------------------------------------------------------- + + /**_______________________________________________________________________________________________________ + @short get information about supported interfaces + @descr - + + @seealso XTypeProvider + + @param - + + @return Sequence of types of all supported interfaces + + @onerror A RuntimeException is thrown. + */ + + virtual UNO3_SEQUENCE< UNO3_TYPE > SAL_CALL getTypes() throw( UNO3_RUNTIMEEXCEPTION ); + + //--------------------------------------------------------------------------------------------------------- + // XAggregation + //--------------------------------------------------------------------------------------------------------- + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_ANY SAL_CALL queryAggregation( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION ); + + //--------------------------------------------------------------------------------------------------------- + // XStatusIndicator + //--------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL start( const UNO3_OUSTRING& sText , + sal_Int32 nRange ) throw( UNO3_RUNTIMEEXCEPTION ); + + /*-****************************************************************************************************//** + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL end() throw( UNO3_RUNTIMEEXCEPTION ); + + /*-****************************************************************************************************//** + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL reset() throw( UNO3_RUNTIMEEXCEPTION ); + + /*-****************************************************************************************************//** + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL setText( const UNO3_OUSTRING& sText ) throw( UNO3_RUNTIMEEXCEPTION ); + + /*-****************************************************************************************************//** + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL setValue( sal_Int32 nValue ) throw( UNO3_RUNTIMEEXCEPTION ); + + //--------------------------------------------------------------------------------------------------------- + // XLayoutConstrains + //--------------------------------------------------------------------------------------------------------- + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_SIZE SAL_CALL getMinimumSize() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_SIZE SAL_CALL getPreferredSize() throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_SIZE SAL_CALL calcAdjustedSize( const UNO3_SIZE& aNewSize ) throw( UNO3_RUNTIMEEXCEPTION ); + + //--------------------------------------------------------------------------------------------------------- + // XControl + //--------------------------------------------------------------------------------------------------------- + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL createPeer( const UNO3_REFERENCE< UNO3_XTOOLKIT >& xToolkit , + const UNO3_REFERENCE< UNO3_XWINDOWPEER >& xParent ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL setModel( const UNO3_REFERENCE< UNO3_XCONTROLMODEL >& xModel ) throw( UNO3_RUNTIMEEXCEPTION ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_REFERENCE< UNO3_XCONTROLMODEL > SAL_CALL getModel() throw( UNO3_RUNTIMEEXCEPTION ); + + //--------------------------------------------------------------------------------------------------------- + // XComponent + //--------------------------------------------------------------------------------------------------------- + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL dispose() throw( UNO3_RUNTIMEEXCEPTION ); + + //--------------------------------------------------------------------------------------------------------- + // XWindow + //--------------------------------------------------------------------------------------------------------- + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setPosSize( sal_Int32 nX , + sal_Int32 nY , + sal_Int32 nWidth , + sal_Int32 nHeight , + sal_Int16 nFlags ) throw( UNO3_RUNTIMEEXCEPTION ); + + //--------------------------------------------------------------------------------------------------------- + // BaseControl + //--------------------------------------------------------------------------------------------------------- + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + static const UNO3_SEQUENCE< UNO3_OUSTRING > impl_getStaticSupportedServiceNames(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + static const UNO3_OUSTRING impl_getStaticImplementationName(); + +//____________________________________________________________________________________________________________ +// protected methods +//____________________________________________________________________________________________________________ + +protected: + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual UNO3_WINDOWDESCRIPTOR* impl_getWindowDescriptor( const UNO3_REFERENCE< UNO3_XWINDOWPEER >& xParentPeer ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void impl_paint ( sal_Int32 nX, sal_Int32 nY, const UNO3_REFERENCE< UNO3_XGRAPHICS > & rGraphics ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void impl_recalcLayout( const UNO3_WINDOWEVENT& aEvent ); + +//____________________________________________________________________________________________________________ +// debug methods +//____________________________________________________________________________________________________________ + +private: + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + #if OSL_DEBUG_LEVEL > 1 + + #endif + +//____________________________________________________________________________________________________________ +// private variables +//____________________________________________________________________________________________________________ + +private: + + UNO3_REFERENCE< UNO3_XFIXEDTEXT > m_xText ; + UNO3_REFERENCE< UNO3_XPROGRESSBAR > m_xProgressBar ; + +}; // class StatusIndicator + +} // namespace unocontrols + +#endif // #ifndef _UNOCONTROLS_STATUSINDICATOR_CTRL_HXX diff --git a/UnoControls/util/ctl.component b/UnoControls/util/ctl.component new file mode 100644 index 000000000000..32901f529c8b --- /dev/null +++ b/UnoControls/util/ctl.component @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="stardiv.UnoControls.FrameControl"> + <service name="com.sun.star.frame.FrameControl"/> + </implementation> + <implementation name="stardiv.UnoControls.ProgressBar"> + <service name="com.sun.star.awt.XProgressBar"/> + </implementation> + <implementation name="stardiv.UnoControls.ProgressMonitor"> + <service name="com.sun.star.awt.XProgressMonitor"/> + </implementation> + <implementation name="stardiv.UnoControls.StatusIndicator"> + <service name="com.sun.star.task.XStatusIndicator"/> + </implementation> +</component> diff --git a/UnoControls/util/makefile.mk b/UnoControls/util/makefile.mk new file mode 100644 index 000000000000..73617d24452c --- /dev/null +++ b/UnoControls/util/makefile.mk @@ -0,0 +1,69 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=.. + +PRJNAME=UnoControls +TARGET=ctl +LIBTARGET=NO + +# --- Settings ----------------------------------------------------- + +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +LIB1TARGET= $(SLB)$/$(TARGET).lib +LIB1FILES= $(SLB)$/base.lib \ + $(SLB)$/controls.lib + +SHL1TARGET= $(TARGET)$(DLLPOSTFIX) +SHL1IMPLIB= i$(TARGET) + +SHL1VERSIONMAP=$(SOLARENV)/src/component.map +SHL1DEF=$(MISC)$/$(SHL1TARGET).def +DEF1NAME=$(SHL1TARGET) + +SHL1STDLIBS= \ + $(TOOLSLIB) \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + $(SALLIB) + +SHL1DEPN= makefile.mk +SHL1LIBS= $(LIB1TARGET) + +# --- Targets ------------------------------------------------------ +.INCLUDE : target.mk + +ALLTAR : $(MISC)/ctl.component + +$(MISC)/ctl.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + ctl.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt ctl.component diff --git a/UnoControls/util/makefile.pmk b/UnoControls/util/makefile.pmk new file mode 100644 index 000000000000..02a34a2434a1 --- /dev/null +++ b/UnoControls/util/makefile.pmk @@ -0,0 +1,27 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +.INCLUDE : settings.mk diff --git a/UnoControls/util/target.pmk b/UnoControls/util/target.pmk new file mode 100644 index 000000000000..c7c1de9c2563 --- /dev/null +++ b/UnoControls/util/target.pmk @@ -0,0 +1,35 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +ALLSLO: $(SLOFILES) + +SOSHL: $(SHL1TARGETN) + +WHOLEPRJ: + cd $(PRJ)$/prj + make debug linkinc prjpch compinc + @echo "READY" + |