LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewcontactofunocontrol.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 32 38 84.2 %
Date: 2012-08-25 Functions: 7 8 87.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 30 62 48.4 %

           Branch data     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                 :        533 :     ViewContactOfUnoControl_Impl::ViewContactOfUnoControl_Impl()
      69                 :            :     {
      70                 :        533 :     }
      71                 :            : 
      72                 :            :     //--------------------------------------------------------------------
      73                 :        526 :     ViewContactOfUnoControl_Impl::~ViewContactOfUnoControl_Impl()
      74                 :            :     {
      75                 :        526 :     }
      76                 :            : 
      77                 :            :     //====================================================================
      78                 :            :     //= ViewContactOfUnoControl
      79                 :            :     //====================================================================
      80                 :            :     DBG_NAME( ViewContactOfUnoControl )
      81                 :            :     //--------------------------------------------------------------------
      82                 :        533 :     ViewContactOfUnoControl::ViewContactOfUnoControl( SdrUnoObj& _rUnoObject )
      83                 :            :         :ViewContactOfSdrObj( _rUnoObject )
      84         [ +  - ]:        533 :         ,m_pImpl( new ViewContactOfUnoControl_Impl )
      85                 :            :     {
      86                 :            :         DBG_CTOR( ViewContactOfUnoControl, NULL );
      87                 :        533 :     }
      88                 :            : 
      89                 :            :     //--------------------------------------------------------------------
      90                 :        526 :     ViewContactOfUnoControl::~ViewContactOfUnoControl()
      91                 :            :     {
      92                 :            :         DBG_DTOR( ViewContactOfUnoControl, NULL );
      93         [ -  + ]:       1052 :     }
      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                 :        498 :     ViewObjectContact& ViewContactOfUnoControl::CreateObjectSpecificViewObjectContact( ObjectContact& _rObjectContact )
     108                 :            :     {
     109                 :            :         // print or print preview requires special handling
     110                 :        498 :         const OutputDevice* pDevice = _rObjectContact.TryToGetOutputDevice();
     111 [ -  + ][ +  - ]:        498 :         bool bPrintOrPreview = ( pDevice != NULL ) && ( pDevice->GetOutDevType() == OUTDEV_PRINTER );
     112                 :            : 
     113         [ -  + ]:        498 :         ObjectContactOfPageView* pPageViewContact = dynamic_cast< ObjectContactOfPageView* >( &_rObjectContact  );
     114 [ +  + ][ -  + ]:        498 :         bPrintOrPreview |= ( pPageViewContact != NULL ) && pPageViewContact->GetPageWindow().GetPageView().GetView().IsPrintPreview();
     115                 :            : 
     116         [ -  + ]:        498 :         if ( bPrintOrPreview )
     117         [ #  # ]:          0 :             return *new UnoControlPrintOrPreviewContact( *pPageViewContact, *this );
     118                 :            : 
     119                 :            :         // all others are nowadays served by the same implementation
     120         [ +  - ]:        498 :         return *new ViewObjectContactOfUnoControl( _rObjectContact, *this );
     121                 :            :     }
     122                 :            : 
     123                 :            :     //--------------------------------------------------------------------
     124                 :        944 :     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                 :        944 :         const Rectangle& rRectangle(GetSdrUnoObj().GetGeoRect());
     130                 :            :         const basegfx::B2DRange aRange(
     131                 :        944 :             rRectangle.Left(), rRectangle.Top(),
     132         [ +  - ]:       1888 :             rRectangle.Right(), rRectangle.Bottom());
     133                 :            : 
     134                 :            :         // create object transform
     135         [ +  - ]:        944 :         basegfx::B2DHomMatrix aTransform;
     136                 :            : 
     137 [ +  - ][ +  - ]:        944 :         aTransform.set(0, 0, aRange.getWidth());
     138 [ +  - ][ +  - ]:        944 :         aTransform.set(1, 1, aRange.getHeight());
     139 [ +  - ][ +  - ]:        944 :         aTransform.set(0, 2, aRange.getMinX());
     140 [ +  - ][ +  - ]:        944 :         aTransform.set(1, 2, aRange.getMinY());
     141                 :            : 
     142         [ +  - ]:        944 :         Reference< XControlModel > xControlModel = GetSdrUnoObj().GetUnoControlModel();
     143                 :            : 
     144         [ +  + ]:        944 :         if(xControlModel.is())
     145                 :            :         {
     146                 :            :             // create control primitive WITHOUT possibly existing XControl; this would be done in
     147                 :            :             // the VOC in createPrimitive2DSequence()
     148                 :            :             const drawinglayer::primitive2d::Primitive2DReference xRetval(
     149                 :            :                 new drawinglayer::primitive2d::ControlPrimitive2D(
     150                 :            :                     aTransform,
     151 [ +  - ][ +  - ]:        891 :                     xControlModel));
                 [ +  - ]
     152                 :            : 
     153         [ +  - ]:        891 :             return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
     154                 :            :         }
     155                 :            :         else
     156                 :            :         {
     157                 :            :             // always append an invisible outline for the cases where no visible content exists
     158                 :            :             const drawinglayer::primitive2d::Primitive2DReference xRetval(
     159                 :            :                 drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
     160         [ +  - ]:         53 :                     false, aTransform));
     161                 :            : 
     162         [ +  - ]:         53 :             return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
     163         [ +  - ]:        944 :         }
     164                 :            :     }
     165                 :            : 
     166                 :            : //........................................................................
     167                 :            : } } // namespace sdr::contact
     168                 :            : //........................................................................
     169                 :            : 
     170                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10