LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - objectcontactofobjlistpainter.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 47 64 73.4 %
Date: 2014-11-03 Functions: 13 22 59.1 %
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/objectcontactofobjlistpainter.hxx>
      21             : #include <svx/sdr/contact/displayinfo.hxx>
      22             : #include <svx/sdr/contact/viewobjectcontact.hxx>
      23             : #include <svx/svdpage.hxx>
      24             : #include <svx/svdobj.hxx>
      25             : #include <svx/sdr/contact/viewcontact.hxx>
      26             : #include <svx/svdmodel.hxx>
      27             : #include <basegfx/matrix/b2dhommatrix.hxx>
      28             : #include <drawinglayer/processor2d/processor2dtools.hxx>
      29             : #include <svx/unoapi.hxx>
      30             : #include <boost/scoped_ptr.hpp>
      31             : 
      32             : 
      33             : namespace sdr
      34             : {
      35             :     namespace contact
      36             :     {
      37         580 :         ObjectContactPainter::ObjectContactPainter()
      38             :         {
      39         580 :         }
      40             : 
      41             :         // The destructor.
      42         580 :         ObjectContactPainter::~ObjectContactPainter()
      43             :         {
      44         580 :         }
      45             :     } // end of namespace contact
      46             : } // end of namespace sdr
      47             : 
      48             : 
      49             : 
      50             : namespace sdr
      51             : {
      52             :     namespace contact
      53             :     {
      54         572 :         sal_uInt32 ObjectContactOfObjListPainter::GetPaintObjectCount() const
      55             :         {
      56         572 :             return maStartObjects.size();
      57             :         }
      58             : 
      59         572 :         ViewContact& ObjectContactOfObjListPainter::GetPaintObjectViewContact(sal_uInt32 nIndex) const
      60             :         {
      61         572 :             const SdrObject* pObj = maStartObjects[nIndex];
      62             :             DBG_ASSERT(pObj, "ObjectContactOfObjListPainter: Corrupt SdrObjectVector (!)");
      63         572 :             return pObj->GetViewContact();
      64             :         }
      65             : 
      66         572 :         ObjectContactOfObjListPainter::ObjectContactOfObjListPainter(
      67             :             OutputDevice& rTargetDevice,
      68             :             const SdrObjectVector& rObjects,
      69             :             const SdrPage* pProcessedPage)
      70             :         :   ObjectContactPainter(),
      71             :             mrTargetOutputDevice(rTargetDevice),
      72             :             maStartObjects(rObjects),
      73         572 :             mpProcessedPage(pProcessedPage)
      74             :         {
      75         572 :         }
      76             : 
      77         572 :         ObjectContactOfObjListPainter::~ObjectContactOfObjListPainter()
      78             :         {
      79         572 :         }
      80             : 
      81             :         // Process the whole displaying
      82         572 :         void ObjectContactOfObjListPainter::ProcessDisplay(DisplayInfo& rDisplayInfo)
      83             :         {
      84         572 :             const sal_uInt32 nCount(GetPaintObjectCount());
      85             : 
      86         572 :             if(nCount)
      87             :             {
      88         572 :                 OutputDevice* pTargetDevice = TryToGetOutputDevice();
      89             : 
      90         572 :                 if(pTargetDevice)
      91             :                 {
      92             :                     // update current ViewInformation2D at the ObjectContact
      93         572 :                     const GDIMetaFile* pMetaFile = pTargetDevice->GetConnectMetaFile();
      94         572 :                     const bool bOutputToRecordingMetaFile(pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
      95         572 :                     basegfx::B2DRange aViewRange;
      96             : 
      97             :                     // create ViewRange
      98         572 :                     if(!bOutputToRecordingMetaFile)
      99             :                     {
     100             :                         // use visible pixels, but transform to world coordinates
     101           0 :                         const Size aOutputSizePixel(pTargetDevice->GetOutputSizePixel());
     102           0 :                         aViewRange = ::basegfx::B2DRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight());
     103           0 :                         aViewRange.transform(pTargetDevice->GetInverseViewTransformation());
     104             :                     }
     105             : 
     106             :                     // upate local ViewInformation2D
     107             :                     const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D(
     108             :                         basegfx::B2DHomMatrix(),
     109             :                         pTargetDevice->GetViewTransformation(),
     110             :                         aViewRange,
     111             :                         GetXDrawPageForSdrPage(const_cast< SdrPage* >(mpProcessedPage)),
     112             :                         0.0,
     113         572 :                         com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>());
     114         572 :                     updateViewInformation2D(aNewViewInformation2D);
     115             : 
     116             :                     // collect primitive data in a sequence; this will already use the updated ViewInformation2D
     117        1144 :                     drawinglayer::primitive2d::Primitive2DSequence xPrimitiveSequence;
     118             : 
     119        1144 :                     for(sal_uInt32 a(0L); a < nCount; a++)
     120             :                     {
     121         572 :                         const ViewObjectContact& rViewObjectContact = GetPaintObjectViewContact(a).GetViewObjectContact(*this);
     122             : 
     123             :                         drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xPrimitiveSequence,
     124         572 :                             rViewObjectContact.getPrimitive2DSequenceHierarchy(rDisplayInfo));
     125             :                     }
     126             : 
     127             :                     // if there is something to show, use a vclProcessor to render it
     128         572 :                     if(xPrimitiveSequence.hasElements())
     129             :                     {
     130             :                         boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createProcessor2DFromOutputDevice(
     131             :                             *pTargetDevice,
     132         512 :                             getViewInformation2D()));
     133             : 
     134         512 :                         if(pProcessor2D)
     135             :                         {
     136         512 :                             pProcessor2D->process(xPrimitiveSequence);
     137         512 :                         }
     138         572 :                     }
     139             :                 }
     140             :             }
     141         572 :         }
     142             : 
     143             :         // VirtualDevice?
     144           0 :         bool ObjectContactOfObjListPainter::isOutputToVirtualDevice() const
     145             :         {
     146           0 :             return (OUTDEV_VIRDEV == mrTargetOutputDevice.GetOutDevType());
     147             :         }
     148             : 
     149             :         // recording MetaFile?
     150           0 :         bool ObjectContactOfObjListPainter::isOutputToRecordingMetaFile() const
     151             :         {
     152           0 :             GDIMetaFile* pMetaFile = mrTargetOutputDevice.GetConnectMetaFile();
     153           0 :             return (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
     154             :         }
     155             : 
     156             :         // pdf export?
     157           0 :         bool ObjectContactOfObjListPainter::isOutputToPDFFile() const
     158             :         {
     159           0 :             return (0 != mrTargetOutputDevice.GetPDFWriter());
     160             :         }
     161             : 
     162         578 :         OutputDevice* ObjectContactOfObjListPainter::TryToGetOutputDevice() const
     163             :         {
     164         578 :             return &mrTargetOutputDevice;
     165             :         }
     166             :     } // end of namespace contact
     167             : } // end of namespace sdr
     168             : 
     169             : 
     170             : 
     171             : namespace sdr
     172             : {
     173             :     namespace contact
     174             :     {
     175           0 :         sal_uInt32 ObjectContactOfPagePainter::GetPaintObjectCount() const
     176             :         {
     177           0 :             return (GetStartPage() ? 1L : 0L);
     178             :         }
     179             : 
     180           0 :         ViewContact& ObjectContactOfPagePainter::GetPaintObjectViewContact(sal_uInt32 /*nIndex*/) const
     181             :         {
     182             :             DBG_ASSERT(GetStartPage(), "ObjectContactOfPagePainter::GetPaintObjectViewContact: no StartPage set (!)");
     183           0 :             return GetStartPage()->GetViewContact();
     184             :         }
     185             : 
     186           8 :         ObjectContactOfPagePainter::ObjectContactOfPagePainter(
     187             :             const SdrPage* pPage,
     188             :             ObjectContact& rOriginalObjectContact)
     189             :         :   ObjectContactPainter(),
     190             :             mrOriginalObjectContact(rOriginalObjectContact),
     191           8 :             mxStartPage(const_cast< SdrPage* >(pPage)) // no SdrPageWeakRef available to hold a const SdrPage*
     192             :         {
     193           8 :         }
     194             : 
     195           8 :         ObjectContactOfPagePainter::~ObjectContactOfPagePainter()
     196             :         {
     197           8 :         }
     198             : 
     199           8 :         void ObjectContactOfPagePainter::SetStartPage(const SdrPage* pPage)
     200             :         {
     201           8 :             if(pPage != GetStartPage())
     202             :             {
     203           0 :                 mxStartPage.reset(const_cast< SdrPage* >(pPage)); // no SdrPageWeakRef available to hold a const SdrPage*
     204             :             }
     205           8 :         }
     206             : 
     207           0 :         OutputDevice* ObjectContactOfPagePainter::TryToGetOutputDevice() const
     208             :         {
     209           0 :             return mrOriginalObjectContact.TryToGetOutputDevice();
     210             :         }
     211             :     } // end of namespace contact
     212         651 : } // end of namespace sdr
     213             : 
     214             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10