LCOV - code coverage report
Current view: top level - sw/source/uibase/wrtsh - wrtundo.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 34 65 52.3 %
Date: 2014-11-03 Functions: 4 6 66.7 %
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 <tools/resid.hxx>
      21             : #include <sfx2/app.hxx>
      22             : #include <svl/slstitm.hxx>
      23             : #include <wrtsh.hxx>
      24             : #include <swundo.hxx>
      25             : #include <IDocumentUndoRedo.hxx>
      26             : #include <swdtflvr.hxx>
      27             : #include <svtools/svtresid.hxx>
      28             : #include <svtools/svtools.hrc>
      29             : #include <wrtsh.hrc>
      30             : #include <sfx2/sfx.hrc>
      31             : 
      32             : // Undo ends all modes. If a selection is emerged by the Undo,
      33             : // this must be considered for further action.
      34             : 
      35           8 : void SwWrtShell::Do( DoType eDoType, sal_uInt16 nCnt )
      36             : {
      37             :     // #105332# save current state of DoesUndo()
      38           8 :     bool bSaveDoesUndo = DoesUndo();
      39             : 
      40           8 :     StartAllAction();
      41           8 :     switch (eDoType)
      42             :     {
      43             :         case UNDO:
      44           6 :             DoUndo(false); // #i21739#
      45             :             // Reset modes
      46           6 :             EnterStdMode();
      47           6 :             SwEditShell::Undo(nCnt);
      48           6 :             break;
      49             :         case REDO:
      50           2 :             DoUndo(false); // #i21739#
      51             :             // Reset modes
      52           2 :             EnterStdMode();
      53           2 :             SwEditShell::Redo( nCnt );
      54           2 :             break;
      55             :         case REPEAT:
      56             :             // #i21739# do not touch undo flag here !!!
      57           0 :             SwEditShell::Repeat( nCnt );
      58           0 :             break;
      59             :     }
      60           8 :     EndAllAction();
      61             :     // #105332# restore undo state
      62           8 :     DoUndo(bSaveDoesUndo);
      63             : 
      64           8 :     bool bCreateXSelection = false;
      65           8 :     const bool bFrmSelected = IsFrmSelected() || IsObjSelected();
      66           8 :     if ( IsSelection() )
      67             :     {
      68           0 :         if ( bFrmSelected )
      69           0 :             UnSelectFrm();
      70             : 
      71             :         // Set the function pointer for canceling the selection at the
      72             :         // cursor position.
      73           0 :         fnKillSel = &SwWrtShell::ResetSelect;
      74           0 :         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
      75           0 :         bCreateXSelection = true;
      76             :     }
      77           8 :     else if ( bFrmSelected )
      78             :     {
      79           0 :         EnterSelFrmMode();
      80           0 :         bCreateXSelection = true;
      81             :     }
      82           8 :     else if( (CNT_GRF | CNT_OLE ) & GetCntType() )
      83             :     {
      84           0 :         SelectObj( GetCharRect().Pos() );
      85           0 :         EnterSelFrmMode();
      86           0 :         bCreateXSelection = true;
      87             :     }
      88             : 
      89           8 :     if( bCreateXSelection )
      90           0 :         SwTransferable::CreateSelection( *this );
      91             : 
      92             :     // Bug 32918: After deleting of the numbering the object panel remains.
      93             :     //            Why is not here always a CallChgLink called?
      94           8 :     CallChgLnk();
      95           8 : }
      96             : 
      97         379 : OUString SwWrtShell::GetDoString( DoType eDoType ) const
      98             : {
      99         379 :     OUString aUndoStr;
     100         379 :     sal_uInt16 nResStr = STR_UNDO;
     101         379 :     switch( eDoType )
     102             :     {
     103             :     case UNDO:
     104         377 :         nResStr = STR_UNDO;
     105         377 :         (void)GetLastUndoInfo(&aUndoStr, 0);
     106         377 :         break;
     107             :     case REDO:
     108           2 :         nResStr = STR_REDO;
     109           2 :         (void)GetFirstRedoInfo(&aUndoStr);
     110           2 :         break;
     111             :     default:;//prevent warning
     112             :     }
     113             : 
     114         379 :     return  SvtResId( nResStr ).toString() + aUndoStr;
     115             : }
     116             : 
     117           0 : void SwWrtShell::GetDoStrings( DoType eDoType, SfxStringListItem& rStrs ) const
     118             : {
     119           0 :     SwUndoComments_t comments;
     120           0 :     switch( eDoType )
     121             :     {
     122             :     case UNDO:
     123           0 :         comments = GetIDocumentUndoRedo().GetUndoComments();
     124           0 :         break;
     125             :     case REDO:
     126           0 :         comments = GetIDocumentUndoRedo().GetRedoComments();
     127           0 :         break;
     128             :     default:;//prevent warning
     129             :     }
     130             : 
     131           0 :     OUString buf;
     132           0 :     for (size_t i = 0; i < comments.size(); ++i)
     133             :     {
     134             :         OSL_ENSURE(!comments[i].isEmpty(), "no Undo/Redo Text set");
     135           0 :         buf += comments[i] + "\n";
     136             :     }
     137           0 :     rStrs.SetString(buf);
     138           0 : }
     139             : 
     140           0 : OUString SwWrtShell::GetRepeatString() const
     141             : {
     142           0 :     OUString str;
     143           0 :     GetRepeatInfo(& str);
     144             : 
     145           0 :     if (str.isEmpty())
     146             :     {
     147           0 :         return str;
     148             :     }
     149             : 
     150           0 :     return SvtResId(STR_REPEAT).toString() + str;
     151         270 : }
     152             : 
     153             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10