LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/drawfunc - fupoor.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 16 115 13.9 %
Date: 2013-07-09 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         203 : 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         203 :     mnCode(0)
      45             : {
      46         203 :     aScrollTimer.SetTimeoutHdl( LINK(this, FuPoor, ScrollHdl) );
      47         203 :     aScrollTimer.SetTimeout(SELENG_AUTOREPEAT_INTERVAL);
      48             : 
      49         203 :     aDragTimer.SetTimeoutHdl( LINK(this, FuPoor, DragTimerHdl) );
      50         203 :     aDragTimer.SetTimeout(SELENG_DRAGDROP_TIMEOUT);
      51         203 : }
      52             : 
      53         402 : FuPoor::~FuPoor()
      54             : {
      55         201 :     aDragTimer.Stop();
      56         201 :     aScrollTimer.Stop();
      57             : 
      58         201 :     delete pDialog;
      59         201 : }
      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 : sal_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 : sal_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 : sal_Bool FuPoor::KeyInput(const KeyEvent& /* rKEvt */)
     179             : {
     180           0 :     sal_Bool bReturn = false;
     181             : 
     182           0 :     return(bReturn);
     183             : }
     184             : 
     185           0 : sal_uInt8 FuPoor::Command(const CommandEvent& rCEvt)
     186             : {
     187           0 :     if ( COMMAND_STARTDRAG == rCEvt.GetCommand() )
     188             :     {
     189             :         //!!! sollte Joe eigentlich machen:
     190             :         // nur, wenn im Outliner was selektiert ist, darf
     191             :         // Command sal_True zurueckliefern:
     192             : 
     193           0 :         OutlinerView* pOutView = pView->GetTextEditOutlinerView();
     194             : 
     195           0 :         if ( pOutView )
     196           0 :             return pOutView->HasSelection() ? pView->Command(rCEvt,pWindow) : SC_CMD_NONE;
     197             :         else
     198           0 :             return pView->Command(rCEvt,pWindow);
     199             :     }
     200             :     else
     201           0 :         return pView->Command(rCEvt,pWindow);
     202             : }
     203             : 
     204           0 : void FuPoor::DoCut()
     205             : {
     206           0 :     if (pView)
     207             :     {
     208             : //!     pView->DoCut(pWindow);
     209             :     }
     210           0 : }
     211             : 
     212             : /*************************************************************************
     213             : |*
     214             : |* Copy object to clipboard
     215             : |*
     216             : \************************************************************************/
     217             : 
     218           0 : void FuPoor::DoCopy()
     219             : {
     220           0 :     if (pView)
     221             :     {
     222             : //!     pView->DoCopy(pWindow);
     223             :     }
     224           0 : }
     225             : 
     226           0 : void FuPoor::DoPaste()
     227             : {
     228           0 :     if (pView)
     229             :     {
     230             : //!     pView->DoPaste(pWindow);
     231             :     }
     232           0 : }
     233             : 
     234             : /*************************************************************************
     235             : |*
     236             : |* Timer-Handler fuer Drag&Drop
     237             : |*
     238             : \************************************************************************/
     239             : 
     240           0 : IMPL_LINK_NOARG(FuPoor, DragTimerHdl)
     241             : {
     242             :     //  ExecuteDrag (und das damit verbundene Reschedule) direkt aus dem Timer
     243             :     //  aufzurufen, bringt die VCL-Timer-Verwaltung durcheinander, wenn dabei
     244             :     //  (z.B. im Drop) wieder ein Timer gestartet wird (z.B. ComeBack-Timer der
     245             :     //  DrawView fuer Solid Handles / ModelHasChanged) - der neue Timer laeuft
     246             :     //  dann um die Dauer des Drag&Drop zu spaet ab.
     247             :     //  Darum Drag&Drop aus eigenem Event:
     248             : 
     249           0 :     Application::PostUserEvent( LINK( this, FuPoor, DragHdl ) );
     250           0 :     return 0;
     251             : }
     252             : 
     253           0 : IMPL_LINK_NOARG(FuPoor, DragHdl)
     254             : {
     255           0 :     SdrHdl* pHdl = pView->PickHandle(aMDPos);
     256             : 
     257           0 :     if ( pHdl==NULL && pView->IsMarkedHit(aMDPos) )
     258             :     {
     259           0 :         pWindow->ReleaseMouse();
     260           0 :         bIsInDragMode = sal_True;
     261             : 
     262             : //      pView->BeginDrag(pWindow, aMDPos);
     263           0 :         pViewShell->GetScDrawView()->BeginDrag(pWindow, aMDPos);
     264             :     }
     265           0 :     return 0;
     266             : }
     267             : 
     268             : //  Detektiv-Linie
     269             : 
     270           0 : sal_Bool FuPoor::IsDetectiveHit( const Point& rLogicPos )
     271             : {
     272           0 :     SdrPageView* pPV = pView->GetSdrPageView();
     273           0 :     if (!pPV)
     274           0 :         return false;
     275             : 
     276           0 :     sal_Bool bFound = false;
     277           0 :     SdrObjListIter aIter( *pPV->GetObjList(), IM_FLAT );
     278           0 :     SdrObject* pObject = aIter.Next();
     279           0 :     while (pObject && !bFound)
     280             :     {
     281           0 :         if (ScDetectiveFunc::IsNonAlienArrow( pObject ))
     282             :         {
     283             :             sal_uInt16 nHitLog = (sal_uInt16) pWindow->PixelToLogic(
     284           0 :                                 Size(pView->GetHitTolerancePixel(),0)).Width();
     285           0 :             if(SdrObjectPrimitiveHit(*pObject, rLogicPos, nHitLog, *pPV, 0, false))
     286             :             {
     287           0 :                 bFound = sal_True;
     288             :             }
     289             :         }
     290             : 
     291           0 :         pObject = aIter.Next();
     292             :     }
     293           0 :     return bFound;
     294             : }
     295             : 
     296         412 : void FuPoor::StopDragTimer()
     297             : {
     298         412 :     if (aDragTimer.IsActive() )
     299           0 :         aDragTimer.Stop();
     300         412 : }
     301             : 
     302             : /*************************************************************************
     303             : |*
     304             : |* Create default drawing objects via keyboard
     305             : |*
     306             : \************************************************************************/
     307             : 
     308           0 : SdrObject* FuPoor::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& /* rRectangle */)
     309             : {
     310             :     // empty base implementation
     311           0 :     return 0L;
     312             : }
     313             : 
     314           0 : void FuPoor::ImpForceQuadratic(Rectangle& rRect)
     315             : {
     316           0 :     if(rRect.GetWidth() > rRect.GetHeight())
     317             :     {
     318             :         rRect = Rectangle(
     319           0 :             Point(rRect.Left() + ((rRect.GetWidth() - rRect.GetHeight()) / 2), rRect.Top()),
     320           0 :             Size(rRect.GetHeight(), rRect.GetHeight()));
     321             :     }
     322             :     else
     323             :     {
     324             :         rRect = Rectangle(
     325           0 :             Point(rRect.Left(), rRect.Top() + ((rRect.GetHeight() - rRect.GetWidth()) / 2)),
     326           0 :             Size(rRect.GetWidth(), rRect.GetWidth()));
     327             :     }
     328           0 : }
     329             : 
     330             : // #i33136#
     331           0 : bool FuPoor::doConstructOrthogonal() const
     332             : {
     333           0 :     return false;
     334          93 : }
     335             : 
     336             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10