1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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:
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
51 namespace sdr::contact
{ class ObjectContact
; }
53 enum class SdrViewContext
{
62 enum class SdrEventKind
{
87 /* for PickAnything() */
88 enum class SdrMouseEventKind
95 // helper class SdrViewEvent
96 struct SVXCORE_DLLPUBLIC SdrViewEvent
100 SdrObject
* mpRootObj
; // mark this when SdrBeginTextEdit is executed
102 const SvxURLField
* mpURLField
;
106 SdrEventKind meEvent
;
108 sal_uInt16 mnMouseClicks
;
109 MouseEventModifiers mnMouseMode
;
110 sal_uInt16 mnMouseCode
;
111 sal_uInt16 mnHlplIdx
;
114 bool mbMouseDown
: 1;
116 bool mbIsAction
: 1; // Action is active
117 bool mbIsTextEdit
: 1; // TextEdit runs currently
120 bool mbPrevNextMark
: 1;
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
);
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;
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(...))
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:
204 // - mode for editing points
205 // - mode for editing gluepoints
207 // - ... to be continued
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:
225 // - Object-specific dragging
226 // - General dragging
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.
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 // ~~~~~~~~~~~~~~~~~~~~
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);
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);
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: */