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

Generated by: LCOV version 1.10