Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/source/uibase/app/swwait.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 <swwait.hxx>
21
#include <docsh.hxx>
22
23
#include <sfx2/viewfrm.hxx>
24
#include <sfx2/dispatch.hxx>
25
26
#include <vcl/window.hxx>
27
28
SwWait::SwWait(
29
    SwDocShell &rDocShell,
30
    const bool bLockUnlockDispatcher )
31
8.76k
    : mrDoc ( rDocShell )
32
8.76k
    , mbLockUnlockDispatcher( bLockUnlockDispatcher )
33
8.76k
{
34
8.76k
    EnterWaitAndLockDispatcher();
35
8.76k
}
36
37
SwWait::~SwWait()
38
8.76k
{
39
8.76k
    LeaveWaitAndUnlockDispatcher();
40
8.76k
}
41
42
void SwWait::EnterWaitAndLockDispatcher()
43
8.76k
{
44
8.76k
    SfxViewFrame *pFrame = SfxViewFrame::GetFirst( &mrDoc, false );
45
17.5k
    while ( pFrame )
46
8.76k
    {
47
8.76k
        pFrame->GetWindow().EnterWait();
48
8.76k
        if ( mbLockUnlockDispatcher )
49
8.76k
        {
50
            // do not lock already locked dispatchers
51
8.76k
            SfxDispatcher* pDispatcher = pFrame->GetDispatcher();
52
8.76k
            if ( !pDispatcher->IsLocked() )
53
8.76k
            {
54
8.76k
                pDispatcher->Lock( true );
55
8.76k
                mpLockedDispatchers.insert( pDispatcher );
56
8.76k
            }
57
8.76k
        }
58
59
8.76k
        pFrame = SfxViewFrame::GetNext( *pFrame, &mrDoc, false );
60
8.76k
    }
61
8.76k
}
62
63
void SwWait::LeaveWaitAndUnlockDispatcher()
64
8.76k
{
65
8.76k
    SfxViewFrame *pFrame = SfxViewFrame::GetFirst( &mrDoc, false );
66
17.5k
    while ( pFrame )
67
8.76k
    {
68
8.76k
        pFrame->GetWindow().LeaveWait();
69
8.76k
        if ( mbLockUnlockDispatcher )
70
8.76k
        {
71
            // only unlock dispatchers which had been locked
72
8.76k
            SfxDispatcher* pDispatcher = pFrame->GetDispatcher();
73
8.76k
            if ( mpLockedDispatchers.erase( pDispatcher ) )
74
8.76k
            {
75
8.76k
                pDispatcher->Lock( false );
76
8.76k
            }
77
8.76k
        }
78
79
8.76k
        pFrame = SfxViewFrame::GetNext( *pFrame, &mrDoc, false );
80
8.76k
    }
81
8.76k
}
82
83
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */