LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/view - drawvie3.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 104 1.0 %
Date: 2012-12-27 Functions: 2 9 22.2 %
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 :     SdrObject* pObj = NULL;
      64           0 :     if( AreObjectsMarked() )
      65             :     {
      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 :     SdrObject* pObj = NULL;
      89           0 :     if( AreObjectsMarked() )
      90             :     {
      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 :     const SdrObject* pObj = NULL;
     112           0 :     if( AreObjectsMarked() )
     113             :     {
     114           0 :         const SdrMarkList* pMark = &GetMarkedObjectList();
     115           0 :         sal_uLong nCount = pMark->GetMarkCount();
     116           0 :         Point p0;
     117           0 :         for( sal_uLong i=0; i<nCount; i++ )
     118             :         {
     119           0 :             pObj = pMark->GetMark(i)->GetMarkedSdrObj();
     120           0 :             if( ScDrawLayer::GetAnchorType( *pObj ) == SCA_CELL )
     121           0 :                 bCell =true;
     122             :             else
     123           0 :                 bPage = sal_True;
     124             :         }
     125             :     }
     126           0 :     if( bPage && !bCell )
     127           0 :         return SCA_PAGE;
     128           0 :     if( !bPage && bCell )
     129           0 :         return SCA_CELL;
     130           0 :     return SCA_DONTKNOW;
     131             : }
     132             : 
     133             : namespace {
     134             : 
     135             : /**
     136             :  * Updated the anchors of any non-note object that is cell anchored which
     137             :  * has been moved since the last anchors for its position was calculated.
     138             :  */
     139           0 : void adjustAnchoredPosition(const SdrHint& rHint, const ScDocument& rDoc, SCTAB nTab)
     140             : {
     141           0 :     if (rHint.GetKind() != HINT_OBJCHG && rHint.GetKind() != HINT_OBJINSERTED)
     142           0 :         return;
     143             : 
     144           0 :     SdrObject* pObj = const_cast<SdrObject*>(rHint.GetObject());
     145           0 :     if (!pObj)
     146           0 :         return;
     147             : 
     148           0 :     ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pObj);
     149           0 :     if (!pAnchor)
     150           0 :         return;
     151             : 
     152           0 :     if (pAnchor->meType == ScDrawObjData::CellNote)
     153           0 :         return;
     154             : 
     155           0 :     if (pAnchor->maLastRect == pObj->GetLogicRect())
     156           0 :         return;
     157             : 
     158           0 :     if (pAnchor->maStart.Tab() != nTab)
     159             :         // The object is not anchored on the current sheet.  Skip it.
     160             :         // TODO: In the future, we may want to adjust objects that are
     161             :         // anchored on all selected sheets.
     162           0 :         return;
     163             : 
     164           0 :     ScDrawLayer::SetCellAnchoredFromPosition(*pObj, rDoc, pAnchor->maStart.Tab());
     165             : }
     166             : 
     167             : }
     168             : 
     169           0 : void ScDrawView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
     170             : {
     171           0 :     if (rHint.ISA(ScTabDeletedHint))                        // Tabelle geloescht
     172             :     {
     173           0 :         SCTAB nDelTab = ((ScTabDeletedHint&)rHint).GetTab();
     174           0 :         if (ValidTab(nDelTab))
     175             :         {
     176             :             // used to be: HidePagePgNum(nDelTab) - hide only if the deleted sheet is shown here
     177           0 :             if ( nDelTab == nTab )
     178           0 :                 HideSdrPage();
     179             :         }
     180             :     }
     181           0 :     else if (rHint.ISA(ScTabSizeChangedHint))               // Groesse geaendert
     182             :     {
     183           0 :         if ( nTab == ((ScTabSizeChangedHint&)rHint).GetTab() )
     184           0 :             UpdateWorkArea();
     185             :     }
     186           0 :     else if ( rHint.ISA( SdrHint ) )
     187             :     {
     188           0 :         if (const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ))
     189           0 :             adjustAnchoredPosition(*pSdrHint, *pDoc, nTab);
     190           0 :         FmFormView::Notify( rBC,rHint );
     191             :     }
     192             :     else
     193           0 :         FmFormView::Notify( rBC,rHint );
     194           0 : }
     195             : 
     196           0 : void ScDrawView::UpdateIMap( SdrObject* pObj )
     197             : {
     198           0 :     if ( pViewData &&
     199           0 :          pViewData->GetViewShell()->GetViewFrame()->HasChildWindow( ScIMapChildWindowId() ) &&
     200           0 :          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 = ( (SdrGrafObj*) pObj )->GetGraphic();
     215             :         else
     216             :         {
     217           0 :             Graphic* pGraphic = ((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             :         // TargetListe kann von uns wieder geloescht werden
     225           0 :         for ( size_t i = 0, n = aTargetList.size(); i < n; ++i )
     226           0 :             delete aTargetList[ i ];
     227             :     }
     228          15 : }
     229             : 
     230             : 
     231             : 
     232             : 
     233             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10