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_PACKAGE_SOURCE_XSTOR_OHIERARCHYHOLDER_HXX
21 #define INCLUDED_PACKAGE_SOURCE_XSTOR_OHIERARCHYHOLDER_HXX
23 #include <com/sun/star/embed/XStorage.hpp>
24 #include <com/sun/star/embed/XTransactionListener.hpp>
25 #include <com/sun/star/embed/XExtendedStorageStream.hpp>
26 #include <cppuhelper/implbase.hxx>
27 #include <cppuhelper/weakref.hxx>
28 #include <unotools/weakref.hxx>
30 #include <comphelper/sequenceashashmap.hxx>
32 #include <rtl/ref.hxx>
34 #include <unordered_map>
38 class OHierarchyElement_Impl
;
41 typedef std::unordered_map
< OUString
,
42 ::rtl::Reference
< OHierarchyElement_Impl
> > OHierarchyElementList_Impl
;
44 typedef ::std::vector
< css::uno::WeakReference
< css::embed::XExtendedStorageStream
> >
45 OWeakStorRefVector_Impl
;
47 class OHierarchyElement_Impl
: public cppu::WeakImplHelper
< css::embed::XTransactionListener
>
51 ::rtl::Reference
< OHierarchyElement_Impl
> m_rParent
;
52 rtl::Reference
< OStorage
> m_xOwnStorage
;
53 unotools::WeakReference
< OStorage
> m_xWeakOwnStorage
;
55 OHierarchyElementList_Impl m_aChildren
;
57 OWeakStorRefVector_Impl m_aOpenStreams
;
60 explicit OHierarchyElement_Impl(rtl::Reference
< OStorage
> xStorage
)
61 : m_xOwnStorage(std::move( xStorage
))
64 explicit OHierarchyElement_Impl( unotools::WeakReference
< OStorage
>&& xWeakStorage
)
65 : m_xWeakOwnStorage(std::move( xWeakStorage
))
70 void SetParent( const ::rtl::Reference
< OHierarchyElement_Impl
>& rParent
) { m_rParent
= rParent
; }
72 void TestForClosing();
74 void RemoveElement( const ::rtl::Reference
< OHierarchyElement_Impl
>& aRef
);
76 css::uno::Reference
< css::embed::XExtendedStorageStream
>
77 GetStreamHierarchically( sal_Int32 nStorageMode
,
78 std::vector
<OUString
>& aPath
,
79 sal_Int32 nStreamMode
,
80 const ::comphelper::SequenceAsHashMap
& aEncryptionData
);
82 void RemoveStreamHierarchically( std::vector
<OUString
>& aListPath
);
85 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
87 // XTransactionListener
88 virtual void SAL_CALL
preCommit( const css::lang::EventObject
& aEvent
) override
;
89 virtual void SAL_CALL
commited( const css::lang::EventObject
& aEvent
) override
;
90 virtual void SAL_CALL
preRevert( const css::lang::EventObject
& aEvent
) override
;
91 virtual void SAL_CALL
reverted( const css::lang::EventObject
& aEvent
) override
;
95 class OHierarchyHolder_Impl
97 ::rtl::Reference
< OHierarchyElement_Impl
> m_xChild
;
99 explicit OHierarchyHolder_Impl(unotools::WeakReference
<OStorage
>&& xOwnStorage
)
100 : m_xChild( new OHierarchyElement_Impl( std::move(xOwnStorage
) ) )
103 static std::vector
<OUString
> GetListPathFromString( std::u16string_view aPath
);
105 css::uno::Reference
< css::embed::XExtendedStorageStream
>
106 GetStreamHierarchically( sal_Int32 nStorageMode
,
107 std::vector
<OUString
>& aListPath
,
108 sal_Int32 nStreamMode
,
109 const ::comphelper::SequenceAsHashMap
& aEncryptionData
= ::comphelper::SequenceAsHashMap() );
111 void RemoveStreamHierarchically( std::vector
<OUString
>& aListPath
);
114 #endif // _OHIERARCHYHOLDER
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */