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

Generated by: LCOV version 1.10