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