LCOV - code coverage report
Current view: top level - libreoffice/svx/source/sdr/primitive2d - sdrole2primitive2d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 16 47 34.0 %
Date: 2012-12-27 Functions: 2 4 50.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          41 :         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          41 :             maSdrLFSTAttribute(rSdrLFSTAttribute)
      45             :         {
      46          41 :         }
      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          41 :         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          41 :             Primitive2DSequence  aRetval;
      79             : 
      80             :             // create unit outline polygon
      81          41 :             const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
      82             : 
      83             :             // add fill
      84          82 :             if(!bBehaveCompatibleToPaintVersion
      85          41 :                 && !getSdrLFSTAttribute().getFill().isDefault())
      86             :             {
      87             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      88             :                     createPolyPolygonFillPrimitive(
      89             :                         basegfx::B2DPolyPolygon(aUnitOutline),
      90           0 :                         getTransform(),
      91           0 :                         getSdrLFSTAttribute().getFill(),
      92           0 :                         getSdrLFSTAttribute().getFillFloatTransGradient()));
      93             :             }
      94             : 
      95             :             // add line
      96             :             // #i97981# condition was inverse to purpose. When being compatible to paint version,
      97             :             // border needs to be suppressed
      98          82 :             if(!bBehaveCompatibleToPaintVersion
      99          41 :                 && !getSdrLFSTAttribute().getLine().isDefault())
     100             :             {
     101             :                 // if line width is given, polygon needs to be grown by half of it to make the
     102             :                 // outline to be outside of the bitmap
     103           0 :                 if(0.0 != getSdrLFSTAttribute().getLine().getWidth())
     104             :                 {
     105             :                     // decompose to get scale
     106           0 :                     basegfx::B2DVector aScale, aTranslate;
     107             :                     double fRotate, fShearX;
     108           0 :                     getTransform().decompose(aScale, aTranslate, fRotate, fShearX);
     109             : 
     110             :                     // create expanded range (add relative half line width to unit rectangle)
     111           0 :                     double fHalfLineWidth(getSdrLFSTAttribute().getLine().getWidth() * 0.5);
     112           0 :                     double fScaleX(0.0 != aScale.getX() ? fHalfLineWidth / fabs(aScale.getX()) : 1.0);
     113           0 :                     double fScaleY(0.0 != aScale.getY() ? fHalfLineWidth / fabs(aScale.getY()) : 1.0);
     114           0 :                     const basegfx::B2DRange aExpandedRange(-fScaleX, -fScaleY, 1.0 + fScaleX, 1.0 + fScaleY);
     115           0 :                     basegfx::B2DPolygon aExpandedUnitOutline(basegfx::tools::createPolygonFromRect(aExpandedRange));
     116             : 
     117             :                     appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
     118             :                         createPolygonLinePrimitive(
     119             :                             aExpandedUnitOutline,
     120           0 :                             getTransform(),
     121           0 :                             getSdrLFSTAttribute().getLine(),
     122           0 :                             attribute::SdrLineStartEndAttribute()));
     123             :                 }
     124             :                 else
     125             :                 {
     126             :                     appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
     127             :                         createPolygonLinePrimitive(
     128             :                             aUnitOutline,
     129           0 :                             getTransform(),
     130           0 :                             getSdrLFSTAttribute().getLine(),
     131           0 :                             attribute::SdrLineStartEndAttribute()));
     132             :                 }
     133             :             }
     134             :             else
     135             :             {
     136             :                 // if initially no line is defined, create one for HitTest and BoundRect
     137             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
     138             :                     createHiddenGeometryPrimitives2D(
     139             :                         false,
     140             :                         basegfx::B2DPolyPolygon(aUnitOutline),
     141          41 :                         getTransform()));
     142             :             }
     143             : 
     144             :             // add graphic content
     145          41 :             appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, getOLEContent());
     146             : 
     147             :             // add text, no need to supress to stay compatible since text was
     148             :             // always supported by the old paints, too
     149          41 :             if(!getSdrLFSTAttribute().getText().isDefault())
     150             :             {
     151             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
     152             :                     createTextPrimitive(
     153             :                         basegfx::B2DPolyPolygon(aUnitOutline),
     154           0 :                         getTransform(),
     155           0 :                         getSdrLFSTAttribute().getText(),
     156           0 :                         getSdrLFSTAttribute().getLine(),
     157             :                         false,
     158             :                         false,
     159           0 :                         false));
     160             :             }
     161             : 
     162             :             // add shadow
     163          82 :             if(!bBehaveCompatibleToPaintVersion
     164          41 :                 && !getSdrLFSTAttribute().getShadow().isDefault())
     165             :             {
     166             :                 aRetval = createEmbeddedShadowPrimitive(
     167             :                     aRetval,
     168           0 :                     getSdrLFSTAttribute().getShadow());
     169             :             }
     170             : 
     171          41 :             return aRetval;
     172             :         }
     173             : 
     174             :         // provide unique ID
     175           0 :         ImplPrimitrive2DIDBlock(SdrOle2Primitive2D, PRIMITIVE2D_ID_SDROLE2PRIMITIVE2D)
     176             : 
     177             :     } // end of namespace primitive2d
     178             : } // end of namespace drawinglayer
     179             : 
     180             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10