LCOV - code coverage report
Current view: top level - libreoffice/sw/source/filter/ww8 - WW8TableInfo.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 253 594 42.6 %
Date: 2012-12-27 Functions: 56 100 56.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             : 
      21             : #include <iostream>
      22             : #include <set>
      23             : #include <stdio.h>
      24             : #include "WW8TableInfo.hxx"
      25             : #include "fmtfsize.hxx"
      26             : #include "attributeoutputbase.hxx"
      27             : #include "swtable.hxx"
      28             : #include "frmfmt.hxx"
      29             : #include "pam.hxx"
      30             : #include "ndtxt.hxx"
      31             : #include "dbgoutsw.hxx"
      32             : 
      33             : namespace ww8
      34             : {
      35             : 
      36             : // WW8TableNodeInfoInner
      37             : 
      38         114 : WW8TableNodeInfoInner::WW8TableNodeInfoInner(WW8TableNodeInfo * pParent)
      39             : : mpParent(pParent)
      40             : , mnCell(0)
      41             : , mnRow(0)
      42             : , mnShadowsBefore(0)
      43             : , mnShadowsAfter(0)
      44             : , mbEndOfLine(false)
      45             : , mbEndOfCell(false)
      46             : , mbFirstInTable(false)
      47             : , mbVertMerge(false)
      48             : , mpTableBox(NULL)
      49         114 : , mpTable(NULL)
      50             : {
      51         114 : }
      52             : 
      53         114 : WW8TableNodeInfoInner::~WW8TableNodeInfoInner()
      54             : {
      55         114 : }
      56             : 
      57         114 : void WW8TableNodeInfoInner::setDepth(sal_uInt32 nDepth)
      58             : {
      59         114 :     mnDepth = nDepth;
      60         114 : }
      61             : 
      62         114 : void WW8TableNodeInfoInner::setCell(sal_uInt32 nCell)
      63             : {
      64         114 :     mnCell = nCell;
      65         114 : }
      66             : 
      67         114 : void WW8TableNodeInfoInner::setRow(sal_uInt32 nRow)
      68             : {
      69         114 :     mnRow = nRow;
      70         114 : }
      71             : 
      72           0 : void WW8TableNodeInfoInner::setShadowsBefore(sal_uInt32 nShadowsBefore)
      73             : {
      74           0 :     mnShadowsBefore = nShadowsBefore;
      75           0 : }
      76             : 
      77           0 : void WW8TableNodeInfoInner::setShadowsAfter(sal_uInt32 nShadowsAfter)
      78             : {
      79           0 :     mnShadowsAfter = nShadowsAfter;
      80           0 : }
      81             : 
      82          12 : void WW8TableNodeInfoInner::setEndOfLine(bool bEndOfLine)
      83             : {
      84          12 :     mbEndOfLine = bEndOfLine;
      85          12 : }
      86             : 
      87          38 : void WW8TableNodeInfoInner::setEndOfCell(bool bEndOfCell)
      88             : {
      89          38 :     mbEndOfCell = bEndOfCell;
      90          38 : }
      91             : 
      92           5 : void WW8TableNodeInfoInner::setFirstInTable(bool bFirstInTable)
      93             : {
      94           5 :     mbFirstInTable = bFirstInTable;
      95           5 : }
      96             : 
      97           0 : void WW8TableNodeInfoInner::setVertMerge(bool bVertMerge)
      98             : 
      99             : {
     100           0 :     mbVertMerge = bVertMerge;
     101           0 : }
     102             : 
     103         114 : void WW8TableNodeInfoInner::setTableBox(const SwTableBox * pTableBox)
     104             : {
     105         114 :     mpTableBox = pTableBox;
     106         114 : }
     107             : 
     108         114 : void WW8TableNodeInfoInner::setTable(const SwTable * pTable)
     109             : {
     110         114 :     mpTable = pTable;
     111         114 : }
     112             : 
     113           0 : void WW8TableNodeInfoInner::setRect(const SwRect & rRect)
     114             : {
     115           0 :     maRect = rRect;
     116           0 : }
     117             : 
     118          15 : sal_uInt32 WW8TableNodeInfoInner::getDepth() const
     119             : {
     120          15 :     return mnDepth;
     121             : }
     122             : 
     123         363 : sal_uInt32 WW8TableNodeInfoInner::getCell() const
     124             : {
     125         363 :     return mnCell;
     126             : }
     127             : 
     128         240 : sal_uInt32 WW8TableNodeInfoInner::getRow() const
     129             : {
     130         240 :     return mnRow;
     131             : }
     132             : 
     133           0 : sal_uInt32 WW8TableNodeInfoInner::getShadowsBefore() const
     134             : {
     135           0 :     return mnShadowsBefore;
     136             : }
     137             : 
     138           0 : sal_uInt32 WW8TableNodeInfoInner::getShadowsAfter() const
     139             : {
     140           0 :     return mnShadowsAfter;
     141             : }
     142             : 
     143         114 : bool WW8TableNodeInfoInner::isEndOfCell() const
     144             : {
     145         114 :     return mbEndOfCell;
     146             : }
     147             : 
     148         228 : bool WW8TableNodeInfoInner::isEndOfLine() const
     149             : {
     150         228 :     return mbEndOfLine;
     151             : }
     152             : 
     153          38 : bool WW8TableNodeInfoInner::isFirstInTable() const
     154             : {
     155          38 :     return mbFirstInTable;
     156             : }
     157             : 
     158          79 : const SwNode * WW8TableNodeInfoInner::getNode() const
     159             : {
     160          79 :     const SwNode * pResult = NULL;
     161             : 
     162          79 :     if (mpParent != NULL)
     163          79 :         pResult = mpParent->getNode();
     164             : 
     165          79 :     return pResult;
     166             : }
     167             : 
     168           0 : TableBoxVectorPtr WW8TableNodeInfoInner::getTableBoxesOfRow()
     169             : {
     170           0 :     TableBoxVectorPtr pResult(new TableBoxVector);
     171             : 
     172             :     WW8TableCellGrid::Pointer_t pCellGrid =
     173           0 :         mpParent->getParent()->getCellGridForTable(getTable(), false);
     174             : 
     175           0 :     if (pCellGrid.get() == NULL)
     176             :     {
     177           0 :         const SwTableLine * pTabLine = getTableBox()->GetUpper();
     178           0 :         const SwTableBoxes & rTblBoxes = pTabLine->GetTabBoxes();
     179             : 
     180           0 :         sal_uInt8 nBoxes = rTblBoxes.size();
     181           0 :         for ( sal_uInt8 n = 0; n < nBoxes; n++ )
     182             :         {
     183           0 :             pResult->push_back(rTblBoxes[n]);
     184             :         }
     185             :     }
     186             :     else
     187           0 :         pResult = pCellGrid->getTableBoxesOfRow(this);
     188             : 
     189           0 :     return pResult;
     190             : }
     191             : 
     192          69 : GridColsPtr WW8TableNodeInfoInner::getGridColsOfRow(AttributeOutputBase & rBase)
     193             : {
     194          69 :     GridColsPtr pResult(new GridCols);
     195          69 :     WidthsPtr pWidths(getWidthsOfRow());
     196             : 
     197          69 :     const SwFrmFmt *pFmt = getTable()->GetFrmFmt();
     198             :     OSL_ENSURE(pFmt,"Impossible");
     199          69 :     if (!pFmt)
     200             :         return pResult;
     201             : 
     202          69 :     const SwFmtFrmSize &rSize = pFmt->GetFrmSize();
     203          69 :     unsigned long nTblSz = static_cast<unsigned long>(rSize.GetWidth());
     204             : 
     205          69 :     sal_uInt32 nPageSize = 0;
     206          69 :     bool bRelBoxSize = false;
     207             : 
     208             :     rBase.GetTablePageSize
     209          69 :         ( this, nPageSize, bRelBoxSize );
     210             : 
     211          69 :     SwTwips nSz = 0;
     212          69 :     Widths::const_iterator aWidthsEnd = pWidths->end();
     213         299 :     for ( Widths::const_iterator aIt = pWidths->begin();
     214             :           aIt != aWidthsEnd;
     215             :           ++aIt)
     216             :     {
     217         230 :         nSz += *aIt;
     218         230 :         SwTwips nCalc = nSz;
     219         230 :         if ( bRelBoxSize )
     220           0 :             nCalc = ( nCalc * nPageSize ) / nTblSz;
     221             : 
     222         230 :         pResult->push_back( nCalc );
     223             :     }
     224             : 
     225          69 :     return pResult;
     226             : }
     227             : 
     228          69 : WidthsPtr WW8TableNodeInfoInner::getWidthsOfRow()
     229             : {
     230          69 :     WidthsPtr pWidths;
     231             : 
     232             :     WW8TableCellGrid::Pointer_t pCellGrid =
     233          69 :         mpParent->getParent()->getCellGridForTable(getTable(), false);
     234             : 
     235          69 :     if (pCellGrid.get() == NULL)
     236             :     {
     237          69 :         const SwTableBox * pTabBox = getTableBox();
     238          69 :         const SwTableLine * pTabLine = pTabBox->GetUpper();
     239          69 :         const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes();
     240             : 
     241          69 :         pWidths = WidthsPtr(new Widths);
     242             :         // number of cell written
     243          69 :         sal_uInt32 nBoxes = rTabBoxes.size();
     244          69 :         if ( nBoxes > MAXTABLECELLS )
     245           0 :             nBoxes = MAXTABLECELLS;
     246             : 
     247         299 :         for (sal_uInt32 n = 0; n < nBoxes; n++)
     248             :         {
     249         230 :             const SwFrmFmt* pBoxFmt = rTabBoxes[ n ]->GetFrmFmt();
     250         230 :             const SwFmtFrmSize& rLSz = pBoxFmt->GetFrmSize();
     251             : 
     252         230 :             pWidths->push_back(rLSz.GetWidth());
     253             :         }
     254             :     }
     255             :     else
     256           0 :         pWidths = pCellGrid->getWidthsOfRow(this);
     257             : 
     258          69 :     return pWidths;
     259             : }
     260             : 
     261           0 : RowSpansPtr WW8TableNodeInfoInner::getRowSpansOfRow()
     262             : {
     263           0 :     RowSpansPtr pResult(new RowSpans);
     264             : 
     265             :     WW8TableCellGrid::Pointer_t pCellGrid =
     266           0 :         mpParent->getParent()->getCellGridForTable(getTable(), false);
     267             : 
     268           0 :     if (pCellGrid.get() == NULL)
     269             :     {
     270           0 :         const SwTableBox * pTabBox = getTableBox();
     271           0 :         const SwTableLine * pTabLine = pTabBox->GetUpper();
     272           0 :         const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes();
     273             : 
     274           0 :         sal_uInt32 nBoxes = rTabBoxes.size();
     275           0 :         if (nBoxes > MAXTABLECELLS)
     276           0 :             nBoxes = MAXTABLECELLS;
     277             : 
     278           0 :         for (sal_uInt32 n = 0; n < nBoxes; ++n)
     279             :         {
     280           0 :             pResult->push_back(rTabBoxes[n]->getRowSpan());
     281             :         }
     282             :     }
     283             :     else
     284           0 :         pResult = pCellGrid->getRowSpansOfRow(this);
     285             : 
     286           0 :     return pResult;
     287             :  }
     288             : 
     289         255 : const SwTableBox * WW8TableNodeInfoInner::getTableBox() const
     290             : {
     291         255 :     return mpTableBox;
     292             : }
     293             : 
     294         363 : const SwTable * WW8TableNodeInfoInner::getTable() const
     295             : {
     296         363 :     return mpTable;
     297             : }
     298             : 
     299           0 : const SwRect & WW8TableNodeInfoInner::getRect() const
     300             : {
     301           0 :     return maRect;
     302             : }
     303             : 
     304             : #ifdef DBG_UTIL
     305             : ::std::string WW8TableNodeInfoInner::toString() const
     306             : {
     307             :     static char buffer[256];
     308             :     snprintf(buffer, sizeof(buffer),
     309             :              "<tableinner depth=\"%" SAL_PRIuUINT32 "\""
     310             :              " cell=\"%" SAL_PRIuUINT32 "\""
     311             :              " row=\"%" SAL_PRIuUINT32 "\""
     312             :              " endOfCell=\"%s\""
     313             :              " endOfLine=\"%s\""
     314             :              " shadowsBefore=\"%" SAL_PRIuUINT32 "\""
     315             :              " shadowsAfter=\"%" SAL_PRIuUINT32 "\""
     316             :              " vertMerge=\"%s\"/>",
     317             :              mnDepth, mnCell, mnRow,
     318             :              mbEndOfCell ? "yes" : "no",
     319             :              mbEndOfLine ? "yes" : "no",
     320             :              mnShadowsBefore,
     321             :              mnShadowsAfter,
     322             :              mbVertMerge ? "yes" : "no");
     323             : 
     324             :     return string(buffer);
     325             : }
     326             : #endif
     327             : 
     328         114 : WW8TableNodeInfo::WW8TableNodeInfo(WW8TableInfo * pParent,
     329             :                                    const SwNode * pNode)
     330             : : mpParent(pParent),
     331             :   mnDepth(0),
     332             :   mpNode(pNode),
     333             :   mpNext(NULL),
     334         114 :   mpNextNode(NULL)
     335             : {
     336         114 : }
     337             : 
     338         228 : WW8TableNodeInfo::~WW8TableNodeInfo()
     339             : {
     340         228 : }
     341             : 
     342             : #ifdef DBG_UTIL
     343             : ::std::string WW8TableNodeInfo::toString() const
     344             : {
     345             :     static char buffer[1024];
     346             :     snprintf(buffer, sizeof(buffer),
     347             :              "<tableNodeInfo p=\"%p\" depth=\"%" SAL_PRIuUINT32 "\">"
     348             :              ,this, getDepth());
     349             : 
     350             :     ::std::string sResult(buffer);
     351             : 
     352             :     Inners_t::const_iterator aIt(mInners.begin());
     353             :     Inners_t::const_iterator aEnd(mInners.end());
     354             : 
     355             :     while (aIt != aEnd)
     356             :     {
     357             :         WW8TableNodeInfoInner::Pointer_t pInner = aIt->second;
     358             :         sResult += pInner->toString();
     359             : 
     360             :         ++aIt;
     361             :     }
     362             :     sResult += dbg_out(*mpNode);
     363             :     sResult += "</tableNodeInfo>";
     364             : 
     365             :     return sResult;
     366             : }
     367             : #endif
     368             : 
     369         114 : void WW8TableNodeInfo::setDepth(sal_uInt32 nDepth)
     370             : {
     371         114 :     mnDepth = nDepth;
     372             : 
     373         114 :     Inners_t::iterator aIt = mInners.find(mnDepth);
     374             : 
     375         114 :     if (aIt == mInners.end())
     376         114 :         mInners[mnDepth] = WW8TableNodeInfoInner::Pointer_t(new WW8TableNodeInfoInner(this));
     377             : 
     378         114 :     mInners[mnDepth]->setDepth(mnDepth);
     379         114 : }
     380             : 
     381          12 : void WW8TableNodeInfo::setEndOfLine(bool bEndOfLine)
     382             : {
     383          12 :     WW8TableNodeInfoInner::Pointer_t pInner = getInnerForDepth(mnDepth);
     384          12 :     pInner->setEndOfLine(bEndOfLine);
     385             : 
     386             : #ifdef DBG_UTIL
     387             :     SAL_INFO( "sw.ww8", "<endOfLine depth=\"" << mnDepth << "\">" << toString() << "</endOfLine>" );
     388             : #endif
     389          12 : }
     390             : 
     391          38 : void WW8TableNodeInfo::setEndOfCell(bool bEndOfCell)
     392             : {
     393          38 :     WW8TableNodeInfoInner::Pointer_t pInner = getInnerForDepth(mnDepth);
     394          38 :     pInner->setEndOfCell(bEndOfCell);
     395             : 
     396             : #ifdef DBG_UTIL
     397             :     SAL_INFO( "sw.ww8", "<endOfCell depth=\"" << mnDepth << "\">" << toString() << "</endOfCell>" );
     398             : #endif
     399          38 : }
     400             : 
     401           5 : void WW8TableNodeInfo::setFirstInTable(bool bFirstInTable)
     402             : {
     403           5 :     WW8TableNodeInfoInner::Pointer_t pInner = getInnerForDepth(mnDepth);
     404             : 
     405           5 :     pInner->setFirstInTable(bFirstInTable);
     406             : 
     407             : #ifdef DBG_UTIL
     408             :     SAL_INFO( "sw.ww8", "<firstInTable depth=\"" << mnDepth << "\">" << toString() << "</firstInTable>" );
     409             : #endif
     410           5 : }
     411             : 
     412           0 : void WW8TableNodeInfo::setVertMerge(bool bVertMerge)
     413             : {
     414           0 :     WW8TableNodeInfoInner::Pointer_t pInner = getInnerForDepth(mnDepth);
     415             : 
     416           0 :     pInner->setVertMerge(bVertMerge);
     417             : 
     418             : #ifdef DBG_UTIL
     419             :     SAL_INFO( "sw.ww8", "<vertMerge depth=\"" << mnDepth << "\">" << toString() << "</vertMerge>" );
     420             : #endif
     421           0 : }
     422             : 
     423         114 : void WW8TableNodeInfo::setTableBox(const SwTableBox * pTableBox)
     424             : {
     425         114 :     getInnerForDepth(mnDepth)->setTableBox(pTableBox);
     426         114 : }
     427             : 
     428         114 : void WW8TableNodeInfo::setTable(const SwTable * pTable)
     429             : {
     430         114 :     getInnerForDepth(mnDepth)->setTable(pTable);
     431         114 : }
     432             : 
     433         109 : void WW8TableNodeInfo::setNext(WW8TableNodeInfo * pNext)
     434             : {
     435         109 :     mpNext = pNext;
     436             : 
     437             : #ifdef DBG_UTIL
     438             :     SAL_INFO( "sw.ww8", "<setnext><from>" << toString() << "</from><to>" << pNext->toString() << "</to></setnext>" );
     439             : #endif
     440         109 : }
     441             : 
     442           5 : void WW8TableNodeInfo::setNextNode(const SwNode * pNode)
     443             : {
     444           5 :     mpNextNode = pNode;
     445           5 : }
     446             : 
     447           0 : void WW8TableNodeInfo::setRect(const SwRect & rRect)
     448             : {
     449           0 :     getInnerForDepth(mnDepth)->setRect(rRect);
     450           0 : }
     451             : 
     452         114 : void WW8TableNodeInfo::setCell(sal_uInt32 nCell)
     453             : {
     454         114 :     getInnerForDepth(mnDepth)->setCell(nCell);
     455         114 : }
     456             : 
     457         114 : void WW8TableNodeInfo::setRow(sal_uInt32 nRow)
     458             : {
     459         114 :     getInnerForDepth(mnDepth)->setRow(nRow);
     460         114 : }
     461             : 
     462           0 : void WW8TableNodeInfo::setShadowsBefore(sal_uInt32 nShadowsBefore)
     463             : {
     464           0 :     getInnerForDepth(mnDepth)->setShadowsBefore(nShadowsBefore);
     465           0 : }
     466             : 
     467           0 : void WW8TableNodeInfo::setShadowsAfter(sal_uInt32 nShadowsAfter)
     468             : {
     469           0 :     getInnerForDepth(mnDepth)->setShadowsAfter(nShadowsAfter);
     470           0 : }
     471             : 
     472          69 : WW8TableInfo * WW8TableNodeInfo::getParent() const
     473             : {
     474          69 :     return mpParent;
     475             : }
     476             : 
     477         129 : sal_uInt32 WW8TableNodeInfo::getDepth() const
     478             : {
     479         129 :     if (!mInners.empty())
     480          15 :         return mInners.begin()->second->getDepth();
     481             : 
     482         114 :     return mnDepth;
     483             : }
     484             : 
     485         188 : const SwNode * WW8TableNodeInfo::getNode() const
     486             : {
     487         188 :     return mpNode;
     488             : }
     489             : 
     490           0 : const SwTableBox * WW8TableNodeInfo::getTableBox() const
     491             : {
     492           0 :     return getInnerForDepth(mnDepth)->getTableBox();
     493             : }
     494             : 
     495         114 : WW8TableNodeInfo * WW8TableNodeInfo::getNext() const
     496             : {
     497         114 :     return mpNext;
     498             : }
     499             : 
     500           5 : const SwNode * WW8TableNodeInfo::getNextNode() const
     501             : {
     502           5 :     return mpNextNode;
     503             : }
     504             : 
     505          38 : sal_uInt32 WW8TableNodeInfo::getCell() const
     506             : {
     507          38 :     return getInnerForDepth(mnDepth)->getCell();
     508             : }
     509             : 
     510          38 : sal_uInt32 WW8TableNodeInfo::getRow() const
     511             : {
     512          38 :     return getInnerForDepth(mnDepth)->getRow();
     513             : }
     514             : 
     515          76 : const ww8::WW8TableNodeInfo::Inners_t & WW8TableNodeInfo::getInners() const
     516             : {
     517          76 :     return mInners;
     518             : }
     519             : 
     520          38 : const WW8TableNodeInfoInner::Pointer_t WW8TableNodeInfo::getFirstInner() const
     521             : {
     522          38 :     WW8TableNodeInfoInner::Pointer_t pResult;
     523             : 
     524          38 :     if (!mInners.empty())
     525          38 :         pResult = mInners.begin()->second;
     526             : 
     527          38 :     return pResult;
     528             : }
     529             : 
     530         625 : const WW8TableNodeInfoInner::Pointer_t WW8TableNodeInfo::getInnerForDepth(sal_uInt32 nDepth) const
     531             : {
     532         625 :     WW8TableNodeInfoInner::Pointer_t pResult;
     533             : 
     534         625 :     Inners_t::const_iterator aIt = mInners.find(nDepth);
     535         625 :     if (aIt != mInners.end())
     536             :     {
     537         625 :         pResult = aIt->second;
     538             :     }
     539             : 
     540         625 :     return pResult;
     541             : }
     542             : 
     543             : // WW8TableInfo
     544             : 
     545          86 : WW8TableInfo::WW8TableInfo()
     546             : {
     547          86 : }
     548             : 
     549         172 : WW8TableInfo::~WW8TableInfo()
     550             : {
     551         172 : }
     552             : 
     553             : WW8TableNodeInfo *
     554           0 : WW8TableInfo::processSwTableByLayout(const SwTable * pTable)
     555             : {
     556           0 :     SwTableCellInfo aTableCellInfo(pTable);
     557           0 :     WW8TableNodeInfo * pPrev = NULL;
     558             : 
     559           0 :     while (aTableCellInfo.getNext())
     560             :     {
     561           0 :         SwRect aRect = aTableCellInfo.getRect();
     562             : 
     563             :         SAL_INFO( "sw.ww8", "<CellFrm>" );
     564             :         SAL_INFO( "sw.ww8", "<rect top=\"" << aRect.Top() << "\" bottom=\"" << aRect.Bottom()
     565             :             << "\" left=\"" << aRect.Left() << "\" right=\"" << aRect.Right() << "\"/>" );
     566           0 :         const SwTableBox * pTableBox = aTableCellInfo.getTableBox();
     567           0 :         const SwStartNode * pSttNd = pTableBox->GetSttNd();
     568             : 
     569           0 :         if (pSttNd != NULL)
     570             :         {
     571           0 :             SwPaM aPam(*pSttNd, 0);
     572             : 
     573           0 :             bool bDone = false;
     574           0 :             do
     575             :             {
     576           0 :                 SwNode & rNode = aPam.GetPoint()->nNode.GetNode();
     577             : 
     578           0 :                 insertTableNodeInfo(&rNode, pTable, pTableBox, 0, 0, 1, & aRect);
     579             : 
     580           0 :                 if (rNode.IsEndNode())
     581             :                 {
     582           0 :                     SwEndNode * pEndNode = rNode.GetEndNode();
     583           0 :                     SwStartNode * pTmpSttNd = pEndNode->StartOfSectionNode();
     584             : 
     585           0 :                     if (pTmpSttNd == pSttNd)
     586           0 :                         bDone = true;
     587             :                 }
     588             : 
     589           0 :                 aPam.GetPoint()->nNode++;
     590             :             }
     591           0 :             while (!bDone);
     592             :         }
     593             : 
     594             :         SAL_INFO( "sw.ww8", "</CellFrm>" );
     595             :     }
     596             : 
     597           0 :     pPrev = reorderByLayout(pTable);
     598             : 
     599           0 :     return pPrev;
     600             : }
     601             : 
     602           5 : void WW8TableInfo::processSwTable(const SwTable * pTable)
     603             : {
     604             :     SAL_INFO( "sw.ww8", "<processSwTable>" );
     605             : 
     606           5 :     WW8TableNodeInfo * pPrev = NULL;
     607             : 
     608           5 :     if (pTable->IsTblComplex() && pTable->HasLayout())
     609             :     {
     610           0 :         pPrev = processSwTableByLayout(pTable);
     611             : 
     612             : #ifdef DBG_UTIL
     613             :         SAL_INFO( "sw.ww8", getCellGridForTable(pTable)->toString());
     614             : #endif
     615             :     }
     616             :     else
     617             :     {
     618           5 :         const SwTableLines & rLines = pTable->GetTabLines();
     619             : 
     620          17 :         for (sal_uInt16 n = 0; n < rLines.size(); n++)
     621             :         {
     622          12 :             const SwTableLine * pLine = rLines[n];
     623             : 
     624          12 :             pPrev = processTableLine(pTable, pLine, n, 1, pPrev);
     625             :         }
     626             : 
     627             :     }
     628             : 
     629           5 :     if (pPrev != NULL)
     630             :     {
     631           5 :         SwTableNode * pTableNode = pTable->GetTableNode();
     632           5 :         SwEndNode * pEndNode = pTableNode->EndOfSectionNode();
     633             : 
     634           5 :         pPrev->setNextNode(pEndNode);
     635             :     }
     636             :     SAL_INFO( "sw.ww8", "</processSwTable>" );
     637           5 : }
     638             : 
     639             : WW8TableNodeInfo *
     640          12 : WW8TableInfo::processTableLine(const SwTable * pTable,
     641             :                                const SwTableLine * pTableLine,
     642             :                                sal_uInt32 nRow,
     643             :                                sal_uInt32 nDepth, WW8TableNodeInfo * pPrev)
     644             : {
     645             :     SAL_INFO( "sw.ww8", "<processTableLine row=\"" << nRow << "\" depth=\"" << nDepth << "\">" );
     646             : 
     647          12 :     const SwTableBoxes & rBoxes = pTableLine->GetTabBoxes();
     648             : 
     649          12 :     WW8TableNodeInfo::Pointer_t pTextNodeInfo;
     650             : 
     651          50 :     for (sal_uInt16 n = 0; n < rBoxes.size(); n++)
     652             :     {
     653          38 :         const SwTableBox * pBox = rBoxes[n];
     654             : 
     655          38 :         pPrev = processTableBox(pTable, pBox, nRow, n, nDepth, n == rBoxes.size() - 1, pPrev);
     656             :     }
     657             : 
     658             :     SAL_INFO( "sw.ww8", "</processTableLine>" );
     659             : 
     660          12 :     return pPrev;
     661             : }
     662             : 
     663             : WW8TableNodeInfo::Pointer_t
     664           0 : WW8TableInfo::processTableBoxLines(const SwTableBox * pBox,
     665             :                                    const SwTable * pTable,
     666             :                                    const SwTableBox * pBoxToSet,
     667             :                                    sal_uInt32 nRow,
     668             :                                    sal_uInt32 nCell,
     669             :                                    sal_uInt32 nDepth)
     670             : {
     671             :     SAL_INFO( "sw.ww8", "<processTableBoxLines depth=\"" << nDepth << "\" row=\"" << nRow
     672             :         << "\" cell=\"" << nCell << "\">" );
     673             : 
     674           0 :     const SwTableLines & rLines = pBox->GetTabLines();
     675           0 :     WW8TableNodeInfo::Pointer_t pNodeInfo;
     676             : 
     677           0 :     if (!rLines.empty())
     678             :     {
     679           0 :         for (sal_uInt32 n = 0; n < rLines.size(); n++)
     680             :         {
     681           0 :             const SwTableLine * pLine = rLines[n];
     682           0 :             const SwTableBoxes & rBoxes = pLine->GetTabBoxes();
     683             : 
     684           0 :             for (sal_uInt16 nBox = 0; nBox < rBoxes.size(); nBox++)
     685           0 :                 pNodeInfo = processTableBoxLines(rBoxes[nBox], pTable, pBoxToSet, nRow, nCell, nDepth);
     686             :         }
     687             :     }
     688             :     else
     689             :     {
     690           0 :         const SwStartNode * pSttNd = pBox->GetSttNd();
     691           0 :         const SwEndNode * pEndNd = pSttNd->EndOfSectionNode();
     692           0 :         SwPaM aPaM(*pSttNd, 0);
     693           0 :         SwPaM aEndPaM(*pEndNd, 0);
     694             : 
     695           0 :         bool bDone = false;
     696           0 :         while (!bDone)
     697             :         {
     698           0 :             SwNode & rNode = aPaM.GetPoint()->nNode.GetNode();
     699             : 
     700           0 :             pNodeInfo = insertTableNodeInfo(&rNode, pTable, pBoxToSet, nRow, nCell, nDepth);
     701             : 
     702           0 :             if (aPaM.GetPoint()->nNode == aEndPaM.GetPoint()->nNode)
     703           0 :                 bDone = true;
     704             :             else
     705           0 :                 aPaM.GetPoint()->nNode++;
     706           0 :         }
     707             :     }
     708             : 
     709             :     SAL_INFO( "sw.ww8", "</processTableBoxLines>" );
     710             : 
     711           0 :     return pNodeInfo;
     712             : }
     713             : 
     714             : WW8TableNodeInfo *
     715          38 : WW8TableInfo::processTableBox(const SwTable * pTable,
     716             :                               const SwTableBox * pBox,
     717             :                               sal_uInt32 nRow,
     718             :                               sal_uInt32 nCell,
     719             :                               sal_uInt32 nDepth,
     720             :                               bool bEndOfLine,
     721             :                               WW8TableNodeInfo * pPrev)
     722             : {
     723             :     SAL_INFO( "sw.ww8", "<processTableBox row=\"" << nRow << "\" cell=\"" << nCell
     724             :         << "\" depth=\"" << nDepth << "\">" );
     725             : 
     726          38 :     WW8TableNodeInfo::Pointer_t pNodeInfo;
     727          38 :     const SwTableLines & rLines = pBox->GetTabLines();
     728          38 :     const SwStartNode * pSttNd = pBox->GetSttNd();
     729          38 :     WW8TableNodeInfo::Pointer_t pEndOfCellInfo;
     730             : 
     731          38 :     if (!rLines.empty())
     732             :     {
     733           0 :         pNodeInfo = processTableBoxLines(pBox, pTable, pBox, nRow, nCell, nDepth);
     734           0 :         pNodeInfo->setEndOfCell(true);
     735           0 :         if (bEndOfLine)
     736           0 :             pNodeInfo->setEndOfLine(true);
     737             : 
     738           0 :         for (sal_uInt32 n = 0; n < rLines.size(); n++)
     739             :         {
     740           0 :             const SwTableLine * pLine = rLines[n];
     741             : 
     742           0 :             pPrev = processTableLine(pTable, pLine, n, 1, pPrev);
     743             :         }
     744             :     }
     745             :     else
     746             :     {
     747          38 :         SwPaM aPaM(*pSttNd, 0);
     748             : 
     749          38 :         bool bDone = false;
     750          38 :         sal_uInt32 nDepthInsideCell = 0;
     751             : 
     752         114 :         do
     753             :         {
     754         114 :             SwNode & rNode = aPaM.GetPoint()->nNode.GetNode();
     755             : 
     756         114 :             if (rNode.IsStartNode())
     757             :             {
     758          38 :                 if (nDepthInsideCell > 0)
     759           0 :                     pEndOfCellInfo.reset();
     760             : 
     761          38 :                 nDepthInsideCell++;
     762             :             }
     763             : 
     764         114 :             pNodeInfo = insertTableNodeInfo(&rNode, pTable, pBox, nRow, nCell, nDepth);
     765             : 
     766         114 :             if (pPrev != NULL)
     767         109 :                 pPrev->setNext(pNodeInfo.get());
     768             : 
     769         114 :             pPrev = pNodeInfo.get();
     770             : 
     771         114 :             if (nDepthInsideCell == 1 && rNode.IsTxtNode())
     772          38 :                 pEndOfCellInfo = pNodeInfo;
     773             : 
     774         114 :             if (rNode.IsEndNode())
     775             :             {
     776          38 :                 nDepthInsideCell--;
     777             : 
     778          38 :                 if (nDepthInsideCell == 0 && pEndOfCellInfo.get() == NULL)
     779           0 :                     pEndOfCellInfo = pNodeInfo;
     780             : 
     781          38 :                 SwEndNode * pEndNode = rNode.GetEndNode( );
     782          38 :                 SwStartNode * pTmpSttNd = pEndNode->StartOfSectionNode();
     783          38 :                 if (pTmpSttNd == pSttNd)
     784          38 :                     bDone = true;
     785             :             }
     786             : 
     787         114 :             aPaM.GetPoint()->nNode++;
     788             :         }
     789         114 :         while (!bDone);
     790             : 
     791          38 :         if (pEndOfCellInfo.get() != NULL)
     792             :         {
     793          38 :             pEndOfCellInfo->setEndOfCell(true);
     794             : 
     795          38 :             if (bEndOfLine)
     796          12 :                 pEndOfCellInfo->setEndOfLine(true);
     797          38 :         }
     798             :     }
     799             : 
     800             :     SAL_INFO( "sw.ww8", "</processTableBox>" );
     801             : 
     802          38 :     return pPrev;
     803             : }
     804             : 
     805         114 : WW8TableNodeInfo::Pointer_t WW8TableInfo::insertTableNodeInfo
     806             : (const SwNode * pNode,
     807             :  const SwTable * pTable,
     808             :  const SwTableBox * pTableBox,
     809             :  sal_uInt32 nRow,
     810             :  sal_uInt32 nCell,
     811             :  sal_uInt32 nDepth,
     812             :  SwRect * pRect)
     813             : {
     814         114 :     WW8TableNodeInfo::Pointer_t pNodeInfo = getTableNodeInfo(pNode);
     815             : 
     816         114 :     if (pNodeInfo.get() == NULL)
     817             :     {
     818             :         pNodeInfo =
     819         114 :             WW8TableNodeInfo::Pointer_t(new WW8TableNodeInfo(this, pNode));
     820         114 :         mMap.insert(Map_t::value_type(pNode, pNodeInfo));
     821             :     }
     822             : 
     823         114 :     pNodeInfo->setDepth(nDepth + pNodeInfo->getDepth());
     824             : 
     825         114 :     pNodeInfo->setTable(pTable);
     826         114 :     pNodeInfo->setTableBox(pTableBox);
     827             : 
     828         114 :     pNodeInfo->setCell(nCell);
     829         114 :     pNodeInfo->setRow(nRow);
     830             : 
     831         114 :     if (pNode->IsTxtNode())
     832             :     {
     833          38 :         FirstInTableMap_t::const_iterator aIt = mFirstInTableMap.find(pTable);
     834          38 :         if (aIt == mFirstInTableMap.end())
     835             :         {
     836           5 :             mFirstInTableMap[pTable] = pNode;
     837           5 :             pNodeInfo->setFirstInTable(true);
     838             :         }
     839             :     }
     840             : 
     841         114 :     if (pRect)
     842             :     {
     843           0 :         WW8TableCellGrid::Pointer_t pCellGrid = getCellGridForTable(pTable);
     844             : 
     845           0 :         pCellGrid->insert(*pRect, pNodeInfo.get());
     846           0 :         pNodeInfo->setRect(*pRect);
     847             :     }
     848             : 
     849             : #ifdef DBG_UTIL
     850             :     SAL_INFO( "sw.ww8", pNodeInfo->toString());
     851             : #endif
     852         114 :     return pNodeInfo;
     853             : }
     854             : 
     855          69 : WW8TableCellGrid::Pointer_t WW8TableInfo::getCellGridForTable
     856             : (const SwTable * pTable, bool bCreate)
     857             : {
     858          69 :     WW8TableCellGrid::Pointer_t pResult;
     859          69 :     CellGridMap_t::iterator aIt = mCellGridMap.find(pTable);
     860             : 
     861          69 :     if (aIt == mCellGridMap.end())
     862             :     {
     863          69 :         if (bCreate)
     864             :         {
     865           0 :             pResult = WW8TableCellGrid::Pointer_t(new WW8TableCellGrid);
     866           0 :             mCellGridMap[pTable] = pResult;
     867             :         }
     868             :     }
     869             :     else
     870           0 :         pResult = mCellGridMap[pTable];
     871             : 
     872          69 :     return pResult;
     873             : }
     874             : 
     875         854 : WW8TableNodeInfo::Pointer_t WW8TableInfo::getTableNodeInfo
     876             : (const SwNode * pNode)
     877             : {
     878         854 :     WW8TableNodeInfo::Pointer_t pResult;
     879         854 :     Map_t::iterator aIt = mMap.find(pNode);
     880             : 
     881         854 :     if (aIt != mMap.end())
     882         228 :         pResult = (*aIt).second;
     883             : 
     884         854 :     return pResult;
     885             : }
     886             : 
     887         340 : const SwNode * WW8TableInfo::getNextNode(const SwNode * pNode)
     888             : {
     889         340 :     const SwNode * pResult = NULL;
     890             : 
     891         340 :     WW8TableNodeInfo::Pointer_t pNodeInfo = getTableNodeInfo(pNode);
     892             : 
     893         340 :     if (pNodeInfo.get() != NULL)
     894             :     {
     895         114 :         WW8TableNodeInfo * pNextInfo = pNodeInfo->getNext();
     896             : 
     897         114 :         if (pNextInfo != NULL)
     898         109 :             pResult = pNextInfo->getNode();
     899             :         else
     900             :         {
     901           5 :             const SwNode * pNextNode = pNodeInfo->getNextNode();
     902             : 
     903           5 :             if (pNextNode != NULL)
     904           5 :                 pResult = pNextNode;
     905             :         }
     906             :     }
     907             : 
     908         340 :     return pResult;
     909             : }
     910             : 
     911           0 : bool WW8TableNodeInfo::operator < (const WW8TableNodeInfo & rInfo) const
     912             : {
     913           0 :     bool bRet = false;
     914             : 
     915           0 :     if (rInfo.mpNode != NULL)
     916             :     {
     917           0 :         if (mpNode == NULL)
     918             :         {
     919           0 :             bRet = true;
     920             :         }
     921             :         else
     922             :         {
     923           0 :             if (mpNode->GetIndex() < rInfo.mpNode->GetIndex())
     924           0 :                 bRet = true;
     925             :         }
     926             :     }
     927             : 
     928           0 :     return bRet;
     929             : }
     930             : 
     931           0 : bool CellInfo::operator < (const CellInfo & aCellInfo) const
     932             : {
     933           0 :     bool aRet = false;
     934             : 
     935           0 :     if (top() < aCellInfo.top())
     936           0 :         aRet = true;
     937           0 :     else if (top() == aCellInfo.top())
     938             :     {
     939           0 :         if (left() < aCellInfo.left())
     940           0 :             aRet = true;
     941           0 :         else if (left() == aCellInfo.left())
     942             :         {
     943           0 :             if (width() < aCellInfo.width())
     944           0 :                 aRet = true;
     945           0 :             else if (width() == aCellInfo.width())
     946             :             {
     947           0 :                 if (height() < aCellInfo.height())
     948           0 :                     aRet = true;
     949           0 :                 else if (height() == aCellInfo.height())
     950             :                 {
     951           0 :                     if (aCellInfo.getTableNodeInfo() != NULL)
     952             :                     {
     953           0 :                         if (m_pNodeInfo == NULL)
     954           0 :                             aRet = true;
     955             :                         else
     956             :                         {
     957           0 :                             aRet = *m_pNodeInfo < *aCellInfo.getTableNodeInfo();
     958             :                         }
     959             :                     }
     960             :                 }
     961             :             }
     962             :         }
     963             :     }
     964             : 
     965           0 :     return aRet;
     966             : }
     967             : 
     968             : #ifdef DBG_UTIL
     969             : ::std::string CellInfo::toString() const
     970             : {
     971             :     static char sBuffer[256];
     972             : 
     973             :     snprintf(sBuffer, sizeof(sBuffer),
     974             :              "<cellinfo left=\"%ld\""
     975             :              " right=\"%ld\""
     976             :              " top=\"%ld\""
     977             :              " bottom=\"%ld\""
     978             :              " node=\"%p\"/>",
     979             :              left(),
     980             :              right(),
     981             :              top(),
     982             :              bottom(),
     983             :              m_pNodeInfo);
     984             : 
     985             :     return sBuffer;
     986             : }
     987             : #endif
     988             : 
     989           0 : WW8TableNodeInfo * WW8TableInfo::reorderByLayout(const SwTable * pTable)
     990             : {
     991           0 :     WW8TableNodeInfo * pPrev = NULL;
     992           0 :     WW8TableCellGrid::Pointer_t pCellGrid = getCellGridForTable(pTable);
     993             : 
     994             : #ifdef DBG_UTIL
     995             :     SAL_INFO( "sw.ww8", pCellGrid->toString());
     996             : #endif
     997             : 
     998           0 :     pCellGrid->addShadowCells();
     999           0 :     pPrev = pCellGrid->connectCells();
    1000             : 
    1001           0 :     return pPrev;
    1002             : }
    1003             : 
    1004           0 : WW8TableCellGrid::WW8TableCellGrid()
    1005             : {
    1006           0 : }
    1007             : 
    1008           0 : WW8TableCellGrid::~WW8TableCellGrid()
    1009             : {
    1010           0 : }
    1011             : 
    1012           0 : WW8TableCellGridRow::Pointer_t WW8TableCellGrid::getRow(long nTop, bool bCreate)
    1013             : {
    1014           0 :     WW8TableCellGridRow::Pointer_t pResult;
    1015             : 
    1016           0 :     RowTops_t::iterator aIt = m_aRowTops.find(nTop);
    1017             : 
    1018           0 :     if (aIt == m_aRowTops.end())
    1019             :     {
    1020           0 :         if (bCreate)
    1021             :         {
    1022           0 :             pResult = WW8TableCellGridRow::Pointer_t(new WW8TableCellGridRow);
    1023           0 :             m_aRows[nTop] = pResult;
    1024           0 :             m_aRowTops.insert(nTop);
    1025             :         }
    1026             :     }
    1027             :     else
    1028           0 :         pResult = m_aRows[nTop];
    1029             : 
    1030           0 :     return pResult;
    1031             : }
    1032             : 
    1033           0 : WW8TableCellGrid::RowTops_t::const_iterator WW8TableCellGrid::getRowTopsBegin() const
    1034             : {
    1035           0 :     return m_aRowTops.begin();
    1036             : }
    1037             : 
    1038           0 : WW8TableCellGrid::RowTops_t::const_iterator WW8TableCellGrid::getRowTopsEnd() const
    1039             : {
    1040           0 :     return m_aRowTops.end();
    1041             : }
    1042             : 
    1043           0 : CellInfoMultiSet::const_iterator WW8TableCellGrid::getCellsBegin(long nTop)
    1044             : {
    1045           0 :     return getRow(nTop)->begin();
    1046             : }
    1047             : 
    1048           0 : CellInfoMultiSet::const_iterator WW8TableCellGrid::getCellsEnd(long nTop)
    1049             : {
    1050           0 :     return getRow(nTop)->end();
    1051             : }
    1052             : 
    1053           0 : void WW8TableCellGrid::insert(const SwRect & rRect,
    1054             :                               WW8TableNodeInfo * pNodeInfo,
    1055             :                               unsigned long * pFmtFrmWidth)
    1056             : {
    1057           0 :     CellInfo aCellInfo(rRect, pNodeInfo);
    1058             : 
    1059           0 :     if (pFmtFrmWidth != NULL)
    1060           0 :         aCellInfo.setFmtFrmWidth(*pFmtFrmWidth);
    1061             : 
    1062           0 :     WW8TableCellGridRow::Pointer_t pRow = getRow(rRect.Top());
    1063           0 :     pRow->insert(aCellInfo);
    1064           0 : }
    1065             : 
    1066           0 : void WW8TableCellGrid::addShadowCells()
    1067             : {
    1068             :     SAL_INFO( "sw.ww8", "<addShadowCells>" );
    1069             : 
    1070           0 :     RowTops_t::const_iterator aTopsIt = getRowTopsBegin();
    1071             : 
    1072           0 :     while (aTopsIt != getRowTopsEnd())
    1073             :     {
    1074             : #ifdef DBG_UTIL
    1075             :         long nTop = *aTopsIt;
    1076             :         (void) nTop;
    1077             : #endif
    1078           0 :         CellInfoMultiSet::const_iterator aCellIt = getCellsBegin(*aTopsIt);
    1079           0 :         CellInfoMultiSet::const_iterator aCellEndIt = getCellsEnd(*aTopsIt);
    1080             : 
    1081           0 :         RowSpansPtr pRowSpans(new RowSpans);
    1082             : 
    1083           0 :         bool bBeginningOfCell = true;
    1084           0 :         bool bVertMerge = false;
    1085           0 :         SwRect aRect = aCellIt->getRect();
    1086           0 :         long nRowSpan = 1;
    1087           0 :         while (aCellIt != aCellEndIt)
    1088             :         {
    1089           0 :             WW8TableNodeInfo * pNodeInfo = aCellIt->getTableNodeInfo();
    1090             : 
    1091           0 :             if (bBeginningOfCell)
    1092             :             {
    1093           0 :                 RowTops_t::const_iterator aRowSpanIt(aTopsIt);
    1094           0 :                 ++aRowSpanIt;
    1095             : 
    1096           0 :                 if (aRowSpanIt != getRowTopsEnd() &&
    1097           0 :                     *aRowSpanIt < aCellIt->bottom())
    1098             :                 {
    1099           0 :                     aRect.Top(*aRowSpanIt);
    1100           0 :                     unsigned long nFmtFrmWidth = aCellIt->getFmtFrmWidth();
    1101           0 :                     insert(aRect, NULL, &nFmtFrmWidth);
    1102             : 
    1103           0 :                     bVertMerge = true;
    1104             :                 }
    1105             :                 else
    1106           0 :                     bVertMerge = false;
    1107             : 
    1108           0 :                 nRowSpan = 1;
    1109           0 :                 while (aRowSpanIt != getRowTopsEnd() &&
    1110           0 :                        *aRowSpanIt < aCellIt->bottom())
    1111             :                 {
    1112           0 :                     ++aRowSpanIt;
    1113           0 :                     nRowSpan++;
    1114             :                 }
    1115             : 
    1116           0 :                 if (pNodeInfo != NULL)
    1117           0 :                     pRowSpans->push_back(nRowSpan);
    1118             :                 else
    1119           0 :                     pRowSpans->push_back(-nRowSpan);
    1120             :             }
    1121             : 
    1122           0 :             if (pNodeInfo != NULL)
    1123             :             {
    1124           0 :                 pNodeInfo->setVertMerge(bVertMerge);
    1125             :             }
    1126             : 
    1127           0 :             ++aCellIt;
    1128           0 :             if (aCellIt != aCellEndIt)
    1129             :             {
    1130           0 :                 bBeginningOfCell = (aRect.Left() != aCellIt->left());
    1131           0 :                 aRect = aCellIt->getRect();
    1132             :             }
    1133             :         }
    1134             : 
    1135           0 :         WW8TableCellGridRow::Pointer_t pRow = getRow(*aTopsIt);
    1136           0 :         if (pRow.get() != NULL)
    1137           0 :             pRow->setRowSpans(pRowSpans);
    1138             : 
    1139           0 :         ++aTopsIt;
    1140           0 :     }
    1141             :     SAL_INFO( "sw.ww8", "</addShadowCells>" );
    1142           0 : }
    1143             : 
    1144           0 : WW8TableNodeInfo * WW8TableCellGrid::connectCells()
    1145             : {
    1146           0 :     RowTops_t::const_iterator aTopsIt = getRowTopsBegin();
    1147           0 :     sal_uInt32 nRow = 0;
    1148           0 :     WW8TableNodeInfo * pLastNodeInfo = NULL;
    1149             : 
    1150           0 :     while (aTopsIt != getRowTopsEnd())
    1151             :     {
    1152           0 :         CellInfoMultiSet::const_iterator aCellIt = getCellsBegin(*aTopsIt);
    1153           0 :         CellInfoMultiSet::const_iterator aCellEndIt = getCellsEnd(*aTopsIt);
    1154           0 :         GridColsPtr pWidths(new Widths);
    1155           0 :         TableBoxVectorPtr pTableBoxes(new TableBoxVector);
    1156             : 
    1157           0 :         sal_uInt32 nShadows = 0;
    1158           0 :         sal_uInt32 nCell = 0;
    1159           0 :         bool bBeginningOfCell = true;
    1160           0 :         WW8TableNodeInfo * pEndOfCellInfo = NULL;
    1161           0 :         sal_uInt32 nDepthInCell = 0;
    1162           0 :         while (aCellIt != aCellEndIt)
    1163             :         {
    1164           0 :             long nCellX = aCellIt->left();
    1165           0 :             WW8TableNodeInfo * pNodeInfo = aCellIt->getTableNodeInfo();
    1166           0 :             if (pNodeInfo != NULL)
    1167             :             {
    1168           0 :                 const SwNode * pNode = pNodeInfo->getNode();
    1169             : 
    1170           0 :                 if (pNode->IsStartNode())
    1171             :                 {
    1172           0 :                     nDepthInCell++;
    1173           0 :                     pEndOfCellInfo = NULL;
    1174             :                 }
    1175             : 
    1176           0 :                 if (nDepthInCell == 1 && pNode->IsTxtNode())
    1177           0 :                     pEndOfCellInfo = pNodeInfo;
    1178             : 
    1179           0 :                 pNodeInfo->setShadowsBefore(nShadows);
    1180           0 :                 pNodeInfo->setCell(nCell);
    1181           0 :                 pNodeInfo->setRow(nRow);
    1182           0 :                 if (pLastNodeInfo != NULL)
    1183             :                 {
    1184           0 :                     pLastNodeInfo->setNext(pNodeInfo);
    1185           0 :                     pLastNodeInfo->setNextNode(pNode);
    1186             :                 }
    1187           0 :                 pLastNodeInfo = pNodeInfo;
    1188           0 :                 nShadows = 0;
    1189             : 
    1190           0 :                 if (pNode->IsEndNode())
    1191             :                 {
    1192           0 :                     nDepthInCell--;
    1193             : 
    1194           0 :                     if (nDepthInCell == 0 && pEndOfCellInfo == NULL)
    1195           0 :                         pEndOfCellInfo = pNodeInfo;
    1196             :                 }
    1197             :             }
    1198             :             else
    1199             :             {
    1200           0 :                 nShadows++;
    1201             :             }
    1202             : 
    1203           0 :             if (bBeginningOfCell)
    1204             :             {
    1205           0 :                 pWidths->push_back(aCellIt->getFmtFrmWidth());
    1206             : 
    1207           0 :                 if (pNodeInfo != NULL)
    1208           0 :                     pTableBoxes->push_back(pNodeInfo->getTableBox());
    1209             :                 else
    1210           0 :                     pTableBoxes->push_back(NULL);
    1211             :             }
    1212             : 
    1213           0 :             ++aCellIt;
    1214           0 :             bBeginningOfCell = false;
    1215             : 
    1216           0 :             if (aCellIt != aCellEndIt && aCellIt->left() != nCellX)
    1217             :             {
    1218           0 :                 nCell++;
    1219           0 :                 bBeginningOfCell = true;
    1220             : 
    1221           0 :                 if (pEndOfCellInfo != NULL)
    1222             :                 {
    1223           0 :                     pEndOfCellInfo->setEndOfCell(true);
    1224             :                 }
    1225             : 
    1226           0 :                 pEndOfCellInfo = NULL;
    1227             :             }
    1228             :         }
    1229             : 
    1230           0 :         pLastNodeInfo->setShadowsAfter(nShadows);
    1231             : 
    1232           0 :         if (pEndOfCellInfo == NULL)
    1233             :         {
    1234           0 :             pEndOfCellInfo = pLastNodeInfo;
    1235             :         }
    1236             : 
    1237           0 :         pEndOfCellInfo->setEndOfCell(true);
    1238           0 :         pLastNodeInfo->setEndOfLine(true);
    1239             : 
    1240           0 :         WW8TableCellGridRow::Pointer_t pRow(getRow(*aTopsIt));
    1241           0 :         pRow->setTableBoxVector(pTableBoxes);
    1242           0 :         pRow->setWidths(pWidths);
    1243             : 
    1244           0 :         nShadows = 0;
    1245             : 
    1246           0 :         ++aTopsIt;
    1247           0 :         nRow++;
    1248           0 :     }
    1249             : 
    1250           0 :     return pLastNodeInfo;
    1251             : }
    1252             : 
    1253             : #ifdef DBG_UTIL
    1254             : ::std::string WW8TableCellGrid::toString()
    1255             : {
    1256             :     string sResult = "<WW8TableCellGrid>";
    1257             : 
    1258             :     RowTops_t::const_iterator aTopsIt = getRowTopsBegin();
    1259             :     static char sBuffer[1024];
    1260             :     while (aTopsIt != getRowTopsEnd())
    1261             :     {
    1262             :         sprintf(sBuffer, "<row y=\"%ld\">", *aTopsIt);
    1263             :         sResult += sBuffer;
    1264             : 
    1265             :         CellInfoMultiSet::const_iterator aCellIt = getCellsBegin(*aTopsIt);
    1266             :         CellInfoMultiSet::const_iterator aCellsEnd = getCellsEnd(*aTopsIt);
    1267             : 
    1268             :         while (aCellIt != aCellsEnd)
    1269             :         {
    1270             :             snprintf(sBuffer, sizeof(sBuffer), "<cellInfo top=\"%ld\" bottom=\"%ld\" left=\"%ld\" right=\"%ld\">",
    1271             :                      aCellIt->top(), aCellIt->bottom(), aCellIt->left(), aCellIt->right());
    1272             :             sResult += sBuffer;
    1273             : 
    1274             :             WW8TableNodeInfo * pInfo = aCellIt->getTableNodeInfo();
    1275             :             if (pInfo != NULL)
    1276             :                 sResult += pInfo->toString();
    1277             :             else
    1278             :                 sResult += "<shadow/>\n";
    1279             : 
    1280             :             sResult += "</cellInfo>\n";
    1281             :             ++aCellIt;
    1282             :         }
    1283             : 
    1284             :         WW8TableCellGridRow::Pointer_t pRow = getRow(*aTopsIt);
    1285             :         WidthsPtr pWidths = pRow->getWidths();
    1286             :         if (pWidths != NULL)
    1287             :         {
    1288             :             sResult += "<widths>";
    1289             : 
    1290             :             Widths::const_iterator aItEnd = pWidths->end();
    1291             :             for (Widths::const_iterator aIt = pWidths->begin();
    1292             :                  aIt != aItEnd;
    1293             :                  ++aIt)
    1294             :             {
    1295             :                 if (aIt != pWidths->begin())
    1296             :                     sResult += ", ";
    1297             : 
    1298             :                 snprintf(sBuffer, sizeof(sBuffer), "%" SAL_PRIxUINT32 "", *aIt);
    1299             :                 sResult += sBuffer;
    1300             :             }
    1301             : 
    1302             :             sResult += "</widths>";
    1303             :         }
    1304             : 
    1305             :         RowSpansPtr pRowSpans = pRow->getRowSpans();
    1306             :         if (pRowSpans.get() != NULL)
    1307             :         {
    1308             :             sResult += "<rowspans>";
    1309             : 
    1310             :             RowSpans::const_iterator aItEnd = pRowSpans->end();
    1311             :             for (RowSpans::const_iterator aIt = pRowSpans->begin();
    1312             :                  aIt != aItEnd;
    1313             :                  ++aIt)
    1314             :             {
    1315             :                 if (aIt != pRowSpans->begin())
    1316             :                     sResult += ", ";
    1317             : 
    1318             :                 snprintf(sBuffer, sizeof(sBuffer), "%" SAL_PRIxUINT32 "", *aIt);
    1319             :                 sResult += sBuffer;
    1320             :             }
    1321             : 
    1322             :             sResult += "</rowspans>";
    1323             :         }
    1324             : 
    1325             :         sResult += "</row>\n";
    1326             :         ++aTopsIt;
    1327             :     }
    1328             : 
    1329             :     sResult += "</WW8TableCellGrid>\n";
    1330             : 
    1331             :     return sResult;
    1332             : }
    1333             : #endif
    1334             : 
    1335           0 : TableBoxVectorPtr WW8TableCellGrid::getTableBoxesOfRow
    1336             : (WW8TableNodeInfoInner * pNodeInfoInner)
    1337             : {
    1338           0 :     TableBoxVectorPtr pResult;
    1339             :     WW8TableCellGridRow::Pointer_t pRow =
    1340           0 :         getRow(pNodeInfoInner->getRect().Top(), false);
    1341             : 
    1342           0 :     if (pRow.get() != NULL)
    1343             :     {
    1344           0 :         pResult = pRow->getTableBoxVector();
    1345             :     }
    1346             : 
    1347           0 :     return pResult;
    1348             : }
    1349             : 
    1350           0 : WidthsPtr WW8TableCellGrid::getWidthsOfRow
    1351             : (WW8TableNodeInfoInner * pNodeInfoInner)
    1352             : {
    1353           0 :     GridColsPtr pResult;
    1354             : 
    1355             :     WW8TableCellGridRow::Pointer_t pRow =
    1356           0 :         getRow(pNodeInfoInner->getRect().Top(), false);
    1357             : 
    1358           0 :     if (pRow.get() != NULL)
    1359             :     {
    1360           0 :         pResult = pRow->getWidths();
    1361             :     }
    1362             : 
    1363           0 :     return pResult;
    1364             : }
    1365             : 
    1366           0 : RowSpansPtr WW8TableCellGrid::getRowSpansOfRow
    1367             : (WW8TableNodeInfoInner * pNodeInfoInner)
    1368             : {
    1369           0 :     RowSpansPtr pResult;
    1370             : 
    1371             :     WW8TableCellGridRow::Pointer_t pRow =
    1372           0 :         getRow(pNodeInfoInner->getRect().Top(), false);
    1373             : 
    1374           0 :     if (pRow.get() != NULL)
    1375             :     {
    1376           0 :         pResult = pRow->getRowSpans();
    1377             :     }
    1378             : 
    1379           0 :     return pResult;
    1380             : }
    1381             : 
    1382           0 : WW8TableCellGridRow::WW8TableCellGridRow()
    1383           0 : : m_pCellInfos(new CellInfoMultiSet)
    1384             : {
    1385           0 : }
    1386             : 
    1387           0 : WW8TableCellGridRow::~WW8TableCellGridRow()
    1388             : {
    1389           0 : }
    1390             : 
    1391           0 : void WW8TableCellGridRow::insert(const CellInfo & rCellInfo)
    1392             : {
    1393           0 :     m_pCellInfos->insert(rCellInfo);
    1394             : 
    1395             : #ifdef DBG_UTIL
    1396             :     SAL_INFO( "sw.ww8", "<gridRowInsert>" << rCellInfo.toString() << "</gridRowInsert>" );
    1397             : #endif
    1398           0 : }
    1399             : 
    1400           0 : CellInfoMultiSet::const_iterator WW8TableCellGridRow::begin() const
    1401             : {
    1402           0 :     return m_pCellInfos->begin();
    1403             : }
    1404             : 
    1405           0 : CellInfoMultiSet::const_iterator WW8TableCellGridRow::end() const
    1406             : {
    1407           0 :     return m_pCellInfos->end();
    1408             : }
    1409             : 
    1410           0 : void WW8TableCellGridRow::setTableBoxVector(TableBoxVectorPtr pTableBoxVector)
    1411             : {
    1412           0 :     m_pTableBoxVector = pTableBoxVector;
    1413           0 : }
    1414             : 
    1415           0 : void WW8TableCellGridRow::setWidths(WidthsPtr pWidths)
    1416             : {
    1417           0 :     m_pWidths = pWidths;
    1418           0 : }
    1419             : 
    1420           0 : void WW8TableCellGridRow::setRowSpans(RowSpansPtr pRowSpans)
    1421             : {
    1422           0 :     m_pRowSpans = pRowSpans;
    1423           0 : }
    1424             : 
    1425           0 : TableBoxVectorPtr WW8TableCellGridRow::getTableBoxVector() const
    1426             : {
    1427           0 :     return m_pTableBoxVector;
    1428             : }
    1429             : 
    1430           0 : WidthsPtr WW8TableCellGridRow::getWidths() const
    1431             : {
    1432           0 :     return m_pWidths;
    1433             : }
    1434             : 
    1435           0 : RowSpansPtr WW8TableCellGridRow::getRowSpans() const
    1436             : {
    1437           0 :     return m_pRowSpans;
    1438             : }
    1439             : 
    1440           0 : CellInfo::CellInfo(const SwRect & aRect, WW8TableNodeInfo * pNodeInfo)
    1441           0 : : m_aRect(aRect), m_pNodeInfo(pNodeInfo), m_nFmtFrmWidth(0)
    1442             : {
    1443           0 :     if (pNodeInfo != NULL)
    1444             :     {
    1445           0 :         const SwTableBox * pBox = pNodeInfo->getTableBox();
    1446           0 :         const SwFrmFmt * pFrmFmt = pBox->GetFrmFmt();
    1447           0 :         const SwFmtFrmSize & rSize = pFrmFmt->GetFrmSize();
    1448             : 
    1449           0 :         m_nFmtFrmWidth = rSize.GetWidth();
    1450             :     }
    1451           0 : }
    1452             : 
    1453          18 : }
    1454             : 
    1455             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10