LibreOffice Module ucb (master) 1
tdoc_stgelems.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 <rtl/ref.hxx>
23
25
26#include <com/sun/star/embed/XStorage.hpp>
27#include <com/sun/star/embed/XTransactedObject.hpp>
28#include <com/sun/star/io/XOutputStream.hpp>
29#include <com/sun/star/io/XStream.hpp>
30#include <com/sun/star/io/XTruncate.hpp>
31#include <com/sun/star/lang/XComponent.hpp>
32#include <com/sun/star/uno/XAggregation.hpp>
33
34#include "tdoc_storage.hxx"
35
36#include <mutex>
37
38namespace tdoc_ucp {
39
40class OfficeDocumentsManager;
41
43{
44public:
46 css::uno::Reference< css::embed::XStorage > xParentStorage,
47 const OUString & rUri );
48
50 { return m_bParentIsRootStorage; }
51 const css::uno::Reference< css::embed::XStorage >&
53 { return m_xParentStorage; }
54 void setParentStorage( const css::uno::Reference< css::embed::XStorage > & xStg )
55 {
56 std::scoped_lock aGuard( m_aMutex );
57 m_xParentStorage = xStg;
58 }
59
60private:
61 std::mutex m_aMutex;
62 css::uno::Reference< css::embed::XStorage > m_xParentStorage;
64};
65
66
67typedef
68 cppu::WeakImplHelper<
69 css::embed::XStorage,
70 css::embed::XTransactedObject > StorageUNOBase;
71
73{
74public:
75 Storage(
76 const css::uno::Reference< css::uno::XComponentContext > & rxContext,
78 const OUString & rUri,
79 const css::uno::Reference< css::embed::XStorage > & xParentStorage,
80 const css::uno::Reference< css::embed::XStorage > & xStorageToWrap );
81 virtual ~Storage() override;
82
83 // XInterface
84 virtual css::uno::Any SAL_CALL queryInterface(
85 const css::uno::Type& aType ) override;
86 virtual void SAL_CALL acquire()
87 noexcept override;
88 virtual void SAL_CALL release()
89 noexcept override;
90
91 // XTypeProvider (implemented by base, but needs to be overridden for
92 // delegating to aggregate)
93 virtual css::uno::Sequence< css::uno::Type > SAL_CALL
94 getTypes() override;
95 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
96 getImplementationId() override;
97
98 // XComponent ( one of XStorage bases )
99 virtual void SAL_CALL
100 dispose() override;
101 virtual void SAL_CALL
102 addEventListener( const css::uno::Reference< css::lang::XEventListener > & xListener ) override;
103 virtual void SAL_CALL
104 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
105
106 // XNameAccess ( one of XStorage bases )
107 virtual css::uno::Any SAL_CALL
108 getByName( const OUString& aName ) override;
109 virtual css::uno::Sequence< OUString > SAL_CALL
110 getElementNames() override;
111 virtual sal_Bool SAL_CALL
112 hasByName( const OUString& aName ) override;
113
114 // XElementAccess (base of XNameAccess)
115 virtual css::uno::Type SAL_CALL
116 getElementType() override;
117 virtual sal_Bool SAL_CALL
118 hasElements() override;
119
120 // XStorage
121 virtual void SAL_CALL
122 copyToStorage( const css::uno::Reference< css::embed::XStorage >& xDest ) override;
123 virtual css::uno::Reference< css::io::XStream > SAL_CALL
124 openStreamElement( const OUString& aStreamName,
125 sal_Int32 nOpenMode ) override;
126 virtual css::uno::Reference< css::io::XStream > SAL_CALL
127 openEncryptedStreamElement( const OUString& aStreamName,
128 sal_Int32 nOpenMode,
129 const OUString& aPassword ) override;
130 virtual css::uno::Reference< css::embed::XStorage > SAL_CALL
131 openStorageElement( const OUString& aStorName,
132 sal_Int32 nOpenMode ) override;
133 virtual css::uno::Reference< css::io::XStream > SAL_CALL
134 cloneStreamElement( const OUString& aStreamName ) override;
135 virtual css::uno::Reference< css::io::XStream > SAL_CALL
136 cloneEncryptedStreamElement( const OUString& aStreamName,
137 const OUString& aPassword ) override;
138 virtual void SAL_CALL
139 copyLastCommitTo( const css::uno::Reference<
140 css::embed::XStorage >& xTargetStorage ) override;
141 virtual void SAL_CALL
142 copyStorageElementLastCommitTo( const OUString& aStorName,
143 const css::uno::Reference<
144 css::embed::XStorage > &
145 xTargetStorage ) override;
146 virtual sal_Bool SAL_CALL
147 isStreamElement( const OUString& aElementName ) override;
148 virtual sal_Bool SAL_CALL
149 isStorageElement( const OUString& aElementName ) override;
150 virtual void SAL_CALL
151 removeElement( const OUString& aElementName ) override;
152 virtual void SAL_CALL
153 renameElement( const OUString& aEleName,
154 const OUString& aNewName ) override;
155 virtual void SAL_CALL
156 copyElementTo( const OUString& aElementName,
157 const css::uno::Reference< css::embed::XStorage >& xDest,
158 const OUString& aNewName ) override;
159 virtual void SAL_CALL
160 moveElementTo( const OUString& aElementName,
161 const css::uno::Reference< css::embed::XStorage >& xDest,
162 const OUString& rNewName ) override;
163
164 // XTransactedObject
165 virtual void SAL_CALL commit() override;
166 virtual void SAL_CALL revert() override;
167
168private:
170 css::uno::Reference< css::uno::XAggregation > m_xAggProxy;
171 css::uno::Reference< css::embed::XStorage > m_xWrappedStorage;
172 css::uno::Reference< css::embed::XTransactedObject > m_xWrappedTransObj;
173 css::uno::Reference< css::lang::XComponent > m_xWrappedComponent;
174 css::uno::Reference< css::lang::XTypeProvider > m_xWrappedTypeProv;
176
177 StorageElementFactory::StorageMap::iterator m_aContainerIt;
178
180};
181
182
183typedef
184 cppu::WeakImplHelper<
185 css::io::XOutputStream,
186 css::lang::XComponent > OutputStreamUNOBase;
187
189{
190public:
192 const css::uno::Reference< css::uno::XComponentContext > & rxContext,
193 const OUString & rUri,
194 const css::uno::Reference< css::embed::XStorage > & xParentStorage,
195 const css::uno::Reference< css::io::XOutputStream > & xStreamToWrap );
196 virtual ~OutputStream() override;
197
198 // XInterface
199 virtual css::uno::Any SAL_CALL
200 queryInterface( const css::uno::Type& aType ) override;
201
202 // XTypeProvider (implemented by base, but needs to be overridden for
203 // delegating to aggregate)
204 virtual css::uno::Sequence< css::uno::Type > SAL_CALL
205 getTypes() override;
206 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
207 getImplementationId() override;
208
209 // XOutputStream
210 virtual void SAL_CALL
211 writeBytes( const css::uno::Sequence< sal_Int8 >& aData ) override;
212 virtual void SAL_CALL
213 flush( ) override;
214 // Note: We need to intercept this one.
215 virtual void SAL_CALL
216 closeOutput( ) override;
217
218 // XComponent
219 // Note: We need to intercept this one.
220 virtual void SAL_CALL
221 dispose() override;
222 virtual void SAL_CALL
223 addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
224 virtual void SAL_CALL
225 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
226
227private:
228 css::uno::Reference<
229 css::uno::XAggregation > m_xAggProxy;
230 css::uno::Reference<
231 css::io::XOutputStream > m_xWrappedStream;
232 css::uno::Reference<
233 css::lang::XComponent > m_xWrappedComponent;
234 css::uno::Reference<
235 css::lang::XTypeProvider > m_xWrappedTypeProv;
236};
237
238
239typedef cppu::WeakImplHelper< css::io::XStream,
240 css::io::XOutputStream,
241 css::io::XTruncate,
242 css::io::XInputStream,
243 css::lang::XComponent >
245
247{
248public:
249 Stream(
250 const css::uno::Reference< css::uno::XComponentContext > & rxContext,
252 const OUString & rUri,
253 const css::uno::Reference< css::embed::XStorage > & xParentStorage,
254 const css::uno::Reference< css::io::XStream > & xStreamToWrap );
255
256 virtual ~Stream() override;
257
258 // XInterface
259 virtual css::uno::Any SAL_CALL
260 queryInterface( const css::uno::Type& aType ) override;
261
262 // XTypeProvider (implemented by base, but needs to be overridden for
263 // delegating to aggregate)
264 virtual css::uno::Sequence< css::uno::Type > SAL_CALL
265 getTypes() override;
266 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
267 getImplementationId() override;
268
269 // XStream
270 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
271 getInputStream() override;
272
273 virtual css::uno::Reference< css::io::XOutputStream > SAL_CALL
274 getOutputStream() override;
275
276 // XOutputStream
277 virtual void SAL_CALL
278 writeBytes( const css::uno::Sequence< sal_Int8 >& aData ) override;
279
280 virtual void SAL_CALL
281 flush() override;
282
283 virtual void SAL_CALL
284 closeOutput() override;
285
286 // XTruncate
287 virtual void SAL_CALL
288 truncate() override;
289
290 // XInputStream
291 virtual sal_Int32 SAL_CALL
292 readBytes( css::uno::Sequence< sal_Int8 >& aData,
293 sal_Int32 nBytesToRead ) override;
294
295 virtual sal_Int32 SAL_CALL
296 readSomeBytes( css::uno::Sequence< sal_Int8 >& aData,
297 sal_Int32 nMaxBytesToRead ) override;
298
299 virtual void SAL_CALL
300 skipBytes( sal_Int32 nBytesToSkip ) override;
301
302 virtual sal_Int32 SAL_CALL
303 available() override;
304
305 virtual void SAL_CALL
306 closeInput() override;
307
308 // XComponent
309 // Note: We need to intercept this one.
310 virtual void SAL_CALL
311 dispose() override;
312 virtual void SAL_CALL
313 addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
314 virtual void SAL_CALL
315 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
316
317private:
319 void commitChanges();
320
322 OUString m_uri;
323 css::uno::Reference<
324 css::uno::XAggregation > m_xAggProxy;
325 css::uno::Reference<
326 css::io::XStream > m_xWrappedStream;
327 css::uno::Reference<
328 css::io::XOutputStream > m_xWrappedOutputStream;
329 css::uno::Reference<
330 css::io::XTruncate > m_xWrappedTruncate;
331 css::uno::Reference<
332 css::io::XInputStream > m_xWrappedInputStream;
333 css::uno::Reference<
334 css::lang::XComponent > m_xWrappedComponent;
335 css::uno::Reference<
336 css::lang::XTypeProvider > m_xWrappedTypeProv;
337};
338
339} // namespace tdoc_ucp
340
341/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL closeOutput() override
virtual void SAL_CALL flush() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual ~OutputStream() override
OutputStream(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const OUString &rUri, const css::uno::Reference< css::embed::XStorage > &xParentStorage, const css::uno::Reference< css::io::XOutputStream > &xStreamToWrap)
css::uno::Reference< css::lang::XTypeProvider > m_xWrappedTypeProv
css::uno::Reference< css::io::XOutputStream > m_xWrappedStream
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
css::uno::Reference< css::lang::XComponent > m_xWrappedComponent
virtual void SAL_CALL writeBytes(const css::uno::Sequence< sal_Int8 > &aData) override
css::uno::Reference< css::uno::XAggregation > m_xAggProxy
virtual void SAL_CALL dispose() override
ParentStorageHolder(css::uno::Reference< css::embed::XStorage > xParentStorage, const OUString &rUri)
css::uno::Reference< css::embed::XStorage > m_xParentStorage
const css::uno::Reference< css::embed::XStorage > & getParentStorage() const
void setParentStorage(const css::uno::Reference< css::embed::XStorage > &xStg)
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
css::uno::Reference< css::lang::XTypeProvider > m_xWrappedTypeProv
css::uno::Reference< css::embed::XStorage > m_xWrappedStorage
css::uno::Reference< css::uno::XAggregation > m_xAggProxy
virtual void SAL_CALL removeElement(const OUString &aElementName) override
css::uno::Reference< css::lang::XComponent > m_xWrappedComponent
virtual void SAL_CALL commit() override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Storage(const css::uno::Reference< css::uno::XComponentContext > &rxContext, rtl::Reference< StorageElementFactory > xFactory, const OUString &rUri, const css::uno::Reference< css::embed::XStorage > &xParentStorage, const css::uno::Reference< css::embed::XStorage > &xStorageToWrap)
virtual void SAL_CALL copyStorageElementLastCommitTo(const OUString &aStorName, const css::uno::Reference< css::embed::XStorage > &xTargetStorage) override
virtual css::uno::Reference< css::embed::XStorage > SAL_CALL openStorageElement(const OUString &aStorName, sal_Int32 nOpenMode) override
virtual css::uno::Reference< css::io::XStream > SAL_CALL cloneEncryptedStreamElement(const OUString &aStreamName, const OUString &aPassword) override
virtual css::uno::Reference< css::io::XStream > SAL_CALL openStreamElement(const OUString &aStreamName, sal_Int32 nOpenMode) override
virtual sal_Bool SAL_CALL isStreamElement(const OUString &aElementName) override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
virtual sal_Bool SAL_CALL hasElements() override
virtual void SAL_CALL dispose() override
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL copyToStorage(const css::uno::Reference< css::embed::XStorage > &xDest) override
rtl::Reference< StorageElementFactory > m_xFactory
virtual css::uno::Type SAL_CALL getElementType() override
virtual void SAL_CALL moveElementTo(const OUString &aElementName, const css::uno::Reference< css::embed::XStorage > &xDest, const OUString &rNewName) override
virtual void SAL_CALL copyLastCommitTo(const css::uno::Reference< css::embed::XStorage > &xTargetStorage) override
virtual ~Storage() override
virtual void SAL_CALL revert() override
virtual void SAL_CALL copyElementTo(const OUString &aElementName, const css::uno::Reference< css::embed::XStorage > &xDest, const OUString &aNewName) override
virtual void SAL_CALL renameElement(const OUString &aEleName, const OUString &aNewName) override
css::uno::Reference< css::embed::XTransactedObject > m_xWrappedTransObj
virtual css::uno::Reference< css::io::XStream > SAL_CALL openEncryptedStreamElement(const OUString &aStreamName, sal_Int32 nOpenMode, const OUString &aPassword) override
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
StorageElementFactory::StorageMap::iterator m_aContainerIt
virtual css::uno::Reference< css::io::XStream > SAL_CALL cloneStreamElement(const OUString &aStreamName) override
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
virtual sal_Bool SAL_CALL isStorageElement(const OUString &aElementName) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual void SAL_CALL release() noexcept override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
virtual sal_Int32 SAL_CALL readSomeBytes(css::uno::Sequence< sal_Int8 > &aData, sal_Int32 nMaxBytesToRead) override
virtual sal_Int32 SAL_CALL readBytes(css::uno::Sequence< sal_Int8 > &aData, sal_Int32 nBytesToRead) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual void SAL_CALL skipBytes(sal_Int32 nBytesToSkip) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
virtual void SAL_CALL writeBytes(const css::uno::Sequence< sal_Int8 > &aData) override
virtual void SAL_CALL dispose() override
virtual void SAL_CALL flush() override
css::uno::Reference< css::lang::XComponent > m_xWrappedComponent
css::uno::Reference< css::io::XOutputStream > m_xWrappedOutputStream
css::uno::Reference< css::io::XStream > m_xWrappedStream
virtual sal_Int32 SAL_CALL available() override
css::uno::Reference< css::uno::XAggregation > m_xAggProxy
css::uno::Reference< css::io::XInputStream > m_xWrappedInputStream
virtual void SAL_CALL closeInput() override
virtual void SAL_CALL closeOutput() override
rtl::Reference< OfficeDocumentsManager > m_docsMgr
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual css::uno::Reference< css::io::XOutputStream > SAL_CALL getOutputStream() override
virtual void SAL_CALL truncate() override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
css::uno::Reference< css::lang::XTypeProvider > m_xWrappedTypeProv
Stream(const css::uno::Reference< css::uno::XComponentContext > &rxContext, rtl::Reference< OfficeDocumentsManager > const &docsMgr, const OUString &rUri, const css::uno::Reference< css::embed::XStorage > &xParentStorage, const css::uno::Reference< css::io::XStream > &xStreamToWrap)
css::uno::Reference< css::io::XTruncate > m_xWrappedTruncate
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getInputStream() override
virtual ~Stream() override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Reference< XSingleServiceFactory > xFactory
OUString aName
constexpr OUStringLiteral aData
cppu::WeakImplHelper< css::io::XStream, css::io::XOutputStream, css::io::XTruncate, css::io::XInputStream, css::lang::XComponent > StreamUNOBase
cppu::WeakImplHelper< css::io::XOutputStream, css::lang::XComponent > OutputStreamUNOBase
cppu::WeakImplHelper< css::embed::XStorage, css::embed::XTransactedObject > StorageUNOBase
unsigned char sal_Bool