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
), m_pPrinterBinName(new LwpAtomHolder
),
81 m_pPaperName(new LwpAtomHolder
),m_pXFPageMaster(NULL
)
85 LwpPageLayout::~LwpPageLayout()
87 if (m_pPrinterBinName
)
89 delete m_pPrinterBinName
;
96 void LwpPageLayout::Read()
100 if (LwpFileHeader::m_nFileRevision
< 0x000B)
102 // read PreRevBLayout...
105 m_nPrinterBin
= m_pObjStrm
->QuickReaduInt16();
106 m_pPrinterBinName
->Read(m_pObjStrm
);
108 if (LwpFileHeader::m_nFileRevision
>= 0x000B)
109 m_nBdroffset
= m_pObjStrm
->QuickReadInt32();
111 if (m_pObjStrm
->CheckExtra())
113 m_pPaperName
->Read(m_pObjStrm
);
114 m_pObjStrm
->SkipExtra();
119 void LwpPageLayout::Parse(IXFStream
* pOutputStream
)
121 //Only parse this layout
122 LwpObject
* pStory
= m_Content
.obj();
125 pStory
->SetFoundry(m_pFoundry
);
126 pStory
->Parse(pOutputStream
); //Do not parse the next story
131 * @descr: set page margins
134 void LwpPageLayout::ParseMargins(XFPageMaster
* pm1
)
136 double fLeft
= GetMarginsValue(MARGIN_LEFT
);
137 double fRight
= GetMarginsValue(MARGIN_RIGHT
);
138 double fTop
= GetMarginsValue(MARGIN_TOP
);
139 double fBottom
= GetMarginsValue(MARGIN_BOTTOM
);
141 pm1
->SetMargins( fLeft
, fRight
, fTop
, fBottom
);
146 * @descr: set page height and width
149 void LwpPageLayout::ParseGeometry(XFPageMaster
* pm1
)
152 LwpLayoutGeometry* pLayoutGeo = GetGeometry();
155 pm1->SetPageHeight( GetGeometryHeight() );
156 pm1->SetPageWidth( GetGeometryWidth() );
161 GetWidthAndHeight(fWidth
, fHeight
);
162 pm1
->SetPageWidth( fWidth
);
163 pm1
->SetPageHeight( fHeight
);
167 * @descr: set page watermark
170 void LwpPageLayout::ParseWaterMark(XFPageMaster
*pm1
)
172 XFBGImage
* pXFBGImage
= GetXFBGImage();
175 pm1
->SetBackImage(pXFBGImage
);
180 * @descr: set page columns
183 void LwpPageLayout::ParseColumns(XFPageMaster
* pm1
)
185 XFColumns
* pColumns
= GetXFColumns();
188 pm1
->SetColumns(pColumns
);
193 * @descr: set page borders
196 void LwpPageLayout::ParseBorders(XFPageMaster
*pm1
)
198 XFBorders
* pBordres
= GetXFBorders();
201 pm1
->SetBorders(pBordres
);
207 * @descr: set page shadow
210 void LwpPageLayout::ParseShadow(XFPageMaster
*pm1
)
212 XFShadow
* pXFShadow
= GetXFShadow();
215 pm1
->SetShadow(pXFShadow
);
220 * @descr: set page back pattern
223 void LwpPageLayout::ParsePatternFill(XFPageMaster
* pm1
)
225 XFBGImage
* pXFBGImage
= this->GetFillPattern();
228 pm1
->SetBackImage(pXFBGImage
);
232 * @descr: set page background
235 void LwpPageLayout::ParseBackGround(XFPageMaster
* pm1
)
237 if (this->IsPatternFill())
239 ParsePatternFill(pm1
);
248 * @descr: set page back color
251 void LwpPageLayout::ParseBackColor(XFPageMaster
* pm1
)
253 LwpColor
* pColor
= GetBackColor();
256 pm1
->SetBackColor(XFColor(pColor
->To24Color()));
261 * @descr: set page footnote separator information
264 void LwpPageLayout::ParseFootNoteSeparator(XFPageMaster
* pm1
)
266 //Get the footnoteoptions for the root document
267 LwpDocument
* pDocument
= m_pFoundry
->GetDocument();
270 LwpObjectID
* pFontnodeId
= pDocument
->GetValidFootnoteOpts();
272 LwpFootnoteOptions
* pFootnoteOpts
= pFontnodeId
? dynamic_cast<LwpFootnoteOptions
*>(pFontnodeId
->obj()) : NULL
;
275 LwpFootnoteSeparatorOptions
* pFootnoteSep
= pFootnoteOpts
->GetFootnoteSeparator();
277 sal_uInt32 nLengthPercent
= 100;
279 if(pFootnoteSep
->HasSeparator())
281 fWidth
= pFootnoteSep
->GetTopBorderWidth();
283 if(pFootnoteSep
->HasCustomLength())
285 nLengthPercent
= static_cast<sal_uInt32
>(100*LwpTools::ConvertFromUnitsToMetric(pFootnoteSep
->GetLength())/GetMarginWidth());
286 if(nLengthPercent
> 100)
287 nLengthPercent
= 100;
289 double fAbove
= LwpTools::ConvertFromUnitsToMetric(pFootnoteSep
->GetAbove());
290 double fBelow
= LwpTools::ConvertFromUnitsToMetric(pFootnoteSep
->GetBelow());
291 LwpColor aColor
= pFootnoteSep
->GetTopBorderColor();
292 enumXFAlignType eAlignType
= enumXFAlignStart
;
293 if(pFootnoteSep
->GetIndent() > 0)
295 //SODC don't support indent
296 sal_uInt32 nIndentPercent
= static_cast<sal_uInt32
>(100*LwpTools::ConvertFromUnitsToMetric(pFootnoteSep
->GetIndent())/GetMarginWidth());
297 if(nIndentPercent
+ nLengthPercent
>= 100)
298 eAlignType
= enumXFAlignEnd
;
300 if(aColor
.IsValidColor())
302 XFColor
aXFColor(aColor
.To24Color());
303 pm1
->SetFootNoteSeparator(eAlignType
,fWidth
, nLengthPercent
, fAbove
, fBelow
, aXFColor
);
310 * @descr: Register master page and page master style
313 void LwpPageLayout::RegisterStyle()
315 XFPageMaster
* pm1
= new XFPageMaster();
316 m_pXFPageMaster
= pm1
;
318 ParseGeometry( pm1
);
319 //Does not process LayoutScale, for watermark is not supported in SODC.
320 ParseWaterMark( pm1
);
325 // ParseBackColor(pm1);
326 ParseBackGround(pm1
);
327 ParseFootNoteSeparator(pm1
);
328 pm1
->SetTextDir(GetTextDirection());
330 LwpUseWhen
* pUseWhen
= GetUseWhen();
331 if(IsComplex() ||( pUseWhen
&& pUseWhen
->IsUseOnAllOddPages()))
333 pm1
->SetPageUsage(enumXFPageUsageMirror
);
336 //Add the page master to stylemanager
337 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
338 m_pXFPageMaster
= pm1
= (XFPageMaster
*)pXFStyleManager
->AddStyle(pm1
);
339 OUString pmname
= pm1
->GetStyleName();
342 XFMasterPage
* mp1
= new XFMasterPage();
343 mp1
->SetStyleName(GetName()->str());
344 mp1
->SetPageMaster(pmname
);
345 mp1
= (XFMasterPage
*)pXFStyleManager
->AddStyle(mp1
);
346 m_StyleName
= mp1
->GetStyleName();
349 LwpFooterLayout
* pLayoutFooter
= GetFooterLayout();
352 pLayoutFooter
->SetFoundry(m_pFoundry
);
353 pLayoutFooter
->RegisterStyle(pm1
);
354 pLayoutFooter
->RegisterStyle(mp1
);
358 LwpHeaderLayout
* pLayoutHeader
= GetHeaderLayout();
361 pLayoutHeader
->SetFoundry(m_pFoundry
);
362 pLayoutHeader
->RegisterStyle(pm1
);
363 pLayoutHeader
->RegisterStyle(mp1
);
365 //register child layout style for mirror page and frame
366 RegisterChildStyle();
370 * @descr: Register master page for endnote which name is "endnote"
371 * @return: Return the master page name.
373 OUString
LwpPageLayout::RegisterEndnoteStyle()
375 XFPageMaster
* pm1
= new XFPageMaster();
376 m_pXFPageMaster
= pm1
;
378 ParseGeometry( pm1
);
379 ParseWaterMark( pm1
);
384 // ParseBackColor(pm1);
385 ParseBackGround(pm1
);
386 //ParseFootNoteSeparator(pm1);
387 pm1
->SetTextDir(GetTextDirection());
389 LwpUseWhen
* pUseWhen
= GetUseWhen();
390 if(IsComplex() ||( pUseWhen
&& pUseWhen
->IsUseOnAllOddPages()))
392 pm1
->SetPageUsage(enumXFPageUsageMirror
);
395 //Add the page master to stylemanager
396 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
397 m_pXFPageMaster
= pm1
= (XFPageMaster
*)pXFStyleManager
->AddStyle(pm1
);
398 OUString pmname
= pm1
->GetStyleName();
401 XFMasterPage
* mp1
= new XFMasterPage();
402 mp1
->SetStyleName(A2OUSTR("Endnote"));
403 mp1
->SetPageMaster(pmname
);
406 LwpFooterLayout
* pLayoutFooter
= GetFooterLayout();
409 pLayoutFooter
->SetFoundry(m_pFoundry
);
410 pLayoutFooter
->RegisterStyle(pm1
);
411 pLayoutFooter
->RegisterStyle(mp1
);
415 LwpHeaderLayout
* pLayoutHeader
= GetHeaderLayout();
418 pLayoutHeader
->SetFoundry(m_pFoundry
);
419 pLayoutHeader
->RegisterStyle(pm1
);
420 pLayoutHeader
->RegisterStyle(mp1
);
423 return pXFStyleManager
->AddStyle(mp1
)->GetStyleName();
426 * @descr: Whether current page layout has columns
429 sal_Bool
LwpPageLayout::HasColumns()
431 return GetNumCols() > 1 ? sal_True
: sal_False
;
435 * @descr: Whether has filler page text in current page layout
438 sal_Bool
LwpPageLayout::HasFillerPageText(LwpFoundry
* pFoundry
)
440 if(!pFoundry
) return sal_False
;
442 sal_Bool bFillerPage
= sal_False
;
443 LwpLayout::UseWhenType eWhenType
= GetUseWhenType();
444 if(eWhenType
==LwpLayout::StartOnOddPage
||eWhenType
==LwpLayout::StartOnEvenPage
)
447 sal_uInt16 nPageNumber
= 0;
449 //get the page number that current page layout inserted
450 nPageNumber
= GetPageNumber(FIRST_LAYOUTPAGENO
)-1;
454 if((eWhenType
==LwpLayout::StartOnOddPage
)&&(LwpTools::IsOddNumber(nPageNumber
)))
456 bFillerPage
= sal_True
;
458 else if((eWhenType
==LwpLayout::StartOnEvenPage
)&&(LwpTools::IsEvenNumber(nPageNumber
)))
460 bFillerPage
= sal_True
;
464 bFillerPage
= sal_False
;
473 * @descr: Parse filler page text
476 void LwpPageLayout::ConvertFillerPageText(XFContentContainer
* pCont
)
478 if(HasFillerPageText(m_pFoundry
))
480 //get filerpage story from division info
481 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
482 LwpDivInfo
* pDivInfo
= dynamic_cast<LwpDivInfo
*>(pDoc
->GetDivInfoID()->obj());
483 LwpStory
* pStory
= dynamic_cast<LwpStory
*>(pDivInfo
->GetFillerPageTextID()->obj());
485 //parse fillerpage story
488 pStory
->XFConvert(pCont
);
493 * @descr: Clear columns style in page layout
496 void LwpPageLayout::ResetXFColumns()
500 m_pXFPageMaster
->SetColumns(NULL
);
504 LwpHeaderLayout
* LwpPageLayout::GetHeaderLayout()
506 LwpVirtualLayout
* pLay
= dynamic_cast<LwpVirtualLayout
*>(GetChildHead()->obj());
509 if( pLay
->GetLayoutType() == LWP_HEADER_LAYOUT
)
510 return ( static_cast<LwpHeaderLayout
*> (pLay
) );
511 pLay
= dynamic_cast<LwpVirtualLayout
*> (pLay
->GetNext()->obj());
516 LwpFooterLayout
* LwpPageLayout::GetFooterLayout()
518 LwpVirtualLayout
* pLay
= dynamic_cast<LwpVirtualLayout
*>(GetChildHead()->obj());
521 if( pLay
->GetLayoutType() == LWP_FOOTER_LAYOUT
)
522 return ( static_cast<LwpFooterLayout
*> (pLay
) );
523 pLay
= dynamic_cast<LwpVirtualLayout
*> (pLay
->GetNext()->obj());
529 * @descr: Get the odd layout if current page layout is mirror page
532 LwpPageLayout
* LwpPageLayout::GetOddChildLayout()
536 LwpVirtualLayout
* pLay
= dynamic_cast<LwpVirtualLayout
*>(GetChildHead()->obj());
539 if( pLay
->GetLayoutType() == LWP_PAGE_LAYOUT
)
541 LwpPageLayout
* pPageLayout
= static_cast<LwpPageLayout
*> (pLay
);
542 LwpUseWhen
* pUseWhen
= pPageLayout
->GetUseWhen();
543 if(pUseWhen
&& pUseWhen
->IsUseOnAllOddPages())
548 pLay
= dynamic_cast<LwpVirtualLayout
*> (pLay
->GetNext()->obj());
555 * @descr: Get margin width of page
558 double LwpPageLayout::GetMarginWidth()
560 double fPagewidth
= GetGeometryWidth();
561 double fLeftMargin
= GetMarginsValue(MARGIN_LEFT
);
562 double fRightMargin
= GetMarginsValue(MARGIN_RIGHT
);
564 return fPagewidth
- (fLeftMargin
+ fRightMargin
);
568 * @descr: Get the pagenumber
569 * @param: if nLayoutNumber =FIRST_LAYOUTPAGENO, return the first page number that current page layout covers
570 =LAST_LAYOUTPAGENO, return the last page number that current page layout covers
571 else, return the specified page number that current page layout covers
573 * @return: if reture value >=0, success to find the page number, or fail.
575 sal_Int32
LwpPageLayout::GetPageNumber(sal_uInt16 nLayoutNumber
)
577 sal_Int16 nPageNumber
= -1;
578 LwpFoundry
* pFoundry
= this->GetFoundry();
579 LwpDocument
* pDoc
= pFoundry
->GetDocument();
580 LwpDLVListHeadTailHolder
* pHeadTail
= dynamic_cast<LwpDLVListHeadTailHolder
*>(pDoc
->GetPageHintsID()->obj());
581 if(!pHeadTail
) return nPageNumber
;
584 LwpPageHint
* pPageHint
= dynamic_cast<LwpPageHint
*>(pHeadTail
->GetHead()->obj());
587 if(*(this->GetObjectID()) == *(pPageHint
->GetPageLayoutID()))
589 sal_uInt16 nNumber
= pPageHint
->GetPageNumber();
590 if(nLayoutNumber
==FIRST_LAYOUTPAGENO
&& pPageHint
->GetLayoutPageNumber()==1)
592 //get the first page number
593 nPageNumber
= nNumber
;
596 else if( nLayoutNumber
==LAST_LAYOUTPAGENO
&& nNumber
>nPageNumber
)
598 //get the last page number
599 nPageNumber
= nNumber
;
600 if(pPageHint
->GetNext()->IsNull())
602 //if is last page number of entire document, reture directly
603 return nPageNumber
+ pDoc
->GetNumberOfPagesBefore();
606 else if(nLayoutNumber
> 0 && pPageHint
->GetLayoutPageNumber() == nLayoutNumber
)
608 //get specified page number
609 nPageNumber
= nNumber
;
614 pPageHint
= dynamic_cast<LwpPageHint
*>(pPageHint
->GetNext()->obj());
618 return nPageNumber
+ 1 + pDoc
->GetNumberOfPagesBefore();
624 * @descr: Get page width and height
627 void LwpPageLayout::GetWidthAndHeight(double& fWidth
, double& fHeight
)
629 //use customized size
630 LwpLayoutGeometry
* pLayoutGeo
= GetGeometry();
633 fWidth
= GetGeometryWidth();
634 fHeight
= GetGeometryHeight();
637 if(GetUsePrinterSettings())
639 //replaced by printer paper size
641 sal_Bool bScreen
= aPrinter
.IsDisplayPrinter();
642 if (!bScreen
)//Printer available
644 Size aPaperSize
= aPrinter
.GetPaperSize();
645 aPaperSize
= aPrinter
.PixelToLogic( aPaperSize
, MapMode( MAP_10TH_MM
) );
646 fWidth
= static_cast<double>(aPaperSize
.Width())/100; //cm unit
647 fHeight
= static_cast<double>(aPaperSize
.Height())/100;
651 //Follow the former design of Lotus WordPro filter, some default will be given:
652 //Page Width: 8.5 Inch -> 21.59 cm
653 //Page Height: 11 Inch -> 27.94 cm
658 //End of modification, by ZF
662 * @descr: Get page width
665 double LwpPageLayout::GetWidth()
667 double fWidth
=0, fHeight
= 0;
668 GetWidthAndHeight(fWidth
, fHeight
);
673 * @descr: Get page height
676 double LwpPageLayout::GetHeight()
678 double fWidth
=0, fHeight
= 0;
679 GetWidthAndHeight(fWidth
, fHeight
);
683 * @descr: Compare the position of layout. If the poistion of this layout is earlier than other layout,return ture, or return false
686 sal_Bool
LwpPageLayout::operator<(LwpPageLayout
& Other
)
688 LwpPara
* pThisPara
= GetPagePosition();
689 LwpPara
* pOtherPara
= Other
.GetPagePosition();
690 if(pThisPara
&& pOtherPara
)
692 if(pThisPara
== pOtherPara
)
694 //If the two layouts in the same para, compare which layout is earlied according to frib order
695 return pThisPara
->ComparePagePosition(this, &Other
);
699 return *pThisPara
< *pOtherPara
;
710 * @descr: Get the position of pagelayout
713 LwpPara
* LwpPageLayout::GetPagePosition()
715 LwpPara
* pPara
= dynamic_cast<LwpPara
*>(GetPosition()->obj());
718 //Get the position from its related section
719 LwpSection
* pSection
= NULL
;
720 LwpFoundry
* pFoundry
= GetFoundry();
723 while( (pSection
= pFoundry
->EnumSections(pSection
)) )
725 if(pSection
->GetPageLayout() == this)
726 return dynamic_cast<LwpPara
*>(pSection
->GetPosition()->obj());
732 LwpHeaderLayout::LwpHeaderLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
733 : LwpPlacableLayout(objHdr
, pStrm
)
737 LwpHeaderLayout::~LwpHeaderLayout()
741 void LwpHeaderLayout::Read()
743 LwpPlacableLayout::Read();
745 if(LwpFileHeader::m_nFileRevision
>= 0x000E)
746 m_nBorderOffset
= m_pObjStrm
->QuickReadInt32();
749 m_pObjStrm
->SkipExtra();
753 void LwpHeaderLayout::RegisterStyle(XFPageMaster
* pm1
)
755 XFHeaderStyle
* pHeaderStyle
= new XFHeaderStyle();
757 //Modify page top margin
758 //page top maring: from top of header to the top edge
759 double top
= GetMarginsValue(MARGIN_TOP
);
760 pm1
->SetMargins(-1, -1, top
, -1);
762 ParseMargins(pHeaderStyle
);
763 ParseBorder(pHeaderStyle
);
764 ParseShadow(pHeaderStyle
);
765 // ParseBackColor(pHeaderStyle);
766 ParseBackGround(pHeaderStyle
);
768 ParseWaterMark(pHeaderStyle
);
771 pm1
->SetHeaderStyle(pHeaderStyle
);
774 void LwpHeaderLayout::ParseMargins(XFHeaderStyle
* ph1
)
776 //Set height: from top of header to top of body, including the spacing between header and body
777 double height
= GetGeometryHeight()- GetMarginsValue(MARGIN_TOP
);
778 if( IsAutoGrowDown() )
780 ph1
->SetMinHeight(height
);
784 ph1
->SetHeight(height
);
787 //Set left,right,bottom margins
788 LwpMiddleLayout
* parent
= dynamic_cast<LwpMiddleLayout
*> (GetParent()->obj());
789 //left margin in SODC: the space from the left edge of body to the left edge of header
790 double left
= GetMarginsValue(MARGIN_LEFT
) - (parent
? parent
->GetMarginsValue(MARGIN_LEFT
) : 0);
791 if(left
<=0) //The left margin in SODC can not be minus value
795 //left margin in SODC: the space from the right edge of header to the right edge of body
796 double right
= GetMarginsValue(MARGIN_RIGHT
) - (parent
? parent
->GetMarginsValue(MARGIN_RIGHT
) : 0);
797 if(right
<=0)//The right margin in SODC can not be minus value
801 ph1
->SetMargins( left
, right
, GetMarginsValue(MARGIN_BOTTOM
));
803 //Word Pro has no dynamic spacing, should be set to false
804 ph1
->SetDynamicSpace(sal_False
);
807 void LwpHeaderLayout::ParseBorder(XFHeaderStyle
* pHeaderStyle
)
809 XFBorders
* pBordres
= GetXFBorders();
812 pHeaderStyle
->SetBorders(pBordres
);
816 void LwpHeaderLayout::ParseShadow(XFHeaderStyle
* pHeaderStyle
)
818 XFShadow
* pXFShadow
= GetXFShadow();
821 pHeaderStyle
->SetShadow(pXFShadow
);
826 * @descr: set header back pattern
829 void LwpHeaderLayout::ParsePatternFill(XFHeaderStyle
* pHeaderStyle
)
831 XFBGImage
* pXFBGImage
= this->GetFillPattern();
834 pHeaderStyle
->SetBackImage(pXFBGImage
);
838 * @descr: set header background
841 void LwpHeaderLayout::ParseBackGround(XFHeaderStyle
* pHeaderStyle
)
843 if (this->IsPatternFill())
845 ParsePatternFill(pHeaderStyle
);
849 ParseBackColor(pHeaderStyle
);
853 void LwpHeaderLayout::ParseBackColor(XFHeaderStyle
* pHeaderStyle
)
855 LwpColor
* pColor
= GetBackColor();
858 pHeaderStyle
->SetBackColor(XFColor(pColor
->To24Color()));
863 void LwpHeaderLayout::ParseWaterMark(XFHeaderStyle
* pHeaderStyle
)
865 XFBGImage
* pXFBGImage
= GetXFBGImage();
868 pHeaderStyle
->SetBackImage(pXFBGImage
);
873 void LwpHeaderLayout::RegisterStyle(XFMasterPage
* mp1
)
875 XFHeader
* pHeader
= new XFHeader();
876 LwpObject
* pStory
= m_Content
.obj();
879 LwpGlobalMgr
* pGlobal
= LwpGlobalMgr::GetInstance();
880 LwpChangeMgr
* pChangeMgr
= pGlobal
->GetLwpChangeMgr();
881 pChangeMgr
->SetHeadFootFribMap(sal_True
);
883 //Call the RegisterStyle first to register the styles in header paras, and then XFConvert()
884 pStory
->SetFoundry(m_pFoundry
);
885 pStory
->RegisterStyle();
887 //register child layout style for framelayout,
888 RegisterChildStyle();
890 pChangeMgr
->SetHeadFootChange(pHeader
);
891 pStory
->XFConvert(pHeader
);
893 pChangeMgr
->SetHeadFootFribMap(sal_False
);
895 mp1
->SetHeader(pHeader
);
898 LwpFooterLayout::LwpFooterLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
899 : LwpPlacableLayout( objHdr
, pStrm
)
903 LwpFooterLayout::~LwpFooterLayout()
907 void LwpFooterLayout::Read()
909 LwpPlacableLayout::Read();
911 if(LwpFileHeader::m_nFileRevision
>= 0x000E)
912 m_nBorderOffset
= m_pObjStrm
->QuickReadInt32();
915 m_pObjStrm
->SkipExtra();
918 void LwpFooterLayout::RegisterStyle(XFPageMaster
* pm1
)
920 XFFooterStyle
* pFooterStyle
= new XFFooterStyle();
922 //Modify page bottom margin
923 //page bottom maring: from bottom of footer to the bottom edge
924 double bottom
= GetMarginsValue(MARGIN_BOTTOM
);
925 pm1
->SetMargins(-1, -1, -1, bottom
);
927 ParseMargins(pFooterStyle
);
928 ParseBorder(pFooterStyle
);
929 ParseShadow(pFooterStyle
);
930 ParseBackGround(pFooterStyle
);
931 // ParseBackColor(pFooterStyle);
933 ParseWaterMark(pFooterStyle
);
936 pm1
->SetFooterStyle(pFooterStyle
);
939 void LwpFooterLayout::ParseMargins(XFFooterStyle
* pFooterStyle
)
942 //Set height: from top of header to top of body, including the spacing between header and body
943 double height
= GetGeometryHeight() - GetMarginsValue(MARGIN_BOTTOM
);
946 pFooterStyle
->SetMinHeight(height
);
950 pFooterStyle
->SetHeight(height
);
953 //Set left,right,top margins
954 LwpMiddleLayout
* parent
= dynamic_cast<LwpMiddleLayout
*> (GetParent()->obj());
955 double left
= GetMarginsValue(MARGIN_LEFT
) - (parent
? parent
->GetMarginsValue(MARGIN_LEFT
) : 0);
956 if(left
<=0) //The left margin in SODC can not be minus value
960 double right
= GetMarginsValue(MARGIN_RIGHT
) - (parent
? parent
->GetMarginsValue(MARGIN_RIGHT
) : 0);
961 if(right
<=0)//The left margin in SODC can not be minus value
965 pFooterStyle
->SetMargins( left
, right
, GetMarginsValue(MARGIN_TOP
));
967 //Word Pro has no dynamic spacing, should be set to false
968 pFooterStyle
->SetDynamicSpace(sal_False
);
971 void LwpFooterLayout::ParseBorder(XFFooterStyle
* pFooterStyle
)
973 XFBorders
* pBordres
= GetXFBorders();
976 pFooterStyle
->SetBorders(pBordres
);
980 void LwpFooterLayout::ParseShadow(XFFooterStyle
* pFooterStyle
)
982 XFShadow
* pXFShadow
= GetXFShadow();
985 pFooterStyle
->SetShadow(pXFShadow
);
989 * @descr: set footer back pattern
992 void LwpFooterLayout::ParsePatternFill(XFFooterStyle
* pFooterStyle
)
994 XFBGImage
* pXFBGImage
= this->GetFillPattern();
997 pFooterStyle
->SetBackImage(pXFBGImage
);
1001 * @descr: set footer background
1004 void LwpFooterLayout::ParseBackGround(XFFooterStyle
* pFooterStyle
)
1006 if (this->IsPatternFill())
1008 ParsePatternFill(pFooterStyle
);
1012 ParseBackColor(pFooterStyle
);
1016 void LwpFooterLayout::ParseBackColor(XFFooterStyle
* pFooterStyle
)
1018 LwpColor
* pColor
= GetBackColor();
1021 pFooterStyle
->SetBackColor(XFColor(pColor
->To24Color()));
1025 void LwpFooterLayout::RegisterStyle(XFMasterPage
* mp1
)
1027 XFFooter
* pFooter
= new XFFooter();
1028 LwpObject
* pStory
= m_Content
.obj(VO_STORY
);
1029 //Call the RegisterStyle first to register the styles in footer paras, and then XFConvert()
1032 LwpGlobalMgr
* pGlobal
= LwpGlobalMgr::GetInstance();
1033 LwpChangeMgr
* pChangeMgr
= pGlobal
->GetLwpChangeMgr();
1034 pChangeMgr
->SetHeadFootFribMap(sal_True
);
1036 pStory
->SetFoundry(m_pFoundry
);
1037 pStory
->RegisterStyle();
1039 //register child layout style for framelayout,
1040 RegisterChildStyle();
1043 pChangeMgr
->SetHeadFootChange(pFooter
);//add by ,7/6
1045 pStory
->XFConvert(pFooter
);
1047 pChangeMgr
->SetHeadFootFribMap(sal_False
);
1049 mp1
->SetFooter(pFooter
);
1053 void LwpFooterLayout::ParseWaterMark(XFFooterStyle
* pFooterStyle
)
1055 XFBGImage
* pXFBGImage
= GetXFBGImage();
1058 pFooterStyle
->SetBackImage(pXFBGImage
);
1063 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */