Coverage Report

Created: 2025-12-08 09:28

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
4.41k
    : mrDoc ( rDocShell )
32
4.41k
    , mbLockUnlockDispatcher( bLockUnlockDispatcher )
33
4.41k
{
34
4.41k
    EnterWaitAndLockDispatcher();
35
4.41k
}
36
37
SwWait::~SwWait()
38
4.41k
{
39
4.41k
    LeaveWaitAndUnlockDispatcher();
40
4.41k
}
41
42
void SwWait::EnterWaitAndLockDispatcher()
43
4.41k
{
44
4.41k
    SfxViewFrame *pFrame = SfxViewFrame::GetFirst( &mrDoc, false );
45
8.83k
    while ( pFrame )
46
4.41k
    {
47
4.41k
        pFrame->GetWindow().EnterWait();
48
4.41k
        if ( mbLockUnlockDispatcher )
49
4.41k
        {
50
            // do not look already locked dispatchers
51
4.41k
            SfxDispatcher* pDispatcher = pFrame->GetDispatcher();
52
4.41k
            if ( !pDispatcher->IsLocked() )
53
4.41k
            {
54
4.41k
                pDispatcher->Lock( true );
55
4.41k
                mpLockedDispatchers.insert( pDispatcher );
56
4.41k
            }
57
4.41k
        }
58
59
4.41k
        pFrame = SfxViewFrame::GetNext( *pFrame, &mrDoc, false );
60
4.41k
    }
61
4.41k
}
62
63
void SwWait::LeaveWaitAndUnlockDispatcher()
64
4.41k
{
65
4.41k
    SfxViewFrame *pFrame = SfxViewFrame::GetFirst( &mrDoc, false );
66
8.83k
    while ( pFrame )
67
4.41k
    {
68
4.41k
        pFrame->GetWindow().LeaveWait();
69
4.41k
        if ( mbLockUnlockDispatcher )
70
4.41k
        {
71
            // only unlock dispatchers which had been locked
72
4.41k
            SfxDispatcher* pDispatcher = pFrame->GetDispatcher();
73
4.41k
            if ( mpLockedDispatchers.erase( pDispatcher ) )
74
4.41k
            {
75
4.41k
                pDispatcher->Lock( false );
76
4.41k
            }
77
4.41k
        }
78
79
4.41k
        pFrame = SfxViewFrame::GetNext( *pFrame, &mrDoc, false );
80
4.41k
    }
81
4.41k
}
82
83
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */