LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/view - drawvie4.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 276 0.7 %
Date: 2013-07-09 Functions: 2 17 11.8 %
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/svditer.hxx>
      21             : #include <svx/svdograf.hxx>
      22             : #include <svx/svdogrp.hxx>
      23             : #include <svx/svdoole2.hxx>
      24             : #include <svx/svdpage.hxx>
      25             : #include <svx/svdundo.hxx>
      26             : #include <sfx2/docfile.hxx>
      27             : #include <tools/urlobj.hxx>
      28             : #include <toolkit/helper/vclunohelper.hxx>
      29             : 
      30             : #include "drawview.hxx"
      31             : #include "global.hxx"
      32             : #include "drwlayer.hxx"
      33             : #include "viewdata.hxx"
      34             : #include "document.hxx"
      35             : #include "docsh.hxx"
      36             : #include "drwtrans.hxx"
      37             : #include "transobj.hxx"     // SetDrawClipDoc
      38             : #include "drawutil.hxx"
      39             : #include "scmod.hxx"
      40             : #include "globstr.hrc"
      41             : #include "chartarr.hxx"
      42             : 
      43             : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
      44             : #include <com/sun/star/embed/Aspects.hpp>
      45             : #include <com/sun/star/embed/XEmbeddedObject.hpp>
      46             : #include <com/sun/star/embed/XComponentSupplier.hpp>
      47             : #include <com/sun/star/chart2/XChartTypeContainer.hpp>
      48             : #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
      49             : #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
      50             : 
      51             : using namespace com::sun::star;
      52             : 
      53             : // STATIC DATA -----------------------------------------------------------
      54             : 
      55          31 : Point aDragStartDiff;
      56             : 
      57             : // -----------------------------------------------------------------------
      58             : 
      59           0 : void ScDrawView::CheckOle( const SdrMarkList& rMarkList, sal_Bool& rAnyOle, sal_Bool& rOneOle )
      60             : {
      61           0 :     rAnyOle = rOneOle = false;
      62           0 :     sal_uLong nCount = rMarkList.GetMarkCount();
      63           0 :     for (sal_uLong i=0; i<nCount; i++)
      64             :     {
      65           0 :         SdrMark* pMark = rMarkList.GetMark(i);
      66           0 :         SdrObject* pObj = pMark->GetMarkedSdrObj();
      67           0 :         sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
      68           0 :         if (nSdrObjKind == OBJ_OLE2)
      69             :         {
      70           0 :             rAnyOle = sal_True;
      71           0 :             rOneOle = (nCount == 1);
      72           0 :             break;
      73             :         }
      74           0 :         else if ( pObj->ISA(SdrObjGroup) )
      75             :         {
      76           0 :             SdrObjListIter aIter( *pObj, IM_DEEPNOGROUPS );
      77           0 :             SdrObject* pSubObj = aIter.Next();
      78           0 :             while (pSubObj)
      79             :             {
      80           0 :                 if ( pSubObj->GetObjIdentifier() == OBJ_OLE2 )
      81             :                 {
      82           0 :                     rAnyOle = sal_True;
      83             :                     // rOneOle remains sal_False - a group isn't treated like a single OLE object
      84           0 :                     return;
      85             :                 }
      86           0 :                 pSubObj = aIter.Next();
      87           0 :             }
      88             :         }
      89             :     }
      90             : }
      91             : 
      92           0 : sal_Bool ScDrawView::BeginDrag( Window* pWindow, const Point& rStartPos )
      93             : {
      94           0 :     sal_Bool bReturn = false;
      95             : 
      96           0 :     if ( AreObjectsMarked() )
      97             :     {
      98           0 :         BrkAction();
      99             : 
     100           0 :         Rectangle aMarkedRect = GetAllMarkedRect();
     101           0 :         Region aRegion( aMarkedRect );
     102             : 
     103           0 :         aDragStartDiff = rStartPos - aMarkedRect.TopLeft();
     104             : 
     105             :         sal_Bool bAnyOle, bOneOle;
     106           0 :         const SdrMarkList& rMarkList = GetMarkedObjectList();
     107           0 :         CheckOle( rMarkList, bAnyOle, bOneOle );
     108             : 
     109           0 :         ScDocShellRef aDragShellRef;
     110           0 :         if (bAnyOle)
     111             :         {
     112           0 :             aDragShellRef = new ScDocShell;     // DocShell needs a Ref immediately
     113           0 :             aDragShellRef->DoInitNew(NULL);
     114             :         }
     115           0 :         ScDrawLayer::SetGlobalDrawPersist(aDragShellRef);
     116           0 :         SdrModel* pModel = GetMarkedObjModel();
     117           0 :         ScDrawLayer::SetGlobalDrawPersist(NULL);
     118             : 
     119             :         //  Charts now always copy their data in addition to the source reference, so
     120             :         //  there's no need to call SchDLL::Update for the charts in the clipboard doc.
     121             :         //  Update with the data (including NumberFormatter) from the live document would
     122             :         //  also store the NumberFormatter in the clipboard chart (#88749#)
     123             :         // lcl_RefreshChartData( pModel, pViewData->GetDocument() );
     124             : 
     125           0 :         ScDocShell* pDocSh = pViewData->GetDocShell();
     126             : 
     127           0 :         TransferableObjectDescriptor aObjDesc;
     128           0 :         pDocSh->FillTransferableObjectDescriptor( aObjDesc );
     129           0 :         aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
     130             :         // maSize is set in ScDrawTransferObj ctor
     131             : 
     132           0 :         ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
     133           0 :         uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
     134             : 
     135           0 :         pTransferObj->SetDrawPersist( &aDragShellRef );    // keep persist for ole objects alive
     136           0 :         pTransferObj->SetDragSource( this );            // copies selection
     137             : 
     138           0 :         SC_MOD()->SetDragObject( NULL, pTransferObj );      // for internal D&D
     139           0 :         pTransferObj->StartDrag( pWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
     140             :     }
     141             : 
     142           0 :     return bReturn;
     143             : }
     144             : 
     145             : namespace {
     146             : 
     147           0 : void getRangeFromDataSource( uno::Reference< chart2::data::XDataSource > xDataSource, std::vector<OUString>& rRangeRep)
     148             : {
     149           0 :     uno::Sequence<uno::Reference<chart2::data::XLabeledDataSequence> > xSeqs = xDataSource->getDataSequences();
     150           0 :     for (sal_Int32 i = 0, n = xSeqs.getLength(); i < n; ++i)
     151             :     {
     152           0 :         uno::Reference<chart2::data::XLabeledDataSequence> xLS = xSeqs[i];
     153           0 :         uno::Reference<chart2::data::XDataSequence> xSeq = xLS->getValues();
     154           0 :         if (xSeq.is())
     155             :         {
     156           0 :             OUString aRep = xSeq->getSourceRangeRepresentation();
     157           0 :             rRangeRep.push_back(aRep);
     158             :         }
     159           0 :         xSeq = xLS->getLabel();
     160           0 :         if (xSeq.is())
     161             :         {
     162           0 :             OUString aRep = xSeq->getSourceRangeRepresentation();
     163           0 :             rRangeRep.push_back(aRep);
     164             :         }
     165           0 :     }
     166           0 : }
     167             : 
     168             : 
     169           0 : void getRangeFromErrorBar(const uno::Reference< chart2::XChartDocument > xChartDoc, std::vector<OUString>& rRangeRep)
     170             : {
     171           0 :     uno::Reference <chart2::XDiagram > xDiagram = xChartDoc->getFirstDiagram();
     172           0 :     if(!xDiagram.is())
     173           0 :         return;
     174             : 
     175           0 :     uno::Reference< chart2::XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY);
     176           0 :     if(!xCooSysContainer.is())
     177           0 :         return;
     178             : 
     179           0 :     uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > xCooSysSequence( xCooSysContainer->getCoordinateSystems());
     180           0 :     for(sal_Int32 i = 0; i < xCooSysSequence.getLength(); ++i)
     181             :     {
     182           0 :         uno::Reference< chart2::XChartTypeContainer > xChartTypeContainer( xCooSysSequence[i], uno::UNO_QUERY);
     183           0 :         if(!xChartTypeContainer.is())
     184           0 :             continue;
     185             : 
     186           0 :         uno::Sequence< uno::Reference< chart2::XChartType > > xChartTypeSequence( xChartTypeContainer->getChartTypes() );
     187           0 :         for(sal_Int32 nChartType = 0; nChartType < xChartTypeSequence.getLength(); ++nChartType)
     188             :         {
     189           0 :             uno::Reference< chart2::XDataSeriesContainer > xDataSequenceContainer( xChartTypeSequence[nChartType], uno::UNO_QUERY);
     190           0 :             if(!xDataSequenceContainer.is())
     191           0 :                 continue;
     192             : 
     193           0 :             uno::Sequence< uno::Reference< chart2::XDataSeries > > xSeriesSequence( xDataSequenceContainer->getDataSeries() );
     194           0 :             for(sal_Int32 nDataSeries = 0; nDataSeries < xSeriesSequence.getLength(); ++nDataSeries)
     195             :             {
     196           0 :                 uno::Reference< chart2::XDataSeries > xSeries = xSeriesSequence[nDataSeries];
     197           0 :                 uno::Reference< beans::XPropertySet > xPropSet( xSeries, uno::UNO_QUERY);
     198           0 :                 uno::Reference< chart2::data::XDataSource > xErrorBarY;
     199           0 :                 xPropSet->getPropertyValue("ErrorBarY") >>= xErrorBarY;
     200           0 :                 if(xErrorBarY.is())
     201           0 :                     getRangeFromDataSource(xErrorBarY, rRangeRep);
     202           0 :                 uno::Reference< chart2::data::XDataSource > xErrorBarX;
     203           0 :                 xPropSet->getPropertyValue("ErrorBarX") >>= xErrorBarX;
     204           0 :                 if(xErrorBarX.is())
     205           0 :                     getRangeFromDataSource(xErrorBarX, rRangeRep);
     206           0 :             }
     207           0 :         }
     208           0 :     }
     209             : }
     210             : 
     211           0 : void getRangeFromOle2Object(const SdrOle2Obj& rObj, std::vector<OUString>& rRangeRep)
     212             : {
     213           0 :     if (!rObj.IsChart())
     214             :         // not a chart object.
     215           0 :         return;
     216             : 
     217           0 :     uno::Reference<embed::XEmbeddedObject> xObj = rObj.GetObjRef();
     218           0 :     if (!xObj.is())
     219           0 :         return;
     220             : 
     221           0 :     uno::Reference<embed::XComponentSupplier> xCompSupp(xObj, uno::UNO_QUERY);
     222           0 :     if (!xCompSupp.is())
     223           0 :         return;
     224             : 
     225           0 :     uno::Reference<chart2::XChartDocument> xChartDoc(xCompSupp->getComponent(), uno::UNO_QUERY);
     226           0 :     if (!xChartDoc.is())
     227           0 :         return;
     228             : 
     229           0 :     if(xChartDoc->hasInternalDataProvider())
     230           0 :         return;
     231             : 
     232           0 :     getRangeFromErrorBar(xChartDoc, rRangeRep);
     233             : 
     234           0 :     uno::Reference<chart2::data::XDataSource> xDataSource(xChartDoc, uno::UNO_QUERY);
     235           0 :     if (!xDataSource.is())
     236           0 :         return;
     237             : 
     238             :     // Get all data sources used in this chart.
     239           0 :     getRangeFromDataSource(xDataSource, rRangeRep);
     240             : }
     241             : 
     242             : /**
     243             :  * Get all cell ranges that are referenced by the selected chart objects.
     244             :  */
     245           0 : void getChartSourceRanges(ScDocument* pDoc, const SdrMarkList& rObjs, std::vector<ScRange>& rRanges)
     246             : {
     247           0 :     std::vector<OUString> aRangeReps;
     248           0 :     for (size_t i = 0, n = rObjs.GetMarkCount(); i < n; ++i)
     249             :     {
     250           0 :         const SdrMark* pMark = rObjs.GetMark(i);
     251           0 :         if (!pMark)
     252           0 :             continue;
     253             : 
     254           0 :         const SdrObject* pObj = pMark->GetMarkedSdrObj();
     255           0 :         if (!pObj)
     256           0 :             continue;
     257             : 
     258           0 :         switch (pObj->GetObjIdentifier())
     259             :         {
     260             :             case OBJ_OLE2:
     261           0 :                 getRangeFromOle2Object(static_cast<const SdrOle2Obj&>(*pObj), aRangeReps);
     262           0 :             break;
     263             :             case OBJ_GRUP:
     264             :             {
     265           0 :                 SdrObjListIter aIter(*pObj, IM_DEEPNOGROUPS);
     266           0 :                 for (SdrObject* pSubObj = aIter.Next(); pSubObj; pSubObj = aIter.Next())
     267             :                 {
     268           0 :                     if (pSubObj->GetObjIdentifier() != OBJ_OLE2)
     269           0 :                         continue;
     270             : 
     271           0 :                     getRangeFromOle2Object(static_cast<const SdrOle2Obj&>(*pSubObj), aRangeReps);
     272           0 :                 }
     273             : 
     274             :             }
     275           0 :             break;
     276             :             default:
     277             :                 ;
     278             :         }
     279             :     }
     280             : 
     281             :     // Compile all range representation strings into ranges.
     282           0 :     std::vector<OUString>::const_iterator it = aRangeReps.begin(), itEnd = aRangeReps.end();
     283           0 :     for (; it != itEnd; ++it)
     284             :     {
     285           0 :         ScRangeList aRange;
     286           0 :         ScAddress aAddr;
     287           0 :         if (aRange.Parse(*it, pDoc, pDoc->GetAddressConvention()) & SCA_VALID)
     288             :         {
     289           0 :             for(size_t i = 0; i < aRange.size(); ++i)
     290           0 :                 rRanges.push_back(*aRange[i]);
     291             :         }
     292           0 :         else if (aAddr.Parse(*it, pDoc, pDoc->GetAddressConvention()) & SCA_VALID)
     293           0 :             rRanges.push_back(aAddr);
     294           0 :     }
     295           0 : }
     296             : 
     297             : class InsertTabIndex : std::unary_function<ScRange, void>
     298             : {
     299             :     std::vector<SCTAB>& mrTabs;
     300             : public:
     301           0 :     InsertTabIndex(std::vector<SCTAB>& rTabs) : mrTabs(rTabs) {}
     302           0 :     void operator() (const ScRange& rRange)
     303             :     {
     304           0 :         mrTabs.push_back(rRange.aStart.Tab());
     305           0 :     }
     306             : };
     307             : 
     308             : class CopyRangeData : std::unary_function<ScRange, void>
     309             : {
     310             :     ScDocument* mpSrc;
     311             :     ScDocument* mpDest;
     312             : public:
     313           0 :     CopyRangeData(ScDocument* pSrc, ScDocument* pDest) : mpSrc(pSrc), mpDest(pDest) {}
     314             : 
     315           0 :     void operator() (const ScRange& rRange)
     316             :     {
     317           0 :         OUString aTabName;
     318           0 :         mpSrc->GetName(rRange.aStart.Tab(), aTabName);
     319             : 
     320             :         SCTAB nTab;
     321           0 :         if (!mpDest->GetTable(aTabName, nTab))
     322             :             // Sheet by this name doesn't exist.
     323           0 :             return;
     324             : 
     325           0 :         mpSrc->CopyStaticToDocument(rRange, nTab, mpDest);
     326             :     }
     327             : };
     328             : 
     329           0 : void copyChartRefDataToClipDoc(ScDocument* pSrcDoc, ScDocument* pClipDoc, const std::vector<ScRange>& rRanges)
     330             : {
     331             :     // Get a list of referenced table indices.
     332           0 :     std::vector<SCTAB> aTabs;
     333           0 :     std::for_each(rRanges.begin(), rRanges.end(), InsertTabIndex(aTabs));
     334           0 :     std::sort(aTabs.begin(), aTabs.end());
     335           0 :     aTabs.erase(std::unique(aTabs.begin(), aTabs.end()), aTabs.end());
     336             : 
     337             :     // Get table names.
     338           0 :     if (aTabs.empty())
     339           0 :         return;
     340             : 
     341             :     // Create sheets only for referenced source sheets.
     342           0 :     OUString aName;
     343           0 :     std::vector<SCTAB>::const_iterator it = aTabs.begin(), itEnd = aTabs.end();
     344           0 :     if (!pSrcDoc->GetName(*it, aName))
     345           0 :         return;
     346             : 
     347           0 :     pClipDoc->SetTabNameOnLoad(0, aName); // document initially has one sheet.
     348             : 
     349           0 :     for (++it; it != itEnd; ++it)
     350             :     {
     351           0 :         if (!pSrcDoc->GetName(*it, aName))
     352           0 :             return;
     353             : 
     354           0 :         pClipDoc->AppendTabOnLoad(aName);
     355             :     }
     356             : 
     357           0 :     std::for_each(rRanges.begin(), rRanges.end(), CopyRangeData(pSrcDoc, pClipDoc));
     358             : }
     359             : 
     360             : }
     361             : 
     362           0 : void ScDrawView::DoCopy()
     363             : {
     364           0 :     const SdrMarkList& rMarkList = GetMarkedObjectList();
     365           0 :     std::vector<ScRange> aRanges;
     366           0 :     getChartSourceRanges(pDoc, rMarkList, aRanges);
     367             : 
     368             :     // update ScGlobal::pDrawClipDocShellRef
     369           0 :     ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc(!aRanges.empty()) );
     370           0 :     if (ScGlobal::pDrawClipDocShellRef)
     371             :     {
     372             :         // Copy data referenced by the chart objects to the draw clip
     373             :         // document. We need to do this before GetMarkedObjModel() below.
     374           0 :         ScDocShellRef xDocSh = *ScGlobal::pDrawClipDocShellRef;
     375           0 :         ScDocument* pClipDoc = xDocSh->GetDocument();
     376           0 :         copyChartRefDataToClipDoc(pDoc, pClipDoc, aRanges);
     377             :     }
     378           0 :     SdrModel* pModel = GetMarkedObjModel();
     379           0 :     ScDrawLayer::SetGlobalDrawPersist(NULL);
     380             : 
     381             :     //  Charts now always copy their data in addition to the source reference, so
     382             :     //  there's no need to call SchDLL::Update for the charts in the clipboard doc.
     383             :     //  Update with the data (including NumberFormatter) from the live document would
     384             :     //  also store the NumberFormatter in the clipboard chart (#88749#)
     385             : 
     386           0 :     ScDocShell* pDocSh = pViewData->GetDocShell();
     387             : 
     388           0 :     TransferableObjectDescriptor aObjDesc;
     389           0 :     pDocSh->FillTransferableObjectDescriptor( aObjDesc );
     390           0 :     aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
     391             :     // maSize is set in ScDrawTransferObj ctor
     392             : 
     393           0 :     ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
     394           0 :     uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
     395             : 
     396           0 :     if ( ScGlobal::pDrawClipDocShellRef )
     397             :     {
     398           0 :         pTransferObj->SetDrawPersist( &(*ScGlobal::pDrawClipDocShellRef) );    // keep persist for ole objects alive
     399             :     }
     400             : 
     401           0 :     pTransferObj->CopyToClipboard( pViewData->GetActiveWin() );     // system clipboard
     402           0 :     SC_MOD()->SetClipObject( NULL, pTransferObj );                  // internal clipboard
     403           0 : }
     404             : 
     405           0 : uno::Reference<datatransfer::XTransferable> ScDrawView::CopyToTransferable()
     406             : {
     407             :     sal_Bool bAnyOle, bOneOle;
     408           0 :     const SdrMarkList& rMarkList = GetMarkedObjectList();
     409           0 :     CheckOle( rMarkList, bAnyOle, bOneOle );
     410             : 
     411             :     // update ScGlobal::pDrawClipDocShellRef
     412           0 :     ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) );
     413           0 :     SdrModel* pModel = GetMarkedObjModel();
     414           0 :     ScDrawLayer::SetGlobalDrawPersist(NULL);
     415             : 
     416             :     //  Charts now always copy their data in addition to the source reference, so
     417             :     //  there's no need to call SchDLL::Update for the charts in the clipboard doc.
     418             :     //  Update with the data (including NumberFormatter) from the live document would
     419             :     //  also store the NumberFormatter in the clipboard chart (#88749#)
     420             :     // lcl_RefreshChartData( pModel, pViewData->GetDocument() );
     421             : 
     422           0 :     ScDocShell* pDocSh = pViewData->GetDocShell();
     423             : 
     424           0 :     TransferableObjectDescriptor aObjDesc;
     425           0 :     pDocSh->FillTransferableObjectDescriptor( aObjDesc );
     426           0 :     aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
     427             :     // maSize is set in ScDrawTransferObj ctor
     428             : 
     429           0 :     ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
     430           0 :     uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
     431             : 
     432           0 :     if ( ScGlobal::pDrawClipDocShellRef )
     433             :     {
     434           0 :         pTransferObj->SetDrawPersist( &(*ScGlobal::pDrawClipDocShellRef) );    // keep persist for ole objects alive
     435             :     }
     436             : 
     437           0 :     return xTransferable;
     438             : }
     439             : 
     440             : //  Korrektur fuer 100% berechnen, unabhaengig von momentanen Einstellungen
     441             : 
     442           0 : void ScDrawView::CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const
     443             : {
     444           0 :     double nPPTX = ScGlobal::nScreenPPTX;
     445           0 :     double nPPTY = ScGlobal::nScreenPPTY;
     446             : 
     447           0 :     if (pViewData)
     448           0 :         nPPTX /= pViewData->GetDocShell()->GetOutputFactor();
     449             : 
     450           0 :     SCCOL nEndCol = 0;
     451           0 :     SCROW nEndRow = 0;
     452           0 :     pDoc->GetTableArea( nTab, nEndCol, nEndRow );
     453           0 :     if (nEndCol<20)
     454           0 :         nEndCol = 20;
     455           0 :     if (nEndRow<20)
     456           0 :         nEndRow = 1000;
     457             : 
     458           0 :     Fraction aZoom(1,1);
     459             :     ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev, aZoom,aZoom,
     460           0 :                             nPPTX, nPPTY, rFractX,rFractY );
     461           0 : }
     462             : 
     463           0 : void ScDrawView::SetMarkedOriginalSize()
     464             : {
     465           0 :     SdrUndoGroup* pUndoGroup = new SdrUndoGroup(*GetModel());
     466             : 
     467           0 :     const SdrMarkList& rMarkList = GetMarkedObjectList();
     468           0 :     long nDone = 0;
     469           0 :     sal_uLong nCount = rMarkList.GetMarkCount();
     470           0 :     for (sal_uLong i=0; i<nCount; i++)
     471             :     {
     472           0 :         SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
     473           0 :         sal_uInt16 nIdent = pObj->GetObjIdentifier();
     474           0 :         sal_Bool bDo = false;
     475           0 :         Size aOriginalSize;
     476           0 :         if (nIdent == OBJ_OLE2)
     477             :         {
     478             :             // TODO/LEAN: working with visual area can switch object to running state
     479           0 :             uno::Reference < embed::XEmbeddedObject > xObj( ((SdrOle2Obj*)pObj)->GetObjRef(), uno::UNO_QUERY );
     480           0 :             if ( xObj.is() )    // NULL for an invalid object that couldn't be loaded
     481             :             {
     482           0 :                 sal_Int64 nAspect = ((SdrOle2Obj*)pObj)->GetAspect();
     483             : 
     484           0 :                 if ( nAspect == embed::Aspects::MSOLE_ICON )
     485             :                 {
     486           0 :                     MapMode aMapMode( MAP_100TH_MM );
     487           0 :                     aOriginalSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize( &aMapMode );
     488           0 :                     bDo = sal_True;
     489             :                 }
     490             :                 else
     491             :                 {
     492           0 :                     MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( ((SdrOle2Obj*)pObj)->GetAspect() ) );
     493           0 :                     awt::Size aSz;
     494             :                     try
     495             :                     {
     496           0 :                         aSz = xObj->getVisualAreaSize( ((SdrOle2Obj*)pObj)->GetAspect() );
     497             :                         aOriginalSize = OutputDevice::LogicToLogic(
     498             :                                             Size( aSz.Width, aSz.Height ),
     499           0 :                                             aUnit, MAP_100TH_MM );
     500           0 :                         bDo = sal_True;
     501           0 :                     } catch( embed::NoVisualAreaSizeException& )
     502             :                     {
     503             :                         OSL_ENSURE( false, "Can't get the original size of the object!" );
     504             :                     }
     505             :                 }
     506           0 :             }
     507             :         }
     508           0 :         else if (nIdent == OBJ_GRAF)
     509             :         {
     510           0 :             const Graphic& rGraphic = ((SdrGrafObj*)pObj)->GetGraphic();
     511             : 
     512           0 :             MapMode aSourceMap = rGraphic.GetPrefMapMode();
     513           0 :             MapMode aDestMap( MAP_100TH_MM );
     514           0 :             if (aSourceMap.GetMapUnit() == MAP_PIXEL)
     515             :             {
     516             :                 //  Pixel-Korrektur beruecksichtigen, damit Bitmap auf dem Bildschirm stimmt
     517             : 
     518           0 :                 Fraction aNormScaleX, aNormScaleY;
     519           0 :                 CalcNormScale( aNormScaleX, aNormScaleY );
     520           0 :                 aDestMap.SetScaleX(aNormScaleX);
     521           0 :                 aDestMap.SetScaleY(aNormScaleY);
     522             :             }
     523           0 :             if (pViewData)
     524             :             {
     525           0 :                 Window* pActWin = pViewData->GetActiveWin();
     526           0 :                 if (pActWin)
     527             :                 {
     528             :                     aOriginalSize = pActWin->LogicToLogic(
     529           0 :                                     rGraphic.GetPrefSize(), &aSourceMap, &aDestMap );
     530           0 :                     bDo = sal_True;
     531             :                 }
     532           0 :             }
     533             :         }
     534             : 
     535           0 :         if ( bDo )
     536             :         {
     537           0 :             Rectangle aDrawRect = pObj->GetLogicRect();
     538             : 
     539           0 :             pUndoGroup->AddAction( new SdrUndoGeoObj( *pObj ) );
     540           0 :             pObj->Resize( aDrawRect.TopLeft(), Fraction( aOriginalSize.Width(), aDrawRect.GetWidth() ),
     541           0 :                                                  Fraction( aOriginalSize.Height(), aDrawRect.GetHeight() ) );
     542           0 :             ++nDone;
     543             :         }
     544             :     }
     545             : 
     546           0 :     if (nDone)
     547             :     {
     548           0 :         pUndoGroup->SetComment(ScGlobal::GetRscString( STR_UNDO_ORIGINALSIZE ));
     549           0 :         ScDocShell* pDocSh = pViewData->GetDocShell();
     550           0 :         pDocSh->GetUndoManager()->AddUndoAction(pUndoGroup);
     551           0 :         pDocSh->SetDrawModified();
     552             :     }
     553             :     else
     554           0 :         delete pUndoGroup;
     555          93 : }
     556             : 
     557             : 
     558             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10