LCOV - code coverage report
Current view: top level - libreoffice/framework/inc/uiconfiguration - moduleuiconfigurationmanager.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 8 37.5 %
Date: 2012-12-27 Functions: 2 10 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 __FRAMEWORK_UICONFIGURATION_MODULEUICONFIGMANAGER_HXX_
      21             : #define __FRAMEWORK_UICONFIGURATION_MODULEUICONFIGMANAGER_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 <accelerators/presethandler.hxx>
      32             : #include <threadhelp/threadhelpbase.hxx>
      33             : #include <macros/generic.hxx>
      34             : #include <macros/xinterface.hxx>
      35             : #include <macros/xtypeprovider.hxx>
      36             : #include <macros/xserviceinfo.hxx>
      37             : #include <stdtypes.h>
      38             : #include <uiconfiguration/moduleimagemanager.hxx>
      39             : 
      40             : #include <com/sun/star/lang/XServiceInfo.hpp>
      41             : #include <com/sun/star/lang/XTypeProvider.hpp>
      42             : #include <com/sun/star/lang/XComponent.hpp>
      43             : #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
      44             : #include <com/sun/star/ui/XUIConfiguration.hpp>
      45             : #include <com/sun/star/ui/XUIConfigurationManager.hpp>
      46             : #include <com/sun/star/ui/XModuleUIConfigurationManager.hpp>
      47             : #include <com/sun/star/ui/UIElementType.hpp>
      48             : #include <com/sun/star/lang/XInitialization.hpp>
      49             : #include <com/sun/star/ui/ConfigurationEvent.hpp>
      50             : #include <com/sun/star/embed/XTransactedObject.hpp>
      51             : #include <com/sun/star/container/XIndexContainer.hpp>
      52             : 
      53             : #include <cppuhelper/weak.hxx>
      54             : #include <cppuhelper/interfacecontainer.hxx>
      55             : #include <rtl/ustring.hxx>
      56             : 
      57             : 
      58             : namespace framework
      59             : {
      60             :     class ModuleUIConfigurationManager :   public com::sun::star::lang::XTypeProvider                       ,
      61             :                                            public com::sun::star::lang::XServiceInfo                        ,
      62             :                                            public com::sun::star::lang::XComponent                          ,
      63             :                                            public com::sun::star::lang::XInitialization                     ,
      64             :                                            public ::com::sun::star::ui::XUIConfiguration              ,
      65             :                                            public ::com::sun::star::ui::XUIConfigurationManager       ,
      66             :                                            public ::com::sun::star::ui::XModuleUIConfigurationManager ,
      67             :                                            public ::com::sun::star::ui::XUIConfigurationPersistence   ,
      68             :                                            private ThreadHelpBase                       ,   // Struct for right initalization of mutex member! Must be first of baseclasses.
      69             :                                            public ::cppu::OWeakObject
      70             :     {
      71             :         public:
      72             :             //  XInterface, XTypeProvider, XServiceInfo
      73             :             FWK_DECLARE_XINTERFACE
      74             :             FWK_DECLARE_XTYPEPROVIDER
      75             :             DECLARE_XSERVICEINFO
      76             : 
      77             :             ModuleUIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager );
      78             :             virtual ~ModuleUIConfigurationManager();
      79             : 
      80             :             // XComponent
      81             :             virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
      82             :             virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
      83             :             virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
      84             : 
      85             :             // XInitialization
      86             :             virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
      87             : 
      88             :             // XUIConfiguration
      89             :             virtual void SAL_CALL addConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
      90             :             virtual void SAL_CALL removeConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
      91             : 
      92             :             // XUIConfigurationManager
      93             :             virtual void SAL_CALL reset() throw (::com::sun::star::uno::RuntimeException);
      94             :             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);
      95             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > SAL_CALL createSettings(  ) throw (::com::sun::star::uno::RuntimeException);
      96             :             virtual sal_Bool SAL_CALL hasSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
      97             :             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);
      98             :             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);
      99             :             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);
     100             :             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);
     101             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getImageManager() throw (::com::sun::star::uno::RuntimeException);
     102             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getShortCutManager() throw (::com::sun::star::uno::RuntimeException);
     103             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getEventsManager() throw (::com::sun::star::uno::RuntimeException);
     104             : 
     105             :             // XModuleUIConfigurationManager
     106             :             virtual sal_Bool SAL_CALL isDefaultSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     107             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getDefaultSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     108             : 
     109             :             // XUIConfigurationPersistence
     110             :             virtual void SAL_CALL reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     111             :             virtual void SAL_CALL store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     112             :             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);
     113             :             virtual sal_Bool SAL_CALL isModified() throw (::com::sun::star::uno::RuntimeException);
     114             :             virtual sal_Bool SAL_CALL isReadOnly() throw (::com::sun::star::uno::RuntimeException);
     115             : 
     116             :         private:
     117             :             // private data types
     118             :             enum Layer
     119             :             {
     120             :                 LAYER_DEFAULT,
     121             :                 LAYER_USERDEFINED,
     122             :                 LAYER_COUNT
     123             :             };
     124             : 
     125             :             enum NotifyOp
     126             :             {
     127             :                 NotifyOp_Remove,
     128             :                 NotifyOp_Insert,
     129             :                 NotifyOp_Replace
     130             :             };
     131             : 
     132           0 :             struct UIElementInfo
     133             :             {
     134           0 :                 UIElementInfo( const rtl::OUString& rResourceURL, const rtl::OUString& rUIName ) :
     135           0 :                     aResourceURL( rResourceURL), aUIName( rUIName ) {}
     136             :                 rtl::OUString   aResourceURL;
     137             :                 rtl::OUString   aUIName;
     138             :             };
     139             : 
     140           0 :             struct UIElementData
     141             :             {
     142           0 :                 UIElementData() : bModified( false ), bDefault( true ), bDefaultNode( true ) {};
     143             : 
     144             :                 rtl::OUString aResourceURL;
     145             :                 rtl::OUString aName;
     146             :                 bool          bModified;        // has been changed since last storing
     147             :                 bool          bDefault;         // default settings
     148             :                 bool          bDefaultNode;     // this is a default layer element data
     149             :                 com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > xSettings;
     150             :             };
     151             : 
     152             :             struct UIElementType;
     153             :             friend struct UIElementType;
     154             :             typedef ::boost::unordered_map< rtl::OUString, UIElementData, OUStringHashCode, ::std::equal_to< rtl::OUString > > UIElementDataHashMap;
     155             : 
     156         128 :             struct UIElementType
     157             :             {
     158         128 :                 UIElementType() : bModified( false ),
     159             :                                   bLoaded( false ),
     160             :                                   bDefaultLayer( false ),
     161         128 :                                   nElementType( ::com::sun::star::ui::UIElementType::UNKNOWN ) {}
     162             : 
     163             : 
     164             :                 bool                                                              bModified;
     165             :                 bool                                                              bLoaded;
     166             :                 bool                                                              bDefaultLayer;
     167             :                 sal_Int16                                                         nElementType;
     168             :                 UIElementDataHashMap                                              aElementsHashMap;
     169             :                 com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage;
     170             :             };
     171             : 
     172             :             typedef ::std::vector< UIElementType > UIElementTypesVector;
     173             :             typedef ::std::vector< ::com::sun::star::ui::ConfigurationEvent > ConfigEventNotifyContainer;
     174             :             typedef ::boost::unordered_map< rtl::OUString, UIElementInfo, OUStringHashCode, ::std::equal_to< rtl::OUString > > UIElementInfoHashMap;
     175             : 
     176             :             // private methods
     177             :             void            impl_Initialize();
     178             :             void            implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent& aEvent, NotifyOp eOp );
     179             :             void            impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType );
     180             :             void            impl_preloadUIElementTypeList( Layer eLayer, sal_Int16 nElementType );
     181             :             UIElementData*  impl_findUIElementData( const rtl::OUString& aResourceURL, sal_Int16 nElementType, bool bLoad = true );
     182             :             void            impl_requestUIElementData( sal_Int16 nElementType, Layer eLayer, UIElementData& aUIElementData );
     183             :             void            impl_storeElementTypeData( com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage, UIElementType& rElementType, bool bResetModifyState = true );
     184             :             void            impl_resetElementTypeData( UIElementType& rUserElementType, UIElementType& rDefaultElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer );
     185             :             void            impl_reloadElementTypeData( UIElementType& rUserElementType, UIElementType& rDefaultElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer );
     186             : 
     187             :             UIElementTypesVector                                                            m_aUIElements[LAYER_COUNT];
     188             :             PresetHandler*                                                                  m_pStorageHandler[::com::sun::star::ui::UIElementType::COUNT];
     189             :             com::sun::star::uno::Reference< com::sun::star::embed::XStorage >               m_xDefaultConfigStorage;
     190             :             com::sun::star::uno::Reference< com::sun::star::embed::XStorage >               m_xUserConfigStorage;
     191             :             bool                                                                            m_bReadOnly;
     192             :             bool                                                                            m_bInitialized;
     193             :             bool                                                                            m_bModified;
     194             :             bool                                                                            m_bConfigRead;
     195             :             bool                                                                            m_bDisposed;
     196             :             rtl::OUString                                                                   m_aXMLPostfix;
     197             :             rtl::OUString                                                                   m_aPropUIName;
     198             :             rtl::OUString                                                                   m_aPropResourceURL;
     199             :             rtl::OUString                                                                   m_aModuleIdentifier;
     200             :             rtl::OUString                                                                   m_aModuleShortName;
     201             :             com::sun::star::uno::Reference< com::sun::star::embed::XTransactedObject >      m_xUserRootCommit;
     202             :             com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >    m_xServiceManager;
     203             :             ::cppu::OMultiTypeInterfaceContainerHelper                                      m_aListenerContainer;   /// container for ALL Listener
     204             :             com::sun::star::uno::Reference< com::sun::star::lang::XComponent >              m_xModuleImageManager;
     205             :             com::sun::star::uno::Reference< com::sun::star::uno::XInterface >               m_xModuleAcceleratorManager;
     206             :    };
     207             : }
     208             : 
     209             : #endif // __FRAMEWORK_UICONFIGURATION_MODULEUICONFIGMANAGER_HXX_
     210             : 
     211             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10