LibreOffice Module lotuswordpro (master) 1
lwppagelayout.cxx
Go to the documentation of this file.
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#include <memory>
58#include "lwppagelayout.hxx"
59#include "lwplaypiece.hxx"
60#include "lwpfootnote.hxx"
61#include "lwpdoc.hxx"
62#include "lwpholder.hxx"
63#include "lwppagehint.hxx"
64#include "lwpdivinfo.hxx"
65#include "lwpstory.hxx"
66#include <o3tl/numeric.hxx>
70#include <xfilter/xfheader.hxx>
73#include <xfilter/xffooter.hxx>
74#include <lwpchangemgr.hxx>
75#include <lwpfilehdr.hxx>
76#include <lwpglobalmgr.hxx>
78#include <sal/log.hxx>
79#include <vcl/print.hxx>
80
82 : LwpLayout(objHdr, pStrm)
83 , m_nPrinterBin(0)
84 , m_nBdroffset(0)
85 , m_pXFPageMaster(nullptr)
86{
87}
88
91{
93
95 {
96 // read PreRevBLayout...
97 }
98
99 m_nPrinterBin = m_pObjStrm->QuickReaduInt16();
101
102 if (LwpFileHeader::m_nFileRevision >= 0x000B)
103 m_nBdroffset = m_pObjStrm->QuickReadInt32();
104
105 if (m_pObjStrm->CheckExtra())
106 {
108 m_pObjStrm->SkipExtra();
109 }
110}
111
112void LwpPageLayout::Parse(IXFStream* pOutputStream)
113{
114 //Only parse this layout
116 if (pStory.is())
117 {
118 pStory->SetFoundry(m_pFoundry);
119 pStory->DoParse(pOutputStream); //Do not parse the next story
120 }
121}
122
128{
129 double fLeft = GetMarginsValue(MARGIN_LEFT);
130 double fRight = GetMarginsValue(MARGIN_RIGHT);
131 double fTop = GetMarginsValue(MARGIN_TOP);
132 double fBottom = GetMarginsValue(MARGIN_BOTTOM);
133
134 pm1->SetMargins(fLeft, fRight, fTop, fBottom);
135}
136
142{
143 /*
144 LwpLayoutGeometry* pLayoutGeo = GetGeometry();
145 if(pLayoutGeo)
146 {
147 pm1->SetPageHeight( GetGeometryHeight() );
148 pm1->SetPageWidth( GetGeometryWidth() );
149 }
150 */
151 double fWidth = 0;
152 double fHeight = 0;
153 GetWidthAndHeight(fWidth, fHeight);
154 pm1->SetPageWidth(fWidth);
155 pm1->SetPageHeight(fHeight);
156}
157
163{
164 std::unique_ptr<XFBGImage> xXFBGImage(GetXFBGImage());
165 if (xXFBGImage)
166 {
167 pm1->SetBackImage(xXFBGImage);
168 }
169}
170
176{
177 XFColumns* pColumns = GetXFColumns();
178 if (pColumns)
179 {
180 pm1->SetColumns(pColumns);
181 }
182}
183
189{
190 std::unique_ptr<XFBorders> pBordres = GetXFBorders();
191 if (pBordres)
192 {
193 pm1->SetBorders(std::move(pBordres));
194 }
195}
196
202{
203 XFShadow* pXFShadow = GetXFShadow();
204 if (pXFShadow)
205 {
206 pm1->SetShadow(pXFShadow);
207 }
208}
209
215{
216 std::unique_ptr<XFBGImage> xXFBGImage(GetFillPattern());
217 if (xXFBGImage)
218 {
219 pm1->SetBackImage(xXFBGImage);
220 }
221}
227{
228 if (IsPatternFill())
229 {
230 ParsePatternFill(pm1);
231 }
232 else
233 {
234 ParseBackColor(pm1);
235 }
236}
237
243{
244 LwpColor* pColor = GetBackColor();
245 if (pColor)
246 {
247 pm1->SetBackColor(XFColor(pColor->To24Color()));
248 }
249}
250
256{
257 //Get the footnoteoptions for the root document
258 LwpDocument* pDocument = m_pFoundry ? m_pFoundry->GetDocument() : nullptr;
259 if (!pDocument)
260 return;
261
262 LwpObjectID* pFontnodeId = pDocument->GetValidFootnoteOpts();
263
264 LwpFootnoteOptions* pFootnoteOpts
265 = pFontnodeId ? dynamic_cast<LwpFootnoteOptions*>(pFontnodeId->obj().get()) : nullptr;
266 if (!pFootnoteOpts)
267 return;
268
269 LwpFootnoteSeparatorOptions& rFootnoteSep = pFootnoteOpts->GetFootnoteSeparator();
270 //set length
271 sal_uInt32 nLengthPercent = 100;
272 double fWidth = 0;
273 if (rFootnoteSep.HasSeparator())
274 {
275 fWidth = rFootnoteSep.GetTopBorderWidth();
276 }
277 if (rFootnoteSep.HasCustomLength())
278 {
279 const double fMarginWidth = GetMarginWidth();
280 if (fMarginWidth == 0.0)
281 throw o3tl::divide_by_zero();
282
283 nLengthPercent = static_cast<sal_uInt32>(
284 100 * LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetLength()) / fMarginWidth);
285 if (nLengthPercent > 100)
286 nLengthPercent = 100;
287 }
288 double fAbove = LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetAbove());
289 double fBelow = LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetBelow());
290 LwpColor aColor = rFootnoteSep.GetTopBorderColor();
292 if (rFootnoteSep.GetIndent() > 0)
293 {
294 const double fMarginWidth = GetMarginWidth();
295 if (fMarginWidth == 0.0)
296 throw o3tl::divide_by_zero();
297
298 //SODC don't support indent
299 sal_uInt32 nIndentPercent = static_cast<sal_uInt32>(
300 100 * LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetIndent()) / fMarginWidth);
301 if (nIndentPercent + nLengthPercent >= 100)
302 eAlignType = enumXFAlignEnd;
303 }
304 if (aColor.IsValidColor())
305 {
306 XFColor aXFColor(aColor.To24Color());
307 pm1->SetFootNoteSeparator(eAlignType, fWidth, nLengthPercent, fAbove, fBelow, aXFColor);
308 }
309}
310
316{
317 std::unique_ptr<XFPageMaster> xpm1(new XFPageMaster);
318
319 ParseGeometry(xpm1.get());
320 //Does not process LayoutScale, for watermark is not supported in SODC.
321 ParseWaterMark(xpm1.get());
322 ParseMargins(xpm1.get());
323 ParseColumns(xpm1.get());
324 ParseBorders(xpm1.get());
325 ParseShadow(xpm1.get());
326 ParseBackGround(xpm1.get());
327 ParseFootNoteSeparator(xpm1.get());
328 xpm1->SetTextDir(GetTextDirection());
329
330 LwpUseWhen* pUseWhen = GetUseWhen();
331 if (IsComplex() || (pUseWhen && pUseWhen->IsUseOnAllOddPages()))
332 {
333 xpm1->SetPageUsage(enumXFPageUsageMirror);
334 }
335
336 //Add the page master to stylemanager
338 XFPageMaster* pm1
339 = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(std::move(xpm1)).m_pStyle);
340 m_pXFPageMaster = pm1;
341 OUString pmname = pm1->GetStyleName();
342
343 //Add master page
344 std::unique_ptr<XFMasterPage> p1(new XFMasterPage);
345 p1->SetStyleName(GetName().str());
346 p1->SetPageMaster(pmname);
347 XFMasterPage* p1_added
348 = static_cast<XFMasterPage*>(pXFStyleManager->AddStyle(std::move(p1)).m_pStyle);
349 m_StyleName = p1_added->GetStyleName();
350
351 //Set footer style
352 LwpFooterLayout* pLayoutFooter = GetFooterLayout();
353 if (pLayoutFooter)
354 {
355 pLayoutFooter->SetFoundry(m_pFoundry);
356 pLayoutFooter->RegisterStyle(pm1);
357 pLayoutFooter->RegisterStyle(p1_added);
358 }
359
360 //Set header style
361 LwpHeaderLayout* pLayoutHeader = GetHeaderLayout();
362 if (pLayoutHeader)
363 {
364 pLayoutHeader->SetFoundry(m_pFoundry);
365 pLayoutHeader->RegisterStyle(pm1);
366 pLayoutHeader->RegisterStyle(p1_added);
367 }
368 //register child layout style for mirror page and frame
370}
371
377{
378 std::unique_ptr<XFPageMaster> pm1(new XFPageMaster);
379
380 ParseGeometry(pm1.get());
381 ParseWaterMark(pm1.get());
382 ParseMargins(pm1.get());
383 ParseColumns(pm1.get());
384 ParseBorders(pm1.get());
385 ParseShadow(pm1.get());
386 ParseBackGround(pm1.get());
387 pm1->SetTextDir(GetTextDirection());
388
389 LwpUseWhen* pUseWhen = GetUseWhen();
390 if (IsComplex() || (pUseWhen && pUseWhen->IsUseOnAllOddPages()))
391 {
392 pm1->SetPageUsage(enumXFPageUsageMirror);
393 }
394
395 //Add the page master to stylemanager
398 = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(std::move(pm1)).m_pStyle);
399 OUString pmname = m_pXFPageMaster->GetStyleName();
400
401 //Add master page
402 std::unique_ptr<XFMasterPage> p1(new XFMasterPage);
403 p1->SetStyleName("Endnote");
404 p1->SetPageMaster(pmname);
405
406 //Set footer style
407 LwpFooterLayout* pLayoutFooter = GetFooterLayout();
408 if (pLayoutFooter)
409 {
410 pLayoutFooter->SetFoundry(m_pFoundry);
411 pLayoutFooter->RegisterStyle(m_pXFPageMaster);
412 pLayoutFooter->RegisterStyle(p1.get());
413 }
414
415 //Set header style
416 LwpHeaderLayout* pLayoutHeader = GetHeaderLayout();
417 if (pLayoutHeader)
418 {
419 pLayoutHeader->SetFoundry(m_pFoundry);
420 pLayoutHeader->RegisterStyle(m_pXFPageMaster);
421 pLayoutHeader->RegisterStyle(p1.get());
422 }
423
424 return pXFStyleManager->AddStyle(std::move(p1)).m_pStyle->GetStyleName();
425}
430bool LwpPageLayout::HasColumns() { return GetNumCols() > 1; }
431
437{
438 if (!pFoundry)
439 return false;
440
441 bool bFillerPage = false;
443 if (eWhenType == LwpLayout::StartOnOddPage || eWhenType == LwpLayout::StartOnEvenPage)
444 {
445 //get the page number that current page layout inserted
446 sal_Int32 nPageNumber = GetPageNumber(FIRST_LAYOUTPAGENO) - 1;
447
448 if (nPageNumber > 0)
449 {
450 if ((eWhenType == LwpLayout::StartOnOddPage) && (LwpTools::IsOddNumber(nPageNumber)))
451 {
452 bFillerPage = true;
453 }
454 else if ((eWhenType == LwpLayout::StartOnEvenPage)
455 && (LwpTools::IsEvenNumber(nPageNumber)))
456 {
457 bFillerPage = true;
458 }
459 else
460 {
461 bFillerPage = false;
462 }
463 }
464 }
465
466 return bFillerPage;
467}
468
474{
476 return;
477
478 //get fillerpage story from division info
480 LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pDoc->GetDivInfoID().obj().get());
481 LwpStory* pStory
482 = pDivInfo ? dynamic_cast<LwpStory*>(pDivInfo->GetFillerPageTextID().obj().get()) : nullptr;
483
484 //parse fillerpage story
485 if (pStory)
486 {
487 pStory->XFConvert(pCont);
488 }
489}
495{
496 if (m_pXFPageMaster)
497 {
498 m_pXFPageMaster->SetColumns(nullptr);
499 }
500}
501
503{
505 dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get()));
506 while (xLay.is())
507 {
508 if (xLay->GetLayoutType() == LWP_HEADER_LAYOUT)
509 return dynamic_cast<LwpHeaderLayout*>(xLay.get());
511 dynamic_cast<LwpVirtualLayout*>(xLay->GetNext().obj().get()));
512 if (xNext == xLay)
513 {
514 SAL_WARN("lwp", "loop in layout");
515 break;
516 }
517 xLay = xNext;
518 }
519 return nullptr;
520}
521
523{
525 dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get()));
526 while (xLay.is())
527 {
528 if (xLay->GetLayoutType() == LWP_FOOTER_LAYOUT)
529 return dynamic_cast<LwpFooterLayout*>(xLay.get());
531 dynamic_cast<LwpVirtualLayout*>(xLay->GetNext().obj().get()));
532 if (xNext == xLay)
533 {
534 SAL_WARN("lwp", "loop in layout");
535 break;
536 }
537 xLay = xNext;
538 }
539 return nullptr;
540}
541
547{
548 if (!IsComplex())
549 return nullptr;
551 dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get()));
553 while (xLay.is())
554 {
555 bool bAlreadySeen = !aSeen.insert(xLay.get()).second;
556 if (bAlreadySeen)
557 throw std::runtime_error("loop in conversion");
558
559 if (xLay->GetLayoutType() == LWP_PAGE_LAYOUT)
560 {
561 LwpPageLayout* pPageLayout = static_cast<LwpPageLayout*>(xLay.get());
562 LwpUseWhen* pUseWhen = pPageLayout->GetUseWhen();
563 if (pUseWhen && pUseWhen->IsUseOnAllOddPages())
564 {
565 return pPageLayout;
566 }
567 }
568 xLay.set(dynamic_cast<LwpVirtualLayout*>(xLay->GetNext().obj().get()));
569 }
570 return nullptr;
571}
572
578{
579 double fPagewidth = GetGeometryWidth();
580 double fLeftMargin = GetMarginsValue(MARGIN_LEFT);
581 double fRightMargin = GetMarginsValue(MARGIN_RIGHT);
582
583 return fPagewidth - (fLeftMargin + fRightMargin);
584}
585
594sal_Int32 LwpPageLayout::GetPageNumber(sal_uInt16 nLayoutNumber)
595{
596 sal_Int16 nPageNumber = -1;
597 LwpFoundry* pFoundry = GetFoundry();
598 if (!pFoundry)
599 return nPageNumber;
600 LwpDocument* pDoc = pFoundry->GetDocument();
601 LwpDLVListHeadTailHolder* pHeadTail
602 = dynamic_cast<LwpDLVListHeadTailHolder*>(pDoc->GetPageHintsID().obj().get());
603 if (!pHeadTail)
604 return nPageNumber;
605
606 //get first pagehint
607 LwpPageHint* pPageHint = dynamic_cast<LwpPageHint*>(pHeadTail->GetHead().obj().get());
609 while (pPageHint)
610 {
611 bool bAlreadySeen = !aSeen.insert(pPageHint).second;
612 if (bAlreadySeen)
613 throw std::runtime_error("loop in conversion");
614
615 if (GetObjectID() == pPageHint->GetPageLayoutID())
616 {
617 sal_uInt16 nNumber = pPageHint->GetPageNumber();
618 if (nLayoutNumber == FIRST_LAYOUTPAGENO && pPageHint->GetLayoutPageNumber() == 1)
619 {
620 //get the first page number
621 nPageNumber = nNumber;
622 break;
623 }
624 else if (nLayoutNumber == LAST_LAYOUTPAGENO && nNumber > nPageNumber)
625 {
626 //get the last page number
627 nPageNumber = nNumber;
628 if (pPageHint->GetNext().IsNull())
629 {
630 //if is last page number of entire document, return directly
631 return nPageNumber + pDoc->GetNumberOfPagesBefore();
632 }
633 }
634 else if (nLayoutNumber > 0 && pPageHint->GetLayoutPageNumber() == nLayoutNumber)
635 {
636 //get specified page number
637 nPageNumber = nNumber;
638 break;
639 }
640 }
641
642 pPageHint = dynamic_cast<LwpPageHint*>(pPageHint->GetNext().obj().get());
643 }
644 if (nPageNumber >= 0)
645 {
646 return nPageNumber + 1 + pDoc->GetNumberOfPagesBefore();
647 }
648 return -1;
649}
650
655void LwpPageLayout::GetWidthAndHeight(double& fWidth, double& fHeight)
656{
657 //use customized size
658 LwpLayoutGeometry* pLayoutGeo = GetGeometry();
659 if (pLayoutGeo)
660 {
661 fWidth = GetGeometryWidth();
662 fHeight = GetGeometryHeight();
663 }
664
666 {
667 //replaced by printer paper size
669 bool bScreen = pPrinter->IsDisplayPrinter();
670 if (!bScreen) //Printer available
671 {
672 Size aPaperSize = pPrinter->GetPaperSize();
673 aPaperSize = pPrinter->PixelToLogic(aPaperSize, MapMode(MapUnit::Map10thMM));
674 fWidth = static_cast<double>(aPaperSize.Width()) / 100; //cm unit
675 fHeight = static_cast<double>(aPaperSize.Height()) / 100;
676 }
677 }
678
679 //Follow the former design of Lotus WordPro filter, some default will be given:
680 //Page Width: 8.5 Inch -> 21.59 cm
681 //Page Height: 11 Inch -> 27.94 cm
682 if (fWidth < 4.39)
683 fWidth = 21.59;
684 if (fHeight < 4.49)
685 fHeight = 27.94;
686 //End of modification, by ZF
687}
688
694{
695 double fWidth = 0, fHeight = 0;
696 GetWidthAndHeight(fWidth, fHeight);
697 return fWidth;
698}
699
705{
706 double fWidth = 0, fHeight = 0;
707 GetWidthAndHeight(fWidth, fHeight);
708 return fHeight;
709}
715{
716 LwpPara* pThisPara = GetPagePosition();
717 LwpPara* pOtherPara = Other.GetPagePosition();
718 if (pThisPara && pOtherPara)
719 {
720 if (pThisPara == pOtherPara)
721 {
722 //If the two layouts in the same para, compare which layout is earlied according to frib order
723 return pThisPara->ComparePagePosition(this, &Other);
724 }
725 else
726 {
727 return *pThisPara < *pOtherPara;
728 }
729 }
730
731 return pThisPara == nullptr;
732}
733
739{
740 LwpPara* pPara = dynamic_cast<LwpPara*>(GetPosition().obj().get());
741 if (pPara)
742 return pPara;
743 //Get the position from its related section
744 LwpFoundry* pFoundry = GetFoundry();
745 if (pFoundry)
746 {
747 LwpSection* pSection = nullptr;
748 while ((pSection = pFoundry->EnumSections(pSection)))
749 {
750 if (pSection->GetPageLayout() == this)
751 return dynamic_cast<LwpPara*>(pSection->GetPosition().obj().get());
752 }
753 }
754
755 return nullptr;
756}
758 : LwpPlacableLayout(objHdr, pStrm)
759 , m_nBorderOffset(0)
760{
761}
762
764
766{
768
769 if (LwpFileHeader::m_nFileRevision >= 0x000E)
770 m_nBorderOffset = m_pObjStrm->QuickReadInt32();
771 else
772 m_nBorderOffset = 0;
773 m_pObjStrm->SkipExtra();
774}
775
777{
778 std::unique_ptr<XFHeaderStyle> xHeaderStyle(new XFHeaderStyle);
779
780 //Modify page top margin
781 //page top margin: from top of header to the top edge
783 pm1->SetMargins(-1, -1, top, -1);
784
785 ParseMargins(xHeaderStyle.get());
786 ParseBorder(xHeaderStyle.get());
787 ParseShadow(xHeaderStyle.get());
788 ParseBackGround(xHeaderStyle.get());
789
790 ParseWaterMark(xHeaderStyle.get());
791 //End by
792
793 pm1->SetHeaderStyle(xHeaderStyle.release());
794}
795
797{
798 //Set height: from top of header to top of body, including the spacing between header and body
799 double height = GetGeometryHeight() - GetMarginsValue(MARGIN_TOP);
800 if (GetIsAutoGrowDown())
801 {
802 ph1->SetMinHeight(height);
803 }
804 else
805 {
806 ph1->SetHeight(height);
807 }
808
809 //Set left,right,bottom margins
810 LwpMiddleLayout* parent = dynamic_cast<LwpMiddleLayout*>(GetParent().obj().get());
811 //left margin in SODC: the space from the left edge of body to the left edge of header
812 double left
813 = GetMarginsValue(MARGIN_LEFT) - (parent ? parent->GetMarginsValue(MARGIN_LEFT) : 0);
814 if (left <= 0) //The left margin in SODC can not be minus value
815 {
816 left = -1;
817 }
818 //left margin in SODC: the space from the right edge of header to the right edge of body
819 double right
820 = GetMarginsValue(MARGIN_RIGHT) - (parent ? parent->GetMarginsValue(MARGIN_RIGHT) : 0);
821 if (right <= 0) //The right margin in SODC can not be minus value
822 {
823 right = -1;
824 }
826
827 //Word Pro has no dynamic spacing, should be set to false
828 ph1->SetDynamicSpace(false);
829}
830
832{
833 std::unique_ptr<XFBorders> pBordres = GetXFBorders();
834 if (pBordres)
835 {
836 pHeaderStyle->SetBorders(std::move(pBordres));
837 }
838}
839
841{
842 XFShadow* pXFShadow = GetXFShadow();
843 if (pXFShadow)
844 {
845 pHeaderStyle->SetShadow(pXFShadow);
846 }
847}
848
854{
855 std::unique_ptr<XFBGImage> xXFBGImage(GetFillPattern());
856 if (xXFBGImage)
857 {
858 pHeaderStyle->SetBackImage(xXFBGImage);
859 }
860}
866{
867 if (IsPatternFill())
868 {
869 ParsePatternFill(pHeaderStyle);
870 }
871 else
872 {
873 ParseBackColor(pHeaderStyle);
874 }
875}
876
878{
879 LwpColor* pColor = GetBackColor();
880 if (pColor)
881 {
882 pHeaderStyle->SetBackColor(XFColor(pColor->To24Color()));
883 }
884}
885
887{
888 std::unique_ptr<XFBGImage> xXFBGImage(GetXFBGImage());
889 if (xXFBGImage)
890 {
891 pHeaderStyle->SetBackImage(xXFBGImage);
892 }
893}
894//End by
895
897{
900 if (pStory.is())
901 {
903 LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
904 pChangeMgr->SetHeadFootFribMap(true);
905
906 //Call the RegisterStyle first to register the styles in header paras, and then XFConvert()
907 pStory->SetFoundry(m_pFoundry);
908 pStory->DoRegisterStyle();
909 //, 06/27/2005
910 //register child layout style for framelayout,
912 //End
913 pChangeMgr->SetHeadFootChange(xHeader.get());
914 pStory->DoXFConvert(xHeader.get());
915
916 pChangeMgr->SetHeadFootFribMap(false);
917 }
918 mp1->SetHeader(xHeader);
919}
920
922 : LwpPlacableLayout(objHdr, pStrm)
923 , m_nBorderOffset(0)
924{
925}
926
928
930{
932
933 if (LwpFileHeader::m_nFileRevision >= 0x000E)
934 m_nBorderOffset = m_pObjStrm->QuickReadInt32();
935 else
936 m_nBorderOffset = 0;
937 m_pObjStrm->SkipExtra();
938}
939
941{
942 std::unique_ptr<XFFooterStyle> xFooterStyle(new XFFooterStyle);
943
944 //Modify page bottom margin
945 //page bottom margin: from bottom of footer to the bottom edge
947 pm1->SetMargins(-1, -1, -1, bottom);
948
949 ParseMargins(xFooterStyle.get());
950 ParseBorder(xFooterStyle.get());
951 ParseShadow(xFooterStyle.get());
952 ParseBackGround(xFooterStyle.get());
953
954 ParseWaterMark(xFooterStyle.get());
955
956 pm1->SetFooterStyle(xFooterStyle.release());
957}
958
960{
961 //Set height: from top of header to top of body, including the spacing between header and body
963 if (IsAutoGrowUp())
964 {
965 pFooterStyle->SetMinHeight(height);
966 }
967 else
968 {
969 pFooterStyle->SetHeight(height);
970 }
971
972 //Set left,right,top margins
973 LwpMiddleLayout* parent = dynamic_cast<LwpMiddleLayout*>(GetParent().obj().get());
974 double left
975 = GetMarginsValue(MARGIN_LEFT) - (parent ? parent->GetMarginsValue(MARGIN_LEFT) : 0);
976 if (left <= 0) //The left margin in SODC can not be minus value
977 {
978 left = -1;
979 }
980 double right
981 = GetMarginsValue(MARGIN_RIGHT) - (parent ? parent->GetMarginsValue(MARGIN_RIGHT) : 0);
982 if (right <= 0) //The left margin in SODC can not be minus value
983 {
984 right = -1;
985 }
987
988 //Word Pro has no dynamic spacing, should be set to false
989 pFooterStyle->SetDynamicSpace(false);
990}
991
993{
994 std::unique_ptr<XFBorders> pBordres = GetXFBorders();
995 if (pBordres)
996 {
997 pFooterStyle->SetBorders(std::move(pBordres));
998 }
999}
1000
1002{
1003 XFShadow* pXFShadow = GetXFShadow();
1004 if (pXFShadow)
1005 {
1006 pFooterStyle->SetShadow(pXFShadow);
1007 }
1008}
1014{
1015 std::unique_ptr<XFBGImage> xXFBGImage(GetFillPattern());
1016 if (xXFBGImage)
1017 {
1018 pFooterStyle->SetBackImage(xXFBGImage);
1019 }
1020}
1026{
1027 if (IsPatternFill())
1028 {
1029 ParsePatternFill(pFooterStyle);
1030 }
1031 else
1032 {
1033 ParseBackColor(pFooterStyle);
1034 }
1035}
1036
1038{
1039 LwpColor* pColor = GetBackColor();
1040 if (pColor)
1041 {
1042 pFooterStyle->SetBackColor(XFColor(pColor->To24Color()));
1043 }
1044}
1045
1047{
1050 //Call the RegisterStyle first to register the styles in footer paras, and then XFConvert()
1051 if (pStory.is())
1052 {
1054 LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
1055 pChangeMgr->SetHeadFootFribMap(true);
1056
1057 pStory->SetFoundry(m_pFoundry);
1058 pStory->DoRegisterStyle();
1059 //register child layout style for framelayout,
1061
1062 pChangeMgr->SetHeadFootChange(xFooter.get());
1063
1064 pStory->DoXFConvert(xFooter.get());
1065
1066 pChangeMgr->SetHeadFootFribMap(false);
1067 }
1068 mp1->SetFooter(xFooter);
1069}
1070
1072{
1073 std::unique_ptr<XFBGImage> xXFBGImage(GetXFBGImage());
1074 if (xXFBGImage)
1075 {
1076 pFooterStyle->SetBackImage(xXFBGImage);
1077 }
1078}
1079
1080/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Stream wrapper for sax writer.
Definition: ixfstream.hxx:72
virtual OUString GetStyleName()=0
@descr: return the style name.
void Read(LwpObjectStream *pStrm)
@descr read atomholder from object stream the default encoding used in Word Pro is 1252
void SetHeadFootFribMap(bool bFlag)
void SetHeadFootChange(XFContentContainer *pCont)
lwpcolor class (red, green, blue, extra)
Definition: lwpcolor.hxx:71
bool IsValidColor() const
Definition: lwpcolor.hxx:114
sal_uInt32 To24Color()
@descr return the BGR format
Definition: lwpcolor.cxx:66
LwpObjectID & GetParent()
Definition: lwpdlvlist.hxx:111
LwpObjectID & GetChildHead()
Definition: lwpdlvlist.hxx:109
LwpAtomHolder & GetName()
Definition: lwpdlvlist.hxx:108
VO_HEADTAILHOLDER, LwpDLVListHeadTailHolder, contains a LwpDLVListHeadTail (Head and tail id)
Definition: lwpholder.hxx:87
LwpObjectID & GetHead()
Definition: lwpholder.hxx:91
LwpObjectID & GetNext()
Definition: lwpdlvlist.hxx:75
LwpObjectID & GetFillerPageTextID()
Definition: lwpdivinfo.hxx:78
Document object, represent document and division.
Definition: lwpdoc.hxx:76
LwpObjectID & GetDivInfoID()
Definition: lwpdoc.hxx:183
LwpObjectID * GetValidFootnoteOpts()
@descr Get the footnoteoptions from the root document
Definition: lwpdoc.cxx:443
sal_uInt16 GetNumberOfPagesBefore()
@descr Get the numbers of page before current division
Definition: lwpdoc.cxx:734
LwpObjectID & GetPageHintsID()
Definition: lwpdoc.hxx:184
static sal_uInt16 m_nFileRevision
Definition: lwpfilehdr.hxx:77
void ParseMargins(XFFooterStyle *pFooterStyle)
void ParseWaterMark(XFFooterStyle *pFooterStyle)
virtual ~LwpFooterLayout() override
void ParseBackColor(XFFooterStyle *pFooterStyle)
void ParsePatternFill(XFFooterStyle *pFooterStyle)
@descr: set footer back pattern
void ParseBackGround(XFFooterStyle *pFooterStyle)
@descr: set footer background
void ParseBorder(XFFooterStyle *pFooterStyle)
sal_Int32 m_nBorderOffset
void Read() override
@descr Read name of LwpDLNFVList from object stream
void RegisterStyle(XFPageMaster *pm1)
void ParseShadow(XFFooterStyle *pFooterStyle)
LwpFooterLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
VO_FOOTNOTEOPTS object.
LwpFootnoteSeparatorOptions & GetFootnoteSeparator()
footnote separator options information
sal_uInt32 GetLength() const
sal_uInt32 GetIndent() const
sal_uInt32 GetBelow() const
sal_uInt32 GetAbove() const
LwpSection * EnumSections(LwpSection *pSection)
@descr: Get next section
Definition: lwpfoundry.cxx:244
LwpDocument * GetDocument()
Definition: lwpfoundry.hxx:254
XFStyleManager * GetXFStyleManager()
LwpChangeMgr * GetLwpChangeMgr()
static LwpGlobalMgr * GetInstance(LwpSvStream *pSvStream=nullptr)
virtual ~LwpHeaderLayout() override
void ParseMargins(XFHeaderStyle *ph1)
sal_Int32 m_nBorderOffset
void ParseShadow(XFHeaderStyle *ph1)
void RegisterStyle(XFPageMaster *pm1)
void ParseBackColor(XFHeaderStyle *ph1)
LwpHeaderLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
void ParsePatternFill(XFHeaderStyle *ph1)
@descr: set header back pattern
void ParseWaterMark(XFHeaderStyle *ph1)
void ParseBorder(XFHeaderStyle *ph1)
void Read() override
@descr Read name of LwpDLNFVList from object stream
void ParseBackGround(XFHeaderStyle *ph1)
@descr: set header background
UseWhenType GetUseWhenType()
@descr: Get use when type
Definition: lwplayout.cxx:1651
void Read() override
@descr Read name of LwpDLNFVList from object stream
Definition: lwplayout.cxx:1478
XFShadow * GetXFShadow()
@descr: create xfshadow
Definition: lwplayout.cxx:1860
LwpObjectID & GetPosition()
Definition: lwplayout.hxx:449
virtual sal_uInt16 GetNumCols() override
@descr: Get columns number
Definition: lwplayout.cxx:1517
@ StartOnEvenPage
Definition: lwplayout.hxx:442
@ StartOnOddPage
Definition: lwplayout.hxx:441
XFColumns * GetXFColumns()
@descr: Create and return XFColumns object
Definition: lwplayout.cxx:1570
std::unique_ptr< XFBorders > GetXFBorders()
@descr: create xfborder.
Definition: lwplayout.cxx:834
std::unique_ptr< XFBGImage > GetXFBGImage()
@descr: Create and return xfbgimage object for watermark
Definition: lwplayout.cxx:1381
virtual bool IsAutoGrowUp() override
@descr: Whether the height of layout is auto grow up
Definition: lwplayout.cxx:1169
enumXFTextDir GetTextDirection()
@descr: Get text direction settings.
Definition: lwplayout.cxx:860
LwpObjectID m_Content
Definition: lwplayout.hxx:401
std::unique_ptr< XFBGImage > GetFillPattern()
@descr: Get the fill pattern style.
Definition: lwplayout.cxx:1109
double GetGeometryWidth()
@descr: Get layout width, measured by "cm"
Definition: lwplayout.cxx:677
bool IsPatternFill()
@descr: Whether the fill is pattern fill or not
Definition: lwplayout.cxx:1094
LwpColor * GetBackColor()
@descr: Get background color.
Definition: lwplayout.cxx:894
LwpLayoutGeometry * GetGeometry()
@descr: Get the geometry of current layout
Definition: lwplayout.cxx:634
bool GetUsePrinterSettings()
@descr: Whether the page uses the printer setting
Definition: lwplayout.cxx:1437
double GetGeometryHeight()
@descr: Get layout height, measured by "cm"
Definition: lwplayout.cxx:662
Base class of all Lwp VO objects.
Definition: lwpobjhdr.hxx:71
object id class
Definition: lwpobjid.hxx:79
rtl::Reference< LwpObject > obj(VO_TYPE tag=VO_INVALID) const
@descr get object from object factory per the object id
Definition: lwpobjid.cxx:183
bool IsNull() const
Definition: lwpobjid.hxx:110
void SetFoundry(LwpFoundry *pFoundry)
Definition: lwpobj.hxx:137
LwpFoundry * m_pFoundry
Definition: lwpobj.hxx:91
virtual void RegisterStyle()
@descr default register style function
Definition: lwpobj.cxx:100
std::unique_ptr< LwpObjectStream > m_pObjStrm
Definition: lwpobj.hxx:90
LwpFoundry * GetFoundry()
Definition: lwpobj.hxx:136
LwpObjectID & GetObjectID()
Definition: lwpobj.hxx:138
LwpObjectID & GetPosition()
Definition: lwpsection.hxx:75
LwpObjectID & GetPageLayoutID()
sal_uInt16 GetPageNumber() const
sal_uInt16 GetLayoutPageNumber() const
virtual void RegisterStyle() override
@descr: Register master page and page master style
void ParseBorders(XFPageMaster *pm1)
@descr: set page borders
bool HasFillerPageText(LwpFoundry const *pFoundry)
@descr: Whether has filler page text in current page layout
void ParseBackColor(XFPageMaster *pm1)
@descr: set page back color
LwpHeaderLayout * GetHeaderLayout()
bool HasColumns()
@descr: Whether current page layout has columns
virtual ~LwpPageLayout() override
LwpPageLayout * GetOddChildLayout()
@descr: Get the odd layout if current page layout is mirror page
LwpAtomHolder m_PaperName
sal_Int32 m_nBdroffset
virtual sal_Int32 GetPageNumber(sal_uInt16 nLayoutNumber) override
@descr: Get the pagenumber
void GetWidthAndHeight(double &fWidth, double &fHeight)
@descr: Get page width and height
void ParseColumns(XFPageMaster *pm1)
@descr: set page columns
OUString RegisterEndnoteStyle()
@descr: Register master page for endnote which name is "endnote"
void ParseBackGround(XFPageMaster *pm1)
@descr: set page background
void ParseFootNoteSeparator(XFPageMaster *pm1)
@descr: set page footnote separator information
void ConvertFillerPageText(XFContentContainer *pCont)
@descr: Parse filler page text
void ParsePatternFill(XFPageMaster *pm1)
@descr: set page back pattern
bool operator<(LwpPageLayout &Other)
@descr: Compare the position of layout.
void ParseGeometry(XFPageMaster *pm1)
@descr: set page height and width
sal_uInt16 m_nPrinterBin
void ResetXFColumns()
@descr: Clear columns style in page layout
double GetMarginWidth()
@descr: Get margin width of page
double GetHeight() override
@descr: Get page height
void ParseMargins(XFPageMaster *pm1)
@descr: set page margins
void ParseShadow(XFPageMaster *pm1)
@descr: set page shadow
void Read() override
@descr Read name of LwpDLNFVList from object stream
LwpPara * GetPagePosition()
@descr: Get the position of pagelayout
void ParseWaterMark(XFPageMaster *pm1)
@descr: set page watermark
LwpFooterLayout * GetFooterLayout()
virtual void Parse(IXFStream *pOutputStream) override
@descr default parse function
double GetWidth() override
@descr: Get page width
XFPageMaster * m_pXFPageMaster
LwpPageLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
LwpAtomHolder m_PrinterBinName
bool ComparePagePosition(LwpVirtualLayout const *pPreLayout, LwpVirtualLayout const *pNextLayout)
@descr: If the two layouts in the same para, compare which layout is earlied according to frib order
Definition: lwppara1.cxx:555
void Read() override
@descr Read name of LwpDLNFVList from object stream
Definition: lwplayout.cxx:1936
LwpPageLayout * GetPageLayout()
@descr Get page layout pointer
Definition: lwpsection.hxx:112
virtual void XFConvert(XFContentContainer *pCont) override
@descr default XFConvert function pCont is the XFContentContainer for the object conversion
Definition: lwpstory.cxx:101
encapsulate XInputStream to provide SvStream like interfaces
Definition: lwpsvstream.hxx:69
static bool IsOddNumber(sal_uInt16 nNumber)
Definition: lwptools.hxx:122
static double ConvertFromUnitsToMetric(sal_Int32 nUnits)
Definition: lwptools.hxx:117
static bool IsEvenNumber(sal_uInt16 nNumber)
Definition: lwptools.hxx:126
bool IsUseOnAllOddPages() const
Definition: lwpusewhen.hxx:127
LwpUseWhen * GetUseWhen()
@descr: Get usewhen pointer
Definition: lwplayout.cxx:224
OUString m_StyleName
Definition: lwplayout.hxx:249
bool IsComplex() const
@descr: Whether it is a mirror layout
Definition: lwplayout.cxx:218
bool GetIsAutoGrowDown()
Definition: lwplayout.hxx:135
void RegisterChildStyle()
@descr: Register child layout style
Definition: lwplayout.cxx:327
double GetMarginsValue(sal_uInt8 nWhichSide)
Definition: lwplayout.hxx:153
constexpr tools::Long Height() const
constexpr tools::Long Width() const
Color object.
Definition: xfcolor.hxx:70
A container for content.
void SetMargins(double left, double right, double top)
@descr Foot object.
Definition: xffooter.hxx:71
void SetShadow(XFShadow *pShadow)
@descr Set header shadow.
void SetBackColor(XFColor color)
@descr Set header background color.
void SetMinHeight(double minHeight)
@descr Set header min height.
void SetMargins(double left, double right, double bottom)
@descr Set margins for header style.
void SetDynamicSpace(bool dynamic)
void SetHeight(double height)
@descr Set header fixed height.
void SetBorders(std::unique_ptr< XFBorders > pBorders)
@descr Set header borders.
void SetBackImage(std::unique_ptr< XFBGImage > &rImage)
void SetHeader(rtl::Reference< XFHeader > const &rHeader)
void SetFooter(rtl::Reference< XFFooter > const &rFooter)
void SetBackImage(std::unique_ptr< XFBGImage > &rImage)
void SetHeaderStyle(XFHeaderStyle *pHeaderStyle)
void SetBackColor(XFColor color)
void SetMargins(double left, double right, double top, double bottom)
void SetPageWidth(double width)
void SetFooterStyle(XFFooterStyle *pFooterStyle)
void SetFootNoteSeparator(enumXFAlignType align, double width, sal_Int32 lengthPercent, double spaceAbove, double spaceBelow, XFColor color)
void SetBorders(std::unique_ptr< XFBorders > pBorders)
void SetShadow(XFShadow *pShadow)
void SetPageHeight(double height)
void SetColumns(XFColumns *pColumns)
Shadow object.
Definition: xfshadow.hxx:72
Style manager for the filter.
IXFStyleRet AddStyle(std::unique_ptr< IXFStyle > pStyle)
virtual OUString GetStyleName() override
@descr get style name.
Definition: xfstyle.cxx:70
std::pair< const_iterator, bool > insert(Value &&x)
OString right
OString top
OString bottom
#define SAL_WARN(area, stream)
@ VO_STORY
Definition: lwpdefs.hxx:72
#define LAST_LAYOUTPAGENO
Definition: lwplayout.hxx:88
#define FIRST_LAYOUTPAGENO
Definition: lwplayout.hxx:87
const sal_uInt8 MARGIN_BOTTOM
Definition: lwpmargins.hxx:66
const sal_uInt8 MARGIN_RIGHT
Definition: lwpmargins.hxx:64
const sal_uInt8 MARGIN_TOP
Definition: lwpmargins.hxx:65
const sal_uInt8 MARGIN_LEFT
Definition: lwpmargins.hxx:63
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
IXFStyle * m_pStyle
Definition: xfstylecont.hxx:71
sal_uInt64 left
@ enumXFPageUsageMirror
Definition: xfdefs.hxx:401
enumXFAlignType
Definition: xfdefs.hxx:172
@ enumXFAlignStart
Definition: xfdefs.hxx:174
@ enumXFAlignEnd
Definition: xfdefs.hxx:176