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

Generated by: LCOV version 1.10