| 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 | #pragma once |
| 11 | |
| 12 | #include <undobase.hxx> |
| 13 | |
| 14 | #include <memory> |
| 15 | #include <map> |
| 16 | |
| 17 | class ScDocShell; |
| 18 | |
| 19 | /** |
| 20 | * Undo object for named ranges, both in global and sheet-local scopes. |
| 21 | */ |
| 22 | class ScUndoAllRangeNames final : public ScSimpleUndo |
| 23 | { |
| 24 | public: |
| 25 | ScUndoAllRangeNames(ScDocShell& rDocSh, const std::map<OUString, ScRangeName*>& rOldNames, |
| 26 | const std::map<OUString, ScRangeName>& rNewNames); |
| 27 | |
| 28 | virtual ~ScUndoAllRangeNames() override; |
| 29 | |
| 30 | virtual void Undo() override; |
| 31 | virtual void Redo() override; |
| 32 | virtual void Repeat(SfxRepeatTarget& rTarget) override; |
| 33 | virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; |
| 34 | virtual OUString GetComment() const override; |
| 35 | |
| 36 | private: |
| 37 | void DoChange(const std::map<OUString, ScRangeName>& rNames); |
| 38 | |
| 39 | private: |
| 40 | std::map<OUString, ScRangeName> m_OldNames; |
| 41 | std::map<OUString, ScRangeName> m_NewNames; |
| 42 | }; |
| 43 | |
| 44 | class ScUndoAddRangeData final : public ScSimpleUndo |
| 45 | { |
| 46 | public: |
| 47 | // nTab = -1 for global range names |
| 48 | ScUndoAddRangeData(ScDocShell& rDocSh, const ScRangeData* pRangeData, SCTAB nTab); |
| 49 | |
| 50 | virtual ~ScUndoAddRangeData() override; |
| 51 | |
| 52 | virtual void Undo() override; |
| 53 | virtual void Redo() override; |
| 54 | virtual void Repeat(SfxRepeatTarget& rTarget) override; |
| 55 | virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; |
| 56 | virtual OUString GetComment() const override; |
| 57 | |
| 58 | private: |
| 59 | std::unique_ptr<ScRangeData> mpRangeData; |
| 60 | SCTAB mnTab; |
| 61 | }; |
| 62 | |
| 63 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |