Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/inc/ViewShellBase.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 <glob.hxx>
23
#include <sfx2/viewsh.hxx>
24
#include <memory>
25
26
class SdDrawDocument;
27
struct SdViewOptions;
28
class SfxRequest;
29
30
namespace sdtools {
31
class EventMultiplexer;
32
}
33
34
namespace sd {
35
36
class DrawController;
37
class DrawDocShell;
38
class FormShellManager;
39
class ToolBarManager;
40
class ViewShell;
41
class ViewShellManager;
42
class ViewTabBar;
43
44
/** SfxViewShell descendant that the stacked Draw/Impress shells are
45
    based on.
46
47
    <p>The "base" part of the name does not mean that this is a base
48
    class of some class hierarchy.  It rather is the base of the
49
    stacked shells.</p>
50
51
    <p>This class starts as a new and relatively small class.  Over
52
    time as much code as possible should be moved from the stacked
53
    shells to this class.</p>
54
*/
55
class ViewShellBase
56
    : public SfxViewShell
57
{
58
public:
59
    SFX_DECL_INTERFACE(SD_IF_SDVIEWSHELLBASE)
60
61
private:
62
    /// SfxInterface initializer.
63
    static void InitInterface_Impl();
64
65
public:
66
    /** This constructor is used by the view factory of the SFX macros.
67
        Note that LateInit() has to be called after the constructor
68
        terminates and before doing anything else.
69
    */
70
    ViewShellBase (
71
        SfxViewFrame& rFrame,
72
        SfxViewShell* pOldShell);
73
74
    virtual ~ViewShellBase() override;
75
76
    /** This method is part of the object construction.  It HAS to be called
77
        after the constructor has created a new object.
78
    */
79
    void LateInit (const OUString& rsDefaultView);
80
81
    std::shared_ptr<ViewShellManager> const & GetViewShellManager() const;
82
83
    /** Return the main view shell stacked on the called ViewShellBase
84
        object.  This is usually the view shell displayed in the center
85
        pane.
86
    */
87
    std::shared_ptr<ViewShell> GetMainViewShell() const;
88
89
    /** When given a view frame this static method returns the
90
        corresponding sd::ViewShellBase object.
91
        @return
92
            When the SfxViewShell of the given frame is not a
93
            ViewShellBase object then NULL is returned.
94
    */
95
    SAL_RET_MAYBENULL static ViewShellBase* GetViewShellBase (SfxViewFrame const * pFrame);
96
97
0
    DrawDocShell* GetDocShell() const { return mpDocShell;}
98
0
    SdDrawDocument* GetDocument() const { return mpDocument;}
99
100
    /** Callback function for general slot calls.  At the moment these are
101
        slots for switching the pane docking windows on and off.
102
    */
103
    virtual void Execute (SfxRequest& rRequest);
104
105
    /** Callback function for retrieving item values related to certain
106
        slots.  This is the companion of Execute() and handles the slots
107
        concerned with showing the pane docking windows.
108
    */
109
    void GetState (SfxItemSet& rSet);
110
111
    /* override these from SfxViewShell */
112
    virtual OUString GetSelectionText(bool = false, bool bOnlyASample = false) override;
113
    virtual bool HasSelection(bool = true ) const override;
114
115
    SvBorder GetBorder (bool bOuterResize);
116
    virtual void InnerResizePixel (const Point& rOrigin, const Size& rSize, bool inplaceEditModeChange) override;
117
    virtual void OuterResizePixel (const Point& rOrigin, const Size& rSize) override;
118
119
    /** This call is forwarded to the main sub-shell.
120
    */
121
    virtual ErrCode DoVerb(sal_Int32 nVerb) override;
122
123
    /** Return a new renderer that can be used for example for printing the
124
        document.
125
    */
126
    virtual css::uno::Reference<css::view::XRenderable> GetRenderable() override;
127
128
    /// Forwarded to the print manager.
129
    virtual SfxPrinter* GetPrinter (bool bCreate = false) override;
130
131
    /// Forwarded to the print manager.
132
    virtual sal_uInt16 SetPrinter (
133
        SfxPrinter* pNewPrinter,
134
        SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL) override;
135
136
    /// Forward methods to main sub shell.
137
    virtual void WriteUserDataSequence (
138
        css::uno::Sequence< css::beans::PropertyValue >&) override;
139
140
    /** Pass the given properties to the main view shell.  After that we
141
        ensure that the right view shell type is displayed in the center
142
        pane.
143
    */
144
    virtual void ReadUserDataSequence (
145
        const css::uno::Sequence< css::beans::PropertyValue >&) override;
146
147
    virtual void UIActivating( SfxInPlaceClient* ) override;
148
    virtual void UIDeactivated( SfxInPlaceClient* ) override;
149
    virtual void Activate (bool IsMDIActivate) override;
150
    using SfxViewShell::Deactivate;
151
    virtual void SetZoomFactor (
152
        const Fraction &rZoomX,
153
        const Fraction &rZoomY) override;
154
    virtual bool PrepareClose (bool bUI = true) override;
155
    virtual void WriteUserData (OUString&, bool bBrowse = false) override;
156
    virtual void ReadUserData (const OUString&, bool bBrowse = false) override;
157
    SAL_RET_MAYBENULL virtual SdrView* GetDrawView() const override;
158
159
    /** When <TRUE/> is given, then the mouse shape is set to hour glass (or
160
        whatever the busy shape looks like on the system.)
161
    */
162
    void SetBusyState (bool bBusy);
163
164
    /** Call this method when the controls of this view shell or the
165
        embedded sub shell need to be rearranged.  This is necessary
166
        e.g. when the border has been modified (UpdateBorder() calls this
167
        method).
168
169
        This method is like ResizePixel() with no arguments.
170
    */
171
    void Rearrange();
172
173
    /** Update the border that is set with SfxViewShell::SetBorderPixel().
174
        This is done by adding the border used by the ViewShellBase itself
175
        with the border used by the main view shell.
176
177
        @param bForce   if true the borders are also updated if old border
178
                        and new border are same.
179
    */
180
    void UpdateBorder ( bool bForce = false );
181
182
    /** With this method the UI controls can be turned on or off.  It is
183
        used by the FuSlideShow to hide the UI controls while showing a
184
        non-full-screen or in-window presentation in the center pane.
185
    */
186
    void ShowUIControls (bool bVisible);
187
188
    /** Return an event multiplexer.  It is a single class that forwards
189
        events from various sources.  This method must not be called before
190
        LateInit() has terminated.
191
    */
192
    std::shared_ptr<sdtools::EventMultiplexer> const & GetEventMultiplexer() const;
193
194
    /** returns the complete area of the current view relative to the frame
195
        window
196
    */
197
    const ::tools::Rectangle& getClientRectangle() const;
198
199
    std::shared_ptr<ToolBarManager> const & GetToolBarManager() const;
200
    FormShellManager* GetFormShellManager() const;
201
202
    DrawController* GetDrawController() const;
203
204
    void SetViewTabBar (const ::rtl::Reference<ViewTabBar>& rViewTabBar);
205
206
    /** Return the window that is used by the main view shell to display its
207
        view and other UI elements, like scroll bars and rulers.  Ownership
208
        of that window remains with the called ViewShellBase object.
209
    */
210
    vcl::Window* GetViewWindow();
211
212
    /** returns the ui descriptive name for the given uno slot. The result is taken from the configuration
213
        and not cached, so do not use it excessive (f.e. in status updates) */
214
    OUString RetrieveLabelFromCommand( const OUString& aCmdURL ) const;
215
    /// See SfxViewShell::getPart().
216
    int getPart() const override;
217
    /// See SfxViewShell::getEditMode().
218
    int getEditMode() const override;
219
    /// See SfxViewShell::setEditMode().
220
    void setEditMode(int nMode);
221
    /// See SfxViewShell::afterCallbackRegistered().
222
    void afterCallbackRegistered() override;
223
    /// See SfxViewShell::NotifyCursor().
224
    void NotifyCursor(SfxViewShell* pViewShell) const override;
225
    /// See SfxViewShell::GetColorConfigColor().
226
    ::Color GetColorConfigColor(svtools::ColorConfigEntry nColorType) const override;
227
228
0
    void setLOKVisibleArea(const ::tools::Rectangle& rArea) { maLOKVisibleArea = rArea; }
229
0
    virtual ::tools::Rectangle getLOKVisibleArea() const override { return maLOKVisibleArea; }
230
231
    const SdViewOptions& GetViewOptions() const;
232
    void SetViewOptions(const SdViewOptions& rOptions) const;
233
234
protected:
235
236
    virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
237
238
    virtual void InitializeFramework();
239
240
private:
241
    class Implementation;
242
    std::unique_ptr<Implementation> mpImpl;
243
    DrawDocShell* mpDocShell;
244
    SdDrawDocument* mpDocument;
245
    ::tools::Rectangle maLOKVisibleArea;
246
247
    /** Determine from the properties of the document shell the initial type
248
        of the view shell in the center pane.  We use this method to avoid
249
        starting with the wrong type.  When ReadUserDataSequence() is called
250
        we check that the right type is active and change again if that is
251
        not the case because something went wrong.
252
    */
253
    OUString GetInitialViewShellType() const;
254
};
255
256
} // end of namespace sd
257
258
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */