LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpcelllayout.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 194 341 56.9 %
Date: 2012-08-25 Functions: 22 43 51.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 99 242 40.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 - cell layouts
      59                 :            :  */
      60                 :            : /*************************************************************************
      61                 :            :  * Change History
      62                 :            :  April 2005         Created
      63                 :            :  ************************************************************************/
      64                 :            : #include "lwpcelllayout.hxx"
      65                 :            : #include "lwpfoundry.hxx"
      66                 :            : #include "lwpobjfactory.hxx"
      67                 :            : #include "lwptblcell.hxx"
      68                 :            : #include "lwptblformula.hxx"
      69                 :            : #include "lwpholder.hxx"
      70                 :            : #include "lwpnumericfmt.hxx"
      71                 :            : #include "lwptable.hxx"
      72                 :            : #include "lwpglobalmgr.hxx"
      73                 :            : 
      74                 :            : #include "xfilter/xfstylemanager.hxx"
      75                 :            : #include "xfilter/xfcell.hxx"
      76                 :            : #include "xfilter/xfcellstyle.hxx"
      77                 :            : #include "xfilter/xfcolstyle.hxx"
      78                 :            : 
      79                 :         69 : LwpCellLayout::LwpCellLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
      80                 :            :     : LwpMiddleLayout(objHdr, pStrm)
      81 [ +  - ][ +  - ]:        345 :     , cType(LDT_NONE)
                 [ +  + ]
      82                 :         69 : {}
      83                 :            : 
      84                 :        414 : LwpCellLayout::~LwpCellLayout()
      85         [ +  - ]:        477 : {}
           [ +  +  -  + ]
      86                 :            : 
      87                 :            : /**
      88                 :            :  * @short   Get table layout pointer, if default cell layout, return NULL
      89                 :            :  * @param LwpTableLayout *
      90                 :            :  * @return
      91                 :            :  */
      92                 :         21 : LwpTableLayout * LwpCellLayout::GetTableLayout()
      93                 :            : {
      94         [ -  + ]:         21 :     LwpRowLayout * pRow = dynamic_cast<LwpRowLayout *>(GetParent()->obj());
      95         [ -  + ]:         21 :     if(!pRow)
      96                 :            :     {
      97                 :          0 :         return NULL;
      98                 :            :     }
      99                 :         21 :     LwpTableLayout * pTableLayout = pRow->GetParentTableLayout();
     100                 :         21 :     return pTableLayout;
     101                 :            : }
     102                 :            : /**
     103                 :            :  * @short   Get table pointer, if default cell layout, return NULL
     104                 :            :  * @param LwpTable *
     105                 :            :  * @return
     106                 :            :  */
     107                 :          3 : LwpTable * LwpCellLayout::GetTable()
     108                 :            : {
     109                 :          3 :     LwpTableLayout * pTableLayout = GetTableLayout();
     110         [ -  + ]:          3 :     if(!pTableLayout)
     111                 :            :     {
     112                 :          0 :         return NULL;
     113                 :            :     }
     114                 :          3 :     LwpTable *pTable = pTableLayout->GetTable();
     115                 :          3 :     return pTable;
     116                 :            : }
     117                 :            : /**
     118                 :            :  * @short   Set current cell layout to cell layout map
     119                 :            :  * @param
     120                 :            :  * @return
     121                 :            :  */
     122                 :          9 : void LwpCellLayout::SetCellMap()
     123                 :            : {
     124                 :            :     // this function is called from LwpTableLayout, so it can't be NULL
     125                 :          9 :     GetTableLayout()->SetWordProCellMap(crowid, ccolid, this);
     126                 :          9 : }
     127                 :            : /**
     128                 :            :  * @short  Get actual width of this cell layout
     129                 :            :  * @param
     130                 :            :  * @return width (cm)
     131                 :            :  */
     132                 :          0 : double LwpCellLayout::GetActualWidth()
     133                 :            : {
     134                 :            :     //Get table layout
     135         [ #  # ]:          0 :     LwpTableLayout * pTableLayout = GetTableLayout();
     136                 :            : 
     137         [ #  # ]:          0 :     if (pTableLayout == NULL)
     138                 :            :     {
     139         [ #  # ]:          0 :         return GetGeometryWidth();
     140                 :            :     }
     141                 :            : 
     142         [ #  # ]:          0 :     OUString strColStyle = pTableLayout->GetColumnWidth(ccolid);
     143                 :            : 
     144         [ #  # ]:          0 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     145         [ #  # ]:          0 :     XFColStyle *pStyle = static_cast<XFColStyle *>(pXFStyleManager->FindStyle(strColStyle));
     146         [ #  # ]:          0 :     if(pStyle)
     147                 :            :     {
     148                 :          0 :         return pStyle->GetWidth();
     149                 :            :     }
     150                 :            : 
     151         [ #  # ]:          0 :     return GetGeometryWidth();
     152                 :            : }
     153                 :            : 
     154                 :            : /**
     155                 :            :  * @short   Apply padding to cell style
     156                 :            :  * @param pCellStyle - pointer of XFCellStyle
     157                 :            :  * @return
     158                 :            :  */
     159                 :        225 : void LwpCellLayout::ApplyPadding(XFCellStyle *pCellStyle)
     160                 :            : {
     161                 :        225 :     double fLeft = GetMarginsValue(MARGIN_LEFT);
     162                 :        225 :     double fRight = GetMarginsValue(MARGIN_RIGHT);
     163                 :        225 :     double fTop = GetMarginsValue(MARGIN_TOP);
     164                 :        225 :     double fBottom = GetMarginsValue(MARGIN_BOTTOM);
     165                 :        225 :     pCellStyle->SetPadding((float)fLeft,(float)fRight,(float)fTop,(float)fBottom);
     166                 :        225 : }
     167                 :            : /**
     168                 :            :  * @short   Apply border to cell style according to cell position, default cell layout won't use this function
     169                 :            :  * @param
     170                 :            :  * @return pCellStyle - pointer of XFCellStyle
     171                 :            :  */
     172                 :          9 : void LwpCellLayout::ApplyBorders(XFCellStyle *pCellStyle)
     173                 :            : {
     174                 :            :     // judge cell border type
     175                 :          9 :     LwpCellBorderType eType = GetCellBorderType(crowid, ccolid, GetTableLayout());
     176                 :            : 
     177                 :            :     // get left cell and judge if neighbour border is different
     178                 :          9 :     XFBorders * pBorders = GetXFBorders();
     179         [ -  + ]:          9 :     if(!pBorders)
     180                 :            :     {
     181                 :          9 :         return;
     182                 :            :     }
     183                 :            : 
     184   [ +  +  +  -  :          9 :     switch (eType)
                      - ]
     185                 :            :     {
     186                 :            :     case enumNoBottomBorder:
     187                 :          3 :         pBorders->SetWidth(enumXFBorderBottom, 0);
     188                 :          3 :         break;
     189                 :            :     case enumNoLeftBorder:
     190                 :          3 :         pBorders->SetWidth(enumXFBorderLeft, 0);
     191                 :          3 :         break;
     192                 :            :     case enumNoLeftNoBottomBorder:
     193                 :          3 :         pBorders->SetWidth(enumXFBorderBottom, 0);
     194                 :          3 :         pBorders->SetWidth(enumXFBorderLeft, 0);
     195                 :          3 :         break;
     196                 :            :     case enumWholeBorder:
     197                 :          0 :         break;
     198                 :            :     default:
     199                 :            :         assert(sal_False);
     200                 :            :     }
     201                 :          9 :     pCellStyle->SetBorders(pBorders);
     202                 :            : }
     203                 :            : /**
     204                 :            :  * @short   Apply watermark to cell style
     205                 :            :  * @param pCellStyle - pointer of XFCellStyle
     206                 :            :  * @return
     207                 :            :  */
     208                 :        225 : void LwpCellLayout::ApplyWatermark(XFCellStyle *pCellStyle)
     209                 :            : {
     210                 :        225 :     XFBGImage* pBGImage = GetXFBGImage();
     211         [ -  + ]:        225 :     if(pBGImage)
     212                 :            :     {
     213                 :          0 :         pCellStyle->SetBackImage(pBGImage);
     214                 :            :     }
     215                 :        225 : }
     216                 :            : 
     217                 :            : /**
     218                 :            :  * @short   Apply pattern fill to cell style
     219                 :            :  * @param pCellStyle - pointer of XFCellStyle
     220                 :            :  * @return
     221                 :            :  */
     222                 :          0 : void LwpCellLayout::ApplyPatternFill(XFCellStyle* pCellStyle)
     223                 :            : {
     224                 :          0 :     XFBGImage* pXFBGImage = this->GetFillPattern();
     225         [ #  # ]:          0 :     if (pXFBGImage)
     226                 :            :     {
     227                 :          0 :         pCellStyle->SetBackImage(pXFBGImage);
     228                 :            :     }
     229                 :          0 : }
     230                 :            : 
     231                 :            : /**
     232                 :            :  * @short   Apply background to cell style
     233                 :            :  * @param pCellStyle - pointer of XFCellStyle
     234                 :            :  * @return
     235                 :            :  */
     236                 :          9 : void LwpCellLayout::ApplyBackGround(XFCellStyle* pCellStyle)
     237                 :            : {
     238         [ -  + ]:          9 :     if (this->IsPatternFill())
     239                 :            :     {
     240                 :          0 :         ApplyPatternFill(pCellStyle);
     241                 :            :     }
     242                 :            :     else
     243                 :            :     {
     244                 :          9 :         ApplyBackColor(pCellStyle);
     245                 :            :     }
     246                 :          9 : }
     247                 :            : /**
     248                 :            :  * @short   Apply back color to cell style
     249                 :            :  * @param pCellStyle - pointer of XFCellStyle
     250                 :            :  * @return
     251                 :            :  */
     252                 :        225 : void LwpCellLayout::ApplyBackColor(XFCellStyle *pCellStyle)
     253                 :            : {
     254                 :        225 :     LwpColor* pColor = GetBackColor();
     255 [ #  # ][ -  + ]:        225 :     if(pColor && pColor->IsValidColor())
                 [ -  + ]
     256                 :            :     {
     257         [ #  # ]:          0 :         XFColor aXFColor(pColor->To24Color());
     258         [ #  # ]:          0 :         pCellStyle->SetBackColor(aXFColor);
     259                 :            :     }
     260                 :        225 : }
     261                 :            : /**
     262                 :            :  * @short   register style of cell layout
     263                 :            :  * @param pCellStyle The style of the cell, which would be applied to the cell.
     264                 :            :  * @return
     265                 :            :  */
     266                 :        225 : void LwpCellLayout::ApplyFmtStyle(XFCellStyle *pCellStyle)
     267                 :            : {
     268         [ +  + ]:        225 :     LwpLayoutNumerics* pLayoutNumerics = dynamic_cast<LwpLayoutNumerics*>(cLayNumerics.obj());
     269         [ +  + ]:        225 :     if (!pLayoutNumerics)
     270                 :            :     {
     271                 :            :         // if current layout doesn't have format, go to based on layout
     272         [ +  + ]:        153 :         LwpCellLayout* pCellLayout = dynamic_cast<LwpCellLayout*>(m_BasedOnStyle.obj());
     273         [ +  + ]:        153 :         if (pCellLayout)
     274                 :            :         {
     275         [ -  + ]:          9 :             pLayoutNumerics = dynamic_cast<LwpLayoutNumerics*>(pCellLayout->GetNumericsObject()->obj());
     276                 :            :         }
     277                 :            :     }
     278                 :            : 
     279                 :            :     // apply format style
     280         [ +  + ]:        225 :     if (pLayoutNumerics)
     281                 :            :     {
     282                 :         81 :         XFStyle* pStyle = pLayoutNumerics->Convert();
     283         [ +  - ]:         81 :         if (pStyle)
     284                 :            :         {
     285                 :         81 :             XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     286                 :         81 :             m_NumfmtName = pXFStyleManager->AddStyle(pStyle)->GetStyleName();
     287                 :         81 :             pCellStyle->SetDataStyle(m_NumfmtName);
     288                 :            :         }
     289                 :            :     }
     290                 :            : 
     291                 :        225 :     return;
     292                 :            : }
     293                 :            : /**
     294                 :            :  * @short   get style name according to cell position, only table default cells use this function
     295                 :            :  * @param   nRow - default cell position row number
     296                 :            :  * @param   nCol - default cell position col number
     297                 :            :  * @return  OUString - registered cell style name
     298                 :            :  */
     299                 :         51 : OUString LwpCellLayout::GetCellStyleName(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
     300                 :            : {
     301                 :            :     // judge cell border type
     302                 :         51 :     LwpCellBorderType eType = GetCellBorderType(nRow, nCol, pTableLayout);
     303                 :         51 :     return m_CellStyleNames[eType];
     304                 :            : }
     305                 :            : /**
     306                 :            : *   Make the XFCell
     307                 :            : *   @date   03/26/2005
     308                 :            : *   @param  aTableID - ID of the table which this cell belongs to
     309                 :            : *   @param  bIsTopRow - whether current cell is top row
     310                 :            : *   @param  bIsRightCol - whether current cell is the rightest column
     311                 :            : *   @return XFCell*
     312                 :            : */
     313                 :         60 : XFCell* LwpCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol)
     314                 :            : {
     315                 :            :     // if cell layout is aTableID's default cell layout
     316                 :            :     // it can't have any content, bypass these code
     317 [ +  - ][ -  + ]:         60 :     LwpTable * pTable = dynamic_cast<LwpTable *>(aTableID.obj());
     318         [ -  + ]:         60 :     if (!pTable)
     319                 :            :     {
     320                 :            :         assert(sal_False);
     321                 :          0 :         return NULL;
     322                 :            :     }
     323 [ +  - ][ +  - ]:         60 :     XFCell * pXFCell = new XFCell();
     324                 :         60 :     OUString aStyleName = m_StyleName;
     325                 :            : 
     326                 :            :     // if cell layout is aTableID's default cell layout
     327                 :            :     // we should judt its style by current positon
     328         [ +  + ]:         60 :     if (*pTable->GetDefaultCellStyle() == *GetObjectID())
     329                 :            :     {
     330 [ +  - ][ +  - ]:         51 :         aStyleName = GetCellStyleName(nRow, nCol, pTable->GetTableLayout());
     331                 :            :     }
     332                 :            : 
     333                 :            :     // content of cell
     334 [ +  - ][ +  + ]:         60 :     LwpStory* pStory = dynamic_cast<LwpStory*>(m_Content.obj());
     335         [ +  + ]:         60 :     if (pStory)
     336                 :            :     {
     337         [ +  - ]:          9 :         pStory->XFConvert(pXFCell);
     338                 :            :     }
     339                 :            : 
     340         [ +  - ]:         60 :     ApplyProtect(pXFCell, aTableID);
     341         [ +  - ]:         60 :     pXFCell->SetStyleName(aStyleName);
     342                 :         60 :     return pXFCell;
     343                 :            : }
     344                 :            : 
     345                 :          3 : LwpPara* LwpCellLayout::GetLastParaOfPreviousStory()
     346                 :            : {
     347                 :          3 :     LwpObjectID* pPreStoryID = this->GetPreviousCellStory();
     348 [ #  # ][ -  + ]:          3 :     if (pPreStoryID && !(pPreStoryID->IsNull()))
                 [ -  + ]
     349                 :            :     {
     350         [ #  # ]:          0 :         LwpStory* pPreStory = dynamic_cast<LwpStory*>(pPreStoryID->obj(VO_STORY));
     351         [ #  # ]:          0 :         return dynamic_cast<LwpPara*>(pPreStory->GetLastPara()->obj(VO_PARA));
     352                 :            :     }
     353                 :            :     else
     354                 :            :     {
     355                 :          3 :         return NULL;
     356                 :            :     }
     357                 :            : }
     358                 :            : 
     359                 :            : /**
     360                 :            :  * @short    Get previous cell which used for bullet inside cell
     361                 :            :  * @param
     362                 :            :  * @return   LwpObjectID * - object ID of cell content story
     363                 :            :  */
     364                 :          3 : LwpObjectID * LwpCellLayout::GetPreviousCellStory()
     365                 :            : {
     366                 :          3 :     LwpTable *pTable = GetTable();
     367         [ -  + ]:          3 :     if (!pTable)
     368                 :            :     {
     369                 :            :         assert(sal_False);
     370                 :          0 :         return NULL;
     371                 :            :     }
     372                 :          3 :     sal_uInt16 nRow = crowid;
     373                 :          3 :     sal_uInt16 nCol = ccolid;
     374                 :            : 
     375                 :            :     // if table is reset paragraph in columns, get cell on the top side of current cell
     376         [ -  + ]:          3 :     if (pTable->IsNumberDown())
     377                 :            :     {
     378         [ #  # ]:          0 :         if (nRow == 0)
     379                 :            :         {
     380                 :          0 :             return NULL;
     381                 :            :         }
     382                 :          0 :         nRow -=1;
     383                 :            :     }
     384                 :            :     else
     385                 :            :     {
     386                 :            :         // if not, get cell on the left side of current cell
     387         [ +  - ]:          3 :         if (nCol == 0)
     388                 :            :         {
     389         [ +  - ]:          3 :             if (nRow == 0)
     390                 :            :             {
     391                 :          3 :                 return NULL;
     392                 :            :             }
     393                 :            :             else
     394                 :            :             {
     395                 :          0 :                 nRow--;
     396                 :          0 :                 nCol = pTable->GetColumn() - 1;
     397                 :            :             }
     398                 :            :         }
     399                 :            :         else
     400                 :            :         {
     401                 :          0 :             nCol -=1;
     402                 :            :         }
     403                 :            :     }
     404                 :            : 
     405                 :            :     // get the object id pointer of previous cell story
     406                 :          0 :     LwpTableLayout * pTableLayout = GetTableLayout();
     407         [ #  # ]:          0 :     if (!pTableLayout)
     408                 :            :     {
     409                 :            :         assert(sal_False);
     410                 :          0 :         return NULL;
     411                 :            :     }
     412                 :          3 :     return pTableLayout->SearchCellStoryMap(nRow, nCol);
     413                 :            : }
     414                 :            : 
     415                 :            : /**
     416                 :            :  * @short   judge border type by cell neighbour
     417                 :            :  * @param nRow
     418                 :            :  * @param nCol
     419                 :            :  * @param pTableLayout
     420                 :            :  * @return   LwpCellBorderType
     421                 :            :  */
     422                 :         60 : LwpCellBorderType LwpCellLayout::GetCellBorderType(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
     423                 :            : {
     424         [ -  + ]:         60 :     if (!pTableLayout)
     425                 :            :     {
     426                 :            :         assert(sal_False);
     427                 :          0 :         return enumWholeBorder;
     428                 :            :     }
     429                 :            : 
     430                 :            :     // get left cell and judge if neighbour border is different
     431                 :         60 :     XFBorders * pBorders = GetXFBorders();
     432         [ -  + ]:         60 :     if(!pBorders)
     433                 :            :     {
     434                 :          0 :         return enumWholeBorder;
     435                 :            :     }
     436                 :         60 :     XFBorder *pLeftBorder = pBorders->GetLeft();
     437                 :         60 :     XFBorder *pBottomBorder = pBorders->GetBottom();
     438                 :         60 :     sal_Bool bNoLeftBorder = sal_False;
     439                 :         60 :     sal_Bool bNoBottomBorder = sal_False;
     440                 :            : 
     441                 :         60 :     LwpCellLayout * pLeftNeighbour = GetCellByRowCol(nRow, GetLeftColID(nCol), pTableLayout);
     442         [ +  + ]:         60 :     if (pLeftNeighbour)
     443                 :            :     {
     444                 :         45 :         XFBorders * pNeighbourBorders = pLeftNeighbour->GetXFBorders();
     445         [ +  - ]:         45 :         if (pNeighbourBorders)
     446                 :            :         {
     447                 :         45 :             XFBorder * pRightBorder = pNeighbourBorders->GetRight();
     448         [ +  - ]:         45 :             if (*pLeftBorder == *pRightBorder)
     449                 :            :             {
     450                 :            :                 // for these 2 types cell, left border should be ignored for sake of avoiding duplication border
     451                 :            :                 // but if left border is different with right border of left cell
     452                 :            :                 // we should not ignored it
     453                 :         45 :                 bNoLeftBorder = sal_True;
     454                 :            :             }
     455                 :         45 :             delete pNeighbourBorders;
     456                 :            :         }
     457                 :            : 
     458                 :            :     }
     459                 :            : 
     460                 :         60 :     LwpCellLayout * pBelowNeighbour = GetCellByRowCol(GetBelowRowID(nRow), nCol, pTableLayout);
     461         [ +  + ]:         60 :     if (pBelowNeighbour) //&& (eType == enumRightNotLastCellBorder || eType ==  enumLeftNotLastCellBorder) )
     462                 :            :     {
     463                 :         48 :         XFBorders * pBelowBorders = pBelowNeighbour->GetXFBorders();
     464         [ +  - ]:         48 :         if (pBelowBorders)
     465                 :            :         {
     466                 :         48 :             XFBorder * pTopBorder = pBelowBorders->GetTop();
     467         [ +  - ]:         48 :             if (*pTopBorder == *pBottomBorder)
     468                 :            :             {
     469                 :            :                 // for these 2 types cell, bottom border should be ignored for sake of avoiding duplication border
     470                 :            :                 // but if bottom border is different with right border of left cell
     471                 :            :                 // we should not ignored it
     472                 :         48 :                 bNoBottomBorder = sal_True;
     473                 :            :             }
     474                 :         48 :             delete pBelowBorders;
     475                 :            :         }
     476                 :            :     }
     477                 :            : 
     478                 :         60 :     delete pBorders;
     479                 :            : 
     480         [ +  + ]:         60 :     if (bNoBottomBorder)
     481                 :            :     {
     482         [ +  + ]:         48 :         if (bNoLeftBorder)
     483                 :            :         {
     484                 :         36 :             return enumNoLeftNoBottomBorder;
     485                 :            :         }
     486                 :         12 :         return enumNoBottomBorder;
     487                 :            :     }
     488         [ +  + ]:         12 :     if (bNoLeftBorder)
     489                 :            :     {
     490                 :          9 :         return enumNoLeftBorder;
     491                 :            :     }
     492                 :         60 :     return enumWholeBorder;
     493                 :            : }
     494                 :            : 
     495                 :            : /**
     496                 :            :  * @short   Get neighbour cell by specifying ROW+COL
     497                 :            :  * @param   nRow
     498                 :            :  * @param   nCol
     499                 :            :  * @return   LwpCellLayout *
     500                 :            :  */
     501                 :        120 : LwpCellLayout * LwpCellLayout::GetCellByRowCol(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
     502                 :            : {
     503                 :        120 :     return pTableLayout->GetCellByRowCol(nRow, nCol);
     504                 :            : }
     505                 :            : /**
     506                 :            :  * @short   Register table's default cell layout
     507                 :            :  * @param
     508                 :            :  * @return
     509                 :            :  */
     510                 :         54 : void LwpCellLayout::RegisterDefaultCell()
     511                 :            : {
     512                 :         54 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     513         [ +  + ]:        270 :     for (sal_uInt16 eLoop = enumWholeBorder; eLoop < enumCellBorderTopLimit; eLoop++)
     514                 :            :     {
     515                 :            :         // register cell style
     516         [ +  - ]:        216 :         XFCellStyle *pCellStyle = new XFCellStyle();
     517                 :            : 
     518                 :        216 :         ApplyPadding(pCellStyle);
     519                 :        216 :         ApplyBackColor(pCellStyle);
     520                 :        216 :         ApplyWatermark(pCellStyle);
     521                 :        216 :         ApplyFmtStyle(pCellStyle);
     522                 :        216 :         pCellStyle->SetAlignType(enumXFAlignNone, GetVerticalAlignmentType());
     523                 :            : 
     524                 :        216 :         XFBorders * pBorders = GetXFBorders();
     525         [ +  + ]:        216 :         if (pBorders)
     526                 :            :         {
     527   [ +  +  +  +  :         48 :             switch(eLoop)
                      - ]
     528                 :            :             {
     529                 :            :             case enumNoBottomBorder:
     530                 :            :                 // _
     531                 :            :                 //| |
     532                 :            :                 //
     533                 :            :                 // remove bottom line
     534                 :         12 :                 pBorders->SetWidth(enumXFBorderBottom, 0);
     535                 :         12 :                 break;
     536                 :            :             case enumNoLeftNoBottomBorder:
     537                 :            :                 // _
     538                 :            :                 //  |
     539                 :            :                 //
     540                 :            :                 // remove left and bottom
     541                 :         12 :                 pBorders->SetWidth(enumXFBorderLeft, 0);
     542                 :         12 :                 pBorders->SetWidth(enumXFBorderBottom, 0);
     543                 :         12 :                 break;
     544                 :            :             case enumWholeBorder:
     545                 :            :                 //--
     546                 :            :                 //||
     547                 :            :                 //--
     548                 :            :                 // nothing to remove
     549                 :         12 :                 break;
     550                 :            :             case enumNoLeftBorder:
     551                 :            :                 //
     552                 :            :                 //| |
     553                 :            :                 //--
     554                 :            :                 // remove left line
     555                 :         12 :                 pBorders->SetWidth(enumXFBorderLeft, 0);
     556                 :         12 :                 break;
     557                 :            :             default:
     558                 :            :                 assert(sal_False);
     559                 :            :             }
     560                 :         48 :             pCellStyle->SetBorders(pBorders);
     561                 :            :         }
     562                 :        216 :         m_CellStyleNames[eLoop] = pXFStyleManager->AddStyle(pCellStyle)->GetStyleName();
     563                 :            :     }
     564                 :         54 : }
     565                 :            : /**
     566                 :            :  * @short    Register 4 types of cell style and register content styles
     567                 :            :  * @param
     568                 :            :  * @param
     569                 :            :  * @param
     570                 :            :  * @return
     571                 :            :  */
     572                 :         63 : void LwpCellLayout::RegisterStyle()
     573                 :            : {
     574         [ -  + ]:         63 :     LwpVirtualLayout * pParent = dynamic_cast<LwpVirtualLayout *>(GetParent()->obj());
     575 [ +  - ][ +  + ]:         63 :     if (!pParent || pParent->GetLayoutType() != LWP_ROW_LAYOUT)
                 [ +  + ]
     576                 :            :     {
     577                 :            :         // default cell layout, we must register 4 styles for it
     578                 :         54 :         RegisterDefaultCell();
     579                 :         63 :         return;
     580                 :            :     }
     581                 :            : 
     582                 :            :     // register cell style
     583         [ +  - ]:          9 :     XFCellStyle *pCellStyle = new XFCellStyle();
     584                 :            : 
     585                 :          9 :     ApplyPadding(pCellStyle);
     586                 :            : //  ApplyBackColor(pCellStyle);
     587                 :          9 :     ApplyBackGround(pCellStyle);
     588                 :          9 :     ApplyWatermark(pCellStyle);
     589                 :          9 :     ApplyFmtStyle(pCellStyle);
     590                 :          9 :     ApplyBorders(pCellStyle);
     591                 :            : 
     592                 :          9 :     pCellStyle->SetAlignType(enumXFAlignNone, GetVerticalAlignmentType());
     593                 :            : 
     594                 :          9 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     595                 :          9 :     m_StyleName = pXFStyleManager->AddStyle(pCellStyle)->GetStyleName();
     596                 :            : 
     597                 :            :     // content object register styles
     598                 :          9 :     LwpObject * pObj = m_Content.obj();
     599         [ +  - ]:          9 :     if (pObj)
     600                 :            :     {
     601                 :          9 :         pObj->SetFoundry(m_pFoundry);
     602                 :          9 :         pObj->RegisterStyle();
     603                 :            :     }
     604                 :            : 
     605                 :            :     //register child layout style
     606                 :          9 :     RegisterChildStyle();
     607                 :            : }
     608                 :            : /**
     609                 :            :  * @short   Read cell layout
     610                 :            :  * @param
     611                 :            :  * @return
     612                 :            :  */
     613                 :         69 : void LwpCellLayout::Read()
     614                 :            : {
     615                 :         69 :     LwpObjectStream* pStrm = m_pObjStrm;
     616                 :            : 
     617                 :         69 :     LwpMiddleLayout::Read();
     618                 :            : 
     619                 :            :     // before the layout hierarchy rework
     620         [ +  - ]:         69 :     if (LwpFileHeader::m_nFileRevision  < 0x000b)
     621                 :            :     {
     622                 :            :         assert(sal_False);
     623                 :            :     }
     624                 :            :     else
     625                 :            :     {
     626                 :         69 :         crowid = pStrm->QuickReaduInt16();
     627                 :         69 :         ccolid = (sal_uInt8) pStrm->QuickReaduInt16();  // written as a lushort
     628                 :            : 
     629                 :            :         sal_uInt16 type;
     630                 :            : 
     631                 :         69 :         type = pStrm->QuickReaduInt16();
     632                 :         69 :         pStrm->SkipExtra();
     633                 :         69 :         cType = (LeaderDotType)type;
     634                 :            : 
     635                 :         69 :         cLayNumerics.ReadIndexed(pStrm);
     636                 :         69 :         cLayDiagonalLine.ReadIndexed(pStrm);
     637                 :            : 
     638                 :         69 :         pStrm->SkipExtra();
     639                 :            :     }
     640                 :         69 : }
     641                 :            : 
     642                 :            : /**
     643                 :            : *   Apply protect attribute to cell of table
     644                 :            : *   @date   04/04/2005
     645                 :            : *   @param  aTableID - ID of the table which the cell belongs to
     646                 :            : *   @param
     647                 :            : *   @return XFCell*
     648                 :            : */
     649                 :         60 : void LwpCellLayout::ApplyProtect(XFCell * pCell, LwpObjectID aTableID)
     650                 :            : {
     651                 :         60 :     sal_Bool bProtected = sal_False;
     652                 :            :     // judge current cell
     653         [ -  + ]:         60 :     if (IsProtected())
     654                 :            :     {
     655                 :          0 :         bProtected = sal_True;
     656                 :            :     }
     657                 :            :     else
     658                 :            :     {
     659                 :            :         // judge base on
     660         [ +  + ]:         60 :         LwpCellLayout * pBase = dynamic_cast<LwpCellLayout *>(m_BasedOnStyle.obj());
     661 [ +  + ][ -  + ]:         60 :         if (pBase && pBase->IsProtected())
                 [ -  + ]
     662                 :            :         {
     663                 :          0 :             bProtected = sal_True;
     664                 :            :         }
     665                 :            :         else
     666                 :            :         {
     667                 :            :             // judge whole table
     668         [ -  + ]:         60 :             LwpTable * pTable = dynamic_cast<LwpTable *>(aTableID.obj());
     669                 :         60 :             LwpTableLayout * pTableLayout = static_cast<LwpTableLayout *>(pTable->GetTableLayout());
     670                 :         60 :             LwpSuperTableLayout * pSuper = pTableLayout->GetSuperTableLayout();
     671 [ -  + ][ -  + ]:         60 :             if (pSuper && pSuper->IsProtected())
                 [ +  - ]
     672                 :            :             {
     673                 :          0 :                 bProtected = sal_True;
     674                 :            :             }
     675                 :            :         }
     676                 :            :     }
     677                 :            : 
     678                 :         60 :     pCell->SetProtect(bProtected);
     679                 :         60 : }
     680                 :            : 
     681                 :            : 
     682                 :          0 : LwpConnectedCellLayout::LwpConnectedCellLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
     683                 :          0 :     : LwpCellLayout(objHdr, pStrm)
     684                 :          0 : {}
     685                 :            : 
     686                 :          0 : LwpConnectedCellLayout::~LwpConnectedCellLayout()
     687         [ #  # ]:          0 : {}
     688                 :            : /**
     689                 :            :  * @short   Set current connected cell layout to cell layout map
     690                 :            :  * @param pCellLayoutMap - cell layout map reference
     691                 :            :  * @return
     692                 :            :  */
     693                 :          0 : void LwpConnectedCellLayout::SetCellMap()
     694                 :            : {
     695                 :            :     // this function is called from LwpTableLayout, so it can't be NULL
     696                 :          0 :     LwpTableLayout * pTableLayout = GetTableLayout();
     697                 :          0 :     sal_uInt16 nRowSpan = m_nRealrowspan;
     698                 :            : 
     699         [ #  # ]:          0 :     for (sal_uInt16 iLoop = 0; iLoop < nRowSpan; iLoop ++)
     700                 :            :     {
     701         [ #  # ]:          0 :         for (sal_uInt16 jLoop = 0; jLoop < cnumcols; jLoop ++)
     702                 :          0 :             pTableLayout->SetWordProCellMap(iLoop + crowid, jLoop + ccolid, this);
     703                 :            :     }
     704                 :          0 : }
     705                 :            : 
     706                 :            : /**
     707                 :            :  * @short   judge border type by cell neighbour
     708                 :            :  * @param nRow
     709                 :            :  * @param nCol
     710                 :            :  * @param pTableLayout
     711                 :            :  * @return   LwpCellBorderType
     712                 :            :  */
     713                 :          0 : LwpCellBorderType LwpConnectedCellLayout::GetCellBorderType(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
     714                 :            : {
     715         [ #  # ]:          0 :     if (!pTableLayout)
     716                 :            :     {
     717                 :            :         assert(sal_False);
     718                 :          0 :         return enumWholeBorder;
     719                 :            :     }
     720                 :            : 
     721                 :          0 :     sal_uInt16 nRowSpan = m_nRealrowspan;
     722                 :            : 
     723                 :            :     // get left cell and judge if neighbour border is different
     724                 :          0 :     XFBorders * pBorders = GetXFBorders();
     725         [ #  # ]:          0 :     if(!pBorders)
     726                 :            :     {
     727                 :          0 :         return enumWholeBorder;
     728                 :            :     }
     729                 :          0 :     XFBorder *pLeftBorder = pBorders->GetLeft();
     730                 :          0 :     XFBorder *pBottomBorder = pBorders->GetBottom();
     731                 :          0 :     sal_Bool bNoLeftBorder = sal_True;
     732                 :          0 :     sal_Bool bNoBottomBorder = sal_True;
     733                 :            : 
     734         [ #  # ]:          0 :     if (nCol == 0)
     735                 :            :     {
     736                 :          0 :         bNoLeftBorder = sal_False;
     737                 :            :     }
     738                 :            :     else
     739                 :            :     {
     740         [ #  # ]:          0 :         for (sal_uInt16 iLoop=0; iLoop < nRowSpan; iLoop++)
     741                 :            :         {
     742                 :          0 :             LwpCellLayout * pLeftNeighbour = GetCellByRowCol(nRow+iLoop, GetLeftColID(nCol), pTableLayout);
     743         [ #  # ]:          0 :             if (pLeftNeighbour)
     744                 :            :             {
     745                 :          0 :                 XFBorders * pNeighbourBorders = pLeftNeighbour->GetXFBorders();
     746         [ #  # ]:          0 :                 if (pNeighbourBorders)
     747                 :            :                 {
     748                 :          0 :                     XFBorder * pRightBorder = pNeighbourBorders->GetRight();
     749         [ #  # ]:          0 :                     if (*pLeftBorder != *pRightBorder)
     750                 :            :                     {
     751                 :            :                         // if left border is different with right border of left cell
     752                 :            :                         // we should not ignored it
     753                 :          0 :                         bNoLeftBorder = sal_False;
     754                 :          0 :                         break;
     755                 :            :                     }
     756                 :          0 :                     delete pNeighbourBorders;
     757                 :            :                 }
     758                 :            :             }
     759                 :            :         }
     760                 :            :     }
     761                 :            : 
     762         [ #  # ]:          0 :     if ( (nRow + nRowSpan) == pTableLayout->GetTable()->GetRow() )
     763                 :            :     {
     764                 :          0 :         bNoBottomBorder = sal_False;
     765                 :            :     }
     766                 :            :     else
     767                 :            :     {
     768         [ #  # ]:          0 :         for (sal_uInt16 iLoop = 0; iLoop < cnumcols; iLoop ++)
     769                 :            :         {
     770                 :          0 :             LwpCellLayout * pBelowNeighbour = GetCellByRowCol(nRow + nRowSpan, nCol+iLoop, pTableLayout);
     771         [ #  # ]:          0 :             if (pBelowNeighbour)
     772                 :            :             {
     773                 :          0 :                 XFBorders * pBelowBorders = pBelowNeighbour->GetXFBorders();
     774         [ #  # ]:          0 :                 if (pBelowBorders)
     775                 :            :                 {
     776                 :          0 :                     XFBorder * pTopBorder = pBelowBorders->GetTop();
     777         [ #  # ]:          0 :                     if (*pTopBorder != *pBottomBorder)
     778                 :            :                     {
     779                 :            :                         // if bottom border is different with right border of left cell
     780                 :            :                         // we should not ignored it
     781                 :          0 :                         bNoBottomBorder = sal_False;
     782                 :          0 :                         break;
     783                 :            :                     }
     784                 :          0 :                     delete pBelowBorders;
     785                 :            :                 }
     786                 :            :             }
     787                 :            :         }
     788                 :            :     }
     789                 :          0 :     delete pBorders;
     790                 :            : 
     791         [ #  # ]:          0 :     if (bNoBottomBorder)
     792                 :            :     {
     793         [ #  # ]:          0 :         if (bNoLeftBorder)
     794                 :            :         {
     795                 :          0 :             return enumNoLeftNoBottomBorder;
     796                 :            :         }
     797                 :          0 :         return enumNoBottomBorder;
     798                 :            :     }
     799         [ #  # ]:          0 :     if (bNoLeftBorder)
     800                 :            :     {
     801                 :          0 :         return enumNoLeftBorder;
     802                 :            :     }
     803                 :          0 :     return enumWholeBorder;
     804                 :            : }
     805                 :            : /**
     806                 :            :  * @short   Read connected cell layout
     807                 :            :  * @param
     808                 :            :  * @return
     809                 :            :  */
     810                 :          0 : void LwpConnectedCellLayout::Read()
     811                 :            : {
     812                 :          0 :     LwpCellLayout::Read();
     813                 :            :     sal_uInt16 numcols;
     814                 :            : 
     815                 :          0 :     cnumrows = m_pObjStrm->QuickReaduInt16();
     816                 :          0 :     numcols = m_pObjStrm->QuickReaduInt16();        // written as a lushort
     817                 :          0 :     cnumcols = (sal_uInt8)numcols;
     818                 :            : 
     819                 :          0 :     m_nRealrowspan = cnumrows;
     820                 :          0 :     m_nRealcolspan = cnumcols;
     821                 :            : 
     822                 :          0 :     m_pObjStrm->SkipExtra();
     823                 :          0 : }
     824                 :          0 : XFCell* LwpConnectedCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol)
     825                 :            : {
     826                 :          0 :     XFCell * pXFCell = LwpCellLayout::ConvertCell(aTableID, nRow, nCol);
     827                 :          0 :     pXFCell->SetColumnSpaned(cnumcols);
     828                 :            : //  if(!m_bSplitFlag)
     829                 :            : //  {
     830                 :            : //  }
     831                 :          0 :     return pXFCell;
     832                 :            : }
     833                 :            : /**
     834                 :            :  * @short   parse connected cell layout
     835                 :            :  * @param pOutputStream - output stream
     836                 :            :  * @return
     837                 :            :  */
     838                 :          0 :  void  LwpConnectedCellLayout::Parse(IXFStream* /*pOutputStream*/)
     839                 :            : {
     840                 :          0 : }
     841                 :            : 
     842                 :          0 : LwpHiddenCellLayout::LwpHiddenCellLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
     843         [ #  # ]:          0 :     : LwpCellLayout(objHdr, pStrm)
     844                 :          0 : {}
     845                 :            : 
     846                 :          0 : LwpHiddenCellLayout::~LwpHiddenCellLayout()
     847         [ #  # ]:          0 : {}
     848                 :            : /**
     849                 :            :  * @short   Set current hidden cell layout to cell layout map
     850                 :            :  * @param
     851                 :            :  * @return
     852                 :            :  */
     853                 :          0 : void LwpHiddenCellLayout::SetCellMap()
     854                 :            : {
     855                 :          0 :     return;
     856                 :            : }
     857                 :            : /**
     858                 :            :  * @short   Read hidden cell layout
     859                 :            :  * @param
     860                 :            :  * @return
     861                 :            :  */
     862                 :          0 : void LwpHiddenCellLayout::Read()
     863                 :            : {
     864                 :          0 :     LwpCellLayout::Read();
     865                 :            : 
     866                 :          0 :     cconnectedlayout.ReadIndexed(m_pObjStrm);
     867                 :          0 :     m_pObjStrm->SkipExtra();
     868                 :            : 
     869                 :          0 : }
     870                 :            : /**
     871                 :            :  * @short   Convert hidden cell layout
     872                 :            :  * @param aTableID - Object ID of table
     873                 :            :  * @return XFCell * - pointer to converted cell
     874                 :            :  */
     875                 :            : 
     876                 :          0 : XFCell* LwpHiddenCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol)
     877                 :            : {
     878         [ #  # ]:          0 :     if (!cconnectedlayout.obj())
     879                 :          0 :         return NULL;
     880         [ #  # ]:          0 :     LwpConnectedCellLayout* pConnCell = dynamic_cast<LwpConnectedCellLayout* >(cconnectedlayout.obj());
     881                 :            : 
     882         [ #  # ]:          0 :     if (nRow < (pConnCell->GetNumrows()+pConnCell->GetRowID()))
     883                 :          0 :         return NULL;
     884                 :            :     // if the hidden cell should be displayed for limit of SODC
     885                 :            :     // use the default cell layout
     886                 :          0 :     XFCell* pXFCell = NULL;
     887         [ #  # ]:          0 :     LwpTable *pTable = dynamic_cast<LwpTable *>(aTableID.obj());
     888         [ #  # ]:          0 :     if (pTable)
     889                 :            :     {
     890         [ #  # ]:          0 :         LwpCellLayout *pDefault = dynamic_cast<LwpCellLayout *>(pTable->GetDefaultCellStyle()->obj());
     891         [ #  # ]:          0 :         if (pDefault)
     892                 :            :         {
     893                 :          0 :             pXFCell = pDefault->ConvertCell(aTableID, nRow, nCol);
     894                 :            :         }
     895                 :            :         else
     896                 :            :         {
     897                 :          0 :             pXFCell = pConnCell->ConvertCell(aTableID, nRow, nCol);
     898                 :            :         }
     899                 :          0 :         pXFCell->SetColumnSpaned(pConnCell->GetNumcols());
     900                 :            :     }
     901                 :            :     else
     902                 :            :     {
     903                 :            :         assert(sal_False);
     904                 :            :     }
     905                 :          0 :     return pXFCell;
     906                 :            : }
     907                 :            : /**
     908                 :            :  * @short   parse hidden cell layout
     909                 :            :  * @param pOutputStream - output stream
     910                 :            :  * @return
     911                 :            :  */
     912                 :          0 :  void  LwpHiddenCellLayout::Parse(IXFStream* /*pOutputStream*/)
     913                 :            : {
     914                 :          0 : }
     915                 :            : 
     916                 :            : 
     917                 :          0 : LwpParallelColumnsBlock::LwpParallelColumnsBlock(LwpObjectHeader &objHdr, LwpSvStream* pStrm):LwpCellLayout(objHdr, pStrm)
     918                 :          0 : {}
     919                 :            : 
     920                 :          0 : LwpParallelColumnsBlock::~LwpParallelColumnsBlock()
     921         [ #  # ]:          0 : {}
     922                 :            : 
     923                 :          0 : void LwpParallelColumnsBlock::Read()
     924                 :            : {
     925                 :          0 :     LwpCellLayout::Read();
     926                 :          0 :     m_pObjStrm->SkipExtra();
     927                 :          0 : }
     928                 :            : 
     929                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10