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  protected:
53  virtual ~OXUndoEnvironment() override;
54 
55  void SetUndoMode(bool _bUndo);
56 
57  public:
59 
65  {
67  public:
68  OUndoEnvLock(OXUndoEnvironment& _rUndoEnv): m_rUndoEnv(_rUndoEnv){m_rUndoEnv.Lock();}
69  ~OUndoEnvLock(){ m_rUndoEnv.UnLock(); }
70  };
71 
76  class OUndoMode
77  {
79  public:
81  :m_rUndoEnv(_rUndoEnv)
82  {
83  m_rUndoEnv.Lock();
84  m_rUndoEnv.SetUndoMode(true);
85  }
87  {
88  m_rUndoEnv.SetUndoMode(false);
89  m_rUndoEnv.UnLock();
90  }
91  };
92 
93  void Lock();
94  void UnLock();
95  bool IsLocked() const;
96 
97  // returns sal_True is we are in UNDO
98  bool IsUndoMode() const;
99 
100  // access control
101  struct Accessor { friend class OReportModel; private: Accessor() { } };
102  void Clear(const Accessor& _r);
103 
104  void AddElement(const css::uno::Reference< css::uno::XInterface>& Element);
105  void RemoveElement(const css::uno::Reference< css::uno::XInterface>& Element);
106 
107  void AddSection( const css::uno::Reference< css::report::XSection>& _xSection);
108  void RemoveSection( const css::uno::Reference< css::report::XSection>& _xSection );
113  void RemoveSection(OReportPage const * _pPage);
114 
115  protected:
116  // XEventListener
117  virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
118 
119  // XPropertyChangeListener
120  virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override;
121 
122  // XContainerListener
123  virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override;
124  virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent& rEvent) override;
125  virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent& rEvent) override;
126 
127  // XModifyListener
128  virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
129 
130  void ModeChanged();
131 
132  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
133 
134  private:
135  void implSetModified();
136 
137  void switchListening( const css::uno::Reference< css::container::XIndexAccess >& _rxContainer, bool _bStartListening );
138  void switchListening( const css::uno::Reference< css::uno::XInterface >& _rxObject, bool _bStartListening );
139 
140  ::std::vector< css::uno::Reference< css::container::XChild> >::const_iterator
141  getSection(const css::uno::Reference< css::container::XChild>& _xContainer) const;
142  };
143 
144 }
145 #endif
146 
147 /* 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:64
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:78
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:80
void SetUndoMode(bool _bUndo)
Definition: UndoEnv.cxx:609
OUndoEnvLock(OXUndoEnvironment &_rUndoEnv)
Definition: UndoEnv.hxx:68
This is near the same as OUndoEnvLock but it is also possible to ask for the current mode...
Definition: UndoEnv.hxx:76
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldPrt)