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