1 /*************************************************************************
3 * The Contents of this file are made available subject to the terms of
4 * either of the following licenses
6 * - GNU Lesser General Public License Version 2.1
7 * - Sun Industry Standards Source License Version 1.1
9 * Sun Microsystems Inc., October, 2000
11 * GNU Lesser General Public License Version 2.1
12 * =============================================
13 * Copyright 2000 by Sun Microsystems, Inc.
14 * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License version 2.1, as published by the Free Software Foundation.
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 * Sun Industry Standards Source License Version 1.1
32 * =================================================
33 * The contents of this file are subject to the Sun Industry Standards
34 * Source License Version 1.1 (the "License"); You may not use this file
35 * except in compliance with the License. You may obtain a copy of the
36 * License at http://www.openoffice.org/license.html.
38 * Software provided under this License is provided on an "AS IS" basis,
39 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
40 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
41 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
42 * See the License for the specific provisions governing your rights and
43 * obligations concerning the Software.
45 * The Initial Developer of the Original Code is: IBM Corporation
47 * Copyright: 2008 by IBM Corporation
49 * All Rights Reserved.
51 * Contributor(s): _______________________________________
54 ************************************************************************/
55 /*************************************************************************
58 ************************************************************************/
59 #include "lwppagelayout.hxx"
60 #include "lwplaypiece.hxx"
61 #include "lwpfootnote.hxx"
63 #include "lwpholder.hxx"
64 #include "lwppagehint.hxx"
65 #include "lwpdivinfo.hxx"
66 #include "lwpstory.hxx"
67 #include "xfilter/xfstylemanager.hxx"
68 #include "xfilter/xfmasterpage.hxx"
69 #include "xfilter/xfcontentcontainer.hxx"
70 #include "xfilter/xfheader.hxx"
71 #include "xfilter/xfheaderstyle.hxx"
72 #include "xfilter/xffooterstyle.hxx"
73 #include "xfilter/xffooter.hxx"
74 #include <sfx2/printer.hxx>
75 #include "lwpchangemgr.hxx"
76 #include "lwpglobalmgr.hxx"
78 LwpPageLayout::LwpPageLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
79 : LwpLayout(objHdr
, pStrm
), m_pPrinterBinName(new LwpAtomHolder
),
80 m_pPaperName(new LwpAtomHolder
),m_pXFPageMaster(NULL
)
84 LwpPageLayout::~LwpPageLayout()
86 if (m_pPrinterBinName
)
88 delete m_pPrinterBinName
;
95 void LwpPageLayout::Read()
99 if (LwpFileHeader::m_nFileRevision
< 0x000B)
101 // read PreRevBLayout...
104 m_pObjStrm
->QuickRead(&m_nPrinterBin
, sizeof(m_nPrinterBin
));
105 m_pPrinterBinName
->Read(m_pObjStrm
);
107 if (LwpFileHeader::m_nFileRevision
>= 0x000B)
109 m_pObjStrm
->QuickRead(&m_nBdroffset
, sizeof(m_nBdroffset
));
112 if (m_pObjStrm
->CheckExtra())
114 m_pPaperName
->Read(m_pObjStrm
);
115 m_pObjStrm
->SkipExtra();
120 void LwpPageLayout::Parse(IXFStream
* pOutputStream
)
122 //Only parse this layout
123 LwpObject
* pStory
= m_Content
.obj();
126 pStory
->SetFoundry(m_pFoundry
);
127 pStory
->Parse(pOutputStream
); //Do not parse the next story
132 * @descr: set page margins
135 void LwpPageLayout::ParseMargins(XFPageMaster
* pm1
)
137 double fLeft
= GetMarginsValue(MARGIN_LEFT
);
138 double fRight
= GetMarginsValue(MARGIN_RIGHT
);
139 double fTop
= GetMarginsValue(MARGIN_TOP
);
140 double fBottom
= GetMarginsValue(MARGIN_BOTTOM
);
142 pm1
->SetMargins( fLeft
, fRight
, fTop
, fBottom
);
147 * @descr: set page height and width
150 void LwpPageLayout::ParseGeometry(XFPageMaster
* pm1
)
153 LwpLayoutGeometry* pLayoutGeo = GetGeometry();
156 pm1->SetPageHeight( GetGeometryHeight() );
157 pm1->SetPageWidth( GetGeometryWidth() );
162 GetWidthAndHeight(fWidth
, fHeight
);
163 pm1
->SetPageWidth( fWidth
);
164 pm1
->SetPageHeight( fHeight
);
168 * @descr: set page watermark
171 void LwpPageLayout::ParseWaterMark(XFPageMaster
*pm1
)
173 XFBGImage
* pXFBGImage
= GetXFBGImage();
176 pm1
->SetBackImage(pXFBGImage
);
181 * @descr: set page columns
184 void LwpPageLayout::ParseColumns(XFPageMaster
* pm1
)
186 XFColumns
* pColumns
= GetXFColumns();
189 pm1
->SetColumns(pColumns
);
194 * @descr: set page borders
197 void LwpPageLayout::ParseBorders(XFPageMaster
*pm1
)
199 XFBorders
* pBordres
= GetXFBorders();
202 pm1
->SetBorders(pBordres
);
208 * @descr: set page shadow
211 void LwpPageLayout::ParseShadow(XFPageMaster
*pm1
)
213 XFShadow
* pXFShadow
= GetXFShadow();
216 pm1
->SetShadow(pXFShadow
);
221 * @descr: set page back pattern
224 void LwpPageLayout::ParsePatternFill(XFPageMaster
* pm1
)
226 XFBGImage
* pXFBGImage
= this->GetFillPattern();
229 pm1
->SetBackImage(pXFBGImage
);
233 * @descr: set page background
236 void LwpPageLayout::ParseBackGround(XFPageMaster
* pm1
)
238 if (this->IsPatternFill())
240 ParsePatternFill(pm1
);
249 * @descr: set page back color
252 void LwpPageLayout::ParseBackColor(XFPageMaster
* pm1
)
254 LwpColor
* pColor
= GetBackColor();
257 pm1
->SetBackColor(XFColor(pColor
->To24Color()));
262 * @descr: set page footnote separator information
265 void LwpPageLayout::ParseFootNoteSeparator(XFPageMaster
* pm1
)
267 //Get the footnoteoptions for the root document
268 LwpDocument
* pDocument
= m_pFoundry
->GetDocument();
271 LwpFootnoteOptions
* pFootnoteOpts
= static_cast<LwpFootnoteOptions
*>(pDocument
->GetValidFootnoteOpts()->obj());
274 LwpFootnoteSeparatorOptions
* pFootnoteSep
= pFootnoteOpts
->GetFootnoteSeparator();
276 sal_uInt32 nLengthPercent
= 100;
278 if(pFootnoteSep
->HasSeparator())
280 fWidth
= pFootnoteSep
->GetTopBorderWidth();
282 if(pFootnoteSep
->HasCustomLength())
284 nLengthPercent
= static_cast<sal_uInt32
>(100*LwpTools::ConvertFromUnitsToMetric(pFootnoteSep
->GetLength())/GetMarginWidth());
285 if(nLengthPercent
> 100)
286 nLengthPercent
= 100;
288 double fAbove
= LwpTools::ConvertFromUnitsToMetric(pFootnoteSep
->GetAbove());
289 double fBelow
= LwpTools::ConvertFromUnitsToMetric(pFootnoteSep
->GetBelow());
290 LwpColor aColor
= pFootnoteSep
->GetTopBorderColor();
291 enumXFAlignType eAlignType
= enumXFAlignStart
;
292 if(pFootnoteSep
->GetIndent() > 0)
294 //SODC don't support indent
295 sal_uInt32 nIndentPercent
= static_cast<sal_uInt32
>(100*LwpTools::ConvertFromUnitsToMetric(pFootnoteSep
->GetIndent())/GetMarginWidth());
296 if(nIndentPercent
+ nLengthPercent
>= 100)
297 eAlignType
= enumXFAlignEnd
;
299 if(aColor
.IsValidColor())
301 XFColor
aXFColor(aColor
.To24Color());
302 pm1
->SetFootNoteSeparator(eAlignType
,fWidth
, nLengthPercent
, fAbove
, fBelow
, aXFColor
);
309 * @descr: Register master page and page master style
312 void LwpPageLayout::RegisterStyle()
314 XFPageMaster
* pm1
= new XFPageMaster();
315 m_pXFPageMaster
= pm1
;
317 ParseGeometry( pm1
);
318 //Does not process LayoutScale, for watermark is not supported in SODC.
319 ParseWaterMark( pm1
);
324 // ParseBackColor(pm1);
325 ParseBackGround(pm1
);
326 ParseFootNoteSeparator(pm1
);
327 pm1
->SetTextDir(GetTextDirection());
329 LwpUseWhen
* pUseWhen
= GetUseWhen();
330 if(IsComplex() ||( pUseWhen
&& pUseWhen
->IsUseOnAllOddPages()))
332 pm1
->SetPageUsage(enumXFPageUsageMirror
);
335 //Add the page master to stylemanager
336 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
337 OUString pmname
= pXFStyleManager
->AddStyle(pm1
)->GetStyleName();
340 XFMasterPage
* mp1
= new XFMasterPage();
341 mp1
->SetStyleName(GetName()->str());
342 mp1
->SetPageMaster(pmname
);
343 m_StyleName
= pXFStyleManager
->AddStyle(mp1
)->GetStyleName();
346 LwpFooterLayout
* pLayoutFooter
= GetFooterLayout();
349 pLayoutFooter
->SetFoundry(m_pFoundry
);
350 pLayoutFooter
->RegisterStyle(pm1
);
351 pLayoutFooter
->RegisterStyle(mp1
);
355 LwpHeaderLayout
* pLayoutHeader
= GetHeaderLayout();
358 pLayoutHeader
->SetFoundry(m_pFoundry
);
359 pLayoutHeader
->RegisterStyle(pm1
);
360 pLayoutHeader
->RegisterStyle(mp1
);
362 //register child layout style for mirror page and frame
363 RegisterChildStyle();
367 * @descr: Register master page for endnote which name is "endnote"
368 * @return: Return the master page name.
370 OUString
LwpPageLayout::RegisterEndnoteStyle()
372 XFPageMaster
* pm1
= new XFPageMaster();
373 m_pXFPageMaster
= pm1
;
375 ParseGeometry( pm1
);
376 ParseWaterMark( pm1
);
381 // ParseBackColor(pm1);
382 ParseBackGround(pm1
);
383 //ParseFootNoteSeparator(pm1);
384 pm1
->SetTextDir(GetTextDirection());
386 LwpUseWhen
* pUseWhen
= GetUseWhen();
387 if(IsComplex() ||( pUseWhen
&& pUseWhen
->IsUseOnAllOddPages()))
389 pm1
->SetPageUsage(enumXFPageUsageMirror
);
392 //Add the page master to stylemanager
393 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
394 OUString pmname
= pXFStyleManager
->AddStyle(pm1
)->GetStyleName();
397 XFMasterPage
* mp1
= new XFMasterPage();
398 mp1
->SetStyleName(A2OUSTR("Endnote"));
399 mp1
->SetPageMaster(pmname
);
402 LwpFooterLayout
* pLayoutFooter
= GetFooterLayout();
405 pLayoutFooter
->SetFoundry(m_pFoundry
);
406 pLayoutFooter
->RegisterStyle(pm1
);
407 pLayoutFooter
->RegisterStyle(mp1
);
411 LwpHeaderLayout
* pLayoutHeader
= GetHeaderLayout();
414 pLayoutHeader
->SetFoundry(m_pFoundry
);
415 pLayoutHeader
->RegisterStyle(pm1
);
416 pLayoutHeader
->RegisterStyle(mp1
);
419 return pXFStyleManager
->AddStyle(mp1
)->GetStyleName();
422 * @descr: Whether current page layout has columns
425 sal_Bool
LwpPageLayout::HasColumns()
427 return GetNumCols() > 1 ? sal_True
: sal_False
;
431 * @descr: Whether has filler page text in current page layout
434 sal_Bool
LwpPageLayout::HasFillerPageText(LwpFoundry
* pFoundry
)
436 if(!pFoundry
) return sal_False
;
438 sal_Bool bFillerPage
= sal_False
;
439 LwpLayout::UseWhenType eWhenType
= GetUseWhenType();
440 if(eWhenType
==LwpLayout::StartOnOddPage
||eWhenType
==LwpLayout::StartOnEvenPage
)
443 sal_uInt16 nPageNumber
= 0;
445 //get the page number that current page layout inserted
446 nPageNumber
= GetPageNumber(FIRST_LAYOUTPAGENO
)-1;
450 if((eWhenType
==LwpLayout::StartOnOddPage
)&&(LwpTools::IsOddNumber(nPageNumber
)))
452 bFillerPage
= sal_True
;
454 else if((eWhenType
==LwpLayout::StartOnEvenPage
)&&(LwpTools::IsEvenNumber(nPageNumber
)))
456 bFillerPage
= sal_True
;
460 bFillerPage
= sal_False
;
469 * @descr: Parse filler page text
472 void LwpPageLayout::ConvertFillerPageText(XFContentContainer
* pCont
)
474 if(HasFillerPageText(m_pFoundry
))
476 //get filerpage story from division info
477 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
478 LwpDivInfo
* pDivInfo
= static_cast<LwpDivInfo
*>(pDoc
->GetDivInfoID()->obj());
479 LwpStory
* pStory
= static_cast<LwpStory
*>(pDivInfo
->GetFillerPageTextID()->obj());
481 //parse fillerpage story
484 pStory
->XFConvert(pCont
);
489 * @descr: Clear columns style in page layout
492 void LwpPageLayout::ResetXFColumns()
496 m_pXFPageMaster
->SetColumns(NULL
);
500 LwpHeaderLayout
* LwpPageLayout::GetHeaderLayout()
502 LwpVirtualLayout
* pLay
= static_cast<LwpVirtualLayout
*>(GetChildHead()->obj());
505 if( pLay
->GetLayoutType() == LWP_HEADER_LAYOUT
)
506 return ( static_cast<LwpHeaderLayout
*> (pLay
) );
507 pLay
= static_cast<LwpVirtualLayout
*> (pLay
->GetNext()->obj());
512 LwpFooterLayout
* LwpPageLayout::GetFooterLayout()
514 LwpVirtualLayout
* pLay
= static_cast<LwpVirtualLayout
*>(GetChildHead()->obj());
517 if( pLay
->GetLayoutType() == LWP_FOOTER_LAYOUT
)
518 return ( static_cast<LwpFooterLayout
*> (pLay
) );
519 pLay
= static_cast<LwpVirtualLayout
*> (pLay
->GetNext()->obj());
525 * @descr: Get the odd layout if current page layout is mirror page
528 LwpPageLayout
* LwpPageLayout::GetOddChildLayout()
532 LwpVirtualLayout
* pLay
= static_cast<LwpVirtualLayout
*>(GetChildHead()->obj());
535 if( pLay
->GetLayoutType() == LWP_PAGE_LAYOUT
)
537 LwpPageLayout
* pPageLayout
= static_cast<LwpPageLayout
*> (pLay
);
538 LwpUseWhen
* pUseWhen
= pPageLayout
->GetUseWhen();
539 if(pUseWhen
&& pUseWhen
->IsUseOnAllOddPages())
544 pLay
= static_cast<LwpVirtualLayout
*> (pLay
->GetNext()->obj());
551 * @descr: Get margin width of page
554 double LwpPageLayout::GetMarginWidth()
556 double fPagewidth
= GetGeometryWidth();
557 double fLeftMargin
= GetMarginsValue(MARGIN_LEFT
);
558 double fRightMargin
= GetMarginsValue(MARGIN_RIGHT
);
560 return fPagewidth
- (fLeftMargin
+ fRightMargin
);
564 * @descr: Get the pagenumber
565 * @param: if nLayoutNumber =FIRST_LAYOUTPAGENO, return the first page number that current page layout covers
566 =LAST_LAYOUTPAGENO, return the last page number that current page layout covers
567 else, return the specified page number that current page layout covers
569 * @return: if reture value >=0, success to find the page number, or fail.
571 sal_Int32
LwpPageLayout::GetPageNumber(sal_uInt16 nLayoutNumber
)
573 sal_Int16 nPageNumber
= -1;
574 LwpFoundry
* pFoundry
= this->GetFoundry();
575 LwpDocument
* pDoc
= pFoundry
->GetDocument();
576 LwpDLVListHeadTailHolder
* pHeadTail
= static_cast<LwpDLVListHeadTailHolder
*>(pDoc
->GetPageHintsID()->obj());
577 if(!pHeadTail
) return nPageNumber
;
580 LwpPageHint
* pPageHint
=static_cast<LwpPageHint
*>(pHeadTail
->GetHead()->obj());
583 if(*(this->GetObjectID()) == *(pPageHint
->GetPageLayoutID()))
585 sal_uInt16 nNumber
= pPageHint
->GetPageNumber();
586 if(nLayoutNumber
==FIRST_LAYOUTPAGENO
&& pPageHint
->GetLayoutPageNumber()==1)
588 //get the first page number
589 nPageNumber
= nNumber
;
592 else if( nLayoutNumber
==LAST_LAYOUTPAGENO
&& nNumber
>nPageNumber
)
594 //get the last page number
595 nPageNumber
= nNumber
;
596 if(pPageHint
->GetNext()->IsNull())
598 //if is last page number of entire document, reture directly
599 return nPageNumber
+ pDoc
->GetNumberOfPagesBefore();
602 else if(nLayoutNumber
> 0 && pPageHint
->GetLayoutPageNumber() == nLayoutNumber
)
604 //get specified page number
605 nPageNumber
= nNumber
;
610 pPageHint
= static_cast<LwpPageHint
*>(pPageHint
->GetNext()->obj());
614 return nPageNumber
+ 1 + pDoc
->GetNumberOfPagesBefore();
620 * @descr: Get page width and height
623 void LwpPageLayout::GetWidthAndHeight(double& fWidth
, double& fHeight
)
625 //use customized size
626 LwpLayoutGeometry
* pLayoutGeo
= GetGeometry();
629 fWidth
= GetGeometryWidth();
630 fHeight
= GetGeometryHeight();
633 if(GetUsePrinterSettings())
635 //replaced by printer paper size
637 sal_Bool bScreen
= aPrinter
.IsDisplayPrinter();
638 if (!bScreen
)//Printer available
640 Size aPaperSize
= aPrinter
.GetPaperSize();
641 aPaperSize
= aPrinter
.PixelToLogic( aPaperSize
, MapMode( MAP_10TH_MM
) );
642 fWidth
= static_cast<double>(aPaperSize
.Width())/100; //cm unit
643 fHeight
= static_cast<double>(aPaperSize
.Height())/100;
647 //Follow the former design of Lotus WordPro filter, some default will be given:
648 //Page Width: 8.5 Inch -> 21.59 cm
649 //Page Height: 11 Inch -> 27.94 cm
654 //End of modification, by ZF
658 * @descr: Get page width
661 double LwpPageLayout::GetWidth()
663 double fWidth
=0, fHeight
= 0;
664 GetWidthAndHeight(fWidth
, fHeight
);
669 * @descr: Get page height
672 double LwpPageLayout::GetHeight()
674 double fWidth
=0, fHeight
= 0;
675 GetWidthAndHeight(fWidth
, fHeight
);
679 * @descr: Compare the position of layout. If the poistion of this layout is earlier than other layout,return ture, or return false
682 sal_Bool
LwpPageLayout::operator<(LwpPageLayout
& Other
)
684 LwpPara
* pThisPara
= GetPagePosition();
685 LwpPara
* pOtherPara
= Other
.GetPagePosition();
686 if(pThisPara
&& pOtherPara
)
688 if(pThisPara
== pOtherPara
)
690 //If the two layouts in the same para, compare which layout is earlied according to frib order
691 return pThisPara
->ComparePagePosition(this, &Other
);
695 return *pThisPara
< *pOtherPara
;
706 * @descr: Get the position of pagelayout
709 LwpPara
* LwpPageLayout::GetPagePosition()
711 LwpPara
* pPara
= static_cast<LwpPara
*>(GetPosition()->obj());
714 //Get the position from its related section
715 LwpSection
* pSection
= NULL
;
716 LwpFoundry
* pFoundry
= GetFoundry();
719 while(pSection
= pFoundry
->EnumSections(pSection
))
721 if(pSection
->GetPageLayout() == this)
722 return static_cast<LwpPara
*>(pSection
->GetPosition()->obj());
728 LwpHeaderLayout::LwpHeaderLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
729 : LwpPlacableLayout(objHdr
, pStrm
)
733 LwpHeaderLayout::~LwpHeaderLayout()
737 void LwpHeaderLayout::Read()
739 LwpPlacableLayout::Read();
741 if(LwpFileHeader::m_nFileRevision
>= 0x000E)
743 m_pObjStrm
->QuickRead(&m_nBorderOffset
, sizeof(m_nBorderOffset
));
747 m_pObjStrm
->SkipExtra();
751 void LwpHeaderLayout::RegisterStyle(XFPageMaster
* pm1
)
753 XFHeaderStyle
* pHeaderStyle
= new XFHeaderStyle();
755 //Modify page top margin
756 //page top maring: from top of header to the top edge
757 double top
= GetMarginsValue(MARGIN_TOP
);
758 pm1
->SetMargins(-1, -1, top
, -1);
760 ParseMargins(pHeaderStyle
);
761 ParseBorder(pHeaderStyle
);
762 ParseShadow(pHeaderStyle
);
763 // ParseBackColor(pHeaderStyle);
764 ParseBackGround(pHeaderStyle
);
766 ParseWaterMark(pHeaderStyle
);
769 pm1
->SetHeaderStyle(pHeaderStyle
);
772 void LwpHeaderLayout::ParseMargins(XFHeaderStyle
* ph1
)
774 //Set height: from top of header to top of body, including the spacing between header and body
775 double height
= GetGeometryHeight()- GetMarginsValue(MARGIN_TOP
);
776 if( IsAutoGrowDown() )
778 ph1
->SetMinHeight(height
);
782 ph1
->SetHeight(height
);
785 //Set left,right,bottom margins
786 LwpMiddleLayout
* parent
= static_cast<LwpMiddleLayout
*> (GetParent()->obj());
787 //left margin in SODC: the space from the left edge of body to the left edge of header
788 double left
= GetMarginsValue(MARGIN_LEFT
) - parent
->GetMarginsValue(MARGIN_LEFT
);
789 if(left
<=0) //The left margin in SODC can not be minus value
793 //left margin in SODC: the space from the right edge of header to the right edge of body
794 double right
= GetMarginsValue(MARGIN_RIGHT
) - parent
->GetMarginsValue(MARGIN_RIGHT
);
795 if(right
<=0)//The right margin in SODC can not be minus value
799 ph1
->SetMargins( left
, right
, GetMarginsValue(MARGIN_BOTTOM
));
801 //Word Pro has no dynamic spacing, should be set to false
802 ph1
->SetDynamicSpace(sal_False
);
805 void LwpHeaderLayout::ParseBorder(XFHeaderStyle
* pHeaderStyle
)
807 XFBorders
* pBordres
= GetXFBorders();
810 pHeaderStyle
->SetBorders(pBordres
);
814 void LwpHeaderLayout::ParseShadow(XFHeaderStyle
* pHeaderStyle
)
816 XFShadow
* pXFShadow
= GetXFShadow();
819 pHeaderStyle
->SetShadow(pXFShadow
);
824 * @descr: set header back pattern
827 void LwpHeaderLayout::ParsePatternFill(XFHeaderStyle
* pHeaderStyle
)
829 XFBGImage
* pXFBGImage
= this->GetFillPattern();
832 pHeaderStyle
->SetBackImage(pXFBGImage
);
836 * @descr: set header background
839 void LwpHeaderLayout::ParseBackGround(XFHeaderStyle
* pHeaderStyle
)
841 if (this->IsPatternFill())
843 ParsePatternFill(pHeaderStyle
);
847 ParseBackColor(pHeaderStyle
);
851 void LwpHeaderLayout::ParseBackColor(XFHeaderStyle
* pHeaderStyle
)
853 LwpColor
* pColor
= GetBackColor();
856 pHeaderStyle
->SetBackColor(XFColor(pColor
->To24Color()));
861 void LwpHeaderLayout::ParseWaterMark(XFHeaderStyle
* pHeaderStyle
)
863 XFBGImage
* pXFBGImage
= GetXFBGImage();
866 pHeaderStyle
->SetBackImage(pXFBGImage
);
871 void LwpHeaderLayout::RegisterStyle(XFMasterPage
* mp1
)
873 XFHeader
* pHeader
= new XFHeader();
874 LwpObject
* pStory
= m_Content
.obj();
877 LwpGlobalMgr
* pGlobal
= LwpGlobalMgr::GetInstance();
878 LwpChangeMgr
* pChangeMgr
= pGlobal
->GetLwpChangeMgr();
879 pChangeMgr
->SetHeadFootFribMap(sal_True
);
881 //Call the RegisterStyle first to register the styles in header paras, and then XFConvert()
882 pStory
->SetFoundry(m_pFoundry
);
883 pStory
->RegisterStyle();
885 //register child layout style for framelayout,
886 RegisterChildStyle();
888 pChangeMgr
->SetHeadFootChange(pHeader
);
889 pStory
->XFConvert(pHeader
);
891 pChangeMgr
->SetHeadFootFribMap(sal_False
);
893 mp1
->SetHeader(pHeader
);
896 LwpFooterLayout::LwpFooterLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
897 : LwpPlacableLayout( objHdr
, pStrm
)
901 LwpFooterLayout::~LwpFooterLayout()
905 void LwpFooterLayout::Read()
907 LwpPlacableLayout::Read();
909 if(LwpFileHeader::m_nFileRevision
>= 0x000E)
911 m_pObjStrm
->QuickRead(&m_nBorderOffset
, sizeof(m_nBorderOffset
));
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
= static_cast<LwpMiddleLayout
*> (GetParent()->obj());
955 double left
= GetMarginsValue(MARGIN_LEFT
) - parent
->GetMarginsValue(MARGIN_LEFT
);
956 if(left
<=0) //The left margin in SODC can not be minus value
960 double right
= GetMarginsValue(MARGIN_RIGHT
) - parent
->GetMarginsValue(MARGIN_RIGHT
);
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
);