LibreOffice Module svx (master)  1
svdoashp.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
22 #include <svx/svdobj.hxx>
23 #include <svx/svdotext.hxx>
24 #include <svx/svdhdl.hxx>
25 #include <vector>
26 #include <com/sun/star/uno/Reference.h>
27 #include <com/sun/star/drawing/XCustomShapeEngine.hpp>
28 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
29 #include <svx/svxdllapi.h>
30 #include <o3tl/typed_flags_set.hxx>
31 
32 namespace sdr
33 {
34  namespace properties
35  {
36  class CustomShapeProperties;
37  }
38 }
39 
41 {
42 public:
43  bool bMirroredX;
44  bool bMirroredY;
46 
47  css::uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq;
48 };
49 
51 {
52  NONE = 0,
53  RESIZE_FIXED = 1,
54  CREATE_FIXED = 2,
57  MOVE_SHAPE = 16,
58  ORTHO4 = 32,
60 };
61 
62 namespace o3tl
63 {
64  template<> struct typed_flags<CustomShapeHandleModes> : is_typed_flags<CustomShapeHandleModes, 127> {};
65 }
66 
68 {
69  css::uno::Reference< css::drawing::XCustomShapeHandle > xInteraction;
70  css::awt::Point aPosition;
72 };
73 
75 {
76 private:
77  // fObjectRotation is containing the object rotation in degrees.
80 
81 protected:
82  virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
83  virtual void setUnoShape(const css::uno::Reference<css::drawing::XShape>& rxUnoShape) override;
84 
85 public:
86  virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
87 
88  // to allow sdr::properties::CustomShapeProperties access
90 
91  css::uno::Reference< css::drawing::XShape > mXRenderedCustomShape;
92 
93  mutable css::uno::Reference< css::drawing::XCustomShapeEngine > mxCustomShapeEngine;
94 
95  // #i37011# render geometry shadow
97 
98  css::uno::Reference< css::drawing::XCustomShapeEngine > const & GetCustomShapeEngine() const;
99 
100  std::vector< SdrCustomShapeInteraction > GetInteractionHandles() const; // needed in unit test
101  SVX_DLLPRIVATE void DragCreateObject( SdrDragStat& rDrag );
102  SVX_DLLPRIVATE void DragResizeCustomShape( const tools::Rectangle& rNewRect );
103  void DragMoveCustomShapeHdl( const Point& rDestination,
104  const sal_uInt16 nCustomShapeHdlNum, bool bMoveCalloutRectangle ); // needed in unit test
105 
106  // #i37011# centralize throw-away of render geometry
107  void InvalidateRenderGeometry();
108 
109  // #i38892#
110  void ImpCheckCustomGluePointsAreAdded();
111 
112  // returns the new text rect that corresponds to the current logic rect, the return value can be empty if nothing changed.
113  tools::Rectangle ImpCalculateTextFrame( const bool bHgt, const bool bWdt );
114 
115 public:
116  // #i37011#
117  const SdrObject* GetSdrObjectFromCustomShape() const;
118  const SdrObject* GetSdrObjectShadowFromCustomShape() const;
119  bool GetTextBounds( tools::Rectangle& rTextBound ) const;
120  bool IsTextPath() const;
121  basegfx::B2DPolyPolygon GetLineGeometry( const bool bBezierAllowed ) const;
122 
123 protected:
124  // #115391# new method for SdrObjCustomShape and SdrTextObj to correctly handle and set
125  // SdrTextMinFrameWidthItem and SdrTextMinFrameHeightItem based on all settings, necessities
126  // and object sizes
127  virtual void AdaptTextMinSize() override;
128 
130 
131  // protected destructor
132  virtual ~SdrObjCustomShape() override;
133 
134  virtual void InternalSetStyleSheet( SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr, bool bBroadcast ) override;
135 
136 public:
137  bool UseNoFillStyle() const;
138 
139  bool IsMirroredX() const;
140  bool IsMirroredY() const;
141  void SetMirroredX( const bool bMirroredX );
142  void SetMirroredY( const bool bMirroredY );
143 
144  double GetObjectRotation() const { return fObjectRotation;}
145  double GetExtraTextRotation( const bool bPreRotation = false ) const;
146 
147  SdrObjCustomShape(SdrModel& rSdrModel);
148  SdrObjCustomShape(SdrModel& rSdrModel, SdrObjCustomShape const & rSource);
149 
150  /* is merging default attributes from type-shape into the SdrCustomShapeGeometryItem. If pType
151  is NULL then the type is being taken from the "Type" property of the SdrCustomShapeGeometryItem.
152  MergeDefaultAttributes is called when creating CustomShapes via UI and after importing */
153  void MergeDefaultAttributes( const OUString* pType = nullptr );
154 
155  /* the method is checking if the geometry data is unchanged/default, in this case the data might not be stored */
156  enum class DefaultType
157  {
158  Path,
159  Viewbox,
160  Segments,
161  Gluepoints,
162  StretchX,
163  StretchY,
164  Equations,
165  TextFrames
166  };
167  bool IsDefaultGeometry( const DefaultType eDefaultType ) const;
168 
169  virtual SdrObjKind GetObjIdentifier() const override;
170  virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
171 
172  virtual void Move(const Size& rSiz) override;
173  virtual void Shear(const Point& rRef, Degree100 nAngle, double tn, bool bVShear) override;
174  virtual void SetSnapRect(const tools::Rectangle& rRect) override;
175  virtual void SetLogicRect(const tools::Rectangle& rRect) override;
176  virtual void AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override;
177 
178  virtual void NbcMove(const Size& rSiz) override;
179  virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
180  virtual void NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) override;
181  virtual void NbcMirror(const Point& rRef1, const Point& rRef2) override;
182  virtual void NbcShear(const Point& rRef, Degree100 nAngle, double tn, bool bVShear) override;
183  virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
184  virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
185 
186  virtual SdrGluePoint GetVertexGluePoint(sal_uInt16 nNum) const override;
187 
188  // special drag methods
189  virtual bool hasSpecialDrag() const override;
190  virtual bool beginSpecialDrag(SdrDragStat& rDrag) const override;
191  virtual bool applySpecialDrag(SdrDragStat& rDrag) override;
192 
193  virtual bool MovCreate(SdrDragStat& rStat) override; // #i37448#
194  virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
195 
201  void SuggestTextFrameSize(Size aSuggestedTextFrameSize);
202  virtual bool AdjustTextFrameWidthAndHeight(tools::Rectangle& rR, bool bHgt = true, bool bWdt = true) const override;
203  virtual bool NbcAdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = true) override;
204  virtual bool AdjustTextFrameWidthAndHeight() override;
205  virtual bool IsAutoGrowHeight() const override;
206  virtual bool IsAutoGrowWidth() const override;
207  virtual void SetVerticalWriting(bool bVertical) override;
208  virtual void TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, tools::Rectangle* pViewInit, tools::Rectangle* pViewMin) const override;
209  virtual void EndTextEdit( SdrOutliner& rOutl ) override;
210  virtual void TakeTextAnchorRect( tools::Rectangle& rAnchorRect ) const override;
211  virtual void TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText,
212  tools::Rectangle* pAnchorRect, bool bLineWidth = true ) const override;
213  virtual SdrObjCustomShape* CloneSdrObject(SdrModel& rTargetModel) const override;
214 
215  virtual OUString TakeObjNameSingul() const override;
216  virtual OUString TakeObjNamePlural() const override;
217 
218  virtual basegfx::B2DPolyPolygon TakeCreatePoly( const SdrDragStat& rDrag) const override;
219 
220  virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
221  virtual basegfx::B2DPolyPolygon TakeContour() const override;
222 
223  virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject) override;
224 
225  virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
226 
227  // react on model/page change
228  virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;
229 
230  virtual std::unique_ptr<SdrObjGeoData> NewGeoData() const override;
231  virtual void SaveGeoData(SdrObjGeoData &rGeo) const override;
232  virtual void RestoreGeoData(const SdrObjGeoData &rGeo) override;
233 
234  // need to take fObjectRotation instead of aGeo.nAngle, replace it temporary
235  virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const override;
236  virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon) override;
237 
238  virtual const SdrGluePointList* GetGluePointList() const override;
239  //virtual SdrGluePointList* GetGluePointList();
240  virtual SdrGluePointList* ForceGluePointList() override;
241 
242  virtual sal_uInt32 GetHdlCount() const override;
243  virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
244 
245  // #i33136#
246  static bool doConstructOrthogonal(std::u16string_view rName);
247 
249 
250  OUString GetCustomShapeName() const;
251 };
252 
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void Shear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear)
Definition: svdobj.cxx:1599
virtual void NbcSetOutlinerParaObject(std::optional< OutlinerParaObject > pTextObject) override
Definition: svdotext.cxx:1339
virtual bool IsAutoGrowHeight() const
Definition: svdotext.cxx:304
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: svdotxtr.cxx:102
virtual bool NbcAdjustTextFrameWidthAndHeight(bool bHgt=true, bool bWdt=true)
Definition: svdotxat.cxx:241
virtual SdrObjKind GetObjIdentifier() const override
Definition: svdotext.cxx:463
virtual void TakeTextEditArea(Size *pPaperMin, Size *pPaperMax, tools::Rectangle *pViewInit, tools::Rectangle *pViewMin) const
Definition: svdotxed.cxx:131
virtual sal_uInt32 GetHdlCount() const override
Via GetHdlCount the number of Handles can be retrieved.
Definition: svdotxdr.cxx:36
virtual OUString TakeObjNameSingul() const override
Definition: svdotext.cxx:994
virtual bool hasSpecialDrag() const override
The standard transformations (Move,Resize,Rotate,Mirror,Shear) are taken over by the View (TakeXorPol...
Definition: svdotxdr.cxx:67
virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix &rMatrix, const basegfx::B2DPolyPolygon &rPolyPolygon) override
Definition: svdotext.cxx:1607
All geometrical data of an arbitrary object for use in undo/redo.
Definition: svdobj.hxx:174
virtual void EndTextEdit(SdrOutliner &rOutl)
Definition: svdotxed.cxx:264
virtual void NbcMirror(const Point &rRef1, const Point &rRef2) override
Definition: svdotxtr.cxx:232
SdrObjKind
Definition: svdobjkind.hxx:24
Provides information about various ZObject properties.
Definition: svdobj.hxx:196
virtual SdrGluePoint GetVertexGluePoint(sal_uInt16 nNum) const
Definition: svdobj.cxx:2278
virtual void SaveGeoData(SdrObjGeoData &rGeo) const override
Definition: svdotext.cxx:1417
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: svdotext.cxx:60
virtual void NbcShear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear) override
Definition: svdotxtr.cxx:210
virtual bool IsAutoGrowWidth() const
Definition: svdotext.cxx:329
css::awt::Point aPosition
Definition: svdoashp.hxx:70
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
Definition: svdotext.cxx:439
virtual SdrTextObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: svdotext.cxx:1071
virtual void handlePageChange(SdrPage *pOldPage, SdrPage *pNewPage) override
Definition: svdotext.cxx:490
CustomShapeHandleModes
Definition: svdoashp.hxx:50
virtual bool applySpecialDrag(SdrDragStat &rDrag) override
Definition: svdotxdr.cxx:149
virtual const SdrGluePointList * GetGluePointList() const
Definition: svdobj.cxx:2315
virtual void InternalSetStyleSheet(SfxStyleSheet *pNewStyleSheet, bool bDontRemoveHardAttr, bool bBroadcast)
Definition: svdobj.cxx:2270
virtual void AdjustToMaxRect(const tools::Rectangle &rMaxRect, bool bShrinkOnly=false)
Definition: svdobj.cxx:1685
virtual void TakeTextAnchorRect(::tools::Rectangle &rAnchorRect) const
Definition: svdotext.cxx:667
virtual void SetLogicRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1699
virtual void Move(const Size &rSiz)
Definition: svdobj.cxx:1534
virtual void NbcMove(const Size &rSiz) override
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdotxtr.cxx:94
virtual void NbcRotate(const Point &rRef, Degree100 nAngle, double sn, double cs) override
Definition: svdotxtr.cxx:186
virtual void AdaptTextMinSize()
Definition: svdotext.cxx:517
Abstract DrawObject.
Definition: svdobj.hxx:260
css::uno::Reference< css::drawing::XCustomShapeHandle > xInteraction
Definition: svdoashp.hxx:69
virtual basegfx::B2DPolyPolygon TakeContour() const override
contour for TextToContour
Definition: svdotext.cxx:1087
virtual void setUnoShape(const css::uno::Reference< css::drawing::XShape > &_rxUnoShape)
Sets a new UNO representation of the shape.
Definition: svdobj.cxx:2828
friend class SdrObjCustomShape
Definition: svdotext.hxx:163
SdrObject * mpLastShadowGeometry
Definition: svdoashp.hxx:96
CustomShapeHandleModes nMode
Definition: svdoashp.hxx:71
css::uno::Reference< css::drawing::XShape > mXRenderedCustomShape
Definition: svdoashp.hxx:91
virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat &rDrag) const override
Polygon dragged by the user when creating the object.
Definition: svdotxdr.cxx:230
virtual void TakeTextRect(SdrOutliner &rOutliner, tools::Rectangle &rTextRect, bool bNoEditText, tools::Rectangle *pAnchorRect, bool bLineWidth=true) const
Definition: svdotext.cxx:691
virtual SdrGluePointList * ForceGluePointList()
Definition: svdobj.cxx:2322
virtual bool AdjustTextFrameWidthAndHeight()
Definition: svdotxat.cxx:257
double GetObjectRotation() const
Definition: svdoashp.hxx:144
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
Size m_aSuggestedTextFrameSize
Definition: svdoashp.hxx:129
css::uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq
Definition: svdoashp.hxx:47
virtual void RestoreGeoData(const SdrObjGeoData &rGeo) override
Definition: svdotext.cxx:1425
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:98
virtual bool beginSpecialDrag(SdrDragStat &rDrag) const
Definition: svdobj.cxx:1343
virtual void SetSnapRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1690
virtual bool EndCreate(SdrDragStat &rStat, SdrCreateCmd eCmd) override
Definition: svdotxdr.cxx:207
virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix &rMatrix, basegfx::B2DPolyPolygon &rPolyPolygon) const override
Definition: svdotext.cxx:1572
double fObjectRotation
Definition: svdoashp.hxx:45
css::uno::Reference< css::drawing::XCustomShapeEngine > mxCustomShapeEngine
Definition: svdoashp.hxx:93
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:373
virtual void NbcSetLogicRect(const tools::Rectangle &rRect) override
Definition: svdotxtr.cxx:74
SdrCreateCmd
Definition: svdtypes.hxx:26
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: svdotext.cxx:66
virtual bool MovCreate(SdrDragStat &rStat) override
Definition: svdotxdr.cxx:192
virtual basegfx::B2DPolyPolygon TakeXorPoly() const override
The Xor-Polygon is required by the View to drag the object.
Definition: svdotext.cxx:1076
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: svdotxtr.cxx:408
bool mbAdjustingTextFrameWidthAndHeight
Definition: svdoashp.hxx:79
virtual void AddToHdlList(SdrHdlList &rHdlList) const override
Definition: svdotxdr.cxx:41
virtual void SetVerticalWriting(bool bVertical)
Definition: svdotext.cxx:1486
double fObjectRotation
Definition: svdoashp.hxx:78
virtual void NbcSetSnapRect(const tools::Rectangle &rRect) override
Definition: svdotxtr.cxx:42
virtual std::unique_ptr< SdrObjGeoData > NewGeoData() const override
A derived class must override these 3 methods if it has own geometric data that must be saved for Und...
Definition: svdotext.cxx:1412
virtual OUString TakeObjNamePlural() const override
Definition: svdotext.cxx:1053