1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svl/slstitm.hxx>
21 #include <rtl/ustrbuf.hxx>
24 #include <IDocumentUndoRedo.hxx>
25 #include <swdtflvr.hxx>
26 #include <svtools/svtresid.hxx>
27 #include <svtools/strings.hrc>
28 #include <osl/diagnose.h>
30 // Undo ends all modes. If a selection is emerged by the Undo,
31 // this must be considered for further action.
33 void SwWrtShell::Do(DoType eDoType
, sal_uInt16 nCnt
, sal_uInt16 nOffset
)
35 // #105332# save current state of DoesUndo()
36 bool bSaveDoesUndo
= DoesUndo();
42 DoUndo(false); // #i21739#
45 SwEditShell::Undo(nCnt
, nOffset
);
48 DoUndo(false); // #i21739#
51 SwEditShell::Redo( nCnt
);
54 // #i21739# do not touch undo flag here !!!
55 SwEditShell::Repeat( nCnt
);
59 // #105332# restore undo state
60 DoUndo(bSaveDoesUndo
);
62 bool bCreateXSelection
= false;
63 const bool bFrameSelected
= IsFrameSelected() || GetSelectedObjCount();
69 // Set the function pointer for canceling the selection at the
71 m_fnKillSel
= &SwWrtShell::ResetSelect
;
72 m_fnSetCursor
= &SwWrtShell::SetCursorKillSel
;
73 bCreateXSelection
= true;
75 else if ( bFrameSelected
)
78 bCreateXSelection
= true;
80 else if( (CNT_GRF
| CNT_OLE
) & GetCntType() )
82 SelectObj( GetCharRect().Pos() );
84 bCreateXSelection
= true;
87 if( bCreateXSelection
)
88 SwTransferable::CreateSelection( *this );
90 // Bug 32918: After deleting of the numbering the object panel remains.
91 // Why is not here always a CallChgLink called?
95 OUString
SwWrtShell::GetDoString( DoType eDoType
) const
98 TranslateId pResStr
= STR_UNDO
;
103 (void)GetLastUndoInfo(&aUndoStr
, nullptr, &m_rView
);
107 (void)GetFirstRedoInfo(&aUndoStr
, nullptr, &m_rView
);
109 default:;//prevent warning
112 return SvtResId(pResStr
) + aUndoStr
;
115 void SwWrtShell::GetDoStrings( DoType eDoType
, SfxStringListItem
& rStrs
) const
117 SwUndoComments_t comments
;
121 comments
= GetIDocumentUndoRedo().GetUndoComments();
124 comments
= GetIDocumentUndoRedo().GetRedoComments();
126 default:;//prevent warning
130 for (const OUString
& comment
: comments
)
132 OSL_ENSURE(!comment
.isEmpty(), "no Undo/Redo Text set");
133 buf
.append(comment
+ "\n");
135 rStrs
.SetString(buf
.makeStringAndClear());
138 OUString
SwWrtShell::GetRepeatString() const
141 GetRepeatInfo(& str
);
148 return SvtResId(STR_REPEAT
) + str
;
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */