cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / inc / ViewShellImplementation.hxx
blobb4a02c3d5419b3d88cbc3ffccc95da8ae4b82079
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include "ViewShell.hxx"
23 #include "ViewShellManager.hxx"
24 #include "ToolBarManager.hxx"
25 #include <o3tl/deleter.hxx>
26 #include <memory>
28 class SvxIMapDlg;
30 namespace sd
32 /** This class contains (will contain) the implementation of methods that
33 have not be accessible from the outside.
35 class ViewShell::Implementation
37 public:
38 bool mbIsMainViewShell;
39 /// Set to true when the ViewShell::Init() method has been called.
40 bool mbIsInitialized;
41 /** Set to true while ViewShell::ArrangeGUIElements() is being
42 executed. It is used as guard against recursive execution.
44 bool mbArrangeActive;
46 /** Remember a link to the sub shell factory, so that it can be
47 unregistered at the ViewShellManager when a ViewShell is deleted.
49 ViewShellManager::SharedShellFactory mpSubShellFactory;
51 /** This update lock for the ToolBarManager exists in order to avoid
52 problems with tool bars being displayed while the mouse button is
53 pressed. With docked tool bars this can lead to a size change of
54 the view. This would change the relative mouse coordinates and thus
55 interpret every mouse click as move command.
57 class ToolBarManagerLock
59 public:
60 /** Create a new instance. This allows the mpSelf member to be set
61 automatically.
63 static std::shared_ptr<ToolBarManagerLock>
64 Create(const std::shared_ptr<ToolBarManager>& rpManager);
65 /** Release the lock. When the UI is captured
66 (Application::IsUICaptured() returns <TRUE/>) then the lock is
67 released later asynchronously.
68 @param bForce
69 When this flag is <TRUE/> then the lock is released even
70 when IsUICaptured() returns <TRUE/>.
72 void Release(bool bForce = false);
73 DECL_DLLPRIVATE_LINK(TimeoutCallback, Timer*, void);
75 private:
76 ::std::unique_ptr<ToolBarManager::UpdateLock,
77 o3tl::default_delete<ToolBarManager::UpdateLock>>
78 mpLock;
79 /** The timer is used both as a safe guard to unlock the update lock
80 when Release() is not called explicitly. It is also used to
81 defer the release of the lock to a time when the UI is not
82 captured.
84 Timer maTimer;
85 /** The shared_ptr to this allows the ToolBarManagerLock to control
86 its own lifetime. This, of course, does work only when no one
87 holds another shared_ptr longer than only temporary.
89 std::shared_ptr<ToolBarManagerLock> mpSelf;
90 ToolBarManagerLock(const std::shared_ptr<sd::ToolBarManager>& rpManager);
91 ~ToolBarManagerLock();
93 class Deleter;
94 friend class Deleter;
96 // The member is not a unique_ptr because it takes over its own life time
97 // control.
98 std::weak_ptr<ToolBarManagerLock> mpUpdateLockForMouse;
100 Implementation(ViewShell& rViewShell);
101 ~Implementation() COVERITY_NOEXCEPT_FALSE;
103 /** Process the SID_MODIFY slot.
105 void ProcessModifyPageSlot(SfxRequest& rRequest, SdPage* pCurrentPage, PageKind ePageKind);
107 /** Assign the given layout to the given page. This method is at the
108 moment merely a front end for ProcessModifyPageSlot.
109 @param pPage
110 If a NULL pointer is given then this call is ignored.
112 void AssignLayout(SfxRequest const& rRequest, PageKind ePageKind);
114 /** Determine the view id of the view shell. This corresponds to the
115 view id stored in the SfxViewFrame class.
117 We can not use the view of that class because with the introduction
118 of the multi pane GUI we do not switch the SfxViewShell anymore when
119 switching the view in the center pane. The view id of the
120 SfxViewFrame is thus not modified and we can not set it from the
121 outside.
123 The view id is still needed for the SFX to determine on start up
124 (e.g. after loading a document) which ViewShellBase sub class to
125 use. These sub classes--like OutlineViewShellBase--exist only to be
126 used by the SFX as factories. They only set the initial pane
127 configuration, nothing more.
129 So what we do here in essence is to return one of the
130 ViewShellFactoryIds that can be used to select the factory that
131 creates the ViewShellBase subclass with the initial pane
132 configuration that has in the center pane a view shell of the same
133 type as mrViewShell.
135 SfxInterfaceId GetViewId() const;
137 /** Return a pointer to the image map dialog that is displayed in some
138 child window.
139 @return
140 Returns <NULL/> when the image map dialog is not available.
142 static SvxIMapDlg* GetImageMapDialog();
144 private:
145 ViewShell& mrViewShell;
148 } // end of namespace sd
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */