2010-10-27 13:11:31 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-17 12:30:48 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-11-08 10:53:37 +00:00
|
|
|
|
2013-10-28 03:54:49 +01:00
|
|
|
#ifndef INCLUDED_BASIC_SOURCE_INC_SCRIPTCONT_HXX
|
|
|
|
#define INCLUDED_BASIC_SOURCE_INC_SCRIPTCONT_HXX
|
2006-11-08 10:53:37 +00:00
|
|
|
|
|
|
|
#include "namecont.hxx"
|
2007-06-27 13:23:39 +00:00
|
|
|
#include <basic/basmgr.hxx>
|
2010-07-27 14:43:33 +02:00
|
|
|
#include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
|
2010-03-02 12:39:31 +00:00
|
|
|
#include <comphelper/uno3.hxx>
|
2006-11-08 10:53:37 +00:00
|
|
|
|
|
|
|
namespace basic
|
|
|
|
{
|
|
|
|
|
2014-02-25 17:41:32 +01:00
|
|
|
|
2011-03-25 10:40:25 +01:00
|
|
|
|
2006-11-08 10:53:37 +00:00
|
|
|
class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPassword
|
|
|
|
{
|
2012-12-30 13:07:28 -02:00
|
|
|
OUString maScriptLanguage;
|
2010-09-20 15:03:23 +02:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > mxCodeNameAccess;
|
2006-11-08 10:53:37 +00:00
|
|
|
|
|
|
|
// Methods to distinguish between deffirent library types
|
2014-03-26 16:37:00 +01:00
|
|
|
virtual SfxLibrary* SAL_CALL implCreateLibrary( const OUString& aName ) SAL_OVERRIDE;
|
2006-11-08 10:53:37 +00:00
|
|
|
virtual SfxLibrary* SAL_CALL implCreateLibraryLink
|
2012-12-30 13:07:28 -02:00
|
|
|
( const OUString& aName, const OUString& aLibInfoFileURL,
|
2014-04-04 16:52:44 +02:00
|
|
|
const OUString& StorageURL, bool ReadOnly ) SAL_OVERRIDE;
|
2015-03-04 09:28:31 +00:00
|
|
|
virtual ::com::sun::star::uno::Any SAL_CALL createEmptyLibraryElement() SAL_OVERRIDE;
|
|
|
|
virtual bool SAL_CALL isLibraryElementValid(const css::uno::Any& rElement) const SAL_OVERRIDE;
|
2006-11-08 10:53:37 +00:00
|
|
|
virtual void SAL_CALL writeLibraryElement
|
|
|
|
(
|
2010-06-15 20:02:53 +02:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary,
|
2012-12-30 13:07:28 -02:00
|
|
|
const OUString& aElementName,
|
2010-06-15 20:02:53 +02:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput
|
2006-11-08 10:53:37 +00:00
|
|
|
)
|
2014-03-26 16:37:00 +01:00
|
|
|
throw(::com::sun::star::uno::Exception) SAL_OVERRIDE;
|
2006-11-08 10:53:37 +00:00
|
|
|
|
|
|
|
virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement
|
2010-06-15 20:02:53 +02:00
|
|
|
(
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary,
|
2012-12-30 13:07:28 -02:00
|
|
|
const OUString& aElementName,
|
|
|
|
const OUString& aFile,
|
2014-03-26 16:37:00 +01:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream ) SAL_OVERRIDE;
|
2006-11-08 10:53:37 +00:00
|
|
|
|
2014-03-26 16:37:00 +01:00
|
|
|
virtual void SAL_CALL importFromOldStorage( const OUString& aFile ) SAL_OVERRIDE;
|
2006-11-08 10:53:37 +00:00
|
|
|
|
2015-04-14 12:44:47 +02:00
|
|
|
virtual SfxLibraryContainer* createInstanceImpl() SAL_OVERRIDE;
|
2006-11-08 10:53:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Password encryption
|
2014-04-04 16:52:44 +02:00
|
|
|
virtual bool implStorePasswordLibrary( SfxLibrary* pLib, const OUString& aName,
|
2014-03-26 16:37:00 +01:00
|
|
|
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;
|
2006-11-08 10:53:37 +00:00
|
|
|
|
|
|
|
// New variant for library export
|
2014-04-04 16:52:44 +02:00
|
|
|
virtual bool implStorePasswordLibrary( SfxLibrary* pLib, const OUString& aName,
|
2006-11-08 10:53:37 +00:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
|
2012-12-30 13:07:28 -02:00
|
|
|
const OUString& aTargetURL,
|
2015-03-09 10:11:00 +00:00
|
|
|
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;
|
2006-11-08 10:53:37 +00:00
|
|
|
|
2014-04-04 16:52:44 +02:00
|
|
|
virtual bool implLoadPasswordLibrary( SfxLibrary* pLib, const OUString& Name,
|
|
|
|
bool bVerifyPasswordOnly=false )
|
2006-11-08 10:53:37 +00:00
|
|
|
throw(::com::sun::star::lang::WrappedTargetException,
|
2015-06-28 16:56:44 +01:00
|
|
|
::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2006-11-08 10:53:37 +00:00
|
|
|
|
2014-03-26 16:37:00 +01:00
|
|
|
virtual void onNewRootStorage() SAL_OVERRIDE;
|
2007-01-02 14:40:51 +00:00
|
|
|
|
|
|
|
|
2006-11-08 10:53:37 +00:00
|
|
|
// OldBasicPassword interface
|
2014-03-26 16:37:00 +01:00
|
|
|
virtual void setLibraryPassword( const OUString& rLibraryName, const OUString& rPassword ) SAL_OVERRIDE;
|
|
|
|
virtual OUString getLibraryPassword( const OUString& rLibraryName ) SAL_OVERRIDE;
|
|
|
|
virtual void clearLibraryPassword( const OUString& rLibraryName ) SAL_OVERRIDE;
|
2014-03-26 08:51:00 +02:00
|
|
|
virtual bool hasLibraryPassword( const OUString& rLibraryName ) SAL_OVERRIDE;
|
2006-11-08 10:53:37 +00:00
|
|
|
|
2014-03-26 16:37:00 +01:00
|
|
|
virtual const sal_Char* SAL_CALL getInfoFileName() const SAL_OVERRIDE;
|
|
|
|
virtual const sal_Char* SAL_CALL getOldInfoFileName() const SAL_OVERRIDE;
|
|
|
|
virtual const sal_Char* SAL_CALL getLibElementFileExtension() const SAL_OVERRIDE;
|
|
|
|
virtual const sal_Char* SAL_CALL getLibrariesDir() const SAL_OVERRIDE;
|
2006-11-08 10:53:37 +00:00
|
|
|
|
|
|
|
public:
|
2015-04-14 12:44:47 +02:00
|
|
|
SfxScriptLibraryContainer();
|
2007-03-15 14:38:46 +00:00
|
|
|
SfxScriptLibraryContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
|
2006-11-08 10:53:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Methods XLibraryContainerPassword
|
2012-12-30 13:07:28 -02:00
|
|
|
virtual sal_Bool SAL_CALL isLibraryPasswordProtected( const OUString& Name )
|
2006-11-08 10:53:37 +00:00
|
|
|
throw (::com::sun::star::container::NoSuchElementException,
|
2014-03-26 16:37:00 +01:00
|
|
|
::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2012-12-30 13:07:28 -02:00
|
|
|
virtual sal_Bool SAL_CALL isLibraryPasswordVerified( const OUString& Name )
|
2006-11-08 10:53:37 +00:00
|
|
|
throw (::com::sun::star::lang::IllegalArgumentException,
|
|
|
|
::com::sun::star::container::NoSuchElementException,
|
2014-03-26 16:37:00 +01:00
|
|
|
::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2012-12-30 13:07:28 -02:00
|
|
|
virtual sal_Bool SAL_CALL verifyLibraryPassword( const OUString& Name, const OUString& Password )
|
2006-11-08 10:53:37 +00:00
|
|
|
throw (::com::sun::star::lang::IllegalArgumentException,
|
|
|
|
::com::sun::star::container::NoSuchElementException,
|
2014-03-26 16:37:00 +01:00
|
|
|
::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2012-12-30 13:07:28 -02:00
|
|
|
virtual void SAL_CALL changeLibraryPassword( const OUString& Name,
|
|
|
|
const OUString& OldPassword, const OUString& NewPassword )
|
2006-11-08 10:53:37 +00:00
|
|
|
throw (::com::sun::star::lang::IllegalArgumentException,
|
|
|
|
::com::sun::star::container::NoSuchElementException,
|
2014-03-26 16:37:00 +01:00
|
|
|
::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2010-10-06 10:16:27 +01:00
|
|
|
// XLibraryQueryExecutable
|
2012-12-30 13:07:28 -02:00
|
|
|
virtual sal_Bool SAL_CALL HasExecutableCode(const OUString&)
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2007-03-15 14:38:46 +00:00
|
|
|
// Methods XServiceInfo
|
2012-12-30 13:07:28 -02:00
|
|
|
virtual OUString SAL_CALL getImplementationName( )
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2012-12-30 13:07:28 -02:00
|
|
|
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
|
2014-03-26 16:37:00 +01:00
|
|
|
throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2006-11-08 10:53:37 +00:00
|
|
|
};
|
|
|
|
|
2014-02-25 17:41:32 +01:00
|
|
|
|
2014-12-27 21:01:22 +00:00
|
|
|
typedef std::unordered_map< OUString, ::com::sun::star::script::ModuleInfo, OUStringHash, ::std::equal_to< OUString > > ModuleInfoMap;
|
2010-03-02 12:39:31 +00:00
|
|
|
|
2011-03-25 10:40:25 +01:00
|
|
|
typedef ::cppu::ImplHelper1< ::com::sun::star::script::vba::XVBAModuleInfo > SfxScriptLibrary_BASE;
|
2006-11-08 10:53:37 +00:00
|
|
|
|
2011-03-25 10:40:25 +01:00
|
|
|
class SfxScriptLibrary : public SfxLibrary, public SfxScriptLibrary_BASE
|
2006-11-08 10:53:37 +00:00
|
|
|
{
|
|
|
|
friend class SfxScriptLibraryContainer;
|
|
|
|
|
2014-12-27 21:01:22 +00:00
|
|
|
typedef std::unordered_map< OUString, ::com::sun::star::script::ModuleInfo, OUStringHash > ModuleInfoMap;
|
2011-03-25 10:40:25 +01:00
|
|
|
|
2012-08-21 22:54:26 +09:00
|
|
|
bool mbLoadedSource;
|
|
|
|
bool mbLoadedBinary;
|
2010-03-02 12:39:31 +00:00
|
|
|
ModuleInfoMap mModuleInfos;
|
2006-11-08 10:53:37 +00:00
|
|
|
|
2007-01-02 14:40:51 +00:00
|
|
|
// Provide modify state including resources
|
2015-04-14 12:44:47 +02:00
|
|
|
virtual bool isModified() SAL_OVERRIDE;
|
|
|
|
virtual void storeResources() SAL_OVERRIDE;
|
2014-03-26 16:37:00 +01:00
|
|
|
virtual void storeResourcesAsURL( const OUString& URL, const OUString& NewName ) SAL_OVERRIDE;
|
2012-12-30 13:07:28 -02:00
|
|
|
virtual void storeResourcesToURL( const OUString& URL,
|
2014-03-26 16:37:00 +01:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ) SAL_OVERRIDE;
|
2007-01-02 14:40:51 +00:00
|
|
|
virtual void storeResourcesToStorage( const ::com::sun::star::uno::Reference
|
2014-03-26 16:37:00 +01:00
|
|
|
< ::com::sun::star::embed::XStorage >& xStorage ) SAL_OVERRIDE;
|
2014-05-21 22:26:05 +02:00
|
|
|
virtual bool isLoadedStorable() SAL_OVERRIDE;
|
2007-01-02 14:40:51 +00:00
|
|
|
|
2006-11-08 10:53:37 +00:00
|
|
|
public:
|
|
|
|
SfxScriptLibrary
|
|
|
|
(
|
2007-03-15 14:38:46 +00:00
|
|
|
ModifiableHelper& _rModifiable,
|
2013-05-13 16:29:28 +02:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
|
2012-11-02 17:46:30 +02:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >& xSFI
|
2006-11-08 10:53:37 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
SfxScriptLibrary
|
|
|
|
(
|
2007-03-15 14:38:46 +00:00
|
|
|
ModifiableHelper& _rModifiable,
|
2013-05-13 16:29:28 +02:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
|
2012-11-02 17:46:30 +02:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >& xSFI,
|
2014-04-04 16:52:44 +02:00
|
|
|
const OUString& aLibInfoFileURL, const OUString& aStorageURL, bool ReadOnly
|
2006-11-08 10:53:37 +00:00
|
|
|
);
|
2008-06-06 12:29:08 +00:00
|
|
|
|
2010-03-02 12:39:31 +00:00
|
|
|
DECLARE_XINTERFACE()
|
|
|
|
DECLARE_XTYPEPROVIDER()
|
|
|
|
|
|
|
|
// XVBAModuleInfo
|
2014-03-26 16:37:00 +01:00
|
|
|
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;
|
|
|
|
virtual sal_Bool SAL_CALL hasModuleInfo( const OUString& ModuleName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
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;
|
|
|
|
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;
|
2010-03-02 12:39:31 +00:00
|
|
|
|
2008-06-06 12:29:08 +00:00
|
|
|
static bool containsValidModule( const ::com::sun::star::uno::Any& _rElement );
|
|
|
|
|
|
|
|
protected:
|
2015-03-04 09:28:31 +00:00
|
|
|
virtual bool SAL_CALL isLibraryElementValid(const css::uno::Any& rElement) const SAL_OVERRIDE;
|
2006-11-08 10:53:37 +00:00
|
|
|
};
|
|
|
|
|
2014-02-25 17:41:32 +01:00
|
|
|
|
2011-03-25 10:40:25 +01:00
|
|
|
|
|
|
|
} // namespace basic
|
2006-11-08 10:53:37 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-10-27 13:11:31 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|