1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: wrtundo.cxx,v $
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>
41 #include <swundo.hxx> // fuer Undo-Ids
42 #include <swdtflvr.hxx>
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();
63 DoUndo(sal_False
); // #i21739#
66 SwEditShell::Undo(UNDO_EMPTY
, nCnt
);
69 DoUndo(sal_False
); // #i21739#
72 SwEditShell::Redo( nCnt
);
75 // #i21739# do not touch undo flag here !!!
76 SwEditShell::Repeat( nCnt
);
80 // #105332# restore undo state
81 DoUndo(bSaveDoesUndo
);
83 BOOL bCreateXSelection
= FALSE
;
84 const BOOL bFrmSelected
= IsFrmSelected() || IsObjSelected();
90 // Funktionspointer fuer das Aufheben der Selektion setzen
92 fnKillSel
= &SwWrtShell::ResetSelect
;
93 fnSetCrsr
= &SwWrtShell::SetCrsrKillSel
;
94 bCreateXSelection
= TRUE
;
96 else if ( bFrmSelected
)
99 bCreateXSelection
= TRUE
;
101 else if( (CNT_GRF
| CNT_OLE
) & GetCntType() )
103 SelectObj( GetCharRect().Pos() );
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?
117 String
SwWrtShell::GetDoString( DoType eDoType
) const
119 String aStr
, aUndoStr
;
120 USHORT nResStr
= STR_UNDO
;
125 aUndoStr
= GetUndoIdsStr();
129 aUndoStr
= GetRedoIdsStr();
131 default:;//prevent warning
134 aStr
.Insert( String(ResId( nResStr
, *SFX_APP()->GetSfxResManager())), 0 );
140 USHORT
SwWrtShell::GetDoStrings( DoType eDoType
, SfxStringListItem
& rStrs
) const
146 GetUndoIds( NULL
, &aIds
);
149 GetRedoIds( NULL
, &aIds
);
151 default:;//prevent warning
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();
162 ASSERT( !this, "no Undo/Redo Test set" );
166 rStrs
.SetString( sList
);
171 String
SwWrtShell::GetRepeatString() const
174 String aUndoStr
= GetRepeatIdsStr();
176 if (aUndoStr
.Len() > 0)
178 aStr
.Insert( ResId( STR_REPEAT
, *SFX_APP()->GetSfxResManager()), 0 );