LibreOffice Module sfx2 (master) 1
docundomanager.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
20#ifndef INCLUDED_SFX2_SOURCE_INC_DOCUNDOMANAGER_HXX
21#define INCLUDED_SFX2_SOURCE_INC_DOCUNDOMANAGER_HXX
22
23#include <sfx2/sfxbasemodel.hxx>
24
25#include <com/sun/star/document/XUndoManager.hpp>
26
28#include <vcl/svapp.hxx>
29
30#include <memory>
31
35{
36public:
40 {
42 }
43
44protected:
46 :m_rModel( i_model )
47 {
48 }
49 virtual ~SfxModelSubComponent();
50
53
54protected:
55 const SfxBaseModel& getBaseModel() const { return m_rModel; }
57
58private:
60};
61
63{
64public:
66 {
67 // not yet initialized
69 // fully alive, i.e. initialized, and not yet disposed
71 };
72
73 SfxModelGuard( SfxBaseModel const & i_rModel, const AllowedModelState i_eState = E_FULLY_ALIVE )
74 : m_aGuard()
75 {
76 i_rModel.MethodEntryCheck( i_eState != E_INITIALIZING );
77 }
79 :m_aGuard()
80 {
81 i_rSubComponent.MethodEntryCheck();
82 }
83
84 void clear()
85 {
86 m_aGuard.clear();
87 }
88
89private:
91};
92
93namespace sfx2
94{
95 //= DocumentUndoManager
96
97 struct DocumentUndoManager_Impl;
98 class DocumentUndoManager final : public ::cppu::WeakImplHelper<css::document::XUndoManager>
100 {
102
103 public:
104 DocumentUndoManager( SfxBaseModel& i_document );
105 virtual ~DocumentUndoManager() override;
108
109 void disposing();
110
111 // non-UNO API for our owner
115 bool isInContext() const;
116
117 // XInterface
118 virtual void SAL_CALL acquire( ) noexcept override;
119 virtual void SAL_CALL release( ) noexcept override;
120
121 // XUndoManager
122 virtual void SAL_CALL enterUndoContext( const OUString& i_title ) override;
123 virtual void SAL_CALL enterHiddenUndoContext( ) override;
124 virtual void SAL_CALL leaveUndoContext( ) override;
125 virtual void SAL_CALL addUndoAction( const css::uno::Reference< css::document::XUndoAction >& i_action ) override;
126 virtual void SAL_CALL undo( ) override;
127 virtual void SAL_CALL redo( ) override;
128 virtual sal_Bool SAL_CALL isUndoPossible( ) override;
129 virtual sal_Bool SAL_CALL isRedoPossible( ) override;
130 virtual OUString SAL_CALL getCurrentUndoActionTitle( ) override;
131 virtual OUString SAL_CALL getCurrentRedoActionTitle( ) override;
132 virtual css::uno::Sequence< OUString > SAL_CALL getAllUndoActionTitles( ) override;
133 virtual css::uno::Sequence< OUString > SAL_CALL getAllRedoActionTitles( ) override;
134 virtual void SAL_CALL clear( ) override;
135 virtual void SAL_CALL clearRedo( ) override;
136 virtual void SAL_CALL reset( ) override;
137 virtual void SAL_CALL addUndoManagerListener( const css::uno::Reference< css::document::XUndoManagerListener >& i_listener ) override;
138 virtual void SAL_CALL removeUndoManagerListener( const css::uno::Reference< css::document::XUndoManagerListener >& i_listener ) override;
139
140 // XLockable, base of XUndoManager
141 virtual void SAL_CALL lock( ) override;
142 virtual void SAL_CALL unlock( ) override;
143 virtual sal_Bool SAL_CALL isLocked( ) override;
144
145 // XChild, base of XUndoManager
146 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override;
147 virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override;
148
149 private:
151 };
152
153
154} // namespace sfx2
155
156
157#endif // INCLUDED_SFX2_SOURCE_INC_DOCUNDOMANAGER_HXX
158
159/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void MethodEntryCheck(const bool i_mustBeInitialized) const
virtual void SAL_CALL acquire() noexcept override
increment refcount @seealso XInterface @seealso release() @onerror A RuntimeException is thrown.
virtual void SAL_CALL release() noexcept override
decrement refcount @seealso XInterface @seealso acquire() @onerror A RuntimeException is thrown.
SfxModelGuard(SfxModelSubComponent &i_rSubComponent)
SolarMutexClearableGuard m_aGuard
SfxModelGuard(SfxBaseModel const &i_rModel, const AllowedModelState i_eState=E_FULLY_ALIVE)
base class for sub components of an SfxBaseModel, which share their ref count and lifetime with the S...
SfxModelSubComponent(SfxBaseModel &i_model)
SfxBaseModel & m_rModel
void MethodEntryCheck()
checks whether the instance is alive, i.e.
virtual ~SfxModelSubComponent()
const SfxBaseModel & getBaseModel() const
SfxBaseModel & getBaseModel()
virtual sal_Bool SAL_CALL isUndoPossible() override
virtual void SAL_CALL redo() override
virtual void SAL_CALL clear() override
virtual css::uno::Sequence< OUString > SAL_CALL getAllRedoActionTitles() override
DocumentUndoManager & operator=(const DocumentUndoManager &)=delete
virtual void SAL_CALL undo() override
virtual OUString SAL_CALL getCurrentUndoActionTitle() override
virtual void SAL_CALL enterHiddenUndoContext() override
virtual void SAL_CALL clearRedo() override
virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface > &Parent) override
virtual void SAL_CALL addUndoManagerListener(const css::uno::Reference< css::document::XUndoManagerListener > &i_listener) override
virtual void SAL_CALL release() noexcept override
DocumentUndoManager(const DocumentUndoManager &)=delete
virtual void SAL_CALL leaveUndoContext() override
virtual void SAL_CALL enterUndoContext(const OUString &i_title) override
bool isInContext() const
determines whether we have an open Undo context.
std::unique_ptr< DocumentUndoManager_Impl > m_pImpl
virtual OUString SAL_CALL getCurrentRedoActionTitle() override
virtual void SAL_CALL unlock() override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
virtual void SAL_CALL removeUndoManagerListener(const css::uno::Reference< css::document::XUndoManagerListener > &i_listener) override
DocumentUndoManager(SfxBaseModel &i_document)
virtual void SAL_CALL reset() override
virtual sal_Bool SAL_CALL isRedoPossible() override
virtual void SAL_CALL lock() override
virtual css::uno::Sequence< OUString > SAL_CALL getAllUndoActionTitles() override
virtual ~DocumentUndoManager() override
virtual void SAL_CALL addUndoAction(const css::uno::Reference< css::document::XUndoAction > &i_action) override
virtual void SAL_CALL acquire() noexcept override
virtual sal_Bool SAL_CALL isLocked() override
called to query another interface of the component @descr Will allow to query for XInteractionHandler...
unsigned char sal_Bool