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