LibreOffice Module svl (master) 1
fsstorage.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#ifndef INCLUDED_SVL_SOURCE_FSSTOR_FSSTORAGE_HXX
21#define INCLUDED_SVL_SOURCE_FSSTOR_FSSTORAGE_HXX
22
23#include <com/sun/star/uno/Sequence.hxx>
24#include <com/sun/star/embed/XStorage.hpp>
25#include <com/sun/star/embed/XHierarchicalStorageAccess.hpp>
26#include <com/sun/star/io/XStream.hpp>
27#include <com/sun/star/beans/XPropertySet.hpp>
28#include <com/sun/star/lang/XTypeProvider.hpp>
29#include <com/sun/star/uno/XComponentContext.hpp>
31#include <cppuhelper/weak.hxx>
32
33#include <ucbhelper/content.hxx>
34
35class FSStorage final : public css::lang::XTypeProvider
36 , public css::embed::XStorage
37 , public css::embed::XHierarchicalStorageAccess
38 , public css::beans::XPropertySet
39 , public ::cppu::OWeakObject
40{
41 std::mutex m_aMutex;
42 OUString m_aURL;
44 sal_Int32 m_nMode;
46 css::uno::Reference< css::uno::XComponentContext > m_xContext;
47
48public:
49
50 FSStorage( const ::ucbhelper::Content& aContent,
51 sal_Int32 nMode,
52 css::uno::Reference< css::uno::XComponentContext > const & xContext );
53
54 virtual ~FSStorage() override;
55
57
58 static void CopyStreamToSubStream( const OUString& aSourceURL,
59 const css::uno::Reference< css::embed::XStorage >& xDest,
60 const OUString& aNewEntryName );
61
63 const css::uno::Reference<css::embed::XStorage>& xDest);
64
65 static bool MakeFolderNoUI( std::u16string_view rFolder );
66
67 // XInterface
68
69 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& rType ) override;
70
71 virtual void SAL_CALL acquire() noexcept override;
72
73 virtual void SAL_CALL release() noexcept override;
74
75 // XTypeProvider
76
77 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
78
79 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
80
81 // XStorage
82
83 virtual void SAL_CALL copyToStorage( const css::uno::Reference< css::embed::XStorage >& xDest ) override;
84
85 virtual css::uno::Reference< css::io::XStream > SAL_CALL openStreamElement(
86 const OUString& aStreamName, sal_Int32 nOpenMode ) override;
87
88 virtual css::uno::Reference< css::io::XStream > SAL_CALL openEncryptedStreamElement(
89 const OUString& aStreamName, sal_Int32 nOpenMode, const OUString& aPass ) override;
90
91 virtual css::uno::Reference< css::embed::XStorage > SAL_CALL openStorageElement(
92 const OUString& aStorName, sal_Int32 nStorageMode ) override;
93
94 virtual css::uno::Reference< css::io::XStream > SAL_CALL cloneStreamElement(
95 const OUString& aStreamName ) override;
96
97 virtual css::uno::Reference< css::io::XStream > SAL_CALL cloneEncryptedStreamElement(
98 const OUString& aStreamName, const OUString& aPass ) override;
99
100 virtual void SAL_CALL copyLastCommitTo(
101 const css::uno::Reference< css::embed::XStorage >& xTargetStorage ) override;
102
103 virtual void SAL_CALL copyStorageElementLastCommitTo(
104 const OUString& aStorName,
105 const css::uno::Reference< css::embed::XStorage >& xTargetStorage ) override;
106
107 virtual sal_Bool SAL_CALL isStreamElement( const OUString& aElementName ) override;
108
109 virtual sal_Bool SAL_CALL isStorageElement( const OUString& aElementName ) override;
110
111 virtual void SAL_CALL removeElement( const OUString& aElementName ) override;
112
113 virtual void SAL_CALL renameElement( const OUString& rEleName, const OUString& rNewName ) override;
114
115 virtual void SAL_CALL copyElementTo( const OUString& aElementName,
116 const css::uno::Reference< css::embed::XStorage >& xDest,
117 const OUString& aNewName ) override;
118
119 virtual void SAL_CALL moveElementTo( const OUString& aElementName,
120 const css::uno::Reference< css::embed::XStorage >& xDest,
121 const OUString& rNewName ) override;
122
123 // XNameAccess
124
125 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
126
127 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
128
129 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
130
131 virtual css::uno::Type SAL_CALL getElementType() override;
132
133 virtual sal_Bool SAL_CALL hasElements() override;
134
135 // XComponent
136
137 virtual void SAL_CALL dispose() override;
138
139 virtual void SAL_CALL addEventListener(
140 const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
141
142 virtual void SAL_CALL removeEventListener(
143 const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
144
145 // XPropertySet
146
147 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
148
149 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
150
151 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
152
153 virtual void SAL_CALL addPropertyChangeListener(
154 const OUString& aPropertyName,
155 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
156
157 virtual void SAL_CALL removePropertyChangeListener(
158 const OUString& aPropertyName,
159 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
160
161 virtual void SAL_CALL addVetoableChangeListener(
162 const OUString& PropertyName,
163 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
164
165 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
166
167 // XHierarchicalStorageAccess
168
169 virtual css::uno::Reference< css::embed::XExtendedStorageStream > SAL_CALL openStreamElementByHierarchicalName( const OUString& sStreamPath, ::sal_Int32 nOpenMode ) override;
170
171 virtual css::uno::Reference< css::embed::XExtendedStorageStream > SAL_CALL openEncryptedStreamElementByHierarchicalName( const OUString& sStreamName, ::sal_Int32 nOpenMode, const OUString& sPassword ) override;
172
173 virtual void SAL_CALL removeStreamElementByHierarchicalName( const OUString& sElementPath ) override;
174
175private:
176 css::uno::Reference< css::embed::XStorage > openStorageElementImpl(
177 std::unique_lock<std::mutex>& rGuard,
178 std::u16string_view aStorName, sal_Int32 nStorageMode );
179 css::uno::Reference< css::io::XStream > openStreamElementImpl(
180 std::unique_lock<std::mutex>& rGuard,
181 std::u16string_view aStreamName, sal_Int32 nOpenMode );
182 void disposeImpl(std::unique_lock<std::mutex>& rGuard);
183};
184
185#endif
186
187/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL dispose() override
Definition: fsstorage.cxx:883
virtual sal_Bool SAL_CALL isStreamElement(const OUString &aElementName) override
Definition: fsstorage.cxx:554
::comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_aListenersContainer
Definition: fsstorage.hxx:45
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: fsstorage.cxx:737
virtual void SAL_CALL copyStorageElementLastCommitTo(const OUString &aStorName, const css::uno::Reference< css::embed::XStorage > &xTargetStorage) override
Definition: fsstorage.cxx:543
virtual void SAL_CALL renameElement(const OUString &rEleName, const OUString &rNewName) override
Definition: fsstorage.cxx:588
std::mutex m_aMutex
Definition: fsstorage.hxx:41
css::uno::Reference< css::io::XStream > openStreamElementImpl(std::unique_lock< std::mutex > &rGuard, std::u16string_view aStreamName, sal_Int32 nOpenMode)
Definition: fsstorage.cxx:292
sal_Int32 m_nMode
Definition: fsstorage.hxx:44
void disposeImpl(std::unique_lock< std::mutex > &rGuard)
Definition: fsstorage.cxx:889
virtual void SAL_CALL copyToStorage(const css::uno::Reference< css::embed::XStorage > &xDest) override
Definition: fsstorage.cxx:245
virtual css::uno::Reference< css::embed::XExtendedStorageStream > SAL_CALL openStreamElementByHierarchicalName(const OUString &sStreamPath, ::sal_Int32 nOpenMode) override
Definition: fsstorage.cxx:977
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: fsstorage.cxx:898
virtual void SAL_CALL removeStreamElementByHierarchicalName(const OUString &sElementPath) override
Definition: fsstorage.cxx:1086
virtual sal_Bool SAL_CALL hasElements() override
Definition: fsstorage.cxx:858
virtual sal_Bool SAL_CALL isStorageElement(const OUString &aElementName) override
Definition: fsstorage.cxx:564
FSStorage(const ::ucbhelper::Content &aContent, sal_Int32 nMode, css::uno::Reference< css::uno::XComponentContext > const &xContext)
Definition: fsstorage.cxx:60
OUString m_aURL
Definition: fsstorage.hxx:42
css::uno::Reference< css::embed::XStorage > openStorageElementImpl(std::unique_lock< std::mutex > &rGuard, std::u16string_view aStorName, sal_Int32 nStorageMode)
Definition: fsstorage.cxx:396
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: fsstorage.cxx:945
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: fsstorage.cxx:932
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: fsstorage.cxx:198
virtual void SAL_CALL copyLastCommitTo(const css::uno::Reference< css::embed::XStorage > &xTargetStorage) override
Definition: fsstorage.cxx:537
virtual ~FSStorage() override
Definition: fsstorage.cxx:76
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: fsstorage.cxx:786
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: fsstorage.hxx:46
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: fsstorage.cxx:953
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: fsstorage.cxx:906
static bool MakeFolderNoUI(std::u16string_view rFolder)
Definition: fsstorage.cxx:87
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: fsstorage.cxx:923
virtual void SAL_CALL copyElementTo(const OUString &aElementName, const css::uno::Reference< css::embed::XStorage > &xDest, const OUString &aNewName) override
Definition: fsstorage.cxx:651
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: fsstorage.cxx:969
virtual css::uno::Reference< css::io::XStream > SAL_CALL openStreamElement(const OUString &aStreamName, sal_Int32 nOpenMode) override
Definition: fsstorage.cxx:285
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: fsstorage.cxx:238
virtual void SAL_CALL acquire() noexcept override
Definition: fsstorage.cxx:216
virtual css::uno::Reference< css::io::XStream > SAL_CALL cloneStreamElement(const OUString &aStreamName) override
Definition: fsstorage.cxx:473
virtual void SAL_CALL release() noexcept override
Definition: fsstorage.cxx:221
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: fsstorage.cxx:838
virtual css::uno::Reference< css::io::XStream > SAL_CALL cloneEncryptedStreamElement(const OUString &aStreamName, const OUString &aPass) override
Definition: fsstorage.cxx:530
virtual css::uno::Reference< css::embed::XStorage > SAL_CALL openStorageElement(const OUString &aStorName, sal_Int32 nStorageMode) override
Definition: fsstorage.cxx:389
void CopyContentToStorage_Impl(ucbhelper::Content &rContent, const css::uno::Reference< css::embed::XStorage > &xDest)
Definition: fsstorage.cxx:138
virtual void SAL_CALL moveElementTo(const OUString &aElementName, const css::uno::Reference< css::embed::XStorage > &xDest, const OUString &rNewName) override
Definition: fsstorage.cxx:722
ucbhelper::Content & GetContent()
Definition: fsstorage.cxx:104
static void CopyStreamToSubStream(const OUString &aSourceURL, const css::uno::Reference< css::embed::XStorage > &xDest, const OUString &aNewEntryName)
Definition: fsstorage.cxx:110
virtual void SAL_CALL removeElement(const OUString &aElementName) override
Definition: fsstorage.cxx:574
virtual css::uno::Reference< css::embed::XExtendedStorageStream > SAL_CALL openEncryptedStreamElementByHierarchicalName(const OUString &sStreamName, ::sal_Int32 nOpenMode, const OUString &sPassword) override
Definition: fsstorage.cxx:1081
::ucbhelper::Content m_aContent
Definition: fsstorage.hxx:43
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: fsstorage.cxx:228
virtual css::uno::Reference< css::io::XStream > SAL_CALL openEncryptedStreamElement(const OUString &aStreamName, sal_Int32 nOpenMode, const OUString &aPass) override
Definition: fsstorage.cxx:383
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: fsstorage.cxx:961
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: fsstorage.cxx:916
virtual css::uno::Type SAL_CALL getElementType() override
Definition: fsstorage.cxx:852
Type
unsigned char sal_Bool
signed char sal_Int8