diff options
Diffstat (limited to 'UnoControls')
26 files changed, 11709 insertions, 0 deletions
diff --git a/UnoControls/inc/basecontainercontrol.hxx b/UnoControls/inc/basecontainercontrol.hxx new file mode 100644 index 000000000000..cc052ca67f5f --- /dev/null +++ b/UnoControls/inc/basecontainercontrol.hxx @@ -0,0 +1,598 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 CSS_UNO ::com::sun::star::uno +#define CSS_AWT ::com::sun::star::awt +#define CSS_LANG ::com::sun::star::lang +#define CSS_CONTAINER ::com::sun::star::container + +//____________________________________________________________________________________________________________ +// structs, types, forwards +//____________________________________________________________________________________________________________ + +struct IMPL_ControlInfo +{ + CSS_UNO::Reference< CSS_AWT::XControl > xControl ; + ::rtl::OUString sName ; +}; + +// makro define a list-class for struct IMPL_ControlInfo! +class IMPL_ControlInfoList ; +DECLARE_LIST( IMPL_ControlInfoList, IMPL_ControlInfo* ) + +//____________________________________________________________________________________________________________ +// classes +//____________________________________________________________________________________________________________ + +class BaseContainerControl : public CSS_AWT::XControlModel + , public CSS_AWT::XControlContainer + , public BaseControl +{ + +//____________________________________________________________________________________________________________ +// public methods +//____________________________________________________________________________________________________________ + +public: + + //________________________________________________________________________________________________________ + // construct/destruct + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + BaseContainerControl( const CSS_UNO::Reference< CSS_LANG::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 CSS_UNO::Any SAL_CALL queryInterface( + const CSS_UNO::Type& aType + ) throw( CSS_UNO::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 CSS_UNO::Sequence< CSS_UNO::Type > SAL_CALL getTypes() + throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XAggregation + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Any SAL_CALL queryAggregation( + const CSS_UNO::Type& aType + ) throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XControl + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL createPeer( + const CSS_UNO::Reference< CSS_AWT::XToolkit >& xToolkit , + const CSS_UNO::Reference< CSS_AWT::XWindowPeer >& xParent + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL setModel( + const CSS_UNO::Reference< CSS_AWT::XControlModel >& xModel + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Reference< CSS_AWT::XControlModel > SAL_CALL getModel() + throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XComponent + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL dispose() throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XEventListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL disposing( const CSS_LANG::EventObject& rEvent ) throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XControlContainer + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addControl( + const ::rtl::OUString& sName , + const CSS_UNO::Reference< CSS_AWT::XControl >& xControl + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addContainerListener( + const CSS_UNO::Reference< CSS_CONTAINER::XContainerListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeControl( + const CSS_UNO::Reference< CSS_AWT::XControl >& xControl + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeContainerListener( + const CSS_UNO::Reference< CSS_CONTAINER::XContainerListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setStatusText( + const ::rtl::OUString& sStatusText + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Reference< CSS_AWT::XControl > SAL_CALL getControl( + const ::rtl::OUString& sName + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Sequence< CSS_UNO::Reference< CSS_AWT::XControl > > SAL_CALL getControls() + throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XUnoControlContainer + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addTabController( + const CSS_UNO::Reference< CSS_AWT::XTabController >& xTabController + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeTabController( + const CSS_UNO::Reference< CSS_AWT::XTabController >& xTabController + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setTabControllers( + const CSS_UNO::Sequence< CSS_UNO::Reference< CSS_AWT::XTabController > >& xTabControllers + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Sequence< CSS_UNO::Reference< CSS_AWT::XTabController > > SAL_CALL getTabControllers() + throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XWindow + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw( CSS_UNO::RuntimeException ); + +//____________________________________________________________________________________________________________ +// protected methods +//____________________________________________________________________________________________________________ + +protected: + using OComponentHelper::disposing; + /**_______________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual CSS_AWT::WindowDescriptor* impl_getWindowDescriptor( + const CSS_UNO::Reference< CSS_AWT::XWindowPeer >& xParentPeer + ); + + /**_______________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void impl_paint( + sal_Int32 nX , + sal_Int32 nY , + const CSS_UNO::Reference< CSS_AWT::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: + // list of pointer of "struct IMPL_ControlInfo" to hold child-controls + IMPL_ControlInfoList* m_pControlInfoList ; + + // list of references of XTabController to hold tab-order in this container + CSS_UNO::Sequence< CSS_UNO::Reference< CSS_AWT::XTabController > > m_xTabControllerList ; + + ::cppu::OMultiTypeInterfaceContainerHelper m_aListeners ; + +}; // class BaseContainerControl + +// The namespace aliases are only used in this header +#undef CSS_UNO +#undef CSS_AWT +#undef CSS_LANG +#undef CSS_CONTAINER + +} // namespace unocontrols + +#endif // ifndef _UNOCONTROLS_BASECONTAINERCONTROL_CTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/inc/basecontrol.hxx b/UnoControls/inc/basecontrol.hxx new file mode 100644 index 000000000000..e8eb59bce4ac --- /dev/null +++ b/UnoControls/inc/basecontrol.hxx @@ -0,0 +1,1272 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 CSS_UNO ::com::sun::star::uno +#define CSS_AWT ::com::sun::star::awt +#define CSS_LANG ::com::sun::star::lang + +//____________________________________________________________________________________________________________ +// 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. + ::osl::Mutex m_aMutex ; +}; + +//____________________________________________________________________________________________________________ +// classes +//____________________________________________________________________________________________________________ + +class BaseControl : public CSS_LANG::XServiceInfo + , public CSS_AWT::XPaintListener + , public CSS_AWT::XWindowListener + , public CSS_AWT::XView + , public CSS_AWT::XWindow + , public CSS_AWT::XControl + , public IMPL_MutexContainer + , public ::cppu::OComponentHelper +{ +//____________________________________________________________________________________________________________ +// public methods +//____________________________________________________________________________________________________________ + +public: + + //________________________________________________________________________________________________________ + // construct/destruct + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + BaseControl( const CSS_UNO::Reference< CSS_LANG::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 CSS_UNO::Any SAL_CALL queryInterface( + const CSS_UNO::Type& aType + ) throw( CSS_UNO::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 CSS_UNO::Sequence< CSS_UNO::Type > SAL_CALL getTypes() + throw( CSS_UNO::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 CSS_UNO::Sequence< sal_Int8 > SAL_CALL getImplementationId() + throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XAggregation + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setDelegator( + const CSS_UNO::Reference< CSS_UNO::XInterface >& xDelegator + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Any SAL_CALL queryAggregation( + const CSS_UNO::Type& aType + ) throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XServiceInfo + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& sServiceName + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() + throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XComponent + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL dispose() throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addEventListener( + const CSS_UNO::Reference< CSS_LANG::XEventListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeEventListener( + const CSS_UNO::Reference< CSS_LANG::XEventListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XControl + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL createPeer( + const CSS_UNO::Reference< CSS_AWT::XToolkit >& xToolkit, + const CSS_UNO::Reference< CSS_AWT::XWindowPeer >& xParent + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setContext( + const CSS_UNO::Reference< CSS_UNO::XInterface >& xContext + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL setModel( + const CSS_UNO::Reference< CSS_AWT::XControlModel >& xModel + ) throw( CSS_UNO::RuntimeException ) = 0 ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setDesignMode( sal_Bool bOn ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Reference< CSS_UNO::XInterface > SAL_CALL getContext() + throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Reference< CSS_AWT::XControlModel > SAL_CALL getModel() + throw( CSS_UNO::RuntimeException ) = 0; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Reference< CSS_AWT::XWindowPeer > SAL_CALL getPeer() + throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Reference< CSS_AWT::XView > SAL_CALL getView() + throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL isDesignMode() throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL isTransparent() throw( CSS_UNO::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( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setEnable( sal_Bool bEnable ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setFocus() throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_AWT::Rectangle SAL_CALL getPosSize() throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addWindowListener( + const CSS_UNO::Reference< CSS_AWT::XWindowListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addFocusListener( + const CSS_UNO::Reference< CSS_AWT::XFocusListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addKeyListener( + const CSS_UNO::Reference< CSS_AWT::XKeyListener >& xListener ) + throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addMouseListener( + const CSS_UNO::Reference< CSS_AWT::XMouseListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addMouseMotionListener( + const CSS_UNO::Reference< CSS_AWT::XMouseMotionListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addPaintListener( + const CSS_UNO::Reference< CSS_AWT::XPaintListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeWindowListener( + const CSS_UNO::Reference< CSS_AWT::XWindowListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeFocusListener( + const CSS_UNO::Reference< CSS_AWT::XFocusListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeKeyListener( + const CSS_UNO::Reference< CSS_AWT::XKeyListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeMouseListener( + const CSS_UNO::Reference< CSS_AWT::XMouseListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeMouseMotionListener( + const CSS_UNO::Reference< CSS_AWT::XMouseMotionListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removePaintListener( + const CSS_UNO::Reference< CSS_AWT::XPaintListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XView + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL draw( sal_Int32 nX , + sal_Int32 nY ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL setGraphics( + const CSS_UNO::Reference< CSS_AWT::XGraphics >& xDevice + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setZoom( float fZoomX , + float fZoomY ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Reference< CSS_AWT::XGraphics > SAL_CALL getGraphics() + throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_AWT::Size SAL_CALL getSize() throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // CSS_LANG::XEventListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL disposing( + const CSS_LANG::EventObject& rSource + ) throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XPaintListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowPaint( + const CSS_AWT::PaintEvent& rEvent + ) throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XWindowListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowResized( const CSS_AWT::WindowEvent& aEvent ) throw( CSS_UNO::RuntimeException ); + virtual void SAL_CALL windowMoved( const CSS_AWT::WindowEvent& aEvent ) throw( CSS_UNO::RuntimeException ); + virtual void SAL_CALL windowShown( const CSS_LANG::EventObject& aEvent ) throw( CSS_UNO::RuntimeException ); + virtual void SAL_CALL windowHidden( const CSS_LANG::EventObject& aEvent ) throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // impl but public method to register service + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + static const CSS_UNO::Sequence< ::rtl::OUString > impl_getStaticSupportedServiceNames(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + static const ::rtl::OUString impl_getStaticImplementationName(); + +//____________________________________________________________________________________________________________ +// protected methods +//____________________________________________________________________________________________________________ + +protected: + using OComponentHelper::disposing; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + const CSS_UNO::Reference< CSS_LANG::XMultiServiceFactory > impl_getMultiServiceFactory(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + const CSS_UNO::Reference< CSS_AWT::XWindow > impl_getPeerWindow(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + const CSS_UNO::Reference< CSS_AWT::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 CSS_AWT::WindowDescriptor* impl_getWindowDescriptor( + const CSS_UNO::Reference< CSS_AWT::XWindowPeer >& xParentPeer + ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void impl_paint( sal_Int32 nX , + sal_Int32 nY , + const CSS_UNO::Reference< CSS_AWT::XGraphics >& xGraphics ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void impl_recalcLayout( const CSS_AWT::WindowEvent& aEvent ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + CSS_UNO::Reference< CSS_UNO::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: + + CSS_UNO::Reference< CSS_LANG::XMultiServiceFactory > m_xFactory ; + CSS_UNO::Reference< CSS_UNO::XInterface > m_xDelegator ; + OMRCListenerMultiplexerHelper* m_pMultiplexer ; // multiplex events + CSS_UNO::Reference< CSS_UNO::XInterface > m_xMultiplexer ; + CSS_UNO::Reference< CSS_UNO::XInterface > m_xContext ; + CSS_UNO::Reference< CSS_AWT::XWindowPeer > m_xPeer ; + CSS_UNO::Reference< CSS_AWT::XWindow > m_xPeerWindow ; + CSS_UNO::Reference< CSS_AWT::XGraphics > m_xGraphicsView ; // graphics for CSS_AWT::XView-operations + CSS_UNO::Reference< CSS_AWT::XGraphics > m_xGraphicsPeer ; // graphics for painting on a peer + sal_Int32 m_nX ; // Position ... + sal_Int32 m_nY ; + sal_Int32 m_nWidth ; // ... and size of window + sal_Int32 m_nHeight ; + sal_Bool m_bVisible ; // Some state flags + sal_Bool m_bInDesignMode ; + sal_Bool m_bEnable ; + +}; // class BaseControl + +// The namespace aliaes are only used in this header +#undef CSS_UNO +#undef CSS_AWT +#undef CSS_LANG + +} // namespace unocontrols + +#endif // ifndef _UNOCONTROLS_BASECONTROL_CTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/inc/multiplexer.hxx b/UnoControls/inc/multiplexer.hxx new file mode 100644 index 000000000000..b9a90c5a33f1 --- /dev/null +++ b/UnoControls/inc/multiplexer.hxx @@ -0,0 +1,784 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 CSS_UNO ::com::sun::star::uno +#define CSS_AWT ::com::sun::star::awt +#define CSS_LANG ::com::sun::star::lang + +//____________________________________________________________________________________________________________ +// class +//____________________________________________________________________________________________________________ + +class OMRCListenerMultiplexerHelper : public CSS_AWT::XFocusListener + , public CSS_AWT::XWindowListener + , public CSS_AWT::XKeyListener + , public CSS_AWT::XMouseListener + , public CSS_AWT::XMouseMotionListener + , public CSS_AWT::XPaintListener + , public CSS_AWT::XTopWindowListener + , public ::cppu::OWeakObject +{ + +//____________________________________________________________________________________________________________ +// public 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 CSS_UNO::Reference< CSS_AWT::XWindow >& xControl , + const CSS_UNO::Reference< CSS_AWT::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 CSS_UNO::Any SAL_CALL queryInterface( const CSS_UNO::Type& aType ) + throw( CSS_UNO::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 CSS_UNO::Reference< CSS_UNO::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 CSS_UNO::Reference< CSS_AWT::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 CSS_UNO::Type& aType , + const CSS_UNO::Reference< CSS_UNO::XInterface >& xListener ); + + /**_______________________________________________________________________________________________________ + @short Remove the specified listener from the source. + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + void unadvise( const CSS_UNO::Type& aType , + const CSS_UNO::Reference< CSS_UNO::XInterface >& xListener ); + + //________________________________________________________________________________________________________ + // XEventListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL disposing(const CSS_LANG::EventObject& aSource) + throw( CSS_UNO::RuntimeException ) ; + + //________________________________________________________________________________________________________ + // XFocusListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL focusGained(const CSS_AWT::FocusEvent& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL focusLost(const CSS_AWT::FocusEvent& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + //________________________________________________________________________________________________________ + // XWindowListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowResized(const CSS_AWT::WindowEvent& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowMoved(const CSS_AWT::WindowEvent& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowShown(const CSS_LANG::EventObject& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowHidden(const CSS_LANG::EventObject& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + //________________________________________________________________________________________________________ + // XKeyListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL keyPressed( const CSS_AWT::KeyEvent& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL keyReleased( const CSS_AWT::KeyEvent& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + //________________________________________________________________________________________________________ + // XMouseListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL mousePressed(const CSS_AWT::MouseEvent& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL mouseReleased(const CSS_AWT::MouseEvent& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL mouseEntered(const CSS_AWT::MouseEvent& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL mouseExited(const CSS_AWT::MouseEvent& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + //________________________________________________________________________________________________________ + // XMouseMotionListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL mouseDragged(const CSS_AWT::MouseEvent& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL mouseMoved(const CSS_AWT::MouseEvent& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + //________________________________________________________________________________________________________ + // XPaintListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowPaint(const CSS_AWT::PaintEvent& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + //________________________________________________________________________________________________________ + // XTopWindowListener + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowOpened( const CSS_LANG::EventObject& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowClosing( const CSS_LANG::EventObject& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowClosed( const CSS_LANG::EventObject& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowMinimized( const CSS_LANG::EventObject& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowNormalized( const CSS_LANG::EventObject& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowActivated( const CSS_LANG::EventObject& aEvent ) + throw( CSS_UNO::RuntimeException ) ; + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL windowDeactivated( const CSS_LANG::EventObject& aEvent ) + throw( CSS_UNO::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 CSS_UNO::Reference< CSS_AWT::XWindow >& xPeer , + const CSS_UNO::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 CSS_UNO::Reference< CSS_AWT::XWindow >& xPeer , + const CSS_UNO::Type& aType ); + +//____________________________________________________________________________________________________________ +// private variables +//____________________________________________________________________________________________________________ + +private: + + ::osl::Mutex m_aMutex ; + CSS_UNO::Reference< CSS_AWT::XWindow > m_xPeer ; /// The source of the events. Normally this is the peer object. + CSS_UNO::WeakReference< CSS_AWT::XWindow > m_xControl ; + ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerHolder ; + +}; // class OMRCListenerMultiplexerHelper + +// The namespace aliases are only used in this header +#undef CSS_UNO +#undef CSS_AWT +#undef CSS_LANG + + +} // namespace unocontrols + +#endif // ifndef _UNOCONTROLS_MULTIPLEXER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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..5f65d3c80717 --- /dev/null +++ b/UnoControls/prj/d.lst @@ -0,0 +1,5 @@ +..\%__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 diff --git a/UnoControls/source/base/basecontainercontrol.cxx b/UnoControls/source/base/basecontainercontrol.cxx new file mode 100644 index 000000000000..8709f3c3f331 --- /dev/null +++ b/UnoControls/source/base/basecontainercontrol.cxx @@ -0,0 +1,645 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/base/basecontrol.cxx b/UnoControls/source/base/basecontrol.cxx new file mode 100644 index 000000000000..f26250bed987 --- /dev/null +++ b/UnoControls/source/base/basecontrol.cxx @@ -0,0 +1,1022 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/base/makefile.mk b/UnoControls/source/base/makefile.mk new file mode 100644 index 000000000000..be1fcbf5c8c2 --- /dev/null +++ b/UnoControls/source/base/makefile.mk @@ -0,0 +1,68 @@ +#************************************************************************* +# +# 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) \ +# $(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..4ac7156eb2ae --- /dev/null +++ b/UnoControls/source/base/multiplexer.cxx @@ -0,0 +1,539 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 "multiplexer.hxx" + +#include <osl/diagnose.h> + +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( RuntimeException ) +{ + MULTIPLEX( XFocusListener, focusGained, FocusEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XFcousListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::focusLost(const FocusEvent& aEvent ) throw( RuntimeException ) +{ + MULTIPLEX( XFocusListener, focusLost, FocusEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowResized(const WindowEvent& aEvent ) throw( RuntimeException ) +{ + MULTIPLEX( XWindowListener, windowResized, WindowEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowMoved(const WindowEvent& aEvent ) throw( RuntimeException ) +{ + MULTIPLEX( XWindowListener, windowMoved, WindowEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowShown(const EventObject& aEvent ) throw( RuntimeException ) +{ + MULTIPLEX( XWindowListener, windowShown, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowHidden(const EventObject& aEvent ) throw( RuntimeException ) +{ + MULTIPLEX( XWindowListener, windowHidden, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XKeyListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::keyPressed(const KeyEvent& aEvent) throw( RuntimeException ) +{ + MULTIPLEX( XKeyListener, keyPressed, KeyEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XKeyListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::keyReleased(const KeyEvent& aEvent) throw( RuntimeException ) +{ + MULTIPLEX( XKeyListener, keyReleased, KeyEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XMouseListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::mousePressed(const MouseEvent& aEvent) throw( RuntimeException ) +{ + MULTIPLEX( XMouseListener, mousePressed, MouseEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XMouseListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::mouseReleased(const MouseEvent& aEvent) throw( RuntimeException ) +{ + MULTIPLEX( XMouseListener, mouseReleased, MouseEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XMouseListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::mouseEntered(const MouseEvent& aEvent) throw( RuntimeException ) +{ + MULTIPLEX( XMouseListener, mouseEntered, MouseEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XMouseListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::mouseExited(const MouseEvent& aEvent) throw( RuntimeException ) +{ + MULTIPLEX( XMouseListener, mouseExited, MouseEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XMouseMotionListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::mouseDragged(const MouseEvent& aEvent) throw( RuntimeException ) +{ + MULTIPLEX( XMouseMotionListener, mouseDragged, MouseEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XMouseMotionListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::mouseMoved(const MouseEvent& aEvent) throw( RuntimeException ) +{ + MULTIPLEX( XMouseMotionListener, mouseMoved, MouseEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XPaintListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowPaint(const PaintEvent& aEvent) throw( RuntimeException ) +{ + MULTIPLEX( XPaintListener, windowPaint, PaintEvent, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XTopWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowOpened(const EventObject& aEvent) throw( RuntimeException ) +{ + MULTIPLEX( XTopWindowListener, windowOpened, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XTopWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowClosing( const EventObject& aEvent ) throw( RuntimeException ) +{ + MULTIPLEX( XTopWindowListener, windowClosing, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XTopWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowClosed( const EventObject& aEvent ) throw( RuntimeException ) +{ + MULTIPLEX( XTopWindowListener, windowClosed, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XTopWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowMinimized( const EventObject& aEvent ) throw( RuntimeException ) +{ + MULTIPLEX( XTopWindowListener, windowMinimized, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XTopWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowNormalized( const EventObject& aEvent ) throw( RuntimeException ) +{ + MULTIPLEX( XTopWindowListener, windowNormalized, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XTopWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowActivated( const EventObject& aEvent ) throw( RuntimeException ) +{ + MULTIPLEX( XTopWindowListener, windowActivated, EventObject, aEvent ) +} + +//____________________________________________________________________________________________________________ +// XTopWindowListener +//____________________________________________________________________________________________________________ + +void OMRCListenerMultiplexerHelper::windowDeactivated( const EventObject& aEvent ) throw( 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 + { + OSL_ENSURE( 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 + { + OSL_ENSURE( sal_False, "unknown listener" ); + } +} + +} // namespace unocontrols + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/base/registercontrols.cxx b/UnoControls/source/base/registercontrols.cxx new file mode 100644 index 000000000000..e8f58b8fa7f2 --- /dev/null +++ b/UnoControls/source/base/registercontrols.cxx @@ -0,0 +1,325 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 COMPONENT_INFO(CLASS) \ + \ + AS_DBG_OUT ( "\tCOMPONENT_INFO():\t[start]\n" ) \ + try \ + { \ + /* Set default result of follow operations !!! */ \ + bReturn = sal_False ; \ + \ + /* Do the follow only, if given key is valid ! */ \ + if ( xKey.is () ) \ + { \ + AS_DBG_OUT ( "\tCOMPONENT_INFO():\t\txkey is valid ...\n" ) \ + /* Build new keyname */ \ + sKeyName = OUString::createFromAscii( "/" ) ; \ + sKeyName += CLASS::impl_getStaticImplementationName() ; \ + sKeyName += OUString::createFromAscii( "/UNO/SERVICES" ); \ + \ + /* Create new key with new name. */ \ + xNewKey = xKey->createKey( sKeyName ); \ + \ + /* If this new key valid ... */ \ + if ( xNewKey.is () ) \ + { \ + AS_DBG_OUT ( "\tCOMPONENT_INFO():\t\txNewkey is valid ...\n" ) \ + /* Get information about supported services. */ \ + seqServiceNames = CLASS::impl_getStaticSupportedServiceNames() ; \ + pArray = seqServiceNames.getArray() ; \ + nLength = seqServiceNames.getLength() ; \ + nCounter = 0 ; \ + \ + AS_DBG_OUT ( "\tCOMPONENT_INFO():\t\tloop ..." ) \ + /* Then set this information on this key. */ \ + for ( nCounter = 0; nCounter < nLength; ++nCounter ) \ + { \ + xNewKey->createKey( pArray [nCounter] ); \ + } \ + AS_DBG_OUT ( " OK\n" ) \ + \ + /* Result of this operations = OK. */ \ + bReturn = sal_True ; \ + } \ + AS_DBG_OUT ( "\tCOMPONENT_INFO():\t\t... leave xNewKey\n" ) \ + } \ + AS_DBG_OUT ( "\tCOMPONENT_INFO():\t\t... leave xKey\n" ) \ + } \ + catch( InvalidRegistryException& ) \ + { \ + AS_DBG_OUT ( "\tCOMPONENT_INFO():\t\tInvalidRegistryException detected!!!\n" ) \ + bReturn = sal_False ; \ + } \ + AS_DBG_OUT ( "\tCOMPONENT_INFO():\t[end]\n" ) + +//****************************************************************************************************************************** +#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 ; +} + +//______________________________________________________________________________________________________________ +// write component info to registry +//______________________________________________________________________________________________________________ + +extern "C" sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/ , + void* pRegistryKey ) +{ + AS_DBG_OUT ( "component_writeInfo():\t[start]\n" ) + + // Set default return value for this operation - if it failed. + sal_Bool bReturn = sal_False ; + + if ( pRegistryKey != NULL ) + { + AS_DBG_OUT ( "component_writeInfo():\t\tpRegistryKey is valid ... enter scope\n" ) + + // Define variables for following macros! + // bReturn is set automaticly. + Reference< XRegistryKey > xKey( reinterpret_cast< XRegistryKey* >( pRegistryKey ) ) ; + Reference< XRegistryKey > xNewKey ; + Sequence< OUString > seqServiceNames ; + const OUString* pArray ; + sal_Int32 nLength ; + sal_Int32 nCounter ; + OUString sKeyName ; + + //============================================================================= + // Add new macro line to register new services. + // + // !!! ATTENTION !!! + // Write no ";" at end of line! (see macro) + //============================================================================= + COMPONENT_INFO ( FrameControl ) + COMPONENT_INFO ( ProgressBar ) + COMPONENT_INFO ( ProgressMonitor ) + COMPONENT_INFO ( StatusIndicator ) + //============================================================================= + + AS_DBG_OUT ( "component_writeInfo():\t\t... leave pRegistryKey scope\n" ) + } + + AS_DBG_OUT ( "component_writeInfo():\t[end]\n" ) + + // Return with result of this operation. + return bReturn ; +} + +//______________________________________________________________________________________________________________ +// 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 ; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/OConnectionPointContainerHelper.cxx b/UnoControls/source/controls/OConnectionPointContainerHelper.cxx new file mode 100644 index 000000000000..c5bd8cfce1e9 --- /dev/null +++ b/UnoControls/source/controls/OConnectionPointContainerHelper.cxx @@ -0,0 +1,190 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/OConnectionPointHelper.cxx b/UnoControls/source/controls/OConnectionPointHelper.cxx new file mode 100644 index 000000000000..a8b174b01a3a --- /dev/null +++ b/UnoControls/source/controls/OConnectionPointHelper.cxx @@ -0,0 +1,275 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 , + 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/framecontrol.cxx b/UnoControls/source/controls/framecontrol.cxx new file mode 100644 index 000000000000..9987478b7b56 --- /dev/null +++ b/UnoControls/source/controls/framecontrol.cxx @@ -0,0 +1,607 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 <osl/diagnose.h> + +//______________________________________________________________________________________________________________ +// 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 : OSL_ENSURE ( 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 : OSL_ENSURE ( 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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..7d05435e48b2 --- /dev/null +++ b/UnoControls/source/controls/progressbar.cxx @@ -0,0 +1,494 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 ( PROGRESSBAR_DEFAULT_HORIZONTAL ) + , m_aBlockSize ( PROGRESSBAR_DEFAULT_BLOCKDIMENSION ) + , m_nForegroundColor ( PROGRESSBAR_DEFAULT_FOREGROUNDCOLOR ) + , m_nBackgroundColor ( PROGRESSBAR_DEFAULT_BACKGROUNDCOLOR ) + , m_nMinRange ( PROGRESSBAR_DEFAULT_MINRANGE ) + , m_nMaxRange ( PROGRESSBAR_DEFAULT_MAXRANGE ) + , m_nBlockValue ( PROGRESSBAR_DEFAULT_BLOCKVALUE ) + , m_nValue ( PROGRESSBAR_DEFAULT_VALUE ) +{ +} + +ProgressBar::~ProgressBar() +{ +} + +//____________________________________________________________________________________________________________ +// XInterface +//____________________________________________________________________________________________________________ + +Any SAL_CALL ProgressBar::queryInterface( const Type& rType ) 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 += PROGRESSBAR_FREESPACE ; + // paint block + rGraphics->drawRect (nBlockStart, nY+PROGRESSBAR_FREESPACE, m_aBlockSize.Width, m_aBlockSize.Height) ; + // step next free field + nBlockStart += m_aBlockSize.Width ; + } + } + // draw 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 -= PROGRESSBAR_FREESPACE ; + // paint block + rGraphics->drawRect (nX+PROGRESSBAR_FREESPACE, nBlockStart, m_aBlockSize.Width, m_aBlockSize.Height) ; + // step next free field + nBlockStart -= m_aBlockSize.Height; + } + } + + // Paint shadow border around the progressbar + rGraphics->setLineColor ( PROGRESSBAR_LINECOLOR_SHADOW ) ; + rGraphics->drawLine ( nX, nY, impl_getWidth(), nY ) ; + rGraphics->drawLine ( nX, nY, nX , impl_getHeight() ) ; + + rGraphics->setLineColor ( PROGRESSBAR_LINECOLOR_BRIGHT ) ; + rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, impl_getWidth()-1, nY ) ; + rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, nX , impl_getHeight()-1 ) ; + } +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + +void ProgressBar::impl_recalcRange () +{ + MutexGuard aGuard (m_aMutex) ; + + sal_Int32 nWindowWidth = impl_getWidth() ; + sal_Int32 nWindowHeight = impl_getHeight() ; + double fBlockHeight ; + double fBlockWidth ; + double fMaxBlocks ; + + if( nWindowWidth > nWindowHeight ) + { + m_bHorizontal = sal_True ; + fBlockHeight = (nWindowHeight-(2*PROGRESSBAR_FREESPACE)) ; + fBlockWidth = fBlockHeight ; + fMaxBlocks = nWindowWidth/(fBlockWidth+PROGRESSBAR_FREESPACE); + } + else + { + m_bHorizontal = sal_False ; + fBlockWidth = (nWindowWidth-(2*PROGRESSBAR_FREESPACE)) ; + fBlockHeight = fBlockWidth ; + fMaxBlocks = nWindowHeight/(fBlockHeight+PROGRESSBAR_FREESPACE); + } + + double fRange = m_nMaxRange-m_nMinRange ; + double fBlockValue = fRange/fMaxBlocks ; + + m_nBlockValue = fBlockValue ; + m_aBlockSize.Height = (sal_Int32)fBlockHeight; + m_aBlockSize.Width = (sal_Int32)fBlockWidth ; +} + +} // namespace unocontrols + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/progressmonitor.cxx b/UnoControls/source/controls/progressmonitor.cxx new file mode 100644 index 000000000000..bf6dc153a933 --- /dev/null +++ b/UnoControls/source/controls/progressmonitor.cxx @@ -0,0 +1,1080 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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( PROGRESSMONITOR_DEFAULT_TOPIC ) ) ; + m_xText_Top->setText ( OUString::createFromAscii( PROGRESSMONITOR_DEFAULT_TEXT ) ) ; + m_xTopic_Bottom->setText ( OUString::createFromAscii( PROGRESSMONITOR_DEFAULT_TOPIC ) ) ; + m_xText_Bottom->setText ( OUString::createFromAscii( PROGRESSMONITOR_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 (PROGRESSMONITOR_DEFAULT_WIDTH, PROGRESSMONITOR_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 * PROGRESSMONITOR_FREEBORDER ; + nWidth += aProgressBarSize.Width ; + + nHeight = 6 * PROGRESSMONITOR_FREEBORDER ; + nHeight += aTopicSize_Top.Height ; + nHeight += aProgressBarSize.Height ; + nHeight += aTopicSize_Bottom.Height; + nHeight += 2 ; // 1 for black line, 1 for white line = 3D-Line! + nHeight += aButtonSize.Height ; + + // norm to minimum + if ( nWidth < PROGRESSMONITOR_DEFAULT_WIDTH ) + { + nWidth = PROGRESSMONITOR_DEFAULT_WIDTH ; + } + if ( nHeight < PROGRESSMONITOR_DEFAULT_HEIGHT ) + { + nHeight = PROGRESSMONITOR_DEFAULT_HEIGHT ; + } + + // return to caller + return Size ( nWidth, nHeight ) ; +} + +//____________________________________________________________________________________________________________ +// XLayoutConstrains +//____________________________________________________________________________________________________________ + +Size SAL_CALL ProgressMonitor::calcAdjustedSize ( const Size& /*rNewSize*/ ) 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 ( PROGRESSMONITOR_LINECOLOR_SHADOW ) ; + rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, impl_getWidth()-1, nY ) ; + rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, nX , impl_getHeight()-1 ) ; + + rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT ) ; + rGraphics->drawLine ( nX, nY, impl_getWidth(), nY ) ; + rGraphics->drawLine ( nX, nY, nX , impl_getHeight() ) ; + + // Paint 3D-line + rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_SHADOW ) ; + rGraphics->drawLine ( m_a3DLine.X, m_a3DLine.Y, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y ) ; + + rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT ) ; + rGraphics->drawLine ( m_a3DLine.X, m_a3DLine.Y+1, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y+1 ) ; + } +} + +//____________________________________________________________________________________________________________ +// private method +//____________________________________________________________________________________________________________ + +void ProgressMonitor::impl_recalcLayout () +{ + sal_Int32 nX_Button ; + sal_Int32 nY_Button ; + sal_Int32 nWidth_Button ; + sal_Int32 nHeight_Button ; + + sal_Int32 nX_ProgressBar ; + sal_Int32 nY_ProgressBar ; + sal_Int32 nWidth_ProgressBar ; + sal_Int32 nHeight_ProgressBar ; + + sal_Int32 nX_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 = PROGRESSMONITOR_FREEBORDER ; + nY_Topic_Top = PROGRESSMONITOR_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+PROGRESSMONITOR_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*PROGRESSMONITOR_FREEBORDER) ; + if ( nSummaryWidth < PROGRESSMONITOR_DEFAULT_WIDTH ) + nWidth_Text_Top = PROGRESSMONITOR_DEFAULT_WIDTH-nWidth_Topic_Top-(3*PROGRESSMONITOR_FREEBORDER); + // Fix size of column to maximum! + if ( nSummaryWidth > impl_getWidth() ) + nWidth_Text_Top = impl_getWidth()-nWidth_Topic_Top-(3*PROGRESSMONITOR_FREEBORDER) ; + nHeight_Text_Top = nHeight_Topic_Top ; + + // Position of progressbar is 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+PROGRESSMONITOR_FREEBORDER ; + nWidth_ProgressBar = PROGRESSMONITOR_FREEBORDER+nWidth_Topic_Top+nWidth_Text_Top ; + nHeight_ProgressBar = nHeight_Button ; + + // Oriented by left column before progressbar. + nX_Topic_Bottom = nX_Topic_Top ; + nY_Topic_Bottom = nY_ProgressBar+nHeight_ProgressBar+PROGRESSMONITOR_FREEBORDER ; + nWidth_Topic_Bottom = nWidth_Topic_Top ; + nHeight_Topic_Bottom = aTopicSize_Bottom.Height ; + + // Oriented by right column before progressbar. + nX_Text_Bottom = nX_Topic_Bottom+nWidth_Topic_Bottom+PROGRESSMONITOR_FREEBORDER ; + nY_Text_Bottom = nY_Topic_Bottom ; + nWidth_Text_Bottom = nWidth_Text_Top ; + nHeight_Text_Bottom = nHeight_Topic_Bottom ; + + // Oriented by progressbar. + nX_3DLine = nX_Topic_Top ; + nY_3DLine = nY_Topic_Bottom+nHeight_Topic_Bottom+(PROGRESSMONITOR_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+PROGRESSMONITOR_FREEBORDER ; + + // Calc offsets to center controls + sal_Int32 nDx ; + sal_Int32 nDy ; + + nDx = ( (2*PROGRESSMONITOR_FREEBORDER)+nWidth_ProgressBar ) ; + nDy = ( (6*PROGRESSMONITOR_FREEBORDER)+nHeight_Topic_Top+nHeight_ProgressBar+nHeight_Topic_Bottom+2+nHeight_Button ) ; + + // At this point use original dialog size to center controls! + nDx = (impl_getWidth ()/2)-(nDx/2) ; + nDy = (impl_getHeight()/2)-(nDy/2) ; + + if ( nDx<0 ) + { + nDx=0 ; + } + if ( nDy<0 ) + { + nDy=0 ; + } + + // Set new position and size on all controls + 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+(PROGRESSMONITOR_FREEBORDER/2) ; + m_a3DLine.Width = nWidth_ProgressBar ; + m_a3DLine.Height = nHeight_ProgressBar ; + + // All childcontrols make an implicit repaint in setPosSize()! + // Make it also for this 3D-line ... + Reference< XGraphics > xGraphics = impl_getGraphicsPeer () ; + + xGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_SHADOW ) ; + xGraphics->drawLine ( m_a3DLine.X, m_a3DLine.Y, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y ) ; + + xGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT ) ; + xGraphics->drawLine ( m_a3DLine.X, m_a3DLine.Y+1, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y+1 ) ; +} + +//____________________________________________________________________________________________________________ +// private method +//____________________________________________________________________________________________________________ + +void ProgressMonitor::impl_rebuildFixedText () +{ + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + // Rebuild fixedtext before progress + + // Rebuild left site of text + if (m_xTopic_Top.is()) + { + 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/statusindicator.cxx b/UnoControls/source/controls/statusindicator.cxx new file mode 100644 index 000000000000..70b195931c18 --- /dev/null +++ b/UnoControls/source/controls/statusindicator.cxx @@ -0,0 +1,562 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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( STATUSINDICATOR_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 (STATUSINDICATOR_DEFAULT_WIDTH, STATUSINDICATOR_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*STATUSINDICATOR_FREEBORDER)+aTextSize.Height ; + + // norm to minimum + if ( nWidth<STATUSINDICATOR_DEFAULT_WIDTH ) + { + nWidth = STATUSINDICATOR_DEFAULT_WIDTH ; + } + if ( nHeight<STATUSINDICATOR_DEFAULT_HEIGHT ) + { + nHeight = STATUSINDICATOR_DEFAULT_HEIGHT ; + } + + // return to caller + return Size ( nWidth, nHeight ) ; +} + +//____________________________________________________________________________________________________________ +// XLayoutConstrains +//____________________________________________________________________________________________________________ + +Size SAL_CALL StatusIndicator::calcAdjustedSize ( const Size& /*rNewSize*/ ) 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( STATUSINDICATOR_BACKGROUNDCOLOR ); + + // FixedText background = gray + Reference< XControl > xTextControl( m_xText, UNO_QUERY ); + xPeer = xTextControl->getPeer(); + if( xPeer.is() == sal_True ) + xPeer->setBackground( STATUSINDICATOR_BACKGROUNDCOLOR ); + + // Progress background = gray + xPeer = Reference< XWindowPeer >( m_xProgressBar, UNO_QUERY ); + if( xPeer.is() == sal_True ) + xPeer->setBackground( STATUSINDICATOR_BACKGROUNDCOLOR ); + + // paint shadow border + rGraphics->setLineColor ( STATUSINDICATOR_LINECOLOR_BRIGHT ); + rGraphics->drawLine ( nX, nY, impl_getWidth(), nY ); + rGraphics->drawLine ( nX, nY, nX , impl_getHeight() ); + + rGraphics->setLineColor ( STATUSINDICATOR_LINECOLOR_SHADOW ); + rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, impl_getWidth()-1, nY ); + rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, nX , impl_getHeight()-1 ); + } +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + +void StatusIndicator::impl_recalcLayout ( const WindowEvent& aEvent ) +{ + sal_Int32 nX_ProgressBar ; + sal_Int32 nY_ProgressBar ; + sal_Int32 nWidth_ProgressBar ; + sal_Int32 nHeight_ProgressBar ; + sal_Int32 nX_Text ; + sal_Int32 nY_Text ; + sal_Int32 nWidth_Text ; + sal_Int32 nHeight_Text ; + + // Ready for multithreading + MutexGuard aGuard ( m_aMutex ) ; + + // get information about required place of child controls + Size aWindowSize ( aEvent.Width, aEvent.Height ); + Reference< XLayoutConstrains > xTextLayout ( m_xText, UNO_QUERY ); + Size aTextSize = xTextLayout->getPreferredSize(); + + if( aWindowSize.Width < STATUSINDICATOR_DEFAULT_WIDTH ) + { + aWindowSize.Width = STATUSINDICATOR_DEFAULT_WIDTH; + } + if( aWindowSize.Height < STATUSINDICATOR_DEFAULT_HEIGHT ) + { + aWindowSize.Height = STATUSINDICATOR_DEFAULT_HEIGHT; + } + + // calc position and size of child controls + nX_Text = STATUSINDICATOR_FREEBORDER ; + nY_Text = STATUSINDICATOR_FREEBORDER ; + nWidth_Text = aTextSize.Width ; + nHeight_Text = aTextSize.Height ; + + nX_ProgressBar = nX_Text+nWidth_Text+STATUSINDICATOR_FREEBORDER ; + nY_ProgressBar = nY_Text ; + nWidth_ProgressBar = aWindowSize.Width-nWidth_Text-(3*STATUSINDICATOR_FREEBORDER) ; + nHeight_ProgressBar = nHeight_Text ; + + // Set new position and size on all controls + 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 ) ; +} + +} // namespace unocontrols + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/inc/OConnectionPointContainerHelper.hxx b/UnoControls/source/inc/OConnectionPointContainerHelper.hxx new file mode 100644 index 000000000000..e0cc5a9b70b9 --- /dev/null +++ b/UnoControls/source/inc/OConnectionPointContainerHelper.hxx @@ -0,0 +1,265 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 CSS_UNO ::com::sun::star::uno +#define CSS_LANG ::com::sun::star::lang + +//______________________________________________________________________________________________________________ +// defines +//______________________________________________________________________________________________________________ + +//______________________________________________________________________________________________________________ +// class declaration OConnectionPointContainerHelper +//______________________________________________________________________________________________________________ + +class OConnectionPointContainerHelper : public CSS_LANG::XConnectionPointContainer + , public ::cppu::OWeakObject +{ + +//______________________________________________________________________________________________________________ +// public methods +//______________________________________________________________________________________________________________ + +public: + + //__________________________________________________________________________________________________________ + // construct/destruct + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + OConnectionPointContainerHelper( ::osl::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 CSS_UNO::Any SAL_CALL queryInterface( const CSS_UNO::Type& aType ) + throw( CSS_UNO::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 CSS_UNO::Sequence< CSS_UNO::Type > SAL_CALL getConnectionPointTypes() + throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual CSS_UNO::Reference< CSS_LANG::XConnectionPoint > SAL_CALL queryConnectionPoint( + const CSS_UNO::Type& aType + ) throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL advise( + const CSS_UNO::Type& aType , + const CSS_UNO::Reference< CSS_UNO::XInterface >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL unadvise( + const CSS_UNO::Type& aType , + const CSS_UNO::Reference< CSS_UNO::XInterface >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + ::cppu::OMultiTypeInterfaceContainerHelper& impl_getMultiTypeContainer(); + +//______________________________________________________________________________________________________________ +// private variables +//______________________________________________________________________________________________________________ + +private: + + ::osl::Mutex& m_aSharedMutex ; + ::cppu::OMultiTypeInterfaceContainerHelper m_aMultiTypeContainer ; // Container to hold listener + +}; // class OConnectionPointContainerHelper + +// The namespace aliases are only used in this header +#undef CSS_UNO +#undef CSS_LANG + +} // namespace unocontrols + +#endif // #ifndef _OCONNECTIONPOINTCONTAINERHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/inc/OConnectionPointHelper.hxx b/UnoControls/source/inc/OConnectionPointHelper.hxx new file mode 100644 index 000000000000..b36147e727cb --- /dev/null +++ b/UnoControls/source/inc/OConnectionPointHelper.hxx @@ -0,0 +1,309 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 CSS_UNO ::com::sun::star::uno +#define CSS_LANG ::com::sun::star::lang + +//______________________________________________________________________________________________________________ +// defines +//______________________________________________________________________________________________________________ + +//______________________________________________________________________________________________________________ +// class declaration OConnectionPointHelper +//______________________________________________________________________________________________________________ + +class OConnectionPointHelper : public CSS_LANG::XConnectionPoint + , public ::cppu::OWeakObject +{ + +//______________________________________________________________________________________________________________ +// public methods +//______________________________________________________________________________________________________________ + +public: + + //__________________________________________________________________________________________________________ + // construct/destruct + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + OConnectionPointHelper( ::osl::Mutex& aMutex , + OConnectionPointContainerHelper* pContainerImplementation , + CSS_UNO::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 CSS_UNO::Any SAL_CALL queryInterface( const CSS_UNO::Type& aType ) + throw( CSS_UNO::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 CSS_UNO::Type SAL_CALL getConnectionType() + throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual CSS_UNO::Reference< CSS_LANG::XConnectionPointContainer > SAL_CALL getConnectionPointContainer() + throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL advise( + const CSS_UNO::Reference< CSS_UNO::XInterface >& xListener + ) throw ( + CSS_LANG::ListenerExistException, + CSS_LANG::InvalidListenerException , + CSS_UNO::RuntimeException + ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL unadvise( const CSS_UNO::Reference< CSS_UNO::XInterface >& xListener ) + throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual CSS_UNO::Sequence< CSS_UNO::Reference< CSS_UNO::XInterface > > SAL_CALL getConnections() + throw( CSS_UNO::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: + + ::osl::Mutex& m_aSharedMutex ; + CSS_UNO::WeakReference< CSS_LANG::XConnectionPointContainer > m_oContainerWeakReference ; // Reference to container-class!. Don't use Reference<...> + // It is a ring-reference => and must be a wekreference! + OConnectionPointContainerHelper* m_pContainerImplementation ; + CSS_UNO::Type m_aInterfaceType ; + CSS_UNO::Reference< CSS_UNO::XInterface > m_xLock ; + +}; // class OConnectionPointHelper + +// The namespace aliases are only used in this header +#undef CSS_UNO +#undef CSS_LANG + +} // namespace unocontrols + +#endif // #ifndef _OCONNECTIONPOINTHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/inc/framecontrol.hxx b/UnoControls/source/inc/framecontrol.hxx new file mode 100644 index 000000000000..5d068ad0cfa1 --- /dev/null +++ b/UnoControls/source/inc/framecontrol.hxx @@ -0,0 +1,641 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 CSS_UNO ::com::sun::star::uno +#define CSS_LANG ::com::sun::star::lang +#define CSS_BEANS ::com::sun::star::beans +#define CSS_AWT ::com::sun::star::awt +#define CSS_FRAME ::com::sun::star::frame + +//______________________________________________________________________________________________________________ +// 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 CSS_AWT::XControlModel + , public CSS_LANG::XConnectionPointContainer + , public BaseControl // This order is neccessary for right initialization of m_aMutex! + , public ::cppu::OBroadcastHelper + , public ::cppu::OPropertySetHelper +{ + +//______________________________________________________________________________________________________________ +// public methods +//______________________________________________________________________________________________________________ + +public: + + //__________________________________________________________________________________________________________ + // construct/destruct + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + FrameControl( const CSS_UNO::Reference< CSS_LANG::XMultiServiceFactory >& xFactory ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual ~FrameControl(); + + //__________________________________________________________________________________________________________ + // XInterface + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual CSS_UNO::Any SAL_CALL queryInterface( + const CSS_UNO::Type& aType + ) throw( CSS_UNO::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 CSS_UNO::Sequence< CSS_UNO::Type > SAL_CALL getTypes() + throw( CSS_UNO::RuntimeException ); + + //__________________________________________________________________________________________________________ + // XAggregation + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + CSS_UNO::Any SAL_CALL queryAggregation( + const CSS_UNO::Type& aType + ) throw( CSS_UNO::RuntimeException ); + + //__________________________________________________________________________________________________________ + // XControl + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL createPeer( + const CSS_UNO::Reference< CSS_AWT::XToolkit >& xToolkit , + const CSS_UNO::Reference< CSS_AWT::XWindowPeer >& xParent + ) throw ( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual sal_Bool SAL_CALL setModel( + const CSS_UNO::Reference< CSS_AWT::XControlModel >& xModel + ) throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual CSS_UNO::Reference< CSS_AWT::XControlModel > SAL_CALL getModel() + throw( CSS_UNO::RuntimeException ); + + //__________________________________________________________________________________________________________ + // XComponent + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL dispose() throw( CSS_UNO::RuntimeException ); + + //__________________________________________________________________________________________________________ + // XView + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual sal_Bool SAL_CALL setGraphics( + const CSS_UNO::Reference< CSS_AWT::XGraphics >& xDevice + ) throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual CSS_UNO::Reference< CSS_AWT::XGraphics > SAL_CALL getGraphics() + throw( CSS_UNO::RuntimeException ); + + //__________________________________________________________________________________________________________ + // XConnectionPointContainer + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual CSS_UNO::Sequence< CSS_UNO::Type > SAL_CALL getConnectionPointTypes() + throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual CSS_UNO::Reference< CSS_LANG::XConnectionPoint > SAL_CALL queryConnectionPoint( + const CSS_UNO::Type& aType + ) throw ( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL advise( + const CSS_UNO::Type& aType , + const CSS_UNO::Reference< CSS_UNO::XInterface >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL unadvise( + const CSS_UNO::Type& aType , + const CSS_UNO::Reference< CSS_UNO::XInterface >& xListener + ) throw( CSS_UNO::RuntimeException ); + + //__________________________________________________________________________________________________________ + // impl but public methods to register service! + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + static const CSS_UNO::Sequence< ::rtl::OUString > impl_getStaticSupportedServiceNames(); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + static const ::rtl::OUString impl_getStaticImplementationName(); + +//______________________________________________________________________________________________________________ +// protected methods +//______________________________________________________________________________________________________________ + +protected: + using OPropertySetHelper::getFastPropertyValue; + //__________________________________________________________________________________________________________ + // OPropertySetHelper + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual sal_Bool SAL_CALL convertFastPropertyValue( + CSS_UNO::Any& rConvertedValue , + CSS_UNO::Any& rOldValue , + sal_Int32 nHandle , + const CSS_UNO::Any& rValue + ) throw( CSS_LANG::IllegalArgumentException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle , + const CSS_UNO::Any& rValue + ) throw ( ::com::sun::star::uno::Exception ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL getFastPropertyValue( CSS_UNO::Any& rValue , + sal_Int32 nHandle ) const ; + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + + //__________________________________________________________________________________________________________ + // XPropertySet + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + CSS_UNO::Reference< CSS_BEANS::XPropertySetInfo > SAL_CALL getPropertySetInfo() + throw( CSS_UNO::RuntimeException ); + + //__________________________________________________________________________________________________________ + // BaseControl + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual CSS_AWT::WindowDescriptor* impl_getWindowDescriptor( + const CSS_UNO::Reference< CSS_AWT::XWindowPeer >& xParentPeer + ); + +//______________________________________________________________________________________________________________ +// private methods +//______________________________________________________________________________________________________________ + +private: + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + void impl_createFrame( const CSS_UNO::Reference< CSS_AWT::XWindowPeer >& xPeer , + const ::rtl::OUString& sURL , + const CSS_UNO::Sequence< CSS_BEANS::PropertyValue >& seqArguments ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + void impl_deleteFrame(); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + static const CSS_UNO::Sequence< CSS_BEANS::Property > impl_getStaticPropertyDescriptor(); + + +//______________________________________________________________________________________________________________ +// private variables +//______________________________________________________________________________________________________________ + +private: + + CSS_UNO::Reference< CSS_FRAME::XFrame > m_xFrame ; + ::rtl::OUString m_sComponentURL ; + CSS_UNO::Sequence< CSS_BEANS::PropertyValue > m_seqLoaderArguments ; + ::cppu::OMultiTypeInterfaceContainerHelper m_aInterfaceContainer ; + OConnectionPointContainerHelper m_aConnectionPointContainer ; + +}; // class FrameControl + +// The namespace alaises are only used in the header +#undef CSS_UNO +#undef CSS_LANG +#undef CSS_BEANS +#undef CSS_AWT +#undef CSS_FRAME + +} // namespace unocontrols + +#endif // #ifndef _UNOCONTROLS_FRAMECONTROL_CTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/inc/progressbar.hxx b/UnoControls/source/inc/progressbar.hxx new file mode 100644 index 000000000000..97cad21816dd --- /dev/null +++ b/UnoControls/source/inc/progressbar.hxx @@ -0,0 +1,459 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 CSS_UNO ::com::sun::star::uno +#define CSS_LANG ::com::sun::star::lang +#define CSS_AWT ::com::sun::star::awt + +//____________________________________________________________________________________________________________ +// defines +//____________________________________________________________________________________________________________ + +#define SERVICENAME_PROGRESSBAR "com.sun.star.awt.XProgressBar" +#define IMPLEMENTATIONNAME_PROGRESSBAR "stardiv.UnoControls.ProgressBar" +#define PROGRESSBAR_FREESPACE 4 +#define PROGRESSBAR_DEFAULT_HORIZONTAL sal_True +#define PROGRESSBAR_DEFAULT_BLOCKDIMENSION Size(1,1) +#define PROGRESSBAR_DEFAULT_BACKGROUNDCOLOR TRGB_COLORDATA( 0x00, 0xC0, 0xC0, 0xC0 ) // lightgray +#define PROGRESSBAR_DEFAULT_FOREGROUNDCOLOR 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 TRGB_COLORDATA( 0x00, 0xFF, 0xFF, 0xFF ) // white +#define PROGRESSBAR_LINECOLOR_SHADOW TRGB_COLORDATA( 0x00, 0x00, 0x00, 0x00 ) // black + +//____________________________________________________________________________________________________________ +// classes +//____________________________________________________________________________________________________________ + +class ProgressBar : public CSS_AWT::XControlModel + , public CSS_AWT::XProgressBar + , public BaseControl +{ + +//____________________________________________________________________________________________________________ +// public methods +//____________________________________________________________________________________________________________ + +public: + + //________________________________________________________________________________________________________ + // construct/destruct + //________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + ProgressBar( const CSS_UNO::Reference< CSS_LANG::XMultiServiceFactory >& xFactory ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual ~ProgressBar(); + + //__________________________________________________________________________________________________________ + // XInterface + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual CSS_UNO::Any SAL_CALL queryInterface( const CSS_UNO::Type& aType ) + throw( CSS_UNO::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 CSS_UNO::Sequence< CSS_UNO::Type > SAL_CALL getTypes() + throw( CSS_UNO::RuntimeException ); + + //__________________________________________________________________________________________________________ + // XAggregation + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + CSS_UNO::Any SAL_CALL queryAggregation( const CSS_UNO::Type& aType ) + throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XProgressBar + //________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL setForegroundColor( sal_Int32 nColor ) + throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL setBackgroundColor( sal_Int32 nColor ) + throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL setValue( sal_Int32 nValue ) throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void SAL_CALL setRange( + sal_Int32 nMin , + sal_Int32 nMax + ) throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual sal_Int32 SAL_CALL getValue() throw( CSS_UNO::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( CSS_UNO::RuntimeException ); + + //__________________________________________________________________________________________________________ + // XControl + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual sal_Bool SAL_CALL setModel( + const CSS_UNO::Reference< CSS_AWT::XControlModel >& xModel + ) throw( CSS_UNO::RuntimeException ); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual CSS_UNO::Reference< CSS_AWT::XControlModel > SAL_CALL getModel() + throw( CSS_UNO::RuntimeException ); + + //__________________________________________________________________________________________________________ + // BaseControl + //__________________________________________________________________________________________________________ + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + static const CSS_UNO::Sequence< ::rtl::OUString > impl_getStaticSupportedServiceNames(); + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + static const ::rtl::OUString impl_getStaticImplementationName(); + +//____________________________________________________________________________________________________________ +// protected methods +//____________________________________________________________________________________________________________ + +protected: + + /**_________________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + virtual void impl_paint( + sal_Int32 nX , + sal_Int32 nY , + const CSS_UNO::Reference< CSS_AWT::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] + CSS_AWT::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 + +// The namespace aliases are only used in the header +#undef CSS_UNO +#undef CSS_LANG +#undef CSS_AWT + +} // namespace unocontrols + +#endif // #ifndef _UNOCONTROLS_PROGRESSBAR_CTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/inc/progressmonitor.hxx b/UnoControls/source/inc/progressmonitor.hxx new file mode 100644 index 000000000000..08353d11f4a0 --- /dev/null +++ b/UnoControls/source/inc/progressmonitor.hxx @@ -0,0 +1,808 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 CSS_UNO ::com::sun::star::uno +#define CSS_AWT ::com::sun::star::awt +#define CSS_LANG ::com::sun::star::lang + +//____________________________________________________________________________________________________________ +// defines +//____________________________________________________________________________________________________________ + +#define SERVICENAME_PROGRESSMONITOR "com.sun.star.awt.XProgressMonitor" +#define IMPLEMENTATIONNAME_PROGRESSMONITOR "stardiv.UnoControls.ProgressMonitor" +#define PROGRESSMONITOR_FREEBORDER 10 // border around and between the controls +#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 PROGRESSMONITOR_DEFAULT_TOPIC "\0" +#define PROGRESSMONITOR_DEFAULT_TEXT "\0" +#define PROGRESSMONITOR_BACKGROUNDCOLOR TRGB_COLORDATA( 0x00, 0xC0, 0xC0, 0xC0 ) // lighgray +#define PROGRESSMONITOR_LINECOLOR_BRIGHT TRGB_COLORDATA( 0x00, 0xFF, 0xFF, 0xFF ) // white +#define PROGRESSMONITOR_LINECOLOR_SHADOW TRGB_COLORDATA( 0x00, 0x00, 0x00, 0x00 ) // black +#define PROGRESSMONITOR_DEFAULT_WIDTH 350 +#define PROGRESSMONITOR_DEFAULT_HEIGHT 100 + +//____________________________________________________________________________________________________________ +// structs, types +//____________________________________________________________________________________________________________ + +/// Item of TextList +struct IMPL_TextlistItem +{ + ::rtl::OUString sTopic ; /// Left site of textline in dialog + ::rtl::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 CSS_AWT::XLayoutConstrains + , public CSS_AWT::XButton + , public CSS_AWT::XProgressMonitor + , public BaseContainerControl +{ + +//____________________________________________________________________________________________________________ +// public methods +//____________________________________________________________________________________________________________ + +public: + + //________________________________________________________________________________________________________ + // construct/destruct + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + ProgressMonitor( const CSS_UNO::Reference< CSS_LANG::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 CSS_UNO::Any SAL_CALL queryInterface( const CSS_UNO::Type& aType ) + throw( CSS_UNO::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 CSS_UNO::Sequence< CSS_UNO::Type > SAL_CALL getTypes() throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XAggregation + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Any SAL_CALL queryAggregation( const CSS_UNO::Type& aType ) + throw( CSS_UNO::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 ::rtl::OUString& sTopic , + const ::rtl::OUString& sText , + sal_Bool bbeforeProgress + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeText( + const ::rtl::OUString& sTopic , + sal_Bool bbeforeProgress + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL updateText( + const ::rtl::OUString& sTopic , + const ::rtl::OUString& sText , + sal_Bool bbeforeProgress + ) throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XProgressBar + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setForegroundColor( sal_Int32 nColor ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setBackgroundColor( sal_Int32 nColor ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setValue( sal_Int32 nValue ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setRange( sal_Int32 nMin , + sal_Int32 nMax ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Int32 SAL_CALL getValue() throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XButton + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL addActionListener( + const CSS_UNO::Reference< CSS_AWT::XActionListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL removeActionListener( + const CSS_UNO::Reference< CSS_AWT::XActionListener >& xListener + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setLabel( const ::rtl::OUString& sLabel ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL setActionCommand( const ::rtl::OUString& sCommand ) + throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XLayoutConstrains + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_AWT::Size SAL_CALL getMinimumSize() throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_AWT::Size SAL_CALL getPreferredSize() throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_AWT::Size SAL_CALL calcAdjustedSize( const CSS_AWT::Size& aNewSize ) + throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XControl + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL createPeer( + const CSS_UNO::Reference< CSS_AWT::XToolkit >& xToolkit , + const CSS_UNO::Reference< CSS_AWT::XWindowPeer >& xParent + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL setModel( const CSS_UNO::Reference< CSS_AWT::XControlModel >& xModel ) + throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Reference< CSS_AWT::XControlModel > SAL_CALL getModel() + throw( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // XComponent + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL dispose() throw( CSS_UNO::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( CSS_UNO::RuntimeException ); + + //________________________________________________________________________________________________________ + // BaseControl + //________________________________________________________________________________________________________ + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + static const CSS_UNO::Sequence< ::rtl::OUString > impl_getStaticSupportedServiceNames(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + static const ::rtl::OUString impl_getStaticImplementationName(); + +//____________________________________________________________________________________________________________ +// protected methods +//____________________________________________________________________________________________________________ + +protected: + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void impl_paint( sal_Int32 nX , + sal_Int32 nY , + const CSS_UNO::Reference< CSS_AWT::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 ::rtl::OUString& sTopic , sal_Bool bbeforeProgress ); + +//____________________________________________________________________________________________________________ +// debug methods +//____________________________________________________________________________________________________________ + +private: + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + #ifdef DBG_UTIL + + sal_Bool impl_debug_checkParameter( const ::rtl::OUString& sTopic, const ::rtl::OUString& sText, sal_Bool bbeforeProgress ); // addText, updateText + sal_Bool impl_debug_checkParameter( const ::rtl::OUString& rTopic, sal_Bool bbeforeProgress ); // removeText + + #endif +//____________________________________________________________________________________________________________ +// private variables +//____________________________________________________________________________________________________________ + +private: + + IMPL_Textlist* m_pTextlist_Top ; // Elements before progress + CSS_UNO::Reference< CSS_AWT::XFixedText > m_xTopic_Top ; // (used, if parameter "beforeProgress"=sal_True in "addText, updateText, removeText") + CSS_UNO::Reference< CSS_AWT::XFixedText > m_xText_Top ; + + IMPL_Textlist* m_pTextlist_Bottom ; // Elements below of progress + CSS_UNO::Reference< CSS_AWT::XFixedText > m_xTopic_Bottom ; // (used, if parameter "beforeProgress"=sal_False in "addText, updateText, removeText") + CSS_UNO::Reference< CSS_AWT::XFixedText > m_xText_Bottom ; + + CSS_UNO::Reference< CSS_AWT::XProgressBar > m_xProgressBar ; + CSS_UNO::Reference< CSS_AWT::XButton > m_xButton ; + CSS_AWT::Rectangle m_a3DLine ; + +}; // class ProgressMonitor + +// The namespaces aliases are only used the this header +#undef CSS_UNO +#undef CSS_AWT +#undef CSS_LANG + +} // namespace unocontrols + +#endif // #ifndef _UNOCONTROLS_PROGRESSMONITOR_CTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/inc/statusindicator.hxx b/UnoControls/source/inc/statusindicator.hxx new file mode 100644 index 000000000000..d8e888f9dc42 --- /dev/null +++ b/UnoControls/source/inc/statusindicator.hxx @@ -0,0 +1,584 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 CSS_UNO ::com::sun::star::uno +#define CSS_AWT ::com::sun::star::awt +#define CSS_LANG ::com::sun::star::lang +#define CSS_TASK ::com::sun::star::task + +//____________________________________________________________________________________________________________ +// defines +//____________________________________________________________________________________________________________ + +#define SERVICENAME_STATUSINDICATOR "com.sun.star.task.XStatusIndicator" +#define IMPLEMENTATIONNAME_STATUSINDICATOR "stardiv.UnoControls.StatusIndicator" +#define STATUSINDICATOR_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 STATUSINDICATOR_DEFAULT_TEXT "\0" +#define STATUSINDICATOR_BACKGROUNDCOLOR TRGB_COLORDATA( 0x00, 0xC0, 0xC0, 0xC0 ) // lighgray +#define STATUSINDICATOR_LINECOLOR_BRIGHT TRGB_COLORDATA( 0x00, 0xFF, 0xFF, 0xFF ) // white +#define STATUSINDICATOR_LINECOLOR_SHADOW TRGB_COLORDATA( 0x00, 0x00, 0x00, 0x00 ) // black +#define STATUSINDICATOR_DEFAULT_WIDTH 300 +#define STATUSINDICATOR_DEFAULT_HEIGHT 25 + +//____________________________________________________________________________________________________________ +// structs, types +//____________________________________________________________________________________________________________ + +//____________________________________________________________________________________________________________ +// class declaration +//____________________________________________________________________________________________________________ + +class StatusIndicator : public CSS_AWT::XLayoutConstrains + , public CSS_TASK::XStatusIndicator + , public BaseContainerControl +{ + + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + + public: + + //--------------------------------------------------------------------------------------------------------- + // construct/destruct + //--------------------------------------------------------------------------------------------------------- + + /**_______________________________________________________________________________________________________ + @short + @descr + + @seealso + + @param + + @return + + @onerror + */ + + StatusIndicator( const CSS_UNO::Reference< CSS_LANG::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 CSS_UNO::Any SAL_CALL queryInterface( const CSS_UNO::Type& aType ) + throw( CSS_UNO::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 CSS_UNO::Sequence< CSS_UNO::Type > SAL_CALL getTypes() + throw( CSS_UNO::RuntimeException ); + + //--------------------------------------------------------------------------------------------------------- + // XAggregation + //--------------------------------------------------------------------------------------------------------- + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Any SAL_CALL queryAggregation( const CSS_UNO::Type& aType ) + throw( CSS_UNO::RuntimeException ); + + //--------------------------------------------------------------------------------------------------------- + // XStatusIndicator + //--------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL start( + const ::rtl::OUString& sText , + sal_Int32 nRange + ) throw( CSS_UNO::RuntimeException ); + + /*-****************************************************************************************************//** + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL end() throw( CSS_UNO::RuntimeException ); + + /*-****************************************************************************************************//** + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL reset() throw( CSS_UNO::RuntimeException ); + + /*-****************************************************************************************************//** + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL setText( const ::rtl::OUString& sText ) throw( CSS_UNO::RuntimeException ); + + /*-****************************************************************************************************//** + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL setValue( sal_Int32 nValue ) throw( CSS_UNO::RuntimeException ); + + //--------------------------------------------------------------------------------------------------------- + // XLayoutConstrains + //--------------------------------------------------------------------------------------------------------- + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_AWT::Size SAL_CALL getMinimumSize() throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_AWT::Size SAL_CALL getPreferredSize() throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_AWT::Size SAL_CALL calcAdjustedSize( const CSS_AWT::Size& aNewSize ) + throw( CSS_UNO::RuntimeException ); + + //--------------------------------------------------------------------------------------------------------- + // XControl + //--------------------------------------------------------------------------------------------------------- + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL createPeer( + const CSS_UNO::Reference< CSS_AWT::XToolkit >& xToolkit , + const CSS_UNO::Reference< CSS_AWT::XWindowPeer >& xParent + ) throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual sal_Bool SAL_CALL setModel( const CSS_UNO::Reference< CSS_AWT::XControlModel >& xModel ) + throw( CSS_UNO::RuntimeException ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_UNO::Reference< CSS_AWT::XControlModel > SAL_CALL getModel() + throw( CSS_UNO::RuntimeException ); + + //--------------------------------------------------------------------------------------------------------- + // XComponent + //--------------------------------------------------------------------------------------------------------- + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void SAL_CALL dispose() throw( CSS_UNO::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( CSS_UNO::RuntimeException ); + + //--------------------------------------------------------------------------------------------------------- + // BaseControl + //--------------------------------------------------------------------------------------------------------- + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + static const CSS_UNO::Sequence< ::rtl::OUString > impl_getStaticSupportedServiceNames(); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + static const ::rtl::OUString impl_getStaticImplementationName(); + +//____________________________________________________________________________________________________________ +// protected methods +//____________________________________________________________________________________________________________ + +protected: + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual CSS_AWT::WindowDescriptor* impl_getWindowDescriptor( + const CSS_UNO::Reference< CSS_AWT::XWindowPeer >& xParentPeer + ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void impl_paint ( + sal_Int32 nX, + sal_Int32 nY, + const CSS_UNO::Reference< CSS_AWT::XGraphics > & rGraphics + ); + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + + virtual void impl_recalcLayout( const CSS_AWT::WindowEvent& aEvent ); + +//____________________________________________________________________________________________________________ +// debug methods +//____________________________________________________________________________________________________________ + +private: + + /**_______________________________________________________________________________________________________ + @short - + @descr - + + @seealso - + + @param - + + @return - + + @onerror - + */ + +//____________________________________________________________________________________________________________ +// private variables +//____________________________________________________________________________________________________________ + +private: + + CSS_UNO::Reference< CSS_AWT::XFixedText > m_xText ; + CSS_UNO::Reference< CSS_AWT::XProgressBar > m_xProgressBar ; + +}; // class StatusIndicator + +// The name space aliases are only used in the header +#undef CSS_UNO +#undef CSS_AWT +#undef CSS_LANG +#undef CSS_TASK + +} // namespace unocontrols + +#endif // #ifndef _UNOCONTROLS_STATUSINDICATOR_CTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/util/makefile.mk b/UnoControls/util/makefile.mk new file mode 100644 index 000000000000..aacddb23c0ad --- /dev/null +++ b/UnoControls/util/makefile.mk @@ -0,0 +1,61 @@ +#************************************************************************* +# +# 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 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" + |