LCOV - code coverage report
Current view: top level - reportdesign/inc - UndoActions.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 42 0.0 %
Date: 2012-08-25 Functions: 0 33 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 18 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #ifndef RPTUI_UNDOACTIONS_HXX
      29                 :            : #define RPTUI_UNDOACTIONS_HXX
      30                 :            : 
      31                 :            : #include "dllapi.h"
      32                 :            : 
      33                 :            : #include "RptModel.hxx"
      34                 :            : 
      35                 :            : #include <com/sun/star/util/XModifyListener.hpp>
      36                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      37                 :            : #include <com/sun/star/beans/PropertyChangeEvent.hpp>
      38                 :            : #include <com/sun/star/script/ScriptEvent.hpp>
      39                 :            : #include <com/sun/star/script/XScriptListener.hpp>
      40                 :            : #include <com/sun/star/script/ScriptEventDescriptor.hpp>
      41                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      42                 :            : #include <com/sun/star/container/ContainerEvent.hpp>
      43                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      44                 :            : #include <com/sun/star/report/XReportComponent.hpp>
      45                 :            : #include <com/sun/star/report/XReportDefinition.hpp>
      46                 :            : #include <com/sun/star/report/XGroup.hpp>
      47                 :            : #include <com/sun/star/document/XUndoManager.hpp>
      48                 :            : 
      49                 :            : #include <cppuhelper/implbase3.hxx>
      50                 :            : #include <comphelper/uno3.hxx>
      51                 :            : #include <comphelper/sequence.hxx>
      52                 :            : #include <svl/lstner.hxx>
      53                 :            : #include <svx/svdouno.hxx>
      54                 :            : #include <svx/svdundo.hxx>
      55                 :            : #include <tools/string.hxx>
      56                 :            : 
      57                 :            : #include <functional>
      58                 :            : #include <memory>
      59                 :            : 
      60                 :            : namespace dbaui
      61                 :            : {
      62                 :            :     class IController;
      63                 :            : }
      64                 :            : namespace rptui
      65                 :            : {
      66                 :            :     enum Action
      67                 :            :     {
      68                 :            :         Inserted = 1,
      69                 :            :         Removed  = 2
      70                 :            :     };
      71                 :            : 
      72                 :            :     /** Helper class to allow std::mem_fun for SAL_CALL
      73                 :            :     */
      74                 :          0 :     class REPORTDESIGN_DLLPUBLIC OGroupHelper
      75                 :            :     {
      76                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > m_xGroup;
      77                 :            :         OGroupHelper(const OGroupHelper&);
      78                 :            :         OGroupHelper& operator=(const OGroupHelper&);
      79                 :            :     public:
      80                 :          0 :         OGroupHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup)
      81                 :          0 :             :m_xGroup(_xGroup)
      82                 :            :         {
      83                 :          0 :         }
      84                 :          0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >   getHeader() { return m_xGroup->getHeader(); }
      85                 :          0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >   getFooter() { return m_xGroup->getFooter(); }
      86                 :          0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >     getGroup() { return m_xGroup; }
      87                 :            : 
      88                 :          0 :         inline ::sal_Bool getHeaderOn() { return m_xGroup->getHeaderOn(); }
      89                 :          0 :         inline ::sal_Bool getFooterOn() { return m_xGroup->getFooterOn(); }
      90                 :            : 
      91                 :            :         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);
      92                 :            : 
      93                 :            :     };
      94                 :            :     typedef com::sun::star::uno::Reference< ::com::sun::star::report::XSection > TSection;
      95                 :            : 
      96                 :            :     /** Helper class to allow std::mem_fun for SAL_CALL
      97                 :            :     */
      98                 :          0 :     class REPORTDESIGN_DLLPUBLIC OReportHelper
      99                 :            :     {
     100                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > m_xReport;
     101                 :            :     public:
     102                 :          0 :         OReportHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport)
     103                 :          0 :             :m_xReport(_xReport)
     104                 :            :         {
     105                 :          0 :         }
     106                 :          0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getReportHeader() { return m_xReport->getReportHeader(); }
     107                 :          0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getReportFooter() { return m_xReport->getReportFooter(); }
     108                 :          0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getPageHeader()   { return m_xReport->getPageHeader(); }
     109                 :          0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getPageFooter()   { return m_xReport->getPageFooter(); }
     110                 :          0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getDetail()       { return m_xReport->getDetail(); }
     111                 :            : 
     112                 :          0 :         inline ::sal_Bool getReportHeaderOn() { return m_xReport->getReportHeaderOn(); }
     113                 :          0 :         inline ::sal_Bool getReportFooterOn() { return m_xReport->getReportFooterOn(); }
     114                 :          0 :         inline ::sal_Bool getPageHeaderOn() { return m_xReport->getPageHeaderOn(); }
     115                 :          0 :         inline ::sal_Bool getPageFooterOn() { return m_xReport->getPageFooterOn(); }
     116                 :            : 
     117                 :            :         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);
     118                 :            :     };
     119                 :            : 
     120                 :            :     //==================================================================================================================
     121                 :            :     //= UndoContext
     122                 :            :     //==================================================================================================================
     123                 :            :     class UndoContext
     124                 :            :     {
     125                 :            :     public:
     126                 :          0 :         UndoContext( SfxUndoManager& i_undoManager, const ::rtl::OUString& i_undoTitle )
     127                 :          0 :             :m_rUndoManager( i_undoManager )
     128                 :            :         {
     129                 :          0 :             m_rUndoManager.EnterListAction( i_undoTitle, String() );
     130                 :          0 :         }
     131                 :            : 
     132                 :          0 :         ~UndoContext()
     133                 :            :         {
     134                 :          0 :             m_rUndoManager.LeaveListAction();
     135                 :          0 :         }
     136                 :            : 
     137                 :            :     private:
     138                 :            :         SfxUndoManager& m_rUndoManager;
     139                 :            :     };
     140                 :            : 
     141                 :            :     //==================================================================================================================
     142                 :            :     //= UndoSuppressor
     143                 :            :     //==================================================================================================================
     144                 :            :     class UndoSuppressor
     145                 :            :     {
     146                 :            :     public:
     147                 :          0 :         UndoSuppressor( SfxUndoManager& i_undoManager )
     148                 :          0 :             :m_rUndoManager( i_undoManager )
     149                 :            :         {
     150                 :          0 :             m_rUndoManager.EnableUndo( false );
     151                 :          0 :         }
     152                 :            : 
     153                 :          0 :         ~UndoSuppressor()
     154                 :            :         {
     155                 :          0 :             m_rUndoManager.EnableUndo( true );
     156                 :          0 :         }
     157                 :            : 
     158                 :            :     private:
     159                 :            :         SfxUndoManager& m_rUndoManager;
     160                 :            :     };
     161                 :            : 
     162                 :            :     //==================================================================================================================
     163                 :            :     //= OCommentUndoAction
     164                 :            :     //==================================================================================================================
     165                 :            :     class REPORTDESIGN_DLLPUBLIC OCommentUndoAction : public SdrUndoAction
     166                 :            :     {
     167                 :            :     protected:
     168                 :            :         String                  m_strComment; // undo, redo comment
     169                 :            :         ::dbaui::IController*   m_pController;
     170                 :            : 
     171                 :            :     public:
     172                 :            :         TYPEINFO();
     173                 :            :         OCommentUndoAction( SdrModel& rMod
     174                 :            :                             ,sal_uInt16 nCommentID);
     175                 :            :         virtual ~OCommentUndoAction();
     176                 :            : 
     177                 :          0 :         virtual rtl::OUString GetComment() const { return m_strComment; }
     178                 :            :         virtual void        Undo();
     179                 :            :         virtual void        Redo();
     180                 :            :     };
     181                 :            :     //==================================================================
     182                 :            :     // OUndoContainerAction
     183                 :            :     //==================================================================
     184                 :            :     class REPORTDESIGN_DLLPUBLIC OUndoContainerAction: public OCommentUndoAction
     185                 :            :     {
     186                 :            :         OUndoContainerAction(OUndoContainerAction&);
     187                 :            :         void operator =(OUndoContainerAction&);
     188                 :            :     protected:
     189                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     190                 :            :                         m_xElement;     // object not owned by the action
     191                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     192                 :            :                         m_xOwnElement;  // object owned by the action
     193                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
     194                 :            :                         m_xContainer;
     195                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     196                 :            :                         m_xSection;
     197                 :            :         Action          m_eAction;
     198                 :            : 
     199                 :            :     public:
     200                 :            :         OUndoContainerAction(SdrModel& rMod
     201                 :            :                             ,Action _eAction
     202                 :            :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > _xContainer
     203                 :            :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
     204                 :            :                             ,sal_uInt16 _nCommentId);
     205                 :            :         virtual ~OUndoContainerAction();
     206                 :            : 
     207                 :            :         virtual void Undo();
     208                 :            :         virtual void Redo();
     209                 :            : 
     210                 :            :     protected:
     211                 :            :         virtual void    implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
     212                 :            :         virtual void    implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
     213                 :            :     };
     214                 :            : 
     215                 :            :     //==================================================================
     216                 :            :     // OUndoReportSectionAction
     217                 :            :     //==================================================================
     218 [ #  # ][ #  # ]:          0 :     class REPORTDESIGN_DLLPUBLIC OUndoReportSectionAction : public OUndoContainerAction
     219                 :            :     {
     220                 :            :         OReportHelper                               m_aReportHelper;
     221                 :            :         ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     222                 :            :                                     ,OReportHelper> m_pMemberFunction;
     223                 :            :     public:
     224                 :            :         OUndoReportSectionAction(SdrModel& rMod
     225                 :            :                             ,Action _eAction
     226                 :            :                             ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     227                 :            :                                 ,OReportHelper> _pMemberFunction
     228                 :            :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport
     229                 :            :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
     230                 :            :                             ,sal_uInt16 _nCommentId);
     231                 :            : 
     232                 :            :     protected:
     233                 :            :         virtual void    implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
     234                 :            :         virtual void    implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
     235                 :            :     };
     236                 :            : 
     237                 :            :     //==================================================================
     238                 :            :     // OUndoGroupSectionAction
     239                 :            :     //==================================================================
     240 [ #  # ][ #  # ]:          0 :     class REPORTDESIGN_DLLPUBLIC OUndoGroupSectionAction : public OUndoContainerAction
     241                 :            :     {
     242                 :            :         OGroupHelper                                m_aGroupHelper;
     243                 :            :         ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     244                 :            :                                     ,OGroupHelper> m_pMemberFunction;
     245                 :            :     public:
     246                 :            :         OUndoGroupSectionAction(SdrModel& rMod
     247                 :            :                             ,Action _eAction
     248                 :            :                             ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     249                 :            :                                             ,OGroupHelper> _pMemberFunction
     250                 :            :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup
     251                 :            :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElem
     252                 :            :                             ,sal_uInt16 _nCommentId);
     253                 :            : 
     254                 :            :     protected:
     255                 :            :         virtual void    implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
     256                 :            :         virtual void    implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
     257                 :            :     };
     258                 :            : 
     259                 :            :     ///==================================================================
     260                 :            :     /// ORptUndoPropertyAction
     261                 :            :     ///==================================================================
     262         [ #  # ]:          0 :     class REPORTDESIGN_DLLPUBLIC ORptUndoPropertyAction: public OCommentUndoAction
     263                 :            :     {
     264                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xObj;
     265                 :            :         ::rtl::OUString                     m_aPropertyName;
     266                 :            :         ::com::sun::star::uno::Any          m_aNewValue;
     267                 :            :         ::com::sun::star::uno::Any          m_aOldValue;
     268                 :            : 
     269                 :            :         /** sets either the old value or the new value again at the property set.
     270                 :            :          *
     271                 :            :          * \param _bOld If set to <TRUE/> than the old value will be set otherwise the new value will be set.
     272                 :            :          */
     273                 :            :         void setProperty(sal_Bool _bOld);
     274                 :            :     protected:
     275                 :            :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject();
     276                 :            : 
     277                 :            :     public:
     278                 :            :         ORptUndoPropertyAction(SdrModel& rMod, const ::com::sun::star::beans::PropertyChangeEvent& evt);
     279                 :            : 
     280                 :            :         virtual void Undo();
     281                 :            :         virtual void Redo();
     282                 :            : 
     283                 :            :         virtual rtl::OUString GetComment() const;
     284                 :            :     };
     285                 :            : 
     286                 :            :     //==================================================================
     287                 :            :     // OUndoPropertyReportSectionAction
     288                 :            :     //==================================================================
     289 [ #  # ][ #  # ]:          0 :     class REPORTDESIGN_DLLPUBLIC OUndoPropertyReportSectionAction : public ORptUndoPropertyAction
     290                 :            :     {
     291                 :            :         OReportHelper                               m_aReportHelper;
     292                 :            :         ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     293                 :            :                                     ,OReportHelper> m_pMemberFunction;
     294                 :            :     protected:
     295                 :            :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject();
     296                 :            :     public:
     297                 :            :         OUndoPropertyReportSectionAction(SdrModel& rMod
     298                 :            :                             ,const ::com::sun::star::beans::PropertyChangeEvent& evt
     299                 :            :                             ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     300                 :            :                                 ,OReportHelper> _pMemberFunction
     301                 :            :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReport
     302                 :            :                             );
     303                 :            :     };
     304                 :            : 
     305                 :            :     //==================================================================
     306                 :            :     // OUndoPropertyGroupSectionAction
     307                 :            :     //==================================================================
     308 [ #  # ][ #  # ]:          0 :     class REPORTDESIGN_DLLPUBLIC OUndoPropertyGroupSectionAction : public ORptUndoPropertyAction
     309                 :            :     {
     310                 :            :         OGroupHelper                                m_aGroupHelper;
     311                 :            :         ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     312                 :            :                                     ,OGroupHelper> m_pMemberFunction;
     313                 :            :     protected:
     314                 :            :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getObject();
     315                 :            :     public:
     316                 :            :         OUndoPropertyGroupSectionAction(SdrModel& rMod
     317                 :            :                             ,const ::com::sun::star::beans::PropertyChangeEvent& evt
     318                 :            :                             ,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >
     319                 :            :                                             ,OGroupHelper> _pMemberFunction
     320                 :            :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup
     321                 :            :                             );
     322                 :            :     };
     323                 :            : 
     324                 :            : }
     325                 :            : #endif //RPTUI_UNDOACTIONS_HXX
     326                 :            : 
     327                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10