Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / svx / svdview.hxx
blobaeb364a985dc3d9c7487f33a259a75835e21c36f
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 <svtools/accessibilityoptions.hxx>
27 #include <svx/svxdllapi.h>
28 #include <svx/svdcrtv.hxx>
29 #include <vcl/event.hxx>
30 #include <unotools/options.hxx>
31 #include <basegfx/polygon/b2dpolypolygon.hxx>
33 // class hierarchy of View:
34 // SfxListener
35 // SdrPaintView PntV Action ModChg Attr Notify
36 // SdrSnapView SnpV Action
38 // SdrMarkView MrkV Action MrkChg ModChg Notify
40 // SdrEditView EdtV MrkChg ModChg Attr
41 // SdrPolyEditView PoEV
42 // SdrGlueEditView GlEV
43 // SdrObjEditView EdxV Action ModChg Attr Notify
45 // SdrExchangeView XcgV
46 // SdrDragView DrgV Action
48 // SdrCreateView CrtV Action
49 // SdrView View
51 class SvxURLField;
52 namespace sdr::contact { class ObjectContact; }
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 SVXCORE_DLLPUBLIC SdrViewEvent
99 SdrHdl* mpHdl;
100 SdrObject* mpObj;
101 SdrObject* mpRootObj; // mark this when SdrBeginTextEdit is executed
102 SdrPageView* mpPV;
103 const SvxURLField* mpURLField;
105 Point maLogicPos;
106 SdrHitKind meHit;
107 SdrEventKind meEvent;
109 sal_uInt16 mnMouseClicks;
110 MouseEventModifiers mnMouseMode;
111 sal_uInt16 mnMouseCode;
112 sal_uInt16 mnHlplIdx;
113 sal_uInt16 mnGlueId;
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;
124 public:
125 SdrViewEvent();
128 // helper class for all D&D overlays
129 class SVXCORE_DLLPUBLIC SdrDropMarkerOverlay
131 // The OverlayObjects
132 sdr::overlay::OverlayObjectList maObjects;
134 void ImplCreateOverlays(
135 const SdrView& rView,
136 const basegfx::B2DPolyPolygon& rLinePolyPolygon);
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();
146 class SVXCORE_DLLPUBLIC SdrView : public SdrCreateView, public tools::WeakBase
148 friend class SdrPageView;
150 bool mbNoExtendedMouseDispatcher : 1;
151 bool mbNoExtendedKeyDispatcher : 1;
152 bool mbMasterPagePaintCaching : 1;
154 SvtAccessibilityOptions maAccessibilityOptions;
156 public:
157 explicit SdrView(
158 SdrModel& rSdrModel,
159 OutputDevice* pOut = nullptr);
161 virtual ~SdrView() override;
163 virtual bool IsSdrView() const final { return true; }
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) { mbNoExtendedMouseDispatcher = !bOn; }
176 bool IsExtendedMouseEventDispatcherEnabled() const { return mbNoExtendedMouseDispatcher; }
178 void EnableExtendedKeyInputDispatcher(bool bOn) { mbNoExtendedKeyDispatcher=!bOn; }
179 bool IsExtendedKeyInputDispatcherEnabled() const { return mbNoExtendedKeyDispatcher; }
181 void SetMasterPagePaintCaching(bool bOn);
182 bool IsMasterPagePaintCaching() const { return mbMasterPagePaintCaching; }
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;
188 using SdrCreateView::RequestHelp;
189 virtual bool Command(const CommandEvent& rCEvt, vcl::Window* pWin) override;
191 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
193 bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll=false) { return SdrCreateView::SetAttributes(rSet,bReplaceAll); }
195 /* new interface src537 */
196 void GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr=false) const;
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;
207 // The methods consider the particular context:
208 // - simple drawing
209 // - mode for editing points
210 // - mode for editing gluepoints
211 // - TextEdit
212 // - ... to be continued
213 void MarkAll();
214 void UnmarkAll();
216 const tools::Rectangle& GetMarkedRect() const;
218 virtual void DeleteMarked();
220 // Marking objects, traverse stations or gluepoints (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);
227 // The following actions are possible:
228 // - ObjectCreating
229 // - ObjectMarking
230 // - Object-specific dragging
231 // - General dragging
232 // and more...
233 OUString GetStatusText();
235 virtual void onAccessibilityOptionsChanged();
237 // Do not create ObjectContact locally, but offer a call to allow override
238 // and to create own derivations of ObjectContact
239 virtual sdr::contact::ObjectContact* createViewSpecificObjectContact(
240 SdrPageWindow& rPageWindow,
241 const char* pDebugName) const;
243 // Interactive Move Action programmatically
244 bool MoveShapeHandle(const sal_uInt32 handleNum, const Point& aEndPoint, const sal_Int32 aObjectOrdNum = -1);
247 // First of all the app creates a SdrModel.
248 // Then it opens a Win and creates a SdrView.
249 // ShowSdrPage() announces a page at SdrView.
250 // It's possible to show SdrView in any Wins at once.
251 // internal:
252 // SdrView can show as many Wins as it wants at once. Pages are announced
253 // or checked out with the help of ShowSdrPage()/HideSdrPage(). For every announced
254 // page there is a SdrPageView instance in container aPages. If more than one page
255 // is showed, you have to pay attention that the offset parameter of ShowSdrPage()
256 // is conformed to the size of the page (to prevent overlapping of two pages).
258 // elementary methods:
259 // ~~~~~~~~~~~~~~~~~~~~
260 // simple events:
261 // ~~~~~~~~~~~~~~~~
262 // bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin);
263 // bool MouseButtonDown(const MouseEvent& rMEvt, vcl::Window* pWin);
264 // bool MouseButtonUp(const MouseEvent& rMEvt, vcl::Window* pWin);
265 // bool MouseMove(const MouseEvent& rMEvt, vcl::Window* pWin);
266 // bool Command(const CommandEvent& rCEvt, vcl::Window* pWin);
268 // SfxItems:
269 // ~~~~~~~~~
270 // sal_Bool GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr=sal_False) const;
271 // sal_Bool SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll);
272 // SfxStyleSheet* GetStyleSheet() const;
273 // sal_Bool SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr);
275 // others:
276 // ~~~~~~~~~~
277 // Pointer GetPreferredPointer(const Point& rMousePos, const OutputDevice* pOut, sal_uInt16 nTol=0) const;
278 // OUString GetStatusText();
281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */