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

Generated by: LCOV version 1.10