LCOV - code coverage report
Current view: top level - sd/source/ui/func - fuzoom.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 78 0.0 %
Date: 2012-08-25 Functions: 0 14 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 90 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "fuzoom.hxx"
      30                 :            : 
      31                 :            : #include <svx/svxids.hrc>
      32                 :            : #include <sfx2/bindings.hxx>
      33                 :            : #include <sfx2/viewfrm.hxx>
      34                 :            : #include "app.hrc"
      35                 :            : #include <svx/svdpagv.hxx>
      36                 :            : 
      37                 :            : #include "FrameView.hxx"
      38                 :            : #include "ViewShell.hxx"
      39                 :            : #include "View.hxx"
      40                 :            : #include "Window.hxx"
      41                 :            : #include "drawdoc.hxx"
      42                 :            : #include "zoomlist.hxx"
      43                 :            : 
      44                 :            : namespace sd {
      45                 :            : 
      46                 :            : sal_uInt16 SidArrayZoom[] = {
      47                 :            :                     SID_ATTR_ZOOM,
      48                 :            :                     SID_ZOOM_OUT,
      49                 :            :                     SID_ZOOM_IN,
      50                 :            :                     0 };
      51                 :            : 
      52 [ #  # ][ #  # ]:          0 : TYPEINIT1( FuZoom, FuPoor );
      53                 :            : 
      54                 :            : /*************************************************************************
      55                 :            : |*
      56                 :            : |* Konstruktor
      57                 :            : |*
      58                 :            : \************************************************************************/
      59                 :            : 
      60                 :          0 : FuZoom::FuZoom(
      61                 :            :     ViewShell* pViewSh,
      62                 :            :     ::sd::Window* pWin,
      63                 :            :     ::sd::View* pView,
      64                 :            :     SdDrawDocument* pDoc,
      65                 :            :     SfxRequest& rReq)
      66                 :            :     : FuPoor(pViewSh, pWin, pView, pDoc, rReq),
      67                 :            :       bVisible(sal_False),
      68         [ #  # ]:          0 :       bStartDrag(sal_False)
      69                 :            : {
      70                 :          0 : }
      71                 :            : 
      72                 :            : /*************************************************************************
      73                 :            : |*
      74                 :            : |* Destruktor
      75                 :            : |*
      76                 :            : \************************************************************************/
      77                 :            : 
      78                 :          0 : FuZoom::~FuZoom()
      79                 :            : {
      80         [ #  # ]:          0 :     if (bVisible)
      81                 :            :     {
      82                 :            :         // Hide ZoomRect
      83         [ #  # ]:          0 :         mpViewShell->DrawMarkRect(aZoomRect);
      84                 :            : 
      85                 :          0 :         bVisible = sal_False;
      86                 :          0 :         bStartDrag = sal_False;
      87                 :            :     }
      88         [ #  # ]:          0 : }
      89                 :            : 
      90                 :          0 : FunctionReference FuZoom::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      91                 :            : {
      92 [ #  # ][ #  # ]:          0 :     FunctionReference xFunc( new FuZoom( pViewSh, pWin, pView, pDoc, rReq ) );
      93                 :          0 :     return xFunc;
      94                 :            : }
      95                 :            : 
      96                 :            : /*************************************************************************
      97                 :            : |*
      98                 :            : |* MouseButtonDown-event
      99                 :            : |*
     100                 :            : \************************************************************************/
     101                 :            : 
     102                 :          0 : sal_Bool FuZoom::MouseButtonDown(const MouseEvent& rMEvt)
     103                 :            : {
     104                 :            :     // remember button state for creation of own MouseEvents
     105                 :          0 :     SetMouseButtonCode(rMEvt.GetButtons());
     106                 :            : 
     107                 :          0 :     mpWindow->CaptureMouse();
     108                 :          0 :     bStartDrag = sal_True;
     109                 :            : 
     110                 :          0 :     aBeginPosPix = rMEvt.GetPosPixel();
     111                 :          0 :     aBeginPos = mpWindow->PixelToLogic(aBeginPosPix);
     112                 :            : 
     113                 :          0 :     return sal_True;
     114                 :            : }
     115                 :            : 
     116                 :            : /*************************************************************************
     117                 :            : |*
     118                 :            : |* MouseMove-event
     119                 :            : |*
     120                 :            : \************************************************************************/
     121                 :            : 
     122                 :          0 : sal_Bool FuZoom::MouseMove(const MouseEvent& rMEvt)
     123                 :            : {
     124         [ #  # ]:          0 :     if (bStartDrag)
     125                 :            :     {
     126         [ #  # ]:          0 :         if (bVisible)
     127                 :            :         {
     128         [ #  # ]:          0 :             mpViewShell->DrawMarkRect(aZoomRect);
     129                 :            :         }
     130                 :            : 
     131                 :          0 :         Point aPosPix = rMEvt.GetPosPixel();
     132         [ #  # ]:          0 :         ForceScroll(aPosPix);
     133                 :            : 
     134         [ #  # ]:          0 :         aEndPos = mpWindow->PixelToLogic(aPosPix);
     135         [ #  # ]:          0 :         aBeginPos = mpWindow->PixelToLogic(aBeginPosPix);
     136                 :            : 
     137         [ #  # ]:          0 :         if (nSlotId == SID_ZOOM_PANNING)
     138                 :            :         {
     139                 :            :             // Panning
     140                 :            : 
     141                 :          0 :             Point aScroll = aBeginPos - aEndPos;
     142                 :            : 
     143 [ #  # ][ #  # ]:          0 :             if (aScroll.X() != 0 || aScroll.Y() != 0)
                 [ #  # ]
     144                 :            :             {
     145         [ #  # ]:          0 :                 Size aWorkSize = mpView->GetWorkArea().GetSize();
     146         [ #  # ]:          0 :                 Size aPageSize = mpView->GetSdrPageView()->GetPage()->GetSize();
     147                 :          0 :                 aScroll.X() /= aWorkSize.Width()  / aPageSize.Width();
     148                 :          0 :                 aScroll.Y() /= aWorkSize.Height() / aPageSize.Height();
     149         [ #  # ]:          0 :                 mpViewShell->Scroll(aScroll.X(), aScroll.Y());
     150                 :          0 :                 aBeginPosPix = aPosPix;
     151                 :            :             }
     152                 :            :         }
     153                 :            :         else
     154                 :            :         {
     155         [ #  # ]:          0 :             Rectangle aRect(aBeginPos, aEndPos);
     156                 :          0 :             aZoomRect = aRect;
     157         [ #  # ]:          0 :             aZoomRect.Justify();
     158         [ #  # ]:          0 :             mpViewShell->DrawMarkRect(aZoomRect);
     159                 :            :         }
     160                 :            : 
     161                 :          0 :         bVisible = sal_True;
     162                 :            :     }
     163                 :            : 
     164                 :          0 :     return bStartDrag;
     165                 :            : }
     166                 :            : 
     167                 :            : /*************************************************************************
     168                 :            : |*
     169                 :            : |* MouseButtonUp-event
     170                 :            : |*
     171                 :            : \************************************************************************/
     172                 :            : 
     173                 :          0 : sal_Bool FuZoom::MouseButtonUp(const MouseEvent& rMEvt)
     174                 :            : {
     175                 :            :     // remember button state for creation of own MouseEvents
     176                 :          0 :     SetMouseButtonCode(rMEvt.GetButtons());
     177                 :            : 
     178         [ #  # ]:          0 :     if (bVisible)
     179                 :            :     {
     180                 :            :         // Hide ZoomRect
     181         [ #  # ]:          0 :         mpViewShell->DrawMarkRect(aZoomRect);
     182                 :          0 :         bVisible = sal_False;
     183                 :            :     }
     184                 :            : 
     185                 :          0 :     Point aPosPix = rMEvt.GetPosPixel();
     186                 :            : 
     187         [ #  # ]:          0 :     if(SID_ZOOM_PANNING != nSlotId)
     188                 :            :     {
     189                 :            :         // Zoom
     190 [ #  # ][ #  # ]:          0 :         Size aZoomSizePixel = mpWindow->LogicToPixel(aZoomRect).GetSize();
     191                 :          0 :         sal_uLong nTol = DRGPIX + DRGPIX;
     192                 :            : 
     193 [ #  # ][ #  # ]:          0 :         if ( aZoomSizePixel.Width() < (long) nTol && aZoomSizePixel.Height() < (long) nTol )
                 [ #  # ]
     194                 :            :         {
     195                 :            :             // Klick auf der Stelle: Zoomfaktor verdoppeln
     196         [ #  # ]:          0 :             Point aPos = mpWindow->PixelToLogic(aPosPix);
     197         [ #  # ]:          0 :             Size aSize = mpWindow->PixelToLogic(mpWindow->GetOutputSizePixel());
     198                 :          0 :             aSize.Width() /= 2;
     199                 :          0 :             aSize.Height() /= 2;
     200                 :          0 :             aPos.X() -= aSize.Width() / 2;
     201                 :          0 :             aPos.Y() -= aSize.Height() / 2;
     202                 :          0 :             aZoomRect.SetPos(aPos);
     203         [ #  # ]:          0 :             aZoomRect.SetSize(aSize);
     204                 :            :         }
     205                 :            : 
     206         [ #  # ]:          0 :         mpViewShell->SetZoomRect(aZoomRect);
     207                 :            :     }
     208                 :            : 
     209                 :            :     Rectangle aVisAreaWin = mpWindow->PixelToLogic(Rectangle(Point(0,0),
     210 [ #  # ][ #  # ]:          0 :                                            mpWindow->GetOutputSizePixel()));
     211 [ #  # ][ #  # ]:          0 :     mpViewShell->GetZoomList()->InsertZoomRect(aVisAreaWin);
     212                 :            : 
     213                 :          0 :     bStartDrag = sal_False;
     214         [ #  # ]:          0 :     mpWindow->ReleaseMouse();
     215         [ #  # ]:          0 :     mpViewShell->Cancel();
     216                 :            : 
     217                 :          0 :     return sal_True;
     218                 :            : }
     219                 :            : 
     220                 :            : /*************************************************************************
     221                 :            : |*
     222                 :            : |* Function aktivieren
     223                 :            : |*
     224                 :            : \************************************************************************/
     225                 :            : 
     226                 :          0 : void FuZoom::Activate()
     227                 :            : {
     228                 :          0 :     aPtr = mpWindow->GetPointer();
     229                 :            : 
     230         [ #  # ]:          0 :     if (nSlotId == SID_ZOOM_PANNING)
     231                 :            :     {
     232         [ #  # ]:          0 :         mpWindow->SetPointer(Pointer(POINTER_HAND));
     233                 :            :     }
     234                 :            :     else
     235                 :            :     {
     236         [ #  # ]:          0 :         mpWindow->SetPointer(Pointer(POINTER_MAGNIFY));
     237                 :            :     }
     238                 :          0 : }
     239                 :            : 
     240                 :            : /*************************************************************************
     241                 :            : |*
     242                 :            : |* Function deaktivieren
     243                 :            : |*
     244                 :            : \************************************************************************/
     245                 :            : 
     246                 :          0 : void FuZoom::Deactivate()
     247                 :            : {
     248                 :          0 :     mpWindow->SetPointer( aPtr );
     249                 :          0 :     mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom );
     250                 :          0 : }
     251                 :            : } // end of namespace sd
     252                 :            : 
     253                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10