LCOV - code coverage report
Current view: top level - toolkit/inc/toolkit/controls - controlmodelcontainerbase.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 2 50.0 %
Date: 2012-08-25 Functions: 1 4 25.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 8 25.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef TOOLKIT_CONTROL_MODEL_CONTAINERBASE_HXX
      30                 :            : #define TOOLKIT_CONTROL_MODEL_CONTAINERBASE_HXX
      31                 :            : 
      32                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      33                 :            : #include <com/sun/star/container/XContainer.hpp>
      34                 :            : #include <com/sun/star/awt/XTabControllerModel.hpp>
      35                 :            : #include <com/sun/star/util/XChangesNotifier.hpp>
      36                 :            : #include <com/sun/star/util/XChangesListener.hpp>
      37                 :            : #include <com/sun/star/util/XModifyListener.hpp>
      38                 :            : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
      39                 :            : #include <com/sun/star/resource/XStringResourceResolver.hpp>
      40                 :            : #include <cppuhelper/implbase8.hxx>
      41                 :            : #include <cppuhelper/implbase2.hxx>
      42                 :            : #include <toolkit/helper/listenermultiplexer.hxx>
      43                 :            : #include <toolkit/controls/unocontrolmodel.hxx>
      44                 :            : #include <toolkit/controls/unocontrolcontainer.hxx>
      45                 :            : #include <cppuhelper/propshlp.hxx>
      46                 :            : #include <cppuhelper/basemutex.hxx>
      47                 :            : #include <com/sun/star/graphic/XGraphic.hpp>
      48                 :            : #include <com/sun/star/awt/tab/XTabPageModel.hpp>
      49                 :            : #include <com/sun/star/uno/XComponentContext.hpp>
      50                 :            : #include <com/sun/star/lang/XInitialization.hpp>
      51                 :            : //  ----------------------------------------------------
      52                 :            : //  class ControlModelContainerBase
      53                 :            : //  ----------------------------------------------------
      54                 :            : typedef UnoControlModel     ControlModel_Base;
      55                 :            : typedef ::cppu::AggImplInheritanceHelper8   <   ControlModel_Base
      56                 :            :                             ,   ::com::sun::star::lang::XMultiServiceFactory
      57                 :            :                             ,   ::com::sun::star::container::XContainer
      58                 :            :                             ,   ::com::sun::star::container::XNameContainer
      59                 :            :                             ,   ::com::sun::star::awt::XTabControllerModel
      60                 :            :                             ,   ::com::sun::star::util::XChangesNotifier
      61                 :            :                             ,   ::com::sun::star::beans::XPropertyChangeListener
      62                 :            :                             ,   ::com::sun::star::awt::tab::XTabPageModel
      63                 :            :                             ,   ::com::sun::star::lang::XInitialization
      64                 :            :                             >   ControlModelContainer_IBase;
      65                 :            : 
      66                 :            : class ControlModelContainerBase :   public ControlModelContainer_IBase
      67                 :            : {
      68                 :            : public:
      69                 :            :     enum ChildOperation { Insert = 0, Remove };
      70                 :            :     // would like to make this typedef private, too, but the Forte 7 compiler does have
      71                 :            :     // problems with this .....
      72                 :            :     typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >, ::rtl::OUString >
      73                 :            :                                                         UnoControlModelHolder;
      74                 :            : private:
      75                 :            :     typedef ::std::list< UnoControlModelHolder >        UnoControlModelHolderList;
      76                 :            : 
      77                 :            : public:
      78                 :            :     // for grouping control models (XTabControllerModel::getGroupXXX)
      79                 :            :     typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >
      80                 :            :                                                         ModelGroup;
      81                 :            :     typedef ::std::vector< ModelGroup >                 AllGroups;
      82                 :            : 
      83                 :            :     friend struct CloneControlModel;
      84                 :            :     friend struct FindControlModel;
      85                 :            :     friend struct CompareControlModel;
      86                 :            : 
      87                 :            : protected:
      88                 :            :     ContainerListenerMultiplexer        maContainerListeners;
      89                 :            :     ::cppu::OInterfaceContainerHelper   maChangeListeners;
      90                 :            :     UnoControlModelHolderList           maModels;
      91                 :            : 
      92                 :            :     AllGroups                           maGroups;
      93                 :            :     sal_Bool                            mbGroupsUpToDate;
      94                 :            : 
      95                 :            :     bool                                    m_bEnabled;
      96                 :            :     ::rtl::OUString                         m_sTitle;
      97                 :            :     ::rtl::OUString                         m_sImageURL;
      98                 :            :     ::rtl::OUString                         m_sTooltip;
      99                 :            :     sal_Int16                               m_nTabPageId;
     100                 :            : 
     101                 :            :     void    Clone_Impl(ControlModelContainerBase& _rClone) const;
     102                 :            : protected:
     103                 :            :     ::com::sun::star::uno::Any          ImplGetDefaultValue( sal_uInt16 nPropId ) const;
     104                 :            :     ::cppu::IPropertyArrayHelper&       SAL_CALL getInfoHelper();
     105                 :            : 
     106                 :            :     UnoControlModelHolderList::iterator         ImplFindElement( const ::rtl::OUString& rName );
     107                 :            : 
     108                 :            :     void updateUserFormChildren(  const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xAllChildren, const rtl::OUString& aName, ChildOperation Operation,  const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& xTarget ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     109                 :            : public:
     110                 :            :                         ControlModelContainerBase( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory );
     111                 :            :                         ControlModelContainerBase( const ControlModelContainerBase& rModel );
     112                 :            :                         ~ControlModelContainerBase();
     113                 :            : 
     114                 :            :     UnoControlModel*    Clone() const;
     115                 :            : 
     116                 :            :     // ::com::sun::star::container::XContainer
     117                 :            :     void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
     118                 :            :     void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
     119                 :            : 
     120                 :            :     // ::com::sun::star::container::XElementAcces
     121                 :            :     ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw(::com::sun::star::uno::RuntimeException);
     122                 :            :     sal_Bool SAL_CALL hasElements(  ) throw(::com::sun::star::uno::RuntimeException);
     123                 :            : 
     124                 :            :     // ::com::sun::star::container::XNameContainer, XNameReplace, XNameAccess
     125                 :            :     void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     126                 :            :     ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     127                 :            :     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw(::com::sun::star::uno::RuntimeException);
     128                 :            :     sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
     129                 :            :     void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     130                 :            :     void SAL_CALL removeByName( const ::rtl::OUString& Name ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     131                 :            : 
     132                 :            :     // ::com::sun::star::beans::XMultiPropertySet
     133                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
     134                 :            : 
     135                 :            :     // ::com::sun::star::lang::XMultiServiceFactory
     136                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     137                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     138                 :            :     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
     139                 :            : 
     140                 :            :     // XComponent
     141                 :            :     void SAL_CALL dispose(  ) throw(::com::sun::star::uno::RuntimeException);
     142                 :            : 
     143                 :            :     // XTabControllerModel
     144                 :            :     virtual sal_Bool SAL_CALL getGroupControl(  ) throw (::com::sun::star::uno::RuntimeException);
     145                 :            :     virtual void SAL_CALL setGroupControl( sal_Bool GroupControl ) throw (::com::sun::star::uno::RuntimeException);
     146                 :            :     virtual void SAL_CALL setControlModels( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Controls ) throw (::com::sun::star::uno::RuntimeException);
     147                 :            :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > SAL_CALL getControlModels(  ) throw (::com::sun::star::uno::RuntimeException);
     148                 :            :     virtual void SAL_CALL setGroup( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group, const ::rtl::OUString& GroupName ) throw (::com::sun::star::uno::RuntimeException);
     149                 :            :     virtual sal_Int32 SAL_CALL getGroupCount(  ) throw (::com::sun::star::uno::RuntimeException);
     150                 :            :     virtual void SAL_CALL getGroup( sal_Int32 nGroup, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group, ::rtl::OUString& Name ) throw (::com::sun::star::uno::RuntimeException);
     151                 :            :     virtual void SAL_CALL getGroupByName( const ::rtl::OUString& Name, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group ) throw (::com::sun::star::uno::RuntimeException);
     152                 :            : 
     153                 :            :     // XChangesNotifier
     154                 :            :     virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
     155                 :            :     virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
     156                 :            : 
     157                 :            :     // XPropertyChangeListener
     158                 :            :     virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
     159                 :            : 
     160                 :            :     // XEventListener
     161                 :            :     using cppu::OPropertySetHelper::disposing;
     162                 :            :     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& evt ) throw (::com::sun::star::uno::RuntimeException);
     163                 :            : 
     164                 :            :     // XServiceInfo
     165 [ +  - ][ +  - ]:          8 :     DECLIMPL_SERVICEINFO_DERIVED(ControlModelContainerBase, ControlModel_Base, "toolkit.ControlModelContainerBase" )
     166                 :            : 
     167                 :            :     // XInitialization
     168                 :            :     virtual void SAL_CALL initialize (const com::sun::star::uno::Sequence<com::sun::star::uno::Any>& rArguments)
     169                 :            :             throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
     170                 :            : 
     171                 :            :     // ::com::sun::star::awt::tab::XTabPageModel
     172                 :            :     virtual ::sal_Int16 SAL_CALL getTabPageID() throw (::com::sun::star::uno::RuntimeException);
     173                 :            :     virtual ::sal_Bool SAL_CALL getEnabled() throw (::com::sun::star::uno::RuntimeException);
     174                 :            :     virtual void SAL_CALL setEnabled( ::sal_Bool _enabled ) throw (::com::sun::star::uno::RuntimeException);
     175                 :            :     virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException);
     176                 :            :     virtual void SAL_CALL setTitle( const ::rtl::OUString& _title ) throw (::com::sun::star::uno::RuntimeException);
     177                 :            :     virtual ::rtl::OUString SAL_CALL getImageURL() throw (::com::sun::star::uno::RuntimeException);
     178                 :            :     virtual void SAL_CALL setImageURL( const ::rtl::OUString& _imageurl ) throw (::com::sun::star::uno::RuntimeException);
     179                 :            :     virtual ::rtl::OUString SAL_CALL getTooltip() throw (::com::sun::star::uno::RuntimeException);
     180                 :            :     virtual void SAL_CALL setTooltip( const ::rtl::OUString& _tooltip ) throw (::com::sun::star::uno::RuntimeException);
     181                 :            : 
     182                 :            : protected:
     183                 :            :     void startControlListening( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxChildModel );
     184                 :            :     void stopControlListening( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxChildModel );
     185                 :            : 
     186                 :            :     void implNotifyTabModelChange( const ::rtl::OUString& _rAccessor );
     187                 :            : 
     188                 :            :     void implUpdateGroupStructure();
     189                 :            : };
     190                 :            : 
     191                 :            : class ResourceListener  :public ::com::sun::star::util::XModifyListener,
     192                 :            :                          public ::cppu::OWeakObject,
     193                 :            :                          public ::cppu::BaseMutex
     194                 :            : {
     195                 :            :     public:
     196                 :            :         ResourceListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& xListener );
     197                 :            :         virtual ~ResourceListener();
     198                 :            : 
     199                 :            :         void startListening( const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver  >& rResource );
     200                 :            :         void stopListening();
     201                 :            : 
     202                 :            :         // XInterface
     203                 :            :         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
     204                 :            :         virtual void SAL_CALL acquire() throw ();
     205                 :            :         virtual void SAL_CALL release() throw ();
     206                 :            : 
     207                 :            :         // XModifyListener
     208                 :            :         virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
     209                 :            : 
     210                 :            :         // XEventListener
     211                 :            :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
     212                 :            : 
     213                 :            :     private:
     214                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver > m_xResource;
     215                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >             m_xListener;
     216                 :            :         bool                                                                                    m_bListening;
     217                 :            : };
     218                 :            : 
     219                 :            : typedef ::cppu::AggImplInheritanceHelper2   < UnoControlContainer
     220                 :            :                             ,   ::com::sun::star::container::XContainerListener
     221                 :            :                             ,   ::com::sun::star::util::XChangesListener
     222                 :            :                             >   ContainerControl_IBase;
     223                 :            : 
     224                 :            : class ControlContainerBase : public ContainerControl_IBase
     225                 :            : {
     226                 :            : protected:
     227                 :            :     bool                                                                        mbSizeModified;
     228                 :            :     bool                                                                        mbPosModified;
     229                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController >   mxTabController;
     230                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > mxListener;
     231                 :            : 
     232                 :            :     void        ImplInsertControl( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel, const ::rtl::OUString& rName );
     233                 :            :     void        ImplRemoveControl( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel );
     234                 :            :     virtual void        ImplSetPosSize( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& rxCtrl );
     235                 :            :     void        ImplUpdateResourceResolver();
     236                 :            :     void        ImplStartListingForResourceEvents();
     237                 :            : 
     238                 :            :     ControlContainerBase();
     239                 :            : 
     240                 :            : public:
     241                 :            :     ControlContainerBase( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory );
     242                 :            :     ~ControlContainerBase();
     243                 :            : 
     244 [ #  # ][ #  # ]:          0 :     DECLIMPL_SERVICEINFO_DERIVED( ControlContainerBase, UnoControlBase, "toolkit.ControlContainerBase" )
     245                 :            : 
     246                 :            :     void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
     247                 :            :     void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
     248                 :            : 
     249                 :            :     void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& Toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent ) throw(::com::sun::star::uno::RuntimeException);
     250                 :            : 
     251                 :            :     // ::com::sun::star::container::XContainerListener
     252                 :            :     void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
     253                 :            :     void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
     254                 :            :     void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
     255                 :            : 
     256                 :            :     // XChangesListener
     257                 :            :     virtual void SAL_CALL changesOccurred( const ::com::sun::star::util::ChangesEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
     258                 :            : 
     259                 :            :     // ::com::sun::star::awt::XControl
     260                 :            :     sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& Model ) throw(::com::sun::star::uno::RuntimeException);
     261                 :            :     void SAL_CALL setDesignMode( sal_Bool bOn ) throw(::com::sun::star::uno::RuntimeException);
     262                 :            : protected:
     263                 :            :     virtual void ImplModelPropertiesChanged( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& rEvents ) throw(::com::sun::star::uno::RuntimeException);
     264                 :            :     virtual void removingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl );
     265                 :            :     virtual void addingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl );
     266                 :            : };
     267                 :            : #endif
     268                 :            : 
     269                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10