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>
29 #include <comphelper/sequenceashashmap.hxx>
31 #include <rtl/ref.hxx>
33 #include <unordered_map>
37 class OHierarchyElement_Impl
;
39 typedef std::unordered_map
< OUString
,
40 ::rtl::Reference
< OHierarchyElement_Impl
> > OHierarchyElementList_Impl
;
42 typedef ::std::vector
< css::uno::WeakReference
< css::embed::XExtendedStorageStream
> >
43 OWeakStorRefVector_Impl
;
45 class OHierarchyElement_Impl
: public cppu::WeakImplHelper
< css::embed::XTransactionListener
>
49 ::rtl::Reference
< OHierarchyElement_Impl
> m_rParent
;
50 css::uno::Reference
< css::embed::XStorage
> m_xOwnStorage
;
51 css::uno::WeakReference
< css::embed::XStorage
> m_xWeakOwnStorage
;
53 OHierarchyElementList_Impl m_aChildren
;
55 OWeakStorRefVector_Impl m_aOpenStreams
;
58 explicit OHierarchyElement_Impl( css::uno::Reference
< css::embed::XStorage
> xStorage
)
59 : m_xOwnStorage(std::move( xStorage
))
62 explicit OHierarchyElement_Impl( css::uno::WeakReference
< css::embed::XStorage
> xWeakStorage
)
63 : m_xWeakOwnStorage(std::move( xWeakStorage
))
68 void SetParent( const ::rtl::Reference
< OHierarchyElement_Impl
>& rParent
) { m_rParent
= rParent
; }
70 void TestForClosing();
72 void RemoveElement( const ::rtl::Reference
< OHierarchyElement_Impl
>& aRef
);
74 css::uno::Reference
< css::embed::XExtendedStorageStream
>
75 GetStreamHierarchically( sal_Int32 nStorageMode
,
76 std::vector
<OUString
>& aPath
,
77 sal_Int32 nStreamMode
,
78 const ::comphelper::SequenceAsHashMap
& aEncryptionData
);
80 void RemoveStreamHierarchically( std::vector
<OUString
>& aListPath
);
83 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
85 // XTransactionListener
86 virtual void SAL_CALL
preCommit( const css::lang::EventObject
& aEvent
) override
;
87 virtual void SAL_CALL
commited( const css::lang::EventObject
& aEvent
) override
;
88 virtual void SAL_CALL
preRevert( const css::lang::EventObject
& aEvent
) override
;
89 virtual void SAL_CALL
reverted( const css::lang::EventObject
& aEvent
) override
;
93 class OHierarchyHolder_Impl
: public ::cppu::OWeakObject
95 css::uno::WeakReference
< css::embed::XStorage
> m_xWeakOwnStorage
;
96 ::rtl::Reference
< OHierarchyElement_Impl
> m_xChild
;
98 explicit OHierarchyHolder_Impl( const css::uno::Reference
< css::embed::XStorage
>& xOwnStorage
)
99 : m_xWeakOwnStorage( xOwnStorage
)
100 , m_xChild( new OHierarchyElement_Impl( css::uno::WeakReference
< css::embed::XStorage
>( 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: */