LibreOffice Module sw (master) 1
wrtundo.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <svl/slstitm.hxx>
21#include <rtl/ustrbuf.hxx>
22#include <wrtsh.hxx>
23#include <swundo.hxx>
24#include <IDocumentUndoRedo.hxx>
25#include <swdtflvr.hxx>
26#include <svtools/svtresid.hxx>
27#include <svtools/strings.hrc>
28#include <osl/diagnose.h>
29
30// Undo ends all modes. If a selection is emerged by the Undo,
31// this must be considered for further action.
32
33void SwWrtShell::Do(DoType eDoType, sal_uInt16 nCnt, sal_uInt16 nOffset)
34{
35 // #105332# save current state of DoesUndo()
36 bool bSaveDoesUndo = DoesUndo();
37
39 switch (eDoType)
40 {
41 case UNDO:
42 DoUndo(false); // #i21739#
43 // Reset modes
45 SwEditShell::Undo(nCnt, nOffset);
46 break;
47 case REDO:
48 DoUndo(false); // #i21739#
49 // Reset modes
51 SwEditShell::Redo( nCnt );
52 break;
53 case REPEAT:
54 // #i21739# do not touch undo flag here !!!
55 SwEditShell::Repeat( nCnt );
56 break;
57 }
59 // #105332# restore undo state
60 DoUndo(bSaveDoesUndo);
61
62 bool bCreateXSelection = false;
63 const bool bFrameSelected = IsFrameSelected() || IsObjSelected();
64 if ( IsSelection() )
65 {
66 if ( bFrameSelected )
68
69 // Set the function pointer for canceling the selection at the
70 // cursor position.
73 bCreateXSelection = true;
74 }
75 else if ( bFrameSelected )
76 {
78 bCreateXSelection = true;
79 }
80 else if( (CNT_GRF | CNT_OLE ) & GetCntType() )
81 {
84 bCreateXSelection = true;
85 }
86
87 if( bCreateXSelection )
89
90 // Bug 32918: After deleting of the numbering the object panel remains.
91 // Why is not here always a CallChgLink called?
92 CallChgLnk();
93}
94
95OUString SwWrtShell::GetDoString( DoType eDoType ) const
96{
97 OUString aUndoStr;
98 TranslateId pResStr = STR_UNDO;
99 switch( eDoType )
100 {
101 case UNDO:
102 pResStr = STR_UNDO;
103 (void)GetLastUndoInfo(&aUndoStr, nullptr, &m_rView);
104 break;
105 case REDO:
106 pResStr = STR_REDO;
107 (void)GetFirstRedoInfo(&aUndoStr, nullptr, &m_rView);
108 break;
109 default:;//prevent warning
110 }
111
112 return SvtResId(pResStr) + aUndoStr;
113}
114
116{
117 SwUndoComments_t comments;
118 switch( eDoType )
119 {
120 case UNDO:
121 comments = GetIDocumentUndoRedo().GetUndoComments();
122 break;
123 case REDO:
124 comments = GetIDocumentUndoRedo().GetRedoComments();
125 break;
126 default:;//prevent warning
127 }
128
129 OUStringBuffer buf;
130 for (const OUString & comment : comments)
131 {
132 OSL_ENSURE(!comment.isEmpty(), "no Undo/Redo Text set");
133 buf.append(comment + "\n");
134 }
135 rStrs.SetString(buf.makeStringAndClear());
136}
137
139{
140 OUString str;
141 GetRepeatInfo(& str);
142
143 if (str.isEmpty())
144 {
145 return str;
146 }
147
148 return SvtResId(STR_REPEAT) + str;
149}
150
151/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetString(const OUString &)
const SwRect & GetCharRect() const
Definition: crsrsh.hxx:536
bool IsSelection() const
Definition: crsrsh.hxx:910
void CallChgLnk()
Definition: crsrsh.cxx:2847
sal_uInt16 GetCntType() const
Determine form of content. Return Type at CurrentCursor->SPoint.
Definition: edws.cxx:126
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
void Repeat(sal_uInt16 const nCount)
Definition: edundo.cxx:214
bool GetFirstRedoInfo(OUString *const o_pStr, SwUndoId *const o_pId, const SwView *pView=nullptr) const
Definition: edws.cxx:244
bool GetLastUndoInfo(OUString *const o_pStr, SwUndoId *const o_pId, const SwView *pView=nullptr) const
Definition: edws.cxx:237
void Redo(sal_uInt16 const nCount=1)
Definition: edundo.cxx:162
void Undo(sal_uInt16 const nCount=1, sal_uInt16 nOffset=0)
Definition: edundo.cxx:105
bool DoesUndo() const
Definition: edws.cxx:203
void DoUndo(bool bOn=true)
Undo.
Definition: edws.cxx:200
void EndAllAction()
Definition: edws.cxx:97
SwUndoId GetRepeatInfo(OUString *const o_pStr) const
Definition: edws.cxx:251
bool IsFrameSelected() const
Definition: feshview.cxx:1133
size_t IsObjSelected() const
Definition: feshview.cxx:1125
bool SelectObj(const Point &rSelPt, sal_uInt8 nFlag=0, SdrObject *pObj=nullptr)
If an object has been given, exactly this object is selected (instead of searching over position).
Definition: feshview.cxx:161
static void CreateSelection(SwWrtShell &rSh, const SwFrameShell *pCreator=nullptr)
Definition: swdtflvr.cxx:4370
IDocumentUndoRedo const & GetIDocumentUndoRedo() const
Provides access to the document undo/redo interface.
Definition: viewsh.cxx:2835
SAL_DLLPRIVATE tools::Long SetCursorKillSel(const Point *, bool bProp)
Definition: select.cxx:325
void EnterSelFrameMode(const Point *pStartDrag=nullptr)
Definition: select.cxx:711
OUString GetRepeatString() const
Definition: wrtundo.cxx:138
void GetDoStrings(DoType eDoType, SfxStringListItem &rStrLstItem) const
Definition: wrtundo.cxx:115
void EnterStdMode()
Definition: select.cxx:560
SELECTFUNC m_fnKillSel
Definition: wrtsh.hxx:117
void Do(DoType eDoType, sal_uInt16 nCnt=1, sal_uInt16 nOffset=0)
Definition: wrtundo.cxx:33
SwView & m_rView
Definition: wrtsh.hxx:573
SELECTFUNC m_fnSetCursor
Definition: wrtsh.hxx:115
void UnSelectFrame()
Definition: select.cxx:332
tools::Long ResetSelect(const Point *, bool)
Definition: select.cxx:342
OUString GetDoString(DoType eDoType) const
Definition: wrtundo.cxx:95
#define CNT_OLE
Definition: editsh.hxx:133
#define CNT_GRF
Definition: editsh.hxx:132
SVT_DLLPUBLIC OUString SvtResId(TranslateId aId)
std::vector< OUString > SwUndoComments_t
Definition: swundo.hxx:26