LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - fupoor.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 15 115 13.0 %
Date: 2012-08-25 Functions: 3 24 12.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 13 142 9.2 %

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

Generated by: LCOV version 1.10