LibreOffice Module chart2 (master) 1
UndoGuard.hxx
Go to the documentation of this file.
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 "ChartModelClone.hxx"
22
23#include <rtl/ustring.hxx>
24
25#include <memory>
26
27namespace com::sun::star::document { class XUndoManager; }
28namespace com::sun::star::frame { class XModel; }
29
30namespace chart
31{
32
37{
38public:
39 explicit UndoGuard(
40 OUString i_undoMessage,
41 const css::uno::Reference< css::document::XUndoManager > & i_undoManager,
42 const ModelFacet i_facet = E_MODEL
43 );
44 ~UndoGuard();
45
46 void commit();
47 void rollback();
48
49protected:
50 bool isActionPosted() const { return m_bActionPosted; }
51
52private:
53 void discardSnapshot();
54
55private:
57 const css::uno::Reference< css::document::XUndoManager > m_xUndoManager;
58
59 std::shared_ptr< ChartModelClone > m_pDocumentSnapshot;
60 OUString m_aUndoString;
62};
63
68{
69public:
70 explicit UndoLiveUpdateGuard(
71 const OUString& i_undoMessage,
72 const css::uno::Reference< css::document::XUndoManager > & i_undoManager
73 );
75};
76
81 public UndoGuard
82{
83public:
85 const OUString& i_undoMessage,
86 const css::uno::Reference< css::document::XUndoManager > & i_undoManager
87 );
89};
90
92{
93public:
95 const OUString& i_undoMessage,
96 const css::uno::Reference< css::document::XUndoManager > & i_undoManager
97 );
99};
100
102{
103public:
104 explicit HiddenUndoContext(
105 const css::uno::Reference< css::document::XUndoManager > & i_undoManager
106 );
108
109private:
110 css::uno::Reference< css::document::XUndoManager > m_xUndoManager;
111};
112
113}
114
115/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
HiddenUndoContext(const css::uno::Reference< css::document::XUndoManager > &i_undoManager)
Definition: UndoGuard.cxx:121
css::uno::Reference< css::document::XUndoManager > m_xUndoManager
Definition: UndoGuard.hxx:110
UndoGuardWithSelection(const OUString &i_undoMessage, const css::uno::Reference< css::document::XUndoManager > &i_undoManager)
Definition: UndoGuard.cxx:109
A guard which does nothing, unless you explicitly call commitAction.
Definition: UndoGuard.hxx:37
void discardSnapshot()
Definition: UndoGuard.cxx:79
const css::uno::Reference< css::document::XUndoManager > m_xUndoManager
Definition: UndoGuard.hxx:57
bool isActionPosted() const
Definition: UndoGuard.hxx:50
UndoGuard(OUString i_undoMessage, const css::uno::Reference< css::document::XUndoManager > &i_undoManager, const ModelFacet i_facet=E_MODEL)
OUString m_aUndoString
Definition: UndoGuard.hxx:60
std::shared_ptr< ChartModelClone > m_pDocumentSnapshot
Definition: UndoGuard.hxx:59
rtl::Reference<::chart::ChartModel > m_xChartModel
Definition: UndoGuard.hxx:56
Same as UndoLiveUpdateGuard but with additional storage of the chart's data.
Definition: UndoGuard.hxx:82
UndoLiveUpdateGuardWithData(const OUString &i_undoMessage, const css::uno::Reference< css::document::XUndoManager > &i_undoManager)
Definition: UndoGuard.cxx:97
A guard which, in its destructor, restores the model state it found in the constructor.
Definition: UndoGuard.hxx:68
UndoLiveUpdateGuard(const OUString &i_undoMessage, const css::uno::Reference< css::document::XUndoManager > &i_undoManager)
Definition: UndoGuard.cxx:86