fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / controller / main / UndoActions.cxx
blobb09c070b022923b132a393dbfff51e334c11bac2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/chart2/XChartDocument.hpp>
27 #include <com/sun/star/util/XCloneable.hpp>
28 #include <com/sun/star/view/XSelectionSupplier.hpp>
29 #include <com/sun/star/lang/DisposedException.hpp>
31 #include <tools/diagnose_ex.h>
32 #include <svx/svdundo.hxx>
34 #include <boost/shared_ptr.hpp>
35 #include <algorithm>
37 using namespace ::com::sun::star;
39 namespace chart
41 namespace impl
43 using ::com::sun::star::uno::Reference;
44 using ::com::sun::star::uno::XInterface;
45 using ::com::sun::star::uno::UNO_QUERY;
46 using ::com::sun::star::uno::UNO_QUERY_THROW;
47 using ::com::sun::star::uno::UNO_SET_THROW;
48 using ::com::sun::star::uno::Exception;
49 using ::com::sun::star::uno::RuntimeException;
50 using ::com::sun::star::uno::Any;
51 using ::com::sun::star::uno::makeAny;
52 using ::com::sun::star::uno::Sequence;
53 using ::com::sun::star::uno::Type;
54 using ::com::sun::star::frame::XModel;
55 using ::com::sun::star::util::XCloneable;
56 using ::com::sun::star::lang::XComponent;
57 using ::com::sun::star::lang::DisposedException;
58 using ::com::sun::star::view::XSelectionSupplier;
59 using ::com::sun::star::chart2::XChartDocument;
60 using ::com::sun::star::document::UndoFailedException;
62 UndoElement::UndoElement( const OUString& i_actionString, const Reference< XModel >& i_documentModel, const ::boost::shared_ptr< ChartModelClone >& i_modelClone )
63 :UndoElement_MBase()
64 ,UndoElement_TBase( m_aMutex )
65 ,m_sActionString( i_actionString )
66 ,m_xDocumentModel( i_documentModel )
67 ,m_pModelClone( i_modelClone )
71 UndoElement::~UndoElement()
75 void SAL_CALL UndoElement::disposing()
77 if ( !!m_pModelClone )
78 m_pModelClone->dispose();
79 m_pModelClone.reset();
80 m_xDocumentModel.clear();
83 OUString SAL_CALL UndoElement::getTitle() throw (RuntimeException, std::exception)
85 return m_sActionString;
88 void UndoElement::impl_toggleModelState()
90 // get a snapshot of the current state of our model
91 ::boost::shared_ptr< ChartModelClone > pNewClone( new ChartModelClone( m_xDocumentModel, m_pModelClone->getFacet() ) );
92 // apply the previous snapshot to our model
93 m_pModelClone->applyToModel( m_xDocumentModel );
94 // remember the new snapshot, for the next toggle
95 m_pModelClone = pNewClone;
98 void SAL_CALL UndoElement::undo( ) throw (UndoFailedException, RuntimeException, std::exception)
100 impl_toggleModelState();
103 void SAL_CALL UndoElement::redo( ) throw (UndoFailedException, RuntimeException, std::exception)
105 impl_toggleModelState();
108 // = ShapeUndoElement
110 ShapeUndoElement::ShapeUndoElement( SdrUndoAction& i_sdrUndoAction )
111 :ShapeUndoElement_MBase()
112 ,ShapeUndoElement_TBase( m_aMutex )
113 ,m_pAction( &i_sdrUndoAction )
117 ShapeUndoElement::~ShapeUndoElement()
121 OUString SAL_CALL ShapeUndoElement::getTitle() throw (RuntimeException, std::exception)
123 if ( !m_pAction )
124 throw DisposedException( OUString(), *this );
125 return m_pAction->GetComment();
128 void SAL_CALL ShapeUndoElement::undo( ) throw (UndoFailedException, RuntimeException, std::exception)
130 if ( !m_pAction )
131 throw DisposedException( OUString(), *this );
132 m_pAction->Undo();
135 void SAL_CALL ShapeUndoElement::redo( ) throw (UndoFailedException, RuntimeException, std::exception)
137 if ( !m_pAction )
138 throw DisposedException( OUString(), *this );
139 m_pAction->Redo();
142 void SAL_CALL ShapeUndoElement::disposing()
146 } // namespace impl
147 } // namespace chart
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */