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

Generated by: LCOV version 1.10