LibreOffice Module sc (master) 1
undorangename.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 <undorangename.hxx>
11#include <globstr.hrc>
12#include <scresid.hxx>
13
14#include <sfx2/app.hxx>
15
16#include <memory>
17#include <utility>
18
20 ScDocShell* pDocSh,
21 const std::map<OUString, ScRangeName*>& rOldNames,
22 const std::map<OUString, ScRangeName>& rNewNames)
23 : ScSimpleUndo(pDocSh)
24{
25 for (const auto& [rName, pRangeName] : rOldNames)
26 {
27 m_OldNames.insert(std::make_pair(rName, *pRangeName));
28 }
29
30 for (auto const& it : rNewNames)
31 {
32 m_NewNames.insert(std::make_pair(it.first, it.second));
33 }
34}
35
37{
38}
39
41{
43}
44
46{
48}
49
50void ScUndoAllRangeNames::Repeat(SfxRepeatTarget& /*rTarget*/)
51{
52}
53
54bool ScUndoAllRangeNames::CanRepeat(SfxRepeatTarget& /*rTarget*/) const
55{
56 return false;
57}
58
60{
61 return ScResId(STR_UNDO_RANGENAMES);
62}
63
64void ScUndoAllRangeNames::DoChange(const std::map<OUString, ScRangeName>& rNames)
65{
67
69 rDoc.SetAllRangeNames(rNames);
71
72 SfxGetpApp()->Broadcast(SfxHint(SfxHintId::ScAreasChanged));
73}
74
76 ScSimpleUndo(pDocSh),
77 mpRangeData(new ScRangeData(*pRangeData)),
78 mnTab(nTab)
79{
80
81}
82
84{
85}
86
88{
90 ScRangeName* pRangeName = nullptr;
91 if (mnTab == -1)
92 {
93 pRangeName = rDoc.GetRangeName();
94 }
95 else
96 {
97 pRangeName = rDoc.GetRangeName( mnTab );
98 }
99 pRangeName->erase(*mpRangeData);
100 SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreasChanged ) );
101
102}
103
105{
107 ScRangeName* pRangeName = nullptr;
108 if (mnTab == -1)
109 {
110 pRangeName = rDoc.GetRangeName();
111 }
112 else
113 {
114 pRangeName = rDoc.GetRangeName( mnTab );
115 }
116 pRangeName->insert(new ScRangeData(*mpRangeData));
117 SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreasChanged ) );
118}
119
120void ScUndoAddRangeData::Repeat(SfxRepeatTarget& /*rTarget*/)
121{
122}
123
124bool ScUndoAddRangeData::CanRepeat(SfxRepeatTarget& /*rTarget*/) const
125{
126 return false;
127}
128
130{
131 return ScResId(STR_UNDO_RANGENAMES);
132}
133
134/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxApplication * SfxGetpApp()
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
SC_DLLPUBLIC void SetAllRangeNames(const std::map< OUString, ScRangeName > &rRangeMap)
Definition: documen3.cxx:126
SC_DLLPUBLIC void CompileHybridFormula()
Call this immediately after updating named ranges.
Definition: document10.cxx:319
SC_DLLPUBLIC void PreprocessAllRangeNamesUpdate(const std::map< OUString, ScRangeName > &rRangeMap)
Call this immediately before updating all named ranges.
Definition: document10.cxx:251
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:171
void erase(const ScRangeData &r)
Definition: rangenam.cxx:846
SC_DLLPUBLIC bool insert(ScRangeData *p, bool bReuseFreeIndex=true)
Insert object into set.
Definition: rangenam.cxx:802
ScDocShell * pDocShell
Definition: undobase.hxx:50
std::unique_ptr< ScRangeData > mpRangeData
virtual void Undo() override
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
ScUndoAddRangeData(ScDocShell *pDocSh, const ScRangeData *pRangeData, SCTAB nTab)
virtual ~ScUndoAddRangeData() override
virtual OUString GetComment() const override
virtual void Repeat(SfxRepeatTarget &rTarget) override
virtual void Redo() override
virtual OUString GetComment() const override
virtual void Redo() override
std::map< OUString, ScRangeName > m_NewNames
void DoChange(const std::map< OUString, ScRangeName > &rNames)
virtual ~ScUndoAllRangeNames() override
virtual void Undo() override
ScUndoAllRangeNames(ScDocShell *pDocSh, const std::map< OUString, ScRangeName * > &rOldNames, const std::map< OUString, ScRangeName > &rNewNames)
std::map< OUString, ScRangeName > m_OldNames
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual void Repeat(SfxRepeatTarget &rTarget) override
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
sal_Int16 SCTAB
Definition: types.hxx:22