Line data Source code
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 _SVDOMEAS_HXX
21 : #define _SVDOMEAS_HXX
22 :
23 : #include <svx/svdotext.hxx>
24 : #include "svx/svxdllapi.h"
25 : #include <editeng/measfld.hxx>
26 :
27 : //************************************************************
28 : // Initial Declarations
29 : //************************************************************
30 :
31 : class SdrOutliner;
32 : struct ImpMeasureRec;
33 : struct ImpMeasurePoly;
34 :
35 : namespace sdr { namespace properties {
36 : class MeasureProperties;
37 : }}
38 :
39 : //************************************************************
40 : // Auxiliary Class SdrMeasureObjGeoData
41 : //************************************************************
42 :
43 : class SdrMeasureObjGeoData : public SdrTextObjGeoData
44 : {
45 : public:
46 : Point aPt1;
47 : Point aPt2;
48 :
49 : public:
50 : SdrMeasureObjGeoData();
51 : virtual ~SdrMeasureObjGeoData();
52 : };
53 :
54 : //************************************************************
55 : // SdrMeasureObj
56 : //************************************************************
57 :
58 0 : class SVX_DLLPUBLIC SdrMeasureObj : public SdrTextObj
59 : {
60 : private:
61 : // to allow sdr::properties::MeasureProperties access to SetTextDirty()
62 : friend class sdr::properties::MeasureProperties;
63 :
64 : friend class SdrMeasureField;
65 :
66 : protected:
67 : virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact();
68 : virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties();
69 :
70 : Point aPt1;
71 : Point aPt2;
72 : bool bTextDirty;
73 :
74 : protected:
75 : void ImpTakeAttr(ImpMeasureRec& rRec) const;
76 : void TakeRepresentation( XubString& rStr, SdrMeasureFieldKind eMeasureFieldKind ) const;
77 : void ImpCalcGeometrics(const ImpMeasureRec& rRec, ImpMeasurePoly& rPol) const;
78 : basegfx::B2DPolyPolygon ImpCalcXPoly(const ImpMeasurePoly& rPol) const;
79 : void ImpEvalDrag(ImpMeasureRec& rRec, const SdrDragStat& rDrag) const;
80 9 : void SetTextDirty() { bTextDirty=sal_True; SetTextSizeDirty(); if (!aOutRect.IsEmpty()) { SetBoundRectDirty(); SetRectsDirty(sal_True); } }
81 : void UndirtyText() const;
82 :
83 : virtual SdrObjGeoData* NewGeoData() const;
84 : virtual void SaveGeoData(SdrObjGeoData& rGeo) const;
85 : virtual void RestGeoData(const SdrObjGeoData& rGeo);
86 :
87 : public:
88 : TYPEINFO();
89 : SdrMeasureObj();
90 : SdrMeasureObj(const Point& rPt1, const Point& rPt2);
91 : virtual ~SdrMeasureObj();
92 :
93 : virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const;
94 : virtual sal_uInt16 GetObjIdentifier() const;
95 : virtual void TakeUnrotatedSnapRect(Rectangle& rRect) const;
96 : virtual SdrMeasureObj* Clone() const;
97 :
98 : virtual void TakeObjNameSingul(String& rName) const;
99 : virtual void TakeObjNamePlural(String& rName) const;
100 :
101 : virtual basegfx::B2DPolyPolygon TakeXorPoly() const;
102 : virtual sal_uInt32 GetHdlCount() const;
103 : virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const;
104 :
105 : // special drag methods
106 : virtual bool hasSpecialDrag() const;
107 : virtual bool beginSpecialDrag(SdrDragStat& rDrag) const;
108 : virtual bool applySpecialDrag(SdrDragStat& rDrag);
109 : virtual String getSpecialDragComment(const SdrDragStat& rDrag) const;
110 :
111 : virtual bool BegCreate(SdrDragStat& rStat);
112 : virtual bool MovCreate(SdrDragStat& rStat);
113 : virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
114 : virtual bool BckCreate(SdrDragStat& rStat);
115 : virtual void BrkCreate(SdrDragStat& rStat);
116 : virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const;
117 : virtual Pointer GetCreatePointer() const;
118 :
119 : virtual void NbcMove(const Size& rSiz);
120 : virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
121 : virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs);
122 : virtual void NbcMirror(const Point& rRef1, const Point& rRef2);
123 : virtual void NbcShear(const Point& rRef, long nWink, double tn, bool bVShear);
124 : virtual long GetRotateAngle() const;
125 : virtual void RecalcSnapRect();
126 :
127 : virtual sal_uInt32 GetSnapPointCount() const;
128 : virtual Point GetSnapPoint(sal_uInt32 i) const;
129 :
130 : virtual sal_Bool IsPolyObj() const;
131 : virtual sal_uInt32 GetPointCount() const;
132 : virtual Point GetPoint(sal_uInt32 i) const;
133 : virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 i);
134 :
135 : virtual SdrObject* DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const;
136 :
137 : virtual sal_Bool BegTextEdit(SdrOutliner& rOutl);
138 : virtual const Size& GetTextSize() const;
139 : virtual void TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText = false,
140 : Rectangle* pAnchorRect=NULL, bool bLineWidth = true ) const;
141 : virtual void TakeTextAnchorRect(Rectangle& rAnchorRect) const;
142 : virtual void TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const;
143 : virtual sal_uInt16 GetOutlinerViewAnchorMode() const;
144 : virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject);
145 : virtual OutlinerParaObject* GetOutlinerParaObject() const;
146 :
147 : virtual bool CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos,
148 : bool bEdit, Color*& rpTxtColor, Color*& rpFldColor, String& rRet) const;
149 :
150 : // #i97878#
151 : virtual sal_Bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const;
152 : virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon);
153 : };
154 :
155 : /////////////////////////////////////////////////////////////////////////////////////////////////
156 : //
157 : // Creating:
158 : // ~~~~~~~~~
159 : // dragging reference point 1 to reference point 2 -> reference edge
160 : //
161 : // Defaults:
162 : // ~~~~~~~~~~~~~
163 : // dimension line and auxiliary dimension lines: solid black hairlines
164 : // arrows : 2mm x 4mm
165 : // text size
166 : // ___
167 : // | dimension | 2mm
168 : // |<--------------------->|---
169 : // | | 8mm
170 : // | |
171 : // Pt1============# Pt2-- <----reference edge (from Pt1 to Pt2)
172 : // # # |___ <-excess length of the auxiliary dimention line(s)
173 : // # #=========#
174 : // # objected to be dimensioned #
175 : // #=======================#
176 : //
177 : // Attributes:
178 : // ~~~~~~~~~~
179 : // 1. Where is the text: middle, right or left (default=automatic)
180 : // 2. Text above or below the line or line broken by text (default=automatic)
181 : // Default=8mm
182 : // 3. The distance from the dimension line to the reference edge (= to the dimesnioned object)
183 : // 4. dimension line below the reference edge (default=no))
184 : // 5. excess lenth of the auxiliary dimension lines beyond the reference edge (2x, default=0)
185 : // 6. excess lenth of the auxiliary dimension lines past the dimesion line (default=2mm)
186 : // 7. distance between the auxiliary dimension line and the reference edge
187 : //
188 : // Dragging: Handle Shift
189 : // ~~~~~~~~~
190 : // - reference points SolidQuadHdl only the length
191 : // 1.+2. Anpacken des Textes
192 : // 3.+4. Hdl on arrow (2x) SolidQuadHdl only the Bool
193 : // 5. Hdl one end point CircHdl both lengths ?
194 : // 6.+7. no dragging
195 : //
196 : // Open:
197 : // ~~~~~~
198 : // - radiuses (anchor as type immediately)
199 : //
200 : // Special:
201 : // ~~~~~~~~
202 : // Connecting to a maximum of two objects
203 : // -> during Copy, etc. use the respective code of the connectors?!?
204 : // this probably will be pretty complicated ...
205 : //
206 : /////////////////////////////////////////////////////////////////////////////////////////////////
207 :
208 : #endif //_SVDOMEAS_HXX
209 :
210 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|