merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / wrtsh / wrtundo.cxx
blob63aa5bfb427e12b4d3cdeb20a0fd9c9cbca02425
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: wrtundo.cxx,v $
10 * $Revision: 1.14 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #define _SVSTDARR_STRINGSDTOR
37 #include <tools/resid.hxx>
38 #include <sfx2/app.hxx>
39 #include <svtools/slstitm.hxx>
40 #include <wrtsh.hxx>
41 #include <swundo.hxx> // fuer Undo-Ids
42 #include <swdtflvr.hxx>
44 #ifndef _WRTSH_HRC
45 #include <wrtsh.hrc>
46 #endif
47 #include <sfx2/sfx.hrc>
50 // Undo beendet alle Modi. Falls eine Selektion durch das Undo entstanden
51 // ist, muss die fuer die weiteren Aktionen beruecksichtigt werden.
54 void SwWrtShell::Do( DoType eDoType, USHORT nCnt )
56 // #105332# save current state of DoesUndo()
57 sal_Bool bSaveDoesUndo = DoesUndo();
59 StartAllAction();
60 switch( eDoType )
62 case UNDO:
63 DoUndo(sal_False); // #i21739#
64 // Modi zuruecksetzen
65 EnterStdMode();
66 SwEditShell::Undo(UNDO_EMPTY, nCnt );
67 break;
68 case REDO:
69 DoUndo(sal_False); // #i21739#
70 // Modi zuruecksetzen
71 EnterStdMode();
72 SwEditShell::Redo( nCnt );
73 break;
74 case REPEAT:
75 // #i21739# do not touch undo flag here !!!
76 SwEditShell::Repeat( nCnt );
77 break;
79 EndAllAction();
80 // #105332# restore undo state
81 DoUndo(bSaveDoesUndo);
83 BOOL bCreateXSelection = FALSE;
84 const BOOL bFrmSelected = IsFrmSelected() || IsObjSelected();
85 if ( IsSelection() )
87 if ( bFrmSelected )
88 UnSelectFrm();
90 // Funktionspointer fuer das Aufheben der Selektion setzen
91 // bei Cursor setzen
92 fnKillSel = &SwWrtShell::ResetSelect;
93 fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
94 bCreateXSelection = TRUE;
96 else if ( bFrmSelected )
98 EnterSelFrmMode();
99 bCreateXSelection = TRUE;
101 else if( (CNT_GRF | CNT_OLE ) & GetCntType() )
103 SelectObj( GetCharRect().Pos() );
104 EnterSelFrmMode();
105 bCreateXSelection = TRUE;
108 if( bCreateXSelection )
109 SwTransferable::CreateSelection( *this );
111 // Bug 32918: nach loeschen der Numerierung bleibt die Obj. Leiste stehen
112 // Warum wird hier nicht immer ein CallChgLink gerufen?
113 CallChgLnk();
117 String SwWrtShell::GetDoString( DoType eDoType ) const
119 String aStr, aUndoStr;
120 USHORT nResStr = STR_UNDO;
121 switch( eDoType )
123 case UNDO:
124 nResStr = STR_UNDO;
125 aUndoStr = GetUndoIdsStr();
126 break;
127 case REDO:
128 nResStr = STR_REDO;
129 aUndoStr = GetRedoIdsStr();
130 break;
131 default:;//prevent warning
134 aStr.Insert( String(ResId( nResStr, *SFX_APP()->GetSfxResManager())), 0 );
135 aStr += aUndoStr;
137 return aStr;
140 USHORT SwWrtShell::GetDoStrings( DoType eDoType, SfxStringListItem& rStrs ) const
142 SwUndoIds aIds;
143 switch( eDoType )
145 case UNDO:
146 GetUndoIds( NULL, &aIds );
147 break;
148 case REDO:
149 GetRedoIds( NULL, &aIds );
150 break;
151 default:;//prevent warning
154 String sList;
155 for( USHORT n = 0, nEnd = aIds.Count(); n < nEnd; ++n )
157 const SwUndoIdAndName& rIdNm = *aIds[ n ];
158 if( rIdNm.GetUndoStr() )
159 sList += *rIdNm.GetUndoStr();
160 else
162 ASSERT( !this, "no Undo/Redo Test set" );
164 sList += '\n';
166 rStrs.SetString( sList );
167 return aIds.Count();
171 String SwWrtShell::GetRepeatString() const
173 String aStr;
174 String aUndoStr = GetRepeatIdsStr();
176 if (aUndoStr.Len() > 0)
178 aStr.Insert( ResId( STR_REPEAT, *SFX_APP()->GetSfxResManager()), 0 );
179 aStr += aUndoStr;
182 return aStr;