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