Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / include / svx / svdview.hxx
bloba237bc23f8cbe6a50c105adb157c385cc224076b
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 // Klassenhierarchie der 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 SdrViewContext {SDRCONTEXT_STANDARD,
55 SDRCONTEXT_POINTEDIT,
56 SDRCONTEXT_GLUEPOINTEDIT,
57 SDRCONTEXT_GRAPHIC,
58 SDRCONTEXT_MEDIA,
59 SDRCONTEXT_TABLE};
61 enum SdrEventKind {SDREVENT_NONE,
62 SDREVENT_TEXTEDIT,
63 SDREVENT_MOVACTION,
64 SDREVENT_ENDACTION,
65 SDREVENT_BCKACTION,
66 SDREVENT_BRKACTION,
67 SDREVENT_ENDCREATE,
68 SDREVENT_ENDDRAG,
69 SDREVENT_MARKOBJ,
70 SDREVENT_MARKPOINT,
71 SDREVENT_MARKGLUEPOINT,
72 SDREVENT_BEGMARK,
73 SDREVENT_BEGINSOBJPOINT,
74 SDREVENT_ENDINSOBJPOINT,
75 SDREVENT_BEGINSGLUEPOINT,
76 SDREVENT_BEGDRAGHELPLINE,
77 SDREVENT_BEGDRAGOBJ,
78 SDREVENT_BEGCREATEOBJ,
79 SDREVENT_BEGMACROOBJ,
80 SDREVENT_BEGTEXTEDIT,
81 SDREVENT_ENDMARK,
82 SDREVENT_BRKMARK,
83 SDREVENT_EXECUTEURL};
85 #define SDRMOUSEBUTTONDOWN 1
86 #define SDRMOUSEMOVE 2
87 #define SDRMOUSEBUTTONUP 3
89 // helper class SdrViewEvent
90 struct SVX_DLLPUBLIC SdrViewEvent
92 SdrHdl* pHdl;
93 SdrObject* pObj;
94 SdrObject* pRootObj; // Dieses Markieren bei SdrBeginTextEdit
95 SdrPageView* pPV;
96 const SvxURLField* pURLField;
98 Point aLogicPos;
99 SdrHitKind eHit;
100 SdrEventKind eEvent;
101 SdrHdlKind eHdlKind;
102 SdrCreateCmd eEndCreateCmd; // auch fuer EndInsPoint
104 sal_uInt16 nMouseClicks;
105 sal_uInt16 nMouseMode;
106 sal_uInt16 nMouseCode;
107 sal_uInt16 nHlplIdx;
108 sal_uInt16 nGlueId;
110 bool bMouseDown : 1;
111 bool bMouseUp : 1;
112 bool bDoubleHdlSize : 1; // Doppelte Handlegroesse wg. TextEdit
113 bool bIsAction : 1; // Action ist aktiv
114 bool bIsTextEdit : 1; // TextEdit laeuft zur Zeit
115 bool bTextEditHit : 1; // offene OutlinerView getroffen
116 bool bAddMark : 1;
117 bool bUnmark : 1;
118 bool bPrevNextMark : 1;
119 bool bMarkPrev : 1;
120 bool bInsPointNewObj : 1;
121 bool bDragWithCopy : 1;
122 bool bCaptureMouse : 1;
123 bool bReleaseMouse : 1;
125 public:
126 SdrViewEvent();
127 ~SdrViewEvent();
129 // nEventKind ist SDRMOUSEBUTTONDOWN, SDRMOUSEMOVE oder SDRMOUSEBUTTONUP
130 void SetMouseEvent(const MouseEvent& rMEvt, sal_uInt16 nEventKind);
133 // helper class for all D&D overlays
134 class SVX_DLLPUBLIC SdrDropMarkerOverlay
136 // The OverlayObjects
137 ::sdr::overlay::OverlayObjectList maObjects;
139 void ImplCreateOverlays(
140 const SdrView& rView,
141 const basegfx::B2DPolyPolygon& rLinePolyPolygon);
143 public:
144 SdrDropMarkerOverlay(const SdrView& rView, const SdrObject& rObject);
145 SdrDropMarkerOverlay(const SdrView& rView, const Rectangle& rRectangle);
146 SdrDropMarkerOverlay(const SdrView& rView, const Point& rStart, const Point& rEnd);
147 ~SdrDropMarkerOverlay();
152 * View
154 class SVX_DLLPUBLIC SdrView: public SdrCreateView, public tools::WeakBase< SdrView >
156 friend class SdrPageView;
158 bool bNoExtendedMouseDispatcher : 1;
159 bool bNoExtendedKeyDispatcher : 1;
160 bool bNoExtendedCommandDispatcher : 1;
161 bool bTextEditOnObjectsWithoutTextIfTextTool : 1;
162 bool mbMasterPagePaintCaching : 1;
164 protected:
165 SvtAccessibilityOptions maAccessibilityOptions;
167 public:
168 TYPEINFO_OVERRIDE();
169 explicit SdrView(SdrModel* pModel1, OutputDevice* pOut = 0L);
170 virtual ~SdrView();
172 // Default sind alle Dispatcher aktiviert. Will die App z.B. fuer
173 // Sonderbehandlungen im MouseDispatcher eingreifen, so muss sie
174 // den erweiterten MouseDispather mit unten stehender Methode deaktivieren
175 // und selbst nachimplementieren. Beispiel fuer MouseButtonDown:
176 // SdrViewEvent aVEvt;
177 // SdrHitKind eHit=pSdrView->PickAnything(rMEvt,SDRMOUSEBUTTONDOWN,aVEvt);
178 // ... hier Applikationsspezifischer Eingriff ...
179 // pSdrView->DoMouseEvent(aVEvt);
180 // SetPointer(GetPreferredPointer(...))
181 // CaptureMouse(...)
182 void EnableExtendedMouseEventDispatcher(bool bOn) { bNoExtendedMouseDispatcher = !bOn; }
183 bool IsExtendedMouseEventDispatcherEnabled() const { return bNoExtendedMouseDispatcher; }
185 void EnableExtendedKeyInputDispatcher(bool bOn) { bNoExtendedKeyDispatcher=!bOn; }
186 bool IsExtendedKeyInputDispatcherEnabled() const { return bNoExtendedKeyDispatcher; }
188 void EnableExtendedCommandEventDispatcher(bool bOn) { bNoExtendedCommandDispatcher=!bOn; }
189 bool IsExtendedCommandEventDispatcherEnabled() const { return bNoExtendedCommandDispatcher; }
191 void EnableTextEditOnObjectsWithoutTextIfTextTool(bool bOn) { bTextEditOnObjectsWithoutTextIfTextTool=bOn; }
192 bool IsEnableTextEditOnObjectsWithoutTextIfTextToolEnabled() const { return bTextEditOnObjectsWithoutTextIfTextTool; }
194 void SetMasterPagePaintCaching(bool bOn);
195 bool IsMasterPagePaintCaching() const { return mbMasterPagePaintCaching; }
197 bool KeyInput(const KeyEvent& rKEvt, Window* pWin) SAL_OVERRIDE;
198 virtual bool MouseButtonDown(const MouseEvent& rMEvt, Window* pWin) SAL_OVERRIDE;
199 virtual bool MouseButtonUp(const MouseEvent& rMEvt, Window* pWin) SAL_OVERRIDE;
200 virtual bool MouseMove(const MouseEvent& rMEvt, Window* pWin) SAL_OVERRIDE;
201 virtual bool Command(const CommandEvent& rCEvt, Window* pWin) SAL_OVERRIDE;
203 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ) SAL_OVERRIDE;
205 bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll=false) { return SdrCreateView::SetAttributes(rSet,bReplaceAll); }
206 bool SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr=false) { return SdrCreateView::SetStyleSheet(pStyleSheet,bDontRemoveHardAttr); }
208 /* new interface src537 */
209 bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr=false) const;
211 SfxStyleSheet* GetStyleSheet() const;
213 // unvollstaendige Implementation:
214 // Das OutputDevice ist notwendig, damit ich die HandleSize ermitteln kann.
215 // Bei NULL wird das 1. angemeldete Win verwendet.
216 Pointer GetPreferredPointer(const Point& rMousePos, const OutputDevice* pOut, sal_uInt16 nModifier=0, bool bLeftDown=false) const;
217 SdrHitKind PickAnything(const MouseEvent& rMEvt, sal_uInt16 nMouseDownOrMoveOrUp, SdrViewEvent& rVEvt) const;
218 SdrHitKind PickAnything(const Point& rLogicPos, SdrViewEvent& rVEvt) const;
219 bool DoMouseEvent(const SdrViewEvent& rVEvt);
220 virtual SdrViewContext GetContext() const;
222 // Die Methoden beruecksichtigen den jeweiligen Kontex:
223 // - Einfaches Zeichnen
224 // - Punktbearbeitungs-Mode
225 // - Klebepunkt-Editmode
226 // - TextEdit
227 // - ... to be continued
228 void MarkAll();
229 void UnmarkAll();
231 const Rectangle& GetMarkedRect() const;
233 virtual void DeleteMarked();
235 // Markieren von Objekten, Polygonpunkten oder Klebepunkten (je nach View-
236 // Kontext) durch Aufziehen eines Selektionsrahmens.
237 // bAddMark=TRUE: zur bestehenden Selektion hinzumarkieren (->Shift)
238 // bUnmark=TRUE: Bereits selektierte Objekte/Punkte/Klebepunkte die innerhalb
239 // des aufgezogenen Rahmens liegen werden deselektiert.
240 bool BegMark(const Point& rPnt, bool bAddMark=false, bool bUnmark=false);
242 // Folgende Actions sind moeglich:
243 // - ObjectCreating
244 // - ObjectMarking
245 // - Object-specific dragging
246 // - General dragging
247 // und mehr...
248 OUString GetStatusText();
250 SvtAccessibilityOptions& getAccessibilityOptions();
252 virtual void onAccessibilityOptionsChanged();
255 #endif // INCLUDED_SVX_SVDVIEW_HXX
257 // Die App macht sich zunaechst ein SdrModel.
258 // Anschliessend oeffnet sie ein Win und erzeugt dann eine SdrView.
259 // An der SdrView meldet sie dann mit der Methode ShowSdrPage() eine Seite an.
260 // Eine SdrView kann in beliebig vielen Fenstern gleichzeitig angezeigt werden.
261 // Intern:
262 // Eine SdrView kann beliebig viele Seiten gleichzeitig anzeigen. Seiten
263 // werden an- und abgemeldet mit ShowSdrPage()/HideSdrPage(). Fuer jede angemeldete
264 // Seite wird eine SdrPageView-Instanz im Container aPages angelegt. Bei
265 // gleichzeitiger Anzeige mehrerer Seiten ist darauf zu achten, dass der Offset-
266 // Parameter von ShowSdrPage() der Seitengroesse angepasst ist, da sich sonst die
267 // Seiten ueberlappen koennten.
269 // Elementare Methoden:
270 // ~~~~~~~~~~~~~~~~~~~~
271 // Einfache Events:
272 // ~~~~~~~~~~~~~~~~
273 // sal_Bool KeyInput(const KeyEvent& rKEvt, Window* pWin);
274 // sal_Bool MouseButtonDown(const MouseEvent& rMEvt, Window* pWin);
275 // sal_Bool MouseButtonUp(const MouseEvent& rMEvt, Window* pWin);
276 // sal_Bool MouseMove(const MouseEvent& rMEvt, Window* pWin);
277 // sal_Bool Command(const CommandEvent& rCEvt, Window* pWin);
279 // Exchange (Clipboard derzeit noch ohne SdrPrivateData):
280 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
281 // sal_Bool Cut(sal_uIntPtr nFormat=SDR_ANYFORMAT);
282 // sal_Bool Yank(sal_uIntPtr nFormat=SDR_ANYFORMAT);
283 // sal_Bool Paste(Window* pWin=NULL, sal_uIntPtr nFormat=SDR_ANYFORMAT);
285 // SfxItems:
286 // ~~~~~~~~~
287 // sal_Bool GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr=sal_False) const;
288 // sal_Bool SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll);
289 // SfxStyleSheet* GetStyleSheet() const;
290 // sal_Bool SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr);
292 // Sonstiges:
293 // ~~~~~~~~~~
294 // Pointer GetPreferredPointer(const Point& rMousePos, const OutputDevice* pOut, sal_uInt16 nTol=0) const;
295 // OUString GetStatusText();
297 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */