LCOV - code coverage report
Current view: top level - sc/source/ui/undo - undoblk2.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 68 0.0 %
Date: 2014-04-14 Functions: 0 15 0.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             :  *   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 "scitems.hxx"
      21             : 
      22             : #include "undoblk.hxx"
      23             : #include "document.hxx"
      24             : #include "docsh.hxx"
      25             : #include "tabvwsh.hxx"
      26             : #include "olinetab.hxx"
      27             : #include "globstr.hrc"
      28             : #include "global.hxx"
      29             : #include "target.hxx"
      30             : 
      31             : #include "undoolk.hxx"
      32             : 
      33           0 : TYPEINIT1(ScUndoWidthOrHeight,      SfxUndoAction);
      34             : 
      35             : /** Change column widths or row heights */
      36           0 : ScUndoWidthOrHeight::ScUndoWidthOrHeight( ScDocShell* pNewDocShell,
      37             :                 const ScMarkData& rMark,
      38             :                 SCCOLROW nNewStart, SCTAB nNewStartTab, SCCOLROW nNewEnd, SCTAB nNewEndTab,
      39             :                 ScDocument* pNewUndoDoc, const std::vector<sc::ColRowSpan>& rRanges,
      40             :                 ScOutlineTable* pNewUndoTab,
      41             :                 ScSizeMode eNewMode, sal_uInt16 nNewSizeTwips, bool bNewWidth ) :
      42             :     ScSimpleUndo( pNewDocShell ),
      43             :     aMarkData( rMark ),
      44             :     nStart( nNewStart ),
      45             :     nEnd( nNewEnd ),
      46             :     nStartTab( nNewStartTab ),
      47             :     nEndTab( nNewEndTab ),
      48             :     pUndoDoc( pNewUndoDoc ),
      49             :     pUndoTab( pNewUndoTab ),
      50             :     maRanges(rRanges),
      51             :     nNewSize( nNewSizeTwips ),
      52             :     bWidth( bNewWidth ),
      53             :     eMode( eNewMode ),
      54           0 :     pDrawUndo( NULL )
      55             : {
      56           0 :     pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
      57           0 : }
      58             : 
      59           0 : ScUndoWidthOrHeight::~ScUndoWidthOrHeight()
      60             : {
      61           0 :     delete pUndoDoc;
      62           0 :     delete pUndoTab;
      63           0 :     DeleteSdrUndoAction( pDrawUndo );
      64           0 : }
      65             : 
      66           0 : OUString ScUndoWidthOrHeight::GetComment() const
      67             : {
      68             :     // [ "optimal " ] "Column width" | "row height"
      69             :     return ( bWidth ?
      70           0 :         ( ( eMode == SC_SIZE_OPTIMAL )?
      71             :         ScGlobal::GetRscString( STR_UNDO_OPTCOLWIDTH ) :
      72             :         ScGlobal::GetRscString( STR_UNDO_COLWIDTH )
      73             :         ) :
      74           0 :         ( ( eMode == SC_SIZE_OPTIMAL )?
      75             :         ScGlobal::GetRscString( STR_UNDO_OPTROWHEIGHT ) :
      76             :         ScGlobal::GetRscString( STR_UNDO_ROWHEIGHT )
      77           0 :         ) );
      78             : }
      79             : 
      80           0 : void ScUndoWidthOrHeight::Undo()
      81             : {
      82           0 :     BeginUndo();
      83             : 
      84           0 :     ScDocument* pDoc = pDocShell->GetDocument();
      85             : 
      86           0 :     SCCOLROW nPaintStart = nStart > 0 ? nStart-1 : static_cast<SCCOLROW>(0);
      87             : 
      88           0 :     if (eMode==SC_SIZE_OPTIMAL)
      89             :     {
      90           0 :         if ( SetViewMarkData( aMarkData ) )
      91           0 :             nPaintStart = 0;        // paint all, because of changed selection
      92             :     }
      93             : 
      94             :     //! outlines from all tables?
      95           0 :     if (pUndoTab)                                           // Outlines are included when saving ?
      96           0 :         pDoc->SetOutlineTable( nStartTab, pUndoTab );
      97             : 
      98           0 :     SCTAB nTabCount = pDoc->GetTableCount();
      99           0 :     ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end();
     100           0 :     for (; itr != itrEnd && *itr < nTabCount; ++itr)
     101             :     {
     102           0 :         if (bWidth) // Width
     103             :         {
     104           0 :             pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, *itr,
     105           0 :                     static_cast<SCCOL>(nEnd), MAXROW, *itr, IDF_NONE,
     106           0 :                     false, pDoc );
     107           0 :             pDoc->UpdatePageBreaks( *itr );
     108           0 :             pDocShell->PostPaint( static_cast<SCCOL>(nPaintStart), 0, *itr,
     109           0 :                     MAXCOL, MAXROW, *itr, PAINT_GRID | PAINT_TOP );
     110             :         }
     111             :         else        // Height
     112             :         {
     113           0 :             pUndoDoc->CopyToDocument( 0, nStart, *itr, MAXCOL, nEnd, *itr, IDF_NONE, false, pDoc );
     114           0 :             pDoc->UpdatePageBreaks( *itr );
     115           0 :             pDocShell->PostPaint( 0, nPaintStart, *itr, MAXCOL, MAXROW, *itr, PAINT_GRID | PAINT_LEFT );
     116             :         }
     117             :     }
     118             : 
     119           0 :     DoSdrUndoAction( pDrawUndo, pDoc );
     120             : 
     121           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     122           0 :     if (pViewShell)
     123             :     {
     124           0 :         pViewShell->UpdateScrollBars();
     125             : 
     126           0 :         SCTAB nCurrentTab = pViewShell->GetViewData()->GetTabNo();
     127           0 :         if ( nCurrentTab < nStartTab || nCurrentTab > nEndTab )
     128           0 :             pViewShell->SetTabNo( nStartTab );
     129             :     }
     130             : 
     131           0 :     EndUndo();
     132           0 : }
     133             : 
     134           0 : void ScUndoWidthOrHeight::Redo()
     135             : {
     136           0 :     BeginRedo();
     137             : 
     138           0 :     sal_Bool bPaintAll = false;
     139           0 :     if (eMode==SC_SIZE_OPTIMAL)
     140             :     {
     141           0 :         if ( SetViewMarkData( aMarkData ) )
     142           0 :             bPaintAll = sal_True;       // paint all, because of changed selection
     143             :     }
     144             : 
     145           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     146           0 :     if (pViewShell)
     147             :     {
     148           0 :         SCTAB nTab = pViewShell->GetViewData()->GetTabNo();
     149           0 :         if ( nTab < nStartTab || nTab > nEndTab )
     150           0 :             pViewShell->SetTabNo( nStartTab );
     151             : 
     152             :         // SetWidthOrHeight changes current sheet!
     153             :         pViewShell->SetWidthOrHeight(
     154           0 :             bWidth, maRanges, eMode, nNewSize, false, true, &aMarkData);
     155             :     }
     156             : 
     157             :     // paint grid if selection was changed directly at the MarkData
     158           0 :     if (bPaintAll)
     159           0 :         pDocShell->PostPaint( 0, 0, nStartTab, MAXCOL, MAXROW, nEndTab, PAINT_GRID );
     160             : 
     161           0 :     EndRedo();
     162           0 : }
     163             : 
     164           0 : void ScUndoWidthOrHeight::Repeat(SfxRepeatTarget& rTarget)
     165             : {
     166           0 :     if (rTarget.ISA(ScTabViewTarget))
     167           0 :         ((ScTabViewTarget&)rTarget).GetViewShell()->SetMarkedWidthOrHeight( bWidth, eMode, nNewSize, true );
     168           0 : }
     169             : 
     170           0 : bool ScUndoWidthOrHeight::CanRepeat(SfxRepeatTarget& rTarget) const
     171             : {
     172           0 :     return rTarget.ISA(ScTabViewTarget);
     173           0 : }
     174             : 
     175             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10