LCOV - code coverage report
Current view: top level - libreoffice/reportdesign/inc - UndoEnv.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 12 0.0 %
Date: 2012-12-27 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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_UNDOENV_HXX
      20             : #define INCLUDED_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/report/XReportDefinition.hpp>
      26             : 
      27             : #include <cppuhelper/compbase3.hxx>
      28             : #include <memory>
      29             : #include <svl/lstner.hxx>
      30             : 
      31             : namespace rptui
      32             : {
      33             :     class OXUndoEnvironmentImpl;
      34             : 
      35             :     //========================================================================
      36             :     class REPORTDESIGN_DLLPUBLIC OXUndoEnvironment
      37             :         : public ::cppu::WeakImplHelper3<   ::com::sun::star::beans::XPropertyChangeListener
      38             :                                         ,   ::com::sun::star::container::XContainerListener
      39             :                                         ,   ::com::sun::star::util::XModifyListener
      40             :                                         >
      41             :         , public SfxListener
      42             :     {
      43             :         const ::std::auto_ptr<OXUndoEnvironmentImpl> m_pImpl;
      44             : 
      45             :         OXUndoEnvironment(const OXUndoEnvironment&);
      46             :         OXUndoEnvironment& operator=(const OXUndoEnvironment&);
      47             : 
      48             :     protected:
      49             :         virtual ~OXUndoEnvironment();
      50             : 
      51             :         void SetUndoMode(sal_Bool _bUndo);
      52             : 
      53             :     public:
      54             :         OXUndoEnvironment(OReportModel& _rModel);
      55             : 
      56             :         /**
      57             :            Create an object ob OUndoEnvLock locks the undo possibility
      58             :            As long as in the OUndoEnvLock scope, no undo is possible for manipulated object.
      59             :          */
      60             :         class OUndoEnvLock
      61             :         {
      62             :             OXUndoEnvironment& m_rUndoEnv;
      63             :         public:
      64           0 :             OUndoEnvLock(OXUndoEnvironment& _rUndoEnv): m_rUndoEnv(_rUndoEnv){m_rUndoEnv.Lock();}
      65           0 :             ~OUndoEnvLock(){ m_rUndoEnv.UnLock(); }
      66             :         };
      67             : 
      68             :         /**
      69             :            This is near the same as OUndoEnvLock but it is also possible to ask for the current mode.
      70             :            UndoMode will set if SID_UNDO is called in execute()
      71             :          */
      72             :         class OUndoMode
      73             :         {
      74             :             OXUndoEnvironment& m_rUndoEnv;
      75             :         public:
      76           0 :             OUndoMode(OXUndoEnvironment& _rUndoEnv)
      77           0 :                 :m_rUndoEnv(_rUndoEnv)
      78             :             {
      79           0 :                 m_rUndoEnv.Lock();
      80           0 :                 m_rUndoEnv.SetUndoMode(sal_True);
      81           0 :             }
      82           0 :             ~OUndoMode()
      83             :             {
      84           0 :                 m_rUndoEnv.SetUndoMode(sal_False);
      85           0 :                 m_rUndoEnv.UnLock();
      86           0 :             }
      87             :         };
      88             : 
      89             :         void Lock();
      90             :         void UnLock();
      91             :         sal_Bool IsLocked() const;
      92             : 
      93             :         // returns sal_True is we are in UNDO
      94             :         sal_Bool IsUndoMode() const;
      95             : 
      96             :         // access control
      97           0 :         struct Accessor { friend class OReportModel; private: Accessor() { } };
      98             :         void Clear(const Accessor& _r);
      99             : 
     100             :         void AddElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
     101             :         void RemoveElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
     102             : 
     103             :         void AddSection( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection);
     104             :         void RemoveSection( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection );
     105             :         /** removes the section from the page out of the undo env
     106             :         *
     107             :         * \param _pPage
     108             :         */
     109             :         void RemoveSection(OReportPage* _pPage);
     110             : 
     111             :     protected:
     112             :         // XEventListener
     113             :         virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
     114             : 
     115             :         // XPropertyChangeListener
     116             :         virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
     117             : 
     118             :         // XContainerListener
     119             :         virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
     120             :         virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
     121             :         virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
     122             : 
     123             :         // XModifyListener
     124             :         virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
     125             : 
     126             :         void ModeChanged();
     127             : 
     128             :         virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
     129             : 
     130             :     private:
     131             :         void TogglePropertyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
     132             : 
     133             :         void    implSetModified();
     134             : 
     135             :         void    switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _rxContainer, bool _bStartListening ) SAL_THROW(());
     136             :         void    switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject, bool _bStartListening ) SAL_THROW(());
     137             : 
     138             :         ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild> >::const_iterator
     139             :             getSection(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild>& _xContainer) const;
     140             :     };
     141             : 
     142             : }
     143             : #endif //
     144             : 
     145             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10