LCOV - code coverage report
Current view: top level - libreoffice/framework/inc/uiconfiguration - uiconfigurationmanager.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 8 37.5 %
Date: 2012-12-27 Functions: 2 9 22.2 %
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 __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGER_HXX_
      21             : #define __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGER_HXX_
      22             : 
      23             : 
      24             : /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
      25             :                with solaris headers ...
      26             : */
      27             : #include <vector>
      28             : #include <list>
      29             : #include <boost/unordered_map.hpp>
      30             : 
      31             : #include <threadhelp/threadhelpbase.hxx>
      32             : #include <macros/generic.hxx>
      33             : #include <macros/xinterface.hxx>
      34             : #include <macros/xtypeprovider.hxx>
      35             : #include <macros/xserviceinfo.hxx>
      36             : #include <stdtypes.h>
      37             : #include <uiconfiguration/imagemanager.hxx>
      38             : 
      39             : #include <com/sun/star/lang/XServiceInfo.hpp>
      40             : #include <com/sun/star/lang/XTypeProvider.hpp>
      41             : #include <com/sun/star/lang/XComponent.hpp>
      42             : #include <com/sun/star/ui/XUIConfiguration.hpp>
      43             : #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
      44             : 
      45             : #include <com/sun/star/ui/XUIConfigurationStorage.hpp>
      46             : #include <com/sun/star/ui/XUIConfigurationManager.hpp>
      47             : #include <com/sun/star/ui/ConfigurationEvent.hpp>
      48             : #include <com/sun/star/ui/UIElementType.hpp>
      49             : #include <com/sun/star/container/XIndexContainer.hpp>
      50             : 
      51             : #include <cppuhelper/weak.hxx>
      52             : #include <cppuhelper/interfacecontainer.hxx>
      53             : #include <rtl/ustring.hxx>
      54             : 
      55             : 
      56             : namespace framework
      57             : {
      58             :     class UIConfigurationManager :   public com::sun::star::lang::XTypeProvider ,
      59             :                                      public com::sun::star::lang::XServiceInfo  ,
      60             :                                      public com::sun::star::lang::XComponent    ,
      61             :                                      public ::com::sun::star::ui::XUIConfiguration             ,
      62             :                                      public ::com::sun::star::ui::XUIConfigurationManager      ,
      63             :                                      public ::com::sun::star::ui::XUIConfigurationPersistence  ,
      64             :                                      public ::com::sun::star::ui::XUIConfigurationStorage      ,
      65             :                                      private ThreadHelpBase                     ,   // Struct for right initalization of mutex member! Must be first of baseclasses.
      66             :                                      public ::cppu::OWeakObject
      67             :     {
      68             :         public:
      69             :             //  XInterface, XTypeProvider, XServiceInfo
      70             :             FWK_DECLARE_XINTERFACE
      71             :             FWK_DECLARE_XTYPEPROVIDER
      72             :             DECLARE_XSERVICEINFO
      73             : 
      74             :             UIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager );
      75             :             virtual ~UIConfigurationManager();
      76             : 
      77             :             // XComponent
      78             :             virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
      79             :             virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
      80             :             virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
      81             : 
      82             :             // XUIConfiguration
      83             :             virtual void SAL_CALL addConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
      84             :             virtual void SAL_CALL removeConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
      85             : 
      86             :             // XUIConfigurationManager
      87             :             virtual void SAL_CALL reset() throw (::com::sun::star::uno::RuntimeException);
      88             :             virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getUIElementsInfo( sal_Int16 ElementType ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
      89             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > SAL_CALL createSettings(  ) throw (::com::sun::star::uno::RuntimeException);
      90             :             virtual sal_Bool SAL_CALL hasSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
      91             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getSettings( const ::rtl::OUString& ResourceURL, sal_Bool bWriteable ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
      92             :             virtual void SAL_CALL replaceSettings( const ::rtl::OUString& ResourceURL, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& aNewData ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
      93             :             virtual void SAL_CALL removeSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
      94             :             virtual void SAL_CALL insertSettings( const ::rtl::OUString& NewResourceURL, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& aNewData ) throw (::com::sun::star::container::ElementExistException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
      95             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getImageManager() throw (::com::sun::star::uno::RuntimeException);
      96             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getShortCutManager() throw (::com::sun::star::uno::RuntimeException);
      97             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getEventsManager() throw (::com::sun::star::uno::RuntimeException);
      98             : 
      99             :             // XUIConfigurationPersistence
     100             :             virtual void SAL_CALL reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     101             :             virtual void SAL_CALL store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     102             :             virtual void SAL_CALL storeToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     103             :             virtual sal_Bool SAL_CALL isModified() throw (::com::sun::star::uno::RuntimeException);
     104             :             virtual sal_Bool SAL_CALL isReadOnly() throw (::com::sun::star::uno::RuntimeException);
     105             : 
     106             :             // XUIConfigurationStorage
     107             :             virtual void SAL_CALL setStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage ) throw (::com::sun::star::uno::RuntimeException);
     108             :             virtual sal_Bool SAL_CALL hasStorage() throw (::com::sun::star::uno::RuntimeException);
     109             : 
     110             :         private:
     111             :             // private data types
     112             :             enum NotifyOp
     113             :             {
     114             :                 NotifyOp_Remove,
     115             :                 NotifyOp_Insert,
     116             :                 NotifyOp_Replace
     117             :             };
     118             : 
     119           0 :             struct UIElementInfo
     120             :             {
     121           0 :                 UIElementInfo( const rtl::OUString& rResourceURL, const rtl::OUString& rUIName ) :
     122           0 :                     aResourceURL( rResourceURL), aUIName( rUIName ) {}
     123             :                 rtl::OUString   aResourceURL;
     124             :                 rtl::OUString   aUIName;
     125             :             };
     126             : 
     127           0 :             struct UIElementData
     128             :             {
     129           0 :                 UIElementData() : bModified( false ), bDefault( true ) {};
     130             : 
     131             :                 rtl::OUString aResourceURL;
     132             :                 rtl::OUString aName;
     133             :                 bool          bModified;        // has been changed since last storing
     134             :                 bool          bDefault;         // default settings
     135             :                 com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > xSettings;
     136             :             };
     137             : 
     138             :             struct UIElementType;
     139             :             friend struct UIElementType;
     140             :             typedef ::boost::unordered_map< rtl::OUString, UIElementData, OUStringHashCode, ::std::equal_to< rtl::OUString > > UIElementDataHashMap;
     141             : 
     142        1320 :             struct UIElementType
     143             :             {
     144        3064 :                 UIElementType() : bModified( false ),
     145             :                                   bLoaded( false ),
     146             :                                   bDefaultLayer( false ),
     147        3064 :                                   nElementType( ::com::sun::star::ui::UIElementType::UNKNOWN ) {}
     148             : 
     149             : 
     150             :                 bool                                                              bModified;
     151             :                 bool                                                              bLoaded;
     152             :                 bool                                                              bDefaultLayer;
     153             :                 sal_Int16                                                         nElementType;
     154             :                 UIElementDataHashMap                                              aElementsHashMap;
     155             :                 com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage;
     156             :             };
     157             : 
     158             :             typedef ::std::vector< UIElementType > UIElementTypesVector;
     159             :             typedef ::std::vector< ::com::sun::star::ui::ConfigurationEvent > ConfigEventNotifyContainer;
     160             :             typedef ::boost::unordered_map< rtl::OUString, UIElementInfo, OUStringHashCode, ::std::equal_to< rtl::OUString > > UIElementInfoHashMap;
     161             : 
     162             :             // private methods
     163             :             void            impl_Initialize();
     164             :             void            implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent& aEvent, NotifyOp eOp );
     165             :             void            impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType );
     166             :             void            impl_preloadUIElementTypeList( sal_Int16 nElementType );
     167             :             UIElementData*  impl_findUIElementData( const rtl::OUString& aResourceURL, sal_Int16 nElementType, bool bLoad = true );
     168             :             void            impl_requestUIElementData( sal_Int16 nElementType, UIElementData& aUIElementData );
     169             :             void            impl_storeElementTypeData( com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xStorage, UIElementType& rElementType, bool bResetModifyState = true );
     170             :             void            impl_resetElementTypeData( UIElementType& rDocElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer );
     171             :             void            impl_reloadElementTypeData( UIElementType& rDocElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer );
     172             : 
     173             :             UIElementTypesVector                                                            m_aUIElements;
     174             :             com::sun::star::uno::Reference< com::sun::star::embed::XStorage >               m_xDocConfigStorage;
     175             :             bool                                                                            m_bReadOnly;
     176             :             bool                                                                            m_bModified;
     177             :             bool                                                                            m_bConfigRead;
     178             :             bool                                                                            m_bDisposed;
     179             :             rtl::OUString                                                                   m_aXMLPostfix;
     180             :             rtl::OUString                                                                   m_aPropUIName;
     181             :             rtl::OUString                                                                   m_aPropResourceURL;
     182             :             rtl::OUString                                                                   m_aModuleIdentifier;
     183             :             com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >    m_xServiceManager;
     184             :             ::cppu::OMultiTypeInterfaceContainerHelper                                      m_aListenerContainer;   /// container for ALL Listener
     185             :             com::sun::star::uno::Reference< com::sun::star::lang::XComponent >              m_xImageManager;
     186             :             com::sun::star::uno::Reference< com::sun::star::uno::XInterface >               m_xAccConfig;
     187             :    };
     188             : }
     189             : 
     190             : #endif // __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGER_HXX_
     191             : 
     192             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10