| 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 <unordered_map> |
| 23 |
#include <com/sun/star/uno/XComponentContext.hpp> |
| 24 |
#include <com/sun/star/lang/XInitialization.hpp> |
| 25 |
#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp> |
| 26 |
#include <com/sun/star/script/XLibraryContainerPassword.hpp> |
| 27 |
#include <com/sun/star/script/XLibraryContainerExport.hpp> |
| 28 |
#include <com/sun/star/script/XLibraryQueryExecutable.hpp> |
| 29 |
#include <com/sun/star/script/XLibraryContainer3.hpp> |
| 30 |
#include <com/sun/star/container/XNameContainer.hpp> |
| 31 |
#include <com/sun/star/container/XContainer.hpp> |
| 32 |
#include <com/sun/star/ucb/XSimpleFileAccess3.hpp> |
| 33 |
#include <com/sun/star/io/XOutputStream.hpp> |
| 34 |
#include <com/sun/star/io/XInputStream.hpp> |
| 35 |
#include <com/sun/star/util/XStringSubstitution.hpp> |
| 36 |
#include <com/sun/star/document/XStorageBasedDocument.hpp> |
| 37 |
#include <com/sun/star/lang/XServiceInfo.hpp> |
| 38 |
#include <com/sun/star/frame/XModel.hpp> |
| 39 |
#include <com/sun/star/deployment/XPackage.hpp> |
| 40 |
#include <com/sun/star/beans/XPropertySet.hpp> |
| 41 |
#include <com/sun/star/script/vba/XVBACompatibility.hpp> |
| 42 |
#include <com/sun/star/script/vba/XVBAScriptListener.hpp> |
| 43 |
#include <com/sun/star/util/XChangesNotifier.hpp> |
| 44 |
|
| 45 |
#include <unotools/eventlisteneradapter.hxx> |
| 46 |
#include <comphelper/compbase.hxx> |
| 47 |
#include <cppuhelper/weakref.hxx> |
| 48 |
#include <rtl/ref.hxx> |
| 49 |
#include <comphelper/interfacecontainer4.hxx> |
| 50 |
#include <xmlscript/xmllib_imexp.hxx> |
| 51 |
|
| 52 |
class BasicManager; |
| 53 |
|
| 54 |
namespace basic |
| 55 |
{ |
| 56 |
class NameContainer final |
| 57 |
{ |
| 58 |
cppu::OWeakObject& rOwner; |
| 59 |
|
| 60 |
std::unordered_map<OUString, css::uno::Any> maMap; |
| 61 |
|
| 62 |
css::uno::Type mType; |
| 63 |
css::uno::XInterface* mpxEventSource; |
| 64 |
|
| 65 |
::comphelper::OInterfaceContainerHelper4<css::container::XContainerListener> maContainerListeners; |
| 66 |
::comphelper::OInterfaceContainerHelper4<css::util::XChangesListener> maChangesListeners; |
| 67 |
|
| 68 |
public: |
| 69 |
NameContainer(const css::uno::Type& rType, cppu::OWeakObject& owner) |
| 70 |
: rOwner(owner) |
| 71 |
, mType( rType ) |
| 72 |
, mpxEventSource( nullptr ) |
| 73 |
{} |
| 74 |
|
| 75 |
void setEventSource( css::uno::XInterface* pxEventSource ) |
| 76 |
{ mpxEventSource = pxEventSource; } |
| 77 |
|
| 78 |
/// @throws css::lang::IllegalArgumentException |
| 79 |
/// @throws css::lang::WrappedTargetException |
| 80 |
/// @throws css::uno::RuntimeException |
| 81 |
void insertNoCheck(const OUString& aName, const css::uno::Any& aElement, |
| 82 |
std::unique_lock<std::mutex>& guard); |
| 83 |
|
| 84 |
// Methods XElementAccess |
| 85 |
css::uno::Type getElementType(); |
| 86 |
sal_Bool hasElements(); |
| 87 |
|
| 88 |
// Methods XNameAccess |
| 89 |
css::uno::Any getByName(const OUString& aName); |
| 90 |
css::uno::Sequence<OUString> getElementNames(); |
| 91 |
sal_Bool hasByName(const OUString& aName); |
| 92 |
|
| 93 |
// Methods XNameReplace |
| 94 |
void replaceByName(const OUString& aName, const css::uno::Any& aElement, |
| 95 |
std::unique_lock<std::mutex>& guard); |
| 96 |
|
| 97 |
// Methods XNameContainer |
| 98 |
void insertByName(const OUString& aName, const css::uno::Any& aElement, |
| 99 |
std::unique_lock<std::mutex>& guard); |
| 100 |
void removeByName(const OUString& Name, std::unique_lock<std::mutex>& guard); |
| 101 |
|
| 102 |
// Methods XContainer |
| 103 |
void addContainerListener( |
| 104 |
const css::uno::Reference<css::container::XContainerListener>& xListener, |
| 105 |
std::unique_lock<std::mutex>& guard); |
| 106 |
void removeContainerListener( |
| 107 |
const css::uno::Reference<css::container::XContainerListener>& xListener, |
| 108 |
std::unique_lock<std::mutex>& guard); |
| 109 |
|
| 110 |
// Methods XChangesNotifier |
| 111 |
void addChangesListener(const css::uno::Reference<css::util::XChangesListener>& xListener, |
| 112 |
std::unique_lock<std::mutex>& guard); |
| 113 |
void removeChangesListener(const css::uno::Reference<css::util::XChangesListener>& xListener, |
| 114 |
std::unique_lock<std::mutex>& guard); |
| 115 |
}; |
| 116 |
|
| 117 |
|
| 118 |
class ModifiableHelper |
| 119 |
{ |
| 120 |
private: |
| 121 |
comphelper::OInterfaceContainerHelper4<css::util::XModifyListener> m_aModifyListeners; |
| 122 |
::cppu::OWeakObject& m_rEventSource; |
| 123 |
bool mbModified; |
| 124 |
|
| 125 |
public: |
| 126 |
ModifiableHelper( ::cppu::OWeakObject& _rEventSource ) |
| 127 |
:m_rEventSource( _rEventSource ) |
| 128 |
,mbModified( false ) |
| 129 |
{ |
| 130 |
} |
| 131 |
|
| 132 |
bool isModified() const { return mbModified; } |
| 133 |
void setModified( bool _bModified, std::unique_lock<std::mutex>& guard ); |
| 134 |
|
| 135 |
void addModifyListener( const css::uno::Reference< css::util::XModifyListener >& _rxListener, std::unique_lock<std::mutex>& guard ) |
| 136 |
{ |
| 137 |
m_aModifyListeners.addInterface(guard, _rxListener); |
| 138 |
} |
| 139 |
|
| 140 |
void removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& _rxListener, std::unique_lock<std::mutex>& guard ) |
| 141 |
{ |
| 142 |
m_aModifyListeners.removeInterface(guard, _rxListener); |
| 143 |
} |
| 144 |
}; |
| 145 |
|
| 146 |
|
| 147 |
typedef comphelper::OInterfaceContainerHelper4< |
| 148 |
css::script::vba::XVBAScriptListener > VBAScriptListenerContainer; |
| 149 |
|
| 150 |
class SfxLibrary; |
| 151 |
|
| 152 |
typedef comphelper::WeakComponentImplHelper< |
| 153 |
css::lang::XInitialization, |
| 154 |
css::script::XStorageBasedLibraryContainer, |
| 155 |
css::script::XLibraryContainerPassword, |
| 156 |
css::script::XLibraryContainerExport, |
| 157 |
css::script::XLibraryContainer3, |
| 158 |
css::container::XContainer, |
| 159 |
css::script::XLibraryQueryExecutable, |
| 160 |
css::script::vba::XVBACompatibility, |
| 161 |
css::lang::XServiceInfo, |
| 162 |
css::beans::XPropertySet> SfxLibraryContainer_BASE; |
| 163 |
|
| 164 |
class SfxLibraryContainer |
| 165 |
: public SfxLibraryContainer_BASE |
| 166 |
, public ::utl::OEventListenerAdapter |
| 167 |
{ |
| 168 |
VBAScriptListenerContainer maVBAScriptListeners; |
| 169 |
sal_Int32 mnRunningVBAScripts; |
| 170 |
bool mbVBACompat; |
| 171 |
rtl_TextEncoding meVBATextEncoding; |
| 172 |
OUString msProjectName; |
| 173 |
protected: |
| 174 |
css::uno::Reference< css::uno::XComponentContext > mxContext; |
| 175 |
css::uno::Reference< css::ucb::XSimpleFileAccess3 > mxSFI; |
| 176 |
css::uno::Reference< css::util::XStringSubstitution > mxStringSubstitution; |
| 177 |
css::uno::WeakReference< css::frame::XModel > mxOwnerDocument; |
| 178 |
|
| 179 |
ModifiableHelper maModifiable; |
| 180 |
|
| 181 |
NameContainer maNameContainer; |
| 182 |
|
| 183 |
OUString maInitialDocumentURL; |
| 184 |
OUString maInfoFileName; |
| 185 |
OUString maOldInfoFileName; |
| 186 |
OUString maLibElementFileExtension; |
| 187 |
OUString maLibraryPath; |
| 188 |
OUString maLibrariesDir; |
| 189 |
|
| 190 |
css::uno::Reference< css::embed::XStorage > mxStorage; |
| 191 |
BasicManager* mpBasMgr; |
| 192 |
bool mbOwnBasMgr; |
| 193 |
|
| 194 |
bool mbOldInfoFormat; |
| 195 |
bool mbOasis2OOoFormat; |
| 196 |
|
| 197 |
enum InitMode |
| 198 |
{ |
| 199 |
DEFAULT, |
| 200 |
CONTAINER_INIT_FILE, |
| 201 |
LIBRARY_INIT_FILE, |
| 202 |
OFFICE_DOCUMENT, |
| 203 |
OLD_BASIC_STORAGE |
| 204 |
} meInitMode; |
| 205 |
|
| 206 |
void implStoreLibrary( SfxLibrary* pLib, |
| 207 |
std::u16string_view rName, |
| 208 |
const css::uno::Reference< css::embed::XStorage >& rStorage ); |
| 209 |
|
| 210 |
// New variant for library export |
| 211 |
void implStoreLibrary( SfxLibrary* pLib, |
| 212 |
std::u16string_view rName, |
| 213 |
const css::uno::Reference< css::embed::XStorage >& rStorage, |
| 214 |
std::u16string_view rTargetURL, |
| 215 |
const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& rToUseSFI, |
| 216 |
const css::uno::Reference< css::task::XInteractionHandler >& rHandler ); |
| 217 |
|
| 218 |
void implStoreLibraryIndexFile( SfxLibrary* pLib, const ::xmlscript::LibDescriptor& rLib, |
| 219 |
const css::uno::Reference< css::embed::XStorage >& xStorage ); |
| 220 |
|
| 221 |
// New variant for library export |
| 222 |
void implStoreLibraryIndexFile( SfxLibrary* pLib, const ::xmlscript::LibDescriptor& rLib, |
| 223 |
const css::uno::Reference< css::embed::XStorage >& xStorage, |
| 224 |
std::u16string_view aTargetURL, |
| 225 |
const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& rToUseSFI ); |
| 226 |
|
| 227 |
bool implLoadLibraryIndexFile( SfxLibrary* pLib, |
| 228 |
::xmlscript::LibDescriptor& rLib, |
| 229 |
const css::uno::Reference< css::embed::XStorage >& xStorage, |
| 230 |
const OUString& aIndexFileName, |
| 231 |
std::unique_lock<std::mutex>& guard ); |
| 232 |
|
| 233 |
void implImportLibDescriptor(SfxLibrary* pLib, ::xmlscript::LibDescriptor const& rLib, |
| 234 |
std::unique_lock<std::mutex>& guard); |
| 235 |
|
| 236 |
// Methods to distinguish between different library types |
| 237 |
virtual rtl::Reference<SfxLibrary> implCreateLibrary( const OUString& aName ) = 0; |
| 238 |
virtual rtl::Reference<SfxLibrary> implCreateLibraryLink |
| 239 |
( const OUString& aName, const OUString& aLibInfoFileURL, |
| 240 |
const OUString& StorageURL, bool ReadOnly ) = 0; |
| 241 |
virtual css::uno::Any createEmptyLibraryElement() = 0; |
| 242 |
virtual bool isLibraryElementValid(const css::uno::Any& rElement) const = 0; |
| 243 |
/// @throws css::uno::Exception |
| 244 |
virtual void writeLibraryElement |
| 245 |
( |
| 246 |
const css::uno::Reference< css::container::XNameContainer>& xLibrary, |
| 247 |
const OUString& aElementName, |
| 248 |
const css::uno::Reference< css::io::XOutputStream >& xOutput |
| 249 |
) = 0; |
| 250 |
|
| 251 |
virtual css::uno::Any importLibraryElement |
| 252 |
( |
| 253 |
const css::uno::Reference< css::container::XNameContainer>& xLibrary, |
| 254 |
const OUString& aElementName, |
| 255 |
const OUString& aFile, |
| 256 |
const css::uno::Reference< css::io::XInputStream >& xElementStream ) = 0; |
| 257 |
virtual void importFromOldStorage( const OUString& aFile ) = 0; |
| 258 |
|
| 259 |
// Password encryption |
| 260 |
virtual bool implStorePasswordLibrary( SfxLibrary* pLib, const OUString& aName, |
| 261 |
const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Reference< css::task::XInteractionHandler >& Handler ); |
| 262 |
|
| 263 |
// New variant for library export |
| 264 |
virtual bool implStorePasswordLibrary( SfxLibrary* pLib, const OUString& aName, |
| 265 |
const css::uno::Reference< css::embed::XStorage >& rStorage, |
| 266 |
const OUString& aTargetURL, |
| 267 |
const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& rToUseSFI, const css::uno::Reference< css::task::XInteractionHandler >& Handler ); |
| 268 |
|
| 269 |
/// @throws css::lang::WrappedTargetException |
| 270 |
/// @throws css::uno::RuntimeException |
| 271 |
virtual bool implLoadPasswordLibrary( SfxLibrary* pLib, const OUString& Name, |
| 272 |
bool bVerifyPasswordOnly, |
| 273 |
std::unique_lock<std::mutex>& guard ); |
| 274 |
|
| 275 |
virtual void onNewRootStorage() = 0; |
| 276 |
|
| 277 |
|
| 278 |
// #56666, Creates another library container |
| 279 |
// instance of the same derived class |
| 280 |
virtual rtl::Reference<SfxLibraryContainer> createInstanceImpl() = 0; |
| 281 |
|
| 282 |
|
| 283 |
// Interface to get the BasicManager (Hack for password implementation) |
| 284 |
BasicManager* getBasicManager(); |
| 285 |
OUString createAppLibraryFolder( SfxLibrary* pLib, std::u16string_view aName ); |
| 286 |
|
| 287 |
void init( const OUString& rInitialDocumentURL, |
| 288 |
const css::uno::Reference< css::embed::XStorage >& _rxInitialStorage, |
| 289 |
std::unique_lock<std::mutex>& guard ); |
| 290 |
|
| 291 |
virtual OUString getInfoFileName() const = 0; |
| 292 |
virtual OUString getOldInfoFileName() const = 0; |
| 293 |
virtual OUString getLibElementFileExtension() const = 0; |
| 294 |
virtual OUString getLibrariesDir() const = 0; |
| 295 |
|
| 296 |
// Handle maLibInfoFileURL and maStorageURL correctly |
| 297 |
void checkStorageURL |
| 298 |
( |
| 299 |
const OUString& aSourceURL, |
| 300 |
OUString& aLibInfoFileURL, |
| 301 |
OUString& aStorageURL, |
| 302 |
OUString& aUnexpandedStorageURL |
| 303 |
); |
| 304 |
/// @throws css::uno::RuntimeException |
| 305 |
OUString expand_url( const OUString& url ); |
| 306 |
|
| 307 |
SfxLibrary* getImplLib( const OUString& rLibraryName ); |
| 308 |
|
| 309 |
void storeLibraries_Impl( |
| 310 |
const css::uno::Reference< css::embed::XStorage >& xStorage, |
| 311 |
bool bComplete, |
| 312 |
std::unique_lock<std::mutex>& guard ); |
| 313 |
|
| 314 |
void initializeFromDocument( const css::uno::Reference< css::document::XStorageBasedDocument >& _rxDocument, |
| 315 |
std::unique_lock<std::mutex>& guard ); |
| 316 |
|
| 317 |
css::uno::Reference<css::container::XNameContainer> |
| 318 |
createLibrary_Impl(const OUString& Name, std::unique_lock<std::mutex>& guard); |
| 319 |
css::uno::Reference<css::container::XNameAccess> |
| 320 |
createLibraryLink_Impl(const OUString& Name, const OUString& StorageURL, sal_Bool ReadOnly, |
| 321 |
std::unique_lock<std::mutex>& guard); |
| 322 |
void loadLibrary_Impl(const OUString& Name, std::unique_lock<std::mutex>& guard); |
| 323 |
|
| 324 |
|
| 325 |
// OEventListenerAdapter |
| 326 |
virtual void _disposing( const css::lang::EventObject& _rSource ) override; |
| 327 |
|
| 328 |
// WeakComponentImplHelperBase |
| 329 |
virtual void disposing(std::unique_lock<std::mutex>& guard) override; |
| 330 |
|
| 331 |
private: |
| 332 |
void init_Impl( const OUString& rInitialDocumentURL, |
| 333 |
const css::uno::Reference< css::embed::XStorage >& _rxInitialStorage, |
| 334 |
std::unique_lock<std::mutex>& guard ); |
| 335 |
void implScanExtensions(std::unique_lock<std::mutex>& guard); |
| 336 |
static constexpr OUString sVBATextEncodingPropName = u"VBATextEncoding"_ustr; |
| 337 |
|
| 338 |
public: |
| 339 |
SfxLibraryContainer(); |
| 340 |
virtual ~SfxLibraryContainer() override; |
| 341 |
|
| 342 |
|
| 343 |
// Interface to set the BasicManager (Hack for password implementation) |
| 344 |
void setBasicManager( BasicManager* pBasMgr ) |
| 345 |
{ |
| 346 |
mpBasMgr = pBasMgr; |
| 347 |
} |
| 348 |
|
| 349 |
void enterMethod(); |
| 350 |
static void leaveMethod(); |
| 351 |
|
| 352 |
// Methods XElementAccess |
| 353 |
virtual css::uno::Type SAL_CALL getElementType() override; |
| 354 |
virtual sal_Bool SAL_CALL hasElements() override; |
| 355 |
|
| 356 |
// Methods XNameAccess |
| 357 |
virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; |
| 358 |
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; |
| 359 |
virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; |
| 360 |
|
| 361 |
// Members XStorageBasedLibraryContainer |
| 362 |
virtual css::uno::Reference< css::embed::XStorage > SAL_CALL getRootStorage() override; |
| 363 |
virtual void SAL_CALL setRootStorage( const css::uno::Reference< css::embed::XStorage >& _rootstorage ) override; |
| 364 |
virtual void SAL_CALL storeLibrariesToStorage( const css::uno::Reference< css::embed::XStorage >& RootStorage ) override; |
| 365 |
|
| 366 |
// Methods XModifiable (base of XPersistentLibraryContainer) |
| 367 |
virtual sal_Bool SAL_CALL isModified( ) override; |
| 368 |
virtual void SAL_CALL setModified( sal_Bool bModified ) override; |
| 369 |
virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; |
| 370 |
virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; |
| 371 |
|
| 372 |
// Methods XPersistentLibraryContainer (base of XStorageBasedLibraryContainer) |
| 373 |
virtual css::uno::Any SAL_CALL getRootLocation() override; |
| 374 |
virtual OUString SAL_CALL getContainerLocationName() override; |
| 375 |
virtual void SAL_CALL storeLibraries( ) override; |
| 376 |
|
| 377 |
//Methods XLibraryContainer3 |
| 378 |
virtual OUString SAL_CALL getOriginalLibraryLinkURL( const OUString& Name ) override; |
| 379 |
|
| 380 |
// Methods XLibraryContainer2 (base of XPersistentLibraryContainer) |
| 381 |
virtual sal_Bool SAL_CALL isLibraryLink( const OUString& Name ) override; |
| 382 |
virtual OUString SAL_CALL getLibraryLinkURL( const OUString& Name ) override; |
| 383 |
virtual sal_Bool SAL_CALL isLibraryReadOnly( const OUString& Name ) override; |
| 384 |
virtual void SAL_CALL setLibraryReadOnly( const OUString& Name, sal_Bool bReadOnly ) override; |
| 385 |
virtual void SAL_CALL renameLibrary( const OUString& Name, const OUString& NewName ) override; |
| 386 |
|
| 387 |
// Methods XLibraryContainer (base of XLibraryContainer2) |
| 388 |
virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL |
| 389 |
createLibrary( const OUString& Name ) override; |
| 390 |
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL createLibraryLink |
| 391 |
( const OUString& Name, const OUString& StorageURL, sal_Bool ReadOnly ) override; |
| 392 |
virtual void SAL_CALL removeLibrary( const OUString& Name ) override; |
| 393 |
virtual sal_Bool SAL_CALL isLibraryLoaded( const OUString& Name ) override; |
| 394 |
virtual void SAL_CALL loadLibrary( const OUString& Name ) override; |
| 395 |
|
| 396 |
// Methods XInitialization |
| 397 |
virtual void SAL_CALL initialize( const css::uno::Sequence< |
| 398 |
css::uno::Any >& aArguments ) override; |
| 399 |
|
| 400 |
// Methods XLibraryContainerPassword |
| 401 |
virtual sal_Bool SAL_CALL isLibraryPasswordProtected( const OUString& Name ) override; |
| 402 |
virtual sal_Bool SAL_CALL isLibraryPasswordVerified( const OUString& Name ) override; |
| 403 |
virtual sal_Bool SAL_CALL verifyLibraryPassword( const OUString& Name, const OUString& Password ) override; |
| 404 |
virtual void SAL_CALL changeLibraryPassword( const OUString& Name, |
| 405 |
const OUString& OldPassword, const OUString& NewPassword ) override; |
| 406 |
|
| 407 |
// Methods XContainer |
| 408 |
virtual void SAL_CALL addContainerListener( const css::uno::Reference< |
| 409 |
css::container::XContainerListener >& xListener ) override; |
| 410 |
virtual void SAL_CALL removeContainerListener( const css::uno::Reference< |
| 411 |
css::container::XContainerListener >& xListener ) override; |
| 412 |
|
| 413 |
// Methods XLibraryContainerExport |
| 414 |
virtual void SAL_CALL exportLibrary( const OUString& Name, const OUString& URL, |
| 415 |
const css::uno::Reference< css::task::XInteractionHandler >& Handler ) override; |
| 416 |
|
| 417 |
// Methods XServiceInfo |
| 418 |
virtual OUString SAL_CALL getImplementationName( ) override = 0; |
| 419 |
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; |
| 420 |
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override = 0; |
| 421 |
// Methods XVBACompatibility |
| 422 |
virtual sal_Bool SAL_CALL getVBACompatibilityMode() override; |
| 423 |
virtual void SAL_CALL setVBACompatibilityMode( sal_Bool _vbacompatmodeon ) override; |
| 424 |
virtual OUString SAL_CALL getProjectName() override { return msProjectName; } |
| 425 |
virtual void SAL_CALL setProjectName( const OUString& _projectname ) override; |
| 426 |
virtual sal_Int32 SAL_CALL getRunningVBAScripts() override; |
| 427 |
virtual void SAL_CALL addVBAScriptListener( |
| 428 |
const css::uno::Reference< css::script::vba::XVBAScriptListener >& Listener ) override; |
| 429 |
virtual void SAL_CALL removeVBAScriptListener( |
| 430 |
const css::uno::Reference< css::script::vba::XVBAScriptListener >& Listener ) override; |
| 431 |
virtual void SAL_CALL broadcastVBAScriptEvent( sal_Int32 nIdentifier, const OUString& rModuleName ) override; |
| 432 |
|
| 433 |
// css::beans::XPropertySet |
| 434 |
virtual css::uno::Reference<css::beans::XPropertySetInfo> |
| 435 |
SAL_CALL getPropertySetInfo() override; |
| 436 |
virtual void SAL_CALL setPropertyValue(const OUString& aPropertyName, |
| 437 |
const css::uno::Any& aValue) override; |
| 438 |
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& PropertyName) override; |
| 439 |
virtual void SAL_CALL addPropertyChangeListener( |
| 440 |
const OUString& aPropertyName, |
| 441 |
const css::uno::Reference<css::beans::XPropertyChangeListener>& xListener) override; |
| 442 |
virtual void SAL_CALL removePropertyChangeListener( |
| 443 |
const OUString& aPropertyName, |
| 444 |
const css::uno::Reference<css::beans::XPropertyChangeListener>& aListener) override; |
| 445 |
virtual void SAL_CALL addVetoableChangeListener( |
| 446 |
const OUString& PropertyName, |
| 447 |
const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener) override; |
| 448 |
virtual void SAL_CALL removeVetoableChangeListener( |
| 449 |
const OUString& PropertyName, |
| 450 |
const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener) override; |
| 451 |
|
| 452 |
}; |
| 453 |
|
| 454 |
|
| 455 |
class LibraryContainerMethodGuard |
| 456 |
{ |
| 457 |
public: |
| 458 |
LibraryContainerMethodGuard( SfxLibraryContainer& _rContainer ) |
| 459 |
{ |
| 460 |
_rContainer.enterMethod(); |
| 461 |
} |
| 462 |
|
| 463 |
~LibraryContainerMethodGuard() |
| 464 |
{ |
| 465 |
basic::SfxLibraryContainer::leaveMethod(); |
| 466 |
} |
| 467 |
}; |
| 468 |
|
| 469 |
|
| 470 |
class SfxLibrary |
| 471 |
: public comphelper::WeakComponentImplHelper< |
| 472 |
css::container::XNameContainer, css::container::XContainer, css::util::XChangesNotifier> |
| 473 |
{ |
| 474 |
friend class SfxLibraryContainer; |
| 475 |
friend class SfxDialogLibraryContainer; |
| 476 |
friend class SfxScriptLibraryContainer; |
| 477 |
|
| 478 |
css::uno::Reference< css::ucb::XSimpleFileAccess3 > mxSFI; |
| 479 |
|
| 480 |
ModifiableHelper& mrModifiable; |
| 481 |
NameContainer maNameContainer; |
| 482 |
|
| 483 |
bool mbLoaded; |
| 484 |
bool mbIsModified; |
| 485 |
bool mbInitialised; |
| 486 |
bool mbLink; |
| 487 |
bool mbReadOnly; |
| 488 |
bool mbReadOnlyLink; |
| 489 |
bool mbPreload; |
| 490 |
bool mbPasswordProtected; |
| 491 |
bool mbPasswordVerified; |
| 492 |
bool mbDoc50Password; |
| 493 |
bool mbSharedIndexFile; |
| 494 |
bool mbExtension; |
| 495 |
|
| 496 |
private: |
| 497 |
|
| 498 |
OUString maLibElementFileExtension; |
| 499 |
OUString maLibInfoFileURL; |
| 500 |
OUString maStorageURL; |
| 501 |
OUString maUnexpandedStorageURL; |
| 502 |
OUString maOriginalStorageURL; |
| 503 |
OUString maPassword; |
| 504 |
|
| 505 |
// Additional functionality for localisation |
| 506 |
// Provide modify state including resources |
| 507 |
virtual bool isModified() = 0; |
| 508 |
virtual void storeResources() = 0; |
| 509 |
virtual void storeResourcesAsURL( const OUString& URL, const OUString& NewName ) = 0; |
| 510 |
virtual void storeResourcesToURL( const OUString& URL, |
| 511 |
const css::uno::Reference< css::task::XInteractionHandler >& xHandler ) = 0; |
| 512 |
virtual void storeResourcesToStorage( const css::uno::Reference< css::embed::XStorage >& xStorage ) = 0; |
| 513 |
|
| 514 |
protected: |
| 515 |
bool implIsModified() const { return mbIsModified; } |
| 516 |
void implSetModified(bool _bIsModified, std::unique_lock<std::mutex>& guard); |
| 517 |
bool isPasswordProtected() const { return mbPasswordProtected; } |
| 518 |
|
| 519 |
private: |
| 520 |
/** checks whether the lib is readonly, or a readonly link, throws an IllegalArgumentException if so |
| 521 |
*/ |
| 522 |
void impl_checkReadOnly(); |
| 523 |
/** checks whether the library is loaded, throws a LibraryNotLoadedException (wrapped in a WrappedTargetException), |
| 524 |
if not. |
| 525 |
*/ |
| 526 |
void impl_checkLoaded(); |
| 527 |
|
| 528 |
private: |
| 529 |
void impl_removeWithoutChecks(const OUString& _rElementName, |
| 530 |
std::unique_lock<std::mutex>& guard); |
| 531 |
|
| 532 |
public: |
| 533 |
SfxLibrary( |
| 534 |
ModifiableHelper& _rModifiable, |
| 535 |
const css::uno::Type& aType, |
| 536 |
const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& xSFI |
| 537 |
); |
| 538 |
SfxLibrary( |
| 539 |
ModifiableHelper& _rModifiable, |
| 540 |
const css::uno::Type& aType, |
| 541 |
const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& xSFI, |
| 542 |
OUString aLibInfoFileURL, |
| 543 |
OUString aStorageURL, |
| 544 |
bool ReadOnly |
| 545 |
); |
| 546 |
|
| 547 |
// Methods XElementAccess |
| 548 |
virtual css::uno::Type SAL_CALL getElementType( ) override; |
| 549 |
virtual sal_Bool SAL_CALL hasElements( ) override; |
| 550 |
|
| 551 |
// Methods XNameAccess |
| 552 |
virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; |
| 553 |
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override; |
| 554 |
virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; |
| 555 |
|
| 556 |
// Methods XNameReplace |
| 557 |
virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override; |
| 558 |
|
| 559 |
// Methods XNameContainer |
| 560 |
virtual void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override; |
| 561 |
virtual void SAL_CALL removeByName( const OUString& Name ) override; |
| 562 |
|
| 563 |
// Methods XContainer |
| 564 |
virtual void SAL_CALL addContainerListener( const css::uno::Reference< |
| 565 |
css::container::XContainerListener >& xListener ) override; |
| 566 |
virtual void SAL_CALL removeContainerListener( const css::uno::Reference< |
| 567 |
css::container::XContainerListener >& xListener ) override; |
| 568 |
|
| 569 |
// Methods XChangesNotifier |
| 570 |
virtual void SAL_CALL addChangesListener( const css::uno::Reference< |
| 571 |
css::util::XChangesListener >& xListener ) override; |
| 572 |
virtual void SAL_CALL removeChangesListener( const css::uno::Reference< |
| 573 |
css::util::XChangesListener >& xListener ) override; |
| 574 |
|
| 575 |
protected: |
| 576 |
virtual bool isLoadedStorable(); |
| 577 |
|
| 578 |
virtual bool isLibraryElementValid(const css::uno::Any& rElement) const = 0; |
| 579 |
}; |
| 580 |
|
| 581 |
|
| 582 |
class ScriptSubPackageIterator |
| 583 |
{ |
| 584 |
css::uno::Reference< css::deployment::XPackage > m_xMainPackage; |
| 585 |
|
| 586 |
bool m_bIsValid; |
| 587 |
bool m_bIsBundle; |
| 588 |
|
| 589 |
css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > m_aSubPkgSeq; |
| 590 |
sal_Int32 m_nSubPkgCount; |
| 591 |
sal_Int32 m_iNextSubPkg; |
| 592 |
|
| 593 |
static css::uno::Reference< css::deployment::XPackage > |
| 594 |
implDetectScriptPackage( const css::uno::Reference |
| 595 |
< css::deployment::XPackage >& rPackage, bool& rbPureDialogLib ); |
| 596 |
|
| 597 |
public: |
| 598 |
ScriptSubPackageIterator( css::uno::Reference< css::deployment::XPackage > const & xMainPackage ); |
| 599 |
|
| 600 |
css::uno::Reference< css::deployment::XPackage > getNextScriptSubPackage( bool& rbPureDialogLib ); |
| 601 |
}; |
| 602 |
|
| 603 |
|
| 604 |
class ScriptExtensionIterator final |
| 605 |
{ |
| 606 |
public: |
| 607 |
ScriptExtensionIterator(); |
| 608 |
OUString nextBasicOrDialogLibrary( bool& rbPureDialogLib ); |
| 609 |
|
| 610 |
private: |
| 611 |
css::uno::Reference< css::deployment::XPackage > |
| 612 |
implGetNextUserScriptPackage( bool& rbPureDialogLib ); |
| 613 |
css::uno::Reference< css::deployment::XPackage > |
| 614 |
implGetNextSharedScriptPackage( bool& rbPureDialogLib ); |
| 615 |
css::uno::Reference< css::deployment::XPackage > |
| 616 |
implGetNextBundledScriptPackage( bool& rbPureDialogLib ); |
| 617 |
|
| 618 |
css::uno::Reference< css::uno::XComponentContext > m_xContext; |
| 619 |
|
| 620 |
enum IteratorState |
| 621 |
{ |
| 622 |
USER_EXTENSIONS, |
| 623 |
SHARED_EXTENSIONS, |
| 624 |
BUNDLED_EXTENSIONS, |
| 625 |
END_REACHED |
| 626 |
} m_eState; |
| 627 |
|
| 628 |
css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > m_aUserPackagesSeq; |
| 629 |
bool m_bUserPackagesLoaded; |
| 630 |
|
| 631 |
css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > m_aSharedPackagesSeq; |
| 632 |
bool m_bSharedPackagesLoaded; |
| 633 |
|
| 634 |
css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > m_aBundledPackagesSeq; |
| 635 |
bool m_bBundledPackagesLoaded; |
| 636 |
|
| 637 |
int m_iUserPackage; |
| 638 |
int m_iSharedPackage; |
| 639 |
int m_iBundledPackage; |
| 640 |
|
| 641 |
ScriptSubPackageIterator* m_pScriptSubPackageIterator; |
| 642 |
|
| 643 |
}; // end class ScriptExtensionIterator |
| 644 |
|
| 645 |
|
| 646 |
} // namespace basic |
| 647 |
|
| 648 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |