LCOV - code coverage report
Current view: top level - libreoffice/basic/source/inc - namecont.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 27 40 67.5 %
Date: 2012-12-27 Functions: 15 25 60.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 BASIC_NAMECONTAINER_HXX
      21             : #define BASIC_NAMECONTAINER_HXX
      22             : 
      23             : #include <boost/unordered_map.hpp>
      24             : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      25             : #include <com/sun/star/uno/XComponentContext.hpp>
      26             : #include <com/sun/star/lang/XInitialization.hpp>
      27             : #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
      28             : #include <com/sun/star/script/XLibraryContainerPassword.hpp>
      29             : #include <com/sun/star/script/XLibraryContainerExport.hpp>
      30             : #include <com/sun/star/script/XLibraryQueryExecutable.hpp>
      31             : #include <com/sun/star/script/XLibraryContainer3.hpp>
      32             : #include <com/sun/star/container/XNameContainer.hpp>
      33             : #include <com/sun/star/container/XContainer.hpp>
      34             : #include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
      35             : #include <com/sun/star/io/XOutputStream.hpp>
      36             : #include <com/sun/star/io/XInputStream.hpp>
      37             : #include <com/sun/star/util/XMacroExpander.hpp>
      38             : #include <com/sun/star/util/XStringSubstitution.hpp>
      39             : #include <com/sun/star/document/XStorageBasedDocument.hpp>
      40             : #include <com/sun/star/lang/XServiceInfo.hpp>
      41             : #include <com/sun/star/frame/XModel.hpp>
      42             : #include <com/sun/star/deployment/XPackage.hpp>
      43             : #include <com/sun/star/script/vba/XVBACompatibility.hpp>
      44             : #include <com/sun/star/script/vba/XVBAScriptListener.hpp>
      45             : #include <com/sun/star/util/XChangesNotifier.hpp>
      46             : 
      47             : #include <osl/mutex.hxx>
      48             : #include <unotools/eventlisteneradapter.hxx>
      49             : #include <cppuhelper/implbase3.hxx>
      50             : #include <cppuhelper/compbase8.hxx>
      51             : #include <cppuhelper/interfacecontainer.hxx>
      52             : #include <cppuhelper/weakref.hxx>
      53             : #include <cppuhelper/component.hxx>
      54             : #include <cppuhelper/typeprovider.hxx>
      55             : #include <cppuhelper/basemutex.hxx>
      56             : #include <sot/storage.hxx>
      57             : #include <comphelper/listenernotification.hxx>
      58             : #include <xmlscript/xmllib_imexp.hxx>
      59             : #include <cppuhelper/compbase9.hxx>
      60             : 
      61             : class BasicManager;
      62             : 
      63             : namespace basic
      64             : {
      65             : typedef ::cppu::WeakImplHelper3<
      66             :     ::com::sun::star::container::XNameContainer,
      67             :     ::com::sun::star::container::XContainer,
      68             :     ::com::sun::star::util::XChangesNotifier > NameContainer_BASE;
      69             : 
      70             : //============================================================================
      71             : 
      72         698 : class NameContainer : public ::cppu::BaseMutex, public NameContainer_BASE
      73             : {
      74             :     typedef boost::unordered_map < OUString, sal_Int32, ::rtl::OUStringHash > NameContainerNameMap;
      75             : 
      76             :     NameContainerNameMap mHashMap;
      77             :     ::com::sun::star::uno::Sequence< OUString > mNames;
      78             :     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > mValues;
      79             :     sal_Int32 mnElementCount;
      80             : 
      81             :     ::com::sun::star::uno::Type mType;
      82             :     ::com::sun::star::uno::XInterface* mpxEventSource;
      83             : 
      84             :     ::cppu::OInterfaceContainerHelper maContainerListeners;
      85             :     ::cppu::OInterfaceContainerHelper maChangesListeners;
      86             : 
      87             : public:
      88        1274 :     NameContainer( const ::com::sun::star::uno::Type& rType )
      89             :         : mnElementCount( 0 )
      90             :         , mType( rType )
      91             :         , mpxEventSource( NULL )
      92             :         , maContainerListeners( m_aMutex )
      93        1274 :         , maChangesListeners( m_aMutex )
      94        1274 :     {}
      95             : 
      96         509 :     void setEventSource( ::com::sun::star::uno::XInterface* pxEventSource )
      97         509 :         { mpxEventSource = pxEventSource; }
      98             : 
      99             :     // Methods XElementAccess
     100             :     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  )
     101             :         throw(::com::sun::star::uno::RuntimeException);
     102             :     virtual sal_Bool SAL_CALL hasElements(  )
     103             :         throw(::com::sun::star::uno::RuntimeException);
     104             : 
     105             :     // Methods XNameAccess
     106             :     virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
     107             :         throw(::com::sun::star::container::NoSuchElementException,
     108             :               ::com::sun::star::lang::WrappedTargetException,
     109             :               ::com::sun::star::uno::RuntimeException);
     110             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames(  )
     111             :         throw(::com::sun::star::uno::RuntimeException);
     112             :     virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
     113             :         throw(::com::sun::star::uno::RuntimeException);
     114             : 
     115             :     // Methods XNameReplace
     116             :     virtual void SAL_CALL replaceByName( const OUString& aName, const ::com::sun::star::uno::Any& aElement )
     117             :         throw(::com::sun::star::lang::IllegalArgumentException,
     118             :               ::com::sun::star::container::NoSuchElementException,
     119             :               ::com::sun::star::lang::WrappedTargetException,
     120             :               ::com::sun::star::uno::RuntimeException);
     121             : 
     122             :     // Methods XNameContainer
     123             :     virtual void SAL_CALL insertByName( const OUString& aName, const ::com::sun::star::uno::Any& aElement )
     124             :         throw(::com::sun::star::lang::IllegalArgumentException,
     125             :               ::com::sun::star::container::ElementExistException,
     126             :               ::com::sun::star::lang::WrappedTargetException,
     127             :               ::com::sun::star::uno::RuntimeException);
     128             :     virtual void SAL_CALL removeByName( const OUString& Name )
     129             :         throw(::com::sun::star::container::NoSuchElementException,
     130             :               ::com::sun::star::lang::WrappedTargetException,
     131             :               ::com::sun::star::uno::RuntimeException);
     132             : 
     133             :     // Methods XContainer
     134             :     virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference<
     135             :         ::com::sun::star::container::XContainerListener >& xListener )
     136             :             throw (::com::sun::star::uno::RuntimeException);
     137             :     virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference<
     138             :         ::com::sun::star::container::XContainerListener >& xListener )
     139             :             throw (::com::sun::star::uno::RuntimeException);
     140             : 
     141             :     // Methods XChangesNotifier
     142             :     virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference<
     143             :         ::com::sun::star::util::XChangesListener >& xListener )
     144             :             throw (::com::sun::star::uno::RuntimeException);
     145             :     virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference<
     146             :         ::com::sun::star::util::XChangesListener >& xListener )
     147             :             throw (::com::sun::star::uno::RuntimeException);
     148             : };
     149             : 
     150             : //============================================================================
     151             : 
     152         433 : class ModifiableHelper
     153             : {
     154             : private:
     155             :     ::cppu::OInterfaceContainerHelper   m_aModifyListeners;
     156             :     ::cppu::OWeakObject&                m_rEventSource;
     157             :     sal_Bool                            mbModified;
     158             : 
     159             : public:
     160         775 :     ModifiableHelper( ::cppu::OWeakObject& _rEventSource, ::osl::Mutex& _rMutex )
     161             :         :m_aModifyListeners( _rMutex )
     162             :         ,m_rEventSource( _rEventSource )
     163         775 :         ,mbModified( sal_False )
     164             :     {
     165         775 :     }
     166             : 
     167           0 :     inline  sal_Bool    isModified() const  { return mbModified; }
     168             :             void        setModified( sal_Bool _bModified );
     169             : 
     170           0 :     inline  void    addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& _rxListener )
     171             :     {
     172           0 :         m_aModifyListeners.addInterface( _rxListener );
     173           0 :     }
     174             : 
     175           0 :     inline  void    removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& _rxListener )
     176             :     {
     177           0 :         m_aModifyListeners.removeInterface( _rxListener );
     178           0 :     }
     179             : };
     180             : 
     181             : //============================================================================
     182             : 
     183             : typedef ::comphelper::OListenerContainerBase<
     184             :     ::com::sun::star::script::vba::XVBAScriptListener,
     185             :     ::com::sun::star::script::vba::VBAScriptEvent > VBAScriptListenerContainer_BASE;
     186             : 
     187         433 : class VBAScriptListenerContainer : public VBAScriptListenerContainer_BASE
     188             : {
     189             : public:
     190             :     explicit VBAScriptListenerContainer( ::osl::Mutex& rMutex );
     191             : 
     192             : private:
     193             :     virtual bool implTypedNotify(
     194             :         const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& rxListener,
     195             :         const ::com::sun::star::script::vba::VBAScriptEvent& rEvent )
     196             :         throw (::com::sun::star::uno::Exception);
     197             : };
     198             : 
     199             : //============================================================================
     200             : 
     201             : class SfxLibrary;
     202             : 
     203             : typedef ::cppu::WeakComponentImplHelper9<
     204             :     ::com::sun::star::lang::XInitialization,
     205             :     ::com::sun::star::script::XStorageBasedLibraryContainer,
     206             :     ::com::sun::star::script::XLibraryContainerPassword,
     207             :     ::com::sun::star::script::XLibraryContainerExport,
     208             :     ::com::sun::star::script::XLibraryContainer3,
     209             :     ::com::sun::star::container::XContainer,
     210             :     ::com::sun::star::script::XLibraryQueryExecutable,
     211             :     ::com::sun::star::script::vba::XVBACompatibility,
     212             :     ::com::sun::star::lang::XServiceInfo > SfxLibraryContainer_BASE;
     213             : 
     214             : class SfxLibraryContainer : public SfxLibraryContainer_BASE, public ::utl::OEventListenerAdapter
     215             : {
     216             :     VBAScriptListenerContainer maVBAScriptListeners;
     217             :     sal_Int32 mnRunningVBAScripts;
     218             :     sal_Bool mbVBACompat;
     219             :     OUString msProjectName;
     220             : protected:
     221             :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >   mxMSF;
     222             :     ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >      mxSFI;
     223             :     ::com::sun::star::uno::Reference< ::com::sun::star::util::XMacroExpander >         mxMacroExpander;
     224             :     ::com::sun::star::uno::Reference< ::com::sun::star::util::XStringSubstitution >    mxStringSubstitution;
     225             :     ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel >            mxOwnerDocument;
     226             : 
     227             :     ::osl::Mutex        maMutex;
     228             :     ModifiableHelper    maModifiable;
     229             : 
     230             :     NameContainer maNameContainer;
     231             :     bool    mbOldInfoFormat;
     232             :     bool    mbOasis2OOoFormat;
     233             : 
     234             :     OUString maInitialDocumentURL;
     235             :     OUString maInfoFileName;
     236             :     OUString maOldInfoFileName;
     237             :     OUString maLibElementFileExtension;
     238             :     OUString maLibraryPath;
     239             :     OUString maLibrariesDir;
     240             : 
     241             :     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > mxStorage;
     242             :     BasicManager*   mpBasMgr;
     243             :     bool        mbOwnBasMgr;
     244             : 
     245             :     enum InitMode
     246             :     {
     247             :         DEFAULT,
     248             :         CONTAINER_INIT_FILE,
     249             :         LIBRARY_INIT_FILE,
     250             :         OFFICE_DOCUMENT,
     251             :         OLD_BASIC_STORAGE
     252             :     } meInitMode;
     253             : 
     254             :     void implStoreLibrary( SfxLibrary* pLib,
     255             :                             const OUString& aName,
     256             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
     257             : 
     258             :     // New variant for library export
     259             :     void implStoreLibrary( SfxLibrary* pLib,
     260             :                             const OUString& aName,
     261             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
     262             :                             const OUString& aTargetURL,
     263             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 > xToUseSFI,
     264             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler );
     265             : 
     266             :     void implStoreLibraryIndexFile( SfxLibrary* pLib, const ::xmlscript::LibDescriptor& rLib,
     267             :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
     268             : 
     269             :     // New variant for library export
     270             :     void implStoreLibraryIndexFile( SfxLibrary* pLib, const ::xmlscript::LibDescriptor& rLib,
     271             :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
     272             :                                     const OUString& aTargetURL,
     273             :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 > xToUseSFI );
     274             : 
     275             :     bool implLoadLibraryIndexFile( SfxLibrary* pLib,
     276             :                                     ::xmlscript::LibDescriptor& rLib,
     277             :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
     278             :                                     const OUString& aIndexFileName );
     279             : 
     280             :     void implImportLibDescriptor( SfxLibrary* pLib, ::xmlscript::LibDescriptor& rLib );
     281             : 
     282             :     // Methods to distinguish between deffirent library types
     283             :     virtual SfxLibrary* SAL_CALL implCreateLibrary( const OUString& aName ) = 0;
     284             :     virtual SfxLibrary* SAL_CALL implCreateLibraryLink
     285             :         ( const OUString& aName, const OUString& aLibInfoFileURL,
     286             :           const OUString& StorageURL, sal_Bool ReadOnly ) = 0;
     287             :     virtual ::com::sun::star::uno::Any SAL_CALL createEmptyLibraryElement( void ) = 0;
     288             :     virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const = 0;
     289             :     virtual void SAL_CALL writeLibraryElement
     290             :     (
     291             :         const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary,
     292             :         const OUString& aElementName,
     293             :         const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput
     294             :     )
     295             :         throw(::com::sun::star::uno::Exception) = 0;
     296             : 
     297             :     virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement
     298             :     (
     299             :         const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary,
     300             :         const OUString& aElementName,
     301             :         const OUString& aFile,
     302             :         const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream ) = 0;
     303             :     virtual void SAL_CALL importFromOldStorage( const OUString& aFile ) = 0;
     304             : 
     305             :     // Password encryption
     306             :     virtual sal_Bool implStorePasswordLibrary( SfxLibrary* pLib, const OUString& aName,
     307             :                         const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler );
     308             : 
     309             :     // New variant for library export
     310             :     virtual sal_Bool implStorePasswordLibrary( SfxLibrary* pLib, const OUString& aName,
     311             :                         const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
     312             :                         const OUString& aTargetURL,
     313             :                         const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 > xToUseSFI, const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler );
     314             : 
     315             :     virtual sal_Bool implLoadPasswordLibrary( SfxLibrary* pLib, const OUString& Name,
     316             :         sal_Bool bVerifyPasswordOnly=false )
     317             :             throw(::com::sun::star::lang::WrappedTargetException,
     318             :                   ::com::sun::star::uno::RuntimeException);
     319             : 
     320             :     virtual void onNewRootStorage() = 0;
     321             : 
     322             : 
     323             :     // #56666, Creates another library container
     324             :     //         instance of the same derived class
     325             :     virtual SfxLibraryContainer* createInstanceImpl( void ) = 0;
     326             : 
     327             : 
     328             :     // Interface to get the BasicManager (Hack for password implementation)
     329             :     BasicManager* getBasicManager( void );
     330             :     OUString createAppLibraryFolder( SfxLibrary* pLib, const OUString& aName );
     331             : 
     332             :     void init( const OUString& rInitialDocumentURL,
     333             :                const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxInitialStorage );
     334             : 
     335             :     virtual const sal_Char* SAL_CALL    getInfoFileName() const = 0;
     336             :     virtual const sal_Char* SAL_CALL    getOldInfoFileName() const = 0;
     337             :     virtual const sal_Char* SAL_CALL    getLibElementFileExtension() const = 0;
     338             :     virtual const sal_Char* SAL_CALL    getLibrariesDir() const = 0;
     339             : 
     340             :     // Handle maLibInfoFileURL and maStorageURL correctly
     341             :     void checkStorageURL
     342             :     (
     343             :         const OUString& aSourceURL,
     344             :         OUString& aLibInfoFileURL,
     345             :         OUString& aStorageURL,
     346             :         OUString& aUnexpandedStorageURL
     347             :     );
     348             :     OUString expand_url( const OUString& url )
     349             :         throw(::com::sun::star::uno::RuntimeException);
     350             : 
     351             :     SfxLibrary* getImplLib( const OUString& rLibraryName );
     352             : 
     353             :     void storeLibraries_Impl(
     354             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
     355             :                             bool bComplete );
     356             : 
     357             :     void SAL_CALL initializeFromDocumentURL( const OUString& _rInitialDocumentURL );
     358             :     void SAL_CALL initializeFromDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageBasedDocument >& _rxDocument );
     359             : 
     360             :     // OEventListenerAdapter
     361             :     virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource );
     362             : 
     363             :     // OComponentHelper
     364             :     virtual void SAL_CALL disposing();
     365             : 
     366             : private:
     367             :     void init_Impl( const OUString& rInitialDocumentURL,
     368             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxInitialStorage );
     369             :     void implScanExtensions( void );
     370             : 
     371             : public:
     372             :     SfxLibraryContainer( void );
     373             :     ~SfxLibraryContainer();
     374             : 
     375             : 
     376             :     // Interface to set the BasicManager (Hack for password implementation)
     377          10 :     void setBasicManager( BasicManager* pBasMgr )
     378             :     {
     379          10 :         mpBasMgr = pBasMgr;
     380          10 :     }
     381             : 
     382             :     void    enterMethod();
     383             :     void    leaveMethod();
     384        7289 :     bool    isDisposed() const { return rBHelper.bInDispose || rBHelper.bDisposed; }
     385             :     void    checkDisposed() const;
     386             : 
     387             :     // Methods XElementAccess
     388             :     virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
     389             :         throw(::com::sun::star::uno::RuntimeException);
     390             :     virtual sal_Bool SAL_CALL hasElements()
     391             :         throw(::com::sun::star::uno::RuntimeException);
     392             : 
     393             :     // Methods XNameAccess
     394             :     virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
     395             :         throw(::com::sun::star::container::NoSuchElementException,
     396             :               ::com::sun::star::lang::WrappedTargetException,
     397             :               ::com::sun::star::uno::RuntimeException);
     398             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames()
     399             :         throw(::com::sun::star::uno::RuntimeException);
     400             :     virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
     401             :         throw(::com::sun::star::uno::RuntimeException);
     402             : 
     403             :     // Members XStorageBasedLibraryContainer
     404             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > SAL_CALL getRootStorage() throw (::com::sun::star::uno::RuntimeException);
     405             :     virtual void SAL_CALL setRootStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rootstorage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     406             :     virtual void SAL_CALL storeLibrariesToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& RootStorage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     407             : 
     408             :     // Methods XModifiable (base of XPersistentLibraryContainer)
     409             :     virtual ::sal_Bool SAL_CALL isModified(  ) throw (::com::sun::star::uno::RuntimeException);
     410             :     virtual void SAL_CALL setModified( ::sal_Bool bModified ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException);
     411             :     virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
     412             :     virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
     413             : 
     414             :     // Methods XPersistentLibraryContainer (base of XStorageBasedLibraryContainer)
     415             :     virtual ::com::sun::star::uno::Any SAL_CALL getRootLocation() throw (::com::sun::star::uno::RuntimeException);
     416             :     virtual OUString SAL_CALL getContainerLocationName() throw (::com::sun::star::uno::RuntimeException);
     417             :     virtual void SAL_CALL storeLibraries(  ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     418             : 
     419             :     //Methods XLibraryContainer3
     420             :     virtual OUString SAL_CALL getOriginalLibraryLinkURL( const OUString& Name )
     421             :         throw (::com::sun::star::lang::IllegalArgumentException,
     422             :                ::com::sun::star::container::NoSuchElementException,
     423             :                ::com::sun::star::uno::RuntimeException);
     424             : 
     425             :     // Methods XLibraryContainer2 (base of XPersistentLibraryContainer)
     426             :     virtual sal_Bool SAL_CALL isLibraryLink( const OUString& Name )
     427             :         throw (::com::sun::star::container::NoSuchElementException,
     428             :                ::com::sun::star::uno::RuntimeException);
     429             :     virtual OUString SAL_CALL getLibraryLinkURL( const OUString& Name )
     430             :         throw (::com::sun::star::lang::IllegalArgumentException,
     431             :                ::com::sun::star::container::NoSuchElementException,
     432             :                ::com::sun::star::uno::RuntimeException);
     433             :     virtual sal_Bool SAL_CALL isLibraryReadOnly( const OUString& Name )
     434             :         throw (::com::sun::star::container::NoSuchElementException,
     435             :                ::com::sun::star::uno::RuntimeException);
     436             :     virtual void SAL_CALL setLibraryReadOnly( const OUString& Name, sal_Bool bReadOnly )
     437             :         throw (::com::sun::star::container::NoSuchElementException,
     438             :                ::com::sun::star::uno::RuntimeException);
     439             :     virtual void SAL_CALL renameLibrary( const OUString& Name, const OUString& NewName )
     440             :         throw (::com::sun::star::container::NoSuchElementException,
     441             :                ::com::sun::star::container::ElementExistException,
     442             :                ::com::sun::star::uno::RuntimeException);
     443             : 
     444             :     // Methods XLibraryContainer (base of XLibraryContainer2)
     445             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > SAL_CALL
     446             :         createLibrary( const OUString& Name )
     447             :             throw(::com::sun::star::lang::IllegalArgumentException,
     448             :                   ::com::sun::star::container::ElementExistException,
     449             :                   ::com::sun::star::uno::RuntimeException);
     450             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL createLibraryLink
     451             :         ( const OUString& Name, const OUString& StorageURL, sal_Bool ReadOnly )
     452             :             throw(::com::sun::star::lang::IllegalArgumentException,
     453             :                   ::com::sun::star::container::ElementExistException,
     454             :                   ::com::sun::star::uno::RuntimeException);
     455             :     virtual void SAL_CALL removeLibrary( const OUString& Name )
     456             :         throw(::com::sun::star::container::NoSuchElementException,
     457             :               ::com::sun::star::lang::WrappedTargetException,
     458             :               ::com::sun::star::uno::RuntimeException);
     459             :     virtual sal_Bool SAL_CALL isLibraryLoaded( const OUString& Name )
     460             :         throw(::com::sun::star::container::NoSuchElementException,
     461             :               ::com::sun::star::uno::RuntimeException);
     462             :     virtual void SAL_CALL loadLibrary( const OUString& Name )
     463             :         throw(::com::sun::star::container::NoSuchElementException,
     464             :               ::com::sun::star::lang::WrappedTargetException,
     465             :               ::com::sun::star::uno::RuntimeException);
     466             : 
     467             :     // Methods XInitialization
     468             :     virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence<
     469             :         ::com::sun::star::uno::Any >& aArguments )
     470             :             throw (::com::sun::star::uno::Exception,
     471             :                    ::com::sun::star::uno::RuntimeException);
     472             : 
     473             :     // Methods XLibraryContainerPassword
     474             :     virtual sal_Bool SAL_CALL isLibraryPasswordProtected( const OUString& Name )
     475             :         throw (::com::sun::star::container::NoSuchElementException,
     476             :                ::com::sun::star::uno::RuntimeException);
     477             :     virtual sal_Bool SAL_CALL isLibraryPasswordVerified( const OUString& Name )
     478             :         throw (::com::sun::star::lang::IllegalArgumentException,
     479             :                ::com::sun::star::container::NoSuchElementException,
     480             :                ::com::sun::star::uno::RuntimeException);
     481             :     virtual sal_Bool SAL_CALL verifyLibraryPassword( const OUString& Name, const OUString& Password )
     482             :         throw (::com::sun::star::lang::IllegalArgumentException,
     483             :                ::com::sun::star::container::NoSuchElementException,
     484             :                ::com::sun::star::uno::RuntimeException);
     485             :     virtual void SAL_CALL changeLibraryPassword( const OUString& Name,
     486             :         const OUString& OldPassword, const OUString& NewPassword )
     487             :         throw (::com::sun::star::lang::IllegalArgumentException,
     488             :                ::com::sun::star::container::NoSuchElementException,
     489             :                ::com::sun::star::uno::RuntimeException);
     490             : 
     491             :     // Methods XContainer
     492             :     virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference<
     493             :         ::com::sun::star::container::XContainerListener >& xListener )
     494             :             throw (::com::sun::star::uno::RuntimeException);
     495             :     virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference<
     496             :         ::com::sun::star::container::XContainerListener >& xListener )
     497             :             throw (::com::sun::star::uno::RuntimeException);
     498             : 
     499             :     // Methods XLibraryContainerExport
     500             :     virtual void SAL_CALL exportLibrary( const OUString& Name, const OUString& URL,
     501             :         const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler )
     502             :             throw (::com::sun::star::uno::Exception,
     503             :                    ::com::sun::star::container::NoSuchElementException,
     504             :                    ::com::sun::star::uno::RuntimeException);
     505             : 
     506             :     // Methods XServiceInfo
     507             :     virtual OUString SAL_CALL getImplementationName( )
     508             :         throw (::com::sun::star::uno::RuntimeException) = 0;
     509             :     virtual ::sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
     510             :         throw (::com::sun::star::uno::RuntimeException);
     511             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
     512             :         throw (::com::sun::star::uno::RuntimeException) = 0;
     513             :     // Methods XVBACompatibility
     514             :     virtual ::sal_Bool SAL_CALL getVBACompatibilityMode() throw (::com::sun::star::uno::RuntimeException);
     515             :     virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException);
     516           1 :     virtual OUString SAL_CALL getProjectName() throw (::com::sun::star::uno::RuntimeException) { return msProjectName; }
     517             :     virtual void SAL_CALL setProjectName( const OUString& _projectname ) throw (::com::sun::star::uno::RuntimeException);
     518             :     virtual sal_Int32 SAL_CALL getRunningVBAScripts()
     519             :             throw (::com::sun::star::uno::RuntimeException);
     520             :     virtual void SAL_CALL addVBAScriptListener(
     521             :         const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& Listener )
     522             :             throw (::com::sun::star::uno::RuntimeException);
     523             :     virtual void SAL_CALL removeVBAScriptListener(
     524             :         const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& Listener )
     525             :             throw (::com::sun::star::uno::RuntimeException);
     526             :     virtual void SAL_CALL broadcastVBAScriptEvent( sal_Int32 nIdentifier, const OUString& rModuleName )
     527             :             throw (::com::sun::star::uno::RuntimeException);
     528             : };
     529             : 
     530             : //============================================================================
     531             : 
     532             : class LibraryContainerMethodGuard
     533             : {
     534             : private:
     535             :     SfxLibraryContainer&    m_rContainer;
     536             : public:
     537        7289 :     LibraryContainerMethodGuard( SfxLibraryContainer& _rContainer )
     538        7289 :         :m_rContainer( _rContainer )
     539             :     {
     540        7289 :         m_rContainer.enterMethod();
     541        7289 :     }
     542             : 
     543        7289 :     ~LibraryContainerMethodGuard()
     544             :     {
     545        7289 :         m_rContainer.leaveMethod();
     546        7289 :     }
     547             : };
     548             : 
     549             : //============================================================================
     550             : 
     551         265 : class SfxLibrary
     552             :     : public ::com::sun::star::container::XNameContainer
     553             :     , public ::com::sun::star::container::XContainer
     554             :     , public ::com::sun::star::util::XChangesNotifier
     555             :     , public ::cppu::BaseMutex
     556             :     , public ::cppu::OComponentHelper
     557             : {
     558             :     friend class SfxLibraryContainer;
     559             :     friend class SfxDialogLibraryContainer;
     560             :     friend class SfxScriptLibraryContainer;
     561             : 
     562             :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >   mxMSF;
     563             :     ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >      mxSFI;
     564             : 
     565             :     ModifiableHelper&   mrModifiable;
     566             :     NameContainer       maNameContainer;
     567             : 
     568             :     sal_Bool mbLoaded;
     569             :     sal_Bool mbIsModified;
     570             :     bool mbInitialised;
     571             : 
     572             : private:
     573             : 
     574             :     OUString maLibElementFileExtension;
     575             :     OUString maLibInfoFileURL;
     576             :     OUString maStorageURL;
     577             :     OUString maUnexpandedStorageURL;
     578             :     OUString maOriginalStorageURL;
     579             : 
     580             :     sal_Bool mbLink;
     581             :     sal_Bool mbReadOnly;
     582             :     sal_Bool mbReadOnlyLink;
     583             :     sal_Bool mbPreload;
     584             : 
     585             :     sal_Bool mbPasswordProtected;
     586             :     sal_Bool mbPasswordVerified;
     587             :     bool mbDoc50Password;
     588             :     OUString maPassword;
     589             : 
     590             :     bool mbSharedIndexFile;
     591             :     bool mbExtension;
     592             : 
     593             :     // Additional functionality for localisation
     594             :     // Provide modify state including resources
     595             :     virtual sal_Bool isModified( void ) = 0;
     596             :     virtual void storeResources( void ) = 0;
     597             :     virtual void storeResourcesAsURL( const OUString& URL, const OUString& NewName ) = 0;
     598             :     virtual void storeResourcesToURL( const OUString& URL,
     599             :         const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ) = 0;
     600             :     virtual void storeResourcesToStorage( const ::com::sun::star::uno::Reference
     601             :         < ::com::sun::star::embed::XStorage >& xStorage ) = 0;
     602             : 
     603             : protected:
     604           0 :     inline  sal_Bool    implIsModified() const  { return mbIsModified; }
     605             :             void        implSetModified( sal_Bool _bIsModified );
     606             : 
     607             : private:
     608             :     /** checks whether the lib is readonly, or a readonly link, throws an IllegalArgumentException if so
     609             :     */
     610             :     void    impl_checkReadOnly();
     611             :     /** checks whether the library is loaded, throws a LibraryNotLoadedException (wrapped in a WrappedTargetException),
     612             :         if not.
     613             :     */
     614             :     void    impl_checkLoaded();
     615             : 
     616             : private:
     617             :     void    impl_removeWithoutChecks( const OUString& _rElementName );
     618             : 
     619             : public:
     620             :     SfxLibrary(
     621             :         ModifiableHelper& _rModifiable,
     622             :         const ::com::sun::star::uno::Type& aType,
     623             :         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF,
     624             :         const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >& xSFI
     625             :     );
     626             :     SfxLibrary(
     627             :         ModifiableHelper& _rModifiable,
     628             :         const ::com::sun::star::uno::Type& aType,
     629             :         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF,
     630             :         const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >& xSFI,
     631             :         const OUString& aLibInfoFileURL,
     632             :         const OUString& aStorageURL,
     633             :         sal_Bool ReadOnly
     634             :     );
     635             : 
     636             :     // Methods XInterface
     637             :     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType ) throw( ::com::sun::star::uno::RuntimeException );
     638       12022 :     virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
     639       11788 :     virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
     640             : 
     641             :     // Methods XElementAccess
     642             :     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  )
     643             :         throw(::com::sun::star::uno::RuntimeException);
     644             :     virtual sal_Bool SAL_CALL hasElements(  )
     645             :         throw(::com::sun::star::uno::RuntimeException);
     646             : 
     647             :     // Methods XNameAccess
     648             :     virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
     649             :         throw(::com::sun::star::container::NoSuchElementException,
     650             :               ::com::sun::star::lang::WrappedTargetException,
     651             :               ::com::sun::star::uno::RuntimeException);
     652             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames(  )
     653             :         throw(::com::sun::star::uno::RuntimeException);
     654             :     virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
     655             :         throw(::com::sun::star::uno::RuntimeException);
     656             : 
     657             :     // Methods XNameReplace
     658             :     virtual void SAL_CALL replaceByName( const OUString& aName, const ::com::sun::star::uno::Any& aElement )
     659             :         throw(::com::sun::star::lang::IllegalArgumentException,
     660             :               ::com::sun::star::container::NoSuchElementException,
     661             :               ::com::sun::star::lang::WrappedTargetException,
     662             :               ::com::sun::star::uno::RuntimeException);
     663             : 
     664             :     // Methods XNameContainer
     665             :     virtual void SAL_CALL insertByName( const OUString& aName, const ::com::sun::star::uno::Any& aElement )
     666             :         throw(::com::sun::star::lang::IllegalArgumentException,
     667             :               ::com::sun::star::container::ElementExistException,
     668             :               ::com::sun::star::lang::WrappedTargetException,
     669             :               ::com::sun::star::uno::RuntimeException);
     670             :     virtual void SAL_CALL removeByName( const OUString& Name )
     671             :         throw(::com::sun::star::container::NoSuchElementException,
     672             :               ::com::sun::star::lang::WrappedTargetException,
     673             :               ::com::sun::star::uno::RuntimeException);
     674             : 
     675             :     // XTypeProvider
     676             :     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  )
     677             :         throw( ::com::sun::star::uno::RuntimeException );
     678             :     ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId(  )
     679             :         throw( ::com::sun::star::uno::RuntimeException );
     680             : 
     681             :     // Methods XContainer
     682             :     virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference<
     683             :         ::com::sun::star::container::XContainerListener >& xListener )
     684             :             throw (::com::sun::star::uno::RuntimeException);
     685             :     virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference<
     686             :         ::com::sun::star::container::XContainerListener >& xListener )
     687             :             throw (::com::sun::star::uno::RuntimeException);
     688             : 
     689             :     // Methods XChangesNotifier
     690             :     virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference<
     691             :         ::com::sun::star::util::XChangesListener >& xListener )
     692             :             throw (::com::sun::star::uno::RuntimeException);
     693             :     virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference<
     694             :         ::com::sun::star::util::XChangesListener >& xListener )
     695             :             throw (::com::sun::star::uno::RuntimeException);
     696             : 
     697             : public:
     698           0 :     struct LibraryContainerAccess { friend class SfxLibraryContainer; private: LibraryContainerAccess() { } };
     699           0 :     void    removeElementWithoutChecks( const OUString& _rElementName, LibraryContainerAccess )
     700             :     {
     701           0 :         impl_removeWithoutChecks( _rElementName );
     702           0 :     }
     703             : 
     704             : protected:
     705             :     virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const = 0;
     706             : };
     707             : 
     708             : //============================================================================
     709             : 
     710           0 : class ScriptSubPackageIterator
     711             : {
     712             :     com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > m_xMainPackage;
     713             : 
     714             :     bool m_bIsValid;
     715             :     bool m_bIsBundle;
     716             : 
     717             :     com::sun::star::uno::Sequence< com::sun::star::uno::Reference
     718             :         < com::sun::star::deployment::XPackage > > m_aSubPkgSeq;
     719             :     sal_Int32 m_nSubPkgCount;
     720             :     sal_Int32 m_iNextSubPkg;
     721             : 
     722             :     com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >
     723             :         implDetectScriptPackage( const com::sun::star::uno::Reference
     724             :             < com::sun::star::deployment::XPackage > xPackage, bool& rbPureDialogLib );
     725             : 
     726             : public:
     727             :     ScriptSubPackageIterator( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xMainPackage );
     728             : 
     729             :     com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > getNextScriptSubPackage( bool& rbPureDialogLib );
     730             : };
     731             : 
     732             : //============================================================================
     733             : 
     734          20 : class ScriptExtensionIterator
     735             : {
     736             : public:
     737             :     ScriptExtensionIterator( void );
     738             :     OUString nextBasicOrDialogLibrary( bool& rbPureDialogLib );
     739             : 
     740             : protected:
     741             :     com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >
     742             :         implGetNextUserScriptPackage( bool& rbPureDialogLib );
     743             :     com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >
     744             :         implGetNextSharedScriptPackage( bool& rbPureDialogLib );
     745             :     com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >
     746             :         implGetNextBundledScriptPackage( bool& rbPureDialogLib );
     747             : 
     748             :     com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
     749             : 
     750             :     enum IteratorState
     751             :     {
     752             :         USER_EXTENSIONS,
     753             :         SHARED_EXTENSIONS,
     754             :         BUNDLED_EXTENSIONS,
     755             :         END_REACHED
     756             :     } m_eState;
     757             : 
     758             :     com::sun::star::uno::Sequence< com::sun::star::uno::Reference
     759             :         < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq;
     760             :     bool m_bUserPackagesLoaded;
     761             : 
     762             :     com::sun::star::uno::Sequence< com::sun::star::uno::Reference
     763             :         < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq;
     764             :     bool m_bSharedPackagesLoaded;
     765             : 
     766             :       com::sun::star::uno::Sequence< com::sun::star::uno::Reference
     767             :         < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq;
     768             :     bool m_bBundledPackagesLoaded;
     769             : 
     770             :     int m_iUserPackage;
     771             :     int m_iSharedPackage;
     772             :        int m_iBundledPackage;
     773             : 
     774             :     ScriptSubPackageIterator* m_pScriptSubPackageIterator;
     775             : 
     776             : }; // end class ScriptExtensionIterator
     777             : 
     778             : //============================================================================
     779             : 
     780             : }   // namespace basic
     781             : 
     782             : #endif
     783             : 
     784             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10