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 /*************************************************************************
58 * For LWP filter architecture prototype
59 ************************************************************************/
61 #include "lwplayout.hxx"
62 #include "lwpusewhen.hxx"
63 #include "lwptools.hxx"
64 #include "lwplaypiece.hxx"
65 #include "xfilter/xfcolumns.hxx"
66 #include "lwpstory.hxx"
67 #include "lwpparastyle.hxx"
68 #include "lwpholder.hxx"
70 #include "lwppagehint.hxx"
71 #include "lwpdivinfo.hxx"
72 #include "lwpgrfobj.hxx"
73 #include <osl/thread.h>
75 LwpVirtualLayout::LwpVirtualLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
76 : LwpDLNFPVList(objHdr
, pStrm
)
77 , m_bGettingHonorProtection(false)
78 , m_bGettingMarginsSameAsParent(false)
79 , m_bGettingHasProtection(false)
80 , m_bGettingIsProtected(false)
81 , m_bGettingIsAutoGrowDown(false)
82 , m_bGettingMarginsValue(false)
83 , m_bGettingExtMarginsValue(false)
93 void LwpVirtualLayout::Read()
95 LwpDLNFPVList::Read();
97 LwpObjectStream
* pStrm
= m_pObjStrm
.get();
98 m_nAttributes
= pStrm
->QuickReaduInt32();
99 m_nAttributes2
= pStrm
->QuickReaduInt32();
100 m_nAttributes3
= pStrm
->QuickReaduInt32();
101 m_nOverrideFlag
= pStrm
->QuickReaduInt32();
102 m_nDirection
= pStrm
->QuickReaduInt16();
104 //Note that two bytes is read into m_nEditorID instead of one byte.
105 m_nEditorID
= pStrm
->QuickReaduInt16();
107 m_NextEnumerated
.ReadIndexed(pStrm
);
108 m_PreviousEnumerated
.ReadIndexed(pStrm
);
113 bool LwpVirtualLayout::MarginsSameAsParent()
115 return (m_nAttributes2
& STYLE2_MARGINSSAMEASPARENT
) != 0;
119 * @descr: Get column width
122 double LwpVirtualLayout::GetColWidth(sal_uInt16
/*nIndex*/)
124 //return GetContentWidth(); //not support now
125 //return LwpTools::ConvertToMetric(5); //test
130 * @descr: Get the gap between columns
133 double LwpVirtualLayout::GetColGap(sal_uInt16
/*nIndex*/)
135 //return DEFAULTGAPSIZE;
136 //return LwpTools::ConvertToMetric(0.17);//DEFAULTGAPSIZE=0.17
137 return LwpTools::ConvertToMetric(0.17);
141 * @descr: Whether it is honoring protection
144 bool LwpVirtualLayout::HonorProtection()
146 if(!(m_nAttributes2
& STYLE2_HONORPROTECTION
))
149 rtl::Reference
<LwpVirtualLayout
> xParent(dynamic_cast<LwpVirtualLayout
*>(GetParent().obj().get()));
150 if (xParent
.is() && !xParent
->IsHeader())
152 return xParent
->GetHonorProtection();
155 if(m_pFoundry
)//is null now
157 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
158 if(pDoc
&& pDoc
->GetRootDocument())
159 return pDoc
->GetRootDocument()->GetHonorProtection();
166 * @descr: Whether it is protected
169 bool LwpVirtualLayout::IsProtected()
171 bool bProtected
= (m_nAttributes
& STYLE_PROTECTED
)!=0;
173 rtl::Reference
<LwpVirtualLayout
> xParent(dynamic_cast<LwpVirtualLayout
*>(GetParent().obj().get()));
174 if (xParent
.is() && !xParent
->IsHeader())
176 if (xParent
->GetHonorProtection() && (xParent
->GetHasProtection()||bProtected
))
181 else if(m_pFoundry
)//is null now
183 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
186 if (pDoc
->GetHonorProtection() && bProtected
)
197 * @descr: Whether it has protection
200 bool LwpVirtualLayout::HasProtection()
202 if(m_nAttributes
& STYLE_PROTECTED
)
205 rtl::Reference
<LwpVirtualLayout
> xParent(dynamic_cast<LwpVirtualLayout
*>(GetParent().obj().get()));
206 if (xParent
.is() && !xParent
->IsHeader())
208 return xParent
->GetHasProtection();
215 * @descr: Whether it is a mirror layout
218 bool LwpVirtualLayout::IsComplex()
220 return (m_nAttributes
& STYLE_COMPLEX
) != 0;
224 * @descr: Get usewhen pointer
227 LwpUseWhen
* LwpVirtualLayout::GetUseWhen()
230 If we have a parent, and I'm not a page layout,
231 use my parents information.
233 if(GetLayoutType()!=LWP_PAGE_LAYOUT
)
236 rtl::Reference
<LwpVirtualLayout
> xParent(dynamic_cast<LwpVirtualLayout
*>(GetParent().obj().get()));
237 if (xParent
.is() && !xParent
->IsHeader() && (xParent
->GetLayoutType() != LWP_PAGE_LAYOUT
))
238 return xParent
->GetUseWhen();
242 return VirtualGetUseWhen();
245 * @descr: Whether this layout is page layout or not
247 bool LwpVirtualLayout::IsPage()
249 return (GetLayoutType() == LWP_PAGE_LAYOUT
);
252 * @descr: Whether this layout is header layout or not
254 bool LwpVirtualLayout::IsHeader()
256 return (GetLayoutType() == LWP_HEADER_LAYOUT
);
259 * @descr: Whether this layout is footer layout or not
261 bool LwpVirtualLayout::IsFooter()
263 return (GetLayoutType() == LWP_FOOTER_LAYOUT
);
266 * @descr: Whether this layout is frame layout or not
268 bool LwpVirtualLayout::IsFrame()
270 return (GetLayoutType() == LWP_FRAME_LAYOUT
);
274 * @descr: Whether this layout is cell layout or not
276 bool LwpVirtualLayout::IsCell()
278 return (GetLayoutType() == LWP_CELL_LAYOUT
279 || GetLayoutType() == LWP_CONNECTED_CELL_LAYOUT
280 || GetLayoutType() == LWP_HIDDEN_CELL_LAYOUT
);
283 * @descr: Whether this layout is supertable layout or not
285 bool LwpVirtualLayout::IsSuperTable()
287 return (GetLayoutType() == LWP_SUPERTABLE_LAYOUT
);
290 * @descr: Whether this layout is group layout or not
292 bool LwpVirtualLayout::IsGroupHead()
294 return (GetLayoutType() == LWP_GROUP_LAYOUT
);
297 * @descr: get the relative type
299 sal_uInt8
LwpVirtualLayout::GetRelativeType()
301 return LwpLayoutRelativityGuts::LAY_PARENT_RELATIVE
;
304 * @descr: whether it is relative anchored layout
306 bool LwpVirtualLayout::IsRelativeAnchored()
310 nType
= GetRelativeType();
311 return (nType
== LwpLayoutRelativityGuts::LAY_PARA_RELATIVE
) || (nType
== LwpLayoutRelativityGuts::LAY_INLINE
)
312 || (nType
== LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE
) || (nType
== LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL
);
315 * @descr: whether it is MinimumHeight layout
317 bool LwpVirtualLayout::IsMinimumHeight()
319 return ((m_nAttributes3
& STYLE3_MINHEIGHTVALID
) != 0);
323 * @descr: Get parent layout
326 rtl::Reference
<LwpVirtualLayout
> LwpVirtualLayout::GetParentLayout()
328 return rtl::Reference
<LwpVirtualLayout
>(dynamic_cast<LwpVirtualLayout
*>(GetParent().obj().get()));
332 * @descr: Register child layout style
335 void LwpVirtualLayout::RegisterChildStyle()
337 //Register all children styles
338 rtl::Reference
<LwpVirtualLayout
> xLayout(dynamic_cast<LwpVirtualLayout
*>(GetChildHead().obj().get()));
341 xLayout
->SetFoundry(m_pFoundry
);
342 xLayout
->RegisterStyle();
343 xLayout
.set(dynamic_cast<LwpVirtualLayout
*>(xLayout
->GetNext().obj().get()));
347 bool LwpVirtualLayout::NoContentReference()
349 return (m_nAttributes2
& STYLE2_NOCONTENTREFERENCE
) != 0;
352 bool LwpVirtualLayout::IsStyleLayout()
354 if (m_nAttributes3
& STYLE3_STYLELAYOUT
)
357 rtl::Reference
<LwpVirtualLayout
> xParent(dynamic_cast<LwpVirtualLayout
*>(GetParent().obj().get()));
359 return xParent
->IsStyleLayout();
364 * @descr: Find child layout by layout type
367 LwpVirtualLayout
* LwpVirtualLayout::FindChildByType(LWP_LAYOUT_TYPE eType
)
369 LwpObjectID
& rID
= GetChildHead();
373 LwpVirtualLayout
* pLayout
= dynamic_cast<LwpVirtualLayout
*>(rID
.obj().get());
379 if (pLayout
&& pLayout
->GetLayoutType() == eType
)
383 rID
= pLayout
->GetNext();
390 * @descr: Whether the size of layout is fit the graphic
393 bool LwpVirtualLayout::IsFitGraphic()
395 return IsAutoGrowRight() && !IsAutoGrowLeft() && GetIsAutoGrowDown();
399 * @descr: Whether the width of layout is auto grow
402 bool LwpVirtualLayout::IsAutoGrowWidth()
404 return IsAutoGrowLeft() || IsAutoGrowRight();
408 * @descr: Determine whether the layout width is to margin
411 bool LwpVirtualLayout::IsInlineToMargin()
413 return (m_nAttributes3
& STYLE3_INLINETOMARGIN
) != 0;
416 void LwpAssociatedLayouts::Read(LwpObjectStream
* pStrm
)
418 m_OnlyLayout
.ReadIndexed(pStrm
);
419 m_Layouts
.Read(pStrm
);
424 * @descr: Looking for the layout which follows the pStartLayout
425 * @param: pStartLayout - the layout which is used for looking for its following layout
427 rtl::Reference
<LwpVirtualLayout
> LwpAssociatedLayouts::GetLayout(LwpVirtualLayout
*pStartLayout
)
429 if (!pStartLayout
&& !m_OnlyLayout
.IsNull())
430 /* Looking for the first layout and there's only one layout in the list.*/
431 return rtl::Reference
<LwpVirtualLayout
>(dynamic_cast<LwpVirtualLayout
*>(m_OnlyLayout
.obj().get()));
433 rtl::Reference
<LwpObjectHolder
> xObjHolder(dynamic_cast<LwpObjectHolder
*>(m_Layouts
.GetHead().obj().get()));
436 rtl::Reference
<LwpVirtualLayout
> xLayout(dynamic_cast<LwpVirtualLayout
*>(xObjHolder
->GetObject().obj().get()));
440 while (xObjHolder
.is() && pStartLayout
!= xLayout
.get())
442 xObjHolder
.set(dynamic_cast<LwpObjectHolder
*>(xObjHolder
->GetNext().obj().get()));
445 xLayout
.set(dynamic_cast<LwpVirtualLayout
*>(xObjHolder
->GetObject().obj().get()));
451 xObjHolder
.set(dynamic_cast<LwpObjectHolder
*>(xObjHolder
->GetNext().obj().get()));
454 xLayout
.set(dynamic_cast<LwpVirtualLayout
*>(xObjHolder
->GetObject().obj().get()));
460 return rtl::Reference
<LwpVirtualLayout
>();
463 LwpHeadLayout::LwpHeadLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
464 : LwpVirtualLayout(objHdr
, pStrm
)
467 void LwpHeadLayout::Read()
469 LwpVirtualLayout::Read();
470 //For PermissiveLayout
471 m_pObjStrm
->SkipExtra();
473 m_pObjStrm
->SkipExtra();
476 void LwpHeadLayout::RegisterStyle()
478 //Register all children styles
479 rtl::Reference
<LwpVirtualLayout
> xLayout(dynamic_cast<LwpVirtualLayout
*>(GetChildHead().obj().get()));
482 xLayout
->SetFoundry(m_pFoundry
);
483 //if the layout is relative to para, the layout will be registered in para
484 if (!xLayout
->IsRelativeAnchored())
486 if (xLayout
.get() == this)
488 OSL_FAIL("Layout points to itself");
491 xLayout
->DoRegisterStyle();
493 rtl::Reference
<LwpVirtualLayout
> xNext(dynamic_cast<LwpVirtualLayout
*>(xLayout
->GetNext().obj().get()));
494 if (xNext
.get() == xLayout
.get())
496 OSL_FAIL("Layout points to itself");
504 * @descr find endnote supertable layout from the child layout list. Suppose that there is only one endnote supertablelayout in one division
505 * @return pointer to endnote supertable layout
507 rtl::Reference
<LwpVirtualLayout
> LwpHeadLayout::FindEnSuperTableLayout()
509 rtl::Reference
<LwpVirtualLayout
> xLayout(dynamic_cast<LwpVirtualLayout
*>(GetChildHead().obj().get()));
510 while (xLayout
.get())
512 if (xLayout
->GetLayoutType() == LWP_ENDNOTE_SUPERTABLE_LAYOUT
)
516 xLayout
.set(dynamic_cast<LwpVirtualLayout
*>(xLayout
->GetNext().obj().get()));
518 return rtl::Reference
<LwpVirtualLayout
>();
521 LwpLayoutStyle::LwpLayoutStyle()
522 : m_nStyleDefinition(0)
523 , m_pDescription(new LwpAtomHolder
)
528 LwpLayoutStyle::~LwpLayoutStyle()
532 void LwpLayoutStyle::Read(LwpObjectStream
* pStrm
)
534 m_nStyleDefinition
= pStrm
->QuickReaduInt32();
535 m_pDescription
->Read(pStrm
);
536 if (pStrm
->CheckExtra())
538 m_nKey
= pStrm
->QuickReaduInt16();
543 LwpLayoutMisc::LwpLayoutMisc() :
544 m_nGridDistance(0), m_nGridType(0),
545 m_pContentStyle(new LwpAtomHolder
)
549 LwpLayoutMisc::~LwpLayoutMisc()
553 delete m_pContentStyle
;
557 void LwpLayoutMisc::Read(LwpObjectStream
* pStrm
)
559 m_nGridType
= pStrm
->QuickReaduInt16();
560 m_nGridDistance
= pStrm
->QuickReadInt32();
561 m_pContentStyle
->Read(pStrm
);
565 LwpMiddleLayout::LwpMiddleLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
566 : LwpVirtualLayout(objHdr
, pStrm
)
567 , m_pStyleStuff(new LwpLayoutStyle
)
568 , m_pMiscStuff(new LwpLayoutMisc
)
569 , m_bGettingGeometry(false)
573 LwpMiddleLayout::~LwpMiddleLayout()
577 delete m_pStyleStuff
;
584 void LwpMiddleLayout::Read()
586 LwpObjectStream
* pStrm
= m_pObjStrm
.get();
588 LwpVirtualLayout::Read();
590 //skip CLiteLayout data;
591 LwpAtomHolder ContentClass
;
592 ContentClass
.Read(pStrm
);
595 // before layout hierarchy rework
596 if(LwpFileHeader::m_nFileRevision
< 0x000B)
599 m_Content
.ReadIndexed(pStrm
);
602 m_BasedOnStyle
.ReadIndexed(pStrm
);
603 m_TabPiece
.ReadIndexed(pStrm
);
605 sal_uInt8 nWhatsItGot
= pStrm
->QuickReaduInt8();
607 if (nWhatsItGot
& DISK_GOT_STYLE_STUFF
)
609 m_pStyleStuff
->Read(pStrm
);
611 if (nWhatsItGot
& DISK_GOT_MISC_STUFF
)
613 m_pMiscStuff
->Read(pStrm
);
616 m_LayGeometry
.ReadIndexed(pStrm
);
617 m_LayScale
.ReadIndexed(pStrm
);
618 m_LayMargins
.ReadIndexed(pStrm
);
619 m_LayBorderStuff
.ReadIndexed(pStrm
);
620 m_LayBackgroundStuff
.ReadIndexed(pStrm
);
622 if (pStrm
->CheckExtra())
624 m_LayExtBorderStuff
.ReadIndexed(pStrm
);
629 rtl::Reference
<LwpObject
> LwpMiddleLayout::GetBasedOnStyle()
631 rtl::Reference
<LwpObject
> xRet(m_BasedOnStyle
.obj());
632 if (xRet
.get() == this)
634 SAL_WARN("lwp", "style based on itself");
635 return rtl::Reference
<LwpObject
>();
641 * @descr: Get the geometry of current layout
644 LwpLayoutGeometry
* LwpMiddleLayout::Geometry()
646 if( !m_LayGeometry
.IsNull() )
648 return ( dynamic_cast<LwpLayoutGeometry
*> (m_LayGeometry
.obj().get()) );
652 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
653 if (LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get()))
655 return pLay
->GetGeometry();
662 * @descr: Get layout height, measured by "cm"
665 double LwpMiddleLayout::GetGeometryHeight()
667 LwpLayoutGeometry
* pGeo
= GetGeometry();
670 return ( LwpTools::ConvertFromUnitsToMetric( pGeo
->GetHeight() ) );
677 * @descr: Get layout width, measured by "cm"
680 double LwpMiddleLayout::GetGeometryWidth()
682 LwpLayoutGeometry
* pGeo
= GetGeometry();
685 return ( LwpTools::ConvertFromUnitsToMetric( pGeo
->GetWidth() ) );
692 * @descr: Whether the margins is same as parent layout
695 bool LwpMiddleLayout::MarginsSameAsParent()
697 if(m_nOverrideFlag
& OVER_MARGINS
)
699 return LwpVirtualLayout::MarginsSameAsParent();
701 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
702 if (LwpVirtualLayout
* pLay
= dynamic_cast<LwpVirtualLayout
*>(xBase
.get()))
704 pLay
->GetMarginsSameAsParent();
706 return LwpVirtualLayout::MarginsSameAsParent();
711 * @param: nWhichSide - 0: left, 1: right, 2:top, 3: bottom
713 double LwpMiddleLayout::MarginsValue(sal_uInt8 nWhichSide
)
716 if((nWhichSide
==MARGIN_LEFT
)||(nWhichSide
==MARGIN_RIGHT
))
718 if ( GetMarginsSameAsParent() )
720 rtl::Reference
<LwpVirtualLayout
> xParent(dynamic_cast<LwpVirtualLayout
*>(GetParent().obj().get()));
721 if (xParent
.is() && !xParent
->IsHeader())
723 fValue
= xParent
->GetMarginsValue(nWhichSide
);
729 if(m_nOverrideFlag
& OVER_MARGINS
)
731 LwpLayoutMargins
* pMar1
= dynamic_cast<LwpLayoutMargins
*> (m_LayMargins
.obj().get());
734 fValue
= pMar1
->GetMargins().GetMarginsValue(nWhichSide
);
738 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
739 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*>(xBase
.get());
742 fValue
= pStyle
->GetMarginsValue(nWhichSide
);
745 return LwpVirtualLayout::MarginsValue(nWhichSide
);
748 * @descr: Get extmargin value
749 * @param: nWhichSide - 0: left, 1: right, 2:top, 3: bottom
753 double LwpMiddleLayout::ExtMarginsValue(sal_uInt8 nWhichSide
)
756 if(m_nOverrideFlag
& OVER_MARGINS
)
758 LwpLayoutMargins
* pMar1
= dynamic_cast<LwpLayoutMargins
*> (m_LayMargins
.obj().get());
761 fValue
= pMar1
->GetExtMargins().GetMarginsValue(nWhichSide
);
765 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*>(GetBasedOnStyle().get());
768 fValue
= pStyle
->GetExtMarginsValue(nWhichSide
);
771 return LwpVirtualLayout::ExtMarginsValue(nWhichSide
);
774 * @descr: Get the LwpBorderStuff object according to m_LayBorderStuff id.
776 LwpBorderStuff
* LwpMiddleLayout::GetBorderStuff()
778 if(m_nOverrideFlag
& OVER_BORDERS
)
780 LwpLayoutBorder
* pLayoutBorder
= dynamic_cast<LwpLayoutBorder
*>(m_LayBorderStuff
.obj().get());
781 return pLayoutBorder
? &pLayoutBorder
->GetBorderStuff() : nullptr;
785 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
786 if (LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get()))
788 return pLay
->GetBorderStuff();
795 * @descr: Get LwpBackgroundStuff object according to m_LayBackgroundStuff id;
797 LwpBackgroundStuff
* LwpMiddleLayout::GetBackgroundStuff()
799 if(m_nOverrideFlag
& OVER_BACKGROUND
)
801 LwpLayoutBackground
* pLayoutBackground
= dynamic_cast<LwpLayoutBackground
*>(m_LayBackgroundStuff
.obj().get());
802 return pLayoutBackground
? &pLayoutBackground
->GetBackgoudStuff() : nullptr;
806 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
807 if (LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get()))
809 return pLay
->GetBackgroundStuff();
815 * @descr: create xfborder.
817 XFBorders
* LwpMiddleLayout::GetXFBorders()
819 LwpBorderStuff
* pBorderStuff
= GetBorderStuff();
820 if(pBorderStuff
&&pBorderStuff
->GetSide() != 0)
822 //copy from lwpparastyle.
823 XFBorders
*pXFBorders
= new XFBorders();
824 // apply 4 borders respectively
825 LwpBorderStuff::BorderType pType
[] = { LwpBorderStuff::LEFT
, LwpBorderStuff::RIGHT
,
826 LwpBorderStuff::TOP
, LwpBorderStuff::BOTTOM
};
828 for (LwpBorderStuff::BorderType
& nC
: pType
)
830 if (pBorderStuff
->HasSide(nC
))
832 LwpParaStyle::ApplySubBorder(pBorderStuff
, nC
, pXFBorders
);
841 * @descr: Get text direction settings.
843 enumXFTextDir
LwpMiddleLayout::GetTextDirection()
845 enumXFTextDir eTextDir
= enumXFTextDirNone
;
846 sal_uInt8 nDirection
= GetContentOrientation();
849 case TEXT_ORIENT_LRTB
:
851 eTextDir
= enumXFTextDirLR_TB
;
854 case TEXT_ORIENT_TBRL
:
856 eTextDir
= enumXFTextDirTB_RL
;
859 case TEXT_ORIENT_RLBT
: // not supported now
861 eTextDir
= enumXFTextDirNone
;
864 case TEXT_ORIENT_BTLR
: // not supported now
866 eTextDir
= enumXFTextDirNone
;
875 * @descr: Get back ground color.
877 LwpColor
* LwpMiddleLayout::GetBackColor()
879 LwpBackgroundStuff
* pBackgroundStuff
= GetBackgroundStuff();
880 if(pBackgroundStuff
&& !pBackgroundStuff
->IsTransparent())
882 LwpColor
* pColor
= pBackgroundStuff
->GetFillColor();
883 if(pColor
->IsValidColor())
892 * @descr: Add back color settings into xfpagemaster.
894 LwpTabOverride
* LwpMiddleLayout::GetTabOverride()
896 if(m_nAttributes
& OVER_TABS
)
898 if(!m_TabPiece
.IsNull())
900 LwpTabPiece
*pPiece
= dynamic_cast<LwpTabPiece
*>(m_TabPiece
.obj().get());
901 return static_cast<LwpTabOverride
*>(pPiece
? pPiece
->GetOverride() : nullptr);
907 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
908 if (LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get()))
910 return pLay
->GetTabOverride();
917 * @descr: Layscale for graphic & watermark
919 sal_uInt16
LwpMiddleLayout::GetScaleMode()
921 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj().is() && GetLayoutScale())
922 return GetLayoutScale()->GetScaleMode();
923 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
925 return dynamic_cast<LwpMiddleLayout
&>(*xBase
.get()).GetScaleMode();
927 return (LwpLayoutScale::FIT_IN_FRAME
| LwpLayoutScale::MAINTAIN_ASPECT_RATIO
);
930 sal_uInt16
LwpMiddleLayout::GetScaleTile()
932 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj().is() && GetLayoutScale())
933 return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::TILED
)
935 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
937 return dynamic_cast<LwpMiddleLayout
&>(*xBase
.get()).GetScaleTile();
942 sal_uInt16
LwpMiddleLayout::GetScaleCenter()
944 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj().is() && GetLayoutScale())
946 return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::CENTERED
)
949 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
951 return dynamic_cast<LwpMiddleLayout
&>(*xBase
.get()).GetScaleCenter();
956 sal_uInt32
LwpMiddleLayout::GetScalePercentage()
958 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj().is() && GetLayoutScale())
959 return GetLayoutScale()->GetScalePercentage()/10;//m_nScalePercentage 1000 = 100%
960 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
962 return dynamic_cast<LwpMiddleLayout
&>(*xBase
.get()).GetScalePercentage();
967 double LwpMiddleLayout::GetScaleWidth()
969 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj().is() && GetLayoutScale())
970 return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleWidth());
971 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
973 return dynamic_cast<LwpMiddleLayout
&>(*xBase
.get()).GetScaleWidth();
978 double LwpMiddleLayout::GetScaleHeight()
980 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj().is() && GetLayoutScale())
981 return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleHeight());
982 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
984 return dynamic_cast<LwpMiddleLayout
&>(*xBase
.get()).GetScaleHeight();
988 bool LwpMiddleLayout::CanSizeRight()
990 sal_uInt8 RelType
= GetRelativeType();
992 if (RelType
== LwpLayoutRelativityGuts::LAY_INLINE
|| RelType
== LwpLayoutRelativityGuts::LAY_PARA_RELATIVE
993 || RelType
== LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL
)
999 sal_Int32
LwpMiddleLayout::GetMinimumWidth()
1001 if (((m_nAttributes3
& STYLE3_WIDTHVALID
) != 0) && GetGeometry())
1003 return GetGeometry()->GetWidth();
1005 else if (m_nOverrideFlag
& OVER_SIZE
)
1007 return DetermineWidth();
1011 sal_Int32
LwpMiddleLayout::DetermineWidth()
1013 if (IsSizeRightToContent())
1017 else if (IsSizeRightToContainer())
1021 else if (LwpLayoutGeometry
* pGeo
= GetGeometry())
1023 m_nAttributes3
|= STYLE3_WIDTHVALID
;
1024 return pGeo
->GetWidth();
1028 bool LwpMiddleLayout::IsSizeRightToContainer()
1030 if (!CanSizeRight())
1033 if (m_nOverrideFlag
& OVER_SIZE
)
1035 return (m_nDirection
& ((LAY_USEDIRECTION
|LAY_AUTOSIZE
|LAY_TOCONTAINER
)
1037 == ((LAY_USEDIRECTION
| LAY_TOCONTAINER
| LAY_AUTOSIZE
) << SHIFT_RIGHT
);
1039 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1042 LwpMiddleLayout
* pLayout
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get());
1043 return pLayout
&& pLayout
->IsSizeRightToContainer();
1048 bool LwpMiddleLayout::IsSizeRightToContent()
1050 if (!CanSizeRight())
1053 if (m_nOverrideFlag
& OVER_SIZE
)
1055 return (m_nDirection
& ((LAY_USEDIRECTION
|LAY_AUTOSIZE
|LAY_TOCONTAINER
)
1057 == ((LAY_USEDIRECTION
| LAY_AUTOSIZE
) << SHIFT_RIGHT
);
1059 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1062 LwpMiddleLayout
* pLayout
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get());
1063 return pLayout
&& pLayout
->IsSizeRightToContent();
1070 * @descr: Get layout height
1073 double LwpMiddleLayout::GetHeight()
1075 return GetGeometryHeight();
1079 * @descr: Get layout height
1082 double LwpMiddleLayout::GetWidth()
1084 return GetGeometryWidth();
1087 * @descr: Get layout origin point
1090 LwpPoint
LwpMiddleLayout::GetOrigin()
1092 LwpLayoutGeometry
* pGeo
= GetGeometry();
1095 sal_uInt8 nType
= GetRelativeType();
1096 if(nType
== LwpLayoutRelativityGuts::LAY_INLINE
1097 || nType
== LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE
)
1099 return pGeo
->GetAbsoluteOrigin();
1102 return pGeo
->GetOrigin();
1110 * @descr: Whether the fill is pattern fill or not
1111 * @return: True if yes, false if not.
1113 bool LwpMiddleLayout::IsPatternFill()
1115 LwpBackgroundStuff
* pBackgroundStuff
= GetBackgroundStuff();
1116 if (pBackgroundStuff
)
1118 return pBackgroundStuff
->IsPatternFill();
1125 * @descr: Get the fill pattern style. Data are saved in a XFBGImage object
1126 * @return: the fill pattern style.
1128 XFBGImage
* LwpMiddleLayout::GetFillPattern()
1130 LwpBackgroundStuff
* pBackgroundStuff
= GetBackgroundStuff();
1131 if (pBackgroundStuff
)
1133 return pBackgroundStuff
->GetFillPattern();
1141 * @descr: Whether the height and width of layout is auto grow
1144 bool LwpMiddleLayout::IsAutoGrow()
1146 if(m_nOverrideFlag
& OVER_SIZE
)
1148 return (m_nDirection
&
1149 ((LAY_AUTOGROW
<< SHIFT_UP
) | (LAY_AUTOGROW
<< SHIFT_DOWN
) |
1150 (LAY_AUTOGROW
<< SHIFT_RIGHT
) | (LAY_AUTOGROW
<< SHIFT_LEFT
))) != 0;
1154 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1155 if (LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get()))
1157 return pLay
->IsAutoGrow();
1160 return LwpVirtualLayout::IsAutoGrow();
1164 * @descr: Whether the height of layout is auto grow down
1167 bool LwpMiddleLayout::IsAutoGrowDown()
1169 if(m_nOverrideFlag
& OVER_SIZE
)
1171 return (m_nDirection
& (LAY_AUTOGROW
<< SHIFT_DOWN
)) != 0;
1175 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1176 if (LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get()))
1178 return pLay
->GetIsAutoGrowDown();
1181 return LwpVirtualLayout::IsAutoGrowDown();
1185 * @descr: Whether the height of layout is auto grow up
1188 bool LwpMiddleLayout::IsAutoGrowUp()
1190 if(m_nOverrideFlag
& OVER_SIZE
)
1192 return (m_nDirection
& (LAY_AUTOGROW
<< SHIFT_UP
)) != 0;
1196 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1197 if (LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get()))
1199 return pLay
->IsAutoGrowUp();
1202 return LwpVirtualLayout::IsAutoGrowUp();
1206 * @descr: Whether the height of layout is auto grow down
1209 bool LwpMiddleLayout::IsAutoGrowLeft()
1211 if(m_nOverrideFlag
& OVER_SIZE
)
1213 return (m_nDirection
& (LAY_AUTOGROW
<< SHIFT_LEFT
)) != 0;
1217 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1218 if (LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get()))
1220 return pLay
->IsAutoGrowLeft();
1223 return LwpVirtualLayout::IsAutoGrowLeft();
1227 * @descr: Whether the height of layout is auto grow down
1230 bool LwpMiddleLayout::IsAutoGrowRight()
1232 if(m_nOverrideFlag
& OVER_SIZE
)
1234 return (m_nDirection
& (LAY_AUTOGROW
<< SHIFT_RIGHT
)) != 0;
1238 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1239 if (LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get()))
1241 return pLay
->IsAutoGrowRight();
1244 return LwpVirtualLayout::IsAutoGrowRight();
1248 * @descr: Get contents orientation
1251 sal_uInt8
LwpMiddleLayout::GetContentOrientation()
1253 //content orientation in Graphic objects and OLE objects not supported now
1254 if((m_nOverrideFlag
& OVER_ROTATION
)&& !m_LayGeometry
.IsNull())
1256 LwpLayoutGeometry
* pLayGeometry
= dynamic_cast<LwpLayoutGeometry
*> (m_LayGeometry
.obj().get());
1258 return pLayGeometry
->GetContentOrientation();
1262 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1263 if (LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get()))
1265 return pLay
->GetContentOrientation();
1268 return LwpVirtualLayout::GetContentOrientation();
1272 * @descr: Whether it is honoring protection
1275 bool LwpMiddleLayout::HonorProtection()
1277 if(m_nOverrideFlag
& OVER_MISC
)
1279 if(!(m_nAttributes2
& STYLE2_HONORPROTECTION
))
1282 rtl::Reference
<LwpVirtualLayout
> xParent(dynamic_cast<LwpVirtualLayout
*>(GetParent().obj().get()));
1283 if (xParent
.is() && !xParent
->IsHeader())
1285 return xParent
->GetHonorProtection();
1288 if(m_pFoundry
)//is null now
1290 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
1293 return pDoc
->GetHonorProtection();
1299 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1300 if (LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get()))
1302 return pLay
->GetHonorProtection();
1306 return LwpVirtualLayout::HonorProtection();
1310 * @descr: Whether it is protected
1313 bool LwpMiddleLayout::IsProtected()
1315 bool bProtected
= false;
1316 if(m_nOverrideFlag
& OVER_MISC
)
1318 bProtected
= (m_nAttributes
& STYLE_PROTECTED
)!=0;
1322 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1323 if (LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get()))
1325 bProtected
= pLay
->GetIsProtected();
1328 bProtected
= LwpVirtualLayout::IsProtected();
1331 rtl::Reference
<LwpVirtualLayout
> xParent(dynamic_cast<LwpVirtualLayout
*>(GetParent().obj().get()));
1332 if (xParent
.is() && !xParent
->IsHeader())
1334 /* If a parent's protected then none of its children can be accessed. */
1335 if (xParent
->GetIsProtected())
1338 if (xParent
->GetHonorProtection())
1341 /* If our parent isn't honoring protection then we aren't protected. */
1345 if(m_pFoundry
)//is null now
1347 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
1350 if (pDoc
->GetHonorProtection())
1353 /* If the document isn't honoring protection then we aren't protected.*/
1362 * @descr: Get watermark layout
1365 rtl::Reference
<LwpVirtualLayout
> LwpMiddleLayout::GetWaterMarkLayout()
1367 rtl::Reference
<LwpVirtualLayout
> xLay(dynamic_cast<LwpVirtualLayout
*>(GetChildHead().obj().get()));
1370 if (xLay
->IsForWaterMark())
1374 xLay
.set(dynamic_cast<LwpVirtualLayout
*>(xLay
->GetNext().obj().get()));
1376 return rtl::Reference
<LwpVirtualLayout
>();
1380 * @descr: Create and reture xfbgimage object for watermark
1383 XFBGImage
* LwpMiddleLayout::GetXFBGImage()
1385 rtl::Reference
<LwpVirtualLayout
> xWaterMarkLayout(GetWaterMarkLayout());
1386 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*>(xWaterMarkLayout
.get());
1390 LwpGraphicObject
* pGrfObj
= dynamic_cast<LwpGraphicObject
*>(pLay
->GetContent().obj().get());
1393 XFBGImage
* pXFBGImage
= new XFBGImage();
1395 if(pGrfObj
->IsLinked())
1398 OUString linkedfilepath
= pGrfObj
->GetLinkedFilePath();
1399 OUString fileURL
= LwpTools::convertToFileUrl(OUStringToOString(linkedfilepath
, osl_getThreadTextEncoding()));
1400 pXFBGImage
->SetFileLink(fileURL
);
1404 sal_uInt8
* pGrafData
= nullptr;
1405 sal_uInt32 nDataLen
= pGrfObj
->GetRawGrafData(pGrafData
);
1406 pXFBGImage
->SetImageData(pGrafData
, nDataLen
);
1410 pGrafData
= nullptr;
1414 //automatic, top left
1415 pXFBGImage
->SetPosition(enumXFAlignStart
,enumXFAlignTop
);
1416 if(pLay
->GetScaleCenter())
1419 pXFBGImage
->SetPosition();
1421 else if(pLay
->GetScaleTile())
1424 pXFBGImage
->SetRepeate();
1426 //fit type, area type
1427 if((pLay
->GetScaleMode()& LwpLayoutScale::FIT_IN_FRAME
)!=0)
1429 if((pLay
->GetScaleMode()& LwpLayoutScale::MAINTAIN_ASPECT_RATIO
)==0)
1431 pXFBGImage
->SetStretch();
1441 * @descr: Whether the page uses the printer setting
1444 bool LwpMiddleLayout::GetUsePrinterSettings()
1446 if(m_nOverrideFlag
& OVER_SIZE
)
1448 return (m_nAttributes3
& STYLE3_USEPRINTERSETTINGS
) != 0;
1452 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1453 if (LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*>(xBase
.get()))
1455 return pLay
->GetUsePrinterSettings();
1461 //Check whether there are contents in the layout
1462 bool LwpMiddleLayout::HasContent()
1464 rtl::Reference
<LwpObject
> content
= m_Content
.obj();
1470 LwpLayout::LwpLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
) :
1471 LwpMiddleLayout(objHdr
, pStrm
), m_pUseWhen(new LwpUseWhen
)
1474 LwpLayout::~LwpLayout()
1482 void LwpLayout::Read()
1484 LwpObjectStream
* pStrm
= m_pObjStrm
.get();
1486 LwpMiddleLayout::Read();
1487 if (LwpFileHeader::m_nFileRevision
< 0x000B)
1489 // read PreRevBLayout...
1493 sal_uInt16 nSimple
= pStrm
->QuickReaduInt16();
1497 m_pUseWhen
->Read(pStrm
);
1499 sal_uInt8 nFlag
= pStrm
->QuickReaduInt8();
1501 m_Position
.ReadIndexed(pStrm
);
1504 m_LayColumns
.ReadIndexed(pStrm
);
1505 m_LayGutterStuff
.ReadIndexed(pStrm
);
1506 m_LayJoinStuff
.ReadIndexed(pStrm
);
1507 m_LayShadow
.ReadIndexed(pStrm
);
1509 if (pStrm
->CheckExtra())
1511 m_LayExtJoinStuff
.ReadIndexed(pStrm
);
1518 * @descr: Get columns number
1521 sal_uInt16
LwpLayout::GetNumCols()
1523 if(m_nOverrideFlag
& OVER_COLUMNS
)
1525 LwpLayoutColumns
* pLayColumns
= dynamic_cast<LwpLayoutColumns
*>(m_LayColumns
.obj().get());
1528 return pLayColumns
->GetNumCols();
1532 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1533 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*>(xBase
.get());
1536 return pStyle
->GetNumCols();
1539 return LwpVirtualLayout::GetNumCols();
1544 * @descr: Get column width
1545 * @param: the order of column
1547 double LwpLayout::GetColWidth(sal_uInt16 nIndex
)
1549 if((m_nOverrideFlag
& OVER_COLUMNS
)||(m_nAttributes2
& STYLE2_LOCALCOLUMNINFO
))
1551 LwpLayoutColumns
* pLayColumns
= dynamic_cast<LwpLayoutColumns
*>(m_LayColumns
.obj().get());
1554 return pLayColumns
->GetColWidth(nIndex
);
1558 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1559 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*>(xBase
.get());
1562 return pStyle
->GetColWidth(nIndex
);
1565 return LwpVirtualLayout::GetColWidth(nIndex
);
1570 * @descr: Get gap between columns
1571 * @param: the order of column
1573 double LwpLayout::GetColGap(sal_uInt16 nIndex
)
1575 if((m_nOverrideFlag
& OVER_COLUMNS
)||(m_nAttributes2
& STYLE2_LOCALCOLUMNINFO
))
1577 LwpLayoutColumns
* pLayColumns
= dynamic_cast<LwpLayoutColumns
*>(m_LayColumns
.obj().get());
1580 return pLayColumns
->GetColGap(nIndex
);
1584 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1585 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*>(xBase
.get());
1588 return pStyle
->GetColGap(nIndex
);
1591 return LwpVirtualLayout::GetColGap(nIndex
);
1595 * @descr: Create and return XFColumns object
1598 XFColumns
* LwpLayout::GetXFColumns()
1600 //if there is only one column, do not need insert columns
1601 sal_uInt16 nCols
= GetNumCols();
1607 XFColumns
* pColumns
= new XFColumns();
1609 std::unique_ptr
<XFColumnSep
> pColumnSep(GetColumnSep());
1612 pColumns
->SetSeparator(*pColumnSep
);
1615 //set column count and column gap
1616 pColumns
->SetCount(nCols
);
1617 double fGap
= GetColGap(0);
1618 pColumns
->SetGap(fGap
);
1621 for(sal_uInt16 nIndex
= 0; nIndex
<nCols
; nIndex
++)
1624 sal_Int32 nWidth
= 8305/nCols
; //relative width
1625 aColumn
.SetRelWidth(nWidth
);
1627 //the left and right margins is 0;
1628 double nGap
= GetColGap(nIndex
)/2;
1629 aColumn
.SetMargins(nGap
,nGap
);
1632 aColumn
.SetMargins(0,nGap
);
1634 if(nIndex
==(nCols
-1))
1636 aColumn
.SetMargins(nGap
,0);
1638 pColumns
->AddColumn(aColumn
);
1645 * @descr: Create and return XFColumnSep object
1648 XFColumnSep
* LwpLayout::GetColumnSep()
1651 //Get LwpLayoutGutters
1652 LwpLayoutGutters
* pLayoutGutters
= dynamic_cast<LwpLayoutGutters
*>(m_LayGutterStuff
.obj().get());
1658 LwpBorderStuff
& rBorderStuff
= pLayoutGutters
->GetBorderStuff();
1660 LwpBorderStuff::BorderType eType
= LwpBorderStuff::LEFT
;
1661 LwpColor aColor
= rBorderStuff
.GetSideColor(eType
);
1662 double fWidth
= rBorderStuff
.GetSideWidth(eType
);
1663 //sal_uInt16 nType = rBorderStuff->GetSideType(eType);
1665 XFColumnSep
* pColumnSep
= new XFColumnSep();
1666 XFColor
aXFColor(aColor
.To24Color());
1667 pColumnSep
->SetColor(aXFColor
);
1668 pColumnSep
->SetWidth(fWidth
);
1669 pColumnSep
->SetRelHeight(100);
1670 pColumnSep
->SetVerticalAlign(enumXFAlignTop
);
1676 * @descr: Get use when type
1679 LwpLayout::UseWhenType
LwpLayout::GetUseWhenType()
1681 UseWhenType eType
= StartWithinPage
;
1682 LwpUseWhen
* pUseWhen
= GetUseWhen();
1685 if(pUseWhen
->IsStartOnThisHF())
1687 eType
= StartWithinColume
;
1689 else if(pUseWhen
->IsStartOnThisPage())
1691 eType
= StartWithinPage
;
1693 else if(pUseWhen
->IsStartOnNextPage())
1695 eType
= StartOnNextPage
;
1697 else if(pUseWhen
->IsStartOnNextOddPage())
1699 eType
= StartOnOddPage
;
1701 else if(pUseWhen
->IsStartOnNextEvenPage())
1703 eType
= StartOnEvenPage
;
1709 eType
= StartOnNextPage
;
1715 * @descr: Get use page
1718 sal_uInt16
LwpLayout::GetUsePage()
1720 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1722 LwpUseWhen
* pUseWhen
= GetUseWhen();
1724 return pUseWhen
->GetUsePage();
1730 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1731 if (LwpLayout
* pLay
= dynamic_cast<LwpLayout
*>(xBase
.get()))
1733 return pLay
->GetUsePage();
1740 * @descr: Get usewhen pointer
1743 LwpUseWhen
* LwpLayout::VirtualGetUseWhen()
1745 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1751 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1752 if (LwpLayout
* pLay
= dynamic_cast<LwpLayout
*>(xBase
.get()))
1754 return pLay
->VirtualGetUseWhen();
1757 return LwpVirtualLayout::VirtualGetUseWhen();
1761 * @descr: Whether it is use on all pages
1764 bool LwpLayout::IsUseOnAllPages()
1766 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1768 LwpUseWhen
* pUseWhen
= GetUseWhen();
1770 return pUseWhen
->IsUseOnAllPages();
1776 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1777 if (LwpLayout
* pLay
= dynamic_cast<LwpLayout
*>(xBase
.get()))
1779 return pLay
->IsUseOnAllPages();
1782 return LwpVirtualLayout::IsUseOnAllPages();
1786 * @descr: Whether it is use on all even pages
1789 bool LwpLayout::IsUseOnAllEvenPages()
1791 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1793 LwpUseWhen
* pUseWhen
= GetUseWhen();
1795 return pUseWhen
->IsUseOnAllEvenPages();
1801 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1802 if (LwpLayout
* pLay
= dynamic_cast<LwpLayout
*>(xBase
.get()))
1804 return pLay
->IsUseOnAllEvenPages();
1807 return LwpVirtualLayout::IsUseOnAllEvenPages();
1811 * @descr: Whether it is use on all odd pages
1814 bool LwpLayout::IsUseOnAllOddPages()
1816 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1818 LwpUseWhen
* pUseWhen
= GetUseWhen();
1820 return pUseWhen
->IsUseOnAllOddPages();
1826 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1827 if (LwpLayout
* pLay
= dynamic_cast<LwpLayout
*>(xBase
.get()))
1829 return pLay
->IsUseOnAllOddPages();
1832 return LwpVirtualLayout::IsUseOnAllOddPages();
1836 * @descr: Whether it is use on current page
1839 bool LwpLayout::IsUseOnPage()
1841 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1843 LwpUseWhen
* pUseWhen
= GetUseWhen();
1845 return pUseWhen
->IsUseOnPage();
1851 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1852 if (LwpLayout
* pLay
= dynamic_cast<LwpLayout
*>(xBase
.get()))
1854 return pLay
->IsUseOnPage();
1857 return LwpVirtualLayout::IsUseOnPage();
1861 * @descr: Get the LwpShadow object according to m_LayShadow id.
1863 LwpShadow
* LwpLayout::GetShadow()
1865 if(m_nOverrideFlag
& OVER_SHADOW
)
1867 LwpLayoutShadow
* pLayoutShadow
= dynamic_cast<LwpLayoutShadow
*>(m_LayShadow
.obj().get());
1868 return pLayoutShadow
? &pLayoutShadow
->GetShadow() : nullptr;
1872 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
1873 if (LwpLayout
* pLay
= dynamic_cast<LwpLayout
*>(xBase
.get()))
1875 return pLay
->GetShadow();
1882 * @descr: create xfshadow
1884 XFShadow
* LwpLayout::GetXFShadow()
1886 LwpShadow
* pShadow
= GetShadow();
1889 LwpColor color
= pShadow
->GetColor();
1890 double offsetX
= pShadow
->GetOffsetX();
1891 double offsetY
= pShadow
->GetOffsetY();
1893 if( offsetX
&& offsetY
&& color
.IsValidColor() )
1895 XFShadow
* pXFShadow
= new XFShadow();
1896 enumXFShadowPos eXFShadowPos
= enumXFShadowLeftTop
;
1909 eXFShadowPos
= enumXFShadowLeftTop
;
1911 eXFShadowPos
= enumXFShadowLeftBottom
;
1917 eXFShadowPos
= enumXFShadowRightTop
;
1919 eXFShadowPos
= enumXFShadowRightBottom
;
1922 pXFShadow
->SetPosition(eXFShadowPos
);
1923 pXFShadow
->SetOffset(fOffset
);
1924 pXFShadow
->SetColor(XFColor(color
.To24Color()));
1933 * @descr get the layout that containers the current frame layout
1936 rtl::Reference
<LwpVirtualLayout
> LwpLayout::GetContainerLayout()
1938 if(IsRelativeAnchored())
1941 LwpPara
* pPara
= dynamic_cast<LwpPara
*>(GetPosition().obj().get());
1944 LwpStory
* pStory
= pPara
->GetStory();
1945 return pStory
? pStory
->GetTabLayout() : nullptr;
1948 return GetParentLayout();
1951 LwpPlacableLayout::LwpPlacableLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
1952 : LwpLayout(objHdr
, pStrm
)
1955 , m_nBaseLineOffset(0)
1958 LwpPlacableLayout::~LwpPlacableLayout()
1961 void LwpPlacableLayout::Read()
1963 LwpObjectStream
* pStrm
= m_pObjStrm
.get();
1965 if(LwpFileHeader::m_nFileRevision
< 0x000B)
1971 sal_uInt16 simple
= pStrm
->QuickReaduInt16();
1974 m_nWrapType
= pStrm
->QuickReaduInt8();
1975 m_nBuoyancy
= pStrm
->QuickReaduInt8();
1976 m_nBaseLineOffset
= pStrm
->QuickReadInt32();
1977 m_Script
.Read( pStrm
);
1981 m_nWrapType
= LAY_WRAP_AROUND
;
1982 m_nBuoyancy
= LAY_BUOYNEUTRAL
;
1983 m_nBaseLineOffset
= 0;
1985 m_LayRelativity
.ReadIndexed( pStrm
);
1986 if(pStrm
->CheckExtra())
1988 sal_uInt16 count
= pStrm
->QuickReaduInt16();
1991 // temporily added by to avoid assertion
2004 * @descr: get wrap type
2006 sal_uInt8
LwpPlacableLayout::GetWrapType()
2008 if(m_nOverrideFlag
& OVER_PLACEMENT
)
2014 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
2015 if (LwpPlacableLayout
* pLay
= dynamic_cast<LwpPlacableLayout
*>(xBase
.get()))
2017 return pLay
->GetWrapType();
2020 return LAY_WRAP_AROUND
;
2023 * @descr: get LayoutRelativity
2025 LwpLayoutRelativity
* LwpPlacableLayout::GetRelativityPiece()
2027 if(!m_LayRelativity
.IsNull())
2029 if(m_nOverrideFlag
& OVER_PLACEMENT
)
2031 return dynamic_cast<LwpLayoutRelativity
*>(m_LayRelativity
.obj().get());
2036 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
2037 if (LwpPlacableLayout
* pLay
= dynamic_cast<LwpPlacableLayout
*>(xBase
.get()))
2039 return pLay
->GetRelativityPiece();
2045 * @descr: Get relative type
2048 sal_uInt8
LwpPlacableLayout::GetRelativeType()
2050 LwpLayoutRelativity
* pLayRel
= GetRelativityPiece();
2053 return pLayRel
->GetRelGuts().GetRelativeType();
2055 return LwpVirtualLayout::GetRelativeType();
2058 * @descr: Get offset from the baseline
2061 sal_Int32
LwpPlacableLayout::GetBaseLineOffset()
2063 /* The baseline is only valid if this is flow-with-text */
2064 if(GetRelativeType()!=LwpLayoutRelativityGuts::LAY_INLINE
)
2069 // First, ask our content if it has a baseline, ignore now
2071 if (Content && Content->GetBaseLineOffset(&Baseline))
2075 if(m_nOverrideFlag
& OVER_PLACEMENT
)
2077 return m_nBaseLineOffset
;
2081 rtl::Reference
<LwpObject
> xBase(GetBasedOnStyle());
2082 if (LwpPlacableLayout
* pLay
= dynamic_cast<LwpPlacableLayout
*>(xBase
.get()))
2084 return pLay
->GetBaseLineOffset();
2091 * @descr: whether the parent layout is page layout
2094 bool LwpPlacableLayout::IsAnchorPage()
2096 if(IsRelativeAnchored())
2099 rtl::Reference
<LwpVirtualLayout
> xLayout
= GetParentLayout();
2100 if (xLayout
.is() && (xLayout
->IsPage() || xLayout
->IsHeader() || xLayout
->IsFooter()))
2107 * @descr: whether the parent layout is frame layout
2110 bool LwpPlacableLayout::IsAnchorFrame()
2112 if(IsRelativeAnchored())
2115 rtl::Reference
<LwpVirtualLayout
> xLayout
= GetParentLayout();
2116 if (xLayout
.is() && (xLayout
->IsFrame() || xLayout
->IsGroupHead()))
2123 * @descr: whether the parent layout is cell layout
2126 bool LwpPlacableLayout::IsAnchorCell()
2128 if(IsRelativeAnchored())
2131 rtl::Reference
<LwpVirtualLayout
> xLayout
= GetParentLayout();
2132 if (xLayout
.is() && xLayout
->IsCell())
2140 * @descr: Set font style for setting position of frame
2143 void LwpPlacableLayout::SetFont(rtl::Reference
<XFFont
> const & pFont
)
2148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */