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

Generated by: LCOV version 1.10