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

Generated by: LCOV version 1.11