LCOV - code coverage report
Current view: top level - sw/source/uibase/wrtsh - wrtundo.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 34 65 52.3 %
Date: 2015-06-13 12:38:46 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           4 : void SwWrtShell::Do( DoType eDoType, sal_uInt16 nCnt )
      36             : {
      37             :     // #105332# save current state of DoesUndo()
      38           4 :     bool bSaveDoesUndo = DoesUndo();
      39             : 
      40           4 :     StartAllAction();
      41           4 :     switch (eDoType)
      42             :     {
      43             :         case UNDO:
      44           3 :             DoUndo(false); // #i21739#
      45             :             // Reset modes
      46           3 :             EnterStdMode();
      47           3 :             SwEditShell::Undo(nCnt);
      48           3 :             break;
      49             :         case REDO:
      50           1 :             DoUndo(false); // #i21739#
      51             :             // Reset modes
      52           1 :             EnterStdMode();
      53           1 :             SwEditShell::Redo( nCnt );
      54           1 :             break;
      55             :         case REPEAT:
      56             :             // #i21739# do not touch undo flag here !!!
      57           0 :             SwEditShell::Repeat( nCnt );
      58           0 :             break;
      59             :     }
      60           4 :     EndAllAction();
      61             :     // #105332# restore undo state
      62           4 :     DoUndo(bSaveDoesUndo);
      63             : 
      64           4 :     bool bCreateXSelection = false;
      65           4 :     const bool bFrmSelected = IsFrmSelected() || IsObjSelected();
      66           4 :     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 :         m_fnKillSel = &SwWrtShell::ResetSelect;
      74           0 :         m_fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
      75           0 :         bCreateXSelection = true;
      76             :     }
      77           4 :     else if ( bFrmSelected )
      78             :     {
      79           0 :         EnterSelFrmMode();
      80           0 :         bCreateXSelection = true;
      81             :     }
      82           4 :     else if( (CNT_GRF | CNT_OLE ) & GetCntType() )
      83             :     {
      84           0 :         SelectObj( GetCharRect().Pos() );
      85           0 :         EnterSelFrmMode();
      86           0 :         bCreateXSelection = true;
      87             :     }
      88             : 
      89           4 :     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           4 :     CallChgLnk();
      95           4 : }
      96             : 
      97         509 : OUString SwWrtShell::GetDoString( DoType eDoType ) const
      98             : {
      99         509 :     OUString aUndoStr;
     100         509 :     sal_uInt16 nResStr = STR_UNDO;
     101         509 :     switch( eDoType )
     102             :     {
     103             :     case UNDO:
     104         491 :         nResStr = STR_UNDO;
     105         491 :         (void)GetLastUndoInfo(&aUndoStr, 0);
     106         491 :         break;
     107             :     case REDO:
     108          18 :         nResStr = STR_REDO;
     109          18 :         (void)GetFirstRedoInfo(&aUndoStr);
     110          18 :         break;
     111             :     default:;//prevent warning
     112             :     }
     113             : 
     114         509 :     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         177 : }
     152             : 
     153             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11