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 _SVDOASHP_HXX
21 : #define _SVDOASHP_HXX
22 :
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 :
32 : //************************************************************
33 : // Vorausdeklarationen
34 : //************************************************************
35 :
36 : class SdrObjList;
37 : class SdrObjListIter;
38 : class SfxItemSet;
39 :
40 : namespace sdr
41 : {
42 : namespace properties
43 : {
44 : class CustomShapeProperties;
45 : } // end of namespace properties
46 : } // end of namespace sdr
47 :
48 312 : class SdrAShapeObjGeoData : public SdrTextObjGeoData
49 : {
50 : public:
51 :
52 : sal_Bool bMirroredX;
53 : sal_Bool bMirroredY;
54 : double fObjectRotation;
55 :
56 : com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue >
57 : aAdjustmentSeq;
58 : };
59 :
60 : #define CUSTOMSHAPE_HANDLE_RESIZE_FIXED 1
61 : #define CUSTOMSHAPE_HANDLE_CREATE_FIXED 2
62 : #define CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X 4
63 : #define CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y 8
64 : #define CUSTOMSHAPE_HANDLE_MOVE_SHAPE 16
65 : #define CUSTOMSHAPE_HANDLE_ORTHO4 32
66 :
67 0 : struct SdrCustomShapeInteraction
68 : {
69 : com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle > xInteraction;
70 : com::sun::star::awt::Point aPosition;
71 : sal_Int32 nMode;
72 : };
73 :
74 : //************************************************************
75 : // SdrObjCustomShape
76 : //************************************************************
77 :
78 : class SVX_DLLPUBLIC SdrObjCustomShape : public SdrTextObj
79 : {
80 : private:
81 : // fObjectRotation is containing the object rotation in degrees.
82 : double fObjectRotation;
83 :
84 : protected:
85 : virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact();
86 :
87 : public:
88 : virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties();
89 :
90 : // to allow sdr::properties::CustomShapeProperties access
91 : friend class sdr::properties::CustomShapeProperties;
92 :
93 : com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mXRenderedCustomShape;
94 :
95 : mutable com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeEngine > mxCustomShapeEngine;
96 :
97 : // #i37011# render geometry shadow
98 : SdrObject* mpLastShadowGeometry;
99 :
100 : com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeEngine > GetCustomShapeEngine() const;
101 :
102 : // SVX_DLLPRIVATE com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle > >
103 : // SdrObjCustomShape::GetInteraction( const SdrObjCustomShape* pCustomShape ) const;
104 : // #i47293#
105 : // SVX_DLLPRIVATE std::vector< com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle > > GetFixedInteractionHandle() const;
106 :
107 : SVX_DLLPRIVATE std::vector< SdrCustomShapeInteraction > GetInteractionHandles( const SdrObjCustomShape* pCustomShape ) const;
108 :
109 : SVX_DLLPRIVATE void DragCreateObject( SdrDragStat& rDrag );
110 :
111 : SVX_DLLPRIVATE void DragResizeCustomShape( const Rectangle& rNewRect, SdrObjCustomShape* pObj ) const;
112 : SVX_DLLPRIVATE void DragMoveCustomShapeHdl( const Point aDestination, const sal_uInt16 nCustomShapeHdlNum, SdrObjCustomShape* pObj ) const;
113 :
114 : // #i37011# centralize throw-away of render geometry
115 : void InvalidateRenderGeometry();
116 :
117 : // #i38892#
118 : void ImpCheckCustomGluePointsAreAdded();
119 :
120 : // returns the new text rect that corresponds to the current logic rect, the return value can be empty if nothing changed.
121 : Rectangle ImpCalculateTextFrame( const bool bHgt, const bool bWdt );
122 :
123 : public:
124 : // #i37011#
125 : const SdrObject* GetSdrObjectFromCustomShape() const;
126 : const SdrObject* GetSdrObjectShadowFromCustomShape() const;
127 : sal_Bool GetTextBounds( Rectangle& rTextBound ) const;
128 : sal_Bool IsTextPath() const;
129 : static basegfx::B2DPolyPolygon GetLineGeometry( const SdrObjCustomShape* pCustomShape, const sal_Bool bBezierAllowed );
130 :
131 : protected:
132 :
133 : String aName;
134 :
135 : public:
136 :
137 : sal_Bool UseNoFillStyle() const;
138 :
139 : sal_Bool IsMirroredX() const;
140 : sal_Bool IsMirroredY() const;
141 : bool IsPostRotate() const;
142 : void SetMirroredX( const sal_Bool bMirroredX );
143 : void SetMirroredY( const sal_Bool bMirroredY );
144 :
145 : double GetObjectRotation() const;
146 : double GetExtraTextRotation( const bool bPreRotation = false ) const;
147 :
148 : TYPEINFO();
149 : SdrObjCustomShape();
150 : virtual ~SdrObjCustomShape();
151 :
152 : /* is merging default attributes from type-shype into the SdrCustomShapeGeometryItem. If pType
153 : is NULL then the type is being taken from the "Type" property of the SdrCustomShapeGeometryItem.
154 : MergeDefaultAttributes is called when creating CustomShapes via UI and after importing */
155 : void MergeDefaultAttributes( const rtl::OUString* pType = NULL );
156 :
157 : /* the method is checking if the geometry data is unchanged/default, in this case the data might not be stored */
158 : enum DefaultType
159 : {
160 : DEFAULT_PATH,
161 : DEFAULT_VIEWBOX,
162 : DEFAULT_SEGMENTS,
163 : DEFAULT_GLUEPOINTS,
164 : DEFAULT_STRETCHX,
165 : DEFAULT_STRETCHY,
166 : DEFAULT_EQUATIONS,
167 : DEFAULT_HANDLES,
168 : DEFAULT_TEXTFRAMES
169 : };
170 : sal_Bool IsDefaultGeometry( const DefaultType eDefaultType ) const;
171 :
172 : virtual sal_uInt16 GetObjIdentifier() const;
173 : virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const;
174 :
175 : virtual void SetModel(SdrModel* pNewModel);
176 :
177 : virtual void RecalcSnapRect();
178 :
179 : virtual const Rectangle& GetSnapRect() const;
180 : virtual const Rectangle& GetCurrentBoundRect() const;
181 : virtual const Rectangle& GetLogicRect() const;
182 :
183 : virtual void Move(const Size& rSiz);
184 : virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true);
185 : virtual void Shear(const Point& rRef, long nWink, double tn, bool bVShear);
186 : virtual void SetSnapRect(const Rectangle& rRect);
187 : virtual void SetLogicRect(const Rectangle& rRect);
188 :
189 : virtual void NbcMove(const Size& rSiz);
190 : virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
191 : virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs);
192 : virtual void NbcMirror(const Point& rRef1, const Point& rRef2);
193 : virtual void NbcShear(const Point& rRef, long nWink, double tn, bool bVShear);
194 : virtual void NbcSetSnapRect(const Rectangle& rRect);
195 : virtual void NbcSetLogicRect(const Rectangle& rRect);
196 :
197 : virtual SdrGluePoint GetVertexGluePoint(sal_uInt16 nNum) const;
198 :
199 : virtual void NbcSetStyleSheet( SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr );
200 :
201 : // special drag methods
202 : virtual bool hasSpecialDrag() const;
203 : virtual bool beginSpecialDrag(SdrDragStat& rDrag) const;
204 : virtual bool applySpecialDrag(SdrDragStat& rDrag);
205 :
206 : virtual bool BegCreate( SdrDragStat& rStat );
207 : virtual bool MovCreate(SdrDragStat& rStat); // #i37448#
208 : virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
209 :
210 : virtual bool AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt = true, bool bWdt = true) const;
211 : virtual bool NbcAdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = true);
212 : virtual bool AdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = true);
213 : virtual bool IsAutoGrowHeight() const;
214 : virtual bool IsAutoGrowWidth() const;
215 : virtual void SetVerticalWriting( sal_Bool bVertical );
216 : virtual sal_Bool BegTextEdit( SdrOutliner& rOutl );
217 : virtual void TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const;
218 : virtual void EndTextEdit( SdrOutliner& rOutl );
219 : virtual void TakeTextAnchorRect( Rectangle& rAnchorRect ) const;
220 : virtual void TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText = false,
221 : Rectangle* pAnchorRect=NULL, bool bLineWidth = true ) const;
222 : virtual SdrObjCustomShape* Clone() const;
223 : SdrObjCustomShape& operator=(const SdrObjCustomShape& rObj);
224 :
225 : virtual void TakeObjNameSingul(String& rName) const;
226 : virtual void TakeObjNamePlural(String& rName) const;
227 :
228 : virtual basegfx::B2DPolyPolygon TakeCreatePoly( const SdrDragStat& rDrag) const;
229 :
230 : virtual basegfx::B2DPolyPolygon TakeXorPoly() const;
231 : virtual basegfx::B2DPolyPolygon TakeContour() const;
232 :
233 : virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject);
234 :
235 : virtual SdrObject* DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const;
236 :
237 : virtual void SetPage( SdrPage* pNewPage );
238 :
239 : virtual SdrObjGeoData *NewGeoData() const;
240 : virtual void SaveGeoData(SdrObjGeoData &rGeo) const;
241 : virtual void RestGeoData(const SdrObjGeoData &rGeo);
242 :
243 : // need to take fObjectRotation instead of aGeo.nWink, replace it temporary
244 : virtual sal_Bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const;
245 : virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon);
246 :
247 : virtual const SdrGluePointList* GetGluePointList() const;
248 : //virtual SdrGluePointList* GetGluePointList();
249 : virtual SdrGluePointList* ForceGluePointList();
250 :
251 : virtual sal_uInt32 GetHdlCount() const;
252 : virtual SdrHdl* GetHdl( sal_uInt32 nHdlNum ) const;
253 :
254 : // #i33136#
255 : static bool doConstructOrthogonal(const ::rtl::OUString& rName);
256 :
257 : using SdrTextObj::NbcSetOutlinerParaObject;
258 : };
259 :
260 : #endif //_SVDOASHP_HXX
261 :
262 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|