Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/inc/DrawViewShell.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 <memory>
23
#include "ViewShell.hxx"
24
#include "tools/AsynchronousCall.hxx"
25
#include "TabControl.hxx"
26
#include <glob.hxx>
27
#include <pres.hxx>
28
#include <unotools/caserotate.hxx>
29
#include <unotools/options.hxx>
30
#include <sddllapi.h>
31
#include <viewopt.hxx>
32
33
namespace svx::sidebar { class SelectionChangeHandler; }
34
namespace com::sun::star::lang { class XEventListener; }
35
namespace com::sun::star::scanner { class XScannerManager2; }
36
namespace com::sun::star::presentation { class XSlideShow; }
37
38
class Outliner;
39
class SdPage;
40
class SdStyleSheet;
41
class SdrExternalToolEdit;
42
class TabBar;
43
class SdrObject;
44
class SdrPageView;
45
class TransferableDataHelper;
46
class TransferableClipboardListener;
47
class SdrLayer;
48
class SvxClipboardFormatItem;
49
class SvxNameDialog;
50
struct ESelection;
51
class AbstractSvxObjectNameDialog;
52
53
namespace sd {
54
55
class DrawView;
56
class LayerTabBar;
57
class Ruler;
58
class AnnotationManager;
59
class ViewOverlayManager;
60
61
template <typename MIN_T, typename T, typename MAX_T>
62
constexpr bool CHECK_RANGE(MIN_T nMin, T nValue, MAX_T nMax)
63
0
{
64
0
    return nValue >= nMin && nValue <= nMax;
65
0
}
Unexecuted instantiation: bool sd::CHECK_RANGE<int, unsigned short, int>(int, unsigned short, int)
Unexecuted instantiation: bool sd::CHECK_RANGE<int, int, unsigned short>(int, int, unsigned short)
Unexecuted instantiation: bool sd::CHECK_RANGE<com::sun::star::drawing::FillStyle, com::sun::star::drawing::FillStyle, com::sun::star::drawing::FillStyle>(com::sun::star::drawing::FillStyle, com::sun::star::drawing::FillStyle, com::sun::star::drawing::FillStyle)
Unexecuted instantiation: bool sd::CHECK_RANGE<int, int, int>(int, int, int)
Unexecuted instantiation: bool sd::CHECK_RANGE<AutoLayout, AutoLayout, AutoLayout>(AutoLayout, AutoLayout, AutoLayout)
66
67
/** Base class of the stacked shells that provide graphical views to
68
    Draw and Impress documents and editing functionality.  In contrast
69
    to this other stacked shells are responsible for showing an
70
    overview over several slides or a textual
71
    overview over the text in an Impress document (OutlineViewShell).
72
*/
73
class SAL_DLLPUBLIC_RTTI DrawViewShell
74
    : public ViewShell,
75
      public SfxListener,
76
      public utl::ConfigurationListener
77
{
78
public:
79
    SFX_DECL_INTERFACE(SD_IF_SDDRAWVIEWSHELL)
80
81
private:
82
    /// SfxInterface initializer.
83
    static void InitInterface_Impl();
84
85
public:
86
    /** Create a new stackable shell that may take some information
87
        (e.g. the frame view) from the given previous shell.
88
        @param ePageKind
89
            This parameter gives the initial page kind that the new shell
90
            will show.
91
        @param pFrameView
92
            The frame view that makes it possible to pass information from
93
            one view shell to the next.
94
    */
95
    DrawViewShell (
96
        ViewShellBase& rViewShellBase,
97
        vcl::Window* pParentWindow,
98
        PageKind ePageKind,
99
        FrameView* pFrameView);
100
101
    virtual ~DrawViewShell() override;
102
103
    virtual void Init (bool bIsMainViewShell) override;
104
105
    virtual void Shutdown() override;
106
107
    void PrePaint() override;
108
    virtual void Paint(const ::tools::Rectangle& rRect, ::sd::Window* pWin) override;
109
110
    /** Arrange and resize the GUI elements like rulers, sliders, and
111
        buttons as well as the actual document view according to the size of
112
        the enclosing window and current sizes of buttons, rulers, and
113
        sliders.
114
    */
115
    virtual void    ArrangeGUIElements() override;
116
117
    void            HidePage();
118
119
    virtual bool    KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin) override;
120
    virtual void    MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin) override;
121
    virtual void    MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin) override;
122
    virtual void    MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin) override;
123
    virtual void    Command(const CommandEvent& rCEvt, ::sd::Window* pWin) override;
124
0
    bool            IsMouseButtonDown() const { return mbMouseButtonDown; }
125
0
    bool            IsMouseSelecting() const { return mbMouseSelecting; }
126
127
    virtual void    Resize() override;
128
129
    void            ShowMousePosInfo(const ::tools::Rectangle& rRect, ::sd::Window const * pWin);
130
131
    virtual void    ChangeEditMode (EditMode eMode, bool bIsLayerModeActive);
132
133
    virtual void    SetZoom( ::tools::Long nZoom ) override;
134
    virtual void    SetZoomRect( const ::tools::Rectangle& rZoomRect ) override;
135
136
    void            InsertURLField(const OUString& rURL, const OUString& rText, const OUString& rTarget, OUString const& rAltText);
137
    void            InsertURLButton(const OUString& rURL, const OUString& rText, const OUString& rTarget,
138
                                    const Point* pPos);
139
140
    void            SelectionHasChanged();
141
    void            ModelHasChanged();
142
    virtual void    Activate(bool bIsMDIActivate) override;
143
    virtual void    Deactivate(bool IsMDIActivate) override;
144
    virtual void    UIActivating( SfxInPlaceClient* ) override;
145
    virtual void    UIDeactivated( SfxInPlaceClient* ) override;
146
    OUString        GetSelectionText( bool bCompleteWords );
147
    bool            HasSelection( bool bText ) const;
148
149
    //If we are editing a PresObjKind::Outline return the Outliner and fill rSel
150
    //with the current selection
151
    ::Outliner*     GetOutlinerForMasterPageOutlineTextObj(ESelection &rSel);
152
153
    void            ExecCtrl(SfxRequest& rReq);
154
    void            GetCtrlState(SfxItemSet& rSet);
155
    void            GetDrawAttrState(SfxItemSet& rSet);
156
    void            GetMenuState(SfxItemSet& rSet);
157
    void            GetTableMenuState(SfxItemSet& rSet);
158
    /** Set the items of the given item set that are related to
159
        switching the editing mode to the correct values.
160
        <p>This function also sets the states of the mode buttons
161
        (those at the upper right corner) accordingly.</p>
162
    */
163
    void            GetModeSwitchingMenuState (SfxItemSet &rSet);
164
    void            GetAttrState(SfxItemSet& rSet);
165
    void            GetSnapItemState(SfxItemSet& rSet);
166
167
    void            SetPageProperties (SfxRequest& rReq);
168
    void            GetPageProperties(SfxItemSet& rSet);
169
    void            GetMarginProperties(SfxItemSet& rSet);
170
171
    void            GetState (SfxItemSet& rSet);
172
    void            Execute (SfxRequest& rReq);
173
174
    void            ExecStatusBar(SfxRequest& rReq);
175
    void            GetStatusBarState(SfxItemSet& rSet);
176
177
    void            ExecOptionsBar(SfxRequest& rReq);
178
    void            GetOptionsBarState(SfxItemSet& rSet);
179
180
    void            ExecRuler(SfxRequest& rReq);
181
    void            GetRulerState(SfxItemSet& rSet);
182
183
    void            ExecFormText(SfxRequest& rReq);
184
    void            GetFormTextState(SfxItemSet& rSet);
185
186
    void            ExecAnimationWin(SfxRequest& rReq);
187
    void            GetAnimationWinState(SfxItemSet& rSet);
188
189
    void            ExecNavigatorWin(SfxRequest& rReq);
190
    void            GetNavigatorWinState(SfxItemSet& rSet);
191
192
    void            ExecutePropPanelAttr (SfxRequest const & rReq);
193
    void            GetStatePropPanelAttr(SfxItemSet& rSet);
194
195
    void            ExecEffectWin(SfxRequest& rReq);
196
197
    void            Update3DWindow();
198
    void            AssignFrom3DWindow();
199
200
    void            ExecGallery(SfxRequest const & rReq);
201
202
    void            ExecBmpMask( SfxRequest const & rReq );
203
    void            GetBmpMaskState( SfxItemSet& rSet );
204
205
    void            ExecIMap( SfxRequest const & rReq );
206
    void            GetIMapState( SfxItemSet& rSet );
207
208
    void            FuTransformDocumentStructure(const SfxRequest& rReq);
209
    void            FuTemporary(SfxRequest& rReq);
210
    void            FuPermanent(SfxRequest& rReq);
211
    void            FuSupport(SfxRequest& rReq);
212
    void            FuDeleteSelectedObjects();
213
    void            FuSupportRotate(SfxRequest const & rReq);
214
    void            FuTable(SfxRequest& rReq);
215
216
    void            AttrExec (SfxRequest& rReq);
217
    void            AttrState (SfxItemSet& rSet);
218
219
    void            ExecGoToNextPage (SfxRequest& rReq);
220
    void            GetStateGoToNextPage (SfxItemSet& rSet);
221
222
    void            ExecGoToPreviousPage (SfxRequest& rReq);
223
    void            GetStateGoToPreviousPage (SfxItemSet& rSet);
224
225
    void            ExecGoToFirstPage (SfxRequest& rReq);
226
    void            GetStateGoToFirstPage (SfxItemSet& rSet);
227
228
    void            ExecGoToLastPage (SfxRequest& rReq);
229
    void            GetStateGoToLastPage (SfxItemSet& rSet);
230
231
    void            ExecGoToPage (SfxRequest& rReq);
232
    void            GetStateGoToPage (SfxItemSet& rSet);
233
234
    SD_DLLPUBLIC void ExecChar(SfxRequest& rReq);
235
236
    void            ExecuteAnnotation (SfxRequest const & rRequest);
237
    void            GetAnnotationState (SfxItemSet& rItemSet);
238
239
0
    AnnotationManager* getAnnotationManagerPtr() { return mpAnnotationManager.get(); }
240
241
    void            StartRulerDrag (const Ruler& rRuler, const MouseEvent& rMEvt);
242
243
    virtual bool    PrepareClose( bool bUI = true ) override;
244
245
0
    PageKind        GetPageKind() const { return mePageKind; }
246
0
    void            SetPageKind( PageKind ePageKind ) { mePageKind = ePageKind; }
247
0
    const Point&    GetMousePos() const { return maMousePos; }
248
249
0
    EditMode        GetEditMode() const { return meEditMode; }
250
0
    virtual SdPage* GetActualPage() override { return mpActualPage; }
251
252
    /// inherited from sd::ViewShell
253
    virtual SdPage* getCurrentPage() const override;
254
255
    void            ResetActualPage();
256
    void            ResetActualLayer();
257
    SD_DLLPUBLIC bool SwitchPage(sal_uInt16 nPage, bool bAllowChangeFocus = true,
258
                                 bool bUpdateScrollbars = true);
259
    bool            IsSwitchPageAllowed() const;
260
261
    /**
262
     * Mark the desired page as selected (1), deselected (0), toggle (2).
263
     * nPage refers to the page in question.
264
     */
265
    bool            SelectPage(sal_uInt16 nPage, sal_uInt16 nSelect);
266
    bool            IsSelected(sal_uInt16 nPage);
267
268
    void            GotoBookmark(std::u16string_view rBookmark);
269
    //Realize multi-selection of objects, If object is marked, the
270
    //corresponding entry is set true, else the corresponding entry is set
271
    //false.
272
    void            FreshNavigatrTree();
273
    void            MakeVisible(const ::tools::Rectangle& rRect, vcl::Window& rWin);
274
275
    virtual void    ReadFrameViewData(FrameView* pView) override;
276
    virtual void    WriteFrameViewData() override;
277
278
    virtual ErrCode DoVerb(sal_Int32 nVerb) override;
279
    virtual bool    ActivateObject(SdrOle2Obj* pObj, sal_Int32 nVerb) override;
280
281
0
    void            SetZoomOnPage( bool bZoom ) { mbZoomOnPage = bZoom; }
282
0
    bool            IsZoomOnPage() const { return mbZoomOnPage; }
283
    static void     CheckLineTo (SfxRequest& rReq);
284
    void            SetChildWindowState( SfxItemSet& rSet );
285
286
    void            UpdateIMapDlg( SdrObject* pObj );
287
288
    void            LockInput();
289
    void            UnlockInput();
290
0
    bool            IsInputLocked() const { return mnLockCount > 0; }
291
292
0
    sal_uInt16      GetCurPagePos() const { return maTabControl->GetCurPagePos(); }
293
294
    /** Show controls of the UI or hide them, depending on the given flag.
295
        Do not call this method directly.  Call the method at ViewShellBase
296
        instead.
297
    */
298
    virtual void    ShowUIControls (bool bVisible) override;
299
300
    void            ScannerEvent();
301
302
0
    bool            IsLayerModeActive() const { return mbIsLayerModeActive;}
303
304
    virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper,
305
                                    ::sd::Window* pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer ) override;
306
    virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt, DropTargetHelper& rTargetHelper,
307
                                    ::sd::Window* pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer ) override;
308
309
    virtual void    WriteUserDataSequence ( css::uno::Sequence < css::beans::PropertyValue >& ) override;
310
    virtual void    ReadUserDataSequence ( const css::uno::Sequence < css::beans::PropertyValue >& ) override;
311
312
    virtual void    VisAreaChanged(const ::tools::Rectangle& rRect) override;
313
314
    /** Create an accessible object representing the specified window.
315
        @param pWindow
316
            The returned object makes the document displayed in this window
317
            accessible.
318
        @return
319
            Returns an <type>AccessibleDrawDocumentView</type> object.
320
   */
321
    virtual rtl::Reference<comphelper::OAccessible>
322
    CreateAccessibleDocumentView(::sd::Window* pWindow) override;
323
324
    /** Return the number of layers managed by the layer tab control.  This
325
        will usually differ from the number of layers managed by the layer
326
        administrator.
327
        @return
328
            The number of layers managed by the layer tab control.  The
329
            returned value is independent of whether the layer mode is
330
            currently active and the tab control is visible.
331
    */
332
    int GetTabLayerCount() const;
333
334
    /** Return the numerical id of the currently active layer as seen by the
335
        layer tab control.
336
        @return
337
            The returned id is a number between zero (inclusive) and the
338
            number of layers as returned by the
339
            <member>GetTabLayerCount</member> method (exclusive).
340
    */
341
    int GetActiveTabLayerIndex() const;
342
343
    /** Set the active layer at the layer tab control and update the control
344
        accordingly to reflect the change on screen.
345
        @param nId
346
            The id is expected to be a number between zero (inclusive) and
347
            the number of layers as returned by the
348
            <member>GetTabLayerCount</member> method (exclusive). Note that
349
            Invalid values are ignored. No exception is thrown in that case.
350
    */
351
    void SetActiveTabLayerIndex (int nId);
352
353
    /** Return a pointer to the tab control for pages.
354
    */
355
0
    TabControl& GetPageTabControl() { return *maTabControl; }
356
357
    /** Return a pointer to the tab control for layers.
358
    */
359
    SD_DLLPUBLIC LayerTabBar* GetLayerTabControl(); // export for unit test
360
361
    /** Renames the given slide using an SvxNameDialog
362
363
        @param nPageId the index of the page in the SdTabControl.
364
        @param rName the new name of the slide.
365
366
        @return false, if the new name is invalid for some reason.
367
368
        <p>Implemented in <code>drviews8.cxx</code>.</p>
369
     */
370
    bool RenameSlide( sal_uInt16 nPageId, const OUString & rName );
371
372
    /** modifies the given layer with the given values */
373
    void ModifyLayer( SdrLayer* pLayer, const OUString& rLayerName, const OUString& rLayerTitle, const OUString& rLayerDesc, bool bIsVisible, bool bIsLocked, bool bIsPrintable );
374
375
    virtual css::uno::Reference<css::drawing::XDrawSubController> CreateSubController() override;
376
377
0
    DrawView*   GetDrawView() const { return mpDrawView.get(); }
378
379
    /** Relocation to a new parent window is not supported for DrawViewShell
380
        objects so this method always returns <FALSE/>.
381
    */
382
    virtual bool RelocateToParentWindow (vcl::Window* pParentWindow) override;
383
384
    OUString const & GetSidebarContextName() const;
385
386
0
    bool IsInSwitchPage() const { return mbIsInSwitchPage; }
387
388
    const SdViewOptions& GetViewOptions() const;
389
    void SetViewOptions(const SdViewOptions& rOptions);
390
    //move this method to ViewShell.
391
    //void  NotifyAccUpdate();
392
393
    void destroyXSlideShowInstance();
394
395
    virtual void RememberCanvasPageVisArea(const ::tools::Rectangle &aRect) override;
396
397
protected:
398
                    DECL_DLLPRIVATE_LINK( ClipboardChanged, TransferableDataHelper*, void );
399
                    DECL_DLLPRIVATE_LINK( TabSplitHdl, TabBar *, void );
400
                    DECL_DLLPRIVATE_LINK( NameObjectHdl, AbstractSvxObjectNameDialog&, bool );
401
                    DECL_DLLPRIVATE_LINK(RenameSlideHdl, SvxNameDialog&, bool);
402
403
    void            DeleteActualPage();
404
    void            DeleteActualLayer();
405
406
    virtual VclPtr<SvxRuler> CreateHRuler(::sd::Window* pWin) override;
407
    virtual VclPtr<SvxRuler> CreateVRuler(::sd::Window* pWin) override;
408
    virtual void    UpdateHRuler() override;
409
    virtual void    UpdateVRuler() override;
410
    virtual void    SetZoomFactor(double fZoomX, double fZoomY) override;
411
412
    void            SetupPage( Size const &rSize, ::tools::Long nLeft, ::tools::Long nRight, ::tools::Long nUpper, ::tools::Long nLower,
413
                               bool bSize, bool bMargin, bool bScaleAll );
414
415
    void            GetMenuStateSel(SfxItemSet& rSet);
416
417
private:
418
    DrawViewShell(const DrawViewShell&) = delete;
419
    DrawViewShell& operator=(const DrawViewShell&) = delete;
420
421
    void Construct (DrawDocShell* pDocSh, PageKind ePageKind);
422
423
    void ImplDestroy();
424
425
    /** Depending on the given request create a new page or duplicate an
426
        existing one.  See ViewShell::CreateOrDuplicatePage() for more
427
        information.
428
    */
429
    virtual SdPage* CreateOrDuplicatePage (
430
        SfxRequest& rRequest,
431
        PageKind ePageKind,
432
        SdPage* pPage,
433
        const sal_Int32 nInsertPosition = -1) override;
434
435
    void DuplicateSelectedSlides (SfxRequest& rRequest);
436
437
    virtual void Notify (SfxBroadcaster& rBC, const SfxHint& rHint) override;
438
439
    /** Stop a running slide show.
440
    */
441
    void StopSlideShow();
442
443
    /** Show the context menu for snap lines and points.  Because snap lines
444
        can not be selected the index of the snap line/point for which the
445
        popup menu is opened has to be passed to the processing slot
446
        handlers.  This can be done only by manually showing the popup menu.
447
        @param pParent
448
            The parent for the context menu.
449
        @param rRect
450
            The location at which to display the context menu.
451
        @param rPageView
452
            The page view is used to access the help lines.
453
        @param nSnapLineIndex
454
            Index of the snap line or snap point for which to show the
455
            context menu.
456
    */
457
    void ShowSnapLineContextMenu(weld::Window* pParent, const ::tools::Rectangle& rRect,
458
        SdrPageView& rPageView, const sal_uInt16 nSnapLineIndex);
459
460
    using ViewShell::Notify;
461
462
    virtual void ConfigurationChanged( utl::ConfigurationBroadcaster* pCb, ConfigurationHints ) override;
463
464
    void ConfigureAppBackgroundColor( svtools::ColorConfig* pColorConfig = nullptr );
465
466
    /// return true if "Edit Hyperlink" in context menu should be disabled
467
    bool ShouldDisableEditHyperlink() const;
468
469
private:
470
    std::unique_ptr<DrawView> mpDrawView;
471
    SdPage*             mpActualPage;
472
    ::tools::Rectangle           maMarkRect;
473
    Point               maMousePos;
474
    VclPtr<TabControl>  maTabControl;
475
    EditMode            meEditMode;
476
    PageKind            mePageKind;
477
    bool                mbZoomOnPage;
478
    bool                mbIsRulerDrag;
479
    sal_uLong           mnLockCount;
480
    bool                mbReadOnly;
481
    static bool         mbPipette;
482
    /** Prevents grabbing focus while loading - see tdf#83773 that introduced
483
        the grabbing, and tdf#150773 that needs grabbing disabled on loading
484
    */
485
    bool mbFirstTimeActivation = true;
486
    /** This flag controls whether the layer mode is active, i.e. the layer
487
        dialog is visible.
488
    */
489
    bool mbIsLayerModeActive;
490
    /** This item contains the clipboard formats of the current clipboard
491
        content that are supported both by that content and by the
492
        DrawViewShell.
493
    */
494
    ::std::unique_ptr<SvxClipboardFormatItem> mpCurrentClipboardFormats;
495
    /** On some occasions it is necessary to make SwitchPage calls
496
        asynchronously.
497
    */
498
    sdtools::AsynchronousCall maAsynchronousSwitchPageCall;
499
    /** This flag is used to prevent nested calls to SwitchPage().
500
    */
501
    bool mbIsInSwitchPage;
502
    RotateTransliteration m_aRotateCase;
503
    /** Listen for selection changes and broadcast context changes for the sidebar.
504
    */
505
    ::rtl::Reference<svx::sidebar::SelectionChangeHandler> mpSelectionChangeHandler;
506
    css::uno::Reference< css::scanner::XScannerManager2 > mxScannerManager;
507
    css::uno::Reference< css::lang::XEventListener >      mxScannerListener;
508
    rtl::Reference<TransferableClipboardListener>         mxClipEvtLstnr;
509
    bool                                                  mbPastePossible;
510
    bool                                                  mbMouseButtonDown;
511
    bool                                                  mbMouseSelecting;
512
    std::unique_ptr<AnnotationManager> mpAnnotationManager;
513
    std::unique_ptr<ViewOverlayManager> mpViewOverlayManager;
514
    std::vector<std::unique_ptr<SdrExternalToolEdit>> m_ExternalEdits;
515
516
    css::uno::Reference<css::presentation::XSlideShow> mxSlideShow;
517
518
    ::tools::Rectangle  maCanvasPageVisArea;
519
};
520
521
/// Merge the background properties together and deposit the result in rMergeAttr
522
SD_DLLPUBLIC void MergePageBackgroundFilling(SdPage *pPage, SdStyleSheet *pStyleSheet, bool bMasterPage, SfxItemSet& rMergedAttr);
523
524
} // end of namespace sd
525
526
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */