LCOV - code coverage report
Current view: top level - sw/source/core/inc - UndoTable.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 5 17 29.4 %
Date: 2015-06-13 12:38:46 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 <set>
      25             : #include <swtypes.hxx>
      26             : #include <itabenum.hxx>
      27             : #include <memory>
      28             : #include <vector>
      29             : #include <boost/noncopyable.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 SwTableToTextSaves;
      41             : class SwTable;
      42             : class SwTableBox;
      43             : class SwStartNode;
      44             : class SwTableNode;
      45             : class SwTableAutoFormat;
      46             : class SwTableSortBoxes;
      47             : 
      48             : class SwUndoInsTable : public SwUndo
      49             : {
      50             :     OUString sTableNm;
      51             :     SwInsertTableOptions aInsTableOpts;
      52             :     SwDDEFieldType* pDDEFieldType;
      53             :     std::vector<sal_uInt16> *pColWidth;
      54             :     SwRedlineData*  pRedlData;
      55             :     SwTableAutoFormat* pAutoFormat;
      56             :     sal_uLong nSttNode;
      57             :     sal_uInt16 nRows, nCols;
      58             :     sal_uInt16 nAdjust;
      59             : 
      60             : public:
      61             :     SwUndoInsTable( const SwPosition&, sal_uInt16 nCols, sal_uInt16 nRows,
      62             :                     sal_uInt16 eAdjust, const SwInsertTableOptions& rInsTableOpts,
      63             :                     const SwTableAutoFormat* pTAFormat, const std::vector<sal_uInt16> *pColArr,
      64             :                   const OUString & rName);
      65             : 
      66             :     virtual ~SwUndoInsTable();
      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 SwUndoTextToTable : public SwUndo, public SwUndRng
      76             : {
      77             :     OUString sTableNm;
      78             :     SwInsertTableOptions aInsTableOpts;
      79             :     std::vector<sal_uLong>* pDelBoxes;
      80             :     SwTableAutoFormat* pAutoFormat;
      81             :     SwHistory* pHistory;
      82             :     sal_Unicode cTrenner;
      83             :     sal_uInt16 nAdjust;
      84             :     bool bSplitEnd : 1;
      85             : 
      86             : public:
      87             :     SwUndoTextToTable( const SwPaM&, const SwInsertTableOptions&, sal_Unicode,
      88             :                     sal_uInt16,
      89             :                     const SwTableAutoFormat* pAFormat );
      90             : 
      91             :     virtual ~SwUndoTextToTable();
      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 SwUndoTableToText : public SwUndo
     102             : {
     103             :     OUString sTableNm;
     104             :     SwDDEFieldType* pDDEFieldType;
     105             :     _SaveTable* pTableSave;
     106             :     SwTableToTextSaves* pBoxSaves;
     107             :     SwHistory* pHistory;
     108             :     sal_uLong nSttNd, nEndNd;
     109             :     sal_Unicode cTrenner;
     110             :     sal_uInt16 nHdlnRpt;
     111             :     bool bCheckNumFormat : 1;
     112             : 
     113             : public:
     114             :     SwUndoTableToText( const SwTable& rTable, sal_Unicode cCh );
     115             : 
     116             :     virtual ~SwUndoTableToText();
     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 nContentIdx = SAL_MAX_INT32);
     125             : };
     126             : 
     127             : class SwUndoAttrTable : public SwUndo
     128             : {
     129             :     sal_uLong nSttNode;
     130             :     _SaveTable* pSaveTable;
     131             :     bool bClearTabCol : 1;
     132             : 
     133             : public:
     134             :     SwUndoAttrTable( const SwTableNode& rTableNd, bool bClearTabCols = false );
     135             : 
     136             :     virtual ~SwUndoAttrTable();
     137             : 
     138             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     139             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     140             : };
     141             : 
     142             : class SwUndoTableNumFormat;
     143             : 
     144             : class SwUndoTableAutoFormat : public SwUndo
     145             : {
     146             :     sal_uLong nSttNode;
     147             :     _SaveTable* pSaveTable;
     148             :     std::vector< std::shared_ptr<SwUndoTableNumFormat> > m_Undos;
     149             :     bool bSaveContentAttr;
     150             :     sal_uInt16 m_nRepeatHeading;
     151             : 
     152             :     void UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext);
     153             : 
     154             : public:
     155             :     SwUndoTableAutoFormat( const SwTableNode& rTableNd, const SwTableAutoFormat& );
     156             : 
     157             :     virtual ~SwUndoTableAutoFormat();
     158             : 
     159             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     160             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     161             : 
     162             :     void SaveBoxContent( const SwTableBox& rBox );
     163             : };
     164             : 
     165             : class SwUndoTableNdsChg : public SwUndo, private boost::noncopyable
     166             : {
     167             :     _SaveTable* pSaveTable;
     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           9 :         _BoxMove(sal_uLong idx, bool moved=false) : index(idx), hasMoved(moved) {};
     174          12 :         bool operator<(const _BoxMove& other) const { return index < other.index; };
     175             :     };
     176             :     std::unique_ptr< std::set<_BoxMove> > pNewSttNds;
     177             :     std::unique_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             :     SwUndoTableNdsChg( SwUndoId UndoId,
     186             :                     const SwSelBoxes& rBoxes,
     187             :                     const SwTableNode& rTableNd,
     188             :                     long nMn, long nMx,
     189             :                     sal_uInt16 nCnt, bool bFlg, bool bSameHeight );
     190             : 
     191             :     // for SetColWidth
     192             :     SwUndoTableNdsChg( SwUndoId UndoId, const SwSelBoxes& rBoxes,
     193             :                     const SwTableNode& rTableNd );
     194             : 
     195             :     virtual ~SwUndoTableNdsChg();
     196             : 
     197             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     198             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     199             : 
     200             :     void SaveNewBoxes( const SwTableNode& rTableNd, const SwTableSortBoxes& rOld );
     201             :     void SaveNewBoxes( const SwTableNode& rTableNd, 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 SwUndoTableMerge : public SwUndo, private SwUndRng
     218             : {
     219             :     sal_uLong nTableNode;
     220             :     _SaveTable* pSaveTable;
     221             :     std::set<sal_uLong> m_Boxes;
     222             :     std::vector<sal_uLong> aNewSttNds;
     223             :     SwUndoMoves* pMoves;
     224             :     SwHistory* pHistory;
     225             : 
     226             : public:
     227             :     SwUndoTableMerge( const SwPaM& rTableSel );
     228             : 
     229             :     virtual ~SwUndoTableMerge();
     230             : 
     231             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     232             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     233             : 
     234             :     void MoveBoxContent( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& rPos );
     235             : 
     236             :     void SetSelBoxes( const SwSelBoxes& rBoxes );
     237             : 
     238           1 :     void AddNewBox( sal_uLong nSttNdIdx )
     239           1 :         { aNewSttNds.push_back( nSttNdIdx ); }
     240             : 
     241             :     void SaveCollection( const SwTableBox& rBox );
     242             : };
     243             : 
     244             : class SwUndoTableNumFormat : public SwUndo
     245             : {
     246             :     SfxItemSet *pBoxSet;
     247             :     SwHistory* pHistory;
     248             :     OUString aStr, aNewFormula;
     249             : 
     250             :     sal_uLong nFormatIdx, nNewFormatIdx;
     251             :     double fNum, fNewNum;
     252             :     sal_uLong nNode;
     253             :     sal_uLong nNdPos;
     254             : 
     255             :     bool bNewFormat : 1;
     256             :     bool bNewFormula : 1;
     257             :     bool bNewValue : 1;
     258             : 
     259             : public:
     260             :     SwUndoTableNumFormat( const SwTableBox& rBox, const SfxItemSet* pNewSet = 0 );
     261             : 
     262             :     virtual ~SwUndoTableNumFormat();
     263             : 
     264             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     265             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     266             : 
     267           0 :     void SetNumFormat( sal_uLong nNewNumFormatIdx, const double& rNewNumber )
     268           0 :             { nFormatIdx = nNewNumFormatIdx; fNum = rNewNumber; }
     269             :     void SetBox( const SwTableBox& rBox );
     270             : };
     271             : 
     272             : class _UndoTableCpyTable_Entries;
     273             : 
     274             : class SwUndoTableCpyTable : public SwUndo
     275             : {
     276             :     _UndoTableCpyTable_Entries* pArr;
     277             :     SwUndoTableNdsChg* 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             :     static SwUndo* PrepareRedline( SwDoc* pDoc, const SwTableBox& rBox,
     282             :                 const SwPosition& rPos, bool& rJoin, bool bRedo );
     283             : 
     284             : public:
     285             :     SwUndoTableCpyTable();
     286             : 
     287             :     virtual ~SwUndoTableCpyTable();
     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 bDelContent );
     293             :     void AddBoxAfter( const SwTableBox& rBox, const SwNodeIndex& rIdx,
     294             :                 bool bDelContent );
     295             : 
     296             :     bool IsEmpty() const;
     297             :     bool InsertRow( SwTable& rTable, const SwSelBoxes& rBoxes, sal_uInt16 nCnt );
     298             : };
     299             : 
     300             : class SwUndoCpyTable : public SwUndo
     301             : {
     302             :     SwUndoDelete* pDel;
     303             :     sal_uLong nTableNode;
     304             : 
     305             : public:
     306             :     SwUndoCpyTable();
     307             : 
     308             :     virtual ~SwUndoCpyTable();
     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 )           { nTableNode = nIdx; }
     314             : };
     315             : 
     316             : class SwUndoSplitTable : public SwUndo
     317             : {
     318             :     sal_uLong nTableNode, nOffset;
     319             :     SwSaveRowSpan* mpSaveRowSpan; // stores row span values at the splitting row
     320             :     _SaveTable* pSavTable;
     321             :     SwHistory* pHistory;
     322             :     sal_uInt16 nMode, nFormulaEnd;
     323             :     bool bCalcNewSize;
     324             : 
     325             : public:
     326             :     SwUndoSplitTable( const SwTableNode& rTableNd, SwSaveRowSpan* pRowSp,
     327             :             sal_uInt16 nMode, bool bCalcNewSize );
     328             : 
     329             :     virtual ~SwUndoSplitTable();
     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 SetTableNodeOffset( sal_uLong nIdx )     { nOffset = nIdx - nTableNode; }
     336           0 :     SwHistory* GetHistory()                 { return pHistory; }
     337             :     void SaveFormula( SwHistory& rHistory );
     338             : };
     339             : 
     340             : class SwUndoMergeTable : public SwUndo
     341             : {
     342             :     OUString aName;
     343             :     sal_uLong nTableNode;
     344             :     _SaveTable* pSavTable, *pSavHdl;
     345             :     SwHistory* pHistory;
     346             :     sal_uInt16 nMode;
     347             :     bool bWithPrev;
     348             : 
     349             : public:
     350             :     SwUndoMergeTable( const SwTableNode& rTableNd, const SwTableNode& rDelTableNd,
     351             :                     bool bWithPrev, sal_uInt16 nMode );
     352             : 
     353             :     virtual ~SwUndoMergeTable();
     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           2 : class SwUndoTableHeadline : public SwUndo
     363             : {
     364             :     sal_uLong nTableNd;
     365             :     sal_uInt16 nOldHeadline;
     366             :     sal_uInt16 nNewHeadline;
     367             : 
     368             : public:
     369             :     SwUndoTableHeadline( 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.11