LCOV - code coverage report
Current view: top level - basic/source/inc - namecont.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 40 0.0 %
Date: 2014-04-14 Functions: 0 25 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_BASIC_SOURCE_INC_NAMECONT_HXX
      21             : #define INCLUDED_BASIC_SOURCE_INC_NAMECONT_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           0 : class NameContainer : public ::cppu::BaseMutex, public NameContainer_BASE
      73             : {
      74             :     typedef boost::unordered_map < OUString, sal_Int32, 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           0 :     NameContainer( const ::com::sun::star::uno::Type& rType )
      89             :         : mnElementCount( 0 )
      90             :         , mType( rType )
      91             :         , mpxEventSource( NULL )
      92             :         , maContainerListeners( m_aMutex )
      93           0 :         , maChangesListeners( m_aMutex )
      94           0 :     {}
      95             : 
      96           0 :     void setEventSource( ::com::sun::star::uno::XInterface* pxEventSource )
      97           0 :         { mpxEventSource = pxEventSource; }
      98             : 
      99             :     // Methods XElementAccess
     100             :     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  )
     101             :         throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     102             :     virtual sal_Bool SAL_CALL hasElements(  )
     103             :         throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     110             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames(  )
     111             :         throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     112             :     virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
     113             :         throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     148             : };
     149             : 
     150             : 
     151             : 
     152           0 : class ModifiableHelper
     153             : {
     154             : private:
     155             :     ::cppu::OInterfaceContainerHelper   m_aModifyListeners;
     156             :     ::cppu::OWeakObject&                m_rEventSource;
     157             :     bool                                mbModified;
     158             : 
     159             : public:
     160           0 :     ModifiableHelper( ::cppu::OWeakObject& _rEventSource, ::osl::Mutex& _rMutex )
     161             :         :m_aModifyListeners( _rMutex )
     162             :         ,m_rEventSource( _rEventSource )
     163           0 :         ,mbModified( false )
     164             :     {
     165           0 :     }
     166             : 
     167           0 :     inline  bool    isModified() const  { return mbModified; }
     168             :             void    setModified( 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           0 : 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) SAL_OVERRIDE;
     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             :     bool mbVBACompat;
     219             :     OUString msProjectName;
     220             : protected:
     221             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >       mxContext;
     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, 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 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 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 bool implLoadPasswordLibrary( SfxLibrary* pLib, const OUString& Name,
     316             :                                           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 ) SAL_OVERRIDE;
     362             : 
     363             :     // OComponentHelper
     364             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
     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             :     virtual ~SfxLibraryContainer();
     374             : 
     375             : 
     376             :     // Interface to set the BasicManager (Hack for password implementation)
     377           0 :     void setBasicManager( BasicManager* pBasMgr )
     378             :     {
     379           0 :         mpBasMgr = pBasMgr;
     380           0 :     }
     381             : 
     382             :     void    enterMethod();
     383             :     void    leaveMethod();
     384           0 :     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, std::exception) SAL_OVERRIDE;
     390             :     virtual sal_Bool SAL_CALL hasElements()
     391             :         throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     398             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames()
     399             :         throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     400             :     virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
     401             :         throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     407             : 
     408             :     // Methods XModifiable (base of XPersistentLibraryContainer)
     409             :     virtual sal_Bool SAL_CALL isModified(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     410             :     virtual void SAL_CALL setModified( sal_Bool bModified ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     411             :     virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     412             :     virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     413             : 
     414             :     // Methods XPersistentLibraryContainer (base of XStorageBasedLibraryContainer)
     415             :     virtual ::com::sun::star::uno::Any SAL_CALL getRootLocation() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     416             :     virtual OUString SAL_CALL getContainerLocationName() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     417             :     virtual void SAL_CALL storeLibraries(  ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     433             :     virtual sal_Bool SAL_CALL isLibraryReadOnly( const OUString& Name )
     434             :         throw (::com::sun::star::container::NoSuchElementException,
     435             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     459             :     virtual sal_Bool SAL_CALL isLibraryLoaded( const OUString& Name )
     460             :         throw(::com::sun::star::container::NoSuchElementException,
     461             :               ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     505             : 
     506             :     // Methods XServiceInfo
     507             :     virtual OUString SAL_CALL getImplementationName( )
     508             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE = 0;
     509             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
     510             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     511             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
     512             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE = 0;
     513             :     // Methods XVBACompatibility
     514             :     virtual sal_Bool SAL_CALL getVBACompatibilityMode() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     515             :     virtual void SAL_CALL setVBACompatibilityMode( sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     516           0 :     virtual OUString SAL_CALL getProjectName() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE { return msProjectName; }
     517             :     virtual void SAL_CALL setProjectName( const OUString& _projectname ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     518             :     virtual sal_Int32 SAL_CALL getRunningVBAScripts()
     519             :             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     526             :     virtual void SAL_CALL broadcastVBAScriptEvent( sal_Int32 nIdentifier, const OUString& rModuleName )
     527             :             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     528             : };
     529             : 
     530             : 
     531             : 
     532             : class LibraryContainerMethodGuard
     533             : {
     534             : private:
     535             :     SfxLibraryContainer&    m_rContainer;
     536             : public:
     537           0 :     LibraryContainerMethodGuard( SfxLibraryContainer& _rContainer )
     538           0 :         :m_rContainer( _rContainer )
     539             :     {
     540           0 :         m_rContainer.enterMethod();
     541           0 :     }
     542             : 
     543           0 :     ~LibraryContainerMethodGuard()
     544             :     {
     545           0 :         m_rContainer.leaveMethod();
     546           0 :     }
     547             : };
     548             : 
     549             : 
     550             : 
     551           0 : 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::uno::XComponentContext >       mxContext;
     563             :     ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >      mxSFI;
     564             : 
     565             :     ModifiableHelper&   mrModifiable;
     566             :     NameContainer       maNameContainer;
     567             : 
     568             :     bool mbLoaded;
     569             :     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             :     bool mbLink;
     581             :     bool mbReadOnly;
     582             :     bool mbReadOnlyLink;
     583             :     bool mbPreload;
     584             : 
     585             :     bool mbPasswordProtected;
     586             :     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 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  bool    implIsModified() const  { return mbIsModified; }
     605             :             void    implSetModified( 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::uno::XComponentContext >& xContext,
     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::uno::XComponentContext >& xContext,
     630             :         const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >& xSFI,
     631             :         const OUString& aLibInfoFileURL,
     632             :         const OUString& aStorageURL,
     633             :         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, std::exception ) SAL_OVERRIDE;
     638           0 :     virtual void SAL_CALL acquire() throw() SAL_OVERRIDE { OComponentHelper::acquire(); }
     639           0 :     virtual void SAL_CALL release() throw() SAL_OVERRIDE { OComponentHelper::release(); }
     640             : 
     641             :     // Methods XElementAccess
     642             :     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  )
     643             :         throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     644             :     virtual sal_Bool SAL_CALL hasElements(  )
     645             :         throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     652             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames(  )
     653             :         throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     654             :     virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
     655             :         throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     674             : 
     675             :     // XTypeProvider
     676             :     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  )
     677             :         throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     678             :     ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId(  )
     679             :         throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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, std::exception) SAL_OVERRIDE;
     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           0 : 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