LCOV - code coverage report
Current view: top level - svx/source/sdr/primitive2d - sdrole2primitive2d.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 50 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             : #include <svx/sdr/primitive2d/sdrole2primitive2d.hxx>
      21             : #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
      22             : #include <basegfx/polygon/b2dpolygontools.hxx>
      23             : #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
      24             : #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
      25             : #include <basegfx/polygon/b2dpolygon.hxx>
      26             : 
      27             : 
      28             : 
      29             : using namespace com::sun::star;
      30             : 
      31             : 
      32             : 
      33             : namespace drawinglayer
      34             : {
      35             :     namespace primitive2d
      36             :     {
      37           0 :         SdrOle2Primitive2D::SdrOle2Primitive2D(
      38             :             const Primitive2DSequence& rOLEContent,
      39             :             const basegfx::B2DHomMatrix& rTransform,
      40             :             const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute)
      41             :         :   BasePrimitive2D(),
      42             :             maOLEContent(rOLEContent),
      43             :             maTransform(rTransform),
      44           0 :             maSdrLFSTAttribute(rSdrLFSTAttribute)
      45             :         {
      46           0 :         }
      47             : 
      48           0 :         bool SdrOle2Primitive2D::operator==(const BasePrimitive2D& rPrimitive) const
      49             :         {
      50           0 :             if(BasePrimitive2D::operator==(rPrimitive))
      51             :             {
      52           0 :                 const SdrOle2Primitive2D& rCompare = (SdrOle2Primitive2D&)rPrimitive;
      53             : 
      54             :                 // #i108636# The standard operator== on two UNO sequences did not work as i
      55             :                 // would have expected; it just checks the .is() states and the data type
      56             :                 // of the sequence. What i need here is detection of equality of the whole
      57             :                 // sequence content, thus i need to use the arePrimitive2DSequencesEqual helper
      58             :                 // here instead of the operator== which lead to always returning false and thus
      59             :                 // always re-decompositions of the subcontent.
      60           0 :                 if(arePrimitive2DSequencesEqual(getOLEContent(), rCompare.getOLEContent())
      61           0 :                     && getTransform() == rCompare.getTransform()
      62           0 :                     && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute())
      63             :                 {
      64           0 :                     return true;
      65             :                 }
      66             :             }
      67             : 
      68           0 :             return false;
      69             :         }
      70             : 
      71           0 :         Primitive2DSequence SdrOle2Primitive2D::get2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
      72             :         {
      73             :             // to take care of getSdrLFSTAttribute() later, the same as in SdrGrafPrimitive2D::create2DDecomposition
      74             :             // should happen. For the moment we only need the OLE itself
      75             :             // Added complete primitive preparation using getSdrLFSTAttribute() now. To not do stuff which is not needed now, it
      76             :             // may be supressed by using a static bool. The paint version only supported text.
      77             :             static bool bBehaveCompatibleToPaintVersion(false);
      78           0 :             Primitive2DSequence  aRetval;
      79             : 
      80             :             // create unit outline polygon
      81           0 :             const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
      82             : 
      83             :             // add fill
      84           0 :             if(!bBehaveCompatibleToPaintVersion
      85           0 :                 && !getSdrLFSTAttribute().getFill().isDefault())
      86             :             {
      87           0 :                 basegfx::B2DPolyPolygon aTransformed(aUnitOutline);
      88             : 
      89           0 :                 aTransformed.transform(getTransform());
      90             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      91             :                     createPolyPolygonFillPrimitive(
      92             :                         aTransformed,
      93           0 :                         getSdrLFSTAttribute().getFill(),
      94           0 :                         getSdrLFSTAttribute().getFillFloatTransGradient()));
      95             :             }
      96             : 
      97             :             // add line
      98             :             // #i97981# condition was inverse to purpose. When being compatible to paint version,
      99             :             // border needs to be suppressed
     100           0 :             if(!bBehaveCompatibleToPaintVersion
     101           0 :                 && !getSdrLFSTAttribute().getLine().isDefault())
     102             :             {
     103             :                 // if line width is given, polygon needs to be grown by half of it to make the
     104             :                 // outline to be outside of the bitmap
     105           0 :                 if(0.0 != getSdrLFSTAttribute().getLine().getWidth())
     106             :                 {
     107             :                     // decompose to get scale
     108           0 :                     basegfx::B2DVector aScale, aTranslate;
     109             :                     double fRotate, fShearX;
     110           0 :                     getTransform().decompose(aScale, aTranslate, fRotate, fShearX);
     111             : 
     112             :                     // create expanded range (add relative half line width to unit rectangle)
     113           0 :                     double fHalfLineWidth(getSdrLFSTAttribute().getLine().getWidth() * 0.5);
     114           0 :                     double fScaleX(0.0 != aScale.getX() ? fHalfLineWidth / fabs(aScale.getX()) : 1.0);
     115           0 :                     double fScaleY(0.0 != aScale.getY() ? fHalfLineWidth / fabs(aScale.getY()) : 1.0);
     116           0 :                     const basegfx::B2DRange aExpandedRange(-fScaleX, -fScaleY, 1.0 + fScaleX, 1.0 + fScaleY);
     117           0 :                     basegfx::B2DPolygon aExpandedUnitOutline(basegfx::tools::createPolygonFromRect(aExpandedRange));
     118             : 
     119           0 :                     aExpandedUnitOutline.transform(getTransform());
     120             :                     appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
     121             :                         createPolygonLinePrimitive(
     122             :                             aExpandedUnitOutline,
     123           0 :                             getSdrLFSTAttribute().getLine(),
     124           0 :                             attribute::SdrLineStartEndAttribute()));
     125             :                 }
     126             :                 else
     127             :                 {
     128           0 :                     basegfx::B2DPolygon aTransformed(aUnitOutline);
     129             : 
     130           0 :                     aTransformed.transform(getTransform());
     131             :                     appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
     132             :                         createPolygonLinePrimitive(
     133             :                             aTransformed,
     134           0 :                             getSdrLFSTAttribute().getLine(),
     135           0 :                             attribute::SdrLineStartEndAttribute()));
     136             :                 }
     137             :             }
     138             :             else
     139             :             {
     140             :                 // if initially no line is defined, create one for HitTest and BoundRect
     141             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
     142             :                     createHiddenGeometryPrimitives2D(
     143             :                         false,
     144             :                         basegfx::B2DPolyPolygon(aUnitOutline),
     145           0 :                         getTransform()));
     146             :             }
     147             : 
     148             :             // add graphic content
     149           0 :             appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, getOLEContent());
     150             : 
     151             :             // add text, no need to supress to stay compatible since text was
     152             :             // always supported by the old paints, too
     153           0 :             if(!getSdrLFSTAttribute().getText().isDefault())
     154             :             {
     155             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
     156             :                     createTextPrimitive(
     157             :                         basegfx::B2DPolyPolygon(aUnitOutline),
     158           0 :                         getTransform(),
     159           0 :                         getSdrLFSTAttribute().getText(),
     160           0 :                         getSdrLFSTAttribute().getLine(),
     161             :                         false,
     162             :                         false,
     163           0 :                         false));
     164             :             }
     165             : 
     166             :             // add shadow
     167           0 :             if(!bBehaveCompatibleToPaintVersion
     168           0 :                 && !getSdrLFSTAttribute().getShadow().isDefault())
     169             :             {
     170           0 :                 aRetval = createEmbeddedShadowPrimitive(
     171             :                     aRetval,
     172           0 :                     getSdrLFSTAttribute().getShadow());
     173             :             }
     174             : 
     175           0 :             return aRetval;
     176             :         }
     177             : 
     178             :         // provide unique ID
     179           0 :         ImplPrimitive2DIDBlock(SdrOle2Primitive2D, PRIMITIVE2D_ID_SDROLE2PRIMITIVE2D)
     180             : 
     181             :     } // end of namespace primitive2d
     182             : } // end of namespace drawinglayer
     183             : 
     184             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10