Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/framework/layoutmanager.hxx
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
#pragma once
21
22
#include <com/sun/star/lang/XServiceInfo.hpp>
23
#include <com/sun/star/frame/XLayoutManager2.hpp>
24
#include <com/sun/star/ui/XUIConfigurationManager.hpp>
25
#include <com/sun/star/frame/XModuleManager2.hpp>
26
#include <com/sun/star/awt/XWindowListener.hpp>
27
#include <com/sun/star/util/XURLTransformer.hpp>
28
#include <com/sun/star/ui/XUIElementFactoryManager.hpp>
29
#include <com/sun/star/ui/DockingArea.hpp>
30
#include <com/sun/star/uno/XComponentContext.hpp>
31
#include <com/sun/star/awt/XTopWindow2.hpp>
32
33
#include <cppuhelper/basemutex.hxx>
34
#include <cppuhelper/propshlp.hxx>
35
#include <cppuhelper/implbase.hxx>
36
#include <comphelper/multicontainer2.hxx>
37
#include <cppuhelper/supportsservice.hxx>
38
#include <comphelper/propertycontainer.hxx>
39
#include <comphelper/uno3.hxx>
40
#include <framework/fwkdllapi.h>
41
#include <framework/uielement.hxx>
42
#include <tools/gen.hxx>
43
#include <vcl/timer.hxx>
44
#include <vcl/vclevent.hxx>
45
46
namespace framework
47
{
48
class MenuBarManager;
49
class MenuBarWrapper;
50
class ProgressBarWrapper;
51
class ToolbarLayoutManager;
52
class GlobalSettings;
53
namespace detail
54
{
55
class InfoHelperBuilder;
56
}
57
typedef ::cppu::WeakImplHelper<css::lang::XServiceInfo, css::frame::XLayoutManager2,
58
                               css::awt::XWindowListener>
59
    LayoutManager_Base;
60
typedef ::comphelper::OPropertyContainer LayoutManager_PBase;
61
62
class FWK_DLLPUBLIC LayoutManager final : public LayoutManager_Base,
63
                                          private cppu::BaseMutex,
64
                                          public ::cppu::OBroadcastHelper,
65
                                          public LayoutManager_PBase
66
{
67
public:
68
    LayoutManager(const css::uno::Reference<css::uno::XComponentContext>& xContext);
69
    virtual ~LayoutManager() override;
70
71
    /** declaration of XInterface, XTypeProvider, XServiceInfo */
72
    DECLARE_XINTERFACE()
73
    DECLARE_XTYPEPROVIDER()
74
    virtual OUString SAL_CALL getImplementationName() override
75
0
    {
76
0
        return u"com.sun.star.comp.framework.LayoutManager"_ustr;
77
0
    }
78
79
    virtual sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override
80
0
    {
81
0
        return cppu::supportsService(this, ServiceName);
82
0
    }
83
84
    virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
85
0
    {
86
0
        css::uno::Sequence<OUString> aSeq{ u"com.sun.star.frame.LayoutManager"_ustr };
87
0
        return aSeq;
88
0
    }
89
90
    // XLayoutManager
91
    virtual void SAL_CALL
92
    attachFrame(const css::uno::Reference<css::frame::XFrame>& Frame) override;
93
    virtual void SAL_CALL reset() override;
94
    virtual css::awt::Rectangle SAL_CALL getCurrentDockingArea() override;
95
    virtual css::uno::Reference<css::ui::XDockingAreaAcceptor>
96
        SAL_CALL getDockingAreaAcceptor() override;
97
    virtual void SAL_CALL setDockingAreaAcceptor(
98
        const css::uno::Reference<css::ui::XDockingAreaAcceptor>& xDockingAreaAcceptor)
99
        final override;
100
    virtual void SAL_CALL createElement(const OUString& aName) override;
101
    virtual void SAL_CALL destroyElement(const OUString& aName) override;
102
    virtual sal_Bool SAL_CALL requestElement(const OUString& ResourceURL) override;
103
    virtual css::uno::Reference<css::ui::XUIElement>
104
        SAL_CALL getElement(const OUString& aName) override;
105
    virtual css::uno::Sequence<css::uno::Reference<css::ui::XUIElement>>
106
        SAL_CALL getElements() override;
107
    virtual sal_Bool SAL_CALL showElement(const OUString& aName) override;
108
    virtual sal_Bool SAL_CALL hideElement(const OUString& aName) override;
109
    virtual sal_Bool SAL_CALL dockWindow(const OUString& aName, css::ui::DockingArea DockingArea,
110
                                         const css::awt::Point& Pos) override;
111
    virtual sal_Bool SAL_CALL dockAllWindows(::sal_Int16 nElementType) override;
112
    virtual sal_Bool SAL_CALL floatWindow(const OUString& aName) override;
113
    virtual sal_Bool SAL_CALL lockWindow(const OUString& ResourceURL) override;
114
    virtual sal_Bool SAL_CALL unlockWindow(const OUString& ResourceURL) override;
115
    bool makeContextSensitive(std::u16string_view sResourceURL, bool bSensitive);
116
    virtual void SAL_CALL setElementSize(const OUString& aName,
117
                                         const css::awt::Size& aSize) override;
118
    virtual void SAL_CALL setElementPos(const OUString& aName,
119
                                        const css::awt::Point& aPos) override;
120
    virtual void SAL_CALL setElementPosSize(const OUString& aName, const css::awt::Point& aPos,
121
                                            const css::awt::Size& aSize) override;
122
    virtual sal_Bool SAL_CALL isElementVisible(const OUString& aName) override;
123
    virtual sal_Bool SAL_CALL isElementFloating(const OUString& aName) override;
124
    virtual sal_Bool SAL_CALL isElementDocked(const OUString& aName) override;
125
    virtual sal_Bool SAL_CALL isElementLocked(const OUString& ResourceURL) override;
126
    virtual css::awt::Size SAL_CALL getElementSize(const OUString& aName) override;
127
    virtual css::awt::Point SAL_CALL getElementPos(const OUString& aName) override;
128
    virtual void SAL_CALL lock() override;
129
    virtual void SAL_CALL unlock() override;
130
    virtual void SAL_CALL doLayout() override;
131
    virtual void SAL_CALL setVisible(sal_Bool bVisible) override;
132
    virtual sal_Bool SAL_CALL isVisible() override;
133
134
    // XMenuBarMergingAcceptor
135
136
    virtual sal_Bool SAL_CALL setMergedMenuBar(
137
        const css::uno::Reference<css::container::XIndexAccess>& xMergedMenuBar) override;
138
    virtual void SAL_CALL removeMergedMenuBar() override;
139
140
    //  XWindowListener
141
    virtual void SAL_CALL windowResized(const css::awt::WindowEvent& aEvent) override;
142
    virtual void SAL_CALL windowMoved(const css::awt::WindowEvent& aEvent) override;
143
    virtual void SAL_CALL windowShown(const css::lang::EventObject& aEvent) override;
144
    virtual void SAL_CALL windowHidden(const css::lang::EventObject& aEvent) override;
145
146
    //   XFrameActionListener
147
    virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent) override;
148
149
    //  XEventListener
150
    using cppu::OPropertySetHelper::disposing;
151
    virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
152
153
    //  XUIConfigurationListener
154
    virtual void SAL_CALL elementInserted(const css::ui::ConfigurationEvent& Event) override;
155
    virtual void SAL_CALL elementRemoved(const css::ui::ConfigurationEvent& Event) override;
156
    virtual void SAL_CALL elementReplaced(const css::ui::ConfigurationEvent& Event) override;
157
158
    //  XLayoutManagerEventBroadcaster
159
    virtual void SAL_CALL addLayoutManagerEventListener(
160
        const css::uno::Reference<css::frame::XLayoutManagerListener>& aLayoutManagerListener)
161
        override;
162
    virtual void SAL_CALL removeLayoutManagerEventListener(
163
        const css::uno::Reference<css::frame::XLayoutManagerListener>& aLayoutManagerListener)
164
        override;
165
166
    DECL_LINK(MenuBarClose, void*, void);
167
    DECL_LINK(WindowEventListener, VclWindowEvent&, void);
168
169
    //  called from ToolbarLayoutManager
170
    void requestLayout();
171
172
    /// Reading of settings - shared with ToolbarLayoutManager.
173
    static bool readWindowStateData(
174
        const OUString& rName, UIElement& rElementData,
175
        const css::uno::Reference<css::container::XNameAccess>& rPersistentWindowState,
176
        std::unique_ptr<GlobalSettings>& rGlobalSettings, bool& bInGlobalSettings,
177
        const css::uno::Reference<css::uno::XComponentContext>& rComponentContext);
178
179
private:
180
    DECL_LINK(AsyncLayoutHdl, Timer*, void);
181
182
    //  menu bar
183
184
    void implts_createMenuBar(const OUString& rMenuBarName);
185
    void impl_clearUpMenuBar();
186
    void implts_reset(bool bAttach);
187
    void implts_updateMenuBarClose();
188
    bool implts_resetMenuBar();
189
    void implts_createMSCompatibleMenuBar(const OUString& rName);
190
191
    //  locking
192
193
    void implts_lock();
194
    bool implts_unlock();
195
196
    //  query
197
198
    css::uno::Reference<css::ui::XUIElement> implts_findElement(std::u16string_view aName);
199
200
    bool implts_readWindowStateData(const OUString& rName, UIElement& rElementData);
201
    void implts_writeWindowStateData(const OUString& rName, const UIElement& rElementData);
202
    void implts_destroyElements();
203
    void implts_toggleFloatingUIElementsVisibility(bool bActive);
204
    void implts_reparentChildWindows();
205
    css::uno::Reference<css::ui::XUIElement>
206
    implts_createDockingWindow(const OUString& aElementName);
207
208
    bool implts_isEmbeddedLayoutManager() const;
209
    css::uno::Reference<css::ui::XUIElement> implts_createElement(const OUString& aName);
210
211
    // layouting methods
212
    bool implts_resizeContainerWindow(const css::awt::Size& rContainerSize,
213
                                      const css::awt::Point& rComponentPos);
214
    ::Size implts_getContainerWindowOutputSize();
215
216
    void implts_setDockingAreaWindowSizes();
217
    css::awt::Rectangle implts_calcDockingAreaSizes();
218
    bool implts_doLayout(bool bForceRequestBorderSpace, bool bOuterResize);
219
    void implts_doLayout_notify(bool bOuterResize);
220
221
    // internal methods to control status/progress bar
222
    ::Size implts_getStatusBarSize();
223
    void implts_destroyStatusBar();
224
    void implts_createStatusBar(const OUString& rStatusBarName);
225
    void implts_createProgressBar();
226
    void implts_destroyProgressBar();
227
    void implts_setStatusBarPosSize(const ::Point& rPos, const ::Size& rSize);
228
    bool implts_showStatusBar(bool bStoreState = false);
229
    bool implts_hideStatusBar(bool bStoreState = false);
230
    void implts_readStatusBarState(const OUString& rStatusBarName);
231
    bool implts_showProgressBar();
232
    bool implts_hideProgressBar();
233
    void implts_backupProgressBarWrapper();
234
    void implts_setOffset(const sal_Int32 nBottomOffset);
235
236
    /// @throws css::uno::RuntimeException
237
    void implts_setInplaceMenuBar(
238
        const css::uno::Reference<css::container::XIndexAccess>& xMergedMenuBar);
239
    /// @throws css::uno::RuntimeException
240
    void implts_resetInplaceMenuBar();
241
242
    void implts_setVisibleState(bool bShow);
243
    void implts_updateUIElementsVisibleState(bool bShow);
244
    void implts_setCurrentUIVisibility(bool bShow);
245
    void implts_notifyListeners(short nEvent, const css::uno::Any& rInfoParam);
246
247
    //  OPropertySetHelper
248
249
    virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,
250
                                                           const css::uno::Any& aValue) override;
251
    virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
252
    virtual css::uno::Reference<css::beans::XPropertySetInfo>
253
        SAL_CALL getPropertySetInfo() override;
254
255
    css::uno::Reference<css::uno::XComponentContext>
256
        m_xContext; /** reference to factory, which has created this instance. */
257
    css::uno::Reference<css::util::XURLTransformer> m_xURLTransformer;
258
    css::uno::Reference<css::frame::XFrame> m_xFrame;
259
    css::uno::Reference<css::ui::XUIConfigurationManager> m_xModuleCfgMgr;
260
    css::uno::Reference<css::ui::XUIConfigurationManager> m_xDocCfgMgr;
261
    css::uno::Reference<css::awt::XWindow> m_xContainerWindow;
262
    css::uno::Reference<css::awt::XTopWindow2> m_xContainerTopWindow;
263
    sal_Int32 m_nLockCount;
264
    bool m_bInplaceMenuSet;
265
    bool m_bMenuVisible;
266
    bool m_bVisible;
267
    bool m_bParentWindowVisible;
268
    bool m_bMustDoLayout;
269
    bool m_bAutomaticToolbars;
270
    bool m_bHideCurrentUI;
271
    bool m_bGlobalSettings;
272
    bool m_bPreserveContentSize;
273
    bool m_bMenuBarCloseButton;
274
    css::awt::Rectangle m_aDockingArea;
275
    css::uno::Reference<css::ui::XDockingAreaAcceptor> m_xDockingAreaAcceptor;
276
    rtl::Reference<MenuBarManager> m_xInplaceMenuBar;
277
    rtl::Reference<MenuBarWrapper> m_xMenuBar;
278
    UIElement m_aStatusBarElement;
279
    UIElement m_aProgressBarElement;
280
    rtl::Reference<ProgressBarWrapper> m_xProgressBarBackup;
281
    css::uno::Reference<css::frame::XModuleManager2> m_xModuleManager;
282
    css::uno::Reference<css::ui::XUIElementFactoryManager> m_xUIElementFactoryManager;
283
    css::uno::Reference<css::container::XNameAccess> m_xPersistentWindowState;
284
    css::uno::Reference<css::container::XNameAccess> m_xPersistentWindowStateSupplier;
285
    std::unique_ptr<GlobalSettings> m_pGlobalSettings;
286
    OUString m_aModuleIdentifier;
287
    Timer m_aAsyncLayoutTimer;
288
    // container for ALL Listener
289
    comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerContainer;
290
    rtl::Reference<ToolbarLayoutManager> m_xToolbarManager;
291
    bool m_bInSetCurrentUIVisibility;
292
293
    friend class detail::InfoHelperBuilder;
294
};
295
296
} // namespace framework
297
298
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */