LCOV - code coverage report
Current view: top level - include/toolkit/controls - controlmodelcontainerbase.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 3 33.3 %
Date: 2015-06-13 12:38:46 Functions: 1 5 20.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_TOOLKIT_CONTROLS_CONTROLMODELCONTAINERBASE_HXX
      21             : #define INCLUDED_TOOLKIT_CONTROLS_CONTROLMODELCONTAINERBASE_HXX
      22             : 
      23             : #include <com/sun/star/container/XNameContainer.hpp>
      24             : #include <com/sun/star/container/XContainer.hpp>
      25             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      26             : #include <com/sun/star/awt/XTabControllerModel.hpp>
      27             : #include <com/sun/star/util/XChangesNotifier.hpp>
      28             : #include <com/sun/star/util/XChangesListener.hpp>
      29             : #include <com/sun/star/util/XModifyListener.hpp>
      30             : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
      31             : #include <com/sun/star/resource/XStringResourceResolver.hpp>
      32             : #include <cppuhelper/implbase8.hxx>
      33             : #include <cppuhelper/implbase3.hxx>
      34             : #include <toolkit/helper/listenermultiplexer.hxx>
      35             : #include <toolkit/controls/unocontrolmodel.hxx>
      36             : #include <toolkit/controls/unocontrolcontainer.hxx>
      37             : #include <cppuhelper/propshlp.hxx>
      38             : #include <cppuhelper/basemutex.hxx>
      39             : #include <com/sun/star/graphic/XGraphic.hpp>
      40             : #include <com/sun/star/awt/tab/XTabPageModel.hpp>
      41             : #include <com/sun/star/uno/XComponentContext.hpp>
      42             : #include <com/sun/star/lang/XInitialization.hpp>
      43             : #include <tools/gen.hxx>
      44             : 
      45             : //  class ControlModelContainerBase
      46             : 
      47             : typedef UnoControlModel     ControlModel_Base;
      48             : typedef ::cppu::AggImplInheritanceHelper8   <   ControlModel_Base
      49             :                             ,   ::com::sun::star::lang::XMultiServiceFactory
      50             :                             ,   ::com::sun::star::container::XContainer
      51             :                             ,   ::com::sun::star::container::XNameContainer
      52             :                             ,   ::com::sun::star::awt::XTabControllerModel
      53             :                             ,   ::com::sun::star::util::XChangesNotifier
      54             :                             ,   ::com::sun::star::beans::XPropertyChangeListener
      55             :                             ,   ::com::sun::star::awt::tab::XTabPageModel
      56             :                             ,   ::com::sun::star::lang::XInitialization
      57             :                             >   ControlModelContainer_IBase;
      58             : 
      59             : class ControlModelContainerBase :   public ControlModelContainer_IBase
      60             : {
      61             : public:
      62             :     enum ChildOperation { Insert = 0, Remove };
      63             :     // would like to make this typedef private, too, but the Forte 7 compiler does have
      64             :     // problems with this .....
      65             :     typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >, OUString >
      66             :                                                         UnoControlModelHolder;
      67             : private:
      68             :     typedef ::std::list< UnoControlModelHolder >        UnoControlModelHolderList;
      69             : 
      70             : public:
      71             :     // for grouping control models (XTabControllerModel::getGroupXXX)
      72             :     typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >
      73             :                                                         ModelGroup;
      74             :     typedef ::std::vector< ModelGroup >                 AllGroups;
      75             : 
      76             :     friend struct CloneControlModel;
      77             :     friend struct FindControlModel;
      78             :     friend struct CompareControlModel;
      79             : 
      80             : protected:
      81             :     ContainerListenerMultiplexer        maContainerListeners;
      82             :     ::cppu::OInterfaceContainerHelper   maChangeListeners;
      83             :     UnoControlModelHolderList           maModels;
      84             : 
      85             :     AllGroups                           maGroups;
      86             :     bool                            mbGroupsUpToDate;
      87             : 
      88             :     bool                         m_bEnabled;
      89             :     OUString                         m_sImageURL;
      90             :     OUString                         m_sTooltip;
      91             :     sal_Int16                        m_nTabPageId;
      92             : 
      93             :     void    Clone_Impl(ControlModelContainerBase& _rClone) const;
      94             : protected:
      95             :     ::com::sun::star::uno::Any          ImplGetDefaultValue( sal_uInt16 nPropId ) const SAL_OVERRIDE;
      96             :     ::cppu::IPropertyArrayHelper&       SAL_CALL getInfoHelper() SAL_OVERRIDE;
      97             : 
      98             :     UnoControlModelHolderList::iterator         ImplFindElement( const OUString& rName );
      99             : 
     100             :     void updateUserFormChildren(  const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xAllChildren, const 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);
     101             : public:
     102             :                         ControlModelContainerBase( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
     103             :                         ControlModelContainerBase( const ControlModelContainerBase& rModel );
     104             :                         virtual ~ControlModelContainerBase();
     105             : 
     106             :     UnoControlModel*    Clone() const SAL_OVERRIDE;
     107             : 
     108             :     // ::com::sun::star::container::XContainer
     109             :     void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     110             :     void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     111             : 
     112             :     // ::com::sun::star::container::XElementAcces
     113             :     ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     114             :     sal_Bool SAL_CALL hasElements(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     115             : 
     116             :     // ::com::sun::star::container::XNameContainer, XNameReplace, XNameAccess
     117             :     void SAL_CALL replaceByName( const 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, std::exception) SAL_OVERRIDE;
     118             :     ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     119             :     ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     120             :     sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     121             :     void SAL_CALL insertByName( const 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, std::exception) SAL_OVERRIDE;
     122             :     void SAL_CALL removeByName( const OUString& Name ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     123             : 
     124             :     // ::com::sun::star::beans::XMultiPropertySet
     125             :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     126             : 
     127             :     // ::com::sun::star::lang::XMultiServiceFactory
     128             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     129             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const 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, std::exception) SAL_OVERRIDE;
     130             :     ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     131             : 
     132             :     // XComponent
     133             :     void SAL_CALL dispose(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     134             : 
     135             :     // XTabControllerModel
     136             :     virtual sal_Bool SAL_CALL getGroupControl(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     137             :     virtual void SAL_CALL setGroupControl( sal_Bool GroupControl ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     138             :     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, std::exception) SAL_OVERRIDE;
     139             :     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, std::exception) SAL_OVERRIDE;
     140             :     virtual void SAL_CALL setGroup( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group, const OUString& GroupName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     141             :     virtual sal_Int32 SAL_CALL getGroupCount(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     142             :     virtual void SAL_CALL getGroup( sal_Int32 nGroup, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group, OUString& Name ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     143             :     virtual void SAL_CALL getGroupByName( const OUString& Name, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     144             : 
     145             :     // XChangesNotifier
     146             :     virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     147             :     virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     148             : 
     149             :     // XPropertyChangeListener
     150             :     virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     151             : 
     152             :     // XEventListener
     153             :     using cppu::OPropertySetHelper::disposing;
     154             :     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& evt ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     155             : 
     156             :     // XServiceInfo
     157          10 :     DECLIMPL_SERVICEINFO_DERIVED(ControlModelContainerBase, ControlModel_Base, "toolkit.ControlModelContainerBase" )
     158             : 
     159             :     // XInitialization
     160             :     virtual void SAL_CALL initialize (const com::sun::star::uno::Sequence<com::sun::star::uno::Any>& rArguments)
     161             :             throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     162             : 
     163             :     // ::com::sun::star::awt::tab::XTabPageModel
     164             :     virtual ::sal_Int16 SAL_CALL getTabPageID() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     165             :     virtual sal_Bool SAL_CALL getEnabled() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     166             :     virtual void SAL_CALL setEnabled( sal_Bool _enabled ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     167             :     virtual OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     168             :     virtual void SAL_CALL setTitle( const OUString& _title ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     169             :     virtual OUString SAL_CALL getImageURL() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     170             :     virtual void SAL_CALL setImageURL( const OUString& _imageurl ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     171             :     virtual OUString SAL_CALL getToolTip() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     172             :     virtual void SAL_CALL setToolTip( const OUString& _tooltip ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     173             : 
     174             : protected:
     175             :     void startControlListening( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxChildModel );
     176             :     void stopControlListening( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxChildModel );
     177             : 
     178             :     void implNotifyTabModelChange( const OUString& _rAccessor );
     179             : 
     180             :     void implUpdateGroupStructure();
     181             : };
     182             : 
     183             : class ResourceListener  :public ::com::sun::star::util::XModifyListener,
     184             :                          public ::cppu::OWeakObject,
     185             :                          public ::cppu::BaseMutex
     186             : {
     187             :     public:
     188             :         ResourceListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& xListener );
     189             :         virtual ~ResourceListener();
     190             : 
     191             :         void startListening( const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver  >& rResource );
     192             :         void stopListening();
     193             : 
     194             :         // XInterface
     195             :         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     196             :         virtual void SAL_CALL acquire() throw () SAL_OVERRIDE;
     197             :         virtual void SAL_CALL release() throw () SAL_OVERRIDE;
     198             : 
     199             :         // XModifyListener
     200             :         virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     201             : 
     202             :         // XEventListener
     203             :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     204             : 
     205             :     private:
     206             :         ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver > m_xResource;
     207             :         ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >             m_xListener;
     208             :         bool                                                                                    m_bListening;
     209             : };
     210             : 
     211             : typedef ::cppu::AggImplInheritanceHelper3   < UnoControlContainer
     212             :                             ,   ::com::sun::star::container::XContainerListener
     213             :                             ,   ::com::sun::star::util::XChangesListener
     214             :                             ,   ::com::sun::star::util::XModifyListener
     215             :                             >   ContainerControl_IBase;
     216             : 
     217             : class ControlContainerBase : public ContainerControl_IBase
     218             : {
     219             :     ::Size ImplGetSizePixel( const ::Size& inSize );
     220             : protected:
     221             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >  m_xContext;
     222             :     bool                                                                        mbSizeModified;
     223             :     bool                                                                        mbPosModified;
     224             :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController >   mxTabController;
     225             :     ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > mxListener;
     226             : 
     227             :     void        ImplInsertControl( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel, const OUString& rName );
     228             :     void        ImplRemoveControl( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel );
     229             :     virtual void        ImplSetPosSize( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& rxCtrl );
     230             :     void        ImplUpdateResourceResolver();
     231             :     void        ImplStartListingForResourceEvents();
     232             : 
     233             : #ifdef _MSC_VER
     234             :     // just implemented to let the various FooImplInheritanceHelper compile
     235             :     ControlContainerBase();
     236             : #endif
     237             : 
     238             : public:
     239             :     ControlContainerBase( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
     240             :     virtual ~ControlContainerBase();
     241             : 
     242           0 :     DECLIMPL_SERVICEINFO_DERIVED( ControlContainerBase, UnoControlBase, "toolkit.ControlContainerBase" )
     243             : 
     244             :     void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     245             :     void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     246             : 
     247             :     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, std::exception) SAL_OVERRIDE;
     248             : 
     249             :     // ::com::sun::star::container::XContainerListener
     250             :     void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     251             :     void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     252             :     void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     253             : 
     254             :     // XChangesListener
     255             :     virtual void SAL_CALL changesOccurred( const ::com::sun::star::util::ChangesEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     256             : 
     257             :     // ::com::sun::star::awt::XControl
     258             :     sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& Model ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     259             :     void SAL_CALL setDesignMode( sal_Bool bOn ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     260             :     // XModifyListener
     261             :     // Using a dummy/no-op implementation here, not sure if every container control needs
     262             :     // to implement this, certainly Dialog does, lets see about others
     263           0 :     virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE {}
     264             : protected:
     265             :     virtual void ImplModelPropertiesChanged( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& rEvents ) throw(::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
     266             :     virtual void removingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ) SAL_OVERRIDE;
     267             :     virtual void addingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ) SAL_OVERRIDE;
     268             : };
     269             : #endif
     270             : 
     271             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11