LCOV - code coverage report
Current view: top level - sc/source/ui/view - drawvie3.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 36 104 34.6 %
Date: 2012-08-25 Functions: 3 7 42.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 32 130 24.6 %

           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/svdograf.hxx>
      30                 :            : #include <svx/svdoole2.hxx>
      31                 :            : #include <sfx2/app.hxx>
      32                 :            : #include <sfx2/viewfrm.hxx>
      33                 :            : 
      34                 :            : #include "drawview.hxx"
      35                 :            : #include "drwlayer.hxx"
      36                 :            : #include "viewdata.hxx"
      37                 :            : #include "dbfunc.hxx"
      38                 :            : #include "document.hxx"
      39                 :            : #include "userdat.hxx"
      40                 :            : #include "tabvwsh.hxx"
      41                 :            : #include "docsh.hxx"
      42                 :            : 
      43                 :            : void ScIMapDlgSet( const Graphic& rGraphic, const ImageMap* pImageMap,
      44                 :            :                     const TargetList* pTargetList, void* pEditingObj );     // imapwrap
      45                 :            : sal_uInt16 ScIMapChildWindowId();
      46                 :            : 
      47                 :            : // STATIC DATA -----------------------------------------------------------
      48                 :            : 
      49                 :        229 : ScDrawView::ScDrawView( OutputDevice* pOut, ScViewData* pData ) :
      50                 :        229 :     FmFormView( pData->GetDocument()->GetDrawLayer(), pOut ),
      51                 :            :     pViewData( pData ),
      52                 :            :     pDev( pOut ),
      53         [ +  - ]:        229 :     pDoc( pData->GetDocument() ),
      54                 :        229 :     nTab( pData->GetTabNo() ),
      55                 :            :     pDropMarker( NULL ),
      56                 :            :     pDropMarkObj( NULL ),
      57                 :        458 :     bInConstruct( true )
      58                 :            : {
      59                 :            :     // #i73602# Use default from the configuration
      60 [ +  - ][ +  - ]:        229 :     SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_Calc());
      61                 :            : 
      62                 :            :     // #i74769#, #i75172# Use default from the configuration
      63 [ +  - ][ +  - ]:        229 :     SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_Calc());
      64                 :            : 
      65         [ +  - ]:        229 :     Construct();
      66                 :        229 : }
      67                 :            : 
      68                 :            : // Verankerung setzen
      69                 :            : 
      70                 :          0 : void ScDrawView::SetPageAnchored()
      71                 :            : {
      72                 :          0 :     SdrObject* pObj = NULL;
      73         [ #  # ]:          0 :     if( AreObjectsMarked() )
      74                 :            :     {
      75                 :          0 :         const SdrMarkList* pMark = &GetMarkedObjectList();
      76                 :          0 :         sal_uLong nCount = pMark->GetMarkCount();
      77         [ #  # ]:          0 :         for( sal_uLong i=0; i<nCount; i++ )
      78                 :            :         {
      79                 :          0 :             pObj = pMark->GetMark(i)->GetMarkedSdrObj();
      80                 :          0 :             ScDrawLayer::SetPageAnchored( *pObj );
      81                 :            :         }
      82                 :            : 
      83         [ #  # ]:          0 :         if ( pViewData )
      84                 :          0 :             pViewData->GetDocShell()->SetDrawModified();
      85                 :            : 
      86                 :            :         // Remove the anchor object.
      87                 :          0 :         aHdl.RemoveAllByKind(HDL_ANCHOR);
      88                 :          0 :         aHdl.RemoveAllByKind(HDL_ANCHOR_TR);
      89                 :            :     }
      90                 :          0 : }
      91                 :            : 
      92                 :          0 : void ScDrawView::SetCellAnchored()
      93                 :            : {
      94         [ #  # ]:          0 :     if (!pDoc)
      95                 :          0 :         return;
      96                 :            : 
      97                 :          0 :     SdrObject* pObj = NULL;
      98         [ #  # ]:          0 :     if( AreObjectsMarked() )
      99                 :            :     {
     100                 :          0 :         const SdrMarkList* pMark = &GetMarkedObjectList();
     101                 :          0 :         sal_uLong nCount = pMark->GetMarkCount();
     102         [ #  # ]:          0 :         for( sal_uLong i=0; i<nCount; i++ )
     103                 :            :         {
     104                 :          0 :             pObj = pMark->GetMark(i)->GetMarkedSdrObj();
     105                 :          0 :             ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, nTab);
     106                 :            :         }
     107                 :            : 
     108         [ #  # ]:          0 :         if ( pViewData )
     109                 :          0 :             pViewData->GetDocShell()->SetDrawModified();
     110                 :            : 
     111                 :            :         // Set the anchor object.
     112                 :          0 :         AddCustomHdl();
     113                 :            :     }
     114                 :            : }
     115                 :            : 
     116                 :          0 : ScAnchorType ScDrawView::GetAnchorType() const
     117                 :            : {
     118                 :          0 :     sal_Bool bPage = false;
     119                 :          0 :     sal_Bool bCell = false;
     120                 :          0 :     const SdrObject* pObj = NULL;
     121         [ #  # ]:          0 :     if( AreObjectsMarked() )
     122                 :            :     {
     123                 :          0 :         const SdrMarkList* pMark = &GetMarkedObjectList();
     124                 :          0 :         sal_uLong nCount = pMark->GetMarkCount();
     125                 :          0 :         Point p0;
     126         [ #  # ]:          0 :         for( sal_uLong i=0; i<nCount; i++ )
     127                 :            :         {
     128 [ #  # ][ #  # ]:          0 :             pObj = pMark->GetMark(i)->GetMarkedSdrObj();
     129 [ #  # ][ #  # ]:          0 :             if( ScDrawLayer::GetAnchorType( *pObj ) == SCA_CELL )
     130                 :          0 :                 bCell =true;
     131                 :            :             else
     132                 :          0 :                 bPage = sal_True;
     133                 :            :         }
     134                 :            :     }
     135 [ #  # ][ #  # ]:          0 :     if( bPage && !bCell )
     136                 :          0 :         return SCA_PAGE;
     137 [ #  # ][ #  # ]:          0 :     if( !bPage && bCell )
     138                 :          0 :         return SCA_CELL;
     139                 :          0 :     return SCA_DONTKNOW;
     140                 :            : }
     141                 :            : 
     142                 :            : namespace {
     143                 :            : 
     144                 :            : /**
     145                 :            :  * Updated the anchors of any non-note object that is cell anchored which
     146                 :            :  * has been moved since the last anchors for its position was calculated.
     147                 :            :  */
     148                 :        402 : void adjustAnchoredPosition(const SdrHint& rHint, const ScDocument& rDoc, SCTAB nTab)
     149                 :            : {
     150 [ +  + ][ +  + ]:        402 :     if (rHint.GetKind() != HINT_OBJCHG && rHint.GetKind() != HINT_OBJINSERTED)
                 [ +  + ]
     151                 :        118 :         return;
     152                 :            : 
     153                 :        284 :     SdrObject* pObj = const_cast<SdrObject*>(rHint.GetObject());
     154         [ -  + ]:        284 :     if (!pObj)
     155                 :          0 :         return;
     156                 :            : 
     157                 :        284 :     ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pObj);
     158         [ +  + ]:        284 :     if (!pAnchor)
     159                 :        256 :         return;
     160                 :            : 
     161         [ +  + ]:         28 :     if (pAnchor->meType == ScDrawObjData::CellNote)
     162                 :         24 :         return;
     163                 :            : 
     164         [ -  + ]:          4 :     if (pAnchor->maLastRect == pObj->GetLogicRect())
     165                 :          0 :         return;
     166                 :            : 
     167         [ -  + ]:          4 :     if (pAnchor->maStart.Tab() != nTab)
     168                 :            :         // The object is not anchored on the current sheet.  Skip it.
     169                 :            :         // TODO: In the future, we may want to adjust objects that are
     170                 :            :         // anchored on all selected sheets.
     171                 :          0 :         return;
     172                 :            : 
     173                 :        402 :     ScDrawLayer::SetCellAnchoredFromPosition(*pObj, rDoc, pAnchor->maStart.Tab());
     174                 :            : }
     175                 :            : 
     176                 :            : }
     177                 :            : 
     178                 :        618 : void ScDrawView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
     179                 :            : {
     180         [ +  + ]:        618 :     if (rHint.ISA(ScTabDeletedHint))                        // Tabelle geloescht
     181                 :            :     {
     182                 :         19 :         SCTAB nDelTab = ((ScTabDeletedHint&)rHint).GetTab();
     183         [ +  - ]:         19 :         if (ValidTab(nDelTab))
     184                 :            :         {
     185                 :            :             // used to be: HidePagePgNum(nDelTab) - hide only if the deleted sheet is shown here
     186         [ +  + ]:         19 :             if ( nDelTab == nTab )
     187                 :         18 :                 HideSdrPage();
     188                 :            :         }
     189                 :            :     }
     190         [ +  + ]:        599 :     else if (rHint.ISA(ScTabSizeChangedHint))               // Groesse geaendert
     191                 :            :     {
     192         [ +  + ]:        197 :         if ( nTab == ((ScTabSizeChangedHint&)rHint).GetTab() )
     193                 :        182 :             UpdateWorkArea();
     194                 :            :     }
     195         [ +  - ]:        402 :     else if ( rHint.ISA( SdrHint ) )
     196                 :            :     {
     197 [ +  - ][ +  - ]:        402 :         if (const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ))
                 [ +  - ]
     198                 :        402 :             adjustAnchoredPosition(*pSdrHint, *pDoc, nTab);
     199                 :        402 :         FmFormView::Notify( rBC,rHint );
     200                 :            :     }
     201                 :            :     else
     202                 :          0 :         FmFormView::Notify( rBC,rHint );
     203                 :        618 : }
     204                 :            : 
     205                 :          0 : void ScDrawView::UpdateIMap( SdrObject* pObj )
     206                 :            : {
     207   [ #  #  #  # ]:          0 :     if ( pViewData &&
           [ #  #  #  #  
           #  # ][ #  # ]
     208                 :          0 :          pViewData->GetViewShell()->GetViewFrame()->HasChildWindow( ScIMapChildWindowId() ) &&
     209                 :          0 :          pObj && ( pObj->ISA(SdrGrafObj) || pObj->ISA(SdrOle2Obj) ) )
     210                 :            :     {
     211         [ #  # ]:          0 :         Graphic     aGraphic;
     212         [ #  # ]:          0 :         TargetList  aTargetList;
     213         [ #  # ]:          0 :         ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pObj );
     214                 :          0 :         const ImageMap* pImageMap = NULL;
     215         [ #  # ]:          0 :         if ( pIMapInfo )
     216                 :          0 :             pImageMap = &pIMapInfo->GetImageMap();
     217                 :            : 
     218                 :            :         // Target-Liste besorgen
     219         [ #  # ]:          0 :         pViewData->GetViewShell()->GetViewFrame()->GetTargetList( aTargetList );
     220                 :            : 
     221                 :            :         // Grafik vom Objekt besorgen
     222 [ #  # ][ #  # ]:          0 :         if ( pObj->ISA( SdrGrafObj ) )
                 [ #  # ]
     223 [ #  # ][ #  # ]:          0 :             aGraphic = ( (SdrGrafObj*) pObj )->GetGraphic();
     224                 :            :         else
     225                 :            :         {
     226         [ #  # ]:          0 :             Graphic* pGraphic = ((const SdrOle2Obj*) pObj )->GetGraphic();
     227         [ #  # ]:          0 :             if ( pGraphic )
     228         [ #  # ]:          0 :                 aGraphic = *pGraphic;
     229                 :            :         }
     230                 :            : 
     231         [ #  # ]:          0 :         ScIMapDlgSet( aGraphic, pImageMap, &aTargetList, pObj );    // aus imapwrap
     232                 :            : 
     233                 :            :         // TargetListe kann von uns wieder geloescht werden
     234         [ #  # ]:          0 :         for ( size_t i = 0, n = aTargetList.size(); i < n; ++i )
     235 [ #  # ][ #  # ]:          0 :             delete aTargetList[ i ];
         [ #  # ][ #  # ]
     236                 :            :     }
     237                 :          0 : }
     238                 :            : 
     239                 :            : 
     240                 :            : 
     241                 :            : 
     242                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10