LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/drawfunc - fusel2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 71 1.4 %
Date: 2013-07-09 Functions: 2 7 28.6 %
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             : #include <svx/svditer.hxx>
      21             : #include <svx/svdocapt.hxx>
      22             : #include <svx/svdpagv.hxx>
      23             : #include <sfx2/dispatch.hxx>
      24             : #include <editeng/outliner.hxx>
      25             : 
      26             : #include "fusel.hxx"
      27             : #include "tabvwsh.hxx"
      28             : #include "document.hxx"
      29             : #include "detfunc.hxx"
      30             : #include "futext.hxx"
      31             : #include "sc.hrc"
      32             : #include "attrib.hxx"
      33             : #include "scitems.hxx"
      34             : #include "userdat.hxx"
      35             : #include "drwlayer.hxx"
      36             : #include "docsh.hxx"
      37             : #include "drawview.hxx"
      38             : #include <svx/sdrhittesthelper.hxx>
      39             : 
      40             : // -----------------------------------------------------------------------
      41             : 
      42           0 : inline long Diff( const Point& rP1, const Point& rP2 )
      43             : {
      44           0 :     long nX = rP1.X() - rP2.X();
      45           0 :     if (nX<0) nX = -nX;
      46           0 :     long nY = rP1.Y() - rP2.Y();
      47           0 :     if (nY<0) nY = -nY;
      48           0 :     return nX+nY;
      49             : }
      50             : 
      51           0 : sal_Bool FuSelection::TestDetective( SdrPageView* pPV, const Point& rPos )
      52             : {
      53           0 :     if (!pPV)
      54           0 :         return false;
      55             : 
      56           0 :     sal_Bool bFound = false;
      57           0 :     SdrObjListIter aIter( *pPV->GetObjList(), IM_FLAT );
      58           0 :     SdrObject* pObject = aIter.Next();
      59           0 :     while (pObject && !bFound)
      60             :     {
      61           0 :         if (ScDetectiveFunc::IsNonAlienArrow( pObject ))
      62             :         {
      63             :             sal_uInt16 nHitLog = (sal_uInt16) pWindow->PixelToLogic(
      64           0 :                                 Size(pView->GetHitTolerancePixel(),0)).Width();
      65           0 :             if (SdrObjectPrimitiveHit(*pObject, rPos, nHitLog, *pPV, 0, false))
      66             :             {
      67           0 :                 ScViewData* pViewData = pViewShell->GetViewData();
      68           0 :                 ScSplitPos ePos = pViewShell->FindWindow( pWindow );
      69           0 :                 Point aLineStart = pObject->GetPoint(0);
      70           0 :                 Point aLineEnd   = pObject->GetPoint(1);
      71           0 :                 Point aPixel = pWindow->LogicToPixel( aLineStart );
      72             :                 SCsCOL nStartCol;
      73             :                 SCsROW nStartRow;
      74           0 :                 pViewData->GetPosFromPixel( aPixel.X(), aPixel.Y(), ePos, nStartCol, nStartRow );
      75           0 :                 aPixel = pWindow->LogicToPixel( aLineEnd );
      76             :                 SCsCOL nEndCol;
      77             :                 SCsROW nEndRow;
      78           0 :                 pViewData->GetPosFromPixel( aPixel.X(), aPixel.Y(), ePos, nEndCol, nEndRow );
      79           0 :                 SCsCOL nCurX = (SCsCOL) pViewData->GetCurX();
      80           0 :                 SCsROW nCurY = (SCsROW) pViewData->GetCurY();
      81           0 :                 sal_Bool bStart = ( Diff( rPos,aLineStart ) > Diff( rPos,aLineEnd ) );
      82           0 :                 if ( nCurX == nStartCol && nCurY == nStartRow )
      83           0 :                     bStart = false;
      84           0 :                 else if ( nCurX == nEndCol && nCurY == nEndRow )
      85           0 :                     bStart = sal_True;
      86             : 
      87             :                 SCsCOL nDifX;
      88             :                 SCsROW nDifY;
      89           0 :                 if ( bStart )
      90             :                 {
      91           0 :                     nDifX = nStartCol - nCurX;
      92           0 :                     nDifY = nStartRow - nCurY;
      93             :                 }
      94             :                 else
      95             :                 {
      96           0 :                     nDifX = nEndCol - nCurX;
      97           0 :                     nDifY = nEndRow - nCurY;
      98             :                 }
      99           0 :                 pViewShell->MoveCursorRel( nDifX, nDifY, SC_FOLLOW_JUMP, false );
     100             : 
     101           0 :                 bFound = sal_True;
     102             :             }
     103             :         }
     104             : 
     105           0 :         pObject = aIter.Next();
     106             :     }
     107           0 :     return bFound;
     108             : }
     109             : 
     110           0 : bool FuSelection::IsNoteCaptionMarked() const
     111             : {
     112           0 :     if( pView )
     113             :     {
     114           0 :         const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     115           0 :         if( rMarkList.GetMarkCount() == 1 )
     116             :         {
     117           0 :             SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     118           0 :             return ScDrawLayer::IsNoteCaption( pObj );
     119             :         }
     120             :     }
     121           0 :     return false;
     122             : }
     123             : 
     124           0 : bool FuSelection::IsNoteCaptionClicked( const Point& rPos ) const
     125             : {
     126           0 :     SdrPageView* pPageView = pView ? pView->GetSdrPageView() : 0;
     127           0 :     if( pPageView )
     128             :     {
     129           0 :         const ScViewData& rViewData = *pViewShell->GetViewData();
     130           0 :         ScDocument& rDoc = *rViewData.GetDocument();
     131           0 :         SCTAB nTab = rViewData.GetTabNo();
     132           0 :         ScDocShell* pDocSh = rViewData.GetDocShell();
     133           0 :         bool bProtectDoc =  rDoc.IsTabProtected( nTab ) || (pDocSh && pDocSh->IsReadOnly());
     134             : 
     135             :         // search the last object (on top) in the object list
     136           0 :         SdrObjListIter aIter( *pPageView->GetObjList(), IM_DEEPNOGROUPS, sal_True );
     137           0 :         for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() )
     138             :         {
     139           0 :             if( pObj->GetLogicRect().IsInside( rPos ) )
     140             :             {
     141           0 :                 if( const ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObj, nTab ) )
     142             :                 {
     143           0 :                     const ScAddress& rNotePos = pCaptData->maStart;
     144             :                     // skip caption objects of notes in protected cells
     145           0 :                     const ScProtectionAttr* pProtAttr =  static_cast< const ScProtectionAttr* >( rDoc.GetAttr( rNotePos.Col(), rNotePos.Row(), nTab, ATTR_PROTECTION ) );
     146           0 :                     bool bProtectAttr = pProtAttr->GetProtection() || pProtAttr->GetHideCell();
     147           0 :                     if( !bProtectAttr || !bProtectDoc )
     148           0 :                         return true;
     149             :                 }
     150             :             }
     151           0 :         }
     152             :     }
     153           0 :     return false;
     154             : }
     155             : 
     156           0 : void FuSelection::ActivateNoteHandles(SdrObject* pObject)
     157             : {
     158           0 :     if( pView && ScDrawLayer::IsNoteCaption( pObject ) )
     159             :     {
     160             :         // Leave the internal layer unlocked - relock in ScDrawView::MarkListHasChanged()
     161           0 :         pView->UnlockInternalLayer();
     162           0 :         pView->MarkObj( pObject, pView->GetSdrPageView() );
     163             :     }
     164          93 : }
     165             : 
     166             : //==================================================================
     167             : 
     168             : 
     169             : 
     170             : 
     171             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10