LCOV - code coverage report
Current view: top level - sd/source/ui/view - drviews8.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 59 1.7 %
Date: 2014-11-03 Functions: 2 3 66.7 %
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 "DrawViewShell.hxx"
      21             : 
      22             : #include "ViewShellHint.hxx"
      23             : 
      24             : #include <toolkit/helper/vclunohelper.hxx>
      25             : #include <sfx2/dispatch.hxx>
      26             : #include <svx/svxids.hrc>
      27             : #include <vcl/msgbox.hxx>
      28             : #include <svx/svddef.hxx>
      29             : #include <sfx2/bindings.hxx>
      30             : #include <sfx2/request.hxx>
      31             : #include <sfx2/viewfrm.hxx>
      32             : #include <svx/svdograf.hxx>
      33             : #include <svx/svdpagv.hxx>
      34             : 
      35             : #include "app.hrc"
      36             : #include "strings.hrc"
      37             : 
      38             : #include "sdresid.hxx"
      39             : #include "Window.hxx"
      40             : #include "drawview.hxx"
      41             : #include "zoomlist.hxx"
      42             : #include <osl/mutex.hxx>
      43             : #include <tools/helpers.hxx>
      44             : #include <vcl/svapp.hxx>
      45             : 
      46             : namespace sd {
      47             : 
      48           0 : void DrawViewShell::ScannerEvent( const ::com::sun::star::lang::EventObject& )
      49             : {
      50           0 :     if( mxScannerManager.is() )
      51             :     {
      52           0 :         const ::com::sun::star::scanner::ScannerContext aContext( mxScannerManager->getAvailableScanners().getConstArray()[ 0 ] );
      53           0 :         const ::com::sun::star::scanner::ScanError      eError = mxScannerManager->getError( aContext );
      54             : 
      55           0 :         if( ::com::sun::star::scanner::ScanError_ScanErrorNone == eError )
      56             :         {
      57           0 :             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBitmap( mxScannerManager->getBitmap( aContext ) );
      58             : 
      59           0 :             if( xBitmap.is() )
      60             :             {
      61           0 :                 const BitmapEx aScanBmp( VCLUnoHelper::GetBitmap( xBitmap ) );
      62             : 
      63           0 :                 if( !!aScanBmp )
      64             :                 {
      65           0 :                     const SolarMutexGuard aGuard;
      66           0 :                     SdrPage*            pPage = mpDrawView->GetSdrPageView()->GetPage();
      67           0 :                     Size                aBmpSize( aScanBmp.GetPrefSize() ), aPageSize( pPage->GetSize() );
      68           0 :                     const MapMode       aMap100( MAP_100TH_MM );
      69             : 
      70           0 :                     if( !aBmpSize.Width() || !aBmpSize.Height() )
      71           0 :                         aBmpSize = aScanBmp.GetSizePixel();
      72             : 
      73           0 :                     if( aScanBmp.GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
      74           0 :                         aBmpSize = GetActiveWindow()->PixelToLogic( aBmpSize, aMap100 );
      75             :                     else
      76           0 :                         aBmpSize = OutputDevice::LogicToLogic( aBmpSize, aScanBmp.GetPrefMapMode(), aMap100 );
      77             : 
      78           0 :                     aPageSize.Width() -= pPage->GetLftBorder() + pPage->GetRgtBorder();
      79           0 :                     aPageSize.Height() -= pPage->GetUppBorder() + pPage->GetLwrBorder();
      80             : 
      81           0 :                     if( ( ( aBmpSize.Height() > aPageSize.Height() ) || ( aBmpSize.Width() > aPageSize.Width() ) ) && aBmpSize.Height() && aPageSize.Height() )
      82             :                     {
      83           0 :                         double fGrfWH = (double) aBmpSize.Width() / aBmpSize.Height();
      84           0 :                         double fWinWH = (double) aPageSize.Width() / aPageSize.Height();
      85             : 
      86           0 :                         if( fGrfWH < fWinWH )
      87             :                         {
      88           0 :                             aBmpSize.Width() = FRound( aPageSize.Height() * fGrfWH );
      89           0 :                             aBmpSize.Height()= aPageSize.Height();
      90             :                         }
      91           0 :                         else if( fGrfWH > 0.F )
      92             :                         {
      93           0 :                             aBmpSize.Width() = aPageSize.Width();
      94           0 :                             aBmpSize.Height()= FRound( aPageSize.Width() / fGrfWH );
      95             :                         }
      96             :                     }
      97             : 
      98           0 :                     Point aPnt ( ( aPageSize.Width() - aBmpSize.Width() ) >> 1, ( aPageSize.Height() - aBmpSize.Height() ) >> 1 );
      99           0 :                     aPnt += Point( pPage->GetLftBorder(), pPage->GetUppBorder() );
     100           0 :                     Rectangle   aRect( aPnt, aBmpSize );
     101           0 :                     SdrGrafObj* pGrafObj = NULL;
     102           0 :                     bool        bInsertNewObject = true;
     103             : 
     104           0 :                     if( GetView()->AreObjectsMarked() )
     105             :                     {
     106           0 :                         const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
     107             : 
     108           0 :                         if( rMarkList.GetMarkCount() == 1 )
     109             :                         {
     110           0 :                             SdrMark*    pMark = rMarkList.GetMark(0);
     111           0 :                             SdrObject*  pObj = pMark->GetMarkedSdrObj();
     112             : 
     113           0 :                             if( pObj->ISA( SdrGrafObj ) )
     114             :                             {
     115           0 :                                 pGrafObj = static_cast< SdrGrafObj* >( pObj );
     116             : 
     117           0 :                                 if( pGrafObj->IsEmptyPresObj() )
     118             :                                 {
     119           0 :                                     bInsertNewObject = false;
     120           0 :                                     pGrafObj->SetEmptyPresObj(false);
     121           0 :                                     pGrafObj->SetOutlinerParaObject(NULL);
     122           0 :                                     pGrafObj->SetGraphic( Graphic( aScanBmp ) );
     123             :                                 }
     124             :                             }
     125             :                         }
     126             :                     }
     127             : 
     128           0 :                     if( bInsertNewObject )
     129             :                     {
     130           0 :                         pGrafObj = new SdrGrafObj( Graphic( aScanBmp ), aRect );
     131           0 :                         SdrPageView* pPV = GetView()->GetSdrPageView();
     132           0 :                         GetView()->InsertObjectAtView( pGrafObj, *pPV, SDRINSERT_SETDEFLAYER );
     133           0 :                     }
     134           0 :                 }
     135           0 :             }
     136           0 :         }
     137             :     }
     138             : 
     139           0 :     SfxBindings& rBindings = GetViewFrame()->GetBindings();
     140           0 :     rBindings.Invalidate( SID_TWAIN_SELECT );
     141           0 :     rBindings.Invalidate( SID_TWAIN_TRANSFER );
     142           0 : }
     143             : 
     144         114 : } // end of namespace sd
     145             : 
     146             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10