LCOV - code coverage report
Current view: top level - libreoffice/svx/source/sdr/contact - viewcontactofgraphic.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 104 152 68.4 %
Date: 2012-12-27 Functions: 9 10 90.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/contact/viewcontactofgraphic.hxx>
      21             : #include <svx/sdr/contact/viewobjectcontactofgraphic.hxx>
      22             : #include <svx/svdograf.hxx>
      23             : #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
      24             : #include <svl/itemset.hxx>
      25             : 
      26             : #ifndef ITEMID_GRF_CROP
      27             : #define ITEMID_GRF_CROP 0
      28             : #endif
      29             : 
      30             : #include <svx/sdgcpitm.hxx>
      31             : #include <svx/sdr/contact/displayinfo.hxx>
      32             : #include <svx/sdr/contact/viewobjectcontact.hxx>
      33             : #include <svx/sdr/contact/objectcontact.hxx>
      34             : #include <svx/sdr/event/eventhandler.hxx>
      35             : #include <basegfx/matrix/b2dhommatrix.hxx>
      36             : #include <svx/sdr/primitive2d/sdrgrafprimitive2d.hxx>
      37             : #include "svx/svdstr.hrc"
      38             : #include <svx/svdglob.hxx>
      39             : #include <vcl/svapp.hxx>
      40             : #include <basegfx/polygon/b2dpolygontools.hxx>
      41             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      42             : #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
      43             : #include <drawinglayer/primitive2d/textprimitive2d.hxx>
      44             : #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
      45             : #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
      46             : #include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx>
      47             : #include <editeng/eeitem.hxx>
      48             : #include <editeng/colritem.hxx>
      49             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      50             : #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
      51             : 
      52             : //////////////////////////////////////////////////////////////////////////////
      53             : 
      54             : namespace sdr
      55             : {
      56             :     namespace contact
      57             :     {
      58             :         // Create a Object-Specific ViewObjectContact, set ViewContact and
      59             :         // ObjectContact. Always needs to return something.
      60           8 :         ViewObjectContact& ViewContactOfGraphic::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
      61             :         {
      62           8 :             ViewObjectContact* pRetval = new ViewObjectContactOfGraphic(rObjectContact, *this);
      63             :             DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
      64             : 
      65           8 :             return *pRetval;
      66             :         }
      67             : 
      68          64 :         ViewContactOfGraphic::ViewContactOfGraphic(SdrGrafObj& rGrafObj)
      69          64 :         :   ViewContactOfTextObj(rGrafObj)
      70             :         {
      71          64 :         }
      72             : 
      73         116 :         ViewContactOfGraphic::~ViewContactOfGraphic()
      74             :         {
      75         116 :         }
      76             : 
      77           2 :         void ViewContactOfGraphic::flushGraphicObjects()
      78             :         {
      79             :             // #i102380# The graphic is swapped out. To let that have an effect ist is necessary to
      80             :             // delete copies of the GraphicObject which are not swapped out and have no SwapHandler set
      81             :             // (this is what happnes when the GraphicObject gets copied to a SdrGrafPrimitive2D). This
      82             :             // is best achieved for the VC by clearing the local decomposition cache. It would be possible
      83             :             // to also do this for the VOC cache, but that VOCs exist exactly expresss that the object
      84             :             // gets visualised, so this would be wrong.
      85           2 :             flushViewIndependentPrimitive2DSequence();
      86           2 :         }
      87             : 
      88           0 :         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGraphic::createVIP2DSForPresObj(
      89             :             const basegfx::B2DHomMatrix& rObjectMatrix,
      90             :             const drawinglayer::attribute::SdrLineFillShadowTextAttribute& rAttribute,
      91             :             const GraphicAttr& rLocalGrafInfo) const
      92             :         {
      93           0 :             drawinglayer::primitive2d::Primitive2DSequence xRetval;
      94           0 :             GraphicObject aEmptyGraphicObject;
      95           0 :             GraphicAttr aEmptyGraphicAttr;
      96             : 
      97             :             // SdrGrafPrimitive2D without content in original size which carries all eventual attributes and texts
      98             :             const drawinglayer::primitive2d::Primitive2DReference xReferenceA(new drawinglayer::primitive2d::SdrGrafPrimitive2D(
      99             :                 rObjectMatrix,
     100             :                 rAttribute,
     101             :                 aEmptyGraphicObject,
     102           0 :                 aEmptyGraphicAttr));
     103           0 :             xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReferenceA, 1);
     104             : 
     105             :             // SdrGrafPrimitive2D with content (which is the preview graphic) scaled to smaller size and
     106             :             // without attributes
     107           0 :             basegfx::B2DHomMatrix aSmallerMatrix;
     108             : 
     109             :             // #i94431# for some reason, i forgot to take the PrefMapMode of the graphic
     110             :             // into account. Since EmptyPresObj's are only used in Draw/Impress, it is
     111             :             // safe to assume 100th mm as target.
     112           0 :             Size aPrefSize(GetGrafObject().GetGrafPrefSize());
     113             : 
     114           0 :             if(MAP_PIXEL == GetGrafObject().GetGrafPrefMapMode().GetMapUnit())
     115             :             {
     116           0 :                 aPrefSize = Application::GetDefaultDevice()->PixelToLogic(aPrefSize, MAP_100TH_MM);
     117             :             }
     118             :             else
     119             :             {
     120           0 :                 aPrefSize = Application::GetDefaultDevice()->LogicToLogic(aPrefSize, GetGrafObject().GetGrafPrefMapMode(), MAP_100TH_MM);
     121             :             }
     122             : 
     123             :             // decompose object matrix to get single values
     124           0 :             basegfx::B2DVector aScale, aTranslate;
     125             :             double fRotate, fShearX;
     126           0 :             rObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
     127             : 
     128           0 :             const double fOffsetX((aScale.getX() - aPrefSize.getWidth()) / 2.0);
     129           0 :             const double fOffsetY((aScale.getY() - aPrefSize.getHeight()) / 2.0);
     130             : 
     131           0 :             if(basegfx::fTools::moreOrEqual(fOffsetX, 0.0) && basegfx::fTools::moreOrEqual(fOffsetY, 0.0))
     132             :             {
     133             :                 // create the EmptyPresObj fallback visualisation. The fallback graphic
     134             :                 // is already provided in rGraphicObject in this case, use it
     135           0 :                 aSmallerMatrix = basegfx::tools::createScaleTranslateB2DHomMatrix(aPrefSize.getWidth(), aPrefSize.getHeight(), fOffsetX, fOffsetY);
     136             :                 aSmallerMatrix = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate)
     137           0 :                     * aSmallerMatrix;
     138             : 
     139           0 :                 const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(false);
     140             :                 const drawinglayer::primitive2d::Primitive2DReference xReferenceB(new drawinglayer::primitive2d::SdrGrafPrimitive2D(
     141             :                     aSmallerMatrix,
     142             :                     drawinglayer::attribute::SdrLineFillShadowTextAttribute(),
     143             :                     rGraphicObject,
     144           0 :                     rLocalGrafInfo));
     145             : 
     146           0 :                 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xReferenceB);
     147             :             }
     148             : 
     149           0 :             return xRetval;
     150             :         }
     151             : 
     152          25 :         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGraphic::createVIP2DSForDraft(
     153             :             const basegfx::B2DHomMatrix& rObjectMatrix,
     154             :             const drawinglayer::attribute::SdrLineFillShadowTextAttribute& rAttribute) const
     155             :         {
     156          25 :             drawinglayer::primitive2d::Primitive2DSequence xRetval;
     157          25 :             GraphicObject aEmptyGraphicObject;
     158          25 :             GraphicAttr aEmptyGraphicAttr;
     159             : 
     160             :             // SdrGrafPrimitive2D without content in original size which carries all eventual attributes and texts
     161             :             const drawinglayer::primitive2d::Primitive2DReference xReferenceA(new drawinglayer::primitive2d::SdrGrafPrimitive2D(
     162             :                 rObjectMatrix,
     163             :                 rAttribute,
     164             :                 aEmptyGraphicObject,
     165          25 :                 aEmptyGraphicAttr));
     166          25 :             xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReferenceA, 1);
     167             : 
     168          25 :             if(rAttribute.getLine().isDefault())
     169             :             {
     170             :                 // create a surrounding frame when no linestyle given
     171          25 :                 const Color aColor(Application::GetSettings().GetStyleSettings().GetShadowColor());
     172          25 :                 const basegfx::BColor aBColor(aColor.getBColor());
     173          25 :                 basegfx::B2DPolygon aOutline(basegfx::tools::createUnitPolygon());
     174          25 :                 aOutline.transform(rObjectMatrix);
     175             : 
     176             :                 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval,
     177             :                     drawinglayer::primitive2d::Primitive2DReference(
     178             :                         new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
     179             :                             aOutline,
     180          25 :                             aBColor)));
     181             :             }
     182             : 
     183             :             // decompose object matrix to get single values
     184          25 :             basegfx::B2DVector aScale, aTranslate;
     185             :             double fRotate, fShearX;
     186          25 :             rObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
     187             : 
     188             :             // define a distance value, used for distance from bitmap to borders and from bitmap
     189             :             // to text, too (2 mm)
     190          25 :             const double fDistance(200.0);
     191             : 
     192             :             // consume borders from values
     193          25 :             aScale.setX(std::max(0.0, aScale.getX() - (2.0 * fDistance)));
     194          25 :             aScale.setY(std::max(0.0, aScale.getY() - (2.0 * fDistance)));
     195          25 :             aTranslate.setX(aTranslate.getX() + fDistance);
     196          25 :             aTranslate.setY(aTranslate.getY() + fDistance);
     197             : 
     198             :             // draw a draft bitmap
     199          25 :             const Bitmap aDraftBitmap(ResId(BMAP_GrafikEi, *ImpGetResMgr()));
     200             : 
     201          25 :             if(!aDraftBitmap.IsEmpty())
     202             :             {
     203           0 :                 Size aPrefSize(aDraftBitmap.GetPrefSize());
     204             : 
     205           0 :                 if(MAP_PIXEL == aDraftBitmap.GetPrefMapMode().GetMapUnit())
     206             :                 {
     207           0 :                     aPrefSize = Application::GetDefaultDevice()->PixelToLogic(aDraftBitmap.GetSizePixel(), MAP_100TH_MM);
     208             :                 }
     209             :                 else
     210             :                 {
     211           0 :                     aPrefSize = Application::GetDefaultDevice()->LogicToLogic(aPrefSize, aDraftBitmap.GetPrefMapMode(), MAP_100TH_MM);
     212             :                 }
     213             : 
     214           0 :                 const double fBitmapScaling(2.0);
     215           0 :                 const double fWidth(aPrefSize.getWidth() * fBitmapScaling);
     216           0 :                 const double fHeight(aPrefSize.getHeight() * fBitmapScaling);
     217             : 
     218           0 :                 if(basegfx::fTools::more(fWidth, 1.0)
     219           0 :                     && basegfx::fTools::more(fHeight, 1.0)
     220           0 :                     && basegfx::fTools::lessOrEqual(fWidth, aScale.getX())
     221           0 :                     && basegfx::fTools::lessOrEqual(fHeight, aScale.getY()))
     222             :                 {
     223             :                     const basegfx::B2DHomMatrix aBitmapMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
     224           0 :                         fWidth, fHeight, fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
     225             : 
     226             :                     drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval,
     227             :                         drawinglayer::primitive2d::Primitive2DReference(
     228             :                             new drawinglayer::primitive2d::BitmapPrimitive2D(
     229             :                                 BitmapEx(aDraftBitmap),
     230           0 :                                 aBitmapMatrix)));
     231             : 
     232             :                     // consume bitmap size in X
     233           0 :                     aScale.setX(std::max(0.0, aScale.getX() - (fWidth + fDistance)));
     234           0 :                     aTranslate.setX(aTranslate.getX() + fWidth + fDistance);
     235             :                 }
     236             :             }
     237             : 
     238             :             // Build the text for the draft object
     239          25 :             XubString aDraftText = GetGrafObject().GetFileName();
     240             : 
     241          25 :             if(!aDraftText.Len())
     242             :             {
     243          25 :                 aDraftText = GetGrafObject().GetName();
     244          25 :                 aDraftText.AppendAscii(" ...");
     245             :             }
     246             : 
     247          25 :             if(aDraftText.Len() && GetGrafObject().GetModel())
     248             :             {
     249             :                 // #i103255# Goal is to produce TextPrimitives which hold the given text as
     250             :                 // BlockText in the available space. It would be very tricky to do
     251             :                 // an own word wrap/line layout here.
     252             :                 // Using SdrBlockTextPrimitive2D OTOH is critical since it internally
     253             :                 // uses the SdrObject it references. To solve this, create a temp
     254             :                 // SdrObject with Attributes and Text, generate a SdrBlockTextPrimitive2D
     255             :                 // directly and immediately decompose it. After that, it is no longer
     256             :                 // needed and can be deleted.
     257             : 
     258             :                 // create temp RectObj as TextObj and set needed attributes
     259          25 :                 SdrRectObj aRectObj(OBJ_TEXT);
     260          25 :                 aRectObj.SetModel(GetGrafObject().GetModel());
     261          25 :                 aRectObj.NbcSetText(aDraftText);
     262          25 :                 aRectObj.SetMergedItem(SvxColorItem(Color(COL_LIGHTRED), EE_CHAR_COLOR));
     263             : 
     264             :                 // get SdrText and OPO
     265          25 :                 SdrText* pSdrText = aRectObj.getText(0);
     266          25 :                 OutlinerParaObject* pOPO = aRectObj.GetOutlinerParaObject();
     267             : 
     268          25 :                 if(pSdrText && pOPO)
     269             :                 {
     270             :                     // directly use the remaining space as TextRangeTransform
     271             :                     const basegfx::B2DHomMatrix aTextRangeTransform(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
     272          25 :                         aScale, fShearX, fRotate, aTranslate));
     273             : 
     274             :                     // directly create temp SdrBlockTextPrimitive2D
     275             :                     drawinglayer::primitive2d::SdrBlockTextPrimitive2D aBlockTextPrimitive(
     276             :                         pSdrText,
     277             :                         *pOPO,
     278             :                         aTextRangeTransform,
     279             :                         SDRTEXTHORZADJUST_LEFT,
     280             :                         SDRTEXTVERTADJUST_TOP,
     281             :                         false,
     282             :                         false,
     283             :                         false,
     284             :                         false,
     285          25 :                         false);
     286             : 
     287             :                     // decompose immediately with neutral ViewInformation. This will
     288             :                     // layout the text to more simple TextPrimitives from drawinglayer
     289          25 :                     const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
     290             : 
     291             :                     drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(
     292             :                         xRetval,
     293          25 :                         aBlockTextPrimitive.get2DDecomposition(aViewInformation2D));
     294          25 :                 }
     295             :             }
     296             : 
     297          25 :             return xRetval;
     298             :         }
     299             : 
     300          46 :         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGraphic::createViewIndependentPrimitive2DSequence() const
     301             :         {
     302          46 :             drawinglayer::primitive2d::Primitive2DSequence xRetval;
     303          46 :             const SfxItemSet& rItemSet = GetGrafObject().GetMergedItemSet();
     304             :             drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
     305             :                 drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
     306             :                     rItemSet,
     307          46 :                     GetGrafObject().getText(0)));
     308             : 
     309             :             // create and fill GraphicAttr
     310          46 :             GraphicAttr aLocalGrafInfo;
     311          46 :             const sal_uInt16 nTrans(((SdrGrafTransparenceItem&)rItemSet.Get(SDRATTR_GRAFTRANSPARENCE)).GetValue());
     312          46 :             const SdrGrafCropItem& rCrop((const SdrGrafCropItem&)rItemSet.Get(SDRATTR_GRAFCROP));
     313          46 :             aLocalGrafInfo.SetLuminance(((SdrGrafLuminanceItem&)rItemSet.Get(SDRATTR_GRAFLUMINANCE)).GetValue());
     314          46 :             aLocalGrafInfo.SetContrast(((SdrGrafContrastItem&)rItemSet.Get(SDRATTR_GRAFCONTRAST)).GetValue());
     315          46 :             aLocalGrafInfo.SetChannelR(((SdrGrafRedItem&)rItemSet.Get(SDRATTR_GRAFRED)).GetValue());
     316          46 :             aLocalGrafInfo.SetChannelG(((SdrGrafGreenItem&)rItemSet.Get(SDRATTR_GRAFGREEN)).GetValue());
     317          46 :             aLocalGrafInfo.SetChannelB(((SdrGrafBlueItem&)rItemSet.Get(SDRATTR_GRAFBLUE)).GetValue());
     318          46 :             aLocalGrafInfo.SetGamma(((SdrGrafGamma100Item&)rItemSet.Get(SDRATTR_GRAFGAMMA)).GetValue() * 0.01);
     319          46 :             aLocalGrafInfo.SetTransparency((sal_uInt8)::basegfx::fround(Min(nTrans, (sal_uInt16)100) * 2.55));
     320          46 :             aLocalGrafInfo.SetInvert(((SdrGrafInvertItem&)rItemSet.Get(SDRATTR_GRAFINVERT)).GetValue());
     321          46 :             aLocalGrafInfo.SetDrawMode(((SdrGrafModeItem&)rItemSet.Get(SDRATTR_GRAFMODE)).GetValue());
     322          46 :             aLocalGrafInfo.SetCrop(rCrop.GetLeft(), rCrop.GetTop(), rCrop.GetRight(), rCrop.GetBottom());
     323             : 
     324          46 :             if(aAttribute.isDefault() && 255L != aLocalGrafInfo.GetTransparency())
     325             :             {
     326             :                 // no fill, no line, no text (invisible), but the graphic content is visible.
     327             :                 // Create evtl. shadow for content which was not created by createNewSdrLineFillShadowTextAttribute yet
     328             :                 const drawinglayer::attribute::SdrShadowAttribute aShadow(
     329          46 :                     drawinglayer::primitive2d::createNewSdrShadowAttribute(rItemSet));
     330             : 
     331          46 :                 if(!aShadow.isDefault())
     332             :                 {
     333             :                     // create new attribute set if indeed shadow is used
     334             :                     aAttribute = drawinglayer::attribute::SdrLineFillShadowTextAttribute(
     335           0 :                         aAttribute.getLine(),
     336           0 :                         aAttribute.getFill(),
     337           0 :                         aAttribute.getLineStartEnd(),
     338             :                         aShadow,
     339           0 :                         aAttribute.getFillFloatTransGradient(),
     340           0 :                         aAttribute.getText());
     341          46 :                 }
     342             :             }
     343             :             // take unrotated snap rect for position and size. Directly use model data, not getBoundRect() or getSnapRect()
     344             :             // which will use the primitive data we just create in the near future
     345          46 :             Rectangle rRectangle = GetGrafObject().GetGeoRect();
     346             :             // Hack for calc, transform position of object according
     347             :             // to current zoom so as objects relative position to grid
     348             :             // appears stable
     349          46 :             rRectangle += GetGrafObject().GetGridOffset();
     350             :             const ::basegfx::B2DRange aObjectRange(
     351          92 :                 rRectangle.Left(), rRectangle.Top(),
     352         138 :                 rRectangle.Right(), rRectangle.Bottom());
     353             : 
     354             :             // look for mirroring
     355          46 :             const GeoStat& rGeoStat(GetGrafObject().GetGeoStat());
     356          46 :             const sal_Int32 nDrehWink(rGeoStat.nDrehWink);
     357          46 :             const bool bRota180(18000 == nDrehWink);
     358          46 :             const bool bMirrored(GetGrafObject().IsMirrored());
     359          46 :             const sal_uInt16 nMirrorCase(bRota180 ? (bMirrored ? 3 : 4) : (bMirrored ? 2 : 1));
     360          46 :             bool bHMirr((2 == nMirrorCase ) || (4 == nMirrorCase));
     361          46 :             bool bVMirr((3 == nMirrorCase ) || (4 == nMirrorCase));
     362             : 
     363             :             // set mirror flags at LocalGrafInfo. Take into account that the geometry in
     364             :             // aObjectRange is already changed and rotated when bRota180 is used. To rebuild
     365             :             // that old behaviour (as long as part of the model data), correct the H/V flags
     366             :             // accordingly. The created bitmapPrimitive WILL use the rotation, too.
     367          46 :             if(bRota180)
     368             :             {
     369             :                 // if bRota180 which is used for vertical mirroring, the graphic will already be rotated
     370             :                 // by 180 degrees. To correct, switch off VMirror and invert HMirroring.
     371           0 :                 bHMirr = !bHMirr;
     372           0 :                 bVMirr = false;
     373             :             }
     374             : 
     375          46 :             if(bHMirr || bVMirr)
     376             :             {
     377           0 :                 aLocalGrafInfo.SetMirrorFlags((bHMirr ? BMP_MIRROR_HORZ : 0)|(bVMirr ? BMP_MIRROR_VERT : 0));
     378             :             }
     379             : 
     380             :             // fill object matrix
     381          46 :             const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0);
     382          46 :             const double fRotate(nDrehWink ? (36000 - nDrehWink) * F_PI18000 : 0.0);
     383             :             const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
     384             :                 aObjectRange.getWidth(), aObjectRange.getHeight(),
     385             :                 fShearX, fRotate,
     386          46 :                 aObjectRange.getMinX(), aObjectRange.getMinY()));
     387             : 
     388             :             // get the current, unchenged graphic obect from SdrGrafObj
     389          46 :             const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(false);
     390             : 
     391          46 :             if(visualisationUsesPresObj())
     392             :             {
     393             :                 // it's an EmptyPresObj, create the SdrGrafPrimitive2D without content and another scaled one
     394             :                 // with the content which is the placeholder graphic
     395           0 :                 xRetval = createVIP2DSForPresObj(aObjectMatrix, aAttribute, aLocalGrafInfo);
     396             :             }
     397          46 :             else if(visualisationUsesDraft())
     398             :             {
     399             :                 // #i102380# The graphic is swapped out. To not force a swap-in here, there is a mechanism
     400             :                 // which shows a swapped-out-visualisation (which gets created here now) and an asynchronious
     401             :                 // visual update mechanism for swapped-out grapgics when they were loaded (see AsynchGraphicLoadingEvent
     402             :                 // and ViewObjectContactOfGraphic implementation). Not forcing the swap-in here allows faster
     403             :                 // (non-blocking) processing here and thus in the effect e.g. fast scrolling through pages
     404          25 :                 xRetval = createVIP2DSForDraft(aObjectMatrix, aAttribute);
     405             :             }
     406             :             else
     407             :             {
     408             :                 // create primitive. Info: Calling the copy-constructor of GraphicObject in this
     409             :                 // SdrGrafPrimitive2D constructor will force a full swap-in of the graphic
     410             :                 const drawinglayer::primitive2d::Primitive2DReference xReference(
     411             :                     new drawinglayer::primitive2d::SdrGrafPrimitive2D(
     412             :                         aObjectMatrix,
     413             :                         aAttribute,
     414             :                         rGraphicObject,
     415          21 :                         aLocalGrafInfo));
     416             : 
     417          21 :                 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
     418             :             }
     419             : 
     420             :             // always append an invisible outline for the cases where no visible content exists
     421             :             drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval,
     422             :                 drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
     423          46 :                     false, aObjectMatrix));
     424             : 
     425          46 :             return xRetval;
     426             :         }
     427             : 
     428         100 :         bool ViewContactOfGraphic::visualisationUsesPresObj() const
     429             :         {
     430         100 :             return GetGrafObject().IsEmptyPresObj();
     431             :         }
     432             : 
     433          54 :         bool ViewContactOfGraphic::visualisationUsesDraft() const
     434             :         {
     435             :             // no draft when already PresObj
     436          54 :             if(visualisationUsesPresObj())
     437           0 :                 return false;
     438             : 
     439             :             // draft when swapped out
     440          54 :             const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(false);
     441             :             static bool bAllowReplacements(true);
     442             : 
     443          54 :             if(rGraphicObject.IsSwappedOut() && bAllowReplacements)
     444           0 :                 return true;
     445             : 
     446             :             // draft when no graphic
     447          54 :             if(GRAPHIC_NONE == rGraphicObject.GetType() || GRAPHIC_DEFAULT == rGraphicObject.GetType())
     448          25 :                return true;
     449             : 
     450          29 :             return false;
     451             :         }
     452             : 
     453             :     } // end of namespace contact
     454             : } // end of namespace sdr
     455             : 
     456             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10