LCOV - code coverage report
Current view: top level - sc/source/ui/view - gridwin3.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 197 0.0 %
Date: 2014-04-14 Functions: 0 17 0.0 %
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 "scitems.hxx"
      22             : #include <editeng/eeitem.hxx>
      23             : 
      24             : #include <svx/svdoutl.hxx>
      25             : #include <svx/svdotext.hxx>
      26             : #include <svx/svdpagv.hxx>
      27             : #include <editeng/sizeitem.hxx>
      28             : #include <sfx2/bindings.hxx>
      29             : #include <svl/ptitem.hxx>
      30             : 
      31             : #include "tabvwsh.hxx"
      32             : #include "gridwin.hxx"
      33             : #include "dbfunc.hxx"
      34             : #include "viewdata.hxx"
      35             : #include "output.hxx"
      36             : #include "drawview.hxx"
      37             : #include "fupoor.hxx"
      38             : 
      39             : #include "drawutil.hxx"
      40             : #include "document.hxx"
      41             : #include "drwlayer.hxx"
      42             : #include <vcl/svapp.hxx>
      43             : #include "userdat.hxx"
      44             : #include "unitconv.hxx"
      45             : #include <svx/svdpage.hxx>
      46             : 
      47             : 
      48           0 : bool ScGridWindow::DrawMouseButtonDown(const MouseEvent& rMEvt)
      49             : {
      50           0 :     bool bRet = false;
      51           0 :     FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
      52           0 :     if (pDraw && !pViewData->IsRefMode())
      53             :     {
      54           0 :         pDraw->SetWindow( this );
      55           0 :         Point aLogicPos = PixelToLogic(rMEvt.GetPosPixel());
      56           0 :         if ( pDraw->IsDetectiveHit( aLogicPos ) )
      57             :         {
      58             :             //  auf Detektiv-Pfeilen gar nichts (Doppelklick wird bei ButtonUp ausgewertet)
      59           0 :             bRet = true;
      60             :         }
      61             :         else
      62             :         {
      63           0 :             bRet = pDraw->MouseButtonDown( rMEvt );
      64           0 :             if ( bRet )
      65           0 :                 UpdateStatusPosSize();
      66             :         }
      67             :     }
      68             : 
      69             :     //  bei rechter Taste Draw-Aktion abbrechen
      70             : 
      71           0 :     ScDrawView* pDrView = pViewData->GetScDrawView();
      72           0 :     if ( pDrView && !rMEvt.IsLeft() && !bRet )
      73             :     {
      74           0 :         pDrView->BrkAction();
      75           0 :         bRet = true;
      76             :     }
      77           0 :     return bRet;
      78             : }
      79             : 
      80           0 : bool ScGridWindow::DrawMouseButtonUp(const MouseEvent& rMEvt)
      81             : {
      82           0 :     ScViewFunc* pView = pViewData->GetView();
      83           0 :     bool bRet = false;
      84           0 :     FuPoor* pDraw = pView->GetDrawFuncPtr();
      85           0 :     if (pDraw && !pViewData->IsRefMode())
      86             :     {
      87           0 :         pDraw->SetWindow( this );
      88           0 :         bRet = pDraw->MouseButtonUp( rMEvt );
      89             : 
      90             :         // execute "format paint brush" for drawing objects
      91           0 :         SfxItemSet* pDrawBrush = pView->GetDrawBrushSet();
      92           0 :         if ( pDrawBrush )
      93             :         {
      94           0 :             ScDrawView* pDrView = pViewData->GetScDrawView();
      95           0 :             if ( pDrView )
      96             :             {
      97           0 :                 bool bReplaceAll = true;
      98           0 :                 pDrView->SetAttrToMarked(*pDrawBrush, bReplaceAll);
      99             :             }
     100             : 
     101           0 :             if ( !pView->IsPaintBrushLocked() )
     102           0 :                 pView->ResetBrushDocument();        // end paint brush mode if not locked
     103             :         }
     104             :     }
     105             : 
     106           0 :     return bRet;
     107             : }
     108             : 
     109           0 : bool ScGridWindow::DrawMouseMove(const MouseEvent& rMEvt)
     110             : {
     111           0 :     FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
     112           0 :     if (pDraw && !pViewData->IsRefMode())
     113             :     {
     114           0 :         pDraw->SetWindow( this );
     115           0 :         bool bRet = pDraw->MouseMove( rMEvt );
     116           0 :         if ( bRet )
     117           0 :             UpdateStatusPosSize();
     118           0 :         return bRet;
     119             :     }
     120             :     else
     121             :     {
     122           0 :         SetPointer( Pointer( POINTER_ARROW ) );
     123           0 :         return false;
     124             :     }
     125             : }
     126             : 
     127           0 : void ScGridWindow::DrawEndAction()
     128             : {
     129           0 :     ScDrawView* pDrView = pViewData->GetScDrawView();
     130           0 :     if ( pDrView && pDrView->IsAction() )
     131           0 :         pDrView->BrkAction();
     132             : 
     133           0 :     FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
     134           0 :     if (pDraw)
     135           0 :         pDraw->StopDragTimer();
     136             : 
     137             :     //  ReleaseMouse beim Aufruf
     138           0 : }
     139             : 
     140           0 : bool ScGridWindow::DrawCommand(const CommandEvent& rCEvt)
     141             : {
     142           0 :     ScDrawView* pDrView = pViewData->GetScDrawView();
     143           0 :     FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
     144           0 :     if (pDrView && pDraw && !pViewData->IsRefMode())
     145             :     {
     146           0 :         pDraw->SetWindow( this );
     147           0 :         sal_uInt8 nUsed = pDraw->Command( rCEvt );
     148           0 :         if( nUsed == SC_CMD_USED )
     149           0 :             nButtonDown = 0;                    // MouseButtonUp wird verschluckt...
     150           0 :         if( nUsed || pDrView->IsAction() )
     151           0 :             return true;
     152             :     }
     153             : 
     154           0 :     return false;
     155             : }
     156             : 
     157           0 : bool ScGridWindow::DrawKeyInput(const KeyEvent& rKEvt)
     158             : {
     159           0 :     ScDrawView* pDrView = pViewData->GetScDrawView();
     160           0 :     FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
     161           0 :     if (pDrView && pDraw && !pViewData->IsRefMode())
     162             :     {
     163           0 :         pDraw->SetWindow( this );
     164           0 :         bool bOldMarked = pDrView->AreObjectsMarked();
     165           0 :         if (pDraw->KeyInput( rKEvt ))
     166             :         {
     167           0 :             bool bLeaveDraw = false;
     168           0 :             bool bUsed = true;
     169           0 :             bool bNewMarked = pDrView->AreObjectsMarked();
     170           0 :             if ( !pViewData->GetView()->IsDrawSelMode() )
     171           0 :                 if ( !bNewMarked )
     172             :                 {
     173           0 :                     pViewData->GetViewShell()->SetDrawShell( false );
     174           0 :                     bLeaveDraw = true;
     175           0 :                     if ( !bOldMarked &&
     176           0 :                         rKEvt.GetKeyCode().GetCode() == KEY_DELETE )
     177           0 :                         bUsed = false;                  // nichts geloescht
     178           0 :                     if(bOldMarked)
     179           0 :                         GetFocus();
     180             :                 }
     181           0 :             if (!bLeaveDraw)
     182           0 :                 UpdateStatusPosSize();      // for moving/resizing etc. by keyboard
     183           0 :             return bUsed;
     184             :         }
     185             :     }
     186             : 
     187           0 :     return false;
     188             : }
     189             : 
     190           0 : void ScGridWindow::DrawRedraw( ScOutputData& rOutputData, ScUpdateMode eMode, sal_uLong nLayer )
     191             : {
     192             :     // #109985#
     193           0 :     const ScViewOptions& rOpts = pViewData->GetOptions();
     194             : 
     195             :     // use new flags at SdrPaintView for hiding objects
     196           0 :     const bool bDrawOle(VOBJ_MODE_SHOW == rOpts.GetObjMode(VOBJ_TYPE_OLE));
     197           0 :     const bool bDrawChart(VOBJ_MODE_SHOW == rOpts.GetObjMode(VOBJ_TYPE_CHART));
     198           0 :     const bool bDrawDraw(VOBJ_MODE_SHOW == rOpts.GetObjMode(VOBJ_TYPE_DRAW));
     199             : 
     200           0 :     if(bDrawOle || bDrawChart || bDrawDraw)
     201             :     {
     202           0 :         ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
     203             : 
     204           0 :         if(pDrView)
     205             :         {
     206           0 :             pDrView->setHideOle(!bDrawOle);
     207           0 :             pDrView->setHideChart(!bDrawChart);
     208           0 :             pDrView->setHideDraw(!bDrawDraw);
     209           0 :             pDrView->setHideFormControl(!bDrawDraw);
     210             :         }
     211             : 
     212           0 :         if(SC_UPDATE_CHANGED == eMode)
     213             :         {
     214           0 :             rOutputData.DrawingSingle((sal_uInt16)nLayer);
     215             :         }
     216             :         else
     217             :         {
     218           0 :             rOutputData.DrawSelectiveObjects((sal_uInt16)nLayer);
     219             :         }
     220             :     }
     221           0 : }
     222             : 
     223           0 : void ScGridWindow::DrawSdrGrid( const Rectangle& rDrawingRect, OutputDevice* pContentDev )
     224             : {
     225             :     //  Draw-Gitterlinien
     226             : 
     227           0 :     ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
     228           0 :     if ( pDrView && pDrView->IsGridVisible() )
     229             :     {
     230           0 :         SdrPageView* pPV = pDrView->GetSdrPageView();
     231             :         OSL_ENSURE(pPV, "keine PageView");
     232           0 :         if (pPV)
     233             :         {
     234           0 :             pContentDev->SetLineColor(COL_GRAY);
     235             : 
     236           0 :             pPV->DrawPageViewGrid( *pContentDev, rDrawingRect );
     237             :         }
     238             :     }
     239           0 : }
     240             : 
     241           0 : MapMode ScGridWindow::GetDrawMapMode( bool bForce )
     242             : {
     243           0 :     ScDocument* pDoc = pViewData->GetDocument();
     244           0 :     SCTAB nTab = pViewData->GetTabNo();
     245           0 :     sal_Bool bNegativePage = pDoc->IsNegativePage( nTab );
     246             : 
     247           0 :     MapMode aDrawMode = pViewData->GetLogicMode();
     248             : 
     249           0 :     ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
     250           0 :     if ( pDrView || bForce )
     251             :     {
     252           0 :         Fraction aScaleX;
     253           0 :         Fraction aScaleY;
     254           0 :         if (pDrView)
     255           0 :             pDrView->GetScale( aScaleX, aScaleY );
     256             :         else
     257             :         {
     258           0 :             SCCOL nEndCol = 0;
     259           0 :             SCROW nEndRow = 0;
     260           0 :             pDoc->GetTableArea( nTab, nEndCol, nEndRow );
     261           0 :             if (nEndCol<20) nEndCol = 20;
     262           0 :             if (nEndRow<20) nEndRow = 1000;
     263             :             ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, this,
     264           0 :                                     pViewData->GetZoomX(),pViewData->GetZoomY(),
     265             :                                     pViewData->GetPPTX(),pViewData->GetPPTY(),
     266           0 :                                     aScaleX,aScaleY );
     267             :         }
     268           0 :         aDrawMode.SetScaleX(aScaleX);
     269           0 :         aDrawMode.SetScaleY(aScaleY);
     270             :     }
     271           0 :     aDrawMode.SetOrigin(Point());
     272           0 :     Point aStartPos = pViewData->GetPixPos(eWhich);
     273           0 :     if ( bNegativePage )
     274             :     {
     275             :         //  RTL uses negative positions for drawing objects
     276           0 :         aStartPos.X() = -aStartPos.X() + GetOutputSizePixel().Width() - 1;
     277             :     }
     278           0 :     aDrawMode.SetOrigin( PixelToLogic( aStartPos, aDrawMode ) );
     279             : 
     280           0 :     return aDrawMode;
     281             : }
     282             : 
     283           0 : void ScGridWindow::DrawAfterScroll()
     284             : {
     285           0 :     Update();       // immer, damit das Verhalten mit/ohne DrawingLayer gleich ist
     286             : 
     287           0 :     ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
     288           0 :     if (pDrView)
     289             :     {
     290           0 :         OutlinerView* pOlView = pDrView->GetTextEditOutlinerView();
     291           0 :         if (pOlView && pOlView->GetWindow() == this)
     292           0 :             pOlView->ShowCursor(false);                 // ist beim Scrollen weggekommen
     293             :     }
     294           0 : }
     295             : 
     296           0 : void ScGridWindow::CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress)
     297             : {
     298           0 :     ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
     299           0 :     if (pDrView)
     300             :     {
     301           0 :         const ScViewOptions& rOpts = pViewData->GetOptions();
     302           0 :         if(rOpts.GetOption( VOPT_ANCHOR ))
     303             :         {
     304           0 :             sal_Bool bNegativePage = pViewData->GetDocument()->IsNegativePage( pViewData->GetTabNo() );
     305           0 :             Point aPos = pViewData->GetScrPos( rAddress.Col(), rAddress.Row(), eWhich, true );
     306           0 :             aPos = PixelToLogic(aPos);
     307           0 :             rHdl.AddHdl(new SdrHdl(aPos, bNegativePage ? HDL_ANCHOR_TR : HDL_ANCHOR));
     308             :         }
     309             :     }
     310           0 : }
     311             : 
     312           0 : SdrObject* ScGridWindow::GetEditObject()
     313             : {
     314           0 :     ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
     315           0 :     if (pDrView)
     316             :     {
     317           0 :         OutlinerView* pOlView = pDrView->GetTextEditOutlinerView();
     318           0 :         if (pOlView && pOlView->GetWindow() == this)
     319           0 :             return pDrView->GetTextEditObject();
     320             :     }
     321             : 
     322           0 :     return NULL;
     323             : }
     324             : 
     325           0 : void ScGridWindow::UpdateStatusPosSize()
     326             : {
     327           0 :     ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
     328           0 :     if (!pDrView)
     329           0 :         return;         // shouldn't be called in that case
     330             : 
     331           0 :     SdrPageView* pPV = pDrView->GetSdrPageView();
     332           0 :     if (!pPV)
     333           0 :         return;         // shouldn't be called in that case either
     334             : 
     335           0 :     SfxItemSet aSet(pViewData->GetViewShell()->GetPool(), SID_ATTR_POSITION, SID_ATTR_SIZE);
     336             : 
     337             :     //  Fill items for position and size:
     338             :     //  show action rectangle during action,
     339             :     //  position and size of selected object(s) if something is selected,
     340             :     //  mouse position otherwise
     341             : 
     342           0 :     sal_Bool bActionItem = false;
     343           0 :     if ( pDrView->IsAction() )              // action rectangle
     344             :     {
     345           0 :         Rectangle aRect;
     346           0 :         pDrView->TakeActionRect( aRect );
     347           0 :         if ( !aRect.IsEmpty() )
     348             :         {
     349             :             // mouse position will have been adjusted for offset
     350             :             // at current position and zoom, restore that adjustment here
     351             :             // so status shows correct value
     352           0 :             aRect -= pDrView->GetGridOffset();
     353           0 :             pPV->LogicToPagePos(aRect);
     354           0 :             aSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) );
     355             :             aSet.Put( SvxSizeItem( SID_ATTR_SIZE,
     356           0 :                     Size( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ) ) );
     357           0 :             bActionItem = sal_True;
     358             :         }
     359             :     }
     360           0 :     if ( !bActionItem )
     361             :     {
     362           0 :         if ( pDrView->AreObjectsMarked() )      // selected objects
     363             :         {
     364           0 :             Rectangle aRect = pDrView->GetAllMarkedRect();
     365             :             // mouse position will have been adjusted for offset
     366             :             // at current position and zoom, restore that adjustment here
     367             :             // so status shows correct value
     368           0 :             aRect -=  pDrView->GetGridOffset();
     369           0 :             pPV->LogicToPagePos(aRect);
     370           0 :             aSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) );
     371             :             aSet.Put( SvxSizeItem( SID_ATTR_SIZE,
     372           0 :                     Size( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ) ) );
     373             :         }
     374             :         else                                // mouse position
     375             :         {
     376           0 :             Point aPos = PixelToLogic(aCurMousePos);
     377           0 :             pPV->LogicToPagePos(aPos);
     378           0 :             aSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos ) );
     379           0 :             aSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) );
     380             :         }
     381             :     }
     382             : 
     383           0 :     pViewData->GetBindings().SetState(aSet);
     384             : }
     385             : 
     386           0 : bool ScGridWindow::DrawHasMarkedObj()
     387             : {
     388           0 :     ScDrawView* p = pViewData->GetScDrawView();
     389           0 :     return p ? p->AreObjectsMarked() : false;
     390             : }
     391             : 
     392           0 : void ScGridWindow::DrawMarkDropObj( SdrObject* pObj )
     393             : {
     394           0 :     ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
     395           0 :     if (pDrView)
     396           0 :         pDrView->MarkDropObj(pObj);
     397           0 : }
     398             : 
     399             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10