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

Generated by: LCOV version 1.10