LibreOffice Module reportdesign (master)  1
UndoEnv.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 #ifndef INCLUDED_REPORTDESIGN_INC_UNDOENV_HXX
20 #define INCLUDED_REPORTDESIGN_INC_UNDOENV_HXX
21 
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>
28 
29 #include <memory>
30 #include <cppuhelper/implbase.hxx>
31 #include <svl/lstner.hxx>
32 #include "dllapi.h"
33 #include "RptPage.hxx"
34 
35 namespace rptui
36 {
37  class OXUndoEnvironmentImpl;
38 
39 
41  : public ::cppu::WeakImplHelper< css::beans::XPropertyChangeListener
42  , css::container::XContainerListener
43  , css::util::XModifyListener
44  >
45  , public SfxListener
46  {
47  const ::std::unique_ptr<OXUndoEnvironmentImpl> m_pImpl;
48 
49  OXUndoEnvironment(const OXUndoEnvironment&) = delete;
50  OXUndoEnvironment& operator=(const OXUndoEnvironment&) = delete;
51 
52  virtual ~OXUndoEnvironment() override;
53 
54  void SetUndoMode(bool _bUndo);
55 
56  public:
58 
64  {
66  public:
67  OUndoEnvLock(OXUndoEnvironment& _rUndoEnv): m_rUndoEnv(_rUndoEnv){m_rUndoEnv.Lock();}
68  ~OUndoEnvLock(){ m_rUndoEnv.UnLock(); }
69  };
70 
75  class OUndoMode
76  {
78  public:
80  :m_rUndoEnv(_rUndoEnv)
81  {
82  m_rUndoEnv.Lock();
83  m_rUndoEnv.SetUndoMode(true);
84  }
86  {
87  m_rUndoEnv.SetUndoMode(false);
88  m_rUndoEnv.UnLock();
89  }
90  };
91 
92  void Lock();
93  void UnLock();
94  bool IsLocked() const;
95 
96  // returns sal_True is we are in UNDO
97  bool IsUndoMode() const;
98 
99  // access control
100  struct Accessor { friend class OReportModel; private: Accessor() { } };
101  void Clear(const Accessor& _r);
102 
103  void AddElement(const css::uno::Reference< css::uno::XInterface>& Element);
104  void RemoveElement(const css::uno::Reference< css::uno::XInterface>& Element);
105 
106  void AddSection( const css::uno::Reference< css::report::XSection>& _xSection);
107  void RemoveSection( const css::uno::Reference< css::report::XSection>& _xSection );
112  void RemoveSection(OReportPage const * _pPage);
113 
114  private:
115  // XEventListener
116  virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
117 
118  // XPropertyChangeListener
119  virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override;
120 
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;
125 
126  // XModifyListener
127  virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
128 
129  void ModeChanged();
130 
131  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
132 
133  private:
134  void implSetModified();
135 
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 );
138 
139  ::std::vector< css::uno::Reference< css::container::XChild> >::const_iterator
140  getSection(const css::uno::Reference< css::container::XChild>& _xContainer) const;
141  };
142 
143 }
144 #endif
145 
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Create an object ob OUndoEnvLock locks the undo possibility As long as in the OUndoEnvLock scope...
Definition: UndoEnv.hxx:63
void SAL_CALL elementReplaced(const css::container::ContainerEvent &Event) override
#define REPORTDESIGN_DLLPUBLIC
Definition: dllapi.h:28
const ::std::unique_ptr< OXUndoEnvironmentImpl > m_pImpl
Definition: UndoEnv.hxx:47
OXUndoEnvironment & m_rUndoEnv
Definition: UndoEnv.hxx:77
void SAL_CALL elementRemoved(const css::container::ContainerEvent &Event) override
DECL_LISTENERMULTIPLEXER_END void SAL_CALL elementInserted(const css::container::ContainerEvent &Event) override
OUndoMode(OXUndoEnvironment &_rUndoEnv)
Definition: UndoEnv.hxx:79
void Clear(EHistoryType eHistory)
void SetUndoMode(bool _bUndo)
Definition: UndoEnv.cxx:606
OUndoEnvLock(OXUndoEnvironment &_rUndoEnv)
Definition: UndoEnv.hxx:67
This is near the same as OUndoEnvLock but it is also possible to ask for the current mode...
Definition: UndoEnv.hxx:75
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldPrt)