LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpframelayout.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 273 555 49.2 %
Date: 2012-08-25 Functions: 34 62 54.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 128 463 27.6 %

           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                 :            :  *  the class for VO_FrameLayout
      59                 :            :  ************************************************************************/
      60                 :            : /*************************************************************************
      61                 :            :  * Change History
      62                 :            : Mar 2005            Created
      63                 :            :  ************************************************************************/
      64                 :            : #include "lwpframelayout.hxx"
      65                 :            : #include "lwppara.hxx"
      66                 :            : #include "xfilter/xfstylemanager.hxx"
      67                 :            : #include "xfilter/xfparagraph.hxx"
      68                 :            : #include    "xfilter/xffloatframe.hxx"
      69                 :            : #include "xfilter/xfrubystyle.hxx"
      70                 :            : #include "lwppagelayout.hxx"
      71                 :            : #include "lwpoleobject.hxx"
      72                 :            : #include "lwptablelayout.hxx"
      73                 :            : #include "lwpgrfobj.hxx"
      74                 :            : #include "lwpglobalmgr.hxx"
      75                 :            : 
      76                 :         81 : LwpFrame::LwpFrame(LwpPlacableLayout* pLayout):m_pLayout(pLayout)
      77                 :            : {
      78                 :         81 : }
      79                 :            : 
      80                 :         81 : LwpFrame::~LwpFrame()
      81                 :            : {
      82                 :         81 : }
      83                 :            : /**
      84                 :            : * @descr:  parse frame
      85                 :            : * @param:  register frame style
      86                 :            : * @param:  pFrameStyle - Frame Style object
      87                 :            : *
      88                 :            : */
      89                 :         75 : void  LwpFrame::RegisterStyle(XFFrameStyle* pFrameStyle)
      90                 :            : {
      91                 :         75 :     ApplyWrapType(pFrameStyle);
      92                 :         75 :     ApplyMargins(pFrameStyle);
      93                 :         75 :     ApplyPadding(pFrameStyle);
      94                 :         75 :     ApplyBorders(pFrameStyle);
      95                 :         75 :     ApplyColumns(pFrameStyle);
      96                 :         75 :     ApplyShadow(pFrameStyle);
      97                 :         75 :     ApplyBackGround(pFrameStyle);
      98                 :         75 :     ApplyWatermark(pFrameStyle);
      99                 :            : //  ApplyBackColor(pFrameStyle);
     100                 :         75 :     ApplyProtect(pFrameStyle);
     101                 :         75 :     ApplyTextDir(pFrameStyle);
     102                 :         75 :     ApplyPosType(pFrameStyle);
     103                 :            : 
     104         [ +  - ]:         75 :     pFrameStyle->SetStyleName(m_pLayout->GetName()->str());
     105                 :         75 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     106                 :         75 :     m_StyleName = pXFStyleManager->AddStyle(pFrameStyle)->GetStyleName();
     107                 :         75 :     m_pLayout->SetStyleName(m_StyleName);
     108                 :         75 : }
     109                 :            : /**
     110                 :            : * @descr:  parse frame and set frame properties
     111                 :            : * @param:   pXFFrame - XFFrame object
     112                 :            : * @param:  nPageNo - the page number that the frame anchors
     113                 :            : *
     114                 :            : */
     115                 :         39 :  void LwpFrame::Parse(XFFrame* pXFFrame, sal_Int32 nPageNo)
     116                 :            :  {
     117                 :            :     //set the frame style name
     118         [ +  - ]:         39 :     pXFFrame->SetStyleName(m_StyleName);
     119                 :            : 
     120                 :            :     //SetAnchorType and position,if it's page anchor,set the page number.
     121         [ +  - ]:         39 :     ParseAnchorType(pXFFrame);
     122         [ -  + ]:         39 :     if(nPageNo>0)
     123                 :            :     {
     124                 :          0 :         pXFFrame->SetAnchorPage(nPageNo);
     125                 :            :     }
     126                 :            : 
     127                 :            :     //Set frame Name
     128                 :         39 :     OUString aFrameName = m_pLayout->GetName()->str();
     129         [ -  + ]:         39 :     if(!aFrameName.isEmpty())
     130                 :            :     {
     131                 :            :         //cause the bug of SODC, the linkframe name can not be "Frame1", so I change the frame name
     132                 :            :         /*if(aFrameName.equals(A2OUSTR("Frame1")))
     133                 :            :         {
     134                 :            :             aFrameName = A2OUSTR("Frame1_COPY");
     135                 :            :         }
     136                 :            :         pXFFrame->SetName(aFrameName);*/
     137                 :          0 :         pXFFrame->SetName(m_StyleName);
     138                 :            :     }
     139                 :            : 
     140         [ +  - ]:         39 :     LwpLayoutGeometry* pLayoutGeo = m_pLayout->GetGeometry();
     141                 :            :     //Set frame Width and height
     142         [ +  - ]:         39 :     if(pLayoutGeo)
     143                 :            :     {
     144         [ +  - ]:         39 :         double fWidth = m_pLayout->GetWidth();
     145         [ +  - ]:         39 :         double fHeight = m_pLayout->GetHeight();
     146                 :            : 
     147                 :         39 :         pXFFrame->SetWidth( fWidth );
     148                 :         39 :         pXFFrame->SetHeight( fHeight );
     149                 :            : 
     150                 :            :         //Get content obj;
     151         [ +  - ]:         39 :         /*LwpObject* pObj =*/ m_pLayout->GetContent()->obj();
     152 [ +  - ][ -  + ]:         39 :         if(m_pLayout->IsGroupHead()&&(m_pLayout->IsMinimumHeight()))
         [ #  # ][ #  # ]
                 [ -  + ]
     153                 :            :         {
     154                 :            :             //process grouplayout height. there is problems now
     155                 :          0 :             pXFFrame->SetHeight( fHeight );
     156                 :            :         }
     157                 :            :         /*
     158                 :            :         else if(m_pLayout->IsFitGraphic() && pObj && pObj->GetTag() == VO_GRAPHIC)
     159                 :            :         {
     160                 :            :             //If is graphic, get original size and set it;
     161                 :            :             LwpGraphicObject* pGrpObj = static_cast<LwpGraphicObject*>(pObj);
     162                 :            :             long nHeight =0, nWidth =0;
     163                 :            :             pGrpObj->GetGrafOrgSize(nWidth, nHeight);
     164                 :            :             //add margins to the width and height;
     165                 :            :             fWidth = (double)nWidth/TWIPS_PER_CM + m_pLayout->GetMarginsValue(MARGIN_LEFT) + m_pLayout->GetMarginsValue(MARGIN_RIGHT);
     166                 :            :             fHeight = (double)nHeight/TWIPS_PER_CM + m_pLayout->GetMarginsValue(MARGIN_TOP) + m_pLayout->GetMarginsValue(MARGIN_BOTTOM);
     167                 :            :             pXFFrame->SetWidth(fWidth);
     168                 :            :             pXFFrame->SetHeight(fHeight);
     169                 :            :         }
     170                 :            :         */
     171 [ +  - ][ +  + ]:         39 :         else if(m_pLayout->IsAutoGrow())
     172                 :            :         {
     173                 :         18 :             pXFFrame->SetMinHeight( fHeight );
     174                 :            :         }
     175                 :            :     }
     176                 :            : 
     177 [ +  - ][ +  - ]:         39 :     if(m_pLayout->IsFrame())
     178                 :            :     {
     179                 :            :         //Set frame link. Only frame layout has this feature
     180                 :         39 :         LwpFrameLayout* pLayout= static_cast<LwpFrameLayout*>(m_pLayout);
     181         [ +  - ]:         39 :         pXFFrame->SetNextLink(pLayout->GetNextLinkName());
     182                 :         39 :     }
     183                 :            : 
     184                 :         39 :  }
     185                 :            : /**
     186                 :            : * @descr:  parse frame relative to page, frame or cell
     187                 :            : * @param:   pCont - content container which contains the frame
     188                 :            : *
     189                 :            : */
     190                 :          0 :  void LwpFrame::XFConvert(XFContentContainer* pCont)
     191                 :            :  {
     192                 :            :      //parse the frame which anchor to page
     193                 :          0 :     LwpVirtualLayout* pParent = m_pLayout->GetParentLayout();
     194 [ #  # ][ #  # ]:          0 :     if(pParent->IsPage()&& pParent->GetParentLayout()->IsPage())
                 [ #  # ]
     195                 :            :     {
     196                 :            :         //for mirror page, problems exist if the parent layout is header or footer layout,
     197                 :          0 :         pParent = pParent->GetParentLayout();
     198                 :            :     }
     199 [ #  # ][ #  # ]:          0 :     if(m_pLayout->IsAnchorPage()&& pParent->IsPage())
                 [ #  # ]
     200                 :            :     {
     201                 :            :         //get parent layout
     202         [ #  # ]:          0 :         if(m_pLayout->IsUseOnPage())
     203                 :            :         {
     204                 :          0 :             sal_Int32 nPageNo = pParent->GetPageNumber(m_pLayout->GetUsePage());
     205         [ #  # ]:          0 :             if(nPageNo>0)
     206                 :          0 :                 m_pLayout->XFConvertFrame(pCont, nPageNo);
     207                 :            :         }
     208         [ #  # ]:          0 :         else if(m_pLayout->IsUseOnAllPages())
     209                 :            :         {
     210                 :          0 :             sal_Int32 nFirst = pParent->GetPageNumber(FIRST_LAYOUTPAGENO);
     211                 :          0 :             sal_Int32 nLast = pParent->GetPageNumber(LAST_LAYOUTPAGENO);
     212         [ #  # ]:          0 :             if(nLast > 0)
     213                 :          0 :                 m_pLayout->XFConvertFrame(pCont, nFirst, nLast, sal_True);
     214                 :            : 
     215                 :            :         }
     216 [ #  # ][ #  # ]:          0 :         else if(m_pLayout->IsUseOnAllOddPages()||m_pLayout->IsUseOnAllEvenPages())
                 [ #  # ]
     217                 :            :         {
     218                 :          0 :             sal_Int32 nFirst = pParent->GetPageNumber(FIRST_LAYOUTPAGENO);
     219                 :          0 :             sal_Int32 nLast = pParent->GetPageNumber(LAST_LAYOUTPAGENO);
     220         [ #  # ]:          0 :             if(nLast > 0)
     221                 :            :             {
     222                 :          0 :                 sal_uInt16 first = static_cast<sal_uInt16>(nFirst);
     223 [ #  # ][ #  # ]:          0 :                 if((m_pLayout->IsUseOnAllOddPages() && !LwpTools::IsOddNumber(first))
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     224         [ #  # ]:          0 :                 || (m_pLayout->IsUseOnAllEvenPages() && !LwpTools::IsEvenNumber(first)))
     225                 :          0 :                     nFirst++;
     226         [ #  # ]:          0 :                 if(nFirst <= nLast)
     227                 :            :                 {
     228         [ #  # ]:          0 :                     m_pLayout->XFConvertFrame(pCont, nFirst, nLast, sal_False);
     229                 :            :                 }
     230                 :            :             }
     231                 :            :         }
     232                 :            :     }
     233                 :            :     else
     234                 :            :     {
     235                 :          0 :         m_pLayout->XFConvertFrame(pCont);
     236                 :            :     }
     237                 :            : 
     238                 :          0 :  }
     239                 :            : /**
     240                 :            : * @descr:  set frame wrap type style
     241                 :            : * @param:  pFrameStyle - Frame Style object
     242                 :            : *
     243                 :            : */
     244                 :         75 : void LwpFrame::ApplyWrapType(XFFrameStyle *pFrameStyle)
     245                 :            : {
     246                 :         75 :     enumXFWrap eWrap = enumXFWrapNone;
     247   [ +  -  +  -  :         75 :     switch(m_pLayout->GetWrapType())
                -  -  - ]
     248                 :            :     {
     249                 :            :         case LwpPlacableLayout::LAY_WRAP_AROUND:    //fall throught
     250                 :            :         case LwpPlacableLayout::LAY_WRAP_IRREG_BIGGEST:
     251                 :            :         {
     252                 :            :             //In SODC, if Optimal wrap type is used and the distance between the frame object
     253                 :            :             //and page margins is less than 2cm, the text is not wraped. While there is no this feature in Word Pro
     254                 :            :             //So the optimal wrap type is translated to left side or right side wrap type according to the distance
     255                 :            :             //between the frame object and page margins
     256                 :            : 
     257                 :         69 :             eWrap = enumXFWrapBest;
     258                 :         69 :             LwpMiddleLayout* pParent = static_cast<LwpMiddleLayout*>(m_pLayout->GetContainerLayout());
     259         [ +  + ]:         69 :             if(pParent)
     260                 :            :             {
     261         [ +  + ]:         66 :                 if(IsLeftWider())
     262                 :          6 :                     eWrap = enumXFWrapLeft;
     263                 :            :                 else
     264                 :         60 :                     eWrap = enumXFWrapRight;
     265                 :            :             }
     266                 :         69 :             break;
     267                 :            :         }
     268                 :            :         case LwpPlacableLayout::LAY_NO_WRAP_BESIDE:
     269                 :            :         {
     270                 :          0 :             eWrap = enumXFWrapNone;
     271                 :          0 :             break;
     272                 :            :         }
     273                 :            :         case LwpPlacableLayout::LAY_NO_WRAP_AROUND:
     274                 :            :         {
     275                 :          6 :             eWrap = enumXFWrapRunThrough;
     276 [ -  + ][ #  # ]:          6 :             if(!m_pLayout->GetBackColor() && !m_pLayout->GetWaterMarkLayout())
                 [ -  + ]
     277                 :            :             {
     278                 :            :                 //pFrameStyle->SetBackGround(sal_True);
     279                 :          0 :                 XFColor aXFColor(0xffffff); //white color
     280                 :          0 :                 pFrameStyle->SetBackColor(aXFColor);
     281                 :          0 :                 pFrameStyle->SetTransparency(100);  //transparency
     282                 :            :             }
     283                 :          6 :             break;
     284                 :            :         }
     285                 :            :         case LwpPlacableLayout::LAY_WRAP_LEFT:      //fall throught
     286                 :            :         case LwpPlacableLayout::LAY_WRAP_IRREG_LEFT:
     287                 :            :         {
     288                 :          0 :             eWrap = enumXFWrapLeft;
     289                 :          0 :             break;
     290                 :            :         }
     291                 :            :         case LwpPlacableLayout::LAY_WRAP_RIGHT: //fall throught
     292                 :            :         case LwpPlacableLayout::LAY_WRAP_IRREG_RIGHT:
     293                 :            :         {
     294                 :          0 :             eWrap = enumXFWrapRight;
     295                 :          0 :             break;
     296                 :            :         }
     297                 :            :         case LwpPlacableLayout::LAY_WRAP_BOTH:  //fall throught
     298                 :            :         case LwpPlacableLayout::LAY_WRAP_IRREG_BOTH:
     299                 :            :         {
     300                 :          0 :             eWrap = enumXFWrapParallel;
     301                 :          0 :             break;
     302                 :            :         }
     303                 :            :         default:
     304                 :          0 :             break;
     305                 :            :     }
     306                 :            : 
     307                 :            :     //If it is the type of with para above, wrap type is enumXFWrapNone
     308         [ +  + ]:         75 :     if(m_pLayout->GetRelativeType()==LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE)
     309                 :            :     {
     310                 :         48 :         eWrap = enumXFWrapNone;
     311                 :            :     }
     312                 :            : 
     313                 :         75 :     pFrameStyle->SetWrapType(eWrap);
     314                 :         75 : }
     315                 :            : /**
     316                 :            : * @descr:   set frame margins style
     317                 :            : * @param:  pFrameStyle - Frame Style object
     318                 :            : *
     319                 :            : */
     320                 :         75 : void LwpFrame::ApplyMargins(XFFrameStyle *pFrameStyle)
     321                 :            : {
     322                 :         75 :     double fLeft    = m_pLayout->GetExtMarginsValue(MARGIN_LEFT);
     323                 :         75 :     double fRight   = m_pLayout->GetExtMarginsValue(MARGIN_RIGHT);
     324                 :         75 :     double fTop = m_pLayout->GetExtMarginsValue(MARGIN_TOP);
     325                 :         75 :     double fBottom  = m_pLayout->GetExtMarginsValue(MARGIN_BOTTOM);
     326                 :         75 :     pFrameStyle->SetMargins(fLeft,fRight,fTop,fBottom);
     327                 :         75 : }
     328                 :            : /**
     329                 :            : * @descr:  set padding border style
     330                 :            : * @param:  pFrameStyle - Frame Style object
     331                 :            : *
     332                 :            : */
     333                 :         75 : void LwpFrame::ApplyPadding(XFFrameStyle *pFrameStyle)
     334                 :            : {
     335                 :         75 :     double fLeft    = m_pLayout->GetMarginsValue(MARGIN_LEFT);
     336                 :         75 :     double fRight   = m_pLayout->GetMarginsValue(MARGIN_RIGHT);
     337                 :         75 :     double fTop = m_pLayout->GetMarginsValue(MARGIN_TOP);
     338                 :         75 :     double fBottom  = m_pLayout->GetMarginsValue(MARGIN_BOTTOM);
     339                 :         75 :     pFrameStyle->SetPadding(fLeft,fRight,fTop,fBottom);
     340                 :         75 : }
     341                 :            : /**
     342                 :            : * @descr:  set frame border style
     343                 :            : * @param:  pFrameStyle - Frame Style object
     344                 :            : *
     345                 :            : */
     346                 :         75 : void LwpFrame::ApplyBorders(XFFrameStyle *pFrameStyle)
     347                 :            : {
     348                 :         75 :     XFBorders* pBordres = m_pLayout->GetXFBorders();
     349         [ +  + ]:         75 :     if(pBordres)
     350                 :            :     {
     351                 :         48 :         pFrameStyle->SetBorders(pBordres);
     352                 :            :     }
     353                 :         75 : }
     354                 :            : /**
     355                 :            : * @descr:  set frame colums style
     356                 :            : * @param:  pFrameStyle - Frame Style object
     357                 :            : *
     358                 :            : */
     359                 :         75 : void LwpFrame::ApplyColumns(XFFrameStyle *pFrameStyle)
     360                 :            : {
     361                 :         75 :     XFColumns* pColumns = m_pLayout->GetXFColumns();
     362         [ -  + ]:         75 :     if(pColumns)
     363                 :            :     {
     364                 :          0 :         pFrameStyle->SetColumns(pColumns);
     365                 :            :     }
     366                 :         75 : }
     367                 :            : /**
     368                 :            : * @descr:  set frame shadow style
     369                 :            : * @param:  pFrameStyle - Frame Style object
     370                 :            : *
     371                 :            : */
     372                 :         75 : void LwpFrame::ApplyShadow(XFFrameStyle* pFrameStyle)
     373                 :            : {
     374                 :         75 :     XFShadow* pXFShadow = m_pLayout->GetXFShadow();
     375         [ -  + ]:         75 :     if(pXFShadow)
     376                 :            :     {
     377                 :          0 :         pFrameStyle->SetShadow(pXFShadow);
     378                 :            :     }
     379                 :         75 : }
     380                 :            : /**
     381                 :            : * @descr:  set frame back color style
     382                 :            : * @param:  pFrameStyle - Frame Style object
     383                 :            : *
     384                 :            : */
     385                 :         75 : void LwpFrame::ApplyBackColor(XFFrameStyle* pFrameStyle)
     386                 :            : {
     387                 :         75 :     LwpColor* pColor = m_pLayout->GetBackColor();
     388         [ +  - ]:         75 :     if(pColor)
     389                 :            :     {
     390         [ +  - ]:         75 :         XFColor aXFColor(pColor->To24Color());
     391                 :         75 :         pFrameStyle->SetBackColor(aXFColor);
     392                 :            :     }
     393                 :         75 : }
     394                 :            : /**
     395                 :            : * @descr:  set frame protect style
     396                 :            : * @param:  pFrameStyle - Frame Style object
     397                 :            : *
     398                 :            : */
     399                 :         75 : void LwpFrame::ApplyProtect(XFFrameStyle* pFrameStyle)
     400                 :            : {
     401         [ -  + ]:         75 :     if(m_pLayout->IsProtected())
     402                 :            :     {
     403                 :          0 :         pFrameStyle->SetProtect(sal_True,sal_True,sal_True);
     404                 :            :     }
     405                 :         75 : }
     406                 :            : /**
     407                 :            : * @descr:  set frame text direction style
     408                 :            : * @param:  pFrameStyle - Frame Style object
     409                 :            : *
     410                 :            : */
     411                 :         75 : void LwpFrame::ApplyTextDir(XFFrameStyle* pFrameStyle)
     412                 :            : {
     413                 :         75 :     pFrameStyle->SetTextDir(m_pLayout->GetTextDirection());
     414                 :         75 : }
     415                 :            : /**
     416                 :            : * @descr:  set frame position type style
     417                 :            : * @param:  pFrameStyle - Frame Style object
     418                 :            : *
     419                 :            : */
     420                 :         75 : void LwpFrame::ApplyPosType(XFFrameStyle* pFrameStyle)
     421                 :            : {
     422                 :         75 :     enumXFFrameXPos eXPos = enumXFFrameXPosCenter;
     423                 :         75 :     enumXFFrameXRel eXRel = enumXFFrameXRelPara;
     424                 :         75 :     enumXFFrameYPos eYPos = enumXFFrameYPosMiddle;
     425                 :         75 :     enumXFFrameYRel eYRel = enumXFFrameYRelPara;
     426                 :         75 :     sal_uInt8 nType = m_pLayout->GetRelativeType();
     427   [ -  +  -  +  :         75 :     switch(nType)
                   -  - ]
     428                 :            :     {
     429                 :            :         case LwpLayoutRelativityGuts::LAY_PARENT_RELATIVE://fall throught
     430                 :            :         case LwpLayoutRelativityGuts::LAY_CONTENT_RELATIVE:
     431                 :            :         {
     432                 :            :             //anchor to page, frame and cell
     433                 :          0 :             eXPos = enumXFFrameXPosFromLeft;
     434                 :          0 :             eXRel = enumXFFrameXRelPage;
     435                 :            :             //set vertical position
     436         [ #  # ]:          0 :             if(m_pLayout->IsAnchorPage())//in page
     437                 :            :             {
     438                 :          0 :                 LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout();
     439 [ #  # ][ #  # ]:          0 :                 if(pContainer && (pContainer->IsHeader() || pContainer->IsFooter()))
         [ #  # ][ #  # ]
     440                 :            :                 {
     441                 :            :                     //Only anchor to para, the frame can display in header and footer of each page
     442                 :          0 :                     eYPos = enumXFFrameYPosFromTop; //from top
     443                 :          0 :                     eYRel = enumXFFrameYRelPara; //from margin
     444                 :            :                 }
     445                 :            :                 else
     446                 :            :                 {
     447                 :          0 :                     eYPos = enumXFFrameYPosFromTop;
     448                 :          0 :                     eYRel = enumXFFrameYRelPage;
     449                 :            :                 }
     450                 :            :             }
     451         [ #  # ]:          0 :             if(m_pLayout->IsAnchorFrame()) //in frame
     452                 :            :             {
     453                 :          0 :                 eYPos = enumXFFrameYPosFromTop;
     454                 :          0 :                 eYRel = enumXFFrameYRelPage;
     455                 :            :             }
     456         [ #  # ]:          0 :             if(m_pLayout->IsAnchorCell())
     457                 :            :             {
     458                 :            :                 //SODC has no this type, simulate this feature
     459                 :          0 :                 eYPos = enumXFFrameYPosFromTop; //from top
     460                 :          0 :                 eYRel = enumXFFrameYRelPara; //from margin
     461                 :            :             }
     462                 :          0 :             break;
     463                 :            :         }
     464                 :            :         case LwpLayoutRelativityGuts::LAY_PARA_RELATIVE:    //same page as text
     465                 :            :         {
     466                 :         27 :             eXPos = enumXFFrameXPosFromLeft;
     467                 :         27 :             eXRel = enumXFFrameXRelPage;
     468                 :         27 :             eYPos = enumXFFrameYPosBelow;   //below
     469                 :         27 :             eYRel = enumXFFrameYRelChar; //from char
     470                 :            :             //set vertical position
     471                 :         27 :             LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout();
     472 [ +  + ][ +  + ]:         27 :             if(pContainer && pContainer->IsPage())//in page
                 [ +  + ]
     473                 :            :             {
     474                 :            :                 //eYPos = enumXFFrameYPosFromTop;
     475                 :            :                 //eYRel = enumXFFrameYRelPage;
     476                 :         21 :                 eYPos = enumXFFrameYPosBelow;
     477                 :         21 :                 eYRel = enumXFFrameYRelChar;
     478                 :            :             }
     479 [ +  + ][ -  + ]:          6 :             else if(pContainer && pContainer->IsFrame()) //in frame
                 [ -  + ]
     480                 :            :             {
     481                 :          0 :                 eYPos = enumXFFrameYPosFromTop;
     482                 :          0 :                 eYRel = enumXFFrameYRelPage;
     483                 :            :             }
     484                 :            :             else
     485                 :            :             {
     486                 :          6 :                 eYPos = enumXFFrameYPosFromTop; //from top
     487                 :          6 :                 eYRel = enumXFFrameYRelPara; //from margin
     488                 :            :             }
     489                 :         27 :             break;
     490                 :            :         }
     491                 :            :         case LwpLayoutRelativityGuts::LAY_INLINE:   //in text
     492                 :            :         {
     493                 :          0 :             eXPos = enumXFFrameXPosFromLeft;    //need not be set
     494                 :          0 :             eXRel = enumXFFrameXRelParaContent; //need not be set
     495                 :          0 :             eYPos = enumXFFrameYPosTop; //should be from top
     496                 :          0 :             eYRel = enumXFFrameYRelBaseLine;
     497                 :          0 :             sal_Int32 nOffset = m_pLayout->GetBaseLineOffset();
     498         [ #  # ]:          0 :             if(nOffset>0)
     499                 :            :             {
     500                 :          0 :                 eYPos = enumXFFrameYPosFromTop;
     501                 :            :             }
     502                 :          0 :             break;
     503                 :            :         }
     504                 :            :         case LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE:   //with para above
     505                 :            :         {
     506                 :         48 :             eXPos = enumXFFrameXPosFromLeft;
     507                 :         48 :             eXRel = enumXFFrameXRelParaContent;
     508                 :            :             //eYPos = enumXFFrameYPosTop;
     509                 :         48 :             eYPos = enumXFFrameYPosBottom;
     510                 :         48 :             eYRel = enumXFFrameYRelParaContent;
     511                 :         48 :             break;
     512                 :            :         }
     513                 :            :         case LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL:  //in text - vertical
     514                 :            :         {
     515                 :          0 :             eXPos = enumXFFrameXPosFromLeft;
     516                 :          0 :             eXRel = enumXFFrameXRelPage;
     517                 :          0 :             eYPos = enumXFFrameYPosFromTop; //should be below position
     518                 :          0 :             eYRel = enumXFFrameYRelChar;
     519                 :          0 :             break;
     520                 :            :         }
     521                 :            :         default:
     522                 :          0 :             break;
     523                 :            :     }
     524                 :            : 
     525                 :         75 :     pFrameStyle->SetXPosType(eXPos,eXRel);
     526                 :         75 :     pFrameStyle->SetYPosType(eYPos,eYRel);
     527                 :         75 : }
     528                 :            : /**
     529                 :            : * @descr:  set frame watermark style
     530                 :            : * @param:  pFrameStyle - Frame Style object
     531                 :            : *
     532                 :            : */
     533                 :         75 : void LwpFrame::ApplyWatermark(XFFrameStyle *pFrameStyle)
     534                 :            : {
     535                 :         75 :     XFBGImage* pBGImage = m_pLayout->GetXFBGImage();
     536         [ -  + ]:         75 :     if(pBGImage)
     537                 :            :     {
     538                 :          0 :         pFrameStyle->SetBackImage(pBGImage);
     539                 :            :         //set watermark transparent
     540                 :          0 :          LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*>(m_pLayout->GetWaterMarkLayout());
     541                 :          0 :          LwpBackgroundStuff* pBackgroundStuff = pLay->GetBackgroundStuff();
     542 [ #  # ][ #  # ]:          0 :          if(pBackgroundStuff && !pBackgroundStuff->IsTransparent())
                 [ #  # ]
     543                 :            :          {
     544                 :          0 :              pFrameStyle->SetTransparency(100);
     545                 :            :          }
     546                 :            :      }
     547                 :         75 : }
     548                 :            : 
     549                 :            : /**
     550                 :            :  * @short   Apply pattern fill to frame style
     551                 :            :  * @param pFrameStyle - pointer of XFFrameStyle
     552                 :            :  * @return
     553                 :            :  */
     554                 :          0 : void LwpFrame::ApplyPatternFill(XFFrameStyle* pFrameStyle)
     555                 :            : {
     556                 :          0 :     XFBGImage* pXFBGImage = m_pLayout->GetFillPattern();
     557         [ #  # ]:          0 :     if (pXFBGImage)
     558                 :            :     {
     559                 :          0 :         pFrameStyle->SetBackImage(pXFBGImage);
     560                 :            :     }
     561                 :          0 : }
     562                 :            : 
     563                 :            : /**
     564                 :            :  * @short   Apply background to frame style
     565                 :            :  * @param pFrameStyle - pointer of XFFrameStyle
     566                 :            :  * @return
     567                 :            :  */
     568                 :         75 : void LwpFrame::ApplyBackGround(XFFrameStyle* pFrameStyle)
     569                 :            : {
     570         [ -  + ]:         75 :     if (!m_pLayout)
     571                 :            :     {
     572                 :         75 :         return;
     573                 :            :     }
     574                 :            : 
     575         [ -  + ]:         75 :     if (m_pLayout->IsPatternFill())
     576                 :            :     {
     577                 :          0 :         ApplyPatternFill(pFrameStyle);
     578                 :            :     }
     579                 :            :     else
     580                 :            :     {
     581                 :         75 :         ApplyBackColor(pFrameStyle);
     582                 :            :     }
     583                 :            : }
     584                 :            : 
     585                 :            : /**
     586                 :            : * @descr:  set frame size, anchor type, anchored page number
     587                 :            : * @param:  pXFFrame - XFFrame  object
     588                 :            : *
     589                 :            : */
     590                 :         39 : void LwpFrame::ParseAnchorType(XFFrame *pXFFrame)
     591                 :            : {
     592                 :            :     //set position
     593                 :         39 :     double fXOffset = 0;
     594                 :         39 :     double fYOffset = 0;
     595                 :            :     //page number
     596                 :         39 :     sal_uInt16 nPageNum = 0;
     597                 :            :     //set anchor type
     598                 :         39 :     enumXFAnchor eAnchor = enumXFAnchorNone;
     599                 :            : 
     600                 :         39 :     LwpLayoutGeometry* pLayoutGeo = m_pLayout->GetGeometry();
     601         [ +  - ]:         39 :     if(pLayoutGeo)
     602                 :            :     {
     603                 :         39 :         LwpPoint aPoint = pLayoutGeo->GetOrigin();
     604                 :         39 :         fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
     605                 :         39 :         fYOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetY());
     606                 :            :     }
     607                 :            :     //set anchor type
     608                 :         39 :     eAnchor = enumXFAnchorNone;
     609                 :         39 :     sal_uInt8 nType = m_pLayout->GetRelativeType();
     610   [ -  +  -  +  :         39 :     switch(nType)
                   -  - ]
     611                 :            :     {
     612                 :            :         case LwpLayoutRelativityGuts::LAY_PARENT_RELATIVE://fall throught
     613                 :            :         case LwpLayoutRelativityGuts::LAY_CONTENT_RELATIVE:
     614                 :            :         {
     615                 :            :             //anchor to page, frame and cell
     616         [ #  # ]:          0 :             if(m_pLayout->IsAnchorPage())//in page
     617                 :            :             {
     618                 :          0 :                 LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout();
     619 [ #  # ][ #  # ]:          0 :                 if(pContainer && (pContainer->IsHeader() || pContainer->IsFooter()))
         [ #  # ][ #  # ]
     620                 :            :                 {
     621                 :          0 :                     eAnchor = enumXFAnchorPara;
     622                 :          0 :                     fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP);
     623                 :            :                 }
     624                 :            :                 else
     625                 :          0 :                     eAnchor = enumXFAnchorPage;
     626                 :            :             }
     627         [ #  # ]:          0 :             if(m_pLayout->IsAnchorFrame()) //in frame
     628                 :            :             {
     629                 :          0 :                 eAnchor = enumXFAnchorFrame;
     630                 :            :             }
     631         [ #  # ]:          0 :             if(m_pLayout->IsAnchorCell())   //in cell
     632                 :            :             {
     633                 :            :                 //eAnchor = enumXFAnchorChar;
     634                 :          0 :                 eAnchor = enumXFAnchorPara;
     635                 :          0 :                 LwpMiddleLayout* pContainer = static_cast<LwpMiddleLayout*>(m_pLayout->GetContainerLayout());
     636         [ #  # ]:          0 :                 if(pContainer)
     637                 :            :                 {
     638                 :          0 :                     fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP);
     639                 :            :                 }
     640                 :            :             }
     641                 :          0 :             break;
     642                 :            :         }
     643                 :            :         case LwpLayoutRelativityGuts::LAY_PARA_RELATIVE:    //same page as text
     644                 :            :         {
     645                 :         15 :             eAnchor = enumXFAnchorChar;
     646                 :         15 :             LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout();
     647 [ +  + ][ +  + ]:         15 :             if(pContainer && pContainer->IsPage())//in page
                 [ +  - ]
     648                 :            :             {
     649                 :            :                 //eAnchor = enumXFAnchorPage;
     650                 :         12 :                 eAnchor = enumXFAnchorChar;// to character
     651                 :            :             }
     652 [ +  - ][ -  + ]:          3 :             else if(pContainer && pContainer->IsFrame()) //in frame
                 [ -  + ]
     653                 :            :             {
     654                 :          0 :                 eAnchor = enumXFAnchorFrame;
     655                 :            :             }
     656 [ +  - ][ -  + ]:          3 :             else if(pContainer && pContainer->IsCell()) //in cell
                 [ -  + ]
     657                 :            :             {
     658                 :            :                 //eAnchor = enumXFAnchorChar;
     659                 :          0 :                 eAnchor = enumXFAnchorPara;
     660                 :          0 :                 fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP);
     661                 :            :             }
     662 [ +  - ][ -  + ]:          3 :             else if(pContainer && (pContainer->IsHeader() || pContainer->IsFooter()))//in header or footer
         [ #  # ][ +  - ]
     663                 :            :             {
     664                 :          3 :                 eAnchor = enumXFAnchorPara;
     665                 :          3 :                 fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP);
     666                 :            :             }
     667                 :         15 :             break;
     668                 :            :         }
     669                 :            :         case LwpLayoutRelativityGuts::LAY_INLINE:   //in text
     670                 :            :         {
     671                 :          0 :             eAnchor = enumXFAnchorAsChar;
     672         [ #  # ]:          0 :             sal_Int32 nOffset = m_pLayout->GetBaseLineOffset();
     673 [ #  # ][ #  # ]:          0 :             if(nOffset>0 && pLayoutGeo)
     674                 :            :             {
     675                 :            :                 //experiential value
     676 [ #  # ][ #  # ]:          0 :                 fYOffset =-(m_pLayout->GetGeometryHeight()+2*m_pLayout->GetExtMarginsValue(MARGIN_BOTTOM)-LwpTools::ConvertFromUnitsToMetric(nOffset));
     677                 :            :             }
     678                 :            :             break;
     679                 :            :         }
     680                 :            :         case LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE:   //with para above
     681                 :            :         {
     682                 :         24 :             eAnchor = enumXFAnchorPara;
     683                 :         24 :             break;
     684                 :            :         }
     685                 :            :         case LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL:  //in text - vertical
     686                 :            :         {
     687                 :          0 :             eAnchor = enumXFAnchorChar;
     688                 :            :             //set vertical position
     689                 :          0 :             double offset = 0;
     690                 :            : 
     691                 :            :             //because of the different feature between Word Pro and SODC, I simulate the vertical base offset
     692                 :            :             //between anchor and frame orgin using the font height.
     693                 :            :             //LwpPara* pPara = static_cast<LwpPara*>(m_pLayout->GetPosition()->obj());
     694                 :          0 :             XFFont* pFont = m_pLayout->GetFont();
     695         [ #  # ]:          0 :             if(pFont)
     696                 :            :             {
     697                 :          0 :                 offset = (double)(pFont->GetFontSize())*CM_PER_INCH/POINTS_PER_INCH;
     698                 :            :             }
     699                 :          0 :             fYOffset = offset-fYOffset;
     700                 :          0 :             break;
     701                 :            :         }
     702                 :            :         default:
     703                 :          0 :             break;
     704                 :            :     }
     705                 :            : 
     706                 :         39 :     pXFFrame->SetX(fXOffset);
     707                 :         39 :     pXFFrame->SetY(fYOffset);
     708                 :         39 :     pXFFrame->SetAnchorPage(nPageNum);
     709                 :         39 :     pXFFrame->SetAnchorType(eAnchor);
     710                 :         39 : }
     711                 :            : 
     712                 :            : /**
     713                 :            :  * @descr Calculate the distance between the frame object and the page margins.
     714                 :            :  *       And determine which side(left or right) is wider
     715                 :            :  */
     716                 :         66 : sal_Bool LwpFrame::IsLeftWider()
     717                 :            : {
     718                 :            :     //LwpMiddleLayout* pParent = static_cast<LwpMiddleLayout*>(m_pLayout->GetContainerLayout());
     719                 :         66 :     LwpVirtualLayout* pParent = static_cast<LwpVirtualLayout*>(m_pLayout->GetContainerLayout());
     720         [ +  - ]:         66 :     if(pParent)
     721                 :            :     {
     722         [ +  - ]:         66 :         LwpPoint aPoint = m_pLayout->GetOrigin();
     723                 :         66 :         double fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
     724         [ +  - ]:         66 :         double fWidth = m_pLayout->GetWidth();
     725         [ +  - ]:         66 :         double fWrapLeft = m_pLayout->GetExtMarginsValue(MARGIN_LEFT);
     726         [ +  - ]:         66 :         double fWrapRight = m_pLayout->GetExtMarginsValue(MARGIN_RIGHT);
     727                 :            : 
     728                 :            :         //LwpPoint aParentPoint = pParent->GetOrigin();
     729                 :            :         //double fParentXOffset = LwpTools::ConvertFromUnitsToMetric(aParentPoint.GetX());
     730         [ +  - ]:         66 :         double fParentWidth = pParent->GetWidth();
     731 [ +  - ][ -  + ]:         66 :         if(pParent->IsCell())
     732                 :            :         {
     733                 :            :             //Get actual width of this cell layout
     734         [ #  # ]:          0 :             fParentWidth = static_cast<LwpCellLayout*>(pParent)->GetActualWidth();
     735                 :            :         }
     736         [ +  - ]:         66 :         double fParentMarginLeft = pParent->GetMarginsValue(MARGIN_LEFT);
     737         [ +  - ]:         66 :         double fParentMarginRight = pParent->GetMarginsValue(MARGIN_RIGHT);
     738                 :            : 
     739                 :         66 :         double fLeft = fXOffset - fWrapLeft -fParentMarginLeft;
     740                 :         66 :         double fRight = fParentWidth - fParentMarginRight -(fXOffset + fWidth + fWrapRight);
     741         [ +  + ]:         66 :         if(fLeft > fRight)
     742                 :         66 :             return sal_True;
     743                 :            :     }
     744                 :         66 :     return sal_False;
     745                 :            : }
     746                 :            : 
     747                 :        108 : LwpFrameLink::LwpFrameLink()
     748                 :        108 : {}
     749                 :            : 
     750                 :        108 : LwpFrameLink::~LwpFrameLink()
     751                 :        108 : {}
     752                 :            : 
     753                 :            : /**
     754                 :            :  * @descr frame link information
     755                 :            :  *
     756                 :            :  */
     757                 :          0 : void LwpFrameLink::Read(LwpObjectStream* pStrm)
     758                 :            : {
     759                 :          0 :     m_PreviousLayout.ReadIndexed(pStrm);
     760                 :          0 :     m_NextLayout.ReadIndexed(pStrm);
     761                 :          0 :     pStrm->SkipExtra();
     762                 :          0 : }
     763                 :            : 
     764                 :        108 : LwpFrameLayout::LwpFrameLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
     765         [ +  - ]:        108 :     : LwpPlacableLayout(objHdr, pStrm), m_pFrame(NULL)
     766                 :            : {
     767                 :        108 : }
     768                 :            : 
     769                 :        108 : LwpFrameLayout::~LwpFrameLayout()
     770                 :            : {
     771         [ +  + ]:        108 :     delete m_pFrame;
     772         [ -  + ]:        204 : }
     773                 :            : 
     774                 :            : /**
     775                 :            :  * @descr read frame layout object
     776                 :            :  *
     777                 :            :  */
     778                 :        108 : void LwpFrameLayout::Read()
     779                 :            : {
     780                 :        108 :     LwpPlacableLayout::Read();
     781         [ +  - ]:        108 :     if(LwpFileHeader::m_nFileRevision >= 0x000B)
     782                 :            :     {
     783         [ -  + ]:        108 :         if(m_pObjStrm->QuickReaduInt16())
     784                 :            :         {
     785                 :          0 :             m_Link.Read(m_pObjStrm);
     786                 :            :         }
     787                 :            :     }
     788                 :        108 :     m_pObjStrm->SkipExtra();
     789                 :        108 : }
     790                 :            : 
     791                 :            : /**
     792                 :            :  * @descr create a xfframe and add into content container
     793                 :            :  * @param:  pCont - content container that contains the frame.
     794                 :            :  *
     795                 :            :  */
     796                 :         39 :  void LwpFrameLayout::XFConvert(XFContentContainer* pCont)
     797                 :            :  {
     798         [ +  - ]:         39 :     if(m_pFrame)
     799                 :            :     {
     800                 :            :         //parse the frame which anchor to paragraph
     801         [ +  - ]:         39 :         if(IsRelativeAnchored())
     802                 :            :         {
     803                 :         39 :             XFConvertFrame(pCont);
     804                 :            :         }
     805                 :            :         else
     806                 :            :         {
     807                 :          0 :             m_pFrame->XFConvert(pCont);
     808                 :            :         }
     809                 :            : 
     810                 :            :     }
     811                 :         39 :  }
     812                 :            : /**
     813                 :            :  * @descr create a xfframe and add into content container, called by XFConvert
     814                 :            :  * @param:  pCont - content container that contains the frame.
     815                 :            :  * @param:  nPageNo - the page number that the frame anchors
     816                 :            :  *
     817                 :            :  */
     818                 :         39 : void LwpFrameLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart , sal_Int32 nEnd, sal_Bool bAll )
     819                 :            : {
     820         [ +  - ]:         39 :     if(m_pFrame)
     821                 :            :     {
     822                 :         39 :         XFFrame* pXFFrame = NULL;
     823         [ -  + ]:         39 :         if(nEnd < nStart)
     824                 :            :         {
     825         [ #  # ]:          0 :             pXFFrame = new XFFrame();
     826                 :            :         }
     827                 :            :         else
     828                 :            :         {
     829         [ +  - ]:         39 :             pXFFrame = new XFFloatFrame(nStart, nEnd, bAll);
     830                 :            :         }
     831                 :            : 
     832                 :         39 :         m_pFrame->Parse(pXFFrame, nStart);
     833                 :            :         //if it is a link frame, parse contents only once
     834         [ +  - ]:         39 :         if(!HasPreviousLinkLayout())
     835                 :            :         {
     836                 :         39 :             LwpObject* content = m_Content.obj();
     837         [ +  - ]:         39 :             if (content)
     838                 :            :             {
     839                 :         39 :                 content->XFConvert(pXFFrame);
     840                 :            :                 //set frame size according to ole size
     841                 :         39 :                 ApplyGraphicSize(pXFFrame);
     842                 :            :             }
     843                 :            :         }
     844                 :         39 :         pCont ->Add(pXFFrame);
     845                 :            :     }
     846                 :         39 : }
     847                 :            : /**
     848                 :            :  * @descr register frame style
     849                 :            :  *
     850                 :            :  */
     851                 :         78 : void  LwpFrameLayout::RegisterStyle()
     852                 :            : {
     853                 :            :     //if it is for water mark, don't register style
     854         [ -  + ]:         78 :     if (IsForWaterMark())
     855                 :          0 :         return;
     856                 :            : 
     857         [ +  + ]:         78 :     if (m_pFrame)
     858                 :          3 :         return;
     859                 :            : 
     860                 :            :     //register frame style
     861         [ +  - ]:         75 :     XFFrameStyle* pFrameStyle = new XFFrameStyle();
     862                 :         75 :     m_pFrame = new LwpFrame(this);
     863                 :         75 :     m_pFrame->RegisterStyle(pFrameStyle);
     864                 :            : 
     865                 :            :     //register content style
     866                 :         75 :     LwpObject* content = m_Content.obj();
     867         [ +  - ]:         72 :     if (content)
     868                 :            :     {
     869                 :         72 :         content->SetFoundry(m_pFoundry);
     870                 :         72 :         content->RegisterStyle();
     871                 :            :     }
     872                 :            : 
     873                 :            :     //register child frame style
     874                 :         75 :     RegisterChildStyle();
     875                 :            : }
     876                 :            : 
     877                 :            : /**
     878                 :            :  * @descr get the name of the frame that current frame links
     879                 :            :  *
     880                 :            :  */
     881                 :         39 : OUString LwpFrameLayout::GetNextLinkName()
     882                 :            : {
     883                 :         39 :     OUString aName;
     884                 :         39 :     LwpObjectID* pObjectID = m_Link.GetNextLayout();
     885         [ -  + ]:         39 :     if(!pObjectID->IsNull())
     886                 :            :     {
     887 [ #  # ][ #  # ]:          0 :         LwpLayout* pLayout = dynamic_cast<LwpLayout*>(pObjectID->obj());
     888         [ #  # ]:          0 :         if (pLayout)
     889                 :            :         {
     890                 :          0 :             LwpAtomHolder *pHolder = pLayout->GetName();
     891         [ #  # ]:          0 :             if (pHolder)
     892                 :          0 :                 aName = pHolder->str();
     893                 :            :             //for division name confict
     894 [ #  # ][ #  # ]:          0 :             if(!pLayout->GetStyleName().isEmpty())
     895         [ #  # ]:          0 :                 aName = pLayout->GetStyleName();
     896                 :            :         }
     897                 :            :     }
     898                 :         39 :     return aName;
     899                 :            : }
     900                 :            : /**
     901                 :            :  * @descr whether current frame is linked by other frame
     902                 :            :  *
     903                 :            :  */
     904                 :         39 : sal_Bool LwpFrameLayout::HasPreviousLinkLayout()
     905                 :            : {
     906                 :         39 :     LwpObjectID* pObjectID = m_Link.GetPreviousLayout();
     907         [ +  - ]:         39 :     if(pObjectID->IsNull())
     908                 :         39 :         return sal_False;
     909                 :         39 :     return sal_True;
     910                 :            : }
     911                 :            : /**
     912                 :            :  * @descr whether current frame is for water mark. Problem maybe exsits by this method, must be tracking
     913                 :            :  *
     914                 :            :  */
     915                 :         78 :  sal_Bool LwpFrameLayout::IsForWaterMark()
     916                 :            : {
     917         [ -  + ]:         78 :     if(m_nBuoyancy >=LAY_BUOYLAYER)
     918                 :            :     {
     919 [ #  # ][ #  # ]:          0 :         if(!m_Content.IsNull() && (m_Content.obj()->GetTag()==VO_GRAPHIC) )
                 [ #  # ]
     920                 :            :         {
     921                 :          0 :             return sal_True;
     922                 :            :         }
     923                 :            :     }
     924                 :         78 :     return sal_False;
     925                 :            : }
     926                 :            : 
     927                 :            : /**
     928                 :            :  * @descr Get frame width
     929                 :            :  *
     930                 :            :  */
     931                 :        126 : double LwpFrameLayout::GetWidth()
     932                 :            : {
     933                 :        126 :     double fWidth = LwpMiddleLayout::GetWidth();
     934 [ #  # ][ -  + ]:        126 :     if(IsInlineToMargin() && IsAutoGrowWidth())
                 [ -  + ]
     935                 :            :     {
     936                 :            :         //for text field entry when choosing maximize field length
     937                 :          0 :         fWidth = GetMaxWidth();
     938                 :            :     }
     939                 :        126 :     return fWidth;
     940                 :            : }
     941                 :            : 
     942                 :            : /**
     943                 :            :  * @descr Get frame width when the text field chooses maximize field length
     944                 :            :  *
     945                 :            :  */
     946                 :          0 : double LwpFrameLayout::GetMaxWidth()
     947                 :            : {
     948                 :          0 :     double fActualWidth = 0;
     949                 :          0 :     LwpMiddleLayout* pParent = static_cast<LwpMiddleLayout*>(GetContainerLayout());
     950         [ #  # ]:          0 :     if(pParent)
     951                 :            :     {
     952         [ #  # ]:          0 :         LwpPoint aPoint = GetOrigin();
     953                 :          0 :         double fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
     954         [ #  # ]:          0 :         double fWrapRight = GetExtMarginsValue(MARGIN_RIGHT);
     955                 :            : 
     956                 :            :         //Get parent layout width
     957         [ #  # ]:          0 :         double fParentWidth = pParent->GetWidth();
     958 [ #  # ][ #  # ]:          0 :         if(pParent->IsCell())
     959                 :            :         {
     960                 :            :             //Get actual width of this cell layout
     961         [ #  # ]:          0 :             fParentWidth = static_cast<LwpCellLayout*>(pParent)->GetActualWidth();
     962                 :            :         }
     963                 :            : 
     964                 :          0 :         double fParentMarginRight = 0;
     965         [ #  # ]:          0 :         sal_uInt8 nType = GetRelativeType();
     966 [ #  # ][ #  # ]:          0 :         if(nType == LwpLayoutRelativityGuts::LAY_INLINE
     967                 :            :             || nType == LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE )
     968                 :            :         {
     969         [ #  # ]:          0 :             fParentMarginRight = pParent->GetMarginsValue(MARGIN_RIGHT);
     970                 :            :         }
     971                 :            : 
     972                 :          0 :         fActualWidth = fParentWidth - fXOffset - fParentMarginRight - fWrapRight;
     973                 :            :     }
     974                 :            : 
     975                 :          0 :     return fActualWidth;
     976                 :            : }
     977                 :            : 
     978                 :            : /**
     979                 :            :  * @descr Set frame size according to graphic size
     980                 :            :  *
     981                 :            :  */
     982                 :         39 : void LwpFrameLayout::ApplyGraphicSize(XFFrame * pXFFrame)
     983                 :            : {
     984                 :         39 :     LwpObject* content = m_Content.obj();
     985   [ +  +  +  - ]:         66 :     if(content && (content->GetTag() == VO_GRAPHIC
         [ +  - ][ +  - ]
     986                 :         27 :                 || content->GetTag() == VO_OLEOBJECT ))
     987                 :            :     {
     988                 :         39 :         LwpGraphicOleObject* pGraOle = static_cast<LwpGraphicOleObject*>(content);
     989                 :            :         //Get frame geometry size
     990                 :         39 :         double fWidth = 0;
     991                 :         39 :         double fHeight = 0;
     992         [ +  - ]:         39 :         pGraOle->GetGrafScaledSize(fWidth, fHeight);
     993 [ +  - ][ +  + ]:         39 :         if( IsFitGraphic())
     994                 :            :         {
     995                 :            :             //graphic scaled sze
     996 [ +  - ][ +  - ]:         18 :             fWidth += GetMarginsValue(MARGIN_LEFT) + GetMarginsValue(MARGIN_RIGHT);
     997 [ +  - ][ +  - ]:         18 :             fHeight += GetMarginsValue(MARGIN_TOP) + GetMarginsValue(MARGIN_BOTTOM);
     998                 :            :         }
     999 [ +  - ][ +  - ]:         21 :         else if(IsAutoGrowDown() || IsAutoGrowUp())
         [ +  - ][ -  + ]
                 [ -  + ]
    1000                 :            :         {
    1001         [ #  # ]:          0 :             fWidth = GetWidth();
    1002 [ #  # ][ #  # ]:          0 :             fHeight += GetMarginsValue(MARGIN_TOP) + GetMarginsValue(MARGIN_BOTTOM);
    1003                 :            :         }
    1004 [ +  - ][ +  - ]:         21 :         else if( IsAutoGrowLeft() || IsAutoGrowRight())
         [ +  - ][ -  + ]
                 [ -  + ]
    1005                 :            :         {
    1006         [ #  # ]:          0 :             fHeight = GetHeight();
    1007 [ #  # ][ #  # ]:          0 :             fWidth += GetMarginsValue(MARGIN_LEFT) + GetMarginsValue(MARGIN_RIGHT);
    1008                 :            :         }
    1009                 :            :         else
    1010                 :            :         {
    1011         [ +  - ]:         21 :             fWidth = GetWidth();
    1012         [ +  - ]:         21 :             fHeight = GetHeight();
    1013                 :            :         }
    1014                 :         39 :         pXFFrame->SetWidth(fWidth);
    1015                 :         39 :         pXFFrame->SetHeight(fHeight);
    1016                 :            :     }
    1017                 :         39 : }
    1018                 :            : 
    1019                 :          0 : LwpGroupLayout::LwpGroupLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
    1020                 :            :     : LwpPlacableLayout(objHdr, pStrm)
    1021                 :          0 :     , m_pFrame(NULL)
    1022                 :            : {
    1023                 :            : 
    1024                 :          0 : }
    1025                 :            : 
    1026                 :          0 : LwpGroupLayout::~LwpGroupLayout()
    1027                 :            : {
    1028         [ #  # ]:          0 :     delete m_pFrame;
    1029         [ #  # ]:          0 : }
    1030                 :            : /**
    1031                 :            :  * @descr read group layout object
    1032                 :            :  *
    1033                 :            :  */
    1034                 :          0 : void LwpGroupLayout::Read()
    1035                 :            : {
    1036                 :          0 :     LwpPlacableLayout::Read();
    1037                 :          0 :     m_pObjStrm->SkipExtra();
    1038                 :          0 : }
    1039                 :            : /**
    1040                 :            :  * @descr register group frame style
    1041                 :            :  *
    1042                 :            :  */
    1043                 :          0 : void LwpGroupLayout::RegisterStyle()
    1044                 :            : {
    1045         [ #  # ]:          0 :     if (m_pFrame)
    1046                 :          0 :         return;
    1047                 :            : 
    1048                 :            :     //register frame style
    1049         [ #  # ]:          0 :     XFFrameStyle* pFrameStyle = new XFFrameStyle();
    1050                 :          0 :     m_pFrame = new LwpFrame(this);
    1051                 :          0 :     m_pFrame->RegisterStyle(pFrameStyle);
    1052                 :            : 
    1053                 :            :     //register child frame style
    1054                 :          0 :     RegisterChildStyle();
    1055                 :            : }
    1056                 :            : /**
    1057                 :            :  * @descr create a xfframe and add into content container
    1058                 :            :  * @param:  pCont - content container that contains the frame.
    1059                 :            :  *
    1060                 :            :  */
    1061                 :          0 : void LwpGroupLayout::XFConvert(XFContentContainer *pCont)
    1062                 :            : {
    1063         [ #  # ]:          0 :     if(m_pFrame)
    1064                 :            :     {
    1065                 :            :         //parse the frame which anchor to paragraph
    1066         [ #  # ]:          0 :         if(IsRelativeAnchored())
    1067                 :            :         {
    1068                 :          0 :             XFConvertFrame(pCont);
    1069                 :            :         }
    1070                 :            :         else
    1071                 :            :         {
    1072                 :          0 :             m_pFrame->XFConvert(pCont);
    1073                 :            :         }
    1074                 :            : 
    1075                 :            :     }
    1076                 :          0 : }
    1077                 :            : /**
    1078                 :            :  * @descr create a xfframe and add into content container, called by XFConvert
    1079                 :            :  * @param:  pCont - content container that contains the frame.
    1080                 :            :  * @param:  nPageNo - the page number that the frame anchors
    1081                 :            :  *
    1082                 :            :  */
    1083                 :          0 : void LwpGroupLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart , sal_Int32 nEnd, sal_Bool bAll)
    1084                 :            : {
    1085         [ #  # ]:          0 :     if(m_pFrame)
    1086                 :            :     {
    1087                 :          0 :         XFFrame* pXFFrame = NULL;
    1088         [ #  # ]:          0 :         if(nEnd < nStart)
    1089                 :            :         {
    1090         [ #  # ]:          0 :             pXFFrame = new XFFrame();
    1091                 :            :         }
    1092                 :            :         else
    1093                 :            :         {
    1094         [ #  # ]:          0 :             pXFFrame = new XFFloatFrame(nStart, nEnd, bAll);
    1095                 :            :         }
    1096                 :            : 
    1097                 :          0 :         m_pFrame->Parse(pXFFrame, nStart);
    1098                 :            : 
    1099                 :            :         //add child frame into group
    1100                 :          0 :         LwpVirtualLayout* pLayout = static_cast<LwpVirtualLayout*>(GetChildHead()->obj());
    1101         [ #  # ]:          0 :         while(pLayout)
    1102                 :            :         {
    1103                 :          0 :             pLayout->XFConvert(pXFFrame);
    1104                 :          0 :             pLayout = static_cast<LwpVirtualLayout*>(pLayout->GetNext()->obj());
    1105                 :            :         }
    1106                 :            : 
    1107                 :          0 :         pCont ->Add(pXFFrame);
    1108                 :            :     }
    1109                 :          0 : }
    1110                 :            : 
    1111                 :          0 : LwpGroupFrame::LwpGroupFrame(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
    1112                 :          0 :     :LwpContent(objHdr, pStrm)
    1113                 :          0 : {}
    1114                 :            : 
    1115                 :          0 : LwpGroupFrame::~LwpGroupFrame()
    1116         [ #  # ]:          0 : {}
    1117                 :            : 
    1118                 :          0 : void LwpGroupFrame::Read()
    1119                 :            : {
    1120                 :          0 :     LwpContent::Read();
    1121                 :          0 :     m_pObjStrm->SkipExtra();
    1122                 :            : 
    1123                 :          0 : }
    1124                 :            : 
    1125                 :          0 : void  LwpGroupFrame::RegisterStyle()
    1126                 :            : {
    1127                 :          0 : }
    1128                 :            : 
    1129                 :          0 : void LwpGroupFrame::XFConvert(XFContentContainer* /*pCont*/)
    1130                 :            : {
    1131                 :          0 : }
    1132                 :            : 
    1133                 :         12 : LwpDropcapLayout::LwpDropcapLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
    1134                 :         12 :     : LwpFrameLayout(objHdr, pStrm)
    1135                 :            : {
    1136                 :         12 :     m_nChars = 1;
    1137                 :         12 :     m_nLines = 3;
    1138                 :         12 : }
    1139                 :            : 
    1140                 :         12 : void LwpDropcapLayout::Read()
    1141                 :            : {
    1142                 :         12 :     LwpFrameLayout::Read();
    1143                 :         12 :     m_nLines = m_pObjStrm->QuickReaduInt16();
    1144                 :         12 :     m_pObjStrm->SeekRel(1);
    1145                 :         12 :     m_pObjStrm->SkipExtra();
    1146                 :         12 : }
    1147                 :            : 
    1148                 :          0 : void LwpDropcapLayout::Parse(IXFStream* pOutputStream)
    1149                 :            : {
    1150                 :          0 :     LwpStory* pStory = static_cast<LwpStory*>(m_Content.obj(VO_STORY));
    1151         [ #  # ]:          0 :     if (!pStory)
    1152                 :          0 :         return;
    1153                 :          0 :     LwpObject* pPara = pStory->GetFirstPara()->obj(VO_PARA);
    1154         [ #  # ]:          0 :     if(pPara)
    1155                 :            :     {
    1156                 :          0 :         pPara->SetFoundry(m_pFoundry);
    1157                 :          0 :         pPara->Parse(pOutputStream);
    1158                 :            :     }
    1159                 :            : }
    1160                 :            : 
    1161                 :          0 : void LwpDropcapLayout::XFConvert(XFContentContainer* pCont)
    1162                 :            : {
    1163                 :          0 :     LwpStory* pStory = static_cast<LwpStory*>(m_Content.obj(VO_STORY));
    1164         [ #  # ]:          0 :     if (pStory)
    1165                 :            :     {
    1166                 :          0 :         pStory->SetFoundry(m_pFoundry);
    1167                 :          0 :         pStory->XFConvert(pCont);
    1168                 :            :     }
    1169                 :          0 : }
    1170                 :            : 
    1171                 :          0 : LwpStory* LwpDropcapLayout::GetContentStory()
    1172                 :            : {
    1173                 :          0 :     return static_cast<LwpStory*>(m_Content.obj(VO_STORY));
    1174                 :            : }
    1175                 :            : 
    1176                 :          0 : void LwpDropcapLayout::RegisterStyle(LwpFoundry* pFoundry)
    1177                 :            : {
    1178                 :          0 :     LwpStory* pStory = GetContentStory();
    1179         [ #  # ]:          0 :     if (pStory)
    1180                 :            :     {
    1181                 :          0 :         pStory->SetDropcapFlag(sal_True);
    1182                 :          0 :         pStory->SetFoundry(pFoundry);
    1183                 :          0 :         LwpPara* pPara = static_cast<LwpPara*>(pStory->GetFirstPara()->obj());
    1184         [ #  # ]:          0 :         while(pPara)
    1185                 :            :         {
    1186                 :          0 :             pPara->SetFoundry(pFoundry);
    1187                 :          0 :             pPara->RegisterStyle();
    1188                 :          0 :             pPara = static_cast<LwpPara*>(pPara->GetNext()->obj());
    1189                 :            :         }
    1190                 :            :     }
    1191                 :          0 : }
    1192                 :            : 
    1193                 :            : /**
    1194                 :            :  * @descr  do nothing
    1195                 :            :  *
    1196                 :            :  */
    1197                 :          0 : void LwpDropcapLayout::RegisterStyle()
    1198                 :            : {
    1199                 :          0 : }
    1200                 :            : 
    1201                 :          0 : LwpRubyLayout::LwpRubyLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
    1202         [ #  # ]:          0 :     : LwpFrameLayout(objHdr, pStrm)
    1203                 :            : {
    1204                 :          0 : }
    1205                 :            : 
    1206                 :          0 : void LwpRubyLayout::Read()
    1207                 :            : {
    1208                 :          0 :     LwpFrameLayout::Read();
    1209                 :          0 :     m_nPlacement = m_pObjStrm->QuickReaduInt8();
    1210                 :          0 :     m_nAlignment = m_pObjStrm->QuickReaduInt8();;
    1211                 :          0 :     m_nStateFlag = m_pObjStrm->QuickReaduInt16();;
    1212                 :          0 :     m_nXOffset = m_pObjStrm->QuickReadInt32();
    1213                 :          0 :     m_nYOffset = m_pObjStrm->QuickReadInt32();
    1214                 :          0 :     m_objRubyMarker.ReadIndexed(m_pObjStrm);
    1215                 :          0 :     m_pObjStrm->SkipExtra();
    1216                 :          0 : }
    1217                 :            : 
    1218                 :          0 : LwpRubyMarker* LwpRubyLayout::GetMarker()
    1219                 :            : {
    1220                 :          0 :     return static_cast<LwpRubyMarker*>(m_objRubyMarker.obj(VO_RUBYMARKER));
    1221                 :            : }
    1222                 :            : 
    1223                 :          0 : LwpStory* LwpRubyLayout::GetContentStory()
    1224                 :            : {
    1225                 :          0 :     return static_cast<LwpStory*>(m_Content.obj(VO_STORY));
    1226                 :            : }
    1227                 :            : 
    1228                 :          0 : void LwpRubyLayout::ConvertContentText()
    1229                 :            : {
    1230                 :          0 :     LwpStory* pStory = GetContentStory();
    1231                 :          0 :     LwpRubyMarker* pMarker = GetMarker();
    1232 [ #  # ][ #  # ]:          0 :     if (pStory && pMarker)
    1233                 :          0 :         pMarker->SetRubyText(pStory->GetContentText(sal_True));
    1234                 :          0 : }
    1235                 :            : 
    1236                 :          0 : void LwpRubyLayout::RegisterStyle()
    1237                 :            : {
    1238         [ #  # ]:          0 :     LwpRubyMarker* pMarker = GetMarker();
    1239                 :            : 
    1240 [ #  # ][ #  # ]:          0 :     XFRubyStyle* pRubyStyle = new XFRubyStyle;
    1241                 :            : 
    1242                 :          0 :     enumXFRubyPosition eType = enumXFRubyLeft;
    1243         [ #  # ]:          0 :     if (m_nAlignment == LEFT)
    1244                 :            :     {
    1245                 :          0 :         eType = enumXFRubyLeft;
    1246                 :            :     }
    1247         [ #  # ]:          0 :     else if(m_nAlignment == RIGHT)
    1248                 :            :     {
    1249                 :          0 :         eType =  enumXFRubyRight;
    1250                 :            :     }
    1251         [ #  # ]:          0 :     else if(m_nAlignment == CENTER)
    1252                 :            :     {
    1253                 :          0 :         eType =  enumXFRubyCenter;
    1254                 :            :     }
    1255                 :          0 :     pRubyStyle->SetAlignment(eType);
    1256                 :            : 
    1257                 :          0 :     eType = enumXFRubyTop;
    1258         [ #  # ]:          0 :     if (m_nPlacement == TOP)
    1259                 :            :     {
    1260                 :          0 :         eType = enumXFRubyTop;
    1261                 :            :     }
    1262         [ #  # ]:          0 :     else if(m_nPlacement == BOTTOM)
    1263                 :            :     {
    1264                 :          0 :         eType =  enumXFRubyBottom;
    1265                 :            :     }
    1266                 :          0 :     pRubyStyle->SetPosition(eType);
    1267                 :            : 
    1268         [ #  # ]:          0 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
    1269 [ #  # ][ #  # ]:          0 :     OUString rubyStyle = pXFStyleManager->AddStyle(pRubyStyle)->GetStyleName();
    1270                 :          0 :     pMarker->SetRubyStyleName(rubyStyle);
    1271                 :            : 
    1272         [ #  # ]:          0 :     LwpStory* pStory = GetContentStory();
    1273                 :          0 :     pStory->SetFoundry(m_pFoundry);
    1274         [ #  # ]:          0 :     OUString textStyle = pStory->RegisterFirstFribStyle();
    1275                 :          0 :     pMarker->SetTextStyleName(textStyle);
    1276                 :          0 : }
    1277                 :            : 
    1278                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10