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