LCOV - code coverage report
Current view: top level - sw/source/core/layout - colfrm.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 163 203 80.3 %
Date: 2012-08-25 Functions: 7 8 87.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 185 306 60.5 %

           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 <hintids.hxx>
      31                 :            : #include "cntfrm.hxx"
      32                 :            : #include "doc.hxx"
      33                 :            : 
      34                 :            : #include "hintids.hxx"
      35                 :            : #include <editeng/ulspitem.hxx>
      36                 :            : #include <editeng/lrspitem.hxx>
      37                 :            : #include <fmtclds.hxx>
      38                 :            : #include <fmtfordr.hxx>
      39                 :            : #include <frmfmt.hxx>
      40                 :            : #include <node.hxx>
      41                 :            : #include "frmtool.hxx"
      42                 :            : #include "colfrm.hxx"
      43                 :            : #include "pagefrm.hxx"
      44                 :            : #include "bodyfrm.hxx"   // ColumnFrms now with BodyFrm
      45                 :            : #include "rootfrm.hxx"   // wg. RemoveFtns
      46                 :            : #include "sectfrm.hxx"   // wg. FtnAtEnd-Flag
      47                 :            : #include "switerator.hxx"
      48                 :            : 
      49                 :            : // ftnfrm.cxx:
      50                 :            : void lcl_RemoveFtns( SwFtnBossFrm* pBoss, sal_Bool bPageOnly, sal_Bool bEndNotes );
      51                 :            : 
      52                 :            : 
      53                 :            : /*************************************************************************
      54                 :            : |*
      55                 :            : |*  SwColumnFrm::SwColumnFrm()
      56                 :            : |*
      57                 :            : |*************************************************************************/
      58                 :        124 : SwColumnFrm::SwColumnFrm( SwFrmFmt *pFmt, SwFrm* pSib ):
      59                 :        124 :     SwFtnBossFrm( pFmt, pSib )
      60                 :            : {
      61                 :        124 :     nType = FRMC_COLUMN;
      62 [ +  - ][ +  - ]:        124 :     SwBodyFrm* pColBody = new SwBodyFrm( pFmt->GetDoc()->GetDfltFrmFmt(), pSib );
      63         [ +  - ]:        124 :     pColBody->InsertBehind( this, 0 ); // ColumnFrms now with BodyFrm
      64                 :        124 :     SetMaxFtnHeight( LONG_MAX );
      65                 :        124 : }
      66                 :            : 
      67                 :        124 : SwColumnFrm::~SwColumnFrm()
      68                 :            : {
      69         [ +  - ]:        124 :     SwFrmFmt *pFmt = GetFmt();
      70                 :            :     SwDoc *pDoc;
      71 [ +  - ][ +  + ]:        124 :     if ( !(pDoc = pFmt->GetDoc())->IsInDtor() && pFmt->IsLastDepend() )
                 [ +  + ]
      72                 :            :     {
      73                 :            :         //I'm the only one, delete the format.
      74                 :            :         //Get default format before, so the base class can cope with it.
      75         [ +  - ]:         42 :         pDoc->GetDfltFrmFmt()->Add( this );
      76         [ +  - ]:         42 :         pDoc->DelFrmFmt( pFmt );
      77                 :            :     }
      78         [ -  + ]:        248 : }
      79                 :            : 
      80                 :            : /*************************************************************************
      81                 :            : |*
      82                 :            : |*  SwLayoutFrm::ChgColumns()
      83                 :            : |*
      84                 :            : |*************************************************************************/
      85                 :            : 
      86                 :          0 : void lcl_RemoveColumns( SwLayoutFrm *pCont, sal_uInt16 nCnt )
      87                 :            : {
      88                 :            :     OSL_ENSURE( pCont && pCont->Lower() && pCont->Lower()->IsColumnFrm(),
      89                 :            :             "Keine Spalten zu entfernen." );
      90                 :            : 
      91                 :          0 :     SwColumnFrm *pColumn = (SwColumnFrm*)pCont->Lower();
      92                 :          0 :     ::lcl_RemoveFtns( pColumn, sal_True, sal_True );
      93         [ #  # ]:          0 :     while ( pColumn->GetNext() )
      94                 :            :     {
      95                 :            :         OSL_ENSURE( pColumn->GetNext()->IsColumnFrm(),
      96                 :            :                 "Nachbar von ColFrm kein ColFrm." );
      97                 :          0 :         pColumn = (SwColumnFrm*)pColumn->GetNext();
      98                 :            :     }
      99         [ #  # ]:          0 :     for ( sal_uInt16 i = 0; i < nCnt; ++i )
     100                 :            :     {
     101                 :          0 :         SwColumnFrm *pTmp = (SwColumnFrm*)pColumn->GetPrev();
     102                 :          0 :         pColumn->Cut();
     103         [ #  # ]:          0 :         delete pColumn; //format is going to be destroyed in the DTor if needed.
     104                 :          0 :         pColumn = pTmp;
     105                 :            :     }
     106                 :          0 : }
     107                 :            : 
     108                 :         80 : SwLayoutFrm * lcl_FindColumns( SwLayoutFrm *pLay, sal_uInt16 nCount )
     109                 :            : {
     110                 :         80 :     SwFrm *pCol = pLay->Lower();
     111         [ +  + ]:         80 :     if ( pLay->IsPageFrm() )
     112                 :          6 :         pCol = ((SwPageFrm*)pLay)->FindBodyCont()->Lower();
     113                 :            : 
     114 [ +  + ][ +  + ]:         80 :     if ( pCol && pCol->IsColumnFrm() )
                 [ +  + ]
     115                 :            :     {
     116                 :         30 :         SwFrm *pTmp = pCol;
     117                 :            :         sal_uInt16 i;
     118         [ +  + ]:        112 :         for ( i = 0; pTmp; pTmp = pTmp->GetNext(), ++i )
     119                 :            :             /* do nothing */;
     120         [ +  - ]:         30 :         return i == nCount ? (SwLayoutFrm*)pCol : 0;
     121                 :            :     }
     122                 :         80 :     return 0;
     123                 :            : }
     124                 :            : 
     125                 :            : 
     126                 :         50 : static sal_Bool lcl_AddColumns( SwLayoutFrm *pCont, sal_uInt16 nCount )
     127                 :            : {
     128         [ +  - ]:         50 :     SwDoc *pDoc = pCont->GetFmt()->GetDoc();
     129         [ +  - ]:         50 :     const sal_Bool bMod = pDoc->IsModified();
     130                 :            : 
     131                 :            :     //Formats should be shared whenever possible. If a neighbour already has
     132                 :            :     //the same column settings we can add them to the same format.
     133                 :            :     //The neighbour can be searched using the format, however the owner of the
     134                 :            :     //attribute depends on the frame type.
     135                 :         50 :     SwLayoutFrm *pAttrOwner = pCont;
     136         [ +  + ]:         50 :     if ( pCont->IsBodyFrm() )
     137         [ +  - ]:          6 :         pAttrOwner = pCont->FindPageFrm();
     138                 :         50 :     SwLayoutFrm *pNeighbourCol = 0;
     139 [ +  - ][ +  - ]:         50 :     SwIterator<SwLayoutFrm,SwFmt> aIter( *pAttrOwner->GetFmt() );
     140         [ +  - ]:         50 :     SwLayoutFrm *pNeighbour = aIter.First();
     141                 :            : 
     142                 :         50 :     sal_uInt16 nAdd = 0;
     143                 :         50 :     SwFrm *pCol = pCont->Lower();
     144 [ #  # ][ -  + ]:         50 :     if ( pCol && pCol->IsColumnFrm() )
                 [ -  + ]
     145         [ #  # ]:          0 :         for ( nAdd = 1; pCol; pCol = pCol->GetNext(), ++nAdd )
     146                 :            :             /* do nothing */;
     147         [ +  + ]:        100 :     while ( pNeighbour )
     148                 :            :     {
     149 [ +  - ][ +  + ]:         80 :         if ( 0 != (pNeighbourCol = lcl_FindColumns( pNeighbour, nCount+nAdd )) &&
         [ +  - ][ +  + ]
     150                 :            :              pNeighbourCol != pCont )
     151                 :         30 :             break;
     152                 :         50 :         pNeighbourCol = 0;
     153         [ +  - ]:         50 :         pNeighbour = aIter.Next();
     154                 :            :     }
     155                 :            : 
     156                 :            :     sal_Bool bRet;
     157                 :         50 :     SwTwips nMax = pCont->IsPageBodyFrm() ?
     158 [ +  - ][ +  + ]:         50 :                    pCont->FindPageFrm()->GetMaxFtnHeight() : LONG_MAX;
     159         [ +  + ]:         50 :     if ( pNeighbourCol )
     160                 :            :     {
     161                 :         30 :         bRet = sal_False;
     162                 :         30 :         SwFrm *pTmp = pCont->Lower();
     163         [ -  + ]:         30 :         while ( pTmp )
     164                 :            :         {
     165                 :          0 :             pTmp = pTmp->GetNext();
     166                 :          0 :             pNeighbourCol = (SwLayoutFrm*)pNeighbourCol->GetNext();
     167                 :            :         }
     168         [ +  + ]:        112 :         for ( sal_uInt16 i = 0; i < nCount; ++i )
     169                 :            :         {
     170 [ +  - ][ +  - ]:         82 :             SwColumnFrm *pTmpCol = new SwColumnFrm( pNeighbourCol->GetFmt(), pCont );
                 [ +  - ]
     171                 :         82 :             pTmpCol->SetMaxFtnHeight( nMax );
     172         [ +  - ]:         82 :             pTmpCol->InsertBefore( pCont, NULL );
     173                 :         82 :             pNeighbourCol = (SwLayoutFrm*)pNeighbourCol->GetNext();
     174                 :            :         }
     175                 :            :     }
     176                 :            :     else
     177                 :            :     {
     178                 :         20 :         bRet = sal_True;
     179         [ +  + ]:         62 :         for ( sal_uInt16 i = 0; i < nCount; ++i )
     180                 :            :         {
     181         [ +  - ]:         42 :             SwFrmFmt *pFmt = pDoc->MakeFrmFmt( aEmptyStr, pDoc->GetDfltFrmFmt());
     182 [ +  - ][ +  - ]:         42 :             SwColumnFrm *pTmp = new SwColumnFrm( pFmt, pCont );
     183                 :         42 :             pTmp->SetMaxFtnHeight( nMax );
     184         [ +  - ]:         42 :             pTmp->Paste( pCont );
     185                 :            :         }
     186                 :            :     }
     187                 :            : 
     188         [ +  + ]:         50 :     if ( !bMod )
     189         [ +  - ]:         12 :         pDoc->ResetModified();
     190         [ +  - ]:         50 :     return bRet;
     191                 :            : }
     192                 :            : 
     193                 :            : /*--------------------------------------------------
     194                 :            :  * ChgColumns() adds or removes columns from a layoutframe.
     195                 :            :  * Normally, a layoutframe with a column attribut of 1 or 0 columns contains
     196                 :            :  * no columnframe. However, a sectionframe with "footnotes at the end" needs
     197                 :            :  * a columnframe. If the bChgFtn-flag is set, the columnframe will be inserted
     198                 :            :  * or remove, if necessary.
     199                 :            :  * --------------------------------------------------*/
     200                 :            : 
     201                 :         80 : void SwLayoutFrm::ChgColumns( const SwFmtCol &rOld, const SwFmtCol &rNew,
     202                 :            :     const sal_Bool bChgFtn )
     203                 :            : {
     204 [ +  - ][ +  + ]:         80 :     if ( rOld.GetNumCols() <= 1 && rNew.GetNumCols() <= 1 && !bChgFtn )
         [ +  + ][ +  + ]
     205                 :         14 :         return;
     206                 :            :     // #i97379#
     207                 :            :     // If current lower is a no text frame, then columns are not allowed
     208         [ +  + ]:         66 :     if ( Lower() && Lower()->IsNoTxtFrm() &&
           [ -  +  #  # ]
                 [ -  + ]
     209                 :          0 :          rNew.GetNumCols() > 1 )
     210                 :            :     {
     211                 :          0 :         return;
     212                 :            :     }
     213                 :            : 
     214                 :         66 :     sal_uInt16 nNewNum, nOldNum = 1;
     215 [ +  + ][ +  + ]:         66 :     if( Lower() && Lower()->IsColumnFrm() )
                 [ +  + ]
     216                 :            :     {
     217                 :         16 :         SwFrm* pCol = Lower();
     218         [ -  + ]:         16 :         while( 0 != (pCol=pCol->GetNext()) )
     219                 :          0 :             ++nOldNum;
     220                 :            :     }
     221                 :         66 :     nNewNum = rNew.GetNumCols();
     222         [ +  + ]:         66 :     if( !nNewNum )
     223                 :         24 :         ++nNewNum;
     224                 :            :     sal_Bool bAtEnd;
     225         [ +  + ]:         66 :     if( IsSctFrm() )
     226                 :         60 :         bAtEnd = ((SwSectionFrm*)this)->IsAnyNoteAtEnd();
     227                 :            :     else
     228                 :          6 :         bAtEnd = sal_False;
     229                 :            : 
     230                 :            :     //Setting the column width is only needed for new formats.
     231                 :         66 :     sal_Bool bAdjustAttributes = nOldNum != rOld.GetNumCols();
     232                 :            : 
     233                 :            :     //The content is saved and restored if the column count is different.
     234                 :         66 :     SwFrm *pSave = 0;
     235 [ +  - ][ +  + ]:         66 :     if( nOldNum != nNewNum || bChgFtn )
     236                 :            :     {
     237                 :         66 :         SwDoc *pDoc = GetFmt()->GetDoc();
     238                 :            :         OSL_ENSURE( pDoc, "FrmFmt doesn't return a document." );
     239                 :            :         // SaveCntnt would also suck up the content of the footnote container
     240                 :            :         // and store it within the normal text flow.
     241         [ +  + ]:         66 :         if( IsPageBodyFrm() )
     242                 :          6 :             pDoc->GetCurrentLayout()->RemoveFtns( (SwPageFrm*)GetUpper(), sal_True, sal_False );    //swmod 080218
     243                 :         66 :         pSave = ::SaveCntnt( this );
     244                 :            : 
     245                 :            :         //If columns exist, they get deleted if a column count of 0 or 1 is requested.
     246 [ -  + ][ +  + ]:         66 :         if ( nNewNum == 1 && !bAtEnd )
     247                 :            :         {
     248                 :          0 :             ::lcl_RemoveColumns( this, nOldNum );
     249         [ #  # ]:          0 :             if ( IsBodyFrm() )
     250                 :          0 :                 SetFrmFmt( pDoc->GetDfltFrmFmt() );
     251                 :            :             else
     252         [ #  # ]:          0 :                 GetFmt()->SetFmtAttr( SwFmtFillOrder() );
     253         [ #  # ]:          0 :             if ( pSave )
     254                 :          0 :                 ::RestoreCntnt( pSave, this, 0, true );
     255                 :          0 :             return;
     256                 :            :         }
     257         [ +  - ]:         66 :         if ( nOldNum == 1 )
     258                 :            :         {
     259         [ +  + ]:         66 :             if ( IsBodyFrm() )
     260                 :          6 :                 SetFrmFmt( pDoc->GetColumnContFmt() );
     261                 :            :             else
     262         [ +  - ]:         60 :                 GetFmt()->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ) );
     263 [ +  + ][ -  + ]:         66 :             if( !Lower() || !Lower()->IsColumnFrm() )
                 [ +  + ]
     264                 :         50 :                 --nOldNum;
     265                 :            :         }
     266         [ -  + ]:         66 :         if ( nOldNum > nNewNum )
     267                 :            :         {
     268                 :          0 :             ::lcl_RemoveColumns( this, nOldNum - nNewNum );
     269                 :          0 :             bAdjustAttributes = sal_True;
     270                 :            :         }
     271         [ +  + ]:         66 :         else if( nOldNum < nNewNum )
     272                 :            :         {
     273                 :         50 :             sal_uInt16 nAdd = nNewNum - nOldNum;
     274                 :         50 :             bAdjustAttributes = lcl_AddColumns( this, nAdd );
     275                 :            :         }
     276                 :            :     }
     277                 :            : 
     278         [ +  + ]:         66 :     if ( !bAdjustAttributes )
     279                 :            :     {
     280   [ +  -  +  -  :         90 :         if ( rOld.GetLineWidth()    != rNew.GetLineWidth() ||
           -  + ][ -  + ]
     281                 :         30 :              rOld.GetWishWidth()    != rNew.GetWishWidth() ||
     282                 :         30 :              rOld.IsOrtho()         != rNew.IsOrtho() )
     283                 :          0 :             bAdjustAttributes = sal_True;
     284                 :            :         else
     285                 :            :         {
     286                 :         30 :             sal_uInt16 nCount = Min( rNew.GetColumns().size(), rOld.GetColumns().size() );
     287         [ -  + ]:         30 :             for ( sal_uInt16 i = 0; i < nCount; ++i )
     288         [ #  # ]:          0 :                 if ( !(rOld.GetColumns()[i] == rNew.GetColumns()[i]) )
     289                 :            :                 {
     290                 :          0 :                     bAdjustAttributes = sal_True;
     291                 :          0 :                     break;
     292                 :            :                 }
     293                 :            :         }
     294                 :            :     }
     295                 :            : 
     296                 :            :     //The columns can now be easily adjusted.
     297                 :         66 :     AdjustColumns( &rNew, bAdjustAttributes );
     298                 :            : 
     299                 :            :     //Don't restore the content before. An earlier restore would trigger useless
     300                 :            :     //actions during setup.
     301         [ +  + ]:         66 :     if ( pSave )
     302                 :            :     {
     303                 :            :         OSL_ENSURE( Lower() && Lower()->IsLayoutFrm() &&
     304                 :            :                 ((SwLayoutFrm*)Lower())->Lower() &&
     305                 :            :                 ((SwLayoutFrm*)Lower())->Lower()->IsLayoutFrm(),
     306                 :            :                 "Gesucht: Spaltenbody (Tod oder Lebend)." );   // ColumnFrms jetzt mit BodyFrm
     307                 :         80 :         ::RestoreCntnt( pSave, (SwLayoutFrm*)((SwLayoutFrm*)Lower())->Lower(), 0, true );
     308                 :            :     }
     309                 :            : }
     310                 :            : 
     311                 :            : /*************************************************************************
     312                 :            : |*
     313                 :            : |*  SwLayoutFrm::AdjustColumns()
     314                 :            : |*
     315                 :            : |*************************************************************************/
     316                 :            : 
     317                 :        168 : void SwLayoutFrm::AdjustColumns( const SwFmtCol *pAttr, sal_Bool bAdjustAttributes )
     318                 :            : {
     319         [ +  + ]:        168 :     if( !Lower()->GetNext() )
     320                 :            :     {
     321                 :         24 :         Lower()->ChgSize( Prt().SSize() );
     322                 :         24 :         return;
     323                 :            :     }
     324                 :            : 
     325                 :        144 :     const sal_Bool bVert = IsVertical();
     326                 :            :     //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
     327 [ #  # ][ -  + ]:        144 :     SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
     328                 :            : 
     329                 :            :     //If we have a pointer or we have to configure an attribute, we set the
     330                 :            :     //column widths in any case. Otherwise we check if a configuration is needed.
     331         [ +  + ]:        144 :     if ( !pAttr )
     332                 :            :     {
     333                 :          6 :         pAttr = &GetFmt()->GetCol();
     334         [ +  - ]:          6 :         if ( !bAdjustAttributes )
     335                 :            :         {
     336         [ +  - ]:          6 :             long nAvail = (Prt().*fnRect->fnGetWidth)();
     337         [ +  + ]:         22 :             for ( SwLayoutFrm *pCol = (SwLayoutFrm*)Lower();
     338                 :            :                   pCol;
     339                 :         16 :                   pCol = (SwLayoutFrm*)pCol->GetNext() )
     340         [ +  - ]:         16 :                 nAvail -= (pCol->Frm().*fnRect->fnGetWidth)();
     341         [ +  - ]:          6 :             if ( !nAvail )
     342                 :          6 :                 return;
     343                 :            :         }
     344                 :            :     }
     345                 :            : 
     346                 :            :     //The columns can now be easily adjusted.
     347                 :            :     //The widths get counted so we can give the reminder to the last one.
     348         [ +  - ]:        138 :     SwTwips nAvail = (Prt().*fnRect->fnGetWidth)();
     349                 :        138 :     const sal_Bool bLine = pAttr->GetLineAdj() != COLADJ_NONE;
     350         [ -  + ]:        138 :     const sal_uInt16 nMin = bLine ? sal_uInt16( 20 + ( pAttr->GetLineWidth() / 2) ) : 0;
     351                 :            : 
     352                 :            :     // #i27399#
     353                 :            :     // bOrtho means we have to adjust the column frames manually. Otherwise
     354                 :            :     // we may use the values returned by CalcColWidth:
     355 [ +  + ][ +  - ]:        138 :     const sal_Bool bOrtho = pAttr->IsOrtho() && pAttr->GetNumCols() > 0;
     356                 :        138 :     long nGutter = 0;
     357                 :        138 :     sal_uInt16 real_nb_col = 0;
     358                 :            : 
     359                 :        138 :     SwFrm* pColHead = Lower();;
     360                 :            :     SwFrm* pColTail;
     361         [ +  + ]:        546 :     for ( pColTail = pColHead; pColTail; pColTail = pColTail->GetNext(), real_nb_col += 1 );
     362                 :            : 
     363         [ -  + ]:        138 :     sal_uInt16 i = IsRightToLeft() ? real_nb_col : 0;
     364                 :            : 
     365 [ -  + ][ -  + ]:        954 :     for ( SwFrm* pColCursor = IsRightToLeft() ? pColTail : pColHead;
         [ -  + ][ +  + ]
     366                 :            :           pColCursor;
     367                 :        816 :           (pColCursor = IsRightToLeft() ? pColCursor->GetPrev() : pColCursor->GetNext()), (i += IsRightToLeft() ? -1 : +1) )
     368                 :            :     {
     369         [ +  + ]:        408 :         if( !bOrtho )
     370                 :            :         {
     371         [ +  - ]:         12 :             const SwTwips nWidth = (pColCursor == (IsRightToLeft() ? pColTail : pColHead) ) ?
     372                 :            :                                    nAvail :
     373 [ -  + ][ +  + ]:         12 :                                    pAttr->CalcColWidth( i, sal_uInt16( (Prt().*fnRect->fnGetWidth)() ) );
         [ +  - ][ +  - ]
                 [ +  - ]
     374                 :            : 
     375                 :            :             const Size aColSz = bVert ?
     376                 :          0 :                                 Size( Prt().Width(), nWidth ) :
     377         [ -  + ]:         12 :                                 Size( nWidth, Prt().Height() );
     378                 :            : 
     379         [ +  - ]:         12 :             pColCursor->ChgSize( aColSz );
     380                 :            : 
     381                 :            :             // With this, the ColumnBodyFrms from page columns gets adjusted and
     382                 :            :             // their bFixHeight flag is set so they won't shrink/grow.
     383                 :            :             // Don't use the flag with frame columns because BodyFrms in frame
     384                 :            :             // columns can grow/shrink.
     385         [ +  - ]:         12 :             if( IsBodyFrm() )
     386         [ +  - ]:         12 :                 ((SwLayoutFrm*)pColCursor)->Lower()->ChgSize( aColSz );
     387                 :            : 
     388                 :         12 :             nAvail -= nWidth;
     389                 :            :         }
     390                 :            : 
     391 [ +  + ][ +  - ]:        408 :         if ( bOrtho || bAdjustAttributes )
     392                 :            :         {
     393         [ +  - ]:        408 :             const SwColumn *pC = &pAttr->GetColumns()[i];
     394         [ +  - ]:        408 :             const SwAttrSet* pSet = pColCursor->GetAttrSet();
     395 [ +  - ][ +  - ]:        408 :             SvxLRSpaceItem aLR( pSet->GetLRSpace() );
     396                 :            : 
     397                 :            :             //In order to have enough space for the separation lines, we have to
     398                 :            :             //take them into account here. Every time two columns meet we
     399                 :            :             //calculate a clearance of 20 + half the pen width on the left or
     400                 :            :             //right side, respectively.
     401                 :        408 :             const sal_uInt16 nLeft = pC->GetLeft();
     402                 :        408 :             const sal_uInt16 nRight = pC->GetRight();
     403                 :            : 
     404                 :        408 :             aLR.SetLeft ( nLeft );
     405                 :        408 :             aLR.SetRight( nRight );
     406                 :            : 
     407         [ -  + ]:        408 :             if ( bLine )
     408                 :            :             {
     409         [ #  # ]:          0 :                 if ( i == 0 )
     410                 :            :                 {
     411                 :          0 :                     aLR.SetRight( Max( nRight, nMin ) );
     412                 :            :                 }
     413 [ #  # ][ #  # ]:          0 :                 else if ( i == pAttr->GetNumCols() - 1 )
     414                 :            :                 {
     415                 :          0 :                     aLR.SetLeft ( Max( nLeft, nMin ) );
     416                 :            :                 }
     417                 :            :                 else
     418                 :            :                 {
     419                 :          0 :                     aLR.SetLeft ( Max( nLeft,  nMin ) );
     420                 :          0 :                     aLR.SetRight( Max( nRight, nMin ) );
     421                 :            :                 }
     422                 :            :             }
     423                 :            : 
     424         [ +  + ]:        408 :             if ( bAdjustAttributes )
     425                 :            :             {
     426 [ +  - ][ +  - ]:         36 :                 SvxULSpaceItem aUL( pSet->GetULSpace() );
     427                 :         36 :                 aUL.SetUpper( pC->GetUpper());
     428                 :         36 :                 aUL.SetLower( pC->GetLower());
     429                 :            : 
     430 [ +  - ][ +  - ]:         36 :                 ((SwLayoutFrm*)pColCursor)->GetFmt()->SetFmtAttr( aLR );
     431 [ +  - ][ +  - ]:         36 :                 ((SwLayoutFrm*)pColCursor)->GetFmt()->SetFmtAttr( aUL );
                 [ +  - ]
     432                 :            :             }
     433                 :            : 
     434         [ +  - ]:        408 :             nGutter += aLR.GetLeft() + aLR.GetRight();
     435                 :            :         }
     436                 :            :     }
     437                 :            : 
     438         [ +  + ]:        138 :     if( bOrtho )
     439                 :            :     {
     440                 :        132 :         long nInnerWidth = ( nAvail - nGutter ) / pAttr->GetNumCols();
     441                 :        132 :         i = 0;
     442         [ +  + ]:        564 :         for (SwFrm* pColCursor =  pColHead; pColCursor; pColCursor = pColCursor->GetNext(), i++)
     443                 :            :         {
     444                 :            :             SwTwips nWidth;
     445 [ +  - ][ +  + ]:        396 :             if ( i == pAttr->GetNumCols() - 1 )
     446                 :            :             {
     447                 :        132 :                 nWidth = nAvail;
     448                 :            :             }
     449                 :            :             else
     450                 :            :             {
     451 [ +  - ][ +  - ]:        264 :                 SvxLRSpaceItem aLR( pColCursor->GetAttrSet()->GetLRSpace() );
                 [ +  - ]
     452         [ +  - ]:        264 :                 nWidth = nInnerWidth + aLR.GetLeft() + aLR.GetRight();
     453                 :            :             }
     454         [ -  + ]:        396 :             if( nWidth < 0 )
     455                 :            :             {
     456                 :          0 :                 nWidth = 0;
     457                 :            :             }
     458                 :            :             const Size aColSz = bVert ?
     459                 :          0 :                                 Size( Prt().Width(), nWidth ) :
     460         [ -  + ]:        396 :                                 Size( nWidth, Prt().Height() );
     461                 :            : 
     462         [ +  - ]:        396 :             pColCursor->ChgSize( aColSz );
     463                 :            : 
     464         [ -  + ]:        396 :             if( IsBodyFrm() )
     465                 :            :             {
     466         [ #  # ]:          0 :                 ((SwLayoutFrm*)pColCursor)->Lower()->ChgSize( aColSz );
     467                 :            :             }
     468                 :        396 :             nAvail -= nWidth;
     469                 :            :         }
     470                 :            :     }
     471                 :            : }
     472                 :            : 
     473                 :            : 
     474                 :            : 
     475                 :            : 
     476                 :            : 
     477                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10