LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpframelayout.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 276 559 49.4 %
Date: 2014-11-03 Functions: 36 64 56.2 %
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             :  *  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          54 : LwpFrame::LwpFrame(LwpPlacableLayout* pLayout):m_pLayout(pLayout)
      77             : {
      78          54 : }
      79             : 
      80          54 : LwpFrame::~LwpFrame()
      81             : {
      82          54 : }
      83             : /**
      84             : * @descr:  parse frame
      85             : * @param:  register frame style
      86             : * @param:  pFrameStyle - Frame Style object
      87             : *
      88             : */
      89          50 : void  LwpFrame::RegisterStyle(XFFrameStyle* pFrameStyle)
      90             : {
      91          50 :     ApplyWrapType(pFrameStyle);
      92          50 :     ApplyMargins(pFrameStyle);
      93          50 :     ApplyPadding(pFrameStyle);
      94          50 :     ApplyBorders(pFrameStyle);
      95          50 :     ApplyColumns(pFrameStyle);
      96          50 :     ApplyShadow(pFrameStyle);
      97          50 :     ApplyBackGround(pFrameStyle);
      98          50 :     ApplyWatermark(pFrameStyle);
      99             : //  ApplyBackColor(pFrameStyle);
     100          50 :     ApplyProtect(pFrameStyle);
     101          50 :     ApplyTextDir(pFrameStyle);
     102          50 :     ApplyPosType(pFrameStyle);
     103             : 
     104          50 :     pFrameStyle->SetStyleName(m_pLayout->GetName().str());
     105          50 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     106          50 :     m_StyleName = pXFStyleManager->AddStyle(pFrameStyle)->GetStyleName();
     107          50 :     m_pLayout->SetStyleName(m_StyleName);
     108          50 : }
     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          26 :  void LwpFrame::Parse(XFFrame* pXFFrame, sal_Int32 nPageNo)
     116             :  {
     117             :     //set the frame style name
     118          26 :     pXFFrame->SetStyleName(m_StyleName);
     119             : 
     120             :     //SetAnchorType and position,if it's page anchor,set the page number.
     121          26 :     ParseAnchorType(pXFFrame);
     122          26 :     if(nPageNo>0)
     123             :     {
     124           0 :         pXFFrame->SetAnchorPage(nPageNo);
     125             :     }
     126             : 
     127             :     //Set frame Name
     128          26 :     OUString aFrameName = m_pLayout->GetName().str();
     129          26 :     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("Frame1"))
     133             :         {
     134             :             aFrameName = "Frame1_COPY";
     135             :         }
     136             :         pXFFrame->SetName(aFrameName);*/
     137           0 :         pXFFrame->SetName(m_StyleName);
     138             :     }
     139             : 
     140          26 :     LwpLayoutGeometry* pLayoutGeo = m_pLayout->GetGeometry();
     141             :     //Set frame Width and height
     142          26 :     if(pLayoutGeo)
     143             :     {
     144          26 :         double fWidth = m_pLayout->GetWidth();
     145          26 :         double fHeight = m_pLayout->GetHeight();
     146             : 
     147          26 :         pXFFrame->SetWidth( fWidth );
     148          26 :         pXFFrame->SetHeight( fHeight );
     149             : 
     150             :         //Get content obj;
     151          26 :         /*LwpObject* pObj =*/ m_pLayout->GetContent().obj();
     152          26 :         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          26 :         else if(m_pLayout->IsAutoGrow())
     172             :         {
     173          12 :             pXFFrame->SetMinHeight( fHeight );
     174             :         }
     175             :     }
     176             : 
     177          26 :     if(m_pLayout->IsFrame())
     178             :     {
     179             :         //Set frame link. Only frame layout has this feature
     180          26 :         LwpFrameLayout* pLayout= static_cast<LwpFrameLayout*>(m_pLayout);
     181          26 :         pXFFrame->SetNextLink(pLayout->GetNextLinkName());
     182          26 :     }
     183             : 
     184          26 :  }
     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, 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, 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          50 : void LwpFrame::ApplyWrapType(XFFrameStyle *pFrameStyle)
     245             : {
     246          50 :     enumXFWrap eWrap = enumXFWrapNone;
     247          50 :     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 wrapped. 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          46 :             eWrap = enumXFWrapBest;
     258          46 :             LwpMiddleLayout* pParent = static_cast<LwpMiddleLayout*>(m_pLayout->GetContainerLayout());
     259          46 :             if(pParent)
     260             :             {
     261          44 :                 if(IsLeftWider())
     262          28 :                     eWrap = enumXFWrapLeft;
     263             :                 else
     264          16 :                     eWrap = enumXFWrapRight;
     265             :             }
     266          46 :             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           4 :             eWrap = enumXFWrapRunThrough;
     276           4 :             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           4 :             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          50 :     if(m_pLayout->GetRelativeType()==LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE)
     309             :     {
     310          32 :         eWrap = enumXFWrapNone;
     311             :     }
     312             : 
     313          50 :     pFrameStyle->SetWrapType(eWrap);
     314          50 : }
     315             : /**
     316             : * @descr:   set frame margins style
     317             : * @param:  pFrameStyle - Frame Style object
     318             : *
     319             : */
     320          50 : void LwpFrame::ApplyMargins(XFFrameStyle *pFrameStyle)
     321             : {
     322          50 :     double fLeft    = m_pLayout->GetExtMarginsValue(MARGIN_LEFT);
     323          50 :     double fRight   = m_pLayout->GetExtMarginsValue(MARGIN_RIGHT);
     324          50 :     double fTop = m_pLayout->GetExtMarginsValue(MARGIN_TOP);
     325          50 :     double fBottom  = m_pLayout->GetExtMarginsValue(MARGIN_BOTTOM);
     326          50 :     pFrameStyle->SetMargins(fLeft,fRight,fTop,fBottom);
     327          50 : }
     328             : /**
     329             : * @descr:  set padding border style
     330             : * @param:  pFrameStyle - Frame Style object
     331             : *
     332             : */
     333          50 : void LwpFrame::ApplyPadding(XFFrameStyle *pFrameStyle)
     334             : {
     335          50 :     double fLeft    = m_pLayout->GetMarginsValue(MARGIN_LEFT);
     336          50 :     double fRight   = m_pLayout->GetMarginsValue(MARGIN_RIGHT);
     337          50 :     double fTop = m_pLayout->GetMarginsValue(MARGIN_TOP);
     338          50 :     double fBottom  = m_pLayout->GetMarginsValue(MARGIN_BOTTOM);
     339          50 :     pFrameStyle->SetPadding(fLeft,fRight,fTop,fBottom);
     340          50 : }
     341             : /**
     342             : * @descr:  set frame border style
     343             : * @param:  pFrameStyle - Frame Style object
     344             : *
     345             : */
     346          50 : void LwpFrame::ApplyBorders(XFFrameStyle *pFrameStyle)
     347             : {
     348          50 :     XFBorders* pBordres = m_pLayout->GetXFBorders();
     349          50 :     if(pBordres)
     350             :     {
     351          32 :         pFrameStyle->SetBorders(pBordres);
     352             :     }
     353          50 : }
     354             : /**
     355             : * @descr:  set frame columns style
     356             : * @param:  pFrameStyle - Frame Style object
     357             : *
     358             : */
     359          50 : void LwpFrame::ApplyColumns(XFFrameStyle *pFrameStyle)
     360             : {
     361          50 :     XFColumns* pColumns = m_pLayout->GetXFColumns();
     362          50 :     if(pColumns)
     363             :     {
     364           0 :         pFrameStyle->SetColumns(pColumns);
     365             :     }
     366          50 : }
     367             : /**
     368             : * @descr:  set frame shadow style
     369             : * @param:  pFrameStyle - Frame Style object
     370             : *
     371             : */
     372          50 : void LwpFrame::ApplyShadow(XFFrameStyle* pFrameStyle)
     373             : {
     374          50 :     XFShadow* pXFShadow = m_pLayout->GetXFShadow();
     375          50 :     if(pXFShadow)
     376             :     {
     377           0 :         pFrameStyle->SetShadow(pXFShadow);
     378             :     }
     379          50 : }
     380             : /**
     381             : * @descr:  set frame back color style
     382             : * @param:  pFrameStyle - Frame Style object
     383             : *
     384             : */
     385          50 : void LwpFrame::ApplyBackColor(XFFrameStyle* pFrameStyle)
     386             : {
     387          50 :     LwpColor* pColor = m_pLayout->GetBackColor();
     388          50 :     if(pColor)
     389             :     {
     390          50 :         XFColor aXFColor(pColor->To24Color());
     391          50 :         pFrameStyle->SetBackColor(aXFColor);
     392             :     }
     393          50 : }
     394             : /**
     395             : * @descr:  set frame protect style
     396             : * @param:  pFrameStyle - Frame Style object
     397             : *
     398             : */
     399          50 : void LwpFrame::ApplyProtect(XFFrameStyle* pFrameStyle)
     400             : {
     401          50 :     if(m_pLayout->IsProtected())
     402             :     {
     403           0 :         pFrameStyle->SetProtect(true,true,true);
     404             :     }
     405          50 : }
     406             : /**
     407             : * @descr:  set frame text direction style
     408             : * @param:  pFrameStyle - Frame Style object
     409             : *
     410             : */
     411          50 : void LwpFrame::ApplyTextDir(XFFrameStyle* pFrameStyle)
     412             : {
     413          50 :     pFrameStyle->SetTextDir(m_pLayout->GetTextDirection());
     414          50 : }
     415             : /**
     416             : * @descr:  set frame position type style
     417             : * @param:  pFrameStyle - Frame Style object
     418             : *
     419             : */
     420          50 : void LwpFrame::ApplyPosType(XFFrameStyle* pFrameStyle)
     421             : {
     422          50 :     enumXFFrameXPos eXPos = enumXFFrameXPosCenter;
     423          50 :     enumXFFrameXRel eXRel = enumXFFrameXRelPara;
     424          50 :     enumXFFrameYPos eYPos = enumXFFrameYPosMiddle;
     425          50 :     enumXFFrameYRel eYRel = enumXFFrameYRelPara;
     426          50 :     sal_uInt8 nType = m_pLayout->GetRelativeType();
     427          50 :     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          18 :             eXPos = enumXFFrameXPosFromLeft;
     467          18 :             eXRel = enumXFFrameXRelPage;
     468          18 :             eYPos = enumXFFrameYPosBelow;   //below
     469          18 :             eYRel = enumXFFrameYRelChar; //from char
     470             :             //set vertical position
     471          18 :             LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout();
     472          18 :             if(pContainer && pContainer->IsPage())//in page
     473             :             {
     474             :                 //eYPos = enumXFFrameYPosFromTop;
     475             :                 //eYRel = enumXFFrameYRelPage;
     476          14 :                 eYPos = enumXFFrameYPosBelow;
     477          14 :                 eYRel = enumXFFrameYRelChar;
     478             :             }
     479           4 :             else if(pContainer && pContainer->IsFrame()) //in frame
     480             :             {
     481           0 :                 eYPos = enumXFFrameYPosFromTop;
     482           0 :                 eYRel = enumXFFrameYRelPage;
     483             :             }
     484             :             else
     485             :             {
     486           4 :                 eYPos = enumXFFrameYPosFromTop; //from top
     487           4 :                 eYRel = enumXFFrameYRelPara; //from margin
     488             :             }
     489          18 :             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          32 :             eXPos = enumXFFrameXPosFromLeft;
     507          32 :             eXRel = enumXFFrameXRelParaContent;
     508             :             //eYPos = enumXFFrameYPosTop;
     509          32 :             eYPos = enumXFFrameYPosBottom;
     510          32 :             eYRel = enumXFFrameYRelParaContent;
     511          32 :             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          50 :     pFrameStyle->SetXPosType(eXPos,eXRel);
     526          50 :     pFrameStyle->SetYPosType(eYPos,eYRel);
     527          50 : }
     528             : /**
     529             : * @descr:  set frame watermark style
     530             : * @param:  pFrameStyle - Frame Style object
     531             : *
     532             : */
     533          50 : void LwpFrame::ApplyWatermark(XFFrameStyle *pFrameStyle)
     534             : {
     535          50 :     XFBGImage* pBGImage = m_pLayout->GetXFBGImage();
     536          50 :     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          50 : }
     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          50 : void LwpFrame::ApplyBackGround(XFFrameStyle* pFrameStyle)
     569             : {
     570          50 :     if (!m_pLayout)
     571             :     {
     572          50 :         return;
     573             :     }
     574             : 
     575          50 :     if (m_pLayout->IsPatternFill())
     576             :     {
     577           0 :         ApplyPatternFill(pFrameStyle);
     578             :     }
     579             :     else
     580             :     {
     581          50 :         ApplyBackColor(pFrameStyle);
     582             :     }
     583             : }
     584             : 
     585             : /**
     586             : * @descr:  set frame size, anchor type, anchored page number
     587             : * @param:  pXFFrame - XFFrame  object
     588             : *
     589             : */
     590          26 : void LwpFrame::ParseAnchorType(XFFrame *pXFFrame)
     591             : {
     592             :     //set position
     593          26 :     double fXOffset = 0;
     594          26 :     double fYOffset = 0;
     595             :     //page number
     596          26 :     sal_uInt16 nPageNum = 0;
     597             :     //set anchor type
     598          26 :     enumXFAnchor eAnchor = enumXFAnchorNone;
     599             : 
     600          26 :     LwpLayoutGeometry* pLayoutGeo = m_pLayout->GetGeometry();
     601          26 :     if(pLayoutGeo)
     602             :     {
     603          26 :         LwpPoint aPoint = pLayoutGeo->GetOrigin();
     604          26 :         fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
     605          26 :         fYOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetY());
     606             :     }
     607             :     //set anchor type
     608          26 :     eAnchor = enumXFAnchorNone;
     609          26 :     sal_uInt8 nType = m_pLayout->GetRelativeType();
     610          26 :     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          10 :             eAnchor = enumXFAnchorChar;
     646          10 :             LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout();
     647          10 :             if(pContainer && pContainer->IsPage())//in page
     648             :             {
     649             :                 //eAnchor = enumXFAnchorPage;
     650           8 :                 eAnchor = enumXFAnchorChar;// to character
     651             :             }
     652           2 :             else if(pContainer && pContainer->IsFrame()) //in frame
     653             :             {
     654           0 :                 eAnchor = enumXFAnchorFrame;
     655             :             }
     656           2 :             else if(pContainer && pContainer->IsCell()) //in cell
     657             :             {
     658             :                 //eAnchor = enumXFAnchorChar;
     659           0 :                 eAnchor = enumXFAnchorPara;
     660           0 :                 fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP);
     661             :             }
     662           2 :             else if(pContainer && (pContainer->IsHeader() || pContainer->IsFooter()))//in header or footer
     663             :             {
     664           2 :                 eAnchor = enumXFAnchorPara;
     665           2 :                 fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP);
     666             :             }
     667          10 :             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           0 :             break;
     679             :         }
     680             :         case LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE:   //with para above
     681             :         {
     682          16 :             eAnchor = enumXFAnchorPara;
     683          16 :             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 :             rtl::Reference<XFFont> pFont = m_pLayout->GetFont();
     695           0 :             if(pFont.is())
     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          26 :     pXFFrame->SetX(fXOffset);
     707          26 :     pXFFrame->SetY(fYOffset);
     708          26 :     pXFFrame->SetAnchorPage(nPageNum);
     709          26 :     pXFFrame->SetAnchorType(eAnchor);
     710          26 : }
     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          44 : bool LwpFrame::IsLeftWider()
     717             : {
     718             :     //LwpMiddleLayout* pParent = static_cast<LwpMiddleLayout*>(m_pLayout->GetContainerLayout());
     719          44 :     LwpVirtualLayout* pParent = static_cast<LwpVirtualLayout*>(m_pLayout->GetContainerLayout());
     720          44 :     if(pParent)
     721             :     {
     722          44 :         LwpPoint aPoint = m_pLayout->GetOrigin();
     723          44 :         double fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
     724          44 :         double fWidth = m_pLayout->GetWidth();
     725          44 :         double fWrapLeft = m_pLayout->GetExtMarginsValue(MARGIN_LEFT);
     726          44 :         double fWrapRight = m_pLayout->GetExtMarginsValue(MARGIN_RIGHT);
     727             : 
     728             :         //LwpPoint aParentPoint = pParent->GetOrigin();
     729             :         //double fParentXOffset = LwpTools::ConvertFromUnitsToMetric(aParentPoint.GetX());
     730          44 :         double fParentWidth = pParent->GetWidth();
     731          44 :         if(pParent->IsCell())
     732             :         {
     733             :             //Get actual width of this cell layout
     734           0 :             fParentWidth = static_cast<LwpCellLayout*>(pParent)->GetActualWidth();
     735             :         }
     736          44 :         double fParentMarginLeft = pParent->GetMarginsValue(MARGIN_LEFT);
     737          44 :         double fParentMarginRight = pParent->GetMarginsValue(MARGIN_RIGHT);
     738             : 
     739          44 :         double fLeft = fXOffset - fWrapLeft -fParentMarginLeft;
     740          44 :         double fRight = fParentWidth - fParentMarginRight -(fXOffset + fWidth + fWrapRight);
     741          44 :         if(fLeft > fRight)
     742          28 :             return true;
     743             :     }
     744          16 :     return false;
     745             : }
     746             : 
     747          72 : LwpFrameLink::LwpFrameLink()
     748          72 : {}
     749             : 
     750          72 : LwpFrameLink::~LwpFrameLink()
     751          72 : {}
     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          72 : LwpFrameLayout::LwpFrameLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
     765          72 :     : LwpPlacableLayout(objHdr, pStrm), m_pFrame(NULL)
     766             : {
     767          72 : }
     768             : 
     769         208 : LwpFrameLayout::~LwpFrameLayout()
     770             : {
     771          72 :     delete m_pFrame;
     772         136 : }
     773             : 
     774             : /**
     775             :  * @descr read frame layout object
     776             :  *
     777             :  */
     778          72 : void LwpFrameLayout::Read()
     779             : {
     780          72 :     LwpPlacableLayout::Read();
     781          72 :     if(LwpFileHeader::m_nFileRevision >= 0x000B)
     782             :     {
     783          72 :         if(m_pObjStrm->QuickReaduInt16())
     784             :         {
     785           0 :             m_Link.Read(m_pObjStrm);
     786             :         }
     787             :     }
     788          72 :     m_pObjStrm->SkipExtra();
     789          72 : }
     790             : 
     791             : /**
     792             :  * @descr create a xfframe and add into content container
     793             :  * @param:  pCont - content container that contains the frame.
     794             :  *
     795             :  */
     796          26 :  void LwpFrameLayout::XFConvert(XFContentContainer* pCont)
     797             :  {
     798          26 :     if(m_pFrame)
     799             :     {
     800             :         //parse the frame which anchor to paragraph
     801          26 :         if(IsRelativeAnchored())
     802             :         {
     803          26 :             XFConvertFrame(pCont);
     804             :         }
     805             :         else
     806             :         {
     807           0 :             m_pFrame->XFConvert(pCont);
     808             :         }
     809             : 
     810             :     }
     811          26 :  }
     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          26 : void LwpFrameLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart , sal_Int32 nEnd, bool bAll )
     819             : {
     820          26 :     if(m_pFrame)
     821             :     {
     822          26 :         XFFrame* pXFFrame = NULL;
     823          26 :         if(nEnd < nStart)
     824             :         {
     825           0 :             pXFFrame = new XFFrame();
     826             :         }
     827             :         else
     828             :         {
     829          26 :             pXFFrame = new XFFloatFrame(nStart, nEnd, bAll);
     830             :         }
     831             : 
     832          26 :         m_pFrame->Parse(pXFFrame, nStart);
     833             :         //if it is a link frame, parse contents only once
     834          26 :         if(!HasPreviousLinkLayout())
     835             :         {
     836          26 :             rtl::Reference<LwpObject> content = m_Content.obj();
     837          26 :             if (content.is())
     838             :             {
     839          26 :                 content->XFConvert(pXFFrame);
     840             :                 //set frame size according to ole size
     841          26 :                 ApplyGraphicSize(pXFFrame);
     842          26 :             }
     843             :         }
     844          26 :         pCont ->Add(pXFFrame);
     845             :     }
     846          26 : }
     847             : /**
     848             :  * @descr register frame style
     849             :  *
     850             :  */
     851          52 : void  LwpFrameLayout::RegisterStyle()
     852             : {
     853             :     //if it is for water mark, don't register style
     854          52 :     if (IsForWaterMark())
     855           2 :         return;
     856             : 
     857          52 :     if (m_pFrame)
     858           2 :         return;
     859             : 
     860             :     //register frame style
     861          50 :     XFFrameStyle* pFrameStyle = new XFFrameStyle();
     862          50 :     m_pFrame = new LwpFrame(this);
     863          50 :     m_pFrame->RegisterStyle(pFrameStyle);
     864             : 
     865             :     //register content style
     866          50 :     rtl::Reference<LwpObject> content = m_Content.obj();
     867          48 :     if (content.is())
     868             :     {
     869          48 :         content->SetFoundry(m_pFoundry);
     870          48 :         content->RegisterStyle();
     871             :     }
     872             : 
     873             :     //register child frame style
     874          48 :     RegisterChildStyle();
     875             : }
     876             : 
     877             : /**
     878             :  * @descr get the name of the frame that current frame links
     879             :  *
     880             :  */
     881          26 : OUString LwpFrameLayout::GetNextLinkName()
     882             : {
     883          26 :     OUString aName;
     884          26 :     LwpObjectID& rObjectID = m_Link.GetNextLayout();
     885          26 :     if(!rObjectID.IsNull())
     886             :     {
     887           0 :         LwpLayout* pLayout = dynamic_cast<LwpLayout*>(rObjectID.obj().get());
     888           0 :         if (pLayout)
     889             :         {
     890           0 :             LwpAtomHolder& rHolder = pLayout->GetName();
     891           0 :             aName = rHolder.str();
     892             :             //for division name confict
     893           0 :             if(!pLayout->GetStyleName().isEmpty())
     894           0 :                 aName = pLayout->GetStyleName();
     895             :         }
     896             :     }
     897          26 :     return aName;
     898             : }
     899             : /**
     900             :  * @descr whether current frame is linked by other frame
     901             :  *
     902             :  */
     903          26 : bool LwpFrameLayout::HasPreviousLinkLayout()
     904             : {
     905          26 :     LwpObjectID& rObjectID = m_Link.GetPreviousLayout();
     906          26 :     if(rObjectID.IsNull())
     907          26 :         return false;
     908           0 :     return true;
     909             : }
     910             : /**
     911             :  * @descr whether current frame is for water mark. Problem maybe exsits by this method, must be tracking
     912             :  *
     913             :  */
     914          52 : bool LwpFrameLayout::IsForWaterMark()
     915             : {
     916          52 :     if(m_nBuoyancy >=LAY_BUOYLAYER)
     917             :     {
     918           0 :         if(!m_Content.IsNull() && (m_Content.obj()->GetTag()==VO_GRAPHIC) )
     919             :         {
     920           0 :             return true;
     921             :         }
     922             :     }
     923          52 :     return false;
     924             : }
     925             : 
     926             : /**
     927             :  * @descr Get frame width
     928             :  *
     929             :  */
     930          84 : double LwpFrameLayout::GetWidth()
     931             : {
     932          84 :     double fWidth = LwpMiddleLayout::GetWidth();
     933          84 :     if(IsInlineToMargin() && IsAutoGrowWidth())
     934             :     {
     935             :         //for text field entry when choosing maximize field length
     936           0 :         fWidth = GetMaxWidth();
     937             :     }
     938          84 :     return fWidth;
     939             : }
     940             : 
     941             : /**
     942             :  * @descr Get frame width when the text field chooses maximize field length
     943             :  *
     944             :  */
     945           0 : double LwpFrameLayout::GetMaxWidth()
     946             : {
     947           0 :     double fActualWidth = 0;
     948           0 :     LwpMiddleLayout* pParent = static_cast<LwpMiddleLayout*>(GetContainerLayout());
     949           0 :     if(pParent)
     950             :     {
     951           0 :         LwpPoint aPoint = GetOrigin();
     952           0 :         double fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
     953           0 :         double fWrapRight = GetExtMarginsValue(MARGIN_RIGHT);
     954             : 
     955             :         //Get parent layout width
     956           0 :         double fParentWidth = pParent->GetWidth();
     957           0 :         if(pParent->IsCell())
     958             :         {
     959             :             //Get actual width of this cell layout
     960           0 :             fParentWidth = static_cast<LwpCellLayout*>(pParent)->GetActualWidth();
     961             :         }
     962             : 
     963           0 :         double fParentMarginRight = 0;
     964           0 :         sal_uInt8 nType = GetRelativeType();
     965           0 :         if(nType == LwpLayoutRelativityGuts::LAY_INLINE
     966           0 :             || nType == LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE )
     967             :         {
     968           0 :             fParentMarginRight = pParent->GetMarginsValue(MARGIN_RIGHT);
     969             :         }
     970             : 
     971           0 :         fActualWidth = fParentWidth - fXOffset - fParentMarginRight - fWrapRight;
     972             :     }
     973             : 
     974           0 :     return fActualWidth;
     975             : }
     976             : 
     977             : /**
     978             :  * @descr Set frame size according to graphic size
     979             :  *
     980             :  */
     981          26 : void LwpFrameLayout::ApplyGraphicSize(XFFrame * pXFFrame)
     982             : {
     983          26 :     rtl::Reference<LwpObject> content = m_Content.obj();
     984          52 :     if(content.is() && (content->GetTag() == VO_GRAPHIC
     985          18 :                 || content->GetTag() == VO_OLEOBJECT ))
     986             :     {
     987          26 :         LwpGraphicOleObject* pGraOle = static_cast<LwpGraphicOleObject*>(content.get());
     988             :         //Get frame geometry size
     989          26 :         double fWidth = 0;
     990          26 :         double fHeight = 0;
     991          26 :         pGraOle->GetGrafScaledSize(fWidth, fHeight);
     992          26 :         if( IsFitGraphic())
     993             :         {
     994             :             //graphic scaled sze
     995          12 :             fWidth += GetMarginsValue(MARGIN_LEFT) + GetMarginsValue(MARGIN_RIGHT);
     996          12 :             fHeight += GetMarginsValue(MARGIN_TOP) + GetMarginsValue(MARGIN_BOTTOM);
     997             :         }
     998          14 :         else if(IsAutoGrowDown() || IsAutoGrowUp())
     999             :         {
    1000           0 :             fWidth = GetWidth();
    1001           0 :             fHeight += GetMarginsValue(MARGIN_TOP) + GetMarginsValue(MARGIN_BOTTOM);
    1002             :         }
    1003          14 :         else if( IsAutoGrowLeft() || IsAutoGrowRight())
    1004             :         {
    1005           0 :             fHeight = GetHeight();
    1006           0 :             fWidth += GetMarginsValue(MARGIN_LEFT) + GetMarginsValue(MARGIN_RIGHT);
    1007             :         }
    1008             :         else
    1009             :         {
    1010          14 :             fWidth = GetWidth();
    1011          14 :             fHeight = GetHeight();
    1012             :         }
    1013          26 :         pXFFrame->SetWidth(fWidth);
    1014          26 :         pXFFrame->SetHeight(fHeight);
    1015          26 :     }
    1016          26 : }
    1017             : 
    1018           0 : LwpGroupLayout::LwpGroupLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
    1019             :     : LwpPlacableLayout(objHdr, pStrm)
    1020           0 :     , m_pFrame(NULL)
    1021             : {
    1022             : 
    1023           0 : }
    1024             : 
    1025           0 : LwpGroupLayout::~LwpGroupLayout()
    1026             : {
    1027           0 :     delete m_pFrame;
    1028           0 : }
    1029             : /**
    1030             :  * @descr read group layout object
    1031             :  *
    1032             :  */
    1033           0 : void LwpGroupLayout::Read()
    1034             : {
    1035           0 :     LwpPlacableLayout::Read();
    1036           0 :     m_pObjStrm->SkipExtra();
    1037           0 : }
    1038             : /**
    1039             :  * @descr register group frame style
    1040             :  *
    1041             :  */
    1042           0 : void LwpGroupLayout::RegisterStyle()
    1043             : {
    1044           0 :     if (m_pFrame)
    1045           0 :         return;
    1046             : 
    1047             :     //register frame style
    1048           0 :     XFFrameStyle* pFrameStyle = new XFFrameStyle();
    1049           0 :     m_pFrame = new LwpFrame(this);
    1050           0 :     m_pFrame->RegisterStyle(pFrameStyle);
    1051             : 
    1052             :     //register child frame style
    1053           0 :     RegisterChildStyle();
    1054             : }
    1055             : /**
    1056             :  * @descr create a xfframe and add into content container
    1057             :  * @param:  pCont - content container that contains the frame.
    1058             :  *
    1059             :  */
    1060           0 : void LwpGroupLayout::XFConvert(XFContentContainer *pCont)
    1061             : {
    1062           0 :     if(m_pFrame)
    1063             :     {
    1064             :         //parse the frame which anchor to paragraph
    1065           0 :         if(IsRelativeAnchored())
    1066             :         {
    1067           0 :             XFConvertFrame(pCont);
    1068             :         }
    1069             :         else
    1070             :         {
    1071           0 :             m_pFrame->XFConvert(pCont);
    1072             :         }
    1073             : 
    1074             :     }
    1075           0 : }
    1076             : /**
    1077             :  * @descr create a xfframe and add into content container, called by XFConvert
    1078             :  * @param:  pCont - content container that contains the frame.
    1079             :  * @param:  nPageNo - the page number that the frame anchors
    1080             :  *
    1081             :  */
    1082           0 : void LwpGroupLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart , sal_Int32 nEnd, bool bAll)
    1083             : {
    1084           0 :     if(m_pFrame)
    1085             :     {
    1086           0 :         XFFrame* pXFFrame = NULL;
    1087           0 :         if(nEnd < nStart)
    1088             :         {
    1089           0 :             pXFFrame = new XFFrame();
    1090             :         }
    1091             :         else
    1092             :         {
    1093           0 :             pXFFrame = new XFFloatFrame(nStart, nEnd, bAll);
    1094             :         }
    1095             : 
    1096           0 :         m_pFrame->Parse(pXFFrame, nStart);
    1097             : 
    1098             :         //add child frame into group
    1099           0 :         LwpVirtualLayout* pLayout = static_cast<LwpVirtualLayout*>(GetChildHead().obj().get());
    1100           0 :         while(pLayout)
    1101             :         {
    1102           0 :             pLayout->XFConvert(pXFFrame);
    1103           0 :             pLayout = static_cast<LwpVirtualLayout*>(pLayout->GetNext().obj().get());
    1104             :         }
    1105             : 
    1106           0 :         pCont ->Add(pXFFrame);
    1107             :     }
    1108           0 : }
    1109             : 
    1110           0 : LwpGroupFrame::LwpGroupFrame(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
    1111           0 :     :LwpContent(objHdr, pStrm)
    1112           0 : {}
    1113             : 
    1114           0 : LwpGroupFrame::~LwpGroupFrame()
    1115           0 : {}
    1116             : 
    1117           0 : void LwpGroupFrame::Read()
    1118             : {
    1119           0 :     LwpContent::Read();
    1120           0 :     m_pObjStrm->SkipExtra();
    1121             : 
    1122           0 : }
    1123             : 
    1124           0 : void  LwpGroupFrame::RegisterStyle()
    1125             : {
    1126           0 : }
    1127             : 
    1128           0 : void LwpGroupFrame::XFConvert(XFContentContainer* /*pCont*/)
    1129             : {
    1130           0 : }
    1131             : 
    1132           8 : LwpDropcapLayout::LwpDropcapLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
    1133           8 :     : LwpFrameLayout(objHdr, pStrm)
    1134             : {
    1135           8 :     m_nChars = 1;
    1136           8 :     m_nLines = 3;
    1137           8 : }
    1138             : 
    1139           8 : void LwpDropcapLayout::Read()
    1140             : {
    1141           8 :     LwpFrameLayout::Read();
    1142           8 :     m_nLines = m_pObjStrm->QuickReaduInt16();
    1143           8 :     m_pObjStrm->SeekRel(1);
    1144           8 :     m_pObjStrm->SkipExtra();
    1145           8 : }
    1146             : 
    1147           0 : void LwpDropcapLayout::Parse(IXFStream* pOutputStream)
    1148             : {
    1149           0 :     LwpStory* pStory = static_cast<LwpStory*>(m_Content.obj(VO_STORY).get());
    1150           0 :     if (!pStory)
    1151           0 :         return;
    1152           0 :     rtl::Reference<LwpObject> pPara = pStory->GetFirstPara().obj(VO_PARA);
    1153           0 :     if(pPara.is())
    1154             :     {
    1155           0 :         pPara->SetFoundry(m_pFoundry);
    1156           0 :         pPara->Parse(pOutputStream);
    1157           0 :     }
    1158             : }
    1159             : 
    1160           0 : void LwpDropcapLayout::XFConvert(XFContentContainer* pCont)
    1161             : {
    1162           0 :     LwpStory* pStory = static_cast<LwpStory*>(m_Content.obj(VO_STORY).get());
    1163           0 :     if (pStory)
    1164             :     {
    1165           0 :         pStory->SetFoundry(m_pFoundry);
    1166           0 :         pStory->XFConvert(pCont);
    1167             :     }
    1168           0 : }
    1169             : 
    1170           0 : LwpStory* LwpDropcapLayout::GetContentStory()
    1171             : {
    1172           0 :     return static_cast<LwpStory*>(m_Content.obj(VO_STORY).get());
    1173             : }
    1174             : 
    1175           0 : void LwpDropcapLayout::RegisterStyle(LwpFoundry* pFoundry)
    1176             : {
    1177           0 :     LwpStory* pStory = GetContentStory();
    1178           0 :     if (pStory)
    1179             :     {
    1180           0 :         pStory->SetDropcapFlag(true);
    1181           0 :         pStory->SetFoundry(pFoundry);
    1182           0 :         LwpPara* pPara = static_cast<LwpPara*>(pStory->GetFirstPara().obj().get());
    1183           0 :         while(pPara)
    1184             :         {
    1185           0 :             pPara->SetFoundry(pFoundry);
    1186           0 :             pPara->RegisterStyle();
    1187           0 :             pPara = static_cast<LwpPara*>(pPara->GetNext().obj().get());
    1188             :         }
    1189             :     }
    1190           0 : }
    1191             : 
    1192             : /**
    1193             :  * @descr  do nothing
    1194             :  *
    1195             :  */
    1196           0 : void LwpDropcapLayout::RegisterStyle()
    1197             : {
    1198           0 : }
    1199             : 
    1200           0 : LwpRubyLayout::LwpRubyLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
    1201             :     : LwpFrameLayout(objHdr, pStrm)
    1202             :     , m_nPlacement(0)
    1203             :     , m_nAlignment(0)
    1204             :     , m_nStateFlag(0)
    1205             :     , m_nXOffset(0)
    1206           0 :     , m_nYOffset(0)
    1207             : {
    1208           0 : }
    1209             : 
    1210           0 : void LwpRubyLayout::Read()
    1211             : {
    1212           0 :     LwpFrameLayout::Read();
    1213           0 :     m_nPlacement = m_pObjStrm->QuickReaduInt8();
    1214           0 :     m_nAlignment = m_pObjStrm->QuickReaduInt8();
    1215           0 :     m_nStateFlag = m_pObjStrm->QuickReaduInt16();
    1216           0 :     m_nXOffset = m_pObjStrm->QuickReadInt32();
    1217           0 :     m_nYOffset = m_pObjStrm->QuickReadInt32();
    1218           0 :     m_objRubyMarker.ReadIndexed(m_pObjStrm);
    1219           0 :     m_pObjStrm->SkipExtra();
    1220           0 : }
    1221             : 
    1222           0 : LwpRubyMarker* LwpRubyLayout::GetMarker()
    1223             : {
    1224           0 :     return static_cast<LwpRubyMarker*>(m_objRubyMarker.obj(VO_RUBYMARKER).get());
    1225             : }
    1226             : 
    1227           0 : LwpStory* LwpRubyLayout::GetContentStory()
    1228             : {
    1229           0 :     return static_cast<LwpStory*>(m_Content.obj(VO_STORY).get());
    1230             : }
    1231             : 
    1232           0 : void LwpRubyLayout::ConvertContentText()
    1233             : {
    1234           0 :     LwpStory* pStory = GetContentStory();
    1235           0 :     LwpRubyMarker* pMarker = GetMarker();
    1236           0 :     if (pStory && pMarker)
    1237           0 :         pMarker->SetRubyText(pStory->GetContentText(true));
    1238           0 : }
    1239             : 
    1240           0 : void LwpRubyLayout::RegisterStyle()
    1241             : {
    1242           0 :     LwpRubyMarker* pMarker = GetMarker();
    1243             : 
    1244           0 :     XFRubyStyle* pRubyStyle = new XFRubyStyle;
    1245             : 
    1246           0 :     enumXFRubyPosition eType = enumXFRubyLeft;
    1247           0 :     if (m_nAlignment == LEFT)
    1248             :     {
    1249           0 :         eType = enumXFRubyLeft;
    1250             :     }
    1251           0 :     else if(m_nAlignment == RIGHT)
    1252             :     {
    1253           0 :         eType =  enumXFRubyRight;
    1254             :     }
    1255           0 :     else if(m_nAlignment == CENTER)
    1256             :     {
    1257           0 :         eType =  enumXFRubyCenter;
    1258             :     }
    1259           0 :     pRubyStyle->SetAlignment(eType);
    1260             : 
    1261           0 :     eType = enumXFRubyTop;
    1262           0 :     if (m_nPlacement == TOP)
    1263             :     {
    1264           0 :         eType = enumXFRubyTop;
    1265             :     }
    1266           0 :     else if(m_nPlacement == BOTTOM)
    1267             :     {
    1268           0 :         eType =  enumXFRubyBottom;
    1269             :     }
    1270           0 :     pRubyStyle->SetPosition(eType);
    1271             : 
    1272           0 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
    1273           0 :     OUString rubyStyle = pXFStyleManager->AddStyle(pRubyStyle)->GetStyleName();
    1274           0 :     pMarker->SetRubyStyleName(rubyStyle);
    1275             : 
    1276           0 :     LwpStory* pStory = GetContentStory();
    1277           0 :     pStory->SetFoundry(m_pFoundry);
    1278           0 :     OUString textStyle = pStory->RegisterFirstFribStyle();
    1279           0 :     pMarker->SetTextStyleName(textStyle);
    1280           6 : }
    1281             : 
    1282             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10