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

Generated by: LCOV version 1.10