Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/package/source/xstor/ohierarchyholder.hxx
Line
Count
Source
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>
26
#include <cppuhelper/implbase.hxx>
27
#include <cppuhelper/weakref.hxx>
28
#include <unotools/weakref.hxx>
29
30
#include <comphelper/sequenceashashmap.hxx>
31
32
#include <rtl/ref.hxx>
33
#include <mutex>
34
#include <unordered_map>
35
#include <utility>
36
#include <vector>
37
38
class OHierarchyElement_Impl;
39
class OStorage;
40
41
typedef std::unordered_map< OUString,
42
                         ::rtl::Reference< OHierarchyElement_Impl > > OHierarchyElementList_Impl;
43
44
typedef ::std::vector< css::uno::WeakReference< css::embed::XExtendedStorageStream > >
45
                        OWeakStorRefVector_Impl;
46
47
class OHierarchyElement_Impl : public cppu::WeakImplHelper< css::embed::XTransactionListener >
48
{
49
    std::mutex m_aMutex;
50
51
    ::rtl::Reference< OHierarchyElement_Impl > m_rParent;
52
    rtl::Reference< OStorage > m_xOwnStorage;
53
    unotools::WeakReference< OStorage > m_xWeakOwnStorage;
54
55
    OHierarchyElementList_Impl m_aChildren;
56
57
    OWeakStorRefVector_Impl m_aOpenStreams;
58
59
public:
60
    explicit OHierarchyElement_Impl(rtl::Reference< OStorage > xStorage )
61
15.3k
    : m_xOwnStorage(std::move( xStorage ))
62
15.3k
    {}
63
64
    explicit OHierarchyElement_Impl( unotools::WeakReference< OStorage >&& xWeakStorage )
65
10.4k
    : m_xWeakOwnStorage(std::move( xWeakStorage ))
66
10.4k
    {}
67
68
    void Commit();
69
70
11.1k
    void SetParent( const ::rtl::Reference< OHierarchyElement_Impl >& rParent ) { m_rParent = rParent; }
71
72
    void TestForClosing();
73
74
    void RemoveElement( const ::rtl::Reference< OHierarchyElement_Impl >& aRef );
75
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 );
81
82
    void RemoveStreamHierarchically( std::vector<OUString>& aListPath );
83
84
    // XEventListener
85
    virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
86
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;
92
93
};
94
95
class OHierarchyHolder_Impl
96
{
97
    ::rtl::Reference< OHierarchyElement_Impl > m_xChild;
98
public:
99
    explicit OHierarchyHolder_Impl(unotools::WeakReference<OStorage>&& xOwnStorage)
100
10.4k
    : m_xChild( new OHierarchyElement_Impl( std::move(xOwnStorage) ) )
101
10.4k
    {}
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: */