| 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 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 11 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
| 12 |
* contributor license agreements. See the NOTICE file distributed |
| 13 |
* with this work for additional information regarding copyright |
| 14 |
* ownership. The ASF licenses this file to you under the Apache |
| 15 |
* License, Version 2.0 (the "License"); you may not use this file |
| 16 |
* except in compliance with the License. You may obtain a copy of |
| 17 |
* the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 18 |
*/ |
| 19 |
#pragma once |
| 20 |
|
| 21 |
#include <com/sun/star/document/XUndoAction.hpp> |
| 22 |
|
| 23 |
#include <rtl/ref.hxx> |
| 24 |
#include <rtl/ustring.hxx> |
| 25 |
#include <comphelper/compbase.hxx> |
| 26 |
|
| 27 |
#include <memory> |
| 28 |
|
| 29 |
class SdrUndoAction; |
| 30 |
|
| 31 |
namespace chart |
| 32 |
{ |
| 33 |
class ChartModel; |
| 34 |
class ChartModelClone; |
| 35 |
|
| 36 |
namespace impl |
| 37 |
{ |
| 38 |
|
| 39 |
typedef comphelper::WeakComponentImplHelper< css::document::XUndoAction > UndoElement_TBase; |
| 40 |
|
| 41 |
class UndoElement final : public UndoElement_TBase |
| 42 |
{ |
| 43 |
public: |
| 44 |
/** creates a new undo action |
| 45 |
|
| 46 |
@param i_actionString |
| 47 |
is the title of the Undo action |
| 48 |
@param i_documentModel |
| 49 |
is the actual document model which the undo actions operates on |
| 50 |
@param i_modelClone |
| 51 |
is the cloned model from before the changes, which the Undo action represents, have been applied. |
| 52 |
Upon <member>invoking</member>, the clone model is applied to the document model. |
| 53 |
*/ |
| 54 |
UndoElement( OUString i_actionString, |
| 55 |
rtl::Reference<::chart::ChartModel> i_documentModel, |
| 56 |
std::shared_ptr< ChartModelClone > i_modelClone |
| 57 |
); |
| 58 |
virtual ~UndoElement() override; |
| 59 |
|
| 60 |
UndoElement(const UndoElement&) = delete; |
| 61 |
const UndoElement& operator=(const UndoElement&) = delete; |
| 62 |
|
| 63 |
// XUndoAction |
| 64 |
virtual OUString SAL_CALL getTitle() override; |
| 65 |
virtual void SAL_CALL undo( ) override; |
| 66 |
virtual void SAL_CALL redo( ) override; |
| 67 |
|
| 68 |
// WeakComponentImplHelper |
| 69 |
virtual void disposing(std::unique_lock<std::mutex>&) override; |
| 70 |
|
| 71 |
private: |
| 72 |
void impl_toggleModelState(); |
| 73 |
|
| 74 |
private: |
| 75 |
OUString m_sActionString; |
| 76 |
rtl::Reference<::chart::ChartModel> m_xDocumentModel; |
| 77 |
std::shared_ptr< ChartModelClone > m_pModelClone; |
| 78 |
}; |
| 79 |
|
| 80 |
typedef comphelper::WeakComponentImplHelper< css::document::XUndoAction > ShapeUndoElement_TBase; |
| 81 |
class ShapeUndoElement final : public ShapeUndoElement_TBase |
| 82 |
{ |
| 83 |
public: |
| 84 |
explicit ShapeUndoElement( std::unique_ptr<SdrUndoAction> xSdrUndoAction ); |
| 85 |
virtual ~ShapeUndoElement() override; |
| 86 |
|
| 87 |
// XUndoAction |
| 88 |
virtual OUString SAL_CALL getTitle() override; |
| 89 |
virtual void SAL_CALL undo( ) override; |
| 90 |
virtual void SAL_CALL redo( ) override; |
| 91 |
|
| 92 |
private: |
| 93 |
std::unique_ptr<SdrUndoAction> m_xAction; |
| 94 |
}; |
| 95 |
|
| 96 |
} // namespace impl |
| 97 |
} // namespace chart |
| 98 |
|
| 99 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |