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

Generated by: LCOV version 1.10