LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/func - fuzoom.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 79 1.3 %
Date: 2013-07-09 Functions: 2 16 12.5 %
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 "fuzoom.hxx"
      21             : 
      22             : #include <svx/svxids.hrc>
      23             : #include <sfx2/bindings.hxx>
      24             : #include <sfx2/viewfrm.hxx>
      25             : #include "app.hrc"
      26             : #include <svx/svdpagv.hxx>
      27             : 
      28             : #include "FrameView.hxx"
      29             : #include "ViewShell.hxx"
      30             : #include "View.hxx"
      31             : #include "Window.hxx"
      32             : #include "drawdoc.hxx"
      33             : #include "zoomlist.hxx"
      34             : 
      35             : namespace sd {
      36             : 
      37             : sal_uInt16 SidArrayZoom[] = {
      38             :                     SID_ATTR_ZOOM,
      39             :                     SID_ZOOM_OUT,
      40             :                     SID_ZOOM_IN,
      41             :                     0 };
      42             : 
      43           0 : TYPEINIT1( FuZoom, FuPoor );
      44             : 
      45           0 : FuZoom::FuZoom(
      46             :     ViewShell* pViewSh,
      47             :     ::sd::Window* pWin,
      48             :     ::sd::View* pView,
      49             :     SdDrawDocument* pDoc,
      50             :     SfxRequest& rReq)
      51             :     : FuPoor(pViewSh, pWin, pView, pDoc, rReq),
      52             :       bVisible(sal_False),
      53           0 :       bStartDrag(sal_False)
      54             : {
      55           0 : }
      56             : 
      57           0 : FuZoom::~FuZoom()
      58             : {
      59           0 :     if (bVisible)
      60             :     {
      61             :         // Hide ZoomRect
      62           0 :         mpViewShell->DrawMarkRect(aZoomRect);
      63             : 
      64           0 :         bVisible = sal_False;
      65           0 :         bStartDrag = sal_False;
      66             :     }
      67           0 : }
      68             : 
      69           0 : FunctionReference FuZoom::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      70             : {
      71           0 :     FunctionReference xFunc( new FuZoom( pViewSh, pWin, pView, pDoc, rReq ) );
      72           0 :     return xFunc;
      73             : }
      74             : 
      75           0 : sal_Bool FuZoom::MouseButtonDown(const MouseEvent& rMEvt)
      76             : {
      77             :     // remember button state for creation of own MouseEvents
      78           0 :     SetMouseButtonCode(rMEvt.GetButtons());
      79             : 
      80           0 :     mpWindow->CaptureMouse();
      81           0 :     bStartDrag = sal_True;
      82             : 
      83           0 :     aBeginPosPix = rMEvt.GetPosPixel();
      84           0 :     aBeginPos = mpWindow->PixelToLogic(aBeginPosPix);
      85             : 
      86           0 :     return sal_True;
      87             : }
      88             : 
      89           0 : sal_Bool FuZoom::MouseMove(const MouseEvent& rMEvt)
      90             : {
      91           0 :     if (bStartDrag)
      92             :     {
      93           0 :         if (bVisible)
      94             :         {
      95           0 :             mpViewShell->DrawMarkRect(aZoomRect);
      96             :         }
      97             : 
      98           0 :         Point aPosPix = rMEvt.GetPosPixel();
      99           0 :         ForceScroll(aPosPix);
     100             : 
     101           0 :         aEndPos = mpWindow->PixelToLogic(aPosPix);
     102           0 :         aBeginPos = mpWindow->PixelToLogic(aBeginPosPix);
     103             : 
     104           0 :         if (nSlotId == SID_ZOOM_PANNING)
     105             :         {
     106             :             // Panning
     107             : 
     108           0 :             Point aScroll = aBeginPos - aEndPos;
     109             : 
     110           0 :             if (aScroll.X() != 0 || aScroll.Y() != 0)
     111             :             {
     112           0 :                 Size aWorkSize = mpView->GetWorkArea().GetSize();
     113           0 :                 Size aPageSize = mpView->GetSdrPageView()->GetPage()->GetSize();
     114           0 :                 aScroll.X() /= aWorkSize.Width()  / aPageSize.Width();
     115           0 :                 aScroll.Y() /= aWorkSize.Height() / aPageSize.Height();
     116           0 :                 mpViewShell->Scroll(aScroll.X(), aScroll.Y());
     117           0 :                 aBeginPosPix = aPosPix;
     118             :             }
     119             :         }
     120             :         else
     121             :         {
     122           0 :             Rectangle aRect(aBeginPos, aEndPos);
     123           0 :             aZoomRect = aRect;
     124           0 :             aZoomRect.Justify();
     125           0 :             mpViewShell->DrawMarkRect(aZoomRect);
     126             :         }
     127             : 
     128           0 :         bVisible = sal_True;
     129             :     }
     130             : 
     131           0 :     return bStartDrag;
     132             : }
     133             : 
     134           0 : sal_Bool FuZoom::MouseButtonUp(const MouseEvent& rMEvt)
     135             : {
     136             :     // remember button state for creation of own MouseEvents
     137           0 :     SetMouseButtonCode(rMEvt.GetButtons());
     138             : 
     139           0 :     if (bVisible)
     140             :     {
     141             :         // Hide ZoomRect
     142           0 :         mpViewShell->DrawMarkRect(aZoomRect);
     143           0 :         bVisible = sal_False;
     144             :     }
     145             : 
     146           0 :     Point aPosPix = rMEvt.GetPosPixel();
     147             : 
     148           0 :     if(SID_ZOOM_PANNING != nSlotId)
     149             :     {
     150             :         // Zoom
     151           0 :         Size aZoomSizePixel = mpWindow->LogicToPixel(aZoomRect).GetSize();
     152           0 :         sal_uLong nTol = DRGPIX + DRGPIX;
     153             : 
     154           0 :         if ( aZoomSizePixel.Width() < (long) nTol && aZoomSizePixel.Height() < (long) nTol )
     155             :         {
     156             :             // click at place: double zoom factor
     157           0 :             Point aPos = mpWindow->PixelToLogic(aPosPix);
     158           0 :             Size aSize = mpWindow->PixelToLogic(mpWindow->GetOutputSizePixel());
     159           0 :             aSize.Width() /= 2;
     160           0 :             aSize.Height() /= 2;
     161           0 :             aPos.X() -= aSize.Width() / 2;
     162           0 :             aPos.Y() -= aSize.Height() / 2;
     163           0 :             aZoomRect.SetPos(aPos);
     164           0 :             aZoomRect.SetSize(aSize);
     165             :         }
     166             : 
     167           0 :         mpViewShell->SetZoomRect(aZoomRect);
     168             :     }
     169             : 
     170             :     Rectangle aVisAreaWin = mpWindow->PixelToLogic(Rectangle(Point(0,0),
     171           0 :                                            mpWindow->GetOutputSizePixel()));
     172           0 :     mpViewShell->GetZoomList()->InsertZoomRect(aVisAreaWin);
     173             : 
     174           0 :     bStartDrag = sal_False;
     175           0 :     mpWindow->ReleaseMouse();
     176           0 :     mpViewShell->Cancel();
     177             : 
     178           0 :     return sal_True;
     179             : }
     180             : 
     181           0 : void FuZoom::Activate()
     182             : {
     183           0 :     aPtr = mpWindow->GetPointer();
     184             : 
     185           0 :     if (nSlotId == SID_ZOOM_PANNING)
     186             :     {
     187           0 :         mpWindow->SetPointer(Pointer(POINTER_HAND));
     188             :     }
     189             :     else
     190             :     {
     191           0 :         mpWindow->SetPointer(Pointer(POINTER_MAGNIFY));
     192             :     }
     193           0 : }
     194             : 
     195           0 : void FuZoom::Deactivate()
     196             : {
     197           0 :     mpWindow->SetPointer( aPtr );
     198           0 :     mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom );
     199           0 : }
     200          33 : } // end of namespace sd
     201             : 
     202             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10