LibreOffice Module sc (master)  1
undocell2.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 
10 #include <undocell.hxx>
11 #include <globstr.hrc>
12 #include <scresid.hxx>
13 #include <cellvalues.hxx>
14 #include <formulacell.hxx>
15 
16 namespace sc {
17 
18 UndoSetCells::UndoSetCells( ScDocShell* pDocSh, const ScAddress& rTopPos ) :
19  ScSimpleUndo(pDocSh), maTopPos(rTopPos) {}
20 
22 
23 void UndoSetCells::DoChange( const CellValues& rValues )
24 {
25  ScDocument& rDoc = pDocShell->GetDocument();
26  rDoc.CopyCellValuesFrom(maTopPos, rValues);
27 
28  ScRange aRange(maTopPos);
29  aRange.aEnd.IncRow(rValues.size());
30  BroadcastChanges(aRange);
32 }
33 
35 {
36  BeginUndo();
38  EndUndo();
39 }
40 
42 {
43  BeginRedo();
45  EndRedo();
46 }
47 
49 {
50  return false;
51 }
52 
53 OUString UndoSetCells::GetComment() const
54 {
55  // "Input"
56  return ScResId(STR_UNDO_ENTERDATA);
57 }
58 
59 void UndoSetCells::SetNewValues( const std::vector<double>& rVals )
60 {
61  maNewValues.assign(rVals);
62 }
63 
64 void UndoSetCells::SetNewValues( const std::vector<ScFormulaCell*>& rVals )
65 {
66  maNewValues.assign(rVals);
67 }
68 
69 }
70 
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void Redo() override
Definition: undocell2.cxx:41
UndoSetCells(ScDocShell *pDocSh, const ScAddress &rTopPos)
Definition: undocell2.cxx:18
void PostPaintGridAll()
Definition: docsh3.cxx:181
ScAddress maTopPos
Definition: undocell.hxx:347
Think of this as a mini-ScColumn like storage that only stores cell values in a column.
Definition: cellvalues.hxx:42
CellValues maNewValues
Definition: undocell.hxx:349
ScAddress aEnd
Definition: address.hxx:501
void EndUndo()
Definition: undobase.cxx:122
void assign(const std::vector< double > &rVals)
Definition: cellvalues.cxx:91
void BeginRedo()
Definition: undobase.cxx:142
void SetNewValues(const std::vector< double > &rVals)
Definition: undocell2.cxx:59
size_t size() const
Definition: cellvalues.cxx:121
ScDocShell * pDocShell
Definition: undobase.hxx:48
void IncRow(SCROW nDelta=1)
Definition: address.hxx:300
OUString ScResId(const char *pId)
Definition: scdll.cxx:95
void CopyCellValuesFrom(const ScAddress &rTopPos, const sc::CellValues &rSrc)
Definition: document10.cxx:173
virtual bool CanRepeat(SfxRepeatTarget &) const override
Definition: undocell2.cxx:48
CellValues maOldValues
Definition: undocell.hxx:348
void DoChange(const CellValues &rValues)
Definition: undocell2.cxx:23
virtual void Undo() override
Definition: undocell2.cxx:34
virtual OUString GetComment() const override
Definition: undocell2.cxx:53
const ScDocument & GetDocument() const
Definition: docsh.hxx:216
void BroadcastChanges(const ScRange &rRange)
Definition: undobase.cxx:174
virtual ~UndoSetCells() override
Definition: undocell2.cxx:21
void EndRedo()
Definition: undobase.cxx:151
void BeginUndo()
Definition: undobase.cxx:87