LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewcontactofunocontrol.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 36 42 85.7 %
Date: 2014-11-03 Functions: 9 10 90.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 <sal/config.h>
      21             : 
      22             : #include <boost/noncopyable.hpp>
      23             : #include <sdr/contact/viewcontactofunocontrol.hxx>
      24             : #include <sdr/contact/viewobjectcontactofunocontrol.hxx>
      25             : #include <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         672 :     ViewContactOfUnoControl_Impl::ViewContactOfUnoControl_Impl()
      65             :     {
      66         672 :     }
      67             : 
      68             : 
      69         668 :     ViewContactOfUnoControl_Impl::~ViewContactOfUnoControl_Impl()
      70             :     {
      71         668 :     }
      72             : 
      73         672 :     ViewContactOfUnoControl::ViewContactOfUnoControl( SdrUnoObj& _rUnoObject )
      74             :         :ViewContactOfSdrObj( _rUnoObject )
      75         672 :         ,m_pImpl( new ViewContactOfUnoControl_Impl )
      76             :     {
      77         672 :     }
      78             : 
      79             : 
      80        1336 :     ViewContactOfUnoControl::~ViewContactOfUnoControl()
      81             :     {
      82        1336 :     }
      83             : 
      84             : 
      85           0 :     Reference< XControl > ViewContactOfUnoControl::getTemporaryControlForWindow(
      86             :         const vcl::Window& _rWindow, Reference< XControlContainer >& _inout_ControlContainer ) const
      87             :     {
      88           0 :         SdrUnoObj* pUnoObject = dynamic_cast< SdrUnoObj* >( TryToGetSdrObject() );
      89             :         OSL_ENSURE( pUnoObject, "ViewContactOfUnoControl::getTemporaryControlForDevice: no SdrUnoObj!" );
      90           0 :         if ( !pUnoObject )
      91           0 :             return NULL;
      92           0 :         return ViewObjectContactOfUnoControl::getTemporaryControlForWindow( _rWindow, _inout_ControlContainer, *pUnoObject );
      93             :     }
      94             : 
      95             : 
      96         592 :     ViewObjectContact& ViewContactOfUnoControl::CreateObjectSpecificViewObjectContact( ObjectContact& _rObjectContact )
      97             :     {
      98             :         // print or print preview requires special handling
      99         592 :         const OutputDevice* pDevice = _rObjectContact.TryToGetOutputDevice();
     100         592 :         ObjectContactOfPageView* const pPageViewContact = dynamic_cast< ObjectContactOfPageView* >( &_rObjectContact  );
     101             : 
     102             :         const bool bPrintOrPreview = pPageViewContact
     103         592 :             && ( ( ( pDevice != NULL ) && ( pDevice->GetOutDevType() == OUTDEV_PRINTER ) )
     104         590 :                     || pPageViewContact->GetPageWindow().GetPageView().GetView().IsPrintPreview()
     105         592 :                )
     106             :             ;
     107             : 
     108         592 :         if ( bPrintOrPreview )
     109           0 :             return *new UnoControlPrintOrPreviewContact( *pPageViewContact, *this );
     110             : 
     111             :         // all others are nowadays served by the same implementation
     112         592 :         return *new ViewObjectContactOfUnoControl( _rObjectContact, *this );
     113             :     }
     114             : 
     115             : 
     116        1196 :     drawinglayer::primitive2d::Primitive2DSequence ViewContactOfUnoControl::createViewIndependentPrimitive2DSequence() const
     117             :     {
     118             :         // create range. Use model data directly, not getBoundRect()/getSnapRect; these will use
     119             :         // the primitive data themselves in the long run. Use SdrUnoObj's (which is a SdrRectObj)
     120             :         // call to GetGeoRect() to access SdrTextObj::aRect directly and without executing anything
     121        1196 :         Rectangle aRectangle(GetSdrUnoObj().GetGeoRect());
     122             :         // Hack for calc, transform position of object according
     123             :         // to current zoom so as objects relative position to grid
     124             :         // appears stable
     125        1196 :         Point aGridOffset = GetSdrUnoObj().GetGridOffset();
     126        1196 :         aRectangle += aGridOffset;
     127             :         const basegfx::B2DRange aRange(
     128        2392 :             aRectangle.Left(), aRectangle.Top(),
     129        3588 :             aRectangle.Right(), aRectangle.Bottom());
     130             : 
     131             :         // create object transform
     132        1196 :         basegfx::B2DHomMatrix aTransform;
     133             : 
     134        1196 :         aTransform.set(0, 0, aRange.getWidth());
     135        1196 :         aTransform.set(1, 1, aRange.getHeight());
     136        1196 :         aTransform.set(0, 2, aRange.getMinX());
     137        1196 :         aTransform.set(1, 2, aRange.getMinY());
     138             : 
     139        2392 :         Reference< XControlModel > xControlModel = GetSdrUnoObj().GetUnoControlModel();
     140             : 
     141        1196 :         if(xControlModel.is())
     142             :         {
     143             :             // create control primitive WITHOUT possibly existing XControl; this would be done in
     144             :             // the VOC in createPrimitive2DSequence()
     145             :             const drawinglayer::primitive2d::Primitive2DReference xRetval(
     146             :                 new drawinglayer::primitive2d::ControlPrimitive2D(
     147             :                     aTransform,
     148        1157 :                     xControlModel));
     149             : 
     150        1157 :             return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
     151             :         }
     152             :         else
     153             :         {
     154             :             // always append an invisible outline for the cases where no visible content exists
     155             :             const drawinglayer::primitive2d::Primitive2DReference xRetval(
     156             :                 drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
     157          39 :                     false, aTransform));
     158             : 
     159          39 :             return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
     160        1196 :         }
     161             :     }
     162             : 
     163             : 
     164         651 : } } // namespace sdr::contact
     165             : 
     166             : 
     167             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10