LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewcontactofvirtobj.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 21 23 91.3 %
Date: 2014-11-03 Functions: 7 8 87.5 %
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/viewcontactofvirtobj.hxx>
      21             : #include <svx/svdovirt.hxx>
      22             : #include <svx/sdr/contact/displayinfo.hxx>
      23             : #include <basegfx/matrix/b2dhommatrix.hxx>
      24             : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
      25             : #include <vcl/outdev.hxx>
      26             : #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
      27             : 
      28             : 
      29             : 
      30             : namespace sdr
      31             : {
      32             :     namespace contact
      33             :     {
      34        4226 :         ViewContactOfVirtObj::ViewContactOfVirtObj(SdrVirtObj& rObj)
      35        4226 :         :   ViewContactOfSdrObj(rObj)
      36             :         {
      37        4226 :         }
      38             : 
      39        4226 :         ViewContactOfVirtObj::~ViewContactOfVirtObj()
      40             :         {
      41        4226 :         }
      42             : 
      43        1316 :         SdrVirtObj& ViewContactOfVirtObj::GetVirtObj() const
      44             :         {
      45        1316 :             return static_cast<SdrVirtObj&>(mrObject);
      46             :         }
      47             : 
      48             :         // Access to possible sub-hierarchy
      49        4630 :         sal_uInt32 ViewContactOfVirtObj::GetObjectCount() const
      50             :         {
      51             :             // Here, SdrVirtObj's need to return 0L to show that they have no
      52             :             // sub-hierarchy, even when they are group objects. This is necessary
      53             :             // to avoid that the same VOCs will be added to the draw hierarchy
      54             :             // twice which leads to problems.
      55             : 
      56             :             // This solution is only a first solution to get things running. Later
      57             :             // this needs to be replaced with creating real VOCs for the objects
      58             :             // referenced by virtual objects to avoid the 'trick' of setting the
      59             :             // offset for painting at the destination OutputDevive.
      60             : 
      61             :             // As can be seen, with primitives, the problem will be solved using
      62             :             // a transformPrimitive, so this solution can stay with primitives.
      63        4630 :             return 0L;
      64             :         }
      65             : 
      66         658 :         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfVirtObj::createViewIndependentPrimitive2DSequence() const
      67             :         {
      68             :             // create displacement transformation if we have content
      69         658 :             basegfx::B2DHomMatrix aObjectMatrix;
      70         658 :             Point aAnchor(GetVirtObj().GetAnchorPos());
      71             : 
      72         658 :             if(aAnchor.X() || aAnchor.Y())
      73             :             {
      74         646 :                 aObjectMatrix.set(0, 2, aAnchor.X());
      75         646 :                 aObjectMatrix.set(1, 2, aAnchor.Y());
      76             :             }
      77             : 
      78             :             // use method from referenced object to get the Primitive2DSequence
      79             :             const drawinglayer::primitive2d::Primitive2DSequence xSequenceVirtual(
      80        1316 :                 GetVirtObj().GetReferencedObj().GetViewContact().getViewIndependentPrimitive2DSequence());
      81             : 
      82         658 :             if(xSequenceVirtual.hasElements())
      83             :             {
      84             :                 // create transform primitive
      85             :                 const drawinglayer::primitive2d::Primitive2DReference xReference(
      86             :                     new drawinglayer::primitive2d::TransformPrimitive2D(
      87             :                         aObjectMatrix,
      88         658 :                         xSequenceVirtual));
      89             : 
      90         658 :                 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
      91             :             }
      92             :             else
      93             :             {
      94             :                 // always append an invisible outline for the cases where no visible content exists
      95             :                 const drawinglayer::primitive2d::Primitive2DReference xReference(
      96             :                     drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
      97           0 :                         false, aObjectMatrix));
      98             : 
      99           0 :                 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
     100         658 :             }
     101             :         }
     102             :     } // end of namespace contact
     103         651 : } // end of namespace sdr
     104             : 
     105             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10