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 // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svx.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofsdrcaptionobj.hxx> 32*cdf0e10cSrcweir #include <svx/svdocapt.hxx> 33*cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrattributecreator.hxx> 34*cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrcaptionprimitive2d.hxx> 35*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 38*cdf0e10cSrcweir // includes for special text box shadow (SC) 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <svl/itemset.hxx> 41*cdf0e10cSrcweir #include <svx/xhatch.hxx> 42*cdf0e10cSrcweir #include <svx/xflhtit.hxx> 43*cdf0e10cSrcweir #include <svx/xflclit.hxx> 44*cdf0e10cSrcweir #include <svx/xfltrit.hxx> 45*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 46*cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir namespace sdr 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir namespace contact 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir ViewContactOfSdrCaptionObj::ViewContactOfSdrCaptionObj(SdrCaptionObj& rCaptionObj) 55*cdf0e10cSrcweir : ViewContactOfSdrRectObj(rCaptionObj) 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir } 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir ViewContactOfSdrCaptionObj::~ViewContactOfSdrCaptionObj() 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir } 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrCaptionObj::createViewIndependentPrimitive2DSequence() const 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence xRetval; 66*cdf0e10cSrcweir const SdrCaptionObj& rCaptionObj(GetCaptionObj()); 67*cdf0e10cSrcweir const SfxItemSet& rItemSet = rCaptionObj.GetMergedItemSet(); 68*cdf0e10cSrcweir const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute( 69*cdf0e10cSrcweir drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( 70*cdf0e10cSrcweir rItemSet, 71*cdf0e10cSrcweir rCaptionObj.getText(0))); 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir // take unrotated snap rect (direct model data) for position and size 74*cdf0e10cSrcweir const Rectangle& rRectangle = rCaptionObj.GetGeoRect(); 75*cdf0e10cSrcweir const ::basegfx::B2DRange aObjectRange( 76*cdf0e10cSrcweir rRectangle.Left(), rRectangle.Top(), 77*cdf0e10cSrcweir rRectangle.Right(), rRectangle.Bottom()); 78*cdf0e10cSrcweir const GeoStat& rGeoStat(rCaptionObj.GetGeoStat()); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir // fill object matrix 81*cdf0e10cSrcweir basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( 82*cdf0e10cSrcweir aObjectRange.getWidth(), aObjectRange.getHeight(), 83*cdf0e10cSrcweir rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0, 84*cdf0e10cSrcweir rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0, 85*cdf0e10cSrcweir aObjectRange.getMinX(), aObjectRange.getMinY())); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir // calculate corner radius 88*cdf0e10cSrcweir double fCornerRadiusX; 89*cdf0e10cSrcweir double fCornerRadiusY; 90*cdf0e10cSrcweir drawinglayer::primitive2d::calculateRelativeCornerRadius( 91*cdf0e10cSrcweir rCaptionObj.GetEckenradius(), aObjectRange, fCornerRadiusX, fCornerRadiusY); 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir // create primitive. Always create one (even if invisible) to let the decomposition 94*cdf0e10cSrcweir // of SdrCaptionPrimitive2D create needed invisible elements for HitTest and BoundRect 95*cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DReference xReference( 96*cdf0e10cSrcweir new drawinglayer::primitive2d::SdrCaptionPrimitive2D( 97*cdf0e10cSrcweir aObjectMatrix, 98*cdf0e10cSrcweir aAttribute, 99*cdf0e10cSrcweir rCaptionObj.getTailPolygon(), 100*cdf0e10cSrcweir fCornerRadiusX, 101*cdf0e10cSrcweir fCornerRadiusY)); 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir if(!aAttribute.isDefault() && rCaptionObj.GetSpecialTextBoxShadow()) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir // for SC, the caption object may have a specialized shadow. The usual object shadow is off 108*cdf0e10cSrcweir // and a specialized shadow gets created here (see old paint) 109*cdf0e10cSrcweir const SdrShadowColorItem& rShadColItem = (SdrShadowColorItem&)(rItemSet.Get(SDRATTR_SHADOWCOLOR)); 110*cdf0e10cSrcweir const sal_uInt16 nTransp(((SdrShadowTransparenceItem&)(rItemSet.Get(SDRATTR_SHADOWTRANSPARENCE))).GetValue()); 111*cdf0e10cSrcweir const Color aShadCol(rShadColItem.GetColorValue()); 112*cdf0e10cSrcweir const XFillStyle eStyle = ((XFillStyleItem&)(rItemSet.Get(XATTR_FILLSTYLE))).GetValue(); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir // Create own ItemSet and modify as needed 115*cdf0e10cSrcweir // Always hide lines for special calc shadow 116*cdf0e10cSrcweir SfxItemSet aSet(rItemSet); 117*cdf0e10cSrcweir aSet.Put(XLineStyleItem(XLINE_NONE)); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir if(XFILL_HATCH == eStyle) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir // #41666# Hatch color is set hard to shadow color 122*cdf0e10cSrcweir XHatch aHatch = ((XFillHatchItem&)(rItemSet.Get(XATTR_FILLHATCH))).GetHatchValue(); 123*cdf0e10cSrcweir aHatch.SetColor(aShadCol); 124*cdf0e10cSrcweir aSet.Put(XFillHatchItem(String(),aHatch)); 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir else 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir if(XFILL_NONE != eStyle && XFILL_SOLID != eStyle) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir // force fill to solid (for Gradient and Bitmap) 131*cdf0e10cSrcweir aSet.Put(XFillStyleItem(XFILL_SOLID)); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir aSet.Put(XFillColorItem(String(),aShadCol)); 135*cdf0e10cSrcweir aSet.Put(XFillTransparenceItem(nTransp)); 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir // crete FillAttribute from modified ItemSet 139*cdf0e10cSrcweir const drawinglayer::attribute::SdrFillAttribute aFill( 140*cdf0e10cSrcweir drawinglayer::primitive2d::createNewSdrFillAttribute(aSet)); 141*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DReference xSpecialShadow; 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir if(!aFill.isDefault() && 1.0 != aFill.getTransparence()) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir // add shadow offset to object matrix 146*cdf0e10cSrcweir const sal_uInt32 nXDist(((SdrShadowXDistItem&)(rItemSet.Get(SDRATTR_SHADOWXDIST))).GetValue()); 147*cdf0e10cSrcweir const sal_uInt32 nYDist(((SdrShadowYDistItem&)(rItemSet.Get(SDRATTR_SHADOWYDIST))).GetValue()); 148*cdf0e10cSrcweir aObjectMatrix.translate(nXDist, nYDist); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir // create unit outline polygon as geometry (see SdrCaptionPrimitive2D::create2DDecomposition) 151*cdf0e10cSrcweir basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromRect( 152*cdf0e10cSrcweir basegfx::B2DRange(0.0, 0.0, 1.0, 1.0), fCornerRadiusX, fCornerRadiusY)); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir // create the specialized shadow primitive 155*cdf0e10cSrcweir xSpecialShadow = drawinglayer::primitive2d::createPolyPolygonFillPrimitive( 156*cdf0e10cSrcweir basegfx::B2DPolyPolygon(aUnitOutline), 157*cdf0e10cSrcweir aObjectMatrix, 158*cdf0e10cSrcweir aFill, 159*cdf0e10cSrcweir drawinglayer::attribute::FillGradientAttribute()); 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir if(xSpecialShadow.is()) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir // if we really got a special shadow, create a two-element retval with the shadow 165*cdf0e10cSrcweir // behind the standard object's geometry 166*cdf0e10cSrcweir xRetval.realloc(2); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir xRetval[0] = xSpecialShadow; 169*cdf0e10cSrcweir xRetval[1] = xReference; 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir return xRetval; 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir } // end of namespace contact 176*cdf0e10cSrcweir } // end of namespace sdr 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 179*cdf0e10cSrcweir // eof 180