LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/view - cliputil.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 45 2.2 %
Date: 2012-12-27 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             :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4             :  *
       5             :  * The contents of this file are subject to the Mozilla Public License Version
       6             :  * 1.1 (the "License"); you may not use this file except in compliance with
       7             :  * the License or as specified alternatively below. You may obtain a copy of
       8             :  * the License at http://www.mozilla.org/MPL/
       9             :  *
      10             :  * Software distributed under the License is distributed on an "AS IS" basis,
      11             :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12             :  * for the specific language governing rights and limitations under the
      13             :  * License.
      14             :  *
      15             :  * Major Contributor(s):
      16             :  *   Copyright (C) 2011 Kohei Yoshida <kohei.yoshida@suse.com>
      17             :  *
      18             :  * All Rights Reserved.
      19             :  *
      20             :  * For minor contributions see the git repository.
      21             :  *
      22             :  * Alternatively, the contents of this file may be used under the terms of
      23             :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      24             :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      25             :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      26             :  * instead of those above.
      27             :  */
      28             : 
      29             : #include "cliputil.hxx"
      30             : #include "viewdata.hxx"
      31             : #include "tabvwsh.hxx"
      32             : #include "transobj.hxx"
      33             : #include "document.hxx"
      34             : #include "dpobject.hxx"
      35             : #include "globstr.hrc"
      36             : #include "clipparam.hxx"
      37             : #include "rangelst.hxx"
      38             : #include "viewutil.hxx"
      39             : #include "markdata.hxx"
      40             : 
      41             : #include "vcl/waitobj.hxx"
      42             : 
      43           0 : void ScClipUtil::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog )
      44             : {
      45           0 :     Window* pWin = pViewData->GetActiveWin();
      46           0 :     ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
      47           0 :     ScDocument* pThisDoc = pViewData->GetDocument();
      48           0 :     ScDPObject* pDPObj = pThisDoc->GetDPAtCursor( pViewData->GetCurX(),
      49           0 :                          pViewData->GetCurY(), pViewData->GetTabNo() );
      50           0 :     if ( pOwnClip && pDPObj )
      51             :     {
      52             :         // paste from Calc into DataPilot table: sort (similar to drag & drop)
      53             : 
      54           0 :         ScDocument* pClipDoc = pOwnClip->GetDocument();
      55           0 :         SCTAB nSourceTab = pOwnClip->GetVisibleTab();
      56             : 
      57             :         SCCOL nClipStartX;
      58             :         SCROW nClipStartY;
      59             :         SCCOL nClipEndX;
      60             :         SCROW nClipEndY;
      61           0 :         pClipDoc->GetClipStart( nClipStartX, nClipStartY );
      62           0 :         pClipDoc->GetClipArea( nClipEndX, nClipEndY, sal_True );
      63           0 :         nClipEndX = nClipEndX + nClipStartX;
      64           0 :         nClipEndY = nClipEndY + nClipStartY;   // GetClipArea returns the difference
      65             : 
      66           0 :         ScRange aSource( nClipStartX, nClipStartY, nSourceTab, nClipEndX, nClipEndY, nSourceTab );
      67           0 :         sal_Bool bDone = pTabViewShell->DataPilotMove( aSource, pViewData->GetCurPos() );
      68           0 :         if ( !bDone )
      69           0 :             pTabViewShell->ErrorMessage( STR_ERR_DATAPILOT_INPUT );
      70             :     }
      71             :     else
      72             :     {
      73             :         // normal paste
      74           0 :         WaitObject aWait( pViewData->GetDialogParent() );
      75           0 :         if (!pOwnClip)
      76           0 :             pTabViewShell->PasteFromSystem();
      77             :         else
      78             :         {
      79           0 :             ScDocument* pClipDoc = pOwnClip->GetDocument();
      80           0 :             sal_uInt16 nFlags = IDF_ALL;
      81           0 :             if (pClipDoc->GetClipParam().isMultiRange())
      82             :                 // For multi-range paste, we paste values by default.
      83           0 :                 nFlags &= ~IDF_FORMULA;
      84             : 
      85             :             pTabViewShell->PasteFromClip( nFlags, pClipDoc,
      86             :                     PASTE_NOFUNC, false, false, false, INS_NONE, IDF_NONE,
      87           0 :                     bShowDialog );      // allow warning dialog
      88           0 :         }
      89             :     }
      90           0 :     pTabViewShell->CellContentChanged();        // => PasteFromSystem() ???
      91           0 : }
      92             : 
      93           0 : bool ScClipUtil::CheckDestRanges(
      94             :     ScDocument* pDoc, SCCOL nSrcCols, SCROW nSrcRows, const ScMarkData& rMark, const ScRangeList& rDest)
      95             : {
      96           0 :     for (size_t i = 0, n = rDest.size(); i < n; ++i)
      97             :     {
      98           0 :         ScRange aTest = *rDest[i];
      99             :         // Check for filtered rows in all selected sheets.
     100           0 :         ScMarkData::const_iterator itrTab = rMark.begin(), itrTabEnd = rMark.end();
     101           0 :         for (; itrTab != itrTabEnd; ++itrTab)
     102             :         {
     103           0 :             aTest.aStart.SetTab(*itrTab);
     104           0 :             aTest.aEnd.SetTab(*itrTab);
     105           0 :             if (ScViewUtil::HasFiltered(aTest, pDoc))
     106             :             {
     107             :                 // I don't know how to handle pasting into filtered rows yet.
     108           0 :                 return false;
     109             :             }
     110             :         }
     111             : 
     112             :         // Destination range must be an exact multiple of the source range.
     113           0 :         SCROW nRows = aTest.aEnd.Row() - aTest.aStart.Row() + 1;
     114           0 :         SCCOL nCols = aTest.aEnd.Col() - aTest.aStart.Col() + 1;
     115           0 :         SCROW nRowTest = (nRows / nSrcRows) * nSrcRows;
     116           0 :         SCCOL nColTest = (nCols / nSrcCols) * nSrcCols;
     117           0 :         if ( rDest.size() > 1 && ( nRows != nRowTest || nCols != nColTest ) )
     118             :         {
     119             :             // Destination range is not a multiple of the source range. Bail out.
     120           0 :             return false;
     121             :         }
     122             :     }
     123           0 :     return true;
     124          15 : }
     125             : 
     126             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10