LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpcelllayout.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 159 341 46.6 %
Date: 2014-11-03 Functions: 20 43 46.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*************************************************************************
       3             :  *
       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             : #include "lwpcelllayout.hxx"
      62             : #include "lwpfoundry.hxx"
      63             : #include "lwpobjfactory.hxx"
      64             : #include "lwptblcell.hxx"
      65             : #include "lwptblformula.hxx"
      66             : #include "lwpholder.hxx"
      67             : #include "lwpnumericfmt.hxx"
      68             : #include "lwptable.hxx"
      69             : #include "lwpglobalmgr.hxx"
      70             : 
      71             : #include "xfilter/xfstylemanager.hxx"
      72             : #include "xfilter/xfcell.hxx"
      73             : #include "xfilter/xfcellstyle.hxx"
      74             : #include "xfilter/xfcolstyle.hxx"
      75             : 
      76          46 : LwpCellLayout::LwpCellLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
      77             :     : LwpMiddleLayout(objHdr, pStrm)
      78             :     , crowid(0)
      79             :     , ccolid(0)
      80          46 :     , cType(LDT_NONE)
      81             : {
      82          46 : }
      83             : 
      84          88 : LwpCellLayout::~LwpCellLayout()
      85          88 : {}
      86             : 
      87             : /**
      88             :  * @short   Get table layout pointer, if default cell layout, return NULL
      89             :  * @param LwpTableLayout *
      90             :  * @return
      91             :  */
      92           8 : LwpTableLayout * LwpCellLayout::GetTableLayout()
      93             : {
      94           8 :     LwpRowLayout * pRow = dynamic_cast<LwpRowLayout *>(GetParent().obj().get());
      95           8 :     if(!pRow)
      96             :     {
      97           0 :         return NULL;
      98             :     }
      99           8 :     LwpTableLayout * pTableLayout = pRow->GetParentTableLayout();
     100           8 :     return pTableLayout;
     101             : }
     102             : /**
     103             :  * @short   Get table pointer, if default cell layout, return NULL
     104             :  * @param LwpTable *
     105             :  * @return
     106             :  */
     107           2 : LwpTable * LwpCellLayout::GetTable()
     108             : {
     109           2 :     LwpTableLayout * pTableLayout = GetTableLayout();
     110           2 :     if(!pTableLayout)
     111             :     {
     112           0 :         return NULL;
     113             :     }
     114           2 :     LwpTable *pTable = pTableLayout->GetTable();
     115           2 :     return pTable;
     116             : }
     117             : /**
     118             :  * @short   Set current cell layout to cell layout map
     119             :  * @param
     120             :  * @return
     121             :  */
     122           6 : void LwpCellLayout::SetCellMap()
     123             : {
     124             :     // this function is called from LwpTableLayout, so it can't be NULL
     125           6 :     GetTableLayout()->SetWordProCellMap(crowid, ccolid, this);
     126           6 : }
     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         144 : void LwpCellLayout::ApplyPadding(XFCellStyle *pCellStyle)
     160             : {
     161         144 :     double fLeft = GetMarginsValue(MARGIN_LEFT);
     162         144 :     double fRight = GetMarginsValue(MARGIN_RIGHT);
     163         144 :     double fTop = GetMarginsValue(MARGIN_TOP);
     164         144 :     double fBottom = GetMarginsValue(MARGIN_BOTTOM);
     165         144 :     pCellStyle->SetPadding((float)fLeft,(float)fRight,(float)fTop,(float)fBottom);
     166         144 : }
     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           0 : void LwpCellLayout::ApplyBorders(XFCellStyle *pCellStyle)
     173             : {
     174             :     // judge cell border type
     175           0 :     LwpCellBorderType eType = GetCellBorderType(crowid, ccolid, GetTableLayout());
     176             : 
     177             :     // get left cell and judge if neighbour border is different
     178           0 :     XFBorders * pBorders = GetXFBorders();
     179           0 :     if(!pBorders)
     180             :     {
     181           0 :         return;
     182             :     }
     183             : 
     184           0 :     switch (eType)
     185             :     {
     186             :     case enumNoBottomBorder:
     187           0 :         pBorders->SetWidth(enumXFBorderBottom, 0);
     188           0 :         break;
     189             :     case enumNoLeftBorder:
     190           0 :         pBorders->SetWidth(enumXFBorderLeft, 0);
     191           0 :         break;
     192             :     case enumNoLeftNoBottomBorder:
     193           0 :         pBorders->SetWidth(enumXFBorderBottom, 0);
     194           0 :         pBorders->SetWidth(enumXFBorderLeft, 0);
     195           0 :         break;
     196             :     case enumWholeBorder:
     197           0 :         break;
     198             :     default:
     199             :         assert(false);
     200             :     }
     201           0 :     pCellStyle->SetBorders(pBorders);
     202             : }
     203             : /**
     204             :  * @short   Apply watermark to cell style
     205             :  * @param pCellStyle - pointer of XFCellStyle
     206             :  * @return
     207             :  */
     208         144 : void LwpCellLayout::ApplyWatermark(XFCellStyle *pCellStyle)
     209             : {
     210         144 :     XFBGImage* pBGImage = GetXFBGImage();
     211         144 :     if(pBGImage)
     212             :     {
     213           0 :         pCellStyle->SetBackImage(pBGImage);
     214             :     }
     215         144 : }
     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           0 : void LwpCellLayout::ApplyBackGround(XFCellStyle* pCellStyle)
     237             : {
     238           0 :     if (this->IsPatternFill())
     239             :     {
     240           0 :         ApplyPatternFill(pCellStyle);
     241             :     }
     242             :     else
     243             :     {
     244           0 :         ApplyBackColor(pCellStyle);
     245             :     }
     246           0 : }
     247             : /**
     248             :  * @short   Apply back color to cell style
     249             :  * @param pCellStyle - pointer of XFCellStyle
     250             :  * @return
     251             :  */
     252         144 : void LwpCellLayout::ApplyBackColor(XFCellStyle *pCellStyle)
     253             : {
     254         144 :     LwpColor* pColor = GetBackColor();
     255         144 :     if(pColor && pColor->IsValidColor())
     256             :     {
     257           0 :         XFColor aXFColor(pColor->To24Color());
     258           0 :         pCellStyle->SetBackColor(aXFColor);
     259             :     }
     260         144 : }
     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         144 : void LwpCellLayout::ApplyFmtStyle(XFCellStyle *pCellStyle)
     267             : {
     268         144 :     LwpLayoutNumerics* pLayoutNumerics = dynamic_cast<LwpLayoutNumerics*>(cLayNumerics.obj().get());
     269         144 :     if (!pLayoutNumerics)
     270             :     {
     271             :         // if current layout doesn't have format, go to based on layout
     272          96 :         LwpCellLayout* pCellLayout = dynamic_cast<LwpCellLayout*>(m_BasedOnStyle.obj().get());
     273          96 :         if (pCellLayout)
     274             :         {
     275           0 :             pLayoutNumerics = dynamic_cast<LwpLayoutNumerics*>(pCellLayout->GetNumericsObject().obj().get());
     276             :         }
     277             :     }
     278             : 
     279             :     // apply format style
     280         144 :     if (pLayoutNumerics)
     281             :     {
     282          48 :         XFStyle* pStyle = pLayoutNumerics->Convert();
     283          48 :         if (pStyle)
     284             :         {
     285          48 :             XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     286          48 :             m_NumfmtName = pXFStyleManager->AddStyle(pStyle)->GetStyleName();
     287          48 :             pCellStyle->SetDataStyle(m_NumfmtName);
     288             :         }
     289             :     }
     290             : 
     291         144 :     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          40 : OUString LwpCellLayout::GetCellStyleName(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
     300             : {
     301             :     // judge cell border type
     302          40 :     LwpCellBorderType eType = GetCellBorderType(nRow, nCol, pTableLayout);
     303          40 :     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          40 : 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          40 :     LwpTable * pTable = dynamic_cast<LwpTable *>(aTableID.obj().get());
     318          40 :     if (!pTable)
     319             :     {
     320             :         assert(false);
     321           0 :         return NULL;
     322             :     }
     323          40 :     XFCell * pXFCell = new XFCell();
     324          40 :     OUString aStyleName = m_StyleName;
     325             : 
     326             :     // if cell layout is aTableID's default cell layout
     327             :     // we should judt its style by current position
     328          40 :     if (pTable->GetDefaultCellStyle() == GetObjectID())
     329             :     {
     330          40 :         aStyleName = GetCellStyleName(nRow, nCol, pTable->GetTableLayout());
     331             :     }
     332             : 
     333             :     // content of cell
     334          40 :     LwpStory* pStory = dynamic_cast<LwpStory*>(m_Content.obj().get());
     335          40 :     if (pStory)
     336             :     {
     337           0 :         pStory->XFConvert(pXFCell);
     338             :     }
     339             : 
     340          40 :     ApplyProtect(pXFCell, aTableID);
     341          40 :     pXFCell->SetStyleName(aStyleName);
     342          40 :     return pXFCell;
     343             : }
     344             : 
     345           2 : LwpPara* LwpCellLayout::GetLastParaOfPreviousStory()
     346             : {
     347           2 :     LwpObjectID* pPreStoryID = this->GetPreviousCellStory();
     348           2 :     if (pPreStoryID && !(pPreStoryID->IsNull()))
     349             :     {
     350           0 :         LwpStory* pPreStory = dynamic_cast<LwpStory*>(pPreStoryID->obj(VO_STORY).get());
     351           0 :         return dynamic_cast<LwpPara*>(pPreStory->GetLastPara().obj(VO_PARA).get());
     352             :     }
     353             :     else
     354             :     {
     355           2 :         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           2 : LwpObjectID * LwpCellLayout::GetPreviousCellStory()
     365             : {
     366           2 :     LwpTable *pTable = GetTable();
     367           2 :     if (!pTable)
     368             :     {
     369             :         assert(false);
     370           0 :         return NULL;
     371             :     }
     372           2 :     sal_uInt16 nRow = crowid;
     373           2 :     sal_uInt16 nCol = ccolid;
     374             : 
     375             :     // if table is reset paragraph in columns, get cell on the top side of current cell
     376           2 :     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           2 :         if (nCol == 0)
     388             :         {
     389           2 :             if (nRow == 0)
     390             :             {
     391           2 :                 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(false);
     410           0 :         return NULL;
     411             :     }
     412           0 :     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          40 : LwpCellBorderType LwpCellLayout::GetCellBorderType(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
     423             : {
     424          40 :     if (!pTableLayout)
     425             :     {
     426             :         assert(false);
     427           0 :         return enumWholeBorder;
     428             :     }
     429             : 
     430             :     // get left cell and judge if neighbour border is different
     431          40 :     XFBorders * pBorders = GetXFBorders();
     432          40 :     if(!pBorders)
     433             :     {
     434           0 :         return enumWholeBorder;
     435             :     }
     436          40 :     XFBorder& rLeftBorder = pBorders->GetLeft();
     437          40 :     XFBorder& rBottomBorder = pBorders->GetBottom();
     438          40 :     bool bNoLeftBorder = false;
     439          40 :     bool bNoBottomBorder = false;
     440             : 
     441          40 :     LwpCellLayout * pLeftNeighbour = GetCellByRowCol(nRow, GetLeftColID(nCol), pTableLayout);
     442          40 :     if (pLeftNeighbour)
     443             :     {
     444          30 :         XFBorders * pNeighbourBorders = pLeftNeighbour->GetXFBorders();
     445          30 :         if (pNeighbourBorders)
     446             :         {
     447          30 :             XFBorder& rRightBorder = pNeighbourBorders->GetRight();
     448          30 :             if (rLeftBorder == rRightBorder)
     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          30 :                 bNoLeftBorder = true;
     454             :             }
     455          30 :             delete pNeighbourBorders;
     456             :         }
     457             : 
     458             :     }
     459             : 
     460          40 :     LwpCellLayout * pBelowNeighbour = GetCellByRowCol(GetBelowRowID(nRow), nCol, pTableLayout);
     461          40 :     if (pBelowNeighbour) //&& (eType == enumRightNotLastCellBorder || eType ==  enumLeftNotLastCellBorder) )
     462             :     {
     463          32 :         XFBorders * pBelowBorders = pBelowNeighbour->GetXFBorders();
     464          32 :         if (pBelowBorders)
     465             :         {
     466          32 :             XFBorder& rTopBorder = pBelowBorders->GetTop();
     467          32 :             if (rTopBorder == rBottomBorder)
     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          32 :                 bNoBottomBorder = true;
     473             :             }
     474          32 :             delete pBelowBorders;
     475             :         }
     476             :     }
     477             : 
     478          40 :     delete pBorders;
     479             : 
     480          40 :     if (bNoBottomBorder)
     481             :     {
     482          32 :         if (bNoLeftBorder)
     483             :         {
     484          24 :             return enumNoLeftNoBottomBorder;
     485             :         }
     486           8 :         return enumNoBottomBorder;
     487             :     }
     488           8 :     if (bNoLeftBorder)
     489             :     {
     490           6 :         return enumNoLeftBorder;
     491             :     }
     492           2 :     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          80 : LwpCellLayout * LwpCellLayout::GetCellByRowCol(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
     502             : {
     503          80 :     return pTableLayout->GetCellByRowCol(nRow, nCol);
     504             : }
     505             : /**
     506             :  * @short   Register table's default cell layout
     507             :  * @param
     508             :  * @return
     509             :  */
     510          36 : void LwpCellLayout::RegisterDefaultCell()
     511             : {
     512          36 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     513         180 :     for (sal_uInt16 eLoop = enumWholeBorder; eLoop < enumCellBorderTopLimit; eLoop++)
     514             :     {
     515             :         // register cell style
     516         144 :         XFCellStyle *pCellStyle = new XFCellStyle();
     517             : 
     518         144 :         ApplyPadding(pCellStyle);
     519         144 :         ApplyBackColor(pCellStyle);
     520         144 :         ApplyWatermark(pCellStyle);
     521         144 :         ApplyFmtStyle(pCellStyle);
     522         144 :         pCellStyle->SetAlignType(enumXFAlignNone, GetVerticalAlignmentType());
     523             : 
     524         144 :         XFBorders * pBorders = GetXFBorders();
     525         144 :         if (pBorders)
     526             :         {
     527          32 :             switch(eLoop)
     528             :             {
     529             :             case enumNoBottomBorder:
     530             : 
     531             :                 //| |
     532             : 
     533             :                 // remove bottom line
     534           8 :                 pBorders->SetWidth(enumXFBorderBottom, 0);
     535           8 :                 break;
     536             :             case enumNoLeftNoBottomBorder:
     537             : 
     538             :                 //  |
     539             : 
     540             :                 // remove left and bottom
     541           8 :                 pBorders->SetWidth(enumXFBorderLeft, 0);
     542           8 :                 pBorders->SetWidth(enumXFBorderBottom, 0);
     543           8 :                 break;
     544             :             case enumWholeBorder:
     545             : 
     546             :                 //||
     547             : 
     548             :                 // nothing to remove
     549           8 :                 break;
     550             :             case enumNoLeftBorder:
     551             : 
     552             :                 //| |
     553             : 
     554             :                 // remove left line
     555           8 :                 pBorders->SetWidth(enumXFBorderLeft, 0);
     556           8 :                 break;
     557             :             default:
     558             :                 assert(false);
     559             :             }
     560          32 :             pCellStyle->SetBorders(pBorders);
     561             :         }
     562         144 :         m_CellStyleNames[eLoop] = pXFStyleManager->AddStyle(pCellStyle)->GetStyleName();
     563             :     }
     564          36 : }
     565             : /**
     566             :  * @short    Register 4 types of cell style and register content styles
     567             :  * @param
     568             :  * @param
     569             :  * @param
     570             :  * @return
     571             :  */
     572          36 : void LwpCellLayout::RegisterStyle()
     573             : {
     574          36 :     LwpVirtualLayout * pParent = dynamic_cast<LwpVirtualLayout *>(GetParent().obj().get());
     575          36 :     if (!pParent || pParent->GetLayoutType() != LWP_ROW_LAYOUT)
     576             :     {
     577             :         // default cell layout, we must register 4 styles for it
     578          36 :         RegisterDefaultCell();
     579          72 :         return;
     580             :     }
     581             : 
     582             :     // register cell style
     583           0 :     XFCellStyle *pCellStyle = new XFCellStyle();
     584             : 
     585           0 :     ApplyPadding(pCellStyle);
     586             : //  ApplyBackColor(pCellStyle);
     587           0 :     ApplyBackGround(pCellStyle);
     588           0 :     ApplyWatermark(pCellStyle);
     589           0 :     ApplyFmtStyle(pCellStyle);
     590           0 :     ApplyBorders(pCellStyle);
     591             : 
     592           0 :     pCellStyle->SetAlignType(enumXFAlignNone, GetVerticalAlignmentType());
     593             : 
     594           0 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     595           0 :     m_StyleName = pXFStyleManager->AddStyle(pCellStyle)->GetStyleName();
     596             : 
     597             :     // content object register styles
     598           0 :     rtl::Reference<LwpObject> pObj = m_Content.obj();
     599           0 :     if (pObj.is())
     600             :     {
     601           0 :         pObj->SetFoundry(m_pFoundry);
     602           0 :         pObj->RegisterStyle();
     603             :     }
     604             : 
     605             :     //register child layout style
     606           0 :     RegisterChildStyle();
     607             : }
     608             : /**
     609             :  * @short   Read cell layout
     610             :  * @param
     611             :  * @return
     612             :  */
     613          46 : void LwpCellLayout::Read()
     614             : {
     615          46 :     LwpObjectStream* pStrm = m_pObjStrm;
     616             : 
     617          46 :     LwpMiddleLayout::Read();
     618             : 
     619             :     // before the layout hierarchy rework
     620          46 :     if (LwpFileHeader::m_nFileRevision  < 0x000b)
     621             :     {
     622             :         assert(false);
     623             :     }
     624             :     else
     625             :     {
     626          46 :         crowid = pStrm->QuickReaduInt16();
     627          46 :         ccolid = (sal_uInt8) pStrm->QuickReaduInt16();  // written as a lushort
     628             : 
     629             :         sal_uInt16 type;
     630             : 
     631          46 :         type = pStrm->QuickReaduInt16();
     632          46 :         pStrm->SkipExtra();
     633          46 :         cType = (LeaderDotType)type;
     634             : 
     635          46 :         cLayNumerics.ReadIndexed(pStrm);
     636          46 :         cLayDiagonalLine.ReadIndexed(pStrm);
     637             : 
     638          46 :         pStrm->SkipExtra();
     639             :     }
     640          46 : }
     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          40 : void LwpCellLayout::ApplyProtect(XFCell * pCell, LwpObjectID aTableID)
     650             : {
     651          40 :     bool bProtected = false;
     652             :     // judge current cell
     653          40 :     if (IsProtected())
     654             :     {
     655           0 :         bProtected = true;
     656             :     }
     657             :     else
     658             :     {
     659             :         // judge base on
     660          40 :         LwpCellLayout * pBase = dynamic_cast<LwpCellLayout *>(m_BasedOnStyle.obj().get());
     661          40 :         if (pBase && pBase->IsProtected())
     662             :         {
     663           0 :             bProtected = true;
     664             :         }
     665             :         else
     666             :         {
     667             :             // judge whole table
     668          40 :             LwpTable * pTable = dynamic_cast<LwpTable *>(aTableID.obj().get());
     669          40 :             LwpTableLayout * pTableLayout = pTable ? static_cast<LwpTableLayout *>(pTable->GetTableLayout()) : NULL;
     670          40 :             LwpSuperTableLayout * pSuper = pTableLayout ? pTableLayout->GetSuperTableLayout() : NULL;
     671          40 :             if (pSuper && pSuper->IsProtected())
     672             :             {
     673           0 :                 bProtected = true;
     674             :             }
     675             :         }
     676             :     }
     677             : 
     678          40 :     pCell->SetProtect(bProtected);
     679          40 : }
     680             : 
     681           0 : LwpConnectedCellLayout::LwpConnectedCellLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
     682             :     : LwpCellLayout(objHdr, pStrm)
     683             :     , cnumrows(0)
     684             :     , cnumcols(0)
     685             :     , m_nRealrowspan(0)
     686           0 :     , m_nRealcolspan(0)
     687             : {
     688           0 : }
     689             : 
     690           0 : LwpConnectedCellLayout::~LwpConnectedCellLayout()
     691           0 : {}
     692             : /**
     693             :  * @short   Set current connected cell layout to cell layout map
     694             :  * @param pCellLayoutMap - cell layout map reference
     695             :  * @return
     696             :  */
     697           0 : void LwpConnectedCellLayout::SetCellMap()
     698             : {
     699             :     // this function is called from LwpTableLayout, so it can't be NULL
     700           0 :     LwpTableLayout * pTableLayout = GetTableLayout();
     701           0 :     sal_uInt16 nRowSpan = m_nRealrowspan;
     702             : 
     703           0 :     for (sal_uInt16 iLoop = 0; iLoop < nRowSpan; iLoop ++)
     704             :     {
     705           0 :         for (sal_uInt16 jLoop = 0; jLoop < cnumcols; jLoop ++)
     706           0 :             pTableLayout->SetWordProCellMap(iLoop + crowid, jLoop + ccolid, this);
     707             :     }
     708           0 : }
     709             : 
     710             : /**
     711             :  * @short   judge border type by cell neighbour
     712             :  * @param nRow
     713             :  * @param nCol
     714             :  * @param pTableLayout
     715             :  * @return   LwpCellBorderType
     716             :  */
     717           0 : LwpCellBorderType LwpConnectedCellLayout::GetCellBorderType(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
     718             : {
     719           0 :     if (!pTableLayout)
     720             :     {
     721             :         assert(false);
     722           0 :         return enumWholeBorder;
     723             :     }
     724             : 
     725           0 :     sal_uInt16 nRowSpan = m_nRealrowspan;
     726             : 
     727             :     // get left cell and judge if neighbour border is different
     728           0 :     XFBorders * pBorders = GetXFBorders();
     729           0 :     if(!pBorders)
     730             :     {
     731           0 :         return enumWholeBorder;
     732             :     }
     733           0 :     XFBorder& rLeftBorder = pBorders->GetLeft();
     734           0 :     XFBorder& rBottomBorder = pBorders->GetBottom();
     735           0 :     bool bNoLeftBorder = true;
     736           0 :     bool bNoBottomBorder = true;
     737             : 
     738           0 :     if (nCol == 0)
     739             :     {
     740           0 :         bNoLeftBorder = false;
     741             :     }
     742             :     else
     743             :     {
     744           0 :         for (sal_uInt16 iLoop=0; iLoop < nRowSpan; iLoop++)
     745             :         {
     746           0 :             LwpCellLayout * pLeftNeighbour = GetCellByRowCol(nRow+iLoop, GetLeftColID(nCol), pTableLayout);
     747           0 :             if (pLeftNeighbour)
     748             :             {
     749           0 :                 boost::scoped_ptr<XFBorders> pNeighbourBorders(pLeftNeighbour->GetXFBorders());
     750           0 :                 if (pNeighbourBorders)
     751             :                 {
     752           0 :                     XFBorder& rRightBorder = pNeighbourBorders->GetRight();
     753           0 :                     if (rLeftBorder != rRightBorder)
     754             :                     {
     755             :                         // if left border is different with right border of left cell
     756             :                         // we should not ignored it
     757           0 :                         bNoLeftBorder = false;
     758           0 :                         break;
     759             :                     }
     760           0 :                 }
     761             :             }
     762             :         }
     763             :     }
     764             : 
     765           0 :     if ( (nRow + nRowSpan) == pTableLayout->GetTable()->GetRow() )
     766             :     {
     767           0 :         bNoBottomBorder = false;
     768             :     }
     769             :     else
     770             :     {
     771           0 :         for (sal_uInt16 iLoop = 0; iLoop < cnumcols; iLoop ++)
     772             :         {
     773           0 :             LwpCellLayout * pBelowNeighbour = GetCellByRowCol(nRow + nRowSpan, nCol+iLoop, pTableLayout);
     774           0 :             if (pBelowNeighbour)
     775             :             {
     776           0 :                 boost::scoped_ptr<XFBorders> pBelowBorders(pBelowNeighbour->GetXFBorders());
     777           0 :                 if (pBelowBorders)
     778             :                 {
     779           0 :                     XFBorder& rTopBorder = pBelowBorders->GetTop();
     780           0 :                     if (rTopBorder != rBottomBorder)
     781             :                     {
     782             :                         // if bottom border is different with right border of left cell
     783             :                         // we should not ignored it
     784           0 :                         bNoBottomBorder = false;
     785           0 :                         break;
     786             :                     }
     787           0 :                 }
     788             :             }
     789             :         }
     790             :     }
     791           0 :     delete pBorders;
     792             : 
     793           0 :     if (bNoBottomBorder)
     794             :     {
     795           0 :         if (bNoLeftBorder)
     796             :         {
     797           0 :             return enumNoLeftNoBottomBorder;
     798             :         }
     799           0 :         return enumNoBottomBorder;
     800             :     }
     801           0 :     if (bNoLeftBorder)
     802             :     {
     803           0 :         return enumNoLeftBorder;
     804             :     }
     805           0 :     return enumWholeBorder;
     806             : }
     807             : /**
     808             :  * @short   Read connected cell layout
     809             :  * @param
     810             :  * @return
     811             :  */
     812           0 : void LwpConnectedCellLayout::Read()
     813             : {
     814           0 :     LwpCellLayout::Read();
     815             :     sal_uInt16 numcols;
     816             : 
     817           0 :     cnumrows = m_pObjStrm->QuickReaduInt16();
     818           0 :     numcols = m_pObjStrm->QuickReaduInt16();        // written as a lushort
     819           0 :     cnumcols = (sal_uInt8)numcols;
     820             : 
     821           0 :     m_nRealrowspan = cnumrows;
     822           0 :     m_nRealcolspan = cnumcols;
     823             : 
     824           0 :     m_pObjStrm->SkipExtra();
     825           0 : }
     826           0 : XFCell* LwpConnectedCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol)
     827             : {
     828           0 :     XFCell * pXFCell = LwpCellLayout::ConvertCell(aTableID, nRow, nCol);
     829           0 :     pXFCell->SetColumnSpaned(cnumcols);
     830             : //  if(!m_bSplitFlag)
     831             : //  {
     832             : //  }
     833           0 :     return pXFCell;
     834             : }
     835             : /**
     836             :  * @short   parse connected cell layout
     837             :  * @param pOutputStream - output stream
     838             :  * @return
     839             :  */
     840           0 :  void  LwpConnectedCellLayout::Parse(IXFStream* /*pOutputStream*/)
     841             : {
     842           0 : }
     843             : 
     844           0 : LwpHiddenCellLayout::LwpHiddenCellLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
     845           0 :     : LwpCellLayout(objHdr, pStrm)
     846           0 : {}
     847             : 
     848           0 : LwpHiddenCellLayout::~LwpHiddenCellLayout()
     849           0 : {}
     850             : /**
     851             :  * @short   Set current hidden cell layout to cell layout map
     852             :  * @param
     853             :  * @return
     854             :  */
     855           0 : void LwpHiddenCellLayout::SetCellMap()
     856             : {
     857           0 :     return;
     858             : }
     859             : /**
     860             :  * @short   Read hidden cell layout
     861             :  * @param
     862             :  * @return
     863             :  */
     864           0 : void LwpHiddenCellLayout::Read()
     865             : {
     866           0 :     LwpCellLayout::Read();
     867             : 
     868           0 :     cconnectedlayout.ReadIndexed(m_pObjStrm);
     869           0 :     m_pObjStrm->SkipExtra();
     870             : 
     871           0 : }
     872             : /**
     873             :  * @short   Convert hidden cell layout
     874             :  * @param aTableID - Object ID of table
     875             :  * @return XFCell * - pointer to converted cell
     876             :  */
     877             : 
     878           0 : XFCell* LwpHiddenCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol)
     879             : {
     880           0 :     if (!cconnectedlayout.obj().is())
     881           0 :         return NULL;
     882           0 :     LwpConnectedCellLayout* pConnCell = dynamic_cast<LwpConnectedCellLayout* >(cconnectedlayout.obj().get());
     883             : 
     884           0 :     if (!pConnCell || nRow < (pConnCell->GetNumrows()+pConnCell->GetRowID()))
     885           0 :         return NULL;
     886             :     // if the hidden cell should be displayed for limit of SODC
     887             :     // use the default cell layout
     888           0 :     XFCell* pXFCell = NULL;
     889           0 :     LwpTable *pTable = dynamic_cast<LwpTable *>(aTableID.obj().get());
     890           0 :     if (pTable)
     891             :     {
     892           0 :         LwpCellLayout *pDefault = dynamic_cast<LwpCellLayout *>(pTable->GetDefaultCellStyle().obj().get());
     893           0 :         if (pDefault)
     894             :         {
     895           0 :             pXFCell = pDefault->ConvertCell(aTableID, nRow, nCol);
     896             :         }
     897             :         else
     898             :         {
     899           0 :             pXFCell = pConnCell->ConvertCell(aTableID, nRow, nCol);
     900             :         }
     901           0 :         pXFCell->SetColumnSpaned(pConnCell->GetNumcols());
     902             :     }
     903             :     else
     904             :     {
     905             :         assert(false);
     906             :     }
     907           0 :     return pXFCell;
     908             : }
     909             : /**
     910             :  * @short   parse hidden cell layout
     911             :  * @param pOutputStream - output stream
     912             :  * @return
     913             :  */
     914           0 :  void  LwpHiddenCellLayout::Parse(IXFStream* /*pOutputStream*/)
     915             : {
     916           0 : }
     917             : 
     918           0 : LwpParallelColumnsBlock::LwpParallelColumnsBlock(LwpObjectHeader &objHdr, LwpSvStream* pStrm):LwpCellLayout(objHdr, pStrm)
     919           0 : {}
     920             : 
     921           0 : LwpParallelColumnsBlock::~LwpParallelColumnsBlock()
     922           0 : {}
     923             : 
     924           0 : void LwpParallelColumnsBlock::Read()
     925             : {
     926           0 :     LwpCellLayout::Read();
     927           0 :     m_pObjStrm->SkipExtra();
     928           0 : }
     929             : 
     930             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10