LibreOffice Module sw (master) 1
swwait.cxx
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#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
29 SwDocShell &rDocShell,
30 const bool bLockUnlockDispatcher )
31 : mrDoc ( rDocShell )
32 , mbLockUnlockDispatcher( bLockUnlockDispatcher )
33{
35}
36
38{
40}
41
43{
44 SfxViewFrame *pFrame = SfxViewFrame::GetFirst( &mrDoc, false );
45 while ( pFrame )
46 {
47 pFrame->GetWindow().EnterWait();
49 {
50 // do not look already locked dispatchers
51 SfxDispatcher* pDispatcher = pFrame->GetDispatcher();
52 if ( !pDispatcher->IsLocked() )
53 {
54 pDispatcher->Lock( true );
55 mpLockedDispatchers.insert( pDispatcher );
56 }
57 }
58
59 pFrame = SfxViewFrame::GetNext( *pFrame, &mrDoc, false );
60 }
61}
62
64{
65 SfxViewFrame *pFrame = SfxViewFrame::GetFirst( &mrDoc, false );
66 while ( pFrame )
67 {
68 pFrame->GetWindow().LeaveWait();
70 {
71 // only unlock dispatchers which had been locked
72 SfxDispatcher* pDispatcher = pFrame->GetDispatcher();
73 if ( mpLockedDispatchers.erase( pDispatcher ) )
74 {
75 pDispatcher->Lock( false );
76 }
77 }
78
79 pFrame = SfxViewFrame::GetNext( *pFrame, &mrDoc, false );
80 }
81}
82
83/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsLocked() const
void Lock(bool bLock)
vcl::Window & GetWindow() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
SfxDispatcher * GetDispatcher()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
o3tl::sorted_vector< SfxDispatcher * > mpLockedDispatchers
Definition: swwait.hxx:45
SwDocShell & mrDoc
Definition: swwait.hxx:43
~SwWait()
Definition: swwait.cxx:37
const bool mbLockUnlockDispatcher
Definition: swwait.hxx:44
void LeaveWaitAndUnlockDispatcher()
Definition: swwait.cxx:63
SwWait(SwDocShell &rDocShell, const bool bLockUnlockDispatcher)
Definition: swwait.cxx:28
void EnterWaitAndLockDispatcher()
Definition: swwait.cxx:42
size_type erase(const Value &x)
std::pair< const_iterator, bool > insert(Value &&x)
void LeaveWait()
void EnterWait()