LCOV - code coverage report
Current view: top level - sw/source/core/uibase/table - swtablerep.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 81 0.0 %
Date: 2014-04-14 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <hintids.hxx>
      21             : #include <vcl/msgbox.hxx>
      22             : #include <svl/stritem.hxx>
      23             : #include <svl/intitem.hxx>
      24             : #include <editeng/keepitem.hxx>
      25             : #include <editeng/formatbreakitem.hxx>
      26             : #include <editeng/ulspitem.hxx>
      27             : #include <editeng/frmdiritem.hxx>
      28             : #include <svl/ctloptions.hxx>
      29             : #include <swmodule.hxx>
      30             : #include <fmtornt.hxx>
      31             : #include <fmtpdsc.hxx>
      32             : #include <fmtlsplt.hxx>
      33             : 
      34             : #include <svtools/htmlcfg.hxx>
      35             : #include <fmtrowsplt.hxx>
      36             : #include <sfx2/htmlmode.hxx>
      37             : 
      38             : #include <docsh.hxx>
      39             : #include <wrtsh.hxx>
      40             : #include <view.hxx>
      41             : #include <viewopt.hxx>
      42             : #include <uitool.hxx>
      43             : #include <frmatr.hxx>
      44             : 
      45             : #include <tablepg.hxx>
      46             : #include <tablemgr.hxx>
      47             : #include <pagedesc.hxx>
      48             : #include <poolfmt.hxx>
      49             : #include <SwStyleNameMapper.hxx>
      50             : 
      51             : #include <cmdid.h>
      52             : #include <table.hrc>
      53             : #include "swtablerep.hxx"
      54             : 
      55           0 : SwTableRep::SwTableRep( const SwTabCols& rTabCol )
      56             :     :
      57             :     nTblWidth(0),
      58             :     nSpace(0),
      59             :     nLeftSpace(0),
      60             :     nRightSpace(0),
      61             :     nAlign(0),
      62             :     nWidthPercent(0),
      63             :     bLineSelected(sal_False),
      64             :     bWidthChanged(sal_False),
      65           0 :     bColsChanged(sal_False)
      66             : {
      67           0 :     nAllCols = nColCount = rTabCol.Count();
      68           0 :     pTColumns = new TColumn[ nColCount + 1 ];
      69           0 :     SwTwips nStart = 0,
      70             :             nEnd;
      71           0 :     for( sal_uInt16 i = 0; i < nAllCols; ++i )
      72             :     {
      73           0 :         nEnd  = rTabCol[ i ] - rTabCol.GetLeft();
      74           0 :         pTColumns[ i ].nWidth = nEnd - nStart;
      75           0 :         pTColumns[ i ].bVisible = !rTabCol.IsHidden(i);
      76           0 :         if(!pTColumns[ i ].bVisible)
      77           0 :             nColCount --;
      78           0 :         nStart = nEnd;
      79             :     }
      80           0 :     pTColumns[ nAllCols ].nWidth = rTabCol.GetRight() - rTabCol.GetLeft() - nStart;
      81           0 :     pTColumns[ nAllCols ].bVisible = sal_True;
      82           0 :     nColCount++;
      83           0 :     nAllCols++;
      84           0 : }
      85             : 
      86           0 : SwTableRep::~SwTableRep()
      87             : {
      88           0 :     delete[] pTColumns;
      89           0 : }
      90             : 
      91           0 : sal_Bool SwTableRep::FillTabCols( SwTabCols& rTabCols ) const
      92             : {
      93           0 :     long nOldLeft = rTabCols.GetLeft(),
      94           0 :          nOldRight = rTabCols.GetRight();
      95             : 
      96           0 :     sal_Bool bSingleLine = sal_False;
      97             : 
      98           0 :     for ( size_t i = 0; i < rTabCols.Count(); ++i )
      99           0 :         if(!pTColumns[i].bVisible)
     100             :         {
     101           0 :             bSingleLine = sal_True;
     102           0 :             break;
     103             :         }
     104             : 
     105             :     sal_uInt16 i;
     106           0 :     SwTwips nPos = 0;
     107           0 :     SwTwips nLeft = GetLeftSpace();
     108           0 :     rTabCols.SetLeft(nLeft);
     109           0 :     if(bSingleLine)
     110             :     {
     111             :         // The invisible separators are taken from the old TabCols,
     112             :         // the visible coming from pTColumns.
     113           0 :         TColumn*    pOldTColumns = new TColumn[nAllCols + 1];
     114           0 :         SwTwips nStart = 0,
     115             :                 nEnd;
     116           0 :         for(i = 0; i < nAllCols - 1; i++)
     117             :         {
     118           0 :             nEnd  = rTabCols[i] - rTabCols.GetLeft();
     119           0 :             pOldTColumns[i].nWidth = nEnd - nStart;
     120           0 :             pOldTColumns[i].bVisible = !rTabCols.IsHidden(i);
     121           0 :             nStart = nEnd;
     122             :         }
     123           0 :         pOldTColumns[nAllCols - 1].nWidth = rTabCols.GetRight() - rTabCols.GetLeft() - nStart;
     124           0 :         pOldTColumns[nAllCols - 1].bVisible = sal_True;
     125             : 
     126           0 :         sal_uInt16 nOldPos = 0;
     127           0 :         sal_uInt16 nNewPos = 0;
     128           0 :         SwTwips nOld = 0;
     129           0 :         SwTwips nNew = 0;
     130           0 :         sal_Bool bOld = sal_False;
     131           0 :         bool bFirst = true;
     132           0 :         i = 0;
     133             : 
     134           0 :         while ( i < nAllCols -1 )
     135             :         {
     136           0 :             while((bFirst || bOld ) && nOldPos < nAllCols )
     137             :             {
     138           0 :                 nOld += pOldTColumns[nOldPos].nWidth;
     139           0 :                 nOldPos++;
     140           0 :                 if(!pOldTColumns[nOldPos - 1].bVisible)
     141           0 :                     break;
     142             :             }
     143           0 :             while((bFirst || !bOld ) && nNewPos < nAllCols )
     144             :             {
     145           0 :                 nNew += pTColumns[nNewPos].nWidth;
     146           0 :                 nNewPos++;
     147           0 :                 if(pOldTColumns[nNewPos - 1].bVisible)
     148           0 :                     break;
     149             :             }
     150           0 :             bFirst = false;
     151             :             // They have to be inserted sorted.
     152           0 :             bOld = nOld < nNew;
     153           0 :             nPos = sal_uInt16(bOld ? nOld : nNew);
     154           0 :             rTabCols[i] = nPos + nLeft;
     155           0 :             rTabCols.SetHidden( i, bOld );
     156           0 :             i++;
     157             :         }
     158           0 :         rTabCols.SetRight(nLeft + nTblWidth);
     159             : 
     160           0 :         delete[] pOldTColumns;
     161             :     }
     162             :     else
     163             :     {
     164           0 :         for ( i = 0; i < nAllCols - 1; ++i )
     165             :         {
     166           0 :             nPos += pTColumns[i].nWidth;
     167           0 :             rTabCols[i] = nPos + rTabCols.GetLeft();
     168           0 :             rTabCols.SetHidden( i, !pTColumns[i].bVisible );
     169           0 :             rTabCols.SetRight(nLeft + pTColumns[nAllCols - 1].nWidth + nPos);
     170             :         }
     171             :     }
     172             : 
     173             :     // intercept rounding errors
     174           0 :     if(std::abs(nOldLeft - rTabCols.GetLeft()) < 3)
     175           0 :         rTabCols.SetLeft(nOldLeft);
     176             : 
     177           0 :     if(std::abs(nOldRight - rTabCols.GetRight()) < 3)
     178           0 :         rTabCols.SetRight(nOldRight);
     179             : 
     180           0 :     if(GetRightSpace() >= 0 &&
     181           0 :             rTabCols.GetRight() > rTabCols.GetRightMax())
     182           0 :         rTabCols.SetRight(rTabCols.GetRightMax());
     183           0 :     return bSingleLine;
     184           0 : }
     185             : 
     186             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10