LCOV - code coverage report
Current view: top level - sw/source/core/docnode - ndtbl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 709 2306 30.7 %
Date: 2012-08-25 Functions: 32 81 39.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 828 4637 17.9 %

           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                 :            : 
      30                 :            : #include <com/sun/star/chart2/XChartDocument.hpp>
      31                 :            : #include <hintids.hxx>
      32                 :            : #include <editeng/lrspitem.hxx>
      33                 :            : #include <editeng/brkitem.hxx>
      34                 :            : #include <editeng/protitem.hxx>
      35                 :            : #include <editeng/boxitem.hxx>
      36                 :            : #include <svl/stritem.hxx>
      37                 :            : // #i17174#
      38                 :            : #include <editeng/shaditem.hxx>
      39                 :            : #include <fmtfsize.hxx>
      40                 :            : #include <fmtornt.hxx>
      41                 :            : #include <fmtfordr.hxx>
      42                 :            : #include <fmtpdsc.hxx>
      43                 :            : #include <fmtanchr.hxx>
      44                 :            : #include <fmtlsplt.hxx>
      45                 :            : #include <frmatr.hxx>
      46                 :            : #include <charatr.hxx>
      47                 :            : #include <cellfrm.hxx>
      48                 :            : #include <pagefrm.hxx>
      49                 :            : #include <tabcol.hxx>
      50                 :            : #include <doc.hxx>
      51                 :            : #include <IDocumentUndoRedo.hxx>
      52                 :            : #include <UndoManager.hxx>
      53                 :            : #include <cntfrm.hxx>
      54                 :            : #include <pam.hxx>
      55                 :            : #include <swcrsr.hxx>
      56                 :            : #include <viscrs.hxx>
      57                 :            : #include <swtable.hxx>
      58                 :            : #include <swundo.hxx>
      59                 :            : #include <tblsel.hxx>
      60                 :            : #include <fldbas.hxx>
      61                 :            : #include <poolfmt.hxx>
      62                 :            : #include <tabfrm.hxx>
      63                 :            : #include <UndoCore.hxx>
      64                 :            : #include <UndoRedline.hxx>
      65                 :            : #include <UndoDelete.hxx>
      66                 :            : #include <UndoNumbering.hxx>
      67                 :            : #include <UndoTable.hxx>
      68                 :            : #include <hints.hxx>
      69                 :            : #include <tblafmt.hxx>
      70                 :            : #include <swcache.hxx>
      71                 :            : #include <ddefld.hxx>
      72                 :            : #include <frminf.hxx>
      73                 :            : #include <cellatr.hxx>
      74                 :            : #include <swtblfmt.hxx>
      75                 :            : #include <swddetbl.hxx>
      76                 :            : #include <mvsave.hxx>
      77                 :            : #include <docary.hxx>
      78                 :            : #include <redline.hxx>
      79                 :            : #include <rolbck.hxx>
      80                 :            : #include <tblrwcl.hxx>
      81                 :            : #include <editsh.hxx>
      82                 :            : #include <txtfrm.hxx>
      83                 :            : #include <ftnfrm.hxx>
      84                 :            : #include <section.hxx>
      85                 :            : #include <frmtool.hxx>
      86                 :            : #include <node2lay.hxx>
      87                 :            : #include <comcore.hrc>
      88                 :            : #include "docsh.hxx"
      89                 :            : #include <unochart.hxx>
      90                 :            : #include <node.hxx>
      91                 :            : #include <ndtxt.hxx>
      92                 :            : #include <map>
      93                 :            : #include <algorithm>
      94                 :            : #include <rootfrm.hxx>
      95                 :            : #include <fldupde.hxx>
      96                 :            : #include <switerator.hxx>
      97                 :            : #include <boost/foreach.hpp>
      98                 :            : 
      99                 :            : #ifdef DBG_UTIL
     100                 :            : #define CHECK_TABLE(t) (t).CheckConsistency();
     101                 :            : #else
     102                 :            : #define CHECK_TABLE(t)
     103                 :            : #endif
     104                 :            : 
     105                 :            : using ::editeng::SvxBorderLine;
     106                 :            : using namespace ::com::sun::star;
     107                 :            : 
     108                 :            : const sal_Unicode T2T_PARA = 0x0a;
     109                 :            : 
     110                 :            : extern void ClearFEShellTabCols();
     111                 :            : 
     112                 :            : // steht im gctable.cxx
     113                 :            : extern sal_Bool lcl_GC_Line_Border( const SwTableLine*& , void* pPara );
     114                 :            : 
     115                 :        259 : void lcl_SetDfltBoxAttr( SwFrmFmt& rFmt, sal_uInt8 nId )
     116                 :            : {
     117                 :        259 :     sal_Bool bTop = sal_False, bBottom = sal_False, bLeft = sal_False, bRight = sal_False;
     118   [ +  +  +  +  :        259 :     switch ( nId )
                      - ]
     119                 :            :     {
     120                 :         64 :     case 0: bTop = bBottom = bLeft = sal_True;          break;
     121                 :         67 :     case 1: bTop = bBottom = bLeft = bRight = sal_True; break;
     122                 :         64 :     case 2: bBottom = bLeft = sal_True;                 break;
     123                 :         64 :     case 3: bBottom = bLeft = bRight = sal_True;        break;
     124                 :            :     }
     125                 :            : 
     126 [ +  - ][ +  - ]:        259 :     const sal_Bool bHTML = rFmt.getIDocumentSettingAccess()->get(IDocumentSettingAccess::HTML_MODE);
     127         [ -  + ]:        259 :     Color aCol( bHTML ? COL_GRAY : COL_BLACK );
     128         [ +  - ]:        259 :     SvxBorderLine aLine( &aCol, DEF_LINE_WIDTH_0 );
     129         [ -  + ]:        259 :     if ( bHTML )
     130                 :            :     {
     131         [ #  # ]:          0 :         aLine.SetBorderLineStyle(table::BorderLineStyle::DOUBLE);
     132                 :          0 :         aLine.SetWidth( DEF_LINE_WIDTH_0 );
     133                 :            :     }
     134         [ +  - ]:        259 :     SvxBoxItem aBox(RES_BOX); aBox.SetDistance( 55 );
     135         [ +  + ]:        259 :     if ( bTop )
     136         [ +  - ]:        131 :         aBox.SetLine( &aLine, BOX_LINE_TOP );
     137         [ +  - ]:        259 :     if ( bBottom )
     138         [ +  - ]:        259 :         aBox.SetLine( &aLine, BOX_LINE_BOTTOM );
     139         [ +  - ]:        259 :     if ( bLeft )
     140         [ +  - ]:        259 :         aBox.SetLine( &aLine, BOX_LINE_LEFT );
     141         [ +  + ]:        259 :     if ( bRight )
     142         [ +  - ]:        131 :         aBox.SetLine( &aLine, BOX_LINE_RIGHT );
     143 [ +  - ][ +  - ]:        259 :     rFmt.SetFmtAttr( aBox );
     144                 :        259 : }
     145                 :            : 
     146                 :            : typedef std::map<SwFrmFmt *, SwTableBoxFmt *> DfltBoxAttrMap_t;
     147                 :            : typedef std::vector<DfltBoxAttrMap_t *> DfltBoxAttrList_t;
     148                 :            : 
     149                 :            : static void
     150                 :          0 : lcl_SetDfltBoxAttr(SwTableBox& rBox, DfltBoxAttrList_t & rBoxFmtArr,
     151                 :            :         sal_uInt8 const nId, SwTableAutoFmt const*const pAutoFmt = 0)
     152                 :            : {
     153                 :          0 :     DfltBoxAttrMap_t * pMap = rBoxFmtArr[ nId ];
     154         [ #  # ]:          0 :     if (!pMap)
     155                 :            :     {
     156 [ #  # ][ #  # ]:          0 :         pMap = new DfltBoxAttrMap_t;
     157                 :          0 :         rBoxFmtArr[ nId ] = pMap;
     158                 :            :     }
     159                 :            : 
     160                 :          0 :     SwTableBoxFmt* pNewTableBoxFmt = 0;
     161                 :          0 :     SwFrmFmt* pBoxFrmFmt = rBox.GetFrmFmt();
     162         [ #  # ]:          0 :     DfltBoxAttrMap_t::iterator const iter(pMap->find(pBoxFrmFmt));
     163 [ #  # ][ #  # ]:          0 :     if (pMap->end() != iter)
     164                 :            :     {
     165         [ #  # ]:          0 :         pNewTableBoxFmt = iter->second;
     166                 :            :     }
     167                 :            :     else
     168                 :            :     {
     169                 :          0 :         SwDoc* pDoc = pBoxFrmFmt->GetDoc();
     170                 :            :         // format does not exist, so create it
     171         [ #  # ]:          0 :         pNewTableBoxFmt = pDoc->MakeTableBoxFmt();
     172 [ #  # ][ #  # ]:          0 :         pNewTableBoxFmt->SetFmtAttr( pBoxFrmFmt->GetAttrSet().Get( RES_FRM_SIZE ) );
     173                 :            : 
     174         [ #  # ]:          0 :         if( pAutoFmt )
     175                 :          0 :             pAutoFmt->UpdateToSet( nId, (SfxItemSet&)pNewTableBoxFmt->GetAttrSet(),
     176                 :            :                                     SwTableAutoFmt::UPDATE_BOX,
     177   [ #  #  #  # ]:          0 :                                     pDoc->GetNumberFormatter( sal_True ) );
     178                 :            :         else
     179         [ #  # ]:          0 :             ::lcl_SetDfltBoxAttr( *pNewTableBoxFmt, nId );
     180                 :            : 
     181         [ #  # ]:          0 :         (*pMap)[pBoxFrmFmt] = pNewTableBoxFmt;
     182                 :            :     }
     183         [ #  # ]:          0 :     rBox.ChgFrmFmt( pNewTableBoxFmt );
     184                 :          0 : }
     185                 :            : 
     186                 :        879 : SwTableBoxFmt *lcl_CreateDfltBoxFmt( SwDoc &rDoc, std::vector<SwTableBoxFmt*> &rBoxFmtArr,
     187                 :            :                                     sal_uInt16 nCols, sal_uInt8 nId )
     188                 :            : {
     189         [ +  + ]:        879 :     if ( !rBoxFmtArr[nId] )
     190                 :            :     {
     191                 :        259 :         SwTableBoxFmt* pBoxFmt = rDoc.MakeTableBoxFmt();
     192         [ +  - ]:        259 :         if( USHRT_MAX != nCols )
     193                 :            :             pBoxFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE,
     194         [ +  - ]:        259 :                                             USHRT_MAX / nCols, 0 ));
     195                 :        259 :         ::lcl_SetDfltBoxAttr( *pBoxFmt, nId );
     196                 :        259 :         rBoxFmtArr[ nId ] = pBoxFmt;
     197                 :            :     }
     198                 :        879 :     return rBoxFmtArr[nId];
     199                 :            : }
     200                 :            : 
     201                 :          0 : SwTableBoxFmt *lcl_CreateAFmtBoxFmt( SwDoc &rDoc, std::vector<SwTableBoxFmt*> &rBoxFmtArr,
     202                 :            :                                     const SwTableAutoFmt& rAutoFmt,
     203                 :            :                                     sal_uInt16 nCols, sal_uInt8 nId )
     204                 :            : {
     205         [ #  # ]:          0 :     if( !rBoxFmtArr[nId] )
     206                 :            :     {
     207                 :          0 :         SwTableBoxFmt* pBoxFmt = rDoc.MakeTableBoxFmt();
     208                 :          0 :         rAutoFmt.UpdateToSet( nId, (SfxItemSet&)pBoxFmt->GetAttrSet(),
     209                 :            :                                 SwTableAutoFmt::UPDATE_BOX,
     210                 :          0 :                                 rDoc.GetNumberFormatter( sal_True ) );
     211         [ #  # ]:          0 :         if( USHRT_MAX != nCols )
     212                 :            :             pBoxFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE,
     213         [ #  # ]:          0 :                                             USHRT_MAX / nCols, 0 ));
     214                 :          0 :         rBoxFmtArr[ nId ] = pBoxFmt;
     215                 :            :     }
     216                 :          0 :     return rBoxFmtArr[nId];
     217                 :            : }
     218                 :            : 
     219                 :        206 : SwTableNode* SwDoc::IsIdxInTbl(const SwNodeIndex& rIdx)
     220                 :            : {
     221                 :        206 :     SwTableNode* pTableNd = 0;
     222                 :        206 :     sal_uLong nIndex = rIdx.GetIndex();
     223         [ +  + ]:        396 :     do {
     224                 :        412 :         SwNode* pNd = (SwNode*)GetNodes()[ nIndex ]->StartOfSectionNode();
     225         [ +  + ]:        412 :         if( 0 != ( pTableNd = pNd->GetTableNode() ) )
     226                 :         16 :             break;
     227                 :            : 
     228                 :        396 :         nIndex = pNd->GetIndex();
     229                 :            :     } while ( nIndex );
     230                 :        206 :     return pTableNd;
     231                 :            : }
     232                 :            : 
     233                 :            : 
     234                 :            : // --------------- einfuegen einer neuen Box --------------
     235                 :            : 
     236                 :            :     // fuege in der Line, vor der InsPos eine neue Box ein.
     237                 :            : 
     238                 :         28 : sal_Bool SwNodes::InsBoxen( SwTableNode* pTblNd,
     239                 :            :                         SwTableLine* pLine,
     240                 :            :                         SwTableBoxFmt* pBoxFmt,
     241                 :            :                         SwTxtFmtColl* pTxtColl,
     242                 :            :                         const SfxItemSet* pAutoAttr,
     243                 :            :                         sal_uInt16 nInsPos,
     244                 :            :                         sal_uInt16 nCnt )
     245                 :            : {
     246         [ -  + ]:         28 :     if( !nCnt )
     247                 :          0 :         return sal_False;
     248                 :            :     OSL_ENSURE( pLine, "keine gueltige Zeile" );
     249                 :            : 
     250                 :            :     // Index hinter die letzte Box der Line
     251                 :         28 :     sal_uLong nIdxPos = 0;
     252                 :         28 :     SwTableBox *pPrvBox = 0, *pNxtBox = 0;
     253         [ +  + ]:         28 :     if( !pLine->GetTabBoxes().empty() )
     254                 :            :     {
     255         [ -  + ]:         24 :         if( nInsPos < pLine->GetTabBoxes().size() )
     256                 :            :         {
     257         [ #  # ]:          0 :             if( 0 == (pPrvBox = pLine->FindPreviousBox( pTblNd->GetTable(),
     258         [ #  # ]:          0 :                             pLine->GetTabBoxes()[ nInsPos ] )))
     259         [ #  # ]:          0 :                 pPrvBox = pLine->FindPreviousBox( pTblNd->GetTable() );
     260                 :            :         }
     261                 :            :         else
     262                 :            :         {
     263 [ +  - ][ +  + ]:         24 :             if( 0 == (pNxtBox = pLine->FindNextBox( pTblNd->GetTable(),
     264         [ +  - ]:         24 :                             pLine->GetTabBoxes().back() )))
     265         [ +  - ]:         17 :                 pNxtBox = pLine->FindNextBox( pTblNd->GetTable() );
     266                 :            :         }
     267                 :            :     }
     268 [ +  - ][ +  + ]:          4 :     else if( 0 == ( pNxtBox = pLine->FindNextBox( pTblNd->GetTable() )))
     269         [ +  - ]:          2 :         pPrvBox = pLine->FindPreviousBox( pTblNd->GetTable() );
     270                 :            : 
     271 [ +  + ][ +  + ]:         28 :     if( !pPrvBox && !pNxtBox )
     272                 :            :     {
     273                 :         17 :         sal_Bool bSetIdxPos = sal_True;
     274 [ +  - ][ -  + ]:         17 :         if( pTblNd->GetTable().GetTabLines().size() && !nInsPos )
                 [ -  + ]
     275                 :            :         {
     276                 :          0 :             const SwTableLine* pTblLn = pLine;
     277         [ #  # ]:          0 :             while( pTblLn->GetUpper() )
     278                 :          0 :                 pTblLn = pTblLn->GetUpper()->GetUpper();
     279                 :            : 
     280         [ #  # ]:          0 :             if( pTblNd->GetTable().GetTabLines()[ 0 ] == pTblLn )
     281                 :            :             {
     282                 :            :                 // also vor die erste Box der Tabelle
     283         [ #  # ]:          0 :                 while( ( pNxtBox = pLine->GetTabBoxes()[0])->GetTabLines().size() )
     284                 :          0 :                     pLine = pNxtBox->GetTabLines()[0];
     285         [ #  # ]:          0 :                 nIdxPos = pNxtBox->GetSttIdx();
     286                 :          0 :                 bSetIdxPos = sal_False;
     287                 :            :             }
     288                 :            :         }
     289         [ +  - ]:         17 :         if( bSetIdxPos )
     290                 :            :             // Tabelle ohne irgendeinen Inhalt oder am Ende, also vors Ende
     291                 :         17 :             nIdxPos = pTblNd->EndOfSectionIndex();
     292                 :            :     }
     293         [ +  + ]:         11 :     else if( pNxtBox )          // es gibt einen Nachfolger
     294         [ +  - ]:          9 :         nIdxPos = pNxtBox->GetSttIdx();
     295                 :            :     else                        // es gibt einen Vorgaenger
     296                 :          2 :         nIdxPos = pPrvBox->GetSttNd()->EndOfSectionIndex() + 1;
     297                 :            : 
     298         [ +  - ]:         28 :     SwNodeIndex aEndIdx( *this, nIdxPos );
     299         [ +  + ]:        215 :     for( sal_uInt16 n = 0; n < nCnt; ++n )
     300                 :            :     {
     301                 :            :         SwStartNode* pSttNd = new SwStartNode( aEndIdx, ND_STARTNODE,
     302 [ +  - ][ +  - ]:        187 :                                                 SwTableBoxStartNode );
     303                 :        187 :         pSttNd->pStartOfSection = pTblNd;
     304 [ +  - ][ +  - ]:        187 :         new SwEndNode( aEndIdx, *pSttNd );
     305                 :            : 
     306 [ +  - ][ +  - ]:        187 :         pPrvBox = new SwTableBox( pBoxFmt, *pSttNd, pLine );
     307                 :            : 
     308                 :        187 :         SwTableBoxes & rTabBoxes = pLine->GetTabBoxes();
     309                 :        187 :         sal_uInt16 nRealInsPos = nInsPos + n;
     310         [ -  + ]:        187 :         if (nRealInsPos > rTabBoxes.size())
     311                 :          0 :             nRealInsPos = rTabBoxes.size();
     312                 :            : 
     313 [ +  - ][ +  - ]:        187 :         rTabBoxes.insert( rTabBoxes.begin() + nRealInsPos, pPrvBox );
     314                 :            : 
     315   [ +  -  +  - ]:        374 :         if( ! pTxtColl->IsAssignedToListLevelOfOutlineStyle()//<-end,zhaojianwei
                 [ +  - ]
     316                 :            : //FEATURE::CONDCOLL
     317                 :        187 :             && RES_CONDTXTFMTCOLL != pTxtColl->Which()
     318                 :            : //FEATURE::CONDCOLL
     319                 :            :         )
     320                 :        187 :             new SwTxtNode( SwNodeIndex( *pSttNd->EndOfSectionNode() ),
     321 [ +  - ][ +  - ]:        187 :                                 pTxtColl, pAutoAttr );
         [ +  - ][ +  - ]
     322                 :            :         else
     323                 :            :         {
     324                 :            :             // Outline-Numerierung richtig behandeln !!!
     325                 :            :             SwTxtNode* pTNd = new SwTxtNode(
     326                 :          0 :                             SwNodeIndex( *pSttNd->EndOfSectionNode() ),
     327                 :          0 :                             (SwTxtFmtColl*)GetDoc()->GetDfltTxtFmtColl(),
     328 [ #  # ][ #  # ]:          0 :                             pAutoAttr );
           [ #  #  #  # ]
     329         [ #  # ]:          0 :             pTNd->ChgFmtColl( pTxtColl );
     330                 :            :         }
     331                 :            :     }
     332         [ +  - ]:         28 :     return sal_True;
     333                 :            : }
     334                 :            : 
     335                 :            : // --------------- einfuegen einer neuen Tabelle --------------
     336                 :            : 
     337                 :        157 : const SwTable* SwDoc::InsertTable( const SwInsertTableOptions& rInsTblOpts,
     338                 :            :                                    const SwPosition& rPos, sal_uInt16 nRows,
     339                 :            :                                    sal_uInt16 nCols, sal_Int16 eAdjust,
     340                 :            :                                    const SwTableAutoFmt* pTAFmt,
     341                 :            :                                    const std::vector<sal_uInt16> *pColArr,
     342                 :            :                                    sal_Bool bCalledFromShell,
     343                 :            :                                    sal_Bool bNewModel )
     344                 :            : {
     345                 :            :     OSL_ENSURE( nRows, "Tabelle ohne Zeile?" );
     346                 :            :     OSL_ENSURE( nCols, "Tabelle ohne Spalten?" );
     347                 :            : 
     348                 :            :     {
     349                 :            :         // nicht in Fussnoten kopieren !!
     350         [ +  - ]:        157 :         if( rPos.nNode < GetNodes().GetEndOfInserts().GetIndex() &&
           [ -  +  #  # ]
                 [ -  + ]
     351         [ #  # ]:          0 :             rPos.nNode >= GetNodes().GetEndOfInserts().StartOfSectionIndex() )
     352                 :          0 :             return 0;
     353                 :            : 
     354                 :            :         // sollte das ColumnArray die falsche Anzahl haben wird es ignoriert!
     355 [ -  + ][ #  # ]:        157 :         if( pColArr &&
         [ #  # ][ -  + ]
     356                 :          0 :             (size_t)(nCols + ( text::HoriOrientation::NONE == eAdjust ? 2 : 1 )) != pColArr->size() )
     357                 :          0 :             pColArr = 0;
     358                 :            :     }
     359                 :            : 
     360         [ +  - ]:        157 :     String aTblName = GetUniqueTblName();
     361                 :            : 
     362 [ +  - ][ +  - ]:        157 :     if( GetIDocumentUndoRedo().DoesUndo() )
                 [ +  + ]
     363                 :            :     {
     364         [ +  - ]:         64 :         GetIDocumentUndoRedo().AppendUndo(
     365                 :            :             new SwUndoInsTbl( rPos, nCols, nRows, static_cast<sal_uInt16>(eAdjust),
     366                 :            :                                       rInsTblOpts, pTAFmt, pColArr,
     367 [ +  - ][ +  - ]:         64 :                                       aTblName));
                 [ +  - ]
     368                 :            :     }
     369                 :            : 
     370                 :            :     // fuege erstmal die Nodes ein
     371                 :            :     // hole das Auto-Format fuer die Tabelle
     372         [ +  - ]:        157 :     SwTxtFmtColl *pBodyColl = GetTxtCollFromPool( RES_POOLCOLL_TABLE ),
     373                 :        157 :                  *pHeadColl = pBodyColl;
     374                 :            : 
     375                 :        157 :     sal_Bool bDfltBorders = 0 != ( rInsTblOpts.mnInsMode & tabopts::DEFAULT_BORDER );
     376                 :            : 
     377 [ +  - ][ +  + ]:        157 :     if( (rInsTblOpts.mnInsMode & tabopts::HEADLINE) && (1 != nRows || !bDfltBorders) )
                 [ +  + ]
     378         [ +  - ]:        154 :         pHeadColl = GetTxtCollFromPool( RES_POOLCOLL_TABLE_HDLN );
     379                 :            : 
     380                 :            :     const sal_uInt16 nRowsToRepeat =
     381                 :            :             tabopts::HEADLINE == (rInsTblOpts.mnInsMode & tabopts::HEADLINE) ?
     382                 :            :             rInsTblOpts.mnRowsToRepeat :
     383         [ +  - ]:        157 :             0;
     384                 :            : 
     385                 :            :     /* Save content node to extract FRAMEDIR from. */
     386                 :        157 :     const SwCntntNode * pCntntNd = rPos.nNode.GetNode().GetCntntNode();
     387                 :            : 
     388                 :            :     /* If we are called from a shell pass the attrset from
     389                 :            :         pCntntNd (aka the node the table is inserted at) thus causing
     390                 :            :         SwNodes::InsertTable to propagate an adjust item if
     391                 :            :         necessary. */
     392         [ +  - ]:        157 :     SwTableNode *pTblNd = GetNodes().InsertTable(
     393                 :            :         rPos.nNode,
     394                 :            :         nCols,
     395                 :            :         pBodyColl,
     396                 :            :         nRows,
     397                 :            :         nRowsToRepeat,
     398                 :            :         pHeadColl,
     399 [ #  # ][ +  - ]:        314 :         bCalledFromShell ? &pCntntNd->GetSwAttrSet() : 0 );
                 [ -  + ]
     400                 :            : 
     401                 :            :     // dann erstelle die Box/Line/Table-Struktur
     402         [ +  - ]:        157 :     SwTableLineFmt* pLineFmt = MakeTableLineFmt();
     403         [ +  - ]:        157 :     SwTableFmt* pTableFmt = MakeTblFrmFmt( aTblName, GetDfltFrmFmt() );
     404                 :            : 
     405                 :            :     /* If the node to insert the table at is a context node and has a
     406                 :            :        non-default FRAMEDIR propagate it to the table. */
     407         [ +  - ]:        157 :     if (pCntntNd)
     408                 :            :     {
     409         [ +  - ]:        157 :         const SwAttrSet & aNdSet = pCntntNd->GetSwAttrSet();
     410                 :        157 :         const SfxPoolItem *pItem = NULL;
     411                 :            : 
     412 [ +  - ][ +  + ]:        157 :         if (SFX_ITEM_SET == aNdSet.GetItemState( RES_FRAMEDIR, sal_True, &pItem )
         [ +  - ][ +  + ]
     413                 :            :             && pItem != NULL)
     414                 :            :         {
     415         [ +  - ]:        157 :             pTableFmt->SetFmtAttr( *pItem );
     416                 :            :         }
     417                 :            :     }
     418                 :            : 
     419                 :            :     //Orientation am Fmt der Table setzen
     420 [ +  - ][ +  - ]:        157 :     pTableFmt->SetFmtAttr( SwFmtHoriOrient( 0, eAdjust ) );
                 [ +  - ]
     421                 :            :     // alle Zeilen haben die Fill-Order von links nach rechts !
     422 [ +  - ][ +  - ]:        157 :     pLineFmt->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ));
                 [ +  - ]
     423                 :            : 
     424                 :            :     // die Tabelle bekommt USHRT_MAX als default SSize
     425                 :        157 :     SwTwips nWidth = USHRT_MAX;
     426         [ -  + ]:        157 :     if( pColArr )
     427                 :            :     {
     428         [ #  # ]:          0 :         sal_uInt16 nSttPos = pColArr->front();
     429         [ #  # ]:          0 :         sal_uInt16 nLastPos = pColArr->back();
     430         [ #  # ]:          0 :         if( text::HoriOrientation::NONE == eAdjust )
     431                 :            :         {
     432                 :          0 :             sal_uInt16 nFrmWidth = nLastPos;
     433         [ #  # ]:          0 :             nLastPos = (*pColArr)[ pColArr->size()-2 ];
     434 [ #  # ][ #  # ]:          0 :             pTableFmt->SetFmtAttr( SvxLRSpaceItem( nSttPos, nFrmWidth - nLastPos, 0, 0, RES_LR_SPACE ) );
                 [ #  # ]
     435                 :            :         }
     436                 :          0 :         nWidth = nLastPos - nSttPos;
     437                 :            :     }
     438         [ +  - ]:        157 :     else if( nCols )
     439                 :            :     {
     440                 :        157 :         nWidth /= nCols;
     441                 :        157 :         nWidth *= nCols; // to avoid rounding problems
     442                 :            :     }
     443 [ +  - ][ +  - ]:        157 :     pTableFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, nWidth ));
                 [ +  - ]
     444         [ -  + ]:        157 :     if( !(rInsTblOpts.mnInsMode & tabopts::SPLIT_LAYOUT) )
     445 [ #  # ][ #  # ]:          0 :         pTableFmt->SetFmtAttr( SwFmtLayoutSplit( sal_False ));
                 [ #  # ]
     446                 :            : 
     447                 :            :     // verschiebe ggfs. die harten PageDesc/PageBreak Attribute:
     448         [ +  - ]:        157 :     SwCntntNode* pNextNd = GetNodes()[ pTblNd->EndOfSectionIndex()+1 ]
     449         [ +  - ]:        157 :                             ->GetCntntNode();
     450 [ +  - ][ +  + ]:        157 :     if( pNextNd && pNextNd->HasSwAttrSet() )
         [ +  + ][ +  - ]
     451                 :            :     {
     452         [ +  - ]:         37 :         const SfxItemSet* pNdSet = pNextNd->GetpSwAttrSet();
     453                 :            :         const SfxPoolItem *pItem;
     454         [ -  + ]:         37 :         if( SFX_ITEM_SET == pNdSet->GetItemState( RES_PAGEDESC, sal_False,
     455         [ +  - ]:         37 :             &pItem ) )
     456                 :            :         {
     457         [ #  # ]:          0 :             pTableFmt->SetFmtAttr( *pItem );
     458         [ #  # ]:          0 :             pNextNd->ResetAttr( RES_PAGEDESC );
     459         [ #  # ]:          0 :             pNdSet = pNextNd->GetpSwAttrSet();
     460                 :            :         }
     461 [ +  - ][ -  + ]:         74 :         if( pNdSet && SFX_ITEM_SET == pNdSet->GetItemState( RES_BREAK, sal_False,
                 [ -  + ]
     462         [ +  - ]:         37 :              &pItem ) )
     463                 :            :         {
     464         [ #  # ]:          0 :             pTableFmt->SetFmtAttr( *pItem );
     465         [ #  # ]:         37 :             pNextNd->ResetAttr( RES_BREAK );
     466                 :            :         }
     467                 :            :     }
     468                 :            : 
     469                 :        157 :     SwTable * pNdTbl = &pTblNd->GetTable();
     470         [ +  - ]:        157 :     pNdTbl->RegisterToFormat( *pTableFmt );
     471                 :            : 
     472                 :        157 :     pNdTbl->SetRowsToRepeat( nRowsToRepeat );
     473                 :        157 :     pNdTbl->SetTableModel( bNewModel );
     474                 :            : 
     475         [ +  - ]:        157 :     std::vector<SwTableBoxFmt*> aBoxFmtArr;
     476                 :        157 :     SwTableBoxFmt* pBoxFmt = 0;
     477 [ +  + ][ +  - ]:        157 :     if( !bDfltBorders && !pTAFmt )
     478                 :            :     {
     479         [ +  - ]:         90 :         pBoxFmt = MakeTableBoxFmt();
     480 [ +  - ][ +  - ]:         90 :         pBoxFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, USHRT_MAX / nCols, 0 ));
                 [ +  - ]
     481                 :            :     }
     482                 :            :     else
     483                 :            :     {
     484         [ -  + ]:         67 :         const sal_uInt16 nBoxArrLen = pTAFmt ? 16 : 4;
     485         [ +  - ]:         67 :         aBoxFmtArr.resize( nBoxArrLen, NULL );
     486                 :            :     }
     487         [ +  - ]:        157 :     SfxItemSet aCharSet( GetAttrPool(), RES_CHRATR_BEGIN, RES_PARATR_LIST_END-1 );
     488                 :            : 
     489         [ +  - ]:        157 :     SwNodeIndex aNdIdx( *pTblNd, 1 );   // auf den ersten Box-StartNode
     490                 :        157 :     SwTableLines& rLines = pNdTbl->GetTabLines();
     491         [ +  + ]:        553 :     for( sal_uInt16 n = 0; n < nRows; ++n )
     492                 :            :     {
     493 [ +  - ][ +  - ]:        396 :         SwTableLine* pLine = new SwTableLine( pLineFmt, nCols, 0 );
     494 [ +  - ][ +  - ]:        396 :         rLines.insert( rLines.begin() + n, pLine );
     495                 :        396 :         SwTableBoxes& rBoxes = pLine->GetTabBoxes();
     496         [ +  + ]:       1737 :         for( sal_uInt16 i = 0; i < nCols; ++i )
     497                 :            :         {
     498                 :            :             SwTableBoxFmt *pBoxF;
     499         [ -  + ]:       1341 :             if( pTAFmt )
     500                 :            :             {
     501                 :            :                 sal_uInt8 nId = static_cast<sal_uInt8>(!n ? 0 : (( n+1 == nRows )
     502 [ #  # ][ #  # ]:          0 :                                         ? 12 : (4 * (1 + ((n-1) & 1 )))));
     503                 :            :                 nId = nId + static_cast<sal_uInt8>( !i ? 0 :
     504 [ #  # ][ #  # ]:          0 :                             ( i+1 == nCols ? 3 : (1 + ((i-1) & 1))));
     505                 :            :                 pBoxF = ::lcl_CreateAFmtBoxFmt( *this, aBoxFmtArr, *pTAFmt,
     506         [ #  # ]:          0 :                                                 nCols, nId );
     507                 :            : 
     508                 :            :                 // ggfs. noch die Absatz/ZeichenAttribute setzen
     509 [ #  # ][ #  # ]:          0 :                 if( pTAFmt->IsFont() || pTAFmt->IsJustify() )
                 [ #  # ]
     510                 :            :                 {
     511         [ #  # ]:          0 :                     aCharSet.ClearItem();
     512                 :            :                     pTAFmt->UpdateToSet( nId, aCharSet,
     513         [ #  # ]:          0 :                                         SwTableAutoFmt::UPDATE_CHAR, 0 );
     514         [ #  # ]:          0 :                     if( aCharSet.Count() )
     515 [ #  # ][ #  # ]:          0 :                         GetNodes()[ aNdIdx.GetIndex()+1 ]->GetCntntNode()->
     516         [ #  # ]:          0 :                             SetAttr( aCharSet );
     517                 :            :                 }
     518                 :            :             }
     519         [ +  + ]:       1341 :             else if( bDfltBorders )
     520                 :            :             {
     521         [ +  + ]:        879 :                 sal_uInt8 nBoxId = (i < nCols - 1 ? 0 : 1) + (n ? 2 : 0 );
     522         [ +  - ]:        879 :                 pBoxF = ::lcl_CreateDfltBoxFmt( *this, aBoxFmtArr, nCols, nBoxId);
     523                 :            :             }
     524                 :            :             else
     525                 :        462 :                 pBoxF = pBoxFmt;
     526                 :            : 
     527                 :            :             // fuer AutoFormat bei der Eingabe: beim Einfuegen der Tabelle
     528                 :            :             // werden gleich die Spalten gesetzt. Im Array stehen die
     529                 :            :             // Positionen der Spalten!! (nicht deren Breite!)
     530         [ -  + ]:       1341 :             if( pColArr )
     531                 :            :             {
     532 [ #  # ][ #  # ]:          0 :                 nWidth = (*pColArr)[ i + 1 ] - (*pColArr)[ i ];
     533 [ #  # ][ #  # ]:          0 :                 if( pBoxF->GetFrmSize().GetWidth() != nWidth )
     534                 :            :                 {
     535         [ #  # ]:          0 :                     if( pBoxF->GetDepends() )       // neues Format erzeugen!
     536                 :            :                     {
     537         [ #  # ]:          0 :                         SwTableBoxFmt *pNewFmt = MakeTableBoxFmt();
     538         [ #  # ]:          0 :                         *pNewFmt = *pBoxF;
     539                 :          0 :                         pBoxF = pNewFmt;
     540                 :            :                     }
     541 [ #  # ][ #  # ]:          0 :                     pBoxF->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, nWidth ));
                 [ #  # ]
     542                 :            :                 }
     543                 :            :             }
     544                 :            : 
     545 [ +  - ][ +  - ]:       1341 :             SwTableBox *pBox = new SwTableBox( pBoxF, aNdIdx, pLine);
     546 [ +  - ][ +  - ]:       1341 :             rBoxes.insert( rBoxes.begin() + i, pBox );
     547         [ +  - ]:       1341 :             aNdIdx += 3;        // StartNode, TextNode, EndNode  == 3 Nodes
     548                 :            :         }
     549                 :            :     }
     550                 :            :     // und Frms einfuegen.
     551 [ +  - ][ +  - ]:        157 :     GetNodes().GoNext( &aNdIdx );      // zum naechsten ContentNode
     552         [ +  - ]:        157 :     pTblNd->MakeFrms( &aNdIdx );
     553                 :            : 
     554 [ +  - ][ +  - ]:        157 :     if( IsRedlineOn() || (!IsIgnoreRedline() && !pRedlineTbl->empty() ))
         [ +  - ][ +  - ]
         [ -  + ][ -  + ]
     555                 :            :     {
     556         [ #  # ]:          0 :         SwPaM aPam( *pTblNd->EndOfSectionNode(), *pTblNd, 1 );
     557 [ #  # ][ #  # ]:          0 :         if( IsRedlineOn() )
     558 [ #  # ][ #  # ]:          0 :             AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
                 [ #  # ]
     559                 :            :         else
     560 [ #  # ][ #  # ]:          0 :             SplitRedline( aPam );
     561                 :            :     }
     562                 :            : 
     563         [ +  - ]:        157 :     SetModified();
     564                 :            :     CHECK_TABLE( *pNdTbl );
     565 [ +  - ][ +  - ]:        157 :     return pNdTbl;
                 [ +  - ]
     566                 :            : }
     567                 :            : 
     568                 :        157 : SwTableNode* SwNodes::InsertTable( const SwNodeIndex& rNdIdx,
     569                 :            :                                    sal_uInt16 nBoxes,
     570                 :            :                                    SwTxtFmtColl* pCntntTxtColl,
     571                 :            :                                    sal_uInt16 nLines,
     572                 :            :                                    sal_uInt16 nRepeat,
     573                 :            :                                    SwTxtFmtColl* pHeadlineTxtColl,
     574                 :            :                                    const SwAttrSet * pAttrSet)
     575                 :            : {
     576         [ -  + ]:        157 :     if( !nBoxes )
     577                 :          0 :         return 0;
     578                 :            : 
     579                 :            :     // wenn Lines angegeben, erzeuge die Matrix aus Lines & Boxen
     580 [ +  - ][ -  + ]:        157 :     if( !pHeadlineTxtColl || !nLines )
     581                 :          0 :         pHeadlineTxtColl = pCntntTxtColl;
     582                 :            : 
     583 [ +  - ][ +  - ]:        157 :     SwTableNode * pTblNd = new SwTableNode( rNdIdx );
     584 [ +  - ][ +  - ]:        157 :     SwEndNode* pEndNd = new SwEndNode( rNdIdx, *pTblNd );
     585                 :            : 
     586         [ -  + ]:        157 :     if( !nLines )       // fuer die FOR-Schleife
     587                 :          0 :         ++nLines;
     588                 :            : 
     589         [ +  - ]:        157 :     SwNodeIndex aIdx( *pEndNd );
     590                 :        157 :     SwTxtFmtColl* pTxtColl = pHeadlineTxtColl;
     591         [ +  + ]:        553 :     for( sal_uInt16 nL = 0; nL < nLines; ++nL )
     592                 :            :     {
     593         [ +  + ]:       1737 :         for( sal_uInt16 nB = 0; nB < nBoxes; ++nB )
     594                 :            :         {
     595                 :            :             SwStartNode* pSttNd = new SwStartNode( aIdx, ND_STARTNODE,
     596 [ +  - ][ +  - ]:       1341 :                                                     SwTableBoxStartNode );
     597                 :       1341 :             pSttNd->pStartOfSection = pTblNd;
     598                 :            : 
     599 [ +  - ][ +  - ]:       1341 :             SwTxtNode * pTmpNd = new SwTxtNode( aIdx, pTxtColl );
     600                 :            : 
     601                 :            :             // #i60422# Propagate some more attributes.
     602                 :       1341 :             const SfxPoolItem* pItem = NULL;
     603         [ -  + ]:       1341 :             if ( NULL != pAttrSet )
     604                 :            :             {
     605                 :            :                 static const sal_uInt16 aPropagateItems[] = {
     606                 :            :                     RES_PARATR_ADJUST,
     607                 :            :                     RES_CHRATR_FONT, RES_CHRATR_FONTSIZE,
     608                 :            :                     RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONTSIZE,
     609                 :            :                     RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONTSIZE, 0 };
     610                 :            : 
     611                 :          0 :                 const sal_uInt16* pIdx = aPropagateItems;
     612         [ #  # ]:          0 :                 while ( *pIdx != 0 )
     613                 :            :                 {
     614 [ #  # ][ #  # ]:          0 :                     if ( SFX_ITEM_SET != pTmpNd->GetSwAttrSet().GetItemState( *pIdx ) &&
         [ #  # ][ #  # ]
                 [ #  # ]
     615         [ #  # ]:          0 :                          SFX_ITEM_SET == pAttrSet->GetItemState( *pIdx, sal_True, &pItem ) )
     616         [ #  # ]:          0 :                         static_cast<SwCntntNode *>(pTmpNd)->SetAttr(*pItem);
     617                 :          0 :                     ++pIdx;
     618                 :            :                 }
     619                 :            :             }
     620                 :            : 
     621 [ +  - ][ +  - ]:       1341 :             new SwEndNode( aIdx, *pSttNd );
     622                 :            :         }
     623         [ +  - ]:        396 :         if ( nL + 1 >= nRepeat )
     624                 :        396 :             pTxtColl = pCntntTxtColl;
     625                 :            :     }
     626         [ +  - ]:        157 :     return pTblNd;
     627                 :            : }
     628                 :            : 
     629                 :            : 
     630                 :            : //---------------- Text -> Tabelle -----------------------
     631                 :            : 
     632                 :          0 : const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTblOpts,
     633                 :            :                                    const SwPaM& rRange, sal_Unicode cCh,
     634                 :            :                                    sal_Int16 eAdjust,
     635                 :            :                                    const SwTableAutoFmt* pTAFmt )
     636                 :            : {
     637                 :            :     // pruefe ob in der Selection eine Tabelle liegt
     638 [ #  # ][ #  # ]:          0 :     const SwPosition *pStt = rRange.Start(), *pEnd = rRange.End();
     639                 :            :     {
     640                 :          0 :         sal_uLong nCnt = pStt->nNode.GetIndex();
     641         [ #  # ]:          0 :         for( ; nCnt <= pEnd->nNode.GetIndex(); ++nCnt )
     642 [ #  # ][ #  # ]:          0 :             if( !GetNodes()[ nCnt ]->IsTxtNode() )
                 [ #  # ]
     643                 :          0 :                 return 0;
     644                 :            :     }
     645                 :            : 
     646                 :            :     /* Save first node in the selection if it is a context node. */
     647                 :          0 :     SwCntntNode * pSttCntntNd = pStt->nNode.GetNode().GetCntntNode();
     648                 :            : 
     649         [ #  # ]:          0 :     SwPaM aOriginal( *pStt, *pEnd );
     650                 :          0 :     pStt = aOriginal.GetMark();
     651                 :          0 :     pEnd = aOriginal.GetPoint();
     652                 :            : 
     653                 :          0 :     SwUndoTxtToTbl* pUndo = 0;
     654 [ #  # ][ #  # ]:          0 :     if( GetIDocumentUndoRedo().DoesUndo() )
                 [ #  # ]
     655                 :            :     {
     656 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().StartUndo( UNDO_TEXTTOTABLE, NULL );
     657                 :            :         pUndo = new SwUndoTxtToTbl( aOriginal, rInsTblOpts, cCh,
     658 [ #  # ][ #  # ]:          0 :                     static_cast<sal_uInt16>(eAdjust), pTAFmt );
     659 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().AppendUndo( pUndo );
     660                 :            : 
     661                 :            :         // das Splitten vom TextNode nicht in die Undohistory aufnehmen
     662 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().DoUndo( false );
     663                 :            :     }
     664                 :            : 
     665         [ #  # ]:          0 :     ::PaMCorrAbs( aOriginal, *pEnd );
     666                 :            : 
     667                 :            :     // sorge dafuer, das der Bereich auf Node-Grenzen liegt
     668         [ #  # ]:          0 :     SwNodeRange aRg( pStt->nNode, pEnd->nNode );
     669         [ #  # ]:          0 :     if( pStt->nContent.GetIndex() )
     670         [ #  # ]:          0 :         SplitNode( *pStt, false );
     671                 :            : 
     672                 :          0 :     sal_Bool bEndCntnt = 0 != pEnd->nContent.GetIndex();
     673                 :            :     // nicht splitten am Ende der Zeile (aber am Ende vom Doc!!)
     674         [ #  # ]:          0 :     if( bEndCntnt )
     675                 :            :     {
     676         [ #  # ]:          0 :         if( pEnd->nNode.GetNode().GetCntntNode()->Len() != pEnd->nContent.GetIndex()
           [ #  #  #  # ]
                 [ #  # ]
     677         [ #  # ]:          0 :             || pEnd->nNode.GetIndex() >= GetNodes().GetEndOfContent().GetIndex()-1 )
     678                 :            :         {
     679         [ #  # ]:          0 :             SplitNode( *pEnd, false );
     680         [ #  # ]:          0 :             ((SwNodeIndex&)pEnd->nNode)--;
     681                 :            :             ((SwIndex&)pEnd->nContent).Assign(
     682 [ #  # ][ #  # ]:          0 :                                 pEnd->nNode.GetNode().GetCntntNode(), 0 );
     683                 :            :             // ein Node und am Ende ??
     684         [ #  # ]:          0 :             if( pStt->nNode.GetIndex() >= pEnd->nNode.GetIndex() )
     685         [ #  # ]:          0 :                 aRg.aStart--;
     686                 :            :         }
     687                 :            :         else
     688         [ #  # ]:          0 :             aRg.aEnd++;
     689                 :            :     }
     690                 :            : 
     691                 :            : 
     692         [ #  # ]:          0 :     if( aRg.aEnd.GetIndex() == aRg.aStart.GetIndex() )
     693                 :            :     {
     694                 :            :         OSL_FAIL( "Kein Bereich" );
     695         [ #  # ]:          0 :         aRg.aEnd++;
     696                 :            :     }
     697                 :            : 
     698                 :            :     // Wir gehen jetzt immer ueber die Upper, um die Tabelle einzufuegen:
     699         [ #  # ]:          0 :     SwNode2Layout aNode2Layout( aRg.aStart.GetNode() );
     700                 :            : 
     701 [ #  # ][ #  # ]:          0 :     GetIDocumentUndoRedo().DoUndo( 0 != pUndo );
     702                 :            : 
     703                 :            :     // dann erstelle die Box/Line/Table-Struktur
     704         [ #  # ]:          0 :     SwTableBoxFmt* pBoxFmt = MakeTableBoxFmt();
     705         [ #  # ]:          0 :     SwTableLineFmt* pLineFmt = MakeTableLineFmt();
     706 [ #  # ][ #  # ]:          0 :     SwTableFmt* pTableFmt = MakeTblFrmFmt( GetUniqueTblName(), GetDfltFrmFmt() );
                 [ #  # ]
     707                 :            : 
     708                 :            :     // alle Zeilen haben die Fill-Order von links nach rechts !
     709 [ #  # ][ #  # ]:          0 :     pLineFmt->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ));
                 [ #  # ]
     710                 :            :     // die Tabelle bekommt USHRT_MAX als default SSize
     711 [ #  # ][ #  # ]:          0 :     pTableFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, USHRT_MAX ));
                 [ #  # ]
     712         [ #  # ]:          0 :     if( !(rInsTblOpts.mnInsMode & tabopts::SPLIT_LAYOUT) )
     713 [ #  # ][ #  # ]:          0 :         pTableFmt->SetFmtAttr( SwFmtLayoutSplit( sal_False ));
                 [ #  # ]
     714                 :            : 
     715                 :            :     /* If the first node in the selection is a context node and if it
     716                 :            :        has an item FRAMEDIR set (no default) propagate the item to the
     717                 :            :        replacing table. */
     718         [ #  # ]:          0 :     if (pSttCntntNd)
     719                 :            :     {
     720         [ #  # ]:          0 :         const SwAttrSet & aNdSet = pSttCntntNd->GetSwAttrSet();
     721                 :          0 :         const SfxPoolItem *pItem = NULL;
     722                 :            : 
     723 [ #  # ][ #  # ]:          0 :         if (SFX_ITEM_SET == aNdSet.GetItemState( RES_FRAMEDIR, sal_True, &pItem )
         [ #  # ][ #  # ]
     724                 :            :             && pItem != NULL)
     725                 :            :         {
     726         [ #  # ]:          0 :             pTableFmt->SetFmtAttr( *pItem );
     727                 :            :         }
     728                 :            :     }
     729                 :            : 
     730         [ #  # ]:          0 :     SwTableNode* pTblNd = GetNodes().TextToTable(
     731                 :            :             aRg, cCh, pTableFmt, pLineFmt, pBoxFmt,
     732 [ #  # ][ #  # ]:          0 :             GetTxtCollFromPool( RES_POOLCOLL_STANDARD ), pUndo );
     733                 :            : 
     734                 :          0 :     SwTable * pNdTbl = &pTblNd->GetTable();
     735                 :            :     OSL_ENSURE( pNdTbl, "kein Tabellen-Node angelegt."  );
     736                 :            : 
     737                 :            :     const sal_uInt16 nRowsToRepeat =
     738                 :            :             tabopts::HEADLINE == (rInsTblOpts.mnInsMode & tabopts::HEADLINE) ?
     739                 :            :             rInsTblOpts.mnRowsToRepeat :
     740         [ #  # ]:          0 :             0;
     741                 :          0 :     pNdTbl->SetRowsToRepeat( nRowsToRepeat );
     742                 :            : 
     743                 :          0 :     sal_Bool bUseBoxFmt = sal_False;
     744         [ #  # ]:          0 :     if( !pBoxFmt->GetDepends() )
     745                 :            :     {
     746                 :            :         // die Formate an den Boxen haben schon die richtige Size, es darf
     747                 :            :         // also nur noch die richtige Umrandung/AutoFmt gesetzt werden.
     748                 :          0 :         bUseBoxFmt = sal_True;
     749 [ #  # ][ #  # ]:          0 :         pTableFmt->SetFmtAttr( pBoxFmt->GetFrmSize() );
     750 [ #  # ][ #  # ]:          0 :         delete pBoxFmt;
     751                 :          0 :         eAdjust = text::HoriOrientation::NONE;
     752                 :            :     }
     753                 :            : 
     754                 :            :     //Orientation am Fmt der Table setzen
     755 [ #  # ][ #  # ]:          0 :     pTableFmt->SetFmtAttr( SwFmtHoriOrient( 0, eAdjust ) );
                 [ #  # ]
     756         [ #  # ]:          0 :     pNdTbl->RegisterToFormat( *pTableFmt );
     757                 :            : 
     758 [ #  # ][ #  # ]:          0 :     if( pTAFmt || ( rInsTblOpts.mnInsMode & tabopts::DEFAULT_BORDER) )
     759                 :            :     {
     760         [ #  # ]:          0 :         sal_uInt8 nBoxArrLen = pTAFmt ? 16 : 4;
     761                 :          0 :         boost::scoped_ptr< DfltBoxAttrList_t > aBoxFmtArr1;
     762                 :          0 :         boost::scoped_ptr< std::vector<SwTableBoxFmt*> > aBoxFmtArr2;
     763         [ #  # ]:          0 :         if( bUseBoxFmt )
     764                 :            :         {
     765 [ #  # ][ #  # ]:          0 :             aBoxFmtArr1.reset(new DfltBoxAttrList_t( nBoxArrLen, NULL ));
                 [ #  # ]
     766                 :            :         }
     767                 :            :         else
     768                 :            :         {
     769 [ #  # ][ #  # ]:          0 :             aBoxFmtArr2.reset(new std::vector<SwTableBoxFmt*>( nBoxArrLen, NULL ));
                 [ #  # ]
     770                 :            :         }
     771                 :            : 
     772                 :            : 
     773         [ #  # ]:          0 :         SfxItemSet aCharSet( GetAttrPool(), RES_CHRATR_BEGIN, RES_PARATR_LIST_END-1 );
     774                 :            : 
     775 [ #  # ][ #  # ]:          0 :         SwHistory* pHistory = pUndo ? &pUndo->GetHistory() : 0;
     776                 :            : 
     777                 :          0 :         SwTableBoxFmt *pBoxF = 0;
     778                 :          0 :         SwTableLines& rLines = pNdTbl->GetTabLines();
     779                 :          0 :         sal_uInt16 nRows = rLines.size();
     780         [ #  # ]:          0 :         for( sal_uInt16 n = 0; n < nRows; ++n )
     781                 :            :         {
     782                 :          0 :             SwTableBoxes& rBoxes = rLines[ n ]->GetTabBoxes();
     783                 :          0 :             sal_uInt16 nCols = rBoxes.size();
     784         [ #  # ]:          0 :             for( sal_uInt16 i = 0; i < nCols; ++i )
     785                 :            :             {
     786                 :          0 :                 SwTableBox* pBox = rBoxes[ i ];
     787                 :          0 :                 sal_Bool bChgSz = sal_False;
     788                 :            : 
     789         [ #  # ]:          0 :                 if( pTAFmt )
     790                 :            :                 {
     791                 :            :                     sal_uInt8 nId = static_cast<sal_uInt8>(!n ? 0 : (( n+1 == nRows )
     792 [ #  # ][ #  # ]:          0 :                                             ? 12 : (4 * (1 + ((n-1) & 1 )))));
     793                 :            :                     nId = nId + static_cast<sal_uInt8>(!i ? 0 :
     794 [ #  # ][ #  # ]:          0 :                                 ( i+1 == nCols ? 3 : (1 + ((i-1) & 1))));
     795         [ #  # ]:          0 :                     if( bUseBoxFmt )
     796         [ #  # ]:          0 :                         ::lcl_SetDfltBoxAttr( *pBox, *aBoxFmtArr1, nId, pTAFmt );
     797                 :            :                     else
     798                 :            :                     {
     799         [ #  # ]:          0 :                         bChgSz = 0 == (*aBoxFmtArr2)[ nId ];
     800                 :          0 :                         pBoxF = ::lcl_CreateAFmtBoxFmt( *this, *aBoxFmtArr2,
     801         [ #  # ]:          0 :                                                 *pTAFmt, USHRT_MAX, nId );
     802                 :            :                     }
     803                 :            : 
     804                 :            :                     // ggfs. noch die Absatz/ZeichenAttribute setzen
     805 [ #  # ][ #  # ]:          0 :                     if( pTAFmt->IsFont() || pTAFmt->IsJustify() )
                 [ #  # ]
     806                 :            :                     {
     807         [ #  # ]:          0 :                         aCharSet.ClearItem();
     808                 :            :                         pTAFmt->UpdateToSet( nId, aCharSet,
     809         [ #  # ]:          0 :                                             SwTableAutoFmt::UPDATE_CHAR, 0 );
     810         [ #  # ]:          0 :                         if( aCharSet.Count() )
     811                 :            :                         {
     812         [ #  # ]:          0 :                             sal_uLong nSttNd = pBox->GetSttIdx()+1;
     813                 :          0 :                             sal_uLong nEndNd = pBox->GetSttNd()->EndOfSectionIndex();
     814         [ #  # ]:          0 :                             for( ; nSttNd < nEndNd; ++nSttNd )
     815                 :            :                             {
     816 [ #  # ][ #  # ]:          0 :                                 SwCntntNode* pNd = GetNodes()[ nSttNd ]->GetCntntNode();
     817         [ #  # ]:          0 :                                 if( pNd )
     818                 :            :                                 {
     819         [ #  # ]:          0 :                                     if( pHistory )
     820                 :            :                                     {
     821         [ #  # ]:          0 :                                         SwRegHistory aReg( pNd, *pNd, pHistory );
     822 [ #  # ][ #  # ]:          0 :                                         pNd->SetAttr( aCharSet );
     823                 :            :                                     }
     824                 :            :                                     else
     825         [ #  # ]:          0 :                                         pNd->SetAttr( aCharSet );
     826                 :            :                                 }
     827                 :            :                             }
     828                 :            :                         }
     829                 :            :                     }
     830                 :            :                 }
     831                 :            :                 else
     832                 :            :                 {
     833         [ #  # ]:          0 :                     sal_uInt8 nId = (i < nCols - 1 ? 0 : 1) + (n ? 2 : 0 );
     834         [ #  # ]:          0 :                     if( bUseBoxFmt )
     835         [ #  # ]:          0 :                         ::lcl_SetDfltBoxAttr( *pBox, *aBoxFmtArr1, nId );
     836                 :            :                     else
     837                 :            :                     {
     838         [ #  # ]:          0 :                         bChgSz = 0 == (*aBoxFmtArr2)[ nId ];
     839                 :          0 :                         pBoxF = ::lcl_CreateDfltBoxFmt( *this, *aBoxFmtArr2,
     840         [ #  # ]:          0 :                                                         USHRT_MAX, nId );
     841                 :            :                     }
     842                 :            :                 }
     843                 :            : 
     844         [ #  # ]:          0 :                 if( !bUseBoxFmt )
     845                 :            :                 {
     846         [ #  # ]:          0 :                     if( bChgSz )
     847 [ #  # ][ #  # ]:          0 :                         pBoxF->SetFmtAttr( pBox->GetFrmFmt()->GetFrmSize() );
     848         [ #  # ]:          0 :                     pBox->ChgFrmFmt( pBoxF );
     849                 :            :                 }
     850                 :            :             }
     851                 :            :         }
     852                 :            : 
     853         [ #  # ]:          0 :         if( bUseBoxFmt )
     854                 :            :         {
     855         [ #  # ]:          0 :             for( sal_uInt8 i = 0; i < nBoxArrLen; ++i )
     856                 :            :             {
     857         [ #  # ]:          0 :                 delete (*aBoxFmtArr1)[ i ];
     858                 :            :             }
     859 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     860                 :            :     }
     861                 :            : 
     862                 :            :     // JP 03.04.97: Inhalt der Boxen auf Zahlen abpruefen
     863 [ #  # ][ #  # ]:          0 :     if( IsInsTblFormatNum() )
     864                 :            :     {
     865         [ #  # ]:          0 :         for( sal_uInt16 nBoxes = pNdTbl->GetTabSortBoxes().size(); nBoxes; )
     866         [ #  # ]:          0 :             ChkBoxNumFmt( *pNdTbl->GetTabSortBoxes()[ --nBoxes ], sal_False );
     867                 :            :     }
     868                 :            : 
     869                 :          0 :     sal_uLong nIdx = pTblNd->GetIndex();
     870 [ #  # ][ #  # ]:          0 :     aNode2Layout.RestoreUpperFrms( GetNodes(), nIdx, nIdx + 1 );
     871                 :            : 
     872                 :            :     {
     873                 :          0 :         SwPaM& rTmp = (SwPaM&)rRange;   // Point immer an den Anfang
     874         [ #  # ]:          0 :         rTmp.DeleteMark();
     875         [ #  # ]:          0 :         rTmp.GetPoint()->nNode = *pTblNd;
     876 [ #  # ][ #  # ]:          0 :         SwCntntNode* pCNd = GetNodes().GoNext( &rTmp.GetPoint()->nNode );
     877 [ #  # ][ #  # ]:          0 :         rTmp.GetPoint()->nContent.Assign( pCNd, 0 );
     878                 :            :     }
     879                 :            : 
     880         [ #  # ]:          0 :     if( pUndo )
     881                 :            :     {
     882 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().EndUndo( UNDO_TEXTTOTABLE, NULL );
     883                 :            :     }
     884                 :            : 
     885         [ #  # ]:          0 :     SetModified();
     886         [ #  # ]:          0 :     SetFieldsDirty(true, NULL, 0);
     887 [ #  # ][ #  # ]:          0 :     return pNdTbl;
                 [ #  # ]
     888                 :            : }
     889                 :            : 
     890                 :          0 : SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
     891                 :            :                                     SwTableFmt* pTblFmt,
     892                 :            :                                     SwTableLineFmt* pLineFmt,
     893                 :            :                                     SwTableBoxFmt* pBoxFmt,
     894                 :            :                                     SwTxtFmtColl* pTxtColl,
     895                 :            :                                     SwUndoTxtToTbl* pUndo )
     896                 :            : {
     897         [ #  # ]:          0 :     if( rRange.aStart >= rRange.aEnd )
     898                 :          0 :         return 0;
     899                 :            : 
     900 [ #  # ][ #  # ]:          0 :     SwTableNode * pTblNd = new SwTableNode( rRange.aStart );
     901 [ #  # ][ #  # ]:          0 :     new SwEndNode( rRange.aEnd, *pTblNd );
     902                 :            : 
     903                 :          0 :     SwDoc* pDoc = GetDoc();
     904         [ #  # ]:          0 :     std::vector<sal_uInt16> aPosArr;
     905                 :          0 :     SwTable * pTable = &pTblNd->GetTable();
     906                 :            :     SwTableLine* pLine;
     907                 :            :     SwTableBox* pBox;
     908                 :          0 :     sal_uInt16 nBoxes, nLines, nMaxBoxes = 0;
     909                 :            : 
     910         [ #  # ]:          0 :     SwNodeIndex aSttIdx( *pTblNd, 1 );
     911         [ #  # ]:          0 :     SwNodeIndex aEndIdx( rRange.aEnd, -1 );
     912 [ #  # ][ #  # ]:          0 :     for( nLines = 0, nBoxes = 0;
     913                 :          0 :         aSttIdx.GetIndex() < aEndIdx.GetIndex();
     914                 :            :         aSttIdx += 2, nLines++, nBoxes = 0 )
     915                 :            :     {
     916                 :          0 :         SwTxtNode* pTxtNd = aSttIdx.GetNode().GetTxtNode();
     917                 :            :         OSL_ENSURE( pTxtNd, "nur TextNodes in der Tabelle aufnehmen" );
     918                 :            : 
     919 [ #  # ][ #  # ]:          0 :         if( !nLines && 0x0b == cCh )
     920                 :            :         {
     921                 :          0 :             cCh = 0x09;
     922                 :            : 
     923                 :            :             // JP 28.10.96: vom 1. Node die Positionen des Trenners besorgen,
     924                 :            :             //              damit die Boxen entsprechend eingestellt werden
     925 [ #  # ][ #  # ]:          0 :             SwTxtFrmInfo aFInfo( (SwTxtFrm*)pTxtNd->getLayoutFrm( pTxtNd->GetDoc()->GetCurrentLayout() ) );
     926 [ #  # ][ #  # ]:          0 :             if( aFInfo.IsOneLine() )        // nur dann sinnvoll!
     927                 :            :             {
     928                 :          0 :                 const sal_Unicode* pTxt = pTxtNd->GetTxt().GetBuffer();
     929         [ #  # ]:          0 :                 for( xub_StrLen nChPos = 0; *pTxt; ++nChPos, ++pTxt )
     930                 :            :                 {
     931         [ #  # ]:          0 :                     if( *pTxt == cCh )
     932                 :            :                     {
     933                 :            :                         aPosArr.push_back( static_cast<sal_uInt16>(
     934 [ #  # ][ #  # ]:          0 :                                         aFInfo.GetCharPos( nChPos+1, sal_False )) );
     935                 :            :                     }
     936                 :            :                 }
     937                 :            : 
     938                 :            :                 aPosArr.push_back(
     939         [ #  # ]:          0 :                                 static_cast<sal_uInt16>(aFInfo.GetFrm()->IsVertical() ?
     940                 :          0 :                                 aFInfo.GetFrm()->Prt().Bottom() :
     941 [ #  # ][ #  # ]:          0 :                                 aFInfo.GetFrm()->Prt().Right()) );
     942                 :            : 
     943                 :            :             }
     944                 :            :         }
     945                 :            : 
     946                 :            :         // die alten Frames loeschen, es werden neue erzeugt
     947         [ #  # ]:          0 :         pTxtNd->DelFrms();
     948                 :            : 
     949                 :            :         // PageBreaks/PageDesc/ColBreak rausschmeissen.
     950         [ #  # ]:          0 :         const SfxItemSet* pSet = pTxtNd->GetpSwAttrSet();
     951         [ #  # ]:          0 :         if( pSet )
     952                 :            :         {
     953                 :            :             const SfxPoolItem* pItem;
     954 [ #  # ][ #  # ]:          0 :             if( SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, sal_False, &pItem ) )
     955                 :            :             {
     956         [ #  # ]:          0 :                 if( !nLines )
     957         [ #  # ]:          0 :                     pTblFmt->SetFmtAttr( *pItem );
     958         [ #  # ]:          0 :                 pTxtNd->ResetAttr( RES_BREAK );
     959         [ #  # ]:          0 :                 pSet = pTxtNd->GetpSwAttrSet();
     960                 :            :             }
     961                 :            : 
     962         [ #  # ]:          0 :             if( pSet && SFX_ITEM_SET == pSet->GetItemState(
           [ #  #  #  # ]
                 [ #  # ]
     963         [ #  # ]:          0 :                 RES_PAGEDESC, sal_False, &pItem ) &&
     964                 :          0 :                 ((SwFmtPageDesc*)pItem)->GetPageDesc() )
     965                 :            :             {
     966         [ #  # ]:          0 :                 if( !nLines )
     967         [ #  # ]:          0 :                     pTblFmt->SetFmtAttr( *pItem );
     968         [ #  # ]:          0 :                 pTxtNd->ResetAttr( RES_PAGEDESC );
     969                 :            :             }
     970                 :            :         }
     971                 :            : 
     972                 :            :         // setze den bei allen TextNode in der Tabelle den TableNode
     973                 :            :         // als StartNode
     974                 :          0 :         pTxtNd->pStartOfSection = pTblNd;
     975                 :            : 
     976 [ #  # ][ #  # ]:          0 :         pLine = new SwTableLine( pLineFmt, 1, 0 );
     977 [ #  # ][ #  # ]:          0 :         pTable->GetTabLines().insert( pTable->GetTabLines().begin() + nLines, pLine );
     978                 :            : 
     979                 :            :         SwStartNode* pSttNd;
     980 [ #  # ][ #  # ]:          0 :         SwPosition aCntPos( aSttIdx, SwIndex( pTxtNd ));
         [ #  # ][ #  # ]
     981                 :            : 
     982         [ #  # ]:          0 :         std::vector<sal_uLong> aBkmkArr;
     983         [ #  # ]:          0 :         _SaveCntntIdx( pDoc, aSttIdx.GetIndex(), pTxtNd->GetTxt().Len(), aBkmkArr );
     984                 :            : 
     985                 :          0 :         const sal_Unicode* pTxt = pTxtNd->GetTxt().GetBuffer();
     986                 :            : 
     987         [ #  # ]:          0 :         if( T2T_PARA != cCh )
     988         [ #  # ]:          0 :             for( xub_StrLen nChPos = 0; *pTxt; ++nChPos, ++pTxt )
     989         [ #  # ]:          0 :                 if( *pTxt == cCh )
     990                 :            :                 {
     991         [ #  # ]:          0 :                     aCntPos.nContent = nChPos;
     992         [ #  # ]:          0 :                     SwCntntNode* pNewNd = pTxtNd->SplitCntntNode( aCntPos );
     993                 :            : 
     994         [ #  # ]:          0 :                     if( !aBkmkArr.empty() )
     995                 :            :                         _RestoreCntntIdx( aBkmkArr, *pNewNd, nChPos,
     996         [ #  # ]:          0 :                                             nChPos + 1 );
     997                 :            : 
     998                 :            :                     // Trennzeichen loeschen und SuchString korrigieren
     999         [ #  # ]:          0 :                     pTxtNd->EraseText( aCntPos.nContent, 1 );
    1000                 :          0 :                     pTxt = pTxtNd->GetTxt().GetBuffer();
    1001                 :          0 :                     nChPos = 0;
    1002                 :          0 :                     --nChPos, --pTxt;           // for the ++ in the for loop !!!
    1003                 :            : 
    1004                 :            :                     // setze bei allen TextNodes in der Tabelle den TableNode
    1005                 :            :                     // als StartNode
    1006         [ #  # ]:          0 :                     const SwNodeIndex aTmpIdx( aCntPos.nNode, -1 );
    1007                 :            :                     pSttNd = new SwStartNode( aTmpIdx, ND_STARTNODE,
    1008 [ #  # ][ #  # ]:          0 :                                                 SwTableBoxStartNode );
    1009 [ #  # ][ #  # ]:          0 :                     new SwEndNode( aCntPos.nNode, *pSttNd );
    1010                 :          0 :                     pNewNd->pStartOfSection = pSttNd;
    1011                 :            : 
    1012                 :            :                     // Section der Box zuweisen
    1013 [ #  # ][ #  # ]:          0 :                     pBox = new SwTableBox( pBoxFmt, *pSttNd, pLine );
    1014 [ #  # ][ #  # ]:          0 :                     pLine->GetTabBoxes().insert( pLine->GetTabBoxes().begin() + nBoxes++, pBox );
                 [ #  # ]
    1015                 :            :                 }
    1016                 :            : 
    1017                 :            :         // und jetzt den letzten Teil-String
    1018         [ #  # ]:          0 :         if( !aBkmkArr.empty() )
    1019                 :          0 :             _RestoreCntntIdx( aBkmkArr, *pTxtNd, pTxtNd->GetTxt().Len(),
    1020         [ #  # ]:          0 :                                 pTxtNd->GetTxt().Len()+1 );
    1021                 :            : 
    1022 [ #  # ][ #  # ]:          0 :         pSttNd = new SwStartNode( aCntPos.nNode, ND_STARTNODE, SwTableBoxStartNode );
    1023         [ #  # ]:          0 :         const SwNodeIndex aTmpIdx( aCntPos.nNode, 1 );
    1024 [ #  # ][ #  # ]:          0 :         new SwEndNode( aTmpIdx, *pSttNd  );
    1025                 :          0 :         pTxtNd->pStartOfSection = pSttNd;
    1026                 :            : 
    1027 [ #  # ][ #  # ]:          0 :         pBox = new SwTableBox( pBoxFmt, *pSttNd, pLine );
    1028 [ #  # ][ #  # ]:          0 :         pLine->GetTabBoxes().insert( pLine->GetTabBoxes().begin() + nBoxes++, pBox );
    1029         [ #  # ]:          0 :         if( nMaxBoxes < nBoxes )
    1030                 :          0 :             nMaxBoxes = nBoxes;
    1031 [ #  # ][ #  # ]:          0 :     }
    1032                 :            : 
    1033                 :            :     // die Tabelle ausgleichen, leere Sections einfuegen
    1034                 :            :     sal_uInt16 n;
    1035                 :            : 
    1036         [ #  # ]:          0 :     for( n = 0; n < pTable->GetTabLines().size(); ++n )
    1037                 :            :     {
    1038                 :          0 :         SwTableLine* pCurrLine = pTable->GetTabLines()[ n ];
    1039         [ #  # ]:          0 :         if( nMaxBoxes != ( nBoxes = pCurrLine->GetTabBoxes().size() ))
    1040                 :            :         {
    1041                 :            :             InsBoxen( pTblNd, pCurrLine, pBoxFmt, pTxtColl, 0,
    1042         [ #  # ]:          0 :                         nBoxes, nMaxBoxes - nBoxes );
    1043                 :            : 
    1044         [ #  # ]:          0 :             if( pUndo )
    1045         [ #  # ]:          0 :                 for( sal_uInt16 i = nBoxes; i < nMaxBoxes; ++i )
    1046         [ #  # ]:          0 :                     pUndo->AddFillBox( *pCurrLine->GetTabBoxes()[ i ] );
    1047                 :            : 
    1048                 :            :             // fehlen der 1. Line Boxen, dann kann man das Breiten Array
    1049                 :            :             // vergessen!
    1050         [ #  # ]:          0 :             if( !n )
    1051                 :          0 :                 aPosArr.clear();
    1052                 :            :         }
    1053                 :            :     }
    1054                 :            : 
    1055         [ #  # ]:          0 :     if( !aPosArr.empty() )
    1056                 :            :     {
    1057                 :          0 :         SwTableLines& rLns = pTable->GetTabLines();
    1058                 :          0 :         sal_uInt16 nLastPos = 0;
    1059         [ #  # ]:          0 :         for( n = 0; n < aPosArr.size(); ++n )
    1060                 :            :         {
    1061         [ #  # ]:          0 :             SwTableBoxFmt *pNewFmt = pDoc->MakeTableBoxFmt();
    1062                 :            :             pNewFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE,
    1063 [ #  # ][ #  # ]:          0 :                                                 aPosArr[ n ] - nLastPos ));
         [ #  # ][ #  # ]
    1064         [ #  # ]:          0 :             for( sal_uInt16 nTmpLine = 0; nTmpLine < rLns.size(); ++nTmpLine )
    1065                 :            :                 //JP 24.06.98: hier muss ein Add erfolgen, da das BoxFormat
    1066                 :            :                 //              von der rufenden Methode noch gebraucht wird!
    1067         [ #  # ]:          0 :                 pNewFmt->Add( rLns[ nTmpLine ]->GetTabBoxes()[ n ] );
    1068                 :            : 
    1069         [ #  # ]:          0 :             nLastPos = aPosArr[ n ];
    1070                 :            :         }
    1071                 :            : 
    1072                 :            :         // damit die Tabelle die richtige Groesse bekommt, im BoxFormat die
    1073                 :            :         // Groesse nach "oben" transportieren.
    1074                 :            :         OSL_ENSURE( !pBoxFmt->GetDepends(), "wer ist in dem Format noch angemeldet" );
    1075 [ #  # ][ #  # ]:          0 :         pBoxFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, nLastPos ));
                 [ #  # ]
    1076                 :            :     }
    1077                 :            :     else
    1078 [ #  # ][ #  # ]:          0 :         pBoxFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, USHRT_MAX / nMaxBoxes ));
                 [ #  # ]
    1079                 :            : 
    1080                 :            :     // das wars doch wohl ??
    1081 [ #  # ][ #  # ]:          0 :     return pTblNd;
    1082                 :            : }
    1083                 :            : 
    1084                 :         72 : const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> >& rTableNodes )
    1085                 :            : {
    1086         [ -  + ]:         72 :     if (rTableNodes.empty())
    1087                 :          0 :         return NULL;
    1088                 :            : 
    1089         [ +  - ]:         72 :     std::vector<SwNodeRange> rFirstRange = *rTableNodes.begin();
    1090                 :            : 
    1091         [ -  + ]:         72 :     if (rFirstRange.empty())
    1092                 :          0 :         return NULL;
    1093                 :            : 
    1094                 :            :     /* Save first node in the selection if it is a content node. */
    1095                 :         72 :     SwCntntNode * pSttCntntNd = rFirstRange.begin()->aStart.GetNode().GetCntntNode();
    1096                 :            : 
    1097                 :            :     /**debug**/
    1098                 :            : #if OSL_DEBUG_LEVEL > 1
    1099                 :            :     const SwNodeRange& rStartRange = *rTableNodes.begin()->begin();
    1100                 :            :     const SwNodeRange& rEndRange = *rTableNodes.rbegin()->rbegin();
    1101                 :            :     (void) rStartRange;
    1102                 :            :     (void) rEndRange;
    1103                 :            : #endif
    1104                 :            :     /**debug**/
    1105                 :            : 
    1106                 :            :     //!!! not necessarily TextNodes !!!
    1107 [ +  - ][ +  - ]:         72 :     SwPaM aOriginal( rTableNodes.begin()->begin()->aStart, rTableNodes.rbegin()->rbegin()->aEnd );
                 [ +  - ]
    1108                 :         72 :     const SwPosition *pStt = aOriginal.GetMark();
    1109                 :         72 :     const SwPosition *pEnd = aOriginal.GetPoint();
    1110                 :            : 
    1111                 :            : //    SwUndoTxtToTbl* pUndo = 0;
    1112 [ +  - ][ +  - ]:         72 :     bool const bUndo(GetIDocumentUndoRedo().DoesUndo());
    1113         [ -  + ]:         72 :     if (bUndo)
    1114                 :            :     {
    1115                 :            :         // das Splitten vom TextNode nicht in die Undohistory aufnehmen
    1116 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().DoUndo(false);
    1117                 :            :     }
    1118                 :            : 
    1119         [ +  - ]:         72 :     ::PaMCorrAbs( aOriginal, *pEnd );
    1120                 :            : 
    1121                 :            :     // sorge dafuer, das der Bereich auf Node-Grenzen liegt
    1122         [ +  - ]:         72 :     SwNodeRange aRg( pStt->nNode, pEnd->nNode );
    1123         [ -  + ]:         72 :     if( pStt->nContent.GetIndex() )
    1124         [ #  # ]:          0 :         SplitNode( *pStt, false );
    1125                 :            : 
    1126                 :         72 :     sal_Bool bEndCntnt = 0 != pEnd->nContent.GetIndex();
    1127                 :            :     // nicht splitten am Ende der Zeile (aber am Ende vom Doc!!)
    1128         [ -  + ]:         72 :     if( bEndCntnt )
    1129                 :            :     {
    1130         [ #  # ]:          0 :         if( pEnd->nNode.GetNode().GetCntntNode()->Len() != pEnd->nContent.GetIndex()
           [ #  #  #  # ]
                 [ #  # ]
    1131         [ #  # ]:          0 :             || pEnd->nNode.GetIndex() >= GetNodes().GetEndOfContent().GetIndex()-1 )
    1132                 :            :         {
    1133         [ #  # ]:          0 :             SplitNode( *pEnd, false );
    1134         [ #  # ]:          0 :             ((SwNodeIndex&)pEnd->nNode)--;
    1135                 :            :             ((SwIndex&)pEnd->nContent).Assign(
    1136 [ #  # ][ #  # ]:          0 :                                 pEnd->nNode.GetNode().GetCntntNode(), 0 );
    1137                 :            :             // ein Node und am Ende ??
    1138         [ #  # ]:          0 :             if( pStt->nNode.GetIndex() >= pEnd->nNode.GetIndex() )
    1139         [ #  # ]:          0 :                 aRg.aStart--;
    1140                 :            :         }
    1141                 :            :         else
    1142         [ #  # ]:          0 :             aRg.aEnd++;
    1143                 :            :     }
    1144                 :            : 
    1145                 :            : 
    1146         [ -  + ]:         72 :     if( aRg.aEnd.GetIndex() == aRg.aStart.GetIndex() )
    1147                 :            :     {
    1148                 :            :         OSL_FAIL( "Kein Bereich" );
    1149         [ #  # ]:          0 :         aRg.aEnd++;
    1150                 :            :     }
    1151                 :            : 
    1152                 :            :     // Wir gehen jetzt immer ueber die Upper, um die Tabelle einzufuegen:
    1153         [ +  - ]:         72 :     SwNode2Layout aNode2Layout( aRg.aStart.GetNode() );
    1154                 :            : 
    1155 [ +  - ][ +  - ]:         72 :     GetIDocumentUndoRedo().DoUndo(bUndo);
    1156                 :            : 
    1157                 :            :     // dann erstelle die Box/Line/Table-Struktur
    1158         [ +  - ]:         72 :     SwTableBoxFmt* pBoxFmt = MakeTableBoxFmt();
    1159         [ +  - ]:         72 :     SwTableLineFmt* pLineFmt = MakeTableLineFmt();
    1160 [ +  - ][ +  - ]:         72 :     SwTableFmt* pTableFmt = MakeTblFrmFmt( GetUniqueTblName(), GetDfltFrmFmt() );
                 [ +  - ]
    1161                 :            : 
    1162                 :            :     // alle Zeilen haben die Fill-Order von links nach rechts !
    1163 [ +  - ][ +  - ]:         72 :     pLineFmt->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ));
                 [ +  - ]
    1164                 :            :     // die Tabelle bekommt USHRT_MAX als default SSize
    1165 [ +  - ][ +  - ]:         72 :     pTableFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, USHRT_MAX ));
                 [ +  - ]
    1166                 :            : 
    1167                 :            :     /* If the first node in the selection is a context node and if it
    1168                 :            :        has an item FRAMEDIR set (no default) propagate the item to the
    1169                 :            :        replacing table. */
    1170         [ +  - ]:         72 :     if (pSttCntntNd)
    1171                 :            :     {
    1172         [ +  - ]:         72 :         const SwAttrSet & aNdSet = pSttCntntNd->GetSwAttrSet();
    1173                 :         72 :         const SfxPoolItem *pItem = NULL;
    1174                 :            : 
    1175 [ +  - ][ +  + ]:         72 :         if (SFX_ITEM_SET == aNdSet.GetItemState( RES_FRAMEDIR, sal_True, &pItem )
         [ +  - ][ +  + ]
    1176                 :            :             && pItem != NULL)
    1177                 :            :         {
    1178         [ +  - ]:         72 :             pTableFmt->SetFmtAttr( *pItem );
    1179                 :            :         }
    1180                 :            :     }
    1181                 :            : 
    1182         [ +  - ]:         72 :     SwTableNode* pTblNd = GetNodes().TextToTable(
    1183                 :            :             rTableNodes, pTableFmt, pLineFmt, pBoxFmt,
    1184 [ +  - ][ +  - ]:        144 :             GetTxtCollFromPool( RES_POOLCOLL_STANDARD )/*, pUndo*/ );
    1185                 :            : 
    1186                 :         72 :     SwTable * pNdTbl = &pTblNd->GetTable();
    1187                 :            :     OSL_ENSURE( pNdTbl, "kein Tabellen-Node angelegt."  );
    1188         [ +  - ]:         72 :     pNdTbl->RegisterToFormat( *pTableFmt );
    1189                 :            : 
    1190         [ -  + ]:         72 :     if( !pBoxFmt->GetDepends() )
    1191                 :            :     {
    1192                 :            :         // die Formate an den Boxen haben schon die richtige Size, es darf
    1193                 :            :         // also nur noch die richtige Umrandung/AutoFmt gesetzt werden.
    1194 [ #  # ][ #  # ]:          0 :         pTableFmt->SetFmtAttr( pBoxFmt->GetFrmSize() );
    1195 [ #  # ][ #  # ]:          0 :         delete pBoxFmt;
    1196                 :            :     }
    1197                 :            : 
    1198                 :         72 :     sal_uLong nIdx = pTblNd->GetIndex();
    1199 [ +  - ][ +  - ]:         72 :     aNode2Layout.RestoreUpperFrms( GetNodes(), nIdx, nIdx + 1 );
    1200                 :            : 
    1201         [ +  - ]:         72 :     SetModified();
    1202         [ +  - ]:         72 :     SetFieldsDirty( true, NULL, 0 );
    1203 [ +  - ][ +  - ]:         72 :     return pNdTbl;
                 [ +  - ]
    1204                 :            : }
    1205                 :            : 
    1206                 :        436 : SwNodeRange * SwNodes::ExpandRangeForTableBox(const SwNodeRange & rRange)
    1207                 :            : {
    1208                 :        436 :     SwNodeRange * pResult = NULL;
    1209                 :        436 :     bool bChanged = false;
    1210                 :            : 
    1211         [ +  - ]:        436 :     SwNodeIndex aNewStart = rRange.aStart;
    1212         [ +  - ]:        436 :     SwNodeIndex aNewEnd = rRange.aEnd;
    1213                 :            : 
    1214         [ +  - ]:        436 :     SwNodeIndex aEndIndex = rRange.aEnd;
    1215         [ +  - ]:        436 :     SwNodeIndex aIndex = rRange.aStart;
    1216                 :            : 
    1217         [ -  + ]:        436 :     while (aIndex < aEndIndex)
    1218                 :            :     {
    1219                 :          0 :         SwNode& rNode = aIndex.GetNode();
    1220                 :            : 
    1221         [ #  # ]:          0 :         if (rNode.IsStartNode())
    1222                 :            :         {
    1223                 :            :             // advance aIndex to the end node of this start node
    1224                 :          0 :             SwNode * pEndNode = rNode.EndOfSectionNode();
    1225         [ #  # ]:          0 :             aIndex = *pEndNode;
    1226                 :            : 
    1227         [ #  # ]:          0 :             if (aIndex > aNewEnd)
    1228                 :            :             {
    1229         [ #  # ]:          0 :                 aNewEnd = aIndex;
    1230                 :          0 :                 bChanged = true;
    1231                 :            :             }
    1232                 :            :         }
    1233         [ #  # ]:          0 :         else if (rNode.IsEndNode())
    1234                 :            :         {
    1235                 :          0 :             SwNode * pStartNode = rNode.StartOfSectionNode();
    1236         [ #  # ]:          0 :             SwNodeIndex aStartIndex = *pStartNode;
    1237                 :            : 
    1238         [ #  # ]:          0 :             if (aStartIndex < aNewStart)
    1239                 :            :             {
    1240         [ #  # ]:          0 :                 aNewStart = aStartIndex;
    1241                 :          0 :                 bChanged = true;
    1242         [ #  # ]:          0 :             }
    1243                 :            :         }
    1244                 :            : 
    1245         [ #  # ]:          0 :         if (aIndex < aEndIndex)
    1246         [ #  # ]:          0 :             ++aIndex;
    1247                 :            :     }
    1248                 :            : 
    1249                 :        436 :     SwNode * pNode = &aIndex.GetNode();
    1250         [ -  + ]:        436 :     while (pNode->IsEndNode())
    1251                 :            :     {
    1252                 :          0 :         SwNode * pStartNode = pNode->StartOfSectionNode();
    1253         [ #  # ]:          0 :         SwNodeIndex aStartIndex(*pStartNode);
    1254         [ #  # ]:          0 :         aNewStart = aStartIndex;
    1255         [ #  # ]:          0 :         aNewEnd = aIndex;
    1256                 :          0 :         bChanged = true;
    1257                 :            : 
    1258         [ #  # ]:          0 :         ++aIndex;
    1259                 :          0 :         pNode = &aIndex.GetNode();
    1260         [ #  # ]:          0 :     }
    1261                 :            : 
    1262         [ -  + ]:        436 :     if (bChanged)
    1263 [ #  # ][ #  # ]:          0 :         pResult = new SwNodeRange(aNewStart, aNewEnd);
    1264                 :            : 
    1265 [ +  - ][ +  - ]:        436 :     return pResult;
         [ +  - ][ +  - ]
    1266                 :            : }
    1267                 :            : 
    1268                 :         72 : SwTableNode* SwNodes::TextToTable( const SwNodes::TableRanges_t & rTableNodes,
    1269                 :            :                                     SwTableFmt* pTblFmt,
    1270                 :            :                                     SwTableLineFmt* pLineFmt,
    1271                 :            :                                     SwTableBoxFmt* pBoxFmt,
    1272                 :            :                                     SwTxtFmtColl* /*pTxtColl*/  /*, SwUndo... pUndo*/  )
    1273                 :            : {
    1274         [ -  + ]:         72 :     if( !rTableNodes.size() )
    1275                 :          0 :         return 0;
    1276                 :            : 
    1277 [ +  - ][ +  - ]:         72 :     SwTableNode * pTblNd = new SwTableNode( rTableNodes.begin()->begin()->aStart );
    1278                 :            :     //insert the end node after the last text node
    1279 [ +  - ][ +  - ]:         72 :    SwNodeIndex aInsertIndex( rTableNodes.rbegin()->rbegin()->aEnd );
                 [ +  - ]
    1280         [ +  - ]:         72 :    ++aInsertIndex;
    1281                 :            : 
    1282                 :            :    //!! owner ship will be transferred in c-tor to SwNodes array.
    1283                 :            :    //!! Thus no real problem here...
    1284 [ +  - ][ +  - ]:         72 :    new SwEndNode( aInsertIndex, *pTblNd );
    1285                 :            : 
    1286                 :            : #if OSL_DEBUG_LEVEL > 1
    1287                 :            :     /**debug**/
    1288                 :            :     const SwNodeRange& rStartRange = *rTableNodes.begin()->begin();
    1289                 :            :     const SwNodeRange& rEndRange = *rTableNodes.rbegin()->rbegin();
    1290                 :            :     (void) rStartRange;
    1291                 :            :     (void) rEndRange;
    1292                 :            :     /**debug**/
    1293                 :            : #endif
    1294                 :            : 
    1295                 :         72 :     SwDoc* pDoc = GetDoc();
    1296         [ +  - ]:         72 :     std::vector<sal_uInt16> aPosArr;
    1297                 :         72 :     SwTable * pTable = &pTblNd->GetTable();
    1298                 :            :     SwTableLine* pLine;
    1299                 :            :     SwTableBox* pBox;
    1300                 :         72 :     sal_uInt16 nBoxes, nLines, nMaxBoxes = 0;
    1301                 :            : 
    1302         [ +  - ]:         72 :     SwNodeIndex aNodeIndex = rTableNodes.begin()->begin()->aStart;
    1303                 :            :     // delete frames of all contained content nodes
    1304 [ +  - ][ +  - ]:        508 :     for( nLines = 0; aNodeIndex <= rTableNodes.rbegin()->rbegin()->aEnd; ++aNodeIndex,++nLines )
         [ +  - ][ +  + ]
    1305                 :            :     {
    1306                 :        436 :         SwNode& rNode = aNodeIndex.GetNode();
    1307         [ +  - ]:        436 :         if( rNode.IsCntntNode() )
    1308                 :            :         {
    1309         [ +  - ]:        436 :             static_cast<SwCntntNode&>(rNode).DelFrms();
    1310         [ +  - ]:        436 :             if(rNode.IsTxtNode())
    1311                 :            :             {
    1312                 :        436 :                 SwTxtNode& rTxtNode = static_cast<SwTxtNode&>(rNode);
    1313                 :            :                 // setze den bei allen TextNode in der Tabelle den TableNode
    1314                 :            :                 // als StartNode
    1315                 :            : 
    1316                 :            :                 // remove PageBreaks/PageDesc/ColBreak
    1317         [ +  - ]:        436 :                 const SwAttrSet* pSet = rTxtNode.GetpSwAttrSet();
    1318         [ +  + ]:        436 :                 if( pSet )
    1319                 :            :                 {
    1320                 :            :                     const SfxPoolItem* pItem;
    1321 [ +  - ][ -  + ]:        188 :                     if( SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, sal_False, &pItem ) )
    1322                 :            :                     {
    1323         [ #  # ]:          0 :                         if( !nLines )
    1324         [ #  # ]:          0 :                             pTblFmt->SetFmtAttr( *pItem );
    1325         [ #  # ]:          0 :                         rTxtNode.ResetAttr( RES_BREAK );
    1326         [ #  # ]:          0 :                         pSet = rTxtNode.GetpSwAttrSet();
    1327                 :            :                     }
    1328                 :            : 
    1329         [ +  - ]:        376 :                     if( pSet && SFX_ITEM_SET == pSet->GetItemState(
           [ -  +  #  # ]
                 [ -  + ]
    1330         [ +  - ]:        188 :                         RES_PAGEDESC, sal_False, &pItem ) &&
    1331                 :          0 :                         ((SwFmtPageDesc*)pItem)->GetPageDesc() )
    1332                 :            :                     {
    1333         [ #  # ]:          0 :                         if( !nLines )
    1334         [ #  # ]:          0 :                             pTblFmt->SetFmtAttr( *pItem );
    1335         [ #  # ]:        188 :                         rTxtNode.ResetAttr( RES_PAGEDESC );
    1336                 :            :                     }
    1337                 :            :                 }
    1338                 :            :             }
    1339                 :            :         }
    1340                 :            :     }
    1341                 :            : 
    1342                 :         72 :     std::vector<std::vector < SwNodeRange > >::const_iterator aRowIter = rTableNodes.begin();
    1343 [ +  - ][ +  + ]:        302 :     for( nLines = 0, nBoxes = 0;
    1344                 :        151 :         aRowIter != rTableNodes.end();
    1345                 :            :         ++aRowIter, nLines++, nBoxes = 0 )
    1346                 :            :     {
    1347 [ +  - ][ +  - ]:         79 :         pLine = new SwTableLine( pLineFmt, 1, 0 );
    1348 [ +  - ][ +  - ]:         79 :         pTable->GetTabLines().insert( pTable->GetTabLines().begin() + nLines, pLine );
    1349                 :            : 
    1350                 :         79 :         std::vector< SwNodeRange >::const_iterator aCellIter = aRowIter->begin();
    1351                 :            : 
    1352 [ +  - ][ +  + ]:        515 :         for( ; aCellIter != aRowIter->end(); ++aCellIter )
    1353                 :            :         {
    1354         [ +  - ]:        436 :                 const SwNodeIndex aTmpIdx( aCellIter->aStart, 0 );
    1355                 :            : 
    1356         [ +  - ]:        436 :                SwNodeIndex aCellEndIdx(aCellIter->aEnd);
    1357         [ +  - ]:        436 :                ++aCellEndIdx;
    1358                 :            :                SwStartNode* pSttNd = new SwStartNode( aTmpIdx, ND_STARTNODE,
    1359 [ +  - ][ +  - ]:        436 :                                             SwTableBoxStartNode );
    1360                 :            : 
    1361                 :            :                 // Quotation of http://nabble.documentfoundation.org/Some-strange-lines-by-taking-a-look-at-the-bt-of-fdo-51916-tp3994561p3994639.html
    1362                 :            :                 // SwNode's constructor adds itself to the same SwNodes array as the other node (pSttNd).
    1363                 :            :                 // So this statement is only executed for the side-effect.
    1364 [ +  - ][ +  - ]:        436 :                 new SwEndNode( aCellEndIdx, *pSttNd );
    1365                 :            : 
    1366                 :            :                 //set the start node on all node of the current cell
    1367         [ +  - ]:        436 :                 SwNodeIndex aCellNodeIdx = aCellIter->aStart;
    1368 [ +  - ][ +  + ]:        872 :                 for(;aCellNodeIdx <= aCellIter->aEnd; ++aCellNodeIdx )
    1369                 :            :                 {
    1370                 :        436 :                     aCellNodeIdx.GetNode().pStartOfSection = pSttNd;
    1371                 :            :                     //skip start/end node pairs
    1372         [ -  + ]:        436 :                     if( aCellNodeIdx.GetNode().IsStartNode() )
    1373 [ #  # ][ #  # ]:          0 :                         aCellNodeIdx = SwNodeIndex( *aCellNodeIdx.GetNode().EndOfSectionNode() );
                 [ #  # ]
    1374                 :            :                 }
    1375                 :            : 
    1376                 :            :                 // Section der Box zuweisen
    1377 [ +  - ][ +  - ]:        436 :                 pBox = new SwTableBox( pBoxFmt, *pSttNd, pLine );
    1378 [ +  - ][ +  - ]:        436 :                 pLine->GetTabBoxes().insert( pLine->GetTabBoxes().begin() + nBoxes++, pBox );
    1379 [ +  - ][ +  - ]:        436 :         }
                 [ +  - ]
    1380         [ +  + ]:         79 :         if( nMaxBoxes < nBoxes )
    1381                 :         72 :             nMaxBoxes = nBoxes;
    1382                 :            :     }
    1383                 :            : 
    1384                 :            :     // die Tabelle ausgleichen, leere Sections einfuegen
    1385                 :            :     sal_uInt16 n;
    1386                 :            : 
    1387         [ -  + ]:         72 :     if( !aPosArr.empty() )
    1388                 :            :     {
    1389                 :          0 :         SwTableLines& rLns = pTable->GetTabLines();
    1390                 :          0 :         sal_uInt16 nLastPos = 0;
    1391         [ #  # ]:          0 :         for( n = 0; n < aPosArr.size(); ++n )
    1392                 :            :         {
    1393         [ #  # ]:          0 :             SwTableBoxFmt *pNewFmt = pDoc->MakeTableBoxFmt();
    1394                 :            :             pNewFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE,
    1395 [ #  # ][ #  # ]:          0 :                                                 aPosArr[ n ] - nLastPos ));
         [ #  # ][ #  # ]
    1396         [ #  # ]:          0 :             for( sal_uInt16 nLines2 = 0; nLines2 < rLns.size(); ++nLines2 )
    1397                 :            :                 //JP 24.06.98: hier muss ein Add erfolgen, da das BoxFormat
    1398                 :            :                 //              von der rufenden Methode noch gebraucht wird!
    1399         [ #  # ]:          0 :                 pNewFmt->Add( rLns[ nLines2 ]->GetTabBoxes()[ n ] );
    1400                 :            : 
    1401         [ #  # ]:          0 :             nLastPos = aPosArr[ n ];
    1402                 :            :         }
    1403                 :            : 
    1404                 :            :         // damit die Tabelle die richtige Groesse bekommt, im BoxFormat die
    1405                 :            :         // Groesse nach "oben" transportieren.
    1406                 :            :         OSL_ENSURE( !pBoxFmt->GetDepends(), "wer ist in dem Format noch angemeldet" );
    1407 [ #  # ][ #  # ]:          0 :         pBoxFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, nLastPos ));
                 [ #  # ]
    1408                 :            :     }
    1409                 :            :     else
    1410 [ +  - ][ +  - ]:         72 :         pBoxFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, USHRT_MAX / nMaxBoxes ));
                 [ +  - ]
    1411                 :            : 
    1412                 :            :     // das wars doch wohl ??
    1413 [ +  - ][ +  - ]:         72 :     return pTblNd;
    1414                 :            : }
    1415                 :            : 
    1416                 :            : 
    1417                 :            : //---------------- Tabelle -> Text -----------------------
    1418                 :            : 
    1419                 :            : 
    1420                 :          0 : sal_Bool SwDoc::TableToText( const SwTableNode* pTblNd, sal_Unicode cCh )
    1421                 :            : {
    1422         [ #  # ]:          0 :     if( !pTblNd )
    1423                 :          0 :         return sal_False;
    1424                 :            : 
    1425                 :            :     // #i34471#
    1426                 :            :     // If this is trigged by SwUndoTblToTxt::Repeat() nobody ever deleted
    1427                 :            :     // the table cursor.
    1428         [ #  # ]:          0 :     SwEditShell* pESh = GetEditShell();
    1429 [ #  # ][ #  # ]:          0 :     if( pESh && pESh->IsTableMode() )
                 [ #  # ]
    1430         [ #  # ]:          0 :         pESh->ClearMark();
    1431                 :            : 
    1432         [ #  # ]:          0 :     SwNodeRange aRg( *pTblNd, 0, *pTblNd->EndOfSectionNode() );
    1433                 :          0 :     SwUndoTblToTxt* pUndo = 0;
    1434                 :          0 :     SwNodeRange* pUndoRg = 0;
    1435 [ #  # ][ #  # ]:          0 :     if (GetIDocumentUndoRedo().DoesUndo())
                 [ #  # ]
    1436                 :            :     {
    1437 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().ClearRedo();
    1438 [ #  # ][ #  # ]:          0 :         pUndoRg = new SwNodeRange( aRg.aStart, -1, aRg.aEnd, +1 );
    1439 [ #  # ][ #  # ]:          0 :         pUndo = new SwUndoTblToTxt( pTblNd->GetTable(), cCh );
    1440                 :            :     }
    1441                 :            : 
    1442         [ #  # ]:          0 :     SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
    1443                 :          0 :     aMsgHnt.eFlags = TBL_BOXNAME;
    1444         [ #  # ]:          0 :     UpdateTblFlds( &aMsgHnt );
    1445                 :            : 
    1446 [ #  # ][ #  # ]:          0 :     sal_Bool bRet = GetNodes().TableToText( aRg, cCh, pUndo );
    1447         [ #  # ]:          0 :     if( pUndoRg )
    1448                 :            :     {
    1449         [ #  # ]:          0 :         pUndoRg->aStart++;
    1450         [ #  # ]:          0 :         pUndoRg->aEnd--;
    1451         [ #  # ]:          0 :         pUndo->SetRange( *pUndoRg );
    1452 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().AppendUndo(pUndo);
    1453 [ #  # ][ #  # ]:          0 :         delete pUndoRg;
    1454                 :            :     }
    1455                 :            : 
    1456         [ #  # ]:          0 :     if( bRet )
    1457         [ #  # ]:          0 :         SetModified();
    1458                 :            : 
    1459 [ #  # ][ #  # ]:          0 :     return bRet;
    1460                 :            : }
    1461                 :            : 
    1462                 :            : // -- benutze die ForEach Methode vom PtrArray um aus einer Tabelle wieder
    1463                 :            : //      Text zuerzeugen. (Die Boxen koennen auch noch Lines enthalten !!)
    1464                 :            : struct _DelTabPara
    1465                 :            : {
    1466                 :            :     SwTxtNode* pLastNd;
    1467                 :            :     SwNodes& rNds;
    1468                 :            :     SwUndoTblToTxt* pUndo;
    1469                 :            :     sal_Unicode cCh;
    1470                 :            : 
    1471                 :          0 :     _DelTabPara( SwNodes& rNodes, sal_Unicode cChar, SwUndoTblToTxt* pU ) :
    1472                 :          0 :         pLastNd(0), rNds( rNodes ), pUndo( pU ), cCh( cChar ) {}
    1473                 :          0 :     _DelTabPara( const _DelTabPara& rPara ) :
    1474                 :            :         pLastNd(rPara.pLastNd), rNds( rPara.rNds ),
    1475                 :          0 :         pUndo( rPara.pUndo ), cCh( rPara.cCh ) {}
    1476                 :            : };
    1477                 :            : 
    1478                 :            : // forward deklarieren damit sich die Lines und Boxen rekursiv aufrufen
    1479                 :            : // koennen.
    1480                 :            : static void lcl_DelBox( SwTableBox* pBox, _DelTabPara* pDelPara );
    1481                 :            : 
    1482                 :          0 : static void lcl_DelLine( SwTableLine* pLine, _DelTabPara* pPara )
    1483                 :            : {
    1484                 :            :     OSL_ENSURE( pPara, "die Parameter fehlen" );
    1485                 :          0 :     _DelTabPara aPara( *pPara );
    1486 [ #  # ][ #  # ]:          0 :     for( SwTableBoxes::iterator it = pLine->GetTabBoxes().begin();
    1487                 :          0 :              it != pLine->GetTabBoxes().end(); ++it)
    1488         [ #  # ]:          0 :         lcl_DelBox(*it, &aPara );
    1489         [ #  # ]:          0 :     if( pLine->GetUpper() )        // gibt es noch eine uebergeordnete Box ??
    1490                 :            :         // dann gebe den letzten TextNode zurueck
    1491                 :          0 :         pPara->pLastNd = aPara.pLastNd;
    1492                 :          0 : }
    1493                 :            : 
    1494                 :            : 
    1495                 :          0 : static void lcl_DelBox( SwTableBox* pBox, _DelTabPara* pDelPara )
    1496                 :            : {
    1497                 :            :     OSL_ENSURE( pDelPara, "die Parameter fehlen" );
    1498                 :            : 
    1499                 :            :     // loesche erstmal die Lines der Box
    1500         [ #  # ]:          0 :     if( !pBox->GetTabLines().empty() )
    1501 [ #  # ][ #  # ]:          0 :         BOOST_FOREACH( SwTableLine* pLine, pBox->GetTabLines() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1502         [ #  # ]:          0 :             lcl_DelLine( pLine, pDelPara );
    1503                 :            :     else
    1504                 :            :     {
    1505                 :          0 :         SwDoc* pDoc = pDelPara->rNds.GetDoc();
    1506                 :          0 :         SwNodeRange aDelRg( *pBox->GetSttNd(), 0,
    1507         [ #  # ]:          0 :                             *pBox->GetSttNd()->EndOfSectionNode() );
    1508                 :            :         // loesche die Section
    1509         [ #  # ]:          0 :         pDelPara->rNds.SectionUp( &aDelRg );
    1510                 :            :         const SwTxtNode* pCurTxtNd;
    1511         [ #  # ]:          0 :         if( T2T_PARA != pDelPara->cCh && pDelPara->pLastNd &&
           [ #  #  #  # ]
                 [ #  # ]
    1512                 :          0 :             0 != ( pCurTxtNd = aDelRg.aStart.GetNode().GetTxtNode() ))
    1513                 :            :         {
    1514                 :            :             // Join the current text node with the last from the previous box if possible
    1515                 :          0 :             sal_uLong nNdIdx = aDelRg.aStart.GetIndex();
    1516         [ #  # ]:          0 :             aDelRg.aStart--;
    1517 [ #  # ][ #  # ]:          0 :             if( pDelPara->pLastNd == &aDelRg.aStart.GetNode() )
    1518                 :            :             {
    1519                 :            :                 // Inserting the seperator
    1520 [ #  # ][ #  # ]:          0 :                 SwIndex aCntIdx( pDelPara->pLastNd, pDelPara->pLastNd->GetTxt().Len());
    1521                 :            :                 pDelPara->pLastNd->InsertText( rtl::OUString(pDelPara->cCh), aCntIdx,
    1522 [ #  # ][ #  # ]:          0 :                     IDocumentContentOperations::INS_EMPTYEXPAND );
                 [ #  # ]
    1523         [ #  # ]:          0 :                 if( pDelPara->pUndo )
    1524                 :            :                     pDelPara->pUndo->AddBoxPos( *pDoc, nNdIdx, aDelRg.aEnd.GetIndex(),
    1525         [ #  # ]:          0 :                                                 aCntIdx.GetIndex() );
    1526                 :            : 
    1527         [ #  # ]:          0 :                 std::vector<sal_uLong> aBkmkArr;
    1528                 :          0 :                 xub_StrLen nOldTxtLen = aCntIdx.GetIndex();
    1529                 :          0 :                 _SaveCntntIdx( pDoc, nNdIdx, pCurTxtNd->GetTxt().Len(),
    1530         [ #  # ]:          0 :                                 aBkmkArr );
    1531                 :            : 
    1532         [ #  # ]:          0 :                 pDelPara->pLastNd->JoinNext();
    1533                 :            : 
    1534         [ #  # ]:          0 :                 if( !aBkmkArr.empty() )
    1535                 :            :                     _RestoreCntntIdx( pDoc, aBkmkArr,
    1536                 :            :                                         pDelPara->pLastNd->GetIndex(),
    1537 [ #  # ][ #  # ]:          0 :                                         nOldTxtLen );
    1538                 :            :             }
    1539         [ #  # ]:          0 :             else if( pDelPara->pUndo )
    1540                 :            :             {
    1541         [ #  # ]:          0 :                 aDelRg.aStart++;
    1542         [ #  # ]:          0 :                 pDelPara->pUndo->AddBoxPos( *pDoc, nNdIdx, aDelRg.aEnd.GetIndex() );
    1543                 :            :             }
    1544                 :            :         }
    1545         [ #  # ]:          0 :         else if( pDelPara->pUndo )
    1546         [ #  # ]:          0 :             pDelPara->pUndo->AddBoxPos( *pDoc, aDelRg.aStart.GetIndex(), aDelRg.aEnd.GetIndex() );
    1547         [ #  # ]:          0 :         aDelRg.aEnd--;
    1548                 :          0 :         pDelPara->pLastNd = aDelRg.aEnd.GetNode().GetTxtNode();
    1549                 :            : 
    1550                 :            :         //JP 03.04.97: die Ausrichtung der ZahlenFormatierung auf
    1551                 :            :         //              keinen Fall uebernehmen
    1552 [ #  # ][ #  # ]:          0 :         if( pDelPara->pLastNd && pDelPara->pLastNd->HasSwAttrSet() )
         [ #  # ][ #  # ]
    1553 [ #  # ][ #  # ]:          0 :             pDelPara->pLastNd->ResetAttr( RES_PARATR_ADJUST );
    1554                 :            :     }
    1555                 :          0 : }
    1556                 :            : 
    1557                 :            : 
    1558                 :          0 : sal_Bool SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh,
    1559                 :            :                             SwUndoTblToTxt* pUndo )
    1560                 :            : {
    1561                 :            :     // ist eine Tabelle selektiert ?
    1562                 :            :     SwTableNode* pTblNd;
    1563   [ #  #  #  #  :          0 :     if( rRange.aStart.GetIndex() >= rRange.aEnd.GetIndex() ||
           #  # ][ #  # ]
    1564                 :          0 :         0 == ( pTblNd = rRange.aStart.GetNode().GetTableNode()) ||
    1565                 :          0 :         &rRange.aEnd.GetNode() != pTblNd->EndOfSectionNode() )
    1566                 :          0 :         return sal_False;
    1567                 :            : 
    1568                 :            :     // stand die Tabelle ganz alleine in einer Section ?
    1569                 :            :     // dann ueber den Upper der Tabelle die Frames anlegen
    1570                 :          0 :     SwNode2Layout* pNode2Layout = 0;
    1571         [ #  # ]:          0 :     SwNodeIndex aFrmIdx( rRange.aStart );
    1572         [ #  # ]:          0 :     SwNode* pFrmNd = FindPrvNxtFrmNode( aFrmIdx, &rRange.aEnd.GetNode() );
    1573         [ #  # ]:          0 :     if( !pFrmNd )
    1574                 :            :         // dann sammel mal alle Uppers ein
    1575 [ #  # ][ #  # ]:          0 :         pNode2Layout = new SwNode2Layout( *pTblNd );
    1576                 :            : 
    1577                 :            :     // loesche schon mal die Frames
    1578         [ #  # ]:          0 :     pTblNd->DelFrms();
    1579                 :            : 
    1580                 :            :     // dann "loeschen" die Tabellen und fasse alle Lines/Boxen zusammen
    1581                 :          0 :     _DelTabPara aDelPara( *this, cCh, pUndo );
    1582 [ #  # ][ #  # ]:          0 :     BOOST_FOREACH( SwTableLine *pLine, pTblNd->pTable->GetTabLines() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1583         [ #  # ]:          0 :         lcl_DelLine( pLine, &aDelPara );
    1584                 :            : 
    1585                 :            :     // jetzt ist aus jeder TableLine ein TextNode mit dem entsprechenden
    1586                 :            :     // Trenner erzeugt worden. Es braucht nur noch die Table-Section
    1587                 :            :     // geloescht und fuer die neuen TextNode die Frames erzeugt werden.
    1588         [ #  # ]:          0 :     SwNodeRange aDelRg( rRange.aStart, rRange.aEnd );
    1589                 :            : 
    1590                 :            :     // JP 14.01.97: hat die Tabelle PageDesc-/Break-Attribute? Dann in den
    1591                 :            :     //              ersten TextNode uebernehmen
    1592                 :            :     {
    1593                 :            : // was ist mit UNDO???
    1594                 :          0 :         const SfxItemSet& rTblSet = pTblNd->pTable->GetFrmFmt()->GetAttrSet();
    1595                 :            :         const SfxPoolItem *pBreak, *pDesc;
    1596 [ #  # ][ #  # ]:          0 :         if( SFX_ITEM_SET != rTblSet.GetItemState( RES_PAGEDESC, sal_False, &pDesc ))
    1597                 :          0 :             pDesc = 0;
    1598 [ #  # ][ #  # ]:          0 :         if( SFX_ITEM_SET != rTblSet.GetItemState( RES_BREAK, sal_False, &pBreak ))
    1599                 :          0 :             pBreak = 0;
    1600                 :            : 
    1601 [ #  # ][ #  # ]:          0 :         if( pBreak || pDesc )
    1602                 :            :         {
    1603         [ #  # ]:          0 :             SwNodeIndex aIdx( *pTblNd  );
    1604         [ #  # ]:          0 :             SwCntntNode* pCNd = GoNext( &aIdx );
    1605         [ #  # ]:          0 :             if( pBreak )
    1606         [ #  # ]:          0 :                 pCNd->SetAttr( *pBreak );
    1607         [ #  # ]:          0 :             if( pDesc )
    1608 [ #  # ][ #  # ]:          0 :                 pCNd->SetAttr( *pDesc );
    1609                 :            :         }
    1610                 :            :     }
    1611                 :            : 
    1612         [ #  # ]:          0 :     SectionUp( &aDelRg );       // loesche die Section und damit die Tabelle
    1613                 :            :     // #i28006#
    1614                 :          0 :     sal_uLong nStt = aDelRg.aStart.GetIndex(), nEnd = aDelRg.aEnd.GetIndex();
    1615         [ #  # ]:          0 :     if( !pFrmNd )
    1616                 :            :     {
    1617                 :            :         pNode2Layout->RestoreUpperFrms( *this,
    1618         [ #  # ]:          0 :                         aDelRg.aStart.GetIndex(), aDelRg.aEnd.GetIndex() );
    1619 [ #  # ][ #  # ]:          0 :         delete pNode2Layout;
    1620                 :            :     }
    1621                 :            :     else
    1622                 :            :     {
    1623                 :            :         SwCntntNode *pCNd;
    1624                 :            :         SwSectionNode *pSNd;
    1625         [ #  # ]:          0 :         while( aDelRg.aStart.GetIndex() < nEnd )
    1626                 :            :         {
    1627         [ #  # ]:          0 :             if( 0 != ( pCNd = aDelRg.aStart.GetNode().GetCntntNode()))
    1628                 :            :             {
    1629         [ #  # ]:          0 :                 if( pFrmNd->IsCntntNode() )
    1630 [ #  # ][ #  # ]:          0 :                     ((SwCntntNode*)pFrmNd)->MakeFrms( *pCNd );
    1631         [ #  # ]:          0 :                 else if( pFrmNd->IsTableNode() )
    1632         [ #  # ]:          0 :                     ((SwTableNode*)pFrmNd)->MakeFrms( aDelRg.aStart );
    1633         [ #  # ]:          0 :                 else if( pFrmNd->IsSectionNode() )
    1634         [ #  # ]:          0 :                     ((SwSectionNode*)pFrmNd)->MakeFrms( aDelRg.aStart );
    1635         [ #  # ]:          0 :                 pFrmNd = pCNd;
    1636                 :            :             }
    1637         [ #  # ]:          0 :             else if( 0 != ( pSNd = aDelRg.aStart.GetNode().GetSectionNode()))
    1638                 :            :             {
    1639 [ #  # ][ #  # ]:          0 :                 if( !pSNd->GetSection().IsHidden() && !pSNd->IsCntntHidden() )
         [ #  # ][ #  # ]
    1640                 :            :                 {
    1641         [ #  # ]:          0 :                     pSNd->MakeFrms( &aFrmIdx, &aDelRg.aEnd );
    1642                 :          0 :                     pFrmNd = pSNd;
    1643                 :          0 :                     break;
    1644                 :            :                 }
    1645         [ #  # ]:          0 :                 aDelRg.aStart = *pSNd->EndOfSectionNode();
    1646                 :            :             }
    1647         [ #  # ]:          0 :             aDelRg.aStart++;
    1648                 :            :         }
    1649                 :            :     }
    1650                 :            : 
    1651                 :            :     // #i28006# Fly frames have to be restored even if the table was
    1652                 :            :     // #alone in the section
    1653                 :          0 :     const SwFrmFmts& rFlyArr = *GetDoc()->GetSpzFrmFmts();
    1654         [ #  # ]:          0 :     for( sal_uInt16 n = 0; n < rFlyArr.size(); ++n )
    1655                 :            :     {
    1656         [ #  # ]:          0 :         SwFrmFmt *const pFmt = (SwFrmFmt*)rFlyArr[n];
    1657         [ #  # ]:          0 :         const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
    1658         [ #  # ]:          0 :         SwPosition const*const pAPos = rAnchor.GetCntntAnchor();
    1659   [ #  #  #  #  :          0 :         if (pAPos &&
          #  #  #  #  #  
              # ][ #  # ]
    1660                 :          0 :             ((FLY_AT_PARA == rAnchor.GetAnchorId()) ||
    1661                 :          0 :              (FLY_AT_CHAR == rAnchor.GetAnchorId())) &&
    1662                 :          0 :             nStt <= pAPos->nNode.GetIndex() &&
    1663                 :          0 :             pAPos->nNode.GetIndex() < nEnd )
    1664                 :            :         {
    1665         [ #  # ]:          0 :             pFmt->MakeFrms();
    1666                 :            :         }
    1667                 :            :     }
    1668                 :            : 
    1669 [ #  # ][ #  # ]:          0 :     return sal_True;
    1670                 :            : }
    1671                 :            : 
    1672                 :            : 
    1673                 :            : // ----- einfuegen von Spalten/Zeilen ------------------------
    1674                 :            : 
    1675                 :          0 : sal_Bool SwDoc::InsertCol( const SwCursor& rCursor, sal_uInt16 nCnt, sal_Bool bBehind )
    1676                 :            : {
    1677 [ #  # ][ #  # ]:          0 :     if( !::CheckSplitCells( rCursor, nCnt + 1, nsSwTblSearchType::TBLSEARCH_COL ) )
    1678                 :          0 :         return sal_False;
    1679                 :            : 
    1680                 :            :     // lasse ueber das Layout die Boxen suchen
    1681         [ #  # ]:          0 :     SwSelBoxes aBoxes;
    1682         [ #  # ]:          0 :     ::GetTblSel( rCursor, aBoxes, nsSwTblSearchType::TBLSEARCH_COL );
    1683                 :            : 
    1684                 :          0 :     sal_Bool bRet = sal_False;
    1685         [ #  # ]:          0 :     if( !aBoxes.empty() )
    1686         [ #  # ]:          0 :         bRet = InsertCol( aBoxes, nCnt, bBehind );
    1687                 :          0 :     return bRet;
    1688                 :            : }
    1689                 :            : 
    1690                 :          0 : sal_Bool SwDoc::InsertCol( const SwSelBoxes& rBoxes, sal_uInt16 nCnt, sal_Bool bBehind )
    1691                 :            : {
    1692                 :            :     // uebers SwDoc fuer Undo !!
    1693                 :            :     OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" );
    1694         [ #  # ]:          0 :     SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode();
    1695         [ #  # ]:          0 :     if( !pTblNd )
    1696                 :          0 :         return sal_False;
    1697                 :            : 
    1698                 :          0 :     SwTable& rTbl = pTblNd->GetTable();
    1699 [ #  # ][ #  # ]:          0 :     if( rTbl.ISA( SwDDETable ))
                 [ #  # ]
    1700                 :          0 :         return sal_False;
    1701                 :            : 
    1702         [ #  # ]:          0 :     SwTableSortBoxes aTmpLst;
    1703                 :          0 :     SwUndoTblNdsChg* pUndo = 0;
    1704 [ #  # ][ #  # ]:          0 :     if (GetIDocumentUndoRedo().DoesUndo())
                 [ #  # ]
    1705                 :            :     {
    1706                 :            :         pUndo = new SwUndoTblNdsChg( UNDO_TABLE_INSCOL, rBoxes, *pTblNd,
    1707 [ #  # ][ #  # ]:          0 :                                      0, 0, nCnt, bBehind, sal_False );
    1708         [ #  # ]:          0 :         aTmpLst.insert( rTbl.GetTabSortBoxes() );
    1709                 :            :     }
    1710                 :            : 
    1711                 :          0 :     bool bRet(false);
    1712                 :            :     {
    1713 [ #  # ][ #  # ]:          0 :         ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
    1714                 :            : 
    1715         [ #  # ]:          0 :         SwTableFmlUpdate aMsgHnt( &rTbl );
    1716                 :          0 :         aMsgHnt.eFlags = TBL_BOXPTR;
    1717         [ #  # ]:          0 :         UpdateTblFlds( &aMsgHnt );
    1718                 :            : 
    1719         [ #  # ]:          0 :         bRet = rTbl.InsertCol( this, rBoxes, nCnt, bBehind );
    1720         [ #  # ]:          0 :         if (bRet)
    1721                 :            :         {
    1722         [ #  # ]:          0 :             SetModified();
    1723         [ #  # ]:          0 :             ::ClearFEShellTabCols();
    1724         [ #  # ]:          0 :             SetFieldsDirty( true, NULL, 0 );
    1725 [ #  # ][ #  # ]:          0 :         }
    1726                 :            :     }
    1727                 :            : 
    1728         [ #  # ]:          0 :     if( pUndo )
    1729                 :            :     {
    1730         [ #  # ]:          0 :         if( bRet )
    1731                 :            :         {
    1732         [ #  # ]:          0 :             pUndo->SaveNewBoxes( *pTblNd, aTmpLst );
    1733 [ #  # ][ #  # ]:          0 :             GetIDocumentUndoRedo().AppendUndo( pUndo );
    1734                 :            :         }
    1735                 :            :         else
    1736 [ #  # ][ #  # ]:          0 :             delete pUndo;
    1737                 :            :     }
    1738                 :          0 :     return bRet;
    1739                 :            : }
    1740                 :            : 
    1741                 :          2 : sal_Bool SwDoc::InsertRow( const SwCursor& rCursor, sal_uInt16 nCnt, sal_Bool bBehind )
    1742                 :            : {
    1743                 :            :     // lasse ueber das Layout die Boxen suchen
    1744         [ +  - ]:          2 :     SwSelBoxes aBoxes;
    1745         [ +  - ]:          2 :     GetTblSel( rCursor, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW );
    1746                 :            : 
    1747                 :          2 :     sal_Bool bRet = sal_False;
    1748         [ +  - ]:          2 :     if( !aBoxes.empty() )
    1749         [ +  - ]:          2 :         bRet = InsertRow( aBoxes, nCnt, bBehind );
    1750                 :          2 :     return bRet;
    1751                 :            : }
    1752                 :            : 
    1753                 :          2 : sal_Bool SwDoc::InsertRow( const SwSelBoxes& rBoxes, sal_uInt16 nCnt, sal_Bool bBehind )
    1754                 :            : {
    1755                 :            :     // uebers SwDoc fuer Undo !!
    1756                 :            :     OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" );
    1757         [ +  - ]:          2 :     SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode();
    1758         [ -  + ]:          2 :     if( !pTblNd )
    1759                 :          0 :         return sal_False;
    1760                 :            : 
    1761                 :          2 :     SwTable& rTbl = pTblNd->GetTable();
    1762 [ +  - ][ -  + ]:          2 :     if( rTbl.ISA( SwDDETable ))
                 [ +  - ]
    1763                 :          0 :         return sal_False;
    1764                 :            : 
    1765         [ +  - ]:          2 :     SwTableSortBoxes aTmpLst;
    1766                 :          2 :     SwUndoTblNdsChg* pUndo = 0;
    1767 [ +  - ][ +  - ]:          2 :     if (GetIDocumentUndoRedo().DoesUndo())
                 [ +  - ]
    1768                 :            :     {
    1769                 :            :         pUndo = new SwUndoTblNdsChg( UNDO_TABLE_INSROW,rBoxes, *pTblNd,
    1770 [ +  - ][ +  - ]:          2 :                                      0, 0, nCnt, bBehind, sal_False );
    1771         [ +  - ]:          2 :         aTmpLst.insert( rTbl.GetTabSortBoxes() );
    1772                 :            :     }
    1773                 :            : 
    1774                 :          2 :     bool bRet(false);
    1775                 :            :     {
    1776 [ +  - ][ +  - ]:          2 :         ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
    1777                 :            : 
    1778         [ +  - ]:          2 :         SwTableFmlUpdate aMsgHnt( &rTbl );
    1779                 :          2 :         aMsgHnt.eFlags = TBL_BOXPTR;
    1780         [ +  - ]:          2 :         UpdateTblFlds( &aMsgHnt );
    1781                 :            : 
    1782         [ +  - ]:          2 :         bRet = rTbl.InsertRow( this, rBoxes, nCnt, bBehind );
    1783         [ +  - ]:          2 :         if (bRet)
    1784                 :            :         {
    1785         [ +  - ]:          2 :             SetModified();
    1786         [ +  - ]:          2 :             ::ClearFEShellTabCols();
    1787         [ +  - ]:          2 :             SetFieldsDirty( true, NULL, 0 );
    1788 [ +  - ][ +  - ]:          2 :         }
    1789                 :            :     }
    1790                 :            : 
    1791         [ +  - ]:          2 :     if( pUndo )
    1792                 :            :     {
    1793         [ +  - ]:          2 :         if( bRet )
    1794                 :            :         {
    1795         [ +  - ]:          2 :             pUndo->SaveNewBoxes( *pTblNd, aTmpLst );
    1796 [ +  - ][ +  - ]:          2 :             GetIDocumentUndoRedo().AppendUndo( pUndo );
    1797                 :            :         }
    1798                 :            :         else
    1799 [ #  # ][ #  # ]:          0 :             delete pUndo;
    1800                 :            :     }
    1801                 :          2 :     return bRet;
    1802                 :            : 
    1803                 :            : }
    1804                 :            : 
    1805                 :            : // ----- loeschen von Spalten/Zeilen ------------------------
    1806                 :            : 
    1807                 :          2 : sal_Bool SwDoc::DeleteRow( const SwCursor& rCursor )
    1808                 :            : {
    1809                 :            :     // lasse ueber das Layout die Boxen suchen
    1810         [ +  - ]:          2 :     SwSelBoxes aBoxes;
    1811         [ +  - ]:          2 :     GetTblSel( rCursor, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW );
    1812 [ +  - ][ -  + ]:          2 :     if( ::HasProtectedCells( aBoxes ))
    1813                 :          0 :         return sal_False;
    1814                 :            : 
    1815                 :            :     // die Crsr aus dem Loeschbereich entfernen.
    1816                 :            :     // Der Cursor steht danach:
    1817                 :            :     //  - es folgt noch eine Zeile, in dieser
    1818                 :            :     //  - vorher steht noch eine Zeile, in dieser
    1819                 :            :     //  - sonst immer dahinter
    1820                 :            :     {
    1821         [ +  - ]:          2 :         SwTableNode* pTblNd = rCursor.GetNode()->FindTableNode();
    1822                 :            : 
    1823 [ +  - ][ +  - ]:          2 :         if( pTblNd->GetTable().ISA( SwDDETable ))
                 [ -  + ]
    1824                 :          0 :             return sal_False;
    1825                 :            : 
    1826                 :            :         // suche alle Boxen / Lines
    1827         [ +  - ]:          2 :         _FndBox aFndBox( 0, 0 );
    1828                 :            :         {
    1829                 :          2 :             _FndPara aPara( aBoxes, &aFndBox );
    1830         [ +  - ]:          2 :             ForEach_FndLineCopyCol( pTblNd->GetTable().GetTabLines(), &aPara );
    1831                 :            :         }
    1832                 :            : 
    1833         [ -  + ]:          2 :         if( !aFndBox.GetLines().size() )
    1834                 :          0 :             return sal_False;
    1835                 :            : 
    1836         [ +  - ]:          2 :         SwEditShell* pESh = GetEditShell();
    1837         [ +  - ]:          2 :         if( pESh )
    1838                 :            :         {
    1839         [ +  - ]:          2 :             pESh->KillPams();
    1840                 :            :             // JP: eigentlich sollte man ueber alle Shells iterieren!!
    1841                 :            :         }
    1842                 :            : 
    1843                 :          2 :         _FndBox* pFndBox = &aFndBox;
    1844   [ +  -  -  + ]:          4 :         while( 1 == pFndBox->GetLines().size() &&
                 [ -  + ]
    1845         [ +  - ]:          2 :                 1 == pFndBox->GetLines().front().GetBoxes().size() )
    1846                 :            :         {
    1847 [ #  # ][ #  # ]:          0 :             _FndBox *const pTmp = & pFndBox->GetLines().front().GetBoxes()[0];
    1848         [ #  # ]:          0 :             if( pTmp->GetBox()->GetSttNd() )
    1849                 :          0 :                 break;      // das ist sonst zu weit
    1850                 :          0 :             pFndBox = pTmp;
    1851                 :            :         }
    1852                 :            : 
    1853         [ +  - ]:          2 :         SwTableLine* pDelLine = pFndBox->GetLines().back().GetLine();
    1854         [ +  - ]:          2 :         SwTableBox* pDelBox = pDelLine->GetTabBoxes().back();
    1855         [ -  + ]:          2 :         while( !pDelBox->GetSttNd() )
    1856                 :            :         {
    1857                 :          0 :             SwTableLine* pLn = pDelBox->GetTabLines()[
    1858                 :          0 :                         pDelBox->GetTabLines().size()-1 ];
    1859         [ #  # ]:          0 :             pDelBox = pLn->GetTabBoxes().back();
    1860                 :            :         }
    1861                 :          2 :         SwTableBox* pNextBox = pDelLine->FindNextBox( pTblNd->GetTable(),
    1862         [ +  - ]:          2 :                                                         pDelBox, sal_True );
    1863   [ +  -  -  + ]:          4 :         while( pNextBox &&
                 [ -  + ]
    1864         [ +  - ]:          2 :                 pNextBox->GetFrmFmt()->GetProtect().IsCntntProtected() )
    1865         [ #  # ]:          0 :             pNextBox = pNextBox->FindNextBox( pTblNd->GetTable(), pNextBox );
    1866                 :            : 
    1867         [ -  + ]:          2 :         if( !pNextBox )         // keine nachfolgende? dann die vorhergehende
    1868                 :            :         {
    1869         [ #  # ]:          0 :             pDelLine = pFndBox->GetLines().front().GetLine();
    1870                 :          0 :             pDelBox = pDelLine->GetTabBoxes()[ 0 ];
    1871         [ #  # ]:          0 :             while( !pDelBox->GetSttNd() )
    1872                 :          0 :                 pDelBox = pDelBox->GetTabLines()[0]->GetTabBoxes()[0];
    1873                 :          0 :             pNextBox = pDelLine->FindPreviousBox( pTblNd->GetTable(),
    1874         [ #  # ]:          0 :                                                         pDelBox, sal_True );
    1875   [ #  #  #  # ]:          0 :             while( pNextBox &&
                 [ #  # ]
    1876         [ #  # ]:          0 :                     pNextBox->GetFrmFmt()->GetProtect().IsCntntProtected() )
    1877         [ #  # ]:          0 :                 pNextBox = pNextBox->FindPreviousBox( pTblNd->GetTable(), pNextBox );
    1878                 :            :         }
    1879                 :            : 
    1880                 :            :         sal_uLong nIdx;
    1881         [ +  - ]:          2 :         if( pNextBox )      // dann den Cursor hier hinein
    1882         [ +  - ]:          2 :             nIdx = pNextBox->GetSttIdx() + 1;
    1883                 :            :         else                // ansonsten hinter die Tabelle
    1884                 :          0 :             nIdx = pTblNd->EndOfSectionIndex() + 1;
    1885                 :            : 
    1886 [ +  - ][ +  - ]:          2 :         SwNodeIndex aIdx( GetNodes(), nIdx );
    1887                 :          2 :         SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
    1888         [ -  + ]:          2 :         if( !pCNd )
    1889 [ #  # ][ #  # ]:          0 :             pCNd = GetNodes().GoNext( &aIdx );
    1890                 :            : 
    1891         [ +  - ]:          2 :         if( pCNd )
    1892                 :            :         {
    1893                 :            :             // die Cursor von der Shell oder den uebergebenen Cursor aendern?
    1894                 :          2 :             SwPaM* pPam = (SwPaM*)&rCursor;
    1895         [ +  - ]:          2 :             pPam->GetPoint()->nNode = aIdx;
    1896 [ +  - ][ +  - ]:          2 :             pPam->GetPoint()->nContent.Assign( pCNd, 0 );
    1897         [ +  - ]:          2 :             pPam->SetMark();            // beide wollen etwas davon haben
    1898         [ +  - ]:          2 :             pPam->DeleteMark();
    1899 [ +  - ][ +  - ]:          2 :         }
                 [ +  - ]
    1900                 :            :     }
    1901                 :            : 
    1902                 :            :     // dann loesche doch die Zeilen
    1903                 :            : 
    1904 [ +  - ][ +  - ]:          2 :     GetIDocumentUndoRedo().StartUndo(UNDO_ROW_DELETE, NULL);
    1905         [ +  - ]:          2 :     sal_Bool bResult = DeleteRowCol( aBoxes );
    1906 [ +  - ][ +  - ]:          2 :     GetIDocumentUndoRedo().EndUndo(UNDO_ROW_DELETE, NULL);
    1907                 :            : 
    1908                 :          2 :     return bResult;
    1909                 :            : }
    1910                 :            : 
    1911                 :          0 : sal_Bool SwDoc::DeleteCol( const SwCursor& rCursor )
    1912                 :            : {
    1913                 :            :     // lasse ueber das Layout die Boxen suchen
    1914         [ #  # ]:          0 :     SwSelBoxes aBoxes;
    1915         [ #  # ]:          0 :     GetTblSel( rCursor, aBoxes, nsSwTblSearchType::TBLSEARCH_COL );
    1916 [ #  # ][ #  # ]:          0 :     if( ::HasProtectedCells( aBoxes ))
    1917                 :          0 :         return sal_False;
    1918                 :            : 
    1919                 :            :     // die Crsr muessen noch aus dem Loesch Bereich entfernt
    1920                 :            :     // werden. Setze sie immer hinter/auf die Tabelle; ueber die
    1921                 :            :     // Dokument-Position werden sie dann immer an die alte Position gesetzt.
    1922         [ #  # ]:          0 :     SwEditShell* pESh = GetEditShell();
    1923         [ #  # ]:          0 :     if( pESh )
    1924                 :            :     {
    1925         [ #  # ]:          0 :         const SwNode* pNd = rCursor.GetNode()->FindTableBoxStartNode();
    1926 [ #  # ][ #  # ]:          0 :         pESh->ParkCrsr( SwNodeIndex( *pNd ) );
                 [ #  # ]
    1927                 :            :     }
    1928                 :            : 
    1929                 :            :     // dann loesche doch die Spalten
    1930 [ #  # ][ #  # ]:          0 :     GetIDocumentUndoRedo().StartUndo(UNDO_COL_DELETE, NULL);
    1931         [ #  # ]:          0 :     sal_Bool bResult = DeleteRowCol( aBoxes, true );
    1932 [ #  # ][ #  # ]:          0 :     GetIDocumentUndoRedo().EndUndo(UNDO_COL_DELETE, NULL);
    1933                 :            : 
    1934                 :          0 :     return bResult;
    1935                 :            : }
    1936                 :            : 
    1937                 :         10 : sal_Bool SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn )
    1938                 :            : {
    1939 [ +  - ][ -  + ]:         10 :     if( ::HasProtectedCells( rBoxes ))
    1940                 :          0 :         return sal_False;
    1941                 :            : 
    1942                 :            :     // uebers SwDoc fuer Undo !!
    1943                 :            :     OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" );
    1944         [ +  - ]:         10 :     SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode();
    1945         [ -  + ]:         10 :     if( !pTblNd )
    1946                 :          0 :         return sal_False;
    1947                 :            : 
    1948 [ +  - ][ +  - ]:         10 :     if( pTblNd->GetTable().ISA( SwDDETable ))
                 [ -  + ]
    1949                 :          0 :         return sal_False;
    1950                 :            : 
    1951         [ +  - ]:         10 :     ::ClearFEShellTabCols();
    1952         [ +  - ]:         10 :     SwSelBoxes aSelBoxes( rBoxes );
    1953                 :         10 :     SwTable &rTable = pTblNd->GetTable();
    1954                 :         10 :     long nMin = 0;
    1955                 :         10 :     long nMax = 0;
    1956         [ +  - ]:         10 :     if( rTable.IsNewModel() )
    1957                 :            :     {
    1958         [ -  + ]:         10 :         if( bColumn )
    1959         [ #  # ]:          0 :             rTable.ExpandColumnSelection( aSelBoxes, nMin, nMax );
    1960                 :            :         else
    1961         [ +  - ]:         10 :             rTable.FindSuperfluousRows( aSelBoxes );
    1962                 :            :     }
    1963                 :            : 
    1964                 :            :     // soll die gesamte Tabelle geloescht werden ??
    1965                 :         10 :     const sal_uLong nTmpIdx1 = pTblNd->GetIndex();
    1966         [ +  - ]:         10 :     const sal_uLong nTmpIdx2 = aSelBoxes.back()->GetSttNd()->EndOfSectionIndex() + 1;
    1967   [ +  -  +  - ]:         26 :     if( pTblNd->GetTable().GetTabSortBoxes().size() == aSelBoxes.size() &&
         [ +  + ][ +  + ]
    1968         [ +  - ]:          8 :         aSelBoxes[0]->GetSttIdx()-1 == nTmpIdx1 &&
    1969                 :          8 :         nTmpIdx2 == pTblNd->EndOfSectionIndex() )
    1970                 :            :     {
    1971                 :          8 :         sal_Bool bNewTxtNd = sal_False;
    1972                 :            :         // steht diese auch noch alleine in einem FlyFrame ?
    1973         [ +  - ]:          8 :         SwNodeIndex aIdx( *pTblNd, -1 );
    1974                 :          8 :         const SwStartNode* pSttNd = aIdx.GetNode().GetStartNode();
    1975         [ +  - ]:          8 :         if( pSttNd )
    1976                 :            :         {
    1977                 :          8 :             const sal_uLong nTblEnd = pTblNd->EndOfSectionIndex() + 1;
    1978                 :          8 :             const sal_uLong nSectEnd = pSttNd->EndOfSectionIndex();
    1979         [ -  + ]:          8 :             if( nTblEnd == nSectEnd )
    1980                 :            :             {
    1981         [ #  # ]:          0 :                 if( SwFlyStartNode == pSttNd->GetStartNodeType() )
    1982                 :            :                 {
    1983         [ #  # ]:          0 :                     SwFrmFmt* pFmt = pSttNd->GetFlyFmt();
    1984         [ #  # ]:          0 :                     if( pFmt )
    1985                 :            :                     {
    1986                 :            :                         // Ok, das ist das gesuchte FlyFormat
    1987         [ #  # ]:          0 :                         DelLayoutFmt( pFmt );
    1988                 :          0 :                         return sal_True;
    1989                 :            :                     }
    1990                 :            :                 }
    1991                 :            :                 // kein Fly ?? also Kopf- oder Fusszeile: dann immer einen
    1992                 :            :                 // TextNode ueberig lassen.
    1993                 :            :                 // Undo koennen wir dann vergessen !!
    1994                 :          0 :                 bNewTxtNd = sal_True;
    1995                 :            :             }
    1996                 :            :         }
    1997                 :            : 
    1998                 :            :         // kein Fly ?? also Kopf- oder Fusszeile: dann immer einen
    1999                 :            :         // TextNode ueberig lassen.
    2000         [ +  - ]:          8 :         aIdx++;
    2001 [ +  - ][ +  - ]:          8 :         if (GetIDocumentUndoRedo().DoesUndo())
                 [ +  - ]
    2002                 :            :         {
    2003 [ +  - ][ +  - ]:          8 :             GetIDocumentUndoRedo().ClearRedo();
    2004         [ +  - ]:          8 :             SwPaM aPaM( *pTblNd->EndOfSectionNode(), aIdx.GetNode() );
    2005                 :            : 
    2006         [ -  + ]:          8 :             if( bNewTxtNd )
    2007                 :            :             {
    2008         [ #  # ]:          0 :                 const SwNodeIndex aTmpIdx( *pTblNd->EndOfSectionNode(), 1 );
    2009         [ #  # ]:          0 :                 GetNodes().MakeTxtNode( aTmpIdx,
    2010 [ #  # ][ #  # ]:          0 :                             GetTxtCollFromPool( RES_POOLCOLL_STANDARD ) );
                 [ #  # ]
    2011                 :            :             }
    2012                 :            : 
    2013                 :            :             // save the cursors (UNO and otherwise)
    2014 [ +  - ][ +  - ]:          8 :             SwPaM aSavePaM( SwNodeIndex( *pTblNd->EndOfSectionNode() ) );
                 [ +  - ]
    2015 [ +  - ][ -  + ]:          8 :             if( ! aSavePaM.Move( fnMoveForward, fnGoNode ) )
    2016                 :            :             {
    2017 [ #  # ][ #  # ]:          0 :                 *aSavePaM.GetMark() = SwPosition( *pTblNd );
                 [ #  # ]
    2018         [ #  # ]:          0 :                 aSavePaM.Move( fnMoveBackward, fnGoNode );
    2019                 :            :             }
    2020                 :            :             {
    2021         [ +  - ]:          8 :                 SwPaM const tmpPaM(*pTblNd, *pTblNd->EndOfSectionNode());
    2022 [ +  - ][ +  - ]:          8 :                 ::PaMCorrAbs(tmpPaM, *aSavePaM.GetMark());
    2023                 :            :             }
    2024                 :            : 
    2025                 :            :             // harte SeitenUmbrueche am nachfolgenden Node verschieben
    2026                 :          8 :             sal_Bool bSavePageBreak = sal_False, bSavePageDesc = sal_False;
    2027                 :          8 :             sal_uLong nNextNd = pTblNd->EndOfSectionIndex()+1;
    2028 [ +  - ][ +  - ]:          8 :             SwCntntNode* pNextNd = GetNodes()[ nNextNd ]->GetCntntNode();
    2029         [ +  - ]:          8 :             if( pNextNd )
    2030                 :            :             {
    2031                 :            :                 {
    2032                 :          8 :                     SwFrmFmt* pTableFmt = pTblNd->GetTable().GetFrmFmt();
    2033                 :            :                     const SfxPoolItem *pItem;
    2034         [ -  + ]:          8 :                     if( SFX_ITEM_SET == pTableFmt->GetItemState( RES_PAGEDESC,
    2035         [ +  - ]:          8 :                         sal_False, &pItem ) )
    2036                 :            :                     {
    2037         [ #  # ]:          0 :                         pNextNd->SetAttr( *pItem );
    2038                 :          0 :                         bSavePageDesc = sal_True;
    2039                 :            :                     }
    2040                 :            : 
    2041         [ -  + ]:          8 :                     if( SFX_ITEM_SET == pTableFmt->GetItemState( RES_BREAK,
    2042         [ +  - ]:          8 :                         sal_False, &pItem ) )
    2043                 :            :                     {
    2044         [ #  # ]:          0 :                         pNextNd->SetAttr( *pItem );
    2045                 :          8 :                         bSavePageBreak = sal_True;
    2046                 :            :                     }
    2047                 :            :                 }
    2048                 :            :             }
    2049 [ +  - ][ +  - ]:          8 :             SwUndoDelete* pUndo = new SwUndoDelete( aPaM );
    2050         [ -  + ]:          8 :             if( bNewTxtNd )
    2051                 :          0 :                 pUndo->SetTblDelLastNd();
    2052                 :          8 :             pUndo->SetPgBrkFlags( bSavePageBreak, bSavePageDesc );
    2053         [ +  - ]:          8 :             pUndo->SetTableName(pTblNd->GetTable().GetFrmFmt()->GetName());
    2054 [ +  - ][ +  - ]:          8 :             GetIDocumentUndoRedo().AppendUndo( pUndo );
         [ +  - ][ +  - ]
    2055                 :            :         }
    2056                 :            :         else
    2057                 :            :         {
    2058         [ #  # ]:          0 :             if( bNewTxtNd )
    2059                 :            :             {
    2060         [ #  # ]:          0 :                 const SwNodeIndex aTmpIdx( *pTblNd->EndOfSectionNode(), 1 );
    2061         [ #  # ]:          0 :                 GetNodes().MakeTxtNode( aTmpIdx,
    2062 [ #  # ][ #  # ]:          0 :                             GetTxtCollFromPool( RES_POOLCOLL_STANDARD ) );
                 [ #  # ]
    2063                 :            :             }
    2064                 :            : 
    2065                 :            :             // save the cursors (UNO and otherwise)
    2066 [ #  # ][ #  # ]:          0 :             SwPaM aSavePaM( SwNodeIndex( *pTblNd->EndOfSectionNode() ) );
                 [ #  # ]
    2067 [ #  # ][ #  # ]:          0 :             if( ! aSavePaM.Move( fnMoveForward, fnGoNode ) )
    2068                 :            :             {
    2069 [ #  # ][ #  # ]:          0 :                 *aSavePaM.GetMark() = SwPosition( *pTblNd );
                 [ #  # ]
    2070         [ #  # ]:          0 :                 aSavePaM.Move( fnMoveBackward, fnGoNode );
    2071                 :            :             }
    2072                 :            :             {
    2073         [ #  # ]:          0 :                 SwPaM const tmpPaM(*pTblNd, *pTblNd->EndOfSectionNode());
    2074 [ #  # ][ #  # ]:          0 :                 ::PaMCorrAbs(tmpPaM, *aSavePaM.GetMark());
    2075                 :            :             }
    2076                 :            : 
    2077                 :            :             // harte SeitenUmbrueche am nachfolgenden Node verschieben
    2078 [ #  # ][ #  # ]:          0 :             SwCntntNode* pNextNd = GetNodes()[ pTblNd->EndOfSectionIndex()+1 ]->GetCntntNode();
    2079         [ #  # ]:          0 :             if( pNextNd )
    2080                 :            :             {
    2081                 :          0 :                 SwFrmFmt* pTableFmt = pTblNd->GetTable().GetFrmFmt();
    2082                 :            :                 const SfxPoolItem *pItem;
    2083         [ #  # ]:          0 :                 if( SFX_ITEM_SET == pTableFmt->GetItemState( RES_PAGEDESC,
    2084         [ #  # ]:          0 :                     sal_False, &pItem ) )
    2085         [ #  # ]:          0 :                     pNextNd->SetAttr( *pItem );
    2086                 :            : 
    2087         [ #  # ]:          0 :                 if( SFX_ITEM_SET == pTableFmt->GetItemState( RES_BREAK,
    2088         [ #  # ]:          0 :                     sal_False, &pItem ) )
    2089         [ #  # ]:          0 :                     pNextNd->SetAttr( *pItem );
    2090                 :            :             }
    2091                 :            : 
    2092         [ #  # ]:          0 :             pTblNd->DelFrms();
    2093 [ #  # ][ #  # ]:          0 :             DeleteSection( pTblNd );
    2094                 :            :         }
    2095         [ +  - ]:          8 :         SetModified();
    2096         [ +  - ]:          8 :         SetFieldsDirty( true, NULL, 0 );
    2097         [ +  - ]:          8 :         return sal_True;
    2098                 :            :     }
    2099                 :            : 
    2100                 :          2 :     SwUndoTblNdsChg* pUndo = 0;
    2101 [ +  - ][ +  - ]:          2 :     if (GetIDocumentUndoRedo().DoesUndo())
                 [ +  - ]
    2102                 :            :     {
    2103                 :            :         pUndo = new SwUndoTblNdsChg( UNDO_TABLE_DELBOX, aSelBoxes, *pTblNd,
    2104 [ +  - ][ +  - ]:          2 :                                      nMin, nMax, 0, sal_False, sal_False );
    2105                 :            :     }
    2106                 :            : 
    2107                 :          2 :     bool bRet(false);
    2108                 :            :     {
    2109 [ +  - ][ +  - ]:          2 :         ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
    2110                 :            : 
    2111         [ +  - ]:          2 :         SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
    2112                 :          2 :         aMsgHnt.eFlags = TBL_BOXPTR;
    2113         [ +  - ]:          2 :         UpdateTblFlds( &aMsgHnt );
    2114                 :            : 
    2115         [ +  - ]:          2 :         if (rTable.IsNewModel())
    2116                 :            :         {
    2117         [ -  + ]:          2 :             if (bColumn)
    2118         [ #  # ]:          0 :                 rTable.PrepareDeleteCol( nMin, nMax );
    2119         [ +  - ]:          2 :             rTable.FindSuperfluousRows( aSelBoxes );
    2120         [ +  - ]:          2 :             if (pUndo)
    2121         [ +  - ]:          2 :                 pUndo->ReNewBoxes( aSelBoxes );
    2122                 :            :         }
    2123         [ +  - ]:          2 :         bRet = rTable.DeleteSel( this, aSelBoxes, 0, pUndo, sal_True, sal_True );
    2124         [ +  - ]:          2 :         if (bRet)
    2125                 :            :         {
    2126         [ +  - ]:          2 :             SetModified();
    2127         [ +  - ]:          2 :             SetFieldsDirty( true, NULL, 0 );
    2128 [ +  - ][ +  - ]:          2 :         }
    2129                 :            :     }
    2130                 :            : 
    2131         [ +  - ]:          2 :     if( pUndo )
    2132                 :            :     {
    2133         [ +  - ]:          2 :         if( bRet )
    2134                 :            :         {
    2135 [ +  - ][ +  - ]:          2 :             GetIDocumentUndoRedo().AppendUndo( pUndo );
    2136                 :            :         }
    2137                 :            :         else
    2138 [ #  # ][ #  # ]:          0 :             delete pUndo;
    2139                 :            :     }
    2140                 :            : 
    2141                 :         10 :     return bRet;
    2142                 :            : }
    2143                 :            : 
    2144                 :            : 
    2145                 :            : // ---------- teilen / zusammenfassen von Boxen in der Tabelle --------
    2146                 :            : 
    2147                 :          4 : sal_Bool SwDoc::SplitTbl( const SwSelBoxes& rBoxes, sal_Bool bVert, sal_uInt16 nCnt,
    2148                 :            :                       sal_Bool bSameHeight )
    2149                 :            : {
    2150                 :            :     // uebers SwDoc fuer Undo !!
    2151                 :            :     OSL_ENSURE( !rBoxes.empty() && nCnt, "keine gueltige Box-Liste" );
    2152         [ +  - ]:          4 :     SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode();
    2153         [ -  + ]:          4 :     if( !pTblNd )
    2154                 :          0 :         return sal_False;
    2155                 :            : 
    2156                 :          4 :     SwTable& rTbl = pTblNd->GetTable();
    2157 [ +  - ][ -  + ]:          4 :     if( rTbl.ISA( SwDDETable ))
                 [ +  - ]
    2158                 :          0 :         return sal_False;
    2159                 :            : 
    2160         [ +  - ]:          4 :     std::vector<sal_uLong> aNdsCnts;
    2161         [ +  - ]:          4 :     SwTableSortBoxes aTmpLst;
    2162                 :          4 :     SwUndoTblNdsChg* pUndo = 0;
    2163 [ +  - ][ +  - ]:          4 :     if (GetIDocumentUndoRedo().DoesUndo())
                 [ +  - ]
    2164                 :            :     {
    2165                 :            :         pUndo = new SwUndoTblNdsChg( UNDO_TABLE_SPLIT, rBoxes, *pTblNd, 0, 0,
    2166 [ +  - ][ +  - ]:          4 :                                      nCnt, bVert, bSameHeight );
    2167                 :            : 
    2168         [ +  - ]:          4 :         aTmpLst.insert( rTbl.GetTabSortBoxes() );
    2169         [ +  + ]:          4 :         if( !bVert )
    2170                 :            :         {
    2171         [ +  + ]:          4 :             for( sal_uInt16 n = 0; n < rBoxes.size(); ++n )
    2172                 :            :             {
    2173                 :          2 :                 const SwStartNode* pSttNd = rBoxes[ n ]->GetSttNd();
    2174                 :          2 :                 aNdsCnts.push_back( pSttNd->EndOfSectionIndex() -
    2175         [ +  - ]:          2 :                                     pSttNd->GetIndex() );
    2176                 :            :             }
    2177                 :            :         }
    2178                 :            :     }
    2179                 :            : 
    2180                 :          4 :     bool bRet(false);
    2181                 :            :     {
    2182 [ +  - ][ +  - ]:          4 :         ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
    2183                 :            : 
    2184         [ +  - ]:          4 :         SwTableFmlUpdate aMsgHnt( &rTbl );
    2185                 :          4 :         aMsgHnt.eFlags = TBL_BOXPTR;
    2186         [ +  - ]:          4 :         UpdateTblFlds( &aMsgHnt );
    2187                 :            : 
    2188         [ +  + ]:          4 :         if (bVert)
    2189         [ +  - ]:          2 :             bRet = rTbl.SplitCol( this, rBoxes, nCnt );
    2190                 :            :         else
    2191         [ +  - ]:          2 :             bRet = rTbl.SplitRow( this, rBoxes, nCnt, bSameHeight );
    2192                 :            : 
    2193         [ +  - ]:          4 :         if (bRet)
    2194                 :            :         {
    2195         [ +  - ]:          4 :             SetModified();
    2196         [ +  - ]:          4 :             SetFieldsDirty( true, NULL, 0 );
    2197 [ +  - ][ +  - ]:          4 :         }
    2198                 :            :     }
    2199                 :            : 
    2200         [ +  - ]:          4 :     if( pUndo )
    2201                 :            :     {
    2202         [ +  - ]:          4 :         if( bRet )
    2203                 :            :         {
    2204         [ +  + ]:          4 :             if( bVert )
    2205         [ +  - ]:          2 :                 pUndo->SaveNewBoxes( *pTblNd, aTmpLst );
    2206                 :            :             else
    2207         [ +  - ]:          2 :                 pUndo->SaveNewBoxes( *pTblNd, aTmpLst, rBoxes, aNdsCnts );
    2208 [ +  - ][ +  - ]:          4 :             GetIDocumentUndoRedo().AppendUndo( pUndo );
    2209                 :            :         }
    2210                 :            :         else
    2211 [ #  # ][ #  # ]:          0 :             delete pUndo;
    2212                 :            :     }
    2213                 :            : 
    2214                 :          4 :     return bRet;
    2215                 :            : }
    2216                 :            : 
    2217                 :            : 
    2218                 :          2 : sal_uInt16 SwDoc::MergeTbl( SwPaM& rPam )
    2219                 :            : {
    2220                 :            :     // pruefe ob vom aktuellen Crsr der SPoint/Mark in einer Tabelle stehen
    2221         [ +  - ]:          2 :     SwTableNode* pTblNd = rPam.GetNode()->FindTableNode();
    2222         [ -  + ]:          2 :     if( !pTblNd )
    2223                 :          0 :         return TBLMERGE_NOSELECTION;
    2224                 :          2 :     SwTable& rTable = pTblNd->GetTable();
    2225 [ +  - ][ -  + ]:          2 :     if( rTable.ISA(SwDDETable) )
                 [ +  - ]
    2226                 :          0 :         return TBLMERGE_NOSELECTION;
    2227                 :          2 :     sal_uInt16 nRet = TBLMERGE_NOSELECTION;
    2228         [ -  + ]:          2 :     if( !rTable.IsNewModel() )
    2229                 :            :     {
    2230         [ #  # ]:          0 :         nRet =::CheckMergeSel( rPam );
    2231         [ #  # ]:          0 :         if( TBLMERGE_OK != nRet )
    2232                 :          0 :             return nRet;
    2233                 :          0 :         nRet = TBLMERGE_NOSELECTION;
    2234                 :            :     }
    2235                 :            : 
    2236                 :            :     // #i33394#
    2237 [ +  - ][ +  - ]:          2 :     GetIDocumentUndoRedo().StartUndo( UNDO_TABLE_MERGE, NULL );
    2238                 :            : 
    2239         [ +  - ]:          2 :     RedlineMode_t eOld = GetRedlineMode();
    2240         [ +  - ]:          2 :     SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
    2241                 :            : 
    2242 [ +  - ][ +  - ]:          2 :     SwUndoTblMerge *const pUndo( (GetIDocumentUndoRedo().DoesUndo())
    2243         [ +  - ]:          2 :         ?   new SwUndoTblMerge( rPam )
    2244 [ +  - ][ +  - ]:          4 :         :   0 );
    2245                 :            : 
    2246                 :            :     // lasse ueber das Layout die Boxen suchen
    2247         [ +  - ]:          2 :     SwSelBoxes aBoxes;
    2248         [ +  - ]:          2 :     SwSelBoxes aMerged;
    2249                 :            :     SwTableBox* pMergeBox;
    2250                 :            : 
    2251 [ +  - ][ -  + ]:          2 :     if( !rTable.PrepareMerge( rPam, aBoxes, aMerged, &pMergeBox, pUndo ) )
    2252                 :            :     {   // no cells found to merge
    2253         [ #  # ]:          0 :         SetRedlineMode_intern( eOld );
    2254         [ #  # ]:          0 :         if( pUndo )
    2255                 :            :         {
    2256 [ #  # ][ #  # ]:          0 :             delete pUndo;
    2257                 :          0 :             SwUndoId nLastUndoId(UNDO_EMPTY);
    2258 [ #  # ][ #  # ]:          0 :             if (GetIDocumentUndoRedo().GetLastUndoInfo(0, & nLastUndoId)
         [ #  # ][ #  # ]
                 [ #  # ]
    2259                 :            :                 && (UNDO_REDLINE == nLastUndoId))
    2260                 :            :             {
    2261                 :            :                 // FIXME: why is this horrible cleanup necessary?
    2262                 :            :                 SwUndoRedline *const pU = dynamic_cast<SwUndoRedline*>(
    2263 [ #  # ][ #  # ]:          0 :                         GetUndoManager().RemoveLastUndo());
                 [ #  # ]
    2264 [ #  # ][ #  # ]:          0 :                 if( pU->GetRedlSaveCount() )
    2265                 :            :                 {
    2266         [ #  # ]:          0 :                     SwEditShell *const pEditShell(GetEditShell(0));
    2267                 :            :                     OSL_ASSERT(pEditShell);
    2268         [ #  # ]:          0 :                     ::sw::UndoRedoContext context(*this, *pEditShell);
    2269 [ #  # ][ #  # ]:          0 :                     static_cast<SfxUndoAction *>(pU)->UndoWithContext(context);
    2270                 :            :                 }
    2271 [ #  # ][ #  # ]:          0 :                 delete pU;
    2272                 :            :             }
    2273                 :            :         }
    2274                 :            :     }
    2275                 :            :     else
    2276                 :            :     {
    2277                 :            :         // die PaMs muessen noch aus dem Loesch Bereich entfernt
    2278                 :            :         // werden. Setze sie immer hinter/auf die Tabelle; ueber die
    2279                 :            :         // Dokument-Position werden sie dann immer an die alte Position gesetzt.
    2280                 :            :         // Erstmal einen Index auf die Parkposition merken, denn nach GetMergeSel
    2281                 :            :         // komme ich nicht mehr dran.
    2282                 :            :         {
    2283         [ +  - ]:          2 :             rPam.DeleteMark();
    2284         [ +  - ]:          2 :             rPam.GetPoint()->nNode = *pMergeBox->GetSttNd();
    2285         [ +  - ]:          2 :             rPam.GetPoint()->nContent.Assign( 0, 0 );
    2286         [ +  - ]:          2 :             rPam.SetMark();
    2287         [ +  - ]:          2 :             rPam.DeleteMark();
    2288                 :            : 
    2289                 :          2 :             SwPaM* pTmp = &rPam;
    2290         [ -  + ]:          2 :             while( &rPam != ( pTmp = (SwPaM*)pTmp->GetNext() ))
    2291         [ #  # ]:          0 :                 for( int i = 0; i < 2; ++i )
    2292         [ #  # ]:          0 :                     pTmp->GetBound( (sal_Bool)i ) = *rPam.GetPoint();
    2293                 :            :         }
    2294                 :            : 
    2295                 :            :         // dann fuege sie zusammen
    2296         [ +  - ]:          2 :         SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
    2297                 :          2 :         aMsgHnt.eFlags = TBL_BOXPTR;
    2298         [ +  - ]:          2 :         UpdateTblFlds( &aMsgHnt );
    2299                 :            : 
    2300 [ +  - ][ +  - ]:          2 :         if( pTblNd->GetTable().Merge( this, aBoxes, aMerged, pMergeBox, pUndo ))
    2301                 :            :         {
    2302                 :          2 :             nRet = TBLMERGE_OK;
    2303         [ +  - ]:          2 :             SetModified();
    2304         [ +  - ]:          2 :             SetFieldsDirty( true, NULL, 0 );
    2305         [ +  - ]:          2 :             if( pUndo )
    2306                 :            :             {
    2307 [ +  - ][ +  - ]:          2 :                 GetIDocumentUndoRedo().AppendUndo( pUndo );
    2308                 :            :             }
    2309                 :            :         }
    2310                 :            :         else
    2311 [ #  # ][ #  # ]:          0 :             delete pUndo;
    2312                 :            : 
    2313         [ +  - ]:          2 :         rPam.GetPoint()->nNode = *pMergeBox->GetSttNd();
    2314         [ +  - ]:          2 :         rPam.Move();
    2315                 :            : 
    2316         [ +  - ]:          2 :         ::ClearFEShellTabCols();
    2317 [ +  - ][ +  - ]:          2 :         SetRedlineMode_intern( eOld );
    2318                 :            :     }
    2319 [ +  - ][ +  - ]:          2 :     GetIDocumentUndoRedo().EndUndo( UNDO_TABLE_MERGE, NULL );
    2320                 :          2 :     return nRet;
    2321                 :            : }
    2322                 :            : 
    2323                 :            : 
    2324                 :            : 
    2325                 :            : // -------------------------------------------------------
    2326                 :            : 
    2327                 :            : //---------
    2328                 :            : // SwTableNode
    2329                 :            : //---------
    2330                 :            : 
    2331                 :        232 : SwTableNode::SwTableNode( const SwNodeIndex& rIdx )
    2332         [ +  - ]:        232 :     : SwStartNode( rIdx, ND_TABLENODE )
    2333                 :            : {
    2334 [ +  - ][ +  - ]:        232 :     pTable = new SwTable( 0 );
    2335                 :        232 : }
    2336                 :            : 
    2337         [ +  - ]:        232 : SwTableNode::~SwTableNode()
    2338                 :            : {
    2339                 :            :     //don't forget to notify uno wrappers
    2340                 :        232 :     SwFrmFmt* pTblFmt = GetTable().GetFrmFmt();
    2341                 :            :     SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT,
    2342         [ +  - ]:        232 :                                 pTblFmt );
    2343         [ +  - ]:        232 :     pTblFmt->ModifyNotification( &aMsgHint, &aMsgHint );
    2344         [ +  - ]:        232 :     DelFrms();
    2345 [ +  - ][ +  - ]:        232 :     delete pTable;
                 [ +  - ]
    2346         [ -  + ]:        464 : }
    2347                 :            : 
    2348                 :        174 : SwTabFrm *SwTableNode::MakeFrm( SwFrm* pSib )
    2349                 :            : {
    2350         [ +  - ]:        174 :     return new SwTabFrm( *pTable, pSib );
    2351                 :            : }
    2352                 :            : 
    2353                 :            : //Methode erzeugt fuer den vorhergehenden Node alle Ansichten vom
    2354                 :            : //Dokument. Die erzeugten Contentframes werden in das entsprechende
    2355                 :            : //Layout gehaengt.
    2356                 :          6 : void SwTableNode::MakeFrms(const SwNodeIndex & rIdx )
    2357                 :            : {
    2358         [ +  - ]:          6 :     if( !GetTable().GetFrmFmt()->GetDepends())//gibt es ueberhaupt Frames ??
    2359                 :          6 :         return;
    2360                 :            : 
    2361                 :            :     SwFrm *pFrm, *pNew;
    2362                 :          6 :     SwCntntNode * pNode = rIdx.GetNode().GetCntntNode();
    2363                 :            : 
    2364                 :            :     OSL_ENSURE( pNode, "Kein Contentnode oder Copy-Node und neuer Node identisch.");
    2365                 :            : 
    2366                 :          6 :     sal_Bool bBefore = rIdx < GetIndex();
    2367                 :            : 
    2368         [ +  - ]:          6 :     SwNode2Layout aNode2Layout( *this, rIdx.GetIndex() );
    2369                 :            : 
    2370 [ +  - ][ +  + ]:         12 :     while( 0 != (pFrm = aNode2Layout.NextFrm()) )
    2371                 :            :     {
    2372         [ +  - ]:          6 :         pNew = pNode->MakeFrm( pFrm );
    2373                 :            :         // wird ein Node vorher oder nachher mit Frames versehen
    2374         [ +  - ]:          6 :         if ( bBefore )
    2375                 :            :             // der neue liegt vor mir
    2376         [ +  - ]:          6 :             pNew->Paste( pFrm->GetUpper(), pFrm );
    2377                 :            :         else
    2378                 :            :             // der neue liegt hinter mir
    2379         [ #  # ]:          0 :             pNew->Paste( pFrm->GetUpper(), pFrm->GetNext() );
    2380         [ +  - ]:          6 :     }
    2381                 :            : }
    2382                 :            : 
    2383                 :            : //Fuer jede Shell einen TblFrm anlegen und vor den entsprechenden
    2384                 :            : //CntntFrm pasten.
    2385                 :            : 
    2386                 :        168 : void SwTableNode::MakeFrms( SwNodeIndex* pIdxBehind )
    2387                 :            : {
    2388                 :            :     OSL_ENSURE( pIdxBehind, "kein Index" );
    2389         [ +  - ]:        168 :     *pIdxBehind = *this;
    2390         [ +  - ]:        168 :     SwNode *pNd = GetNodes().FindPrvNxtFrmNode( *pIdxBehind, EndOfSectionNode() );
    2391         [ +  + ]:        168 :     if( !pNd )
    2392                 :        168 :         return ;
    2393                 :            : 
    2394                 :         72 :     SwFrm *pFrm( 0L );
    2395                 :         72 :     SwLayoutFrm *pUpper( 0L );
    2396         [ +  - ]:         72 :     SwNode2Layout aNode2Layout( *pNd, GetIndex() );
    2397 [ +  - ][ +  + ]:        136 :     while( 0 != (pUpper = aNode2Layout.UpperFrm( pFrm, *this )) )
    2398                 :            :     {
    2399         [ +  - ]:         64 :         SwTabFrm* pNew = MakeFrm( pUpper );
    2400         [ +  - ]:         64 :         pNew->Paste( pUpper, pFrm );
    2401                 :            :         // #i27138#
    2402                 :            :         // notify accessibility paragraphs objects about changed
    2403                 :            :         // CONTENT_FLOWS_FROM/_TO relation.
    2404                 :            :         // Relation CONTENT_FLOWS_FROM for next paragraph will change
    2405                 :            :         // and relation CONTENT_FLOWS_TO for previous paragraph will change.
    2406                 :            :         {
    2407                 :         64 :             ViewShell* pViewShell( pNew->getRootFrm()->GetCurrShell() );
    2408         [ +  - ]:        128 :             if ( pViewShell && pViewShell->GetLayout() &&
           [ +  -  -  + ]
         [ -  + ][ +  - ]
    2409         [ +  - ]:         64 :                  pViewShell->GetLayout()->IsAnyShellAccessible() )
    2410                 :            :             {
    2411                 :            :                 pViewShell->InvalidateAccessibleParaFlowRelation(
    2412         [ #  # ]:          0 :                             dynamic_cast<SwTxtFrm*>(pNew->FindNextCnt( true )),
    2413 [ #  # ][ #  # ]:          0 :                             dynamic_cast<SwTxtFrm*>(pNew->FindPrevCnt( true )) );
         [ #  # ][ #  # ]
    2414                 :            :             }
    2415                 :            :         }
    2416         [ +  - ]:         64 :         ((SwTabFrm*)pNew)->RegistFlys();
    2417         [ +  - ]:        168 :     }
    2418                 :            : }
    2419                 :            : 
    2420                 :        273 : void SwTableNode::DelFrms()
    2421                 :            : {
    2422                 :            :     //Erstmal die TabFrms ausschneiden und deleten, die Columns und Rows
    2423                 :            :     //nehmen sie mit in's Grab.
    2424                 :            :     //Die TabFrms haengen am FrmFmt des SwTable.
    2425                 :            :     //Sie muessen etwas umstaendlich zerstort werden, damit die Master
    2426                 :            :     //die Follows mit in's Grab nehmen.
    2427                 :            : 
    2428         [ +  - ]:        273 :     SwIterator<SwTabFrm,SwFmt> aIter( *(pTable->GetFrmFmt()) );
    2429         [ +  - ]:        273 :     SwTabFrm *pFrm = aIter.First();
    2430         [ +  + ]:        291 :     while ( pFrm )
    2431                 :            :     {
    2432                 :         18 :         sal_Bool bAgain = sal_False;
    2433                 :            :         {
    2434         [ +  - ]:         18 :             if ( !pFrm->IsFollow() )
    2435                 :            :             {
    2436         [ -  + ]:         18 :                 while ( pFrm->HasFollow() )
    2437         [ #  # ]:          0 :                     pFrm->JoinAndDelFollows();
    2438                 :            :                 // #i27138#
    2439                 :            :                 // notify accessibility paragraphs objects about changed
    2440                 :            :                 // CONTENT_FLOWS_FROM/_TO relation.
    2441                 :            :                 // Relation CONTENT_FLOWS_FROM for current next paragraph will change
    2442                 :            :                 // and relation CONTENT_FLOWS_TO for current previous paragraph will change.
    2443                 :            :                 {
    2444                 :         18 :                     ViewShell* pViewShell( pFrm->getRootFrm()->GetCurrShell() );
    2445         [ +  - ]:         36 :                     if ( pViewShell && pViewShell->GetLayout() &&
           [ +  -  -  + ]
         [ -  + ][ +  - ]
    2446         [ +  - ]:         18 :                          pViewShell->GetLayout()->IsAnyShellAccessible() )
    2447                 :            :                     {
    2448                 :            :                         pViewShell->InvalidateAccessibleParaFlowRelation(
    2449         [ #  # ]:          0 :                             dynamic_cast<SwTxtFrm*>(pFrm->FindNextCnt( true )),
    2450 [ #  # ][ #  # ]:          0 :                             dynamic_cast<SwTxtFrm*>(pFrm->FindPrevCnt( true )) );
         [ #  # ][ #  # ]
    2451                 :            :                     }
    2452                 :            :                 }
    2453         [ +  - ]:         18 :                 pFrm->Cut();
    2454 [ +  - ][ +  - ]:         18 :                 delete pFrm;
    2455                 :         18 :                 bAgain = sal_True;
    2456                 :            :             }
    2457                 :            :         }
    2458 [ +  - ][ +  - ]:         18 :         pFrm = bAgain ? aIter.First() : aIter.Next();
                 [ #  # ]
    2459         [ +  - ]:        273 :     }
    2460                 :        273 : }
    2461                 :            : 
    2462                 :            : 
    2463                 :          0 : void SwTableNode::SetNewTable( SwTable* pNewTable, sal_Bool bNewFrames )
    2464                 :            : {
    2465                 :          0 :     DelFrms();
    2466         [ #  # ]:          0 :     delete pTable;
    2467                 :          0 :     pTable = pNewTable;
    2468         [ #  # ]:          0 :     if( bNewFrames )
    2469                 :            :     {
    2470         [ #  # ]:          0 :         SwNodeIndex aIdx( *EndOfSectionNode());
    2471         [ #  # ]:          0 :         GetNodes().GoNext( &aIdx );
    2472 [ #  # ][ #  # ]:          0 :         MakeFrms( &aIdx );
    2473                 :            :     }
    2474                 :          0 : }
    2475                 :            : 
    2476                 :          2 : void SwDoc::GetTabCols( SwTabCols &rFill, const SwCursor* pCrsr,
    2477                 :            :                         const SwCellFrm* pBoxFrm ) const
    2478                 :            : {
    2479                 :          2 :     const SwTableBox* pBox = 0;
    2480                 :          2 :     SwTabFrm *pTab = 0;
    2481                 :            : 
    2482         [ +  - ]:          2 :     if( pBoxFrm )
    2483                 :            :     {
    2484                 :          2 :         pTab = ((SwFrm*)pBoxFrm)->ImplFindTabFrm();
    2485                 :          2 :         pBox = pBoxFrm->GetTabBox();
    2486                 :            :     }
    2487         [ #  # ]:          0 :     else if( pCrsr )
    2488                 :            :     {
    2489                 :          0 :         const SwCntntNode* pCNd = pCrsr->GetCntntNode();
    2490         [ #  # ]:          0 :         if( !pCNd )
    2491                 :            :             return ;
    2492                 :            : 
    2493                 :          0 :         Point aPt;
    2494         [ #  # ]:          0 :         const SwShellCrsr *pShCrsr = dynamic_cast<const SwShellCrsr*>(pCrsr);
    2495         [ #  # ]:          0 :         if( pShCrsr )
    2496                 :          0 :             aPt = pShCrsr->GetPtPos();
    2497                 :            : 
    2498 [ #  # ][ #  # ]:          0 :         const SwFrm* pTmpFrm = pCNd->getLayoutFrm( pCNd->GetDoc()->GetCurrentLayout(), &aPt, 0, sal_False );
    2499         [ #  # ]:          0 :         do {
    2500                 :          0 :             pTmpFrm = pTmpFrm->GetUpper();
    2501                 :          0 :         } while ( !pTmpFrm->IsCellFrm() );
    2502                 :            : 
    2503                 :          0 :         pBoxFrm = (SwCellFrm*)pTmpFrm;
    2504         [ #  # ]:          0 :         pTab = ((SwFrm*)pBoxFrm)->ImplFindTabFrm();
    2505                 :          0 :         pBox = pBoxFrm->GetTabBox();
    2506                 :            :     }
    2507 [ #  # ][ #  # ]:          0 :     else if( !pCrsr && !pBoxFrm )
    2508                 :            :     {
    2509                 :            :         OSL_ENSURE( !this, "einer von beiden muss angegeben werden!" );
    2510                 :          0 :         return ;
    2511                 :            :     }
    2512                 :            : 
    2513                 :            :     //Fix-Punkte setzen, LeftMin in Dokumentkoordinaten die anderen relativ.
    2514 [ -  + ][ #  # ]:          2 :     SWRECTFN( pTab )
         [ #  # ][ -  + ]
    2515                 :          2 :     const SwPageFrm* pPage = pTab->FindPageFrm();
    2516         [ +  - ]:          2 :     const sal_uLong nLeftMin = (pTab->Frm().*fnRect->fnGetLeft)() -
    2517         [ +  - ]:          2 :                            (pPage->Frm().*fnRect->fnGetLeft)();
    2518         [ +  - ]:          2 :     const sal_uLong nRightMax = (pTab->Frm().*fnRect->fnGetRight)() -
    2519         [ +  - ]:          2 :                             (pPage->Frm().*fnRect->fnGetLeft)();
    2520                 :            : 
    2521                 :          2 :     rFill.SetLeftMin ( nLeftMin );
    2522         [ +  - ]:          2 :     rFill.SetLeft    ( (pTab->Prt().*fnRect->fnGetLeft)() );
    2523         [ +  - ]:          2 :     rFill.SetRight   ( (pTab->Prt().*fnRect->fnGetRight)());
    2524                 :          2 :     rFill.SetRightMax( nRightMax - nLeftMin );
    2525                 :            : 
    2526                 :          2 :     pTab->GetTable()->GetTabCols( rFill, pBox );
    2527                 :            : }
    2528                 :            : 
    2529                 :            : //
    2530                 :            : // Here are some little helpers used in SwDoc::GetTabRows
    2531                 :            : //
    2532                 :            : 
    2533                 :            : #define ROWFUZZY 25
    2534                 :            : 
    2535                 :            : struct FuzzyCompare
    2536                 :            : {
    2537                 :            :     bool operator() ( long s1, long s2 ) const;
    2538                 :            : };
    2539                 :            : 
    2540                 :         60 : bool FuzzyCompare::operator() ( long s1, long s2 ) const
    2541                 :            : {
    2542 [ +  + ][ +  - ]:         60 :     return ( s1 < s2 && abs( s1 - s2 ) > ROWFUZZY );
    2543                 :            : }
    2544                 :            : 
    2545                 :          6 : bool lcl_IsFrmInColumn( const SwCellFrm& rFrm, SwSelBoxes& rBoxes )
    2546                 :            : {
    2547         [ +  - ]:          8 :     for( sal_uInt16 i = 0; i < rBoxes.size(); ++i )
    2548                 :            :     {
    2549         [ +  + ]:          8 :         if ( rFrm.GetTabBox() == rBoxes[ i ] )
    2550                 :          6 :             return true;
    2551                 :            :     }
    2552                 :            : 
    2553                 :          6 :     return false;
    2554                 :            : }
    2555                 :            : 
    2556                 :            : //
    2557                 :            : // SwDoc::GetTabRows()
    2558                 :            : //
    2559                 :            : 
    2560                 :          2 : void SwDoc::GetTabRows( SwTabCols &rFill, const SwCursor* ,
    2561                 :            :                         const SwCellFrm* pBoxFrm ) const
    2562                 :            : {
    2563                 :            :     OSL_ENSURE( pBoxFrm, "GetTabRows called without pBoxFrm" );
    2564                 :            : 
    2565                 :            :     // Make code robust:
    2566         [ +  - ]:          2 :     if ( !pBoxFrm )
    2567                 :            :         return;
    2568                 :            : 
    2569                 :            :     // #i39552# Collection of the boxes of the current
    2570                 :            :     // column has to be done at the beginning of this function, because
    2571                 :            :     // the table may be formatted in ::GetTblSel.
    2572                 :          2 :     SwDeletionChecker aDelCheck( pBoxFrm );
    2573                 :            : 
    2574         [ +  - ]:          2 :     SwSelBoxes aBoxes;
    2575         [ +  - ]:          2 :     const SwCntntFrm* pCntnt = ::GetCellCntnt( *pBoxFrm );
    2576 [ +  - ][ +  - ]:          2 :     if ( pCntnt && pCntnt->IsTxtFrm() )
                 [ +  - ]
    2577                 :            :     {
    2578         [ +  - ]:          2 :         const SwPosition aPos( *((SwTxtFrm*)pCntnt)->GetTxtNode() );
    2579         [ +  - ]:          2 :         const SwCursor aTmpCrsr( aPos, 0, false );
    2580 [ +  - ][ +  - ]:          2 :         ::GetTblSel( aTmpCrsr, aBoxes, nsSwTblSearchType::TBLSEARCH_COL );
                 [ +  - ]
    2581                 :            :     }
    2582                 :            : 
    2583                 :            :     // Make code robust:
    2584 [ +  - ][ -  + ]:          2 :     if ( aDelCheck.HasBeenDeleted() )
    2585                 :            :     {
    2586                 :            :         OSL_FAIL( "Current box has been deleted during GetTabRows()" );
    2587                 :            :         return;
    2588                 :            :     }
    2589                 :            : 
    2590                 :            :     // Make code robust:
    2591         [ +  - ]:          2 :     const SwTabFrm* pTab = pBoxFrm->FindTabFrm();
    2592                 :            :     OSL_ENSURE( pTab, "GetTabRows called without a table" );
    2593         [ -  + ]:          2 :     if ( !pTab )
    2594                 :            :         return;
    2595                 :            : 
    2596         [ +  - ]:          2 :     const SwFrm* pFrm = pTab->GetNextLayoutLeaf();
    2597                 :            : 
    2598                 :            :     //Fix-Punkte setzen, LeftMin in Dokumentkoordinaten die anderen relativ.
    2599 [ +  - ][ -  + ]:          2 :     SWRECTFN( pTab )
         [ #  # ][ #  # ]
                 [ -  + ]
    2600         [ +  - ]:          2 :     const SwPageFrm* pPage = pTab->FindPageFrm();
    2601                 :            :     const long nLeftMin  = ( bVert ?
    2602         [ #  # ]:          0 :                              pTab->GetPrtLeft() - pPage->Frm().Left() :
    2603 [ -  + ][ +  - ]:          2 :                              pTab->GetPrtTop() - pPage->Frm().Top() );
    2604         [ -  + ]:          2 :     const long nLeft     = bVert ? LONG_MAX : 0;
    2605 [ +  - ][ +  - ]:          2 :     const long nRight    = (pTab->Prt().*fnRect->fnGetHeight)();
    2606         [ -  + ]:          2 :     const long nRightMax = bVert ? nRight : LONG_MAX;
    2607                 :            : 
    2608                 :          2 :     rFill.SetLeftMin( nLeftMin );
    2609                 :          2 :     rFill.SetLeft( nLeft );
    2610                 :          2 :     rFill.SetRight( nRight );
    2611                 :          2 :     rFill.SetRightMax( nRightMax );
    2612                 :            : 
    2613                 :            :     typedef std::map< long, std::pair< long, long >, FuzzyCompare > BoundaryMap;
    2614         [ +  - ]:          2 :     BoundaryMap aBoundaries;
    2615         [ +  - ]:          2 :     BoundaryMap::iterator aIter;
    2616                 :          2 :     std::pair< long, long > aPair;
    2617                 :            : 
    2618                 :            :     typedef std::map< long, bool > HiddenMap;
    2619         [ +  - ]:          2 :     HiddenMap aHidden;
    2620         [ +  - ]:          2 :     HiddenMap::iterator aHiddenIter;
    2621                 :            : 
    2622 [ +  + ][ +  - ]:         10 :     while ( pFrm && pTab->IsAnLower( pFrm ) )
         [ +  - ][ +  + ]
    2623                 :            :     {
    2624 [ +  - ][ +  - ]:          8 :         if ( pFrm->IsCellFrm() && pFrm->FindTabFrm() == pTab )
         [ +  - ][ +  - ]
    2625                 :            :         {
    2626                 :            :             // upper and lower borders of current cell frame:
    2627 [ +  - ][ +  - ]:          8 :             long nUpperBorder = (pFrm->Frm().*fnRect->fnGetTop)();
    2628 [ +  - ][ +  - ]:          8 :             long nLowerBorder = (pFrm->Frm().*fnRect->fnGetBottom)();
    2629                 :            : 
    2630                 :            :             // get boundaries for nUpperBorder:
    2631         [ +  - ]:          8 :             aIter = aBoundaries.find( nUpperBorder );
    2632 [ +  - ][ +  + ]:          8 :             if ( aIter == aBoundaries.end() )
    2633                 :            :             {
    2634                 :          2 :                 aPair.first = nUpperBorder; aPair.second = LONG_MAX;
    2635 [ +  - ][ +  - ]:          2 :                 aBoundaries[ nUpperBorder ] = aPair;
    2636                 :            :             }
    2637                 :            : 
    2638                 :            :             // get boundaries for nLowerBorder:
    2639         [ +  - ]:          8 :             aIter = aBoundaries.find( nLowerBorder );
    2640 [ +  - ][ +  + ]:          8 :             if ( aIter == aBoundaries.end() )
    2641                 :            :             {
    2642                 :          4 :                 aPair.first = nUpperBorder; aPair.second = LONG_MAX;
    2643                 :            :             }
    2644                 :            :             else
    2645                 :            :             {
    2646         [ +  - ]:          4 :                 nLowerBorder = (*aIter).first;
    2647         [ +  - ]:          4 :                 long nNewLowerBorderUpperBoundary = Max( (*aIter).second.first, nUpperBorder );
    2648                 :          4 :                 aPair.first = nNewLowerBorderUpperBoundary; aPair.second = LONG_MAX;
    2649                 :            :             }
    2650 [ +  - ][ +  - ]:          8 :             aBoundaries[ nLowerBorder ] = aPair;
    2651                 :            : 
    2652                 :            :             // calculate hidden flags for entry nUpperBorder/nLowerBorder:
    2653                 :          8 :             long nTmpVal = nUpperBorder;
    2654         [ +  + ]:         24 :             for ( sal_uInt8 i = 0; i < 2; ++i )
    2655                 :            :             {
    2656         [ +  - ]:         16 :                 aHiddenIter = aHidden.find( nTmpVal );
    2657 [ +  - ][ +  + ]:         16 :                 if ( aHiddenIter == aHidden.end() )
    2658 [ +  - ][ +  - ]:          6 :                     aHidden[ nTmpVal ] = !lcl_IsFrmInColumn( *((SwCellFrm*)pFrm), aBoxes );
    2659                 :            :                 else
    2660                 :            :                 {
    2661 [ +  - ][ -  + ]:         10 :                     if ( aHidden[ nTmpVal ] &&
         [ #  # ][ -  + ]
    2662         [ #  # ]:          0 :                          lcl_IsFrmInColumn( *((SwCellFrm*)pFrm), aBoxes ) )
    2663         [ #  # ]:          0 :                         aHidden[ nTmpVal ] = false;
    2664                 :            :                 }
    2665                 :         16 :                 nTmpVal = nLowerBorder;
    2666                 :            :             }
    2667                 :            :         }
    2668                 :            : 
    2669         [ +  - ]:          8 :         pFrm = pFrm->GetNextLayoutLeaf();
    2670                 :            :     }
    2671                 :            : 
    2672                 :            :     // transfer calculated values from BoundaryMap and HiddenMap into rFill:
    2673                 :          2 :     sal_uInt16 nIdx = 0;
    2674 [ +  - ][ +  - ]:          8 :     for ( aIter = aBoundaries.begin(); aIter != aBoundaries.end(); ++aIter )
                 [ +  + ]
    2675                 :            :     {
    2676 [ +  - ][ +  - ]:          6 :         const long nTabTop = (pTab->*fnRect->fnGetPrtTop)();
    2677 [ +  - ][ +  - ]:          6 :         const long nKey = (*fnRect->fnYDiff)( (*aIter).first, nTabTop );
    2678         [ +  - ]:          6 :         const std::pair< long, long > aTmpPair = (*aIter).second;
    2679         [ +  - ]:          6 :         const long nFirst = (*fnRect->fnYDiff)( aTmpPair.first, nTabTop );
    2680                 :          6 :         const long nSecond = aTmpPair.second;
    2681                 :            : 
    2682 [ +  - ][ +  - ]:          6 :         aHiddenIter = aHidden.find( (*aIter).first );
    2683 [ +  - ][ +  - ]:          6 :         const bool bHidden = aHiddenIter != aHidden.end() && (*aHiddenIter).second;
         [ +  - ][ -  + ]
         [ +  - ][ #  # ]
    2684         [ +  - ]:          6 :         rFill.Insert( nKey, nFirst, nSecond, bHidden, nIdx++ );
    2685                 :            :     }
    2686                 :            : 
    2687                 :            :     // delete first and last entry
    2688                 :            :     OSL_ENSURE( rFill.Count(), "Deleting from empty vector. Fasten your seatbelts!" );
    2689                 :            :     // #i60818# There may be only one entry in rFill. Make
    2690                 :            :     // code robust by checking count of rFill.
    2691 [ +  - ][ +  - ]:          2 :     if ( rFill.Count() ) rFill.Remove( 0, 1 );
                 [ +  - ]
    2692 [ +  - ][ +  - ]:          2 :     if ( rFill.Count() ) rFill.Remove( rFill.Count() - 1 , 1 );
         [ +  - ][ +  - ]
    2693         [ +  - ]:          2 :     rFill.SetLastRowAllowedToChange( !pTab->HasFollowFlowLine() );
    2694                 :            : }
    2695                 :            : 
    2696                 :          0 : void SwDoc::SetTabCols( const SwTabCols &rNew, sal_Bool bCurRowOnly,
    2697                 :            :                         const SwCursor* pCrsr, const SwCellFrm* pBoxFrm )
    2698                 :            : {
    2699                 :          0 :     const SwTableBox* pBox = 0;
    2700                 :          0 :     SwTabFrm *pTab = 0;
    2701                 :            : 
    2702         [ #  # ]:          0 :     if( pBoxFrm )
    2703                 :            :     {
    2704         [ #  # ]:          0 :         pTab = ((SwFrm*)pBoxFrm)->ImplFindTabFrm();
    2705                 :          0 :         pBox = pBoxFrm->GetTabBox();
    2706                 :            :     }
    2707         [ #  # ]:          0 :     else if( pCrsr )
    2708                 :            :     {
    2709                 :          0 :         const SwCntntNode* pCNd = pCrsr->GetCntntNode();
    2710         [ #  # ]:          0 :         if( !pCNd )
    2711                 :            :             return ;
    2712                 :            : 
    2713                 :          0 :         Point aPt;
    2714         [ #  # ]:          0 :         const SwShellCrsr *pShCrsr = dynamic_cast<const SwShellCrsr*>(pCrsr);
    2715         [ #  # ]:          0 :         if( pShCrsr )
    2716                 :          0 :             aPt = pShCrsr->GetPtPos();
    2717                 :            : 
    2718 [ #  # ][ #  # ]:          0 :         const SwFrm* pTmpFrm = pCNd->getLayoutFrm( pCNd->GetDoc()->GetCurrentLayout(), &aPt, 0, sal_False );
    2719         [ #  # ]:          0 :         do {
    2720                 :          0 :             pTmpFrm = pTmpFrm->GetUpper();
    2721                 :          0 :         } while ( !pTmpFrm->IsCellFrm() );
    2722                 :            : 
    2723                 :          0 :         pBoxFrm = (SwCellFrm*)pTmpFrm;
    2724         [ #  # ]:          0 :         pTab = ((SwFrm*)pBoxFrm)->ImplFindTabFrm();
    2725                 :          0 :         pBox = pBoxFrm->GetTabBox();
    2726                 :            :     }
    2727 [ #  # ][ #  # ]:          0 :     else if( !pCrsr && !pBoxFrm )
    2728                 :            :     {
    2729                 :            :         OSL_ENSURE( !this, "einer von beiden muss angegeben werden!" );
    2730                 :            :         return ;
    2731                 :            :     }
    2732                 :            : 
    2733                 :            :     // sollte die Tabelle noch auf relativen Werten (USHRT_MAX) stehen
    2734                 :            :     // dann muss es jetzt auf absolute umgerechnet werden.
    2735                 :          0 :     SwTable& rTab = *pTab->GetTable();
    2736         [ #  # ]:          0 :     const SwFmtFrmSize& rTblFrmSz = rTab.GetFrmFmt()->GetFrmSize();
    2737 [ #  # ][ #  # ]:          0 :     SWRECTFN( pTab )
         [ #  # ][ #  # ]
                 [ #  # ]
    2738                 :            :     // #i17174# - With fix for #i9040# the shadow size is taken
    2739                 :            :     // from the table width. Thus, add its left and right size to current table
    2740                 :            :     // printing area width in order to get the correct table size attribute.
    2741 [ #  # ][ #  # ]:          0 :     SwTwips nPrtWidth = (pTab->Prt().*fnRect->fnGetWidth)();
    2742                 :            :     {
    2743 [ #  # ][ #  # ]:          0 :         SvxShadowItem aShadow( rTab.GetFrmFmt()->GetShadow() );
    2744         [ #  # ]:          0 :         nPrtWidth += aShadow.CalcShadowSpace( SHADOW_LEFT ) +
    2745 [ #  # ][ #  # ]:          0 :                      aShadow.CalcShadowSpace( SHADOW_RIGHT );
    2746                 :            :     }
    2747         [ #  # ]:          0 :     if( nPrtWidth != rTblFrmSz.GetWidth() )
    2748                 :            :     {
    2749         [ #  # ]:          0 :         SwFmtFrmSize aSz( rTblFrmSz );
    2750                 :          0 :         aSz.SetWidth( nPrtWidth );
    2751 [ #  # ][ #  # ]:          0 :         rTab.GetFrmFmt()->SetFmtAttr( aSz );
    2752                 :            :     }
    2753                 :            : 
    2754 [ #  # ][ #  # ]:          0 :     SwTabCols aOld( rNew.Count() );
    2755                 :            : 
    2756         [ #  # ]:          0 :     const SwPageFrm* pPage = pTab->FindPageFrm();
    2757 [ #  # ][ #  # ]:          0 :     const sal_uLong nLeftMin = (pTab->Frm().*fnRect->fnGetLeft)() -
    2758 [ #  # ][ #  # ]:          0 :                            (pPage->Frm().*fnRect->fnGetLeft)();
    2759 [ #  # ][ #  # ]:          0 :     const sal_uLong nRightMax = (pTab->Frm().*fnRect->fnGetRight)() -
    2760 [ #  # ][ #  # ]:          0 :                             (pPage->Frm().*fnRect->fnGetLeft)();
    2761                 :            : 
    2762                 :            :     //Fix-Punkte setzen, LeftMin in Dokumentkoordinaten die anderen relativ.
    2763                 :          0 :     aOld.SetLeftMin ( nLeftMin );
    2764 [ #  # ][ #  # ]:          0 :     aOld.SetLeft    ( (pTab->Prt().*fnRect->fnGetLeft)() );
    2765 [ #  # ][ #  # ]:          0 :     aOld.SetRight   ( (pTab->Prt().*fnRect->fnGetRight)());
    2766                 :          0 :     aOld.SetRightMax( nRightMax - nLeftMin );
    2767                 :            : 
    2768         [ #  # ]:          0 :     rTab.GetTabCols( aOld, pBox );
    2769         [ #  # ]:          0 :     SetTabCols(rTab, rNew, aOld, pBox, bCurRowOnly );
    2770                 :            : }
    2771                 :            : 
    2772                 :          0 : void SwDoc::SetTabRows( const SwTabCols &rNew, sal_Bool bCurColOnly, const SwCursor*,
    2773                 :            :                         const SwCellFrm* pBoxFrm )
    2774                 :            : {
    2775                 :            :     const SwTableBox* pBox;
    2776                 :            :     SwTabFrm *pTab;
    2777                 :            : 
    2778                 :            :     OSL_ENSURE( pBoxFrm, "SetTabRows called without pBoxFrm" );
    2779                 :            : 
    2780         [ #  # ]:          0 :     pTab = ((SwFrm*)pBoxFrm)->ImplFindTabFrm();
    2781                 :          0 :     pBox = pBoxFrm->GetTabBox();
    2782                 :            : 
    2783                 :            :     // sollte die Tabelle noch auf relativen Werten (USHRT_MAX) stehen
    2784                 :            :     // dann muss es jetzt auf absolute umgerechnet werden.
    2785 [ #  # ][ #  # ]:          0 :     SWRECTFN( pTab )
         [ #  # ][ #  # ]
                 [ #  # ]
    2786 [ #  # ][ #  # ]:          0 :     SwTabCols aOld( rNew.Count() );
    2787                 :            : 
    2788                 :            :     //Fix-Punkte setzen, LeftMin in Dokumentkoordinaten die anderen relativ.
    2789         [ #  # ]:          0 :     const SwPageFrm* pPage = pTab->FindPageFrm();
    2790                 :            : 
    2791 [ #  # ][ #  # ]:          0 :     aOld.SetRight( (pTab->Prt().*fnRect->fnGetHeight)() );
    2792                 :            :     long nLeftMin;
    2793         [ #  # ]:          0 :     if ( bVert )
    2794                 :            :     {
    2795         [ #  # ]:          0 :         nLeftMin = pTab->GetPrtLeft() - pPage->Frm().Left();
    2796                 :          0 :         aOld.SetLeft    ( LONG_MAX );
    2797                 :          0 :         aOld.SetRightMax( aOld.GetRight() );
    2798                 :            : 
    2799                 :            :     }
    2800                 :            :     else
    2801                 :            :     {
    2802         [ #  # ]:          0 :         nLeftMin = pTab->GetPrtTop() - pPage->Frm().Top();
    2803                 :          0 :         aOld.SetLeft    ( 0 );
    2804                 :          0 :         aOld.SetRightMax( LONG_MAX );
    2805                 :            :     }
    2806                 :          0 :     aOld.SetLeftMin ( nLeftMin );
    2807                 :            : 
    2808         [ #  # ]:          0 :     GetTabRows( aOld, 0, pBoxFrm );
    2809                 :            : 
    2810 [ #  # ][ #  # ]:          0 :     GetIDocumentUndoRedo().StartUndo( UNDO_TABLE_ATTR, NULL );
    2811                 :            : 
    2812                 :            :     // check for differences between aOld and rNew:
    2813         [ #  # ]:          0 :     const sal_uInt16 nCount = rNew.Count();
    2814                 :          0 :     const SwTable* pTable = pTab->GetTable();
    2815                 :            :     OSL_ENSURE( pTable, "My colleague told me, this couldn't happen" );
    2816                 :            : 
    2817         [ #  # ]:          0 :     for ( sal_uInt16 i = 0; i <= nCount; ++i )
    2818                 :            :     {
    2819         [ #  # ]:          0 :         const sal_uInt16 nIdxStt = bVert ? nCount - i : i - 1;
    2820         [ #  # ]:          0 :         const sal_uInt16 nIdxEnd = bVert ? nCount - i - 1 : i;
    2821                 :            : 
    2822 [ #  # ][ #  # ]:          0 :         const long nOldRowStart = i == 0  ? 0 : aOld[ nIdxStt ];
    2823 [ #  # ][ #  # ]:          0 :         const long nOldRowEnd =   i == nCount ? aOld.GetRight() : aOld[ nIdxEnd ];
    2824                 :          0 :         const long nOldRowHeight = nOldRowEnd - nOldRowStart;
    2825                 :            : 
    2826 [ #  # ][ #  # ]:          0 :         const long nNewRowStart = i == 0  ? 0 : rNew[ nIdxStt ];
    2827 [ #  # ][ #  # ]:          0 :         const long nNewRowEnd =   i == nCount ? rNew.GetRight() : rNew[ nIdxEnd ];
    2828                 :          0 :         const long nNewRowHeight = nNewRowEnd - nNewRowStart;
    2829                 :            : 
    2830                 :          0 :         const long nDiff = nNewRowHeight - nOldRowHeight;
    2831         [ #  # ]:          0 :         if ( abs( nDiff ) >= ROWFUZZY )
    2832                 :            :         {
    2833                 :            :             // For the old table model pTxtFrm and pLine will be set for every box.
    2834                 :            :             // For the new table model pTxtFrm will be set if the box is not covered,
    2835                 :            :             // but the pLine will be set if the box is not an overlapping box
    2836                 :            :             // In the new table model the row height can be adjusted,
    2837                 :            :             // when both variables are set.
    2838                 :          0 :             SwTxtFrm* pTxtFrm = 0;
    2839                 :          0 :             const SwTableLine* pLine = 0;
    2840                 :            : 
    2841                 :            :             // Iterate over all SwCellFrms with Bottom = nOldPos
    2842         [ #  # ]:          0 :             const SwFrm* pFrm = pTab->GetNextLayoutLeaf();
    2843 [ #  # ][ #  # ]:          0 :             while ( pFrm && pTab->IsAnLower( pFrm ) )
         [ #  # ][ #  # ]
    2844                 :            :             {
    2845 [ #  # ][ #  # ]:          0 :                 if ( pFrm->IsCellFrm() && pFrm->FindTabFrm() == pTab )
         [ #  # ][ #  # ]
    2846                 :            :                 {
    2847 [ #  # ][ #  # ]:          0 :                     const long nLowerBorder = (pFrm->Frm().*fnRect->fnGetBottom)();
    2848 [ #  # ][ #  # ]:          0 :                     const sal_uLong nTabTop = (pTab->*fnRect->fnGetPrtTop)();
    2849 [ #  # ][ #  # ]:          0 :                     if ( abs( (*fnRect->fnYInc)( nTabTop, nOldRowEnd ) - nLowerBorder ) <= ROWFUZZY )
    2850                 :            :                     {
    2851 [ #  # ][ #  # ]:          0 :                         if ( !bCurColOnly || pFrm == pBoxFrm )
    2852                 :            :                         {
    2853         [ #  # ]:          0 :                             const SwFrm* pCntnt = ::GetCellCntnt( static_cast<const SwCellFrm&>(*pFrm) );
    2854                 :            : 
    2855 [ #  # ][ #  # ]:          0 :                             if ( pCntnt && pCntnt->IsTxtFrm() )
                 [ #  # ]
    2856                 :            :                             {
    2857                 :          0 :                                 pBox = ((SwCellFrm*)pFrm)->GetTabBox();
    2858         [ #  # ]:          0 :                                 const long nRowSpan = pBox->getRowSpan();
    2859         [ #  # ]:          0 :                                 if( nRowSpan > 0 ) // Not overlapped
    2860                 :          0 :                                     pTxtFrm = (SwTxtFrm*)pCntnt;
    2861         [ #  # ]:          0 :                                 if( nRowSpan < 2 ) // Not overlapping for row height
    2862                 :          0 :                                     pLine = pBox->GetUpper();
    2863 [ #  # ][ #  # ]:          0 :                                 if( pLine && pTxtFrm ) // always for old table model
    2864                 :            :                                 {
    2865                 :            :                                     // The new row height must not to be calculated from a overlapping box
    2866 [ #  # ][ #  # ]:          0 :                                     SwFmtFrmSize aNew( pLine->GetFrmFmt()->GetFrmSize() );
    2867 [ #  # ][ #  # ]:          0 :                                     const long nNewSize = (pFrm->Frm().*fnRect->fnGetHeight)() + nDiff;
    2868         [ #  # ]:          0 :                                     if( nNewSize != aNew.GetHeight() )
    2869                 :            :                                     {
    2870                 :          0 :                                         aNew.SetHeight( nNewSize );
    2871         [ #  # ]:          0 :                                         if ( ATT_VAR_SIZE == aNew.GetHeightSizeType() )
    2872                 :          0 :                                             aNew.SetHeightSizeType( ATT_MIN_SIZE );
    2873                 :            :                                         // This position must not be in an overlapped box
    2874         [ #  # ]:          0 :                                         const SwPosition aPos( *((SwTxtFrm*)pCntnt)->GetTxtNode() );
    2875         [ #  # ]:          0 :                                         const SwCursor aTmpCrsr( aPos, 0, false );
    2876         [ #  # ]:          0 :                                         SetRowHeight( aTmpCrsr, aNew );
    2877                 :            :                                         // For the new table model we're done, for the old one
    2878                 :            :                                         // there might be another (sub)row to adjust...
    2879         [ #  # ]:          0 :                                         if( pTable->IsNewModel() )
    2880 [ #  # ][ #  # ]:          0 :                                             break;
         [ #  # ][ #  # ]
    2881                 :            :                                     }
    2882 [ #  # ][ #  # ]:          0 :                                     pLine = 0;
    2883                 :            :                                 }
    2884                 :            :                             }
    2885                 :            :                         }
    2886                 :            :                     }
    2887                 :            :                 }
    2888         [ #  # ]:          0 :                 pFrm = pFrm->GetNextLayoutLeaf();
    2889                 :            :             }
    2890                 :            :         }
    2891                 :            :     }
    2892                 :            : 
    2893 [ #  # ][ #  # ]:          0 :     GetIDocumentUndoRedo().EndUndo( UNDO_TABLE_ATTR, NULL );
    2894                 :            : 
    2895         [ #  # ]:          0 :     ::ClearFEShellTabCols();
    2896                 :          0 : }
    2897                 :            : 
    2898                 :            : /* --------------------------------------------------
    2899                 :            :  *  Direktzugriff fuer UNO
    2900                 :            :  * --------------------------------------------------*/
    2901                 :         79 : void SwDoc::SetTabCols(SwTable& rTab, const SwTabCols &rNew, const SwTabCols &rOld,
    2902                 :            :                                 const SwTableBox *pStart, sal_Bool bCurRowOnly )
    2903                 :            : {
    2904         [ -  + ]:         79 :     if (GetIDocumentUndoRedo().DoesUndo())
    2905                 :            :     {
    2906                 :          0 :         GetIDocumentUndoRedo().AppendUndo(
    2907         [ #  # ]:          0 :             new SwUndoAttrTbl( *rTab.GetTableNode(), sal_True ));
    2908                 :            :     }
    2909                 :         79 :     rTab.SetTabCols( rNew, rOld, pStart, bCurRowOnly );
    2910                 :         79 :       ::ClearFEShellTabCols();
    2911                 :         79 :     SetModified();
    2912                 :         79 : }
    2913                 :            : 
    2914                 :         74 : void SwDoc::SetRowsToRepeat( SwTable &rTable, sal_uInt16 nSet )
    2915                 :            : {
    2916 [ +  - ][ +  + ]:         74 :     if( nSet == rTable.GetRowsToRepeat() )
    2917                 :         74 :         return;
    2918                 :            : 
    2919 [ +  - ][ +  - ]:         72 :     if (GetIDocumentUndoRedo().DoesUndo())
                 [ +  + ]
    2920                 :            :     {
    2921         [ +  - ]:          2 :         GetIDocumentUndoRedo().AppendUndo(
    2922 [ +  - ][ +  - ]:          2 :             new SwUndoTblHeadline(rTable, rTable.GetRowsToRepeat(), nSet) );
         [ +  - ][ +  - ]
    2923                 :            :     }
    2924                 :            : 
    2925         [ +  - ]:         72 :     SwMsgPoolItem aChg( RES_TBLHEADLINECHG );
    2926                 :         72 :     rTable.SetRowsToRepeat( nSet );
    2927         [ +  - ]:         72 :     rTable.GetFrmFmt()->ModifyNotification( &aChg, &aChg );
    2928 [ +  - ][ +  - ]:         74 :     SetModified();
    2929                 :            : }
    2930                 :            : 
    2931                 :            : 
    2932                 :            : 
    2933                 :            : 
    2934                 :            : // Splittet eine Tabelle in der Grund-Zeile, in der der Index steht.
    2935                 :            : // Alle GrundZeilen dahinter wandern in eine neue Tabelle/-Node.
    2936                 :            : // Ist das Flag bCalcNewSize auf sal_True, wird fuer beide neuen Tabellen
    2937                 :            : // die neue Size aus dem Max der Boxen errechnet; vorrausgesetzt,
    2938                 :            : // die Size ist "absolut" gesetzt (USHRT_MAX)
    2939                 :            : 
    2940                 :          0 : void SwCollectTblLineBoxes::AddToUndoHistory( const SwCntntNode& rNd )
    2941                 :            : {
    2942         [ #  # ]:          0 :     if( pHst )
    2943                 :          0 :         pHst->Add( rNd.GetFmtColl(), rNd.GetIndex(), ND_TEXTNODE );
    2944                 :          0 : }
    2945                 :            : 
    2946                 :          0 : void SwCollectTblLineBoxes::AddBox( const SwTableBox& rBox )
    2947                 :            : {
    2948         [ #  # ]:          0 :     aPosArr.push_back(nWidth);
    2949                 :          0 :     SwTableBox* p = (SwTableBox*)&rBox;
    2950         [ #  # ]:          0 :     m_Boxes.push_back(p);
    2951         [ #  # ]:          0 :     nWidth = nWidth + (sal_uInt16)rBox.GetFrmFmt()->GetFrmSize().GetWidth();
    2952                 :          0 : }
    2953                 :            : 
    2954                 :          0 : const SwTableBox* SwCollectTblLineBoxes::GetBoxOfPos( const SwTableBox& rBox )
    2955                 :            : {
    2956                 :          0 :     const SwTableBox* pRet = 0;
    2957                 :            :     sal_uInt16 n;
    2958                 :            : 
    2959         [ #  # ]:          0 :     if( !aPosArr.empty() )
    2960                 :            :     {
    2961         [ #  # ]:          0 :         for( n = 0; n < aPosArr.size(); ++n )
    2962         [ #  # ]:          0 :             if( aPosArr[ n ] == nWidth )
    2963                 :          0 :                 break;
    2964         [ #  # ]:          0 :             else if( aPosArr[ n ] > nWidth )
    2965                 :            :             {
    2966         [ #  # ]:          0 :                 if( n )
    2967                 :          0 :                     --n;
    2968                 :          0 :                 break;
    2969                 :            :             }
    2970                 :            : 
    2971         [ #  # ]:          0 :         if( n >= aPosArr.size() )
    2972                 :          0 :             --n;
    2973                 :            : 
    2974                 :          0 :         nWidth = nWidth + (sal_uInt16)rBox.GetFrmFmt()->GetFrmSize().GetWidth();
    2975                 :          0 :         pRet = m_Boxes[ n ];
    2976                 :            :     }
    2977                 :          0 :     return pRet;
    2978                 :            : }
    2979                 :            : 
    2980                 :          0 : sal_Bool SwCollectTblLineBoxes::Resize( sal_uInt16 nOffset, sal_uInt16 nOldWidth )
    2981                 :            : {
    2982                 :            :     sal_uInt16 n;
    2983                 :            : 
    2984         [ #  # ]:          0 :     if( !aPosArr.empty() )
    2985                 :            :     {
    2986         [ #  # ]:          0 :         for( n = 0; n < aPosArr.size(); ++n )
    2987                 :            :         {
    2988         [ #  # ]:          0 :             if( aPosArr[ n ] == nOffset )
    2989                 :          0 :                 break;
    2990         [ #  # ]:          0 :             else if( aPosArr[ n ] > nOffset )
    2991                 :            :             {
    2992         [ #  # ]:          0 :                 if( n )
    2993                 :          0 :                     --n;
    2994                 :          0 :                 break;
    2995                 :            :             }
    2996                 :            :         }
    2997                 :            : 
    2998 [ #  # ][ #  # ]:          0 :         aPosArr.erase( aPosArr.begin(), aPosArr.begin() + n );
    2999 [ #  # ][ #  # ]:          0 :         m_Boxes.erase(m_Boxes.begin(), m_Boxes.begin() + n);
    3000                 :            : 
    3001                 :            :         // dann die Positionen der neuen Size anpassen
    3002         [ #  # ]:          0 :         for( n = 0; n < aPosArr.size(); ++n )
    3003                 :            :         {
    3004                 :          0 :             sal_uLong nSize = nWidth;
    3005                 :          0 :             nSize *= ( aPosArr[ n ] - nOffset );
    3006                 :          0 :             nSize /= nOldWidth;
    3007                 :          0 :             aPosArr[ n ] = sal_uInt16( nSize );
    3008                 :            :         }
    3009                 :            :     }
    3010                 :          0 :     return !aPosArr.empty();
    3011                 :            : }
    3012                 :            : 
    3013                 :          0 : sal_Bool lcl_Line_CollectBox( const SwTableLine*& rpLine, void* pPara )
    3014                 :            : {
    3015                 :          0 :     SwCollectTblLineBoxes* pSplPara = (SwCollectTblLineBoxes*)pPara;
    3016         [ #  # ]:          0 :     if( pSplPara->IsGetValues() )
    3017 [ #  # ][ #  # ]:          0 :         for( SwTableBoxes::iterator it = ((SwTableLine*)rpLine)->GetTabBoxes().begin();
    3018                 :          0 :                  it != ((SwTableLine*)rpLine)->GetTabBoxes().end(); ++it)
    3019         [ #  # ]:          0 :             lcl_Box_CollectBox(*it, pSplPara );
    3020                 :            :     else
    3021 [ #  # ][ #  # ]:          0 :         for( SwTableBoxes::iterator it = ((SwTableLine*)rpLine)->GetTabBoxes().begin();
    3022                 :          0 :                  it != ((SwTableLine*)rpLine)->GetTabBoxes().end(); ++it)
    3023         [ #  # ]:          0 :             lcl_BoxSetSplitBoxFmts(*it, pSplPara );
    3024                 :          0 :     return sal_True;
    3025                 :            : }
    3026                 :            : 
    3027                 :          0 : void lcl_Box_CollectBox( const SwTableBox* pBox, SwCollectTblLineBoxes* pSplPara )
    3028                 :            : {
    3029                 :          0 :     sal_uInt16 nLen = pBox->GetTabLines().size();
    3030         [ #  # ]:          0 :     if( nLen )
    3031                 :            :     {
    3032                 :            :         // dann mit der richtigen Line weitermachen
    3033         [ #  # ]:          0 :         if( pSplPara->IsGetFromTop() )
    3034                 :          0 :             nLen = 0;
    3035                 :            :         else
    3036                 :          0 :             --nLen;
    3037                 :            : 
    3038                 :          0 :         const SwTableLine* pLn = pBox->GetTabLines()[ nLen ];
    3039         [ #  # ]:          0 :         lcl_Line_CollectBox( pLn, pSplPara );
    3040                 :            :     }
    3041                 :            :     else
    3042                 :          0 :         pSplPara->AddBox( *pBox );
    3043                 :          0 : }
    3044                 :            : 
    3045                 :          0 : void lcl_BoxSetSplitBoxFmts( SwTableBox* pBox, SwCollectTblLineBoxes* pSplPara )
    3046                 :            : {
    3047                 :          0 :     sal_uInt16 nLen = pBox->GetTabLines().size();
    3048         [ #  # ]:          0 :     if( nLen )
    3049                 :            :     {
    3050                 :            :         // dann mit der richtigen Line weitermachen
    3051         [ #  # ]:          0 :         if( pSplPara->IsGetFromTop() )
    3052                 :          0 :             nLen = 0;
    3053                 :            :         else
    3054                 :          0 :             --nLen;
    3055                 :            : 
    3056                 :          0 :         const SwTableLine* pLn = pBox->GetTabLines()[ nLen ];
    3057         [ #  # ]:          0 :         lcl_Line_CollectBox( pLn, pSplPara );
    3058                 :            :     }
    3059                 :            :     else
    3060                 :            :     {
    3061                 :          0 :         const SwTableBox* pSrcBox = pSplPara->GetBoxOfPos( *pBox );
    3062                 :          0 :         SwFrmFmt* pFmt = pSrcBox->GetFrmFmt();
    3063                 :            : 
    3064         [ #  # ]:          0 :         if( HEADLINE_BORDERCOPY == pSplPara->GetMode() )
    3065                 :            :         {
    3066                 :          0 :             const SvxBoxItem& rBoxItem = pBox->GetFrmFmt()->GetBox();
    3067         [ #  # ]:          0 :             if( !rBoxItem.GetTop() )
    3068                 :            :             {
    3069         [ #  # ]:          0 :                 SvxBoxItem aNew( rBoxItem );
    3070 [ #  # ][ #  # ]:          0 :                 aNew.SetLine( pFmt->GetBox().GetBottom(), BOX_LINE_TOP );
    3071 [ #  # ][ #  # ]:          0 :                 if( aNew != rBoxItem )
    3072 [ #  # ][ #  # ]:          0 :                     pBox->ClaimFrmFmt()->SetFmtAttr( aNew );
                 [ #  # ]
    3073                 :            :             }
    3074                 :            :         }
    3075                 :            :         else
    3076                 :            :         {
    3077                 :            : sal_uInt16 aTableSplitBoxSetRange[] = {
    3078                 :            :     RES_LR_SPACE,       RES_UL_SPACE,
    3079                 :            :     RES_BACKGROUND,     RES_SHADOW,
    3080                 :            :     RES_PROTECT,        RES_PROTECT,
    3081                 :            :     RES_VERT_ORIENT,    RES_VERT_ORIENT,
    3082                 :          0 :     0 };
    3083                 :          0 :             SfxItemSet aTmpSet( pFmt->GetDoc()->GetAttrPool(),
    3084         [ #  # ]:          0 :                                 aTableSplitBoxSetRange );
    3085         [ #  # ]:          0 :             aTmpSet.Put( pFmt->GetAttrSet() );
    3086         [ #  # ]:          0 :             if( aTmpSet.Count() )
    3087 [ #  # ][ #  # ]:          0 :                 pBox->ClaimFrmFmt()->SetFmtAttr( aTmpSet );
    3088                 :            : 
    3089         [ #  # ]:          0 :             if( HEADLINE_BOXATRCOLLCOPY == pSplPara->GetMode() )
    3090                 :            :             {
    3091         [ #  # ]:          0 :                 SwNodeIndex aIdx( *pSrcBox->GetSttNd(), 1 );
    3092                 :          0 :                 SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
    3093         [ #  # ]:          0 :                 if( !pCNd )
    3094         [ #  # ]:          0 :                     pCNd = aIdx.GetNodes().GoNext( &aIdx );
    3095         [ #  # ]:          0 :                 aIdx = *pBox->GetSttNd();
    3096         [ #  # ]:          0 :                 SwCntntNode* pDNd = aIdx.GetNodes().GoNext( &aIdx );
    3097                 :            : 
    3098                 :            :                 // nur wenn der Node alleine in der Section steht
    3099         [ #  # ]:          0 :                 if( 2 == pDNd->EndOfSectionIndex() -
    3100                 :          0 :                         pDNd->StartOfSectionIndex() )
    3101                 :            :                 {
    3102         [ #  # ]:          0 :                     pSplPara->AddToUndoHistory( *pDNd );
    3103         [ #  # ]:          0 :                     pDNd->ChgFmtColl( pCNd->GetFmtColl() );
    3104         [ #  # ]:          0 :                 }
    3105                 :            :             }
    3106                 :            : 
    3107                 :            :             // bedingte Vorlage beachten
    3108 [ #  # ][ #  # ]:          0 :             pBox->GetSttNd()->CheckSectionCondColl();
    3109                 :            :         }
    3110                 :            :     }
    3111                 :          0 : }
    3112                 :            : 
    3113                 :            : 
    3114                 :          0 : sal_Bool SwDoc::SplitTable( const SwPosition& rPos, sal_uInt16 eHdlnMode,
    3115                 :            :                         sal_Bool bCalcNewSize )
    3116                 :            : {
    3117                 :          0 :     SwNode* pNd = &rPos.nNode.GetNode();
    3118         [ #  # ]:          0 :     SwTableNode* pTNd = pNd->FindTableNode();
    3119 [ #  # ][ #  # ]:          0 :     if( !pTNd || pNd->IsTableNode() )
                 [ #  # ]
    3120                 :          0 :         return 0;
    3121                 :            : 
    3122 [ #  # ][ #  # ]:          0 :     if( pTNd->GetTable().ISA( SwDDETable ))
                 [ #  # ]
    3123                 :          0 :         return sal_False;
    3124                 :            : 
    3125                 :          0 :     SwTable& rTbl = pTNd->GetTable();
    3126         [ #  # ]:          0 :     rTbl.SetHTMLTableLayout( 0 );   // MIB 9.7.97: HTML-Layout loeschen
    3127                 :            : 
    3128         [ #  # ]:          0 :     SwTableFmlUpdate aMsgHnt( &rTbl );
    3129                 :            : 
    3130         [ #  # ]:          0 :     SwHistory aHistory;
    3131 [ #  # ][ #  # ]:          0 :     if (GetIDocumentUndoRedo().DoesUndo())
                 [ #  # ]
    3132                 :            :     {
    3133                 :          0 :         aMsgHnt.pHistory = &aHistory;
    3134                 :            :     }
    3135                 :            : 
    3136                 :            :     {
    3137         [ #  # ]:          0 :         sal_uLong nSttIdx = pNd->FindTableBoxStartNode()->GetIndex();
    3138                 :            : 
    3139                 :            :         // Suche die Grund-Line dieser Box:
    3140         [ #  # ]:          0 :         SwTableBox* pBox = rTbl.GetTblBox( nSttIdx );
    3141         [ #  # ]:          0 :         if( pBox )
    3142                 :            :         {
    3143                 :          0 :             SwTableLine* pLine = pBox->GetUpper();
    3144         [ #  # ]:          0 :             while( pLine->GetUpper() )
    3145                 :          0 :                 pLine = pLine->GetUpper()->GetUpper();
    3146                 :            : 
    3147                 :            :             // in pLine steht jetzt die GrundLine.
    3148         [ #  # ]:          0 :             aMsgHnt.nSplitLine = rTbl.GetTabLines().GetPos( pLine );
    3149                 :            :         }
    3150                 :            : 
    3151         [ #  # ]:          0 :         String sNewTblNm( GetUniqueTblName() );
    3152                 :          0 :         aMsgHnt.DATA.pNewTblNm = &sNewTblNm;
    3153                 :          0 :         aMsgHnt.eFlags = TBL_SPLITTBL;
    3154 [ #  # ][ #  # ]:          0 :         UpdateTblFlds( &aMsgHnt );
    3155                 :            :     }
    3156                 :            : 
    3157                 :            :     //Lines fuer das Layout-Update heraussuchen.
    3158         [ #  # ]:          0 :     _FndBox aFndBox( 0, 0 );
    3159         [ #  # ]:          0 :     aFndBox.SetTableLines( rTbl );
    3160         [ #  # ]:          0 :     aFndBox.DelFrms( rTbl );
    3161                 :            : 
    3162 [ #  # ][ #  # ]:          0 :     SwTableNode* pNew = GetNodes().SplitTable( rPos.nNode, sal_False, bCalcNewSize );
    3163                 :            : 
    3164         [ #  # ]:          0 :     if( pNew )
    3165                 :            :     {
    3166         [ #  # ]:          0 :         SwSaveRowSpan* pSaveRowSp = pNew->GetTable().CleanUpTopRowSpan( rTbl.GetTabLines().size() );
    3167                 :          0 :         SwUndoSplitTbl* pUndo = 0;
    3168 [ #  # ][ #  # ]:          0 :         if (GetIDocumentUndoRedo().DoesUndo())
                 [ #  # ]
    3169                 :            :         {
    3170                 :            :             pUndo = new SwUndoSplitTbl(
    3171 [ #  # ][ #  # ]:          0 :                         *pNew, pSaveRowSp, eHdlnMode, bCalcNewSize);
    3172 [ #  # ][ #  # ]:          0 :             GetIDocumentUndoRedo().AppendUndo(pUndo);
    3173         [ #  # ]:          0 :             if( aHistory.Count() )
    3174         [ #  # ]:          0 :                 pUndo->SaveFormula( aHistory );
    3175                 :            :         }
    3176                 :            : 
    3177   [ #  #  #  #  :          0 :         switch( eHdlnMode )
                      # ]
    3178                 :            :         {
    3179                 :            :             // setze die untere Border der vorherige Line,
    3180                 :            :             // an der aktuellen als obere
    3181                 :            :         case HEADLINE_BORDERCOPY:
    3182                 :            :             {
    3183         [ #  # ]:          0 :                 SwCollectTblLineBoxes aPara( sal_False, eHdlnMode );
    3184                 :          0 :                 SwTableLine* pLn = rTbl.GetTabLines()[
    3185                 :          0 :                             rTbl.GetTabLines().size() - 1 ];
    3186 [ #  # ][ #  # ]:          0 :                 for( SwTableBoxes::iterator it = pLn->GetTabBoxes().begin();
    3187                 :          0 :                          it != pLn->GetTabBoxes().end(); ++it)
    3188         [ #  # ]:          0 :                     lcl_Box_CollectBox(*it, &aPara );
    3189                 :            : 
    3190                 :          0 :                 aPara.SetValues( sal_True );
    3191                 :          0 :                 pLn = pNew->GetTable().GetTabLines()[ 0 ];
    3192 [ #  # ][ #  # ]:          0 :                 for( SwTableBoxes::iterator it = pLn->GetTabBoxes().begin();
    3193                 :          0 :                          it != pLn->GetTabBoxes().end(); ++it)
    3194         [ #  # ]:          0 :                     lcl_BoxSetSplitBoxFmts(*it, &aPara );
    3195                 :            : 
    3196                 :            :                 // Kopfzeile wiederholen abschalten
    3197                 :          0 :                 pNew->GetTable().SetRowsToRepeat( 0 );
    3198                 :            :             }
    3199                 :          0 :             break;
    3200                 :            : 
    3201                 :            :             // setze die Attributierung der ersten Line an der neuen ersten
    3202                 :            :         case HEADLINE_BOXATTRCOPY:
    3203                 :            :         case HEADLINE_BOXATRCOLLCOPY:
    3204                 :            :             {
    3205                 :          0 :                 SwHistory* pHst = 0;
    3206 [ #  # ][ #  # ]:          0 :                 if( HEADLINE_BOXATRCOLLCOPY == eHdlnMode && pUndo )
    3207                 :          0 :                     pHst = pUndo->GetHistory();
    3208                 :            : 
    3209         [ #  # ]:          0 :                 SwCollectTblLineBoxes aPara( sal_True, eHdlnMode, pHst );
    3210                 :          0 :                 SwTableLine* pLn = rTbl.GetTabLines()[ 0 ];
    3211 [ #  # ][ #  # ]:          0 :                 for( SwTableBoxes::iterator it = pLn->GetTabBoxes().begin();
    3212                 :          0 :                          it != pLn->GetTabBoxes().end(); ++it)
    3213         [ #  # ]:          0 :                     lcl_Box_CollectBox(*it, &aPara );
    3214                 :            : 
    3215                 :          0 :                 aPara.SetValues( sal_True );
    3216                 :          0 :                 pLn = pNew->GetTable().GetTabLines()[ 0 ];
    3217 [ #  # ][ #  # ]:          0 :                 for( SwTableBoxes::iterator it = pLn->GetTabBoxes().begin();
    3218                 :          0 :                          it != pLn->GetTabBoxes().end(); ++it)
    3219         [ #  # ]:          0 :                     lcl_BoxSetSplitBoxFmts(*it, &aPara );
    3220                 :            :             }
    3221                 :          0 :             break;
    3222                 :            : 
    3223                 :            :         case HEADLINE_CNTNTCOPY:
    3224         [ #  # ]:          0 :             rTbl.CopyHeadlineIntoTable( *pNew );
    3225         [ #  # ]:          0 :             if( pUndo )
    3226                 :          0 :                 pUndo->SetTblNodeOffset( pNew->GetIndex() );
    3227                 :          0 :             break;
    3228                 :            : 
    3229                 :            :         case HEADLINE_NONE:
    3230                 :            :             // Kopfzeile wiederholen abschalten
    3231                 :          0 :             pNew->GetTable().SetRowsToRepeat( 0 );
    3232                 :          0 :             break;
    3233                 :            :         }
    3234                 :            : 
    3235                 :            :         // und Frms einfuegen.
    3236         [ #  # ]:          0 :         SwNodeIndex aNdIdx( *pNew->EndOfSectionNode() );
    3237 [ #  # ][ #  # ]:          0 :         GetNodes().GoNext( &aNdIdx );      // zum naechsten ContentNode
    3238         [ #  # ]:          0 :         pNew->MakeFrms( &aNdIdx );
    3239                 :            : 
    3240                 :            :         //Zwischen die Tabellen wird ein Absatz geschoben
    3241         [ #  # ]:          0 :         GetNodes().MakeTxtNode( SwNodeIndex( *pNew ),
    3242 [ #  # ][ #  # ]:          0 :                                 GetTxtCollFromPool( RES_POOLCOLL_TEXT ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    3243                 :            :     }
    3244                 :            : 
    3245                 :            :     //Layout updaten
    3246         [ #  # ]:          0 :     aFndBox.MakeFrms( rTbl );
    3247                 :            : 
    3248                 :            :     // TL_CHART2: need to inform chart of probably changed cell names
    3249         [ #  # ]:          0 :     UpdateCharts( rTbl.GetFrmFmt()->GetName() );
    3250                 :            : 
    3251         [ #  # ]:          0 :     SetFieldsDirty( true, NULL, 0 );
    3252                 :            : 
    3253 [ #  # ][ #  # ]:          0 :     return 0 != pNew;
                 [ #  # ]
    3254                 :            : }
    3255                 :            : 
    3256                 :          0 : sal_Bool lcl_ChgTblSize( SwTable& rTbl )
    3257                 :            : {
    3258                 :            :     // das Attribut darf nicht ueber das Modify an der
    3259                 :            :     // Tabelle gesetzt werden, denn sonst werden alle
    3260                 :            :     // Boxen wieder auf 0 zurueck gesetzt. Also locke das Format
    3261                 :          0 :     SwFrmFmt* pFmt = rTbl.GetFrmFmt();
    3262 [ #  # ][ #  # ]:          0 :     SwFmtFrmSize aTblMaxSz( pFmt->GetFrmSize() );
    3263                 :            : 
    3264         [ #  # ]:          0 :     if( USHRT_MAX == aTblMaxSz.GetWidth() )
    3265                 :          0 :         return sal_False;
    3266                 :            : 
    3267                 :          0 :     sal_Bool bLocked = pFmt->IsModifyLocked();
    3268                 :          0 :     pFmt->LockModify();
    3269                 :            : 
    3270                 :          0 :     aTblMaxSz.SetWidth( 0 );
    3271                 :            : 
    3272                 :          0 :     SwTableLines& rLns = rTbl.GetTabLines();
    3273         [ #  # ]:          0 :     for( sal_uInt16 nLns = 0; nLns < rLns.size(); ++nLns )
    3274                 :            :     {
    3275                 :          0 :         SwTwips nMaxLnWidth = 0;
    3276                 :          0 :         SwTableBoxes& rBoxes = rLns[ nLns ]->GetTabBoxes();
    3277         [ #  # ]:          0 :         for( sal_uInt16 nBox = 0; nBox < rBoxes.size(); ++nBox )
    3278         [ #  # ]:          0 :             nMaxLnWidth += rBoxes[nBox]->GetFrmFmt()->GetFrmSize().GetWidth();
    3279                 :            : 
    3280         [ #  # ]:          0 :         if( nMaxLnWidth > aTblMaxSz.GetWidth() )
    3281                 :          0 :             aTblMaxSz.SetWidth( nMaxLnWidth );
    3282                 :            :     }
    3283         [ #  # ]:          0 :     pFmt->SetFmtAttr( aTblMaxSz );
    3284         [ #  # ]:          0 :     if( !bLocked )          // und gegebenenfalls Lock wieder freigeben
    3285                 :          0 :         pFmt->UnlockModify();
    3286                 :            : 
    3287         [ #  # ]:          0 :     return sal_True;
    3288                 :            : }
    3289                 :            : 
    3290                 :          0 : class _SplitTable_Para
    3291                 :            : {
    3292                 :            :     std::map<SwFrmFmt*, SwFrmFmt*> aSrcDestMap;
    3293                 :            :     SwTableNode* pNewTblNd;
    3294                 :            :     SwTable& rOldTbl;
    3295                 :            : 
    3296                 :            : public:
    3297                 :          0 :     _SplitTable_Para( SwTableNode* pNew, SwTable& rOld )
    3298                 :          0 :         : aSrcDestMap(), pNewTblNd( pNew ), rOldTbl( rOld )
    3299                 :          0 :     {}
    3300                 :          0 :     SwFrmFmt* GetDestFmt( SwFrmFmt* pSrcFmt ) const
    3301                 :            :     {
    3302         [ #  # ]:          0 :         std::map<SwFrmFmt*, SwFrmFmt*>::const_iterator it = aSrcDestMap.find( pSrcFmt );
    3303 [ #  # ][ #  # ]:          0 :         return it == aSrcDestMap.end() ? NULL : it->second;
                 [ #  # ]
    3304                 :            :     }
    3305                 :            : 
    3306                 :          0 :     void InsertSrcDest( SwFrmFmt* pSrcFmt, SwFrmFmt* pDestFmt )
    3307                 :          0 :             { aSrcDestMap[ pSrcFmt ] = pDestFmt; }
    3308                 :            : 
    3309                 :          0 :     void ChgBox( SwTableBox* pBox )
    3310                 :            :     {
    3311                 :          0 :         rOldTbl.GetTabSortBoxes().erase( pBox );
    3312                 :          0 :         pNewTblNd->GetTable().GetTabSortBoxes().insert( pBox );
    3313                 :          0 :     }
    3314                 :            : };
    3315                 :            : 
    3316                 :            : 
    3317                 :            : static void lcl_SplitTable_CpyBox( SwTableBox* pBox, _SplitTable_Para* pPara );
    3318                 :            : 
    3319                 :          0 : static void lcl_SplitTable_CpyLine( SwTableLine* pLn, _SplitTable_Para* pPara )
    3320                 :            : {
    3321                 :          0 :     SwFrmFmt *pSrcFmt = pLn->GetFrmFmt();
    3322                 :          0 :     SwTableLineFmt* pDestFmt = (SwTableLineFmt*) pPara->GetDestFmt( pSrcFmt );
    3323         [ #  # ]:          0 :     if( pDestFmt == NULL )
    3324                 :            :     {
    3325                 :          0 :         pPara->InsertSrcDest( pSrcFmt, pLn->ClaimFrmFmt() );
    3326                 :            :     }
    3327                 :            :     else
    3328                 :          0 :         pLn->ChgFrmFmt( pDestFmt );
    3329                 :            : 
    3330 [ #  # ][ #  # ]:          0 :     for( SwTableBoxes::iterator it = pLn->GetTabBoxes().begin();
    3331                 :          0 :              it != pLn->GetTabBoxes().end(); ++it)
    3332         [ #  # ]:          0 :         lcl_SplitTable_CpyBox(*it, pPara );
    3333                 :          0 : }
    3334                 :            : 
    3335                 :          0 : static void lcl_SplitTable_CpyBox( SwTableBox* pBox, _SplitTable_Para* pPara )
    3336                 :            : {
    3337                 :          0 :     SwFrmFmt *pSrcFmt = pBox->GetFrmFmt();
    3338                 :          0 :     SwTableBoxFmt* pDestFmt = (SwTableBoxFmt*)pPara->GetDestFmt( pSrcFmt );
    3339         [ #  # ]:          0 :     if( pDestFmt == NULL )
    3340                 :            :     {
    3341                 :          0 :         pPara->InsertSrcDest( pSrcFmt, pBox->ClaimFrmFmt() );
    3342                 :            :     }
    3343                 :            :     else
    3344                 :          0 :         pBox->ChgFrmFmt( pDestFmt );
    3345                 :            : 
    3346         [ #  # ]:          0 :     if( pBox->GetSttNd() )
    3347                 :          0 :         pPara->ChgBox( pBox );
    3348                 :            :     else
    3349 [ #  # ][ #  # ]:          0 :         BOOST_FOREACH( SwTableLine* pLine, pBox->GetTabLines() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3350         [ #  # ]:          0 :             lcl_SplitTable_CpyLine( pLine, pPara );
    3351                 :          0 : }
    3352                 :            : 
    3353                 :          0 : SwTableNode* SwNodes::SplitTable( const SwNodeIndex& rPos, sal_Bool bAfter,
    3354                 :            :                                     sal_Bool bCalcNewSize )
    3355                 :            : {
    3356                 :          0 :     SwNode* pNd = &rPos.GetNode();
    3357                 :          0 :     SwTableNode* pTNd = pNd->FindTableNode();
    3358 [ #  # ][ #  # ]:          0 :     if( !pTNd || pNd->IsTableNode() )
                 [ #  # ]
    3359                 :          0 :         return 0;
    3360                 :            : 
    3361                 :          0 :     sal_uLong nSttIdx = pNd->FindTableBoxStartNode()->GetIndex();
    3362                 :            : 
    3363                 :            :     // Suche die Grund-Line dieser Box:
    3364                 :          0 :     SwTable& rTbl = pTNd->GetTable();
    3365                 :          0 :     SwTableBox* pBox = rTbl.GetTblBox( nSttIdx );
    3366         [ #  # ]:          0 :     if( !pBox )
    3367                 :          0 :         return 0;
    3368                 :            : 
    3369                 :          0 :     SwTableLine* pLine = pBox->GetUpper();
    3370         [ #  # ]:          0 :     while( pLine->GetUpper() )
    3371                 :          0 :         pLine = pLine->GetUpper()->GetUpper();
    3372                 :            : 
    3373                 :            :     // in pLine steht jetzt die GrundLine.
    3374                 :          0 :     sal_uInt16 nLinePos = rTbl.GetTabLines().GetPos( pLine );
    3375   [ #  #  #  # ]:          0 :     if( USHRT_MAX == nLinePos ||
         [ #  # ][ #  # ]
                 [ #  # ]
    3376                 :          0 :         ( bAfter ? ++nLinePos >= rTbl.GetTabLines().size() : !nLinePos ))
    3377                 :          0 :         return 0;       // nicht gefunden oder letze Line !!
    3378                 :            : 
    3379                 :            :     // Suche jetzt die 1. Box der nachfolgenden Line
    3380                 :          0 :     SwTableLine* pNextLine = rTbl.GetTabLines()[ nLinePos ];
    3381                 :          0 :     pBox = pNextLine->GetTabBoxes()[0];
    3382         [ #  # ]:          0 :     while( !pBox->GetSttNd() )
    3383                 :          0 :         pBox = pBox->GetTabLines()[0]->GetTabBoxes()[0];
    3384                 :            : 
    3385                 :            :     // dann fuege mal einen End- und TabelleNode ins Nodes-Array ein.
    3386                 :            :     SwTableNode * pNewTblNd;
    3387                 :            :     {
    3388                 :          0 :         SwEndNode* pOldTblEndNd = (SwEndNode*)pTNd->EndOfSectionNode()->GetEndNode();
    3389                 :            :         OSL_ENSURE( pOldTblEndNd, "wo ist der EndNode?" );
    3390                 :            : 
    3391         [ #  # ]:          0 :         SwNodeIndex aIdx( *pBox->GetSttNd() );
    3392 [ #  # ][ #  # ]:          0 :         new SwEndNode( aIdx, *pTNd );
    3393 [ #  # ][ #  # ]:          0 :         pNewTblNd = new SwTableNode( aIdx );
    3394                 :          0 :         pNewTblNd->GetTable().SetTableModel( rTbl.IsNewModel() );
    3395                 :            : 
    3396                 :          0 :         pOldTblEndNd->pStartOfSection = pNewTblNd;
    3397                 :          0 :         pNewTblNd->pEndOfSection = pOldTblEndNd;
    3398                 :            : 
    3399                 :          0 :         SwNode* pBoxNd = aIdx.GetNode().GetStartNode();
    3400         [ #  # ]:          0 :         do {
    3401                 :            :             OSL_ENSURE( pBoxNd->IsStartNode(), "das muss ein StartNode sein!" );
    3402                 :          0 :             pBoxNd->pStartOfSection = pNewTblNd;
    3403         [ #  # ]:          0 :             pBoxNd = (*this)[ pBoxNd->EndOfSectionIndex() + 1 ];
    3404         [ #  # ]:          0 :         } while( pBoxNd != pOldTblEndNd );
    3405                 :            :     }
    3406                 :            : 
    3407                 :            :     {
    3408                 :            :         // die Lines ruebermoven...
    3409                 :          0 :         SwTable& rNewTbl = pNewTblNd->GetTable();
    3410                 :          0 :         rNewTbl.GetTabLines().insert( rNewTbl.GetTabLines().begin(),
    3411   [ #  #  #  # ]:          0 :                       rTbl.GetTabLines().begin() + nLinePos, rTbl.GetTabLines().end() );
    3412                 :            :         //
    3413                 :            :         // von hinten (unten-rechts) nach vorn (oben-links) alle Boxen
    3414                 :            :         // beim chart data provider austragen (das modified event wird dann
    3415                 :            :         // in der aufrufenden Funktion getriggert.
    3416                 :            :         // TL_CHART2:
    3417 [ #  # ][ #  # ]:          0 :         SwChartDataProvider *pPCD = rTbl.GetFrmFmt()->getIDocumentChartDataProviderAccess()->GetChartDataProvider();
    3418         [ #  # ]:          0 :         if( pPCD )
    3419                 :            :         {
    3420         [ #  # ]:          0 :             for (sal_uInt16 k = nLinePos;  k < rTbl.GetTabLines().size();  ++k)
    3421                 :            :             {
    3422                 :          0 :                 sal_uInt16 nLineIdx = (rTbl.GetTabLines().size() - 1) - k + nLinePos;
    3423                 :          0 :                 sal_uInt16 nBoxCnt = rTbl.GetTabLines()[ nLineIdx ]->GetTabBoxes().size();
    3424         [ #  # ]:          0 :                 for (sal_uInt16 j = 0;  j < nBoxCnt;  ++j)
    3425                 :            :                 {
    3426                 :          0 :                     sal_uInt16 nIdx = nBoxCnt - 1 - j;
    3427         [ #  # ]:          0 :                     pPCD->DeleteBox( &rTbl, *rTbl.GetTabLines()[ nLineIdx ]->GetTabBoxes()[nIdx] );
    3428                 :            :                 }
    3429                 :            :             }
    3430                 :            :         }
    3431                 :            :         //
    3432                 :            :         // ...und loeschen
    3433                 :          0 :         sal_uInt16 nDeleted = rTbl.GetTabLines().size() - nLinePos;
    3434 [ #  # ][ #  # ]:          0 :         rTbl.GetTabLines().erase( rTbl.GetTabLines().begin() + nLinePos, rTbl.GetTabLines().end() );
    3435                 :            : 
    3436                 :            :         // und die betr. Boxen verschieben. Dabei die Formate eindeutig
    3437                 :            :         // machen und die StartNodes korrigieren
    3438         [ #  # ]:          0 :         _SplitTable_Para aPara( pNewTblNd, rTbl );
    3439 [ #  # ][ #  # ]:          0 :         BOOST_FOREACH( SwTableLine* pNewLine, rNewTbl.GetTabLines() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    3440         [ #  # ]:          0 :             lcl_SplitTable_CpyLine( pNewLine, &aPara );
    3441         [ #  # ]:          0 :         rTbl.CleanUpBottomRowSpan( nDeleted );
    3442                 :            :     }
    3443                 :            : 
    3444                 :            :     {
    3445                 :            :         // Das Tabellen-FrmFormat kopieren
    3446                 :          0 :         SwFrmFmt* pOldTblFmt = rTbl.GetFrmFmt();
    3447                 :            :         SwFrmFmt* pNewTblFmt = pOldTblFmt->GetDoc()->MakeTblFrmFmt(
    3448                 :            :                                 pOldTblFmt->GetDoc()->GetUniqueTblName(),
    3449         [ #  # ]:          0 :                                 pOldTblFmt->GetDoc()->GetDfltFrmFmt() );
    3450                 :            : 
    3451                 :          0 :         *pNewTblFmt = *pOldTblFmt;
    3452                 :          0 :         pNewTblNd->GetTable().RegisterToFormat( *pNewTblFmt );
    3453                 :            : 
    3454                 :            :         // neue Size errechnen ? (lcl_ChgTblSize nur das 2. aufrufen, wenn es
    3455                 :            :         // beim 1. schon geklappt hat; also absolute Groesse hat)
    3456 [ #  # ][ #  # ]:          0 :         if( bCalcNewSize && lcl_ChgTblSize( rTbl ) )
                 [ #  # ]
    3457                 :          0 :             lcl_ChgTblSize( pNewTblNd->GetTable() );
    3458                 :            :     }
    3459                 :            : 
    3460                 :            :     // TL_CHART2: need to inform chart of probably changed cell names
    3461                 :          0 :     rTbl.UpdateCharts();
    3462                 :            : 
    3463                 :          0 :     return pNewTblNd;       // das wars
    3464                 :            : }
    3465                 :            : 
    3466                 :            : // und die Umkehrung davon. rPos muss in der Tabelle stehen, die bestehen
    3467                 :            : // bleibt. Das Flag besagt ob die aktuelle mit der davor oder dahinter
    3468                 :            : // stehenden vereint wird.
    3469                 :          0 : sal_Bool SwDoc::MergeTable( const SwPosition& rPos, sal_Bool bWithPrev, sal_uInt16 nMode )
    3470                 :            : {
    3471         [ #  # ]:          0 :     SwTableNode* pTblNd = rPos.nNode.GetNode().FindTableNode(), *pDelTblNd;
    3472         [ #  # ]:          0 :     if( !pTblNd )
    3473                 :          0 :         return sal_False;
    3474                 :            : 
    3475         [ #  # ]:          0 :     SwNodes& rNds = GetNodes();
    3476         [ #  # ]:          0 :     if( bWithPrev )
    3477 [ #  # ][ #  # ]:          0 :         pDelTblNd = rNds[ pTblNd->GetIndex() - 1 ]->FindTableNode();
    3478                 :            :     else
    3479         [ #  # ]:          0 :         pDelTblNd = rNds[ pTblNd->EndOfSectionIndex() + 1 ]->GetTableNode();
    3480         [ #  # ]:          0 :     if( !pDelTblNd )
    3481                 :          0 :         return sal_False;
    3482                 :            : 
    3483 [ #  # ][ #  # ]:          0 :     if( pTblNd->GetTable().ISA( SwDDETable ) ||
         [ #  # ][ #  # ]
                 [ #  # ]
    3484 [ #  # ][ #  # ]:          0 :         pDelTblNd->GetTable().ISA( SwDDETable ))
    3485                 :          0 :         return sal_False;
    3486                 :            : 
    3487                 :            :     // MIB 9.7.97: HTML-Layout loeschen
    3488         [ #  # ]:          0 :     pTblNd->GetTable().SetHTMLTableLayout( 0 );
    3489         [ #  # ]:          0 :     pDelTblNd->GetTable().SetHTMLTableLayout( 0 );
    3490                 :            : 
    3491                 :            :     // beide Tabellen vorhanden, also kanns losgehen
    3492                 :          0 :     SwUndoMergeTbl* pUndo = 0;
    3493                 :          0 :     SwHistory* pHistory = 0;
    3494 [ #  # ][ #  # ]:          0 :     if (GetIDocumentUndoRedo().DoesUndo())
                 [ #  # ]
    3495                 :            :     {
    3496 [ #  # ][ #  # ]:          0 :         pUndo = new SwUndoMergeTbl( *pTblNd, *pDelTblNd, bWithPrev, nMode );
    3497 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().AppendUndo(pUndo);
    3498 [ #  # ][ #  # ]:          0 :         pHistory = new SwHistory;
    3499                 :            :     }
    3500                 :            : 
    3501                 :            :     // alle "Tabellenformeln" anpassen
    3502         [ #  # ]:          0 :     SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
    3503                 :          0 :     aMsgHnt.DATA.pDelTbl = &pDelTblNd->GetTable();
    3504                 :          0 :     aMsgHnt.eFlags = TBL_MERGETBL;
    3505                 :          0 :     aMsgHnt.pHistory = pHistory;
    3506         [ #  # ]:          0 :     UpdateTblFlds( &aMsgHnt );
    3507                 :            : 
    3508                 :            :     // das eigentliche Mergen
    3509 [ #  # ][ #  # ]:          0 :     SwNodeIndex aIdx( bWithPrev ? *pTblNd : *pDelTblNd );
    3510         [ #  # ]:          0 :     sal_Bool bRet = rNds.MergeTable( aIdx, !bWithPrev, nMode, pHistory );
    3511                 :            : 
    3512         [ #  # ]:          0 :     if( pHistory )
    3513                 :            :     {
    3514         [ #  # ]:          0 :         if( pHistory->Count() )
    3515         [ #  # ]:          0 :             pUndo->SaveFormula( *pHistory );
    3516 [ #  # ][ #  # ]:          0 :         delete pHistory;
    3517                 :            :     }
    3518         [ #  # ]:          0 :     if( bRet )
    3519                 :            :     {
    3520         [ #  # ]:          0 :         SetModified();
    3521         [ #  # ]:          0 :         SetFieldsDirty( true, NULL, 0 );
    3522                 :            :     }
    3523 [ #  # ][ #  # ]:          0 :     return bRet;
    3524                 :            : }
    3525                 :            : 
    3526                 :          0 : sal_Bool SwNodes::MergeTable( const SwNodeIndex& rPos, sal_Bool bWithPrev,
    3527                 :            :                             sal_uInt16 nMode, SwHistory* )
    3528                 :            : {
    3529                 :          0 :     SwTableNode* pDelTblNd = rPos.GetNode().GetTableNode();
    3530                 :            :     OSL_ENSURE( pDelTblNd, "wo ist der TableNode geblieben?" );
    3531                 :            : 
    3532 [ #  # ][ #  # ]:          0 :     SwTableNode* pTblNd = (*this)[ rPos.GetIndex() - 1]->FindTableNode();
    3533                 :            :     OSL_ENSURE( pTblNd, "wo ist der TableNode geblieben?" );
    3534                 :            : 
    3535 [ #  # ][ #  # ]:          0 :     if( !pDelTblNd || !pTblNd )
    3536                 :          0 :         return sal_False;
    3537                 :            : 
    3538         [ #  # ]:          0 :     pDelTblNd->DelFrms();
    3539                 :            : 
    3540                 :          0 :     SwTable& rDelTbl = pDelTblNd->GetTable();
    3541                 :          0 :     SwTable& rTbl = pTblNd->GetTable();
    3542                 :            : 
    3543                 :            :     //Lines fuer das Layout-Update herausuchen.
    3544         [ #  # ]:          0 :     _FndBox aFndBox( 0, 0 );
    3545         [ #  # ]:          0 :     aFndBox.SetTableLines( rTbl );
    3546         [ #  # ]:          0 :     aFndBox.DelFrms( rTbl );
    3547                 :            : 
    3548                 :            :     // TL_CHART2: since chart currently does not want to get informed about
    3549                 :            :     // additional rows/cols there is no need for a modified event in the
    3550                 :            :     // remaining first table. Also, if it is required it  should be done
    3551                 :            :     // after the merging and not here...
    3552                 :            :     // pDoc->UpdateCharts( rTbl.GetFrmFmt()->GetName() );
    3553                 :            : 
    3554                 :            : 
    3555                 :            :     // TL_CHART2:
    3556                 :            :     // tell the charts about the table to be deleted and have them use their own data
    3557         [ #  # ]:          0 :     GetDoc()->CreateChartInternalDataProviders( &rDelTbl );
    3558                 :            : 
    3559                 :            :     // die Breite der TabellenFormate abgleichen:
    3560                 :            :     {
    3561         [ #  # ]:          0 :         const SwFmtFrmSize& rTblSz = rTbl.GetFrmFmt()->GetFrmSize();
    3562         [ #  # ]:          0 :         const SwFmtFrmSize& rDelTblSz = rDelTbl.GetFrmFmt()->GetFrmSize();
    3563 [ #  # ][ #  # ]:          0 :         if( rTblSz != rDelTblSz )
    3564                 :            :         {
    3565                 :            :             // dann sollten die mal schleunigst korrigiert werden
    3566         [ #  # ]:          0 :             if( bWithPrev )
    3567         [ #  # ]:          0 :                 rDelTbl.GetFrmFmt()->SetFmtAttr( rTblSz );
    3568                 :            :             else
    3569         [ #  # ]:          0 :                 rTbl.GetFrmFmt()->SetFmtAttr( rDelTblSz );
    3570                 :            :         }
    3571                 :            :     }
    3572                 :            : 
    3573         [ #  # ]:          0 :     if( !bWithPrev )
    3574                 :            :     {
    3575                 :            :         // dann mussen alle Attruibute der hinteren Tabelle auf die
    3576                 :            :         // vordere uebertragen werden, weil die hintere ueber das loeschen
    3577                 :            :         // des Node geloescht wird.
    3578         [ #  # ]:          0 :         rTbl.SetRowsToRepeat( rDelTbl.GetRowsToRepeat() );
    3579                 :          0 :         rTbl.SetTblChgMode( rDelTbl.GetTblChgMode() );
    3580                 :            : 
    3581                 :          0 :         rTbl.GetFrmFmt()->LockModify();
    3582         [ #  # ]:          0 :         *rTbl.GetFrmFmt() = *rDelTbl.GetFrmFmt();
    3583                 :            :         // auch den Namen umsetzen!
    3584         [ #  # ]:          0 :         rTbl.GetFrmFmt()->SetName( rDelTbl.GetFrmFmt()->GetName() );
    3585                 :          0 :         rTbl.GetFrmFmt()->UnlockModify();
    3586                 :            :     }
    3587                 :            : 
    3588                 :            :     // die Lines und Boxen ruebermoven
    3589                 :          0 :     sal_uInt16 nOldSize = rTbl.GetTabLines().size();
    3590                 :          0 :     rTbl.GetTabLines().insert( rTbl.GetTabLines().begin() + nOldSize,
    3591   [ #  #  #  # ]:          0 :                                rDelTbl.GetTabLines().begin(), rDelTbl.GetTabLines().end() );
    3592                 :          0 :     rDelTbl.GetTabLines().clear();
    3593                 :            : 
    3594         [ #  # ]:          0 :     rTbl.GetTabSortBoxes().insert( rDelTbl.GetTabSortBoxes() );
    3595                 :          0 :     rDelTbl.GetTabSortBoxes().clear();
    3596                 :            : 
    3597                 :            :     // die vordere Tabelle bleibt immer stehen, die hintere wird geloescht
    3598                 :          0 :     SwEndNode* pTblEndNd = pDelTblNd->EndOfSectionNode();
    3599                 :          0 :     pTblNd->pEndOfSection = pTblEndNd;
    3600                 :            : 
    3601         [ #  # ]:          0 :     SwNodeIndex aIdx( *pDelTblNd, 1 );
    3602                 :            : 
    3603                 :          0 :     SwNode* pBoxNd = aIdx.GetNode().GetStartNode();
    3604         [ #  # ]:          0 :     do {
    3605                 :            :         OSL_ENSURE( pBoxNd->IsStartNode(), "das muss ein StartNode sein!" );
    3606                 :          0 :         pBoxNd->pStartOfSection = pTblNd;
    3607         [ #  # ]:          0 :         pBoxNd = (*this)[ pBoxNd->EndOfSectionIndex() + 1 ];
    3608                 :            :     } while( pBoxNd != pTblEndNd );
    3609                 :          0 :     pBoxNd->pStartOfSection = pTblNd;
    3610                 :            : 
    3611         [ #  # ]:          0 :     aIdx -= 2;
    3612         [ #  # ]:          0 :     DelNodes( aIdx, 2 );
    3613                 :            : 
    3614                 :            :     // jetzt an der 1. eingefuegten Line die bedingten Vorlagen umschubsen
    3615                 :          0 :     const SwTableLine* pFirstLn = rTbl.GetTabLines()[ nOldSize ];
    3616                 :            :     if( 1 == nMode )        //
    3617                 :            :     {
    3618                 :            :         // Header-Vorlagen in der Zeile setzen
    3619                 :            :         // und ggfs. in der History speichern fuers Undo!!!
    3620                 :            :     }
    3621         [ #  # ]:          0 :     lcl_LineSetHeadCondColl( pFirstLn );
    3622                 :            : 
    3623                 :            :     // und die Borders "aufrauemen"
    3624         [ #  # ]:          0 :     if( nOldSize )
    3625                 :            :     {
    3626                 :          0 :         _SwGCLineBorder aPara( rTbl );
    3627                 :          0 :         aPara.nLinePos = --nOldSize;
    3628                 :          0 :         pFirstLn = rTbl.GetTabLines()[ nOldSize ];
    3629         [ #  # ]:          0 :         lcl_GC_Line_Border( pFirstLn, &aPara );
    3630                 :            :     }
    3631                 :            : 
    3632                 :            :     //Layout updaten
    3633         [ #  # ]:          0 :     aFndBox.MakeFrms( rTbl );
    3634                 :            : 
    3635 [ #  # ][ #  # ]:          0 :     return sal_True;
    3636                 :            : }
    3637                 :            : 
    3638                 :            : // -------------------------------------------------------------------
    3639                 :            : 
    3640                 :            : 
    3641                 :            : // -- benutze die ForEach Methode vom PtrArray
    3642                 :            : struct _SetAFmtTabPara
    3643                 :            : {
    3644                 :            :     SwTableAutoFmt& rTblFmt;
    3645                 :            :     SwUndoTblAutoFmt* pUndo;
    3646                 :            :     sal_uInt16 nEndBox, nCurBox;
    3647                 :            :     sal_uInt8 nAFmtLine, nAFmtBox;
    3648                 :            : 
    3649                 :          0 :     _SetAFmtTabPara( const SwTableAutoFmt& rNew )
    3650                 :            :         : rTblFmt( (SwTableAutoFmt&)rNew ), pUndo( 0 ),
    3651                 :          0 :         nEndBox( 0 ), nCurBox( 0 ), nAFmtLine( 0 ), nAFmtBox( 0 )
    3652                 :          0 :     {}
    3653                 :            : };
    3654                 :            : 
    3655                 :            : // forward deklarieren damit sich die Lines und Boxen rekursiv aufrufen
    3656                 :            : // koennen.
    3657                 :            : sal_Bool lcl_SetAFmtBox(_FndBox &, _SetAFmtTabPara *pSetPara);
    3658                 :            : sal_Bool lcl_SetAFmtLine(_FndLine &, _SetAFmtTabPara *pPara);
    3659                 :            : 
    3660                 :          0 : sal_Bool lcl_SetAFmtLine(_FndLine & rLine, _SetAFmtTabPara *pPara)
    3661                 :            : {
    3662 [ #  # ][ #  # ]:          0 :     for (_FndBoxes::iterator it = rLine.GetBoxes().begin();
         [ #  # ][ #  # ]
    3663         [ #  # ]:          0 :          it != rLine.GetBoxes().end(); ++it)
    3664                 :            :     {
    3665 [ #  # ][ #  # ]:          0 :         lcl_SetAFmtBox(*it, pPara);
    3666                 :            :     }
    3667                 :          0 :     return sal_True;
    3668                 :            : }
    3669                 :            : 
    3670                 :          0 : sal_Bool lcl_SetAFmtBox( _FndBox & rBox, _SetAFmtTabPara *pSetPara )
    3671                 :            : {
    3672         [ #  # ]:          0 :     if (!rBox.GetUpper()->GetUpper())     // Box on first level?
    3673                 :            :     {
    3674         [ #  # ]:          0 :         if( !pSetPara->nCurBox )
    3675                 :          0 :             pSetPara->nAFmtBox = 0;
    3676         [ #  # ]:          0 :         else if( pSetPara->nCurBox == pSetPara->nEndBox )
    3677                 :          0 :             pSetPara->nAFmtBox = 3;
    3678                 :            :         else
    3679                 :          0 :             pSetPara->nAFmtBox = (sal_uInt8)(1 + ((pSetPara->nCurBox-1) & 1));
    3680                 :            :     }
    3681                 :            : 
    3682         [ #  # ]:          0 :     if (rBox.GetBox()->GetSttNd())
    3683                 :            :     {
    3684                 :          0 :         SwTableBox* pSetBox = static_cast<SwTableBox*>(rBox.GetBox());
    3685                 :          0 :         SwDoc* pDoc = pSetBox->GetFrmFmt()->GetDoc();
    3686         [ #  # ]:          0 :         SfxItemSet aCharSet( pDoc->GetAttrPool(), RES_CHRATR_BEGIN, RES_PARATR_LIST_END-1 );
    3687         [ #  # ]:          0 :         SfxItemSet aBoxSet( pDoc->GetAttrPool(), aTableBoxSetRange );
    3688                 :          0 :         sal_uInt8 nPos = pSetPara->nAFmtLine * 4 + pSetPara->nAFmtBox;
    3689                 :            :         pSetPara->rTblFmt.UpdateToSet( nPos, aCharSet,
    3690         [ #  # ]:          0 :                                         SwTableAutoFmt::UPDATE_CHAR, 0 );
    3691                 :            :         pSetPara->rTblFmt.UpdateToSet( nPos, aBoxSet,
    3692                 :            :                                         SwTableAutoFmt::UPDATE_BOX,
    3693 [ #  # ][ #  # ]:          0 :                                         pDoc->GetNumberFormatter( sal_True ) );
    3694         [ #  # ]:          0 :         if( aCharSet.Count() )
    3695                 :            :         {
    3696         [ #  # ]:          0 :             sal_uLong nSttNd = pSetBox->GetSttIdx()+1;
    3697                 :          0 :             sal_uLong nEndNd = pSetBox->GetSttNd()->EndOfSectionIndex();
    3698         [ #  # ]:          0 :             for( ; nSttNd < nEndNd; ++nSttNd )
    3699                 :            :             {
    3700 [ #  # ][ #  # ]:          0 :                 SwCntntNode* pNd = pDoc->GetNodes()[ nSttNd ]->GetCntntNode();
    3701         [ #  # ]:          0 :                 if( pNd )
    3702         [ #  # ]:          0 :                     pNd->SetAttr( aCharSet );
    3703                 :            :             }
    3704                 :            :         }
    3705                 :            : 
    3706         [ #  # ]:          0 :         if( aBoxSet.Count() )
    3707                 :            :         {
    3708 [ #  # ][ #  # ]:          0 :             if( pSetPara->pUndo &&
                 [ #  # ]
    3709         [ #  # ]:          0 :                 SFX_ITEM_SET == aBoxSet.GetItemState( RES_BOXATR_FORMAT ))
    3710         [ #  # ]:          0 :                 pSetPara->pUndo->SaveBoxCntnt( *pSetBox );
    3711                 :            : 
    3712 [ #  # ][ #  # ]:          0 :             pSetBox->ClaimFrmFmt()->SetFmtAttr( aBoxSet );
    3713 [ #  # ][ #  # ]:          0 :         }
    3714                 :            :     }
    3715                 :            :     else
    3716 [ #  # ][ #  # ]:          0 :         BOOST_FOREACH( _FndLine& rFndLine, rBox.GetLines() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3717         [ #  # ]:          0 :             lcl_SetAFmtLine( rFndLine, pSetPara );
    3718                 :            : 
    3719         [ #  # ]:          0 :     if (!rBox.GetUpper()->GetUpper())     // a BaseLine
    3720                 :          0 :         ++pSetPara->nCurBox;
    3721                 :          0 :     return sal_True;
    3722                 :            : }
    3723                 :            : 
    3724                 :            : 
    3725                 :            :         // AutoFormat fuer die Tabelle/TabellenSelection
    3726                 :          0 : sal_Bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt& rNew )
    3727                 :            : {
    3728                 :            :     OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" );
    3729         [ #  # ]:          0 :     SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode();
    3730         [ #  # ]:          0 :     if( !pTblNd )
    3731                 :          0 :         return sal_False;
    3732                 :            : 
    3733                 :            :     // suche alle Boxen / Lines
    3734         [ #  # ]:          0 :     _FndBox aFndBox( 0, 0 );
    3735                 :            :     {
    3736                 :          0 :         _FndPara aPara( rBoxes, &aFndBox );
    3737         [ #  # ]:          0 :         ForEach_FndLineCopyCol( pTblNd->GetTable().GetTabLines(), &aPara );
    3738                 :            :     }
    3739         [ #  # ]:          0 :     if( aFndBox.GetLines().empty() )
    3740                 :          0 :         return sal_False;
    3741                 :            : 
    3742                 :          0 :     SwTable &table = pTblNd->GetTable();
    3743         [ #  # ]:          0 :     table.SetHTMLTableLayout( 0 );
    3744                 :            : 
    3745                 :          0 :     _FndBox* pFndBox = &aFndBox;
    3746   [ #  #  #  # ]:          0 :     while( 1 == pFndBox->GetLines().size() &&
                 [ #  # ]
    3747         [ #  # ]:          0 :             1 == pFndBox->GetLines().front().GetBoxes().size() )
    3748                 :            :     {
    3749 [ #  # ][ #  # ]:          0 :         pFndBox = &pFndBox->GetLines().front().GetBoxes()[0];
    3750                 :            :     }
    3751                 :            : 
    3752         [ #  # ]:          0 :     if( pFndBox->GetLines().empty() )      // eine zu weit? (nur 1 sel.Box)
    3753                 :          0 :         pFndBox = pFndBox->GetUpper()->GetUpper();
    3754                 :            : 
    3755                 :            : 
    3756                 :            :     // Undo abschalten, Attribute werden sich vorher gemerkt
    3757                 :          0 :     SwUndoTblAutoFmt* pUndo = 0;
    3758 [ #  # ][ #  # ]:          0 :     bool const bUndo(GetIDocumentUndoRedo().DoesUndo());
    3759         [ #  # ]:          0 :     if (bUndo)
    3760                 :            :     {
    3761 [ #  # ][ #  # ]:          0 :         pUndo = new SwUndoTblAutoFmt( *pTblNd, rNew );
    3762 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().AppendUndo(pUndo);
    3763 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().DoUndo(false);
    3764                 :            :     }
    3765                 :            : 
    3766         [ #  # ]:          0 :     rNew.RestoreTableProperties(table);
    3767                 :            : 
    3768                 :          0 :     _SetAFmtTabPara aPara( rNew );
    3769                 :          0 :     _FndLines& rFLns = pFndBox->GetLines();
    3770                 :            :     _FndLine* pLine;
    3771                 :            : 
    3772         [ #  # ]:          0 :     for( sal_uInt16 n = 0; n < rFLns.size(); ++n )
    3773                 :            :     {
    3774         [ #  # ]:          0 :         pLine = &rFLns[n];
    3775                 :            : 
    3776                 :            :         // Upper auf 0 setzen (Base-Line simulieren!)
    3777                 :          0 :         _FndBox* pSaveBox = pLine->GetUpper();
    3778                 :          0 :         pLine->SetUpper( 0 );
    3779                 :            : 
    3780         [ #  # ]:          0 :         if( !n )
    3781                 :          0 :             aPara.nAFmtLine = 0;
    3782         [ #  # ]:          0 :         else if (static_cast<size_t>(n+1) == rFLns.size())
    3783                 :          0 :             aPara.nAFmtLine = 3;
    3784                 :            :         else
    3785                 :          0 :             aPara.nAFmtLine = (sal_uInt8)(1 + ((n-1) & 1 ));
    3786                 :            : 
    3787                 :          0 :         aPara.nAFmtBox = 0;
    3788                 :          0 :         aPara.nCurBox = 0;
    3789                 :          0 :         aPara.nEndBox = pLine->GetBoxes().size()-1;
    3790                 :          0 :         aPara.pUndo = pUndo;
    3791 [ #  # ][ #  # ]:          0 :         for (_FndBoxes::iterator it = pLine->GetBoxes().begin();
         [ #  # ][ #  # ]
    3792         [ #  # ]:          0 :              it != pLine->GetBoxes().end(); ++it)
    3793                 :            :         {
    3794 [ #  # ][ #  # ]:          0 :             lcl_SetAFmtBox(*it, &aPara);
    3795                 :            :         }
    3796                 :            : 
    3797                 :          0 :         pLine->SetUpper( pSaveBox );
    3798                 :            :     }
    3799                 :            : 
    3800         [ #  # ]:          0 :     if( pUndo )
    3801                 :            :     {
    3802 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().DoUndo(bUndo);
    3803                 :            :     }
    3804                 :            : 
    3805         [ #  # ]:          0 :     SetModified();
    3806         [ #  # ]:          0 :     SetFieldsDirty( true, NULL, 0 );
    3807                 :            : 
    3808         [ #  # ]:          0 :     return sal_True;
    3809                 :            : }
    3810                 :            : 
    3811                 :            : 
    3812                 :            :         // Erfrage wie attributiert ist
    3813                 :          0 : sal_Bool SwDoc::GetTableAutoFmt( const SwSelBoxes& rBoxes, SwTableAutoFmt& rGet )
    3814                 :            : {
    3815                 :            :     OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" );
    3816         [ #  # ]:          0 :     SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode();
    3817         [ #  # ]:          0 :     if( !pTblNd )
    3818                 :          0 :         return sal_False;
    3819                 :            : 
    3820                 :            :     // suche alle Boxen / Lines
    3821         [ #  # ]:          0 :     _FndBox aFndBox( 0, 0 );
    3822                 :            :     {
    3823                 :          0 :         _FndPara aPara( rBoxes, &aFndBox );
    3824         [ #  # ]:          0 :         ForEach_FndLineCopyCol( pTblNd->GetTable().GetTabLines(), &aPara );
    3825                 :            :     }
    3826         [ #  # ]:          0 :     if( aFndBox.GetLines().empty() )
    3827                 :          0 :         return sal_False;
    3828                 :            : 
    3829                 :            :     // Store table properties
    3830                 :          0 :     SwTable &table = pTblNd->GetTable();
    3831         [ #  # ]:          0 :     rGet.StoreTableProperties(table);
    3832                 :            : 
    3833                 :          0 :     _FndBox* pFndBox = &aFndBox;
    3834   [ #  #  #  # ]:          0 :     while( 1 == pFndBox->GetLines().size() &&
                 [ #  # ]
    3835         [ #  # ]:          0 :             1 == pFndBox->GetLines().front().GetBoxes().size() )
    3836                 :            :     {
    3837 [ #  # ][ #  # ]:          0 :         pFndBox = &pFndBox->GetLines().front().GetBoxes()[0];
    3838                 :            :     }
    3839                 :            : 
    3840         [ #  # ]:          0 :     if( pFndBox->GetLines().empty() )      // eine zu weit? (nur 1 sel.Box)
    3841                 :          0 :         pFndBox = pFndBox->GetUpper()->GetUpper();
    3842                 :            : 
    3843                 :          0 :     _FndLines& rFLns = pFndBox->GetLines();
    3844                 :            : 
    3845                 :            :     sal_uInt16 aLnArr[4];
    3846                 :          0 :     aLnArr[0] = 0;
    3847         [ #  # ]:          0 :     aLnArr[1] = 1 < rFLns.size() ? 1 : 0;
    3848         [ #  # ]:          0 :     aLnArr[2] = 2 < rFLns.size() ? 2 : aLnArr[1];
    3849                 :          0 :     aLnArr[3] = rFLns.size() - 1;
    3850                 :            : 
    3851         [ #  # ]:          0 :     for( sal_uInt8 nLine = 0; nLine < 4; ++nLine )
    3852                 :            :     {
    3853         [ #  # ]:          0 :         _FndLine& rLine = rFLns[ aLnArr[ nLine ] ];
    3854                 :            : 
    3855                 :            :         sal_uInt16 aBoxArr[4];
    3856                 :          0 :         aBoxArr[0] = 0;
    3857         [ #  # ]:          0 :         aBoxArr[1] = 1 < rLine.GetBoxes().size() ? 1 : 0;
    3858         [ #  # ]:          0 :         aBoxArr[2] = 2 < rLine.GetBoxes().size() ? 2 : aBoxArr[1];
    3859                 :          0 :         aBoxArr[3] = rLine.GetBoxes().size() - 1;
    3860                 :            : 
    3861         [ #  # ]:          0 :         for( sal_uInt8 nBox = 0; nBox < 4; ++nBox )
    3862                 :            :         {
    3863         [ #  # ]:          0 :             SwTableBox* pFBox = rLine.GetBoxes()[ aBoxArr[ nBox ] ].GetBox();
    3864                 :            :             // immer auf die 1. runterfallen
    3865         [ #  # ]:          0 :             while( !pFBox->GetSttNd() )
    3866                 :          0 :                 pFBox = pFBox->GetTabLines()[0]->GetTabBoxes()[0];
    3867                 :            : 
    3868                 :          0 :             sal_uInt8 nPos = nLine * 4 + nBox;
    3869         [ #  # ]:          0 :             SwNodeIndex aIdx( *pFBox->GetSttNd(), 1 );
    3870                 :          0 :             SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
    3871         [ #  # ]:          0 :             if( !pCNd )
    3872 [ #  # ][ #  # ]:          0 :                 pCNd = GetNodes().GoNext( &aIdx );
    3873                 :            : 
    3874         [ #  # ]:          0 :             if( pCNd )
    3875         [ #  # ]:          0 :                 rGet.UpdateFromSet( nPos, pCNd->GetSwAttrSet(),
    3876         [ #  # ]:          0 :                                     SwTableAutoFmt::UPDATE_CHAR, 0 );
    3877                 :          0 :             rGet.UpdateFromSet( nPos, pFBox->GetFrmFmt()->GetAttrSet(),
    3878                 :            :                                 SwTableAutoFmt::UPDATE_BOX,
    3879   [ #  #  #  # ]:          0 :                                 GetNumberFormatter( sal_True ) );
    3880         [ #  # ]:          0 :         }
    3881                 :            :     }
    3882                 :            : 
    3883         [ #  # ]:          0 :     return sal_True;
    3884                 :            : }
    3885                 :            : 
    3886                 :        232 : String SwDoc::GetUniqueTblName() const
    3887                 :            : {
    3888                 :        232 :     ResId aId( STR_TABLE_DEFNAME, *pSwResMgr );
    3889         [ +  - ]:        232 :     String aName( aId );
    3890                 :        232 :     xub_StrLen nNmLen = aName.Len();
    3891                 :            : 
    3892                 :        232 :     sal_uInt16 nNum, nTmp, nFlagSize = ( pTblFrmFmtTbl->size() / 8 ) +2;
    3893                 :            :     sal_uInt16 n;
    3894                 :            : 
    3895         [ +  - ]:        232 :     sal_uInt8* pSetFlags = new sal_uInt8[ nFlagSize ];
    3896                 :        232 :     memset( pSetFlags, 0, nFlagSize );
    3897                 :            : 
    3898         [ +  + ]:        570 :     for( n = 0; n < pTblFrmFmtTbl->size(); ++n )
    3899                 :            :     {
    3900         [ +  - ]:        338 :         const SwFrmFmt* pFmt = (*pTblFrmFmtTbl)[ n ];
    3901 [ +  - ][ +  - ]:        670 :         if( !pFmt->IsDefault() && IsUsed( *pFmt )  &&
         [ +  + ][ +  - ]
                 [ +  + ]
    3902         [ +  - ]:        332 :             pFmt->GetName().Match( aName ) == nNmLen )
    3903                 :            :         {
    3904                 :            :             // Nummer bestimmen und das Flag setzen
    3905 [ +  - ][ +  - ]:        332 :             nNum = static_cast<sal_uInt16>(pFmt->GetName().Copy( nNmLen ).ToInt32());
                 [ +  - ]
    3906 [ +  - ][ +  - ]:        332 :             if( nNum-- && nNum < pTblFrmFmtTbl->size() )
                 [ +  - ]
    3907                 :        332 :                 pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 ));
    3908                 :            :         }
    3909                 :            :     }
    3910                 :            : 
    3911                 :            :     // alle Nummern entsprechend geflag, also bestimme die richtige Nummer
    3912                 :        232 :     nNum = pTblFrmFmtTbl->size();
    3913         [ +  - ]:        232 :     for( n = 0; n < nFlagSize; ++n )
    3914         [ +  - ]:        232 :         if( 0xff != ( nTmp = pSetFlags[ n ] ))
    3915                 :            :         {
    3916                 :            :             // also die Nummer bestimmen
    3917                 :        232 :             nNum = n * 8;
    3918         [ +  + ]:        564 :             while( nTmp & 1 )
    3919                 :        332 :                 ++nNum, nTmp >>= 1;
    3920                 :        232 :             break;
    3921                 :            :         }
    3922                 :            : 
    3923         [ +  - ]:        232 :     delete [] pSetFlags;
    3924 [ +  - ][ +  - ]:        232 :     return aName += String::CreateFromInt32( ++nNum );
         [ +  - ][ +  - ]
                 [ +  - ]
    3925                 :            : }
    3926                 :            : 
    3927                 :         25 : SwTableFmt* SwDoc::FindTblFmtByName( const String& rName, sal_Bool bAll ) const
    3928                 :            : {
    3929                 :         25 :     const SwFmt* pRet = 0;
    3930         [ +  + ]:         25 :     if( bAll )
    3931                 :          4 :         pRet = FindFmtByName( *pTblFrmFmtTbl, rName );
    3932                 :            :     else
    3933                 :            :     {
    3934                 :            :         // dann nur die, die im Doc gesetzt sind
    3935         [ +  + ]:         21 :         for( sal_uInt16 n = 0; n < pTblFrmFmtTbl->size(); ++n )
    3936                 :            :         {
    3937                 :         18 :             const SwFrmFmt* pFmt = (*pTblFrmFmtTbl)[ n ];
    3938   [ +  -  +  - ]:         36 :             if( !pFmt->IsDefault() && IsUsed( *pFmt ) &&
         [ +  - ][ +  - ]
    3939                 :         18 :                 pFmt->GetName() == rName )
    3940                 :            :             {
    3941                 :         18 :                 pRet = pFmt;
    3942                 :         18 :                 break;
    3943                 :            :             }
    3944                 :            :         }
    3945                 :            :     }
    3946                 :         25 :     return (SwTableFmt*)pRet;
    3947                 :            : }
    3948                 :            : 
    3949                 :          0 : sal_Bool SwDoc::SetColRowWidthHeight( SwTableBox& rAktBox, sal_uInt16 eType,
    3950                 :            :                                     SwTwips nAbsDiff, SwTwips nRelDiff )
    3951                 :            : {
    3952         [ #  # ]:          0 :     SwTableNode* pTblNd = (SwTableNode*)rAktBox.GetSttNd()->FindTableNode();
    3953                 :          0 :     SwUndo* pUndo = 0;
    3954                 :            : 
    3955 [ #  # ][ #  # ]:          0 :     if( nsTblChgWidthHeightType::WH_FLAG_INSDEL & eType && pTblNd->GetTable().ISA( SwDDETable ))
         [ #  # ][ #  # ]
                 [ #  # ]
    3956                 :          0 :         return sal_False;
    3957                 :            : 
    3958         [ #  # ]:          0 :     SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
    3959                 :          0 :     aMsgHnt.eFlags = TBL_BOXPTR;
    3960         [ #  # ]:          0 :     UpdateTblFlds( &aMsgHnt );
    3961                 :            : 
    3962 [ #  # ][ #  # ]:          0 :     bool const bUndo(GetIDocumentUndoRedo().DoesUndo());
    3963                 :          0 :     sal_Bool bRet = sal_False;
    3964      [ #  #  # ]:          0 :     switch( eType & 0xff )
    3965                 :            :     {
    3966                 :            :     case nsTblChgWidthHeightType::WH_COL_LEFT:
    3967                 :            :     case nsTblChgWidthHeightType::WH_COL_RIGHT:
    3968                 :            :     case nsTblChgWidthHeightType::WH_CELL_LEFT:
    3969                 :            :     case nsTblChgWidthHeightType::WH_CELL_RIGHT:
    3970                 :            :         {
    3971                 :          0 :              bRet = pTblNd->GetTable().SetColWidth( rAktBox,
    3972                 :            :                                 eType, nAbsDiff, nRelDiff,
    3973 [ #  # ][ #  # ]:          0 :                                 (bUndo) ? &pUndo : 0 );
    3974                 :            :         }
    3975                 :          0 :         break;
    3976                 :            :     case nsTblChgWidthHeightType::WH_ROW_TOP:
    3977                 :            :     case nsTblChgWidthHeightType::WH_ROW_BOTTOM:
    3978                 :            :     case nsTblChgWidthHeightType::WH_CELL_TOP:
    3979                 :            :     case nsTblChgWidthHeightType::WH_CELL_BOTTOM:
    3980                 :          0 :         bRet = pTblNd->GetTable().SetRowHeight( rAktBox,
    3981                 :            :                             eType, nAbsDiff, nRelDiff,
    3982 [ #  # ][ #  # ]:          0 :                             (bUndo) ? &pUndo : 0 );
    3983                 :          0 :         break;
    3984                 :            :     }
    3985                 :            : 
    3986 [ #  # ][ #  # ]:          0 :     GetIDocumentUndoRedo().DoUndo(bUndo); // SetColWidth can turn it off
    3987         [ #  # ]:          0 :     if( pUndo )
    3988                 :            :     {
    3989 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().AppendUndo( pUndo );
    3990                 :            :     }
    3991                 :            : 
    3992         [ #  # ]:          0 :     if( bRet )
    3993                 :            :     {
    3994         [ #  # ]:          0 :         SetModified();
    3995         [ #  # ]:          0 :         if( nsTblChgWidthHeightType::WH_FLAG_INSDEL & eType )
    3996         [ #  # ]:          0 :             SetFieldsDirty( true, NULL, 0 );
    3997                 :            :     }
    3998         [ #  # ]:          0 :     return bRet;
    3999                 :            : }
    4000                 :            : 
    4001                 :            : 
    4002                 :          0 : void SwDoc::ChkBoxNumFmt( SwTableBox& rBox, sal_Bool bCallUpdate )
    4003                 :            : {
    4004                 :            :     //JP 09.07.97: Optimierung: wenn die Box schon sagt, das es Text
    4005                 :            :     //                          sein soll, dann bleibt das auch Text!
    4006                 :          0 :     const SfxPoolItem* pNumFmtItem = 0;
    4007 [ #  # ][ #  # ]:          0 :     if( SFX_ITEM_SET == rBox.GetFrmFmt()->GetItemState( RES_BOXATR_FORMAT,
                 [ #  # ]
    4008         [ #  # ]:          0 :         sal_False, &pNumFmtItem ) && GetNumberFormatter()->IsTextFormat(
    4009 [ #  # ][ #  # ]:          0 :             ((SwTblBoxNumFormat*)pNumFmtItem)->GetValue() ))
    4010                 :          0 :         return ;
    4011                 :            : 
    4012                 :          0 :     SwUndoTblNumFmt* pUndo = 0;
    4013                 :            : 
    4014                 :          0 :     sal_Bool bIsEmptyTxtNd, bChgd = sal_True;
    4015                 :            :     sal_uInt32 nFmtIdx;
    4016                 :            :     double fNumber;
    4017 [ #  # ][ #  # ]:          0 :     if( rBox.HasNumCntnt( fNumber, nFmtIdx, bIsEmptyTxtNd ) )
    4018                 :            :     {
    4019 [ #  # ][ #  # ]:          0 :         if( !rBox.IsNumberChanged() )
    4020                 :          0 :             bChgd = sal_False;
    4021                 :            :         else
    4022                 :            :         {
    4023 [ #  # ][ #  # ]:          0 :             if (GetIDocumentUndoRedo().DoesUndo())
                 [ #  # ]
    4024                 :            :             {
    4025 [ #  # ][ #  # ]:          0 :                 GetIDocumentUndoRedo().StartUndo( UNDO_TABLE_AUTOFMT, NULL );
    4026 [ #  # ][ #  # ]:          0 :                 pUndo = new SwUndoTblNumFmt( rBox );
    4027                 :          0 :                 pUndo->SetNumFmt( nFmtIdx, fNumber );
    4028                 :            :             }
    4029                 :            : 
    4030                 :          0 :             SwTableBoxFmt* pBoxFmt = (SwTableBoxFmt*)rBox.GetFrmFmt();
    4031         [ #  # ]:          0 :             SfxItemSet aBoxSet( GetAttrPool(), RES_BOXATR_FORMAT, RES_BOXATR_VALUE );
    4032                 :            : 
    4033         [ #  # ]:          0 :             sal_Bool bSetNumFmt = IsInsTblFormatNum(), bLockModify = sal_True;
    4034         [ #  # ]:          0 :             if( bSetNumFmt )
    4035                 :            :             {
    4036 [ #  # ][ #  # ]:          0 :                 if( !IsInsTblChangeNumFormat() )
    4037                 :            :                 {
    4038         [ #  # ]:          0 :                     if( !pNumFmtItem )
    4039                 :          0 :                         bSetNumFmt = sal_False;
    4040                 :            :                     else
    4041                 :            :                     {
    4042                 :            :                         sal_uLong nOldNumFmt = ((SwTblBoxNumFormat*)pNumFmtItem)->
    4043                 :          0 :                                             GetValue();
    4044         [ #  # ]:          0 :                         SvNumberFormatter* pNumFmtr = GetNumberFormatter();
    4045                 :            : 
    4046         [ #  # ]:          0 :                         short nFmtType = pNumFmtr->GetType( nFmtIdx );
    4047 [ #  # ][ #  # ]:          0 :                         if( nFmtType == pNumFmtr->GetType( nOldNumFmt ) ||
         [ #  # ][ #  # ]
    4048                 :            :                             NUMBERFORMAT_NUMBER == nFmtType )
    4049                 :            :                             // eingstelltes und vorgegebenes NumFormat
    4050                 :            :                             // stimmen ueberein -> altes Format beibehalten
    4051                 :          0 :                             nFmtIdx = nOldNumFmt;
    4052                 :            :                         else
    4053                 :            :                             // eingstelltes und vorgegebenes NumFormat
    4054                 :            :                             // stimmen nicht ueberein -> als Text einfuegen
    4055                 :          0 :                             bLockModify = bSetNumFmt = sal_False;
    4056                 :            :                     }
    4057                 :            :                 }
    4058                 :            : 
    4059         [ #  # ]:          0 :                 if( bSetNumFmt )
    4060                 :            :                 {
    4061         [ #  # ]:          0 :                     pBoxFmt = (SwTableBoxFmt*)rBox.ClaimFrmFmt();
    4062                 :            : 
    4063 [ #  # ][ #  # ]:          0 :                     aBoxSet.Put( SwTblBoxValue( fNumber ));
                 [ #  # ]
    4064 [ #  # ][ #  # ]:          0 :                     aBoxSet.Put( SwTblBoxNumFormat( nFmtIdx ));
                 [ #  # ]
    4065                 :            :                 }
    4066                 :            :             }
    4067                 :            : 
    4068                 :            :             // JP 28.04.98: Nur Formel zuruecksetzen reicht nicht.
    4069                 :            :             //              Sorge dafuer, das der Text auch entsprechend
    4070                 :            :             //              formatiert wird!
    4071                 :            : 
    4072 [ #  # ][ #  # ]:          0 :             if( !bSetNumFmt && !bIsEmptyTxtNd && pNumFmtItem )
                 [ #  # ]
    4073                 :            :             {
    4074                 :            :                 // JP 15.01.99: Nur Attribute zuruecksetzen reicht nicht.
    4075                 :            :                 //              Sorge dafuer, das der Text auch entsprechend
    4076                 :            :                 //              formatiert wird!
    4077 [ #  # ][ #  # ]:          0 :                 pBoxFmt->SetFmtAttr( *GetDfltAttr( RES_BOXATR_FORMAT ));
    4078                 :            :             }
    4079                 :            : 
    4080         [ #  # ]:          0 :             if( bLockModify ) pBoxFmt->LockModify();
    4081         [ #  # ]:          0 :             pBoxFmt->ResetFmtAttr( RES_BOXATR_FORMAT, RES_BOXATR_VALUE );
    4082         [ #  # ]:          0 :             if( bLockModify ) pBoxFmt->UnlockModify();
    4083                 :            : 
    4084         [ #  # ]:          0 :             if( bSetNumFmt )
    4085 [ #  # ][ #  # ]:          0 :                 pBoxFmt->SetFmtAttr( aBoxSet );
    4086                 :            :         }
    4087                 :            :     }
    4088                 :            :     else
    4089                 :            :     {
    4090                 :            :         // es ist keine Zahl
    4091                 :          0 :         const SfxPoolItem* pValueItem = 0, *pFmtItem = 0;
    4092                 :          0 :         SwTableBoxFmt* pBoxFmt = (SwTableBoxFmt*)rBox.GetFrmFmt();
    4093 [ #  # ][ #  # ]:          0 :         if( SFX_ITEM_SET == pBoxFmt->GetItemState( RES_BOXATR_FORMAT,
                 [ #  # ]
    4094         [ #  # ]:          0 :                 sal_False, &pFmtItem ) ||
    4095                 :            :             SFX_ITEM_SET == pBoxFmt->GetItemState( RES_BOXATR_VALUE,
    4096         [ #  # ]:          0 :                 sal_False, &pValueItem ))
    4097                 :            :         {
    4098 [ #  # ][ #  # ]:          0 :             if (GetIDocumentUndoRedo().DoesUndo())
                 [ #  # ]
    4099                 :            :             {
    4100 [ #  # ][ #  # ]:          0 :                 GetIDocumentUndoRedo().StartUndo( UNDO_TABLE_AUTOFMT, NULL );
    4101 [ #  # ][ #  # ]:          0 :                 pUndo = new SwUndoTblNumFmt( rBox );
    4102                 :            :             }
    4103                 :            : 
    4104         [ #  # ]:          0 :             pBoxFmt = (SwTableBoxFmt*)rBox.ClaimFrmFmt();
    4105                 :            : 
    4106                 :            :             // alle Zahlenformate entfernen
    4107                 :          0 :             sal_uInt16 nWhich1 = RES_BOXATR_FORMULA;
    4108         [ #  # ]:          0 :             if( !bIsEmptyTxtNd )
    4109                 :            :             {
    4110                 :          0 :                 nWhich1 = RES_BOXATR_FORMAT;
    4111                 :            : 
    4112                 :            :                 // JP 15.01.99: Nur Attribute zuruecksetzen reicht nicht.
    4113                 :            :                 //              Sorge dafuer, das der Text auch entsprechend
    4114                 :            :                 //              formatiert wird!
    4115 [ #  # ][ #  # ]:          0 :                 pBoxFmt->SetFmtAttr( *GetDfltAttr( nWhich1 ));
    4116                 :            :             }
    4117         [ #  # ]:          0 :             pBoxFmt->ResetFmtAttr( nWhich1, RES_BOXATR_VALUE );
    4118                 :            :         }
    4119                 :            :         else
    4120                 :          0 :             bChgd = sal_False;
    4121                 :            :     }
    4122                 :            : 
    4123         [ #  # ]:          0 :     if( bChgd )
    4124                 :            :     {
    4125         [ #  # ]:          0 :         if( pUndo )
    4126                 :            :         {
    4127         [ #  # ]:          0 :             pUndo->SetBox( rBox );
    4128 [ #  # ][ #  # ]:          0 :             GetIDocumentUndoRedo().AppendUndo(pUndo);
    4129 [ #  # ][ #  # ]:          0 :             GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
    4130                 :            :         }
    4131                 :            : 
    4132         [ #  # ]:          0 :         const SwTableNode* pTblNd = rBox.GetSttNd()->FindTableNode();
    4133         [ #  # ]:          0 :         if( bCallUpdate )
    4134                 :            :         {
    4135         [ #  # ]:          0 :             SwTableFmlUpdate aTblUpdate( &pTblNd->GetTable() );
    4136         [ #  # ]:          0 :             UpdateTblFlds( &aTblUpdate );
    4137                 :            : 
    4138                 :            :             // TL_CHART2: update charts (when cursor leaves cell and
    4139                 :            :             // automatic update is enabled)
    4140 [ #  # ][ #  # ]:          0 :             if (AUTOUPD_FIELD_AND_CHARTS == getFieldUpdateFlags(true))
    4141 [ #  # ][ #  # ]:          0 :                 pTblNd->GetTable().UpdateCharts();
    4142                 :            :         }
    4143         [ #  # ]:          0 :         SetModified();
    4144                 :            :     }
    4145                 :            : }
    4146                 :            : 
    4147                 :        144 : void SwDoc::SetTblBoxFormulaAttrs( SwTableBox& rBox, const SfxItemSet& rSet )
    4148                 :            : {
    4149         [ +  - ]:        144 :     if (GetIDocumentUndoRedo().DoesUndo())
    4150                 :            :     {
    4151         [ +  - ]:        144 :         GetIDocumentUndoRedo().AppendUndo( new SwUndoTblNumFmt(rBox, &rSet) );
    4152                 :            :     }
    4153                 :            : 
    4154                 :        144 :     SwFrmFmt* pBoxFmt = rBox.ClaimFrmFmt();
    4155         [ -  + ]:        144 :     if( SFX_ITEM_SET == rSet.GetItemState( RES_BOXATR_FORMULA ))
    4156                 :            :     {
    4157                 :          0 :         pBoxFmt->LockModify();
    4158                 :          0 :         pBoxFmt->ResetFmtAttr( RES_BOXATR_VALUE );
    4159                 :          0 :         pBoxFmt->UnlockModify();
    4160                 :            :     }
    4161         [ +  - ]:        144 :     else if( SFX_ITEM_SET == rSet.GetItemState( RES_BOXATR_VALUE ))
    4162                 :            :     {
    4163                 :        144 :         pBoxFmt->LockModify();
    4164                 :        144 :         pBoxFmt->ResetFmtAttr( RES_BOXATR_FORMULA );
    4165                 :        144 :         pBoxFmt->UnlockModify();
    4166                 :            :     }
    4167                 :        144 :     pBoxFmt->SetFmtAttr( rSet );
    4168                 :        144 :     SetModified();
    4169                 :        144 : }
    4170                 :            : 
    4171                 :          0 : void SwDoc::ClearLineNumAttrs( SwPosition & rPos )
    4172                 :            : {
    4173         [ #  # ]:          0 :     SwPaM aPam(rPos);
    4174         [ #  # ]:          0 :     aPam.Move(fnMoveBackward);
    4175                 :          0 :     SwCntntNode *pNode = aPam.GetCntntNode();
    4176         [ #  # ]:          0 :     if ( 0 == pNode )
    4177                 :          0 :         return ;
    4178         [ #  # ]:          0 :     if( pNode->IsTxtNode() )
    4179                 :            :     {
    4180                 :          0 :         SwTxtNode * pTxtNode = pNode->GetTxtNode();
    4181 [ #  # ][ #  # ]:          0 :         if ( pTxtNode && pTxtNode->IsNumbered() && pTxtNode->GetTxt().Len()==0 )
         [ #  # ][ #  # ]
                 [ #  # ]
    4182                 :            :         {
    4183                 :          0 :             const SfxPoolItem* pFmtItem = 0;
    4184                 :          0 :             SfxItemSet rSet( const_cast<SwAttrPool&>(pTxtNode->GetDoc()->GetAttrPool()),
    4185                 :            :                         RES_PARATR_BEGIN, RES_PARATR_END - 1,
    4186         [ #  # ]:          0 :                         0);
    4187         [ #  # ]:          0 :             pTxtNode->SwCntntNode::GetAttr( rSet );
    4188 [ #  # ][ #  # ]:          0 :             if ( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_NUMRULE , sal_False , &pFmtItem ) )
    4189                 :            :             {
    4190                 :            :                 SwUndoDelNum * pUndo;
    4191 [ #  # ][ #  # ]:          0 :                 if( GetIDocumentUndoRedo().DoesUndo() )
                 [ #  # ]
    4192                 :            :                 {
    4193 [ #  # ][ #  # ]:          0 :                     GetIDocumentUndoRedo().ClearRedo();
    4194 [ #  # ][ #  # ]:          0 :                     GetIDocumentUndoRedo().AppendUndo( pUndo = new SwUndoDelNum( aPam ) );
         [ #  # ][ #  # ]
    4195                 :            :                 }
    4196                 :            :                 else
    4197                 :          0 :                     pUndo = 0;
    4198 [ #  # ][ #  # ]:          0 :                 SwRegHistory aRegH( pUndo ? pUndo->GetHistory() : 0 );
    4199         [ #  # ]:          0 :                 aRegH.RegisterInModify( pTxtNode , *pTxtNode );
    4200         [ #  # ]:          0 :                 if ( pUndo )
    4201         [ #  # ]:          0 :                     pUndo->AddNode( *pTxtNode , sal_False );
    4202         [ #  # ]:          0 :                 SfxStringItem * pNewItem = (SfxStringItem*)pFmtItem->Clone();
    4203 [ #  # ][ #  # ]:          0 :                 pNewItem->SetValue(rtl::OUString());
                 [ #  # ]
    4204         [ #  # ]:          0 :                 rSet.Put( *pNewItem );
    4205         [ #  # ]:          0 :                 pTxtNode->SetAttr( rSet );
    4206 [ #  # ][ #  # ]:          0 :                 delete pNewItem;
                 [ #  # ]
    4207         [ #  # ]:          0 :             }
    4208                 :            :         }
    4209 [ #  # ][ #  # ]:          0 :     }
    4210                 :            : }
    4211                 :            : 
    4212                 :       1361 : void SwDoc::ClearBoxNumAttrs( const SwNodeIndex& rNode )
    4213                 :            : {
    4214                 :            :     SwStartNode* pSttNd;
    4215   [ +  +  +  - ]:       1708 :     if( 0 != ( pSttNd = rNode.GetNode().
                 [ +  + ]
    4216                 :            :                                 FindSttNodeByType( SwTableBoxStartNode )) &&
    4217                 :        347 :         2 == pSttNd->EndOfSectionIndex() - pSttNd->GetIndex() )
    4218                 :            :     {
    4219         [ +  - ]:        347 :         SwTableBox* pBox = pSttNd->FindTableNode()->GetTable().
    4220         [ +  - ]:        694 :                             GetTblBox( pSttNd->GetIndex() );
    4221                 :            : 
    4222                 :        347 :         const SfxPoolItem* pFmtItem = 0;
    4223                 :        347 :         const SfxItemSet& rSet = pBox->GetFrmFmt()->GetAttrSet();
    4224 [ +  + ][ +  - ]:       1037 :         if( SFX_ITEM_SET == rSet.GetItemState( RES_BOXATR_FORMAT, sal_False, &pFmtItem ) ||
         [ -  + ][ +  + ]
                 [ +  - ]
    4225         [ +  - ]:        345 :             SFX_ITEM_SET == rSet.GetItemState( RES_BOXATR_FORMULA, sal_False ) ||
    4226         [ +  - ]:        345 :             SFX_ITEM_SET == rSet.GetItemState( RES_BOXATR_VALUE, sal_False ))
    4227                 :            :         {
    4228 [ +  - ][ +  - ]:          2 :             if (GetIDocumentUndoRedo().DoesUndo())
                 [ +  - ]
    4229                 :            :             {
    4230 [ +  - ][ +  - ]:          2 :                 GetIDocumentUndoRedo().AppendUndo(new SwUndoTblNumFmt(*pBox));
         [ +  - ][ +  - ]
    4231                 :            :             }
    4232                 :            : 
    4233         [ +  - ]:          2 :             SwFrmFmt* pBoxFmt = pBox->ClaimFrmFmt();
    4234                 :            : 
    4235                 :            :             //JP 01.09.97: TextFormate bleiben erhalten!
    4236                 :          2 :             sal_uInt16 nWhich1 = RES_BOXATR_FORMAT;
    4237 [ +  - ][ -  + ]:          4 :             if( pFmtItem && GetNumberFormatter()->IsTextFormat(
                 [ -  + ]
    4238 [ +  - ][ +  - ]:          2 :                     ((SwTblBoxNumFormat*)pFmtItem)->GetValue() ))
    4239                 :          0 :                 nWhich1 = RES_BOXATR_FORMULA;
    4240                 :            :             else
    4241                 :            :                 // JP 15.01.99: Nur Attribute zuruecksetzen reicht nicht.
    4242                 :            :                 //              Sorge dafuer, das der Text auch entsprechend
    4243                 :            :                 //              formatiert wird!
    4244 [ +  - ][ +  - ]:          2 :                 pBoxFmt->SetFmtAttr( *GetDfltAttr( RES_BOXATR_FORMAT ));
    4245                 :            : 
    4246         [ +  - ]:          2 :             pBoxFmt->ResetFmtAttr( nWhich1, RES_BOXATR_VALUE );
    4247         [ +  - ]:        347 :             SetModified();
    4248                 :            :         }
    4249                 :            :     }
    4250                 :       1361 : }
    4251                 :            : 
    4252                 :            : // kopiert eine Tabelle aus dem selben oder einem anderen Doc in sich
    4253                 :            : // selbst. Dabei wird eine neue Tabelle angelegt oder eine bestehende
    4254                 :            : // mit dem Inhalt gefuellt; wobei entweder der Inhalt ab einer Box oder
    4255                 :            : // in eine bestehende TblSelektion gefuellt wird.
    4256                 :            : // Gerufen wird es von: edglss.cxx/fecopy.cxx
    4257                 :            : 
    4258                 :          0 : sal_Bool SwDoc::InsCopyOfTbl( SwPosition& rInsPos, const SwSelBoxes& rBoxes,
    4259                 :            :                         const SwTable* pCpyTbl, sal_Bool bCpyName, sal_Bool bCorrPos )
    4260                 :            : {
    4261                 :            :     sal_Bool bRet;
    4262                 :            : 
    4263                 :            :     const SwTableNode* pSrcTblNd = pCpyTbl
    4264                 :            :             ? pCpyTbl->GetTableNode()
    4265         [ #  # ]:          0 :             : rBoxes[ 0 ]->GetSttNd()->FindTableNode();
    4266                 :            : 
    4267                 :          0 :     SwTableNode * pInsTblNd = rInsPos.nNode.GetNode().FindTableNode();
    4268                 :            : 
    4269                 :          0 :     bool const bUndo( GetIDocumentUndoRedo().DoesUndo() );
    4270 [ #  # ][ #  # ]:          0 :     if( !pCpyTbl && !pInsTblNd )
    4271                 :            :     {
    4272                 :          0 :         SwUndoCpyTbl* pUndo = 0;
    4273         [ #  # ]:          0 :         if (bUndo)
    4274                 :            :         {
    4275                 :          0 :             GetIDocumentUndoRedo().ClearRedo();
    4276         [ #  # ]:          0 :             pUndo = new SwUndoCpyTbl;
    4277                 :            :         }
    4278                 :            : 
    4279                 :            :         {
    4280 [ #  # ][ #  # ]:          0 :             ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
    4281                 :          0 :             bRet = pSrcTblNd->GetTable().MakeCopy( this, rInsPos, rBoxes,
    4282 [ #  # ][ #  # ]:          0 :                                                 sal_True, bCpyName );
    4283                 :            :         }
    4284                 :            : 
    4285         [ #  # ]:          0 :         if( pUndo )
    4286                 :            :         {
    4287         [ #  # ]:          0 :             if( !bRet )
    4288                 :            :             {
    4289         [ #  # ]:          0 :                 delete pUndo;
    4290                 :          0 :                 pUndo = 0;
    4291                 :            :             }
    4292                 :            :             else
    4293                 :            :             {
    4294                 :          0 :                 pInsTblNd = GetNodes()[ rInsPos.nNode.GetIndex() - 1 ]->FindTableNode();
    4295                 :            : 
    4296                 :          0 :                 pUndo->SetTableSttIdx( pInsTblNd->GetIndex() );
    4297                 :          0 :                 GetIDocumentUndoRedo().AppendUndo( pUndo );
    4298                 :            :             }
    4299                 :          0 :         }
    4300                 :            :     }
    4301                 :            :     else
    4302                 :            :     {
    4303                 :          0 :         RedlineMode_t eOld = GetRedlineMode();
    4304         [ #  # ]:          0 :         if( IsRedlineOn() )
    4305                 :            :       SetRedlineMode( (RedlineMode_t)(nsRedlineMode_t::REDLINE_ON |
    4306                 :            :                                   nsRedlineMode_t::REDLINE_SHOW_INSERT |
    4307                 :          0 :                                   nsRedlineMode_t::REDLINE_SHOW_DELETE));
    4308                 :            : 
    4309                 :          0 :         SwUndoTblCpyTbl* pUndo = 0;
    4310         [ #  # ]:          0 :         if (bUndo)
    4311                 :            :         {
    4312                 :          0 :             GetIDocumentUndoRedo().ClearRedo();
    4313         [ #  # ]:          0 :             pUndo = new SwUndoTblCpyTbl;
    4314                 :          0 :             GetIDocumentUndoRedo().DoUndo(false);
    4315                 :            :         }
    4316                 :            : 
    4317                 :          0 :         SwDoc* pCpyDoc = (SwDoc*)pSrcTblNd->GetDoc();
    4318                 :          0 :         sal_Bool bDelCpyDoc = pCpyDoc == this;
    4319                 :            : 
    4320         [ #  # ]:          0 :         if( bDelCpyDoc )
    4321                 :            :         {
    4322                 :            :             // kopiere die Tabelle erstmal in ein temp. Doc
    4323 [ #  # ][ #  # ]:          0 :             pCpyDoc = new SwDoc;
    4324         [ #  # ]:          0 :             pCpyDoc->acquire();
    4325                 :            : 
    4326 [ #  # ][ #  # ]:          0 :             SwPosition aPos( SwNodeIndex( pCpyDoc->GetNodes().GetEndOfContent() ));
         [ #  # ][ #  # ]
    4327 [ #  # ][ #  # ]:          0 :             if( !pSrcTblNd->GetTable().MakeCopy( pCpyDoc, aPos, rBoxes, sal_True, sal_True ))
    4328                 :            :             {
    4329 [ #  # ][ #  # ]:          0 :                 if( pCpyDoc->release() == 0 )
    4330 [ #  # ][ #  # ]:          0 :                     delete pCpyDoc;
    4331                 :            : 
    4332         [ #  # ]:          0 :                 if( pUndo )
    4333                 :            :                 {
    4334 [ #  # ][ #  # ]:          0 :                     GetIDocumentUndoRedo().DoUndo(bUndo);
    4335 [ #  # ][ #  # ]:          0 :                     delete pUndo;
    4336                 :          0 :                     pUndo = 0;
    4337                 :            :                 }
    4338                 :          0 :                 return sal_False;
    4339                 :            :             }
    4340         [ #  # ]:          0 :             aPos.nNode -= 1;        // auf den EndNode der Tabelle
    4341 [ #  # ][ #  # ]:          0 :             pSrcTblNd = aPos.nNode.GetNode().FindTableNode();
                 [ #  # ]
    4342                 :            :         }
    4343                 :            : 
    4344                 :          0 :         const SwStartNode* pSttNd = rInsPos.nNode.GetNode().FindTableBoxStartNode();
    4345                 :            : 
    4346                 :          0 :         rInsPos.nContent.Assign( 0, 0 );
    4347                 :            : 
    4348                 :            :         // no complex into complex, but copy into or from new model is welcome
    4349         [ #  # ]:          0 :         if( ( !pSrcTblNd->GetTable().IsTblComplex() || pInsTblNd->GetTable().IsNewModel() )
           [ #  #  #  # ]
         [ #  # ][ #  # ]
    4350                 :          0 :             && ( bDelCpyDoc || !rBoxes.empty() ) )
    4351                 :            :         {
    4352                 :            :             // dann die Tabelle "relativ" kopieren
    4353                 :            :             const SwSelBoxes* pBoxes;
    4354         [ #  # ]:          0 :             SwSelBoxes aBoxes;
    4355                 :            : 
    4356         [ #  # ]:          0 :             if( bDelCpyDoc )
    4357                 :            :             {
    4358                 :          0 :                 SwTableBox* pBox = pInsTblNd->GetTable().GetTblBox(
    4359         [ #  # ]:          0 :                                         pSttNd->GetIndex() );
    4360                 :            :                 OSL_ENSURE( pBox, "Box steht nicht in dieser Tabelle" );
    4361         [ #  # ]:          0 :                 aBoxes.insert( pBox );
    4362                 :          0 :                 pBoxes = &aBoxes;
    4363                 :            :             }
    4364                 :            :             else
    4365                 :          0 :                 pBoxes = &rBoxes;
    4366                 :            : 
    4367                 :            :             // kopiere die Tabelle in die selktierten Zellen.
    4368                 :          0 :             bRet = pInsTblNd->GetTable().InsTable( pSrcTblNd->GetTable(),
    4369         [ #  # ]:          0 :                                                         *pBoxes, pUndo );
    4370                 :            :         }
    4371                 :            :         else
    4372                 :            :         {
    4373         [ #  # ]:          0 :             SwNodeIndex aNdIdx( *pSttNd, 1 );
    4374                 :          0 :             bRet = pInsTblNd->GetTable().InsTable( pSrcTblNd->GetTable(),
    4375 [ #  # ][ #  # ]:          0 :                                                     aNdIdx, pUndo );
    4376                 :            :         }
    4377                 :            : 
    4378         [ #  # ]:          0 :         if( bDelCpyDoc )
    4379                 :            :         {
    4380         [ #  # ]:          0 :             if( pCpyDoc->release() == 0 )
    4381         [ #  # ]:          0 :                 delete pCpyDoc;
    4382                 :            :         }
    4383                 :            : 
    4384         [ #  # ]:          0 :         if( pUndo )
    4385                 :            :         {
    4386                 :            :             // falls die Tabelle nicht kopiert werden konnte, das Undo-Object
    4387                 :            :             // wieder loeschen
    4388                 :          0 :             GetIDocumentUndoRedo().DoUndo(bUndo);
    4389 [ #  # ][ #  # ]:          0 :             if( !bRet && pUndo->IsEmpty() )
                 [ #  # ]
    4390         [ #  # ]:          0 :                 delete pUndo;
    4391                 :            :             else
    4392                 :            :             {
    4393                 :          0 :                 GetIDocumentUndoRedo().AppendUndo(pUndo);
    4394                 :            :             }
    4395                 :            :         }
    4396                 :            : 
    4397         [ #  # ]:          0 :         if( bCorrPos )
    4398                 :            :         {
    4399                 :          0 :             rInsPos.nNode = *pSttNd;
    4400         [ #  # ]:          0 :             rInsPos.nContent.Assign( GetNodes().GoNext( &rInsPos.nNode ), 0 );
    4401                 :            :         }
    4402                 :          0 :         SetRedlineMode( eOld );
    4403                 :            :     }
    4404                 :            : 
    4405         [ #  # ]:          0 :     if( bRet )
    4406                 :            :     {
    4407                 :          0 :         SetModified();
    4408                 :          0 :         SetFieldsDirty( true, NULL, 0 );
    4409                 :            :     }
    4410                 :          0 :     return bRet;
    4411                 :            : }
    4412                 :            : 
    4413                 :            : 
    4414                 :            : 
    4415                 :          0 : sal_Bool SwDoc::_UnProtectTblCells( SwTable& rTbl )
    4416                 :            : {
    4417                 :          0 :     sal_Bool bChgd = sal_False;
    4418                 :          0 :     SwUndoAttrTbl *const pUndo = (GetIDocumentUndoRedo().DoesUndo())
    4419         [ #  # ]:          0 :         ?   new SwUndoAttrTbl( *rTbl.GetTableNode() )
    4420         [ #  # ]:          0 :         :   0;
    4421                 :            : 
    4422                 :          0 :     SwTableSortBoxes& rSrtBox = rTbl.GetTabSortBoxes();
    4423         [ #  # ]:          0 :     for( sal_uInt16 i = rSrtBox.size(); i; )
    4424                 :            :     {
    4425                 :          0 :         SwFrmFmt *pBoxFmt = rSrtBox[ --i ]->GetFrmFmt();
    4426         [ #  # ]:          0 :         if( pBoxFmt->GetProtect().IsCntntProtected() )
    4427                 :            :         {
    4428                 :          0 :             pBoxFmt->ResetFmtAttr( RES_PROTECT );
    4429                 :          0 :             bChgd = sal_True;
    4430                 :            :         }
    4431                 :            :     }
    4432                 :            : 
    4433         [ #  # ]:          0 :     if( pUndo )
    4434                 :            :     {
    4435         [ #  # ]:          0 :         if( bChgd )
    4436                 :            :         {
    4437                 :          0 :             GetIDocumentUndoRedo().AppendUndo( pUndo );
    4438                 :            :         }
    4439                 :            :         else
    4440         [ #  # ]:          0 :             delete pUndo;
    4441                 :            :     }
    4442                 :          0 :     return bChgd;
    4443                 :            : }
    4444                 :            : 
    4445                 :            : 
    4446                 :          0 : sal_Bool SwDoc::UnProtectCells( const String& rName )
    4447                 :            : {
    4448                 :          0 :     sal_Bool bChgd = sal_False;
    4449                 :          0 :     SwTableFmt* pFmt = FindTblFmtByName( rName );
    4450         [ #  # ]:          0 :     if( pFmt )
    4451                 :            :     {
    4452                 :          0 :         bChgd = _UnProtectTblCells( *SwTable::FindTable( pFmt ) );
    4453         [ #  # ]:          0 :         if( bChgd )
    4454                 :          0 :             SetModified();
    4455                 :            :     }
    4456                 :            : 
    4457                 :          0 :     return bChgd;
    4458                 :            : }
    4459                 :            : 
    4460                 :          0 : sal_Bool SwDoc::UnProtectCells( const SwSelBoxes& rBoxes )
    4461                 :            : {
    4462                 :          0 :     sal_Bool bChgd = sal_False;
    4463         [ #  # ]:          0 :     if( !rBoxes.empty() )
    4464                 :            :     {
    4465 [ #  # ][ #  # ]:          0 :         SwUndoAttrTbl *const pUndo = (GetIDocumentUndoRedo().DoesUndo())
    4466         [ #  # ]:          0 :                 ? new SwUndoAttrTbl( *rBoxes[0]->GetSttNd()->FindTableNode() )
    4467   [ #  #  #  # ]:          0 :                 : 0;
                 [ #  # ]
    4468                 :            : 
    4469 [ #  # ][ #  # ]:          0 :         std::vector<SwFrmFmt*> aFmts, aNewFmts;
    4470         [ #  # ]:          0 :         for( sal_uInt16 i = rBoxes.size(); i; )
    4471                 :            :         {
    4472                 :          0 :             SwTableBox* pBox = rBoxes[ --i ];
    4473                 :          0 :             SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
    4474 [ #  # ][ #  # ]:          0 :             if( pBoxFmt->GetProtect().IsCntntProtected() )
    4475                 :            :             {
    4476         [ #  # ]:          0 :                 std::vector<SwFrmFmt*>::iterator it = std::find( aFmts.begin(), aFmts.end(), pBoxFmt );
    4477 [ #  # ][ #  # ]:          0 :                 if( aFmts.end() != it )
    4478         [ #  # ]:          0 :                     pBox->ChgFrmFmt( (SwTableBoxFmt*)*it );
    4479                 :            :                 else
    4480                 :            :                 {
    4481         [ #  # ]:          0 :                     aFmts.push_back( pBoxFmt );
    4482         [ #  # ]:          0 :                     pBoxFmt = pBox->ClaimFrmFmt();
    4483         [ #  # ]:          0 :                     pBoxFmt->ResetFmtAttr( RES_PROTECT );
    4484         [ #  # ]:          0 :                     aNewFmts.push_back( pBoxFmt );
    4485                 :            :                 }
    4486                 :          0 :                 bChgd = sal_True;
    4487                 :            :             }
    4488                 :            :         }
    4489                 :            : 
    4490         [ #  # ]:          0 :         if( pUndo )
    4491                 :            :         {
    4492         [ #  # ]:          0 :             if( bChgd )
    4493                 :            :             {
    4494 [ #  # ][ #  # ]:          0 :                 GetIDocumentUndoRedo().AppendUndo( pUndo );
    4495                 :            :             }
    4496                 :            :             else
    4497 [ #  # ][ #  # ]:          0 :                 delete pUndo;
    4498                 :          0 :         }
    4499                 :            :     }
    4500                 :          0 :     return bChgd;
    4501                 :            : }
    4502                 :            : 
    4503                 :          0 : sal_Bool SwDoc::UnProtectTbls( const SwPaM& rPam )
    4504                 :            : {
    4505                 :          0 :     GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL);
    4506                 :            : 
    4507                 :          0 :     sal_Bool bChgd = sal_False, bHasSel = rPam.HasMark() ||
    4508 [ #  # ][ #  # ]:          0 :                                     rPam.GetNext() != (SwPaM*)&rPam;
    4509                 :          0 :     SwFrmFmts& rFmts = *GetTblFrmFmts();
    4510                 :            :     SwTable* pTbl;
    4511                 :            :     const SwTableNode* pTblNd;
    4512         [ #  # ]:          0 :     for( sal_uInt16 n = rFmts.size(); n ; )
    4513         [ #  # ]:          0 :         if( 0 != (pTbl = SwTable::FindTable( rFmts[ --n ] )) &&
           [ #  #  #  # ]
                 [ #  # ]
    4514                 :            :             0 != (pTblNd = pTbl->GetTableNode() ) &&
    4515                 :          0 :             pTblNd->GetNodes().IsDocNodes() )
    4516                 :            :         {
    4517                 :          0 :             sal_uLong nTblIdx = pTblNd->GetIndex();
    4518                 :            : 
    4519                 :            :             // dann ueberpruefe ob Tabelle in der Selection liegt
    4520         [ #  # ]:          0 :             if( bHasSel )
    4521                 :            :             {
    4522                 :          0 :                 int bFound = sal_False;
    4523                 :          0 :                 SwPaM* pTmp = (SwPaM*)&rPam;
    4524 [ #  # ][ #  # ]:          0 :                 do {
                 [ #  # ]
    4525                 :          0 :                     const SwPosition *pStt = pTmp->Start(),
    4526                 :          0 :                                     *pEnd = pTmp->End();
    4527                 :          0 :                     bFound = pStt->nNode.GetIndex() < nTblIdx &&
    4528 [ #  # ][ #  # ]:          0 :                             nTblIdx < pEnd->nNode.GetIndex();
    4529                 :            : 
    4530                 :          0 :                 } while( !bFound && &rPam != ( pTmp = (SwPaM*)pTmp->GetNext() ) );
    4531         [ #  # ]:          0 :                 if( !bFound )
    4532                 :          0 :                     continue;       // weitersuchen
    4533                 :            :             }
    4534                 :            : 
    4535                 :            :             // dann mal den Schutz aufheben
    4536                 :          0 :             bChgd |= _UnProtectTblCells( *pTbl );
    4537                 :            :         }
    4538                 :            : 
    4539                 :          0 :     GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
    4540         [ #  # ]:          0 :     if( bChgd )
    4541                 :          0 :         SetModified();
    4542                 :            : 
    4543                 :          0 :     return bChgd;
    4544                 :            : }
    4545                 :            : 
    4546                 :          0 : sal_Bool SwDoc::HasTblAnyProtection( const SwPosition* pPos,
    4547                 :            :                                  const String* pTblName,
    4548                 :            :                                  sal_Bool* pFullTblProtection )
    4549                 :            : {
    4550                 :          0 :     sal_Bool bHasProtection = sal_False;
    4551                 :          0 :     SwTable* pTbl = 0;
    4552         [ #  # ]:          0 :     if( pTblName )
    4553                 :          0 :         pTbl = SwTable::FindTable( FindTblFmtByName( *pTblName ) );
    4554         [ #  # ]:          0 :     else if( pPos )
    4555                 :            :     {
    4556                 :          0 :         SwTableNode* pTblNd = pPos->nNode.GetNode().FindTableNode();
    4557         [ #  # ]:          0 :         if( pTblNd )
    4558                 :          0 :             pTbl = &pTblNd->GetTable();
    4559                 :            :     }
    4560                 :            : 
    4561         [ #  # ]:          0 :     if( pTbl )
    4562                 :            :     {
    4563                 :          0 :         SwTableSortBoxes& rSrtBox = pTbl->GetTabSortBoxes();
    4564         [ #  # ]:          0 :         for( sal_uInt16 i = rSrtBox.size(); i; )
    4565                 :            :         {
    4566                 :          0 :             SwFrmFmt *pBoxFmt = rSrtBox[ --i ]->GetFrmFmt();
    4567         [ #  # ]:          0 :             if( pBoxFmt->GetProtect().IsCntntProtected() )
    4568                 :            :             {
    4569         [ #  # ]:          0 :                 if( !bHasProtection )
    4570                 :            :                 {
    4571                 :          0 :                     bHasProtection = sal_True;
    4572         [ #  # ]:          0 :                     if( !pFullTblProtection )
    4573                 :          0 :                         break;
    4574                 :          0 :                     *pFullTblProtection = sal_True;
    4575                 :            :                 }
    4576                 :            :             }
    4577 [ #  # ][ #  # ]:          0 :             else if( bHasProtection && pFullTblProtection )
    4578                 :            :             {
    4579                 :          0 :                 *pFullTblProtection = sal_False;
    4580                 :          0 :                 break;
    4581                 :            :             }
    4582                 :            :         }
    4583                 :            :     }
    4584                 :          0 :     return bHasProtection;
    4585                 :            : }
    4586                 :            : 
    4587                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10