LibreOffice Module svx (master)  1
svdomeas.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 #ifndef INCLUDED_SVX_SVDOMEAS_HXX
21 #define INCLUDED_SVX_SVDOMEAS_HXX
22 
23 #include <svx/svdotext.hxx>
24 #include <svx/svxdllapi.h>
25 #include <editeng/measfld.hxx>
26 
27 class SdrOutliner;
28 struct ImpMeasureRec;
29 struct ImpMeasurePoly;
30 
31 namespace sdr { namespace properties {
32  class MeasureProperties;
33 }}
34 
36 {
37 public:
40 
41 public:
43  virtual ~SdrMeasureObjGeoData() override;
44 };
45 
47 {
48 private:
49  // to allow sdr::properties::MeasureProperties access to SetTextDirty()
51 
52  friend class SdrMeasureField;
53 
54 protected:
55  virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
56  virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
57 
60  bool bTextDirty;
61 
62 protected:
63  void ImpTakeAttr(ImpMeasureRec& rRec) const;
64  OUString TakeRepresentation(SdrMeasureFieldKind eMeasureFieldKind) const;
65  void ImpCalcGeometrics(const ImpMeasureRec& rRec, ImpMeasurePoly& rPol) const;
66  static basegfx::B2DPolyPolygon ImpCalcXPoly(const ImpMeasurePoly& rPol);
67  void ImpEvalDrag(ImpMeasureRec& rRec, const SdrDragStat& rDrag) const;
68  void SetTextDirty() { bTextDirty=true; SetTextSizeDirty(); if (!aOutRect.IsEmpty()) { SetBoundRectDirty(); SetRectsDirty(true); } }
69  void UndirtyText() const;
70 
71  virtual SdrObjGeoData* NewGeoData() const override;
72  virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
73  virtual void RestGeoData(const SdrObjGeoData& rGeo) override;
74 
75  // protected destructor
76  virtual ~SdrMeasureObj() override;
77 
78 public:
79  SdrMeasureObj(SdrModel& rSdrModel);
81  SdrModel& rSdrModel,
82  const Point& rPt1,
83  const Point& rPt2);
84 
85  virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
86  virtual sal_uInt16 GetObjIdentifier() const override;
87  virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override;
88  virtual SdrMeasureObj* CloneSdrObject(SdrModel& rTargetModel) const override;
89 
90  // implemented mainly for the purposes of Clone()
92 
93  virtual OUString TakeObjNameSingul() const override;
94  virtual OUString TakeObjNamePlural() const override;
95 
96  virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
97  virtual sal_uInt32 GetHdlCount() const override;
98  virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
99 
100  // special drag methods
101  virtual bool hasSpecialDrag() const override;
102  virtual bool beginSpecialDrag(SdrDragStat& rDrag) const override;
103  virtual bool applySpecialDrag(SdrDragStat& rDrag) override;
104  virtual OUString getSpecialDragComment(const SdrDragStat& rDrag) const override;
105 
106  virtual bool BegCreate(SdrDragStat& rStat) override;
107  virtual bool MovCreate(SdrDragStat& rStat) override;
108  virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
109  virtual bool BckCreate(SdrDragStat& rStat) override;
110  virtual void BrkCreate(SdrDragStat& rStat) override;
111  virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const override;
112  virtual PointerStyle GetCreatePointer() const override;
113 
114  virtual void NbcMove(const Size& rSiz) override;
115  virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
116  virtual void NbcRotate(const Point& rRef, long nAngle, double sn, double cs) override;
117  virtual void NbcMirror(const Point& rRef1, const Point& rRef2) override;
118  virtual void NbcShear(const Point& rRef, long nAngle, double tn, bool bVShear) override;
119  virtual long GetRotateAngle() const override;
120  virtual void RecalcSnapRect() override;
121 
122  virtual sal_uInt32 GetSnapPointCount() const override;
123  virtual Point GetSnapPoint(sal_uInt32 i) const override;
124 
125  virtual bool IsPolyObj() const override;
126  virtual sal_uInt32 GetPointCount() const override;
127  virtual Point GetPoint(sal_uInt32 i) const override;
128  virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 i) override;
129 
130  virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
131 
132  virtual bool BegTextEdit(SdrOutliner& rOutl) override;
133  virtual const Size& GetTextSize() const override;
134  virtual void TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText,
135  tools::Rectangle* pAnchorRect, bool bLineWidth = true ) const override;
136  virtual void TakeTextAnchorRect(tools::Rectangle& rAnchorRect) const override;
137  virtual void TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, tools::Rectangle* pViewInit, tools::Rectangle* pViewMin) const override;
138  virtual EEAnchorMode GetOutlinerViewAnchorMode() const override;
139  virtual void NbcSetOutlinerParaObject(std::unique_ptr<OutlinerParaObject> pTextObject) override;
140  virtual OutlinerParaObject* GetOutlinerParaObject() const override;
141 
142  virtual bool CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos,
143  bool bEdit, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor, OUString& rRet) const override;
144 
145  // #i97878#
146  virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const override;
147  virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon) override;
148 };
149 
150 // Creating:
151 // ~~~~~~~~~
152 // dragging reference point 1 to reference point 2 -> reference edge
153 //
154 // Defaults:
155 // ~~~~~~~~~~~~~
156 // dimension line and auxiliary dimension lines: solid black hairlines
157 // arrows : 2mm x 4mm
158 // text size
159 // ___
160 // | dimension | 2mm
161 // |<--------------------->|---
162 // | | 8mm
163 // | |
164 // Pt1============# Pt2-- <----reference edge (from Pt1 to Pt2)
165 // # # |___ <-excess length of the auxiliary dimension line(s)
166 // # #=========#
167 // # objected to be dimensioned #
168 // #=======================#
169 //
170 // Attributes:
171 // ~~~~~~~~~~
172 // 1. Where is the text: middle, right or left (default=automatic)
173 // 2. Text above or below the line or line broken by text (default=automatic)
174 // Default=8mm
175 // 3. The distance from the dimension line to the reference edge (= to the dimensioned object)
176 // 4. dimension line below the reference edge (default=no))
177 // 5. excess length of the auxiliary dimension lines beyond the reference edge (2x, default=0)
178 // 6. excess length of the auxiliary dimension lines past the dimension line (default=2mm)
179 // 7. distance between the auxiliary dimension line and the reference edge
180 //
181 // Dragging: Handle Shift
182 // ~~~~~~~~~
183 // - reference points SolidQuadHdl only the length
184 // 1.+2. Seizing the text
185 // 3.+4. Hdl on arrow (2x) SolidQuadHdl only the Bool
186 // 5. Hdl one end point CircHdl both lengths ?
187 // 6.+7. no dragging
188 //
189 // Open:
190 // ~~~~~~
191 // - radiuses (anchor as type immediately)
192 //
193 // Special:
194 // ~~~~~~~~
195 // Connecting to a maximum of two objects
196 // -> during Copy, etc. use the respective code of the connectors?!?
197 // this probably will be pretty complicated ...
198 
199 #endif // INCLUDED_SVX_SVDOMEAS_HXX
200 
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: svdotxtr.cxx:106
virtual ~SdrMeasureObjGeoData() override
Definition: svdomeas.cxx:76
virtual sal_uInt32 GetSnapPointCount() const override
snap to special points of an Object (polygon points, center of circle)
Definition: svdotext.cxx:1112
virtual bool IsPolyObj() const
Definition: svdobj.cxx:1687
virtual void TakeTextEditArea(Size *pPaperMin, Size *pPaperMax, tools::Rectangle *pViewInit, tools::Rectangle *pViewMin) const
Definition: svdotxed.cxx:132
virtual const Size & GetTextSize() const
Definition: svdotext.cxx:253
virtual sal_uInt32 GetHdlCount() const override
Via GetHdlCount the number of Handles can be retrieved.
Definition: svdotxdr.cxx:36
virtual void SetBoundRectDirty()
Definition: svdobj.cxx:336
virtual OUString TakeObjNameSingul() const override
Definition: svdotext.cxx:929
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:1620
virtual sal_uInt32 GetPointCount() const
Definition: svdobj.cxx:1692
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
virtual void RecalcSnapRect() override
Snap is not done on the BoundRect but if possible on logic coordinates (i.e.
Definition: svdotext.cxx:1099
All geometrical data of an arbitrary object for use in undo/redo.
Definition: svdobj.hxx:226
virtual bool BegCreate(SdrDragStat &rStat) override
Every object must be able to create itself interactively.
Definition: svdotxdr.cxx:182
virtual void NbcMirror(const Point &rRef1, const Point &rRef2) override
Definition: svdotxtr.cxx:236
virtual 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:1435
virtual long GetRotateAngle() const override
Definition: svdotxtr.cxx:88
Provides information about various ZObject properties.
Definition: svdobj.hxx:248
SdrMeasureFieldKind
virtual bool BckCreate(SdrDragStat &rStat) override
Definition: svdotxdr.cxx:225
virtual void SaveGeoData(SdrObjGeoData &rGeo) const override
Definition: svdotext.cxx:1440
void SetTextSizeDirty()
Definition: svdotext.hxx:288
SdrMeasureFieldKind eMeasureFieldKind
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: svdotext.cxx:75
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
Definition: svdotext.cxx:408
virtual SdrTextObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: svdotext.cxx:1010
virtual void NbcSetPoint(const Point &rPnt, sal_uInt32 i)
Definition: svdobj.cxx:1711
virtual bool applySpecialDrag(SdrDragStat &rDrag) override
Definition: svdotxdr.cxx:149
virtual OUString getSpecialDragComment(const SdrDragStat &rDrag) const override
Definition: svdotxdr.cxx:174
virtual bool BegTextEdit(SdrOutliner &rOutl)
Definition: svdotxed.cxx:41
virtual void BrkCreate(SdrDragStat &rStat) override
Definition: svdotxdr.cxx:221
SdrTextObj & operator=(const SdrTextObj &rObj)
Definition: svdotext.cxx:1015
virtual void TakeTextAnchorRect(::tools::Rectangle &rAnchorRect) const
Definition: svdotext.cxx:603
virtual sal_uInt16 GetObjIdentifier() const override
Definition: svdotext.cxx:432
virtual void NbcMove(const Size &rSiz) override
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdotxtr.cxx:98
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:1371
friend class SdrMeasureObj
Definition: svdotext.hxx:173
virtual void RestGeoData(const SdrObjGeoData &rGeo) override
Definition: svdotext.cxx:1448
virtual void TakeTextRect(SdrOutliner &rOutliner, tools::Rectangle &rTextRect, bool bNoEditText, tools::Rectangle *pAnchorRect, bool bLineWidth=true) const
Definition: svdotext.cxx:638
virtual OutlinerParaObject * GetOutlinerParaObject() const override
Definition: svdotext.cxx:1362
bool bTextDirty
Definition: svdomeas.hxx:60
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:114
virtual bool beginSpecialDrag(SdrDragStat &rDrag) const
Definition: svdobj.cxx:1312
PointerStyle
virtual void SetRectsDirty(bool bNotMyself=false, bool bRecursive=true)
Definition: svdobj.cxx:462
virtual bool CalcFieldValue(const SvxFieldItem &rField, sal_Int32 nPara, sal_uInt16 nPos, bool bEdit, o3tl::optional< Color > &rpTxtColor, o3tl::optional< Color > &rpFldColor, OUString &rRet) const
Definition: svdotxfl.cxx:24
EEAnchorMode
virtual Point GetSnapPoint(sal_uInt32 i) const override
Definition: svdotext.cxx:1117
virtual bool EndCreate(SdrDragStat &rStat, SdrCreateCmd eCmd) override
Definition: svdotxdr.cxx:207
void SetTextDirty()
Definition: svdomeas.hxx:68
virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix &rMatrix, basegfx::B2DPolyPolygon &rPolyPolygon) const override
Definition: svdotext.cxx:1585
virtual void NbcRotate(const Point &rRef, long nAngle, double sn, double cs) override
Definition: svdotxtr.cxx:190
SdrCreateCmd
Definition: svdtypes.hxx:27
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: svdotext.cxx:81
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:1061
virtual void NbcShear(const Point &rRef, long nAngle, double tn, bool bVShear) override
Definition: svdotxtr.cxx:214
virtual void TakeUnrotatedSnapRect(tools::Rectangle &rRect) const
Definition: svdotext.cxx:598
virtual Point GetPoint(sal_uInt32 i) const
Definition: svdobj.cxx:1697
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: svdotxtr.cxx:418
virtual void AddToHdlList(SdrHdlList &rHdlList) const override
Definition: svdotxdr.cxx:41
virtual EEAnchorMode GetOutlinerViewAnchorMode() const
Definition: svdotxed.cxx:304
virtual OUString TakeObjNamePlural() const override
Definition: svdotext.cxx:993
virtual PointerStyle GetCreatePointer() const override
get the cursor/pointer that signals creating this object
Definition: svdotxdr.cxx:242