fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / undo / undorangename.cxx
blob6cb3d6c8b27a2c37ff80eb21eff5444c77491404
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include "undorangename.hxx"
11 #include "globstr.hrc"
12 #include "global.hxx"
13 #include "docfunc.hxx"
14 #include "sc.hrc"
16 #include <o3tl/ptr_container.hxx>
17 #include <sfx2/app.hxx>
19 #include <memory>
20 #include <utility>
22 using ::std::unique_ptr;
24 ScUndoAllRangeNames::ScUndoAllRangeNames(
25 ScDocShell* pDocSh,
26 const std::map<OUString, ScRangeName*>& rOldNames,
27 const boost::ptr_map<OUString, ScRangeName>& rNewNames) :
28 ScSimpleUndo(pDocSh)
30 std::map<OUString, ScRangeName*>::const_iterator itr, itrEnd;
31 for (itr = rOldNames.begin(), itrEnd = rOldNames.end(); itr != itrEnd; ++itr)
33 unique_ptr<ScRangeName> p(new ScRangeName(*itr->second));
34 o3tl::ptr_container::insert(maOldNames, itr->first, std::move(p));
37 boost::ptr_map<OUString, ScRangeName>::const_iterator it, itEnd;
38 for (it = rNewNames.begin(), itEnd = rNewNames.end(); it != itEnd; ++it)
40 unique_ptr<ScRangeName> p(new ScRangeName(*it->second));
41 o3tl::ptr_container::insert(maNewNames, it->first, std::move(p));
45 ScUndoAllRangeNames::~ScUndoAllRangeNames()
49 void ScUndoAllRangeNames::Undo()
51 DoChange(maOldNames);
54 void ScUndoAllRangeNames::Redo()
56 DoChange(maNewNames);
59 void ScUndoAllRangeNames::Repeat(SfxRepeatTarget& /*rTarget*/)
63 bool ScUndoAllRangeNames::CanRepeat(SfxRepeatTarget& /*rTarget*/) const
65 return false;
68 OUString ScUndoAllRangeNames::GetComment() const
70 return ScGlobal::GetRscString(STR_UNDO_RANGENAMES);
73 void ScUndoAllRangeNames::DoChange(const boost::ptr_map<OUString, ScRangeName>& rNames)
75 ScDocument& rDoc = pDocShell->GetDocument();
77 rDoc.PreprocessRangeNameUpdate();
78 rDoc.SetAllRangeNames(rNames);
79 rDoc.CompileHybridFormula();
81 SfxGetpApp()->Broadcast(SfxSimpleHint(SC_HINT_AREAS_CHANGED));
84 ScUndoAddRangeData::ScUndoAddRangeData(ScDocShell* pDocSh, ScRangeData* pRangeData, SCTAB nTab) :
85 ScSimpleUndo(pDocSh),
86 mpRangeData(new ScRangeData(*pRangeData)),
87 mnTab(nTab)
92 ScUndoAddRangeData::~ScUndoAddRangeData()
94 delete mpRangeData;
97 void ScUndoAddRangeData::Undo()
99 ScDocument& rDoc = pDocShell->GetDocument();
100 ScRangeName* pRangeName = NULL;
101 if (mnTab == -1)
103 pRangeName = rDoc.GetRangeName();
105 else
107 pRangeName = rDoc.GetRangeName( mnTab );
109 pRangeName->erase(*mpRangeData);
110 SfxGetpApp()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
114 void ScUndoAddRangeData::Redo()
116 ScDocument& rDoc = pDocShell->GetDocument();
117 ScRangeName* pRangeName = NULL;
118 if (mnTab == -1)
120 pRangeName = rDoc.GetRangeName();
122 else
124 pRangeName = rDoc.GetRangeName( mnTab );
126 pRangeName->insert(new ScRangeData(*mpRangeData));
127 SfxGetpApp()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
130 void ScUndoAddRangeData::Repeat(SfxRepeatTarget& /*rTarget*/)
134 bool ScUndoAddRangeData::CanRepeat(SfxRepeatTarget& /*rTarget*/) const
136 return false;
139 OUString ScUndoAddRangeData::GetComment() const
141 return ScGlobal::GetRscString(STR_UNDO_RANGENAMES);
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */