LCOV - code coverage report
Current view: top level - framework/source/uiconfiguration - imagemanagerimpl.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 2 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 2 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_FRAMEWORK_SOURCE_UICONFIGURATION_IMAGEMANAGERIMPL_HXX
      21             : #define INCLUDED_FRAMEWORK_SOURCE_UICONFIGURATION_IMAGEMANAGERIMPL_HXX
      22             : 
      23             : #include <macros/generic.hxx>
      24             : #include <macros/xinterface.hxx>
      25             : #include <macros/xtypeprovider.hxx>
      26             : #include <macros/xserviceinfo.hxx>
      27             : #include <stdtypes.h>
      28             : #include <uiconfiguration/imagetype.hxx>
      29             : 
      30             : #include <com/sun/star/lang/XServiceInfo.hpp>
      31             : #include <com/sun/star/lang/XTypeProvider.hpp>
      32             : #include <com/sun/star/lang/XComponent.hpp>
      33             : #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
      34             : #include <com/sun/star/ui/XUIConfigurationStorage.hpp>
      35             : #include <com/sun/star/ui/XUIConfiguration.hpp>
      36             : #include <com/sun/star/ui/XImageManager.hpp>
      37             : #include <com/sun/star/lang/XInitialization.hpp>
      38             : #include <com/sun/star/ui/ConfigurationEvent.hpp>
      39             : #include <com/sun/star/embed/XTransactedObject.hpp>
      40             : 
      41             : #include <cppuhelper/weak.hxx>
      42             : #include <cppuhelper/interfacecontainer.hxx>
      43             : #include <rtl/ustring.hxx>
      44             : 
      45             : #include <vcl/image.hxx>
      46             : #include <rtl/ref.hxx>
      47             : #include <salhelper/simplereferenceobject.hxx>
      48             : 
      49             : #include <list>
      50             : #include <unordered_map>
      51             : #include <vector>
      52             : 
      53             : namespace framework
      54             : {
      55             :     class CmdImageList
      56             :     {
      57             :         public:
      58             :             CmdImageList( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
      59             :                           const OUString& aModuleIdentifier );
      60             :             virtual ~CmdImageList();
      61             : 
      62             :             virtual Image                           getImageFromCommandURL( sal_Int16 nImageType, const OUString& rCommandURL );
      63             :             virtual bool                            hasImage( sal_Int16 nImageType, const OUString& rCommandURL );
      64             :             virtual ::std::vector< OUString >& getImageNames();
      65             :             virtual ::std::vector< OUString >& getImageCommandNames();
      66             : 
      67             :         protected:
      68             :             void                            impl_fillCommandToImageNameMap();
      69             :             ImageList*                      impl_getImageList( sal_Int16 nImageType );
      70           0 :             std::vector< OUString >& impl_getImageNameVector() { return m_aImageNameVector;}
      71           0 :             std::vector< OUString >& impl_getImageCommandNameVector() { return m_aImageCommandNameVector;}
      72             : 
      73             :         private:
      74             :             bool                                                                         m_bVectorInit;
      75             :             OUString                                                                    m_aModuleIdentifier;
      76             :             ImageList*                                                                       m_pImageList[ImageType_COUNT];
      77             :             CommandToImageNameMap                                                            m_aCommandToImageNameMap;
      78             :             ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >     m_xContext;
      79             :             ::std::vector< OUString >                                                   m_aImageNameVector;
      80             :             ::std::vector< OUString >                                                   m_aImageCommandNameVector;
      81             :             OUString                                                                    m_sIconTheme;
      82             :     };
      83             : 
      84             :     class GlobalImageList : public CmdImageList, public salhelper::SimpleReferenceObject
      85             :     {
      86             :         public:
      87             :             GlobalImageList( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
      88             :             virtual ~GlobalImageList();
      89             : 
      90             :             virtual Image                           getImageFromCommandURL( sal_Int16 nImageType, const OUString& rCommandURL ) SAL_OVERRIDE;
      91             :             virtual bool                            hasImage( sal_Int16 nImageType, const OUString& rCommandURL ) SAL_OVERRIDE;
      92             :             virtual ::std::vector< OUString >& getImageNames() SAL_OVERRIDE;
      93             :             virtual ::std::vector< OUString >& getImageCommandNames() SAL_OVERRIDE;
      94             :     };
      95             : 
      96             :     class ImageManagerImpl
      97             :     {
      98             :         public:
      99             :             ImageManagerImpl(const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext
     100             :                 ,::cppu::OWeakObject *pOwner
     101             :                 ,bool _bUseGlobal);
     102             :             ~ImageManagerImpl();
     103             : 
     104             :             void dispose();
     105             :             void initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments );
     106             :             void addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
     107             :             void removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
     108             : 
     109             :             // XImageManager
     110             :             void reset() throw (::com::sun::star::uno::RuntimeException, css::lang::IllegalAccessException);
     111             :             ::com::sun::star::uno::Sequence< OUString > getAllImageNames( ::sal_Int16 nImageType ) throw (::com::sun::star::uno::RuntimeException);
     112             :             bool hasImage( ::sal_Int16 nImageType, const OUString& aCommandURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     113             :             ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > > getImages( ::sal_Int16 nImageType, const ::com::sun::star::uno::Sequence< OUString >& aCommandURLSequence ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     114             :             void replaceImages( ::sal_Int16 nImageType, const ::com::sun::star::uno::Sequence< OUString >& aCommandURLSequence, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > >& aGraphicsSequence ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException, std::exception);
     115             :             void removeImages( ::sal_Int16 nImageType, const ::com::sun::star::uno::Sequence< OUString >& aResourceURLSequence ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
     116             :             void insertImages( ::sal_Int16 nImageType, const ::com::sun::star::uno::Sequence< OUString >& aCommandURLSequence, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > >& aGraphicSequence ) throw (::com::sun::star::container::ElementExistException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
     117             : 
     118             :             // XUIConfiguration
     119             :             void addConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
     120             :             void removeConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
     121             : 
     122             :             // XUIConfigurationPersistence
     123             :             void reload() throw (css::uno::Exception, css::uno::RuntimeException, std::exception);
     124             :             void store()
     125             :                 throw (::com::sun::star::uno::Exception,
     126             :                        ::com::sun::star::uno::RuntimeException,
     127             :                        std::exception);
     128             :             void storeToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage )
     129             :                 throw (::com::sun::star::uno::Exception,
     130             :                        ::com::sun::star::uno::RuntimeException,
     131             :                        std::exception);
     132             :             bool isModified() throw (::com::sun::star::uno::RuntimeException);
     133             :             bool isReadOnly() throw (::com::sun::star::uno::RuntimeException);
     134             : 
     135             :             void clear();
     136             : 
     137             :             typedef std::unordered_map< OUString,
     138             :                                         sal_Bool,
     139             :                                         OUStringHash,
     140             :                                         std::equal_to< OUString > > ImageNameMap;
     141             : 
     142             :             enum Layer
     143             :             {
     144             :                 LAYER_DEFAULT,
     145             :                 LAYER_USERDEFINED,
     146             :                 LAYER_COUNT
     147             :             };
     148             : 
     149             :             enum NotifyOp
     150             :             {
     151             :                 NotifyOp_Remove,
     152             :                 NotifyOp_Insert,
     153             :                 NotifyOp_Replace
     154             :             };
     155             : 
     156             :             typedef ::std::vector< ::com::sun::star::ui::ConfigurationEvent > ConfigEventNotifyContainer;
     157             : 
     158             :             void                                      implts_initialize();
     159             :             void                                      implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent& aEvent, NotifyOp eOp );
     160             :             ImageList*                                implts_getUserImageList( ImageType nImageType );
     161             :             bool                                  implts_loadUserImages( ImageType nImageType,
     162             :                                                                              const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xUserImageStorage,
     163             :                                                                              const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xUserBitmapsStorage );
     164             :             bool                                  implts_storeUserImages( ImageType nImageType,
     165             :                                                                               const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xUserImageStorage,
     166             :                                                                               const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xUserBitmapsStorage );
     167             :             const rtl::Reference< GlobalImageList >&  implts_getGlobalImageList();
     168             :             CmdImageList*                             implts_getDefaultImageList();
     169             : 
     170             :             com::sun::star::uno::Reference< com::sun::star::embed::XStorage >               m_xUserConfigStorage;
     171             :             com::sun::star::uno::Reference< com::sun::star::embed::XStorage >               m_xUserImageStorage;
     172             :             com::sun::star::uno::Reference< com::sun::star::embed::XStorage >               m_xUserBitmapsStorage;
     173             :             com::sun::star::uno::Reference< com::sun::star::embed::XTransactedObject >      m_xUserRootCommit;
     174             :             com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >        m_xContext;
     175             :             ::cppu::OWeakObject*                                                            m_pOwner;
     176             :             rtl::Reference< GlobalImageList >                                               m_pGlobalImageList;
     177             :             CmdImageList*                                                                   m_pDefaultImageList;
     178             :             OUString                                                                   m_aXMLPostfix;
     179             :             OUString                                                                   m_aModuleIdentifier;
     180             :             OUString                                                                   m_aResourceString;
     181             :             osl::Mutex m_mutex;
     182             :             ::cppu::OMultiTypeInterfaceContainerHelper                                      m_aListenerContainer;   /// container for ALL Listener
     183             :             ImageList*                                                                      m_pUserImageList[ImageType_COUNT];
     184             :             bool                                                                            m_bUserImageListModified[ImageType_COUNT];
     185             :             bool                                                                            m_bUseGlobal;
     186             :             bool                                                                            m_bReadOnly;
     187             :             bool                                                                            m_bInitialized;
     188             :             bool                                                                            m_bModified;
     189             :             bool                                                                            m_bConfigRead;
     190             :             bool                                                                            m_bDisposed;
     191             :    };
     192             : }
     193             : 
     194             : #endif
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11