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 <DisposeHelper.hxx>
22 #include <CommonFunctors.hxx>
23 #include <PropertyHelper.hxx>
24 #include "ChartModelClone.hxx"
26 #include <com/sun/star/lang/DisposedException.hpp>
28 #include <tools/diagnose_ex.h>
29 #include <svx/svdundo.hxx>
34 using namespace ::com::sun::star
;
40 using ::com::sun::star::uno::Reference
;
41 using ::com::sun::star::uno::RuntimeException
;
42 using ::com::sun::star::frame::XModel
;
43 using ::com::sun::star::lang::DisposedException
;
45 UndoElement::UndoElement( const OUString
& i_actionString
, const Reference
< XModel
>& i_documentModel
, const std::shared_ptr
< ChartModelClone
>& i_modelClone
)
47 ,UndoElement_TBase( m_aMutex
)
48 ,m_sActionString( i_actionString
)
49 ,m_xDocumentModel( i_documentModel
)
50 ,m_pModelClone( i_modelClone
)
54 UndoElement::~UndoElement()
58 void SAL_CALL
UndoElement::disposing()
61 m_pModelClone
->dispose();
62 m_pModelClone
.reset();
63 m_xDocumentModel
.clear();
66 OUString SAL_CALL
UndoElement::getTitle()
68 return m_sActionString
;
71 void UndoElement::impl_toggleModelState()
73 // get a snapshot of the current state of our model
74 std::shared_ptr
< ChartModelClone
> pNewClone( new ChartModelClone( m_xDocumentModel
, m_pModelClone
->getFacet() ) );
75 // apply the previous snapshot to our model
76 m_pModelClone
->applyToModel( m_xDocumentModel
);
77 // remember the new snapshot, for the next toggle
78 m_pModelClone
= pNewClone
;
81 void SAL_CALL
UndoElement::undo( )
83 impl_toggleModelState();
86 void SAL_CALL
UndoElement::redo( )
88 impl_toggleModelState();
93 ShapeUndoElement::ShapeUndoElement( SdrUndoAction
& i_sdrUndoAction
)
94 :ShapeUndoElement_MBase()
95 ,ShapeUndoElement_TBase( m_aMutex
)
96 ,m_pAction( &i_sdrUndoAction
)
100 ShapeUndoElement::~ShapeUndoElement()
104 OUString SAL_CALL
ShapeUndoElement::getTitle()
107 throw DisposedException( OUString(), *this );
108 return m_pAction
->GetComment();
111 void SAL_CALL
ShapeUndoElement::undo( )
114 throw DisposedException( OUString(), *this );
118 void SAL_CALL
ShapeUndoElement::redo( )
121 throw DisposedException( OUString(), *this );
125 void SAL_CALL
ShapeUndoElement::disposing()
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */