LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/view - cliputil.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 45 2.2 %
Date: 2013-07-09 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  */
      12             : 
      13             : #include "cliputil.hxx"
      14             : #include "viewdata.hxx"
      15             : #include "tabvwsh.hxx"
      16             : #include "transobj.hxx"
      17             : #include "document.hxx"
      18             : #include "dpobject.hxx"
      19             : #include "globstr.hrc"
      20             : #include "clipparam.hxx"
      21             : #include "rangelst.hxx"
      22             : #include "viewutil.hxx"
      23             : #include "markdata.hxx"
      24             : 
      25             : #include "vcl/waitobj.hxx"
      26             : 
      27           0 : void ScClipUtil::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog )
      28             : {
      29           0 :     Window* pWin = pViewData->GetActiveWin();
      30           0 :     ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
      31           0 :     ScDocument* pThisDoc = pViewData->GetDocument();
      32           0 :     ScDPObject* pDPObj = pThisDoc->GetDPAtCursor( pViewData->GetCurX(),
      33           0 :                          pViewData->GetCurY(), pViewData->GetTabNo() );
      34           0 :     if ( pOwnClip && pDPObj )
      35             :     {
      36             :         // paste from Calc into DataPilot table: sort (similar to drag & drop)
      37             : 
      38           0 :         ScDocument* pClipDoc = pOwnClip->GetDocument();
      39           0 :         SCTAB nSourceTab = pOwnClip->GetVisibleTab();
      40             : 
      41             :         SCCOL nClipStartX;
      42             :         SCROW nClipStartY;
      43             :         SCCOL nClipEndX;
      44             :         SCROW nClipEndY;
      45           0 :         pClipDoc->GetClipStart( nClipStartX, nClipStartY );
      46           0 :         pClipDoc->GetClipArea( nClipEndX, nClipEndY, sal_True );
      47           0 :         nClipEndX = nClipEndX + nClipStartX;
      48           0 :         nClipEndY = nClipEndY + nClipStartY;   // GetClipArea returns the difference
      49             : 
      50           0 :         ScRange aSource( nClipStartX, nClipStartY, nSourceTab, nClipEndX, nClipEndY, nSourceTab );
      51           0 :         sal_Bool bDone = pTabViewShell->DataPilotMove( aSource, pViewData->GetCurPos() );
      52           0 :         if ( !bDone )
      53           0 :             pTabViewShell->ErrorMessage( STR_ERR_DATAPILOT_INPUT );
      54             :     }
      55             :     else
      56             :     {
      57             :         // normal paste
      58           0 :         WaitObject aWait( pViewData->GetDialogParent() );
      59           0 :         if (!pOwnClip)
      60           0 :             pTabViewShell->PasteFromSystem();
      61             :         else
      62             :         {
      63           0 :             ScDocument* pClipDoc = pOwnClip->GetDocument();
      64           0 :             sal_uInt16 nFlags = IDF_ALL;
      65           0 :             if (pClipDoc->GetClipParam().isMultiRange())
      66             :                 // For multi-range paste, we paste values by default.
      67           0 :                 nFlags &= ~IDF_FORMULA;
      68             : 
      69             :             pTabViewShell->PasteFromClip( nFlags, pClipDoc,
      70             :                     PASTE_NOFUNC, false, false, false, INS_NONE, IDF_NONE,
      71           0 :                     bShowDialog );      // allow warning dialog
      72           0 :         }
      73             :     }
      74           0 :     pTabViewShell->CellContentChanged();        // => PasteFromSystem() ???
      75           0 : }
      76             : 
      77           0 : bool ScClipUtil::CheckDestRanges(
      78             :     ScDocument* pDoc, SCCOL nSrcCols, SCROW nSrcRows, const ScMarkData& rMark, const ScRangeList& rDest)
      79             : {
      80           0 :     for (size_t i = 0, n = rDest.size(); i < n; ++i)
      81             :     {
      82           0 :         ScRange aTest = *rDest[i];
      83             :         // Check for filtered rows in all selected sheets.
      84           0 :         ScMarkData::const_iterator itrTab = rMark.begin(), itrTabEnd = rMark.end();
      85           0 :         for (; itrTab != itrTabEnd; ++itrTab)
      86             :         {
      87           0 :             aTest.aStart.SetTab(*itrTab);
      88           0 :             aTest.aEnd.SetTab(*itrTab);
      89           0 :             if (ScViewUtil::HasFiltered(aTest, pDoc))
      90             :             {
      91             :                 // I don't know how to handle pasting into filtered rows yet.
      92           0 :                 return false;
      93             :             }
      94             :         }
      95             : 
      96             :         // Destination range must be an exact multiple of the source range.
      97           0 :         SCROW nRows = aTest.aEnd.Row() - aTest.aStart.Row() + 1;
      98           0 :         SCCOL nCols = aTest.aEnd.Col() - aTest.aStart.Col() + 1;
      99           0 :         SCROW nRowTest = (nRows / nSrcRows) * nSrcRows;
     100           0 :         SCCOL nColTest = (nCols / nSrcCols) * nSrcCols;
     101           0 :         if ( rDest.size() > 1 && ( nRows != nRowTest || nCols != nColTest ) )
     102             :         {
     103             :             // Destination range is not a multiple of the source range. Bail out.
     104           0 :             return false;
     105             :         }
     106             :     }
     107           0 :     return true;
     108          93 : }
     109             : 
     110             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10