1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f6e50924SAndrew Rist  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19f6e50924SAndrew Rist  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "precompiled_svx.hxx"
25cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
26cdf0e10cSrcweir #include <svl/itemset.hxx>
27cdf0e10cSrcweir #include <svx/xdef.hxx>
28cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
29cdf0e10cSrcweir #include <svx/xlineit0.hxx>
30cdf0e10cSrcweir #include <svx/xfillit0.hxx>
31cdf0e10cSrcweir #include <svx/xlntrit.hxx>
32cdf0e10cSrcweir #include <svx/xlnwtit.hxx>
33cdf0e10cSrcweir #include <svx/xlinjoit.hxx>
345aaf853bSArmin Le Grand #include <svx/xlncapit.hxx>
35cdf0e10cSrcweir #include <svx/xlnclit.hxx>
36cdf0e10cSrcweir #include <svx/xlnstwit.hxx>
37cdf0e10cSrcweir #include <svx/xlnedwit.hxx>
38cdf0e10cSrcweir #include <svx/xlnstit.hxx>
39cdf0e10cSrcweir #include <svx/xlnstcit.hxx>
40cdf0e10cSrcweir #include <svx/xlnedit.hxx>
41cdf0e10cSrcweir #include <svx/xlnedcit.hxx>
42cdf0e10cSrcweir #include <svx/xdash.hxx>
43cdf0e10cSrcweir #include <svx/xlndsit.hxx>
44cdf0e10cSrcweir #include <svx/xfltrit.hxx>
45cdf0e10cSrcweir #include <svx/xflftrit.hxx>
46cdf0e10cSrcweir #include <svx/xflclit.hxx>
47cdf0e10cSrcweir #include <svx/xgrscit.hxx>
48cdf0e10cSrcweir #include <svx/xflhtit.hxx>
49cdf0e10cSrcweir #include <svx/xflbckit.hxx>
50cdf0e10cSrcweir #include <svx/sdshitm.hxx>
51cdf0e10cSrcweir #include <svx/sdsxyitm.hxx>
52cdf0e10cSrcweir #include <svx/sdshcitm.hxx>
53cdf0e10cSrcweir #include <svx/sdshtitm.hxx>
54035a2f44SArmin Le Grand #include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
55cdf0e10cSrcweir #include <basegfx/polygon/b2dlinegeometry.hxx>
56cdf0e10cSrcweir #include <svx/svdotext.hxx>
57035a2f44SArmin Le Grand #include <drawinglayer/attribute/fillgraphicattribute.hxx>
58cdf0e10cSrcweir #include <svx/sdr/attribute/sdrtextattribute.hxx>
59cdf0e10cSrcweir #include <svx/xbtmpit.hxx>
60cdf0e10cSrcweir #include <svl/itempool.hxx>
61cdf0e10cSrcweir #include <vcl/svapp.hxx>
62cdf0e10cSrcweir #include <basegfx/range/b2drange.hxx>
63cdf0e10cSrcweir #include <svx/svx3ditems.hxx>
64cdf0e10cSrcweir #include <com/sun/star/drawing/ProjectionMode.hpp>
65cdf0e10cSrcweir #include <com/sun/star/drawing/ShadeMode.hpp>
66cdf0e10cSrcweir #include <drawinglayer/attribute/sdrallattribute3d.hxx>
67cdf0e10cSrcweir #include <svx/rectenum.hxx>
68cdf0e10cSrcweir #include <svx/sdtfchim.hxx>
69cdf0e10cSrcweir #include <svx/svdoutl.hxx>
70cdf0e10cSrcweir #include <svx/svdmodel.hxx>
71cdf0e10cSrcweir #include <editeng/editstat.hxx>
72cdf0e10cSrcweir #include <drawinglayer/attribute/fillhatchattribute.hxx>
73cdf0e10cSrcweir #include <drawinglayer/attribute/fillgradientattribute.hxx>
74cdf0e10cSrcweir #include <svx/sdr/attribute/sdrshadowtextattribute.hxx>
75cdf0e10cSrcweir #include <svx/sdr/attribute/sdrlineshadowtextattribute.hxx>
76cdf0e10cSrcweir #include <svx/sdr/attribute/sdrformtextattribute.hxx>
77cdf0e10cSrcweir #include <svx/sdr/attribute/sdrlinefillshadowtextattribute.hxx>
78cdf0e10cSrcweir #include <drawinglayer/attribute/sdrsceneattribute3d.hxx>
79cdf0e10cSrcweir #include <drawinglayer/attribute/sdrlightingattribute3d.hxx>
80cdf0e10cSrcweir #include <drawinglayer/attribute/sdrlightattribute3d.hxx>
81cdf0e10cSrcweir #include <svx/sdr/attribute/sdrfilltextattribute.hxx>
825aaf853bSArmin Le Grand #include <com/sun/star/drawing/LineCap.hpp>
83cdf0e10cSrcweir 
84cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
85cdf0e10cSrcweir 
86cdf0e10cSrcweir namespace drawinglayer
87cdf0e10cSrcweir {
88cdf0e10cSrcweir 	namespace
89cdf0e10cSrcweir 	{
90cdf0e10cSrcweir 		attribute::GradientStyle XGradientStyleToGradientStyle(XGradientStyle eStyle)
91cdf0e10cSrcweir 		{
92cdf0e10cSrcweir 			switch(eStyle)
93cdf0e10cSrcweir 			{
94cdf0e10cSrcweir 				case XGRAD_LINEAR :
95cdf0e10cSrcweir 				{
96cdf0e10cSrcweir 					return attribute::GRADIENTSTYLE_LINEAR;
97cdf0e10cSrcweir 				}
98cdf0e10cSrcweir 				case XGRAD_AXIAL :
99cdf0e10cSrcweir 				{
100cdf0e10cSrcweir 					return attribute::GRADIENTSTYLE_AXIAL;
101cdf0e10cSrcweir 				}
102cdf0e10cSrcweir 				case XGRAD_RADIAL :
103cdf0e10cSrcweir 				{
104cdf0e10cSrcweir 					return attribute::GRADIENTSTYLE_RADIAL;
105cdf0e10cSrcweir 				}
106cdf0e10cSrcweir 				case XGRAD_ELLIPTICAL :
107cdf0e10cSrcweir 				{
108cdf0e10cSrcweir 					return attribute::GRADIENTSTYLE_ELLIPTICAL;
109cdf0e10cSrcweir 				}
110cdf0e10cSrcweir 				case XGRAD_SQUARE :
111cdf0e10cSrcweir 				{
112cdf0e10cSrcweir 					return attribute::GRADIENTSTYLE_SQUARE;
113cdf0e10cSrcweir 				}
114cdf0e10cSrcweir 				default :
115cdf0e10cSrcweir 				{
116cdf0e10cSrcweir 					return attribute::GRADIENTSTYLE_RECT; // XGRAD_RECT
117cdf0e10cSrcweir 				}
118cdf0e10cSrcweir 			}
119cdf0e10cSrcweir 		}
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 		attribute::HatchStyle XHatchStyleToHatchStyle(XHatchStyle eStyle)
122cdf0e10cSrcweir 		{
123cdf0e10cSrcweir 			switch(eStyle)
124cdf0e10cSrcweir 			{
125cdf0e10cSrcweir 				case XHATCH_SINGLE :
126cdf0e10cSrcweir 				{
127cdf0e10cSrcweir 					return attribute::HATCHSTYLE_SINGLE;
128cdf0e10cSrcweir 				}
129cdf0e10cSrcweir 				case XHATCH_DOUBLE :
130cdf0e10cSrcweir 				{
131cdf0e10cSrcweir 					return attribute::HATCHSTYLE_DOUBLE;
132cdf0e10cSrcweir 				}
133cdf0e10cSrcweir 				default :
134cdf0e10cSrcweir 				{
135cdf0e10cSrcweir 					return attribute::HATCHSTYLE_TRIPLE; // XHATCH_TRIPLE
136cdf0e10cSrcweir 				}
137cdf0e10cSrcweir 			}
138cdf0e10cSrcweir 		}
139cdf0e10cSrcweir 
140d5370dc8SArmin Le Grand 		basegfx::B2DLineJoin LineJointToB2DLineJoin(com::sun::star::drawing::LineJoint eLineJoint)
141cdf0e10cSrcweir 		{
142cdf0e10cSrcweir 			switch(eLineJoint)
143cdf0e10cSrcweir 			{
144d5370dc8SArmin Le Grand 				case com::sun::star::drawing::LineJoint_MIDDLE :
145cdf0e10cSrcweir 				{
146cdf0e10cSrcweir 					return basegfx::B2DLINEJOIN_MIDDLE;
147cdf0e10cSrcweir 				}
148d5370dc8SArmin Le Grand 				case com::sun::star::drawing::LineJoint_BEVEL :
149cdf0e10cSrcweir 				{
150cdf0e10cSrcweir 					return basegfx::B2DLINEJOIN_BEVEL;
151cdf0e10cSrcweir 				}
152d5370dc8SArmin Le Grand 				case com::sun::star::drawing::LineJoint_MITER :
153cdf0e10cSrcweir 				{
154cdf0e10cSrcweir 					return basegfx::B2DLINEJOIN_MITER;
155cdf0e10cSrcweir 				}
156d5370dc8SArmin Le Grand 				case com::sun::star::drawing::LineJoint_ROUND :
157cdf0e10cSrcweir 				{
158cdf0e10cSrcweir 					return basegfx::B2DLINEJOIN_ROUND;
159cdf0e10cSrcweir 				}
160d5370dc8SArmin Le Grand 				default : // com::sun::star::drawing::LineJoint_NONE
161cdf0e10cSrcweir 				{
162d5370dc8SArmin Le Grand 					return basegfx::B2DLINEJOIN_NONE;
163cdf0e10cSrcweir 				}
164cdf0e10cSrcweir 			}
165cdf0e10cSrcweir 		}
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 		basegfx::B2DVector RectPointToB2DVector(RECT_POINT eRectPoint)
168cdf0e10cSrcweir 		{
169cdf0e10cSrcweir 			basegfx::B2DVector aRetval(0.0, 0.0);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 			// position changes X
172cdf0e10cSrcweir 			switch(eRectPoint)
173cdf0e10cSrcweir 			{
174cdf0e10cSrcweir 				case RP_LT: case RP_LM: case RP_LB:
175cdf0e10cSrcweir 				{
176cdf0e10cSrcweir 					aRetval.setX(-1.0);
177cdf0e10cSrcweir 					break;
178cdf0e10cSrcweir 				}
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 				case RP_RT: case RP_RM: case RP_RB:
181cdf0e10cSrcweir 				{
182cdf0e10cSrcweir 					aRetval.setX(1.0);
183cdf0e10cSrcweir 					break;
184cdf0e10cSrcweir 				}
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 				default :
187cdf0e10cSrcweir 				{
188cdf0e10cSrcweir 					break;
189cdf0e10cSrcweir 				}
190cdf0e10cSrcweir 			}
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 			// position changes Y
193cdf0e10cSrcweir 			switch(eRectPoint)
194cdf0e10cSrcweir 			{
195cdf0e10cSrcweir 				case RP_LT: case RP_MT: case RP_RT:
196cdf0e10cSrcweir 				{
197cdf0e10cSrcweir 					aRetval.setY(-1.0);
198cdf0e10cSrcweir 					break;
199cdf0e10cSrcweir 				}
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 				case RP_LB: case RP_MB: case RP_RB:
202cdf0e10cSrcweir 				{
203cdf0e10cSrcweir 					aRetval.setY(1.0);
204cdf0e10cSrcweir 					break;
205cdf0e10cSrcweir 				}
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 				default :
208cdf0e10cSrcweir 				{
209cdf0e10cSrcweir 					break;
210cdf0e10cSrcweir 				}
211cdf0e10cSrcweir 			}
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 			return aRetval;
214cdf0e10cSrcweir 		}
215cdf0e10cSrcweir 	} // end of anonymous namespace
216cdf0e10cSrcweir } // end of namespace drawinglayer
217cdf0e10cSrcweir 
218cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
219cdf0e10cSrcweir 
220cdf0e10cSrcweir namespace drawinglayer
221cdf0e10cSrcweir {
222cdf0e10cSrcweir 	namespace primitive2d
223cdf0e10cSrcweir 	{
224cdf0e10cSrcweir 		attribute::SdrLineAttribute createNewSdrLineAttribute(const SfxItemSet& rSet)
225cdf0e10cSrcweir 		{
226cdf0e10cSrcweir 			const XLineStyle eStyle(((XLineStyleItem&)(rSet.Get(XATTR_LINESTYLE))).GetValue());
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 			if(XLINE_NONE != eStyle)
229cdf0e10cSrcweir 			{
230cdf0e10cSrcweir 				sal_uInt16 nTransparence(((const XLineTransparenceItem&)(rSet.Get(XATTR_LINETRANSPARENCE))).GetValue());
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 				if(nTransparence > 100)
233cdf0e10cSrcweir 				{
234cdf0e10cSrcweir 					nTransparence = 100;
235cdf0e10cSrcweir 				}
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 				if(100 != nTransparence)
238cdf0e10cSrcweir 				{
239cdf0e10cSrcweir 					const sal_uInt32 nWidth(((const XLineWidthItem&)(rSet.Get(XATTR_LINEWIDTH))).GetValue());
240cdf0e10cSrcweir 					const Color aColor(((const XLineColorItem&)(rSet.Get(XATTR_LINECOLOR))).GetColorValue());
241d5370dc8SArmin Le Grand 					const com::sun::star::drawing::LineJoint eJoint(((const XLineJointItem&)(rSet.Get(XATTR_LINEJOINT))).GetValue());
2425aaf853bSArmin Le Grand 					const com::sun::star::drawing::LineCap eCap(((const XLineCapItem&)(rSet.Get(XATTR_LINECAP))).GetValue());
243cdf0e10cSrcweir 					::std::vector< double > aDotDashArray;
244cdf0e10cSrcweir 					double fFullDotDashLen(0.0);
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 					if(XLINE_DASH == eStyle)
247cdf0e10cSrcweir 					{
248cdf0e10cSrcweir 						const XDash& rDash = ((const XLineDashItem&)(rSet.Get(XATTR_LINEDASH))).GetDashValue();
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 						if(rDash.GetDots() || rDash.GetDashes())
251cdf0e10cSrcweir 						{
252cdf0e10cSrcweir 							fFullDotDashLen = rDash.CreateDotDashArray(aDotDashArray, (double)nWidth);
253cdf0e10cSrcweir 						}
254cdf0e10cSrcweir 					}
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 					return attribute::SdrLineAttribute(
257d5370dc8SArmin Le Grand 						LineJointToB2DLineJoin(eJoint),
258cdf0e10cSrcweir 						(double)nWidth,
259cdf0e10cSrcweir 						(double)nTransparence * 0.01,
260cdf0e10cSrcweir 						aColor.getBColor(),
2615aaf853bSArmin Le Grand                         eCap,
262cdf0e10cSrcweir 						aDotDashArray,
263cdf0e10cSrcweir 						fFullDotDashLen);
264cdf0e10cSrcweir 				}
265cdf0e10cSrcweir 			}
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 			return attribute::SdrLineAttribute();
268cdf0e10cSrcweir 		}
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 		attribute::SdrLineStartEndAttribute createNewSdrLineStartEndAttribute(
271cdf0e10cSrcweir 			const SfxItemSet& rSet,
272cdf0e10cSrcweir 			double fWidth)
273cdf0e10cSrcweir 		{
274cdf0e10cSrcweir 			const sal_Int32 nTempStartWidth(((const XLineStartWidthItem&)(rSet.Get(XATTR_LINESTARTWIDTH))).GetValue());
275cdf0e10cSrcweir 			const sal_Int32 nTempEndWidth(((const XLineEndWidthItem&)(rSet.Get(XATTR_LINEENDWIDTH))).GetValue());
276cdf0e10cSrcweir 			basegfx::B2DPolyPolygon aStartPolyPolygon;
277cdf0e10cSrcweir 			basegfx::B2DPolyPolygon aEndPolyPolygon;
278cdf0e10cSrcweir 			double fStartWidth(0.0);
279cdf0e10cSrcweir 			double fEndWidth(0.0);
280cdf0e10cSrcweir 			bool bStartActive(false);
281cdf0e10cSrcweir 			bool bEndActive(false);
282cdf0e10cSrcweir 			bool bStartCentered(true);
283cdf0e10cSrcweir 			bool bEndCentered(true);
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 			if(nTempStartWidth)
286cdf0e10cSrcweir 			{
287cdf0e10cSrcweir 				if(nTempStartWidth < 0L)
288cdf0e10cSrcweir 				{
289cdf0e10cSrcweir 					fStartWidth = ((double)(-nTempStartWidth) * fWidth) * 0.01;
290cdf0e10cSrcweir 				}
291cdf0e10cSrcweir 				else
292cdf0e10cSrcweir 				{
293cdf0e10cSrcweir 					fStartWidth = (double)nTempStartWidth;
294cdf0e10cSrcweir 				}
295cdf0e10cSrcweir 
296cdf0e10cSrcweir 				if(0.0 != fStartWidth)
297cdf0e10cSrcweir 				{
298cdf0e10cSrcweir 					aStartPolyPolygon = basegfx::B2DPolyPolygon(((const XLineStartItem&)(rSet.Get(XATTR_LINESTART))).GetLineStartValue());
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 					if(aStartPolyPolygon.count() && aStartPolyPolygon.getB2DPolygon(0L).count())
301cdf0e10cSrcweir 					{
302cdf0e10cSrcweir 						bStartActive = true;
303cdf0e10cSrcweir 						bStartCentered = ((const XLineStartCenterItem&)(rSet.Get(XATTR_LINESTARTCENTER))).GetValue();
304cdf0e10cSrcweir 					}
305cdf0e10cSrcweir 				}
306cdf0e10cSrcweir 			}
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 			if(nTempEndWidth)
309cdf0e10cSrcweir 			{
310cdf0e10cSrcweir 				if(nTempEndWidth < 0L)
311cdf0e10cSrcweir 				{
312cdf0e10cSrcweir 					fEndWidth = ((double)(-nTempEndWidth) * fWidth) * 0.01;
313cdf0e10cSrcweir 				}
314cdf0e10cSrcweir 				else
315cdf0e10cSrcweir 				{
316cdf0e10cSrcweir 					fEndWidth = (double)nTempEndWidth;
317cdf0e10cSrcweir 				}
318cdf0e10cSrcweir 
319cdf0e10cSrcweir 				if(0.0 != fEndWidth)
320cdf0e10cSrcweir 				{
321cdf0e10cSrcweir 					aEndPolyPolygon = basegfx::B2DPolyPolygon(((const XLineEndItem&)(rSet.Get(XATTR_LINEEND))).GetLineEndValue());
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 					if(aEndPolyPolygon.count() && aEndPolyPolygon.getB2DPolygon(0L).count())
324cdf0e10cSrcweir 					{
325cdf0e10cSrcweir 						bEndActive = true;
326cdf0e10cSrcweir 						bEndCentered = ((const XLineEndCenterItem&)(rSet.Get(XATTR_LINEENDCENTER))).GetValue();
327cdf0e10cSrcweir 					}
328cdf0e10cSrcweir 				}
329cdf0e10cSrcweir 			}
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 			if(bStartActive || bEndActive)
332cdf0e10cSrcweir 			{
333cdf0e10cSrcweir 				return attribute::SdrLineStartEndAttribute(
334cdf0e10cSrcweir 					aStartPolyPolygon, aEndPolyPolygon, fStartWidth, fEndWidth,
335cdf0e10cSrcweir 					bStartActive, bEndActive, bStartCentered, bEndCentered);
336cdf0e10cSrcweir 			}
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 			return attribute::SdrLineStartEndAttribute();
339cdf0e10cSrcweir 		}
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 		attribute::SdrShadowAttribute createNewSdrShadowAttribute(const SfxItemSet& rSet)
342cdf0e10cSrcweir 		{
343cdf0e10cSrcweir 			const bool bShadow(((SdrShadowItem&)rSet.Get(SDRATTR_SHADOW)).GetValue());
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 			if(bShadow)
346cdf0e10cSrcweir 			{
347cdf0e10cSrcweir 				sal_uInt16 nTransparence(((SdrShadowTransparenceItem&)(rSet.Get(SDRATTR_SHADOWTRANSPARENCE))).GetValue());
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 				if(nTransparence > 100)
350cdf0e10cSrcweir 				{
351cdf0e10cSrcweir 					nTransparence = 100;
352cdf0e10cSrcweir 				}
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 				if(nTransparence)
355cdf0e10cSrcweir 				{
356cdf0e10cSrcweir 					sal_uInt16 nFillTransparence(((const XFillTransparenceItem&)(rSet.Get(XATTR_FILLTRANSPARENCE))).GetValue());
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 					if(nFillTransparence > 100)
359cdf0e10cSrcweir 					{
360cdf0e10cSrcweir 						nFillTransparence = 100;
361cdf0e10cSrcweir 					}
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 					if(nTransparence == nFillTransparence)
364cdf0e10cSrcweir 					{
365cdf0e10cSrcweir 						// shadow does not really have an own transparence, but the application
366cdf0e10cSrcweir 						// sets the shadow transparence equal to the object transparence for
367cdf0e10cSrcweir 						// convenience. This is not useful for primitive creation, so take
368cdf0e10cSrcweir 						// this as no shadow transparence
369cdf0e10cSrcweir 						nTransparence = 0;
370cdf0e10cSrcweir 					}
371cdf0e10cSrcweir 				}
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 				if(100 != nTransparence)
374cdf0e10cSrcweir 				{
375cdf0e10cSrcweir 					const basegfx::B2DVector aOffset(
376cdf0e10cSrcweir 						(double)((SdrShadowXDistItem&)(rSet.Get(SDRATTR_SHADOWXDIST))).GetValue(),
377cdf0e10cSrcweir 						(double)((SdrShadowYDistItem&)(rSet.Get(SDRATTR_SHADOWYDIST))).GetValue());
378cdf0e10cSrcweir 					const Color aColor(((SdrShadowColorItem&)(rSet.Get(SDRATTR_SHADOWCOLOR))).GetColorValue());
379cdf0e10cSrcweir 
380cdf0e10cSrcweir 					return attribute::SdrShadowAttribute(aOffset, (double)nTransparence * 0.01, aColor.getBColor());
381cdf0e10cSrcweir 				}
382cdf0e10cSrcweir 			}
383cdf0e10cSrcweir 
384cdf0e10cSrcweir 			return attribute::SdrShadowAttribute();
385cdf0e10cSrcweir 		}
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 		attribute::SdrFillAttribute createNewSdrFillAttribute(const SfxItemSet& rSet)
388cdf0e10cSrcweir 		{
389cdf0e10cSrcweir 			const XFillStyle eStyle(((XFillStyleItem&)(rSet.Get(XATTR_FILLSTYLE))).GetValue());
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 			if(XFILL_NONE != eStyle)
392cdf0e10cSrcweir 			{
393cdf0e10cSrcweir 				sal_uInt16 nTransparence(((const XFillTransparenceItem&)(rSet.Get(XATTR_FILLTRANSPARENCE))).GetValue());
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 				if(nTransparence > 100)
396cdf0e10cSrcweir 				{
397cdf0e10cSrcweir 					nTransparence = 100;
398cdf0e10cSrcweir 				}
399cdf0e10cSrcweir 
400*6b9bd1deSArmin Le Grand 				if(100 != nTransparence)
401*6b9bd1deSArmin Le Grand 				{
402*6b9bd1deSArmin Le Grand                     // need to check XFillFloatTransparence, object fill may still be completely transparent
403*6b9bd1deSArmin Le Grand                     const SfxPoolItem* pGradientItem;
404*6b9bd1deSArmin Le Grand 
405*6b9bd1deSArmin Le Grand                     if(SFX_ITEM_SET == rSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE, sal_True, &pGradientItem)
406*6b9bd1deSArmin Le Grand                         && ((XFillFloatTransparenceItem*)pGradientItem)->IsEnabled())
407*6b9bd1deSArmin Le Grand                     {
408*6b9bd1deSArmin Le Grand                         const XGradient& rGradient = ((XFillFloatTransparenceItem*)pGradientItem)->GetGradientValue();
409*6b9bd1deSArmin Le Grand                         const sal_uInt8 nStartLuminance(rGradient.GetStartColor().GetLuminance());
410*6b9bd1deSArmin Le Grand                         const sal_uInt8 nEndLuminance(rGradient.GetEndColor().GetLuminance());
411*6b9bd1deSArmin Le Grand                         const bool bCompletelyTransparent(0xff == nStartLuminance && 0xff == nEndLuminance);
412*6b9bd1deSArmin Le Grand 
413*6b9bd1deSArmin Le Grand                         if(bCompletelyTransparent)
414*6b9bd1deSArmin Le Grand                         {
415*6b9bd1deSArmin Le Grand                             nTransparence = 100;
416*6b9bd1deSArmin Le Grand                         }
417*6b9bd1deSArmin Le Grand                     }
418*6b9bd1deSArmin Le Grand                 }
419*6b9bd1deSArmin Le Grand 
420cdf0e10cSrcweir 				if(100 != nTransparence)
421cdf0e10cSrcweir 				{
422cdf0e10cSrcweir 					const Color aColor(((const XFillColorItem&)(rSet.Get(XATTR_FILLCOLOR))).GetColorValue());
423cdf0e10cSrcweir 					attribute::FillGradientAttribute aGradient;
424cdf0e10cSrcweir 					attribute::FillHatchAttribute aHatch;
425035a2f44SArmin Le Grand 					attribute::SdrFillGraphicAttribute aFillGraphic;
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 					switch(eStyle)
428cdf0e10cSrcweir 					{
429cdf0e10cSrcweir 						case XFILL_NONE : // for warnings
430cdf0e10cSrcweir 						case XFILL_SOLID :
431cdf0e10cSrcweir 						{
432cdf0e10cSrcweir 							// nothing to do, color is defined
433cdf0e10cSrcweir 							break;
434cdf0e10cSrcweir 						}
435cdf0e10cSrcweir 						case XFILL_GRADIENT :
436cdf0e10cSrcweir 						{
437cdf0e10cSrcweir 							XGradient aXGradient(((XFillGradientItem&)(rSet.Get(XATTR_FILLGRADIENT))).GetGradientValue());
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 							const Color aStartColor(aXGradient.GetStartColor());
440cdf0e10cSrcweir 							const sal_uInt16 nStartIntens(aXGradient.GetStartIntens());
441cdf0e10cSrcweir 							basegfx::BColor aStart(aStartColor.getBColor());
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 							if(nStartIntens != 100)
444cdf0e10cSrcweir 							{
445cdf0e10cSrcweir 								const basegfx::BColor aBlack;
446cdf0e10cSrcweir 								aStart = interpolate(aBlack, aStart, (double)nStartIntens * 0.01);
447cdf0e10cSrcweir 							}
448cdf0e10cSrcweir 
449cdf0e10cSrcweir 							const Color aEndColor(aXGradient.GetEndColor());
450cdf0e10cSrcweir 							const sal_uInt16 nEndIntens(aXGradient.GetEndIntens());
451cdf0e10cSrcweir 							basegfx::BColor aEnd(aEndColor.getBColor());
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 							if(nEndIntens != 100)
454cdf0e10cSrcweir 							{
455cdf0e10cSrcweir 								const basegfx::BColor aBlack;
456cdf0e10cSrcweir 								aEnd = interpolate(aBlack, aEnd, (double)nEndIntens * 0.01);
457cdf0e10cSrcweir 							}
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 							aGradient = attribute::FillGradientAttribute(
460cdf0e10cSrcweir 								XGradientStyleToGradientStyle(aXGradient.GetGradientStyle()),
461cdf0e10cSrcweir 								(double)aXGradient.GetBorder() * 0.01,
462cdf0e10cSrcweir 								(double)aXGradient.GetXOffset() * 0.01,
463cdf0e10cSrcweir 								(double)aXGradient.GetYOffset() * 0.01,
464cdf0e10cSrcweir 								(double)aXGradient.GetAngle() * F_PI1800,
465cdf0e10cSrcweir 								aStart,
466cdf0e10cSrcweir 								aEnd,
467cdf0e10cSrcweir 								((const XGradientStepCountItem&)rSet.Get(XATTR_GRADIENTSTEPCOUNT)).GetValue());
468cdf0e10cSrcweir 
469cdf0e10cSrcweir 							break;
470cdf0e10cSrcweir 						}
471cdf0e10cSrcweir 						case XFILL_HATCH :
472cdf0e10cSrcweir 						{
473cdf0e10cSrcweir 							const XHatch& rHatch(((XFillHatchItem&)(rSet.Get(XATTR_FILLHATCH))).GetHatchValue());
474cdf0e10cSrcweir 							const Color aColorB(rHatch.GetColor());
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 							aHatch = attribute::FillHatchAttribute(
477cdf0e10cSrcweir 								XHatchStyleToHatchStyle(rHatch.GetHatchStyle()),
478cdf0e10cSrcweir 								(double)rHatch.GetDistance(),
479cdf0e10cSrcweir 								(double)rHatch.GetAngle() * F_PI1800,
480cdf0e10cSrcweir 								aColorB.getBColor(),
4810702bc67SArmin Le Grand                                 3, // same default as VCL, a minimum of three discrete units (pixels) offset
482cdf0e10cSrcweir 								((const XFillBackgroundItem&)(rSet.Get(XATTR_FILLBACKGROUND))).GetValue());
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 							break;
485cdf0e10cSrcweir 						}
486cdf0e10cSrcweir 						case XFILL_BITMAP :
487cdf0e10cSrcweir 						{
488035a2f44SArmin Le Grand 							aFillGraphic = createNewSdrFillGraphicAttribute(rSet);
489cdf0e10cSrcweir 							break;
490cdf0e10cSrcweir 						}
491cdf0e10cSrcweir 					}
492cdf0e10cSrcweir 
493cdf0e10cSrcweir 					return attribute::SdrFillAttribute(
494cdf0e10cSrcweir 						(double)nTransparence * 0.01,
495cdf0e10cSrcweir 						aColor.getBColor(),
496cdf0e10cSrcweir 						aGradient,
497cdf0e10cSrcweir 						aHatch,
498035a2f44SArmin Le Grand 						aFillGraphic);
499cdf0e10cSrcweir 				}
500cdf0e10cSrcweir 			}
501cdf0e10cSrcweir 
502cdf0e10cSrcweir 			return attribute::SdrFillAttribute();
503cdf0e10cSrcweir 		}
504cdf0e10cSrcweir 
505cdf0e10cSrcweir 		// #i101508# Support handing over given text-to-border distances
506cdf0e10cSrcweir 		attribute::SdrTextAttribute createNewSdrTextAttribute(
507cdf0e10cSrcweir 			const SfxItemSet& rSet,
508cdf0e10cSrcweir 			const SdrText& rText,
509cdf0e10cSrcweir 			const sal_Int32* pLeft,
510cdf0e10cSrcweir 			const sal_Int32* pUpper,
511cdf0e10cSrcweir 			const sal_Int32* pRight,
512cdf0e10cSrcweir 			const sal_Int32* pLower)
513cdf0e10cSrcweir 		{
514cdf0e10cSrcweir 			const SdrTextObj& rTextObj = rText.GetObject();
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 			if(rText.GetOutlinerParaObject() && rText.GetModel())
517cdf0e10cSrcweir 			{
518cdf0e10cSrcweir 				// added TextEdit text suppression
519cdf0e10cSrcweir 				bool bInEditMode(false);
520cdf0e10cSrcweir 
521cdf0e10cSrcweir 				if(rText.GetObject().getTextCount() > 1)
522cdf0e10cSrcweir 				{
523cdf0e10cSrcweir 					bInEditMode = rTextObj.IsInEditMode() && rText.GetObject().getActiveText() == &rText;
524cdf0e10cSrcweir 				}
525cdf0e10cSrcweir 				else
526cdf0e10cSrcweir 				{
527cdf0e10cSrcweir 					bInEditMode = rTextObj.IsInEditMode();
528cdf0e10cSrcweir 				}
529cdf0e10cSrcweir 
530cdf0e10cSrcweir                 OutlinerParaObject aOutlinerParaObject(*rText.GetOutlinerParaObject());
531cdf0e10cSrcweir 
532cdf0e10cSrcweir                 if(bInEditMode)
533cdf0e10cSrcweir                 {
534cdf0e10cSrcweir                     OutlinerParaObject* pTempObj = rTextObj.GetEditOutlinerParaObject();
535cdf0e10cSrcweir 
536cdf0e10cSrcweir                     if(pTempObj)
537cdf0e10cSrcweir                     {
538cdf0e10cSrcweir                         aOutlinerParaObject = *pTempObj;
539cdf0e10cSrcweir                         delete pTempObj;
540cdf0e10cSrcweir                     }
541cdf0e10cSrcweir                     else
542cdf0e10cSrcweir                     {
543cdf0e10cSrcweir                         // #i100537#
544cdf0e10cSrcweir                         // GetEditOutlinerParaObject() returning no object does not mean that
545cdf0e10cSrcweir                         // text edit mode is not active. Do not reset the flag here
546cdf0e10cSrcweir                         // bInEditMode = false;
547cdf0e10cSrcweir                     }
548cdf0e10cSrcweir                 }
549cdf0e10cSrcweir 
55026734c99SArmin Le Grand 			    const SdrFitToSizeType eFit(rTextObj.GetFitToSize());
551cdf0e10cSrcweir 			    const SdrTextAniKind eAniKind(rTextObj.GetTextAniKind());
552cdf0e10cSrcweir 
553cdf0e10cSrcweir 				// #i107346#
554cdf0e10cSrcweir 				const SdrOutliner& rDrawTextOutliner = rText.GetModel()->GetDrawOutliner(&rTextObj);
555cdf0e10cSrcweir 				const bool bWrongSpell(rDrawTextOutliner.GetControlWord() & EE_CNTRL_ONLINESPELLING);
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 			    return attribute::SdrTextAttribute(
558cdf0e10cSrcweir 				    rText,
559cdf0e10cSrcweir                     aOutlinerParaObject,
560cdf0e10cSrcweir 				    ((const XFormTextStyleItem&)rSet.Get(XATTR_FORMTXTSTYLE)).GetValue(),
561cdf0e10cSrcweir 					pLeft ? *pLeft : rTextObj.GetTextLeftDistance(),
562cdf0e10cSrcweir 					pUpper ? *pUpper : rTextObj.GetTextUpperDistance(),
563cdf0e10cSrcweir 					pRight ? *pRight : rTextObj.GetTextRightDistance(),
564cdf0e10cSrcweir 					pLower ? *pLower : rTextObj.GetTextLowerDistance(),
565cdf0e10cSrcweir                     rTextObj.GetTextHorizontalAdjust(rSet),
566cdf0e10cSrcweir                     rTextObj.GetTextVerticalAdjust(rSet),
567cdf0e10cSrcweir 				    ((const SdrTextContourFrameItem&)rSet.Get(SDRATTR_TEXT_CONTOURFRAME)).GetValue(),
56826734c99SArmin Le Grand 				    (SDRTEXTFIT_PROPORTIONAL == eFit || SDRTEXTFIT_ALLLINES == eFit),
569cdf0e10cSrcweir 				    ((const XFormTextHideFormItem&)rSet.Get(XATTR_FORMTXTHIDEFORM)).GetValue(),
570cdf0e10cSrcweir 				    SDRTEXTANI_BLINK == eAniKind,
571cdf0e10cSrcweir 				    SDRTEXTANI_SCROLL == eAniKind || SDRTEXTANI_ALTERNATE == eAniKind || SDRTEXTANI_SLIDE == eAniKind,
572cdf0e10cSrcweir                     bInEditMode,
573cdf0e10cSrcweir                     ((const SdrTextFixedCellHeightItem&)rSet.Get(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue(),
574cdf0e10cSrcweir 					bWrongSpell);
575cdf0e10cSrcweir 			}
576cdf0e10cSrcweir 
577cdf0e10cSrcweir 			return attribute::SdrTextAttribute();
578cdf0e10cSrcweir 		}
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 		attribute::FillGradientAttribute createNewTransparenceGradientAttribute(const SfxItemSet& rSet)
581cdf0e10cSrcweir 		{
582cdf0e10cSrcweir 			const SfxPoolItem* pGradientItem;
583cdf0e10cSrcweir 
584cdf0e10cSrcweir 			if(SFX_ITEM_SET == rSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE, sal_True, &pGradientItem)
585cdf0e10cSrcweir 				&& ((XFillFloatTransparenceItem*)pGradientItem)->IsEnabled())
586cdf0e10cSrcweir 			{
587cdf0e10cSrcweir 				// test if float transparence is completely transparent
588cdf0e10cSrcweir 				const XGradient& rGradient = ((XFillFloatTransparenceItem*)pGradientItem)->GetGradientValue();
589cdf0e10cSrcweir 				const sal_uInt8 nStartLuminance(rGradient.GetStartColor().GetLuminance());
590cdf0e10cSrcweir 				const sal_uInt8 nEndLuminance(rGradient.GetEndColor().GetLuminance());
591cdf0e10cSrcweir 				const bool bCompletelyTransparent(0xff == nStartLuminance && 0xff == nEndLuminance);
592*6b9bd1deSArmin Le Grand 				const bool bNotTransparent(0x00 == nStartLuminance && 0x00 == nEndLuminance);
593cdf0e10cSrcweir 
594*6b9bd1deSArmin Le Grand                 // create nothing when completely transparent: This case is already checked for the
595*6b9bd1deSArmin Le Grand                 // normal fill attributes, XFILL_NONE will be used.
596*6b9bd1deSArmin Le Grand                 // create nothing when not transparent: use normal fill, no need t create a FillGradientAttribute.
597*6b9bd1deSArmin Le Grand                 // Both cases are optimizations, always creating FillGradientAttribute will work, too
598*6b9bd1deSArmin Le Grand 				if(!bNotTransparent && !bCompletelyTransparent)
599cdf0e10cSrcweir 				{
600cdf0e10cSrcweir 					const double fStartLum(nStartLuminance / 255.0);
601cdf0e10cSrcweir 					const double fEndLum(nEndLuminance / 255.0);
602cdf0e10cSrcweir 
603cdf0e10cSrcweir 					return attribute::FillGradientAttribute(
604cdf0e10cSrcweir 						XGradientStyleToGradientStyle(rGradient.GetGradientStyle()),
605cdf0e10cSrcweir 						(double)rGradient.GetBorder() * 0.01,
606cdf0e10cSrcweir 						(double)rGradient.GetXOffset() * 0.01,
607cdf0e10cSrcweir 						(double)rGradient.GetYOffset() * 0.01,
608cdf0e10cSrcweir 						(double)rGradient.GetAngle() * F_PI1800,
609cdf0e10cSrcweir 						basegfx::BColor(fStartLum, fStartLum, fStartLum),
610cdf0e10cSrcweir 						basegfx::BColor(fEndLum, fEndLum, fEndLum),
611cdf0e10cSrcweir 						0);
612cdf0e10cSrcweir 				}
613cdf0e10cSrcweir 			}
614cdf0e10cSrcweir 
615cdf0e10cSrcweir 			return attribute::FillGradientAttribute();
616cdf0e10cSrcweir 		}
617cdf0e10cSrcweir 
618035a2f44SArmin Le Grand 		attribute::SdrFillGraphicAttribute createNewSdrFillGraphicAttribute(const SfxItemSet& rSet)
619cdf0e10cSrcweir 		{
620035a2f44SArmin Le Grand             Graphic aGraphic(((const XFillBitmapItem&)(rSet.Get(XATTR_FILLBITMAP))).GetGraphicObject().GetGraphic());
621cdf0e10cSrcweir 
622035a2f44SArmin Le Grand             if(!(GRAPHIC_BITMAP == aGraphic.GetType() || GRAPHIC_GDIMETAFILE == aGraphic.GetType()))
623035a2f44SArmin Le Grand             {
624035a2f44SArmin Le Grand                 // no content if not bitmap or metafile
625035a2f44SArmin Le Grand                 OSL_ENSURE(false, "No fill graphic in SfxItemSet (!)");
626035a2f44SArmin Le Grand                 return attribute::SdrFillGraphicAttribute();
627035a2f44SArmin Le Grand             }
628cdf0e10cSrcweir 
629035a2f44SArmin Le Grand             Size aPrefSize(aGraphic.GetPrefSize());
630035a2f44SArmin Le Grand 
631035a2f44SArmin Le Grand             if(!aPrefSize.Width() || !aPrefSize.Height())
632035a2f44SArmin Le Grand             {
633035a2f44SArmin Le Grand                 // if there is no logical size, create a size from pixel size and set MapMode accordingly
634035a2f44SArmin Le Grand                 if(GRAPHIC_BITMAP == aGraphic.GetType())
635035a2f44SArmin Le Grand                 {
636035a2f44SArmin Le Grand                     aGraphic.SetPrefSize(aGraphic.GetBitmapEx().GetSizePixel());
637035a2f44SArmin Le Grand                     aGraphic.SetPrefMapMode(MAP_PIXEL);
638035a2f44SArmin Le Grand                 }
639035a2f44SArmin Le Grand             }
640035a2f44SArmin Le Grand 
641035a2f44SArmin Le Grand             if(!aPrefSize.Width() || !aPrefSize.Height())
642035a2f44SArmin Le Grand             {
643035a2f44SArmin Le Grand                 // no content if no size
644035a2f44SArmin Le Grand                 OSL_ENSURE(false, "Graphic has no size in SfxItemSet (!)");
645035a2f44SArmin Le Grand                 return attribute::SdrFillGraphicAttribute();
646035a2f44SArmin Le Grand             }
647035a2f44SArmin Le Grand 
648035a2f44SArmin Le Grand             // convert size and MapMode to destination logical size and MapMode
649035a2f44SArmin Le Grand             const MapUnit aDestinationMapUnit((MapUnit)rSet.GetPool()->GetMetric(0));
650035a2f44SArmin Le Grand 
651035a2f44SArmin Le Grand             if(aGraphic.GetPrefMapMode() != aDestinationMapUnit)
652035a2f44SArmin Le Grand             {
653035a2f44SArmin Le Grand                 // #i100360# for MAP_PIXEL, LogicToLogic will not work properly,
654cdf0e10cSrcweir                 // so fallback to Application::GetDefaultDevice()
655035a2f44SArmin Le Grand                 if(MAP_PIXEL == aGraphic.GetPrefMapMode().GetMapUnit())
656cdf0e10cSrcweir                 {
657035a2f44SArmin Le Grand                     aGraphic.SetPrefSize(
658035a2f44SArmin Le Grand                         Application::GetDefaultDevice()->PixelToLogic(
659035a2f44SArmin Le Grand                             aGraphic.GetPrefSize(),
660035a2f44SArmin Le Grand                             aDestinationMapUnit));
661cdf0e10cSrcweir                 }
662cdf0e10cSrcweir                 else
663cdf0e10cSrcweir                 {
664035a2f44SArmin Le Grand                     aGraphic.SetPrefSize(
665035a2f44SArmin Le Grand                         OutputDevice::LogicToLogic(
666035a2f44SArmin Le Grand                             aGraphic.GetPrefSize(),
667035a2f44SArmin Le Grand                             aGraphic.GetPrefMapMode(),
668035a2f44SArmin Le Grand                             aDestinationMapUnit));
669cdf0e10cSrcweir                 }
670035a2f44SArmin Le Grand             }
671cdf0e10cSrcweir 
672cdf0e10cSrcweir 			// get size
673cdf0e10cSrcweir 			const basegfx::B2DVector aSize(
674cdf0e10cSrcweir 				(double)((const SfxMetricItem&)(rSet.Get(XATTR_FILLBMP_SIZEX))).GetValue(),
675cdf0e10cSrcweir 				(double)((const SfxMetricItem&)(rSet.Get(XATTR_FILLBMP_SIZEY))).GetValue());
676cdf0e10cSrcweir 			const basegfx::B2DVector aOffset(
677cdf0e10cSrcweir 				(double)((const SfxUInt16Item&) (rSet.Get(XATTR_FILLBMP_TILEOFFSETX))).GetValue(),
678cdf0e10cSrcweir 				(double)((const SfxUInt16Item&) (rSet.Get(XATTR_FILLBMP_TILEOFFSETY))).GetValue());
679cdf0e10cSrcweir 			const basegfx::B2DVector aOffsetPosition(
680cdf0e10cSrcweir 				(double)((const SfxUInt16Item&) (rSet.Get(XATTR_FILLBMP_POSOFFSETX))).GetValue(),
681cdf0e10cSrcweir 				(double)((const SfxUInt16Item&) (rSet.Get(XATTR_FILLBMP_POSOFFSETY))).GetValue());
682cdf0e10cSrcweir 
683035a2f44SArmin Le Grand 			return attribute::SdrFillGraphicAttribute(
684035a2f44SArmin Le Grand 				aGraphic,
685cdf0e10cSrcweir 				aSize,
686cdf0e10cSrcweir 				aOffset,
687cdf0e10cSrcweir 				aOffsetPosition,
688cdf0e10cSrcweir 				RectPointToB2DVector((RECT_POINT)((const SfxEnumItem&)(rSet.Get(XATTR_FILLBMP_POS))).GetValue()),
689cdf0e10cSrcweir 				((const SfxBoolItem&) (rSet.Get(XATTR_FILLBMP_TILE))).GetValue(),
690cdf0e10cSrcweir 				((const SfxBoolItem&) (rSet.Get(XATTR_FILLBMP_STRETCH))).GetValue(),
691cdf0e10cSrcweir 				((const SfxBoolItem&) (rSet.Get(XATTR_FILLBMP_SIZELOG))).GetValue());
692cdf0e10cSrcweir 		}
693cdf0e10cSrcweir 
694cdf0e10cSrcweir 		attribute::SdrShadowTextAttribute createNewSdrShadowTextAttribute(
695cdf0e10cSrcweir             const SfxItemSet& rSet,
696cdf0e10cSrcweir             const SdrText* pText,
697cdf0e10cSrcweir             bool bSuppressText)
698cdf0e10cSrcweir 		{
699cdf0e10cSrcweir 			attribute::SdrTextAttribute aText;
700cdf0e10cSrcweir 
701cdf0e10cSrcweir 			// #i98072# added option to suppress text
702cdf0e10cSrcweir             // look for text first
703cdf0e10cSrcweir             if(!bSuppressText && pText)
704cdf0e10cSrcweir             {
705cdf0e10cSrcweir     			aText = createNewSdrTextAttribute(rSet, *pText);
706cdf0e10cSrcweir             }
707cdf0e10cSrcweir 
708cdf0e10cSrcweir 			// try shadow
709cdf0e10cSrcweir 			const attribute::SdrShadowAttribute aShadow(createNewSdrShadowAttribute(rSet));
710cdf0e10cSrcweir 
711cdf0e10cSrcweir 			return attribute::SdrShadowTextAttribute(aShadow, aText);
712cdf0e10cSrcweir 		}
713cdf0e10cSrcweir 
714cdf0e10cSrcweir 		attribute::SdrLineShadowTextAttribute createNewSdrLineShadowTextAttribute(
715cdf0e10cSrcweir             const SfxItemSet& rSet,
716cdf0e10cSrcweir             const SdrText* pText)
717cdf0e10cSrcweir 		{
718cdf0e10cSrcweir 			attribute::SdrLineAttribute aLine;
719cdf0e10cSrcweir 			attribute::SdrLineStartEndAttribute aLineStartEnd;
720cdf0e10cSrcweir 			attribute::SdrTextAttribute aText;
721cdf0e10cSrcweir 			bool bFontworkHideContour(false);
722cdf0e10cSrcweir 
723cdf0e10cSrcweir 			// look for text first
724cdf0e10cSrcweir             if(pText)
725cdf0e10cSrcweir             {
726cdf0e10cSrcweir     			aText = createNewSdrTextAttribute(rSet, *pText);
727cdf0e10cSrcweir 
728cdf0e10cSrcweir 			    // when object has text and text is fontwork and hide contour is set for fontwork, force
729cdf0e10cSrcweir 			    // line and fill style to empty
730cdf0e10cSrcweir 			    if(!aText.isDefault()
731cdf0e10cSrcweir                     && !aText.getSdrFormTextAttribute().isDefault()
732cdf0e10cSrcweir                     && aText.isHideContour())
733cdf0e10cSrcweir 			    {
734cdf0e10cSrcweir 				    bFontworkHideContour = true;
735cdf0e10cSrcweir 			    }
736cdf0e10cSrcweir 			}
737cdf0e10cSrcweir 
738cdf0e10cSrcweir 			// try line style
739cdf0e10cSrcweir 			if(!bFontworkHideContour)
740cdf0e10cSrcweir 			{
741cdf0e10cSrcweir 				aLine = createNewSdrLineAttribute(rSet);
742cdf0e10cSrcweir 
743cdf0e10cSrcweir 				if(!aLine.isDefault())
744cdf0e10cSrcweir 				{
745cdf0e10cSrcweir 					// try LineStartEnd
746cdf0e10cSrcweir 					aLineStartEnd = createNewSdrLineStartEndAttribute(rSet, aLine.getWidth());
747cdf0e10cSrcweir 				}
748cdf0e10cSrcweir 			}
749cdf0e10cSrcweir 
750cdf0e10cSrcweir 			if(!aLine.isDefault() || !aText.isDefault())
751cdf0e10cSrcweir 			{
752cdf0e10cSrcweir 				// try shadow
753cdf0e10cSrcweir 				const attribute::SdrShadowAttribute aShadow(createNewSdrShadowAttribute(rSet));
754cdf0e10cSrcweir 
755cdf0e10cSrcweir 				return attribute::SdrLineShadowTextAttribute(aLine, aLineStartEnd, aShadow, aText);
756cdf0e10cSrcweir 			}
757cdf0e10cSrcweir 
758cdf0e10cSrcweir 			return attribute::SdrLineShadowTextAttribute();
759cdf0e10cSrcweir 		}
760cdf0e10cSrcweir 
761cdf0e10cSrcweir 		attribute::SdrLineFillShadowTextAttribute createNewSdrLineFillShadowTextAttribute(
762cdf0e10cSrcweir             const SfxItemSet& rSet,
7634bf7a51aSArmin Le Grand             const SdrText* pText,
7644bf7a51aSArmin Le Grand             bool bHasContent)
765cdf0e10cSrcweir 		{
766cdf0e10cSrcweir 			attribute::SdrLineAttribute aLine;
767cdf0e10cSrcweir 			attribute::SdrFillAttribute aFill;
768cdf0e10cSrcweir 			attribute::SdrLineStartEndAttribute aLineStartEnd;
769cdf0e10cSrcweir 			attribute::SdrShadowAttribute aShadow;
770cdf0e10cSrcweir 			attribute::FillGradientAttribute aFillFloatTransGradient;
771cdf0e10cSrcweir 			attribute::SdrTextAttribute aText;
772cdf0e10cSrcweir 			bool bFontworkHideContour(false);
773cdf0e10cSrcweir 
774cdf0e10cSrcweir 			// look for text first
775cdf0e10cSrcweir             if(pText)
776cdf0e10cSrcweir             {
777cdf0e10cSrcweir     			aText = createNewSdrTextAttribute(rSet, *pText);
778cdf0e10cSrcweir 
779cdf0e10cSrcweir 			    // when object has text and text is fontwork and hide contour is set for fontwork, force
780cdf0e10cSrcweir 			    // line and fill style to empty
781cdf0e10cSrcweir 			    if(!aText.getSdrFormTextAttribute().isDefault() && aText.isHideContour())
782cdf0e10cSrcweir 			    {
783cdf0e10cSrcweir 				    bFontworkHideContour = true;
784cdf0e10cSrcweir 			    }
785cdf0e10cSrcweir             }
786cdf0e10cSrcweir 
787cdf0e10cSrcweir 			if(!bFontworkHideContour)
788cdf0e10cSrcweir 			{
789cdf0e10cSrcweir 				// try line style
790cdf0e10cSrcweir 				aLine = createNewSdrLineAttribute(rSet);
791cdf0e10cSrcweir 
792cdf0e10cSrcweir 				if(!aLine.isDefault())
793cdf0e10cSrcweir 				{
794cdf0e10cSrcweir 					// try LineStartEnd
795cdf0e10cSrcweir 					aLineStartEnd = createNewSdrLineStartEndAttribute(rSet, aLine.getWidth());
796cdf0e10cSrcweir 				}
797cdf0e10cSrcweir 
798cdf0e10cSrcweir 				// try fill style
799cdf0e10cSrcweir 				aFill = createNewSdrFillAttribute(rSet);
800cdf0e10cSrcweir 
801cdf0e10cSrcweir 				if(!aFill.isDefault())
802cdf0e10cSrcweir 				{
803cdf0e10cSrcweir 					// try fillfloattransparence
804cdf0e10cSrcweir 					aFillFloatTransGradient = createNewTransparenceGradientAttribute(rSet);
805cdf0e10cSrcweir 				}
806cdf0e10cSrcweir 			}
807cdf0e10cSrcweir 
8084bf7a51aSArmin Le Grand             // bHasContent is used from OLE and graphic objects. Normally a possible shadow
8094bf7a51aSArmin Le Grand             // depends on line, fill or text to be set, but for these objects it is possible
8104bf7a51aSArmin Le Grand             // to have none of these, but still content which needs to have a shadow (if set),
8114bf7a51aSArmin Le Grand             // so shadow needs to be tried
8124bf7a51aSArmin Le Grand 			if(bHasContent || !aLine.isDefault() || !aFill.isDefault() || !aText.isDefault())
813cdf0e10cSrcweir 			{
814cdf0e10cSrcweir 				// try shadow
815cdf0e10cSrcweir 				aShadow = createNewSdrShadowAttribute(rSet);
816cdf0e10cSrcweir 
817cdf0e10cSrcweir 				return attribute::SdrLineFillShadowTextAttribute(
818cdf0e10cSrcweir 					aLine, aFill, aLineStartEnd, aShadow, aFillFloatTransGradient, aText);
819cdf0e10cSrcweir 			}
820cdf0e10cSrcweir 
821cdf0e10cSrcweir 			return attribute::SdrLineFillShadowTextAttribute();
822cdf0e10cSrcweir 		}
823cdf0e10cSrcweir 
824cdf0e10cSrcweir 		attribute::SdrLineFillShadowAttribute3D createNewSdrLineFillShadowAttribute(const SfxItemSet& rSet, bool bSuppressFill)
825cdf0e10cSrcweir 		{
826cdf0e10cSrcweir 			attribute::SdrFillAttribute aFill;
827cdf0e10cSrcweir 			attribute::SdrLineStartEndAttribute aLineStartEnd;
828cdf0e10cSrcweir 			attribute::SdrShadowAttribute aShadow;
829cdf0e10cSrcweir 			attribute::FillGradientAttribute aFillFloatTransGradient;
830cdf0e10cSrcweir 
831cdf0e10cSrcweir 			// try line style
832cdf0e10cSrcweir 			const attribute::SdrLineAttribute aLine(createNewSdrLineAttribute(rSet));
833cdf0e10cSrcweir 
834cdf0e10cSrcweir 			if(!aLine.isDefault())
835cdf0e10cSrcweir 			{
836cdf0e10cSrcweir 				// try LineStartEnd
837cdf0e10cSrcweir 				aLineStartEnd = createNewSdrLineStartEndAttribute(rSet, aLine.getWidth());
838cdf0e10cSrcweir 			}
839cdf0e10cSrcweir 
840cdf0e10cSrcweir 			// try fill style
841cdf0e10cSrcweir 			if(!bSuppressFill)
842cdf0e10cSrcweir 			{
843cdf0e10cSrcweir 				aFill = createNewSdrFillAttribute(rSet);
844cdf0e10cSrcweir 
845cdf0e10cSrcweir 				if(!aFill.isDefault())
846cdf0e10cSrcweir 				{
847cdf0e10cSrcweir 					// try fillfloattransparence
848cdf0e10cSrcweir 					aFillFloatTransGradient = createNewTransparenceGradientAttribute(rSet);
849cdf0e10cSrcweir 				}
850cdf0e10cSrcweir 			}
851cdf0e10cSrcweir 
852cdf0e10cSrcweir 			if(!aLine.isDefault() || !aFill.isDefault())
853cdf0e10cSrcweir 			{
854cdf0e10cSrcweir 				// try shadow
855cdf0e10cSrcweir 				aShadow = createNewSdrShadowAttribute(rSet);
856cdf0e10cSrcweir 
857cdf0e10cSrcweir 				return attribute::SdrLineFillShadowAttribute3D(
858cdf0e10cSrcweir 					aLine, aFill, aLineStartEnd, aShadow, aFillFloatTransGradient);
859cdf0e10cSrcweir 			}
860cdf0e10cSrcweir 
861cdf0e10cSrcweir 			return attribute::SdrLineFillShadowAttribute3D();
862cdf0e10cSrcweir 		}
863cdf0e10cSrcweir 
864cdf0e10cSrcweir 		attribute::SdrSceneAttribute createNewSdrSceneAttribute(const SfxItemSet& rSet)
865cdf0e10cSrcweir 		{
866cdf0e10cSrcweir 			// get perspective
867cdf0e10cSrcweir 			::com::sun::star::drawing::ProjectionMode aProjectionMode(::com::sun::star::drawing::ProjectionMode_PARALLEL);
868cdf0e10cSrcweir 			const sal_uInt16 nProjectionValue(((const Svx3DPerspectiveItem&)rSet.Get(SDRATTR_3DSCENE_PERSPECTIVE)).GetValue());
869cdf0e10cSrcweir 
870cdf0e10cSrcweir 			if(1L == nProjectionValue)
871cdf0e10cSrcweir 			{
872cdf0e10cSrcweir 				aProjectionMode = ::com::sun::star::drawing::ProjectionMode_PERSPECTIVE;
873cdf0e10cSrcweir 			}
874cdf0e10cSrcweir 
875cdf0e10cSrcweir 			// get distance
876cdf0e10cSrcweir 			const double fDistance(((const Svx3DDistanceItem&)rSet.Get(SDRATTR_3DSCENE_DISTANCE)).GetValue());
877cdf0e10cSrcweir 
878cdf0e10cSrcweir 			// get shadow slant
879cdf0e10cSrcweir 			const double fShadowSlant(F_PI180 * ((const Svx3DShadowSlantItem&)rSet.Get(SDRATTR_3DSCENE_SHADOW_SLANT)).GetValue());
880cdf0e10cSrcweir 
881cdf0e10cSrcweir 			// get shade mode
882cdf0e10cSrcweir 			::com::sun::star::drawing::ShadeMode aShadeMode(::com::sun::star::drawing::ShadeMode_FLAT);
883cdf0e10cSrcweir 			const sal_uInt16 nShadeValue(((const Svx3DShadeModeItem&)rSet.Get(SDRATTR_3DSCENE_SHADE_MODE)).GetValue());
884cdf0e10cSrcweir 
885cdf0e10cSrcweir 			if(1L == nShadeValue)
886cdf0e10cSrcweir 			{
887cdf0e10cSrcweir 				aShadeMode = ::com::sun::star::drawing::ShadeMode_PHONG;
888cdf0e10cSrcweir 			}
889cdf0e10cSrcweir 			else if(2L == nShadeValue)
890cdf0e10cSrcweir 			{
891cdf0e10cSrcweir 				aShadeMode = ::com::sun::star::drawing::ShadeMode_SMOOTH;
892cdf0e10cSrcweir 			}
893cdf0e10cSrcweir 			else if(3L == nShadeValue)
894cdf0e10cSrcweir 			{
895cdf0e10cSrcweir 				aShadeMode = ::com::sun::star::drawing::ShadeMode_DRAFT;
896cdf0e10cSrcweir 			}
897cdf0e10cSrcweir 
898cdf0e10cSrcweir 			// get two sided lighting
899cdf0e10cSrcweir 			const bool bTwoSidedLighting(((const Svx3DTwoSidedLightingItem&)rSet.Get(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING)).GetValue());
900cdf0e10cSrcweir 
901cdf0e10cSrcweir 			return attribute::SdrSceneAttribute(fDistance, fShadowSlant, aProjectionMode, aShadeMode, bTwoSidedLighting);
902cdf0e10cSrcweir 		}
903cdf0e10cSrcweir 
904cdf0e10cSrcweir 		attribute::SdrLightingAttribute createNewSdrLightingAttribute(const SfxItemSet& rSet)
905cdf0e10cSrcweir 		{
906cdf0e10cSrcweir 			// extract lights from given SfxItemSet (from scene)
907cdf0e10cSrcweir 			::std::vector< attribute::Sdr3DLightAttribute > aLightVector;
908cdf0e10cSrcweir 
909cdf0e10cSrcweir             if(((const Svx3DLightOnOff1Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue())
910cdf0e10cSrcweir             {
911cdf0e10cSrcweir 				const basegfx::BColor aColor(((const Svx3DLightcolor1Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue().getBColor());
912cdf0e10cSrcweir 				const basegfx::B3DVector aDirection(((const Svx3DLightDirection1Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1)).GetValue());
913cdf0e10cSrcweir 				aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, true));
914cdf0e10cSrcweir             }
915cdf0e10cSrcweir 
916cdf0e10cSrcweir             if(((const Svx3DLightOnOff2Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue())
917cdf0e10cSrcweir             {
918cdf0e10cSrcweir 				const basegfx::BColor aColor(((const Svx3DLightcolor2Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue().getBColor());
919cdf0e10cSrcweir 				const basegfx::B3DVector aDirection(((const Svx3DLightDirection2Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2)).GetValue());
920cdf0e10cSrcweir 				aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
921cdf0e10cSrcweir             }
922cdf0e10cSrcweir 
923cdf0e10cSrcweir             if(((const Svx3DLightOnOff3Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue())
924cdf0e10cSrcweir             {
925cdf0e10cSrcweir 				const basegfx::BColor aColor(((const Svx3DLightcolor3Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue().getBColor());
926cdf0e10cSrcweir 				const basegfx::B3DVector aDirection(((const Svx3DLightDirection3Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3)).GetValue());
927cdf0e10cSrcweir 				aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
928cdf0e10cSrcweir             }
929cdf0e10cSrcweir 
930cdf0e10cSrcweir             if(((const Svx3DLightOnOff4Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue())
931cdf0e10cSrcweir             {
932cdf0e10cSrcweir 				const basegfx::BColor aColor(((const Svx3DLightcolor4Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue().getBColor());
933cdf0e10cSrcweir 				const basegfx::B3DVector aDirection(((const Svx3DLightDirection4Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4)).GetValue());
934cdf0e10cSrcweir 				aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
935cdf0e10cSrcweir             }
936cdf0e10cSrcweir 
937cdf0e10cSrcweir             if(((const Svx3DLightOnOff5Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue())
938cdf0e10cSrcweir             {
939cdf0e10cSrcweir 				const basegfx::BColor aColor(((const Svx3DLightcolor5Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue().getBColor());
940cdf0e10cSrcweir 				const basegfx::B3DVector aDirection(((const Svx3DLightDirection5Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5)).GetValue());
941cdf0e10cSrcweir 				aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
942cdf0e10cSrcweir             }
943cdf0e10cSrcweir 
944cdf0e10cSrcweir             if(((const Svx3DLightOnOff6Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue())
945cdf0e10cSrcweir             {
946cdf0e10cSrcweir 				const basegfx::BColor aColor(((const Svx3DLightcolor6Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue().getBColor());
947cdf0e10cSrcweir 				const basegfx::B3DVector aDirection(((const Svx3DLightDirection6Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6)).GetValue());
948cdf0e10cSrcweir 				aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
949cdf0e10cSrcweir             }
950cdf0e10cSrcweir 
951cdf0e10cSrcweir             if(((const Svx3DLightOnOff7Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue())
952cdf0e10cSrcweir             {
953cdf0e10cSrcweir 				const basegfx::BColor aColor(((const Svx3DLightcolor7Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue().getBColor());
954cdf0e10cSrcweir 				const basegfx::B3DVector aDirection(((const Svx3DLightDirection7Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7)).GetValue());
955cdf0e10cSrcweir 				aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
956cdf0e10cSrcweir             }
957cdf0e10cSrcweir 
958cdf0e10cSrcweir             if(((const Svx3DLightOnOff8Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue())
959cdf0e10cSrcweir             {
960cdf0e10cSrcweir 				const basegfx::BColor aColor(((const Svx3DLightcolor8Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue().getBColor());
961cdf0e10cSrcweir 				const basegfx::B3DVector aDirection(((const Svx3DLightDirection8Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8)).GetValue());
962cdf0e10cSrcweir 				aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
963cdf0e10cSrcweir             }
964cdf0e10cSrcweir 
965cdf0e10cSrcweir             // get ambient color
966cdf0e10cSrcweir 			const Color aAmbientValue(((const Svx3DAmbientcolorItem&)rSet.Get(SDRATTR_3DSCENE_AMBIENTCOLOR)).GetValue());
967cdf0e10cSrcweir 			const basegfx::BColor aAmbientLight(aAmbientValue.getBColor());
968cdf0e10cSrcweir 
969cdf0e10cSrcweir             return attribute::SdrLightingAttribute(aAmbientLight, aLightVector);
970cdf0e10cSrcweir 		}
971cdf0e10cSrcweir 
972cdf0e10cSrcweir 		void calculateRelativeCornerRadius(sal_Int32 nRadius, const basegfx::B2DRange& rObjectRange, double& rfCornerRadiusX, double& rfCornerRadiusY)
973cdf0e10cSrcweir 		{
974cdf0e10cSrcweir 			rfCornerRadiusX = rfCornerRadiusY = (double)nRadius;
975cdf0e10cSrcweir 
976cdf0e10cSrcweir 			if(0.0 != rfCornerRadiusX)
977cdf0e10cSrcweir 			{
978cdf0e10cSrcweir 				const double fHalfObjectWidth(rObjectRange.getWidth() * 0.5);
979cdf0e10cSrcweir 
980cdf0e10cSrcweir 				if(0.0 != fHalfObjectWidth)
981cdf0e10cSrcweir 				{
982cdf0e10cSrcweir 					if(rfCornerRadiusX < 0.0)
983cdf0e10cSrcweir 					{
984cdf0e10cSrcweir 						rfCornerRadiusX = 0.0;
985cdf0e10cSrcweir 					}
986cdf0e10cSrcweir 
987cdf0e10cSrcweir 					if(rfCornerRadiusX > fHalfObjectWidth)
988cdf0e10cSrcweir 					{
989cdf0e10cSrcweir 						rfCornerRadiusX = fHalfObjectWidth;
990cdf0e10cSrcweir 					}
991cdf0e10cSrcweir 
992cdf0e10cSrcweir 					rfCornerRadiusX /= fHalfObjectWidth;
993cdf0e10cSrcweir 				}
994cdf0e10cSrcweir 				else
995cdf0e10cSrcweir 				{
996cdf0e10cSrcweir 					rfCornerRadiusX = 0.0;
997cdf0e10cSrcweir 				}
998cdf0e10cSrcweir 			}
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir 			if(0.0 != rfCornerRadiusY)
1001cdf0e10cSrcweir 			{
1002cdf0e10cSrcweir 				const double fHalfObjectHeight(rObjectRange.getHeight() * 0.5);
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir 				if(0.0 != fHalfObjectHeight)
1005cdf0e10cSrcweir 				{
1006cdf0e10cSrcweir 					if(rfCornerRadiusY < 0.0)
1007cdf0e10cSrcweir 					{
1008cdf0e10cSrcweir 						rfCornerRadiusY = 0.0;
1009cdf0e10cSrcweir 					}
1010cdf0e10cSrcweir 
1011cdf0e10cSrcweir 					if(rfCornerRadiusY > fHalfObjectHeight)
1012cdf0e10cSrcweir 					{
1013cdf0e10cSrcweir 						rfCornerRadiusY = fHalfObjectHeight;
1014cdf0e10cSrcweir 					}
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir 					rfCornerRadiusY /= fHalfObjectHeight;
1017cdf0e10cSrcweir 				}
1018cdf0e10cSrcweir 				else
1019cdf0e10cSrcweir 				{
1020cdf0e10cSrcweir 					rfCornerRadiusY = 0.0;
1021cdf0e10cSrcweir 				}
1022cdf0e10cSrcweir 			}
1023cdf0e10cSrcweir 		}
1024cdf0e10cSrcweir 
1025cdf0e10cSrcweir 		// #i101508# Support handing over given text-to-border distances
1026cdf0e10cSrcweir 		attribute::SdrFillTextAttribute createNewSdrFillTextAttribute(
1027cdf0e10cSrcweir 			const SfxItemSet& rSet,
1028cdf0e10cSrcweir 			const SdrText* pText,
1029cdf0e10cSrcweir 			const sal_Int32* pLeft,
1030cdf0e10cSrcweir 			const sal_Int32* pUpper,
1031cdf0e10cSrcweir 			const sal_Int32* pRight,
1032cdf0e10cSrcweir 			const sal_Int32* pLower)
1033cdf0e10cSrcweir 		{
1034cdf0e10cSrcweir 			attribute::SdrFillAttribute aFill;
1035cdf0e10cSrcweir 			attribute::FillGradientAttribute aFillFloatTransGradient;
1036cdf0e10cSrcweir 			attribute::SdrTextAttribute aText;
1037cdf0e10cSrcweir 			bool bFontworkHideContour(false);
1038cdf0e10cSrcweir 
1039cdf0e10cSrcweir 			// look for text first
1040cdf0e10cSrcweir             if(pText)
1041cdf0e10cSrcweir             {
1042cdf0e10cSrcweir     			aText = createNewSdrTextAttribute(rSet, *pText, pLeft, pUpper, pRight, pLower);
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir 			    // when object has text and text is fontwork and hide contour is set for fontwork, force
1045cdf0e10cSrcweir 			    // fill style to empty
1046cdf0e10cSrcweir 			    if(!aText.getSdrFormTextAttribute().isDefault() && aText.isHideContour())
1047cdf0e10cSrcweir 			    {
1048cdf0e10cSrcweir 				    bFontworkHideContour = true;
1049cdf0e10cSrcweir 			    }
1050cdf0e10cSrcweir             }
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir 			if(!bFontworkHideContour)
1053cdf0e10cSrcweir 			{
1054cdf0e10cSrcweir 				// try fill style
1055cdf0e10cSrcweir 				aFill = createNewSdrFillAttribute(rSet);
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 				if(!aFill.isDefault())
1058cdf0e10cSrcweir 				{
1059cdf0e10cSrcweir 					// try fillfloattransparence
1060cdf0e10cSrcweir 					aFillFloatTransGradient = createNewTransparenceGradientAttribute(rSet);
1061cdf0e10cSrcweir 				}
1062cdf0e10cSrcweir 			}
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir 			if(!aFill.isDefault() || !aText.isDefault())
1065cdf0e10cSrcweir 			{
1066cdf0e10cSrcweir 				return attribute::SdrFillTextAttribute(aFill, aFillFloatTransGradient, aText);
1067cdf0e10cSrcweir 			}
1068cdf0e10cSrcweir 
1069cdf0e10cSrcweir 			return attribute::SdrFillTextAttribute();
1070cdf0e10cSrcweir 		}
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir 	} // end of namespace primitive2d
1073cdf0e10cSrcweir } // end of namespace drawinglayer
1074cdf0e10cSrcweir 
1075cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1076cdf0e10cSrcweir // eof
1077