1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
10 * Sun Microsystems Inc., October, 2000
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
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.
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.
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,
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.
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.
46 * The Initial Developer of the Original Code is: IBM Corporation
48 * Copyright: 2008 by IBM Corporation
50 * All Rights Reserved.
52 * Contributor(s): _______________________________________
55 ************************************************************************/
56 /*************************************************************************
59 ************************************************************************/
60 #include "lwppagelayout.hxx"
61 #include "lwplaypiece.hxx"
62 #include "lwpfootnote.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"
79 LwpPageLayout::LwpPageLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
80 : LwpLayout(objHdr
, pStrm
)
81 , m_pPrinterBinName(new LwpAtomHolder
)
84 , m_pPaperName(new LwpAtomHolder
)
85 , m_pXFPageMaster(NULL
)
89 LwpPageLayout::~LwpPageLayout()
91 if (m_pPrinterBinName
)
93 delete m_pPrinterBinName
;
100 void LwpPageLayout::Read()
104 if (LwpFileHeader::m_nFileRevision
< 0x000B)
106 // read PreRevBLayout...
109 m_nPrinterBin
= m_pObjStrm
->QuickReaduInt16();
110 m_pPrinterBinName
->Read(m_pObjStrm
);
112 if (LwpFileHeader::m_nFileRevision
>= 0x000B)
113 m_nBdroffset
= m_pObjStrm
->QuickReadInt32();
115 if (m_pObjStrm
->CheckExtra())
117 m_pPaperName
->Read(m_pObjStrm
);
118 m_pObjStrm
->SkipExtra();
123 void LwpPageLayout::Parse(IXFStream
* pOutputStream
)
125 //Only parse this layout
126 rtl::Reference
<LwpObject
> pStory
= m_Content
.obj();
129 pStory
->SetFoundry(m_pFoundry
);
130 pStory
->Parse(pOutputStream
); //Do not parse the next story
135 * @descr: set page margins
138 void LwpPageLayout::ParseMargins(XFPageMaster
* pm1
)
140 double fLeft
= GetMarginsValue(MARGIN_LEFT
);
141 double fRight
= GetMarginsValue(MARGIN_RIGHT
);
142 double fTop
= GetMarginsValue(MARGIN_TOP
);
143 double fBottom
= GetMarginsValue(MARGIN_BOTTOM
);
145 pm1
->SetMargins( fLeft
, fRight
, fTop
, fBottom
);
150 * @descr: set page height and width
153 void LwpPageLayout::ParseGeometry(XFPageMaster
* pm1
)
156 LwpLayoutGeometry* pLayoutGeo = GetGeometry();
159 pm1->SetPageHeight( GetGeometryHeight() );
160 pm1->SetPageWidth( GetGeometryWidth() );
165 GetWidthAndHeight(fWidth
, fHeight
);
166 pm1
->SetPageWidth( fWidth
);
167 pm1
->SetPageHeight( fHeight
);
171 * @descr: set page watermark
174 void LwpPageLayout::ParseWaterMark(XFPageMaster
*pm1
)
176 XFBGImage
* pXFBGImage
= GetXFBGImage();
179 pm1
->SetBackImage(pXFBGImage
);
184 * @descr: set page columns
187 void LwpPageLayout::ParseColumns(XFPageMaster
* pm1
)
189 XFColumns
* pColumns
= GetXFColumns();
192 pm1
->SetColumns(pColumns
);
197 * @descr: set page borders
200 void LwpPageLayout::ParseBorders(XFPageMaster
*pm1
)
202 XFBorders
* pBordres
= GetXFBorders();
205 pm1
->SetBorders(pBordres
);
210 * @descr: set page shadow
213 void LwpPageLayout::ParseShadow(XFPageMaster
*pm1
)
215 XFShadow
* pXFShadow
= GetXFShadow();
218 pm1
->SetShadow(pXFShadow
);
223 * @descr: set page back pattern
226 void LwpPageLayout::ParsePatternFill(XFPageMaster
* pm1
)
228 XFBGImage
* pXFBGImage
= this->GetFillPattern();
231 pm1
->SetBackImage(pXFBGImage
);
235 * @descr: set page background
238 void LwpPageLayout::ParseBackGround(XFPageMaster
* pm1
)
240 if (this->IsPatternFill())
242 ParsePatternFill(pm1
);
251 * @descr: set page back color
254 void LwpPageLayout::ParseBackColor(XFPageMaster
* pm1
)
256 LwpColor
* pColor
= GetBackColor();
259 pm1
->SetBackColor(XFColor(pColor
->To24Color()));
264 * @descr: set page footnote separator information
267 void LwpPageLayout::ParseFootNoteSeparator(XFPageMaster
* pm1
)
269 //Get the footnoteoptions for the root document
270 LwpDocument
* pDocument
= m_pFoundry
->GetDocument();
273 LwpObjectID
* pFontnodeId
= pDocument
->GetValidFootnoteOpts();
275 LwpFootnoteOptions
* pFootnoteOpts
= pFontnodeId
? dynamic_cast<LwpFootnoteOptions
*>(pFontnodeId
->obj().get()) : NULL
;
278 LwpFootnoteSeparatorOptions
& rFootnoteSep
= pFootnoteOpts
->GetFootnoteSeparator();
280 sal_uInt32 nLengthPercent
= 100;
282 if(rFootnoteSep
.HasSeparator())
284 fWidth
= rFootnoteSep
.GetTopBorderWidth();
286 if(rFootnoteSep
.HasCustomLength())
288 nLengthPercent
= static_cast<sal_uInt32
>(100*LwpTools::ConvertFromUnitsToMetric(rFootnoteSep
.GetLength())/GetMarginWidth());
289 if(nLengthPercent
> 100)
290 nLengthPercent
= 100;
292 double fAbove
= LwpTools::ConvertFromUnitsToMetric(rFootnoteSep
.GetAbove());
293 double fBelow
= LwpTools::ConvertFromUnitsToMetric(rFootnoteSep
.GetBelow());
294 LwpColor aColor
= rFootnoteSep
.GetTopBorderColor();
295 enumXFAlignType eAlignType
= enumXFAlignStart
;
296 if(rFootnoteSep
.GetIndent() > 0)
298 //SODC don't support indent
299 sal_uInt32 nIndentPercent
= static_cast<sal_uInt32
>(100*LwpTools::ConvertFromUnitsToMetric(rFootnoteSep
.GetIndent())/GetMarginWidth());
300 if(nIndentPercent
+ nLengthPercent
>= 100)
301 eAlignType
= enumXFAlignEnd
;
303 if(aColor
.IsValidColor())
305 XFColor
aXFColor(aColor
.To24Color());
306 pm1
->SetFootNoteSeparator(eAlignType
,fWidth
, nLengthPercent
, fAbove
, fBelow
, aXFColor
);
313 * @descr: Register master page and page master style
316 void LwpPageLayout::RegisterStyle()
318 XFPageMaster
* pm1
= new XFPageMaster();
319 m_pXFPageMaster
= pm1
;
321 ParseGeometry( pm1
);
322 //Does not process LayoutScale, for watermark is not supported in SODC.
323 ParseWaterMark( pm1
);
328 // ParseBackColor(pm1);
329 ParseBackGround(pm1
);
330 ParseFootNoteSeparator(pm1
);
331 pm1
->SetTextDir(GetTextDirection());
333 LwpUseWhen
* pUseWhen
= GetUseWhen();
334 if(IsComplex() ||( pUseWhen
&& pUseWhen
->IsUseOnAllOddPages()))
336 pm1
->SetPageUsage(enumXFPageUsageMirror
);
339 //Add the page master to stylemanager
340 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
341 m_pXFPageMaster
= pm1
= static_cast<XFPageMaster
*>(pXFStyleManager
->AddStyle(pm1
).m_pStyle
);
342 OUString pmname
= pm1
->GetStyleName();
345 XFMasterPage
* mp1
= new XFMasterPage();
346 mp1
->SetStyleName(GetName().str());
347 mp1
->SetPageMaster(pmname
);
348 mp1
= static_cast<XFMasterPage
*>(pXFStyleManager
->AddStyle(mp1
).m_pStyle
);
349 m_StyleName
= mp1
->GetStyleName();
352 LwpFooterLayout
* pLayoutFooter
= GetFooterLayout();
355 pLayoutFooter
->SetFoundry(m_pFoundry
);
356 pLayoutFooter
->RegisterStyle(pm1
);
357 pLayoutFooter
->RegisterStyle(mp1
);
361 LwpHeaderLayout
* pLayoutHeader
= GetHeaderLayout();
364 pLayoutHeader
->SetFoundry(m_pFoundry
);
365 pLayoutHeader
->RegisterStyle(pm1
);
366 pLayoutHeader
->RegisterStyle(mp1
);
368 //register child layout style for mirror page and frame
369 RegisterChildStyle();
373 * @descr: Register master page for endnote which name is "endnote"
374 * @return: Return the master page name.
376 OUString
LwpPageLayout::RegisterEndnoteStyle()
378 XFPageMaster
* pm1
= new XFPageMaster();
379 m_pXFPageMaster
= pm1
;
381 ParseGeometry( pm1
);
382 ParseWaterMark( pm1
);
387 // ParseBackColor(pm1);
388 ParseBackGround(pm1
);
389 //ParseFootNoteSeparator(pm1);
390 pm1
->SetTextDir(GetTextDirection());
392 LwpUseWhen
* pUseWhen
= GetUseWhen();
393 if(IsComplex() ||( pUseWhen
&& pUseWhen
->IsUseOnAllOddPages()))
395 pm1
->SetPageUsage(enumXFPageUsageMirror
);
398 //Add the page master to stylemanager
399 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
400 m_pXFPageMaster
= pm1
= static_cast<XFPageMaster
*>(pXFStyleManager
->AddStyle(pm1
).m_pStyle
);
401 OUString pmname
= pm1
->GetStyleName();
404 XFMasterPage
* mp1
= new XFMasterPage();
405 mp1
->SetStyleName("Endnote");
406 mp1
->SetPageMaster(pmname
);
409 LwpFooterLayout
* pLayoutFooter
= GetFooterLayout();
412 pLayoutFooter
->SetFoundry(m_pFoundry
);
413 pLayoutFooter
->RegisterStyle(pm1
);
414 pLayoutFooter
->RegisterStyle(mp1
);
418 LwpHeaderLayout
* pLayoutHeader
= GetHeaderLayout();
421 pLayoutHeader
->SetFoundry(m_pFoundry
);
422 pLayoutHeader
->RegisterStyle(pm1
);
423 pLayoutHeader
->RegisterStyle(mp1
);
426 return pXFStyleManager
->AddStyle(mp1
).m_pStyle
->GetStyleName();
429 * @descr: Whether current page layout has columns
432 bool LwpPageLayout::HasColumns()
434 return GetNumCols() > 1;
438 * @descr: Whether has filler page text in current page layout
441 bool LwpPageLayout::HasFillerPageText(LwpFoundry
* pFoundry
)
443 if(!pFoundry
) return false;
445 bool bFillerPage
= false;
446 LwpLayout::UseWhenType eWhenType
= GetUseWhenType();
447 if(eWhenType
==LwpLayout::StartOnOddPage
||eWhenType
==LwpLayout::StartOnEvenPage
)
450 sal_uInt16 nPageNumber
= 0;
452 //get the page number that current page layout inserted
453 nPageNumber
= GetPageNumber(FIRST_LAYOUTPAGENO
)-1;
457 if((eWhenType
==LwpLayout::StartOnOddPage
)&&(LwpTools::IsOddNumber(nPageNumber
)))
461 else if((eWhenType
==LwpLayout::StartOnEvenPage
)&&(LwpTools::IsEvenNumber(nPageNumber
)))
476 * @descr: Parse filler page text
479 void LwpPageLayout::ConvertFillerPageText(XFContentContainer
* pCont
)
481 if(HasFillerPageText(m_pFoundry
))
483 //get filerpage story from division info
484 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
485 LwpDivInfo
* pDivInfo
= dynamic_cast<LwpDivInfo
*>(pDoc
->GetDivInfoID().obj().get());
486 LwpStory
* pStory
= dynamic_cast<LwpStory
*>(pDivInfo
->GetFillerPageTextID().obj().get());
488 //parse fillerpage story
491 pStory
->XFConvert(pCont
);
496 * @descr: Clear columns style in page layout
499 void LwpPageLayout::ResetXFColumns()
503 m_pXFPageMaster
->SetColumns(NULL
);
507 LwpHeaderLayout
* LwpPageLayout::GetHeaderLayout()
509 LwpVirtualLayout
* pLay
= dynamic_cast<LwpVirtualLayout
*>(GetChildHead().obj().get());
512 if( pLay
->GetLayoutType() == LWP_HEADER_LAYOUT
)
513 return ( static_cast<LwpHeaderLayout
*> (pLay
) );
514 pLay
= dynamic_cast<LwpVirtualLayout
*> (pLay
->GetNext().obj().get());
519 LwpFooterLayout
* LwpPageLayout::GetFooterLayout()
521 LwpVirtualLayout
* pLay
= dynamic_cast<LwpVirtualLayout
*>(GetChildHead().obj().get());
524 if( pLay
->GetLayoutType() == LWP_FOOTER_LAYOUT
)
525 return ( static_cast<LwpFooterLayout
*> (pLay
) );
526 pLay
= dynamic_cast<LwpVirtualLayout
*> (pLay
->GetNext().obj().get());
532 * @descr: Get the odd layout if current page layout is mirror page
535 LwpPageLayout
* LwpPageLayout::GetOddChildLayout()
539 LwpVirtualLayout
* pLay
= dynamic_cast<LwpVirtualLayout
*>(GetChildHead().obj().get());
542 if( pLay
->GetLayoutType() == LWP_PAGE_LAYOUT
)
544 LwpPageLayout
* pPageLayout
= static_cast<LwpPageLayout
*> (pLay
);
545 LwpUseWhen
* pUseWhen
= pPageLayout
->GetUseWhen();
546 if(pUseWhen
&& pUseWhen
->IsUseOnAllOddPages())
551 pLay
= dynamic_cast<LwpVirtualLayout
*> (pLay
->GetNext().obj().get());
558 * @descr: Get margin width of page
561 double LwpPageLayout::GetMarginWidth()
563 double fPagewidth
= GetGeometryWidth();
564 double fLeftMargin
= GetMarginsValue(MARGIN_LEFT
);
565 double fRightMargin
= GetMarginsValue(MARGIN_RIGHT
);
567 return fPagewidth
- (fLeftMargin
+ fRightMargin
);
571 * @descr: Get the pagenumber
572 * @param: if nLayoutNumber =FIRST_LAYOUTPAGENO, return the first page number that current page layout covers
573 =LAST_LAYOUTPAGENO, return the last page number that current page layout covers
574 else, return the specified page number that current page layout covers
576 * @return: if reture value >=0, success to find the page number, or fail.
578 sal_Int32
LwpPageLayout::GetPageNumber(sal_uInt16 nLayoutNumber
)
580 sal_Int16 nPageNumber
= -1;
581 LwpFoundry
* pFoundry
= this->GetFoundry();
582 LwpDocument
* pDoc
= pFoundry
->GetDocument();
583 LwpDLVListHeadTailHolder
* pHeadTail
= dynamic_cast<LwpDLVListHeadTailHolder
*>(pDoc
->GetPageHintsID().obj().get());
584 if(!pHeadTail
) return nPageNumber
;
587 LwpPageHint
* pPageHint
= dynamic_cast<LwpPageHint
*>(pHeadTail
->GetHead().obj().get());
590 if(this->GetObjectID() == pPageHint
->GetPageLayoutID())
592 sal_uInt16 nNumber
= pPageHint
->GetPageNumber();
593 if(nLayoutNumber
==FIRST_LAYOUTPAGENO
&& pPageHint
->GetLayoutPageNumber()==1)
595 //get the first page number
596 nPageNumber
= nNumber
;
599 else if( nLayoutNumber
==LAST_LAYOUTPAGENO
&& nNumber
>nPageNumber
)
601 //get the last page number
602 nPageNumber
= nNumber
;
603 if(pPageHint
->GetNext().IsNull())
605 //if is last page number of entire document, reture directly
606 return nPageNumber
+ pDoc
->GetNumberOfPagesBefore();
609 else if(nLayoutNumber
> 0 && pPageHint
->GetLayoutPageNumber() == nLayoutNumber
)
611 //get specified page number
612 nPageNumber
= nNumber
;
617 pPageHint
= dynamic_cast<LwpPageHint
*>(pPageHint
->GetNext().obj().get());
621 return nPageNumber
+ 1 + pDoc
->GetNumberOfPagesBefore();
627 * @descr: Get page width and height
630 void LwpPageLayout::GetWidthAndHeight(double& fWidth
, double& fHeight
)
632 //use customized size
633 LwpLayoutGeometry
* pLayoutGeo
= GetGeometry();
636 fWidth
= GetGeometryWidth();
637 fHeight
= GetGeometryHeight();
640 if(GetUsePrinterSettings())
642 //replaced by printer paper size
643 ScopedVclPtrInstance
< Printer
> pPrinter
;
644 bool bScreen
= pPrinter
->IsDisplayPrinter();
645 if (!bScreen
)//Printer available
647 Size aPaperSize
= pPrinter
->GetPaperSize();
648 aPaperSize
= pPrinter
->PixelToLogic( aPaperSize
, MapMode( MAP_10TH_MM
) );
649 fWidth
= static_cast<double>(aPaperSize
.Width())/100; //cm unit
650 fHeight
= static_cast<double>(aPaperSize
.Height())/100;
654 //Follow the former design of Lotus WordPro filter, some default will be given:
655 //Page Width: 8.5 Inch -> 21.59 cm
656 //Page Height: 11 Inch -> 27.94 cm
661 //End of modification, by ZF
665 * @descr: Get page width
668 double LwpPageLayout::GetWidth()
670 double fWidth
=0, fHeight
= 0;
671 GetWidthAndHeight(fWidth
, fHeight
);
676 * @descr: Get page height
679 double LwpPageLayout::GetHeight()
681 double fWidth
=0, fHeight
= 0;
682 GetWidthAndHeight(fWidth
, fHeight
);
686 * @descr: Compare the position of layout. If the position of this layout is earlier than other layout,return true, or return false
689 bool LwpPageLayout::operator<(LwpPageLayout
& Other
)
691 LwpPara
* pThisPara
= GetPagePosition();
692 LwpPara
* pOtherPara
= Other
.GetPagePosition();
693 if(pThisPara
&& pOtherPara
)
695 if(pThisPara
== pOtherPara
)
697 //If the two layouts in the same para, compare which layout is earlied according to frib order
698 return pThisPara
->ComparePagePosition(this, &Other
);
702 return *pThisPara
< *pOtherPara
;
713 * @descr: Get the position of pagelayout
716 LwpPara
* LwpPageLayout::GetPagePosition()
718 LwpPara
* pPara
= dynamic_cast<LwpPara
*>(GetPosition().obj().get());
721 //Get the position from its related section
722 LwpFoundry
* pFoundry
= GetFoundry();
725 LwpSection
* pSection
= NULL
;
726 while( (pSection
= pFoundry
->EnumSections(pSection
)) )
728 if(pSection
->GetPageLayout() == this)
729 return dynamic_cast<LwpPara
*>(pSection
->GetPosition().obj().get());
735 LwpHeaderLayout::LwpHeaderLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
736 : LwpPlacableLayout(objHdr
, pStrm
)
741 LwpHeaderLayout::~LwpHeaderLayout()
745 void LwpHeaderLayout::Read()
747 LwpPlacableLayout::Read();
749 if(LwpFileHeader::m_nFileRevision
>= 0x000E)
750 m_nBorderOffset
= m_pObjStrm
->QuickReadInt32();
753 m_pObjStrm
->SkipExtra();
756 void LwpHeaderLayout::RegisterStyle(XFPageMaster
* pm1
)
758 XFHeaderStyle
* pHeaderStyle
= new XFHeaderStyle();
760 //Modify page top margin
761 //page top maring: from top of header to the top edge
762 double top
= GetMarginsValue(MARGIN_TOP
);
763 pm1
->SetMargins(-1, -1, top
, -1);
765 ParseMargins(pHeaderStyle
);
766 ParseBorder(pHeaderStyle
);
767 ParseShadow(pHeaderStyle
);
768 // ParseBackColor(pHeaderStyle);
769 ParseBackGround(pHeaderStyle
);
771 ParseWaterMark(pHeaderStyle
);
774 pm1
->SetHeaderStyle(pHeaderStyle
);
777 void LwpHeaderLayout::ParseMargins(XFHeaderStyle
* ph1
)
779 //Set height: from top of header to top of body, including the spacing between header and body
780 double height
= GetGeometryHeight()- GetMarginsValue(MARGIN_TOP
);
781 if( IsAutoGrowDown() )
783 ph1
->SetMinHeight(height
);
787 ph1
->SetHeight(height
);
790 //Set left,right,bottom margins
791 LwpMiddleLayout
* parent
= dynamic_cast<LwpMiddleLayout
*> (GetParent().obj().get());
792 //left margin in SODC: the space from the left edge of body to the left edge of header
793 double left
= GetMarginsValue(MARGIN_LEFT
) - (parent
? parent
->GetMarginsValue(MARGIN_LEFT
) : 0);
794 if(left
<=0) //The left margin in SODC can not be minus value
798 //left margin in SODC: the space from the right edge of header to the right edge of body
799 double right
= GetMarginsValue(MARGIN_RIGHT
) - (parent
? parent
->GetMarginsValue(MARGIN_RIGHT
) : 0);
800 if(right
<=0)//The right margin in SODC can not be minus value
804 ph1
->SetMargins( left
, right
, GetMarginsValue(MARGIN_BOTTOM
));
806 //Word Pro has no dynamic spacing, should be set to false
807 ph1
->SetDynamicSpace(false);
810 void LwpHeaderLayout::ParseBorder(XFHeaderStyle
* pHeaderStyle
)
812 XFBorders
* pBordres
= GetXFBorders();
815 pHeaderStyle
->SetBorders(pBordres
);
819 void LwpHeaderLayout::ParseShadow(XFHeaderStyle
* pHeaderStyle
)
821 XFShadow
* pXFShadow
= GetXFShadow();
824 pHeaderStyle
->SetShadow(pXFShadow
);
829 * @descr: set header back pattern
832 void LwpHeaderLayout::ParsePatternFill(XFHeaderStyle
* pHeaderStyle
)
834 XFBGImage
* pXFBGImage
= this->GetFillPattern();
837 pHeaderStyle
->SetBackImage(pXFBGImage
);
841 * @descr: set header background
844 void LwpHeaderLayout::ParseBackGround(XFHeaderStyle
* pHeaderStyle
)
846 if (this->IsPatternFill())
848 ParsePatternFill(pHeaderStyle
);
852 ParseBackColor(pHeaderStyle
);
856 void LwpHeaderLayout::ParseBackColor(XFHeaderStyle
* pHeaderStyle
)
858 LwpColor
* pColor
= GetBackColor();
861 pHeaderStyle
->SetBackColor(XFColor(pColor
->To24Color()));
865 void LwpHeaderLayout::ParseWaterMark(XFHeaderStyle
* pHeaderStyle
)
867 XFBGImage
* pXFBGImage
= GetXFBGImage();
870 pHeaderStyle
->SetBackImage(pXFBGImage
);
875 void LwpHeaderLayout::RegisterStyle(XFMasterPage
* mp1
)
877 XFHeader
* pHeader
= new XFHeader();
878 rtl::Reference
<LwpObject
> pStory
= m_Content
.obj();
881 LwpGlobalMgr
* pGlobal
= LwpGlobalMgr::GetInstance();
882 LwpChangeMgr
* pChangeMgr
= pGlobal
->GetLwpChangeMgr();
883 pChangeMgr
->SetHeadFootFribMap(true);
885 //Call the RegisterStyle first to register the styles in header paras, and then XFConvert()
886 pStory
->SetFoundry(m_pFoundry
);
887 pStory
->RegisterStyle();
889 //register child layout style for framelayout,
890 RegisterChildStyle();
892 pChangeMgr
->SetHeadFootChange(pHeader
);
893 pStory
->XFConvert(pHeader
);
895 pChangeMgr
->SetHeadFootFribMap(false);
897 mp1
->SetHeader(pHeader
);
900 LwpFooterLayout::LwpFooterLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
901 : LwpPlacableLayout( objHdr
, pStrm
)
906 LwpFooterLayout::~LwpFooterLayout()
910 void LwpFooterLayout::Read()
912 LwpPlacableLayout::Read();
914 if(LwpFileHeader::m_nFileRevision
>= 0x000E)
915 m_nBorderOffset
= m_pObjStrm
->QuickReadInt32();
918 m_pObjStrm
->SkipExtra();
921 void LwpFooterLayout::RegisterStyle(XFPageMaster
* pm1
)
923 XFFooterStyle
* pFooterStyle
= new XFFooterStyle();
925 //Modify page bottom margin
926 //page bottom maring: from bottom of footer to the bottom edge
927 double bottom
= GetMarginsValue(MARGIN_BOTTOM
);
928 pm1
->SetMargins(-1, -1, -1, bottom
);
930 ParseMargins(pFooterStyle
);
931 ParseBorder(pFooterStyle
);
932 ParseShadow(pFooterStyle
);
933 ParseBackGround(pFooterStyle
);
934 // ParseBackColor(pFooterStyle);
936 ParseWaterMark(pFooterStyle
);
939 pm1
->SetFooterStyle(pFooterStyle
);
942 void LwpFooterLayout::ParseMargins(XFFooterStyle
* pFooterStyle
)
945 //Set height: from top of header to top of body, including the spacing between header and body
946 double height
= GetGeometryHeight() - GetMarginsValue(MARGIN_BOTTOM
);
949 pFooterStyle
->SetMinHeight(height
);
953 pFooterStyle
->SetHeight(height
);
956 //Set left,right,top margins
957 LwpMiddleLayout
* parent
= dynamic_cast<LwpMiddleLayout
*> (GetParent().obj().get());
958 double left
= GetMarginsValue(MARGIN_LEFT
) - (parent
? parent
->GetMarginsValue(MARGIN_LEFT
) : 0);
959 if(left
<=0) //The left margin in SODC can not be minus value
963 double right
= GetMarginsValue(MARGIN_RIGHT
) - (parent
? parent
->GetMarginsValue(MARGIN_RIGHT
) : 0);
964 if(right
<=0)//The left margin in SODC can not be minus value
968 pFooterStyle
->SetMargins( left
, right
, GetMarginsValue(MARGIN_TOP
));
970 //Word Pro has no dynamic spacing, should be set to false
971 pFooterStyle
->SetDynamicSpace(false);
974 void LwpFooterLayout::ParseBorder(XFFooterStyle
* pFooterStyle
)
976 XFBorders
* pBordres
= GetXFBorders();
979 pFooterStyle
->SetBorders(pBordres
);
983 void LwpFooterLayout::ParseShadow(XFFooterStyle
* pFooterStyle
)
985 XFShadow
* pXFShadow
= GetXFShadow();
988 pFooterStyle
->SetShadow(pXFShadow
);
992 * @descr: set footer back pattern
995 void LwpFooterLayout::ParsePatternFill(XFFooterStyle
* pFooterStyle
)
997 XFBGImage
* pXFBGImage
= this->GetFillPattern();
1000 pFooterStyle
->SetBackImage(pXFBGImage
);
1004 * @descr: set footer background
1007 void LwpFooterLayout::ParseBackGround(XFFooterStyle
* pFooterStyle
)
1009 if (this->IsPatternFill())
1011 ParsePatternFill(pFooterStyle
);
1015 ParseBackColor(pFooterStyle
);
1019 void LwpFooterLayout::ParseBackColor(XFFooterStyle
* pFooterStyle
)
1021 LwpColor
* pColor
= GetBackColor();
1024 pFooterStyle
->SetBackColor(XFColor(pColor
->To24Color()));
1028 void LwpFooterLayout::RegisterStyle(XFMasterPage
* mp1
)
1030 XFFooter
* pFooter
= new XFFooter();
1031 rtl::Reference
<LwpObject
> pStory
= m_Content
.obj(VO_STORY
);
1032 //Call the RegisterStyle first to register the styles in footer paras, and then XFConvert()
1035 LwpGlobalMgr
* pGlobal
= LwpGlobalMgr::GetInstance();
1036 LwpChangeMgr
* pChangeMgr
= pGlobal
->GetLwpChangeMgr();
1037 pChangeMgr
->SetHeadFootFribMap(true);
1039 pStory
->SetFoundry(m_pFoundry
);
1040 pStory
->RegisterStyle();
1042 //register child layout style for framelayout,
1043 RegisterChildStyle();
1046 pChangeMgr
->SetHeadFootChange(pFooter
);//add by ,7/6
1048 pStory
->XFConvert(pFooter
);
1050 pChangeMgr
->SetHeadFootFribMap(false);
1052 mp1
->SetFooter(pFooter
);
1055 void LwpFooterLayout::ParseWaterMark(XFFooterStyle
* pFooterStyle
)
1057 XFBGImage
* pXFBGImage
= GetXFBGImage();
1060 pFooterStyle
->SetBackImage(pXFBGImage
);
1065 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */