LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwppagelayout.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 297 463 64.1 %
Date: 2012-08-25 Functions: 45 57 78.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 123 434 28.3 %

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

Generated by: LCOV version 1.10