LibreOffice Module svx (master)  1
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
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 .
18  */
23 #include <svx/svdobj.hxx>
24 #include <svx/svdotext.hxx>
25 #include <svx/svdhdl.hxx>
26 #include <vector>
27 #include <com/sun/star/uno/Reference.h>
28 #include <com/sun/star/drawing/XCustomShapeEngine.hpp>
29 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
30 #include <svx/svxdllapi.h>
31 #include <o3tl/typed_flags_set.hxx>
33 namespace sdr
34 {
35  namespace properties
36  {
37  class CustomShapeProperties;
38  }
39 }
42 {
43 public:
44  bool bMirroredX;
45  bool bMirroredY;
48  css::uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq;
49 };
52 {
53  NONE = 0,
58  MOVE_SHAPE = 16,
59  ORTHO4 = 32,
61 };
63 namespace o3tl
64 {
65  template<> struct typed_flags<CustomShapeHandleModes> : is_typed_flags<CustomShapeHandleModes, 127> {};
66 }
69 {
70  css::uno::Reference< css::drawing::XCustomShapeHandle > xInteraction;
71  css::awt::Point aPosition;
73 };
76 {
77 private:
78  // fObjectRotation is containing the object rotation in degrees.
82 protected:
83  virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
84  virtual void impl_setUnoShape(const css::uno::Reference<css::uno::XInterface>& rxUnoShape) override;
86 public:
87  virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
89  // to allow sdr::properties::CustomShapeProperties access
92  css::uno::Reference< css::drawing::XShape > mXRenderedCustomShape;
94  mutable css::uno::Reference< css::drawing::XCustomShapeEngine > mxCustomShapeEngine;
96  // #i37011# render geometry shadow
99  css::uno::Reference< css::drawing::XCustomShapeEngine > const & GetCustomShapeEngine() const;
101  std::vector< SdrCustomShapeInteraction > GetInteractionHandles() const; // needed in unit test
102  SVX_DLLPRIVATE void DragCreateObject( SdrDragStat& rDrag );
103  SVX_DLLPRIVATE void DragResizeCustomShape( const tools::Rectangle& rNewRect );
104  void DragMoveCustomShapeHdl( const Point& rDestination,
105  const sal_uInt16 nCustomShapeHdlNum, bool bMoveCalloutRectangle ); // needed in unit test
107  // #i37011# centralize throw-away of render geometry
108  void InvalidateRenderGeometry();
110  // #i38892#
111  void ImpCheckCustomGluePointsAreAdded();
113  // returns the new text rect that corresponds to the current logic rect, the return value can be empty if nothing changed.
114  tools::Rectangle ImpCalculateTextFrame( const bool bHgt, const bool bWdt );
116 public:
117  // #i37011#
118  const SdrObject* GetSdrObjectFromCustomShape() const;
119  const SdrObject* GetSdrObjectShadowFromCustomShape() const;
120  bool GetTextBounds( tools::Rectangle& rTextBound ) const;
121  bool IsTextPath() const;
122  basegfx::B2DPolyPolygon GetLineGeometry( const bool bBezierAllowed ) const;
124 protected:
125  // #115391# new method for SdrObjCustomShape and SdrTextObj to correctly handle and set
126  // SdrTextMinFrameWidthItem and SdrTextMinFrameHeightItem based on all settings, necessities
127  // and object sizes
128  virtual void AdaptTextMinSize() override;
132  // protected destructor
133  virtual ~SdrObjCustomShape() override;
135 public:
136  bool UseNoFillStyle() const;
138  bool IsMirroredX() const;
139  bool IsMirroredY() const;
140  void SetMirroredX( const bool bMirroredX );
141  void SetMirroredY( const bool bMirroredY );
143  double GetObjectRotation() const { return fObjectRotation;}
144  double GetExtraTextRotation( const bool bPreRotation = false ) const;
146  SdrObjCustomShape(SdrModel& rSdrModel);
147  SdrObjCustomShape(SdrModel& rSdrModel, SdrObjCustomShape const & rSource);
149  /* is merging default attributes from type-shape into the SdrCustomShapeGeometryItem. If pType
150  is NULL then the type is being taken from the "Type" property of the SdrCustomShapeGeometryItem.
151  MergeDefaultAttributes is called when creating CustomShapes via UI and after importing */
152  void MergeDefaultAttributes( const OUString* pType = nullptr );
154  /* the method is checking if the geometry data is unchanged/default, in this case the data might not be stored */
155  enum class DefaultType
156  {
157  Path,
158  Viewbox,
159  Segments,
160  Gluepoints,
161  StretchX,
162  StretchY,
163  Equations,
164  TextFrames
165  };
166  bool IsDefaultGeometry( const DefaultType eDefaultType ) const;
168  virtual SdrObjKind GetObjIdentifier() const override;
169  virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
171  virtual void Move(const Size& rSiz) override;
172  virtual void Shear(const Point& rRef, Degree100 nAngle, double tn, bool bVShear) override;
173  virtual void SetSnapRect(const tools::Rectangle& rRect) override;
174  virtual void SetLogicRect(const tools::Rectangle& rRect) override;
175  virtual void AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override;
177  virtual void NbcMove(const Size& rSiz) override;
178  virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
179  virtual void NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) override;
180  virtual void NbcMirror(const Point& rRef1, const Point& rRef2) override;
181  virtual void NbcShear(const Point& rRef, Degree100 nAngle, double tn, bool bVShear) override;
182  virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
183  virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
185  virtual SdrGluePoint GetVertexGluePoint(sal_uInt16 nNum) const override;
187  virtual void NbcSetStyleSheet( SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr ) override;
189  // special drag methods
190  virtual bool hasSpecialDrag() const override;
191  virtual bool beginSpecialDrag(SdrDragStat& rDrag) const override;
192  virtual bool applySpecialDrag(SdrDragStat& rDrag) override;
194  virtual bool MovCreate(SdrDragStat& rStat) override; // #i37448#
195  virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
202  void SuggestTextFrameSize(Size aSuggestedTextFrameSize);
203  virtual bool AdjustTextFrameWidthAndHeight(tools::Rectangle& rR, bool bHgt = true, bool bWdt = true) const override;
204  virtual bool NbcAdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = true) override;
205  virtual bool AdjustTextFrameWidthAndHeight() override;
206  virtual bool IsAutoGrowHeight() const override;
207  virtual bool IsAutoGrowWidth() const override;
208  virtual void SetVerticalWriting(bool bVertical) override;
209  virtual void TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, tools::Rectangle* pViewInit, tools::Rectangle* pViewMin) const override;
210  virtual void EndTextEdit( SdrOutliner& rOutl ) override;
211  virtual void TakeTextAnchorRect( tools::Rectangle& rAnchorRect ) const override;
212  virtual void TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText,
213  tools::Rectangle* pAnchorRect, bool bLineWidth = true ) const override;
214  virtual SdrObjCustomShape* CloneSdrObject(SdrModel& rTargetModel) const override;
216  virtual OUString TakeObjNameSingul() const override;
217  virtual OUString TakeObjNamePlural() const override;
219  virtual basegfx::B2DPolyPolygon TakeCreatePoly( const SdrDragStat& rDrag) const override;
221  virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
222  virtual basegfx::B2DPolyPolygon TakeContour() const override;
224  virtual void NbcSetOutlinerParaObject(std::unique_ptr<OutlinerParaObject> pTextObject) override;
226  virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
228  // react on model/page change
229  virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;
231  virtual std::unique_ptr<SdrObjGeoData> NewGeoData() const override;
232  virtual void SaveGeoData(SdrObjGeoData &rGeo) const override;
233  virtual void RestoreGeoData(const SdrObjGeoData &rGeo) override;
235  // need to take fObjectRotation instead of aGeo.nAngle, replace it temporary
236  virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const override;
237  virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon) override;
239  virtual const SdrGluePointList* GetGluePointList() const override;
240  //virtual SdrGluePointList* GetGluePointList();
241  virtual SdrGluePointList* ForceGluePointList() override;
243  virtual sal_uInt32 GetHdlCount() const override;
244  virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
246  // #i33136#
247  static bool doConstructOrthogonal(const OUString& rName);
251  OUString GetCustomShapeName() const;
252 };
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void Shear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear)
Definition: svdobj.cxx:1579
virtual bool IsAutoGrowHeight() const
Definition: svdotext.cxx:306
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:239
virtual SdrObjKind GetObjIdentifier() const override
Definition: svdotext.cxx:464
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:970
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:1623
All geometrical data of an arbitrary object for use in undo/redo.
Definition: svdobj.hxx:172
Definition: svdobjkind.hxx:24
virtual void EndTextEdit(SdrOutliner &rOutl)
Definition: svdotxed.cxx:264
virtual void NbcMirror(const Point &rRef1, const Point &rRef2) override
Definition: svdotxtr.cxx:232
Provides information about various ZObject properties.
Definition: svdobj.hxx:194
virtual SdrGluePoint GetVertexGluePoint(sal_uInt16 nNum) const
Definition: svdobj.cxx:2230
virtual void SaveGeoData(SdrObjGeoData &rGeo) const override
Definition: svdotext.cxx:1443
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: svdotext.cxx:58
virtual void NbcShear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear) override
Definition: svdotxtr.cxx:210
virtual bool IsAutoGrowWidth() const
Definition: svdotext.cxx:331
css::awt::Point aPosition
Definition: svdoashp.hxx:71
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
Definition: svdotext.cxx:440
virtual SdrTextObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: svdotext.cxx:1051
virtual void handlePageChange(SdrPage *pOldPage, SdrPage *pNewPage) override
Definition: svdotext.cxx:491
Definition: svdoashp.hxx:51
virtual bool applySpecialDrag(SdrDragStat &rDrag) override
Definition: svdotxdr.cxx:149
virtual const SdrGluePointList * GetGluePointList() const
Definition: svdobj.cxx:2267
virtual void AdjustToMaxRect(const tools::Rectangle &rMaxRect, bool bShrinkOnly=false)
Definition: svdobj.cxx:1665
virtual void impl_setUnoShape(const css::uno::Reference< css::uno::XInterface > &_rxUnoShape)
Sets a new UNO shape.
Definition: svdobj.cxx:2779
virtual void TakeTextAnchorRect(::tools::Rectangle &rAnchorRect) const
Definition: svdotext.cxx:635
virtual void SetLogicRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1679
virtual void Move(const Size &rSiz)
Definition: svdobj.cxx:1514
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:518
Abstract DrawObject.
Definition: svdobj.hxx:258
css::uno::Reference< css::drawing::XCustomShapeHandle > xInteraction
Definition: svdoashp.hxx:70
virtual basegfx::B2DPolyPolygon TakeContour() const override
contour for TextToContour
Definition: svdotext.cxx:1067
friend class SdrObjCustomShape
Definition: svdotext.hxx:175
SdrObject * mpLastShadowGeometry
Definition: svdoashp.hxx:97
CustomShapeHandleModes nMode
Definition: svdoashp.hxx:72
css::uno::Reference< css::drawing::XShape > mXRenderedCustomShape
Definition: svdoashp.hxx:92
virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat &rDrag) const override
Polygon dragged by the user when creating the object.
Definition: svdotxdr.cxx:230
virtual void NbcSetOutlinerParaObject(std::unique_ptr< OutlinerParaObject > pTextObject) override
Definition: svdotext.cxx:1374
virtual void TakeTextRect(SdrOutliner &rOutliner, tools::Rectangle &rTextRect, bool bNoEditText, tools::Rectangle *pAnchorRect, bool bLineWidth=true) const
Definition: svdotext.cxx:670
virtual SdrGluePointList * ForceGluePointList()
Definition: svdobj.cxx:2274
virtual bool AdjustTextFrameWidthAndHeight()
Definition: svdotxat.cxx:255
double GetObjectRotation() const
Definition: svdoashp.hxx:143
Definition: svxdllapi.h:35
Size m_aSuggestedTextFrameSize
Definition: svdoashp.hxx:130
css::uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq
Definition: svdoashp.hxx:48
virtual void RestoreGeoData(const SdrObjGeoData &rGeo) override
Definition: svdotext.cxx:1451
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:96
virtual bool beginSpecialDrag(SdrDragStat &rDrag) const
Definition: svdobj.cxx:1323
virtual void SetSnapRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1670
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:1588
double fObjectRotation
Definition: svdoashp.hxx:46
css::uno::Reference< css::drawing::XCustomShapeEngine > mxCustomShapeEngine
Definition: svdoashp.hxx:94
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365
virtual void NbcSetStyleSheet(SfxStyleSheet *pNewStyleSheet, bool bDontRemoveHardAttr)
Definition: svdobj.cxx:2222
virtual void NbcSetLogicRect(const tools::Rectangle &rRect) override
Definition: svdotxtr.cxx:74
Definition: svdtypes.hxx:27
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: svdotext.cxx:64
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:1056
Definition: svxdllapi.h:30
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: svdotxtr.cxx:414
bool mbAdjustingTextFrameWidthAndHeight
Definition: svdoashp.hxx:80
virtual void AddToHdlList(SdrHdlList &rHdlList) const override
Definition: svdotxdr.cxx:41
virtual void SetVerticalWriting(bool bVertical)
Definition: svdotext.cxx:1512
double fObjectRotation
Definition: svdoashp.hxx:79
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:1438
virtual OUString TakeObjNamePlural() const override
Definition: svdotext.cxx:1034