| 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 |
|
| 24 |
#include <com/sun/star/resource/XStringResourceSupplier.hpp> |
| 25 |
#include <com/sun/star/resource/XStringResourcePersistence.hpp> |
| 26 |
|
| 27 |
namespace basic |
| 28 |
{ |
| 29 |
|
| 30 |
|
| 31 |
class SfxDialogLibraryContainer final : public SfxLibraryContainer |
| 32 |
{ |
| 33 |
// Methods to distinguish between different library types |
| 34 |
virtual rtl::Reference<SfxLibrary> implCreateLibrary( const OUString& aName ) override; |
| 35 |
virtual rtl::Reference<SfxLibrary> implCreateLibraryLink |
| 36 |
( const OUString& aName, const OUString& aLibInfoFileURL, |
| 37 |
const OUString& StorageURL, bool ReadOnly ) override; |
| 38 |
virtual css::uno::Any createEmptyLibraryElement() override; |
| 39 |
virtual bool isLibraryElementValid(const css::uno::Any& rElement) const override; |
| 40 |
virtual void writeLibraryElement |
| 41 |
( |
| 42 |
const css::uno::Reference< css::container::XNameContainer>& xLibrary, |
| 43 |
const OUString& aElementName, |
| 44 |
const css::uno::Reference< css::io::XOutputStream >& xOutput |
| 45 |
) override; |
| 46 |
|
| 47 |
virtual css::uno::Any importLibraryElement |
| 48 |
( |
| 49 |
const css::uno::Reference< css::container::XNameContainer>& xLibrary, |
| 50 |
const OUString& aElementName, |
| 51 |
const OUString& aFile, |
| 52 |
const css::uno::Reference< css::io::XInputStream >& xElementStream ) override; |
| 53 |
|
| 54 |
virtual void importFromOldStorage( const OUString& aFile ) override; |
| 55 |
|
| 56 |
virtual rtl::Reference<SfxLibraryContainer> createInstanceImpl() override; |
| 57 |
|
| 58 |
virtual void onNewRootStorage() override; |
| 59 |
|
| 60 |
virtual OUString getInfoFileName() const override; |
| 61 |
virtual OUString getOldInfoFileName() const override; |
| 62 |
virtual OUString getLibElementFileExtension() const override; |
| 63 |
virtual OUString getLibrariesDir() const override; |
| 64 |
|
| 65 |
public: |
| 66 |
SfxDialogLibraryContainer(); |
| 67 |
SfxDialogLibraryContainer( const css::uno::Reference< css::embed::XStorage >& xStorage ); |
| 68 |
|
| 69 |
// Methods XStorageBasedLibraryContainer |
| 70 |
virtual void SAL_CALL storeLibrariesToStorage( |
| 71 |
const css::uno::Reference< css::embed::XStorage >& RootStorage ) override; |
| 72 |
|
| 73 |
// Resource handling |
| 74 |
css::uno::Reference< css::resource::XStringResourcePersistence > |
| 75 |
implCreateStringResource( class SfxDialogLibrary* pDialog ); |
| 76 |
|
| 77 |
// Methods XServiceInfo |
| 78 |
virtual OUString SAL_CALL getImplementationName( ) override; |
| 79 |
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; |
| 80 |
// XLibraryQueryExecutable |
| 81 |
virtual sal_Bool SAL_CALL HasExecutableCode(const OUString&) override; |
| 82 |
}; |
| 83 |
|
| 84 |
|
| 85 |
typedef cppu::ImplInheritanceHelper<SfxLibrary, css::resource::XStringResourceSupplier |
| 86 |
> SfxDialogLibrary_BASE; |
| 87 |
|
| 88 |
class SfxDialogLibrary final : public SfxDialogLibrary_BASE |
| 89 |
{ |
| 90 |
SfxDialogLibraryContainer* m_pParent; |
| 91 |
css::uno::Reference< css::resource::XStringResourcePersistence> m_xStringResourcePersistence; |
| 92 |
OUString m_aName; |
| 93 |
|
| 94 |
// Provide modify state including resources |
| 95 |
virtual bool isModified() override; |
| 96 |
virtual void storeResources() override; |
| 97 |
virtual void storeResourcesAsURL( const OUString& URL, const OUString& NewName ) override; |
| 98 |
virtual void storeResourcesToURL( const OUString& URL, |
| 99 |
const css::uno::Reference< css::task::XInteractionHandler >& xHandler ) override; |
| 100 |
virtual void storeResourcesToStorage( const css::uno::Reference |
| 101 |
< css::embed::XStorage >& xStorage ) override; |
| 102 |
|
| 103 |
public: |
| 104 |
SfxDialogLibrary |
| 105 |
( |
| 106 |
ModifiableHelper& _rModifiable, |
| 107 |
OUString aName, |
| 108 |
const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& xSFI, |
| 109 |
SfxDialogLibraryContainer* pParent |
| 110 |
); |
| 111 |
|
| 112 |
SfxDialogLibrary |
| 113 |
( |
| 114 |
ModifiableHelper& _rModifiable, |
| 115 |
OUString aName, |
| 116 |
const css::uno::Reference< css::ucb::XSimpleFileAccess3 >& xSFI, |
| 117 |
const OUString& aLibInfoFileURL, const OUString& aStorageURL, bool ReadOnly, |
| 118 |
SfxDialogLibraryContainer* pParent |
| 119 |
); |
| 120 |
|
| 121 |
// XStringResourceSupplier |
| 122 |
virtual css::uno::Reference< css::resource::XStringResourceResolver > |
| 123 |
SAL_CALL getStringResource( ) override; |
| 124 |
|
| 125 |
const OUString& getName() const |
| 126 |
{ return m_aName; } |
| 127 |
|
| 128 |
const css::uno::Reference< css::resource::XStringResourcePersistence >& |
| 129 |
getStringResourcePersistence() const |
| 130 |
{ |
| 131 |
return m_xStringResourcePersistence; |
| 132 |
} |
| 133 |
|
| 134 |
static bool containsValidDialog( const css::uno::Any& aElement ); |
| 135 |
|
| 136 |
private: |
| 137 |
virtual bool isLibraryElementValid(const css::uno::Any& rElement) const override; |
| 138 |
}; |
| 139 |
|
| 140 |
} // namespace basic |
| 141 |
|
| 142 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |