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

Generated by: LCOV version 1.10