LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewcontactofsdrcaptionobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 43 48 89.6 %
Date: 2012-08-25 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 78 168 46.4 %

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

Generated by: LCOV version 1.10