Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sot/source/base/object.cxx
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
#include <sot/object.hxx>
21
#include <rtl/ref.hxx>
22
23
SotObject::SotObject()
24
505k
    : nOwnerLockCount(0)
25
505k
    , bInClose(false)
26
505k
{
27
505k
}
28
29
505k
SotObject::~SotObject() = default;
30
31
/** When the OwnerLock is decremented to zero, the DoClose method is called.
32
 *  This happens independently of the lock or RefCount. If the OwnerLock
33
 *  counter != zero, no DoClose is called by <SotObject::FuzzyLock>.
34
 *
35
 *  bLock - true, lock. false, unlock.
36
 */
37
void SotObject::OwnerLock(bool bLock)
38
247k
{
39
247k
    if (bLock)
40
123k
    {
41
123k
        nOwnerLockCount++;
42
123k
        acquire();
43
123k
    }
44
123k
    else if (nOwnerLockCount)
45
123k
    {
46
123k
        if (0 == --nOwnerLockCount)
47
123k
            DoClose();
48
123k
        release();
49
123k
    }
50
247k
}
51
52
bool SotObject::DoClose()
53
123k
{
54
123k
    bool bRet = false;
55
123k
    if (!bInClose)
56
123k
    {
57
123k
        rtl::Reference<SotObject> xHoldAlive(this);
58
123k
        bInClose = true;
59
123k
        bRet = Close();
60
123k
        bInClose = false;
61
123k
    }
62
123k
    return bRet;
63
123k
}
64
65
0
bool SotObject::Close() { return true; }
66
67
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */