LibreOffice Module package (master) 1
ohierarchyholder.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_PACKAGE_SOURCE_XSTOR_OHIERARCHYHOLDER_HXX
21#define INCLUDED_PACKAGE_SOURCE_XSTOR_OHIERARCHYHOLDER_HXX
22
23#include <com/sun/star/embed/XStorage.hpp>
24#include <com/sun/star/embed/XTransactionListener.hpp>
25#include <com/sun/star/embed/XExtendedStorageStream.hpp>
28
30
31#include <rtl/ref.hxx>
32#include <mutex>
33#include <unordered_map>
34#include <utility>
35#include <vector>
36
38
39typedef std::unordered_map< OUString,
41
42typedef ::std::vector< css::uno::WeakReference< css::embed::XExtendedStorageStream > >
44
45class OHierarchyElement_Impl : public cppu::WeakImplHelper< css::embed::XTransactionListener >
46{
47 std::mutex m_aMutex;
48
50 css::uno::Reference< css::embed::XStorage > m_xOwnStorage;
51 css::uno::WeakReference< css::embed::XStorage > m_xWeakOwnStorage;
52
54
56
57public:
58 explicit OHierarchyElement_Impl( css::uno::Reference< css::embed::XStorage > xStorage )
59 : m_xOwnStorage(std::move( xStorage ))
60 {}
61
62 explicit OHierarchyElement_Impl( css::uno::WeakReference< css::embed::XStorage > xWeakStorage )
63 : m_xWeakOwnStorage(std::move( xWeakStorage ))
64 {}
65
66 void Commit();
67
68 void SetParent( const ::rtl::Reference< OHierarchyElement_Impl >& rParent ) { m_rParent = rParent; }
69
70 void TestForClosing();
71
72 void RemoveElement( const ::rtl::Reference< OHierarchyElement_Impl >& aRef );
73
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 );
79
80 void RemoveStreamHierarchically( std::vector<OUString>& aListPath );
81
82 // XEventListener
83 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
84
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;
90
91};
92
94{
95 css::uno::WeakReference< css::embed::XStorage > m_xWeakOwnStorage;
97public:
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 ) ) )
101 {}
102
103 static std::vector<OUString> GetListPathFromString( std::u16string_view aPath );
104
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() );
110
111 void RemoveStreamHierarchically( std::vector<OUString>& aListPath );
112};
113
114#endif // _OHIERARCHYHOLDER
115
116/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OHierarchyElement_Impl(css::uno::Reference< css::embed::XStorage > xStorage)
virtual void SAL_CALL preCommit(const css::lang::EventObject &aEvent) override
OWeakStorRefVector_Impl m_aOpenStreams
css::uno::WeakReference< css::embed::XStorage > m_xWeakOwnStorage
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
::rtl::Reference< OHierarchyElement_Impl > m_rParent
OHierarchyElementList_Impl m_aChildren
css::uno::Reference< css::embed::XStorage > m_xOwnStorage
css::uno::Reference< css::embed::XExtendedStorageStream > GetStreamHierarchically(sal_Int32 nStorageMode, std::vector< OUString > &aPath, sal_Int32 nStreamMode, const ::comphelper::SequenceAsHashMap &aEncryptionData)
void SetParent(const ::rtl::Reference< OHierarchyElement_Impl > &rParent)
virtual void SAL_CALL preRevert(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL reverted(const css::lang::EventObject &aEvent) override
OHierarchyElement_Impl(css::uno::WeakReference< css::embed::XStorage > xWeakStorage)
virtual void SAL_CALL commited(const css::lang::EventObject &aEvent) override
void RemoveElement(const ::rtl::Reference< OHierarchyElement_Impl > &aRef)
void RemoveStreamHierarchically(std::vector< OUString > &aListPath)
css::uno::WeakReference< css::embed::XStorage > m_xWeakOwnStorage
css::uno::Reference< css::embed::XExtendedStorageStream > GetStreamHierarchically(sal_Int32 nStorageMode, std::vector< OUString > &aListPath, sal_Int32 nStreamMode, const ::comphelper::SequenceAsHashMap &aEncryptionData=::comphelper::SequenceAsHashMap())
OHierarchyHolder_Impl(const css::uno::Reference< css::embed::XStorage > &xOwnStorage)
void RemoveStreamHierarchically(std::vector< OUString > &aListPath)
static std::vector< OUString > GetListPathFromString(std::u16string_view aPath)
::rtl::Reference< OHierarchyElement_Impl > m_xChild
std::unordered_map< OUString, ::rtl::Reference< OHierarchyElement_Impl > > OHierarchyElementList_Impl
::std::vector< css::uno::WeakReference< css::embed::XExtendedStorageStream > > OWeakStorRefVector_Impl