LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwptablelayout.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 252 643 39.2 %
Date: 2012-08-25 Functions: 34 70 48.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 136 652 20.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  *  The Contents of this file are made available subject to the terms of
       5                 :            :  *  either of the following licenses
       6                 :            :  *
       7                 :            :  *         - GNU Lesser General Public License Version 2.1
       8                 :            :  *         - Sun Industry Standards Source License Version 1.1
       9                 :            :  *
      10                 :            :  *  Sun Microsystems Inc., October, 2000
      11                 :            :  *
      12                 :            :  *  GNU Lesser General Public License Version 2.1
      13                 :            :  *  =============================================
      14                 :            :  *  Copyright 2000 by Sun Microsystems, Inc.
      15                 :            :  *  901 San Antonio Road, Palo Alto, CA 94303, USA
      16                 :            :  *
      17                 :            :  *  This library is free software; you can redistribute it and/or
      18                 :            :  *  modify it under the terms of the GNU Lesser General Public
      19                 :            :  *  License version 2.1, as published by the Free Software Foundation.
      20                 :            :  *
      21                 :            :  *  This library is distributed in the hope that it will be useful,
      22                 :            :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      23                 :            :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      24                 :            :  *  Lesser General Public License for more details.
      25                 :            :  *
      26                 :            :  *  You should have received a copy of the GNU Lesser General Public
      27                 :            :  *  License along with this library; if not, write to the Free Software
      28                 :            :  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      29                 :            :  *  MA  02111-1307  USA
      30                 :            :  *
      31                 :            :  *
      32                 :            :  *  Sun Industry Standards Source License Version 1.1
      33                 :            :  *  =================================================
      34                 :            :  *  The contents of this file are subject to the Sun Industry Standards
      35                 :            :  *  Source License Version 1.1 (the "License"); You may not use this file
      36                 :            :  *  except in compliance with the License. You may obtain a copy of the
      37                 :            :  *  License at http://www.openoffice.org/license.html.
      38                 :            :  *
      39                 :            :  *  Software provided under this License is provided on an "AS IS" basis,
      40                 :            :  *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
      41                 :            :  *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
      42                 :            :  *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
      43                 :            :  *  See the License for the specific provisions governing your rights and
      44                 :            :  *  obligations concerning the Software.
      45                 :            :  *
      46                 :            :  *  The Initial Developer of the Original Code is: IBM Corporation
      47                 :            :  *
      48                 :            :  *  Copyright: 2008 by IBM Corporation
      49                 :            :  *
      50                 :            :  *  All Rights Reserved.
      51                 :            :  *
      52                 :            :  *  Contributor(s): _______________________________________
      53                 :            :  *
      54                 :            :  *
      55                 :            :  ************************************************************************/
      56                 :            : /**
      57                 :            :  * @file
      58                 :            :  *  For LWP filter architecture prototype - table layouts
      59                 :            :  */
      60                 :            : /*************************************************************************
      61                 :            :  * Change History
      62                 :            :  Mar 2005           Created
      63                 :            :  ************************************************************************/
      64                 :            : #include "lwpglobalmgr.hxx"
      65                 :            : #include "lwptablelayout.hxx"
      66                 :            : #include "lwpfoundry.hxx"
      67                 :            : #include "lwpobjfactory.hxx"
      68                 :            : #include "lwpholder.hxx"
      69                 :            : #include "lwptable.hxx"
      70                 :            : #include "lwptblcell.hxx"
      71                 :            : #include "lwpnumericfmt.hxx"
      72                 :            : #include "lwpdlvlist.hxx"
      73                 :            : #include "lwppara.hxx"
      74                 :            : 
      75                 :            : #include "xfilter/xfstylemanager.hxx"
      76                 :            : #include "xfilter/xftablestyle.hxx"
      77                 :            : #include "xfilter/xftable.hxx"
      78                 :            : #include "xfilter/xfrow.hxx"
      79                 :            : #include "xfilter/xfrowstyle.hxx"
      80                 :            : #include "xfilter/xfcell.hxx"
      81                 :            : #include "xfilter/xfcellstyle.hxx"
      82                 :            : #include "xfilter/xfcolstyle.hxx"
      83                 :            : #include "xfilter/xfframestyle.hxx"
      84                 :            : #include "xfilter/xfframe.hxx"
      85                 :            : #include    "xfilter/xffloatframe.hxx"
      86                 :            : #include "lwpframelayout.hxx"
      87                 :            : #include "xfilter/xfparastyle.hxx"
      88                 :            : 
      89                 :          6 : LwpSuperTableLayout::LwpSuperTableLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
      90                 :          6 :     : LwpPlacableLayout(objHdr, pStrm)
      91                 :            : {
      92 [ +  - ][ +  - ]:          6 :     m_pFrame = new LwpFrame(this);
      93                 :          6 : }
      94                 :            : 
      95                 :          6 : LwpSuperTableLayout::~LwpSuperTableLayout()
      96                 :            : {
      97         [ +  - ]:          6 :     if(m_pFrame)
      98                 :            :     {
      99 [ +  - ][ +  - ]:          6 :         delete m_pFrame;
     100                 :            :     }
     101         [ -  + ]:         12 : }
     102                 :            : /**
     103                 :            :  * @short    Read super table layout record
     104                 :            :  */
     105                 :          6 : void LwpSuperTableLayout::Read()
     106                 :            : {
     107                 :          6 :     LwpPlacableLayout::Read();
     108                 :          6 :     m_pObjStrm->SkipExtra();
     109                 :            : 
     110                 :          6 : }
     111                 :            : /**
     112                 :            :  * @short   Get child table layout
     113                 :            :  * @return pointer to table layout
     114                 :            :  */
     115                 :          6 : LwpTableLayout* LwpSuperTableLayout::GetTableLayout()
     116                 :            : {
     117                 :          6 :     LwpObjectID *pID = GetChildTail();
     118                 :            : 
     119 [ +  - ][ +  - ]:          6 :     while(pID && !pID->IsNull())
                 [ +  - ]
     120                 :            :     {
     121         [ -  + ]:          6 :         LwpLayout* pLayout = dynamic_cast<LwpLayout*>(pID->obj());
     122         [ -  + ]:          6 :         if (!pLayout)
     123                 :            :         {
     124                 :          0 :             break;
     125                 :            :         }
     126         [ +  - ]:          6 :         if (pLayout->GetLayoutType() == LWP_TABLE_LAYOUT)
     127                 :            :         {
     128         [ +  - ]:          6 :             return dynamic_cast<LwpTableLayout *>(pLayout);
     129                 :            :         }
     130                 :          0 :         pID = pLayout->GetPrevious();
     131                 :            :     }
     132                 :            : 
     133                 :          6 :     return NULL;
     134                 :            : }
     135                 :            : /**
     136                 :            :  * @short   Get effective heading table layout, the one just before table layout is the only one which is effective
     137                 :            :  * @return LwpTableHeadingLayout* - pointer to table heading layout
     138                 :            :  */
     139                 :          3 : LwpTableHeadingLayout* LwpSuperTableLayout::GetTableHeadingLayout()
     140                 :            : {
     141                 :          3 :     LwpObjectID *pID = GetChildTail();
     142                 :            : 
     143 [ +  - ][ +  + ]:          6 :     while(pID && !pID->IsNull())
                 [ +  + ]
     144                 :            :     {
     145         [ -  + ]:          3 :         LwpLayout * pLayout = dynamic_cast<LwpLayout *>(pID->obj());
     146         [ -  + ]:          3 :         if (!pLayout)
     147                 :            :         {
     148                 :          0 :             break;
     149                 :            :         }
     150                 :            : 
     151         [ -  + ]:          3 :         if (pLayout->GetLayoutType() == LWP_TABLE_HEADING_LAYOUT)
     152                 :            :         {
     153         [ #  # ]:          0 :             return dynamic_cast<LwpTableHeadingLayout *>(pLayout);
     154                 :            :         }
     155                 :          3 :         pID = pLayout->GetPrevious();
     156                 :            :     }
     157                 :            : 
     158                 :          3 :     return NULL;
     159                 :            : }
     160                 :            : /**
     161                 :            :  * @short   Register super table layout style
     162                 :            :  */
     163                 :          3 : void LwpSuperTableLayout::RegisterNewStyle()
     164                 :            : {
     165                 :            :     // if this layout is style of real table entry
     166                 :          3 :     LwpTableLayout* pTableLayout = GetTableLayout();
     167         [ +  - ]:          3 :     if (pTableLayout != NULL)
     168                 :            :     {
     169                 :          3 :         pTableLayout->SetFoundry(m_pFoundry);
     170                 :          3 :         pTableLayout->RegisterStyle();
     171                 :            :     }
     172                 :          3 : }
     173                 :            : /**
     174                 :            :  * @short   Judge whether table size is according to content, borrowed from Word Pro code
     175                 :            :  * @param
     176                 :            :  * @return sal_Bool
     177                 :            :  */
     178                 :          6 : sal_Bool LwpSuperTableLayout::IsSizeRightToContent()
     179                 :            : {
     180                 :            :     /* Only "with paragraph above" tables can size right to content. */
     181         [ +  - ]:          6 :     if (GetRelativeType() == LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE)
     182                 :          6 :         return LwpPlacableLayout::IsSizeRightToContent();
     183                 :            : 
     184                 :          6 :     return sal_False;
     185                 :            : }
     186                 :            : /**
     187                 :            :  * @short   Judge whether table is justifiable, borrowed from Word Pro code
     188                 :            :  * @param
     189                 :            :  * @return sal_Bool
     190                 :            :  */
     191                 :          6 : sal_Bool LwpSuperTableLayout::IsJustifiable()
     192                 :            : {
     193 [ +  - ][ +  - ]:          6 :     return (GetRelativeType() != LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE || IsSizeRightToContent());
     194                 :            : }
     195                 :            : /**
     196                 :            :  * @short   Get width of frame outside table
     197                 :            :  * @param pTableStyle - pointer of XFTableStyle
     198                 :            :  * @return double - table width
     199                 :            :  */
     200                 :          0 : double LwpSuperTableLayout::GetWidth()
     201                 :            : {
     202                 :          0 :     double dWidth = GetTableWidth();
     203                 :          0 :     double dLeft    = GetMarginsValue(MARGIN_LEFT);
     204                 :          0 :     double dRight   = GetMarginsValue(MARGIN_RIGHT);
     205                 :            : 
     206                 :          0 :     return (dWidth + dLeft + dRight);
     207                 :            : }
     208                 :            : /**
     209                 :            :  * @short   Get width of table
     210                 :            :  * @param pTableStyle - pointer of XFTableStyle
     211                 :            :  * @return double - table width
     212                 :            :  */
     213                 :          6 : double LwpSuperTableLayout::GetTableWidth()
     214                 :            : {
     215                 :          6 :     sal_Int32 nWidth = 0;
     216 [ +  - ][ +  - ]:          6 :     if(!IsJustifiable() || ((nWidth = LwpMiddleLayout::GetMinimumWidth()) <= 0))
         [ +  - ][ -  + ]
                 [ -  + ]
     217                 :            :     {
     218         [ #  # ]:          0 :         LwpTableLayout* pTableLayout = GetTableLayout();
     219         [ #  # ]:          0 :         if(!pTableLayout)
     220                 :            :         {
     221                 :            :             assert(sal_False);
     222                 :          0 :             return 0;
     223                 :            :         }
     224         [ #  # ]:          0 :         LwpTable *pTable = pTableLayout->GetTable();
     225         [ #  # ]:          0 :         if(!pTable)
     226                 :            :         {
     227                 :            :             assert(sal_False);
     228                 :          0 :             return 0;
     229                 :            :         }
     230                 :          0 :         double dDefaultWidth = pTable->GetWidth();
     231                 :          0 :         sal_uInt16 nCol = pTable->GetColumn();
     232                 :            : 
     233                 :          0 :         double dWidth = 0;
     234                 :            : 
     235         [ #  # ]:          0 :         for(sal_uInt16 i =0; i< nCol; i++)
     236                 :            :         {
     237                 :          0 :             LwpObjectID *pColumnID = pTableLayout->GetColumnLayoutHead();
     238 [ #  # ][ #  # ]:          0 :             LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj());
     239                 :          0 :             double dColumnWidth = dDefaultWidth;
     240         [ #  # ]:          0 :             while (pColumnLayout)
     241                 :            :             {
     242         [ #  # ]:          0 :                 if(pColumnLayout->GetColumnID() == i)
     243                 :            :                 {
     244         [ #  # ]:          0 :                     dColumnWidth = pColumnLayout->GetWidth();
     245                 :          0 :                     break;
     246                 :            :                 }
     247                 :          0 :                 pColumnID = pColumnLayout->GetNext();
     248 [ #  # ][ #  # ]:          0 :                 pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj());
     249                 :            :             }
     250                 :          0 :             dWidth += dColumnWidth;
     251                 :            :         }
     252                 :            : 
     253                 :          0 :         return dWidth;
     254                 :            :     }
     255                 :            : 
     256         [ +  - ]:          6 :     double dLeft    = GetMarginsValue(MARGIN_LEFT);
     257         [ +  - ]:          6 :     double dRight   = GetMarginsValue(MARGIN_RIGHT);
     258                 :          6 :     return LwpTools::ConvertFromUnitsToMetric(nWidth)-dLeft-dRight;
     259                 :            : 
     260                 :            : }
     261                 :            : /**
     262                 :            :  * @short   Apply shadow to table
     263                 :            :  * @param pTableStyle - pointer of XFTableStyle
     264                 :            :  * @return
     265                 :            :  */
     266                 :          3 : void LwpSuperTableLayout::ApplyShadow(XFTableStyle *pTableStyle)
     267                 :            : {
     268                 :            :     // use shadow property of supertable
     269                 :          3 :     XFShadow* pXFShadow = GetXFShadow();
     270         [ -  + ]:          3 :     if(pXFShadow)
     271                 :            :     {
     272                 :          0 :         pTableStyle->SetShadow(pXFShadow->GetPosition(), pXFShadow->GetOffset(), pXFShadow->GetColor());
     273                 :            :     }
     274                 :          3 : }
     275                 :            : /**
     276                 :            :  * @short   Apply pattern fill to table style
     277                 :            :  * @param pTableStyle - pointer of XFTableStyle
     278                 :            :  * @return
     279                 :            :  */
     280                 :          0 : void LwpSuperTableLayout::ApplyPatternFill(XFTableStyle* pTableStyle)
     281                 :            : {
     282                 :          0 :     XFBGImage* pXFBGImage = this->GetFillPattern();
     283         [ #  # ]:          0 :     if (pXFBGImage)
     284                 :            :     {
     285                 :          0 :         pTableStyle->SetBackImage(pXFBGImage);
     286                 :            :     }
     287                 :          0 : }
     288                 :            : 
     289                 :            : /**
     290                 :            :  * @short   Apply background to table style
     291                 :            :  * @param pTableStyle - pointer of XFTableStyle
     292                 :            :  * @return
     293                 :            :  */
     294                 :          3 : void LwpSuperTableLayout::ApplyBackGround(XFTableStyle* pTableStyle)
     295                 :            : {
     296         [ -  + ]:          3 :     if (this->IsPatternFill())
     297                 :            :     {
     298                 :          0 :         ApplyPatternFill(pTableStyle);
     299                 :            :     }
     300                 :            :     else
     301                 :            :     {
     302                 :          3 :         ApplyBackColor(pTableStyle);
     303                 :            :     }
     304                 :          3 : }
     305                 :            : /**
     306                 :            :  * @short   Apply back color to table
     307                 :            :  * @param pTableStyle - pointer of XFTableStyle
     308                 :            :  * @return
     309                 :            :  */
     310                 :          3 : void LwpSuperTableLayout::ApplyBackColor(XFTableStyle *pTableStyle)
     311                 :            : {
     312                 :          3 :     LwpColor* pColor = GetBackColor();
     313 [ #  # ][ -  + ]:          3 :     if(pColor && pColor->IsValidColor())
                 [ -  + ]
     314                 :            :     {
     315         [ #  # ]:          0 :         XFColor aColor(pColor->To24Color());
     316                 :          0 :         pTableStyle->SetBackColor(aColor);
     317                 :            :     }
     318                 :          3 : }
     319                 :            : /**
     320                 :            :  * @short   Apply watermark to  table
     321                 :            :  * @param pTableStyle - pointer of XFTableStyle
     322                 :            :  * @return
     323                 :            :  */
     324                 :          3 : void LwpSuperTableLayout::ApplyWatermark(XFTableStyle *pTableStyle)
     325                 :            : {
     326                 :          3 :     XFBGImage* pBGImage = GetXFBGImage();
     327         [ -  + ]:          3 :     if(pBGImage)
     328                 :            :     {
     329                 :          0 :         pTableStyle->SetBackImage(pBGImage);
     330                 :            :     }
     331                 :          3 : }
     332                 :            : /**
     333                 :            :  * @short   Apply alignment  to table
     334                 :            :  * @param pTableStyle - pointer of XFTableStyle
     335                 :            :  * @return
     336                 :            :  */
     337                 :          3 : void LwpSuperTableLayout::ApplyAlignment(XFTableStyle * pTableStyle)
     338                 :            : {
     339         [ +  - ]:          3 :     LwpPoint aPoint;
     340 [ +  - ][ +  - ]:          3 :     if (GetGeometry())
     341         [ +  - ]:          3 :         aPoint = GetGeometry()->GetOrigin();
     342                 :            :     //LwpPoint aPoint = GetOrigin();
     343                 :          3 :     double dXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
     344                 :            : 
     345                 :            :     // add left padding to alignment distance
     346         [ +  - ]:          3 :     double dLeft = GetMarginsValue(MARGIN_LEFT);
     347                 :            : 
     348                 :          3 :     pTableStyle->SetAlign(enumXFAlignStart, dXOffset+ dLeft);
     349                 :          3 : }
     350                 :            : /**
     351                 :            :  * @short   Add table to container
     352                 :            :  * @param pCont - pointer of container
     353                 :            :  * @return pCont
     354                 :            :  */
     355                 :          3 : void  LwpSuperTableLayout::XFConvert(XFContentContainer* pCont)
     356                 :            : {
     357   [ +  -  +  - ]:          6 :     if ( LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == GetRelativeType()
                 [ +  - ]
     358                 :          3 :             && !GetContainerLayout()->IsCell())
     359                 :            :     {
     360                 :          3 :         LwpTableLayout * pTableLayout = GetTableLayout();
     361         [ +  - ]:          3 :         if (pTableLayout)
     362                 :            :         {
     363                 :          3 :             pTableLayout->XFConvert(pCont);
     364                 :            :         }
     365                 :            :     }
     366         [ #  # ]:          0 :     else if(IsRelativeAnchored())
     367                 :            :     {
     368                 :            :         //anchor to paragraph except "with paragraph above"
     369                 :          0 :         XFConvertFrame(pCont);
     370                 :            :     }
     371         [ #  # ]:          0 :     else if(m_pFrame)
     372                 :            :     {
     373                 :            :         //anchor to page, frame, cell
     374                 :          0 :         m_pFrame->XFConvert(pCont);
     375                 :            :     }
     376                 :          3 : }
     377                 :            : /**
     378                 :            :  * @short   convert frame which anchor to page
     379                 :            :  * @param
     380                 :            :  * @return
     381                 :            :  */
     382                 :          0 : void  LwpSuperTableLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart , sal_Int32 nEnd , sal_Bool bAll)
     383                 :            : {
     384         [ #  # ]:          0 :     if(m_pFrame)
     385                 :            :     {
     386                 :          0 :         XFFrame* pXFFrame = NULL;
     387         [ #  # ]:          0 :         if(nEnd < nStart)
     388                 :            :         {
     389         [ #  # ]:          0 :             pXFFrame = new XFFrame();
     390                 :            :         }
     391                 :            :         else
     392                 :            :         {
     393         [ #  # ]:          0 :             pXFFrame = new XFFloatFrame(nStart, nEnd, bAll);
     394                 :            :         }
     395                 :            : 
     396                 :          0 :         m_pFrame->Parse(pXFFrame, static_cast<sal_uInt16>(nStart));
     397                 :            :         //parse table, and add table to frame
     398                 :          0 :         LwpTableLayout * pTableLayout = GetTableLayout();
     399         [ #  # ]:          0 :         if (pTableLayout)
     400                 :            :         {
     401                 :          0 :             pTableLayout->XFConvert(pXFFrame);
     402                 :            :         }
     403                 :            :         //add frame to the container
     404                 :          0 :         pCont ->Add(pXFFrame);
     405                 :            :     }
     406                 :            : 
     407                 :          0 : }
     408                 :            : /**
     409                 :            :  * @short  register frame style
     410                 :            :  * @param
     411                 :            :  * @return
     412                 :            :  */
     413                 :          0 : void  LwpSuperTableLayout::RegisterFrameStyle()
     414                 :            : {
     415         [ #  # ]:          0 :     XFFrameStyle* pFrameStyle = new XFFrameStyle();
     416                 :          0 :     m_pFrame->RegisterStyle(pFrameStyle);
     417                 :          0 : }
     418                 :            : 
     419                 :          6 : LwpTableLayout::LwpTableLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
     420 [ +  - ][ +  - ]:          6 :     : LwpLayout(objHdr, pStrm), m_nRows(0), m_nCols(0), m_pXFTable(NULL)
         [ +  - ][ +  - ]
     421                 :            : {
     422                 :          6 :     m_CellsMap.clear();
     423                 :          6 :     m_pColumns = NULL;
     424                 :          6 : }
     425                 :            : 
     426                 :          6 : LwpTableLayout::~LwpTableLayout()
     427                 :            : {
     428                 :          6 :     m_CellsMap.clear();
     429                 :            : 
     430         [ +  + ]:          6 :     if (m_pColumns)
     431                 :            :     {
     432         [ +  - ]:          3 :         delete [] m_pColumns;
     433                 :          3 :         m_pColumns = NULL;
     434                 :            :     }
     435         [ -  + ]:          9 : }
     436                 :            : /**
     437                 :            :  * @short   Get neighbour cell by specifying ROW+COL
     438                 :            :  * @param   nRow
     439                 :            :  * @param   nCol
     440                 :            :  * @return   LwpCellLayout *
     441                 :            :  */
     442                 :        120 : LwpCellLayout * LwpTableLayout::GetCellByRowCol(sal_uInt16 nRow, sal_uInt16 nCol)
     443                 :            : {
     444 [ +  + ][ +  + ]:        120 :     if (nRow >= m_nRows || nCol >= m_nCols)
     445                 :         27 :         return NULL;
     446                 :            : 
     447                 :        120 :     return m_WordProCellsMap[nRow*m_nCols + nCol];
     448                 :            : }
     449                 :            : /**
     450                 :            :  * @short   traverse all table cells
     451                 :            :  * @param
     452                 :            :  * @param
     453                 :            :  * @param
     454                 :            :  */
     455                 :          3 : void LwpTableLayout::TraverseTable()
     456                 :            : {
     457                 :          3 :     sal_uInt32 nCount = m_nRows*m_nCols;
     458                 :            : 
     459                 :            :     // new cell map nRow*nCOl and initialize
     460         [ +  + ]:         63 :     for (sal_uInt32 iLoop = 0; iLoop < nCount; ++iLoop)
     461                 :            :     {
     462         [ +  - ]:         60 :         m_WordProCellsMap.push_back(GetDefaultCellLayout());
     463                 :            :     }
     464                 :            : 
     465                 :            :     // set value
     466                 :          3 :     LwpObjectID *pRowID = GetChildHead();
     467         [ -  + ]:          3 :     LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj());
     468         [ +  + ]:         18 :     while (pRowLayout)
     469                 :            :     {
     470                 :         15 :         pRowLayout->SetRowMap();
     471                 :            : 
     472                 :            :         // for 's analysis job
     473         [ +  - ]:         15 :         m_RowsMap[pRowLayout->GetRowID()] = pRowLayout;
     474                 :         15 :         pRowLayout->CollectMergeInfo();
     475                 :            :         // end for 's analysis
     476                 :            : 
     477                 :         15 :         pRowID = pRowLayout->GetNext();
     478         [ +  + ]:         15 :         pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj());
     479                 :            :     }
     480                 :          3 : }
     481                 :            : 
     482                 :            : /**
     483                 :            :  * @short   search the cell map
     484                 :            :  * @param   nRow - row id (0 based)
     485                 :            :  * @param   nRow - row id (0 based)
     486                 :            :  * @return   LwpObjectID * - pointer to cell story object ID
     487                 :            :  */
     488                 :          0 : LwpObjectID * LwpTableLayout::SearchCellStoryMap(sal_uInt16 nRow, sal_uInt16 nCol)
     489                 :            : {
     490 [ #  # ][ #  # ]:          0 :     if (nRow >= m_nRows || nCol >= m_nCols )
     491                 :            :     {
     492                 :          0 :         return NULL;
     493                 :            :     }
     494                 :            : 
     495                 :          0 :     LwpCellLayout * pCell = GetCellByRowCol(nRow, nCol);
     496         [ #  # ]:          0 :     if (pCell)
     497                 :            :     {
     498                 :            :         // maybe connected cell layout
     499                 :            :         // maybe default cell layout
     500 [ #  # ][ #  # ]:          0 :         if (nRow != pCell->GetRowID() || nCol != pCell->GetColID())
                 [ #  # ]
     501                 :            :         {
     502                 :          0 :             return NULL;
     503                 :            :         }
     504                 :          0 :         return pCell->GetContent();
     505                 :            :     }
     506                 :            : 
     507                 :          0 :     return NULL;
     508                 :            : }
     509                 :            : 
     510                 :            : /**
     511                 :            :  * @short   Get parent super table layout of table layout
     512                 :            :  * @return  LwpSuperTableLayout * - pointer of parent super table layout
     513                 :            :  */
     514                 :         69 : LwpSuperTableLayout * LwpTableLayout::GetSuperTableLayout()
     515                 :            : {
     516         [ +  - ]:         69 :     return dynamic_cast<LwpSuperTableLayout *>(GetParent()->obj());
     517                 :            : }
     518                 :            : /**
     519                 :            :  * @short    Get table pointer
     520                 :            :  * @return   LwpTable * - content table pointer
     521                 :            :  */
     522                 :         54 : LwpTable *  LwpTableLayout::GetTable()
     523                 :            : {
     524         [ -  + ]:         54 :     LwpTable *pTable = dynamic_cast<LwpTable *>(m_Content.obj());
     525                 :         54 :     return pTable;
     526                 :            : }
     527                 :            : /**
     528                 :            :  * @short   Get column style name by column ID
     529                 :            :  * @param   sal_uInt16 -- col id(0 based)
     530                 :            :  * @return OUString - name of column style
     531                 :            :  */
     532                 :          0 : OUString LwpTableLayout::GetColumnWidth(sal_uInt16 nCol)
     533                 :            : {
     534         [ #  # ]:          0 :     if (nCol >= m_nCols)
     535                 :            :     {
     536                 :            :         assert(sal_False);
     537                 :          0 :         return m_DefaultColumnStyleName;
     538                 :            :     }
     539                 :            : 
     540                 :          0 :     LwpColumnLayout * pCol = m_pColumns[nCol];
     541         [ #  # ]:          0 :     if (pCol)
     542                 :            :     {
     543                 :          0 :         return pCol->GetStyleName();
     544                 :            :     }
     545                 :            : 
     546                 :          0 :     return m_DefaultColumnStyleName;
     547                 :            : }
     548                 :            : /**
     549                 :            :  * @short   analyze all columns to get whole table width and width of all columns
     550                 :            :  * @short   and register all column styles
     551                 :            :  * @param   none
     552                 :            :  */
     553                 :          3 : void LwpTableLayout::RegisterColumns()
     554                 :            : {
     555                 :          3 :     LwpTable * pTable = GetTable();
     556                 :          3 :     LwpSuperTableLayout * pSuper = GetSuperTableLayout();
     557                 :            : 
     558                 :          3 :     sal_uInt16 nCols = m_nCols;
     559                 :            : 
     560                 :          3 :     m_pColumns = new LwpColumnLayout *[nCols];
     561                 :          3 :     sal_Bool * pWidthCalculated = new sal_Bool[nCols];
     562         [ +  + ]:         15 :     for(sal_uInt16 i=0;i<nCols; i++)
     563                 :            :     {
     564                 :         12 :         pWidthCalculated[i] = sal_False;
     565                 :         12 :         m_pColumns[i] = NULL;
     566                 :            :     }
     567                 :            : 
     568                 :          3 :     double dDefaultColumn = pTable->GetWidth();
     569                 :          3 :     sal_uInt16 nJustifiableColumn = nCols;
     570                 :            : 
     571                 :          3 :     double dTableWidth = pSuper->GetTableWidth();
     572                 :            : 
     573                 :            :     // Get total width of justifiable columns
     574                 :            :     // NOTICE: all default columns are regarded as justifiable columns
     575                 :          3 :     LwpObjectID *pColumnID = GetColumnLayoutHead();
     576         [ +  - ]:          3 :     LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj());
     577         [ -  + ]:          3 :     while (pColumnLayout)
     578                 :            :     {
     579                 :          0 :         m_pColumns[pColumnLayout->GetColumnID()] = pColumnLayout;
     580         [ #  # ]:          0 :         if (!pColumnLayout->IsJustifiable())
     581                 :            :         {
     582                 :          0 :             pWidthCalculated[pColumnLayout->GetColumnID()] = sal_True;
     583                 :          0 :             dTableWidth -= pColumnLayout->GetWidth();
     584                 :          0 :             nJustifiableColumn --;
     585                 :            :         }
     586                 :            : 
     587                 :          0 :         pColumnID = pColumnLayout->GetNext();
     588         [ #  # ]:          0 :         pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj());
     589                 :            :     }
     590                 :            : 
     591                 :            :     // if all columns are not justifiable, the rightmost column will be changed to justifiable
     592         [ -  + ]:          3 :     if(nJustifiableColumn == 0)
     593                 :            :     {
     594                 :          0 :         nJustifiableColumn ++;
     595         [ #  # ]:          0 :         if (m_pColumns[nCols - 1])
     596                 :            :         {
     597                 :          0 :             pWidthCalculated[nCols-1] = sal_False;
     598                 :          0 :             dTableWidth += m_pColumns[nCols-1]->GetWidth();
     599                 :            :         }
     600                 :            :         else
     601                 :            :         {
     602                 :            :             // this can't happen
     603                 :          0 :             dTableWidth = dDefaultColumn;
     604                 :            :             assert(sal_False);
     605                 :            :         }
     606                 :            :     }
     607                 :            : 
     608                 :            :     // justifiable columns will share the remain width averagely
     609                 :          3 :     dDefaultColumn = dTableWidth/nJustifiableColumn;
     610                 :            : 
     611                 :            :     // register default column style
     612         [ +  - ]:          3 :     XFColStyle *pColStyle = new XFColStyle();
     613                 :          3 :     pColStyle->SetWidth(static_cast<float>(dDefaultColumn));
     614                 :            : 
     615                 :          3 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     616                 :          3 :     m_DefaultColumnStyleName =  pXFStyleManager->AddStyle(pColStyle)->GetStyleName();
     617                 :            : 
     618                 :            :     // register existed column style
     619                 :          3 :     sal_uInt16 i=0;
     620         [ +  + ]:         15 :     for( i=0;i<nCols; i++)
     621                 :            :     {
     622         [ -  + ]:         12 :         if(m_pColumns[i])
     623                 :            :         {
     624                 :          0 :             m_pColumns[i]->SetFoundry(m_pFoundry);
     625         [ #  # ]:          0 :             if(!pWidthCalculated[i])
     626                 :            :             {
     627                 :            :                 // justifiable ----register style with calculated value
     628                 :          0 :                 m_pColumns[i]->SetStyleName(m_DefaultColumnStyleName);
     629                 :            :             }
     630                 :            :             else
     631                 :            :             {
     632                 :            :                 // not justifiable ---- register style with original value
     633                 :          0 :                 m_pColumns[i]->RegisterStyle(m_pColumns[i]->GetWidth());
     634                 :            :             }
     635                 :            :         }
     636                 :            :     }
     637         [ +  - ]:          3 :     delete [] pWidthCalculated;
     638                 :          3 : }
     639                 :            : /**
     640                 :            :  * @short    register all row styles
     641                 :            :  * @param   none
     642                 :            :  */
     643                 :          3 : void LwpTableLayout::RegisterRows()
     644                 :            : {
     645                 :          3 :     LwpTable * pTable = GetTable();
     646         [ -  + ]:          3 :     if (pTable == NULL)
     647                 :            :     {
     648                 :            :         assert(sal_False);
     649                 :          3 :         return;
     650                 :            :     }
     651                 :            : 
     652                 :            :     // register default row style
     653         [ +  - ]:          3 :     XFRowStyle * pRowStyle = new  XFRowStyle();
     654         [ +  - ]:          3 :     if (m_nDirection & 0x0030)
     655                 :            :     {
     656                 :          3 :         pRowStyle->SetMinRowHeight((float)pTable->GetHeight());
     657                 :            :     }
     658                 :            :     else
     659                 :            :     {
     660                 :          0 :         pRowStyle->SetRowHeight((float)pTable->GetHeight());
     661                 :            :     }
     662                 :          3 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     663                 :          3 :     m_DefaultRowStyleName =  pXFStyleManager->AddStyle(pRowStyle)->GetStyleName();
     664                 :            : 
     665                 :            :     // register style of rows
     666                 :          3 :     LwpObjectID * pRowID = GetChildHead();
     667         [ -  + ]:          3 :     LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj());
     668         [ +  + ]:         18 :     while (pRowLayout)
     669                 :            :     {
     670                 :         15 :         pRowLayout->SetFoundry(m_pFoundry);
     671                 :         15 :         pRowLayout->RegisterStyle();
     672                 :            : 
     673                 :         15 :         pRowID = pRowLayout->GetNext();
     674         [ +  + ]:         15 :         pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj());
     675                 :            :     }
     676                 :            : }
     677                 :            : /**
     678                 :            :  * @short   register table style, if needed, including frame style
     679                 :            :  * @param   none
     680                 :            :  */
     681                 :          3 : void LwpTableLayout::RegisterStyle()
     682                 :            : {
     683                 :            :     // get super table layout
     684                 :          3 :     LwpSuperTableLayout * pSuper = GetSuperTableLayout();
     685         [ -  + ]:          3 :     if(!pSuper)
     686                 :            :     {
     687                 :            :         assert(sal_False);
     688                 :          0 :         return;
     689                 :            :     }
     690                 :            : 
     691                 :            :     // get table
     692                 :          3 :     LwpTable * pTable = GetTable();
     693         [ -  + ]:          3 :     if (pTable == NULL)
     694                 :            :     {
     695                 :            :         assert(sal_False);
     696                 :          0 :         return;
     697                 :            :     }
     698                 :            : 
     699                 :            :     // get row/column number of this table
     700                 :          3 :     m_nRows = pTable->GetRow();
     701                 :          3 :     m_nCols = pTable->GetColumn();
     702                 :            : 
     703                 :            :     // get default cell layout of current table
     704                 :          3 :     LwpObjectID * pID= pTable->GetDefaultCellStyle();
     705         [ +  - ]:          3 :     if (pID)
     706                 :            :     {
     707         [ -  + ]:          3 :         m_pDefaultCellLayout = dynamic_cast<LwpCellLayout *>(pID->obj());
     708                 :            :     }
     709                 :            : 
     710                 :            :     // register columns styles
     711                 :          3 :     RegisterColumns();
     712                 :            : 
     713                 :            :     // register style of whole table
     714         [ +  - ]:          3 :     XFTableStyle * pTableStyle = new XFTableStyle();
     715                 :            : 
     716                 :          3 :     sal_uInt8 nType = pSuper->GetRelativeType();
     717                 :            :     // If the table is not "with paragraph above" placement, create an frame style
     718                 :            :     // by supertable layout
     719         [ +  - ]:          6 :     if ( LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == nType
           [ +  -  +  - ]
     720                 :          3 :         && !pSuper->GetContainerLayout()->IsCell())
     721                 :            :     {
     722                 :            :         //with para above
     723                 :            : //      pSuper->ApplyBackColor(pTableStyle);
     724                 :          3 :         pSuper->ApplyBackGround(pTableStyle);
     725                 :          3 :         pSuper->ApplyWatermark(pTableStyle);
     726                 :          3 :         pSuper->ApplyShadow(pTableStyle);
     727                 :          3 :         pSuper->ApplyAlignment(pTableStyle);
     728                 :          3 :         pTableStyle->SetWidth(pSuper->GetTableWidth());
     729                 :            :     }
     730                 :            :     else
     731                 :            :     {
     732                 :          0 :         pSuper->RegisterFrameStyle();
     733                 :          0 :         pTableStyle->SetAlign(enumXFAlignCenter);
     734                 :          0 :         pTableStyle->SetWidth(pSuper->GetTableWidth());
     735                 :            :     }
     736                 :          3 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     737                 :          3 :     m_StyleName = pXFStyleManager->AddStyle(pTableStyle)->GetStyleName();
     738                 :            : 
     739                 :            :     //convert to OO table now and register row stle
     740                 :            :     // traverse
     741                 :          3 :     TraverseTable();
     742                 :            : 
     743                 :          3 :     SplitConflictCells();
     744                 :            : 
     745                 :            :     // Register rows layouts, it must be after SplitConflictCells
     746                 :          3 :     RegisterRows();
     747                 :            : 
     748                 :            :     // Parse table
     749                 :          3 :     ParseTable();
     750                 :            : 
     751                 :            : 
     752                 :            :     //Comment:The old code doesn't check if the LwpFoundry pointer is NULL,
     753                 :            :     //        So the NULL pointer cause sodc frozee. Add code to check the
     754                 :            :     //        the pointer.
     755                 :            :     //New Code
     756 [ +  - ][ +  - ]:          3 :     if( GetFoundry() && GetTable() )
                 [ +  - ]
     757                 :            : 
     758                 :          3 :     PutCellVals( GetFoundry(),*GetTable()->GetObjectID() );
     759                 :            : }
     760                 :            : /**
     761                 :            :  * @short   read table layout
     762                 :            :  * @param   none
     763                 :            :  */
     764                 :          3 : void LwpTableLayout::ParseTable()
     765                 :            : {
     766                 :            :     // get super table layout
     767         [ +  - ]:          3 :     LwpSuperTableLayout * pSuper = GetSuperTableLayout();
     768         [ +  - ]:          3 :     if(!pSuper)
     769                 :            :     {
     770                 :            :         assert(sal_False);
     771                 :          3 :         return;
     772                 :            :     }
     773                 :            : 
     774                 :            :     // set name of object
     775 [ +  - ][ +  - ]:          3 :     m_pXFTable = new XFTable;
     776                 :          3 :     m_pXFTable->SetTableName(pSuper->GetName()->str());
     777                 :            :     // set table style
     778         [ +  - ]:          3 :     m_pXFTable->SetStyleName(m_StyleName);
     779                 :            : 
     780                 :          3 :     sal_uInt16 nRow = m_nRows;
     781                 :          3 :     sal_uInt8 nCol = (sal_uInt8)m_nCols;
     782                 :            : 
     783                 :            :     //process header rows
     784                 :            :     LwpTableHeadingLayout* pTableHeading;
     785         [ +  - ]:          3 :     pTableHeading = pSuper->GetTableHeadingLayout();
     786                 :            :     sal_uInt16 nStartHeadRow;
     787                 :            :     sal_uInt16 nEndHeadRow;
     788                 :            :     sal_uInt16 nContentRow;
     789         [ -  + ]:          3 :     if (pTableHeading)
     790                 :            :     {
     791                 :          0 :         pTableHeading->GetStartEndRow(nStartHeadRow,nEndHeadRow);
     792         [ #  # ]:          0 :         if (nStartHeadRow != 0)
     793         [ #  # ]:          0 :             ConvertTable(m_pXFTable,0,nRow,0,nCol);
     794                 :            :         else
     795                 :            :         {
     796         [ #  # ]:          0 :             nContentRow = ConvertHeadingRow(m_pXFTable,nStartHeadRow,nEndHeadRow+1);
     797         [ #  # ]:          0 :             ConvertTable(m_pXFTable,nContentRow,nRow,0,nCol);
     798                 :            :         }
     799                 :            :     }
     800                 :            :     else
     801         [ +  - ]:          3 :         ConvertTable(m_pXFTable,0,nRow,0,nCol);
     802                 :            : }
     803                 :            : 
     804                 :            : /**
     805                 :            :  * @short   read table layout
     806                 :            :  * @param   none
     807                 :            :  */
     808                 :          6 : void LwpTableLayout::Read()
     809                 :            : {
     810                 :          6 :     LwpLayout::Read();
     811                 :            : 
     812                 :            :     // before layout hierarchy rework!
     813                 :          6 :     if(LwpFileHeader::m_nFileRevision < 0x000b)
     814                 :            :     {
     815                 :            :         assert(sal_False);
     816                 :            :     }
     817                 :          6 :     m_ColumnLayout.ReadIndexed(m_pObjStrm);
     818                 :            : 
     819                 :          6 :     m_pObjStrm->SkipExtra();
     820                 :          6 : }
     821                 :            : 
     822                 :            : /**
     823                 :            :  * @short    Convert table
     824                 :            :  * @param
     825                 :            :  * @return   pCont - container which will contain table
     826                 :            :  */
     827                 :          3 : void LwpTableLayout::XFConvert(XFContentContainer* pCont)
     828                 :            : {
     829                 :            : 
     830                 :          3 :     pCont->Add(m_pXFTable);
     831                 :          3 : }
     832                 :            : /**
     833                 :            :  * @short   convert heading row
     834                 :            :  * @param  pXFTable - pointer of table
     835                 :            :  * @param  nStartRow - start heading row ID
     836                 :            :  * @param  nEndRow - end heading row ID
     837                 :            :  */
     838                 :          0 : sal_uInt16 LwpTableLayout::ConvertHeadingRow(
     839                 :            :         XFTable* pXFTable,sal_uInt16 nStartHeadRow,sal_uInt16 nEndHeadRow)
     840                 :            : {
     841                 :            :     sal_uInt16 nContentRow;
     842                 :          0 :     sal_uInt8 nCol = static_cast<sal_uInt8>(GetTable()->GetColumn());
     843         [ #  # ]:          0 :     XFTable* pTmpTable = new XFTable;
     844                 :            :     XFRow* pXFRow;
     845                 :            : 
     846                 :          0 :     ConvertTable(pTmpTable,nStartHeadRow,nEndHeadRow,0,nCol);
     847                 :            : 
     848                 :          0 :     sal_uInt16 nRowNum = static_cast<sal_uInt16>(pTmpTable->GetRowCount());
     849                 :          0 :     sal_uInt8* CellMark = new sal_uInt8[nRowNum];
     850                 :          0 :     sal_Bool bFindFlag = sal_False;
     851                 :            : 
     852         [ #  # ]:          0 :     if (nRowNum == 1)
     853                 :            :     {
     854                 :          0 :         pXFRow = pTmpTable->GetRow(1);
     855                 :          0 :         pXFTable->AddHeaderRow(pXFRow);
     856                 :          0 :         pTmpTable->RemoveRow(1);
     857                 :          0 :         nContentRow = nEndHeadRow;
     858                 :            :     }
     859                 :            :     else
     860                 :            :     {
     861                 :          0 :         sal_uInt8 nFirstColSpann = 1;
     862         [ #  # ]:          0 :         bFindFlag = FindSplitColMark(pTmpTable,CellMark,nFirstColSpann);
     863                 :            : 
     864         [ #  # ]:          0 :         if (bFindFlag)//split to 2 cells
     865                 :            :         {
     866         [ #  # ]:          0 :             SplitRowToCells(pTmpTable,pXFTable,nFirstColSpann,CellMark);
     867                 :          0 :             nContentRow = nEndHeadRow;
     868                 :            :         }
     869                 :            :         else//can not split,the first row will be the heading row,the rest will be content row
     870                 :            :         {
     871         [ #  # ]:          0 :             pXFRow = pTmpTable->GetRow(1);
     872         [ #  # ]:          0 :             pXFTable->AddHeaderRow(pXFRow);
     873         [ #  # ]:          0 :             pTmpTable->RemoveRow(1);
     874 [ #  # ][ #  # ]:          0 :             nContentRow = m_RowsMap[0]->GetCurMaxSpannedRows(0,nCol);
     875                 :            :         }
     876                 :            :     }
     877         [ #  # ]:          0 :     delete pTmpTable;
     878         [ #  # ]:          0 :     delete [] CellMark;
     879                 :          0 :     return nContentRow;
     880                 :            : }
     881                 :            : 
     882                 :          0 : void LwpTableLayout::SplitRowToCells(XFTable* pTmpTable,XFTable* pXFTable,
     883                 :            :         sal_uInt8 nFirstColSpann,sal_uInt8* pCellMark)
     884                 :            : {
     885                 :            :     sal_uInt16 i;
     886                 :            :     sal_uInt8 j;
     887         [ #  # ]:          0 :     sal_uInt16 nRowNum = static_cast<sal_uInt16>(pTmpTable->GetRowCount());
     888         [ #  # ]:          0 :     sal_uInt8 nCol = static_cast<sal_uInt8>(GetTable()->GetColumn());
     889                 :            : 
     890 [ #  # ][ #  # ]:          0 :     XFRow* pXFRow = new XFRow;
     891                 :            : 
     892                 :            :     //register style for heading row
     893                 :          0 :     double fHeight = 0;
     894                 :          0 :     OUString styleName;
     895 [ #  # ][ #  # ]:          0 :     XFRowStyle* pRowStyle = new XFRowStyle;
     896 [ #  # ][ #  # ]:          0 :     styleName = pTmpTable->GetRow(1)->GetStyleName();
     897                 :            : 
     898                 :            :     // get settings of the row and assign them to new row style
     899         [ #  # ]:          0 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     900         [ #  # ]:          0 :     XFRowStyle *pTempRowStyle = static_cast<XFRowStyle*>(pXFStyleManager->FindStyle(styleName));
     901         [ #  # ]:          0 :     if (pTempRowStyle)
     902         [ #  # ]:          0 :         *pRowStyle = *pTempRowStyle;
     903                 :            : 
     904         [ #  # ]:          0 :     for (i=1;i<=nRowNum;i++)
     905                 :            :     {
     906 [ #  # ][ #  # ]:          0 :         styleName = pTmpTable->GetRow(i)->GetStyleName();
     907         [ #  # ]:          0 :         fHeight+=static_cast<XFRowStyle*>(pXFStyleManager->FindStyle(styleName))->GetRowHeight();
     908                 :            :     }
     909         [ #  # ]:          0 :     if (m_nDirection & 0x0030)
     910                 :            :     {
     911                 :          0 :         pRowStyle->SetMinRowHeight((float)fHeight);
     912                 :            :     }
     913                 :            :     else
     914                 :            :     {
     915                 :          0 :         pRowStyle->SetRowHeight((float)fHeight);
     916                 :            :     }
     917 [ #  # ][ #  # ]:          0 :     pXFRow->SetStyleName(pXFStyleManager->AddStyle(pRowStyle)->GetStyleName());
                 [ #  # ]
     918                 :            : 
     919                 :            :     //construct headong row
     920 [ #  # ][ #  # ]:          0 :     XFCell* pXFCell1 = new XFCell;
     921 [ #  # ][ #  # ]:          0 :     XFCell* pXFCell2 = new XFCell;
     922 [ #  # ][ #  # ]:          0 :     XFTable* pSubTable1 = new XFTable;
     923 [ #  # ][ #  # ]:          0 :     XFTable* pSubTable2 = new XFTable;
     924                 :            :     XFRow* pNewRow;
     925                 :            :     XFRow* pOldRow;
     926                 :            :     XFCell* pNewCell;
     927                 :            : 
     928         [ #  # ]:          0 :     for (i=1;i<=nRowNum;i++)
     929                 :            :     {
     930         [ #  # ]:          0 :         pOldRow = pTmpTable->GetRow(i);
     931 [ #  # ][ #  # ]:          0 :         pNewRow = new XFRow;
     932 [ #  # ][ #  # ]:          0 :         pNewRow->SetStyleName(pOldRow->GetStyleName());
     933         [ #  # ]:          0 :         for (j=1;j<=pCellMark[i];j++)
     934                 :            :         {
     935         [ #  # ]:          0 :             pNewCell = pOldRow->GetCell(j);
     936         [ #  # ]:          0 :             pNewRow->AddCell(pNewCell);
     937                 :            :         }
     938         [ #  # ]:          0 :         pSubTable1->AddRow(pNewRow);
     939                 :            :     }
     940         [ #  # ]:          0 :     ConvertColumn(pSubTable1,0,nFirstColSpann);//add column info
     941                 :            : 
     942         [ #  # ]:          0 :     pXFCell1->Add(pSubTable1);
     943                 :          0 :     pXFCell1->SetColumnSpaned(nFirstColSpann);
     944         [ #  # ]:          0 :     pXFRow->AddCell(pXFCell1);
     945                 :            : 
     946         [ #  # ]:          0 :     for (i=1;i<=nRowNum;i++)
     947                 :            :     {
     948         [ #  # ]:          0 :         pOldRow = pTmpTable->GetRow(i);
     949 [ #  # ][ #  # ]:          0 :         pNewRow = new XFRow;
     950 [ #  # ][ #  # ]:          0 :         pNewRow->SetStyleName(pOldRow->GetStyleName());
     951 [ #  # ][ #  # ]:          0 :         for(j=pCellMark[i]+1;j<=pOldRow->GetCellCount();j++)
     952                 :            :         {
     953         [ #  # ]:          0 :             pNewCell = pOldRow->GetCell(j);
     954         [ #  # ]:          0 :             pNewRow->AddCell(pNewCell);
     955                 :            :         }
     956         [ #  # ]:          0 :         pSubTable2->AddRow(pNewRow);
     957                 :            : 
     958                 :            :     }
     959         [ #  # ]:          0 :     ConvertColumn(pSubTable2,nFirstColSpann,nCol);//add column info
     960         [ #  # ]:          0 :     pXFCell2->Add(pSubTable2);
     961                 :          0 :     pXFCell2->SetColumnSpaned(nCol-nFirstColSpann);
     962         [ #  # ]:          0 :     pXFRow->AddCell(pXFCell2);
     963                 :            : 
     964         [ #  # ]:          0 :     pXFTable->AddHeaderRow(pXFRow);
     965                 :            : 
     966                 :            :     //remove tmp table
     967         [ #  # ]:          0 :     for (i=1;i<=nRowNum;i++)
     968                 :            :     {
     969         [ #  # ]:          0 :         pOldRow = pTmpTable->GetRow(i);
     970 [ #  # ][ #  # ]:          0 :         for(j=1;j<=pOldRow->GetCellCount();j++)
     971         [ #  # ]:          0 :             pOldRow->RemoveCell(j);
     972         [ #  # ]:          0 :         pTmpTable->RemoveRow(i);
     973                 :          0 :     }
     974                 :          0 : }
     975                 :            : 
     976                 :            : /**
     977                 :            :  * @short   find if the heading rows can be split to 2 cells
     978                 :            :  * @param  pXFTable - pointer of tmp XFtable
     979                 :            :  * @param  CellMark - pointer of cell mark array
     980                 :            :  */
     981                 :          0 : sal_Bool  LwpTableLayout::FindSplitColMark(XFTable* pXFTable,sal_uInt8* pCellMark,
     982                 :            :             sal_uInt8& nMaxColSpan)
     983                 :            : {
     984                 :          0 :     sal_uInt16 nRowNum = static_cast<sal_uInt16>(pXFTable->GetRowCount());
     985                 :          0 :     sal_uInt8 nColNum = static_cast<sal_uInt8>(pXFTable->GetColumnCount());
     986                 :          0 :     sal_uInt8 nCellMark=0;
     987                 :            :     sal_uInt8 nCount;
     988                 :            :     sal_uInt8 nColSpan;
     989                 :          0 :     sal_Bool bFindFlag = sal_False;
     990                 :            :     XFRow* pTmpRow;
     991                 :            : 
     992         [ #  # ]:          0 :     for(sal_uInt8 i=1;i<=nColNum;i++)
     993                 :            :     {
     994                 :            :         sal_uInt16 nRowLoop;
     995                 :            :         sal_uInt8 nCellLoop;
     996                 :            : 
     997                 :            :         //find current max column span
     998                 :          0 :         nMaxColSpan = 1;
     999         [ #  # ]:          0 :         for (nRowLoop=1;nRowLoop<=nRowNum;nRowLoop++)
    1000                 :            :         {
    1001                 :          0 :             nColSpan = 0;
    1002         [ #  # ]:          0 :             for(nCellLoop=1; nCellLoop<i+1; nCellLoop++)
    1003                 :            :             {
    1004                 :          0 :                 pTmpRow = pXFTable->GetRow(nRowLoop);
    1005                 :          0 :                 XFCell* pCell = pTmpRow->GetCell(nCellLoop);
    1006         [ #  # ]:          0 :                 if (pCell)
    1007                 :          0 :                     nColSpan += static_cast<sal_uInt8>(pCell->GetColSpaned());
    1008                 :            :                 else
    1009                 :          0 :                     return sal_False;
    1010                 :            :             }
    1011         [ #  # ]:          0 :             if (nColSpan > nMaxColSpan)
    1012                 :          0 :                 nMaxColSpan = nColSpan;
    1013                 :          0 :             pCellMark[nRowLoop] = 0;//reset all cell mark to zero
    1014                 :            :         }
    1015                 :            : 
    1016                 :            :         //find if other row has the same colum
    1017         [ #  # ]:          0 :         for (nRowLoop=1;nRowLoop<=nRowNum;nRowLoop++)
    1018                 :            :         {
    1019                 :          0 :             pTmpRow = pXFTable->GetRow(nRowLoop);
    1020                 :          0 :             nCount = 0;
    1021                 :          0 :             nCellMark = 0;
    1022         [ #  # ]:          0 :             for (nCellLoop=1; nCellLoop<=pTmpRow->GetCellCount(); nCellLoop++)
    1023                 :            :             {
    1024         [ #  # ]:          0 :                 if (nCount>nMaxColSpan)
    1025                 :          0 :                     break;
    1026                 :          0 :                 nCount+= static_cast<sal_uInt8>(pTmpRow->GetCell(nCellLoop)->GetColSpaned());
    1027         [ #  # ]:          0 :                 if (nCount == nMaxColSpan)
    1028                 :            :                 {
    1029                 :          0 :                     nCellMark = nCellLoop;
    1030                 :          0 :                     break;
    1031                 :            :                 }
    1032                 :            :             }
    1033         [ #  # ]:          0 :             if (nCellMark == 0)
    1034                 :          0 :                 break;
    1035                 :            :             else
    1036                 :          0 :                 pCellMark[nRowLoop] = nCellMark;
    1037                 :            :         }
    1038         [ #  # ]:          0 :         for(nRowLoop=1;nRowLoop<=nRowNum;nRowLoop++)//check if all ==0,break
    1039                 :            :         {
    1040         [ #  # ]:          0 :             if (pCellMark[nRowLoop] == 0)
    1041                 :          0 :                 break;
    1042                 :            :         }
    1043         [ #  # ]:          0 :         if (nRowLoop == nRowNum+1)
    1044                 :            :         {
    1045                 :          0 :             bFindFlag = sal_True;
    1046                 :          0 :             return bFindFlag;
    1047                 :            :         }
    1048                 :            : 
    1049                 :            :     }
    1050                 :          0 :     return bFindFlag;
    1051                 :            : }
    1052                 :            : 
    1053                 :            : /**
    1054                 :            :  * @short   convert word pro table to SODC table
    1055                 :            :  * @param  pXFTable - pointer of table
    1056                 :            :  * @param  nStartRow - start row ID
    1057                 :            :  * @param  nEndRow - end row ID
    1058                 :            :  * @param  nStartCol - start column ID
    1059                 :            :  * @param  nEndCol - end column ID
    1060                 :            :  */
    1061                 :          3 : void LwpTableLayout::ConvertTable(XFTable* pXFTable,sal_uInt16 nStartRow,
    1062                 :            :                 sal_uInt16 nEndRow,sal_uInt8 nStartCol,sal_uInt8 nEndCol)
    1063                 :            : {
    1064                 :            :     //out put column info TO BE CHANGED
    1065         [ +  - ]:          3 :     ConvertColumn(pXFTable,nStartCol,nEndCol);
    1066                 :            : 
    1067                 :          3 :     std::map<sal_uInt16,LwpRowLayout*>::iterator iter;
    1068                 :            : 
    1069         [ +  + ]:         18 :     for (sal_uInt16 i=nStartRow; i<nEndRow;)
    1070                 :            :     {
    1071         [ +  - ]:         15 :         iter = m_RowsMap.find(i);
    1072         [ -  + ]:         15 :         if (iter == m_RowsMap.end())
    1073                 :            :         {
    1074         [ #  # ]:          0 :             ConvertDefaultRow(pXFTable,nStartCol,nEndCol,i);
    1075                 :          0 :             i++;
    1076                 :            :         }
    1077                 :            :         else
    1078                 :            :         {
    1079                 :         15 :             LwpRowLayout* pRow = iter->second;
    1080 [ +  - ][ +  - ]:         15 :             if (pRow->GetCurMaxSpannedRows(nStartCol,nEndCol) == 1)
    1081                 :            :             {
    1082         [ +  - ]:         15 :                 pRow->ConvertCommonRow(pXFTable,nStartCol,nEndCol);
    1083                 :         15 :                 i++;
    1084                 :            :             }
    1085                 :            :             else
    1086                 :            :             {
    1087         [ #  # ]:          0 :                 pRow->ConvertRow(pXFTable,nStartCol,nEndCol);
    1088         [ #  # ]:          0 :                 i += pRow->GetCurMaxSpannedRows(nStartCol,nEndCol);
    1089                 :            :             }
    1090                 :            :         }
    1091                 :            :     }
    1092                 :          3 : }
    1093                 :            : 
    1094                 :            : /**
    1095                 :            :  * @short   apply numeric value and formula to cell
    1096                 :            :  * @param  pFoundry - pointer of foundry
    1097                 :            :  * @param  aTableID - table ID
    1098                 :            :  */
    1099                 :          3 : void LwpTableLayout::PutCellVals(LwpFoundry* pFoundry, LwpObjectID aTableID)
    1100                 :            : {
    1101                 :            : 
    1102                 :            :     //Comment:The old code doesn't check if the LwpFoundry pointer is NULL,
    1103                 :            :     //        So the NULL pointer cause sodc frozee. Add code to check the
    1104                 :            :     //        the pointer.
    1105                 :            :     //New Code
    1106         [ -  + ]:          6 :     if( !pFoundry ) return;
    1107                 :            : 
    1108                 :            : 
    1109                 :            :     try{
    1110                 :            : 
    1111         [ +  - ]:          3 :         LwpDLVListHeadHolder* pHolder = (LwpDLVListHeadHolder*)pFoundry->GetNumberManager()->GetTableRangeID().obj();
    1112                 :            : 
    1113         [ +  - ]:          3 :         LwpTableRange* pTableRange = (LwpTableRange*)pHolder->GetHeadID()->obj();
    1114                 :            : 
    1115                 :            :         //Look up the table
    1116         [ -  + ]:          3 :         while (NULL!=pTableRange)
    1117                 :            :         {
    1118                 :          0 :             LwpObjectID aID = pTableRange->GetTableID();
    1119         [ #  # ]:          0 :             if (aID == aTableID)
    1120                 :            :             {
    1121                 :            :                 break;
    1122                 :            :             }
    1123         [ #  # ]:          0 :             pTableRange = pTableRange->GetNext();
    1124                 :            :         }
    1125                 :            : 
    1126         [ -  + ]:          3 :         if (pTableRange)
    1127                 :            :         {
    1128         [ #  # ]:          0 :             LwpCellRange* pRange = (LwpCellRange*)pTableRange->GetCellRangeID().obj();
    1129         [ #  # ]:          0 :             LwpFolder* pFolder = (LwpFolder*)pRange->GetFolderID().obj();
    1130                 :          0 :             LwpObjectID aRowListID = pFolder->GetChildHeadID();
    1131         [ #  # ]:          0 :             LwpRowList* pRowList = (LwpRowList*)aRowListID.obj();
    1132                 :            : 
    1133                 :            :             //loop the rowlist
    1134         [ #  # ]:          0 :             while( NULL!=pRowList)
    1135                 :            :             {
    1136                 :          0 :                 sal_uInt16 nRowID =  pRowList->GetRowID();
    1137                 :            :                 {
    1138         [ #  # ]:          0 :                     LwpCellList* pCellList = (LwpCellList*)pRowList->GetChildHeadID().obj();
    1139                 :            :                     //loop the celllist
    1140         [ #  # ]:          0 :                     while( NULL!=pCellList)
    1141                 :            :                     {
    1142                 :            :                         {//put cell
    1143                 :          0 :                             sal_uInt16 nColID = pCellList->GetColumnID();
    1144                 :            : 
    1145         [ #  # ]:          0 :                             XFCell* pCell = GetCellsMap(nRowID,static_cast<sal_uInt8>(nColID));
    1146         [ #  # ]:          0 :                             if (pCell)
    1147                 :            :                             {
    1148         [ #  # ]:          0 :                                 pCellList->Convert(pCell, this);
    1149                 :            : 
    1150                 :            :                                 //process paragraph
    1151         [ #  # ]:          0 :                                 PostProcessParagraph(pCell, nRowID, nColID);
    1152                 :            :                             }
    1153                 :            :                             else
    1154                 :            :                             {
    1155                 :            :                                 //Hidden cell would not be in cellsmap
    1156                 :            :                                 assert(false);
    1157                 :            :                             }
    1158                 :            :                         }
    1159         [ #  # ]:          0 :                         pCellList = (LwpCellList*)pCellList->GetNextID().obj();
    1160                 :            :                     }
    1161                 :            :                 }
    1162         [ #  # ]:          0 :                 pRowList =(LwpRowList*)pRowList->GetNextID().obj();
    1163                 :            :             }
    1164                 :            :         }
    1165                 :            : 
    1166                 :          0 :     }catch (...) {
    1167                 :            :         assert(false);
    1168                 :            :     }
    1169                 :            : }
    1170                 :            : 
    1171                 :            : /**
    1172                 :            :  * @short   1. set number right alignment to right if number 2. remove tab added before if number
    1173                 :            :  * @param  pCell - cell which to be process
    1174                 :            :  * @param  nRowID - row number in Word Pro file
    1175                 :            :  * @param  nColID - column number in Word Pro file
    1176                 :            :  */
    1177                 :          0 : void LwpTableLayout::PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_uInt16 nColID)
    1178                 :            : {
    1179                 :            :     // if number right, set alignment to right
    1180                 :          0 :     LwpCellLayout * pCellLayout = GetCellByRowCol(nRowID, nColID);
    1181         [ #  # ]:          0 :     if(pCellLayout)
    1182                 :            :     {
    1183                 :          0 :         XFParagraph * pXFPara = NULL;
    1184         [ #  # ]:          0 :         pXFPara = static_cast<XFParagraph*>(pCell->FindFirstContent(enumXFContentPara));
    1185         [ #  # ]:          0 :         if (!pXFPara)
    1186                 :          0 :             return;
    1187                 :          0 :         XFColor aColor;
    1188                 :          0 :         XFColor aNullColor = XFColor();
    1189                 :            : 
    1190         [ #  # ]:          0 :         if ( pXFPara)
    1191                 :            :         {
    1192                 :          0 :             OUString sNumfmt = pCellLayout->GetNumfmtName();
    1193                 :          0 :             sal_Bool bColorMod = sal_False;
    1194                 :          0 :             XFNumberStyle* pNumStyle = NULL;
    1195         [ #  # ]:          0 :             XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
    1196         [ #  # ]:          0 :             if (!sNumfmt.isEmpty())
    1197                 :            :             {
    1198         [ #  # ]:          0 :                 pNumStyle = (XFNumberStyle*)pXFStyleManager->FindStyle( sNumfmt);
    1199                 :          0 :                 aColor = pNumStyle->GetColor();
    1200 [ #  # ][ #  # ]:          0 :                 if ( pNumStyle &&  aColor != aNullColor )
         [ #  # ][ #  # ]
    1201                 :          0 :                     bColorMod = sal_True;//end
    1202                 :            :             }
    1203                 :            : 
    1204 [ #  # ][ #  # ]:          0 :             XFParaStyle * pStyle = pXFStyleManager->FindParaStyle(pXFPara->GetStyleName());
    1205 [ #  # ][ #  # ]:          0 :             if (pStyle->GetNumberRight()  || bColorMod)
                 [ #  # ]
    1206                 :            :             {
    1207 [ #  # ][ #  # ]:          0 :                 XFParaStyle* pOverStyle = new XFParaStyle;
    1208         [ #  # ]:          0 :                 *pOverStyle = *pStyle;
    1209                 :            : 
    1210         [ #  # ]:          0 :                 if (pStyle->GetNumberRight())
    1211                 :          0 :                     pOverStyle->SetAlignType(enumXFAlignEnd);
    1212                 :            : 
    1213         [ #  # ]:          0 :                 if (bColorMod)
    1214                 :            :                 {
    1215                 :          0 :                     XFFont* pFont = pOverStyle->GetFont();
    1216                 :          0 :                     aColor = pFont->GetColor();
    1217 [ #  # ][ #  # ]:          0 :                     if ( aColor == aNullColor )
    1218                 :            :                     {
    1219 [ #  # ][ #  # ]:          0 :                         XFFont* pNewFont = new XFFont;
    1220                 :          0 :                         aColor = pNumStyle->GetColor();
    1221                 :          0 :                         pNewFont->SetColor(aColor);
    1222         [ #  # ]:          0 :                         pOverStyle->SetFont(pNewFont);
    1223                 :            :                     }
    1224                 :            :                 }
    1225                 :            : 
    1226         [ #  # ]:          0 :                 pOverStyle->SetStyleName(A2OUSTR(""));
    1227 [ #  # ][ #  # ]:          0 :                 OUString StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
    1228                 :            : 
    1229         [ #  # ]:          0 :                 pXFPara->SetStyleName(StyleName);
    1230                 :          0 :             }
    1231                 :            :         }
    1232                 :            :     }
    1233                 :            : }
    1234                 :            : 
    1235                 :            : /**
    1236                 :            :  * @short   Parse all cols of table
    1237                 :            :  * @param  pXFTable - pointer to created XFTable
    1238                 :            :  */
    1239                 :          3 : void LwpTableLayout::ConvertColumn(XFTable *pXFTable,sal_uInt8 nStartCol,sal_uInt8 nEndCol)
    1240                 :            : {
    1241                 :          3 :     LwpTable * pTable = GetTable();
    1242         [ -  + ]:          3 :     if (!pTable)
    1243                 :            :     {
    1244                 :            :         assert(sal_False);
    1245                 :          3 :         return;
    1246                 :            :     }
    1247                 :            : 
    1248         [ +  + ]:         15 :     for (sal_uInt32 iLoop = 0; iLoop < static_cast<sal_uInt32>(nEndCol)-nStartCol; ++iLoop)
    1249                 :            :     {
    1250                 :            :         // add row to table
    1251                 :         12 :         LwpObjectID *pColID = GetColumnLayoutHead();
    1252         [ +  - ]:         12 :         LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColID->obj());
    1253         [ -  + ]:         12 :         while (pColumnLayout)
    1254                 :            :         {
    1255         [ #  # ]:          0 :             if (pColumnLayout->GetColumnID() == (iLoop+nStartCol))
    1256                 :            :             {
    1257         [ #  # ]:          0 :                 pXFTable->SetColumnStyle(iLoop+1,  pColumnLayout->GetStyleName());
    1258                 :          0 :                 break;
    1259                 :            :             }
    1260                 :          0 :             pColID = pColumnLayout->GetNext();
    1261         [ #  # ]:          0 :             pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColID->obj());
    1262                 :            :         }
    1263         [ +  - ]:         12 :         if (!pColumnLayout)
    1264                 :            :         {
    1265         [ +  - ]:         12 :             pXFTable->SetColumnStyle(iLoop+1, m_DefaultColumnStyleName);
    1266                 :            :         }
    1267                 :            :     }
    1268                 :            : }
    1269                 :            : /**
    1270                 :            :  * @short   split conflict merged cells
    1271                 :            :  */
    1272                 :          3 : void LwpTableLayout::SplitConflictCells()
    1273                 :            : {
    1274         [ +  - ]:          3 :     LwpTable * pTable = GetTable();
    1275         [ +  - ]:          3 :     if (!pTable)
    1276                 :          3 :         return;
    1277                 :          3 :     sal_uInt16 nCol = pTable->GetColumn();
    1278                 :          3 :     sal_uInt16 nRow = pTable->GetRow();
    1279                 :            : 
    1280                 :            :     sal_uInt16 nEffectRows;
    1281                 :          3 :     std::map<sal_uInt16,LwpRowLayout*>::iterator iter1;
    1282                 :          3 :     std::map<sal_uInt16,LwpRowLayout*>::iterator iter2;
    1283                 :            :     LwpRowLayout* pRowLayout;
    1284                 :            :     LwpRowLayout* pEffectRow;
    1285                 :            : 
    1286         [ +  + ]:         18 :     for (sal_uInt16 i=0; i<nRow; )
    1287                 :            :     {
    1288         [ +  - ]:         15 :         iter1 = m_RowsMap.find(i);
    1289         [ -  + ]:         15 :         if (iter1 == m_RowsMap.end())//default rows
    1290                 :            :         {
    1291                 :          0 :                 i++;
    1292                 :          0 :             continue;
    1293                 :            :         }
    1294                 :         15 :         pRowLayout= iter1->second;
    1295 [ +  - ][ +  - ]:         15 :         if (pRowLayout->GetMergeCellFlag() == sal_False)
    1296                 :            :         {
    1297                 :         15 :             i++;
    1298                 :         15 :             continue;
    1299                 :            :         }
    1300                 :            :         else
    1301                 :            :         {
    1302         [ #  # ]:          0 :             nEffectRows = i + pRowLayout->GetCurMaxSpannedRows(0,(sal_uInt8)nCol);
    1303                 :            : 
    1304         [ #  # ]:          0 :             for (sal_uInt16 j = i+1; j<nEffectRows; j++)
    1305                 :            :             {
    1306         [ #  # ]:          0 :                 iter2 = m_RowsMap.find(j);
    1307         [ #  # ]:          0 :                     if (iter2 == m_RowsMap.end())
    1308                 :          0 :                         continue;
    1309                 :          0 :                     pEffectRow = iter2->second;
    1310 [ #  # ][ #  # ]:          0 :                 if (pEffectRow->GetMergeCellFlag() == sal_False)
    1311                 :          0 :                     continue;
    1312                 :            :                 else
    1313         [ #  # ]:          0 :                     pEffectRow->SetCellSplit(nEffectRows);
    1314                 :            :             }
    1315                 :          0 :             i = nEffectRows;
    1316                 :            :         }
    1317                 :            :     }//end for
    1318                 :            : 
    1319                 :            : }
    1320                 :            : /**
    1321                 :            :  * @short   add default row which are missing in the file
    1322                 :            :  * @param   pXFTable - pointer to new created table
    1323                 :            :  * @param   nStartCol - starting column
    1324                 :            :  * @param   nEndCol  - end column
    1325                 :            :  * @return   pXFTable
    1326                 :            :  */
    1327                 :          0 : void LwpTableLayout::ConvertDefaultRow(XFTable* pXFTable,sal_uInt8 nStartCol,
    1328                 :            :          sal_uInt8 nEndCol,sal_uInt16 nRowID)
    1329                 :            : {
    1330                 :            :     // current row doesn't exist in the file
    1331         [ #  # ]:          0 :     XFRow * pRow = new XFRow();
    1332         [ #  # ]:          0 :     pRow->SetStyleName(m_DefaultRowStyleName);
    1333                 :            : 
    1334         [ #  # ]:          0 :     for (sal_uInt16 j =0;j < nEndCol-nStartCol; j++)
    1335                 :            :     {
    1336                 :            :         // if table has default cell layout, use it to ConvertCell
    1337                 :            :         // otherwise use blank cell
    1338                 :          0 :         XFCell * pCell = NULL;
    1339         [ #  # ]:          0 :         if (m_pDefaultCellLayout)
    1340                 :            :         {
    1341                 :            :             pCell = m_pDefaultCellLayout->ConvertCell(
    1342                 :          0 :                 *GetTable()->GetObjectID(),nRowID,j+nStartCol);
    1343                 :            :         }
    1344                 :            :         else
    1345                 :            :         {
    1346         [ #  # ]:          0 :             pCell = new XFCell();
    1347                 :            :         }
    1348                 :          0 :         pRow->AddCell(pCell);
    1349                 :            :     }
    1350                 :            : 
    1351                 :          0 :     pXFTable->AddRow(pRow);
    1352                 :          0 : }
    1353                 :            : /**
    1354                 :            :  * @short   set cell map info
    1355                 :            :  * @param   pXFCell - pointer to xfcell
    1356                 :            :  * @param   nRow - row id
    1357                 :            :  * @param   nCol - column id
    1358                 :            :  */
    1359                 :         60 : void LwpTableLayout::SetCellsMap(sal_uInt16 nRow,sal_uInt8 nCol,XFCell* pXFCell)
    1360                 :            : {
    1361                 :         60 :     std::pair<std::pair<sal_uInt16,sal_uInt8>,XFCell*> cell;
    1362                 :         60 :     std::pair<sal_uInt16,sal_uInt8> pos;
    1363                 :         60 :     pos.first = nRow;
    1364                 :         60 :     pos.second = nCol;
    1365         [ +  - ]:         60 :     cell.first = pos;
    1366                 :         60 :     cell.second = pXFCell;
    1367         [ +  - ]:         60 :     m_CellsMap.insert(cell);
    1368                 :         60 : }
    1369                 :            : 
    1370                 :            : /**
    1371                 :            :  * @short   get cell map info
    1372                 :            :  * @param   nRow - row id
    1373                 :            :  * @param   nCol  - column id
    1374                 :            :  * @return  pXFCell
    1375                 :            :  */
    1376                 :          0 : XFCell* LwpTableLayout::GetCellsMap(sal_uInt16 nRow,sal_uInt8 nCol)
    1377                 :            : {
    1378                 :          0 :     std::pair<sal_uInt16,sal_uInt8> pos;
    1379                 :          0 :     pos.first = nRow;
    1380                 :          0 :     pos.second = nCol;
    1381                 :          0 :     std::map<std::pair<sal_uInt16,sal_uInt8>,XFCell*>::iterator iter;
    1382         [ #  # ]:          0 :     iter =  m_CellsMap.find(pos);
    1383         [ #  # ]:          0 :     if (iter == m_CellsMap.end())
    1384                 :          0 :         return NULL;
    1385                 :          0 :     return iter->second;
    1386                 :            : }
    1387                 :            : /**
    1388                 :            :  * @descr   Get row layout by row id
    1389                 :            :  * @param   nRow - row id
    1390                 :            :  */
    1391                 :          0 :  LwpRowLayout* LwpTableLayout::GetRowLayout(sal_uInt16 nRow)
    1392                 :            : {
    1393                 :          0 :     LwpObjectID *pRowID = GetChildHead();
    1394         [ #  # ]:          0 :     LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj());
    1395         [ #  # ]:          0 :     while (pRowLayout)
    1396                 :            :     {
    1397         [ #  # ]:          0 :         if(pRowLayout->GetRowID() == nRow)
    1398                 :          0 :             return pRowLayout;
    1399                 :            : 
    1400                 :          0 :         pRowID = pRowLayout->GetNext();
    1401         [ #  # ]:          0 :         pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj());
    1402                 :            :     }
    1403                 :          0 :     return NULL;
    1404                 :            : }
    1405                 :            : 
    1406                 :            : 
    1407                 :            : //add end by
    1408                 :          0 : LwpColumnLayout::LwpColumnLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
    1409                 :          0 :     : LwpVirtualLayout(objHdr, pStrm)
    1410                 :          0 : {}
    1411                 :            : 
    1412                 :          0 : LwpColumnLayout::~LwpColumnLayout()
    1413         [ #  # ]:          0 : {}
    1414                 :          0 : void LwpColumnLayout::Read()
    1415                 :            : {
    1416                 :          0 :     LwpObjectStream* pStrm = m_pObjStrm;
    1417                 :            : 
    1418                 :          0 :     LwpVirtualLayout::Read();
    1419                 :            : 
    1420                 :            :     sal_uInt16 colid;
    1421                 :            : 
    1422                 :          0 :     colid = pStrm->QuickReaduInt16();   // forced to lushort
    1423                 :          0 :     ccolid = (sal_uInt8)colid;  // Phillip
    1424                 :          0 :     cwidth = pStrm->QuickReadInt32();
    1425                 :            : 
    1426                 :          0 :     pStrm->SkipExtra();
    1427                 :          0 : }
    1428                 :            : 
    1429                 :          0 : void LwpColumnLayout::RegisterStyle(double dCalculatedWidth)
    1430                 :            : {
    1431         [ #  # ]:          0 :     XFColStyle * pColStyle = new XFColStyle();
    1432                 :          0 :     pColStyle->SetWidth(static_cast<float>(dCalculatedWidth));
    1433                 :          0 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
    1434                 :          0 :     m_StyleName = pXFStyleManager->AddStyle(pColStyle)->GetStyleName();
    1435                 :          0 : }
    1436                 :            : 
    1437                 :          0 : LwpTableHeadingLayout::LwpTableHeadingLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
    1438                 :          0 :     : LwpTableLayout(objHdr, pStrm)
    1439                 :          0 : {}
    1440                 :            : 
    1441                 :          0 : LwpTableHeadingLayout::~LwpTableHeadingLayout()
    1442         [ #  # ]:          0 : {}
    1443                 :            : /**
    1444                 :            :  * @short   read table heading layout
    1445                 :            :  * @param
    1446                 :            :  * @return
    1447                 :            :  */
    1448                 :          0 : void LwpTableHeadingLayout::Read()
    1449                 :            : {
    1450                 :          0 :     LwpTableLayout::Read();
    1451                 :            : 
    1452                 :          0 :     cStartRow = m_pObjStrm->QuickReaduInt16();
    1453                 :          0 :     cEndRow = m_pObjStrm->QuickReaduInt16();
    1454                 :            : 
    1455                 :          0 :     m_pObjStrm->SkipExtra();
    1456                 :            : 
    1457                 :          0 : }
    1458                 :            : /**
    1459                 :            :  * @short   get start and end row number of table heading
    1460                 :            :  * @param
    1461                 :            :  * @return *pStartRow - starting row number
    1462                 :            :  * @return *pEndRow -   end row number
    1463                 :            :  */
    1464                 :          0 : void LwpTableHeadingLayout::GetStartEndRow(sal_uInt16& nStartRow, sal_uInt16& nEndRow)
    1465                 :            : {
    1466                 :          0 :     nStartRow = cStartRow;
    1467                 :          0 :     nEndRow = cEndRow;
    1468                 :          0 : }
    1469                 :            : /**
    1470                 :            :  * @short   get first row heading layout of table heading
    1471                 :            :  * @param
    1472                 :            :  * @return LwpRowHeadingLayout * - pointer to first row heading layout of table heading
    1473                 :            :  */
    1474                 :          0 : LwpRowHeadingLayout * LwpTableHeadingLayout::GetFirstRowHeadingLayout()
    1475                 :            : {
    1476                 :          0 :     LwpObjectID *pID = GetChildHead();
    1477 [ #  # ][ #  # ]:          0 :     if(pID && !pID->IsNull())
                 [ #  # ]
    1478                 :            :     {
    1479         [ #  # ]:          0 :         LwpRowHeadingLayout * pHeadingRow = dynamic_cast<LwpRowHeadingLayout *>(pID->obj());
    1480                 :          0 :         return pHeadingRow;
    1481                 :            :     }
    1482                 :          0 :     return NULL;
    1483                 :            : }
    1484                 :            : 
    1485                 :          0 : LwpSuperParallelColumnLayout::LwpSuperParallelColumnLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm):LwpSuperTableLayout(objHdr, pStrm)
    1486                 :            : {
    1487                 :          0 : }
    1488                 :          0 : LwpSuperParallelColumnLayout::~LwpSuperParallelColumnLayout()
    1489         [ #  # ]:          0 : {}
    1490                 :            : 
    1491                 :          0 : void LwpSuperParallelColumnLayout::Read()
    1492                 :            : {
    1493                 :          0 :     LwpSuperTableLayout::Read();
    1494                 :          0 :     m_pObjStrm->SkipExtra();
    1495                 :            : 
    1496                 :          0 : }
    1497                 :            : 
    1498                 :          0 : LwpSuperGlossaryLayout::LwpSuperGlossaryLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm):LwpSuperTableLayout(objHdr, pStrm)
    1499                 :            : {
    1500                 :          0 : }
    1501                 :            : 
    1502                 :          0 : LwpSuperGlossaryLayout::~LwpSuperGlossaryLayout()
    1503                 :            : {
    1504         [ #  # ]:          0 : }
    1505                 :            : 
    1506                 :          0 : void LwpSuperGlossaryLayout::Read()
    1507                 :            : {
    1508                 :          0 :     LwpSuperTableLayout::Read();
    1509                 :          0 :     m_pObjStrm->SkipExtra();
    1510                 :          0 : }
    1511                 :            : 
    1512                 :            : 
    1513                 :          0 : LwpParallelColumnsLayout::LwpParallelColumnsLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm):LwpTableLayout(objHdr, pStrm)
    1514                 :            : {
    1515                 :          0 : }
    1516                 :            : 
    1517                 :          0 : LwpParallelColumnsLayout::~LwpParallelColumnsLayout()
    1518                 :            : {
    1519         [ #  # ]:          0 : }
    1520                 :            : 
    1521                 :          0 : void LwpParallelColumnsLayout::Read()
    1522                 :            : {
    1523                 :          0 :     LwpTableLayout::Read();
    1524                 :          0 :     m_pObjStrm->SkipExtra();
    1525                 :          0 : }
    1526                 :            : 
    1527                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10