LCOV - code coverage report
Current view: top level - sw/source/core/inc - rolbck.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 33 0.0 %
Date: 2014-04-14 Functions: 0 41 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_SW_SOURCE_CORE_INC_ROLBCK_HXX
      20             : #define INCLUDED_SW_SOURCE_CORE_INC_ROLBCK_HXX
      21             : 
      22             : #include <tools/solar.h>
      23             : #include <svl/itemset.hxx>
      24             : 
      25             : #include <vector>
      26             : #include <set>
      27             : 
      28             : namespace sfx2 {
      29             :     class MetadatableUndo;
      30             : }
      31             : 
      32             : class SwDoc;
      33             : class SwFmtColl;
      34             : class SwHistoryHint;
      35             : class SwTxtAttr;
      36             : class SfxPoolItem;
      37             : class SwUndoSaveSection;
      38             : class SwTxtFtn;
      39             : class SwUndoDelLayFmt;
      40             : class SwFlyFrmFmt;
      41             : class SwFmtFld;
      42             : class SwTxtFld;
      43             : class SwFieldType;
      44             : class SwTxtTOXMark;
      45             : class SwTxtRefMark;
      46             : class SwFrmFmt;
      47             : class SwpHints;
      48             : class SwFmtChain;
      49             : class SwNode;
      50             : class SwCharFmt;
      51             : 
      52             : #include <tox.hxx>
      53             : 
      54             : #include <SwNumberTreeTypes.hxx>
      55             : #include <IDocumentMarkAccess.hxx>
      56             : 
      57             : #include <memory>
      58             : 
      59             : enum HISTORY_HINT {
      60             :     HSTRY_SETFMTHNT,
      61             :     HSTRY_RESETFMTHNT,
      62             :     HSTRY_SETTXTHNT,
      63             :     HSTRY_SETTXTFLDHNT,
      64             :     HSTRY_SETREFMARKHNT,
      65             :     HSTRY_SETTOXMARKHNT,
      66             :     HSTRY_RESETTXTHNT,
      67             :     HSTRY_SETFTNHNT,
      68             :     HSTRY_CHGFMTCOLL,
      69             :     HSTRY_FLYCNT,
      70             :     HSTRY_BOOKMARK,
      71             :     HSTRY_SETATTRSET,
      72             :     HSTRY_RESETATTRSET,
      73             :     HSTRY_CHGFLYANCHOR,
      74             :     HSTRY_CHGFLYCHAIN,
      75             :     HSTRY_CHGCHARFMT,
      76             :     HSTRY_END
      77             : };
      78             : 
      79             : class SwHistoryHint
      80             : {
      81             :     const HISTORY_HINT m_eWhichId;
      82             : 
      83             : public:
      84           0 :     SwHistoryHint( HISTORY_HINT eWhich ) : m_eWhichId( eWhich ) {}
      85           0 :     virtual ~SwHistoryHint() {}
      86             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) = 0;
      87           0 :     HISTORY_HINT Which() const                     { return m_eWhichId; }
      88             :     virtual OUString GetDescription() const;
      89             : };
      90             : 
      91             : class SwHistorySetFmt : public SwHistoryHint
      92             : {
      93             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
      94             :     ::std::auto_ptr<SfxPoolItem> m_pAttr;
      95             :     SAL_WNODEPRECATED_DECLARATIONS_POP
      96             :     const sal_uLong m_nNodeIndex;
      97             : 
      98             : public:
      99             :     SwHistorySetFmt( const SfxPoolItem* pFmtHt, sal_uLong nNode );
     100             :     virtual ~SwHistorySetFmt();
     101             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     102             :     virtual OUString GetDescription() const SAL_OVERRIDE;
     103             : 
     104             : };
     105             : 
     106           0 : class SwHistoryResetFmt : public SwHistoryHint
     107             : {
     108             :     const sal_uLong m_nNodeIndex;
     109             :     const sal_uInt16 m_nWhich;
     110             : 
     111             : public:
     112             :     SwHistoryResetFmt( const SfxPoolItem* pFmtHt, sal_uLong nNodeIdx );
     113             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     114             : 
     115             : };
     116             : 
     117             : class SwHistorySetTxt : public SwHistoryHint
     118             : {
     119             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     120             :     ::std::auto_ptr<SfxPoolItem> m_pAttr;
     121             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     122             :     const sal_uLong m_nNodeIndex;
     123             :     const sal_Int32 m_nStart;
     124             :     const sal_Int32 m_nEnd;
     125             :     bool m_bFormatIgnoreStart : 1;
     126             :     bool m_bFormatIgnoreEnd   : 1;
     127             : 
     128             : public:
     129             :     SwHistorySetTxt( SwTxtAttr* pTxtHt, sal_uLong nNode );
     130             :     virtual ~SwHistorySetTxt();
     131             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     132             : 
     133             : };
     134             : 
     135             : class SwHistorySetTxtFld : public SwHistoryHint
     136             : {
     137             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     138             :     //!! beware of the order for the declation of the auto_ptrs.
     139             :     //!! If they get destroyed in the wrong order sw may crash (namely mail-merge as well)
     140             :     ::std::auto_ptr<SwFieldType> m_pFldType;
     141             :     const ::std::auto_ptr<SwFmtFld> m_pFld;
     142             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     143             : 
     144             :     sal_uLong m_nNodeIndex;
     145             :     sal_Int32 m_nPos;
     146             :     sal_uInt16 m_nFldWhich;
     147             : 
     148             : public:
     149             :     SwHistorySetTxtFld( SwTxtFld* pTxtFld, sal_uLong nNode );
     150             :     virtual ~SwHistorySetTxtFld();
     151             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     152             : 
     153             :     virtual OUString GetDescription() const SAL_OVERRIDE;
     154             : 
     155             : };
     156             : 
     157           0 : class SwHistorySetRefMark : public SwHistoryHint
     158             : {
     159             :     const OUString m_RefName;
     160             :     const sal_uLong m_nNodeIndex;
     161             :     const sal_Int32 m_nStart;
     162             :     const sal_Int32 m_nEnd;
     163             : 
     164             : public:
     165             :     SwHistorySetRefMark( SwTxtRefMark* pTxtHt, sal_uLong nNode );
     166             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     167             : 
     168             : };
     169             : 
     170           0 : class SwHistorySetTOXMark : public SwHistoryHint
     171             : {
     172             :     SwTOXMark m_TOXMark;
     173             :     const OUString m_TOXName;
     174             :     const TOXTypes m_eTOXTypes;
     175             :     const sal_uLong m_nNodeIndex;
     176             :     const sal_Int32 m_nStart;
     177             :     const sal_Int32 m_nEnd;
     178             : 
     179             : public:
     180             :     SwHistorySetTOXMark( SwTxtTOXMark* pTxtHt, sal_uLong nNode );
     181             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     182             :     bool IsEqual( const SwTOXMark& rCmp ) const;
     183             : 
     184             : };
     185             : 
     186           0 : class SwHistoryResetTxt : public SwHistoryHint
     187             : {
     188             :     const sal_uLong m_nNodeIndex;
     189             :     const sal_Int32 m_nStart;
     190             :     const sal_Int32 m_nEnd;
     191             :     const sal_uInt16 m_nAttr;
     192             : 
     193             : public:
     194             :     SwHistoryResetTxt( sal_uInt16 nWhich, sal_Int32 nStt, sal_Int32 nEnd,
     195             :                        sal_uLong nNode );
     196             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     197             : 
     198           0 :     sal_uInt16 GetWhich() const         { return m_nAttr; }
     199           0 :     sal_uLong GetNode() const           { return m_nNodeIndex; }
     200           0 :     sal_Int32 GetCntnt() const     { return m_nStart; }
     201             : 
     202             : };
     203             : 
     204             : class SwHistorySetFootnote : public SwHistoryHint
     205             : {
     206             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     207             :     const ::std::auto_ptr<SwUndoSaveSection> m_pUndo;
     208             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     209             :     const OUString m_FootnoteNumber;
     210             :     sal_uLong m_nNodeIndex;
     211             :     const sal_Int32 m_nStart;
     212             :     const bool m_bEndNote;
     213             : 
     214             : public:
     215             :     SwHistorySetFootnote( SwTxtFtn* pTxtFtn, sal_uLong nNode );
     216             :     SwHistorySetFootnote( const SwTxtFtn& );
     217             :     virtual ~SwHistorySetFootnote();
     218             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     219             : 
     220             :     virtual OUString GetDescription() const SAL_OVERRIDE;
     221             : 
     222             : };
     223             : 
     224           0 : class SwHistoryChangeFmtColl : public SwHistoryHint
     225             : {
     226             :     SwFmtColl * const m_pColl;
     227             :     const sal_uLong m_nNodeIndex;
     228             :     const sal_uInt8 m_nNodeType;
     229             : 
     230             : public:
     231             :     SwHistoryChangeFmtColl( SwFmtColl* pColl, sal_uLong nNode, sal_uInt8 nNodeWhich );
     232             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     233             : 
     234             : };
     235             : 
     236             : class SwHistoryTxtFlyCnt : public SwHistoryHint
     237             : {
     238             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     239             :     ::std::auto_ptr<SwUndoDelLayFmt> m_pUndo;
     240             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     241             : 
     242             : public:
     243             :     SwHistoryTxtFlyCnt( SwFrmFmt* const pFlyFmt );
     244             :     virtual ~SwHistoryTxtFlyCnt();
     245             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     246           0 :     SwUndoDelLayFmt* GetUDelLFmt() { return m_pUndo.get(); }
     247             : 
     248             : };
     249             : 
     250           0 : class SwHistoryBookmark : public SwHistoryHint
     251             : {
     252             :     public:
     253             :         SwHistoryBookmark(const ::sw::mark::IMark& rBkmk,
     254             :                         bool bSavePos, bool bSaveOtherPos);
     255             :         virtual void SetInDoc(SwDoc * pDoc, bool) SAL_OVERRIDE;
     256             : 
     257             :         bool IsEqualBookmark(const ::sw::mark::IMark& rBkmk);
     258             :         const OUString& GetName() const;
     259             : 
     260             :     private:
     261             :         const OUString m_aName;
     262             :         OUString m_aShortName;
     263             :         KeyCode m_aKeycode;
     264             :         const sal_uLong m_nNode;
     265             :         const sal_uLong m_nOtherNode;
     266             :         const sal_Int32 m_nCntnt;
     267             :         const sal_Int32 m_nOtherCntnt;
     268             :         const bool m_bSavePos;
     269             :         const bool m_bSaveOtherPos;
     270             :         const bool m_bHadOtherPos;
     271             :         const IDocumentMarkAccess::MarkType m_eBkmkType;
     272             :         ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo;
     273             : };
     274             : 
     275           0 : class SwHistorySetAttrSet : public SwHistoryHint
     276             : {
     277             :     SfxItemSet m_OldSet;
     278             :     std::vector<sal_uInt16> m_ResetArray;
     279             :     const sal_uLong m_nNodeIndex;
     280             : 
     281             : public:
     282             :     SwHistorySetAttrSet( const SfxItemSet& rSet, sal_uLong nNode,
     283             :                          const std::set<sal_uInt16> &rSetArr );
     284             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     285             : 
     286             : };
     287             : 
     288           0 : class SwHistoryResetAttrSet : public SwHistoryHint
     289             : {
     290             :     const sal_uLong m_nNodeIndex;
     291             :     const sal_Int32 m_nStart;
     292             :     const sal_Int32 m_nEnd;
     293             :     std::vector<sal_uInt16> m_Array;
     294             : 
     295             : public:
     296             :     SwHistoryResetAttrSet( const SfxItemSet& rSet, sal_uLong nNode,
     297             :                         sal_Int32 nStt,
     298             :                         sal_Int32 nEnd);
     299             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     300             : 
     301           0 :     const std::vector<sal_uInt16>& GetArr() const { return m_Array; }
     302           0 :     sal_uLong GetNode() const               { return m_nNodeIndex; }
     303           0 :     sal_Int32 GetCntnt() const         { return m_nStart; }
     304             : 
     305             : };
     306             : 
     307           0 : class SwHistoryChangeFlyAnchor : public SwHistoryHint
     308             : {
     309             :     SwFrmFmt & m_rFmt;
     310             :     const sal_uLong m_nOldNodeIndex;
     311             :     const sal_Int32 m_nOldContentIndex;
     312             : 
     313             : public:
     314             :     SwHistoryChangeFlyAnchor( SwFrmFmt& rFmt );
     315             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     316             : };
     317             : 
     318           0 : class SwHistoryChangeFlyChain : public SwHistoryHint
     319             : {
     320             :     SwFlyFrmFmt * const m_pPrevFmt;
     321             :     SwFlyFrmFmt * const m_pNextFmt;
     322             :     SwFlyFrmFmt * const m_pFlyFmt;
     323             : 
     324             : public:
     325             :     SwHistoryChangeFlyChain( SwFlyFrmFmt& rFmt, const SwFmtChain& rAttr );
     326             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     327             : };
     328             : 
     329           0 : class SwHistoryChangeCharFmt : public SwHistoryHint
     330             : {
     331             :     const SfxItemSet m_OldSet;
     332             :     const OUString m_Fmt;
     333             : 
     334             : public:
     335             :     SwHistoryChangeCharFmt( const SfxItemSet& rSet, const OUString & sFmt);
     336             :     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) SAL_OVERRIDE;
     337             : 
     338             : };
     339             : 
     340           0 : class SwpHstry : public std::vector<SwHistoryHint*> {
     341             : public:
     342             :     // the destructor will free all objects still in the vector
     343             :     ~SwpHstry();
     344             : };
     345             : 
     346             : class SwHistory
     347             : {
     348             :     friend class SwDoc;         // actually only SwDoc::DelUndoObj may access
     349             :     friend class SwRegHistory;  // for inserting History attributes
     350             : 
     351             :     SwpHstry m_SwpHstry;
     352             :     sal_uInt16 m_nEndDiff;
     353             : 
     354             : public:
     355             :     SwHistory( sal_uInt16 nInitSz = 0 );
     356             :     ~SwHistory();
     357             : 
     358             :     // delete History from nStart to array end
     359             :     void Delete( sal_uInt16 nStart = 0 );
     360             :     // call and delete all objects between nStart and array end
     361             :     bool Rollback( SwDoc* pDoc, sal_uInt16 nStart = 0 );
     362             :     // call all objects between nStart and TmpEnd; store nStart as TmpEnd
     363             :     bool TmpRollback( SwDoc* pDoc, sal_uInt16 nStart, bool ToFirst = true );
     364             : 
     365             :     void Add( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue,
     366             :               sal_uLong nNodeIdx );
     367             :     void Add( SwTxtAttr* pTxtHt, sal_uLong nNodeIdx, bool bNewAttr = true );
     368             :     void Add( SwFmtColl*, sal_uLong nNodeIdx, sal_uInt8 nWhichNd );
     369             :     void Add( const ::sw::mark::IMark&, bool bSavePos, bool bSaveOtherPos );
     370             :     void Add( SwFrmFmt& rFmt );
     371             :     void Add( SwFlyFrmFmt&, sal_uInt16& rSetPos );
     372             :     void Add( const SwTxtFtn& );
     373             :     void Add( const SfxItemSet & rSet, const SwCharFmt & rCharFmt);
     374             : 
     375           0 :     sal_uInt16 Count() const { return m_SwpHstry.size(); }
     376           0 :     sal_uInt16 GetTmpEnd() const { return m_SwpHstry.size() - m_nEndDiff; }
     377             :     sal_uInt16 SetTmpEnd( sal_uInt16 nTmpEnd );        // return previous value
     378           0 :     SwHistoryHint      * operator[]( sal_uInt16 nPos ) { return m_SwpHstry[nPos]; }
     379             :     SwHistoryHint const* operator[]( sal_uInt16 nPos ) const
     380             :         { return m_SwpHstry[nPos]; }
     381             : 
     382             :     // for SwUndoDelete::Undo/Redo
     383           0 :     void Move( sal_uInt16 nPos, SwHistory *pIns,
     384             :                sal_uInt16 const nStart = 0)
     385             :     {
     386           0 :         SwpHstry::iterator itSourceBegin = pIns->m_SwpHstry.begin() + nStart;
     387           0 :         SwpHstry::iterator itSourceEnd = pIns->m_SwpHstry.end();
     388           0 :         if (itSourceBegin == itSourceEnd) return;
     389           0 :         m_SwpHstry.insert(m_SwpHstry.begin() + nPos, itSourceBegin, itSourceEnd);
     390           0 :         pIns->m_SwpHstry.erase( itSourceBegin, itSourceEnd );
     391             :     }
     392             : 
     393             :     // helper methods for recording attribute in History
     394             :     // used by Undo classes (Delete/Overwrite/Inserts)
     395             :     void CopyAttr(
     396             :         SwpHints* pHts,
     397             :         const sal_uLong nNodeIdx,
     398             :         const sal_Int32 nStart,
     399             :         const sal_Int32 nEnd,
     400             :         const bool bCopyFields );
     401             : 
     402             :     void CopyFmtAttr( const SfxItemSet& rSet, sal_uLong nNodeIdx );
     403             : };
     404             : 
     405           0 : class SwRegHistory : public SwClient
     406             : {
     407             : private:
     408             :     std::set<sal_uInt16> m_WhichIdSet;
     409             :     SwHistory * const m_pHistory;
     410             :     sal_uLong m_nNodeIndex;
     411             : 
     412             :     void _MakeSetWhichIds();
     413             : 
     414             : protected:
     415             :     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) SAL_OVERRIDE;
     416             : 
     417             : public:
     418             :     SwRegHistory( SwHistory* pHst );
     419             :     SwRegHistory( const SwNode& rNd, SwHistory* pHst );
     420             :     SwRegHistory( SwModify* pRegIn, const SwNode& rNd, SwHistory* pHst );
     421             : 
     422             :     /// @return true if at least 1 item was inserted
     423             :     bool InsertItems( const SfxItemSet& rSet,
     424             :         sal_Int32 const nStart, sal_Int32 const nEnd,
     425             :         SetAttrMode const nFlags );
     426             : 
     427             :     void AddHint( SwTxtAttr* pHt, const bool bNew = false );
     428             : 
     429             :     void RegisterInModify( SwModify* pRegIn, const SwNode& rNd );
     430           0 :     void ChangeNodeIndex( sal_uLong nNew ) { m_nNodeIndex = nNew; }
     431             : };
     432             : 
     433             : #endif // INCLUDED_SW_SOURCE_CORE_INC_ROLBCK_HXX
     434             : 
     435             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10