LCOV - code coverage report
Current view: top level - reportdesign/inc - UndoActions.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 42 0.0 %
Date: 2014-11-03 Functions: 0 33 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_REPORTDESIGN_INC_UNDOACTIONS_HXX
      20             : #define INCLUDED_REPORTDESIGN_INC_UNDOACTIONS_HXX
      21             : 
      22             : #include "dllapi.h"
      23             : 
      24             : #include "RptModel.hxx"
      25             : 
      26             : #include <com/sun/star/util/XModifyListener.hpp>
      27             : #include <com/sun/star/beans/XPropertySet.hpp>
      28             : #include <com/sun/star/beans/PropertyChangeEvent.hpp>
      29             : #include <com/sun/star/script/ScriptEvent.hpp>
      30             : #include <com/sun/star/script/XScriptListener.hpp>
      31             : #include <com/sun/star/script/ScriptEventDescriptor.hpp>
      32             : #include <com/sun/star/container/XNameContainer.hpp>
      33             : #include <com/sun/star/container/ContainerEvent.hpp>
      34             : #include <com/sun/star/report/XReportComponent.hpp>
      35             : #include <com/sun/star/report/XReportDefinition.hpp>
      36             : #include <com/sun/star/report/XGroup.hpp>
      37             : #include <com/sun/star/document/XUndoManager.hpp>
      38             : 
      39             : #include <cppuhelper/implbase3.hxx>
      40             : #include <comphelper/uno3.hxx>
      41             : #include <comphelper/sequence.hxx>
      42             : #include <svl/lstner.hxx>
      43             : #include <svx/svdouno.hxx>
      44             : #include <svx/svdundo.hxx>
      45             : 
      46             : #include <functional>
      47             : 
      48             : namespace dbaui
      49             : {
      50             :     class IController;
      51             : }
      52             : namespace rptui
      53             : {
      54             :     enum Action
      55             :     {
      56             :         Inserted = 1,
      57             :         Removed  = 2
      58             :     };
      59             : 
      60             :     /** Helper class to allow std::mem_fun for SAL_CALL
      61             :     */
      62           0 :     class REPORTDESIGN_DLLPUBLIC OGroupHelper
      63             :     {
      64             :         ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > m_xGroup;
      65             :         OGroupHelper(const OGroupHelper&);
      66             :         OGroupHelper& operator=(const OGroupHelper&);
      67             :     public:
      68           0 :         OGroupHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup)
      69           0 :             :m_xGroup(_xGroup)
      70             :         {
      71           0 :         }
      72           0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >   getHeader() { return m_xGroup->getHeader(); }
      73           0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >   getFooter() { return m_xGroup->getFooter(); }
      74           0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >     getGroup() { return m_xGroup; }
      75             : 
      76           0 :         inline bool getHeaderOn() { return m_xGroup->getHeaderOn(); }
      77           0 :         inline bool getFooterOn() { return m_xGroup->getFooterOn(); }
      78             : 
      79             :         static ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> , OGroupHelper> getMemberFunction(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection);
      80             : 
      81             :     };
      82             :     typedef com::sun::star::uno::Reference< ::com::sun::star::report::XSection > TSection;
      83             : 
      84             :     /** Helper class to allow std::mem_fun for SAL_CALL
      85             :     */
      86           0 :     class REPORTDESIGN_DLLPUBLIC OReportHelper
      87             :     {
      88             :         ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > m_xReport;
      89             :     public:
      90           0 :         OReportHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport)
      91           0 :             :m_xReport(_xReport)
      92             :         {
      93           0 :         }
      94           0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getReportHeader() { return m_xReport->getReportHeader(); }
      95           0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getReportFooter() { return m_xReport->getReportFooter(); }
      96           0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getPageHeader()   { return m_xReport->getPageHeader(); }
      97           0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getPageFooter()   { return m_xReport->getPageFooter(); }
      98           0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getDetail()       { return m_xReport->getDetail(); }
      99             : 
     100           0 :         inline bool getReportHeaderOn() { return m_xReport->getReportHeaderOn(); }
     101           0 :         inline bool getReportFooterOn() { return m_xReport->getReportFooterOn(); }
     102           0 :         inline bool getPageHeaderOn() { return m_xReport->getPageHeaderOn(); }
     103           0 :         inline bool getPageFooterOn() { return m_xReport->getPageFooterOn(); }
     104             : 
     105             :         static ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> , OReportHelper> getMemberFunction(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection);
     106             :     };
     107             : 
     108             : 
     109             :     //= UndoContext
     110             : 
     111             :     class UndoContext
     112             :     {
     113             :     public:
     114           0 :         UndoContext( SfxUndoManager& i_undoManager, const OUString& i_undoTitle )
     115           0 :             :m_rUndoManager( i_undoManager )
     116             :         {
     117           0 :             m_rUndoManager.EnterListAction( i_undoTitle, OUString() );
     118           0 :         }
     119             : 
     120           0 :         ~UndoContext()
     121             :         {
     122           0 :             m_rUndoManager.LeaveListAction();
     123           0 :         }
     124             : 
     125             :     private:
     126             :         SfxUndoManager& m_rUndoManager;
     127             :     };
     128             : 
     129             : 
     130             :     //= UndoSuppressor
     131             : 
     132             :     class UndoSuppressor
     133             :     {
     134             :     public:
     135           0 :         UndoSuppressor( SfxUndoManager& i_undoManager )
     136           0 :             :m_rUndoManager( i_undoManager )
     137             :         {
     138           0 :             m_rUndoManager.EnableUndo( false );
     139           0 :         }
     140             : 
     141           0 :         ~UndoSuppressor()
     142             :         {
     143           0 :             m_rUndoManager.EnableUndo( true );
     144           0 :         }
     145             : 
     146             :     private:
     147             :         SfxUndoManager& m_rUndoManager;
     148             :     };
     149             : 
     150             : 
     151             :     //= OCommentUndoAction
     152             : 
     153             :     class REPORTDESIGN_DLLPUBLIC OCommentUndoAction : public SdrUndoAction
     154             :     {
     155             :     protected:
     156             :         OUString                m_strComment; // undo, redo comment
     157             :         ::dbaui::IController*   m_pController;
     158             : 
     159             :     public:
     160             :         TYPEINFO_OVERRIDE();
     161             :         OCommentUndoAction( SdrModel& rMod
     162             :                             ,sal_uInt16 nCommentID);
     163             :         virtual ~OCommentUndoAction();
     164             : 
     165           0 :         virtual OUString GetComment() const SAL_OVERRIDE { return m_strComment; }
     166             :         virtual void        Undo() SAL_OVERRIDE;
     167             :         virtual void        Redo() SAL_OVERRIDE;
     168             :     };
     169             : 
     170             :     // OUndoContainerAction
     171             : 
     172             :     class REPORTDESIGN_DLLPUBLIC OUndoContainerAction: public OCommentUndoAction
     173             :     {
     174             :         OUndoContainerAction(OUndoContainerAction&);
     175             :         void operator =(OUndoContainerAction&);
     176             :     protected:
     177             :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     178             :                         m_xElement;     // object not owned by the action
     179             :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     180             :                         m_xOwnElement;  // object owned by the action
     181             :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
     182             :                         m_xContainer;
     183             :         ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     184             :                         m_xSection;
     185             :         Action          m_eAction;
     186             : 
     187             :     public:
     188             :         OUndoContainerAction(SdrModel& rMod
     189             :                             ,Action _eAction
     190             :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > _xContainer
     191             :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
     192             :                             ,sal_uInt16 _nCommentId);
     193             :         virtual ~OUndoContainerAction();
     194             : 
     195             :         virtual void Undo() SAL_OVERRIDE;
     196             :         virtual void Redo() SAL_OVERRIDE;
     197             : 
     198             :     protected:
     199             :         virtual void    implReInsert( );
     200             :         virtual void    implReRemove( );
     201             :     };
     202             : 
     203             : 
     204             :     // OUndoReportSectionAction
     205             : 
     206           0 :     class REPORTDESIGN_DLLPUBLIC OUndoReportSectionAction : public OUndoContainerAction
     207             :     {
     208             :         OReportHelper                               m_aReportHelper;
     209             :         ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     210             :                                     ,OReportHelper> m_pMemberFunction;
     211             :     public:
     212             :         OUndoReportSectionAction(SdrModel& rMod
     213             :                             ,Action _eAction
     214             :                             ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     215             :                                 ,OReportHelper> _pMemberFunction
     216             :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport
     217             :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
     218             :                             ,sal_uInt16 _nCommentId);
     219             : 
     220             :     protected:
     221             :         virtual void    implReInsert( ) SAL_OVERRIDE;
     222             :         virtual void    implReRemove( ) SAL_OVERRIDE;
     223             :     };
     224             : 
     225             : 
     226             :     // OUndoGroupSectionAction
     227           0 :     class REPORTDESIGN_DLLPUBLIC OUndoGroupSectionAction : public OUndoContainerAction
     228             :     {
     229             :         OGroupHelper                                m_aGroupHelper;
     230             :         ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     231             :                                     ,OGroupHelper> m_pMemberFunction;
     232             :     public:
     233             :         OUndoGroupSectionAction(SdrModel& rMod
     234             :                             ,Action _eAction
     235             :                             ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     236             :                                             ,OGroupHelper> _pMemberFunction
     237             :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup
     238             :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
     239             :                             ,sal_uInt16 _nCommentId);
     240             : 
     241             :     protected:
     242             :         virtual void    implReInsert( ) SAL_OVERRIDE;
     243             :         virtual void    implReRemove( ) SAL_OVERRIDE;
     244             :     };
     245             : 
     246             :     // ORptUndoPropertyAction
     247           0 :     class REPORTDESIGN_DLLPUBLIC ORptUndoPropertyAction: public OCommentUndoAction
     248             :     {
     249             :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xObj;
     250             :         OUString                     m_aPropertyName;
     251             :         ::com::sun::star::uno::Any          m_aNewValue;
     252             :         ::com::sun::star::uno::Any          m_aOldValue;
     253             : 
     254             :         /** sets either the old value or the new value again at the property set.
     255             :          *
     256             :          * \param _bOld If set to <TRUE/> than the old value will be set otherwise the new value will be set.
     257             :          */
     258             :         void setProperty(bool _bOld);
     259             :     protected:
     260             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject();
     261             : 
     262             :     public:
     263             :         ORptUndoPropertyAction(SdrModel& rMod, const ::com::sun::star::beans::PropertyChangeEvent& evt);
     264             : 
     265             :         virtual void Undo() SAL_OVERRIDE;
     266             :         virtual void Redo() SAL_OVERRIDE;
     267             : 
     268             :         virtual OUString GetComment() const SAL_OVERRIDE;
     269             :     };
     270             : 
     271             : 
     272             :     // OUndoPropertyReportSectionAction
     273             : 
     274           0 :     class REPORTDESIGN_DLLPUBLIC OUndoPropertyReportSectionAction : public ORptUndoPropertyAction
     275             :     {
     276             :         OReportHelper                               m_aReportHelper;
     277             :         ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     278             :                                     ,OReportHelper> m_pMemberFunction;
     279             :     protected:
     280             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject() SAL_OVERRIDE;
     281             :     public:
     282             :         OUndoPropertyReportSectionAction(SdrModel& rMod
     283             :                             ,const ::com::sun::star::beans::PropertyChangeEvent& evt
     284             :                             ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     285             :                                 ,OReportHelper> _pMemberFunction
     286             :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport
     287             :                             );
     288             :     };
     289             : 
     290             : 
     291             :     // OUndoPropertyGroupSectionAction
     292             : 
     293           0 :     class REPORTDESIGN_DLLPUBLIC OUndoPropertyGroupSectionAction : public ORptUndoPropertyAction
     294             :     {
     295             :         OGroupHelper                                m_aGroupHelper;
     296             :         ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     297             :                                     ,OGroupHelper> m_pMemberFunction;
     298             :     protected:
     299             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject() SAL_OVERRIDE;
     300             :     public:
     301             :         OUndoPropertyGroupSectionAction(SdrModel& rMod
     302             :                             ,const ::com::sun::star::beans::PropertyChangeEvent& evt
     303             :                             ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     304             :                                             ,OGroupHelper> _pMemberFunction
     305             :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup
     306             :                             );
     307             :     };
     308             : 
     309             : }
     310             : #endif // INCLUDED_REPORTDESIGN_INC_UNDOACTIONS_HXX
     311             : 
     312             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10