Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / svdview.hxx
blob10f527735334100c1a27a4532dbfec84acd756a1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_SVDVIEW_HXX
21 #define INCLUDED_SVX_SVDVIEW_HXX
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.hxx>
27 #include <svtools/accessibilityoptions.hxx>
28 #include <svx/svxdllapi.h>
29 #include <svx/svdcrtv.hxx>
30 #include <unotools/options.hxx>
31 #include <basegfx/polygon/b2dpolypolygon.hxx>
32 #include <basegfx/polygon/b2dpolygon.hxx>
34 // class hierarchy of View:
35 // SfxListener
36 // SdrPaintView PntV Action ModChg Attr Notify
37 // SdrSnapView SnpV Action
39 // SdrMarkView MrkV Action MrkChg ModChg Notify
41 // SdrEditView EdtV MrkChg ModChg Attr
42 // SdrPolyEditView PoEV
43 // SdrGlueEditView GlEV
44 // SdrObjEditView EdxV Action ModChg Attr Notify
46 // SdrExchangeView XcgV
47 // SdrDragView DrgV Action
49 // SdrCreateView CrtV Action
50 // SdrView View
52 class SvxURLField;
54 enum class SdrViewContext {
55 Standard,
56 PointEdit,
57 GluePointEdit,
58 Graphic,
59 Media,
60 Table
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
88 /* for PickAnything() */
89 enum class SdrMouseEventKind
91 BUTTONDOWN = 1,
92 MOVE = 2,
93 BUTTONUP = 3,
96 // helper class SdrViewEvent
97 struct SVX_DLLPUBLIC SdrViewEvent
99 SdrHdl* pHdl;
100 SdrObject* pObj;
101 SdrObject* pRootObj; // mark this when SdrBeginTextEdit is executed
102 SdrPageView* pPV;
103 const SvxURLField* pURLField;
105 Point aLogicPos;
106 SdrHitKind eHit;
107 SdrEventKind eEvent;
108 SdrCreateCmd eEndCreateCmd; // for EndInsPoint too
110 sal_uInt16 nMouseClicks;
111 MouseEventModifiers nMouseMode;
112 sal_uInt16 nMouseCode;
113 sal_uInt16 nHlplIdx;
114 sal_uInt16 nGlueId;
116 bool bMouseDown : 1;
117 bool bMouseUp : 1;
118 bool bIsAction : 1; // Action is active
119 bool bIsTextEdit : 1; // TextEdit runs currently
120 bool bTextEditHit : 1; // hit open OutlinerView?
121 bool bAddMark : 1;
122 bool bUnmark : 1;
123 bool bPrevNextMark : 1;
124 bool bMarkPrev : 1;
125 bool bInsPointNewObj : 1;
126 bool bDragWithCopy : 1;
127 bool bCaptureMouse : 1;
128 bool bReleaseMouse : 1;
130 public:
131 SdrViewEvent();
132 ~SdrViewEvent();
135 // helper class for all D&D overlays
136 class SVX_DLLPUBLIC SdrDropMarkerOverlay
138 // The OverlayObjects
139 sdr::overlay::OverlayObjectList maObjects;
141 void ImplCreateOverlays(
142 const SdrView& rView,
143 const basegfx::B2DPolyPolygon& rLinePolyPolygon);
145 public:
146 SdrDropMarkerOverlay(const SdrView& rView, const SdrObject& rObject);
147 SdrDropMarkerOverlay(const SdrView& rView, const tools::Rectangle& rRectangle);
148 SdrDropMarkerOverlay(const SdrView& rView, const Point& rStart, const Point& rEnd);
149 ~SdrDropMarkerOverlay();
154 * View
156 class SVX_DLLPUBLIC SdrView: public SdrCreateView, public tools::WeakBase< SdrView >
158 friend class SdrPageView;
160 bool bNoExtendedMouseDispatcher : 1;
161 bool bNoExtendedKeyDispatcher : 1;
162 bool bNoExtendedCommandDispatcher : 1;
163 bool bTextEditOnObjectsWithoutTextIfTextTool : 1;
164 bool mbMasterPagePaintCaching : 1;
166 protected:
167 SvtAccessibilityOptions maAccessibilityOptions;
169 public:
170 explicit SdrView(SdrModel* pModel1, OutputDevice* pOut = nullptr);
171 virtual ~SdrView() override;
173 // The default value for all dispatchers is activated. If the app for example
174 // wants to intervene in MouseDispatcher for special treatment, you have to
175 // deactivate the MouseDispatcher with the help of the method below and you have
176 // to implement it yourself. Example for MouseButtonDown:
177 // SdrViewEvent aVEvt;
178 // SdrHitKind eHit=pSdrView->PickAnything(rMEvt,SdrMouseEventKind::BUTTONDOWN,aVEvt);
179 // ... hier Applikationsspezifischer Eingriff ...
180 // pSdrView->DoMouseEvent(aVEvt);
181 // SetPointer(GetPreferredPointer(...))
182 // CaptureMouse(...)
183 void EnableExtendedMouseEventDispatcher(bool bOn) { bNoExtendedMouseDispatcher = !bOn; }
184 bool IsExtendedMouseEventDispatcherEnabled() const { return bNoExtendedMouseDispatcher; }
186 void EnableExtendedKeyInputDispatcher(bool bOn) { bNoExtendedKeyDispatcher=!bOn; }
187 bool IsExtendedKeyInputDispatcherEnabled() const { return bNoExtendedKeyDispatcher; }
189 void EnableExtendedCommandEventDispatcher(bool bOn) { bNoExtendedCommandDispatcher=!bOn; }
191 void EnableTextEditOnObjectsWithoutTextIfTextTool(bool bOn) { bTextEditOnObjectsWithoutTextIfTextTool=bOn; }
193 void SetMasterPagePaintCaching(bool bOn);
194 bool IsMasterPagePaintCaching() const { return mbMasterPagePaintCaching; }
196 bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) override;
197 virtual bool MouseButtonDown(const MouseEvent& rMEvt, vcl::Window* pWin) override;
198 virtual bool MouseButtonUp(const MouseEvent& rMEvt, vcl::Window* pWin) override;
199 virtual bool MouseMove(const MouseEvent& rMEvt, vcl::Window* pWin) override;
200 virtual bool Command(const CommandEvent& rCEvt, vcl::Window* pWin) override;
202 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
204 bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll=false) { return SdrCreateView::SetAttributes(rSet,bReplaceAll); }
205 bool SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr) { return SdrCreateView::SetStyleSheet(pStyleSheet,bDontRemoveHardAttr); }
207 /* new interface src537 */
208 bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr=false) const;
210 SfxStyleSheet* GetStyleSheet() const;
212 // incomplete implementation:
213 // OutputDevice is necessary to determine HandleSize.
214 // If NULL the first signed on Win is used.
215 Pointer GetPreferredPointer(const Point& rMousePos, const OutputDevice* pOut, sal_uInt16 nModifier=0, bool bLeftDown=false) const;
216 SdrHitKind PickAnything(const MouseEvent& rMEvt, SdrMouseEventKind nMouseDownOrMoveOrUp, SdrViewEvent& rVEvt) const;
217 SdrHitKind PickAnything(const Point& rLogicPos, SdrViewEvent& rVEvt) const;
218 bool DoMouseEvent(const SdrViewEvent& rVEvt);
219 virtual SdrViewContext GetContext() const;
221 // The methods consider the particular context:
222 // - simple drawing
223 // - mode for editing points
224 // - mode for editing glue points
225 // - TextEdit
226 // - ... to be continued
227 void MarkAll();
228 void UnmarkAll();
230 const tools::Rectangle& GetMarkedRect() const;
232 virtual void DeleteMarked();
234 // Marking objects, traverse stations or glue points (depending on view-
235 // context) by enveloping the selection frame.
236 // bAddMark=TRUE: add to existing selection (->Shift)
237 // bUnmark=TRUE: remove objects from selection which are inside of
238 // the enveloped frame.
239 bool BegMark(const Point& rPnt, bool bAddMark, bool bUnmark);
241 // The following actions are possible:
242 // - ObjectCreating
243 // - ObjectMarking
244 // - Object-specific dragging
245 // - General dragging
246 // and more...
247 OUString GetStatusText();
249 SvtAccessibilityOptions& getAccessibilityOptions() { return maAccessibilityOptions;}
251 virtual void onAccessibilityOptionsChanged();
254 #endif // INCLUDED_SVX_SVDVIEW_HXX
256 // First of all the app creates a SdrModel.
257 // Then it opens a Win and creates a SdrView.
258 // ShowSdrPage() announces a page at SdrView.
259 // It's possible to show SdrView in any Wins at once.
260 // internal:
261 // SdrView can show as many Wins as it wants at once. Pages are announced
262 // or checked out with the help of ShowSdrPage()/HideSdrPage(). For every announced
263 // page there is a SdrPageView instance in container aPages. If more than one page
264 // is showed, you have to pay attention that the offset parameter of ShowSdrPage()
265 // is conformed to the size of the page (to prevent overlapping of two pages).
267 // elementary methods:
268 // ~~~~~~~~~~~~~~~~~~~~
269 // simple events:
270 // ~~~~~~~~~~~~~~~~
271 // bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin);
272 // bool MouseButtonDown(const MouseEvent& rMEvt, vcl::Window* pWin);
273 // bool MouseButtonUp(const MouseEvent& rMEvt, vcl::Window* pWin);
274 // bool MouseMove(const MouseEvent& rMEvt, vcl::Window* pWin);
275 // bool Command(const CommandEvent& rCEvt, vcl::Window* pWin);
277 // Exchange (Clipboard currently without SdrPrivateData):
278 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
279 // sal_Bool Cut(sal_uIntPtr nFormat=SDR_ANYFORMAT);
280 // sal_Bool Yank(sal_uIntPtr nFormat=SDR_ANYFORMAT);
281 // sal_Bool Paste(vcl::Window* pWin=NULL, sal_uIntPtr nFormat=SDR_ANYFORMAT);
283 // SfxItems:
284 // ~~~~~~~~~
285 // sal_Bool GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr=sal_False) const;
286 // sal_Bool SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll);
287 // SfxStyleSheet* GetStyleSheet() const;
288 // sal_Bool SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr);
290 // others:
291 // ~~~~~~~~~~
292 // Pointer GetPreferredPointer(const Point& rMousePos, const OutputDevice* pOut, sal_uInt16 nTol=0) const;
293 // OUString GetStatusText();
295 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */