tdf#151073 - enable firebird for appstore build w/o experimental mode
[LibreOffice.git] / include / svx / svdedtv.hxx
blob1a6ba389715227b365182c1edd92098093f02a9f
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 <svx/svdundo.hxx>
28 #include <o3tl/typed_flags_set.hxx>
30 class SfxUndoAction;
31 class SdrUndoAction;
32 class SdrUndoGroup;
33 class SfxStyleSheet;
34 class SdrLayer;
35 class SvdProgressInfo;
37 enum class SdrHorAlign {
38 NONE,
39 Left,
40 Right,
41 Center
44 enum class SdrVertAlign {
45 NONE,
46 Top,
47 Bottom,
48 Center
51 enum class SdrMergeMode {
52 Merge,
53 Subtract,
54 Intersect
57 // Options for InsertObject()
58 enum class SdrInsertFlags
60 NONE = 0x0000,
61 DONTMARK = 0x0001, /* object will not be marked (the actual marking remains) */
62 ADDMARK = 0x0002, /* object will be added an existing selection */
63 SETDEFATTR = 0x0004, /* actual attributes (+StyleSheet) are assigned to the object */
64 SETDEFLAYER = 0x0008, /* actual layer is assigned to the object */
66 namespace o3tl
68 template<> struct typed_flags<SdrInsertFlags> : is_typed_flags<SdrInsertFlags, 0x0f> {};
71 class SVXCORE_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 m_bPossibilitiesDirty : 1;
81 bool m_bReadOnly : 1;
82 bool m_bGroupPossible : 1;
83 bool m_bUnGroupPossible : 1;
84 bool m_bGrpEnterPossible : 1;
85 bool m_bToTopPossible : 1;
86 bool m_bToBtmPossible : 1;
87 bool m_bReverseOrderPossible : 1;
88 bool m_bImportMtfPossible : 1;
89 bool m_bCombinePossible : 1;
90 bool m_bDismantlePossible : 1;
91 bool m_bCombineNoPolyPolyPossible : 1;
92 bool m_bDismantleMakeLinesPossible : 1;
93 bool m_bOrthoDesiredOnMarked : 1;
94 bool m_bOneOrMoreMovable : 1; // at least one object is moveable
95 bool m_bMoreThanOneNoMovRot : 1; // more than one object is not movable nor turnable (Crook)
96 bool m_bContortionPossible : 1; // all polygones (grouped if necessary)
97 bool m_bMoveAllowed : 1;
98 bool m_bResizeFreeAllowed : 1;
99 bool m_bResizePropAllowed : 1;
100 bool m_bRotateFreeAllowed : 1;
101 bool m_bRotate90Allowed : 1;
102 bool m_bMirrorFreeAllowed : 1;
103 bool m_bMirror45Allowed : 1;
104 bool m_bMirror90Allowed : 1;
105 bool m_bShearAllowed : 1;
106 bool m_bEdgeRadiusAllowed : 1;
107 bool m_bTransparenceAllowed : 1;
108 bool m_bCropAllowed : 1;
109 bool m_bGradientAllowed : 1;
110 bool m_bCanConvToPath : 1;
111 bool m_bCanConvToPoly : 1;
112 bool m_bCanConvToContour : 1;
113 bool m_bMoveProtect : 1;
114 bool m_bResizeProtect : 1;
116 private:
117 SVX_DLLPRIVATE void ImpResetPossibilityFlags();
119 protected:
120 void ImpBroadcastEdgesOfMarkedNodes();
122 // convert the objects marked in poly resp. bezier
123 void ImpConvertTo(bool bPath, bool bLineToArea);
125 // converts an object, when positive it removes the old one from its List
126 // and inserts the new one instead. including Undo.
127 // Nor MarkEntry nor ModelChgBroadcast is created.
128 rtl::Reference<SdrObject> ImpConvertOneObj(SdrObject* pObj, bool bPath, bool bLineToArea);
130 // set both flags: bToTopPossible and bToBtmPossible.
131 // bToTopPossibleDirty and bToBtmPossibleDirty are reset at the same time
132 void ImpCheckToTopBtmPossible();
134 // for CombineMarkedObjects and DismantleMarkedObjects
135 void ImpCopyAttributes(const SdrObject* pSource, SdrObject* pDest) const;
137 // for CombineMarkedObjects
138 static bool ImpCanConvertForCombine1(const SdrObject* pObj);
139 static bool ImpCanConvertForCombine(const SdrObject* pObj);
140 static basegfx::B2DPolyPolygon ImpGetPolyPolygon1(const SdrObject* pObj);
141 static basegfx::B2DPolyPolygon ImpGetPolyPolygon(const SdrObject* pObj);
142 static basegfx::B2DPolygon ImpCombineToSinglePolygon(const basegfx::B2DPolyPolygon& rPolyPolygon);
144 // for DismantleMarkedObjects
145 static bool ImpCanDismantle(const basegfx::B2DPolyPolygon& rPpolyPpolygon, bool bMakeLines);
146 static bool ImpCanDismantle(const SdrObject* pObj, bool bMakeLines);
147 void ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, size_t& rPos, SdrPageView* pPV, bool bMakeLines);
148 static void ImpCrookObj(SdrObject* pO, const Point& rRef, const Point& rRad, SdrCrookMode eMode,
149 bool bVertical, bool bNoContortion, bool bRotate, const tools::Rectangle& rMarkRect);
150 static void ImpDistortObj(SdrObject* pO, const tools::Rectangle& rRef, const XPolygon& rDistortedRect, bool bNoContortion);
151 bool ImpDelLayerCheck(SdrObjList const * pOL, SdrLayerID nDelID) const;
152 void ImpDelLayerDelObjs(SdrObjList* pOL, SdrLayerID nDelID);
154 // Removes all objects of the MarkList from their ObjLists including Undo.
155 // The entries in rMark remain.
156 // @return a list of objects that must be deleted after the outermost EndUndo
157 std::vector<SdrObject *> DeleteMarkedList(SdrMarkList const& rMark); // DeleteMarked -> DeleteMarkedList
159 // Check possibilities of all marked objects
160 virtual void CheckPossibilities();
161 void ForcePossibilities() const { if (m_bPossibilitiesDirty || mbSomeObjChgdFlag) const_cast<SdrEditView*>(this)->CheckPossibilities(); }
163 protected:
164 // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
165 SdrEditView(
166 SdrModel& rSdrModel,
167 OutputDevice* pOut);
169 virtual ~SdrEditView() override;
171 public:
172 // each call of an undo-capable method from its view, generates an undo action.
173 // If one wishes to group method calls into one, these calls should be put
174 // between BegUndo() and EndUndo() calls (unlimited).
175 // The comment used for the UndoAction is the first BegUndo(String).
176 // In this case NotifyNewUndoAction is called at the last EndUndo().
177 // NotifyNewUndoAction() is not called for an empty group.
178 void BegUndo() { mpModel->BegUndo(); } // open undo-grouping
179 void BegUndo(const OUString& rComment) { mpModel->BegUndo(rComment); } // open undo-grouping
180 void BegUndo(const OUString& rComment, const OUString& rObjDescr, SdrRepeatFunc eFunc=SdrRepeatFunc::NONE) { mpModel->BegUndo(rComment,rObjDescr,eFunc); } // open undo-grouping
181 void EndUndo(); // close undo-grouping (incl. BroadcastEdges)
182 void AddUndo(std::unique_ptr<SdrUndoAction> pUndo) { mpModel->AddUndo(std::move(pUndo)); } // add action
183 // only after first BegUndo or before last EndUndo:
184 void SetUndoComment(const OUString& rComment, const OUString& rObjDescr) { mpModel->SetUndoComment(rComment,rObjDescr); }
185 bool IsUndoEnabled() const;
188 * Checks if this or other views have an active text edit, if true, end them.
190 void EndTextEditAllViews() const;
191 void EndTextEditCurrentView(bool bDontDeleteReally = false);
193 std::vector< std::unique_ptr<SdrUndoAction> > CreateConnectorUndo( const SdrObject& rO );
194 void AddUndoActions( std::vector< std::unique_ptr<SdrUndoAction> > );
196 // Layermanagement with Undo.
197 void InsertNewLayer(const OUString& rName, sal_uInt16 nPos);
198 // Delete a layer including all objects contained
199 void DeleteLayer(const OUString& rName);
201 // Marked objects which are outside a page
202 // are assigned to another page; at the moment without undo!!!
203 void ForceMarkedObjToAnotherPage();
204 void ForceMarkedToAnotherPage() { ForceMarkedObjToAnotherPage(); }
206 // delete all marked objects
207 void DeleteMarkedObj();
209 // Set a logical enclosing rectangle for all marked objects.
210 // It is not guaranteed if this succeeds, as a horizontal
211 // line has always a height of 0
212 void SetMarkedObjRect(const tools::Rectangle& rRect);
213 void MoveMarkedObj(const Size& rSiz, bool bCopy=false);
214 void ResizeMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy=false);
215 void ResizeMultMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, const bool bWdh, const bool bHgt);
216 Degree100 GetMarkedObjRotate() const;
217 void RotateMarkedObj(const Point& rRef, Degree100 nAngle, bool bCopy=false);
218 void MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool bCopy=false);
219 void MirrorMarkedObjHorizontal();
220 void MirrorMarkedObjVertical();
221 Degree100 GetMarkedObjShear() const;
222 void ShearMarkedObj(const Point& rRef, Degree100 nAngle, bool bVShear=false, bool bCopy=false);
223 void CrookMarkedObj(const Point& rRef, const Point& rRad, SdrCrookMode eMode, bool bVertical, bool bNoContortion, bool bCopy=false);
224 void DistortMarkedObj(const tools::Rectangle& rRef, const XPolygon& rDistortedRect, bool bNoContortion, bool bCopy=false);
226 // copy marked objects and mark them instead of the old ones
227 void CopyMarkedObj();
228 void SetAllMarkedRect(const tools::Rectangle& rRect) { SetMarkedObjRect(rRect); }
229 void MoveAllMarked(const Size& rSiz, bool bCopy=false) { MoveMarkedObj(rSiz,bCopy); }
230 void ResizeAllMarked(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { ResizeMarkedObj(rRef,xFact,yFact); }
231 void RotateAllMarked(const Point& rRef, Degree100 nAngle) { RotateMarkedObj(rRef,nAngle); }
232 void MirrorAllMarkedHorizontal() { MirrorMarkedObjHorizontal(); }
233 void MirrorAllMarkedVertical() { MirrorMarkedObjVertical(); }
234 void CopyMarked() { CopyMarkedObj(); }
235 bool IsMoveAllowed() const { ForcePossibilities(); return m_bMoveAllowed && !m_bMoveProtect; }
236 bool IsResizeAllowed(bool bProp=false) const;
237 bool IsRotateAllowed(bool b90Deg=false) const;
238 bool IsMirrorAllowed(bool b45Deg=false, bool b90Deg=false) const;
239 bool IsTransparenceAllowed() const;
240 bool IsGradientAllowed() const;
241 bool IsShearAllowed() const;
242 bool IsEdgeRadiusAllowed() const;
243 bool IsCrookAllowed(bool bNoContortion=false) const;
244 bool IsCropAllowed() const;
245 bool IsDistortAllowed(bool bNoContortion=false) const;
247 // Consolidate the text from multiple, selected TextObjects,
248 // attempting to identify paragraph fragments and join them together
249 void CombineMarkedTextObjects();
251 // Unite several objects to a polygon:
252 // - rectangles/circles/text... are implicitly converted.
253 // - polygones are closed automatically
254 // - attributes and layer are taken from the first object marked
255 // (thus from lowest Z-order).
256 // - group objects are included when all (!) member objects of
257 // the group can be changed. If a group includes for example
258 // a bitmap or an OLE-object, the complete group is not considered.
259 // bNoPolyPoly=TRUE: all is grouped to one single polygon
260 void CombineMarkedObjects(bool bNoPolyPoly = true);
262 // for combining multiple polygons, with direct support of the modes
263 // SID_POLY_MERGE, SID_POLY_SUBSTRACT, SID_POLY_INTERSECT
264 void MergeMarkedObjects(SdrMergeMode eMode);
266 // for distribution dialog function
267 void DistributeMarkedObjects(sal_uInt16 SlotID);
269 // for setting either the width or height of all selected
270 // objects to the width/height of the last selected object
271 // of the selection
272 void EqualizeMarkedObjects(bool bWidth);
274 // Decompose marked polypolygon objects into polygons.
275 // Grouped objects are searched and decomposed, if all member objects are PathObjs.
276 // bMakeLines=TRUE: all polygones are decomposed into single lines resp. bezier segments
277 void DismantleMarkedObjects(bool bMakeLines=false);
278 bool IsCombinePossible(bool bNoPolyPoly=false) const;
279 bool IsDismantlePossible(bool bMakeLines=false) const;
281 // Inserts a new, completely constructed object. Subsequently the object belongs to
282 // the model. After insertion the object is marked (if not prevented by nOptions).
283 // Sometimes the object is not inserted, but deleted, this is the case when
284 // the target layer is locked or not visible. In this case
285 // the method returns FALSE.
286 // Amongst others the method does not create an undo-action.
287 bool InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE);
289 // Replace one drawing object by another.
290 // *pNewObj belongs to me, *pOldObj is changed into Undo.
291 // In any case an undo grouping is required and should be applied, e.g.:
292 // aStr+=" replace";
293 // BegUndo(aStr);
294 // ReplaceObject(...);
296 // EndUndo();
297 void ReplaceObjectAtView(SdrObject* pOldObj, SdrPageView& rPV, SdrObject* pNewObj, bool bMark=true);
299 void SetNotPersistAttrToMarked(const SfxItemSet& rAttr);
300 void MergeNotPersistAttrFromMarked(SfxItemSet& rAttr) const;
301 void MergeAttrFromMarked(SfxItemSet& rAttr, bool bOnlyHardAttr) const;
302 SfxItemSet GetAttrFromMarked(bool bOnlyHardAttr) const;
303 void SetAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll);
305 // geometrical attribute (position, size, rotation angle)
306 // A PageOrigin set at a position is taken into account.
307 SfxItemSet GetGeoAttrFromMarked() const;
308 // In LOK, interactive shape movement uses this function
309 // in that case, margin is not taken into account
310 // and the final position of the shape becomes incorrect
311 // However, "Position and Size" dialog and other cases already add the margins.
312 void SetGeoAttrToMarked(const SfxItemSet& rAttr, bool addPageMargin = false);
314 // Returns NULL if:
315 // - nothing is marked,
316 // - no stylesheet is set at the marked object
317 // - point the marked objects to different StyleSheets for multiple selections
318 SfxStyleSheet* GetStyleSheetFromMarked() const;
320 // at the moment without undo :(
321 void SetStyleSheetToMarked(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr);
323 /* new interface src537 */
324 void GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const;
326 void SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
327 SfxStyleSheet* GetStyleSheet() const; // SfxStyleSheet* GetStyleSheet(bool& rOk) const;
328 void SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr);
330 // Group all marked objects to a single group.
331 // Subsequently mark the new group . If the group spawns multiple
332 // pages a group is created per page.
333 // All groups created are subsequently marked.
334 // The method creates SdrObjGroup-instances.
335 void GroupMarked();
337 // All marked object groups are dissolved (1 level).
338 // Now all previously marked member objects are marked.
339 // Previously marked objects, which are not group objects, remain marked.
340 void UnGroupMarked();
342 bool IsGroupPossible() const { ForcePossibilities(); return m_bGroupPossible; }
343 bool IsUnGroupPossible() const { ForcePossibilities(); return m_bUnGroupPossible; }
344 bool IsGroupEnterPossible() const { ForcePossibilities(); return m_bGrpEnterPossible; }
346 // Convert marked objects to polygones/Beziercurves. The bool-functions
347 // return sal_True, if at least one marked object could be converted.
348 // Also member objects of group objects are converted.
349 // For a better description see: SdrObj.HXX
350 bool IsConvertToPathObjPossible() const { ForcePossibilities(); return m_bCanConvToPath; }
351 bool IsConvertToPolyObjPossible() const { ForcePossibilities(); return m_bCanConvToPoly; }
352 bool IsConvertToContourPossible() const { ForcePossibilities(); return m_bCanConvToContour; }
353 void ConvertMarkedToPathObj(bool bLineToArea);
354 void ConvertMarkedToPolyObj();
356 // Align all marked objects vertically. Normally the SnapRect of an object is used.
357 void AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert);
358 bool IsAlignPossible() const;
360 // move marked objects "up"
361 void MovMarkedToTop();
363 // move marked objects "down"
364 void MovMarkedToBtm();
366 // move marked objects "at top"
367 void PutMarkedToTop();
369 // move marked objects "at bottom"
370 void PutMarkedToBtm();
372 // move marked immediately before the object passed
373 // NULL -> as PutMarkedToTop();
374 void PutMarkedInFrontOfObj(const SdrObject* pRefObj);
376 // move marked immediately after object passed
377 // NULL -> as PutMarkedToBtm();
378 void PutMarkedBehindObj(const SdrObject* pRefObj);
380 // swap Z-Order of marked objects
381 void ReverseOrderOfMarked();
383 // Check if forward, backward is possible.
384 // GetMaxToBtmObj() is only partly taken into account by these methods.
385 // Which means it can happen that IsToTopPossible() returns sal_True,
386 // but MovMarkedToTop() changes nothing (e.g. for multiple selections),
387 // as restriction derived via a view by GetMaxToTopObj() prevents this.
388 bool IsToTopPossible() const { ForcePossibilities(); return m_bToTopPossible; }
389 bool IsToBtmPossible() const { ForcePossibilities(); return m_bToBtmPossible; }
390 bool IsReverseOrderPossible() const { ForcePossibilities(); return m_bReverseOrderPossible; }
392 // Using this method the view determines how far an object
393 // can be moved forward or backward (Z-order).
394 // The object returned is not "obsolete". When NULL is
395 // returned there is not such a restriction.
396 virtual SdrObject* GetMaxToTopObj(SdrObject* pObj) const;
397 virtual SdrObject* GetMaxToBtmObj(SdrObject* pObj) const;
399 // Next method is called, if via ToTop, ToBtm, ... the
400 // sequence of object has been changed. It is called after
401 // each SdrObjList::SetObjectOrdNum(nOldPos,nNewPos);
402 virtual void ObjOrderChanged(SdrObject* pObj, size_t nOldPos, size_t nNewPos);
404 // If one or more objects of the type SdrGrafObj or SdrOle2Obj
405 // are marked and these are capable to deliver a StarView-metafile,
406 // this methods converts the metafile to a drawing object.
407 // The SdrGrafObjs/SdrOle2Objs are replaced by the new objects.
408 void DoImportMarkedMtf(SvdProgressInfo *pProgrInfo=nullptr);
409 bool IsImportMtfPossible() const { ForcePossibilities(); return m_bImportMtfPossible; }
411 // override SdrMarkView, for internal use
412 virtual void MarkListHasChanged() override;
413 virtual void ModelHasChanged() override;
416 #endif // INCLUDED_SVX_SVDEDTV_HXX
418 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */