LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewobjectcontactofsdrole2obj.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 29 40 72.5 %
Date: 2014-04-11 Functions: 5 5 100.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/viewobjectcontactofsdrole2obj.hxx>
      21             : #include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
      22             : #include <svx/sdr/contact/viewcontactofsdrole2obj.hxx>
      23             : #include <svx/svdoole2.hxx>
      24             : #include <svx/sdr/contact/objectcontact.hxx>
      25             : #include <svx/svdview.hxx>
      26             : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
      27             : #include <basegfx/polygon/b2dpolygontools.hxx>
      28             : #include <com/sun/star/embed/EmbedMisc.hpp>
      29             : #include <com/sun/star/embed/EmbedStates.hpp>
      30             : #include <com/sun/star/embed/XEmbeddedObject.hpp>
      31             : #include <basegfx/polygon/b2dpolygon.hxx>
      32             : #include <basegfx/matrix/b2dhommatrix.hxx>
      33             : 
      34             : 
      35             : 
      36             : using namespace com::sun::star;
      37             : 
      38             : 
      39             : 
      40             : namespace sdr
      41             : {
      42             :     namespace contact
      43             :     {
      44          97 :         const SdrOle2Obj& ViewObjectContactOfSdrOle2Obj::getSdrOle2Object() const
      45             :         {
      46          97 :             return static_cast< ViewContactOfSdrOle2Obj& >(GetViewContact()).GetOle2Obj();
      47             :         }
      48             : 
      49          97 :         drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfSdrOle2Obj::createPrimitive2DSequence(
      50             :             const DisplayInfo& /*rDisplayInfo*/) const
      51             :         {
      52             :             // this method is overloaded to do some things the old SdrOle2Obj::DoPaintObject did.
      53             :             // In the future, some of these may be solved different, but ATM try to stay compatible
      54             :             // with the old behaviour
      55          97 :             drawinglayer::primitive2d::Primitive2DSequence xRetval;
      56          97 :             const SdrOle2Obj& rSdrOle2 = getSdrOle2Object();
      57          97 :             sal_Int32 nState(-1);
      58             : 
      59             :             {
      60          97 :                 const svt::EmbeddedObjectRef& xObjRef  = rSdrOle2.getEmbeddedObjectRef();
      61          97 :                 if ( xObjRef.is() )
      62          94 :                     nState = xObjRef->getCurrentState();
      63             :             }
      64             : 
      65          97 :             const bool bIsOutplaceActive(nState == embed::EmbedStates::ACTIVE);
      66          97 :             const bool bIsInplaceActive((nState == embed::EmbedStates::INPLACE_ACTIVE) || (nState == embed::EmbedStates::UI_ACTIVE));
      67          97 :             bool bDone(false);
      68             : 
      69          97 :             if(!bDone && bIsInplaceActive)
      70             :             {
      71           0 :                 if( !GetObjectContact().isOutputToPrinter() && !GetObjectContact().isOutputToRecordingMetaFile() )
      72             :                 {
      73             :                     //no need to create a primitive sequence here as the OLE object does render itself
      74             :                     //in case of charts the superfluous creation of a metafile is strongly performance relevant!
      75           0 :                     bDone = true;
      76             :                 }
      77             :             }
      78             : 
      79          97 :             if( !bDone )
      80             :             {
      81             :                 //old stuff that should be reworked
      82             :                 {
      83             :                     //if no replacement image is available load the OLE object
      84             : //                    if(!rSdrOle2.GetGraphic()) //try to fetch the metafile - this can lead to the actual creation of the metafile what can be extremely expensive (e.g. for big charts)!!! #i101925#
      85             : //                    {
      86             : //                      // try to create embedded object
      87             : //                        rSdrOle2.GetObjRef(); //this loads the OLE object if it is not loaded already
      88             : //                    }
      89          97 :                     const svt::EmbeddedObjectRef& xObjRef  = rSdrOle2.getEmbeddedObjectRef();
      90          97 :                     if(xObjRef.is())
      91             :                     {
      92          94 :                         const sal_Int64 nMiscStatus(xObjRef->getStatus(rSdrOle2.GetAspect()));
      93             : 
      94             :                         // this hack (to change model data during PAINT argh(!)) should be reworked
      95          94 :                         if(!rSdrOle2.IsResizeProtect() && (nMiscStatus & embed::EmbedMisc::EMBED_NEVERRESIZE))
      96             :                         {
      97           0 :                             const_cast< SdrOle2Obj* >(&rSdrOle2)->SetResizeProtect(true);
      98             :                         }
      99             : 
     100          94 :                         SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
     101          94 :                         if(pPageView && (nMiscStatus & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE))
     102             :                         {
     103             :                             // connect plugin object
     104           0 :                             pPageView->GetView().DoConnect(const_cast< SdrOle2Obj* >(&rSdrOle2));
     105             :                         }
     106             :                     }
     107             :                 }//end old stuff to rework
     108             : 
     109             :                 // create OLE primitive stuff directly at VC with HC as parameter
     110          97 :                 const ViewContactOfSdrOle2Obj& rVC = static_cast< const ViewContactOfSdrOle2Obj& >(GetViewContact());
     111          97 :                 xRetval = rVC.createPrimitive2DSequenceWithParameters();
     112             : 
     113          97 :                 if(bIsOutplaceActive)
     114             :                 {
     115             :                     // do not shade when printing or PDF exporting
     116           0 :                     if(!GetObjectContact().isOutputToPrinter() && !GetObjectContact().isOutputToRecordingMetaFile())
     117             :                     {
     118             :                         // get object transformation
     119           0 :                         const basegfx::B2DHomMatrix aObjectMatrix(static_cast< ViewContactOfSdrOle2Obj& >(GetViewContact()).createObjectTransform());
     120             : 
     121             :                         // shade the representation if the object is activated outplace
     122           0 :                         basegfx::B2DPolygon aObjectOutline(basegfx::tools::createUnitPolygon());
     123           0 :                         aObjectOutline.transform(aObjectMatrix);
     124             : 
     125             :                         // Use a FillHatchPrimitive2D with necessary attributes
     126             :                         const drawinglayer::attribute::FillHatchAttribute aFillHatch(
     127             :                             drawinglayer::attribute::HATCHSTYLE_SINGLE, // single hatch
     128             :                             125.0, // 1.25 mm
     129             :                             45.0 * F_PI180, // 45 degree diagonal
     130             :                             Color(COL_BLACK).getBColor(), // black color
     131             :                             3, // same default as VCL, a minimum of three discrete units (pixels) offset
     132           0 :                             false); // no filling
     133             : 
     134             :                         const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolyPolygonHatchPrimitive2D(
     135             :                             basegfx::B2DPolyPolygon(aObjectOutline),
     136             :                             Color(COL_BLACK).getBColor(),
     137           0 :                             aFillHatch));
     138             : 
     139           0 :                         drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xReference);
     140             :                     }
     141             :                 }
     142             : 
     143             :             }
     144             : 
     145          97 :             return xRetval;
     146             :         }
     147             : 
     148          13 :         ViewObjectContactOfSdrOle2Obj::ViewObjectContactOfSdrOle2Obj(ObjectContact& rObjectContact, ViewContact& rViewContact)
     149          13 :         :   ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
     150             :         {
     151          13 :         }
     152             : 
     153          22 :         ViewObjectContactOfSdrOle2Obj::~ViewObjectContactOfSdrOle2Obj()
     154             :         {
     155          22 :         }
     156             :     } // end of namespace contact
     157             : } // end of namespace sdr
     158             : 
     159             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10