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"
23 #include <com/sun/star/lang/DisposedException.hpp>
25 #include <svx/svdundo.hxx>
29 using namespace ::com::sun::star
;
35 using ::com::sun::star::uno::Reference
;
36 using ::com::sun::star::frame::XModel
;
37 using ::com::sun::star::lang::DisposedException
;
39 UndoElement::UndoElement( const OUString
& i_actionString
, const Reference
< XModel
>& i_documentModel
, const std::shared_ptr
< ChartModelClone
>& i_modelClone
)
41 ,UndoElement_TBase( m_aMutex
)
42 ,m_sActionString( i_actionString
)
43 ,m_xDocumentModel( i_documentModel
)
44 ,m_pModelClone( i_modelClone
)
48 UndoElement::~UndoElement()
52 void SAL_CALL
UndoElement::disposing()
55 m_pModelClone
->dispose();
56 m_pModelClone
.reset();
57 m_xDocumentModel
.clear();
60 OUString SAL_CALL
UndoElement::getTitle()
62 return m_sActionString
;
65 void UndoElement::impl_toggleModelState()
67 // get a snapshot of the current state of our model
68 std::shared_ptr
< ChartModelClone
> pNewClone( new ChartModelClone( m_xDocumentModel
, m_pModelClone
->getFacet() ) );
69 // apply the previous snapshot to our model
70 m_pModelClone
->applyToModel( m_xDocumentModel
);
71 // remember the new snapshot, for the next toggle
72 m_pModelClone
= pNewClone
;
75 void SAL_CALL
UndoElement::undo( )
77 impl_toggleModelState();
80 void SAL_CALL
UndoElement::redo( )
82 impl_toggleModelState();
87 ShapeUndoElement::ShapeUndoElement( std::unique_ptr
<SdrUndoAction
> xSdrUndoAction
)
88 :ShapeUndoElement_MBase()
89 ,ShapeUndoElement_TBase( m_aMutex
)
90 ,m_xAction( std::move(xSdrUndoAction
) )
94 ShapeUndoElement::~ShapeUndoElement()
98 OUString SAL_CALL
ShapeUndoElement::getTitle()
101 throw DisposedException( OUString(), *this );
102 return m_xAction
->GetComment();
105 void SAL_CALL
ShapeUndoElement::undo( )
108 throw DisposedException( OUString(), *this );
112 void SAL_CALL
ShapeUndoElement::redo( )
115 throw DisposedException( OUString(), *this );
119 void SAL_CALL
ShapeUndoElement::disposing()
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */