LCOV - code coverage report
Current view: top level - svx/source/sdr/primitive2d - sdrolecontentprimitive2d.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 61 0.0 %
Date: 2014-04-14 Functions: 0 5 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/sdrolecontentprimitive2d.hxx>
      21             : #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
      22             : #include <svx/svdoole2.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : #include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
      25             : #include <svtools/colorcfg.hxx>
      26             : #include <basegfx/polygon/b2dpolygontools.hxx>
      27             : #include <basegfx/polygon/b2dpolygon.hxx>
      28             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      29             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      30             : 
      31             : 
      32             : 
      33             : namespace drawinglayer
      34             : {
      35             :     namespace primitive2d
      36             :     {
      37           0 :         Primitive2DSequence SdrOleContentPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
      38             :         {
      39           0 :             Primitive2DSequence aRetval;
      40           0 :             const SdrOle2Obj* pSource = (mpSdrOle2Obj.is() ? static_cast< SdrOle2Obj* >(mpSdrOle2Obj.get()) : 0);
      41           0 :             bool bScaleContent(false);
      42           0 :             Graphic aGraphic;
      43             : 
      44           0 :             if(pSource)
      45             :             {
      46           0 :                 const Graphic* pOLEGraphic = pSource->GetGraphic();
      47             : 
      48           0 :                 if(pOLEGraphic)
      49             :                 {
      50           0 :                     aGraphic = *pOLEGraphic;
      51           0 :                     bScaleContent = pSource->IsEmptyPresObj();
      52             :                 }
      53             :             }
      54             : #ifdef WNT // Little point in displaying the "broken OLE" graphic on OSes that don't have real OLE, maybe?
      55             :             if(GRAPHIC_NONE == aGraphic.GetType())
      56             :             {
      57             :                 // no source, use fallback resource emty OLE graphic
      58             :                 aGraphic = SdrOle2Obj::GetEmptyOLEReplacementGraphic();
      59             :                 bScaleContent = true;
      60             :             }
      61             : #endif
      62           0 :             if(GRAPHIC_NONE != aGraphic.GetType())
      63             :             {
      64           0 :                 const GraphicObject aGraphicObject(aGraphic);
      65           0 :                 const GraphicAttr aGraphicAttr;
      66             : 
      67           0 :                 if(bScaleContent)
      68             :                 {
      69             :                     // get transformation atoms
      70           0 :                     basegfx::B2DVector aScale, aTranslate;
      71             :                     double fRotate, fShearX;
      72           0 :                     getObjectTransform().decompose(aScale, aTranslate, fRotate, fShearX);
      73             : 
      74             :                     // get PrefSize from the graphic in 100th mm
      75           0 :                     Size aPrefSize(aGraphic.GetPrefSize());
      76             : 
      77           0 :                     if(MAP_PIXEL == aGraphic.GetPrefMapMode().GetMapUnit())
      78             :                     {
      79           0 :                         aPrefSize = Application::GetDefaultDevice()->PixelToLogic(aPrefSize, MAP_100TH_MM);
      80             :                     }
      81             :                     else
      82             :                     {
      83           0 :                         aPrefSize = Application::GetDefaultDevice()->LogicToLogic(aPrefSize, aGraphic.GetPrefMapMode(), MAP_100TH_MM);
      84             :                     }
      85             : 
      86           0 :                     const double fOffsetX((aScale.getX() - aPrefSize.getWidth()) / 2.0);
      87           0 :                     const double fOffsetY((aScale.getY() - aPrefSize.getHeight()) / 2.0);
      88             : 
      89           0 :                     if(basegfx::fTools::moreOrEqual(fOffsetX, 0.0) && basegfx::fTools::moreOrEqual(fOffsetY, 0.0))
      90             :                     {
      91             :                         // if content fits into frame, create it
      92             :                         basegfx::B2DHomMatrix aInnerObjectMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix(
      93           0 :                             aPrefSize.getWidth(), aPrefSize.getHeight(), fOffsetX, fOffsetY));
      94             :                         aInnerObjectMatrix = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate)
      95           0 :                             * aInnerObjectMatrix;
      96             : 
      97             :                         const drawinglayer::primitive2d::Primitive2DReference aGraphicPrimitive(
      98             :                             new drawinglayer::primitive2d::GraphicPrimitive2D(
      99             :                                 aInnerObjectMatrix,
     100             :                                 aGraphicObject,
     101           0 :                                 aGraphicAttr));
     102           0 :                         drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aGraphicPrimitive);
     103           0 :                     }
     104             :                 }
     105             :                 else
     106             :                 {
     107             :                     // create graphic primitive for content
     108             :                     const drawinglayer::primitive2d::Primitive2DReference aGraphicPrimitive(
     109             :                         new drawinglayer::primitive2d::GraphicPrimitive2D(
     110             :                             getObjectTransform(),
     111             :                             aGraphicObject,
     112           0 :                             aGraphicAttr));
     113           0 :                     drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aGraphicPrimitive);
     114             :                 }
     115             : 
     116             :                 // a standard gray outline is created for scaled content
     117           0 :                 if(bScaleContent)
     118             :                 {
     119           0 :                     const svtools::ColorConfig aColorConfig;
     120           0 :                     const svtools::ColorConfigValue aColor(aColorConfig.GetColorValue(svtools::OBJECTBOUNDARIES));
     121             : 
     122           0 :                     if(aColor.bIsVisible)
     123             :                     {
     124           0 :                         basegfx::B2DPolygon aOutline(basegfx::tools::createUnitPolygon());
     125           0 :                         const Color aVclColor(aColor.nColor);
     126           0 :                         aOutline.transform(getObjectTransform());
     127             :                         const drawinglayer::primitive2d::Primitive2DReference xOutline(
     128           0 :                             new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOutline, aVclColor.getBColor()));
     129           0 :                         drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xOutline);
     130           0 :                     }
     131           0 :                 }
     132             :             }
     133             : 
     134             :             // get graphic and check scale content state
     135           0 :             return aRetval;
     136             :         }
     137             : 
     138           0 :         SdrOleContentPrimitive2D::SdrOleContentPrimitive2D(
     139             :             const SdrOle2Obj& rSdrOle2Obj,
     140             :             const basegfx::B2DHomMatrix& rObjectTransform,
     141             :             sal_uInt32 nGraphicVersion
     142             :         )
     143             :         :   BufferedDecompositionPrimitive2D(),
     144             :             mpSdrOle2Obj(const_cast< SdrOle2Obj* >(&rSdrOle2Obj)),
     145             :             maObjectTransform(rObjectTransform),
     146           0 :             mnGraphicVersion(nGraphicVersion)
     147             :         {
     148           0 :         }
     149             : 
     150           0 :         bool SdrOleContentPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     151             :         {
     152           0 :             if( BufferedDecompositionPrimitive2D::operator==(rPrimitive) )
     153             :             {
     154           0 :                 const SdrOleContentPrimitive2D& rCompare = (SdrOleContentPrimitive2D&)rPrimitive;
     155           0 :                 const bool bBothNot(!mpSdrOle2Obj.is() && !rCompare.mpSdrOle2Obj.is());
     156           0 :                 const bool bBothAndEqual(mpSdrOle2Obj.is() && rCompare.mpSdrOle2Obj.is()
     157           0 :                     && mpSdrOle2Obj.get() == rCompare.mpSdrOle2Obj.get());
     158             : 
     159           0 :                 return ((bBothNot || bBothAndEqual)
     160           0 :                     && getObjectTransform() == rCompare.getObjectTransform()
     161             : 
     162             :                     // #i104867# to find out if the Graphic content of the
     163             :                     // OLE has changed, use GraphicVersion number
     164           0 :                     && getGraphicVersion() == rCompare.getGraphicVersion()
     165           0 :                 );
     166             :             }
     167             : 
     168           0 :             return false;
     169             :         }
     170             : 
     171           0 :         basegfx::B2DRange SdrOleContentPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
     172             :         {
     173           0 :             basegfx::B2DRange aRange(0.0, 0.0, 1.0, 1.0);
     174           0 :             aRange.transform(getObjectTransform());
     175             : 
     176           0 :             return aRange;
     177             :         }
     178             : 
     179             :         // provide unique ID
     180           0 :         ImplPrimitive2DIDBlock(SdrOleContentPrimitive2D, PRIMITIVE2D_ID_SDROLECONTENTPRIMITIVE2D)
     181             : 
     182             :     } // end of namespace primitive2d
     183             : } // end of namespace drawinglayer
     184             : 
     185             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10