1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVL_SOURCE_FSSTOR_FSSTORAGE_HXX
21 #define INCLUDED_SVL_SOURCE_FSSTOR_FSSTORAGE_HXX
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>
30 #include <comphelper/interfacecontainer4.hxx>
31 #include <cppuhelper/weak.hxx>
33 #include <ucbhelper/content.hxx>
35 class 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
43 ::ucbhelper::Content m_aContent
;
45 ::comphelper::OInterfaceContainerHelper4
<css::lang::XEventListener
> m_aListenersContainer
; // list of listeners
46 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
50 FSStorage( const ::ucbhelper::Content
& aContent
,
52 css::uno::Reference
< css::uno::XComponentContext
> const & xContext
);
54 virtual ~FSStorage() override
;
56 ucbhelper::Content
& GetContent();
58 static void CopyStreamToSubStream( const OUString
& aSourceURL
,
59 const css::uno::Reference
< css::embed::XStorage
>& xDest
,
60 const OUString
& aNewEntryName
);
62 void CopyContentToStorage_Impl(ucbhelper::Content
& rContent
,
63 const css::uno::Reference
<css::embed::XStorage
>& xDest
);
65 static bool MakeFolderNoUI( std::u16string_view rFolder
);
69 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
71 virtual void SAL_CALL
acquire() noexcept override
;
73 virtual void SAL_CALL
release() noexcept override
;
77 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
79 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
83 virtual void SAL_CALL
copyToStorage( const css::uno::Reference
< css::embed::XStorage
>& xDest
) override
;
85 virtual css::uno::Reference
< css::io::XStream
> SAL_CALL
openStreamElement(
86 const OUString
& aStreamName
, sal_Int32 nOpenMode
) override
;
88 virtual css::uno::Reference
< css::io::XStream
> SAL_CALL
openEncryptedStreamElement(
89 const OUString
& aStreamName
, sal_Int32 nOpenMode
, const OUString
& aPass
) override
;
91 virtual css::uno::Reference
< css::embed::XStorage
> SAL_CALL
openStorageElement(
92 const OUString
& aStorName
, sal_Int32 nStorageMode
) override
;
94 virtual css::uno::Reference
< css::io::XStream
> SAL_CALL
cloneStreamElement(
95 const OUString
& aStreamName
) override
;
97 virtual css::uno::Reference
< css::io::XStream
> SAL_CALL
cloneEncryptedStreamElement(
98 const OUString
& aStreamName
, const OUString
& aPass
) override
;
100 virtual void SAL_CALL
copyLastCommitTo(
101 const css::uno::Reference
< css::embed::XStorage
>& xTargetStorage
) override
;
103 virtual void SAL_CALL
copyStorageElementLastCommitTo(
104 const OUString
& aStorName
,
105 const css::uno::Reference
< css::embed::XStorage
>& xTargetStorage
) override
;
107 virtual sal_Bool SAL_CALL
isStreamElement( const OUString
& aElementName
) override
;
109 virtual sal_Bool SAL_CALL
isStorageElement( const OUString
& aElementName
) override
;
111 virtual void SAL_CALL
removeElement( const OUString
& aElementName
) override
;
113 virtual void SAL_CALL
renameElement( const OUString
& rEleName
, const OUString
& rNewName
) override
;
115 virtual void SAL_CALL
copyElementTo( const OUString
& aElementName
,
116 const css::uno::Reference
< css::embed::XStorage
>& xDest
,
117 const OUString
& aNewName
) override
;
119 virtual void SAL_CALL
moveElementTo( const OUString
& aElementName
,
120 const css::uno::Reference
< css::embed::XStorage
>& xDest
,
121 const OUString
& rNewName
) override
;
125 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
127 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
129 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
131 virtual css::uno::Type SAL_CALL
getElementType() override
;
133 virtual sal_Bool SAL_CALL
hasElements() override
;
137 virtual void SAL_CALL
dispose() override
;
139 virtual void SAL_CALL
addEventListener(
140 const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
142 virtual void SAL_CALL
removeEventListener(
143 const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
147 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo() override
;
149 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
151 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
153 virtual void SAL_CALL
addPropertyChangeListener(
154 const OUString
& aPropertyName
,
155 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
157 virtual void SAL_CALL
removePropertyChangeListener(
158 const OUString
& aPropertyName
,
159 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
161 virtual void SAL_CALL
addVetoableChangeListener(
162 const OUString
& PropertyName
,
163 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
165 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
167 // XHierarchicalStorageAccess
169 virtual css::uno::Reference
< css::embed::XExtendedStorageStream
> SAL_CALL
openStreamElementByHierarchicalName( const OUString
& sStreamPath
, ::sal_Int32 nOpenMode
) override
;
171 virtual css::uno::Reference
< css::embed::XExtendedStorageStream
> SAL_CALL
openEncryptedStreamElementByHierarchicalName( const OUString
& sStreamName
, ::sal_Int32 nOpenMode
, const OUString
& sPassword
) override
;
173 virtual void SAL_CALL
removeStreamElementByHierarchicalName( const OUString
& sElementPath
) override
;
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 copyElementToImpl(std::unique_lock
<std::mutex
>& rGuard
,
183 std::u16string_view ElementName
,
184 const css::uno::Reference
< css::embed::XStorage
>& xDest
,
185 const OUString
& rNewName
);
187 void disposeImpl(std::unique_lock
<std::mutex
>& rGuard
);
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */