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