1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "UndoActions.hxx"
21 #include "ChartModelClone.hxx"
22 #include <ChartModel.hxx>
24 #include <com/sun/star/lang/DisposedException.hpp>
26 #include <svx/svdundo.hxx>
31 using namespace ::com::sun::star
;
35 using ::com::sun::star::lang::DisposedException
;
37 UndoElement::UndoElement( OUString i_actionString
, rtl::Reference
<::chart::ChartModel
> i_documentModel
, std::shared_ptr
< ChartModelClone
> i_modelClone
)
38 :m_sActionString(std::move( i_actionString
))
39 ,m_xDocumentModel(std::move( i_documentModel
))
40 ,m_pModelClone(std::move( i_modelClone
))
44 UndoElement::~UndoElement()
48 void UndoElement::disposing(std::unique_lock
<std::mutex
>&)
51 m_pModelClone
->dispose();
52 m_pModelClone
.reset();
53 m_xDocumentModel
.clear();
56 OUString SAL_CALL
UndoElement::getTitle()
58 return m_sActionString
;
61 void UndoElement::impl_toggleModelState()
63 // get a snapshot of the current state of our model
64 auto pNewClone
= std::make_shared
<ChartModelClone
>( m_xDocumentModel
, m_pModelClone
->getFacet() );
65 // apply the previous snapshot to our model
66 m_pModelClone
->applyToModel( m_xDocumentModel
);
67 // remember the new snapshot, for the next toggle
68 m_pModelClone
= std::move(pNewClone
);
71 void SAL_CALL
UndoElement::undo( )
73 impl_toggleModelState();
76 void SAL_CALL
UndoElement::redo( )
78 impl_toggleModelState();
83 ShapeUndoElement::ShapeUndoElement( std::unique_ptr
<SdrUndoAction
> xSdrUndoAction
)
84 :m_xAction( std::move(xSdrUndoAction
) )
88 ShapeUndoElement::~ShapeUndoElement()
92 OUString SAL_CALL
ShapeUndoElement::getTitle()
95 throw DisposedException( OUString(), *this );
96 return m_xAction
->GetComment();
99 void SAL_CALL
ShapeUndoElement::undo( )
102 throw DisposedException( OUString(), *this );
106 void SAL_CALL
ShapeUndoElement::redo( )
109 throw DisposedException( OUString(), *this );
113 } // namespace chart::impl
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */