LCOV - code coverage report
Current view: top level - sc/source/ui/view - cliputil.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 45 2.2 %
Date: 2014-11-03 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             : 
      10             : #include "cliputil.hxx"
      11             : #include "viewdata.hxx"
      12             : #include "tabvwsh.hxx"
      13             : #include "transobj.hxx"
      14             : #include "document.hxx"
      15             : #include "dpobject.hxx"
      16             : #include "globstr.hrc"
      17             : #include "clipparam.hxx"
      18             : #include "rangelst.hxx"
      19             : #include "viewutil.hxx"
      20             : #include "markdata.hxx"
      21             : #include <gridwin.hxx>
      22             : 
      23             : #include <vcl/waitobj.hxx>
      24             : 
      25           0 : void ScClipUtil::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog )
      26             : {
      27           0 :     vcl::Window* pWin = pViewData->GetActiveWin();
      28           0 :     ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
      29           0 :     ScDocument* pThisDoc = pViewData->GetDocument();
      30           0 :     ScDPObject* pDPObj = pThisDoc->GetDPAtCursor( pViewData->GetCurX(),
      31           0 :                          pViewData->GetCurY(), pViewData->GetTabNo() );
      32           0 :     if ( pOwnClip && pDPObj )
      33             :     {
      34             :         // paste from Calc into DataPilot table: sort (similar to drag & drop)
      35             : 
      36           0 :         ScDocument* pClipDoc = pOwnClip->GetDocument();
      37           0 :         SCTAB nSourceTab = pOwnClip->GetVisibleTab();
      38             : 
      39             :         SCCOL nClipStartX;
      40             :         SCROW nClipStartY;
      41             :         SCCOL nClipEndX;
      42             :         SCROW nClipEndY;
      43           0 :         pClipDoc->GetClipStart( nClipStartX, nClipStartY );
      44           0 :         pClipDoc->GetClipArea( nClipEndX, nClipEndY, true );
      45           0 :         nClipEndX = nClipEndX + nClipStartX;
      46           0 :         nClipEndY = nClipEndY + nClipStartY;   // GetClipArea returns the difference
      47             : 
      48           0 :         ScRange aSource( nClipStartX, nClipStartY, nSourceTab, nClipEndX, nClipEndY, nSourceTab );
      49           0 :         bool bDone = pTabViewShell->DataPilotMove( aSource, pViewData->GetCurPos() );
      50           0 :         if ( !bDone )
      51           0 :             pTabViewShell->ErrorMessage( STR_ERR_DATAPILOT_INPUT );
      52             :     }
      53             :     else
      54             :     {
      55             :         // normal paste
      56           0 :         WaitObject aWait( pViewData->GetDialogParent() );
      57           0 :         if (!pOwnClip)
      58           0 :             pTabViewShell->PasteFromSystem();
      59             :         else
      60             :         {
      61           0 :             ScDocument* pClipDoc = pOwnClip->GetDocument();
      62           0 :             InsertDeleteFlags nFlags = IDF_ALL;
      63           0 :             if (pClipDoc->GetClipParam().isMultiRange())
      64             :                 // For multi-range paste, we paste values by default.
      65           0 :                 nFlags &= ~IDF_FORMULA;
      66             : 
      67             :             pTabViewShell->PasteFromClip( nFlags, pClipDoc,
      68             :                     PASTE_NOFUNC, false, false, false, INS_NONE, IDF_NONE,
      69           0 :                     bShowDialog );      // allow warning dialog
      70           0 :         }
      71             :     }
      72           0 :     pTabViewShell->CellContentChanged();        // => PasteFromSystem() ???
      73           0 : }
      74             : 
      75           0 : bool ScClipUtil::CheckDestRanges(
      76             :     ScDocument* pDoc, SCCOL nSrcCols, SCROW nSrcRows, const ScMarkData& rMark, const ScRangeList& rDest)
      77             : {
      78           0 :     for (size_t i = 0, n = rDest.size(); i < n; ++i)
      79             :     {
      80           0 :         ScRange aTest = *rDest[i];
      81             :         // Check for filtered rows in all selected sheets.
      82           0 :         ScMarkData::const_iterator itrTab = rMark.begin(), itrTabEnd = rMark.end();
      83           0 :         for (; itrTab != itrTabEnd; ++itrTab)
      84             :         {
      85           0 :             aTest.aStart.SetTab(*itrTab);
      86           0 :             aTest.aEnd.SetTab(*itrTab);
      87           0 :             if (ScViewUtil::HasFiltered(aTest, pDoc))
      88             :             {
      89             :                 // I don't know how to handle pasting into filtered rows yet.
      90           0 :                 return false;
      91             :             }
      92             :         }
      93             : 
      94             :         // Destination range must be an exact multiple of the source range.
      95           0 :         SCROW nRows = aTest.aEnd.Row() - aTest.aStart.Row() + 1;
      96           0 :         SCCOL nCols = aTest.aEnd.Col() - aTest.aStart.Col() + 1;
      97           0 :         SCROW nRowTest = (nRows / nSrcRows) * nSrcRows;
      98           0 :         SCCOL nColTest = (nCols / nSrcCols) * nSrcCols;
      99           0 :         if ( rDest.size() > 1 && ( nRows != nRowTest || nCols != nColTest ) )
     100             :         {
     101             :             // Destination range is not a multiple of the source range. Bail out.
     102           0 :             return false;
     103             :         }
     104             :     }
     105           0 :     return true;
     106         228 : }
     107             : 
     108             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10