LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - fupoor.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 16 114 14.0 %
Date: 2014-04-11 Functions: 5 26 19.2 %
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 <editeng/outliner.hxx>
      22             : #include <svx/svditer.hxx>
      23             : #include <svx/svdobj.hxx>
      24             : #include <svx/svdpagv.hxx>
      25             : 
      26             : #include "fupoor.hxx"
      27             : #include "tabvwsh.hxx"
      28             : #include "drawview.hxx"
      29             : #include "detfunc.hxx"
      30             : #include "document.hxx"
      31             : #include <vcl/svapp.hxx>
      32             : #include <svx/sdrhittesthelper.hxx>
      33             : 
      34         222 : FuPoor::FuPoor(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
      35             :                SdrModel* pDoc, SfxRequest& rReq) :
      36             :     pView(pViewP),
      37             :     pViewShell(pViewSh),
      38             :     pWindow(pWin),
      39             :     pDrDoc(pDoc),
      40             :     aSfxRequest(rReq),
      41             :     pDialog(NULL),
      42             :     bIsInDragMode(false),
      43             :     // remember MouseButton state
      44         222 :     mnCode(0)
      45             : {
      46         222 :     aScrollTimer.SetTimeoutHdl( LINK(this, FuPoor, ScrollHdl) );
      47         222 :     aScrollTimer.SetTimeout(SELENG_AUTOREPEAT_INTERVAL);
      48             : 
      49         222 :     aDragTimer.SetTimeoutHdl( LINK(this, FuPoor, DragTimerHdl) );
      50         222 :     aDragTimer.SetTimeout(SELENG_DRAGDROP_TIMEOUT);
      51         222 : }
      52             : 
      53         436 : FuPoor::~FuPoor()
      54             : {
      55         218 :     aDragTimer.Stop();
      56         218 :     aScrollTimer.Stop();
      57             : 
      58         218 :     delete pDialog;
      59         218 : }
      60             : 
      61           0 : void FuPoor::Activate()
      62             : {
      63           0 :     if (pDialog)
      64             :     {
      65           0 :         pDialog->Show();
      66             :     }
      67           0 : }
      68             : 
      69           0 : void FuPoor::Deactivate()
      70             : {
      71           0 :     aDragTimer.Stop();
      72           0 :     aScrollTimer.Stop();
      73             : 
      74           0 :     if (pDialog)
      75             :     {
      76           0 :         pDialog->Hide();
      77             :     }
      78           0 : }
      79             : 
      80             : /*************************************************************************
      81             : |*
      82             : |* Scrollen bei Erreichen des Fensterrandes; wird von
      83             : |* MouseMove aufgerufen
      84             : |*
      85             : \************************************************************************/
      86             : 
      87           0 : void FuPoor::ForceScroll(const Point& aPixPos)
      88             : {
      89           0 :     aScrollTimer.Stop();
      90             : 
      91           0 :     Size aSize = pWindow->GetSizePixel();
      92           0 :     SCsCOL dx = 0;
      93           0 :     SCsROW dy = 0;
      94             : 
      95           0 :     if ( aPixPos.X() <= 0              ) dx = -1;
      96           0 :     if ( aPixPos.X() >= aSize.Width()  ) dx =  1;
      97           0 :     if ( aPixPos.Y() <= 0              ) dy = -1;
      98           0 :     if ( aPixPos.Y() >= aSize.Height() ) dy =  1;
      99             : 
     100           0 :     ScViewData* pViewData = pViewShell->GetViewData();
     101           0 :     if ( pViewData->GetDocument()->IsNegativePage( pViewData->GetTabNo() ) )
     102           0 :         dx = -dx;
     103             : 
     104           0 :     ScSplitPos eWhich = pViewData->GetActivePart();
     105           0 :     if ( dx > 0 && pViewData->GetHSplitMode() == SC_SPLIT_FIX && WhichH(eWhich) == SC_SPLIT_LEFT )
     106             :     {
     107             :         pViewShell->ActivatePart( ( eWhich == SC_SPLIT_TOPLEFT ) ?
     108           0 :                         SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT );
     109           0 :         dx = 0;
     110             :     }
     111           0 :     if ( dy > 0 && pViewData->GetVSplitMode() == SC_SPLIT_FIX && WhichV(eWhich) == SC_SPLIT_TOP )
     112             :     {
     113             :         pViewShell->ActivatePart( ( eWhich == SC_SPLIT_TOPLEFT ) ?
     114           0 :                         SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT );
     115           0 :         dy = 0;
     116             :     }
     117             : 
     118           0 :     if ( dx != 0 || dy != 0 )
     119             :     {
     120           0 :         pViewShell->ScrollLines(2*dx, 4*dy);
     121           0 :         aScrollTimer.Start();
     122             :     }
     123           0 : }
     124             : 
     125             : /*************************************************************************
     126             : |*
     127             : |* Timer-Handler fuer Fensterscrolling
     128             : |*
     129             : \************************************************************************/
     130             : 
     131           0 : IMPL_LINK_NOARG_INLINE_START(FuPoor, ScrollHdl)
     132             : {
     133           0 :     Point aPosPixel = pWindow->GetPointerPosPixel();
     134             : 
     135             :     // use remembered MouseButton state to create correct
     136             :     // MouseEvents for this artifical MouseMove.
     137           0 :     MouseMove(MouseEvent(aPosPixel, 1, 0, GetMouseButtonCode()));
     138             : 
     139           0 :     return 0;
     140             : }
     141           0 : IMPL_LINK_INLINE_END( FuPoor, ScrollHdl, Timer *, pTimer )
     142             : 
     143             : // moved from inline to *.cxx
     144           0 : bool FuPoor::MouseButtonUp(const MouseEvent& rMEvt)
     145             : {
     146             :     // remember button state for creation of own MouseEvents
     147           0 :     SetMouseButtonCode(rMEvt.GetButtons());
     148             : 
     149           0 :     return false;
     150             : }
     151             : 
     152             : // moved from inline to *.cxx
     153           0 : bool FuPoor::MouseButtonDown(const MouseEvent& rMEvt)
     154             : {
     155             :     // remember button state for creation of own MouseEvents
     156           0 :     SetMouseButtonCode(rMEvt.GetButtons());
     157             : 
     158           0 :     return false;
     159             : }
     160             : 
     161             : /*************************************************************************
     162             : |*
     163             : |* String in Applikations-Statuszeile ausgeben
     164             : |*
     165             : \************************************************************************/
     166             : 
     167             : //  WriteStatus gibt's nicht mehr
     168             : 
     169             : /*************************************************************************
     170             : |*
     171             : |* Tastaturereignisse bearbeiten
     172             : |*
     173             : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
     174             : |* FALSE.
     175             : |*
     176             : \************************************************************************/
     177             : 
     178           0 : bool FuPoor::KeyInput(const KeyEvent& /* rKEvt */)
     179             : {
     180           0 :     return false;
     181             : }
     182             : 
     183           0 : sal_uInt8 FuPoor::Command(const CommandEvent& rCEvt)
     184             : {
     185           0 :     if ( COMMAND_STARTDRAG == rCEvt.GetCommand() )
     186             :     {
     187             :         //!!! sollte Joe eigentlich machen:
     188             :         // nur, wenn im Outliner was selektiert ist, darf
     189             :         // Command sal_True zurueckliefern:
     190             : 
     191           0 :         OutlinerView* pOutView = pView->GetTextEditOutlinerView();
     192             : 
     193           0 :         if ( pOutView )
     194           0 :             return pOutView->HasSelection() ? (pView->Command(rCEvt,pWindow) ? 1 : 0) : SC_CMD_NONE;
     195             :         else
     196           0 :             return pView->Command(rCEvt,pWindow);
     197             :     }
     198             :     else
     199           0 :         return pView->Command(rCEvt,pWindow);
     200             : }
     201             : 
     202           0 : void FuPoor::DoCut()
     203             : {
     204           0 :     if (pView)
     205             :     {
     206             : //!     pView->DoCut(pWindow);
     207             :     }
     208           0 : }
     209             : 
     210             : /*************************************************************************
     211             : |*
     212             : |* Copy object to clipboard
     213             : |*
     214             : \************************************************************************/
     215             : 
     216           0 : void FuPoor::DoCopy()
     217             : {
     218           0 :     if (pView)
     219             :     {
     220             : //!     pView->DoCopy(pWindow);
     221             :     }
     222           0 : }
     223             : 
     224           0 : void FuPoor::DoPaste()
     225             : {
     226           0 :     if (pView)
     227             :     {
     228             : //!     pView->DoPaste(pWindow);
     229             :     }
     230           0 : }
     231             : 
     232             : /*************************************************************************
     233             : |*
     234             : |* Timer-Handler fuer Drag&Drop
     235             : |*
     236             : \************************************************************************/
     237             : 
     238           0 : IMPL_LINK_NOARG(FuPoor, DragTimerHdl)
     239             : {
     240             :     //  ExecuteDrag (und das damit verbundene Reschedule) direkt aus dem Timer
     241             :     //  aufzurufen, bringt die VCL-Timer-Verwaltung durcheinander, wenn dabei
     242             :     //  (z.B. im Drop) wieder ein Timer gestartet wird (z.B. ComeBack-Timer der
     243             :     //  DrawView fuer Solid Handles / ModelHasChanged) - der neue Timer laeuft
     244             :     //  dann um die Dauer des Drag&Drop zu spaet ab.
     245             :     //  Darum Drag&Drop aus eigenem Event:
     246             : 
     247           0 :     Application::PostUserEvent( LINK( this, FuPoor, DragHdl ) );
     248           0 :     return 0;
     249             : }
     250             : 
     251           0 : IMPL_LINK_NOARG(FuPoor, DragHdl)
     252             : {
     253           0 :     SdrHdl* pHdl = pView->PickHandle(aMDPos);
     254             : 
     255           0 :     if ( pHdl==NULL && pView->IsMarkedHit(aMDPos) )
     256             :     {
     257           0 :         pWindow->ReleaseMouse();
     258           0 :         bIsInDragMode = true;
     259             : 
     260             : //      pView->BeginDrag(pWindow, aMDPos);
     261           0 :         pViewShell->GetScDrawView()->BeginDrag(pWindow, aMDPos);
     262             :     }
     263           0 :     return 0;
     264             : }
     265             : 
     266             : //  Detektiv-Linie
     267             : 
     268           0 : bool FuPoor::IsDetectiveHit( const Point& rLogicPos )
     269             : {
     270           0 :     SdrPageView* pPV = pView->GetSdrPageView();
     271           0 :     if (!pPV)
     272           0 :         return false;
     273             : 
     274           0 :     bool bFound = false;
     275           0 :     SdrObjListIter aIter( *pPV->GetObjList(), IM_FLAT );
     276           0 :     SdrObject* pObject = aIter.Next();
     277           0 :     while (pObject && !bFound)
     278             :     {
     279           0 :         if (ScDetectiveFunc::IsNonAlienArrow( pObject ))
     280             :         {
     281             :             sal_uInt16 nHitLog = (sal_uInt16) pWindow->PixelToLogic(
     282           0 :                                 Size(pView->GetHitTolerancePixel(),0)).Width();
     283           0 :             if(SdrObjectPrimitiveHit(*pObject, rLogicPos, nHitLog, *pPV, 0, false))
     284             :             {
     285           0 :                 bFound = true;
     286             :             }
     287             :         }
     288             : 
     289           0 :         pObject = aIter.Next();
     290             :     }
     291           0 :     return bFound;
     292             : }
     293             : 
     294         450 : void FuPoor::StopDragTimer()
     295             : {
     296         450 :     if (aDragTimer.IsActive() )
     297           0 :         aDragTimer.Stop();
     298         450 : }
     299             : 
     300             : /*************************************************************************
     301             : |*
     302             : |* Create default drawing objects via keyboard
     303             : |*
     304             : \************************************************************************/
     305             : 
     306           0 : SdrObject* FuPoor::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& /* rRectangle */)
     307             : {
     308             :     // empty base implementation
     309           0 :     return 0L;
     310             : }
     311             : 
     312           0 : void FuPoor::ImpForceQuadratic(Rectangle& rRect)
     313             : {
     314           0 :     if(rRect.GetWidth() > rRect.GetHeight())
     315             :     {
     316             :         rRect = Rectangle(
     317           0 :             Point(rRect.Left() + ((rRect.GetWidth() - rRect.GetHeight()) / 2), rRect.Top()),
     318           0 :             Size(rRect.GetHeight(), rRect.GetHeight()));
     319             :     }
     320             :     else
     321             :     {
     322             :         rRect = Rectangle(
     323           0 :             Point(rRect.Left(), rRect.Top() + ((rRect.GetHeight() - rRect.GetWidth()) / 2)),
     324           0 :             Size(rRect.GetWidth(), rRect.GetWidth()));
     325             :     }
     326           0 : }
     327             : 
     328             : // #i33136#
     329           0 : bool FuPoor::doConstructOrthogonal() const
     330             : {
     331           0 :     return false;
     332         102 : }
     333             : 
     334             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10