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
19using ::std::unique_ptr;
20
22 ScDocShell* pDocSh,
23 const std::map<OUString, ScRangeName*>& rOldNames,
24 const std::map<OUString, ScRangeName>& rNewNames)
25 : ScSimpleUndo(pDocSh)
26{
27 for (const auto& [rName, pRangeName] : rOldNames)
28 {
29 m_OldNames.insert(std::make_pair(rName, *pRangeName));
30 }
31
32 for (auto const& it : rNewNames)
33 {
34 m_NewNames.insert(std::make_pair(it.first, it.second));
35 }
36}
37
39{
40}
41
43{
45}
46
48{
50}
51
53{
54}
55
57{
58 return false;
59}
60
62{
63 return ScResId(STR_UNDO_RANGENAMES);
64}
65
66void ScUndoAllRangeNames::DoChange(const std::map<OUString, ScRangeName>& rNames)
67{
69
71 rDoc.SetAllRangeNames(rNames);
73
74 SfxGetpApp()->Broadcast(SfxHint(SfxHintId::ScAreasChanged));
75}
76
78 ScSimpleUndo(pDocSh),
79 mpRangeData(new ScRangeData(*pRangeData)),
80 mnTab(nTab)
81{
82
83}
84
86{
87}
88
90{
92 ScRangeName* pRangeName = nullptr;
93 if (mnTab == -1)
94 {
95 pRangeName = rDoc.GetRangeName();
96 }
97 else
98 {
99 pRangeName = rDoc.GetRangeName( mnTab );
100 }
101 pRangeName->erase(*mpRangeData);
102 SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreasChanged ) );
103
104}
105
107{
109 ScRangeName* pRangeName = nullptr;
110 if (mnTab == -1)
111 {
112 pRangeName = rDoc.GetRangeName();
113 }
114 else
115 {
116 pRangeName = rDoc.GetRangeName( mnTab );
117 }
118 pRangeName->insert(new ScRangeData(*mpRangeData));
119 SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreasChanged ) );
120}
121
123{
124}
125
127{
128 return false;
129}
130
132{
133 return ScResId(STR_UNDO_RANGENAMES);
134}
135
136/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxApplication * SfxGetpApp()
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
SC_DLLPUBLIC void SetAllRangeNames(const std::map< OUString, ScRangeName > &rRangeMap)
Definition: documen3.cxx:129
SC_DLLPUBLIC void CompileHybridFormula()
Call this immediately after updating named ranges.
Definition: document10.cxx:317
SC_DLLPUBLIC void PreprocessAllRangeNamesUpdate(const std::map< OUString, ScRangeName > &rRangeMap)
Call this immediately before updating all named ranges.
Definition: document10.cxx:249
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:174
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