LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - fumark.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1 75 1.3 %
Date: 2014-04-11 Functions: 2 13 15.4 %
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 <sfx2/dispatch.hxx>
      22             : #include <sfx2/viewfrm.hxx>
      23             : 
      24             : #include "fumark.hxx"
      25             : #include "sc.hrc"
      26             : #include "tabvwsh.hxx"
      27             : #include "scmod.hxx"
      28             : #include "reffact.hxx"
      29             : #include "document.hxx"
      30             : #include "scresid.hxx"
      31             : #include "drawview.hxx"
      32             : #include "markdata.hxx"
      33             : 
      34             : /*************************************************************************
      35             : |*
      36             : |* Funktion zum Aufziehen eines Rechtecks
      37             : |*
      38             : \************************************************************************/
      39             : 
      40           0 : FuMarkRect::FuMarkRect(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
      41             :                SdrModel* pDoc, SfxRequest& rReq) :
      42             :     FuPoor(pViewSh, pWin, pViewP, pDoc, rReq),
      43             :     bVisible(false),
      44           0 :     bStartDrag(false)
      45             : {
      46           0 : }
      47             : 
      48             : /*************************************************************************
      49             : |*
      50             : |* Destruktor
      51             : |*
      52             : \************************************************************************/
      53             : 
      54           0 : FuMarkRect::~FuMarkRect()
      55             : {
      56           0 : }
      57             : 
      58             : /*************************************************************************
      59             : |*
      60             : |* MouseButtonDown-event
      61             : |*
      62             : \************************************************************************/
      63             : 
      64           0 : bool FuMarkRect::MouseButtonDown(const MouseEvent& rMEvt)
      65             : {
      66             :     // remember button state for creation of own MouseEvents
      67           0 :     SetMouseButtonCode(rMEvt.GetButtons());
      68             : 
      69           0 :     pWindow->CaptureMouse();
      70           0 :     pView->UnmarkAll();         // der Einheitlichkeit halber und wegen #50558#
      71           0 :     bStartDrag = true;
      72             : 
      73           0 :     aBeginPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
      74           0 :     aZoomRect = Rectangle( aBeginPos, Size() );
      75           0 :     return true;
      76             : }
      77             : 
      78             : /*************************************************************************
      79             : |*
      80             : |* MouseMove-event
      81             : |*
      82             : \************************************************************************/
      83             : 
      84           0 : bool FuMarkRect::MouseMove(const MouseEvent& rMEvt)
      85             : {
      86           0 :     if ( bStartDrag )
      87             :     {
      88           0 :         if ( bVisible )
      89           0 :             pViewShell->DrawMarkRect(aZoomRect);
      90           0 :         Point aPixPos= rMEvt.GetPosPixel();
      91           0 :         ForceScroll(aPixPos);
      92             : 
      93           0 :         Point aEndPos = pWindow->PixelToLogic(aPixPos);
      94           0 :         Rectangle aRect(aBeginPos, aEndPos);
      95           0 :         aZoomRect = aRect;
      96           0 :         aZoomRect.Justify();
      97           0 :         pViewShell->DrawMarkRect(aZoomRect);
      98           0 :         bVisible = true;
      99             :     }
     100             : 
     101           0 :     ForcePointer(&rMEvt);
     102             : 
     103           0 :     return bStartDrag;
     104             : }
     105             : 
     106             : /*************************************************************************
     107             : |*
     108             : |* MouseButtonUp-event
     109             : |*
     110             : \************************************************************************/
     111             : 
     112           0 : bool FuMarkRect::MouseButtonUp(const MouseEvent& rMEvt)
     113             : {
     114             :     // remember button state for creation of own MouseEvents
     115           0 :     SetMouseButtonCode(rMEvt.GetButtons());
     116             : 
     117           0 :     if ( bVisible )
     118             :     {
     119             :         // Hide ZoomRect
     120           0 :         pViewShell->DrawMarkRect(aZoomRect);
     121           0 :         bVisible = false;
     122             :     }
     123             : 
     124           0 :     Size aZoomSizePixel = pWindow->LogicToPixel(aZoomRect).GetSize();
     125             : 
     126           0 :     sal_uInt16 nMinMove = pView->GetMinMoveDistancePixel();
     127           0 :     if ( aZoomSizePixel.Width() < nMinMove || aZoomSizePixel.Height() < nMinMove )
     128             :     {
     129             :         // Klick auf der Stelle
     130             : 
     131           0 :         aZoomRect.SetSize(Size());      // dann ganz leer
     132             :     }
     133             : 
     134           0 :     bStartDrag = false;
     135           0 :     pWindow->ReleaseMouse();
     136             : 
     137           0 :     pViewShell->GetViewData()->GetDispatcher().
     138           0 :         Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
     139             : 
     140             :         //  Daten an der View merken
     141             : 
     142           0 :     pViewShell->SetChartArea( aSourceRange, aZoomRect );
     143             : 
     144             :         //  Chart-Dialog starten:
     145             : 
     146             : //  sal_uInt16 nId  = ScChartDlgWrapper::GetChildWindowId();
     147             : //  SfxChildWindow* pWnd = pViewShell->GetViewFrame()->GetChildWindow( nId );
     148             : //  SC_MOD()->SetRefDialog( nId, pWnd ? sal_False : sal_True );
     149             : 
     150           0 :     return true;
     151             : }
     152             : 
     153             : /*************************************************************************
     154             : |*
     155             : |* Command-event
     156             : |*
     157             : \************************************************************************/
     158             : 
     159           0 : sal_uInt8 FuMarkRect::Command(const CommandEvent& rCEvt)
     160             : {
     161           0 :     if ( COMMAND_STARTDRAG == rCEvt.GetCommand() )
     162             :     {
     163             :         //  nicht anfangen, auf der Tabelle rumzudraggen,
     164             :         //  aber Maus-Status nicht zuruecksetzen
     165           0 :         return SC_CMD_IGNORE;
     166             :     }
     167             :     else
     168           0 :         return FuPoor::Command(rCEvt);
     169             : }
     170             : 
     171             : /*************************************************************************
     172             : |*
     173             : |* Tastaturereignisse bearbeiten
     174             : |*
     175             : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
     176             : |* FALSE.
     177             : |*
     178             : \************************************************************************/
     179             : 
     180           0 : bool FuMarkRect::KeyInput(const KeyEvent& rKEvt)
     181             : {
     182           0 :     bool bReturn = false;
     183             : 
     184           0 :     switch ( rKEvt.GetKeyCode().GetCode() )
     185             :     {
     186             :         case KEY_ESCAPE:
     187             :             //  beenden
     188           0 :             pViewShell->GetViewData()->GetDispatcher().
     189           0 :                 Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
     190           0 :             bReturn = true;
     191           0 :             break;
     192             :     }
     193             : 
     194           0 :     if (!bReturn)
     195             :     {
     196           0 :         bReturn = FuPoor::KeyInput(rKEvt);
     197             :     }
     198             : 
     199           0 :     return bReturn;
     200             : }
     201             : 
     202             : /*************************************************************************
     203             : |*
     204             : |* Function aktivieren
     205             : |*
     206             : \************************************************************************/
     207             : 
     208           0 : void FuMarkRect::Activate()
     209             : {
     210           0 :     FuPoor::Activate();
     211             : 
     212             :         //  Markierung merken, bevor evtl. Tabelle umgeschaltet wird
     213             : 
     214           0 :     ScViewData* pViewData = pViewShell->GetViewData();
     215           0 :     ScMarkData& rMark = pViewData->GetMarkData();
     216             : 
     217           0 :     if ( !rMark.IsMultiMarked() && !rMark.IsMarked() )
     218           0 :         pViewShell->MarkDataArea( true );
     219             : 
     220           0 :     pViewData->GetMultiArea( aSourceRange );        // Mehrfachselektion erlaubt
     221             : 
     222             : //  pViewShell->Unmark();
     223             : 
     224           0 :     ForcePointer(NULL);
     225           0 : }
     226             : 
     227             : /*************************************************************************
     228             : |*
     229             : |* Function deaktivieren
     230             : |*
     231             : \************************************************************************/
     232             : 
     233           0 : void FuMarkRect::Deactivate()
     234             : {
     235           0 :     FuPoor::Deactivate();
     236             : 
     237           0 :     if (bVisible)
     238             :     {
     239             :         // Hide ZoomRect
     240           0 :         pViewShell->DrawMarkRect(aZoomRect);
     241           0 :         bVisible = false;
     242           0 :         bStartDrag = false;
     243             :     }
     244           0 : }
     245             : 
     246             : /*************************************************************************
     247             : |*
     248             : |* Maus-Pointer umschalten
     249             : |*
     250             : \************************************************************************/
     251             : 
     252           0 : void FuMarkRect::ForcePointer(const MouseEvent* /* pMEvt */)
     253             : {
     254           0 :     pViewShell->SetActivePointer( Pointer( POINTER_CHART ) );
     255         102 : }
     256             : 
     257             : 
     258             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10