build fix
[LibreOffice.git] / include / svx / svdedtv.hxx
blobd349eb7142f4c1d5376e7f08be3b879b9a4c2a7b
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_SVDEDTV_HXX
21 #define INCLUDED_SVX_SVDEDTV_HXX
23 #include <svx/svdmrkv.hxx>
24 #include <svx/xpoly.hxx>
25 #include <svx/svdmodel.hxx>
26 #include <svx/svxdllapi.h>
27 #include <o3tl/typed_flags_set.hxx>
29 class SfxUndoAction;
30 class SdrUndoAction;
31 class SdrUndoGroup;
32 class SfxStyleSheet;
33 class SdrLayer;
34 class SvdProgressInfo;
36 enum class SdrHorAlign {
37 NONE,
38 Left,
39 Right,
40 Center
43 enum class SdrVertAlign {
44 NONE,
45 Top,
46 Bottom,
47 Center
50 enum class SdrMergeMode {
51 Merge,
52 Subtract,
53 Intersect
56 // Options for InsertObject()
57 enum class SdrInsertFlags
59 NONE = 0x0000,
60 DONTMARK = 0x0001, /* object will not be marked (the actual marking remains) */
61 ADDMARK = 0x0002, /* object will be added an existing selection */
62 SETDEFATTR = 0x0004, /* actual attributes (+StyleSheet) are assigned to the object */
63 SETDEFLAYER = 0x0008, /* actual layer is assigned to the object */
64 NOBROADCAST = 0x0010, /* insert with NbcInsertObject() for SolidDragging */
66 namespace o3tl
68 template<> struct typed_flags<SdrInsertFlags> : is_typed_flags<SdrInsertFlags, 0x1f> {};
71 class SVX_DLLPUBLIC SdrEditView: public SdrMarkView
73 friend class SdrPageView;
74 friend class SdrDragDistort;
75 friend class SdrDragCrook;
77 protected:
79 // cache the transformation queries, etc. a little
80 bool bPossibilitiesDirty : 1;
81 bool bReadOnly : 1;
82 bool bGroupPossible : 1;
83 bool bUnGroupPossible : 1;
84 bool bGrpEnterPossible : 1;
85 bool bDeletePossible : 1;
86 bool bToTopPossible : 1;
87 bool bToBtmPossible : 1;
88 bool bReverseOrderPossible : 1;
89 bool bImportMtfPossible : 1;
90 bool bCombinePossible : 1;
91 bool bDismantlePossible : 1;
92 bool bCombineNoPolyPolyPossible : 1;
93 bool bDismantleMakeLinesPossible : 1;
94 bool bOrthoDesiredOnMarked : 1;
95 bool bMoreThanOneNotMovable : 1; // more then one objects are not moveable
96 bool bOneOrMoreMovable : 1; // at least one object is moveable
97 bool bMoreThanOneNoMovRot : 1; // more then one object is not movable nor turnable (Crook)
98 bool bContortionPossible : 1; // all polygones (grouped if necessary)
99 bool bMoveAllowed : 1;
100 bool bResizeFreeAllowed : 1;
101 bool bResizePropAllowed : 1;
102 bool bRotateFreeAllowed : 1;
103 bool bRotate90Allowed : 1;
104 bool bMirrorFreeAllowed : 1;
105 bool bMirror45Allowed : 1;
106 bool bMirror90Allowed : 1;
107 bool bShearAllowed : 1;
108 bool bEdgeRadiusAllowed : 1;
109 bool bTransparenceAllowed : 1;
110 bool bCropAllowed : 1;
111 bool bGradientAllowed : 1;
112 bool bCanConvToPath : 1;
113 bool bCanConvToPoly : 1;
114 bool bCanConvToContour : 1;
115 bool bCanConvToPathLineToArea : 1;
116 bool bCanConvToPolyLineToArea : 1;
117 bool bMoveProtect : 1;
118 bool bResizeProtect : 1;
119 // maintain Z-order of the virtual objects (Writer)
120 bool bBundleVirtObj : 1;
122 private:
123 SVX_DLLPRIVATE void ImpClearVars();
124 SVX_DLLPRIVATE void ImpResetPossibilityFlags();
126 protected:
127 void ImpBroadcastEdgesOfMarkedNodes();
129 // convert the objects marked in poly resp. bezier
130 void ImpConvertTo(bool bPath, bool bLineToArea);
132 // converts an object, when positive it removes the old one from its List
133 // and inserts the new one instead. including Undo.
134 // Nor MarkEntry nor ModelChgBroadcast is created.
135 SdrObject* ImpConvertOneObj(SdrObject* pObj, bool bPath, bool bLineToArea);
137 // set both flags: bToTopPossible and bToBtmPossible.
138 // bToTopPossibleDirty and bToBtmPossibleDirty are reset at same time
139 void ImpCheckToTopBtmPossible();
141 // for CombineMarkedObjects and DismantleMarkedObjects
142 void ImpCopyAttributes(const SdrObject* pSource, SdrObject* pDest) const;
144 // for CombineMarkedObjects
145 static bool ImpCanConvertForCombine1(const SdrObject* pObj);
146 static bool ImpCanConvertForCombine(const SdrObject* pObj);
147 static basegfx::B2DPolyPolygon ImpGetPolyPolygon1(const SdrObject* pObj);
148 static basegfx::B2DPolyPolygon ImpGetPolyPolygon(const SdrObject* pObj);
149 static basegfx::B2DPolygon ImpCombineToSinglePolygon(const basegfx::B2DPolyPolygon& rPolyPolygon);
151 // for DismantleMarkedObjects
152 static bool ImpCanDismantle(const basegfx::B2DPolyPolygon& rPpolyPpolygon, bool bMakeLines);
153 static bool ImpCanDismantle(const SdrObject* pObj, bool bMakeLines);
154 void ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, size_t& rPos, SdrPageView* pPV, bool bMakeLines);
155 static void ImpCrookObj(SdrObject* pO, const Point& rRef, const Point& rRad, SdrCrookMode eMode,
156 bool bVertical, bool bNoContortion, bool bRotate, const Rectangle& rMarkRect);
157 static void ImpDistortObj(SdrObject* pO, const Rectangle& rRef, const XPolygon& rDistortedRect, bool bNoContortion);
158 bool ImpDelLayerCheck(SdrObjList* pOL, SdrLayerID nDelID) const;
159 void ImpDelLayerDelObjs(SdrObjList* pOL, SdrLayerID nDelID);
161 // Removes all objects of the MarkList from their ObjLists including Undo.
162 // The entries in rMark remain.
163 void DeleteMarkedList(const SdrMarkList& rMark); // DeleteMarked -> DeleteMarkedList
165 // Check possibilities of all marked objects
166 virtual void CheckPossibilities();
167 void ForcePossibilities() const { if (bPossibilitiesDirty || mbSomeObjChgdFlag) const_cast<SdrEditView*>(this)->CheckPossibilities(); }
169 protected:
170 // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
171 SdrEditView(SdrModel* pModel1, OutputDevice* pOut);
172 virtual ~SdrEditView() override;
174 public:
175 // each call of an undo-capable method from its view, generates an undo action.
176 // If one wishes to group method calls into one, these calls should be put
177 // between BegUndo() and EndUndo() calls (unlimited).
178 // The comment used for the UndoAction is the first BegUndo(String).
179 // In this case NotifyNewUndoAction is called at the last EndUndo().
180 // NotifyNewUndoAction() is not called for an empty group.
181 void BegUndo() { mpModel->BegUndo(); } // open undo-grouping
182 void BegUndo(const OUString& rComment) { mpModel->BegUndo(rComment); } // open undo-grouping
183 void BegUndo(const OUString& rComment, const OUString& rObjDescr, SdrRepeatFunc eFunc=SdrRepeatFunc::NONE) { mpModel->BegUndo(rComment,rObjDescr,eFunc); } // open undo-grouping
184 void EndUndo(); // close undo-grouping (incl. BroadcastEdges)
185 void AddUndo(SdrUndoAction* pUndo) { mpModel->AddUndo(pUndo); } // add action
186 // only after first BegUndo or befor last EndUndo:
187 void SetUndoComment(const OUString& rComment, const OUString& rObjDescr) { mpModel->SetUndoComment(rComment,rObjDescr); }
188 bool IsUndoEnabled() const;
190 std::vector< SdrUndoAction* > CreateConnectorUndo( SdrObject& rO );
191 void AddUndoActions( std::vector< SdrUndoAction* >& );
193 // Layermanagement with Undo.
194 void InsertNewLayer(const OUString& rName, sal_uInt16 nPos);
195 // Delete a layer including all objects contained
196 void DeleteLayer(const OUString& rName);
198 // Marked objects which are outside a page
199 // are assigned to an other page; at the moment without undo!!!
200 void ForceMarkedObjToAnotherPage();
201 void ForceMarkedToAnotherPage() { ForceMarkedObjToAnotherPage(); }
203 // delete all marked objects
204 void DeleteMarkedObj();
206 // Set a logical enclosing rectangle for all marked objects.
207 // It is not guaranteed if this succeeds, as a horizontal
208 // line has always a height of 0
209 void SetMarkedObjRect(const Rectangle& rRect);
210 void MoveMarkedObj(const Size& rSiz, bool bCopy=false);
211 void ResizeMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy=false);
212 void ResizeMultMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, const bool bCopy, const bool bWdh, const bool bHgt);
213 long GetMarkedObjRotate() const;
214 void RotateMarkedObj(const Point& rRef, long nAngle, bool bCopy=false);
215 void MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool bCopy=false);
216 void MirrorMarkedObjHorizontal();
217 void MirrorMarkedObjVertical();
218 long GetMarkedObjShear() const;
219 void ShearMarkedObj(const Point& rRef, long nAngle, bool bVShear=false, bool bCopy=false);
220 void CrookMarkedObj(const Point& rRef, const Point& rRad, SdrCrookMode eMode, bool bVertical, bool bNoContortion, bool bCopy=false);
221 void DistortMarkedObj(const Rectangle& rRef, const XPolygon& rDistortedRect, bool bNoContortion, bool bCopy=false);
223 // copy marked objects and mark them instead of the old ones
224 void CopyMarkedObj();
225 void SetAllMarkedRect(const Rectangle& rRect) { SetMarkedObjRect(rRect); }
226 void MoveAllMarked(const Size& rSiz, bool bCopy=false) { MoveMarkedObj(rSiz,bCopy); }
227 void ResizeAllMarked(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { ResizeMarkedObj(rRef,xFact,yFact); }
228 void RotateAllMarked(const Point& rRef, long nAngle) { RotateMarkedObj(rRef,nAngle); }
229 void MirrorAllMarkedHorizontal() { MirrorMarkedObjHorizontal(); }
230 void MirrorAllMarkedVertical() { MirrorMarkedObjVertical(); }
231 void CopyMarked() { CopyMarkedObj(); }
232 bool IsMoveAllowed() const { ForcePossibilities(); return bMoveAllowed && !bMoveProtect; }
233 bool IsResizeAllowed(bool bProp=false) const;
234 bool IsRotateAllowed(bool b90Deg=false) const;
235 bool IsMirrorAllowed(bool b45Deg=false, bool b90Deg=false) const;
236 bool IsTransparenceAllowed() const;
237 bool IsGradientAllowed() const;
238 bool IsShearAllowed() const;
239 bool IsEdgeRadiusAllowed() const;
240 bool IsCrookAllowed(bool bNoContortion=false) const;
241 bool IsCropAllowed() const;
242 bool IsDistortAllowed(bool bNoContortion=false) const;
244 // Unite several objects to a polygon:
245 // - rectangles/circles/text... are implicite converted.
246 // - polygones are closed automatically
247 // - attributes and layer are taken from the first object marked
248 // (thus from lowest Z-order).
249 // - group objects are included when all (!) member objects of
250 // the group can be changed. If a group includes for example
251 // a bitmap or an OLE-object, the complete group is not considered.
252 // bNoPolyPoly=TRUE: all is grouped to one single polygon
253 void CombineMarkedObjects(bool bNoPolyPoly = true);
255 // for combining multiple polygons, with direct support of the modes
256 // SID_POLY_MERGE, SID_POLY_SUBSTRACT, SID_POLY_INTERSECT
257 void MergeMarkedObjects(SdrMergeMode eMode);
259 // for distribution dialog function
260 void DistributeMarkedObjects();
262 // for setting either the width or height of all selected
263 // objects to the width/height of the last selected object
264 // of the selection
265 void EqualizeMarkedObjects(bool bWidth);
267 // Decompose marked polypolygon objects into polygons.
268 // Grouped objects are searched and decomposed, if all member objects are PathObjs.
269 // bMakeLines=TRUE: all polygones are decomposed into single lines resp. bezier segments
270 void DismantleMarkedObjects(bool bMakeLines=false);
271 bool IsCombinePossible(bool bNoPolyPoly=false) const;
272 bool IsDismantlePossible(bool bMakeLines=false) const;
274 // Inserts a new, completely constructed object. Subsequently the object belongs to
275 // the model. After insertion the object is marked (if not prevented by nOptions).
276 // Sometimes the object is not inserted, but deleted, this is the case when
277 // the target layer is locked or not visible. In this case
278 // the method returns FALSE.
279 // Amongst others the method does not create an undo-action.
280 bool InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE);
282 // Replace one drawing object by another.
283 // *pNewObj belongs to me, *pOldObj is changed into Undo.
284 // In any case an undo grouping is required and should be applied, e.g.:
285 // aStr+=" replace";
286 // BegUndo(aStr);
287 // ReplaceObject(...);
289 // EndUndo();
290 void ReplaceObjectAtView(SdrObject* pOldObj, SdrPageView& rPV, SdrObject* pNewObj, bool bMark=true);
292 void SetNotPersistAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll);
293 void MergeNotPersistAttrFromMarked(SfxItemSet& rAttr, bool bOnlyHardAttr) const;
294 void MergeAttrFromMarked(SfxItemSet& rAttr, bool bOnlyHardAttr) const;
295 SfxItemSet GetAttrFromMarked(bool bOnlyHardAttr) const;
296 void SetAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll);
298 // geometrical attribute (position, size, rotation angle)
299 // A PageOrigin set at a position is taken into account.
300 SfxItemSet GetGeoAttrFromMarked() const;
301 void SetGeoAttrToMarked(const SfxItemSet& rAttr);
303 // Returns NULL if:
304 // - nothing is marked,
305 // - no stylesheet is set at the marked object
306 // - point the marked objects to different StyleSheets for multiple selections
307 SfxStyleSheet* GetStyleSheetFromMarked() const;
309 // at the moment without undo :(
310 void SetStyleSheetToMarked(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr);
312 /* new interface src537 */
313 bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const;
315 bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
316 SfxStyleSheet* GetStyleSheet() const; // SfxStyleSheet* GetStyleSheet(bool& rOk) const;
317 bool SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr);
319 // Group all marked objects to a single group.
320 // Subsequently mark the new group . If the group spawns multiple
321 // pages a group is created per page.
322 // All groups created are subsequently marked.
323 // The method creates SdrObjGroup-instances.
324 void GroupMarked();
326 // All marked object groups are dissolved (1 level).
327 // Now all previously marked member objects are marked.
328 // Previously marked objects, which are not group objects, remain marked.
329 void UnGroupMarked();
331 bool IsGroupPossible() const { ForcePossibilities(); return bGroupPossible; }
332 bool IsUnGroupPossible() const { ForcePossibilities(); return bUnGroupPossible; }
333 bool IsGroupEnterPossible() const { ForcePossibilities(); return bGrpEnterPossible; }
335 // Convert marked objects to polygones/Beziercurves. The bool-functions
336 // return sal_True, if at least one marked object could be converted.
337 // Also member objects of group objects are converted.
338 // For a better description see: SdrObj.HXX
339 bool IsConvertToPathObjPossible() const { ForcePossibilities(); return bCanConvToPath; }
340 bool IsConvertToPolyObjPossible() const { ForcePossibilities(); return bCanConvToPoly; }
341 bool IsConvertToContourPossible() const { ForcePossibilities(); return bCanConvToContour; }
342 void ConvertMarkedToPathObj(bool bLineToArea);
343 void ConvertMarkedToPolyObj();
345 // Align all marked objects vertically. Normally the SnapRect of an object is used.
346 void AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert);
347 bool IsAlignPossible() const;
349 // move marked objects "up"
350 void MovMarkedToTop();
352 // move marked objects "down"
353 void MovMarkedToBtm();
355 // move marked objects "at top"
356 void PutMarkedToTop();
358 // move marked objects "at bottom"
359 void PutMarkedToBtm();
361 // move marked immediately before the object passed
362 // NULL -> as PutMarkedToTop();
363 void PutMarkedInFrontOfObj(const SdrObject* pRefObj);
365 // move marked immediately after object passed
366 // NULL -> as PutMarkedToBtm();
367 void PutMarkedBehindObj(const SdrObject* pRefObj);
369 // swap Z-Order of marked objects
370 void ReverseOrderOfMarked();
372 // Check if forward, backward is possible.
373 // GetMaxToBtmObj() is only partly taken into account by these methods.
374 // Which means it can happen that IsToTopPossible() returns sal_True,
375 // but MovMarkedToTop() changes nothing (e.g. for multiple selections),
376 // as restriction derived via a view by GetMaxToTopObj() prevents this.
377 bool IsToTopPossible() const { ForcePossibilities(); return bToTopPossible; }
378 bool IsToBtmPossible() const { ForcePossibilities(); return bToBtmPossible; }
379 bool IsReverseOrderPossible() const { ForcePossibilities(); return bReverseOrderPossible; }
381 // Using this method the view determines how far an object
382 // can be moved forward or backward (Z-order).
383 // The object returned is not "obsolete". When NULL is
384 // returned there is not such a restriction.
385 virtual SdrObject* GetMaxToTopObj(SdrObject* pObj) const;
386 virtual SdrObject* GetMaxToBtmObj(SdrObject* pObj) const;
388 // Next method is called, if via ToTop, ToBtm, ... the
389 // sequence of object has been changed. It is called after
390 // each SdrObjList::SetObjectOrdNum(nOldPos,nNewPos);
391 virtual void ObjOrderChanged(SdrObject* pObj, sal_uIntPtr nOldPos, sal_uIntPtr nNewPos);
393 // If one or more objects of the type SdrGrafObj or SdrOle2Obj
394 // are marked and these are capable to deliver a StarView-metafile,
395 // this methods converts the metafile to a drawing object.
396 // The SdrGrafObjs/SdrOle2Objs are replaced by the new objects.
397 void DoImportMarkedMtf(SvdProgressInfo *pProgrInfo=nullptr);
398 bool IsImportMtfPossible() const { ForcePossibilities(); return bImportMtfPossible; }
400 // If the mode VirtualObjectBundling is switched on, all ToTop/ToBtm
401 // virtual objects which reference the same object, are contained
402 // in their Z-order (Writer).
403 // Default setting is sal_False=swithed off.
404 void SetVirtualObjectBundling(bool bOn) { bBundleVirtObj=bOn; }
406 // override SdrMarkView, for internal use
407 virtual void MarkListHasChanged() override;
408 virtual void ModelHasChanged() override;
411 #endif // INCLUDED_SVX_SVDEDTV_HXX
413 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */