1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 32 33 #define _SVSTDARR_STRINGSDTOR 34 #include <tools/resid.hxx> 35 #include <sfx2/app.hxx> 36 #include <svl/slstitm.hxx> 37 #include <wrtsh.hxx> 38 #include <swundo.hxx> // fuer Undo-Ids 39 #include <IDocumentUndoRedo.hxx> 40 #include <swdtflvr.hxx> 41 #include <svtools/svtdata.hxx> 42 #include <svtools/svtools.hrc> 43 #include <svtools/svtdata.hxx> 44 #include <wrtsh.hrc> 45 #include <sfx2/sfx.hrc> 46 47 48 // Undo beendet alle Modi. Falls eine Selektion durch das Undo entstanden 49 // ist, muss die fuer die weiteren Aktionen beruecksichtigt werden. 50 51 52 void SwWrtShell::Do( DoType eDoType, sal_uInt16 nCnt ) 53 { 54 // #105332# save current state of DoesUndo() 55 sal_Bool bSaveDoesUndo = DoesUndo(); 56 57 StartAllAction(); 58 switch( eDoType ) 59 { 60 case UNDO: 61 DoUndo(sal_False); // #i21739# 62 // Modi zuruecksetzen 63 EnterStdMode(); 64 SwEditShell::Undo(nCnt); 65 break; 66 case REDO: 67 DoUndo(sal_False); // #i21739# 68 // Modi zuruecksetzen 69 EnterStdMode(); 70 SwEditShell::Redo( nCnt ); 71 break; 72 case REPEAT: 73 // #i21739# do not touch undo flag here !!! 74 SwEditShell::Repeat( nCnt ); 75 break; 76 } 77 EndAllAction(); 78 // #105332# restore undo state 79 DoUndo(bSaveDoesUndo); 80 81 sal_Bool bCreateXSelection = sal_False; 82 const sal_Bool bFrmSelected = IsFrmSelected() || IsObjSelected(); 83 if ( IsSelection() ) 84 { 85 if ( bFrmSelected ) 86 UnSelectFrm(); 87 88 // Funktionspointer fuer das Aufheben der Selektion setzen 89 // bei Cursor setzen 90 fnKillSel = &SwWrtShell::ResetSelect; 91 fnSetCrsr = &SwWrtShell::SetCrsrKillSel; 92 bCreateXSelection = sal_True; 93 } 94 else if ( bFrmSelected ) 95 { 96 EnterSelFrmMode(); 97 bCreateXSelection = sal_True; 98 } 99 else if( (CNT_GRF | CNT_OLE ) & GetCntType() ) 100 { 101 SelectObj( GetCharRect().Pos() ); 102 EnterSelFrmMode(); 103 bCreateXSelection = sal_True; 104 } 105 106 if( bCreateXSelection ) 107 SwTransferable::CreateSelection( *this ); 108 109 // Bug 32918: nach loeschen der Numerierung bleibt die Obj. Leiste stehen 110 // Warum wird hier nicht immer ein CallChgLink gerufen? 111 CallChgLnk(); 112 } 113 114 115 String SwWrtShell::GetDoString( DoType eDoType ) const 116 { 117 ::rtl::OUString aUndoStr; 118 sal_uInt16 nResStr = STR_UNDO; 119 switch( eDoType ) 120 { 121 case UNDO: 122 nResStr = STR_UNDO; 123 GetLastUndoInfo(& aUndoStr, 0); 124 break; 125 case REDO: 126 nResStr = STR_REDO; 127 GetFirstRedoInfo(& aUndoStr); 128 break; 129 default:;//prevent warning 130 } 131 132 ::rtl::OUStringBuffer buf = ::rtl::OUStringBuffer( String( SvtResId( nResStr ) ) ); 133 buf.append(aUndoStr); 134 135 return buf.makeStringAndClear(); 136 } 137 138 sal_uInt16 SwWrtShell::GetDoStrings( DoType eDoType, SfxStringListItem& rStrs ) const 139 { 140 SwUndoComments_t comments; 141 switch( eDoType ) 142 { 143 case UNDO: 144 comments = GetIDocumentUndoRedo().GetUndoComments(); 145 break; 146 case REDO: 147 comments = GetIDocumentUndoRedo().GetRedoComments(); 148 break; 149 default:;//prevent warning 150 } 151 152 ::rtl::OUStringBuffer buf; 153 for (size_t i = 0; i < comments.size(); ++i) 154 { 155 OSL_ENSURE(comments[i].getLength(), "no Undo/Redo Text set"); 156 buf.append(comments[i]); 157 buf.append(sal_Unicode('\n')); 158 } 159 rStrs.SetString(buf.makeStringAndClear()); 160 return static_cast<sal_uInt16>(comments.size()); 161 } 162 163 164 String SwWrtShell::GetRepeatString() const 165 { 166 ::rtl::OUString str; 167 GetRepeatInfo(& str); 168 169 if (str.getLength() == 0) 170 { 171 return str; 172 } 173 174 ::rtl::OUStringBuffer buf( String(SvtResId(STR_REPEAT)) ); 175 buf.append(str); 176 return buf.makeStringAndClear(); 177 } 178 179 180