LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/lotuswordpro/source/filter - lwppagelayout.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 297 466 63.7 %
Date: 2013-07-09 Functions: 47 59 79.7 %
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             :  * Change History
      58             : Mar 2005            Created
      59             :  ************************************************************************/
      60             : #include "lwppagelayout.hxx"
      61             : #include "lwplaypiece.hxx"
      62             : #include "lwpfootnote.hxx"
      63             : #include "lwpdoc.hxx"
      64             : #include "lwpholder.hxx"
      65             : #include "lwppagehint.hxx"
      66             : #include "lwpdivinfo.hxx"
      67             : #include "lwpstory.hxx"
      68             : #include "xfilter/xfstylemanager.hxx"
      69             : #include "xfilter/xfmasterpage.hxx"
      70             : #include "xfilter/xfcontentcontainer.hxx"
      71             : #include "xfilter/xfheader.hxx"
      72             : #include "xfilter/xfheaderstyle.hxx"
      73             : #include "xfilter/xffooterstyle.hxx"
      74             : #include "xfilter/xffooter.hxx"
      75             : #include <sfx2/printer.hxx>
      76             : #include "lwpchangemgr.hxx"
      77             : #include "lwpglobalmgr.hxx"
      78             : 
      79           8 : LwpPageLayout::LwpPageLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
      80           8 :     : LwpLayout(objHdr, pStrm), m_pPrinterBinName(new LwpAtomHolder),
      81          16 :     m_pPaperName(new LwpAtomHolder),m_pXFPageMaster(NULL)
      82             : {
      83           8 : }
      84             : 
      85          24 : LwpPageLayout::~LwpPageLayout()
      86             : {
      87           8 :     if (m_pPrinterBinName)
      88             :     {
      89           8 :         delete m_pPrinterBinName;
      90             :     }
      91           8 :     if (m_pPaperName)
      92             :     {
      93           8 :         delete m_pPaperName;
      94             :     }
      95          16 : }
      96           8 : void LwpPageLayout::Read()
      97             : {
      98           8 :     LwpLayout::Read();
      99             : 
     100           8 :     if (LwpFileHeader::m_nFileRevision < 0x000B)
     101             :     {
     102             :         // read PreRevBLayout...
     103             :     }
     104             : 
     105           8 :     m_nPrinterBin = m_pObjStrm->QuickReaduInt16();
     106           8 :     m_pPrinterBinName->Read(m_pObjStrm);
     107             : 
     108           8 :     if (LwpFileHeader::m_nFileRevision >= 0x000B)
     109           8 :         m_nBdroffset = m_pObjStrm->QuickReadInt32();
     110             : 
     111           8 :     if (m_pObjStrm->CheckExtra())
     112             :     {
     113           6 :         m_pPaperName->Read(m_pObjStrm);
     114           6 :         m_pObjStrm->SkipExtra();
     115             :     }
     116             : 
     117           8 : }
     118             : 
     119           3 : void LwpPageLayout::Parse(IXFStream* pOutputStream)
     120             : {
     121             :     //Only parse this layout
     122           3 :     LwpObject* pStory = m_Content.obj();
     123           3 :     if(pStory)
     124             :     {
     125           3 :         pStory->SetFoundry(m_pFoundry);
     126           3 :         pStory->Parse(pOutputStream);   //Do not parse the next story
     127             :     }
     128           3 : }
     129             : 
     130             : /**
     131             : * @descr:   set page margins
     132             : *
     133             : */
     134           8 : void LwpPageLayout::ParseMargins(XFPageMaster* pm1)
     135             : {
     136           8 :     double fLeft    = GetMarginsValue(MARGIN_LEFT);
     137           8 :     double fRight   = GetMarginsValue(MARGIN_RIGHT);
     138           8 :     double fTop = GetMarginsValue(MARGIN_TOP);
     139           8 :     double fBottom  = GetMarginsValue(MARGIN_BOTTOM);
     140             : 
     141           8 :     pm1->SetMargins( fLeft, fRight, fTop, fBottom );
     142             : 
     143           8 : }
     144             : 
     145             : /**
     146             : * @descr:   set page height and width
     147             : *
     148             : */
     149           8 : void LwpPageLayout::ParseGeometry(XFPageMaster* pm1)
     150             : {
     151             :     /*
     152             :     LwpLayoutGeometry* pLayoutGeo = GetGeometry();
     153             :     if(pLayoutGeo)
     154             :     {
     155             :         pm1->SetPageHeight( GetGeometryHeight() );
     156             :         pm1->SetPageWidth( GetGeometryWidth() );
     157             :     }
     158             :     */
     159           8 :     double fWidth =0;
     160           8 :     double fHeight = 0;
     161           8 :     GetWidthAndHeight(fWidth, fHeight);
     162           8 :     pm1->SetPageWidth( fWidth );
     163           8 :     pm1->SetPageHeight( fHeight );
     164           8 : }
     165             : 
     166             : /**
     167             : * @descr:   set page watermark
     168             : *
     169             : */
     170           8 : void LwpPageLayout::ParseWaterMark(XFPageMaster *pm1)
     171             : {
     172           8 :     XFBGImage* pXFBGImage = GetXFBGImage();
     173           8 :     if(pXFBGImage)
     174             :     {
     175           0 :         pm1->SetBackImage(pXFBGImage);
     176             :     }
     177           8 : }
     178             : 
     179             : /**
     180             : * @descr:   set page columns
     181             : *
     182             : */
     183           8 : void LwpPageLayout::ParseColumns(XFPageMaster * pm1)
     184             : {
     185           8 :     XFColumns* pColumns = GetXFColumns();
     186           8 :     if(pColumns)
     187             :     {
     188           0 :         pm1->SetColumns(pColumns);
     189             :     }
     190           8 : }
     191             : 
     192             : /**
     193             : * @descr:   set page borders
     194             : *
     195             : */
     196           8 : void LwpPageLayout::ParseBorders(XFPageMaster *pm1)
     197             : {
     198           8 :     XFBorders* pBordres = GetXFBorders();
     199           8 :     if(pBordres)
     200             :     {
     201           0 :         pm1->SetBorders(pBordres);
     202             :     }
     203           8 : }
     204             : 
     205             : 
     206             : /**
     207             : * @descr:   set page shadow
     208             : *
     209             : */
     210           8 : void LwpPageLayout::ParseShadow(XFPageMaster *pm1)
     211             : {
     212           8 :     XFShadow* pXFShadow = GetXFShadow();
     213           8 :     if(pXFShadow)
     214             :     {
     215           0 :         pm1->SetShadow(pXFShadow);
     216             :     }
     217           8 : }
     218             : 
     219             : /**
     220             : * @descr:   set page back pattern
     221             : *
     222             : */
     223           0 : void LwpPageLayout::ParsePatternFill(XFPageMaster* pm1)
     224             : {
     225           0 :     XFBGImage* pXFBGImage = this->GetFillPattern();
     226           0 :     if (pXFBGImage)
     227             :     {
     228           0 :         pm1->SetBackImage(pXFBGImage);
     229             :     }
     230           0 : }
     231             : /**
     232             : * @descr:   set page background
     233             : *
     234             : */
     235           8 : void LwpPageLayout::ParseBackGround(XFPageMaster* pm1)
     236             : {
     237           8 :     if (this->IsPatternFill())
     238             :     {
     239           0 :         ParsePatternFill(pm1);
     240             :     }
     241             :     else
     242             :     {
     243           8 :         ParseBackColor(pm1);
     244             :     }
     245           8 : }
     246             : 
     247             : /**
     248             : * @descr:   set page back color
     249             : *
     250             : */
     251           8 : void LwpPageLayout::ParseBackColor(XFPageMaster* pm1)
     252             : {
     253           8 :     LwpColor* pColor = GetBackColor();
     254           8 :     if(pColor)
     255             :     {
     256           8 :         pm1->SetBackColor(XFColor(pColor->To24Color()));
     257             :     }
     258           8 : }
     259             : 
     260             : /**
     261             : * @descr:   set page footnote separator information
     262             : *
     263             : */
     264           8 : void LwpPageLayout::ParseFootNoteSeparator(XFPageMaster * pm1)
     265             : {
     266             :     //Get the footnoteoptions for the root document
     267           8 :     LwpDocument* pDocument = m_pFoundry->GetDocument();
     268           8 :     if(pDocument)
     269             :     {
     270           8 :         LwpObjectID* pFontnodeId = pDocument->GetValidFootnoteOpts();
     271             : 
     272           8 :         LwpFootnoteOptions* pFootnoteOpts = pFontnodeId ? dynamic_cast<LwpFootnoteOptions*>(pFontnodeId->obj()) : NULL;
     273           8 :         if(pFootnoteOpts)
     274             :         {
     275           8 :             LwpFootnoteSeparatorOptions* pFootnoteSep = pFootnoteOpts->GetFootnoteSeparator();
     276             :             //set length
     277           8 :             sal_uInt32 nLengthPercent = 100;
     278           8 :             double fWidth = 0;
     279           8 :             if(pFootnoteSep->HasSeparator())
     280             :             {
     281           8 :                 fWidth = pFootnoteSep->GetTopBorderWidth();
     282             :             }
     283           8 :             if(pFootnoteSep->HasCustomLength())
     284             :             {
     285           0 :                 nLengthPercent =  static_cast<sal_uInt32>(100*LwpTools::ConvertFromUnitsToMetric(pFootnoteSep->GetLength())/GetMarginWidth());
     286           0 :                 if(nLengthPercent > 100)
     287           0 :                     nLengthPercent = 100;
     288             :             }
     289           8 :             double fAbove = LwpTools::ConvertFromUnitsToMetric(pFootnoteSep->GetAbove());
     290           8 :             double fBelow = LwpTools::ConvertFromUnitsToMetric(pFootnoteSep->GetBelow());
     291           8 :             LwpColor aColor = pFootnoteSep->GetTopBorderColor();
     292           8 :             enumXFAlignType eAlignType = enumXFAlignStart;
     293           8 :             if(pFootnoteSep->GetIndent() > 0)
     294             :             {
     295             :                 //SODC don't support indent
     296           0 :                 sal_uInt32 nIndentPercent =  static_cast<sal_uInt32>(100*LwpTools::ConvertFromUnitsToMetric(pFootnoteSep->GetIndent())/GetMarginWidth());
     297           0 :                 if(nIndentPercent + nLengthPercent >= 100)
     298           0 :                     eAlignType = enumXFAlignEnd;
     299             :             }
     300           8 :             if(aColor.IsValidColor())
     301             :             {
     302           8 :                 XFColor aXFColor(aColor.To24Color());
     303           8 :                 pm1->SetFootNoteSeparator(eAlignType,fWidth, nLengthPercent, fAbove, fBelow, aXFColor);
     304           8 :             }
     305             :         }
     306             :     }
     307           8 : }
     308             : 
     309             : /**
     310             : * @descr:   Register master page and page master style
     311             : *
     312             : */
     313           8 : void LwpPageLayout::RegisterStyle()
     314             : {
     315           8 :     XFPageMaster* pm1 = new XFPageMaster();
     316           8 :     m_pXFPageMaster = pm1;
     317             : 
     318           8 :     ParseGeometry( pm1 );
     319             :     //Does not process LayoutScale, for watermark is not supported in SODC.
     320           8 :     ParseWaterMark( pm1);
     321           8 :     ParseMargins( pm1);
     322           8 :     ParseColumns(pm1);
     323           8 :     ParseBorders(pm1);
     324           8 :     ParseShadow(pm1);
     325             : //  ParseBackColor(pm1);
     326           8 :     ParseBackGround(pm1);
     327           8 :     ParseFootNoteSeparator(pm1);
     328           8 :     pm1->SetTextDir(GetTextDirection());
     329             : 
     330           8 :     LwpUseWhen* pUseWhen = GetUseWhen();
     331           8 :     if(IsComplex() ||( pUseWhen && pUseWhen->IsUseOnAllOddPages()))
     332             :     {
     333           0 :         pm1->SetPageUsage(enumXFPageUsageMirror);
     334             :     }
     335             : 
     336             :     //Add the page master to stylemanager
     337           8 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     338           8 :     m_pXFPageMaster = pm1 = (XFPageMaster*)pXFStyleManager->AddStyle(pm1);
     339           8 :     OUString pmname = pm1->GetStyleName();
     340             : 
     341             :     //Add master page
     342           8 :     XFMasterPage* mp1 = new XFMasterPage();
     343           8 :     mp1->SetStyleName(GetName()->str());
     344           8 :     mp1->SetPageMaster(pmname);
     345           8 :     mp1 = (XFMasterPage*)pXFStyleManager->AddStyle(mp1);
     346           8 :     m_StyleName = mp1->GetStyleName();
     347             : 
     348             :     //Set footer style
     349           8 :     LwpFooterLayout* pLayoutFooter = GetFooterLayout();
     350           8 :     if(pLayoutFooter)
     351             :     {
     352           8 :         pLayoutFooter->SetFoundry(m_pFoundry);
     353           8 :         pLayoutFooter->RegisterStyle(pm1);
     354           8 :         pLayoutFooter->RegisterStyle(mp1);
     355             :     }
     356             : 
     357             :     //Set header style
     358           8 :     LwpHeaderLayout* pLayoutHeader = GetHeaderLayout();
     359           8 :     if(pLayoutHeader)
     360             :     {
     361           8 :         pLayoutHeader->SetFoundry(m_pFoundry);
     362           8 :         pLayoutHeader->RegisterStyle(pm1);
     363           8 :         pLayoutHeader->RegisterStyle(mp1);
     364             :     }
     365             :     //register child layout style for mirror page and frame
     366           8 :     RegisterChildStyle();
     367           8 : }
     368             : 
     369             : /**
     370             : * @descr:   Register master page for endnote which name is "endnote"
     371             : * @return:  Return the master page name.
     372             : */
     373           0 : OUString LwpPageLayout::RegisterEndnoteStyle()
     374             : {
     375           0 :     XFPageMaster* pm1 = new XFPageMaster();
     376           0 :     m_pXFPageMaster = pm1;
     377             : 
     378           0 :     ParseGeometry( pm1 );
     379           0 :     ParseWaterMark( pm1);
     380           0 :     ParseMargins( pm1);
     381           0 :     ParseColumns(pm1);
     382           0 :     ParseBorders(pm1);
     383           0 :     ParseShadow(pm1);
     384             : //  ParseBackColor(pm1);
     385           0 :     ParseBackGround(pm1);
     386             :     //ParseFootNoteSeparator(pm1);
     387           0 :     pm1->SetTextDir(GetTextDirection());
     388             : 
     389           0 :     LwpUseWhen* pUseWhen = GetUseWhen();
     390           0 :     if(IsComplex() ||( pUseWhen && pUseWhen->IsUseOnAllOddPages()))
     391             :     {
     392           0 :         pm1->SetPageUsage(enumXFPageUsageMirror);
     393             :     }
     394             : 
     395             :     //Add the page master to stylemanager
     396           0 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     397           0 :     m_pXFPageMaster = pm1 = (XFPageMaster*)pXFStyleManager->AddStyle(pm1);
     398           0 :     OUString pmname = pm1->GetStyleName();
     399             : 
     400             :     //Add master page
     401           0 :     XFMasterPage* mp1 = new XFMasterPage();
     402           0 :     mp1->SetStyleName(A2OUSTR("Endnote"));
     403           0 :     mp1->SetPageMaster(pmname);
     404             : 
     405             :     //Set footer style
     406           0 :     LwpFooterLayout* pLayoutFooter = GetFooterLayout();
     407           0 :     if(pLayoutFooter)
     408             :     {
     409           0 :         pLayoutFooter->SetFoundry(m_pFoundry);
     410           0 :         pLayoutFooter->RegisterStyle(pm1);
     411           0 :         pLayoutFooter->RegisterStyle(mp1);
     412             :     }
     413             : 
     414             :     //Set header style
     415           0 :     LwpHeaderLayout* pLayoutHeader = GetHeaderLayout();
     416           0 :     if(pLayoutHeader)
     417             :     {
     418           0 :         pLayoutHeader->SetFoundry(m_pFoundry);
     419           0 :         pLayoutHeader->RegisterStyle(pm1);
     420           0 :         pLayoutHeader->RegisterStyle(mp1);
     421             :     }
     422             : 
     423           0 :     return pXFStyleManager->AddStyle(mp1)->GetStyleName();
     424             : }
     425             : /**
     426             : * @descr:   Whether current page layout has columns
     427             : *
     428             : */
     429           4 : sal_Bool LwpPageLayout::HasColumns()
     430             : {
     431           4 :     return GetNumCols() > 1 ? sal_True : sal_False;
     432             : }
     433             : 
     434             : /**
     435             : * @descr:   Whether has filler page text in current page layout
     436             : *
     437             : */
     438           0 : sal_Bool LwpPageLayout::HasFillerPageText(LwpFoundry* pFoundry)
     439             : {
     440           0 :     if(!pFoundry) return sal_False;
     441             : 
     442           0 :     sal_Bool bFillerPage = sal_False;
     443           0 :     LwpLayout::UseWhenType eWhenType = GetUseWhenType();
     444           0 :     if(eWhenType==LwpLayout::StartOnOddPage||eWhenType==LwpLayout::StartOnEvenPage)
     445             :     {
     446             :         //get pagenumber
     447           0 :         sal_uInt16 nPageNumber = 0;
     448             : 
     449             :         //get the page number that current page layout inserted
     450           0 :         nPageNumber = GetPageNumber(FIRST_LAYOUTPAGENO)-1;
     451             : 
     452           0 :         if(nPageNumber>0)
     453             :         {
     454           0 :             if((eWhenType==LwpLayout::StartOnOddPage)&&(LwpTools::IsOddNumber(nPageNumber)))
     455             :             {
     456           0 :                 bFillerPage = sal_True;
     457             :             }
     458           0 :             else if((eWhenType==LwpLayout::StartOnEvenPage)&&(LwpTools::IsEvenNumber(nPageNumber)))
     459             :             {
     460           0 :                 bFillerPage = sal_True;
     461             :             }
     462             :             else
     463             :             {
     464           0 :                 bFillerPage = sal_False;
     465             :             }
     466             :         }
     467             :     }
     468             : 
     469           0 :     return bFillerPage;
     470             : }
     471             : 
     472             : /**
     473             : * @descr:   Parse filler page text
     474             : *
     475             : */
     476           0 : void LwpPageLayout::ConvertFillerPageText(XFContentContainer* pCont)
     477             : {
     478           0 :     if(HasFillerPageText(m_pFoundry))
     479             :     {
     480             :         //get filerpage story from division info
     481           0 :         LwpDocument* pDoc = m_pFoundry->GetDocument();
     482           0 :         LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pDoc->GetDivInfoID()->obj());
     483           0 :         LwpStory* pStory = dynamic_cast<LwpStory*>(pDivInfo->GetFillerPageTextID()->obj());
     484             : 
     485             :         //parse fillerpage story
     486           0 :         if(pStory)
     487             :         {
     488           0 :             pStory->XFConvert(pCont);
     489             :         }
     490             :     }
     491           0 : }
     492             : /**
     493             : * @descr:   Clear columns style in page layout
     494             : *
     495             : */
     496           0 : void LwpPageLayout::ResetXFColumns()
     497             : {
     498           0 :     if(m_pXFPageMaster)
     499             :     {
     500           0 :         m_pXFPageMaster->SetColumns(NULL);
     501             :     }
     502           0 : }
     503             : 
     504           8 : LwpHeaderLayout* LwpPageLayout::GetHeaderLayout()
     505             : {
     506           8 :     LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
     507          24 :     while(pLay)
     508             :     {
     509          16 :         if( pLay->GetLayoutType() == LWP_HEADER_LAYOUT )
     510           8 :             return ( static_cast<LwpHeaderLayout*> (pLay) );
     511           8 :         pLay = dynamic_cast<LwpVirtualLayout*> (pLay->GetNext()->obj());
     512             :     }
     513           0 :     return NULL;
     514             : }
     515             : 
     516           8 : LwpFooterLayout* LwpPageLayout::GetFooterLayout()
     517             : {
     518           8 :     LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
     519          16 :     while(pLay)
     520             :     {
     521           8 :         if( pLay->GetLayoutType() == LWP_FOOTER_LAYOUT )
     522           8 :             return ( static_cast<LwpFooterLayout*> (pLay) );
     523           0 :         pLay = dynamic_cast<LwpVirtualLayout*> (pLay->GetNext()->obj());
     524             :     }
     525           0 :     return NULL;
     526             : }
     527             : 
     528             : /**
     529             : * @descr:   Get the odd layout if current page layout is mirror page
     530             : *
     531             : */
     532           4 : LwpPageLayout* LwpPageLayout::GetOddChildLayout()
     533             : {
     534           4 :     if(IsComplex())
     535             :     {
     536           0 :         LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
     537           0 :         while(pLay)
     538             :         {
     539           0 :             if( pLay->GetLayoutType() == LWP_PAGE_LAYOUT )
     540             :             {
     541           0 :                 LwpPageLayout* pPageLayout = static_cast<LwpPageLayout*> (pLay);
     542           0 :                 LwpUseWhen* pUseWhen = pPageLayout->GetUseWhen();
     543           0 :                 if(pUseWhen && pUseWhen->IsUseOnAllOddPages())
     544             :                 {
     545           0 :                     return pPageLayout;
     546             :                 }
     547             :             }
     548           0 :             pLay = dynamic_cast<LwpVirtualLayout*> (pLay->GetNext()->obj());
     549             :         }
     550             :     }
     551           4 :     return NULL;
     552             : }
     553             : 
     554             : /**
     555             : * @descr:   Get margin width of page
     556             : *
     557             : */
     558           0 : double LwpPageLayout::GetMarginWidth()
     559             : {
     560           0 :     double fPagewidth = GetGeometryWidth();
     561           0 :     double fLeftMargin = GetMarginsValue(MARGIN_LEFT);
     562           0 :     double fRightMargin = GetMarginsValue(MARGIN_RIGHT);
     563             : 
     564           0 :     return fPagewidth - (fLeftMargin + fRightMargin);
     565             : }
     566             : 
     567             : /**
     568             :  * @descr:  Get the pagenumber
     569             :  * @param:  if  nLayoutNumber =FIRST_LAYOUTPAGENO,  return the first page number  that current page layout covers
     570             :                               =LAST_LAYOUTPAGENO, return the last page number that current page layout covers
     571             :                                else, return the specified page number that current page layout covers
     572             :  * @param:
     573             :  * @return:  if reture value >=0, success to find the page number, or fail.
     574             : */
     575           0 : sal_Int32 LwpPageLayout::GetPageNumber(sal_uInt16 nLayoutNumber)
     576             : {
     577           0 :     sal_Int16 nPageNumber = -1;
     578           0 :     LwpFoundry* pFoundry = this->GetFoundry();
     579           0 :     LwpDocument* pDoc = pFoundry->GetDocument();
     580           0 :     LwpDLVListHeadTailHolder* pHeadTail = dynamic_cast<LwpDLVListHeadTailHolder*>(pDoc->GetPageHintsID()->obj());
     581           0 :     if(!pHeadTail) return nPageNumber;
     582             : 
     583             :     //get first pagehint
     584           0 :     LwpPageHint* pPageHint = dynamic_cast<LwpPageHint*>(pHeadTail->GetHead()->obj());
     585           0 :     while(pPageHint)
     586             :     {
     587           0 :         if(*(this->GetObjectID()) == *(pPageHint->GetPageLayoutID()))
     588             :         {
     589           0 :             sal_uInt16 nNumber = pPageHint->GetPageNumber();
     590           0 :             if(nLayoutNumber==FIRST_LAYOUTPAGENO && pPageHint->GetLayoutPageNumber()==1)
     591             :             {
     592             :                 //get the first page number
     593           0 :                 nPageNumber = nNumber;
     594           0 :                 break;
     595             :             }
     596           0 :             else if( nLayoutNumber ==LAST_LAYOUTPAGENO && nNumber >nPageNumber )
     597             :             {
     598             :                 //get the last page number
     599           0 :                 nPageNumber = nNumber;
     600           0 :                 if(pPageHint->GetNext()->IsNull())
     601             :                 {
     602             :                     //if is last page number of entire document, reture directly
     603           0 :                     return nPageNumber + pDoc->GetNumberOfPagesBefore();
     604             :                 }
     605             :             }
     606           0 :             else if(nLayoutNumber > 0 && pPageHint->GetLayoutPageNumber() == nLayoutNumber)
     607             :             {
     608             :                 //get specified page number
     609           0 :                 nPageNumber = nNumber;
     610           0 :                 break;
     611             :             }
     612             : 
     613             :         }
     614           0 :         pPageHint = dynamic_cast<LwpPageHint*>(pPageHint->GetNext()->obj());
     615             :     }
     616           0 :     if(nPageNumber>=0)
     617             :     {
     618           0 :         return nPageNumber + 1 + pDoc->GetNumberOfPagesBefore();
     619             :     }
     620           0 :     return -1;
     621             : }
     622             : 
     623             : /**
     624             : * @descr:   Get page width and height
     625             : *
     626             : */
     627          29 : void LwpPageLayout::GetWidthAndHeight(double& fWidth, double& fHeight)
     628             : {
     629             :     //use customized size
     630          29 :     LwpLayoutGeometry* pLayoutGeo = GetGeometry();
     631          29 :     if(pLayoutGeo)
     632             :     {
     633          29 :         fWidth = GetGeometryWidth();
     634          29 :         fHeight = GetGeometryHeight();
     635             :     }
     636             : 
     637          29 :     if(GetUsePrinterSettings())
     638             :     {
     639             :         //replaced by printer paper size
     640          27 :         Printer aPrinter;
     641          27 :         sal_Bool bScreen = aPrinter.IsDisplayPrinter();
     642          27 :         if (!bScreen)//Printer available
     643             :         {
     644           0 :             Size aPaperSize = aPrinter.GetPaperSize();
     645           0 :             aPaperSize = aPrinter.PixelToLogic( aPaperSize, MapMode( MAP_10TH_MM ) );
     646           0 :             fWidth = static_cast<double>(aPaperSize.Width())/100;   //cm unit
     647           0 :             fHeight = static_cast<double>(aPaperSize.Height())/100;
     648          27 :         }
     649             :     }
     650             : 
     651             :     //Follow the former design of Lotus WordPro filter, some default will be given:
     652             :     //Page Width: 8.5 Inch -> 21.59 cm
     653             :     //Page Height: 11 Inch -> 27.94 cm
     654          29 :     if (fWidth < 4.39)
     655           0 :         fWidth = 21.59;
     656          29 :     if (fHeight < 4.49)
     657           0 :         fHeight = 27.94;
     658             :     //End of modification, by ZF
     659          29 : }
     660             : 
     661             : /**
     662             : * @descr:   Get page width
     663             : *
     664             : */
     665          21 : double LwpPageLayout::GetWidth()
     666             : {
     667          21 :     double fWidth =0, fHeight = 0;
     668          21 :     GetWidthAndHeight(fWidth, fHeight);
     669          21 :     return fWidth;
     670             : }
     671             : 
     672             : /**
     673             : * @descr:   Get page height
     674             : *
     675             : */
     676           0 : double LwpPageLayout::GetHeight()
     677             : {
     678           0 :     double fWidth =0, fHeight = 0;
     679           0 :     GetWidthAndHeight(fWidth, fHeight);
     680           0 :     return fHeight;
     681             : }
     682             : /**
     683             : * @descr:  Compare the position of layout. If the poistion of this layout is earlier than other layout,return ture, or return false
     684             : *
     685             : */
     686           0 : sal_Bool LwpPageLayout::operator<(LwpPageLayout& Other)
     687             : {
     688           0 :     LwpPara* pThisPara = GetPagePosition();
     689           0 :     LwpPara* pOtherPara = Other.GetPagePosition();
     690           0 :     if(pThisPara && pOtherPara)
     691             :     {
     692           0 :         if(pThisPara == pOtherPara)
     693             :         {
     694             :             //If the two layouts in the same para, compare which layout is earlied according to frib order
     695           0 :             return pThisPara->ComparePagePosition(this, &Other);
     696             :         }
     697             :         else
     698             :         {
     699           0 :             return *pThisPara < *pOtherPara;
     700             :         }
     701             :     }
     702             : 
     703           0 :     if(!pThisPara)
     704           0 :         return sal_True;
     705             : 
     706           0 :     return sal_False;
     707             : }
     708             : 
     709             : /**
     710             : * @descr:  Get the position of pagelayout
     711             : *
     712             : */
     713           0 : LwpPara* LwpPageLayout::GetPagePosition()
     714             : {
     715           0 :     LwpPara* pPara = dynamic_cast<LwpPara*>(GetPosition()->obj());
     716           0 :     if(pPara)
     717           0 :         return pPara;
     718             :     //Get the position from its related section
     719           0 :     LwpSection* pSection = NULL;
     720           0 :     LwpFoundry* pFoundry = GetFoundry();
     721           0 :     if(pFoundry)
     722             :     {
     723           0 :         while( (pSection = pFoundry->EnumSections(pSection)) )
     724             :         {
     725           0 :             if(pSection->GetPageLayout() == this)
     726           0 :                 return dynamic_cast<LwpPara*>(pSection->GetPosition()->obj());
     727             :         }
     728             :     }
     729             : 
     730           0 :     return NULL;
     731             : }
     732          12 : LwpHeaderLayout::LwpHeaderLayout( LwpObjectHeader &objHdr, LwpSvStream* pStrm )
     733          12 :     : LwpPlacableLayout(objHdr, pStrm)
     734             : {
     735          12 : }
     736             : 
     737          24 : LwpHeaderLayout::~LwpHeaderLayout()
     738             : {
     739          24 : }
     740             : 
     741          12 : void LwpHeaderLayout::Read()
     742             : {
     743          12 :     LwpPlacableLayout::Read();
     744             : 
     745          12 :     if(LwpFileHeader::m_nFileRevision >= 0x000E)
     746          12 :         m_nBorderOffset = m_pObjStrm->QuickReadInt32();
     747             :     else
     748           0 :         m_nBorderOffset = 0;
     749          12 :     m_pObjStrm->SkipExtra();
     750          12 : }
     751             : 
     752             : 
     753           8 : void LwpHeaderLayout::RegisterStyle(XFPageMaster* pm1)
     754             : {
     755           8 :     XFHeaderStyle* pHeaderStyle = new XFHeaderStyle();
     756             : 
     757             :     //Modify page top margin
     758             :     //page top maring: from top of header to the top edge
     759           8 :     double top = GetMarginsValue(MARGIN_TOP);
     760           8 :     pm1->SetMargins(-1, -1, top, -1);
     761             : 
     762           8 :     ParseMargins(pHeaderStyle);
     763           8 :     ParseBorder(pHeaderStyle);
     764           8 :     ParseShadow(pHeaderStyle);
     765             : //  ParseBackColor(pHeaderStyle);
     766           8 :     ParseBackGround(pHeaderStyle);
     767             : 
     768           8 :     ParseWaterMark(pHeaderStyle);
     769             :     //End by
     770             : 
     771           8 :     pm1->SetHeaderStyle(pHeaderStyle);
     772           8 : }
     773             : 
     774           8 : void LwpHeaderLayout::ParseMargins(XFHeaderStyle* ph1)
     775             : {
     776             :     //Set height: from top of header to top of body, including the spacing between header and body
     777           8 :     double height = GetGeometryHeight()- GetMarginsValue(MARGIN_TOP);
     778           8 :     if( IsAutoGrowDown() )
     779             :     {
     780           0 :         ph1->SetMinHeight(height);
     781             :     }
     782             :     else
     783             :     {
     784           8 :         ph1->SetHeight(height);
     785             :     }
     786             : 
     787             :     //Set left,right,bottom margins
     788           8 :     LwpMiddleLayout* parent = dynamic_cast<LwpMiddleLayout*> (GetParent()->obj());
     789             :     //left margin in SODC: the space from the left edge of body to the left edge of header
     790           8 :     double left = GetMarginsValue(MARGIN_LEFT) - (parent ? parent->GetMarginsValue(MARGIN_LEFT) : 0);
     791           8 :     if(left<=0) //The left margin in SODC can not be minus value
     792             :     {
     793           8 :         left = -1;
     794             :     }
     795             :     //left margin in SODC: the space from the right edge of header to the right edge of body
     796           8 :     double right = GetMarginsValue(MARGIN_RIGHT) - (parent ? parent->GetMarginsValue(MARGIN_RIGHT) : 0);
     797           8 :     if(right<=0)//The right margin in SODC can not be minus value
     798             :     {
     799           8 :         right = -1;
     800             :     }
     801           8 :     ph1->SetMargins( left, right, GetMarginsValue(MARGIN_BOTTOM));
     802             : 
     803             :     //Word Pro has no dynamic spacing, should be set to false
     804           8 :     ph1->SetDynamicSpace(sal_False);
     805           8 : }
     806             : 
     807           8 : void LwpHeaderLayout::ParseBorder(XFHeaderStyle* pHeaderStyle)
     808             : {
     809           8 :     XFBorders* pBordres = GetXFBorders();
     810           8 :     if(pBordres)
     811             :     {
     812           0 :         pHeaderStyle->SetBorders(pBordres);
     813             :     }
     814           8 : }
     815             : 
     816           8 : void LwpHeaderLayout::ParseShadow(XFHeaderStyle* pHeaderStyle)
     817             : {
     818           8 :     XFShadow* pXFShadow = GetXFShadow();
     819           8 :     if(pXFShadow)
     820             :     {
     821           0 :         pHeaderStyle->SetShadow(pXFShadow);
     822             :     }
     823           8 : }
     824             : 
     825             : /**
     826             : * @descr:   set header back pattern
     827             : *
     828             : */
     829           0 : void LwpHeaderLayout::ParsePatternFill(XFHeaderStyle* pHeaderStyle)
     830             : {
     831           0 :     XFBGImage* pXFBGImage = this->GetFillPattern();
     832           0 :     if (pXFBGImage)
     833             :     {
     834           0 :         pHeaderStyle->SetBackImage(pXFBGImage);
     835             :     }
     836           0 : }
     837             : /**
     838             : * @descr:   set header background
     839             : *
     840             : */
     841           8 : void LwpHeaderLayout::ParseBackGround(XFHeaderStyle* pHeaderStyle)
     842             : {
     843           8 :     if (this->IsPatternFill())
     844             :     {
     845           0 :         ParsePatternFill(pHeaderStyle);
     846             :     }
     847             :     else
     848             :     {
     849           8 :         ParseBackColor(pHeaderStyle);
     850             :     }
     851           8 : }
     852             : 
     853           8 : void LwpHeaderLayout::ParseBackColor(XFHeaderStyle* pHeaderStyle)
     854             : {
     855           8 :     LwpColor* pColor = GetBackColor();
     856           8 :     if(pColor)
     857             :     {
     858           0 :         pHeaderStyle->SetBackColor(XFColor(pColor->To24Color()));
     859             :     }
     860           8 : }
     861             : 
     862             : 
     863           8 : void LwpHeaderLayout::ParseWaterMark(XFHeaderStyle * pHeaderStyle)
     864             : {
     865           8 :     XFBGImage* pXFBGImage = GetXFBGImage();
     866           8 :     if(pXFBGImage)
     867             :     {
     868           0 :         pHeaderStyle->SetBackImage(pXFBGImage);
     869             :     }
     870           8 : }
     871             : //End by
     872             : 
     873           8 : void LwpHeaderLayout::RegisterStyle(XFMasterPage* mp1)
     874             : {
     875           8 :     XFHeader* pHeader = new XFHeader();
     876           8 :     LwpObject* pStory = m_Content.obj();
     877           8 :     if(pStory)
     878             :     {
     879           8 :         LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
     880           8 :         LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
     881           8 :         pChangeMgr->SetHeadFootFribMap(sal_True);
     882             : 
     883             :         //Call the RegisterStyle first to register the styles in header paras, and then XFConvert()
     884           8 :         pStory->SetFoundry(m_pFoundry);
     885           8 :         pStory->RegisterStyle();
     886             :         //, 06/27/2005
     887             :         //register child layout style for framelayout,
     888           8 :         RegisterChildStyle();
     889             :         //End
     890           8 :         pChangeMgr->SetHeadFootChange(pHeader);
     891           8 :         pStory->XFConvert(pHeader);
     892             : 
     893           8 :         pChangeMgr->SetHeadFootFribMap(sal_False);
     894             :     }
     895           8 :     mp1->SetHeader(pHeader);
     896           8 : }
     897             : 
     898          12 : LwpFooterLayout::LwpFooterLayout( LwpObjectHeader &objHdr, LwpSvStream* pStrm )
     899          12 :     : LwpPlacableLayout( objHdr, pStrm )
     900             : {
     901          12 : }
     902             : 
     903          24 : LwpFooterLayout::~LwpFooterLayout()
     904             : {
     905          24 : }
     906             : 
     907          12 : void LwpFooterLayout::Read()
     908             : {
     909          12 :     LwpPlacableLayout::Read();
     910             : 
     911          12 :     if(LwpFileHeader::m_nFileRevision >= 0x000E)
     912          12 :         m_nBorderOffset = m_pObjStrm->QuickReadInt32();
     913             :     else
     914           0 :         m_nBorderOffset = 0;
     915          12 :     m_pObjStrm->SkipExtra();
     916          12 : }
     917             : 
     918           8 : void LwpFooterLayout::RegisterStyle(XFPageMaster* pm1)
     919             : {
     920           8 :     XFFooterStyle* pFooterStyle = new XFFooterStyle();
     921             : 
     922             :     //Modify page bottom margin
     923             :     //page bottom maring: from bottom of footer to the bottom edge
     924           8 :     double bottom = GetMarginsValue(MARGIN_BOTTOM);
     925           8 :     pm1->SetMargins(-1, -1, -1, bottom);
     926             : 
     927           8 :     ParseMargins(pFooterStyle);
     928           8 :     ParseBorder(pFooterStyle);
     929           8 :     ParseShadow(pFooterStyle);
     930           8 :     ParseBackGround(pFooterStyle);
     931             : //  ParseBackColor(pFooterStyle);
     932             : 
     933           8 :     ParseWaterMark(pFooterStyle);
     934             :     //End by
     935             : 
     936           8 :     pm1->SetFooterStyle(pFooterStyle);
     937           8 : }
     938             : 
     939           8 : void LwpFooterLayout::ParseMargins(XFFooterStyle* pFooterStyle)
     940             : {
     941             : 
     942             :     //Set height: from top of header to top of body, including the spacing between header and body
     943           8 :     double height = GetGeometryHeight() - GetMarginsValue(MARGIN_BOTTOM);
     944           8 :     if( IsAutoGrowUp() )
     945             :     {
     946           0 :         pFooterStyle->SetMinHeight(height);
     947             :     }
     948             :     else
     949             :     {
     950           8 :         pFooterStyle->SetHeight(height);
     951             :     }
     952             : 
     953             :     //Set left,right,top margins
     954           8 :     LwpMiddleLayout* parent = dynamic_cast<LwpMiddleLayout*> (GetParent()->obj());
     955           8 :     double left = GetMarginsValue(MARGIN_LEFT) - (parent ? parent->GetMarginsValue(MARGIN_LEFT) : 0);
     956           8 :     if(left<=0) //The left margin in SODC can not be minus value
     957             :     {
     958           8 :         left = -1;
     959             :     }
     960           8 :     double right = GetMarginsValue(MARGIN_RIGHT) - (parent ? parent->GetMarginsValue(MARGIN_RIGHT) : 0);
     961           8 :     if(right<=0)//The left margin in SODC can not be minus value
     962             :     {
     963           8 :         right = -1;
     964             :     }
     965           8 :     pFooterStyle->SetMargins( left, right, GetMarginsValue(MARGIN_TOP));
     966             : 
     967             :     //Word Pro has no dynamic spacing, should be set to false
     968           8 :     pFooterStyle->SetDynamicSpace(sal_False);
     969           8 : }
     970             : 
     971           8 : void LwpFooterLayout::ParseBorder(XFFooterStyle* pFooterStyle)
     972             : {
     973           8 :     XFBorders* pBordres = GetXFBorders();
     974           8 :     if(pBordres)
     975             :     {
     976           0 :         pFooterStyle->SetBorders(pBordres);
     977             :     }
     978           8 : }
     979             : 
     980           8 : void LwpFooterLayout::ParseShadow(XFFooterStyle* pFooterStyle)
     981             : {
     982           8 :     XFShadow* pXFShadow = GetXFShadow();
     983           8 :     if(pXFShadow)
     984             :     {
     985           0 :         pFooterStyle->SetShadow(pXFShadow);
     986             :     }
     987           8 : }
     988             : /**
     989             : * @descr:   set footer back pattern
     990             : *
     991             : */
     992           0 : void LwpFooterLayout::ParsePatternFill(XFFooterStyle* pFooterStyle)
     993             : {
     994           0 :     XFBGImage* pXFBGImage = this->GetFillPattern();
     995           0 :     if (pXFBGImage)
     996             :     {
     997           0 :         pFooterStyle->SetBackImage(pXFBGImage);
     998             :     }
     999           0 : }
    1000             : /**
    1001             : * @descr:   set footer background
    1002             : *
    1003             : */
    1004           8 : void LwpFooterLayout::ParseBackGround(XFFooterStyle* pFooterStyle)
    1005             : {
    1006           8 :     if (this->IsPatternFill())
    1007             :     {
    1008           0 :         ParsePatternFill(pFooterStyle);
    1009             :     }
    1010             :     else
    1011             :     {
    1012           8 :         ParseBackColor(pFooterStyle);
    1013             :     }
    1014           8 : }
    1015             : 
    1016           8 : void LwpFooterLayout::ParseBackColor(XFFooterStyle* pFooterStyle)
    1017             : {
    1018           8 :     LwpColor* pColor = GetBackColor();
    1019           8 :     if(pColor)
    1020             :     {
    1021           0 :         pFooterStyle->SetBackColor(XFColor(pColor->To24Color()));
    1022             :     }
    1023           8 : }
    1024             : 
    1025           8 : void LwpFooterLayout::RegisterStyle(XFMasterPage* mp1)
    1026             : {
    1027           8 :     XFFooter* pFooter = new XFFooter();
    1028           8 :     LwpObject* pStory = m_Content.obj(VO_STORY);
    1029             :     //Call the RegisterStyle first to register the styles in footer paras, and then XFConvert()
    1030           8 :     if(pStory)
    1031             :     {
    1032           8 :         LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
    1033           8 :         LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
    1034           8 :         pChangeMgr->SetHeadFootFribMap(sal_True);
    1035             : 
    1036           8 :         pStory->SetFoundry(m_pFoundry);
    1037           8 :         pStory->RegisterStyle();
    1038             :         //, 06/27/2005
    1039             :         //register child layout style for framelayout,
    1040           8 :         RegisterChildStyle();
    1041             :         //End
    1042             : 
    1043           8 :         pChangeMgr->SetHeadFootChange(pFooter);//add by ,7/6
    1044             : 
    1045           8 :         pStory->XFConvert(pFooter);
    1046             : 
    1047           8 :         pChangeMgr->SetHeadFootFribMap(sal_False);
    1048             :     }
    1049           8 :     mp1->SetFooter(pFooter);
    1050           8 : }
    1051             : 
    1052             : 
    1053           8 : void LwpFooterLayout::ParseWaterMark(XFFooterStyle * pFooterStyle)
    1054             : {
    1055           8 :     XFBGImage* pXFBGImage = GetXFBGImage();
    1056           8 :     if(pXFBGImage)
    1057             :     {
    1058           0 :         pFooterStyle->SetBackImage(pXFBGImage);
    1059             :     }
    1060          11 : }
    1061             : //End by
    1062             : 
    1063             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10