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 .
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:
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
54 enum SdrViewContext
{SDRCONTEXT_STANDARD
,
56 SDRCONTEXT_GLUEPOINTEDIT
,
61 enum SdrEventKind
{SDREVENT_NONE
,
71 SDREVENT_MARKGLUEPOINT
,
73 SDREVENT_BEGINSOBJPOINT
,
74 SDREVENT_ENDINSOBJPOINT
,
75 SDREVENT_BEGINSGLUEPOINT
,
76 SDREVENT_BEGDRAGHELPLINE
,
78 SDREVENT_BEGCREATEOBJ
,
85 /* for PickAnything() */
86 enum class SdrMouseEventKind
93 // helper class SdrViewEvent
94 struct SVX_DLLPUBLIC SdrViewEvent
98 SdrObject
* pRootObj
; // mark this when SdrBeginTextEdit is executed
100 const SvxURLField
* pURLField
;
106 SdrCreateCmd eEndCreateCmd
; // for EndInsPoint too
108 sal_uInt16 nMouseClicks
;
109 MouseEventModifiers nMouseMode
;
110 sal_uInt16 nMouseCode
;
116 bool bDoubleHdlSize
: 1; // Double Handlesize because of TextEdit
117 bool bIsAction
: 1; // Action is active
118 bool bIsTextEdit
: 1; // TextEdit runs currently
119 bool bTextEditHit
: 1; // hit open OutlinerView?
122 bool bPrevNextMark
: 1;
124 bool bInsPointNewObj
: 1;
125 bool bDragWithCopy
: 1;
126 bool bCaptureMouse
: 1;
127 bool bReleaseMouse
: 1;
133 // nEventKind is SdrMouseEventKind::BUTTONDOWN, SdrMouseEventKind::MOVE or SdrMouseEventKind::BUTTONUP
134 void SetMouseEvent(const MouseEvent
& rMEvt
, SdrMouseEventKind nEventKind
);
137 // helper class for all D&D overlays
138 class SVX_DLLPUBLIC SdrDropMarkerOverlay
140 // The OverlayObjects
141 sdr::overlay::OverlayObjectList maObjects
;
143 void ImplCreateOverlays(
144 const SdrView
& rView
,
145 const basegfx::B2DPolyPolygon
& rLinePolyPolygon
);
148 SdrDropMarkerOverlay(const SdrView
& rView
, const SdrObject
& rObject
);
149 SdrDropMarkerOverlay(const SdrView
& rView
, const Rectangle
& rRectangle
);
150 SdrDropMarkerOverlay(const SdrView
& rView
, const Point
& rStart
, const Point
& rEnd
);
151 ~SdrDropMarkerOverlay();
158 class SVX_DLLPUBLIC SdrView
: public SdrCreateView
, public tools::WeakBase
< SdrView
>
160 friend class SdrPageView
;
162 bool bNoExtendedMouseDispatcher
: 1;
163 bool bNoExtendedKeyDispatcher
: 1;
164 bool bNoExtendedCommandDispatcher
: 1;
165 bool bTextEditOnObjectsWithoutTextIfTextTool
: 1;
166 bool mbMasterPagePaintCaching
: 1;
169 SvtAccessibilityOptions maAccessibilityOptions
;
173 explicit SdrView(SdrModel
* pModel1
, OutputDevice
* pOut
= 0L);
176 // The default value for all dispatchers is activated. If the app for example
177 // wants to intervene in MouseDispatcher for special treatment, you have to
178 // deactivate the MouseDispatcher with the help of the methode below and you have
179 // to implement it yourself. Example for MouseButtonDown:
180 // SdrViewEvent aVEvt;
181 // SdrHitKind eHit=pSdrView->PickAnything(rMEvt,SdrMouseEventKind::BUTTONDOWN,aVEvt);
182 // ... hier Applikationsspezifischer Eingriff ...
183 // pSdrView->DoMouseEvent(aVEvt);
184 // SetPointer(GetPreferredPointer(...))
186 void EnableExtendedMouseEventDispatcher(bool bOn
) { bNoExtendedMouseDispatcher
= !bOn
; }
187 bool IsExtendedMouseEventDispatcherEnabled() const { return bNoExtendedMouseDispatcher
; }
189 void EnableExtendedKeyInputDispatcher(bool bOn
) { bNoExtendedKeyDispatcher
=!bOn
; }
190 bool IsExtendedKeyInputDispatcherEnabled() const { return bNoExtendedKeyDispatcher
; }
192 void EnableExtendedCommandEventDispatcher(bool bOn
) { bNoExtendedCommandDispatcher
=!bOn
; }
193 bool IsExtendedCommandEventDispatcherEnabled() const { return bNoExtendedCommandDispatcher
; }
195 void EnableTextEditOnObjectsWithoutTextIfTextTool(bool bOn
) { bTextEditOnObjectsWithoutTextIfTextTool
=bOn
; }
196 bool IsEnableTextEditOnObjectsWithoutTextIfTextToolEnabled() const { return bTextEditOnObjectsWithoutTextIfTextTool
; }
198 void SetMasterPagePaintCaching(bool bOn
);
199 bool IsMasterPagePaintCaching() const { return mbMasterPagePaintCaching
; }
201 bool KeyInput(const KeyEvent
& rKEvt
, vcl::Window
* pWin
) SAL_OVERRIDE
;
202 virtual bool MouseButtonDown(const MouseEvent
& rMEvt
, vcl::Window
* pWin
) SAL_OVERRIDE
;
203 virtual bool MouseButtonUp(const MouseEvent
& rMEvt
, vcl::Window
* pWin
) SAL_OVERRIDE
;
204 virtual bool MouseMove(const MouseEvent
& rMEvt
, vcl::Window
* pWin
) SAL_OVERRIDE
;
205 virtual bool Command(const CommandEvent
& rCEvt
, vcl::Window
* pWin
) SAL_OVERRIDE
;
207 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster
*, sal_uInt32
) SAL_OVERRIDE
;
209 bool SetAttributes(const SfxItemSet
& rSet
, bool bReplaceAll
=false) { return SdrCreateView::SetAttributes(rSet
,bReplaceAll
); }
210 bool SetStyleSheet(SfxStyleSheet
* pStyleSheet
, bool bDontRemoveHardAttr
=false) { return SdrCreateView::SetStyleSheet(pStyleSheet
,bDontRemoveHardAttr
); }
212 /* new interface src537 */
213 bool GetAttributes(SfxItemSet
& rTargetSet
, bool bOnlyHardAttr
=false) const;
215 SfxStyleSheet
* GetStyleSheet() const;
217 // incomplete implementation:
218 // OutputDevice is necessary to determine HandleSize.
219 // If NULL the first signed on Win is used.
220 Pointer
GetPreferredPointer(const Point
& rMousePos
, const OutputDevice
* pOut
, sal_uInt16 nModifier
=0, bool bLeftDown
=false) const;
221 SdrHitKind
PickAnything(const MouseEvent
& rMEvt
, SdrMouseEventKind nMouseDownOrMoveOrUp
, SdrViewEvent
& rVEvt
) const;
222 SdrHitKind
PickAnything(const Point
& rLogicPos
, SdrViewEvent
& rVEvt
) const;
223 bool DoMouseEvent(const SdrViewEvent
& rVEvt
);
224 virtual SdrViewContext
GetContext() const;
226 // The methods consider the particular context:
228 // - mode for editing points
229 // - mode for editing glue points
231 // - ... to be continued
235 const Rectangle
& GetMarkedRect() const;
237 virtual void DeleteMarked();
239 // Marking objects, traverse stations or glue points (depending on view-
240 // context) by enveloping the selection frame.
241 // bAddMark=TRUE: add to existing selection (->Shift)
242 // bUnmark=TRUE: remove objects from selection which are inside of
243 // the enveloped frame.
244 bool BegMark(const Point
& rPnt
, bool bAddMark
=false, bool bUnmark
=false);
246 // The following actions are possible:
249 // - Object-specific dragging
250 // - General dragging
252 OUString
GetStatusText();
254 SvtAccessibilityOptions
& getAccessibilityOptions() { return maAccessibilityOptions
;}
256 virtual void onAccessibilityOptionsChanged();
259 #endif // INCLUDED_SVX_SVDVIEW_HXX
261 // First of all the app creates a SdrModel.
262 // Then it opens a Win and creates a SdrView.
263 // ShowSdrPage() announces a page at SdrView.
264 // It's possible to show SdrView in any Wins at once.
266 // SdrView can show as many Wins as it wants at once. Pages are announced
267 // or checked out with the help of ShowSdrPage()/HideSdrPage(). For every announced
268 // page there is a SdrPageView instance in container aPages. If more than one page
269 // is showed, you have to pay attention that the offset parameter of ShowSdrPage()
270 // is conformed to the size of the page (to prevent overlapping of two pages).
272 // elementary methods:
273 // ~~~~~~~~~~~~~~~~~~~~
276 // sal_Bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin);
277 // sal_Bool MouseButtonDown(const MouseEvent& rMEvt, vcl::Window* pWin);
278 // sal_Bool MouseButtonUp(const MouseEvent& rMEvt, vcl::Window* pWin);
279 // sal_Bool MouseMove(const MouseEvent& rMEvt, vcl::Window* pWin);
280 // sal_Bool Command(const CommandEvent& rCEvt, vcl::Window* pWin);
282 // Exchange (Clipboard derzeit noch ohne SdrPrivateData):
283 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
284 // sal_Bool Cut(sal_uIntPtr nFormat=SDR_ANYFORMAT);
285 // sal_Bool Yank(sal_uIntPtr nFormat=SDR_ANYFORMAT);
286 // sal_Bool Paste(vcl::Window* pWin=NULL, sal_uIntPtr nFormat=SDR_ANYFORMAT);
290 // sal_Bool GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr=sal_False) const;
291 // sal_Bool SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll);
292 // SfxStyleSheet* GetStyleSheet() const;
293 // sal_Bool SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr);
297 // Pointer GetPreferredPointer(const Point& rMousePos, const OutputDevice* pOut, sal_uInt16 nTol=0) const;
298 // OUString GetStatusText();
300 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */