LCOV - code coverage report
Current view: top level - sw/source/core/inc - UndoTable.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 5 17 29.4 %
Date: 2014-11-03 Functions: 5 10 50.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             : 
      20             : #ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOTABLE_HXX
      21             : #define INCLUDED_SW_SOURCE_CORE_INC_UNDOTABLE_HXX
      22             : 
      23             : #include <undobj.hxx>
      24             : #include <vector>
      25             : #include <set>
      26             : #include <swtypes.hxx>
      27             : #include <itabenum.hxx>
      28             : #include <boost/noncopyable.hpp>
      29             : #include <boost/scoped_ptr.hpp>
      30             : 
      31             : class SfxItemSet;
      32             : 
      33             : struct SwSaveRowSpan;
      34             : class _SaveTable;
      35             : class SwDDEFieldType;
      36             : class SwUndoSaveSections;
      37             : class SwUndoMoves;
      38             : class SwUndoDelete;
      39             : class SwSelBoxes;
      40             : class SwTblToTxtSaves;
      41             : class SwTable;
      42             : class SwTableBox;
      43             : class SwStartNode;
      44             : class SwTableNode;
      45             : class SwTableAutoFmt;
      46             : class SwTableSortBoxes;
      47             : 
      48             : class SwUndoInsTbl : public SwUndo
      49             : {
      50             :     OUString sTblNm;
      51             :     SwInsertTableOptions aInsTblOpts;
      52             :     SwDDEFieldType* pDDEFldType;
      53             :     std::vector<sal_uInt16> *pColWidth;
      54             :     SwRedlineData*  pRedlData;
      55             :     SwTableAutoFmt* pAutoFmt;
      56             :     sal_uLong nSttNode;
      57             :     sal_uInt16 nRows, nCols;
      58             :     sal_uInt16 nAdjust;
      59             : 
      60             : public:
      61             :     SwUndoInsTbl( const SwPosition&, sal_uInt16 nCols, sal_uInt16 nRows,
      62             :                     sal_uInt16 eAdjust, const SwInsertTableOptions& rInsTblOpts,
      63             :                     const SwTableAutoFmt* pTAFmt, const std::vector<sal_uInt16> *pColArr,
      64             :                   const OUString & rName);
      65             : 
      66             :     virtual ~SwUndoInsTbl();
      67             : 
      68             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
      69             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
      70             :     virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
      71             : 
      72             :     virtual SwRewriter GetRewriter() const SAL_OVERRIDE;
      73             : };
      74             : 
      75             : class SwUndoTxtToTbl : public SwUndo, public SwUndRng
      76             : {
      77             :     OUString sTblNm;
      78             :     SwInsertTableOptions aInsTblOpts;
      79             :     std::vector<sal_uLong>* pDelBoxes;
      80             :     SwTableAutoFmt* pAutoFmt;
      81             :     SwHistory* pHistory;
      82             :     sal_Unicode cTrenner;
      83             :     sal_uInt16 nAdjust;
      84             :     bool bSplitEnd : 1;
      85             : 
      86             : public:
      87             :     SwUndoTxtToTbl( const SwPaM&, const SwInsertTableOptions&, sal_Unicode,
      88             :                     sal_uInt16,
      89             :                     const SwTableAutoFmt* pAFmt );
      90             : 
      91             :     virtual ~SwUndoTxtToTbl();
      92             : 
      93             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
      94             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
      95             :     virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
      96             : 
      97             :     SwHistory& GetHistory(); // will be created if necessary
      98             :     void AddFillBox( const SwTableBox& rBox );
      99             : };
     100             : 
     101             : class SwUndoTblToTxt : public SwUndo
     102             : {
     103             :     OUString sTblNm;
     104             :     SwDDEFieldType* pDDEFldType;
     105             :     _SaveTable* pTblSave;
     106             :     SwTblToTxtSaves* pBoxSaves;
     107             :     SwHistory* pHistory;
     108             :     sal_uLong nSttNd, nEndNd;
     109             :     sal_Unicode cTrenner;
     110             :     sal_uInt16 nHdlnRpt;
     111             :     bool bCheckNumFmt : 1;
     112             : 
     113             : public:
     114             :     SwUndoTblToTxt( const SwTable& rTbl, sal_Unicode cCh );
     115             : 
     116             :     virtual ~SwUndoTblToTxt();
     117             : 
     118             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     119             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     120             :     virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
     121             : 
     122             :     void SetRange( const SwNodeRange& );
     123             :     void AddBoxPos( SwDoc& rDoc, sal_uLong nNdIdx, sal_uLong nEndIdx,
     124             :                     sal_Int32 nCntntIdx = SAL_MAX_INT32);
     125             : };
     126             : 
     127             : class SwUndoAttrTbl : public SwUndo
     128             : {
     129             :     sal_uLong nSttNode;
     130             :     _SaveTable* pSaveTbl;
     131             :     bool bClearTabCol : 1;
     132             : 
     133             : public:
     134             :     SwUndoAttrTbl( const SwTableNode& rTblNd, bool bClearTabCols = false );
     135             : 
     136             :     virtual ~SwUndoAttrTbl();
     137             : 
     138             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     139             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     140             : };
     141             : 
     142             : class SwUndoTblNumFmt;
     143             : 
     144             : class SwUndoTblAutoFmt : public SwUndo
     145             : {
     146             :     sal_uLong nSttNode;
     147             :     _SaveTable* pSaveTbl;
     148             :     ::std::vector< ::boost::shared_ptr<SwUndoTblNumFmt> > m_Undos;
     149             :     bool bSaveCntntAttr;
     150             :     sal_uInt16 m_nRepeatHeading;
     151             : 
     152             :     void UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext);
     153             : 
     154             : public:
     155             :     SwUndoTblAutoFmt( const SwTableNode& rTblNd, const SwTableAutoFmt& );
     156             : 
     157             :     virtual ~SwUndoTblAutoFmt();
     158             : 
     159             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     160             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     161             : 
     162             :     void SaveBoxCntnt( const SwTableBox& rBox );
     163             : };
     164             : 
     165             : class SwUndoTblNdsChg : public SwUndo, private boost::noncopyable
     166             : {
     167             :     _SaveTable* pSaveTbl;
     168             :     std::set<sal_uLong> m_Boxes;
     169             :     struct _BoxMove
     170             :     {
     171             :         sal_uLong index;    ///< Index of this box.
     172             :         bool      hasMoved; ///< Has this box been moved already.
     173          18 :         _BoxMove(sal_uLong idx, bool moved=false) : index(idx), hasMoved(moved) {};
     174          22 :         bool operator<(const _BoxMove other) const { return index < other.index; };
     175             :     };
     176             :     boost::scoped_ptr< std::set<_BoxMove> > pNewSttNds;
     177             :     boost::scoped_ptr< SwUndoSaveSections > pDelSects;
     178             :     long nMin, nMax;        // for redo of delete column
     179             :     sal_uLong nSttNode, nCurrBox;
     180             :     sal_uInt16 nCount, nRelDiff, nAbsDiff, nSetColType;
     181             :     bool bFlag;
     182             :     bool bSameHeight;                   // only used for SplitRow
     183             : 
     184             : public:
     185             :     SwUndoTblNdsChg( SwUndoId UndoId,
     186             :                     const SwSelBoxes& rBoxes,
     187             :                     const SwTableNode& rTblNd,
     188             :                     long nMn, long nMx,
     189             :                     sal_uInt16 nCnt, bool bFlg, bool bSameHeight );
     190             : 
     191             :     // for SetColWidth
     192             :     SwUndoTblNdsChg( SwUndoId UndoId, const SwSelBoxes& rBoxes,
     193             :                     const SwTableNode& rTblNd );
     194             : 
     195             :     virtual ~SwUndoTblNdsChg();
     196             : 
     197             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     198             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     199             : 
     200             :     void SaveNewBoxes( const SwTableNode& rTblNd, const SwTableSortBoxes& rOld );
     201             :     void SaveNewBoxes( const SwTableNode& rTblNd, const SwTableSortBoxes& rOld,
     202             :                        const SwSelBoxes& rBoxes, const std::vector<sal_uLong> &rNodeCnts );
     203             :     void SaveSection( SwStartNode* pSttNd );
     204             :     void ReNewBoxes( const SwSelBoxes& rBoxes );
     205             : 
     206           0 :     void SetColWidthParam( sal_uLong nBoxIdx, sal_uInt16 nMode, sal_uInt16 nType,
     207             :                             SwTwips nAbsDif, SwTwips nRelDif )
     208             :     {
     209           0 :         nCurrBox = nBoxIdx;
     210           0 :         nCount = nMode;
     211           0 :         nSetColType = nType;
     212           0 :         nAbsDiff = (sal_uInt16)nAbsDif;
     213           0 :         nRelDiff = (sal_uInt16)nRelDif;
     214           0 :     }
     215             : };
     216             : 
     217             : class SwUndoTblMerge : public SwUndo, private SwUndRng
     218             : {
     219             :     sal_uLong nTblNode;
     220             :     _SaveTable* pSaveTbl;
     221             :     std::set<sal_uLong> m_Boxes;
     222             :     std::vector<sal_uLong> aNewSttNds;
     223             :     SwUndoMoves* pMoves;
     224             :     SwHistory* pHistory;
     225             : 
     226             : public:
     227             :     SwUndoTblMerge( const SwPaM& rTblSel );
     228             : 
     229             :     virtual ~SwUndoTblMerge();
     230             : 
     231             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     232             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     233             : 
     234             :     void MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& rPos );
     235             : 
     236             :     void SetSelBoxes( const SwSelBoxes& rBoxes );
     237             : 
     238           2 :     void AddNewBox( sal_uLong nSttNdIdx )
     239           2 :         { aNewSttNds.push_back( nSttNdIdx ); }
     240             : 
     241             :     void SaveCollection( const SwTableBox& rBox );
     242             : };
     243             : 
     244             : class SwUndoTblNumFmt : public SwUndo
     245             : {
     246             :     SfxItemSet *pBoxSet;
     247             :     SwHistory* pHistory;
     248             :     OUString aStr, aNewFml;
     249             : 
     250             :     sal_uLong nFmtIdx, nNewFmtIdx;
     251             :     double fNum, fNewNum;
     252             :     sal_uLong nNode;
     253             :     sal_uLong nNdPos;
     254             : 
     255             :     bool bNewFmt : 1;
     256             :     bool bNewFml : 1;
     257             :     bool bNewValue : 1;
     258             : 
     259             : public:
     260             :     SwUndoTblNumFmt( const SwTableBox& rBox, const SfxItemSet* pNewSet = 0 );
     261             : 
     262             :     virtual ~SwUndoTblNumFmt();
     263             : 
     264             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     265             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     266             : 
     267           0 :     void SetNumFmt( sal_uLong nNewNumFmtIdx, const double& rNewNumber )
     268           0 :             { nFmtIdx = nNewNumFmtIdx; fNum = rNewNumber; }
     269             :     void SetBox( const SwTableBox& rBox );
     270             : };
     271             : 
     272             : class _UndoTblCpyTbl_Entries;
     273             : 
     274             : class SwUndoTblCpyTbl : public SwUndo
     275             : {
     276             :     _UndoTblCpyTbl_Entries* pArr;
     277             :     SwUndoTblNdsChg* pInsRowUndo;
     278             : 
     279             :     //b6341295: When redlining is active, PrepareRedline has to create the
     280             :     //redlining attributes for the new and the old table cell content
     281             :     SwUndo* PrepareRedline( SwDoc* pDoc, const SwTableBox& rBox,
     282             :                 const SwPosition& rPos, bool& rJoin, bool bRedo );
     283             : 
     284             : public:
     285             :     SwUndoTblCpyTbl();
     286             : 
     287             :     virtual ~SwUndoTblCpyTbl();
     288             : 
     289             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     290             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     291             : 
     292             :     void AddBoxBefore( const SwTableBox& rBox, bool bDelCntnt );
     293             :     void AddBoxAfter( const SwTableBox& rBox, const SwNodeIndex& rIdx,
     294             :                 bool bDelCntnt );
     295             : 
     296             :     bool IsEmpty() const;
     297             :     bool InsertRow( SwTable& rTbl, const SwSelBoxes& rBoxes, sal_uInt16 nCnt );
     298             : };
     299             : 
     300             : class SwUndoCpyTbl : public SwUndo
     301             : {
     302             :     SwUndoDelete* pDel;
     303             :     sal_uLong nTblNode;
     304             : 
     305             : public:
     306             :     SwUndoCpyTbl();
     307             : 
     308             :     virtual ~SwUndoCpyTbl();
     309             : 
     310             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     311             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     312             : 
     313           0 :     void SetTableSttIdx( sal_uLong nIdx )           { nTblNode = nIdx; }
     314             : };
     315             : 
     316             : class SwUndoSplitTbl : public SwUndo
     317             : {
     318             :     sal_uLong nTblNode, nOffset;
     319             :     SwSaveRowSpan* mpSaveRowSpan; // stores row span values at the splitting row
     320             :     _SaveTable* pSavTbl;
     321             :     SwHistory* pHistory;
     322             :     sal_uInt16 nMode, nFmlEnd;
     323             :     bool bCalcNewSize;
     324             : 
     325             : public:
     326             :     SwUndoSplitTbl( const SwTableNode& rTblNd, SwSaveRowSpan* pRowSp,
     327             :             sal_uInt16 nMode, bool bCalcNewSize );
     328             : 
     329             :     virtual ~SwUndoSplitTbl();
     330             : 
     331             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     332             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     333             :     virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
     334             : 
     335           0 :     void SetTblNodeOffset( sal_uLong nIdx )     { nOffset = nIdx - nTblNode; }
     336           0 :     SwHistory* GetHistory()                 { return pHistory; }
     337             :     void SaveFormula( SwHistory& rHistory );
     338             : };
     339             : 
     340             : class SwUndoMergeTbl : public SwUndo
     341             : {
     342             :     OUString aName;
     343             :     sal_uLong nTblNode;
     344             :     _SaveTable* pSavTbl, *pSavHdl;
     345             :     SwHistory* pHistory;
     346             :     sal_uInt16 nMode;
     347             :     bool bWithPrev;
     348             : 
     349             : public:
     350             :     SwUndoMergeTbl( const SwTableNode& rTblNd, const SwTableNode& rDelTblNd,
     351             :                     bool bWithPrev, sal_uInt16 nMode );
     352             : 
     353             :     virtual ~SwUndoMergeTbl();
     354             : 
     355             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     356             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     357             :     virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
     358             : 
     359             :     void SaveFormula( SwHistory& rHistory );
     360             : };
     361             : 
     362           4 : class SwUndoTblHeadline : public SwUndo
     363             : {
     364             :     sal_uLong nTblNd;
     365             :     sal_uInt16 nOldHeadline;
     366             :     sal_uInt16 nNewHeadline;
     367             : 
     368             : public:
     369             :     SwUndoTblHeadline( const SwTable&, sal_uInt16 nOldHdl,  sal_uInt16 nNewHdl );
     370             : 
     371             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     372             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     373             :     virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
     374             : };
     375             : 
     376             : void InsertSort( std::vector<sal_uInt16>& rArr, sal_uInt16 nIdx, sal_uInt16* pInsPos = 0 );
     377             : 
     378             : #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOTABLE_HXX
     379             : 
     380             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10