LibreOffice Module basic (master) 1
scriptcont.hxx
Go to the documentation of this file.
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#pragma once
21
22#include "namecont.hxx"
23#include <basic/basmgr.hxx>
24#include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
25#include <comphelper/uno3.hxx>
27
28namespace basic
29{
30
31
33{
34 css::uno::Reference< css::container::XNameAccess > mxCodeNameAccess;
35
36 // Methods to distinguish between different library types
37 virtual rtl::Reference<SfxLibrary> implCreateLibrary( const OUString& aName ) override;
39 ( const OUString& aName, const OUString& aLibInfoFileURL,
40 const OUString& StorageURL, bool ReadOnly ) override;
41 virtual css::uno::Any createEmptyLibraryElement() override;
42 virtual bool isLibraryElementValid(const css::uno::Any& rElement) const override;
43 virtual void writeLibraryElement
44 (
45 const css::uno::Reference< css::container::XNameContainer>& xLibrary,
46 const OUString& aElementName,
47 const css::uno::Reference< css::io::XOutputStream >& xOutput
48 ) override;
49
50 virtual css::uno::Any importLibraryElement
51 (
52 const css::uno::Reference< css::container::XNameContainer>& xLibrary,
53 const OUString& aElementName,
54 const OUString& aFile,
55 const css::uno::Reference< css::io::XInputStream >& xElementStream ) override;
56
57 virtual void importFromOldStorage( const OUString& aFile ) override;
58
60
61
62 // Password encryption
63 virtual bool implStorePasswordLibrary( SfxLibrary* pLib, const OUString& aName,
64 const css::uno::Reference< css::embed::XStorage>& xStorage, const css::uno::Reference< css::task::XInteractionHandler >& Handler ) override;
65
66 // New variant for library export
67 virtual bool implStorePasswordLibrary( SfxLibrary* pLib, const OUString& aName,
68 const css::uno::Reference< css::embed::XStorage >& xStorage,
69 const OUString& aTargetURL,
70 const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& rToUseSFI, const css::uno::Reference< css::task::XInteractionHandler >& Handler ) override;
71
72 virtual bool implLoadPasswordLibrary( SfxLibrary* pLib, const OUString& Name,
73 bool bVerifyPasswordOnly=false ) override;
74
75 virtual void onNewRootStorage() override;
76
77
78 virtual OUString getInfoFileName() const override;
79 virtual OUString getOldInfoFileName() const override;
80 virtual OUString getLibElementFileExtension() const override;
81 virtual OUString getLibrariesDir() const override;
82
83public:
85 SfxScriptLibraryContainer( const css::uno::Reference< css::embed::XStorage >& xStorage );
86
87
88 // Methods XLibraryContainerPassword
89 virtual sal_Bool SAL_CALL isLibraryPasswordProtected( const OUString& Name ) override;
90 virtual sal_Bool SAL_CALL isLibraryPasswordVerified( const OUString& Name ) override;
91 virtual sal_Bool SAL_CALL verifyLibraryPassword( const OUString& Name, const OUString& Password ) override;
92 virtual void SAL_CALL changeLibraryPassword( const OUString& Name,
93 const OUString& OldPassword, const OUString& NewPassword ) override;
94 // XLibraryQueryExecutable
95 virtual sal_Bool SAL_CALL HasExecutableCode(const OUString&) override;
96 // Methods XServiceInfo
97 virtual OUString SAL_CALL getImplementationName( ) override;
98 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
99
100 // Library password handling for 5.0 documents
101 void setLibraryPassword( const OUString& rLibraryName, const OUString& rPassword );
102};
103
104
105typedef std::unordered_map< OUString, css::script::ModuleInfo > ModuleInfoMap;
106
107typedef ::cppu::ImplHelper1< css::script::vba::XVBAModuleInfo > SfxScriptLibrary_BASE;
108
110{
112
113 typedef std::unordered_map< OUString, css::script::ModuleInfo > ModuleInfoMap;
114
118
119 // Provide modify state including resources
120 virtual bool isModified() override;
121 virtual void storeResources() override;
122 virtual void storeResourcesAsURL( const OUString& URL, const OUString& NewName ) override;
123 virtual void storeResourcesToURL( const OUString& URL,
124 const css::uno::Reference< css::task::XInteractionHandler >& xHandler ) override;
125 virtual void storeResourcesToStorage( const css::uno::Reference< css::embed::XStorage >& xStorage ) override;
126 virtual bool isLoadedStorable() override;
127
128public:
130 (
131 ModifiableHelper& _rModifiable,
132 const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& xSFI
133 );
134
136 (
137 ModifiableHelper& _rModifiable,
138 const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& xSFI,
139 const OUString& aLibInfoFileURL, const OUString& aStorageURL, bool ReadOnly
140 );
141
143 DECLARE_XTYPEPROVIDER()
144
145 // XVBAModuleInfo
146 virtual css::script::ModuleInfo SAL_CALL getModuleInfo( const OUString& ModuleName ) override;
147 virtual sal_Bool SAL_CALL hasModuleInfo( const OUString& ModuleName ) override;
148 virtual void SAL_CALL insertModuleInfo( const OUString& ModuleName, const css::script::ModuleInfo& ModuleInfo ) override;
149 virtual void SAL_CALL removeModuleInfo( const OUString& ModuleName ) override;
150
151 static bool containsValidModule( const css::uno::Any& _rElement );
152
153private:
154 virtual bool isLibraryElementValid(const css::uno::Any& rElement) const override;
155};
156
157
158} // namespace basic
159
160/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Any createEmptyLibraryElement() override
Definition: scriptcont.cxx:137
virtual void SAL_CALL changeLibraryPassword(const OUString &Name, const OUString &OldPassword, const OUString &NewPassword) override
Definition: scriptcont.cxx:413
virtual sal_Bool SAL_CALL isLibraryPasswordProtected(const OUString &Name) override
Definition: scriptcont.cxx:352
SfxScriptLibraryContainer(const css::uno::Reference< css::embed::XStorage > &xStorage)
virtual rtl::Reference< SfxLibrary > implCreateLibraryLink(const OUString &aName, const OUString &aLibInfoFileURL, const OUString &StorageURL, bool ReadOnly) override
Definition: scriptcont.cxx:128
virtual rtl::Reference< SfxLibrary > implCreateLibrary(const OUString &aName) override
Definition: scriptcont.cxx:123
virtual bool implLoadPasswordLibrary(SfxLibrary *pLib, const OUString &Name, bool bVerifyPasswordOnly=false) override
Definition: scriptcont.cxx:811
virtual OUString getOldInfoFileName() const override
Definition: scriptcont.cxx:74
virtual bool isLibraryElementValid(const css::uno::Any &rElement) const override
Definition: scriptcont.cxx:144
virtual css::uno::Any importLibraryElement(const css::uno::Reference< css::container::XNameContainer > &xLibrary, const OUString &aElementName, const OUString &aFile, const css::uno::Reference< css::io::XInputStream > &xElementStream) override
Definition: scriptcont.cxx:199
virtual OUString getInfoFileName() const override
Definition: scriptcont.cxx:69
virtual bool implStorePasswordLibrary(SfxLibrary *pLib, const OUString &aName, const css::uno::Reference< css::embed::XStorage > &xStorage, const css::uno::Reference< css::task::XInteractionHandler > &Handler) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Reference< css::container::XNameAccess > mxCodeNameAccess
Definition: scriptcont.hxx:34
virtual OUString getLibElementFileExtension() const override
Definition: scriptcont.cxx:79
void setLibraryPassword(const OUString &rLibraryName, const OUString &rPassword)
Definition: scriptcont.cxx:90
virtual OUString getLibrariesDir() const override
Definition: scriptcont.cxx:84
virtual sal_Bool SAL_CALL verifyLibraryPassword(const OUString &Name, const OUString &Password) override
Definition: scriptcont.cxx:373
virtual void importFromOldStorage(const OUString &aFile) override
Definition: scriptcont.cxx:334
virtual rtl::Reference< SfxLibraryContainer > createInstanceImpl() override
Definition: scriptcont.cxx:329
virtual void writeLibraryElement(const css::uno::Reference< css::container::XNameContainer > &xLibrary, const OUString &aElementName, const css::uno::Reference< css::io::XOutputStream > &xOutput) override
Definition: scriptcont.cxx:149
virtual void onNewRootStorage() override
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL HasExecutableCode(const OUString &) override
virtual bool implStorePasswordLibrary(SfxLibrary *pLib, const OUString &aName, const css::uno::Reference< css::embed::XStorage > &xStorage, const OUString &aTargetURL, const css::uno::Reference< css::ucb::XSimpleFileAccess3 > &rToUseSFI, const css::uno::Reference< css::task::XInteractionHandler > &Handler) override
virtual sal_Bool SAL_CALL isLibraryPasswordVerified(const OUString &Name) override
Definition: scriptcont.cxx:360
SfxScriptLibrary(ModifiableHelper &_rModifiable, const css::uno::Reference< css::ucb::XSimpleFileAccess3 > &xSFI)
virtual bool isLibraryElementValid(const css::uno::Any &rElement) const override
virtual void storeResources() override
virtual sal_Bool SAL_CALL hasModuleInfo(const OUString &ModuleName) override
virtual void SAL_CALL removeModuleInfo(const OUString &ModuleName) override
virtual css::script::ModuleInfo SAL_CALL getModuleInfo(const OUString &ModuleName) override
virtual void storeResourcesToStorage(const css::uno::Reference< css::embed::XStorage > &xStorage) override
virtual void SAL_CALL insertModuleInfo(const OUString &ModuleName, const css::script::ModuleInfo &ModuleInfo) override
virtual bool isLoadedStorable() override
virtual void storeResourcesToURL(const OUString &URL, const css::uno::Reference< css::task::XInteractionHandler > &xHandler) override
static bool containsValidModule(const css::uno::Any &_rElement)
std::unordered_map< OUString, css::script::ModuleInfo > ModuleInfoMap
Definition: scriptcont.hxx:113
virtual void storeResourcesAsURL(const OUString &URL, const OUString &NewName) override
virtual bool isModified() override
ModuleInfoMap mModuleInfo
Definition: scriptcont.hxx:117
SfxScriptLibrary(ModifiableHelper &_rModifiable, const css::uno::Reference< css::ucb::XSimpleFileAccess3 > &xSFI, const OUString &aLibInfoFileURL, const OUString &aStorageURL, bool ReadOnly)
::cppu::ImplHelper1< css::script::vba::XVBAModuleInfo > SfxScriptLibrary_BASE
Definition: scriptcont.hxx:107
std::unordered_map< OUString, css::script::ModuleInfo > ModuleInfoMap
Definition: scriptcont.hxx:105
unsigned char sal_Bool
#define DECLARE_XINTERFACE()