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