LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - fusel2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 71 0.0 %
Date: 2012-08-25 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 110 0.0 %

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

Generated by: LCOV version 1.10