LCOV - code coverage report
Current view: top level - include/toolkit/controls - controlmodelcontainerbase.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 3 0.0 %
Date: 2014-04-14 Functions: 0 5 0.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/awt/XTabControllerModel.hpp>
      26             : #include <com/sun/star/util/XChangesNotifier.hpp>
      27             : #include <com/sun/star/util/XChangesListener.hpp>
      28             : #include <com/sun/star/util/XModifyListener.hpp>
      29             : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
      30             : #include <com/sun/star/resource/XStringResourceResolver.hpp>
      31             : #include <cppuhelper/implbase8.hxx>
      32             : #include <cppuhelper/implbase3.hxx>
      33             : #include <toolkit/helper/listenermultiplexer.hxx>
      34             : #include <toolkit/controls/unocontrolmodel.hxx>
      35             : #include <toolkit/controls/unocontrolcontainer.hxx>
      36             : #include <cppuhelper/propshlp.hxx>
      37             : #include <cppuhelper/basemutex.hxx>
      38             : #include <com/sun/star/graphic/XGraphic.hpp>
      39             : #include <com/sun/star/awt/tab/XTabPageModel.hpp>
      40             : #include <com/sun/star/uno/XComponentContext.hpp>
      41             : #include <com/sun/star/lang/XInitialization.hpp>
      42             : #include <tools/gen.hxx>
      43             : 
      44             : //  class ControlModelContainerBase
      45             : 
      46             : typedef UnoControlModel     ControlModel_Base;
      47             : typedef ::cppu::AggImplInheritanceHelper8   <   ControlModel_Base
      48             :                             ,   ::com::sun::star::lang::XMultiServiceFactory
      49             :                             ,   ::com::sun::star::container::XContainer
      50             :                             ,   ::com::sun::star::container::XNameContainer
      51             :                             ,   ::com::sun::star::awt::XTabControllerModel
      52             :                             ,   ::com::sun::star::util::XChangesNotifier
      53             :                             ,   ::com::sun::star::beans::XPropertyChangeListener
      54             :                             ,   ::com::sun::star::awt::tab::XTabPageModel
      55             :                             ,   ::com::sun::star::lang::XInitialization
      56             :                             >   ControlModelContainer_IBase;
      57             : 
      58             : class ControlModelContainerBase :   public ControlModelContainer_IBase
      59             : {
      60             : public:
      61             :     enum ChildOperation { Insert = 0, Remove };
      62             :     // would like to make this typedef private, too, but the Forte 7 compiler does have
      63             :     // problems with this .....
      64             :     typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >, OUString >
      65             :                                                         UnoControlModelHolder;
      66             : private:
      67             :     typedef ::std::list< UnoControlModelHolder >        UnoControlModelHolderList;
      68             : 
      69             : public:
      70             :     // for grouping control models (XTabControllerModel::getGroupXXX)
      71             :     typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >
      72             :                                                         ModelGroup;
      73             :     typedef ::std::vector< ModelGroup >                 AllGroups;
      74             : 
      75             :     friend struct CloneControlModel;
      76             :     friend struct FindControlModel;
      77             :     friend struct CompareControlModel;
      78             : 
      79             : protected:
      80             :     ContainerListenerMultiplexer        maContainerListeners;
      81             :     ::cppu::OInterfaceContainerHelper   maChangeListeners;
      82             :     UnoControlModelHolderList           maModels;
      83             : 
      84             :     AllGroups                           maGroups;
      85             :     bool                            mbGroupsUpToDate;
      86             : 
      87             :     bool                         m_bEnabled;
      88             :     OUString                         m_sImageURL;
      89             :     OUString                         m_sTooltip;
      90             :     sal_Int16                        m_nTabPageId;
      91             : 
      92             :     void    Clone_Impl(ControlModelContainerBase& _rClone) const;
      93             : protected:
      94             :     ::com::sun::star::uno::Any          ImplGetDefaultValue( sal_uInt16 nPropId ) const SAL_OVERRIDE;
      95             :     ::cppu::IPropertyArrayHelper&       SAL_CALL getInfoHelper() SAL_OVERRIDE;
      96             : 
      97             :     UnoControlModelHolderList::iterator         ImplFindElement( const OUString& rName );
      98             : 
      99             :     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);
     100             : public:
     101             :                         ControlModelContainerBase( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
     102             :                         ControlModelContainerBase( const ControlModelContainerBase& rModel );
     103             :                         virtual ~ControlModelContainerBase();
     104             : 
     105             :     UnoControlModel*    Clone() const SAL_OVERRIDE;
     106             : 
     107             :     // ::com::sun::star::container::XContainer
     108             :     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;
     109             :     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;
     110             : 
     111             :     // ::com::sun::star::container::XElementAcces
     112             :     ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     113             :     sal_Bool SAL_CALL hasElements(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     114             : 
     115             :     // ::com::sun::star::container::XNameContainer, XNameReplace, XNameAccess
     116             :     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;
     117             :     ::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;
     118             :     ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     119             :     sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     120             :     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;
     121             :     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;
     122             : 
     123             :     // ::com::sun::star::beans::XMultiPropertySet
     124             :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     125             : 
     126             :     // ::com::sun::star::lang::XMultiServiceFactory
     127             :     ::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;
     128             :     ::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;
     129             :     ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     130             : 
     131             :     // XComponent
     132             :     void SAL_CALL dispose(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     133             : 
     134             :     // XTabControllerModel
     135             :     virtual sal_Bool SAL_CALL getGroupControl(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     136             :     virtual void SAL_CALL setGroupControl( sal_Bool GroupControl ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     137             :     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;
     138             :     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;
     139             :     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;
     140             :     virtual sal_Int32 SAL_CALL getGroupCount(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     141             :     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;
     142             :     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;
     143             : 
     144             :     // XChangesNotifier
     145             :     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;
     146             :     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;
     147             : 
     148             :     // XPropertyChangeListener
     149             :     virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     150             : 
     151             :     // XEventListener
     152             :     using cppu::OPropertySetHelper::disposing;
     153             :     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& evt ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     154             : 
     155             :     // XServiceInfo
     156           0 :     DECLIMPL_SERVICEINFO_DERIVED(ControlModelContainerBase, ControlModel_Base, "toolkit.ControlModelContainerBase" )
     157             : 
     158             :     // XInitialization
     159             :     virtual void SAL_CALL initialize (const com::sun::star::uno::Sequence<com::sun::star::uno::Any>& rArguments)
     160             :             throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     161             : 
     162             :     // ::com::sun::star::awt::tab::XTabPageModel
     163             :     virtual ::sal_Int16 SAL_CALL getTabPageID() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     164             :     virtual sal_Bool SAL_CALL getEnabled() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     165             :     virtual void SAL_CALL setEnabled( sal_Bool _enabled ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     166             :     virtual OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     167             :     virtual void SAL_CALL setTitle( const OUString& _title ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     168             :     virtual OUString SAL_CALL getImageURL() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     169             :     virtual void SAL_CALL setImageURL( const OUString& _imageurl ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     170             :     virtual OUString SAL_CALL getToolTip() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     171             :     virtual void SAL_CALL setToolTip( const OUString& _tooltip ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     172             : 
     173             : protected:
     174             :     void startControlListening( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxChildModel );
     175             :     void stopControlListening( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxChildModel );
     176             : 
     177             :     void implNotifyTabModelChange( const OUString& _rAccessor );
     178             : 
     179             :     void implUpdateGroupStructure();
     180             : };
     181             : 
     182             : class ResourceListener  :public ::com::sun::star::util::XModifyListener,
     183             :                          public ::cppu::OWeakObject,
     184             :                          public ::cppu::BaseMutex
     185             : {
     186             :     public:
     187             :         ResourceListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& xListener );
     188             :         virtual ~ResourceListener();
     189             : 
     190             :         void startListening( const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver  >& rResource );
     191             :         void stopListening();
     192             : 
     193             :         // XInterface
     194             :         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;
     195             :         virtual void SAL_CALL acquire() throw () SAL_OVERRIDE;
     196             :         virtual void SAL_CALL release() throw () SAL_OVERRIDE;
     197             : 
     198             :         // XModifyListener
     199             :         virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     200             : 
     201             :         // XEventListener
     202             :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     203             : 
     204             :     private:
     205             :         ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver > m_xResource;
     206             :         ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >             m_xListener;
     207             :         bool                                                                                    m_bListening;
     208             : };
     209             : 
     210             : typedef ::cppu::AggImplInheritanceHelper3   < UnoControlContainer
     211             :                             ,   ::com::sun::star::container::XContainerListener
     212             :                             ,   ::com::sun::star::util::XChangesListener
     213             :                             ,   ::com::sun::star::util::XModifyListener
     214             :                             >   ContainerControl_IBase;
     215             : 
     216             : class ControlContainerBase : public ContainerControl_IBase
     217             : {
     218             :     ::Size ImplGetSizePixel( const ::Size& inSize );
     219             : protected:
     220             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >  m_xContext;
     221             :     bool                                                                        mbSizeModified;
     222             :     bool                                                                        mbPosModified;
     223             :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController >   mxTabController;
     224             :     ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > mxListener;
     225             : 
     226             :     void        ImplInsertControl( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel, const OUString& rName );
     227             :     void        ImplRemoveControl( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel );
     228             :     virtual void        ImplSetPosSize( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& rxCtrl );
     229             :     void        ImplUpdateResourceResolver();
     230             :     void        ImplStartListingForResourceEvents();
     231             : 
     232             : #ifdef _MSC_VER
     233             :     // just implemented to let the various FooImplInheritanceHelper compile
     234             :     ControlContainerBase();
     235             : #endif
     236             : 
     237             : public:
     238             :     ControlContainerBase( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
     239             :     virtual ~ControlContainerBase();
     240             : 
     241           0 :     DECLIMPL_SERVICEINFO_DERIVED( ControlContainerBase, UnoControlBase, "toolkit.ControlContainerBase" )
     242             : 
     243             :     void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     244             :     void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     245             : 
     246             :     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;
     247             : 
     248             :     // ::com::sun::star::container::XContainerListener
     249             :     void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     250             :     void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     251             :     void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     252             : 
     253             :     // XChangesListener
     254             :     virtual void SAL_CALL changesOccurred( const ::com::sun::star::util::ChangesEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     255             : 
     256             :     // ::com::sun::star::awt::XControl
     257             :     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;
     258             :     void SAL_CALL setDesignMode( sal_Bool bOn ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     259             :     // XModifyListener
     260             :     // Using a dummy/no-op implementation here, not sure if every container control needs
     261             :     // to implement this, certainly Dialog does, lets see about others
     262           0 :     virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE {}
     263             : protected:
     264             :     virtual void ImplModelPropertiesChanged( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& rEvents ) throw(::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
     265             :     virtual void removingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ) SAL_OVERRIDE;
     266             :     virtual void addingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ) SAL_OVERRIDE;
     267             : };
     268             : #endif
     269             : 
     270             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10