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

Generated by: LCOV version 1.11