LibreOffice Module svx (master)  1
svdview.hxx
Go to the documentation of this file.
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>
27 #include <svx/svxdllapi.h>
28 #include <svx/svdcrtv.hxx>
29 #include <vcl/event.hxx>
30 #include <unotools/options.hxx>
32 
33 // class hierarchy of View:
34 // SfxListener
35 // SdrPaintView PntV Action ModChg Attr Notify
36 // SdrSnapView SnpV Action
37 //
38 // SdrMarkView MrkV Action MrkChg ModChg Notify
39 //
40 // SdrEditView EdtV MrkChg ModChg Attr
41 // SdrPolyEditView PoEV
42 // SdrGlueEditView GlEV
43 // SdrObjEditView EdxV Action ModChg Attr Notify
44 //
45 // SdrExchangeView XcgV
46 // SdrDragView DrgV Action
47 //
48 // SdrCreateView CrtV Action
49 // SdrView View
50 
51 class SvxURLField;
52 namespace sdr::contact { class ObjectContact; }
53 
54 enum class SdrViewContext {
55  Standard,
56  PointEdit,
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,
74  BeginMark,
83  EndMark,
84  BrkMark,
86 };
87 
88 /* for PickAnything() */
90 {
91  BUTTONDOWN = 1,
92  MOVE = 2,
93  BUTTONUP = 3,
94 };
95 
96 // helper class SdrViewEvent
98 {
101  SdrObject* mpRootObj; // mark this when SdrBeginTextEdit is executed
104 
108 
109  sal_uInt16 mnMouseClicks;
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  ~SdrViewEvent();
127 };
128 
129 // helper class for all D&D overlays
131 {
132  // The OverlayObjects
134 
135  void ImplCreateOverlays(
136  const SdrView& rView,
137  const basegfx::B2DPolyPolygon& rLinePolyPolygon);
138 
139 public:
140  SdrDropMarkerOverlay(const SdrView& rView, const SdrObject& rObject);
141  SdrDropMarkerOverlay(const SdrView& rView, const tools::Rectangle& rRectangle);
142  SdrDropMarkerOverlay(const SdrView& rView, const Point& rStart, const Point& rEnd);
144 };
145 
146 
148 {
149  friend class SdrPageView;
150 
151  bool mbNoExtendedMouseDispatcher : 1;
152  bool mbNoExtendedKeyDispatcher : 1;
153  bool mbMasterPagePaintCaching : 1;
154 
156 
157 public:
158  explicit SdrView(
159  SdrModel& rSdrModel,
160  OutputDevice* pOut = nullptr);
161 
162  virtual ~SdrView() override;
163 
164  // The default value for all dispatchers is activated. If the app for example
165  // wants to intervene in MouseDispatcher for special treatment, you have to
166  // deactivate the MouseDispatcher with the help of the method below and you have
167  // to implement it yourself. Example for MouseButtonDown:
168  // SdrViewEvent aVEvt;
169  // SdrHitKind eHit=pSdrView->PickAnything(rMEvt,SdrMouseEventKind::BUTTONDOWN,aVEvt);
170  // ... here application-specific intervention ...
171  // pSdrView->DoMouseEvent(aVEvt);
172  // SetPointer(GetPreferredPointer(...))
173  // CaptureMouse(...)
174  void EnableExtendedMouseEventDispatcher(bool bOn) { mbNoExtendedMouseDispatcher = !bOn; }
175  bool IsExtendedMouseEventDispatcherEnabled() const { return mbNoExtendedMouseDispatcher; }
176 
177  void EnableExtendedKeyInputDispatcher(bool bOn) { mbNoExtendedKeyDispatcher=!bOn; }
178  bool IsExtendedKeyInputDispatcherEnabled() const { return mbNoExtendedKeyDispatcher; }
179 
180  void SetMasterPagePaintCaching(bool bOn);
181  bool IsMasterPagePaintCaching() const { return mbMasterPagePaintCaching; }
182 
183  bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) override;
184  virtual bool MouseButtonDown(const MouseEvent& rMEvt, OutputDevice* pWin) override;
185  virtual bool MouseButtonUp(const MouseEvent& rMEvt, OutputDevice* pWin) override;
186  virtual bool MouseMove(const MouseEvent& rMEvt, OutputDevice* pWin) override;
188  virtual bool Command(const CommandEvent& rCEvt, vcl::Window* pWin) override;
189 
191 
192  bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll=false) { return SdrCreateView::SetAttributes(rSet,bReplaceAll); }
193 
194  /* new interface src537 */
195  void GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr=false) const;
196 
197  // incomplete implementation:
198  // OutputDevice is necessary to determine HandleSize.
199  // If NULL the first signed on Win is used.
200  PointerStyle GetPreferredPointer(const Point& rMousePos, const OutputDevice* pOut, sal_uInt16 nModifier=0, bool bLeftDown=false) const;
201  SdrHitKind PickAnything(const MouseEvent& rMEvt, SdrMouseEventKind nMouseDownOrMoveOrUp, SdrViewEvent& rVEvt) const;
202  SdrHitKind PickAnything(const Point& rLogicPos, SdrViewEvent& rVEvt) const;
203  bool DoMouseEvent(const SdrViewEvent& rVEvt);
204  virtual SdrViewContext GetContext() const;
205 
206  // The methods consider the particular context:
207  // - simple drawing
208  // - mode for editing points
209  // - mode for editing glue points
210  // - TextEdit
211  // - ... to be continued
212  void MarkAll();
213  void UnmarkAll();
214 
215  const tools::Rectangle& GetMarkedRect() const;
216 
217  virtual void DeleteMarked();
218 
219  // Marking objects, traverse stations or glue points (depending on view-
220  // context) by enveloping the selection frame.
221  // bAddMark=TRUE: add to existing selection (->Shift)
222  // bUnmark=TRUE: remove objects from selection which are inside of
223  // the enveloped frame.
224  bool BegMark(const Point& rPnt, bool bAddMark, bool bUnmark);
225 
226  // The following actions are possible:
227  // - ObjectCreating
228  // - ObjectMarking
229  // - Object-specific dragging
230  // - General dragging
231  // and more...
232  OUString GetStatusText();
233 
234  SvtAccessibilityOptions& getAccessibilityOptions() { return maAccessibilityOptions;}
235 
236  virtual void onAccessibilityOptionsChanged();
237 
238  // Do not create ObjectContact locally, but offer a call to allow override
239  // and to create own derivations of ObjectContact
240  virtual sdr::contact::ObjectContact* createViewSpecificObjectContact(
241  SdrPageWindow& rPageWindow,
242  const char* pDebugName) const;
243 
244  // Interactive Move Action programmatically
245  bool MoveShapeHandle(const sal_uInt32 handleNum, const Point& aEndPoint, const sal_Int32 aObjectOrdNum = -1);
246 };
247 
248 // First of all the app creates a SdrModel.
249 // Then it opens a Win and creates a SdrView.
250 // ShowSdrPage() announces a page at SdrView.
251 // It's possible to show SdrView in any Wins at once.
252 // internal:
253 // SdrView can show as many Wins as it wants at once. Pages are announced
254 // or checked out with the help of ShowSdrPage()/HideSdrPage(). For every announced
255 // page there is a SdrPageView instance in container aPages. If more than one page
256 // is showed, you have to pay attention that the offset parameter of ShowSdrPage()
257 // is conformed to the size of the page (to prevent overlapping of two pages).
258 //
259 // elementary methods:
260 // ~~~~~~~~~~~~~~~~~~~~
261 // simple events:
262 // ~~~~~~~~~~~~~~~~
263 // bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin);
264 // bool MouseButtonDown(const MouseEvent& rMEvt, vcl::Window* pWin);
265 // bool MouseButtonUp(const MouseEvent& rMEvt, vcl::Window* pWin);
266 // bool MouseMove(const MouseEvent& rMEvt, vcl::Window* pWin);
267 // bool Command(const CommandEvent& rCEvt, vcl::Window* pWin);
268 //
269 // SfxItems:
270 // ~~~~~~~~~
271 // sal_Bool GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr=sal_False) const;
272 // sal_Bool SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll);
273 // SfxStyleSheet* GetStyleSheet() const;
274 // sal_Bool SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr);
275 //
276 // others:
277 // ~~~~~~~~~~
278 // Pointer GetPreferredPointer(const Point& rMousePos, const OutputDevice* pOut, sal_uInt16 nTol=0) const;
279 // OUString GetStatusText();
280 
281 
282 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ConfigurationHints
sal_uInt16 mnMouseCode
Definition: svdview.hxx:111
void EnableExtendedKeyInputDispatcher(bool bOn)
Definition: svdview.hxx:177
SdrMouseEventKind
Definition: svdview.hxx:89
SdrViewContext
Definition: svdview.hxx:54
sal_uInt16 mnHlplIdx
Definition: svdview.hxx:112
SdrHdl * mpHdl
Definition: svdview.hxx:99
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr) const
Definition: svdcrtv.cxx:861
SdrEventKind
Definition: svdview.hxx:63
const SvxURLField * mpURLField
Definition: svdview.hxx:103
bool IsExtendedKeyInputDispatcherEnabled() const
Definition: svdview.hxx:178
void EnableExtendedMouseEventDispatcher(bool bOn)
Definition: svdview.hxx:174
bool IsMasterPagePaintCaching() const
Definition: svdview.hxx:181
sal_uInt16 mnGlueId
Definition: svdview.hxx:113
MouseEventModifiers
virtual bool MouseButtonUp(const MouseEvent &rMEvt, OutputDevice *pWin) override
Definition: svdedxv.cxx:1875
SvtAccessibilityOptions maAccessibilityOptions
Definition: svdview.hxx:155
SdrPageView * mpPV
Definition: svdview.hxx:102
SdrHitKind
Definition: svdmrkv.hxx:57
virtual bool MouseMove(const MouseEvent &rMEvt, OutputDevice *pWin) override
handle mouse over effects for handles
Definition: svdcrtv.cxx:297
virtual bool KeyInput(const KeyEvent &rKEvt, vcl::Window *pWin) override
Definition: svdedxv.cxx:1796
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
Definition: svdview.hxx:192
SdrObject * mpRootObj
Definition: svdview.hxx:101
sdr::overlay::OverlayObjectList maObjects
Definition: svdview.hxx:133
Abstract DrawObject.
Definition: svdobj.hxx:258
virtual bool MouseButtonDown(const MouseEvent &rMEvt, OutputDevice *pWin) override
Definition: svdedxv.cxx:1831
void ConfigurationChanged(::utl::ConfigurationBroadcaster *, ConfigurationHints) override
Definition: svdpntv.cxx:231
MouseEventModifiers mnMouseMode
Definition: svdview.hxx:110
SdrObject * mpObj
Definition: svdview.hxx:100
SdrHitKind meHit
Definition: svdview.hxx:106
virtual bool Command(const CommandEvent &rCEvt, vcl::Window *pWin) override
Definition: svdedxv.cxx:1956
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll)
Definition: svdcrtv.cxx:873
PointerStyle
Point maLogicPos
Definition: svdview.hxx:105
SdrEventKind meEvent
Definition: svdview.hxx:107
SvtAccessibilityOptions & getAccessibilityOptions()
Definition: svdview.hxx:234
sal_uInt16 mnMouseClicks
Definition: svdview.hxx:109
bool IsExtendedMouseEventDispatcherEnabled() const
Definition: svdview.hxx:175
virtual bool RequestHelp(const HelpEvent &rHEvt) override
Definition: svdmrkv.cxx:1640