LCOV - code coverage report
Current view: top level - sc/source/ui/app - transobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 420 1.0 %
Date: 2012-08-25 Functions: 1 26 3.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 714 0.1 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "scitems.hxx"
      30                 :            : #include <editeng/eeitem.hxx>
      31                 :            : #include <editeng/justifyitem.hxx>
      32                 :            : 
      33                 :            : 
      34                 :            : #include <com/sun/star/uno/Sequence.hxx>
      35                 :            : #include <com/sun/star/embed/XTransactedObject.hpp>
      36                 :            : 
      37                 :            : #include <unotools/tempfile.hxx>
      38                 :            : #include <unotools/ucbstreamhelper.hxx>
      39                 :            : #include <comphelper/storagehelper.hxx>
      40                 :            : #include <comphelper/servicehelper.hxx>
      41                 :            : #include <sot/storage.hxx>
      42                 :            : #include <vcl/svapp.hxx>
      43                 :            : #include <vcl/virdev.hxx>
      44                 :            : #include <osl/mutex.hxx>
      45                 :            : #include <sfx2/app.hxx>
      46                 :            : #include <sfx2/docfile.hxx>
      47                 :            : 
      48                 :            : #include "transobj.hxx"
      49                 :            : #include "document.hxx"
      50                 :            : #include "viewopti.hxx"
      51                 :            : #include "editutil.hxx"
      52                 :            : #include "impex.hxx"
      53                 :            : #include "cell.hxx"
      54                 :            : #include "printfun.hxx"
      55                 :            : #include "docfunc.hxx"
      56                 :            : #include "scmod.hxx"
      57                 :            : #include "dragdata.hxx"
      58                 :            : #include "clipdata.hxx"
      59                 :            : #include "clipparam.hxx"
      60                 :            : 
      61                 :            : // for InitDocShell
      62                 :            : #include <editeng/paperinf.hxx>
      63                 :            : #include <editeng/sizeitem.hxx>
      64                 :            : #include <svx/algitem.hxx>
      65                 :            : #include <svl/intitem.hxx>
      66                 :            : #include <svl/zforlist.hxx>
      67                 :            : #include "docsh.hxx"
      68                 :            : #include "markdata.hxx"
      69                 :            : #include "stlpool.hxx"
      70                 :            : #include "viewdata.hxx"
      71                 :            : #include "dociter.hxx"
      72                 :            : #include "cellsuno.hxx"
      73                 :            : 
      74                 :            : using namespace com::sun::star;
      75                 :            : 
      76                 :            : // -----------------------------------------------------------------------
      77                 :            : 
      78                 :            : #define SCTRANS_TYPE_IMPEX          1
      79                 :            : #define SCTRANS_TYPE_EDIT_RTF       2
      80                 :            : #define SCTRANS_TYPE_EDIT_BIN       3
      81                 :            : #define SCTRANS_TYPE_EMBOBJ         4
      82                 :            : 
      83                 :            : // -----------------------------------------------------------------------
      84                 :            : 
      85                 :          0 : void ScTransferObj::GetAreaSize( ScDocument* pDoc, SCTAB nTab1, SCTAB nTab2, SCROW& nRow, SCCOL& nCol )
      86                 :            : {
      87                 :          0 :     SCCOL nMaxCol = 0;
      88                 :          0 :     SCROW nMaxRow = 0;
      89         [ #  # ]:          0 :     for( SCTAB nTab = nTab1; nTab <= nTab2; nTab++ )
      90                 :            :     {
      91                 :          0 :         SCCOL nLastCol = 0;
      92                 :          0 :         SCROW nLastRow = 0;
      93                 :            :         // GetPrintArea instead of GetCellArea - include drawing objects
      94 [ #  # ][ #  # ]:          0 :         if( pDoc->GetPrintArea( nTab, nLastCol, nLastRow ) )
      95                 :            :         {
      96         [ #  # ]:          0 :             if( nLastCol > nMaxCol )
      97                 :          0 :                 nMaxCol = nLastCol;
      98         [ #  # ]:          0 :             if( nLastRow > nMaxRow  )
      99                 :          0 :                 nMaxRow = nLastRow;
     100                 :            :         }
     101                 :            :     }
     102                 :          0 :     nRow = nMaxRow;
     103                 :          0 :     nCol = nMaxCol;
     104                 :          0 : }
     105                 :            : 
     106                 :          0 : void ScTransferObj::PaintToDev( OutputDevice* pDev, ScDocument* pDoc, double nPrintFactor,
     107                 :            :                                 const ScRange& rBlock, sal_Bool bMetaFile )
     108                 :            : {
     109         [ #  # ]:          0 :     if (!pDoc)
     110                 :          0 :         return;
     111                 :            : 
     112                 :          0 :     Point aPoint;
     113 [ #  # ][ #  # ]:          0 :     Rectangle aBound( aPoint, pDev->GetOutputSize() );      //! use size from clip area?
     114                 :            : 
     115         [ #  # ]:          0 :     ScViewData aViewData(NULL,NULL);
     116         [ #  # ]:          0 :     aViewData.InitData( pDoc );
     117                 :            : 
     118         [ #  # ]:          0 :     aViewData.SetTabNo( rBlock.aEnd.Tab() );
     119                 :          0 :     aViewData.SetScreen( rBlock.aStart.Col(), rBlock.aStart.Row(),
     120         [ #  # ]:          0 :                             rBlock.aEnd.Col(), rBlock.aEnd.Row() );
     121                 :            : 
     122 [ #  # ][ #  # ]:          0 :     ScPrintFunc::DrawToDev( pDoc, pDev, nPrintFactor, aBound, &aViewData, bMetaFile );
     123                 :            : }
     124                 :            : 
     125                 :            : // -----------------------------------------------------------------------
     126                 :            : 
     127                 :          0 : ScTransferObj::ScTransferObj( ScDocument* pClipDoc, const TransferableObjectDescriptor& rDesc ) :
     128                 :            :     pDoc( pClipDoc ),
     129                 :            :     aObjDesc( rDesc ),
     130                 :            :     nDragHandleX( 0 ),
     131                 :            :     nDragHandleY( 0 ),
     132                 :            :     nDragSourceFlags( 0 ),
     133                 :            :     bDragWasInternal( false ),
     134                 :            :     bUsedForLink( false ),
     135 [ #  # ][ #  # ]:          0 :     bUseInApi( false )
     136                 :            : {
     137                 :            :     OSL_ENSURE(pDoc->IsClipboard(), "wrong document");
     138                 :            : 
     139                 :            :     //
     140                 :            :     // get aBlock from clipboard doc
     141                 :            :     //
     142                 :            : 
     143                 :            :     SCCOL nCol1;
     144                 :            :     SCROW nRow1;
     145                 :            :     SCCOL nCol2;
     146                 :            :     SCROW nRow2;
     147         [ #  # ]:          0 :     pDoc->GetClipStart( nCol1, nRow1 );
     148         [ #  # ]:          0 :     pDoc->GetClipArea( nCol2, nRow2, true );    // real source area - include filtered rows
     149                 :          0 :     nCol2 = sal::static_int_cast<SCCOL>( nCol2 + nCol1 );
     150                 :          0 :     nRow2 = sal::static_int_cast<SCROW>( nRow2 + nRow1 );
     151                 :            : 
     152                 :            :     SCCOL nDummy;
     153         [ #  # ]:          0 :     pDoc->GetClipArea( nDummy, nNonFiltered, false );
     154                 :          0 :     bHasFiltered = (nNonFiltered < (nRow2 - nRow1));
     155                 :          0 :     ++nNonFiltered;     // to get count instead of diff
     156                 :            : 
     157                 :          0 :     SCTAB nTab1=0;
     158                 :          0 :     SCTAB nTab2=0;
     159                 :          0 :     bool bFirst = true;
     160 [ #  # ][ #  # ]:          0 :     for (SCTAB i=0; i< pDoc->GetTableCount(); i++)
     161 [ #  # ][ #  # ]:          0 :         if (pDoc->HasTable(i))
     162                 :            :         {
     163         [ #  # ]:          0 :             if (bFirst)
     164                 :          0 :                 nTab1 = i;
     165                 :          0 :             nTab2 = i;
     166                 :          0 :             bFirst = false;
     167                 :            :         }
     168                 :            :     OSL_ENSURE(!bFirst, "no sheet selected");
     169                 :            : 
     170                 :            :     //  only limit to used cells if whole sheet was marked
     171                 :            :     //  (so empty cell areas can be copied)
     172 [ #  # ][ #  # ]:          0 :     if ( nCol2>=MAXCOL && nRow2>=MAXROW )
     173                 :            :     {
     174                 :            :         SCROW nMaxRow;
     175                 :            :         SCCOL nMaxCol;
     176         [ #  # ]:          0 :         GetAreaSize( pDoc, nTab1, nTab2, nMaxRow, nMaxCol );
     177         [ #  # ]:          0 :         if( nMaxRow < nRow2 )
     178                 :          0 :             nRow2 = nMaxRow;
     179         [ #  # ]:          0 :         if( nMaxCol < nCol2 )
     180                 :          0 :             nCol2 = nMaxCol;
     181                 :            :     }
     182                 :            : 
     183                 :          0 :     aBlock = ScRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
     184                 :          0 :     nVisibleTab = nTab1;    // valid table as default
     185                 :            : 
     186         [ #  # ]:          0 :     Rectangle aMMRect = pDoc->GetMMRect( nCol1,nRow1, nCol2,nRow2, nTab1 );
     187         [ #  # ]:          0 :     aObjDesc.maSize = aMMRect.GetSize();
     188         [ #  # ]:          0 :     PrepareOLE( aObjDesc );
     189                 :          0 : }
     190                 :            : 
     191 [ #  # ][ #  # ]:          0 : ScTransferObj::~ScTransferObj()
         [ #  # ][ #  # ]
     192                 :            : {
     193         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     194                 :            : 
     195         [ #  # ]:          0 :     ScModule* pScMod = SC_MOD();
     196 [ #  # ][ #  # ]:          0 :     if ( pScMod->GetClipData().pCellClipboard == this )
     197                 :            :     {
     198                 :            :         OSL_FAIL("ScTransferObj wasn't released");
     199         [ #  # ]:          0 :         pScMod->SetClipObject( NULL, NULL );
     200                 :            :     }
     201 [ #  # ][ #  # ]:          0 :     if ( pScMod->GetDragData().pCellTransfer == this )
     202                 :            :     {
     203                 :            :         OSL_FAIL("ScTransferObj wasn't released");
     204         [ #  # ]:          0 :         pScMod->ResetDragObject();
     205                 :            :     }
     206                 :            : 
     207 [ #  # ][ #  # ]:          0 :     delete pDoc;        // ScTransferObj is owner of clipboard document
     208                 :            : 
     209         [ #  # ]:          0 :     aDocShellRef.Clear();   // before releasing the mutex
     210                 :            : 
     211 [ #  # ][ #  # ]:          0 :     aDrawPersistRef.Clear();                    // after the model
     212                 :            : 
     213         [ #  # ]:          0 : }
     214                 :            : 
     215                 :        531 : ScTransferObj* ScTransferObj::GetOwnClipboard( Window* pUIWin )
     216                 :            : {
     217                 :        531 :     ScTransferObj* pObj = SC_MOD()->GetClipData().pCellClipboard;
     218 [ #  # ][ -  + ]:        531 :     if ( pObj && pUIWin )
     219                 :            :     {
     220                 :            :         //  check formats to see if pObj is really in the system clipboard
     221                 :            : 
     222                 :            :         //  pUIWin is NULL when called from core (IsClipboardSource),
     223                 :            :         //  in that case don't access the system clipboard, because the call
     224                 :            :         //  may be from other clipboard operations (like flushing, #86059#)
     225                 :            : 
     226         [ #  # ]:          0 :         TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pUIWin ) );
     227 [ #  # ][ #  # ]:          0 :         if ( !aDataHelper.HasFormat( SOT_FORMATSTR_ID_DIF ) )
     228                 :            :         {
     229                 :            : //          OSL_FAIL("ScTransferObj wasn't released");
     230                 :          0 :             pObj = NULL;
     231         [ #  # ]:          0 :         }
     232                 :            :     }
     233                 :        531 :     return pObj;
     234                 :            : }
     235                 :            : 
     236                 :          0 : void ScTransferObj::AddSupportedFormats()
     237                 :            : {
     238                 :          0 :     AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
     239                 :          0 :     AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
     240                 :          0 :     AddFormat( SOT_FORMAT_GDIMETAFILE );
     241                 :          0 :     AddFormat( SOT_FORMAT_BITMAP );
     242                 :            : 
     243                 :            :     // ScImportExport formats
     244                 :          0 :     AddFormat( SOT_FORMATSTR_ID_HTML );
     245                 :          0 :     AddFormat( SOT_FORMATSTR_ID_SYLK );
     246                 :          0 :     AddFormat( SOT_FORMATSTR_ID_LINK );
     247                 :          0 :     AddFormat( SOT_FORMATSTR_ID_DIF );
     248                 :          0 :     AddFormat( SOT_FORMAT_STRING );
     249                 :            : 
     250                 :          0 :     AddFormat( SOT_FORMAT_RTF );
     251         [ #  # ]:          0 :     if ( aBlock.aStart == aBlock.aEnd )
     252                 :          0 :         AddFormat( SOT_FORMATSTR_ID_EDITENGINE );
     253                 :          0 : }
     254                 :            : 
     255                 :          0 : sal_Bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor )
     256                 :            : {
     257                 :          0 :     sal_uInt32  nFormat = SotExchange::GetFormat( rFlavor );
     258                 :          0 :     bool    bOK = false;
     259                 :            : 
     260         [ #  # ]:          0 :     if( HasFormat( nFormat ) )
     261                 :            :     {
     262 [ #  # ][ #  # ]:          0 :         if ( nFormat == SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR || nFormat == SOT_FORMATSTR_ID_OBJECTDESCRIPTOR )
     263                 :            :         {
     264                 :          0 :             bOK = SetTransferableObjectDescriptor( aObjDesc, rFlavor );
     265                 :            :         }
     266         [ #  # ]:          0 :         else if ( ( nFormat == SOT_FORMAT_RTF || nFormat == SOT_FORMATSTR_ID_EDITENGINE ) &&
           [ #  #  #  # ]
                 [ #  # ]
     267                 :          0 :                         aBlock.aStart == aBlock.aEnd )
     268                 :            :         {
     269                 :            :             //  RTF from a single cell is handled by EditEngine
     270                 :            : 
     271                 :          0 :             SCCOL nCol = aBlock.aStart.Col();
     272                 :          0 :             SCROW nRow = aBlock.aStart.Row();
     273                 :          0 :             SCTAB nTab = aBlock.aStart.Tab();
     274                 :            : 
     275         [ #  # ]:          0 :             const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab );
     276 [ #  # ][ #  # ]:          0 :             ScTabEditEngine aEngine( *pPattern, pDoc->GetEditPool() );
     277                 :          0 :             ScBaseCell* pCell = NULL;
     278         [ #  # ]:          0 :             pDoc->GetCell( nCol, nRow, nTab, pCell );
     279         [ #  # ]:          0 :             if (pCell)
     280                 :            :             {
     281         [ #  # ]:          0 :                 if (pCell->GetCellType() == CELLTYPE_EDIT)
     282                 :            :                 {
     283                 :            :                     const EditTextObject* pObj;
     284         [ #  # ]:          0 :                     ((ScEditCell*)pCell)->GetData(pObj);
     285         [ #  # ]:          0 :                     aEngine.SetText( *pObj );
     286                 :            :                 }
     287                 :            :                 else
     288                 :            :                 {
     289         [ #  # ]:          0 :                     String aText;
     290         [ #  # ]:          0 :                     pDoc->GetString( nCol, nRow, nTab, aText );
     291 [ #  # ][ #  # ]:          0 :                     aEngine.SetText(aText);
     292                 :            :                 }
     293                 :            :             }
     294                 :            : 
     295                 :            :             bOK = SetObject( &aEngine,
     296                 :            :                             (nFormat == FORMAT_RTF) ? SCTRANS_TYPE_EDIT_RTF : SCTRANS_TYPE_EDIT_BIN,
     297 [ #  # ][ #  # ]:          0 :                             rFlavor );
                 [ #  # ]
     298                 :            :         }
     299 [ #  # ][ #  # ]:          0 :         else if ( ScImportExport::IsFormatSupported( nFormat ) || nFormat == SOT_FORMAT_RTF )
                 [ #  # ]
     300                 :            :         {
     301                 :            :             //  if this transfer object was used to create a DDE link, filtered rows
     302                 :            :             //  have to be included for subsequent calls (to be consistent with link data)
     303         [ #  # ]:          0 :             if ( nFormat == SOT_FORMATSTR_ID_LINK )
     304                 :          0 :                 bUsedForLink = true;
     305                 :            : 
     306 [ #  # ][ #  # ]:          0 :             bool bIncludeFiltered = pDoc->IsCutMode() || bUsedForLink;
                 [ #  # ]
     307                 :            : 
     308                 :          0 :             ScRange aReducedBlock = aBlock;
     309 [ #  # ][ #  # ]:          0 :             if ( nFormat == SOT_FORMATSTR_ID_HTML && (aBlock.aEnd.Col() == MAXCOL || aBlock.aEnd.Row() == MAXROW) && aBlock.aStart.Tab() == aBlock.aEnd.Tab() )
         [ #  # ][ #  # ]
                 [ #  # ]
     310                 :            :             {
     311                 :          0 :                 bool bShrunk = false;
     312                 :            :                 //shrink the area to allow pasting to external applications
     313                 :          0 :                 SCCOL aStartCol = aReducedBlock.aStart.Col();
     314                 :          0 :                 SCROW aStartRow = aReducedBlock.aStart.Row();
     315                 :          0 :                 SCCOL aEndCol = aReducedBlock.aEnd.Col();
     316                 :          0 :                 SCROW aEndRow = aReducedBlock.aEnd.Row();
     317         [ #  # ]:          0 :                 pDoc->ShrinkToUsedDataArea( bShrunk, aReducedBlock.aStart.Tab(), aStartCol, aStartRow, aEndCol, aEndRow, false);
     318                 :          0 :                 aReducedBlock = ScRange(aStartCol, aStartRow, aReducedBlock.aStart.Tab(), aEndCol, aEndRow, aReducedBlock.aEnd.Tab());
     319                 :            :             }
     320                 :            : 
     321         [ #  # ]:          0 :             ScImportExport aObj( pDoc, aReducedBlock );
     322                 :          0 :             ScExportTextOptions aTextOptions(ScExportTextOptions::None, 0, true);
     323         [ #  # ]:          0 :             if ( bUsedForLink )
     324                 :            :             {
     325                 :            :                 // For a DDE link, convert line breaks and separators to space.
     326                 :          0 :                 aTextOptions.meNewlineConversion = ScExportTextOptions::ToSpace;
     327                 :          0 :                 aTextOptions.mcSeparatorConvertTo = ' ';
     328                 :          0 :                 aTextOptions.mbAddQuotes = false;
     329                 :            :             }
     330                 :          0 :             aObj.SetExportTextOptions(aTextOptions);
     331         [ #  # ]:          0 :             aObj.SetFormulas( pDoc->GetViewOptions().GetOption( VOPT_FORMULAS ) );
     332                 :          0 :             aObj.SetIncludeFiltered( bIncludeFiltered );
     333                 :            : 
     334                 :            :             //  DataType depends on format type:
     335                 :            : 
     336 [ #  # ][ #  # ]:          0 :             if ( rFlavor.DataType.equals( ::getCppuType( (const ::rtl::OUString*) 0 ) ) )
     337                 :            :             {
     338                 :          0 :                 rtl::OUString aString;
     339 [ #  # ][ #  # ]:          0 :                 if ( aObj.ExportString( aString, nFormat ) )
     340         [ #  # ]:          0 :                     bOK = SetString( aString, rFlavor );
     341                 :            :             }
     342 [ #  # ][ #  # ]:          0 :             else if ( rFlavor.DataType.equals( ::getCppuType( (const uno::Sequence< sal_Int8 >*) 0 ) ) )
     343                 :            :             {
     344                 :            :                 //  SetObject converts a stream into a Int8-Sequence
     345         [ #  # ]:          0 :                 bOK = SetObject( &aObj, SCTRANS_TYPE_IMPEX, rFlavor );
     346                 :            :             }
     347                 :            :             else
     348                 :            :             {
     349                 :            :                 OSL_FAIL("unknown DataType");
     350         [ #  # ]:          0 :             }
     351                 :            :         }
     352         [ #  # ]:          0 :         else if ( nFormat == SOT_FORMAT_BITMAP )
     353                 :            :         {
     354                 :          0 :             Rectangle aMMRect = pDoc->GetMMRect( aBlock.aStart.Col(), aBlock.aStart.Row(),
     355                 :          0 :                                                  aBlock.aEnd.Col(), aBlock.aEnd.Row(),
     356         [ #  # ]:          0 :                                                  aBlock.aStart.Tab() );
     357         [ #  # ]:          0 :             VirtualDevice aVirtDev;
     358 [ #  # ][ #  # ]:          0 :             aVirtDev.SetOutputSizePixel( aVirtDev.LogicToPixel( aMMRect.GetSize(), MAP_100TH_MM ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     359                 :            : 
     360         [ #  # ]:          0 :             PaintToDev( &aVirtDev, pDoc, 1.0, aBlock, false );
     361                 :            : 
     362 [ #  # ][ #  # ]:          0 :             aVirtDev.SetMapMode( MapMode( MAP_PIXEL ) );
                 [ #  # ]
     363 [ #  # ][ #  # ]:          0 :             Bitmap aBmp = aVirtDev.GetBitmap( Point(), aVirtDev.GetOutputSize() );
     364 [ #  # ][ #  # ]:          0 :             bOK = SetBitmap( aBmp, rFlavor );
                 [ #  # ]
     365                 :            :         }
     366         [ #  # ]:          0 :         else if ( nFormat == SOT_FORMAT_GDIMETAFILE )
     367                 :            :         {
     368         [ #  # ]:          0 :             InitDocShell();
     369                 :          0 :             SfxObjectShell* pEmbObj = aDocShellRef;
     370                 :            : 
     371                 :            :             // like SvEmbeddedTransfer::GetData:
     372                 :            : 
     373         [ #  # ]:          0 :             GDIMetaFile     aMtf;
     374         [ #  # ]:          0 :             VirtualDevice   aVDev;
     375 [ #  # ][ #  # ]:          0 :             MapMode         aMapMode( pEmbObj->GetMapUnit() );
     376         [ #  # ]:          0 :             Rectangle       aVisArea( pEmbObj->GetVisArea( ASPECT_CONTENT ) );
     377                 :            : 
     378         [ #  # ]:          0 :             aVDev.EnableOutput( false );
     379         [ #  # ]:          0 :             aVDev.SetMapMode( aMapMode );
     380         [ #  # ]:          0 :             aMtf.SetPrefSize( aVisArea.GetSize() );
     381         [ #  # ]:          0 :             aMtf.SetPrefMapMode( aMapMode );
     382         [ #  # ]:          0 :             aMtf.Record( &aVDev );
     383                 :            : 
     384 [ #  # ][ #  # ]:          0 :             pEmbObj->DoDraw( &aVDev, Point(), aVisArea.GetSize(), JobSetup(), ASPECT_CONTENT );
         [ #  # ][ #  # ]
     385                 :            : 
     386         [ #  # ]:          0 :             aMtf.Stop();
     387         [ #  # ]:          0 :             aMtf.WindStart();
     388                 :            : 
     389 [ #  # ][ #  # ]:          0 :             bOK = SetGDIMetaFile( aMtf, rFlavor );
         [ #  # ][ #  # ]
     390                 :            :         }
     391         [ #  # ]:          0 :         else if ( nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
     392                 :            :         {
     393                 :            :             //TODO/LATER: differentiate between formats?!
     394                 :          0 :             InitDocShell();         // set aDocShellRef
     395                 :            : 
     396                 :          0 :             SfxObjectShell* pEmbObj = aDocShellRef;
     397                 :          0 :             bOK = SetObject( pEmbObj, SCTRANS_TYPE_EMBOBJ, rFlavor );
     398                 :            :         }
     399                 :            :     }
     400                 :          0 :     return bOK;
     401                 :            : }
     402                 :            : 
     403                 :          0 : sal_Bool ScTransferObj::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId,
     404                 :            :                                         const datatransfer::DataFlavor& rFlavor )
     405                 :            : {
     406                 :            :     // called from SetObject, put data into stream
     407                 :            : 
     408                 :          0 :     bool bRet = false;
     409   [ #  #  #  # ]:          0 :     switch (nUserObjectId)
     410                 :            :     {
     411                 :            :         case SCTRANS_TYPE_IMPEX:
     412                 :            :             {
     413                 :          0 :                 ScImportExport* pImpEx = (ScImportExport*)pUserObject;
     414                 :            : 
     415                 :          0 :                 sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor );
     416                 :            :                 // mba: no BaseURL for data exchange
     417 [ #  # ][ #  # ]:          0 :                 if ( pImpEx->ExportStream( *rxOStm, String(), nFormat ) )
     418                 :          0 :                     bRet = ( rxOStm->GetError() == ERRCODE_NONE );
     419                 :            :             }
     420                 :          0 :             break;
     421                 :            : 
     422                 :            :         case SCTRANS_TYPE_EDIT_RTF:
     423                 :            :         case SCTRANS_TYPE_EDIT_BIN:
     424                 :            :             {
     425                 :          0 :                 ScTabEditEngine* pEngine = (ScTabEditEngine*)pUserObject;
     426         [ #  # ]:          0 :                 if ( nUserObjectId == SCTRANS_TYPE_EDIT_RTF )
     427                 :            :                 {
     428                 :          0 :                     pEngine->Write( *rxOStm, EE_FORMAT_RTF );
     429                 :          0 :                     bRet = ( rxOStm->GetError() == ERRCODE_NONE );
     430                 :            :                 }
     431                 :            :                 else
     432                 :            :                 {
     433                 :            :                     //  can't use Write for EditEngine format because that would
     434                 :            :                     //  write old format without support for unicode characters.
     435                 :            :                     //  Get the data from the EditEngine's transferable instead.
     436                 :            : 
     437         [ #  # ]:          0 :                     sal_uInt16 nParCnt = pEngine->GetParagraphCount();
     438         [ #  # ]:          0 :                     if ( nParCnt == 0 )
     439                 :          0 :                         nParCnt = 1;
     440         [ #  # ]:          0 :                     ESelection aSel( 0, 0, nParCnt-1, pEngine->GetTextLen(nParCnt-1) );
     441                 :            : 
     442         [ #  # ]:          0 :                     uno::Reference<datatransfer::XTransferable> xEditTrans = pEngine->CreateTransferable( aSel );
     443         [ #  # ]:          0 :                     TransferableDataHelper aEditHelper( xEditTrans );
     444                 :            : 
     445 [ #  # ][ #  # ]:          0 :                     bRet = aEditHelper.GetSotStorageStream( rFlavor, rxOStm );
     446                 :            :                 }
     447                 :            :             }
     448                 :          0 :             break;
     449                 :            : 
     450                 :            :         case SCTRANS_TYPE_EMBOBJ:
     451                 :            :             {
     452                 :            :                 // TODO/MBA: testing
     453                 :          0 :                 SfxObjectShell*   pEmbObj = (SfxObjectShell*) pUserObject;
     454         [ #  # ]:          0 :                 ::utl::TempFile     aTempFile;
     455                 :          0 :                 aTempFile.EnableKillingFile();
     456                 :            :                 uno::Reference< embed::XStorage > xWorkStore =
     457 [ #  # ][ #  # ]:          0 :                     ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE );
         [ #  # ][ #  # ]
     458                 :            : 
     459                 :            :                 // write document storage
     460         [ #  # ]:          0 :                 pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, false );
     461                 :            : 
     462                 :            :                 // mba: no relative ULRs for clipboard!
     463 [ #  # ][ #  # ]:          0 :                 SfxMedium aMedium( xWorkStore, String() );
                 [ #  # ]
     464         [ #  # ]:          0 :                 bRet = pEmbObj->DoSaveObjectAs( aMedium, false );
     465         [ #  # ]:          0 :                 pEmbObj->DoSaveCompleted();
     466                 :            : 
     467         [ #  # ]:          0 :                 uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
     468         [ #  # ]:          0 :                 if ( xTransact.is() )
     469 [ #  # ][ #  # ]:          0 :                     xTransact->commit();
     470                 :            : 
     471 [ #  # ][ #  # ]:          0 :                 SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), STREAM_READ );
                 [ #  # ]
     472         [ #  # ]:          0 :                 if( pSrcStm )
     473                 :            :                 {
     474         [ #  # ]:          0 :                     rxOStm->SetBufferSize( 0xff00 );
     475         [ #  # ]:          0 :                     *rxOStm << *pSrcStm;
     476 [ #  # ][ #  # ]:          0 :                     delete pSrcStm;
     477                 :            :                 }
     478                 :            : 
     479                 :          0 :                 bRet = true;
     480                 :            : 
     481 [ #  # ][ #  # ]:          0 :                 xWorkStore->dispose();
     482         [ #  # ]:          0 :                 xWorkStore = uno::Reference < embed::XStorage >();
     483 [ #  # ][ #  # ]:          0 :                 rxOStm->Commit();
                 [ #  # ]
     484                 :            :             }
     485                 :          0 :             break;
     486                 :            : 
     487                 :            :         default:
     488                 :            :             OSL_FAIL("unknown object id");
     489                 :            :     }
     490                 :          0 :     return bRet;
     491                 :            : }
     492                 :            : 
     493                 :          0 : void ScTransferObj::ObjectReleased()
     494                 :            : {
     495                 :          0 :     ScModule* pScMod = SC_MOD();
     496         [ #  # ]:          0 :     if ( pScMod->GetClipData().pCellClipboard == this )
     497                 :          0 :         pScMod->SetClipObject( NULL, NULL );
     498                 :            : 
     499                 :          0 :     TransferableHelper::ObjectReleased();
     500                 :          0 : }
     501                 :            : 
     502                 :          0 : void ScTransferObj::DragFinished( sal_Int8 nDropAction )
     503                 :            : {
     504 [ #  # ][ #  # ]:          0 :     if ( nDropAction == DND_ACTION_MOVE && !bDragWasInternal && !(nDragSourceFlags & SC_DROP_NAVIGATOR) )
                 [ #  # ]
     505                 :            :     {
     506                 :            :         //  move: delete source data
     507                 :          0 :         ScDocShell* pSourceSh = GetSourceDocShell();
     508         [ #  # ]:          0 :         if (pSourceSh)
     509                 :            :         {
     510         [ #  # ]:          0 :             ScMarkData aMarkData = GetSourceMarkData();
     511                 :            :             //  external drag&drop doesn't copy objects, so they also aren't deleted:
     512                 :            :             //  bApi=TRUE, don't show error messages from drag&drop
     513 [ #  # ][ #  # ]:          0 :             pSourceSh->GetDocFunc().DeleteContents( aMarkData, IDF_ALL & ~IDF_OBJECTS, true, true );
     514                 :            :         }
     515                 :            :     }
     516                 :            : 
     517                 :          0 :     ScModule* pScMod = SC_MOD();
     518         [ #  # ]:          0 :     if ( pScMod->GetDragData().pCellTransfer == this )
     519                 :          0 :         pScMod->ResetDragObject();
     520                 :            : 
     521                 :          0 :     xDragSourceRanges = NULL;       // don't keep source after dropping
     522                 :            : 
     523                 :          0 :     TransferableHelper::DragFinished( nDropAction );
     524                 :          0 : }
     525                 :            : 
     526                 :          0 : void ScTransferObj::SetDragHandlePos( SCCOL nX, SCROW nY )
     527                 :            : {
     528                 :          0 :     nDragHandleX = nX;
     529                 :          0 :     nDragHandleY = nY;
     530                 :          0 : }
     531                 :            : 
     532                 :          0 : void ScTransferObj::SetVisibleTab( SCTAB nNew )
     533                 :            : {
     534                 :          0 :     nVisibleTab = nNew;
     535                 :          0 : }
     536                 :            : 
     537                 :          0 : void ScTransferObj::SetDrawPersist( const SfxObjectShellRef& rRef )
     538                 :            : {
     539                 :          0 :     aDrawPersistRef = rRef;
     540                 :          0 : }
     541                 :            : 
     542                 :          0 : void ScTransferObj::SetDragSource( ScDocShell* pSourceShell, const ScMarkData& rMark )
     543                 :            : {
     544         [ #  # ]:          0 :     ScRangeList aRanges;
     545         [ #  # ]:          0 :     rMark.FillRangeListWithMarks( &aRanges, false );
     546 [ #  # ][ #  # ]:          0 :     xDragSourceRanges = new ScCellRangesObj( pSourceShell, aRanges );
         [ #  # ][ #  # ]
     547                 :          0 : }
     548                 :            : 
     549                 :          0 : void ScTransferObj::SetDragSourceFlags( sal_uInt16 nFlags )
     550                 :            : {
     551                 :          0 :     nDragSourceFlags = nFlags;
     552                 :          0 : }
     553                 :            : 
     554                 :          0 : void ScTransferObj::SetDragWasInternal()
     555                 :            : {
     556                 :          0 :     bDragWasInternal = true;
     557                 :          0 : }
     558                 :            : 
     559                 :          0 : void ScTransferObj::SetUseInApi( bool bSet )
     560                 :            : {
     561                 :          0 :     bUseInApi = bSet;
     562                 :          0 : }
     563                 :            : 
     564                 :          0 : ScDocument* ScTransferObj::GetSourceDocument()
     565                 :            : {
     566                 :          0 :     ScDocShell* pSourceDocSh = GetSourceDocShell();
     567         [ #  # ]:          0 :     if (pSourceDocSh)
     568                 :          0 :         return pSourceDocSh->GetDocument();
     569                 :          0 :     return NULL;
     570                 :            : }
     571                 :            : 
     572                 :          0 : ScDocShell* ScTransferObj::GetSourceDocShell()
     573                 :            : {
     574         [ #  # ]:          0 :     ScCellRangesBase* pRangesObj = ScCellRangesBase::getImplementation( xDragSourceRanges );
     575         [ #  # ]:          0 :     if (pRangesObj)
     576                 :          0 :         return pRangesObj->GetDocShell();
     577                 :            : 
     578                 :          0 :     return NULL;    // none set
     579                 :            : }
     580                 :            : 
     581                 :          0 : ScMarkData ScTransferObj::GetSourceMarkData()
     582                 :            : {
     583                 :          0 :     ScMarkData aMarkData;
     584         [ #  # ]:          0 :     ScCellRangesBase* pRangesObj = ScCellRangesBase::getImplementation( xDragSourceRanges );
     585         [ #  # ]:          0 :     if (pRangesObj)
     586                 :            :     {
     587                 :          0 :         const ScRangeList& rRanges = pRangesObj->GetRangeList();
     588         [ #  # ]:          0 :         aMarkData.MarkFromRangeList( rRanges, false );
     589                 :            :     }
     590                 :          0 :     return aMarkData;
     591                 :            : }
     592                 :            : 
     593                 :            : //
     594                 :            : //  initialize aDocShellRef with a live document from the ClipDoc
     595                 :            : //
     596                 :            : 
     597                 :          0 : void ScTransferObj::InitDocShell()
     598                 :            : {
     599         [ #  # ]:          0 :     if ( !aDocShellRef.Is() )
     600                 :            :     {
     601 [ #  # ][ #  # ]:          0 :         ScDocShell* pDocSh = new ScDocShell;
     602         [ #  # ]:          0 :         aDocShellRef = pDocSh;      // ref must be there before InitNew
     603                 :            : 
     604         [ #  # ]:          0 :         pDocSh->DoInitNew(NULL);
     605                 :            : 
     606                 :          0 :         ScDocument* pDestDoc = pDocSh->GetDocument();
     607         [ #  # ]:          0 :         ScMarkData aDestMark;
     608         [ #  # ]:          0 :         aDestMark.SelectTable( 0, true );
     609                 :            : 
     610 [ #  # ][ #  # ]:          0 :         pDestDoc->SetDocOptions( pDoc->GetDocOptions() );   // #i42666#
     611                 :            : 
     612                 :          0 :         rtl::OUString aTabName;
     613         [ #  # ]:          0 :         pDoc->GetName( aBlock.aStart.Tab(), aTabName );
     614         [ #  # ]:          0 :         pDestDoc->RenameTab( 0, aTabName, false );          // no UpdateRef (empty)
     615                 :            : 
     616         [ #  # ]:          0 :         pDestDoc->CopyStdStylesFrom( pDoc );
     617                 :            : 
     618                 :          0 :         SCCOL nStartX = aBlock.aStart.Col();
     619                 :          0 :         SCROW nStartY = aBlock.aStart.Row();
     620                 :          0 :         SCCOL nEndX = aBlock.aEnd.Col();
     621                 :          0 :         SCROW nEndY = aBlock.aEnd.Row();
     622                 :            : 
     623                 :            :         //  widths / heights
     624                 :            :         //  (must be copied before CopyFromClip, for drawing objects)
     625                 :            : 
     626                 :            :         SCCOL nCol;
     627                 :          0 :         SCTAB nSrcTab = aBlock.aStart.Tab();
     628 [ #  # ][ #  # ]:          0 :         pDestDoc->SetLayoutRTL(0, pDoc->IsLayoutRTL(nSrcTab));
     629         [ #  # ]:          0 :         for (nCol=nStartX; nCol<=nEndX; nCol++)
     630 [ #  # ][ #  # ]:          0 :             if ( pDoc->ColHidden(nCol, nSrcTab) )
     631         [ #  # ]:          0 :                 pDestDoc->ShowCol( nCol, 0, false );
     632                 :            :             else
     633 [ #  # ][ #  # ]:          0 :                 pDestDoc->SetColWidth( nCol, 0, pDoc->GetColWidth( nCol, nSrcTab ) );
     634                 :            : 
     635         [ #  # ]:          0 :         for (SCROW nRow = nStartY; nRow <= nEndY; ++nRow)
     636                 :            :         {
     637 [ #  # ][ #  # ]:          0 :             if ( pDoc->RowHidden(nRow, nSrcTab) )
     638         [ #  # ]:          0 :                 pDestDoc->ShowRow( nRow, 0, false );
     639                 :            :             else
     640                 :            :             {
     641 [ #  # ][ #  # ]:          0 :                 pDestDoc->SetRowHeight( nRow, 0, pDoc->GetOriginalHeight( nRow, nSrcTab ) );
     642                 :            : 
     643                 :            :                 //  if height was set manually, that flag has to be copied, too
     644         [ #  # ]:          0 :                 bool bManual = pDoc->IsManualRowHeight(nRow, nSrcTab);
     645         [ #  # ]:          0 :                 pDestDoc->SetManualHeight(nRow, nRow, 0, bManual);
     646                 :            :             }
     647                 :            :         }
     648                 :            : 
     649 [ #  # ][ #  # ]:          0 :         if ( pDoc->GetDrawLayer() )
     650         [ #  # ]:          0 :             pDocSh->MakeDrawLayer();
     651                 :            : 
     652                 :            :         //  cell range is copied to the original position, but on the first sheet
     653                 :            :         //  -> bCutMode must be set
     654                 :            :         //  pDoc is always a Clipboard-document
     655                 :            : 
     656                 :          0 :         ScRange aDestRange( nStartX,nStartY,0, nEndX,nEndY,0 );
     657         [ #  # ]:          0 :         bool bWasCut = pDoc->IsCutMode();
     658         [ #  # ]:          0 :         if (!bWasCut)
     659         [ #  # ]:          0 :             pDoc->SetClipArea( aDestRange, true );          // Cut
     660         [ #  # ]:          0 :         pDestDoc->CopyFromClip( aDestRange, aDestMark, IDF_ALL, NULL, pDoc, false );
     661         [ #  # ]:          0 :         pDoc->SetClipArea( aDestRange, bWasCut );
     662                 :            : 
     663         [ #  # ]:          0 :         StripRefs( pDoc, nStartX,nStartY, nEndX,nEndY, pDestDoc, 0,0 );
     664                 :            : 
     665                 :          0 :         ScRange aMergeRange = aDestRange;
     666         [ #  # ]:          0 :         pDestDoc->ExtendMerge( aMergeRange, true );
     667                 :            : 
     668         [ #  # ]:          0 :         pDoc->CopyDdeLinks( pDestDoc );         // copy values of DDE Links
     669                 :            : 
     670                 :            :         //  page format (grid etc) and page size (maximum size for ole object)
     671                 :            : 
     672         [ #  # ]:          0 :         Size aPaperSize = SvxPaperInfo::GetPaperSize( PAPER_A4 );       // Twips
     673         [ #  # ]:          0 :         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
     674 [ #  # ][ #  # ]:          0 :         String aStyleName = pDoc->GetPageStyle( aBlock.aStart.Tab() );
     675         [ #  # ]:          0 :         SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SFX_STYLE_FAMILY_PAGE );
     676         [ #  # ]:          0 :         if (pStyleSheet)
     677                 :            :         {
     678         [ #  # ]:          0 :             const SfxItemSet& rSourceSet = pStyleSheet->GetItemSet();
     679         [ #  # ]:          0 :             aPaperSize = ((const SvxSizeItem&) rSourceSet.Get(ATTR_PAGE_SIZE)).GetSize();
     680                 :            : 
     681                 :            :             //  CopyStyleFrom kopiert SetItems mit richtigem Pool
     682         [ #  # ]:          0 :             ScStyleSheetPool* pDestPool = pDestDoc->GetStyleSheetPool();
     683         [ #  # ]:          0 :             pDestPool->CopyStyleFrom( pStylePool, aStyleName, SFX_STYLE_FAMILY_PAGE );
     684                 :            :         }
     685                 :            : 
     686         [ #  # ]:          0 :         ScViewData aViewData( pDocSh, NULL );
     687         [ #  # ]:          0 :         aViewData.SetScreen( nStartX,nStartY, nEndX,nEndY );
     688                 :          0 :         aViewData.SetCurX( nStartX );
     689                 :          0 :         aViewData.SetCurY( nStartY );
     690                 :            : 
     691 [ #  # ][ #  # ]:          0 :         pDestDoc->SetViewOptions( pDoc->GetViewOptions() );
     692                 :            : 
     693                 :            :         //      Size
     694                 :            :         //! get while copying sizes
     695                 :            : 
     696                 :          0 :         long nPosX = 0;
     697                 :          0 :         long nPosY = 0;
     698                 :            : 
     699         [ #  # ]:          0 :         for (nCol=0; nCol<nStartX; nCol++)
     700         [ #  # ]:          0 :             nPosX += pDestDoc->GetColWidth( nCol, 0 );
     701         [ #  # ]:          0 :         nPosY += pDestDoc->GetRowHeight( 0, nStartY-1, 0 );
     702                 :          0 :         nPosX = (long) ( nPosX * HMM_PER_TWIPS );
     703                 :          0 :         nPosY = (long) ( nPosY * HMM_PER_TWIPS );
     704                 :            : 
     705                 :            : 
     706                 :          0 :         aPaperSize.Width()  *= 2;       // limit OLE object to double of page size
     707                 :          0 :         aPaperSize.Height() *= 2;
     708                 :            : 
     709                 :          0 :         long nSizeX = 0;
     710                 :          0 :         long nSizeY = 0;
     711         [ #  # ]:          0 :         for (nCol=nStartX; nCol<=nEndX; nCol++)
     712                 :            :         {
     713         [ #  # ]:          0 :             long nAdd = pDestDoc->GetColWidth( nCol, 0 );
     714 [ #  # ][ #  # ]:          0 :             if ( nSizeX+nAdd > aPaperSize.Width() && nSizeX )   // above limit?
                 [ #  # ]
     715                 :          0 :                 break;
     716                 :          0 :             nSizeX += nAdd;
     717                 :            :         }
     718         [ #  # ]:          0 :         for (SCROW nRow=nStartY; nRow<=nEndY; nRow++)
     719                 :            :         {
     720         [ #  # ]:          0 :             long nAdd = pDestDoc->GetRowHeight( nRow, 0 );
     721 [ #  # ][ #  # ]:          0 :             if ( nSizeY+nAdd > aPaperSize.Height() && nSizeY )  // above limit?
                 [ #  # ]
     722                 :          0 :                 break;
     723                 :          0 :             nSizeY += nAdd;
     724                 :            :         }
     725                 :          0 :         nSizeX = (long) ( nSizeX * HMM_PER_TWIPS );
     726                 :          0 :         nSizeY = (long) ( nSizeY * HMM_PER_TWIPS );
     727                 :            : 
     728                 :            : //      pDocSh->SetVisAreaSize( Size(nSizeX,nSizeY) );
     729                 :            : 
     730         [ #  # ]:          0 :         Rectangle aNewArea( Point(nPosX,nPosY), Size(nSizeX,nSizeY) );
     731                 :            :         //TODO/LATER: why twice?!
     732                 :            :         //pDocSh->SvInPlaceObject::SetVisArea( aNewArea );
     733         [ #  # ]:          0 :         pDocSh->SetVisArea( aNewArea );
     734                 :            : 
     735         [ #  # ]:          0 :         pDocSh->UpdateOle(&aViewData, true);
     736                 :            : 
     737                 :            :         //! SetDocumentModified?
     738         [ #  # ]:          0 :         if ( pDestDoc->IsChartListenerCollectionNeedsUpdate() )
     739 [ #  # ][ #  # ]:          0 :             pDestDoc->UpdateChartListenerCollection();
         [ #  # ][ #  # ]
     740                 :            :     }
     741                 :          0 : }
     742                 :            : 
     743                 :          0 : SfxObjectShell* ScTransferObj::SetDrawClipDoc( sal_Bool bAnyOle )
     744                 :            : {
     745                 :            :     // update ScGlobal::pDrawClipDocShellRef
     746                 :            : 
     747         [ #  # ]:          0 :     delete ScGlobal::pDrawClipDocShellRef;
     748         [ #  # ]:          0 :     if (bAnyOle)
     749                 :            :     {
     750                 :            :         ScGlobal::pDrawClipDocShellRef =
     751         [ #  # ]:          0 :                         new ScDocShellRef(new ScDocShell(SFX_CREATE_MODE_INTERNAL));      // there must be a ref
     752                 :          0 :         (*ScGlobal::pDrawClipDocShellRef)->DoInitNew(NULL);
     753                 :          0 :         return *ScGlobal::pDrawClipDocShellRef;
     754                 :            :     }
     755                 :            :     else
     756                 :            :     {
     757                 :          0 :         ScGlobal::pDrawClipDocShellRef = NULL;
     758                 :          0 :         return NULL;
     759                 :            :     }
     760                 :            : }
     761                 :            : 
     762                 :          0 : void ScTransferObj::StripRefs( ScDocument* pDoc,
     763                 :            :                     SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY,
     764                 :            :                     ScDocument* pDestDoc, SCCOL nSubX, SCROW nSubY )
     765                 :            : {
     766         [ #  # ]:          0 :     if (!pDestDoc)
     767                 :            :     {
     768                 :          0 :         pDestDoc = pDoc;
     769                 :            :         OSL_ENSURE(nSubX==0&&nSubY==0, "can't move within the document");
     770                 :            :     }
     771                 :            : 
     772                 :            :     //  In a clipboard doc the data don't have to be on the first sheet
     773                 :            : 
     774                 :          0 :     SCTAB nSrcTab = 0;
     775 [ #  # ][ #  # ]:          0 :     while (nSrcTab<pDoc->GetTableCount() && !pDoc->HasTable(nSrcTab))
         [ #  # ][ #  # ]
                 [ #  # ]
     776                 :          0 :         ++nSrcTab;
     777                 :          0 :     SCTAB nDestTab = 0;
     778 [ #  # ][ #  # ]:          0 :     while (nDestTab<pDestDoc->GetTableCount() && !pDestDoc->HasTable(nDestTab))
         [ #  # ][ #  # ]
                 [ #  # ]
     779                 :          0 :         ++nDestTab;
     780                 :            : 
     781 [ #  # ][ #  # ]:          0 :     if (!pDoc->HasTable(nSrcTab) || !pDestDoc->HasTable(nDestTab))
         [ #  # ][ #  # ]
                 [ #  # ]
     782                 :            :     {
     783                 :            :         OSL_FAIL("Sheet not found in ScTransferObj::StripRefs");
     784                 :          0 :         return;
     785                 :            :     }
     786                 :            : 
     787         [ #  # ]:          0 :     SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
     788                 :          0 :     ScRange aRef;
     789                 :            : 
     790         [ #  # ]:          0 :     ScCellIterator aIter( pDoc, nStartX, nStartY, nSrcTab, nEndX, nEndY, nSrcTab );
     791         [ #  # ]:          0 :     ScBaseCell* pCell = aIter.GetFirst();
     792         [ #  # ]:          0 :     while (pCell)
     793                 :            :     {
     794         [ #  # ]:          0 :         if (pCell->GetCellType() == CELLTYPE_FORMULA)
     795                 :            :         {
     796         [ #  # ]:          0 :             ScFormulaCell* pFCell = (ScFormulaCell*) pCell;
     797                 :          0 :             bool bOut = false;
     798         [ #  # ]:          0 :             ScDetectiveRefIter aRefIter( pFCell );
     799 [ #  # ][ #  # ]:          0 :             while ( !bOut && aRefIter.GetNextRef( aRef ) )
         [ #  # ][ #  # ]
     800                 :            :             {
     801 [ #  # ][ #  #  :          0 :                 if ( aRef.aStart.Tab() != nSrcTab || aRef.aEnd.Tab() != nSrcTab ||
          #  #  #  #  #  
                #  #  # ]
                 [ #  # ]
     802                 :          0 :                         aRef.aStart.Col() < nStartX || aRef.aEnd.Col() > nEndX ||
     803                 :          0 :                         aRef.aStart.Row() < nStartY || aRef.aEnd.Row() > nEndY )
     804                 :          0 :                     bOut = true;
     805                 :            :             }
     806         [ #  # ]:          0 :             if (bOut)
     807                 :            :             {
     808                 :          0 :                 SCCOL nCol = aIter.GetCol() - nSubX;
     809                 :          0 :                 SCROW nRow = aIter.GetRow() - nSubY;
     810                 :            : 
     811                 :          0 :                 ScBaseCell* pNew = 0;
     812         [ #  # ]:          0 :                 sal_uInt16 nErrCode = pFCell->GetErrCode();
     813         [ #  # ]:          0 :                 if (nErrCode)
     814                 :            :                 {
     815 [ #  # ][ #  # ]:          0 :                     pNew = new ScStringCell( ScGlobal::GetErrorString(nErrCode) );
         [ #  # ][ #  # ]
                 [ #  # ]
     816         [ #  # ]:          0 :                     if ( ((const SvxHorJustifyItem*) pDestDoc->GetAttr(
     817         [ #  # ]:          0 :                             nCol,nRow,nDestTab, ATTR_HOR_JUSTIFY))->GetValue() ==
     818                 :            :                             SVX_HOR_JUSTIFY_STANDARD )
     819                 :            :                         pDestDoc->ApplyAttr( nCol,nRow,nDestTab,
     820 [ #  # ][ #  # ]:          0 :                                 SvxHorJustifyItem(SVX_HOR_JUSTIFY_RIGHT, ATTR_HOR_JUSTIFY) );
                 [ #  # ]
     821                 :            :                 }
     822 [ #  # ][ #  # ]:          0 :                 else if (pFCell->IsValue())
     823                 :            :                 {
     824         [ #  # ]:          0 :                     double fVal = pFCell->GetValue();
     825 [ #  # ][ #  # ]:          0 :                     pNew = new ScValueCell( fVal );
     826                 :            :                 }
     827                 :            :                 else
     828                 :            :                 {
     829 [ #  # ][ #  # ]:          0 :                     String aStr = pFCell->GetString();
     830 [ #  # ][ #  # ]:          0 :                     if ( pFCell->IsMultilineResult() )
     831 [ #  # ][ #  # ]:          0 :                         pNew = new ScEditCell( aStr, pDestDoc );
                 [ #  # ]
     832                 :            :                     else
     833 [ #  # ][ #  # ]:          0 :                         pNew = new ScStringCell( aStr );
         [ #  # ][ #  # ]
     834                 :            :                 }
     835         [ #  # ]:          0 :                 pDestDoc->PutCell( nCol,nRow,nDestTab, pNew );
     836                 :            : 
     837                 :            :                 //  number formats
     838                 :            : 
     839                 :            :                 sal_uLong nOldFormat = ((const SfxUInt32Item*)
     840         [ #  # ]:          0 :                                 pDestDoc->GetAttr(nCol,nRow,nDestTab, ATTR_VALUE_FORMAT))->GetValue();
     841         [ #  # ]:          0 :                 if ( (nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
     842                 :            :                 {
     843                 :            :                     sal_uLong nNewFormat = pFCell->GetStandardFormat( *pFormatter,
     844         [ #  # ]:          0 :                         nOldFormat );
     845                 :            :                     pDestDoc->ApplyAttr( nCol,nRow,nDestTab,
     846 [ #  # ][ #  # ]:          0 :                                 SfxUInt32Item(ATTR_VALUE_FORMAT, nNewFormat) );
                 [ #  # ]
     847                 :            :                 }
     848                 :            :             }
     849                 :            :         }
     850         [ #  # ]:          0 :         pCell = aIter.GetNext();
     851                 :            :     }
     852                 :            : }
     853                 :            : 
     854                 :            : namespace
     855                 :            : {
     856                 :            :     class theScTransferUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScTransferUnoTunnelId> {};
     857                 :            : }
     858                 :            : 
     859                 :          0 : const com::sun::star::uno::Sequence< sal_Int8 >& ScTransferObj::getUnoTunnelId()
     860                 :            : {
     861                 :          0 :     return theScTransferUnoTunnelId::get().getSeq();
     862                 :            : }
     863                 :            : 
     864                 :          0 : sal_Int64 SAL_CALL ScTransferObj::getSomething( const com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( com::sun::star::uno::RuntimeException )
     865                 :            : {
     866                 :            :     sal_Int64 nRet;
     867   [ #  #  #  # ]:          0 :     if( ( rId.getLength() == 16 ) &&
                 [ #  # ]
     868                 :          0 :         ( 0 == memcmp( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
     869                 :            :     {
     870                 :          0 :         nRet = reinterpret_cast< sal_Int64 >( this );
     871                 :            :     }
     872                 :            :     else
     873                 :          0 :         nRet = TransferableHelper::getSomething(rId);
     874                 :          0 :     return nRet;
     875                 :            : }
     876                 :            : 
     877                 :            : 
     878                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10