LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewcontactofsdrcaptionobj.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 61 0.0 %
Date: 2014-04-14 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <svx/sdr/contact/viewcontactofsdrcaptionobj.hxx>
      22             : #include <svx/svdocapt.hxx>
      23             : #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
      24             : #include <svx/sdr/primitive2d/sdrcaptionprimitive2d.hxx>
      25             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      26             : 
      27             : 
      28             : // includes for special text box shadow (SC)
      29             : 
      30             : #include <svl/itemset.hxx>
      31             : #include <svx/xhatch.hxx>
      32             : #include <svx/xflhtit.hxx>
      33             : #include <svx/xflclit.hxx>
      34             : #include <svx/xfltrit.hxx>
      35             : #include <basegfx/polygon/b2dpolygontools.hxx>
      36             : #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
      37             : #include <basegfx/polygon/b2dpolygonclipper.hxx>
      38             : 
      39             : 
      40             : 
      41             : namespace sdr
      42             : {
      43             :     namespace contact
      44             :     {
      45           0 :         ViewContactOfSdrCaptionObj::ViewContactOfSdrCaptionObj(SdrCaptionObj& rCaptionObj)
      46           0 :         :   ViewContactOfSdrRectObj(rCaptionObj)
      47             :         {
      48           0 :         }
      49             : 
      50           0 :         ViewContactOfSdrCaptionObj::~ViewContactOfSdrCaptionObj()
      51             :         {
      52           0 :         }
      53             : 
      54           0 :         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrCaptionObj::createViewIndependentPrimitive2DSequence() const
      55             :         {
      56           0 :             drawinglayer::primitive2d::Primitive2DSequence xRetval;
      57           0 :             const SdrCaptionObj& rCaptionObj(GetCaptionObj());
      58           0 :             const SfxItemSet& rItemSet = rCaptionObj.GetMergedItemSet();
      59             :             const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
      60             :                 drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
      61             :                     rItemSet,
      62           0 :                     rCaptionObj.getText(0),
      63           0 :                     false));
      64             : 
      65             :             // take unrotated snap rect (direct model data) for position and size
      66           0 :             Rectangle rRectangle = rCaptionObj.GetGeoRect();
      67             :             // Hack for calc, transform position of object according
      68             :             // to current zoom so as objects relative position to grid
      69             :             // appears stable
      70           0 :             Point aGridOff = rCaptionObj.GetGridOffset();
      71           0 :             rRectangle += aGridOff;
      72             : 
      73             :             const ::basegfx::B2DRange aObjectRange(
      74           0 :                 rRectangle.Left(), rRectangle.Top(),
      75           0 :                 rRectangle.Right(), rRectangle.Bottom());
      76           0 :             const GeoStat& rGeoStat(rCaptionObj.GetGeoStat());
      77             : 
      78             :             // fill object matrix
      79             :             basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
      80             :                 aObjectRange.getWidth(), aObjectRange.getHeight(),
      81           0 :                 rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0,
      82           0 :                 rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0,
      83           0 :                 aObjectRange.getMinX(), aObjectRange.getMinY()));
      84             : 
      85             :             // calculate corner radius
      86             :             double fCornerRadiusX;
      87             :             double fCornerRadiusY;
      88             :             drawinglayer::primitive2d::calculateRelativeCornerRadius(
      89           0 :                 rCaptionObj.GetEckenradius(), aObjectRange, fCornerRadiusX, fCornerRadiusY);
      90           0 :             ::basegfx::B2DPolygon aTail = rCaptionObj.getTailPolygon();
      91             :             // Hack for calc, transform position of tail according
      92             :             // to current zoom so as objects relative position to grid
      93             :             // appears stable
      94           0 :             aTail.transform( basegfx::tools::createTranslateB2DHomMatrix( aGridOff.X(), aGridOff.Y() ) );
      95             :             // create primitive. Always create one (even if invisible) to let the decomposition
      96             :             // of SdrCaptionPrimitive2D create needed invisible elements for HitTest and BoundRect
      97             :             const drawinglayer::primitive2d::Primitive2DReference xReference(
      98             :                 new drawinglayer::primitive2d::SdrCaptionPrimitive2D(
      99             :                     aObjectMatrix,
     100             :                     aAttribute,
     101             :                     aTail,
     102             :                     fCornerRadiusX,
     103           0 :                     fCornerRadiusY));
     104             : 
     105           0 :             xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
     106             : 
     107           0 :             if(!aAttribute.isDefault() && rCaptionObj.GetSpecialTextBoxShadow())
     108             :             {
     109             :                 // for SC, the caption object may have a specialized shadow. The usual object shadow is off
     110             :                 // and a specialized shadow gets created here (see old paint)
     111           0 :                 const SdrShadowColorItem& rShadColItem = (SdrShadowColorItem&)(rItemSet.Get(SDRATTR_SHADOWCOLOR));
     112           0 :                 const sal_uInt16 nShadowTransparence(((SdrShadowTransparenceItem&)(rItemSet.Get(SDRATTR_SHADOWTRANSPARENCE))).GetValue());
     113           0 :                 const Color aShadowColor(rShadColItem.GetColorValue());
     114           0 :                 const XFillStyle eShadowStyle = ((XFillStyleItem&)(rItemSet.Get(XATTR_FILLSTYLE))).GetValue();
     115             : 
     116             :                 // Create own ItemSet and modify as needed
     117             :                 // Always hide lines for special calc shadow
     118           0 :                 SfxItemSet aSet(rItemSet);
     119           0 :                 aSet.Put(XLineStyleItem(XLINE_NONE));
     120             : 
     121           0 :                 if(XFILL_HATCH == eShadowStyle)
     122             :                 {
     123             :                     // #41666# Hatch color is set hard to shadow color
     124           0 :                     XHatch aHatch = ((XFillHatchItem&)(rItemSet.Get(XATTR_FILLHATCH))).GetHatchValue();
     125           0 :                     aHatch.SetColor(aShadowColor);
     126           0 :                     aSet.Put(XFillHatchItem(OUString(),aHatch));
     127             :                 }
     128             :                 else
     129             :                 {
     130           0 :                     if(XFILL_SOLID != eShadowStyle)
     131             :                     {
     132             :                         // force fill to solid (for Gradient, Bitmap and *no* fill (#119750# not filled comments *have* shadow))
     133           0 :                         aSet.Put(XFillStyleItem(XFILL_SOLID));
     134             :                     }
     135             : 
     136           0 :                     aSet.Put(XFillColorItem(OUString(),aShadowColor));
     137           0 :                     aSet.Put(XFillTransparenceItem(nShadowTransparence));
     138             :                 }
     139             : 
     140             :                 // crete FillAttribute from modified ItemSet
     141             :                 const drawinglayer::attribute::SdrFillAttribute aFill(
     142           0 :                     drawinglayer::primitive2d::createNewSdrFillAttribute(aSet));
     143           0 :                 drawinglayer::primitive2d::Primitive2DReference xSpecialShadow;
     144             : 
     145           0 :                 if(!aFill.isDefault() && 1.0 != aFill.getTransparence())
     146             :                 {
     147             :                     // add shadow offset to object matrix
     148           0 :                     const sal_uInt32 nXDist(((SdrShadowXDistItem&)(rItemSet.Get(SDRATTR_SHADOWXDIST))).GetValue());
     149           0 :                     const sal_uInt32 nYDist(((SdrShadowYDistItem&)(rItemSet.Get(SDRATTR_SHADOWYDIST))).GetValue());
     150             : 
     151           0 :                     if(nXDist || nYDist)
     152             :                     {
     153             :                         // #119750# create obect and shadow outline, clip shadow outline
     154             :                         // on object outline. If there is a rest, create shadow. Do this to
     155             :                         // emulate that shadow is *not* visible behind the object for
     156             :                         // transparent object fill for comments in excel
     157             :                         basegfx::B2DPolygon aObjectOutline(
     158             :                             basegfx::tools::createPolygonFromRect(
     159             :                                 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
     160             :                                 fCornerRadiusX,
     161           0 :                                 fCornerRadiusY));
     162           0 :                         aObjectOutline.transform(aObjectMatrix);
     163             : 
     164             :                         // create shadow outline
     165           0 :                         basegfx::B2DPolygon aShadowOutline(aObjectOutline);
     166             :                         aShadowOutline.transform(
     167           0 :                             basegfx::tools::createTranslateB2DHomMatrix(nXDist, nYDist));
     168             : 
     169             :                         // clip shadow outline against object outline
     170             :                         const basegfx::B2DPolyPolygon aClippedShadow(
     171             :                             basegfx::tools::clipPolygonOnPolyPolygon(
     172             :                                 aShadowOutline,
     173             :                                 basegfx::B2DPolyPolygon(aObjectOutline),
     174             :                                 false, // take the outside
     175           0 :                                 false));
     176             : 
     177           0 :                         if(aClippedShadow.count())
     178             :                         {
     179             :                             // if there is shadow, create the specialized shadow primitive
     180           0 :                             xSpecialShadow = drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
     181             :                                 aClippedShadow,
     182             :                                 aFill,
     183           0 :                                 drawinglayer::attribute::FillGradientAttribute());
     184           0 :                         }
     185             :                     }
     186             :                 }
     187             : 
     188           0 :                 if(xSpecialShadow.is())
     189             :                 {
     190             :                     // if we really got a special shadow, create a two-element retval with the shadow
     191             :                     // behind the standard object's geometry
     192           0 :                     xRetval.realloc(2);
     193             : 
     194           0 :                     xRetval[0] = xSpecialShadow;
     195           0 :                     xRetval[1] = xReference;
     196           0 :                 }
     197             :             }
     198             : 
     199           0 :             return xRetval;
     200             :         }
     201             :     } // end of namespace contact
     202             : } // end of namespace sdr
     203             : 
     204             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10