Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/svdview.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
// HACK to avoid too deep includes and to have some
23
// levels free in svdmark itself (MS compiler include depth limit)
24
#include <svx/svdhdl.hxx>
25
#include <tools/weakbase.h>
26
#include <svx/svxdllapi.h>
27
#include <svx/svdcrtv.hxx>
28
#include <vcl/event.hxx>
29
#include <unotools/options.hxx>
30
#include <basegfx/polygon/b2dpolypolygon.hxx>
31
32
//  class hierarchy of View:
33
//         SfxListener
34
//         SdrPaintView    PntV   Action            ModChg   Attr   Notify
35
//         SdrSnapView     SnpV   Action
36
//
37
//         SdrMarkView     MrkV   Action   MrkChg   ModChg          Notify
38
//
39
//         SdrEditView     EdtV            MrkChg   ModChg   Attr
40
//         SdrPolyEditView PoEV
41
//         SdrGlueEditView GlEV
42
//         SdrObjEditView  EdxV   Action            ModChg   Attr   Notify
43
//
44
//         SdrExchangeView XcgV
45
//         SdrDragView     DrgV   Action
46
//
47
//         SdrCreateView   CrtV   Action
48
//         SdrView         View
49
50
class SvxURLField;
51
class SdrPageWindow;
52
namespace sdr::contact { class ObjectContact; }
53
54
enum class SdrViewContext {
55
    Standard,
56
    PointEdit,
57
    GluePointEdit,
58
    Graphic,
59
    Media,
60
    Table
61
};
62
63
enum class SdrEventKind {
64
    NONE,
65
    TextEdit,
66
    MoveAction,
67
    EndAction,
68
    BackAction,
69
    EndCreate,
70
    EndDrag,
71
    MarkObj,
72
    MarkPoint,
73
    MarkGluePoint,
74
    BeginMark,
75
    BeginInsertObjPoint,
76
    EndInsertObjPoint,
77
    BeginInsertGluePoint,
78
    BeginDragHelpline,
79
    BeginDragObj,
80
    BeginCreateObj,
81
    BeginMacroObj,
82
    BeginTextEdit,
83
    EndMark,
84
    BrkMark,
85
    ExecuteUrl
86
};
87
88
/* for PickAnything() */
89
enum class SdrMouseEventKind
90
{
91
    BUTTONDOWN = 1,
92
    MOVE       = 2,
93
    BUTTONUP   = 3,
94
};
95
96
// helper class SdrViewEvent
97
struct SVXCORE_DLLPUBLIC SdrViewEvent
98
{
99
    SdrHdl* mpHdl;
100
    SdrObject* mpObj;
101
    SdrObject* mpRootObj; // mark this when SdrBeginTextEdit is executed
102
    SdrPageView* mpPV;
103
    const SvxURLField* mpURLField;
104
105
    Point maLogicPos;
106
    SdrHitKind meHit;
107
    SdrEventKind meEvent;
108
109
    sal_uInt16 mnMouseClicks;
110
    MouseEventModifiers mnMouseMode;
111
    sal_uInt16 mnMouseCode;
112
    sal_uInt16 mnHlplIdx;
113
    sal_uInt16 mnGlueId;
114
115
    bool mbMouseDown : 1;
116
    bool mbMouseUp : 1;
117
    bool mbIsAction : 1;       // Action is active
118
    bool mbIsTextEdit : 1;     // TextEdit runs currently
119
    bool mbAddMark : 1;
120
    bool mbUnmark : 1;
121
    bool mbPrevNextMark : 1;
122
    bool mbMarkPrev : 1;
123
124
public:
125
    SdrViewEvent();
126
};
127
128
// helper class for all D&D overlays
129
class SVXCORE_DLLPUBLIC SdrDropMarkerOverlay
130
{
131
    // The OverlayObjects
132
    sdr::overlay::OverlayObjectList maObjects;
133
134
    void ImplCreateOverlays(
135
        const SdrView& rView,
136
        const basegfx::B2DPolyPolygon& rLinePolyPolygon);
137
138
public:
139
    SdrDropMarkerOverlay(const SdrView& rView, const SdrObject& rObject);
140
    SdrDropMarkerOverlay(const SdrView& rView, const tools::Rectangle& rRectangle);
141
    SdrDropMarkerOverlay(const SdrView& rView, const Point& rStart, const Point& rEnd);
142
    ~SdrDropMarkerOverlay();
143
};
144
145
146
class SVXCORE_DLLPUBLIC SdrView : public SdrCreateView, public tools::WeakBase
147
{
148
    friend class SdrPageView;
149
150
    bool mbNoExtendedMouseDispatcher : 1;
151
    bool mbNoExtendedKeyDispatcher : 1;
152
    bool mbMasterPagePaintCaching : 1;
153
154
public:
155
    explicit SdrView(
156
        SdrModel& rSdrModel,
157
        OutputDevice* pOut = nullptr);
158
159
    virtual ~SdrView() override;
160
161
23.5k
    virtual bool IsSdrView() const final { return true; }
162
163
    // The default value for all dispatchers is activated. If the app for example
164
    // wants to intervene in MouseDispatcher for special treatment, you have to
165
    // deactivate the MouseDispatcher with the help of the method below and you have
166
    // to implement it yourself. Example for MouseButtonDown:
167
    //      SdrViewEvent aVEvt;
168
    //      SdrHitKind eHit=pSdrView->PickAnything(rMEvt,SdrMouseEventKind::BUTTONDOWN,aVEvt);
169
    //      ... here application-specific intervention ...
170
    //      pSdrView->DoMouseEvent(aVEvt);
171
    //      SetPointer(GetPreferredPointer(...))
172
    //      CaptureMouse(...)
173
76.1k
    void EnableExtendedMouseEventDispatcher(bool bOn) { mbNoExtendedMouseDispatcher = !bOn; }
174
0
    bool IsExtendedMouseEventDispatcherEnabled() const { return mbNoExtendedMouseDispatcher; }
175
176
76.1k
    void EnableExtendedKeyInputDispatcher(bool bOn) { mbNoExtendedKeyDispatcher=!bOn; }
177
0
    bool IsExtendedKeyInputDispatcherEnabled() const { return mbNoExtendedKeyDispatcher; }
178
179
    void SetMasterPagePaintCaching(bool bOn);
180
0
    bool IsMasterPagePaintCaching() const { return mbMasterPagePaintCaching; }
181
182
    bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) override;
183
    virtual bool MouseButtonDown(const MouseEvent& rMEvt, OutputDevice* pWin) override;
184
    virtual bool MouseButtonUp(const MouseEvent& rMEvt, OutputDevice* pWin) override;
185
    virtual bool MouseMove(const MouseEvent& rMEvt, OutputDevice* pWin) override;
186
    using SdrCreateView::RequestHelp;
187
    virtual bool Command(const CommandEvent& rCEvt, vcl::Window* pWin) override;
188
189
0
    bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll=false) { return SdrCreateView::SetAttributes(rSet,bReplaceAll); }
190
191
    /* new interface src537 */
192
    void GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr=false) const;
193
194
    // incomplete implementation:
195
    // OutputDevice is necessary to determine HandleSize.
196
    // If NULL the first signed on Win is used.
197
    PointerStyle GetPreferredPointer(const Point& rMousePos, const OutputDevice* pOut, sal_uInt16 nModifier=0, bool bLeftDown=false) const;
198
    SdrHitKind PickAnything(const MouseEvent& rMEvt, SdrMouseEventKind nMouseDownOrMoveOrUp, SdrViewEvent& rVEvt) const;
199
    SdrHitKind PickAnything(const Point& rLogicPos, SdrViewEvent& rVEvt) const;
200
    bool DoMouseEvent(const SdrViewEvent& rVEvt);
201
    virtual SdrViewContext GetContext() const;
202
203
    // The methods consider the particular context:
204
    // - simple drawing
205
    // - mode for editing points
206
    // - mode for editing gluepoints
207
    // - TextEdit
208
    // - ... to be continued
209
    void MarkAll();
210
    void UnmarkAll();
211
212
    const tools::Rectangle& GetMarkedRect() const;
213
214
    virtual void DeleteMarked();
215
216
    // Marking objects, traverse stations or gluepoints (depending on view-
217
    // context) by enveloping the selection frame.
218
    //   bAddMark=TRUE: add to existing selection (->Shift)
219
    //   bUnmark=TRUE: remove objects from selection which are inside of
220
    //                 the enveloped frame.
221
    bool BegMark(const Point& rPnt, bool bAddMark, bool bUnmark);
222
223
    // The following actions are possible:
224
    //   - ObjectCreating
225
    //   - ObjectMarking
226
    //   - Object-specific dragging
227
    //   - General dragging
228
    // and more...
229
    OUString GetStatusText();
230
231
    // Do not create ObjectContact locally, but offer a call to allow override
232
    // and to create own derivations of ObjectContact
233
    virtual sdr::contact::ObjectContact* createViewSpecificObjectContact(
234
        SdrPageWindow& rPageWindow,
235
        const char* pDebugName) const;
236
237
    // Interactive Move Action programmatically
238
    bool MoveShapeHandle(const sal_uInt32 handleNum, const Point& aEndPoint, const sal_Int32 aObjectOrdNum = -1);
239
};
240
241
// First of all the app creates a SdrModel.
242
// Then it opens a Win and creates a SdrView.
243
// ShowSdrPage() announces a page at SdrView.
244
// It's possible to show SdrView in any Wins at once.
245
// internal:
246
// SdrView can show as many Wins as it wants at once. Pages are announced
247
// or checked out with the help of ShowSdrPage()/HideSdrPage(). For every announced
248
// page there is a SdrPageView instance in container aPages. If more than one page
249
// is showed, you have to pay attention that the offset parameter of ShowSdrPage()
250
// is conformed to the size of the page (to prevent overlapping of two pages).
251
//
252
// elementary methods:
253
// ~~~~~~~~~~~~~~~~~~~~
254
//   simple events:
255
//   ~~~~~~~~~~~~~~~~
256
//     bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin);
257
//     bool MouseButtonDown(const MouseEvent& rMEvt, vcl::Window* pWin);
258
//     bool MouseButtonUp(const MouseEvent& rMEvt, vcl::Window* pWin);
259
//     bool MouseMove(const MouseEvent& rMEvt, vcl::Window* pWin);
260
//     bool Command(const CommandEvent& rCEvt, vcl::Window* pWin);
261
//
262
//   SfxItems:
263
//   ~~~~~~~~~
264
//     sal_Bool GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr=sal_False) const;
265
//     sal_Bool SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll);
266
//     SfxStyleSheet* GetStyleSheet() const;
267
//     sal_Bool SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr);
268
//
269
//   others:
270
//   ~~~~~~~~~~
271
//     Pointer GetPreferredPointer(const Point& rMousePos, const OutputDevice* pOut, sal_uInt16 nTol=0) const;
272
//     OUString GetStatusText();
273
274
275
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */