LCOV - code coverage report
Current view: top level - basic/source/inc - scriptcont.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 2 100.0 %
Date: 2015-06-13 12:38:46 Functions: 4 4 100.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_SCRIPTCONT_HXX
      21             : #define INCLUDED_BASIC_SOURCE_INC_SCRIPTCONT_HXX
      22             : 
      23             : #include "namecont.hxx"
      24             : #include <basic/basmgr.hxx>
      25             : #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
      26             : #include <comphelper/uno3.hxx>
      27             : 
      28             : namespace basic
      29             : {
      30             : 
      31             : 
      32             : 
      33        7996 : class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPassword
      34             : {
      35             :     OUString maScriptLanguage;
      36             :     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > mxCodeNameAccess;
      37             : 
      38             :     // Methods to distinguish between deffirent library types
      39             :     virtual SfxLibrary* SAL_CALL implCreateLibrary( const OUString& aName ) SAL_OVERRIDE;
      40             :     virtual SfxLibrary* SAL_CALL implCreateLibraryLink
      41             :         ( const OUString& aName, const OUString& aLibInfoFileURL,
      42             :           const OUString& StorageURL, bool ReadOnly ) SAL_OVERRIDE;
      43             :     virtual ::com::sun::star::uno::Any SAL_CALL createEmptyLibraryElement() SAL_OVERRIDE;
      44             :     virtual bool SAL_CALL isLibraryElementValid(const css::uno::Any& rElement) const SAL_OVERRIDE;
      45             :     virtual void SAL_CALL writeLibraryElement
      46             :     (
      47             :         const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary,
      48             :         const OUString& aElementName,
      49             :         const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput
      50             :     )
      51             :         throw(::com::sun::star::uno::Exception) SAL_OVERRIDE;
      52             : 
      53             :     virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement
      54             :     (
      55             :         const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary,
      56             :         const OUString& aElementName,
      57             :         const OUString& aFile,
      58             :         const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream ) SAL_OVERRIDE;
      59             : 
      60             :     virtual void SAL_CALL importFromOldStorage( const OUString& aFile ) SAL_OVERRIDE;
      61             : 
      62             :     virtual SfxLibraryContainer* createInstanceImpl() SAL_OVERRIDE;
      63             : 
      64             : 
      65             :     // Password encryption
      66             :     virtual bool implStorePasswordLibrary( SfxLibrary* pLib, const OUString& aName,
      67             :                         const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage>& xStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler ) SAL_OVERRIDE;
      68             : 
      69             :     // New variant for library export
      70             :     virtual bool implStorePasswordLibrary( SfxLibrary* pLib, const OUString& aName,
      71             :                         const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
      72             :                         const OUString& aTargetURL,
      73             :                         const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >& rToUseSFI, const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler ) SAL_OVERRIDE;
      74             : 
      75             :     virtual bool implLoadPasswordLibrary( SfxLibrary* pLib, const OUString& Name,
      76             :                                           bool bVerifyPasswordOnly=false )
      77             :             throw(::com::sun::star::lang::WrappedTargetException,
      78             :                   ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
      79             : 
      80             :     virtual void onNewRootStorage() SAL_OVERRIDE;
      81             : 
      82             : 
      83             :     // OldBasicPassword interface
      84             :     virtual void setLibraryPassword( const OUString& rLibraryName, const OUString& rPassword ) SAL_OVERRIDE;
      85             :     virtual OUString getLibraryPassword( const OUString& rLibraryName ) SAL_OVERRIDE;
      86             :     virtual void clearLibraryPassword( const OUString& rLibraryName ) SAL_OVERRIDE;
      87             :     virtual bool hasLibraryPassword( const OUString& rLibraryName ) SAL_OVERRIDE;
      88             : 
      89             :     virtual const sal_Char* SAL_CALL    getInfoFileName() const SAL_OVERRIDE;
      90             :     virtual const sal_Char* SAL_CALL    getOldInfoFileName() const SAL_OVERRIDE;
      91             :     virtual const sal_Char* SAL_CALL    getLibElementFileExtension() const SAL_OVERRIDE;
      92             :     virtual const sal_Char* SAL_CALL    getLibrariesDir() const SAL_OVERRIDE;
      93             : 
      94             : public:
      95             :     SfxScriptLibraryContainer();
      96             :     SfxScriptLibraryContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
      97             : 
      98             : 
      99             :     // Methods XLibraryContainerPassword
     100             :     virtual sal_Bool SAL_CALL isLibraryPasswordProtected( const OUString& Name )
     101             :         throw (::com::sun::star::container::NoSuchElementException,
     102             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     103             :     virtual sal_Bool SAL_CALL isLibraryPasswordVerified( const OUString& Name )
     104             :         throw (::com::sun::star::lang::IllegalArgumentException,
     105             :                ::com::sun::star::container::NoSuchElementException,
     106             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     107             :     virtual sal_Bool SAL_CALL verifyLibraryPassword( const OUString& Name, const OUString& Password )
     108             :         throw (::com::sun::star::lang::IllegalArgumentException,
     109             :                ::com::sun::star::container::NoSuchElementException,
     110             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     111             :     virtual void SAL_CALL changeLibraryPassword( const OUString& Name,
     112             :         const OUString& OldPassword, const OUString& NewPassword )
     113             :         throw (::com::sun::star::lang::IllegalArgumentException,
     114             :                ::com::sun::star::container::NoSuchElementException,
     115             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     116             :     // XLibraryQueryExecutable
     117             :     virtual sal_Bool SAL_CALL HasExecutableCode(const OUString&)
     118             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     119             :     // Methods XServiceInfo
     120             :     virtual OUString SAL_CALL getImplementationName( )
     121             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     122             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
     123             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     124             : };
     125             : 
     126             : 
     127             : typedef std::unordered_map< OUString, ::com::sun::star::script::ModuleInfo, OUStringHash, ::std::equal_to< OUString > > ModuleInfoMap;
     128             : 
     129             : typedef ::cppu::ImplHelper1< ::com::sun::star::script::vba::XVBAModuleInfo > SfxScriptLibrary_BASE;
     130             : 
     131        4946 : class SfxScriptLibrary : public SfxLibrary, public SfxScriptLibrary_BASE
     132             : {
     133             :     friend class SfxScriptLibraryContainer;
     134             : 
     135             :     typedef std::unordered_map< OUString, ::com::sun::star::script::ModuleInfo, OUStringHash > ModuleInfoMap;
     136             : 
     137             :     bool mbLoadedSource;
     138             :     bool mbLoadedBinary;
     139             :     ModuleInfoMap mModuleInfos;
     140             : 
     141             :     // Provide modify state including resources
     142             :     virtual bool isModified() SAL_OVERRIDE;
     143             :     virtual void storeResources() SAL_OVERRIDE;
     144             :     virtual void storeResourcesAsURL( const OUString& URL, const OUString& NewName ) SAL_OVERRIDE;
     145             :     virtual void storeResourcesToURL( const OUString& URL,
     146             :         const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ) SAL_OVERRIDE;
     147             :     virtual void storeResourcesToStorage( const ::com::sun::star::uno::Reference
     148             :         < ::com::sun::star::embed::XStorage >& xStorage ) SAL_OVERRIDE;
     149             :     virtual bool isLoadedStorable() SAL_OVERRIDE;
     150             : 
     151             : public:
     152             :     SfxScriptLibrary
     153             :     (
     154             :         ModifiableHelper& _rModifiable,
     155             :         const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
     156             :         const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >& xSFI
     157             :     );
     158             : 
     159             :     SfxScriptLibrary
     160             :     (
     161             :         ModifiableHelper& _rModifiable,
     162             :         const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
     163             :         const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >& xSFI,
     164             :         const OUString& aLibInfoFileURL, const OUString& aStorageURL, bool ReadOnly
     165             :     );
     166             : 
     167             :     DECLARE_XINTERFACE()
     168             :     DECLARE_XTYPEPROVIDER()
     169             : 
     170             :     // XVBAModuleInfo
     171             :     virtual ::com::sun::star::script::ModuleInfo SAL_CALL getModuleInfo( const OUString& ModuleName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     172             :     virtual sal_Bool SAL_CALL hasModuleInfo( const OUString& ModuleName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     173             :     virtual void SAL_CALL insertModuleInfo( const OUString& ModuleName, const ::com::sun::star::script::ModuleInfo& ModuleInfo ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     174             :     virtual void SAL_CALL removeModuleInfo( const OUString& ModuleName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     175             : 
     176             :     static bool containsValidModule( const ::com::sun::star::uno::Any& _rElement );
     177             : 
     178             : protected:
     179             :     virtual bool SAL_CALL isLibraryElementValid(const css::uno::Any& rElement) const SAL_OVERRIDE;
     180             : };
     181             : 
     182             : 
     183             : 
     184             : }   // namespace basic
     185             : 
     186             : #endif
     187             : 
     188             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11