xref: /aoo4110/main/svx/inc/svx/svddrgv.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVDDRGV_HXX
25 #define _SVDDRGV_HXX
26 
27 #include "svx/svxdllapi.h"
28 #include <svx/svdxcgv.hxx>
29 
30 //************************************************************
31 //   Vorausdeklarationen
32 //************************************************************
33 
34 class SdrUndoGeoObj;
35 
36 ////////////////////////////////////////////////////////////////////////////////////////////////////
37 ////////////////////////////////////////////////////////////////////////////////////////////////////
38 //
39 //  @@@@@  @@@@@   @@@@   @@@@   @@ @@ @@ @@@@@ @@   @@
40 //  @@  @@ @@  @@ @@  @@ @@  @@  @@ @@ @@ @@    @@   @@
41 //  @@  @@ @@  @@ @@  @@ @@      @@ @@ @@ @@    @@ @ @@
42 //  @@  @@ @@@@@  @@@@@@ @@ @@@  @@@@@ @@ @@@@  @@@@@@@
43 //  @@  @@ @@  @@ @@  @@ @@  @@   @@@  @@ @@    @@@@@@@
44 //  @@  @@ @@  @@ @@  @@ @@  @@   @@@  @@ @@    @@@ @@@
45 //  @@@@@  @@  @@ @@  @@  @@@@@    @   @@ @@@@@ @@   @@
46 //
47 ////////////////////////////////////////////////////////////////////////////////////////////////////
48 ////////////////////////////////////////////////////////////////////////////////////////////////////
49 
50 class ImpSdrDragViewExtraData;
51 
52 class SVX_DLLPUBLIC SdrDragView: public SdrExchangeView
53 {
54 	friend class				SdrPageView;
55 	friend class				SdrDragMethod;
56 
57 protected:
58 	SdrHdl*						pDragHdl;
59 	SdrDragMethod*				mpCurrentSdrDragMethod;
60 	SdrUndoGeoObj*				pInsPointUndo;
61 	Rectangle					aDragLimit;
62 	XubString					aInsPointUndoStr;
63 	SdrMarkList					aFollowingEdges; // Wenn Knoten gedraggd werden, sollen alle Kanten als Xor folgen
64 	SdrHdlKind					eDragHdl;
65 
66 	sal_uIntPtr						nDragXorPolyLimit;
67 	sal_uIntPtr						nDragXorPointLimit;
68 	sal_uInt16						nRubberEdgeDraggingLimit;
69 	sal_uInt16						nDetailedEdgeDraggingLimit;
70 
71 	unsigned					bFramDrag : 1;        // z.Zt. FrameDrag
72 	unsigned					bDragSpecial : 1;     // z.Zt. Special Obj-Dragging
73 	unsigned					bMarkedHitMovesAlways : 1; // Persistent
74 	unsigned					bDragLimit : 1;      // Limit auf SnapRect statt BoundRect
75 	unsigned					bDragHdl : 1;        // TRUE: RefPt wird verschoben
76 	unsigned					bDragStripes : 1;    // Persistent
77 	unsigned					bMirrRefDragObj : 1; // Persistent - Waehrend des Draggens der Spiegelachse die gespiegelten Objekte als Xor zeigen
78 	unsigned					mbSolidDragging : 1;  // allow solid create/drag of objects
79 	unsigned					bMouseHideWhileDraggingPoints : 1;
80 	unsigned					bResizeAtCenter : 1;
81 	unsigned					bCrookAtCenter : 1;
82 	unsigned					bDragWithCopy : 1;
83 	unsigned					bInsGluePoint : 1;
84 	unsigned					bInsObjPointMode : 1;
85 	unsigned					bInsGluePointMode : 1;
86 	unsigned					bNoDragXorPolys : 1;
87 	unsigned					bAutoVertexCon : 1;  // Automatische Konnektorgenerierung an den Scheitelpunkten
88 	unsigned					bAutoCornerCon : 1;  // Automatische Konnektorgenerierung an den Eckpunkten
89 	unsigned					bRubberEdgeDragging : 1;
90 	unsigned					bDetailedEdgeDragging : 1;
91 
92 private:
93 	SVX_DLLPRIVATE void ImpClearVars();
94 	SVX_DLLPRIVATE void ImpMakeDragAttr();
95 	SVX_DLLPRIVATE void ImpDelDragAttr();
96 
97 protected:
98 	virtual void SetMarkHandles();
99 	void ShowDragObj();
100 	void HideDragObj();
101 	sal_Bool ImpBegInsObjPoint(sal_Bool bIdxZwang, sal_uInt32 nIdx, const Point& rPnt, sal_Bool bNewObj, OutputDevice* pOut);
102 
103 protected:
104 	// #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
105 	SdrDragView(SdrModel* pModel1, OutputDevice* pOut = 0L);
106 	virtual ~SdrDragView();
107 
108 public:
109 	virtual sal_Bool IsAction() const;
110 	virtual void MovAction(const Point& rPnt);
111 	virtual void EndAction();
112 	virtual void BckAction();
113 	virtual void BrkAction();
114 	virtual void TakeActionRect(Rectangle& rRect) const;
115 
116 	// Spezialimplementation fuer den Writer:
117 	// TakeDragObjAnchorPos() liefert die Position an der ein Objekt
118 	// beim Draggen einer Einfachselektion ungefaehr landet wenn es
119 	// "losgelassen" wird (EndDrag).
120 	// In der Regel ist das die linke obere Ecke des zu erwartenden neuen
121 	// SnapRects. Ausnahme: CaptionObj. Dort ist es die Position des
122 	// "Schwanzendes".
123 	// Bei Returncode sal_False konnte ich die Position nicht bestimmen
124 	// (z.B. Punktverschiebung, Mehrfachselektion, Schieben der
125 	// Spiegelschse, ...)
126     sal_Bool TakeDragObjAnchorPos(Point& rPos, sal_Bool bTopRight = sal_False ) const;
127 
128 	// Wird pForcedMeth uebergeben, so wird pHdl, ... nicht ausgewerten, sondern diese
129 	// Drag-Methode verwendet. Die Instanz geht dabei ins Eigentum der View ueber und
130 	// wird zum Ende des Draggings destruiert.
131 	virtual sal_Bool BegDragObj(const Point& rPnt, OutputDevice* pOut=NULL, SdrHdl* pHdl=NULL, short nMinMov=-3, SdrDragMethod* pForcedMeth=NULL);
132 	void MovDragObj(const Point& rPnt);
133 	sal_Bool EndDragObj(sal_Bool bCopy=sal_False);
134 	void BrkDragObj();
IsDragObj() const135 	sal_Bool IsDragObj() const { return mpCurrentSdrDragMethod && !bInsPolyPoint && !bInsGluePoint; }
GetDragHdl() const136 	SdrHdl* GetDragHdl() const { return pDragHdl; }
GetDragMethod() const137 	SdrDragMethod* GetDragMethod() const { return mpCurrentSdrDragMethod; }
IsDraggingPoints() const138 	sal_Bool IsDraggingPoints() const { return eDragHdl==HDL_POLY; }
IsDraggingGluePoints() const139 	sal_Bool IsDraggingGluePoints() const { return eDragHdl==HDL_GLUE; }
140 
141 	// Wer das beim BegDrag oder mittendrin schon festlegen will.
142 	// (Wird bei jedem BegDrag auf sal_False zurueckgesetzt, also nach
143 	// BegDrag setzen.)
SetDragWithCopy(sal_Bool bOn)144 	void SetDragWithCopy(sal_Bool bOn) { bDragWithCopy = bOn; }
IsDragWithCopy() const145 	sal_Bool IsDragWithCopy() const { return bDragWithCopy; }
146 
SetInsertGluePoint(sal_Bool bOn)147 	void SetInsertGluePoint(sal_Bool bOn) { bInsGluePoint = bOn; }
IsInsertGluePoint() const148 	sal_Bool IsInsertGluePoint() const { return bInsGluePoint; }
149 
150 	// Interaktives einfuegen eines neuen Punktes. nIdx=0 => vor dem ersten Punkt.
151 	sal_Bool IsInsObjPointPossible() const;
IsInsPointPossible() const152 	sal_Bool IsInsPointPossible() const { return IsInsObjPointPossible(); }
BegInsObjPoint(const Point & rPnt,sal_Bool bNewObj)153 	sal_Bool BegInsObjPoint(const Point& rPnt, sal_Bool bNewObj) { return ImpBegInsObjPoint(sal_False, 0L, rPnt, bNewObj, 0L); }
MovInsObjPoint(const Point & rPnt)154 	void MovInsObjPoint(const Point& rPnt) { MovDragObj(rPnt); }
155 	sal_Bool EndInsObjPoint(SdrCreateCmd eCmd);
BrkInsObjPoint()156 	void BrkInsObjPoint() { BrkDragObj(); }
IsInsObjPoint() const157 	sal_Bool IsInsObjPoint() const { return mpCurrentSdrDragMethod && bInsPolyPoint; }
158 
159 	// Fuer die App zum Verwalten des Status. GetPreferedPointer() wird
160 	// spaeter vielleicht einen passenden Pointer dafuer liefern
SetInsObjPointMode(sal_Bool bOn)161 	void SetInsObjPointMode(sal_Bool bOn) { bInsObjPointMode = bOn; }
IsInsObjPointMode() const162 	sal_Bool IsInsObjPointMode() const { return bInsObjPointMode; }
163 
164 	sal_Bool IsInsGluePointPossible() const;
165 	sal_Bool BegInsGluePoint(const Point& rPnt);
MovInsGluePoint(const Point & rPnt)166 	void MovInsGluePoint(const Point& rPnt) { MovDragObj(rPnt); }
EndInsGluePoint()167 	sal_Bool EndInsGluePoint() { return EndDragObj(); }
BrkInsGluePoint()168 	void BrkInsGluePoint() { BrkDragObj(); }
IsInsGluePoint() const169 	sal_Bool IsInsGluePoint() const { return mpCurrentSdrDragMethod && bInsGluePoint; }
170 
171 	// Fuer die App zum Verwalten des Status. GetPreferedPointer() wird
172 	// spaeter vielleicht einen passenden Pointer dafuer liefern
SetInsGluePointMode(sal_Bool bOn)173 	void SetInsGluePointMode(sal_Bool bOn) { bInsGluePointMode = bOn; }
IsInsGluePointMode() const174 	sal_Bool IsInsGluePointMode() const { return bInsGluePointMode; }
175 
176 	// Begrenzungslinien ueber's gesamte Win waehrend des Draggens
177 	// Persistent. Default=FALSE.
178 	void SetDragStripes(sal_Bool bOn);
IsDragStripes() const179 	sal_Bool IsDragStripes() const { return bDragStripes; }
180 
181 	// Handles waehrend des Draggens verstecken
182 	//HMHvoid SetDragHdlHide(sal_Bool bOn);
183 	//HMHBOOL IsDragHdlHide() const { return bNoDragHdl; }
184 
185 	// Beim Draggen von Polygonpunkten und Klebepunkten
186 	// die Maus verstecken. Default=FALSE
SetMouseHideWhileDraggingPoints(sal_Bool bOn)187 	void SetMouseHideWhileDraggingPoints(sal_Bool bOn) { bMouseHideWhileDraggingPoints = bOn; }
IsMouseHideWhileDraggingPoints() const188 	sal_Bool IsMouseHideWhileDraggingPoints() const { return bMouseHideWhileDraggingPoints; }
189 
190 	// Beim Draggen werden i.d.R. die Konturen der markierten Objekte
191 	// als Xor-Polygone dargestellt. Wird dieses Flag hier gesetzt,
192 	// wird (z.B. bei Mehrfachselektion) nur ein Xor-Frame gezeichnet.
193 	// Bei objektspeziefischem Dragging (Polygonpunkte,Eckenradius,...
194 	// hat diese Einstellung keine Auswirkung.
195 	// Auch waerend des Draggens umschaltbar.
196 	// Default=Off
197 	void SetNoDragXorPolys(sal_Bool bOn);
IsNoDragXorPolys() const198 	sal_Bool IsNoDragXorPolys() const { return bNoDragXorPolys; }
199 
200 	// Uebersteigt die Anzahl der markierten Objekte den hier eingestellten
201 	// Wert, wird implizit (temporaer) auf NoDragPolys geschaltet.
202 	// PolyPolygone etc werden entsprechend als mehrere Objekte gewertet.
203 	// Default=100
SetDragXorPolyLimit(sal_uIntPtr nObjAnz)204 	void  SetDragXorPolyLimit(sal_uIntPtr nObjAnz) { nDragXorPolyLimit=nObjAnz; }
GetDragXorPolyLimit() const205 	sal_uIntPtr GetDragXorPolyLimit() const { return nDragXorPolyLimit; }
206 
207 	// Wie DragXorPolyLimit, jedoch bezogen auf die Gesamtpunktanzahl
208 	// aller Polygone. Default=500.
209 	// Auf NoDragPolys wird (temporaer) geschaltet, wenn eins der Limits
210 	// ueberstiegen wird.
SetDragXorPointLimit(sal_uIntPtr nPntAnz)211 	void  SetDragXorPointLimit(sal_uIntPtr nPntAnz) { nDragXorPointLimit=nPntAnz; }
GetDragXorPointLimit() const212 	sal_uIntPtr GetDragXorPointLimit() const { return nDragXorPointLimit; }
213 
214 	void SetSolidDragging(bool bOn);
215 	bool IsSolidDragging() const;
216 
217 	// Dragging/Creating von Verbindern:
218 	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
219 	// Verbinder an Objektscheitelpunkte ankleben
220 	// Default=sal_True=Ja
SetAutoVertexConnectors(sal_Bool bOn)221 	void SetAutoVertexConnectors(sal_Bool bOn) { bAutoVertexCon = bOn; }
IsAutoVertexConnectors() const222 	sal_Bool IsAutoVertexConnectors() const { return bAutoVertexCon; }
223 
224 	// Verbinder an Objektecken ankleben
225 	// Default=sal_False=Nein
SetAutoCornerConnectors(sal_Bool bOn)226 	void SetAutoCornerConnectors(sal_Bool bOn) { bAutoCornerCon = bOn; }
IsAutoCornerConnectors() const227 	sal_Bool IsAutoCornerConnectors() const { return bAutoCornerCon; }
228 
229 	// Dragging von verbundenen Objekten (Nodes):
230 	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
231 	// DetailedEdgeDraggingLimit: Wie RubberEdgeDraggingLimit, jedoch bezieht
232 	// sich dieses Limit auf die detalierte Darstellung, d.h. nicht nur
233 	// Gummibaender sondern komplette Neuberechnunen sind beim Draggen sichtbar.
234 	// Diese detalierte Darstellung ist eh nur beim MoveDrag moeglich.
235 	// Defaultwert ist 10
236 	void SetDetailedEdgeDragging(sal_Bool bOn); // Default an
IsDetailedEdgeDragging() const237 	sal_Bool IsDetailedEdgeDragging() const { return bDetailedEdgeDragging; }
238 
239 	void SetDetailedEdgeDraggingLimit(sal_uInt16 nEdgeObjAnz);
GetDetailedEdgeDraggingLimit() const240 	sal_uInt16 GetDetailedEdgeDraggingLimit() const { return nDetailedEdgeDraggingLimit; }
241 
242 	// EdgeDraggingLimit: Sind mehr als nEdgeObjAnz Kanten betroffen, werden
243 	// diese beim interaktiven Draggen nicht mit angezeigt.
244 	// Gemeint sind hier die "Gummibaender", die weniger Rechenzeit benoetigen
245 	// als die kompletten Neuberechnungen beim DetailedEdgeDragging.
246 	// Defaultwert ist 100
247 	void SetRubberEdgeDragging(sal_Bool bOn);  // Default an
IsRubberEdgeDragging() const248 	sal_Bool IsRubberEdgeDragging() const { return bRubberEdgeDragging; }
249 
250 	void SetRubberEdgeDraggingLimit(sal_uInt16 nEdgeObjAnz);
GetRubberEdgeDraggingLimit() const251 	sal_uInt16 GetRubberEdgeDraggingLimit() const { return nRubberEdgeDraggingLimit; }
252 
253 	// Verbinderhandling also zu deutsch wie folgt (bei Defaulteinstellungen):
254 	// - Sind bis max 10 Verbinder betroffen werden diese bei jedem
255 	//   MouseMove neu berechnet
256 	// - Sind zwischen 11 und 100 Verbinder betroffen werden die
257 	//   Verbindungen beim Draggen als gerade Linien dargestellt.
258 	// - Bei mehr als 100 betroffenen Verbindern wird beim Draggen nichts
259 	//   mehr gezeichnet was auf Verbinder hinweist.
260 
261 	// Ist ein spezieller Dragmode eingeschaltet, wie Rotate, Mirror oder Crook,
262 	// dann leitet ein Hit auf das markierte Objekt genau dieses Dragging ein.
263 	// Setzt man MarkedHitMovesAlways auf sal_True, so leitet ein Hit auf das
264 	// markierte Objekt immer ein Moven ein, unabhaengig vom gesetzten DragMode.
265 	// Dieses Flag ist persistent und sollte von der App fuer den Anwender
266 	// konfigurierbar sein!
SetMarkedHitMovesAlways(sal_Bool bOn)267 	void SetMarkedHitMovesAlways(sal_Bool bOn) { bMarkedHitMovesAlways = bOn; }
IsMarkedHitMovesAlways() const268 	sal_Bool IsMarkedHitMovesAlways() const { return bMarkedHitMovesAlways; }
269 
270 	// Beim Draggen der Spiegelachse das Spiegelbild der markierten Objekte
271 	// als Xor darstellen? Persistent. Noch nicht implementiert. Default TRUE.
SetMirrRefDragObj(sal_Bool bOn)272 	void SetMirrRefDragObj(sal_Bool bOn) { bMirrRefDragObj = bOn; }
IsMirrRefDragObj() const273 	sal_Bool IsMirrRefDragObj() const { return bMirrRefDragObj; }
274 
275 	sal_Bool IsOrthoDesired() const;
276 
277 	// Beim Resize die Mitte als Referenz
278 	// Default=FALSE.
IsResizeAtCenter() const279 	sal_Bool IsResizeAtCenter() const { return bResizeAtCenter; }
SetResizeAtCenter(sal_Bool bOn)280 	void SetResizeAtCenter(sal_Bool bOn) { bResizeAtCenter = bOn; }
281 
282 	// Symmetrisches Crook
283 	// Default=FALSE.
IsCrookAtCenter() const284 	sal_Bool IsCrookAtCenter() const { return bCrookAtCenter; }
SetCrookAtCenter(sal_Bool bOn)285 	void SetCrookAtCenter(sal_Bool bOn) { bCrookAtCenter = bOn; }
286 
287 	// Begrenzung des Arbeitsbereichs. Die Begrenzung bezieht sich auf die
288 	// View, nicht auf die einzelnen PageViews. Von der View wird diese
289 	// Begrenzung nur bei Interaktionen wie Dragging und Create ausgewertet.
290 	// Bei von der App algorithmisch oder UI-gesteuerte Aktionen (SetGeoAttr,
291 	// MoveMarkedObj, ...) muss die App dieses Limit selbst beruecksichtigen.
292 	// Ferner ist dieses Limit als Grob-Limit zu sehen. U.U. koennen Objekte
293 	// (z.B. beim Drehen) nicht exakt bis an dieses Limit herangedraggt werden,
294 	// koennen Objekte durch Rundungsfehler doch etwas ueberstehen, ... .
295 	// Default=EmptyRect=keine Begrenzung.
296 	// erst z.T. impl.
297 	// (besser in die DragView?)
SetWorkArea(const Rectangle & rRect)298 	void SetWorkArea(const Rectangle& rRect) { aMaxWorkArea=rRect; }
GetWorkArea() const299 	const Rectangle& GetWorkArea() const { return aMaxWorkArea; }
300 
301 
302 	// Das DragLimit ist bezogen auf die Page des Objekts.
303 	// (Oder auf die View??? Muss ich mal^^^^recherchieren. Joe.)
304 	// sal_False=Kein Limit.
305 	// Das Rueckgabe-Rect muss absolute Koordinaten enthalten. Der Maximale
306 	// Dragbereich wird von der View dann so gewaehlt, dass das SnapRect des
307 	// Objekts bis Maximal auf die Kante des LimitRects gemoved bzw. gesized
308 	// wird. Bei Objekten wie Bezierkurven, gedrehten Rechtecken ist zu beachten
309 	// das durch anschliessende Neuberechnung des SnapRects (bei Resize)
310 	// Rundungsfehler auftreten koennen, wodurch das LimitRect minnimal
311 	// ueberschritten werden koennte...
312 	// Implementiert fuer Move und Resize.
313 	virtual sal_Bool TakeDragLimit(SdrDragMode eMode, Rectangle& rRect) const;
314 };
315 
316 #endif //_SVDDRGV_HXX
317 
318