Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/framework/inc/services/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 <uielement/uielement.hxx>
23
24
#include <com/sun/star/lang/XServiceInfo.hpp>
25
#include <com/sun/star/frame/XLayoutManager2.hpp>
26
#include <com/sun/star/ui/XUIConfigurationManager.hpp>
27
#include <com/sun/star/frame/XModuleManager2.hpp>
28
#include <com/sun/star/awt/XWindowListener.hpp>
29
#include <com/sun/star/util/XURLTransformer.hpp>
30
#include <com/sun/star/ui/XUIElementFactoryManager.hpp>
31
#include <com/sun/star/ui/DockingArea.hpp>
32
#include <com/sun/star/uno/XComponentContext.hpp>
33
#include <com/sun/star/awt/XTopWindow2.hpp>
34
35
#include <cppuhelper/basemutex.hxx>
36
#include <cppuhelper/propshlp.hxx>
37
#include <cppuhelper/implbase.hxx>
38
#include <comphelper/multicontainer2.hxx>
39
#include <cppuhelper/supportsservice.hxx>
40
#include <comphelper/propertycontainer.hxx>
41
#include <comphelper/uno3.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 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
    virtual void SAL_CALL setElementSize(const OUString& aName,
116
                                         const css::awt::Size& aSize) override;
117
    virtual void SAL_CALL setElementPos(const OUString& aName,
118
                                        const css::awt::Point& aPos) override;
119
    virtual void SAL_CALL setElementPosSize(const OUString& aName, const css::awt::Point& aPos,
120
                                            const css::awt::Size& aSize) override;
121
    virtual sal_Bool SAL_CALL isElementVisible(const OUString& aName) override;
122
    virtual sal_Bool SAL_CALL isElementFloating(const OUString& aName) override;
123
    virtual sal_Bool SAL_CALL isElementDocked(const OUString& aName) override;
124
    virtual sal_Bool SAL_CALL isElementLocked(const OUString& ResourceURL) override;
125
    virtual css::awt::Size SAL_CALL getElementSize(const OUString& aName) override;
126
    virtual css::awt::Point SAL_CALL getElementPos(const OUString& aName) override;
127
    virtual void SAL_CALL lock() override;
128
    virtual void SAL_CALL unlock() override;
129
    virtual void SAL_CALL doLayout() override;
130
    virtual void SAL_CALL setVisible(sal_Bool bVisible) override;
131
    virtual sal_Bool SAL_CALL isVisible() override;
132
133
    // XMenuBarMergingAcceptor
134
135
    virtual sal_Bool SAL_CALL setMergedMenuBar(
136
        const css::uno::Reference<css::container::XIndexAccess>& xMergedMenuBar) override;
137
    virtual void SAL_CALL removeMergedMenuBar() override;
138
139
    //  XWindowListener
140
    virtual void SAL_CALL windowResized(const css::awt::WindowEvent& aEvent) override;
141
    virtual void SAL_CALL windowMoved(const css::awt::WindowEvent& aEvent) override;
142
    virtual void SAL_CALL windowShown(const css::lang::EventObject& aEvent) override;
143
    virtual void SAL_CALL windowHidden(const css::lang::EventObject& aEvent) override;
144
145
    //   XFrameActionListener
146
    virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent) override;
147
148
    //  XEventListener
149
    using cppu::OPropertySetHelper::disposing;
150
    virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
151
152
    //  XUIConfigurationListener
153
    virtual void SAL_CALL elementInserted(const css::ui::ConfigurationEvent& Event) override;
154
    virtual void SAL_CALL elementRemoved(const css::ui::ConfigurationEvent& Event) override;
155
    virtual void SAL_CALL elementReplaced(const css::ui::ConfigurationEvent& Event) override;
156
157
    //  XLayoutManagerEventBroadcaster
158
    virtual void SAL_CALL addLayoutManagerEventListener(
159
        const css::uno::Reference<css::frame::XLayoutManagerListener>& aLayoutManagerListener)
160
        override;
161
    virtual void SAL_CALL removeLayoutManagerEventListener(
162
        const css::uno::Reference<css::frame::XLayoutManagerListener>& aLayoutManagerListener)
163
        override;
164
165
    DECL_LINK(MenuBarClose, void*, void);
166
    DECL_LINK(WindowEventListener, VclWindowEvent&, void);
167
168
    //  called from ToolbarLayoutManager
169
    void requestLayout();
170
171
    /// Reading of settings - shared with ToolbarLayoutManager.
172
    static bool readWindowStateData(
173
        const OUString& rName, UIElement& rElementData,
174
        const css::uno::Reference<css::container::XNameAccess>& rPersistentWindowState,
175
        std::unique_ptr<GlobalSettings>& rGlobalSettings, bool& bInGlobalSettings,
176
        const css::uno::Reference<css::uno::XComponentContext>& rComponentContext);
177
178
private:
179
    DECL_LINK(AsyncLayoutHdl, Timer*, void);
180
181
    //  menu bar
182
183
    void implts_createMenuBar(const OUString& rMenuBarName);
184
    void impl_clearUpMenuBar();
185
    void implts_reset(bool bAttach);
186
    void implts_updateMenuBarClose();
187
    bool implts_resetMenuBar();
188
    void implts_createMSCompatibleMenuBar(const OUString& rName);
189
190
    //  locking
191
192
    void implts_lock();
193
    bool implts_unlock();
194
195
    //  query
196
197
    css::uno::Reference<css::ui::XUIElement> implts_findElement(std::u16string_view aName);
198
199
    bool implts_readWindowStateData(const OUString& rName, UIElement& rElementData);
200
    void implts_writeWindowStateData(const OUString& rName, const UIElement& rElementData);
201
    void implts_destroyElements();
202
    void implts_toggleFloatingUIElementsVisibility(bool bActive);
203
    void implts_reparentChildWindows();
204
    css::uno::Reference<css::ui::XUIElement>
205
    implts_createDockingWindow(const OUString& aElementName);
206
207
    bool implts_isEmbeddedLayoutManager() const;
208
    css::uno::Reference<css::ui::XUIElement> implts_createElement(const OUString& aName);
209
210
    // layouting methods
211
    bool implts_resizeContainerWindow(const css::awt::Size& rContainerSize,
212
                                      const css::awt::Point& rComponentPos);
213
    ::Size implts_getContainerWindowOutputSize();
214
215
    void implts_setDockingAreaWindowSizes();
216
    css::awt::Rectangle implts_calcDockingAreaSizes();
217
    bool implts_doLayout(bool bForceRequestBorderSpace, bool bOuterResize);
218
    void implts_doLayout_notify(bool bOuterResize);
219
220
    // internal methods to control status/progress bar
221
    ::Size implts_getStatusBarSize();
222
    void implts_destroyStatusBar();
223
    void implts_createStatusBar(const OUString& rStatusBarName);
224
    void implts_createProgressBar();
225
    void implts_destroyProgressBar();
226
    void implts_setStatusBarPosSize(const ::Point& rPos, const ::Size& rSize);
227
    bool implts_showStatusBar(bool bStoreState = false);
228
    bool implts_hideStatusBar(bool bStoreState = false);
229
    void implts_readStatusBarState(const OUString& rStatusBarName);
230
    bool implts_showProgressBar();
231
    bool implts_hideProgressBar();
232
    void implts_backupProgressBarWrapper();
233
    void implts_setOffset(const sal_Int32 nBottomOffset);
234
235
    /// @throws css::uno::RuntimeException
236
    void implts_setInplaceMenuBar(
237
        const css::uno::Reference<css::container::XIndexAccess>& xMergedMenuBar);
238
    /// @throws css::uno::RuntimeException
239
    void implts_resetInplaceMenuBar();
240
241
    void implts_setVisibleState(bool bShow);
242
    void implts_updateUIElementsVisibleState(bool bShow);
243
    void implts_setCurrentUIVisibility(bool bShow);
244
    void implts_notifyListeners(short nEvent, const css::uno::Any& rInfoParam);
245
246
    //  OPropertySetHelper
247
248
    virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,
249
                                                           const css::uno::Any& aValue) override;
250
    virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
251
    virtual css::uno::Reference<css::beans::XPropertySetInfo>
252
        SAL_CALL getPropertySetInfo() override;
253
254
    css::uno::Reference<css::uno::XComponentContext>
255
        m_xContext; /** reference to factory, which has created this instance. */
256
    css::uno::Reference<css::util::XURLTransformer> m_xURLTransformer;
257
    css::uno::Reference<css::frame::XFrame> m_xFrame;
258
    css::uno::Reference<css::ui::XUIConfigurationManager> m_xModuleCfgMgr;
259
    css::uno::Reference<css::ui::XUIConfigurationManager> m_xDocCfgMgr;
260
    css::uno::Reference<css::awt::XWindow> m_xContainerWindow;
261
    css::uno::Reference<css::awt::XTopWindow2> m_xContainerTopWindow;
262
    sal_Int32 m_nLockCount;
263
    bool m_bInplaceMenuSet;
264
    bool m_bMenuVisible;
265
    bool m_bVisible;
266
    bool m_bParentWindowVisible;
267
    bool m_bMustDoLayout;
268
    bool m_bAutomaticToolbars;
269
    bool m_bHideCurrentUI;
270
    bool m_bGlobalSettings;
271
    bool m_bPreserveContentSize;
272
    bool m_bMenuBarCloseButton;
273
    css::awt::Rectangle m_aDockingArea;
274
    css::uno::Reference<css::ui::XDockingAreaAcceptor> m_xDockingAreaAcceptor;
275
    rtl::Reference<MenuBarManager> m_xInplaceMenuBar;
276
    rtl::Reference<MenuBarWrapper> m_xMenuBar;
277
    UIElement m_aStatusBarElement;
278
    UIElement m_aProgressBarElement;
279
    rtl::Reference<ProgressBarWrapper> m_xProgressBarBackup;
280
    css::uno::Reference<css::frame::XModuleManager2> m_xModuleManager;
281
    css::uno::Reference<css::ui::XUIElementFactoryManager> m_xUIElementFactoryManager;
282
    css::uno::Reference<css::container::XNameAccess> m_xPersistentWindowState;
283
    css::uno::Reference<css::container::XNameAccess> m_xPersistentWindowStateSupplier;
284
    std::unique_ptr<GlobalSettings> m_pGlobalSettings;
285
    OUString m_aModuleIdentifier;
286
    Timer m_aAsyncLayoutTimer;
287
    // container for ALL Listener
288
    comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerContainer;
289
    rtl::Reference<ToolbarLayoutManager> m_xToolbarManager;
290
    bool m_bInSetCurrentUIVisibility;
291
292
    friend class detail::InfoHelperBuilder;
293
};
294
295
} // namespace framework
296
297
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */