LCOV - code coverage report
Current view: top level - sw/source/core/doc - gctable.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 25 211 11.8 %
Date: 2012-08-25 Functions: 4 15 26.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 17 340 5.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <hintids.hxx>
      30                 :            : #include <editeng/boxitem.hxx>
      31                 :            : #include <tblrwcl.hxx>
      32                 :            : #include <swtblfmt.hxx>
      33                 :            : #include <algorithm>
      34                 :            : #include <boost/foreach.hpp>
      35                 :            : 
      36                 :            : using namespace ::editeng;
      37                 :            : 
      38                 :          0 : inline const SvxBorderLine* GetLineTB( const SvxBoxItem* pBox, sal_Bool bTop )
      39                 :            : {
      40         [ #  # ]:          0 :     return bTop ? pBox->GetTop() : pBox->GetBottom();
      41                 :            : }
      42                 :            : 
      43                 :            : 
      44                 :          0 : sal_Bool _SwGCBorder_BoxBrd::CheckLeftBorderOfFormat( const SwFrmFmt& rFmt )
      45                 :            : {
      46                 :            :     const SvxBorderLine* pBrd;
      47                 :            :     const SfxPoolItem* pItem;
      48 [ #  # ][ #  # ]:          0 :     if( SFX_ITEM_SET == rFmt.GetItemState( RES_BOX, sal_True, &pItem ) &&
         [ #  # ][ #  # ]
      49                 :          0 :         0 != ( pBrd = ((SvxBoxItem*)pItem)->GetLeft() ) )
      50                 :            :     {
      51 [ #  # ][ #  # ]:          0 :         if( *pBrdLn == *pBrd )
      52                 :          0 :             bAnyBorderFnd = sal_True;
      53                 :          0 :         return sal_True;
      54                 :            :     }
      55                 :          0 :     return sal_False;
      56                 :            : }
      57                 :            : 
      58                 :            : 
      59                 :            : static bool lcl_GCBorder_ChkBoxBrd_B( const SwTableBox* pBox, _SwGCBorder_BoxBrd* pPara );
      60                 :            : 
      61                 :          0 : static bool lcl_GCBorder_ChkBoxBrd_L( const SwTableLine* pLine, _SwGCBorder_BoxBrd* pPara )
      62                 :            : {
      63                 :          0 :     const SwTableBox* pBox = pLine->GetTabBoxes().front();
      64                 :          0 :     return lcl_GCBorder_ChkBoxBrd_B( pBox, pPara );
      65                 :            : }
      66                 :            : 
      67                 :          0 : static bool lcl_GCBorder_ChkBoxBrd_B( const SwTableBox* pBox, _SwGCBorder_BoxBrd* pPara )
      68                 :            : {
      69                 :          0 :     bool bRet = true;
      70         [ #  # ]:          0 :     if( !pBox->GetTabLines().empty() )
      71                 :            :     {
      72 [ #  # ][ #  # ]:          0 :         for( sal_uInt16 n = 0, nLines = pBox->GetTabLines().size();
                 [ #  # ]
      73                 :            :                 n < nLines && bRet; ++n )
      74                 :            :         {
      75                 :          0 :             const SwTableLine* pLine = pBox->GetTabLines()[ n ];
      76                 :          0 :             bRet = lcl_GCBorder_ChkBoxBrd_L( pLine, pPara );
      77                 :            :         }
      78                 :            :     }
      79                 :            :     else
      80                 :            :     {
      81                 :          0 :         bRet = pPara->CheckLeftBorderOfFormat( *pBox->GetFrmFmt() );
      82                 :            :     }
      83                 :          0 :     return bRet;
      84                 :            : }
      85                 :            : 
      86                 :            : static void lcl_GCBorder_GetLastBox_B( const SwTableBox* pBox, SwTableBoxes* pPara );
      87                 :            : 
      88                 :          0 : static void lcl_GCBorder_GetLastBox_L( const SwTableLine* pLine, SwTableBoxes* pPara )
      89                 :            : {
      90                 :          0 :     const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
      91                 :          0 :     SwTableBox* pBox = rBoxes.back();
      92                 :          0 :     lcl_GCBorder_GetLastBox_B( pBox, pPara );
      93                 :          0 : }
      94                 :            : 
      95                 :          0 : static void lcl_GCBorder_GetLastBox_B( const SwTableBox* pBox, SwTableBoxes* pPara )
      96                 :            : {
      97                 :          0 :     const SwTableLines& rLines = pBox->GetTabLines();
      98         [ #  # ]:          0 :     if( !rLines.empty() )
      99 [ #  # ][ #  # ]:          0 :         BOOST_FOREACH( const SwTableLine* pLine, rLines )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     100         [ #  # ]:          0 :             lcl_GCBorder_GetLastBox_L( pLine, pPara );
     101                 :            :     else
     102         [ #  # ]:          0 :         pPara->push_back( (SwTableBox*)pBox );
     103                 :          0 : }
     104                 :            : 
     105                 :            : // Find the "end" of the passed BorderLine. Returns the "Layout"Pos!
     106                 :          0 : sal_uInt16 lcl_FindEndPosOfBorder( const SwCollectTblLineBoxes& rCollTLB,
     107                 :            :                         const SvxBorderLine& rBrdLn, sal_uInt16& rStt, sal_Bool bTop )
     108                 :            : {
     109                 :          0 :     sal_uInt16 nPos, nLastPos = 0;
     110         [ #  # ]:          0 :     for( sal_uInt16 nEnd = rCollTLB.Count(); rStt < nEnd; ++rStt )
     111                 :            :     {
     112                 :            :         const SfxPoolItem* pItem;
     113                 :            :         const SvxBorderLine* pBrd;
     114         [ #  # ]:          0 :         const SwTableBox& rBox = rCollTLB.GetBox( rStt, &nPos );
     115                 :            : 
     116 [ #  # ][ #  # ]:          0 :         if( SFX_ITEM_SET != rBox.GetFrmFmt()->GetItemState(RES_BOX,sal_True, &pItem )
         [ #  # ][ #  # ]
                 [ #  # ]
     117                 :          0 :             || 0 == ( pBrd = GetLineTB( (SvxBoxItem*)pItem, bTop ))
     118         [ #  # ]:          0 :             || !( *pBrd == rBrdLn ))
     119                 :            :             break;
     120                 :          0 :         nLastPos = nPos;
     121                 :            :     }
     122                 :          0 :     return nLastPos;
     123                 :            : }
     124                 :            : 
     125                 :          0 : inline const SvxBorderLine* lcl_GCBorder_GetBorder( const SwTableBox& rBox,
     126                 :            :                                                 sal_Bool bTop,
     127                 :            :                                                 const SfxPoolItem** ppItem )
     128                 :            : {
     129                 :          0 :     return SFX_ITEM_SET == rBox.GetFrmFmt()->GetItemState( RES_BOX, sal_True, ppItem )
     130                 :          0 :             ? GetLineTB( (SvxBoxItem*)*ppItem, bTop )
     131         [ #  # ]:          0 :             : 0;
     132                 :            : }
     133                 :            : 
     134                 :          0 : void lcl_GCBorder_DelBorder( const SwCollectTblLineBoxes& rCollTLB,
     135                 :            :                                 sal_uInt16& rStt, sal_Bool bTop,
     136                 :            :                                 const SvxBorderLine& rLine,
     137                 :            :                                 const SfxPoolItem* pItem,
     138                 :            :                                 sal_uInt16 nEndPos,
     139                 :            :                                 SwShareBoxFmts* pShareFmts )
     140                 :            : {
     141         [ #  # ]:          0 :     SwTableBox* pBox = (SwTableBox*)&rCollTLB.GetBox( rStt );
     142                 :            :     sal_uInt16 nNextPos;
     143                 :          0 :     const SvxBorderLine* pLn = &rLine;
     144                 :            : 
     145                 :          0 :     do {
     146 [ #  # ][ #  # ]:          0 :         if( pLn && *pLn == rLine )
         [ #  # ][ #  # ]
     147                 :            :         {
     148         [ #  # ]:          0 :             SvxBoxItem aBox( *(SvxBoxItem*)pItem );
     149         [ #  # ]:          0 :             if( bTop )
     150         [ #  # ]:          0 :                 aBox.SetLine( 0, BOX_LINE_TOP );
     151                 :            :             else
     152         [ #  # ]:          0 :                 aBox.SetLine( 0, BOX_LINE_BOTTOM );
     153                 :            : 
     154         [ #  # ]:          0 :             if( pShareFmts )
     155         [ #  # ]:          0 :                 pShareFmts->SetAttr( *pBox, aBox );
     156                 :            :             else
     157 [ #  # ][ #  # ]:          0 :                 pBox->ClaimFrmFmt()->SetFmtAttr( aBox );
                 [ #  # ]
     158                 :            :         }
     159                 :            : 
     160         [ #  # ]:          0 :         if( ++rStt >= rCollTLB.Count() )
     161                 :          0 :             break;
     162                 :            : 
     163         [ #  # ]:          0 :         pBox = (SwTableBox*)&rCollTLB.GetBox( rStt, &nNextPos );
     164         [ #  # ]:          0 :         if( nNextPos > nEndPos )
     165                 :          0 :             break;
     166                 :            : 
     167         [ #  # ]:          0 :         pLn = lcl_GCBorder_GetBorder( *pBox, bTop, &pItem );
     168                 :            : 
     169                 :            :     } while( sal_True );
     170                 :          0 : }
     171                 :            : 
     172                 :            : static void lcl_GC_Box_Border( const SwTableBox* pBox, _SwGCLineBorder* pPara );
     173                 :            : 
     174                 :          0 : void lcl_GC_Line_Border( const SwTableLine* pLine, _SwGCLineBorder* pGCPara )
     175                 :            : {
     176                 :            :     // First the right edge with the left edge of the succeeding Box within this Line
     177                 :            :     {
     178                 :          0 :         _SwGCBorder_BoxBrd aBPara;
     179                 :            :         const SvxBorderLine* pBrd;
     180                 :            :         const SfxPoolItem* pItem;
     181                 :          0 :         const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
     182         [ #  # ]:          0 :         for( sal_uInt16 n = 0, nBoxes = rBoxes.size() - 1; n < nBoxes; ++n )
     183                 :            :         {
     184         [ #  # ]:          0 :             SwTableBoxes aBoxes;
     185                 :            :             {
     186                 :          0 :                 SwTableBox* pBox = rBoxes[ n ];
     187         [ #  # ]:          0 :                 if( pBox->GetSttNd() )
     188         [ #  # ]:          0 :                     aBoxes.insert( aBoxes.begin(), pBox );
     189                 :            :                 else
     190         [ #  # ]:          0 :                     lcl_GCBorder_GetLastBox_B( pBox, &aBoxes );
     191                 :            :             }
     192                 :            : 
     193                 :            :             SwTableBox* pBox;
     194         [ #  # ]:          0 :             for( sal_uInt16 i = aBoxes.size(); i; )
     195 [ #  # ][ #  # ]:          0 :                 if( SFX_ITEM_SET == (pBox = aBoxes[ --i ])->GetFrmFmt()->
                 [ #  # ]
     196         [ #  # ]:          0 :                     GetItemState( RES_BOX, sal_True, &pItem ) &&
     197                 :          0 :                     0 != ( pBrd = ((SvxBoxItem*)pItem)->GetRight() ) )
     198                 :            :                 {
     199                 :          0 :                     aBPara.SetBorder( *pBrd );
     200                 :          0 :                     const SwTableBox* pNextBox = rBoxes[n+1];
     201   [ #  #  #  # ]:          0 :                     if( lcl_GCBorder_ChkBoxBrd_B( pNextBox, &aBPara ) &&
         [ #  # ][ #  # ]
     202                 :          0 :                         aBPara.IsAnyBorderFound() )
     203                 :            :                     {
     204         [ #  # ]:          0 :                         SvxBoxItem aBox( *(SvxBoxItem*)pItem );
     205         [ #  # ]:          0 :                         aBox.SetLine( 0, BOX_LINE_RIGHT );
     206         [ #  # ]:          0 :                         if( pGCPara->pShareFmts )
     207         [ #  # ]:          0 :                             pGCPara->pShareFmts->SetAttr( *pBox, aBox );
     208                 :            :                         else
     209 [ #  # ][ #  # ]:          0 :                             pBox->ClaimFrmFmt()->SetFmtAttr( aBox );
                 [ #  # ]
     210                 :            :                     }
     211                 :            :                 }
     212                 :            : 
     213                 :          0 :             aBoxes.clear();
     214                 :          0 :         }
     215                 :            :     }
     216                 :            : 
     217                 :            :     // And now the own bottom edge with the succeeding top edge
     218         [ #  # ]:          0 :     if( !pGCPara->IsLastLine() )
     219                 :            :     {
     220         [ #  # ]:          0 :         SwCollectTblLineBoxes aBottom( sal_False );
     221         [ #  # ]:          0 :         SwCollectTblLineBoxes aTop( sal_True );
     222                 :            : 
     223         [ #  # ]:          0 :         ::lcl_Line_CollectBox( pLine, &aBottom );
     224                 :            : 
     225                 :          0 :         const SwTableLine* pNextLine = (*pGCPara->pLines)[ pGCPara->nLinePos+1 ];
     226         [ #  # ]:          0 :         ::lcl_Line_CollectBox( pNextLine, &aTop );
     227                 :            : 
     228                 :            :         // remove all "duplicated" Lines that are the same
     229                 :            :         sal_uInt16 nBtmPos, nTopPos,
     230                 :          0 :                 nSttBtm = 0, nSttTop = 0,
     231                 :          0 :                 nEndBtm = aBottom.Count(), nEndTop = aTop.Count();
     232                 :            : 
     233         [ #  # ]:          0 :         const SwTableBox *pBtmBox = &aBottom.GetBox( nSttBtm++, &nBtmPos ),
     234         [ #  # ]:          0 :                          *pTopBox = &aTop.GetBox( nSttTop++, &nTopPos );
     235                 :          0 :         const SfxPoolItem *pBtmItem = 0, *pTopItem = 0;
     236                 :          0 :         const SvxBorderLine *pBtmLine(0), *pTopLine(0);
     237                 :          0 :         sal_Bool bGetTopItem = sal_True, bGetBtmItem = sal_True;
     238                 :            : 
     239                 :          0 :         do {
     240         [ #  # ]:          0 :             if( bGetBtmItem )
     241         [ #  # ]:          0 :                 pBtmLine = lcl_GCBorder_GetBorder( *pBtmBox, sal_False, &pBtmItem );
     242         [ #  # ]:          0 :             if( bGetTopItem )
     243         [ #  # ]:          0 :                 pTopLine = lcl_GCBorder_GetBorder( *pTopBox, sal_True, &pTopItem );
     244                 :            : 
     245 [ #  # ][ #  # ]:          0 :             if( pTopLine && pBtmLine && *pTopLine == *pBtmLine )
         [ #  # ][ #  # ]
                 [ #  # ]
     246                 :            :             {
     247                 :            :                 // We can remove one, but which one?
     248                 :          0 :                 sal_uInt16 nSavSttBtm = nSttBtm, nSavSttTop = nSttTop;
     249                 :            :                 sal_uInt16 nBtmEndPos = ::lcl_FindEndPosOfBorder( aBottom,
     250         [ #  # ]:          0 :                                                 *pTopLine, nSttBtm, sal_False );
     251         [ #  # ]:          0 :                 if( !nBtmEndPos ) nBtmEndPos = nBtmPos;
     252                 :            :                 sal_uInt16 nTopEndPos = ::lcl_FindEndPosOfBorder( aTop,
     253         [ #  # ]:          0 :                                                 *pTopLine, nSttTop, sal_True );
     254         [ #  # ]:          0 :                 if( !nTopEndPos ) nTopEndPos = nTopPos;
     255                 :            : 
     256                 :            : 
     257         [ #  # ]:          0 :                 if( nTopEndPos <= nBtmEndPos )
     258                 :            :                 {
     259                 :            :                     // Delete the TopBorders until BottomEndPos
     260                 :          0 :                     nSttTop = nSavSttTop;
     261         [ #  # ]:          0 :                     if( nTopPos <= nBtmEndPos )
     262                 :            :                         lcl_GCBorder_DelBorder( aTop, --nSttTop, sal_True,
     263                 :            :                                             *pBtmLine, pTopItem, nBtmEndPos,
     264         [ #  # ]:          0 :                                             pGCPara->pShareFmts );
     265                 :            :                     else
     266                 :          0 :                         nSttBtm = nSavSttBtm;
     267                 :            :                 }
     268                 :            :                 else
     269                 :            :                 {
     270                 :            :                     // Else delete the BottomBorders until TopEndPos
     271                 :          0 :                     nSttBtm = nSavSttBtm;
     272         [ #  # ]:          0 :                     if( nBtmPos <= nTopEndPos )
     273                 :            :                         lcl_GCBorder_DelBorder( aBottom, --nSttBtm, sal_False,
     274                 :            :                                             *pTopLine, pBtmItem, nTopEndPos,
     275         [ #  # ]:          0 :                                             pGCPara->pShareFmts );
     276                 :            :                     else
     277                 :          0 :                         nSttTop = nSavSttTop;
     278                 :            :                 }
     279                 :          0 :                 nTopPos = nBtmPos;
     280                 :            :             }
     281                 :            : 
     282         [ #  # ]:          0 :             if( nTopPos == nBtmPos )
     283                 :            :             {
     284 [ #  # ][ #  # ]:          0 :                 if( nSttBtm >= nEndBtm || nSttTop >= nEndTop )
     285                 :          0 :                     break;
     286                 :            : 
     287         [ #  # ]:          0 :                 pBtmBox = &aBottom.GetBox( nSttBtm++, &nBtmPos );
     288         [ #  # ]:          0 :                 pTopBox = &aTop.GetBox( nSttTop++, &nTopPos );
     289                 :          0 :                 bGetTopItem = bGetBtmItem = sal_True;
     290                 :            :             }
     291         [ #  # ]:          0 :             else if( nTopPos < nBtmPos )
     292                 :            :             {
     293         [ #  # ]:          0 :                 if( nSttTop >= nEndTop )
     294                 :          0 :                     break;
     295         [ #  # ]:          0 :                 pTopBox = &aTop.GetBox( nSttTop++, &nTopPos );
     296                 :          0 :                 bGetTopItem = sal_True;
     297                 :          0 :                 bGetBtmItem = sal_False;
     298                 :            :             }
     299                 :            :             else
     300                 :            :             {
     301         [ #  # ]:          0 :                 if( nSttBtm >= nEndBtm )
     302                 :          0 :                     break;
     303         [ #  # ]:          0 :                 pBtmBox = &aBottom.GetBox( nSttBtm++, &nBtmPos );
     304                 :          0 :                 bGetTopItem = sal_False;
     305                 :          0 :                 bGetBtmItem = sal_True;
     306                 :            :             }
     307                 :            : 
     308                 :          0 :         } while( sal_True );
     309                 :            :     }
     310                 :            : 
     311 [ #  # ][ #  # ]:          0 :     for( SwTableBoxes::const_iterator it = pLine->GetTabBoxes().begin();
     312                 :          0 :              it != pLine->GetTabBoxes().end(); ++it)
     313         [ #  # ]:          0 :         lcl_GC_Box_Border(*it, pGCPara );
     314                 :            : 
     315                 :          0 :     ++pGCPara->nLinePos;
     316                 :          0 : }
     317                 :            : 
     318                 :          0 : static void lcl_GC_Box_Border( const SwTableBox* pBox, _SwGCLineBorder* pPara )
     319                 :            : {
     320         [ #  # ]:          0 :     if( !pBox->GetTabLines().empty() )
     321                 :            :     {
     322                 :          0 :         _SwGCLineBorder aPara( *pBox );
     323                 :          0 :         aPara.pShareFmts = pPara->pShareFmts;
     324 [ #  # ][ #  # ]:          0 :         BOOST_FOREACH( const SwTableLine* pLine, pBox->GetTabLines() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     325         [ #  # ]:          0 :             lcl_GC_Line_Border( pLine, &aPara );
     326                 :            :     }
     327                 :          0 : }
     328                 :            : 
     329                 :            : struct _GCLinePara
     330                 :            : {
     331                 :            :     SwTableLines* pLns;
     332                 :            :     SwShareBoxFmts* pShareFmts;
     333                 :            : 
     334                 :        110 :     _GCLinePara( SwTableLines& rLns, _GCLinePara* pPara = 0 )
     335         [ -  + ]:        110 :         : pLns( &rLns ), pShareFmts( pPara ? pPara->pShareFmts : 0 )
     336                 :        110 :     {}
     337                 :            : };
     338                 :            : 
     339                 :            : static bool lcl_MergeGCLine(SwTableLine* pLine, _GCLinePara* pPara);
     340                 :            : 
     341                 :        979 : static bool lcl_MergeGCBox(SwTableBox* pTblBox, _GCLinePara* pPara)
     342                 :            : {
     343                 :        979 :     sal_uInt16 n, nLen = pTblBox->GetTabLines().size();
     344         [ -  + ]:        979 :     if( nLen )
     345                 :            :     {
     346                 :            :         // ATTENTION: The Line count can change!
     347                 :          0 :         _GCLinePara aPara( pTblBox->GetTabLines(), pPara );
     348 [ #  # ][ #  # ]:          0 :         for( n = 0; n < pTblBox->GetTabLines().size() &&
                 [ #  # ]
     349         [ #  # ]:          0 :             lcl_MergeGCLine( pTblBox->GetTabLines()[n], &aPara );
     350                 :            :             ++n )
     351                 :            :             ;
     352                 :            : 
     353         [ #  # ]:          0 :         if( 1 == pTblBox->GetTabLines().size() )
     354                 :            :         {
     355                 :            :             // Box with a Line, then move all the Line's Boxes after this Box
     356                 :            :             // into the parent Line and delete this Box
     357                 :          0 :             SwTableLine* pInsLine = pTblBox->GetUpper();
     358                 :          0 :             SwTableLine* pCpyLine = pTblBox->GetTabLines()[0];
     359         [ #  # ]:          0 :             SwTableBoxes::iterator it = std::find( pInsLine->GetTabBoxes().begin(), pInsLine->GetTabBoxes().end(), pTblBox );
     360         [ #  # ]:          0 :             for( n = 0; n < pCpyLine->GetTabBoxes().size(); ++n )
     361                 :          0 :                 pCpyLine->GetTabBoxes()[n]->SetUpper( pInsLine );
     362                 :            : 
     363 [ #  # ][ #  # ]:          0 :             pInsLine->GetTabBoxes().insert( it + 1, pCpyLine->GetTabBoxes().begin(), pCpyLine->GetTabBoxes().end());
     364                 :          0 :             pCpyLine->GetTabBoxes().clear();
     365                 :            :             // Delete the old Box with the Line
     366 [ #  # ][ #  # ]:          0 :             delete *it;
     367         [ #  # ]:          0 :             pInsLine->GetTabBoxes().erase( it );
     368                 :            : 
     369                 :          0 :             return false; // set up anew
     370                 :            :         }
     371                 :            :     }
     372                 :        979 :     return true;
     373                 :            : }
     374                 :            : 
     375                 :        187 : static bool lcl_MergeGCLine(SwTableLine* pLn, _GCLinePara* pGCPara)
     376                 :            : {
     377                 :        187 :     sal_uInt16 nLen = pLn->GetTabBoxes().size();
     378         [ +  - ]:        187 :     if( nLen )
     379                 :            :     {
     380         [ +  + ]:        187 :         while( 1 == nLen )
     381                 :            :         {
     382                 :            :             // We have a Box with Lines
     383                 :          9 :             SwTableBox* pBox = pLn->GetTabBoxes().front();
     384         [ -  + ]:          9 :             if( pBox->GetTabLines().empty() )
     385                 :            :                 break;
     386                 :            : 
     387                 :          0 :             SwTableLine* pLine = pBox->GetTabLines()[0];
     388                 :            : 
     389                 :            :             // pLine turns into the current Line (that is rpLine), the rest is moved
     390                 :            :             // into the LinesArray past the current one.
     391                 :            :             // The LinesArray is in pPara!
     392                 :          0 :             nLen = pBox->GetTabLines().size();
     393                 :            : 
     394                 :          0 :             SwTableLines& rLns = *pGCPara->pLns;
     395         [ #  # ]:          0 :             sal_uInt16 nInsPos = rLns.GetPos( pLn );
     396                 :            :             OSL_ENSURE( USHRT_MAX != nInsPos, "Could not find Line!" );
     397                 :            : 
     398                 :          0 :             SwTableBox* pUpper = pLn->GetUpper();
     399                 :            : 
     400 [ #  # ][ #  # ]:          0 :             rLns.erase( rLns.begin() + nInsPos );      // remove the Line from the array
     401 [ #  # ][ #  # ]:          0 :             rLns.insert( rLns.begin() + nInsPos, pBox->GetTabLines().begin(), pBox->GetTabLines().end() );
     402                 :            : 
     403                 :            :             // JP 31.03.99: Bug 60000
     404                 :            :             // Pass the attributes of the to-be-deleted Lines to the "inserted" one
     405                 :            :             const SfxPoolItem* pItem;
     406         [ #  # ]:          0 :             if( SFX_ITEM_SET == pLn->GetFrmFmt()->GetItemState(
     407         [ #  # ]:          0 :                                     RES_BACKGROUND, sal_True, &pItem ))
     408                 :            :             {
     409                 :          0 :                 SwTableLines& rBoxLns = pBox->GetTabLines();
     410         [ #  # ]:          0 :                 for( sal_uInt16 nLns = 0; nLns < nLen; ++nLns )
     411         [ #  # ]:          0 :                     if( SFX_ITEM_SET != rBoxLns[ nLns ]->GetFrmFmt()->
     412         [ #  # ]:          0 :                             GetItemState( RES_BACKGROUND, sal_True ))
     413         [ #  # ]:          0 :                         pGCPara->pShareFmts->SetAttr( *rBoxLns[ nLns ], *pItem );
     414                 :            :             }
     415                 :            : 
     416 [ #  # ][ #  # ]:          0 :             pBox->GetTabLines().erase( pBox->GetTabLines().begin(), pBox->GetTabLines().begin() + nLen );  // Remove Lines from the array
     417                 :            : 
     418 [ #  # ][ #  # ]:          0 :             delete pLn;
     419                 :            : 
     420                 :            :             // Set the dependency anew
     421         [ #  # ]:          0 :             while( nLen-- )
     422                 :          0 :                 rLns[ nInsPos++ ]->SetUpper( pUpper );
     423                 :            : 
     424                 :          0 :             pLn = pLine;                        // and set up anew
     425                 :          9 :             nLen = pLn->GetTabBoxes().size();
     426                 :            :         }
     427                 :            : 
     428                 :            :         // ATTENTION: The number of boxes can change!
     429         [ +  + ]:       1166 :         for( nLen = 0; nLen < pLn->GetTabBoxes().size(); ++nLen )
     430         [ -  + ]:        979 :             if( !lcl_MergeGCBox( pLn->GetTabBoxes()[nLen], pGCPara ))
     431                 :          0 :                 --nLen;
     432                 :            :     }
     433                 :        187 :     return true;
     434                 :            : }
     435                 :            : 
     436                 :            : // Clean structure a bit
     437                 :        110 : void SwTable::GCLines()
     438                 :            : {
     439                 :            :     // ATTENTION: The Line count can change!
     440                 :        110 :     _GCLinePara aPara( GetTabLines() );
     441         [ +  - ]:        110 :     SwShareBoxFmts aShareFmts;
     442                 :        110 :     aPara.pShareFmts = &aShareFmts;
     443 [ +  + ][ +  - ]:        407 :     for( sal_uInt16 n = 0; n < GetTabLines().size() &&
                 [ +  + ]
     444         [ +  - ]:        187 :             lcl_MergeGCLine( GetTabLines()[n], &aPara ); ++n )
     445         [ +  - ]:        110 :         ;
     446                 :        110 : }
     447                 :            : 
     448                 :            : 
     449                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10