LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpframelayout.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 557 0.0 %
Date: 2014-04-14 Functions: 0 62 0.0 %
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           0 : LwpFrame::LwpFrame(LwpPlacableLayout* pLayout):m_pLayout(pLayout)
      77             : {
      78           0 : }
      79             : 
      80           0 : LwpFrame::~LwpFrame()
      81             : {
      82           0 : }
      83             : /**
      84             : * @descr:  parse frame
      85             : * @param:  register frame style
      86             : * @param:  pFrameStyle - Frame Style object
      87             : *
      88             : */
      89           0 : void  LwpFrame::RegisterStyle(XFFrameStyle* pFrameStyle)
      90             : {
      91           0 :     ApplyWrapType(pFrameStyle);
      92           0 :     ApplyMargins(pFrameStyle);
      93           0 :     ApplyPadding(pFrameStyle);
      94           0 :     ApplyBorders(pFrameStyle);
      95           0 :     ApplyColumns(pFrameStyle);
      96           0 :     ApplyShadow(pFrameStyle);
      97           0 :     ApplyBackGround(pFrameStyle);
      98           0 :     ApplyWatermark(pFrameStyle);
      99             : //  ApplyBackColor(pFrameStyle);
     100           0 :     ApplyProtect(pFrameStyle);
     101           0 :     ApplyTextDir(pFrameStyle);
     102           0 :     ApplyPosType(pFrameStyle);
     103             : 
     104           0 :     pFrameStyle->SetStyleName(m_pLayout->GetName()->str());
     105           0 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     106           0 :     m_StyleName = pXFStyleManager->AddStyle(pFrameStyle)->GetStyleName();
     107           0 :     m_pLayout->SetStyleName(m_StyleName);
     108           0 : }
     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           0 :  void LwpFrame::Parse(XFFrame* pXFFrame, sal_Int32 nPageNo)
     116             :  {
     117             :     //set the frame style name
     118           0 :     pXFFrame->SetStyleName(m_StyleName);
     119             : 
     120             :     //SetAnchorType and position,if it's page anchor,set the page number.
     121           0 :     ParseAnchorType(pXFFrame);
     122           0 :     if(nPageNo>0)
     123             :     {
     124           0 :         pXFFrame->SetAnchorPage(nPageNo);
     125             :     }
     126             : 
     127             :     //Set frame Name
     128           0 :     OUString aFrameName = m_pLayout->GetName()->str();
     129           0 :     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           0 :     LwpLayoutGeometry* pLayoutGeo = m_pLayout->GetGeometry();
     141             :     //Set frame Width and height
     142           0 :     if(pLayoutGeo)
     143             :     {
     144           0 :         double fWidth = m_pLayout->GetWidth();
     145           0 :         double fHeight = m_pLayout->GetHeight();
     146             : 
     147           0 :         pXFFrame->SetWidth( fWidth );
     148           0 :         pXFFrame->SetHeight( fHeight );
     149             : 
     150             :         //Get content obj;
     151           0 :         /*LwpObject* pObj =*/ m_pLayout->GetContent()->obj();
     152           0 :         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           0 :         else if(m_pLayout->IsAutoGrow())
     172             :         {
     173           0 :             pXFFrame->SetMinHeight( fHeight );
     174             :         }
     175             :     }
     176             : 
     177           0 :     if(m_pLayout->IsFrame())
     178             :     {
     179             :         //Set frame link. Only frame layout has this feature
     180           0 :         LwpFrameLayout* pLayout= static_cast<LwpFrameLayout*>(m_pLayout);
     181           0 :         pXFFrame->SetNextLink(pLayout->GetNextLinkName());
     182           0 :     }
     183             : 
     184           0 :  }
     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           0 : void LwpFrame::ApplyWrapType(XFFrameStyle *pFrameStyle)
     245             : {
     246           0 :     enumXFWrap eWrap = enumXFWrapNone;
     247           0 :     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           0 :             eWrap = enumXFWrapBest;
     258           0 :             LwpMiddleLayout* pParent = static_cast<LwpMiddleLayout*>(m_pLayout->GetContainerLayout());
     259           0 :             if(pParent)
     260             :             {
     261           0 :                 if(IsLeftWider())
     262           0 :                     eWrap = enumXFWrapLeft;
     263             :                 else
     264           0 :                     eWrap = enumXFWrapRight;
     265             :             }
     266           0 :             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           0 :             eWrap = enumXFWrapRunThrough;
     276           0 :             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           0 :             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           0 :     if(m_pLayout->GetRelativeType()==LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE)
     309             :     {
     310           0 :         eWrap = enumXFWrapNone;
     311             :     }
     312             : 
     313           0 :     pFrameStyle->SetWrapType(eWrap);
     314           0 : }
     315             : /**
     316             : * @descr:   set frame margins style
     317             : * @param:  pFrameStyle - Frame Style object
     318             : *
     319             : */
     320           0 : void LwpFrame::ApplyMargins(XFFrameStyle *pFrameStyle)
     321             : {
     322           0 :     double fLeft    = m_pLayout->GetExtMarginsValue(MARGIN_LEFT);
     323           0 :     double fRight   = m_pLayout->GetExtMarginsValue(MARGIN_RIGHT);
     324           0 :     double fTop = m_pLayout->GetExtMarginsValue(MARGIN_TOP);
     325           0 :     double fBottom  = m_pLayout->GetExtMarginsValue(MARGIN_BOTTOM);
     326           0 :     pFrameStyle->SetMargins(fLeft,fRight,fTop,fBottom);
     327           0 : }
     328             : /**
     329             : * @descr:  set padding border style
     330             : * @param:  pFrameStyle - Frame Style object
     331             : *
     332             : */
     333           0 : void LwpFrame::ApplyPadding(XFFrameStyle *pFrameStyle)
     334             : {
     335           0 :     double fLeft    = m_pLayout->GetMarginsValue(MARGIN_LEFT);
     336           0 :     double fRight   = m_pLayout->GetMarginsValue(MARGIN_RIGHT);
     337           0 :     double fTop = m_pLayout->GetMarginsValue(MARGIN_TOP);
     338           0 :     double fBottom  = m_pLayout->GetMarginsValue(MARGIN_BOTTOM);
     339           0 :     pFrameStyle->SetPadding(fLeft,fRight,fTop,fBottom);
     340           0 : }
     341             : /**
     342             : * @descr:  set frame border style
     343             : * @param:  pFrameStyle - Frame Style object
     344             : *
     345             : */
     346           0 : void LwpFrame::ApplyBorders(XFFrameStyle *pFrameStyle)
     347             : {
     348           0 :     XFBorders* pBordres = m_pLayout->GetXFBorders();
     349           0 :     if(pBordres)
     350             :     {
     351           0 :         pFrameStyle->SetBorders(pBordres);
     352             :     }
     353           0 : }
     354             : /**
     355             : * @descr:  set frame columns style
     356             : * @param:  pFrameStyle - Frame Style object
     357             : *
     358             : */
     359           0 : void LwpFrame::ApplyColumns(XFFrameStyle *pFrameStyle)
     360             : {
     361           0 :     XFColumns* pColumns = m_pLayout->GetXFColumns();
     362           0 :     if(pColumns)
     363             :     {
     364           0 :         pFrameStyle->SetColumns(pColumns);
     365             :     }
     366           0 : }
     367             : /**
     368             : * @descr:  set frame shadow style
     369             : * @param:  pFrameStyle - Frame Style object
     370             : *
     371             : */
     372           0 : void LwpFrame::ApplyShadow(XFFrameStyle* pFrameStyle)
     373             : {
     374           0 :     XFShadow* pXFShadow = m_pLayout->GetXFShadow();
     375           0 :     if(pXFShadow)
     376             :     {
     377           0 :         pFrameStyle->SetShadow(pXFShadow);
     378             :     }
     379           0 : }
     380             : /**
     381             : * @descr:  set frame back color style
     382             : * @param:  pFrameStyle - Frame Style object
     383             : *
     384             : */
     385           0 : void LwpFrame::ApplyBackColor(XFFrameStyle* pFrameStyle)
     386             : {
     387           0 :     LwpColor* pColor = m_pLayout->GetBackColor();
     388           0 :     if(pColor)
     389             :     {
     390           0 :         XFColor aXFColor(pColor->To24Color());
     391           0 :         pFrameStyle->SetBackColor(aXFColor);
     392             :     }
     393           0 : }
     394             : /**
     395             : * @descr:  set frame protect style
     396             : * @param:  pFrameStyle - Frame Style object
     397             : *
     398             : */
     399           0 : void LwpFrame::ApplyProtect(XFFrameStyle* pFrameStyle)
     400             : {
     401           0 :     if(m_pLayout->IsProtected())
     402             :     {
     403           0 :         pFrameStyle->SetProtect(sal_True,sal_True,sal_True);
     404             :     }
     405           0 : }
     406             : /**
     407             : * @descr:  set frame text direction style
     408             : * @param:  pFrameStyle - Frame Style object
     409             : *
     410             : */
     411           0 : void LwpFrame::ApplyTextDir(XFFrameStyle* pFrameStyle)
     412             : {
     413           0 :     pFrameStyle->SetTextDir(m_pLayout->GetTextDirection());
     414           0 : }
     415             : /**
     416             : * @descr:  set frame position type style
     417             : * @param:  pFrameStyle - Frame Style object
     418             : *
     419             : */
     420           0 : void LwpFrame::ApplyPosType(XFFrameStyle* pFrameStyle)
     421             : {
     422           0 :     enumXFFrameXPos eXPos = enumXFFrameXPosCenter;
     423           0 :     enumXFFrameXRel eXRel = enumXFFrameXRelPara;
     424           0 :     enumXFFrameYPos eYPos = enumXFFrameYPosMiddle;
     425           0 :     enumXFFrameYRel eYRel = enumXFFrameYRelPara;
     426           0 :     sal_uInt8 nType = m_pLayout->GetRelativeType();
     427           0 :     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           0 :             eXPos = enumXFFrameXPosFromLeft;
     467           0 :             eXRel = enumXFFrameXRelPage;
     468           0 :             eYPos = enumXFFrameYPosBelow;   //below
     469           0 :             eYRel = enumXFFrameYRelChar; //from char
     470             :             //set vertical position
     471           0 :             LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout();
     472           0 :             if(pContainer && pContainer->IsPage())//in page
     473             :             {
     474             :                 //eYPos = enumXFFrameYPosFromTop;
     475             :                 //eYRel = enumXFFrameYRelPage;
     476           0 :                 eYPos = enumXFFrameYPosBelow;
     477           0 :                 eYRel = enumXFFrameYRelChar;
     478             :             }
     479           0 :             else if(pContainer && pContainer->IsFrame()) //in frame
     480             :             {
     481           0 :                 eYPos = enumXFFrameYPosFromTop;
     482           0 :                 eYRel = enumXFFrameYRelPage;
     483             :             }
     484             :             else
     485             :             {
     486           0 :                 eYPos = enumXFFrameYPosFromTop; //from top
     487           0 :                 eYRel = enumXFFrameYRelPara; //from margin
     488             :             }
     489           0 :             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           0 :             eXPos = enumXFFrameXPosFromLeft;
     507           0 :             eXRel = enumXFFrameXRelParaContent;
     508             :             //eYPos = enumXFFrameYPosTop;
     509           0 :             eYPos = enumXFFrameYPosBottom;
     510           0 :             eYRel = enumXFFrameYRelParaContent;
     511           0 :             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           0 :     pFrameStyle->SetXPosType(eXPos,eXRel);
     526           0 :     pFrameStyle->SetYPosType(eYPos,eYRel);
     527           0 : }
     528             : /**
     529             : * @descr:  set frame watermark style
     530             : * @param:  pFrameStyle - Frame Style object
     531             : *
     532             : */
     533           0 : void LwpFrame::ApplyWatermark(XFFrameStyle *pFrameStyle)
     534             : {
     535           0 :     XFBGImage* pBGImage = m_pLayout->GetXFBGImage();
     536           0 :     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           0 : }
     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           0 : void LwpFrame::ApplyBackGround(XFFrameStyle* pFrameStyle)
     569             : {
     570           0 :     if (!m_pLayout)
     571             :     {
     572           0 :         return;
     573             :     }
     574             : 
     575           0 :     if (m_pLayout->IsPatternFill())
     576             :     {
     577           0 :         ApplyPatternFill(pFrameStyle);
     578             :     }
     579             :     else
     580             :     {
     581           0 :         ApplyBackColor(pFrameStyle);
     582             :     }
     583             : }
     584             : 
     585             : /**
     586             : * @descr:  set frame size, anchor type, anchored page number
     587             : * @param:  pXFFrame - XFFrame  object
     588             : *
     589             : */
     590           0 : void LwpFrame::ParseAnchorType(XFFrame *pXFFrame)
     591             : {
     592             :     //set position
     593           0 :     double fXOffset = 0;
     594           0 :     double fYOffset = 0;
     595             :     //page number
     596           0 :     sal_uInt16 nPageNum = 0;
     597             :     //set anchor type
     598           0 :     enumXFAnchor eAnchor = enumXFAnchorNone;
     599             : 
     600           0 :     LwpLayoutGeometry* pLayoutGeo = m_pLayout->GetGeometry();
     601           0 :     if(pLayoutGeo)
     602             :     {
     603           0 :         LwpPoint aPoint = pLayoutGeo->GetOrigin();
     604           0 :         fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
     605           0 :         fYOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetY());
     606             :     }
     607             :     //set anchor type
     608           0 :     eAnchor = enumXFAnchorNone;
     609           0 :     sal_uInt8 nType = m_pLayout->GetRelativeType();
     610           0 :     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           0 :             eAnchor = enumXFAnchorChar;
     646           0 :             LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout();
     647           0 :             if(pContainer && pContainer->IsPage())//in page
     648             :             {
     649             :                 //eAnchor = enumXFAnchorPage;
     650           0 :                 eAnchor = enumXFAnchorChar;// to character
     651             :             }
     652           0 :             else if(pContainer && pContainer->IsFrame()) //in frame
     653             :             {
     654           0 :                 eAnchor = enumXFAnchorFrame;
     655             :             }
     656           0 :             else if(pContainer && pContainer->IsCell()) //in cell
     657             :             {
     658             :                 //eAnchor = enumXFAnchorChar;
     659           0 :                 eAnchor = enumXFAnchorPara;
     660           0 :                 fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP);
     661             :             }
     662           0 :             else if(pContainer && (pContainer->IsHeader() || pContainer->IsFooter()))//in header or footer
     663             :             {
     664           0 :                 eAnchor = enumXFAnchorPara;
     665           0 :                 fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP);
     666             :             }
     667           0 :             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           0 :             eAnchor = enumXFAnchorPara;
     683           0 :             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           0 :     pXFFrame->SetX(fXOffset);
     707           0 :     pXFFrame->SetY(fYOffset);
     708           0 :     pXFFrame->SetAnchorPage(nPageNum);
     709           0 :     pXFFrame->SetAnchorType(eAnchor);
     710           0 : }
     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           0 : sal_Bool LwpFrame::IsLeftWider()
     717             : {
     718             :     //LwpMiddleLayout* pParent = static_cast<LwpMiddleLayout*>(m_pLayout->GetContainerLayout());
     719           0 :     LwpVirtualLayout* pParent = static_cast<LwpVirtualLayout*>(m_pLayout->GetContainerLayout());
     720           0 :     if(pParent)
     721             :     {
     722           0 :         LwpPoint aPoint = m_pLayout->GetOrigin();
     723           0 :         double fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
     724           0 :         double fWidth = m_pLayout->GetWidth();
     725           0 :         double fWrapLeft = m_pLayout->GetExtMarginsValue(MARGIN_LEFT);
     726           0 :         double fWrapRight = m_pLayout->GetExtMarginsValue(MARGIN_RIGHT);
     727             : 
     728             :         //LwpPoint aParentPoint = pParent->GetOrigin();
     729             :         //double fParentXOffset = LwpTools::ConvertFromUnitsToMetric(aParentPoint.GetX());
     730           0 :         double fParentWidth = pParent->GetWidth();
     731           0 :         if(pParent->IsCell())
     732             :         {
     733             :             //Get actual width of this cell layout
     734           0 :             fParentWidth = static_cast<LwpCellLayout*>(pParent)->GetActualWidth();
     735             :         }
     736           0 :         double fParentMarginLeft = pParent->GetMarginsValue(MARGIN_LEFT);
     737           0 :         double fParentMarginRight = pParent->GetMarginsValue(MARGIN_RIGHT);
     738             : 
     739           0 :         double fLeft = fXOffset - fWrapLeft -fParentMarginLeft;
     740           0 :         double fRight = fParentWidth - fParentMarginRight -(fXOffset + fWidth + fWrapRight);
     741           0 :         if(fLeft > fRight)
     742           0 :             return sal_True;
     743             :     }
     744           0 :     return sal_False;
     745             : }
     746             : 
     747           0 : LwpFrameLink::LwpFrameLink()
     748           0 : {}
     749             : 
     750           0 : LwpFrameLink::~LwpFrameLink()
     751           0 : {}
     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           0 : LwpFrameLayout::LwpFrameLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
     765           0 :     : LwpPlacableLayout(objHdr, pStrm), m_pFrame(NULL)
     766             : {
     767           0 : }
     768             : 
     769           0 : LwpFrameLayout::~LwpFrameLayout()
     770             : {
     771           0 :     delete m_pFrame;
     772           0 : }
     773             : 
     774             : /**
     775             :  * @descr read frame layout object
     776             :  *
     777             :  */
     778           0 : void LwpFrameLayout::Read()
     779             : {
     780           0 :     LwpPlacableLayout::Read();
     781           0 :     if(LwpFileHeader::m_nFileRevision >= 0x000B)
     782             :     {
     783           0 :         if(m_pObjStrm->QuickReaduInt16())
     784             :         {
     785           0 :             m_Link.Read(m_pObjStrm);
     786             :         }
     787             :     }
     788           0 :     m_pObjStrm->SkipExtra();
     789           0 : }
     790             : 
     791             : /**
     792             :  * @descr create a xfframe and add into content container
     793             :  * @param:  pCont - content container that contains the frame.
     794             :  *
     795             :  */
     796           0 :  void LwpFrameLayout::XFConvert(XFContentContainer* pCont)
     797             :  {
     798           0 :     if(m_pFrame)
     799             :     {
     800             :         //parse the frame which anchor to paragraph
     801           0 :         if(IsRelativeAnchored())
     802             :         {
     803           0 :             XFConvertFrame(pCont);
     804             :         }
     805             :         else
     806             :         {
     807           0 :             m_pFrame->XFConvert(pCont);
     808             :         }
     809             : 
     810             :     }
     811           0 :  }
     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           0 : void LwpFrameLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart , sal_Int32 nEnd, sal_Bool bAll )
     819             : {
     820           0 :     if(m_pFrame)
     821             :     {
     822           0 :         XFFrame* pXFFrame = NULL;
     823           0 :         if(nEnd < nStart)
     824             :         {
     825           0 :             pXFFrame = new XFFrame();
     826             :         }
     827             :         else
     828             :         {
     829           0 :             pXFFrame = new XFFloatFrame(nStart, nEnd, bAll);
     830             :         }
     831             : 
     832           0 :         m_pFrame->Parse(pXFFrame, nStart);
     833             :         //if it is a link frame, parse contents only once
     834           0 :         if(!HasPreviousLinkLayout())
     835             :         {
     836           0 :             LwpObject* content = m_Content.obj();
     837           0 :             if (content)
     838             :             {
     839           0 :                 content->XFConvert(pXFFrame);
     840             :                 //set frame size according to ole size
     841           0 :                 ApplyGraphicSize(pXFFrame);
     842             :             }
     843             :         }
     844           0 :         pCont ->Add(pXFFrame);
     845             :     }
     846           0 : }
     847             : /**
     848             :  * @descr register frame style
     849             :  *
     850             :  */
     851           0 : void  LwpFrameLayout::RegisterStyle()
     852             : {
     853             :     //if it is for water mark, don't register style
     854           0 :     if (IsForWaterMark())
     855           0 :         return;
     856             : 
     857           0 :     if (m_pFrame)
     858           0 :         return;
     859             : 
     860             :     //register frame style
     861           0 :     XFFrameStyle* pFrameStyle = new XFFrameStyle();
     862           0 :     m_pFrame = new LwpFrame(this);
     863           0 :     m_pFrame->RegisterStyle(pFrameStyle);
     864             : 
     865             :     //register content style
     866           0 :     LwpObject* content = m_Content.obj();
     867           0 :     if (content)
     868             :     {
     869           0 :         content->SetFoundry(m_pFoundry);
     870           0 :         content->RegisterStyle();
     871             :     }
     872             : 
     873             :     //register child frame style
     874           0 :     RegisterChildStyle();
     875             : }
     876             : 
     877             : /**
     878             :  * @descr get the name of the frame that current frame links
     879             :  *
     880             :  */
     881           0 : OUString LwpFrameLayout::GetNextLinkName()
     882             : {
     883           0 :     OUString aName;
     884           0 :     LwpObjectID* pObjectID = m_Link.GetNextLayout();
     885           0 :     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           0 :     return aName;
     899             : }
     900             : /**
     901             :  * @descr whether current frame is linked by other frame
     902             :  *
     903             :  */
     904           0 : sal_Bool LwpFrameLayout::HasPreviousLinkLayout()
     905             : {
     906           0 :     LwpObjectID* pObjectID = m_Link.GetPreviousLayout();
     907           0 :     if(pObjectID->IsNull())
     908           0 :         return sal_False;
     909           0 :     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           0 :  sal_Bool LwpFrameLayout::IsForWaterMark()
     916             : {
     917           0 :     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           0 :     return sal_False;
     925             : }
     926             : 
     927             : /**
     928             :  * @descr Get frame width
     929             :  *
     930             :  */
     931           0 : double LwpFrameLayout::GetWidth()
     932             : {
     933           0 :     double fWidth = LwpMiddleLayout::GetWidth();
     934           0 :     if(IsInlineToMargin() && IsAutoGrowWidth())
     935             :     {
     936             :         //for text field entry when choosing maximize field length
     937           0 :         fWidth = GetMaxWidth();
     938             :     }
     939           0 :     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           0 :             || 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           0 : void LwpFrameLayout::ApplyGraphicSize(XFFrame * pXFFrame)
     983             : {
     984           0 :     LwpObject* content = m_Content.obj();
     985           0 :     if(content && (content->GetTag() == VO_GRAPHIC
     986           0 :                 || content->GetTag() == VO_OLEOBJECT ))
     987             :     {
     988           0 :         LwpGraphicOleObject* pGraOle = static_cast<LwpGraphicOleObject*>(content);
     989             :         //Get frame geometry size
     990           0 :         double fWidth = 0;
     991           0 :         double fHeight = 0;
     992           0 :         pGraOle->GetGrafScaledSize(fWidth, fHeight);
     993           0 :         if( IsFitGraphic())
     994             :         {
     995             :             //graphic scaled sze
     996           0 :             fWidth += GetMarginsValue(MARGIN_LEFT) + GetMarginsValue(MARGIN_RIGHT);
     997           0 :             fHeight += GetMarginsValue(MARGIN_TOP) + GetMarginsValue(MARGIN_BOTTOM);
     998             :         }
     999           0 :         else if(IsAutoGrowDown() || IsAutoGrowUp())
    1000             :         {
    1001           0 :             fWidth = GetWidth();
    1002           0 :             fHeight += GetMarginsValue(MARGIN_TOP) + GetMarginsValue(MARGIN_BOTTOM);
    1003             :         }
    1004           0 :         else if( IsAutoGrowLeft() || IsAutoGrowRight())
    1005             :         {
    1006           0 :             fHeight = GetHeight();
    1007           0 :             fWidth += GetMarginsValue(MARGIN_LEFT) + GetMarginsValue(MARGIN_RIGHT);
    1008             :         }
    1009             :         else
    1010             :         {
    1011           0 :             fWidth = GetWidth();
    1012           0 :             fHeight = GetHeight();
    1013             :         }
    1014           0 :         pXFFrame->SetWidth(fWidth);
    1015           0 :         pXFFrame->SetHeight(fHeight);
    1016             :     }
    1017           0 : }
    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           0 : LwpDropcapLayout::LwpDropcapLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
    1134           0 :     : LwpFrameLayout(objHdr, pStrm)
    1135             : {
    1136           0 :     m_nChars = 1;
    1137           0 :     m_nLines = 3;
    1138           0 : }
    1139             : 
    1140           0 : void LwpDropcapLayout::Read()
    1141             : {
    1142           0 :     LwpFrameLayout::Read();
    1143           0 :     m_nLines = m_pObjStrm->QuickReaduInt16();
    1144           0 :     m_pObjStrm->SeekRel(1);
    1145           0 :     m_pObjStrm->SkipExtra();
    1146           0 : }
    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             :     : LwpFrameLayout(objHdr, pStrm)
    1203             :     , m_nPlacement(0)
    1204             :     , m_nAlignment(0)
    1205             :     , m_nStateFlag(0)
    1206             :     , m_nXOffset(0)
    1207           0 :     , m_nYOffset(0)
    1208             : {
    1209           0 : }
    1210             : 
    1211           0 : void LwpRubyLayout::Read()
    1212             : {
    1213           0 :     LwpFrameLayout::Read();
    1214           0 :     m_nPlacement = m_pObjStrm->QuickReaduInt8();
    1215           0 :     m_nAlignment = m_pObjStrm->QuickReaduInt8();;
    1216           0 :     m_nStateFlag = m_pObjStrm->QuickReaduInt16();;
    1217           0 :     m_nXOffset = m_pObjStrm->QuickReadInt32();
    1218           0 :     m_nYOffset = m_pObjStrm->QuickReadInt32();
    1219           0 :     m_objRubyMarker.ReadIndexed(m_pObjStrm);
    1220           0 :     m_pObjStrm->SkipExtra();
    1221           0 : }
    1222             : 
    1223           0 : LwpRubyMarker* LwpRubyLayout::GetMarker()
    1224             : {
    1225           0 :     return static_cast<LwpRubyMarker*>(m_objRubyMarker.obj(VO_RUBYMARKER));
    1226             : }
    1227             : 
    1228           0 : LwpStory* LwpRubyLayout::GetContentStory()
    1229             : {
    1230           0 :     return static_cast<LwpStory*>(m_Content.obj(VO_STORY));
    1231             : }
    1232             : 
    1233           0 : void LwpRubyLayout::ConvertContentText()
    1234             : {
    1235           0 :     LwpStory* pStory = GetContentStory();
    1236           0 :     LwpRubyMarker* pMarker = GetMarker();
    1237           0 :     if (pStory && pMarker)
    1238           0 :         pMarker->SetRubyText(pStory->GetContentText(sal_True));
    1239           0 : }
    1240             : 
    1241           0 : void LwpRubyLayout::RegisterStyle()
    1242             : {
    1243           0 :     LwpRubyMarker* pMarker = GetMarker();
    1244             : 
    1245           0 :     XFRubyStyle* pRubyStyle = new XFRubyStyle;
    1246             : 
    1247           0 :     enumXFRubyPosition eType = enumXFRubyLeft;
    1248           0 :     if (m_nAlignment == LEFT)
    1249             :     {
    1250           0 :         eType = enumXFRubyLeft;
    1251             :     }
    1252           0 :     else if(m_nAlignment == RIGHT)
    1253             :     {
    1254           0 :         eType =  enumXFRubyRight;
    1255             :     }
    1256           0 :     else if(m_nAlignment == CENTER)
    1257             :     {
    1258           0 :         eType =  enumXFRubyCenter;
    1259             :     }
    1260           0 :     pRubyStyle->SetAlignment(eType);
    1261             : 
    1262           0 :     eType = enumXFRubyTop;
    1263           0 :     if (m_nPlacement == TOP)
    1264             :     {
    1265           0 :         eType = enumXFRubyTop;
    1266             :     }
    1267           0 :     else if(m_nPlacement == BOTTOM)
    1268             :     {
    1269           0 :         eType =  enumXFRubyBottom;
    1270             :     }
    1271           0 :     pRubyStyle->SetPosition(eType);
    1272             : 
    1273           0 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
    1274           0 :     OUString rubyStyle = pXFStyleManager->AddStyle(pRubyStyle)->GetStyleName();
    1275           0 :     pMarker->SetRubyStyleName(rubyStyle);
    1276             : 
    1277           0 :     LwpStory* pStory = GetContentStory();
    1278           0 :     pStory->SetFoundry(m_pFoundry);
    1279           0 :     OUString textStyle = pStory->RegisterFirstFribStyle();
    1280           0 :     pMarker->SetTextStyleName(textStyle);
    1281           0 : }
    1282             : 
    1283             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10