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 .
19 #ifndef INCLUDED_REPORTDESIGN_INC_UNDOENV_HXX
20 #define INCLUDED_REPORTDESIGN_INC_UNDOENV_HXX
22 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
23 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
24 #include <com/sun/star/container/XContainerListener.hpp>
25 #include <com/sun/star/container/XIndexAccess.hpp>
26 #include <com/sun/star/util/XModifyListener.hpp>
27 #include <com/sun/star/report/XSection.hpp>
30 #include <cppuhelper/implbase.hxx>
31 #include <svl/lstner.hxx>
33 #include "RptPage.hxx"
37 class OXUndoEnvironmentImpl
;
40 class SAL_DLLPUBLIC_RTTI OXUndoEnvironment final
41 : public ::cppu::WeakImplHelper
< css::beans::XPropertyChangeListener
42 , css::container::XContainerListener
43 , css::util::XModifyListener
47 const ::std::unique_ptr
<OXUndoEnvironmentImpl
> m_pImpl
;
49 OXUndoEnvironment(const OXUndoEnvironment
&) = delete;
50 OXUndoEnvironment
& operator=(const OXUndoEnvironment
&) = delete;
52 virtual ~OXUndoEnvironment() override
;
54 REPORTDESIGN_DLLPUBLIC
void SetUndoMode(bool _bUndo
);
57 OXUndoEnvironment(OReportModel
& _rModel
);
60 Create an object ob OUndoEnvLock locks the undo possibility
61 As long as in the OUndoEnvLock scope, no undo is possible for manipulated object.
65 OXUndoEnvironment
& m_rUndoEnv
;
67 OUndoEnvLock(OXUndoEnvironment
& _rUndoEnv
): m_rUndoEnv(_rUndoEnv
){m_rUndoEnv
.Lock();}
68 ~OUndoEnvLock(){ m_rUndoEnv
.UnLock(); }
72 This is near the same as OUndoEnvLock but it is also possible to ask for the current mode.
73 UndoMode will set if SID_UNDO is called in execute()
77 OXUndoEnvironment
& m_rUndoEnv
;
79 OUndoMode(OXUndoEnvironment
& _rUndoEnv
)
80 :m_rUndoEnv(_rUndoEnv
)
83 m_rUndoEnv
.SetUndoMode(true);
87 m_rUndoEnv
.SetUndoMode(false);
92 REPORTDESIGN_DLLPUBLIC
void Lock();
93 REPORTDESIGN_DLLPUBLIC
void UnLock();
94 bool IsLocked() const;
96 // returns sal_True is we are in UNDO
97 bool IsUndoMode() const;
100 struct Accessor
{ friend class OReportModel
; private: Accessor() { } };
101 void Clear(const Accessor
& _r
);
103 REPORTDESIGN_DLLPUBLIC
void AddElement(const css::uno::Reference
< css::uno::XInterface
>& Element
);
104 REPORTDESIGN_DLLPUBLIC
void RemoveElement(const css::uno::Reference
< css::uno::XInterface
>& Element
);
106 void AddSection( const css::uno::Reference
< css::report::XSection
>& _xSection
);
107 void RemoveSection( const css::uno::Reference
< css::report::XSection
>& _xSection
);
108 /** removes the section from the page out of the undo env
112 void RemoveSection(OReportPage
const * _pPage
);
116 virtual void SAL_CALL
disposing(const css::lang::EventObject
& Source
) override
;
118 // XPropertyChangeListener
119 virtual void SAL_CALL
propertyChange(const css::beans::PropertyChangeEvent
& evt
) override
;
121 // XContainerListener
122 virtual void SAL_CALL
elementInserted(const css::container::ContainerEvent
& rEvent
) override
;
123 virtual void SAL_CALL
elementReplaced(const css::container::ContainerEvent
& rEvent
) override
;
124 virtual void SAL_CALL
elementRemoved(const css::container::ContainerEvent
& rEvent
) override
;
127 virtual void SAL_CALL
modified( const css::lang::EventObject
& aEvent
) override
;
131 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
134 void implSetModified();
136 void switchListening( const css::uno::Reference
< css::container::XIndexAccess
>& _rxContainer
, bool _bStartListening
);
137 void switchListening( const css::uno::Reference
< css::uno::XInterface
>& _rxObject
, bool _bStartListening
);
139 ::std::vector
< css::uno::Reference
< css::container::XChild
> >::const_iterator
140 getSection(const css::uno::Reference
< css::container::XChild
>& _xContainer
) const;
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */