LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/undo - undoblk2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 67 1.5 %
Date: 2012-12-27 Functions: 2 15 13.3 %
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"              // SearchItem
      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"              // TODO move GetUndo in Document
      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, SCCOLROW nNewCnt, SCCOLROW* pNewRanges,
      40             :                 ScOutlineTable* pNewUndoTab,
      41             :                 ScSizeMode eNewMode, sal_uInt16 nNewSizeTwips, sal_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             :     nRangeCnt( nNewCnt ),
      51             :     pRanges( pNewRanges ),
      52             :     nNewSize( nNewSizeTwips ),
      53             :     bWidth( bNewWidth ),
      54             :     eMode( eNewMode ),
      55           0 :     pDrawUndo( NULL )
      56             : {
      57           0 :     pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
      58           0 : }
      59             : 
      60           0 : ScUndoWidthOrHeight::~ScUndoWidthOrHeight()
      61             : {
      62           0 :     delete[] pRanges;
      63           0 :     delete pUndoDoc;
      64           0 :     delete pUndoTab;
      65           0 :     DeleteSdrUndoAction( pDrawUndo );
      66           0 : }
      67             : 
      68           0 : rtl::OUString ScUndoWidthOrHeight::GetComment() const
      69             : {
      70             :     // [ "optimal " ] "Column width" | "row height"
      71             :     return ( bWidth ?
      72             :         ( ( eMode == SC_SIZE_OPTIMAL )?
      73             :         ScGlobal::GetRscString( STR_UNDO_OPTCOLWIDTH ) :
      74             :         ScGlobal::GetRscString( STR_UNDO_COLWIDTH )
      75             :         ) :
      76             :         ( ( eMode == SC_SIZE_OPTIMAL )?
      77             :         ScGlobal::GetRscString( STR_UNDO_OPTROWHEIGHT ) :
      78             :         ScGlobal::GetRscString( STR_UNDO_ROWHEIGHT )
      79           0 :         ) );
      80             : }
      81             : 
      82           0 : void ScUndoWidthOrHeight::Undo()
      83             : {
      84           0 :     BeginUndo();
      85             : 
      86           0 :     ScDocument* pDoc = pDocShell->GetDocument();
      87             : 
      88           0 :     SCCOLROW nPaintStart = nStart > 0 ? nStart-1 : static_cast<SCCOLROW>(0);
      89             : 
      90           0 :     if (eMode==SC_SIZE_OPTIMAL)
      91             :     {
      92           0 :         if ( SetViewMarkData( aMarkData ) )
      93           0 :             nPaintStart = 0;        // paint all, because of changed selection
      94             :     }
      95             : 
      96             :     //! outlines from all tables?
      97           0 :     if (pUndoTab)                                           // Outlines are included when saving ?
      98           0 :         pDoc->SetOutlineTable( nStartTab, pUndoTab );
      99             : 
     100           0 :     SCTAB nTabCount = pDoc->GetTableCount();
     101           0 :     ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end();
     102           0 :     for (; itr != itrEnd && *itr < nTabCount; ++itr)
     103             :     {
     104           0 :         if (bWidth) // Width
     105             :         {
     106           0 :             pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, *itr,
     107           0 :                     static_cast<SCCOL>(nEnd), MAXROW, *itr, IDF_NONE,
     108           0 :                     false, pDoc );
     109           0 :             pDoc->UpdatePageBreaks( *itr );
     110           0 :             pDocShell->PostPaint( static_cast<SCCOL>(nPaintStart), 0, *itr,
     111           0 :                     MAXCOL, MAXROW, *itr, PAINT_GRID | PAINT_TOP );
     112             :         }
     113             :         else        // Height
     114             :         {
     115           0 :             pUndoDoc->CopyToDocument( 0, nStart, *itr, MAXCOL, nEnd, *itr, IDF_NONE, false, pDoc );
     116           0 :             pDoc->UpdatePageBreaks( *itr );
     117           0 :             pDocShell->PostPaint( 0, nPaintStart, *itr, MAXCOL, MAXROW, *itr, PAINT_GRID | PAINT_LEFT );
     118             :         }
     119             :     }
     120             : 
     121           0 :     DoSdrUndoAction( pDrawUndo, pDoc );
     122             : 
     123           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     124           0 :     if (pViewShell)
     125             :     {
     126           0 :         pViewShell->UpdateScrollBars();
     127             : 
     128           0 :         SCTAB nCurrentTab = pViewShell->GetViewData()->GetTabNo();
     129           0 :         if ( nCurrentTab < nStartTab || nCurrentTab > nEndTab )
     130           0 :             pViewShell->SetTabNo( nStartTab );
     131             :     }
     132             : 
     133           0 :     EndUndo();
     134           0 : }
     135             : 
     136           0 : void ScUndoWidthOrHeight::Redo()
     137             : {
     138           0 :     BeginRedo();
     139             : 
     140           0 :     sal_Bool bPaintAll = false;
     141           0 :     if (eMode==SC_SIZE_OPTIMAL)
     142             :     {
     143           0 :         if ( SetViewMarkData( aMarkData ) )
     144           0 :             bPaintAll = sal_True;       // paint all, because of changed selection
     145             :     }
     146             : 
     147           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     148           0 :     if (pViewShell)
     149             :     {
     150           0 :         SCTAB nTab = pViewShell->GetViewData()->GetTabNo();
     151           0 :         if ( nTab < nStartTab || nTab > nEndTab )
     152           0 :             pViewShell->SetTabNo( nStartTab );
     153             : 
     154             :         // SetWidthOrHeight changes current sheet!
     155           0 :         pViewShell->SetWidthOrHeight( bWidth, nRangeCnt, pRanges, eMode, nNewSize, false, true, &aMarkData );
     156             :     }
     157             : 
     158             :     // paint grid if selection was changed directly at the MarkData
     159           0 :     if (bPaintAll)
     160           0 :         pDocShell->PostPaint( 0, 0, nStartTab, MAXCOL, MAXROW, nEndTab, PAINT_GRID );
     161             : 
     162           0 :     EndRedo();
     163           0 : }
     164             : 
     165           0 : void ScUndoWidthOrHeight::Repeat(SfxRepeatTarget& rTarget)
     166             : {
     167           0 :     if (rTarget.ISA(ScTabViewTarget))
     168           0 :         ((ScTabViewTarget&)rTarget).GetViewShell()->SetMarkedWidthOrHeight( bWidth, eMode, nNewSize, sal_True );
     169           0 : }
     170             : 
     171           0 : sal_Bool ScUndoWidthOrHeight::CanRepeat(SfxRepeatTarget& rTarget) const
     172             : {
     173           0 :     return (rTarget.ISA(ScTabViewTarget));
     174          15 : }
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10