update emoji autocorrect entries from po-files
[LibreOffice.git] / include / svx / svdedtv.hxx
blobcdc23088704a1108f3bc2a04a39d35e677286c66
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 SdrHorAlign {
37 SDRHALIGN_NONE,
38 SDRHALIGN_LEFT,
39 SDRHALIGN_RIGHT,
40 SDRHALIGN_CENTER
43 enum SdrVertAlign {
44 SDRVALIGN_NONE,
45 SDRVALIGN_TOP,
46 SDRVALIGN_BOTTOM,
47 SDRVALIGN_CENTER
50 enum SdrMergeMode {
51 SDR_MERGE_MERGE,
52 SDR_MERGE_SUBSTRACT,
53 SDR_MERGE_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 moveble nor turnable (Crook)
98 bool bContortionPossible : 1; // all polygones (grouped if neccessary)
99 bool bAllPolys : 1; // all polygones (not grouped)
100 bool bOneOrMorePolys : 1; // at least one polygon (not grouped)
101 bool bMoveAllowed : 1;
102 bool bResizeFreeAllowed : 1;
103 bool bResizePropAllowed : 1;
104 bool bRotateFreeAllowed : 1;
105 bool bRotate90Allowed : 1;
106 bool bMirrorFreeAllowed : 1;
107 bool bMirror45Allowed : 1;
108 bool bMirror90Allowed : 1;
109 bool bShearAllowed : 1;
110 bool bEdgeRadiusAllowed : 1;
111 bool bTransparenceAllowed : 1;
112 bool bCropAllowed : 1;
113 bool bGradientAllowed : 1;
114 bool bCanConvToPath : 1;
115 bool bCanConvToPoly : 1;
116 bool bCanConvToContour : 1;
117 bool bCanConvToPathLineToArea : 1;
118 bool bCanConvToPolyLineToArea : 1;
119 bool bMoveProtect : 1;
120 bool bResizeProtect : 1;
121 // maintain Z-order of the virtual objects (Writer)
122 bool bBundleVirtObj : 1;
124 private:
125 SVX_DLLPRIVATE void ImpClearVars();
126 SVX_DLLPRIVATE void ImpResetPossibilityFlags();
128 protected:
129 void ImpBroadcastEdgesOfMarkedNodes();
131 // convert the objects marked in poly resp. bezier
132 void ImpConvertTo(bool bPath, bool bLineToArea);
134 // converts an object, when positive it removes the old one from its List
135 // and inserts the new one instead. including Undo.
136 // Nor MarkEntry nor ModelChgBroadcast is created.
137 SdrObject* ImpConvertOneObj(SdrObject* pObj, bool bPath, bool bLineToArea);
139 // set both flags: bToTopPossible and bToBtmPossible.
140 // bToTopPossibleDirty and bToBtmPossibleDirty are reset at same time
141 void ImpCheckToTopBtmPossible();
143 // for CombineMarkedObjects and DismantleMarkedObjects
144 void ImpCopyAttributes(const SdrObject* pSource, SdrObject* pDest) const;
146 // for CombineMarkedObjects
147 static bool ImpCanConvertForCombine1(const SdrObject* pObj);
148 static bool ImpCanConvertForCombine(const SdrObject* pObj);
149 static basegfx::B2DPolyPolygon ImpGetPolyPolygon1(const SdrObject* pObj, bool bCombine);
150 static basegfx::B2DPolyPolygon ImpGetPolyPolygon(const SdrObject* pObj, bool bCombine);
151 static basegfx::B2DPolygon ImpCombineToSinglePolygon(const basegfx::B2DPolyPolygon& rPolyPolygon);
153 // for DismantleMarkedObjects
154 static bool ImpCanDismantle(const basegfx::B2DPolyPolygon& rPpolyPpolygon, bool bMakeLines);
155 static bool ImpCanDismantle(const SdrObject* pObj, bool bMakeLines);
156 void ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, size_t& rPos, SdrPageView* pPV, bool bMakeLines);
157 static void ImpCrookObj(SdrObject* pO, const Point& rRef, const Point& rRad, SdrCrookMode eMode,
158 bool bVertical, bool bNoContortion, bool bRotate, const Rectangle& rMarkRect);
159 static void ImpDistortObj(SdrObject* pO, const Rectangle& rRef, const XPolygon& rDistortedRect, bool bNoContortion);
160 bool ImpDelLayerCheck(SdrObjList* pOL, SdrLayerID nDelID) const;
161 void ImpDelLayerDelObjs(SdrObjList* pOL, SdrLayerID nDelID);
163 // Removes all objects of the MarkList from their ObjLists including Undo.
164 // The entries in rMark remain.
165 void DeleteMarkedList(const SdrMarkList& rMark); // DeleteMarked -> DeleteMarkedList
167 // Check possibilities of all marked objects
168 virtual void CheckPossibilities();
169 void ForcePossibilities() const { if (bPossibilitiesDirty || bSomeObjChgdFlag) const_cast<SdrEditView*>(this)->CheckPossibilities(); }
171 protected:
172 // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
173 SdrEditView(SdrModel* pModel1, OutputDevice* pOut = 0L);
174 virtual ~SdrEditView();
176 public:
177 // each call of an undo-capable method from its view, generates an undo action.
178 // If one wishes to group method calls into one, these calls should be put
179 // between BegUndo() and EndUndo() calls (unlimited).
180 // The comment used for the UndoAction is the first BegUndo(String).
181 // In this case NotifyNewUndoAction is called at the last EndUndo().
182 // NotifyNewUndoAction() is not called for an empty group.
183 void BegUndo() { pMod->BegUndo(); } // open undo-grouping
184 void BegUndo(const OUString& rComment) { pMod->BegUndo(rComment); } // open undo-grouping
185 void BegUndo(const OUString& rComment, const OUString& rObjDescr, SdrRepeatFunc eFunc=SDRREPFUNC_OBJ_NONE) { pMod->BegUndo(rComment,rObjDescr,eFunc); } // open undo-grouping
186 void EndUndo(); // close undo-grouping (incl. BroadcastEdges)
187 void AddUndo(SdrUndoAction* pUndo) { pMod->AddUndo(pUndo); } // add action
188 // only after first BegUndo or befor last EndUndo:
189 void SetUndoComment(const OUString& rComment) { pMod->SetUndoComment(rComment); }
190 void SetUndoComment(const OUString& rComment, const OUString& rObjDescr) { pMod->SetUndoComment(rComment,rObjDescr); }
191 bool IsUndoEnabled() const;
193 std::vector< SdrUndoAction* > CreateConnectorUndo( SdrObject& rO );
194 void AddUndoActions( std::vector< SdrUndoAction* >& );
196 // Layermanagement with Undo.
197 SdrLayer* InsertNewLayer(const OUString& rName, sal_uInt16 nPos=0xFFFF);
198 // Delete a layer including all objects contained
199 void DeleteLayer(const OUString& rName);
200 // Move a layer (change sequence of layers)
201 void MoveLayer(const OUString& rName, sal_uInt16 nNewPos);
203 // Marked objects which are outside a page
204 // are assigned to an other page; at the moment without undo!!!
205 void ForceMarkedObjToAnotherPage();
206 void ForceMarkedToAnotherPage() { ForceMarkedObjToAnotherPage(); }
208 bool IsReadOnly() const { ForcePossibilities(); return bReadOnly; }
210 // delete all marked objects
211 void DeleteMarkedObj();
212 bool IsDeleteMarkedObjPossible() const { ForcePossibilities(); return bDeletePossible; }
214 // Set a logical enclosing rectangle for all marked objects.
215 // It is not guaranteed if this succeeds, as a horizontal
216 // line has always a height of 0
217 void SetMarkedObjRect(const Rectangle& rRect, bool bCopy=false);
218 void MoveMarkedObj(const Size& rSiz, bool bCopy=false);
219 void ResizeMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy=false);
220 void ResizeMultMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, const bool bCopy, const bool bWdh, const bool bHgt);
221 long GetMarkedObjRotate() const;
222 void RotateMarkedObj(const Point& rRef, long nAngle, bool bCopy=false);
223 void MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool bCopy=false);
224 void MirrorMarkedObjHorizontal(bool bCopy=false);
225 void MirrorMarkedObjVertical(bool bCopy=false);
226 long GetMarkedObjShear() const;
227 void ShearMarkedObj(const Point& rRef, long nAngle, bool bVShear=false, bool bCopy=false);
228 void CrookMarkedObj(const Point& rRef, const Point& rRad, SdrCrookMode eMode, bool bVertical=false, bool bNoContortion=false, bool bCopy=false);
229 void DistortMarkedObj(const Rectangle& rRef, const XPolygon& rDistortedRect, bool bNoContortion=false, bool bCopy=false);
231 // copy marked objects and mark them instead of the old ones
232 void CopyMarkedObj();
233 void SetAllMarkedRect(const Rectangle& rRect, bool bCopy=false) { SetMarkedObjRect(rRect,bCopy); }
234 void MoveAllMarked(const Size& rSiz, bool bCopy=false) { MoveMarkedObj (rSiz,bCopy); }
235 void ResizeAllMarked(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy=false) { ResizeMarkedObj (rRef,xFact,yFact,bCopy); }
236 long GetAllMarkedRotate() const { return GetMarkedObjRotate(); }
237 void RotateAllMarked(const Point& rRef, long nAngle, bool bCopy=false) { RotateMarkedObj(rRef,nAngle,bCopy); }
238 void MirrorAllMarked(const Point& rRef1, const Point& rRef2, bool bCopy=false) { MirrorMarkedObj(rRef1,rRef2,bCopy); }
239 void MirrorAllMarkedHorizontal(bool bCopy=false) { MirrorMarkedObjHorizontal(bCopy); }
240 void MirrorAllMarkedVertical(bool bCopy=false) { MirrorMarkedObjVertical(bCopy); }
241 long GetAllMarkedShear() const { return GetMarkedObjShear(); }
242 void ShearAllMarked(const Point& rRef, long nAngle, bool bVShear=false, bool bCopy=false) { ShearMarkedObj(rRef,nAngle,bVShear,bCopy); }
243 void CrookAllMarked(const Point& rRef, const Point& rRad, SdrCrookMode eMode, bool bVertical=false, bool bNoContortion=false, bool bCopy=false) { CrookMarkedObj(rRef,rRad,eMode,bVertical,bNoContortion,bCopy); }
244 void CopyMarked() { CopyMarkedObj(); }
245 bool IsMoveAllowed() const { ForcePossibilities(); return bMoveAllowed && !bMoveProtect; }
246 bool IsResizeAllowed(bool bProp=false) const;
247 bool IsRotateAllowed(bool b90Deg=false) const;
248 bool IsMirrorAllowed(bool b45Deg=false, bool b90Deg=false) const;
249 bool IsTransparenceAllowed() const;
250 bool IsGradientAllowed() const;
251 bool IsShearAllowed() const;
252 bool IsEdgeRadiusAllowed() const;
253 bool IsCrookAllowed(bool bNoContortion=false) const;
254 bool IsCropAllowed() const;
255 bool IsDistortAllowed(bool bNoContortion=false) const;
257 // Unite several objects to a polygon:
258 // - rectangles/circles/text... are implicite converted.
259 // - polygones are closed automatically
260 // - attributes and layer are taken from the first object marked
261 // (thus from lowest Z-order).
262 // - group objects are included when all (!) member objects of
263 // the group can be changed. If a group includes for example
264 // a bitmap or an OLE-object, the complete group is not considered.
265 // bNoPolyPoly=TRUE: all is grouped to one single polygon
266 void CombineMarkedObjects(bool bNoPolyPoly = true);
268 // for combining multiple polygons, with direct support of the modes
269 // SID_POLY_MERGE, SID_POLY_SUBSTRACT, SID_POLY_INTERSECT
270 void MergeMarkedObjects(SdrMergeMode eMode);
272 // for distribution dialog function
273 void DistributeMarkedObjects();
275 // Decompose marked polypolygon objects into polygons.
276 // Grouped objects are searched and decomposed, if all member objects are PathObjs.
277 // bMakeLines=TRUE: all polygones are decomposed into single lines resp. bezier segments
278 void DismantleMarkedObjects(bool bMakeLines=false);
279 bool IsCombinePossible(bool bNoPolyPoly=false) const;
280 bool IsDismantlePossible(bool bMakeLines=false) const;
282 // Inserts a new, completely constructed object. Subsequently the object belongs to
283 // the model. After insertion the object is marked (if not prevented by nOptions).
284 // Sometimes the object is not inserted, but deleted, this is the case when
285 // the target layer is locked or not visible. In this case
286 // the method returns FALSE.
287 // Amongst others the method does not create an undo-action.
288 bool InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE);
290 // Replace one drawing object by another.
291 // *pNewObj belongs to me, *pOldObj is changed into Undo.
292 // In any case an undo grouping is required and should be applied, e.g.:
293 // aStr+=" replace";
294 // BegUndo(aStr);
295 // ReplaceObject(...);
297 // EndUndo();
298 void ReplaceObjectAtView(SdrObject* pOldObj, SdrPageView& rPV, SdrObject* pNewObj, bool bMark=true);
300 void SetNotPersistAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll);
301 void MergeNotPersistAttrFromMarked(SfxItemSet& rAttr, bool bOnlyHardAttr) const;
302 void MergeAttrFromMarked(SfxItemSet& rAttr, bool bOnlyHardAttr) const;
303 SfxItemSet GetAttrFromMarked(bool bOnlyHardAttr) const;
304 void SetAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll);
306 // geometrical attribute (position, size, rotation angle)
307 // A PageOrigin set at a position is taken into account.
308 SfxItemSet GetGeoAttrFromMarked() const;
309 void SetGeoAttrToMarked(const SfxItemSet& rAttr);
311 // Returns NULL if:
312 // - nothing is marked,
313 // - no stylesheet is set at the marked object
314 // - point the marked objects to different StyleSheets for multiple selections
315 SfxStyleSheet* GetStyleSheetFromMarked() const;
317 // at the moment without undo :(
318 void SetStyleSheetToMarked(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr);
320 /* new interface src537 */
321 bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const;
323 bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
324 SfxStyleSheet* GetStyleSheet() const; // SfxStyleSheet* GetStyleSheet(bool& rOk) const;
325 bool SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr);
327 // Group all marked objects to a single group.
328 // Subsequently mark the new group . If the group spawns multiple
329 // pages a group is created per page.
330 // All groups created are subsequently marked.
331 // Using pUserGrp an own group object can be set.
332 // This is not used immediately, but via Clone copied.
333 // The method creates SdrObjGroup-instancess if NULL is passed,
334 void GroupMarked(const SdrObject* pUserGrp=NULL);
336 // All marked object groups are dissolved (1 level).
337 // Now all previously marked member objects are marked.
338 // Previously marked objects, which are not group objects, remain marked.
339 void UnGroupMarked();
341 bool IsGroupPossible() const { ForcePossibilities(); return bGroupPossible; }
342 bool IsUnGroupPossible() const { ForcePossibilities(); return bUnGroupPossible; }
343 bool IsGroupEnterPossible() const { ForcePossibilities(); return bGrpEnterPossible; }
345 // Convert marked objects to polygones/Beziercurves. The bool-functions
346 // return sal_True, if at least one marked object could be converted.
347 // Also member objects of group objects are converted.
348 // For a better description see: SdrObj.HXX
349 bool IsConvertToPathObjPossible(bool bLineToArea) const { ForcePossibilities(); return bLineToArea ? bCanConvToPathLineToArea : bCanConvToPath; }
350 bool IsConvertToPolyObjPossible(bool bLineToArea) const { ForcePossibilities(); return bLineToArea ? bCanConvToPolyLineToArea : bCanConvToPoly; }
351 bool IsConvertToContourPossible() const { ForcePossibilities(); return bCanConvToContour; }
352 void ConvertMarkedToPathObj(bool bLineToArea);
353 void ConvertMarkedToPolyObj(bool bLineToArea);
355 // Align all marked objects vertically. Normally the SnapRect of an object is used.
356 // If bBoundRects=sal_True then BoundRects is used instead of SnapRect.
357 void AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert, bool bBoundRects=false);
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 bToTopPossible; }
389 bool IsToBtmPossible() const { ForcePossibilities(); return bToBtmPossible; }
390 bool IsReverseOrderPossible() const { ForcePossibilities(); return 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, sal_uIntPtr nOldPos, sal_uIntPtr 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=NULL);
409 bool IsImportMtfPossible() const { ForcePossibilities(); return bImportMtfPossible; }
411 // If the mode VirtualObjectBundling is switched on, all ToTop/ToBtm
412 // virtual objects which reference the same object, are contained
413 // in their Z-order (Writer).
414 // Default setting is sal_False=swithed off.
415 void SetVirtualObjectBundling(bool bOn) { bBundleVirtObj=bOn; }
416 bool IsVirtualObjectBundling() const { return bBundleVirtObj; }
418 // override SdrMarkView, for internal use
419 virtual void MarkListHasChanged() SAL_OVERRIDE;
420 virtual void ModelHasChanged() SAL_OVERRIDE;
423 #endif // INCLUDED_SVX_SVDEDTV_HXX
425 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */