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

Generated by: LCOV version 1.10