LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewcontactofunocontrol.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 34 40 85.0 %
Date: 2014-04-11 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 <sal/config.h>
      21             : 
      22             : #include <boost/noncopyable.hpp>
      23             : #include <svx/sdr/contact/viewcontactofunocontrol.hxx>
      24             : #include <svx/sdr/contact/viewobjectcontactofunocontrol.hxx>
      25             : #include <svx/sdr/contact/objectcontactofpageview.hxx>
      26             : #include <svx/sdr/contact/displayinfo.hxx>
      27             : #include <svx/svdouno.hxx>
      28             : #include <svx/svdpagv.hxx>
      29             : #include <svx/svdview.hxx>
      30             : #include <svx/sdrpagewindow.hxx>
      31             : 
      32             : #include <com/sun/star/awt/XWindow2.hpp>
      33             : 
      34             : #include "svx/sdrpaintwindow.hxx"
      35             : #include <tools/diagnose_ex.h>
      36             : #include <vcl/pdfextoutdevdata.hxx>
      37             : #include <basegfx/matrix/b2dhommatrix.hxx>
      38             : #include <drawinglayer/primitive2d/controlprimitive2d.hxx>
      39             : #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
      40             : 
      41             : 
      42             : namespace sdr { namespace contact {
      43             : 
      44             : 
      45             :     using ::com::sun::star::awt::XControl;
      46             :     using ::com::sun::star::uno::Reference;
      47             :     using ::com::sun::star::awt::XControlContainer;
      48             :     using ::com::sun::star::awt::XControlModel;
      49             :     using ::com::sun::star::awt::XWindow2;
      50             :     using ::com::sun::star::uno::UNO_QUERY;
      51             :     using ::com::sun::star::uno::Exception;
      52             : 
      53             : 
      54             :     //= ViewContactOfUnoControl
      55             : 
      56             :     class ViewContactOfUnoControl_Impl: private boost::noncopyable
      57             :     {
      58             :     public:
      59             :         ViewContactOfUnoControl_Impl();
      60             :         ~ViewContactOfUnoControl_Impl();
      61             :     };
      62             : 
      63             : 
      64         313 :     ViewContactOfUnoControl_Impl::ViewContactOfUnoControl_Impl()
      65             :     {
      66         313 :     }
      67             : 
      68             : 
      69         311 :     ViewContactOfUnoControl_Impl::~ViewContactOfUnoControl_Impl()
      70             :     {
      71         311 :     }
      72             : 
      73             : 
      74             :     //= ViewContactOfUnoControl
      75             : 
      76             : 
      77         313 :     ViewContactOfUnoControl::ViewContactOfUnoControl( SdrUnoObj& _rUnoObject )
      78             :         :ViewContactOfSdrObj( _rUnoObject )
      79         313 :         ,m_pImpl( new ViewContactOfUnoControl_Impl )
      80             :     {
      81         313 :     }
      82             : 
      83             : 
      84         622 :     ViewContactOfUnoControl::~ViewContactOfUnoControl()
      85             :     {
      86         622 :     }
      87             : 
      88             : 
      89           0 :     Reference< XControl > ViewContactOfUnoControl::getTemporaryControlForWindow(
      90             :         const Window& _rWindow, Reference< XControlContainer >& _inout_ControlContainer ) const
      91             :     {
      92           0 :         SdrUnoObj* pUnoObject = dynamic_cast< SdrUnoObj* >( TryToGetSdrObject() );
      93             :         OSL_ENSURE( pUnoObject, "ViewContactOfUnoControl::getTemporaryControlForDevice: no SdrUnoObj!" );
      94           0 :         if ( !pUnoObject )
      95           0 :             return NULL;
      96           0 :         return ViewObjectContactOfUnoControl::getTemporaryControlForWindow( _rWindow, _inout_ControlContainer, *pUnoObject );
      97             :     }
      98             : 
      99             : 
     100         286 :     ViewObjectContact& ViewContactOfUnoControl::CreateObjectSpecificViewObjectContact( ObjectContact& _rObjectContact )
     101             :     {
     102             :         // print or print preview requires special handling
     103         286 :         const OutputDevice* pDevice = _rObjectContact.TryToGetOutputDevice();
     104         286 :         bool bPrintOrPreview = ( pDevice != NULL ) && ( pDevice->GetOutDevType() == OUTDEV_PRINTER );
     105             : 
     106         286 :         ObjectContactOfPageView* pPageViewContact = dynamic_cast< ObjectContactOfPageView* >( &_rObjectContact  );
     107         286 :         bPrintOrPreview |= ( pPageViewContact != NULL ) && pPageViewContact->GetPageWindow().GetPageView().GetView().IsPrintPreview();
     108             : 
     109         286 :         if ( bPrintOrPreview )
     110           0 :             return *new UnoControlPrintOrPreviewContact( *pPageViewContact, *this );
     111             : 
     112             :         // all others are nowadays served by the same implementation
     113         286 :         return *new ViewObjectContactOfUnoControl( _rObjectContact, *this );
     114             :     }
     115             : 
     116             : 
     117         588 :     drawinglayer::primitive2d::Primitive2DSequence ViewContactOfUnoControl::createViewIndependentPrimitive2DSequence() const
     118             :     {
     119             :         // create range. Use model data directly, not getBoundRect()/getSnapRect; these will use
     120             :         // the primitive data themselves in the long run. Use SdrUnoObj's (which is a SdrRectObj)
     121             :         // call to GetGeoRect() to access SdrTextObj::aRect directly and without executing anything
     122         588 :         Rectangle aRectangle(GetSdrUnoObj().GetGeoRect());
     123             :         // Hack for calc, transform position of object according
     124             :         // to current zoom so as objects relative position to grid
     125             :         // appears stable
     126         588 :         Point aGridOffset = GetSdrUnoObj().GetGridOffset();
     127         588 :         aRectangle += aGridOffset;
     128             :         const basegfx::B2DRange aRange(
     129        1176 :             aRectangle.Left(), aRectangle.Top(),
     130        1764 :             aRectangle.Right(), aRectangle.Bottom());
     131             : 
     132             :         // create object transform
     133         588 :         basegfx::B2DHomMatrix aTransform;
     134             : 
     135         588 :         aTransform.set(0, 0, aRange.getWidth());
     136         588 :         aTransform.set(1, 1, aRange.getHeight());
     137         588 :         aTransform.set(0, 2, aRange.getMinX());
     138         588 :         aTransform.set(1, 2, aRange.getMinY());
     139             : 
     140        1176 :         Reference< XControlModel > xControlModel = GetSdrUnoObj().GetUnoControlModel();
     141             : 
     142         588 :         if(xControlModel.is())
     143             :         {
     144             :             // create control primitive WITHOUT possibly existing XControl; this would be done in
     145             :             // the VOC in createPrimitive2DSequence()
     146             :             const drawinglayer::primitive2d::Primitive2DReference xRetval(
     147             :                 new drawinglayer::primitive2d::ControlPrimitive2D(
     148             :                     aTransform,
     149         581 :                     xControlModel));
     150             : 
     151         581 :             return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
     152             :         }
     153             :         else
     154             :         {
     155             :             // always append an invisible outline for the cases where no visible content exists
     156             :             const drawinglayer::primitive2d::Primitive2DReference xRetval(
     157             :                 drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
     158           7 :                     false, aTransform));
     159             : 
     160           7 :             return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
     161         588 :         }
     162             :     }
     163             : 
     164             : 
     165             : } } // namespace sdr::contact
     166             : 
     167             : 
     168             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10