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 /*************************************************************************
57 * For LWP filter architecture prototype
58 ************************************************************************/
59 /*************************************************************************
62 Feb 2005 Process gemotry, margins
63 ************************************************************************/
65 #include "lwplayout.hxx"
66 #include "lwpusewhen.hxx"
67 #include "lwptools.hxx"
68 #include "xfilter/xfcolumns.hxx"
69 #include "lwpstory.hxx"
70 #include "lwpparastyle.hxx"
71 #include "lwpholder.hxx"
73 #include "lwppagehint.hxx"
74 #include "lwpdivinfo.hxx"
75 #include "lwpgrfobj.hxx"
76 #ifndef _OSL_THREAD_H_
77 #include <osl/thread.h>
80 LwpVirtualLayout::LwpVirtualLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
81 : LwpDLNFPVList(objHdr
, pStrm
)
84 void LwpVirtualLayout::Read()
86 LwpDLNFPVList::Read();
88 LwpObjectStream
* pStrm
= m_pObjStrm
;
89 pStrm
->QuickRead(&m_nAttributes
, sizeof(m_nAttributes
));
90 pStrm
->QuickRead(&m_nAttributes2
, sizeof(m_nAttributes2
));
91 pStrm
->QuickRead(&m_nAttributes3
, sizeof(m_nAttributes3
));
92 pStrm
->QuickRead(&m_nOverrideFlag
, sizeof(m_nOverrideFlag
));
93 pStrm
->QuickRead(&m_nDirection
, sizeof(m_nDirection
));
95 //Note that two bytes is read into m_nEditorID instead of one byte.
96 pStrm
->QuickRead(&m_nEditorID
, sizeof(m_nEditorID
));
98 m_NextEnumerated
.ReadIndexed(pStrm
);
99 m_PreviousEnumerated
.ReadIndexed(pStrm
);
104 sal_Bool
LwpVirtualLayout::MarginsSameAsParent()
106 return m_nAttributes2
& STYLE2_MARGINSSAMEASPARENT
? sal_True
: sal_False
;
110 * @descr: Get column width
113 double LwpVirtualLayout::GetColWidth(sal_uInt16 nIndex
)
115 //return GetContentWidth(); //not support now
116 //return LwpTools::ConvertToMetric(5); //test
121 * @descr: Get the gap between columns
124 double LwpVirtualLayout::GetColGap(sal_uInt16 nIndex
)
126 //return DEFAULTGAPSIZE;
127 //return LwpTools::ConvertToMetric(0.17);//DEFAULTGAPSIZE=0.17
128 return LwpTools::ConvertToMetric(0.17);
132 * @descr: Whether it is honoring protection
135 sal_Bool
LwpVirtualLayout::HonorProtection()
137 if(!(m_nAttributes2
& STYLE2_HONORPROTECTION
))
140 LwpVirtualLayout
* pParent
= static_cast<LwpVirtualLayout
*> (GetParent()->obj());
141 if(pParent
&& !pParent
->IsHeader())
143 return pParent
->HonorProtection();
146 if(m_pFoundry
)//is null now
148 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
151 return pDoc->HonorProtection();
153 if(pDoc
&& pDoc
->GetRootDocument())
154 return pDoc
->GetRootDocument()->HonorProtection();
161 * @descr: Whether it is protected
164 sal_Bool
LwpVirtualLayout::IsProtected()
166 sal_Bool bProtected
= (m_nAttributes
& STYLE_PROTECTED
)!=0;
168 LwpVirtualLayout
* pParent
= static_cast<LwpVirtualLayout
*> (GetParent()->obj());
169 if(pParent
&& !pParent
->IsHeader())
171 if(pParent
->HonorProtection()&&(pParent
->HasProtection()||bProtected
))
176 else if(m_pFoundry
)//is null now
178 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
181 if (pDoc
->HonorProtection() && bProtected
)
192 * @descr: Whether it has protection
195 sal_Bool
LwpVirtualLayout::HasProtection()
197 if(m_nAttributes
& STYLE_PROTECTED
)
200 LwpVirtualLayout
* pParent
= static_cast<LwpVirtualLayout
*> (GetParent()->obj());
201 if(pParent
&& !pParent
->IsHeader())
203 return pParent
->HasProtection();
210 * @descr: Whether it is a mirror layout
213 sal_Bool
LwpVirtualLayout::IsComplex()
215 return m_nAttributes
& STYLE_COMPLEX
? sal_True
: sal_False
;
219 * @descr: Get usewhen pointer
222 LwpUseWhen
* LwpVirtualLayout::GetUseWhen()
225 If we have a parent, and I'm not a page layout,
226 use my parents information.
228 if(GetLayoutType()!=LWP_PAGE_LAYOUT
)
231 LwpVirtualLayout
* pParent
= static_cast<LwpVirtualLayout
*> (GetParent()->obj());
232 if(pParent
&& !pParent
->IsHeader()&& (pParent
->GetLayoutType()!=LWP_PAGE_LAYOUT
))
233 return pParent
->GetUseWhen();
237 return VirtualGetUseWhen();
240 * @descr: Whether this layout is page layout or not
244 sal_Bool
LwpVirtualLayout::IsPage()
246 return (GetLayoutType() == LWP_PAGE_LAYOUT
);
249 * @descr: Whether this layout is heaer layout or not
253 sal_Bool
LwpVirtualLayout::IsHeader()
255 return (GetLayoutType() == LWP_HEADER_LAYOUT
);
258 * @descr: Whether this layout is footer layout or not
262 sal_Bool
LwpVirtualLayout::IsFooter()
264 return (GetLayoutType() == LWP_FOOTER_LAYOUT
);
267 * @descr: Whether this layout is frame layout or not
271 sal_Bool
LwpVirtualLayout::IsFrame()
273 return (GetLayoutType() == LWP_FRAME_LAYOUT
);
277 * @descr: Whether this layout is cell layout or not
281 sal_Bool
LwpVirtualLayout::IsCell()
283 return (GetLayoutType() == LWP_CELL_LAYOUT
284 || GetLayoutType() == LWP_CONNECTED_CELL_LAYOUT
285 || GetLayoutType() == LWP_HIDDEN_CELL_LAYOUT
);
288 * @descr: Whether this layout is supertable layout or not
292 sal_Bool
LwpVirtualLayout::IsSuperTable()
294 return (GetLayoutType() == LWP_SUPERTABLE_LAYOUT
);
297 * @descr: Whether this layout is group layout or not
301 sal_Bool
LwpVirtualLayout::IsGroupHead()
303 return (GetLayoutType() == LWP_GROUP_LAYOUT
);
306 * @descr: get the relative type
310 sal_uInt8
LwpVirtualLayout::GetRelativeType()
312 return LwpLayoutRelativityGuts::LAY_PARENT_RELATIVE
;
315 * @descr: whether it is relative anchored layout
319 sal_Bool
LwpVirtualLayout::IsRelativeAnchored()
323 nType
= GetRelativeType();
324 return (nType
== LwpLayoutRelativityGuts::LAY_PARA_RELATIVE
) || (nType
== LwpLayoutRelativityGuts::LAY_INLINE
)
325 || (nType
== LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE
) || (nType
== LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL
);
328 * @descr: whether it is MinimumHeight layout
332 sal_Bool
LwpVirtualLayout::IsMinimumHeight()
334 return ((m_nAttributes3
& STYLE3_MINHEIGHTVALID
) != 0);
338 * @descr: Get parent layout
341 LwpVirtualLayout
* LwpVirtualLayout::GetParentLayout()
343 return static_cast<LwpVirtualLayout
*> (GetParent()->obj());
347 * @descr: Register child layout style
350 void LwpVirtualLayout::RegisterChildStyle()
352 //Register all children styles
353 LwpVirtualLayout
* pLayout
= static_cast<LwpVirtualLayout
*>(GetChildHead()->obj());
356 pLayout
->SetFoundry(m_pFoundry
);
357 pLayout
->RegisterStyle();
358 pLayout
= static_cast<LwpVirtualLayout
*>(pLayout
->GetNext()->obj());
362 sal_Bool
LwpVirtualLayout::NoContentReference()
364 return (m_nAttributes2
& STYLE2_NOCONTENTREFERENCE
) != 0;
367 sal_Bool
LwpVirtualLayout::IsStyleLayout()
369 if (m_nAttributes3
& STYLE3_STYLELAYOUT
)
372 LwpVirtualLayout
* pParent
=static_cast<LwpVirtualLayout
*>(GetParent()->obj());
374 return pParent
->IsStyleLayout();
379 * @descr: Find child layout by layout type
382 LwpVirtualLayout
* LwpVirtualLayout::FindChildByType(LWP_LAYOUT_TYPE eType
)
384 LwpObjectID
*pID
= GetChildHead();
386 while(pID
&& !pID
->IsNull())
388 LwpVirtualLayout
* pLayout
= static_cast<LwpVirtualLayout
*>(pID
->obj());
394 if (pLayout
&& pLayout
->GetLayoutType() == eType
)
398 pID
= pLayout
->GetNext();
405 * @descr: Whether the size of layout is fit the graphic
408 sal_Bool
LwpVirtualLayout::IsFitGraphic()
410 return IsAutoGrowRight() && !IsAutoGrowLeft() && IsAutoGrowDown();
414 * @descr: Whether the width of layout is auto grow
417 sal_Bool
LwpVirtualLayout::IsAutoGrowWidth()
419 return IsAutoGrowLeft() || IsAutoGrowRight();
423 * @descr: Determine whether the layout width is to margin
426 sal_Bool
LwpVirtualLayout::IsInlineToMargin()
428 return (m_nAttributes3
& STYLE3_INLINETOMARGIN
) != 0;
431 void LwpAssociatedLayouts::Read(LwpObjectStream
* pStrm
)
433 m_OnlyLayout
.ReadIndexed(pStrm
);
434 m_Layouts
.Read(pStrm
);
439 * @descr: Looking for the layout which follows the pStartLayout
440 * @param: pStartLayout - the layout which is used for looking for its following layout
442 LwpVirtualLayout
* LwpAssociatedLayouts::GetLayout(LwpVirtualLayout
*pStartLayout
)
444 LwpVirtualLayout
* pLayout
= NULL
;
446 if (!pStartLayout
&& !m_OnlyLayout
.IsNull())
447 /* Looking for the first layout and there's only one layout in the list.*/
448 return static_cast<LwpVirtualLayout
*>(m_OnlyLayout
.obj());
450 LwpObjectHolder
* pObjHolder
=static_cast<LwpObjectHolder
*>(m_Layouts
.GetHead()->obj());
453 pLayout
= static_cast<LwpVirtualLayout
*>(pObjHolder
->GetObject()->obj());
457 while(pObjHolder
&& pStartLayout
!= pLayout
)
459 pObjHolder
= static_cast<LwpObjectHolder
*>(pObjHolder
->GetNext()->obj());
462 pLayout
= static_cast<LwpVirtualLayout
*>(pObjHolder
->GetObject()->obj());
468 pObjHolder
= static_cast<LwpObjectHolder
*>(pObjHolder
->GetNext()->obj());
471 pLayout
= static_cast<LwpVirtualLayout
*>(pObjHolder
->GetObject()->obj());
482 LwpHeadLayout::LwpHeadLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
483 : LwpVirtualLayout(objHdr
, pStrm
)
486 void LwpHeadLayout::Read()
488 LwpVirtualLayout::Read();
489 //For PermissiveLayout
490 m_pObjStrm
->SkipExtra();
492 m_pObjStrm
->SkipExtra();
495 void LwpHeadLayout::RegisterStyle()
497 //Register all children styles
498 LwpVirtualLayout
* pLayout
= static_cast<LwpVirtualLayout
*>(GetChildHead()->obj());
501 pLayout
->SetFoundry(m_pFoundry
);
502 //if the layout is relative to para, the layout will be registered in para
503 if(!pLayout
->IsRelativeAnchored())
505 pLayout
->RegisterStyle();
507 pLayout
= static_cast<LwpVirtualLayout
*>(pLayout
->GetNext()->obj());
512 * @descr find endnote supertable layout from the child layout list. Suppose that there is only one endnote supertablelayout in one division
513 * @return pointer to endnote supertable layout
515 LwpVirtualLayout
* LwpHeadLayout::FindEnSuperTableLayout()
517 LwpVirtualLayout
* pLayout
= static_cast<LwpVirtualLayout
*>(GetChildHead()->obj());
520 if(pLayout
->GetLayoutType() == LWP_ENDNOTE_SUPERTABLE_LAYOUT
)
524 pLayout
= static_cast<LwpVirtualLayout
*>(pLayout
->GetNext()->obj());
529 LwpLayoutStyle::LwpLayoutStyle() :
530 m_nStyleDefinition(0), m_nKey(0),
531 m_pDescription(new LwpAtomHolder
)
535 LwpLayoutStyle::~LwpLayoutStyle()
539 delete m_pDescription
;
543 void LwpLayoutStyle::Read(LwpObjectStream
* pStrm
)
545 pStrm
->QuickRead(&m_nStyleDefinition
, sizeof(m_nStyleDefinition
));
546 m_pDescription
->Read(pStrm
);
547 if (pStrm
->CheckExtra())
549 pStrm
->QuickRead(&m_nKey
, 2);
554 LwpLayoutMisc::LwpLayoutMisc() :
555 m_nGridDistance(0), m_nGridType(0),
556 m_pContentStyle(new LwpAtomHolder
)
560 LwpLayoutMisc::~LwpLayoutMisc()
564 delete m_pContentStyle
;
568 void LwpLayoutMisc::Read(LwpObjectStream
* pStrm
)
570 pStrm
->QuickRead(&m_nGridType
, 2);
571 pStrm
->QuickRead(&m_nGridDistance
, 4);
572 m_pContentStyle
->Read(pStrm
);
576 LwpMiddleLayout::LwpMiddleLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
577 : LwpVirtualLayout(objHdr
, pStrm
),
578 m_pStyleStuff(new LwpLayoutStyle
), m_pMiscStuff(new LwpLayoutMisc
)
581 LwpMiddleLayout::~LwpMiddleLayout()
585 delete m_pStyleStuff
;
592 void LwpMiddleLayout::Read()
594 LwpObjectStream
* pStrm
= m_pObjStrm
;
596 LwpVirtualLayout::Read();
598 //skip CLiteLayout data;
599 LwpAtomHolder ContentClass
;
600 ContentClass
.Read(pStrm
);
603 // before layout hierarchy rework
604 if(LwpFileHeader::m_nFileRevision
< 0x000B)
607 m_Content
.ReadIndexed(pStrm
);
610 m_BasedOnStyle
.ReadIndexed(pStrm
);
611 m_TabPiece
.ReadIndexed(pStrm
);
613 sal_uInt8 nWhatsItGot
= 0;
614 pStrm
->QuickRead(&nWhatsItGot
, 1);
616 if (nWhatsItGot
& DISK_GOT_STYLE_STUFF
)
618 m_pStyleStuff
->Read(pStrm
);
620 if (nWhatsItGot
& DISK_GOT_MISC_STUFF
)
622 m_pMiscStuff
->Read(pStrm
);
625 m_LayGeometry
.ReadIndexed(pStrm
);
626 m_LayScale
.ReadIndexed(pStrm
);
627 m_LayMargins
.ReadIndexed(pStrm
);
628 m_LayBorderStuff
.ReadIndexed(pStrm
);
629 m_LayBackgroundStuff
.ReadIndexed(pStrm
);
631 if (pStrm
->CheckExtra())
633 m_LayExtBorderStuff
.ReadIndexed(pStrm
);
639 #include "lwplaypiece.hxx"
642 * @descr: Get the geometry of current layout
645 LwpLayoutGeometry
* LwpMiddleLayout::GetGeometry()
647 if( !m_LayGeometry
.IsNull() )
649 return ( static_cast<LwpLayoutGeometry
*> (m_LayGeometry
.obj()) );
651 else if( !m_BasedOnStyle
.IsNull() )
653 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
654 return pLay
->GetGeometry();
660 * @descr: Get layout height, measured by "cm"
663 double LwpMiddleLayout::GetGeometryHeight()
665 LwpLayoutGeometry
* pGeo
= GetGeometry();
668 return ( LwpTools::ConvertFromUnitsToMetric( pGeo
->GetHeight() ) );
675 * @descr: Get layout width, measured by "cm"
678 double LwpMiddleLayout::GetGeometryWidth()
680 LwpLayoutGeometry
* pGeo
= GetGeometry();
683 return ( LwpTools::ConvertFromUnitsToMetric( pGeo
->GetWidth() ) );
690 * @descr: Whether the margins is same as parent layout
693 BOOL
LwpMiddleLayout::MarginsSameAsParent()
695 if(m_nOverrideFlag
& OVER_MARGINS
)
697 return LwpVirtualLayout::MarginsSameAsParent();
699 if(!m_BasedOnStyle
.IsNull())
701 LwpVirtualLayout
* play
= static_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj());
702 play
->MarginsSameAsParent();
704 return LwpVirtualLayout::MarginsSameAsParent();
710 * @param: nWhichSide - 0: left, 1: right, 2:top, 3: bottom
712 double LwpMiddleLayout::GetMarginsValue(const sal_uInt8
&nWhichSide
)
715 if((nWhichSide
==MARGIN_LEFT
)||(nWhichSide
==MARGIN_RIGHT
))
717 if ( MarginsSameAsParent() )
719 LwpVirtualLayout
* pParent
= static_cast<LwpVirtualLayout
*> (GetParent()->obj());
720 if(pParent
&& !pParent
->IsHeader())
722 fValue
= pParent
->GetMarginsValue(nWhichSide
);
728 if(m_nOverrideFlag
& OVER_MARGINS
)
730 LwpLayoutMargins
* pMar1
= static_cast<LwpLayoutMargins
*> (m_LayMargins
.obj());
733 fValue
= pMar1
->GetMargins()->GetMarginsValue(nWhichSide
);
737 LwpVirtualLayout
* pStyle
= static_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj());
740 fValue
= pStyle
->GetMarginsValue(nWhichSide
);
743 return LwpVirtualLayout::GetMarginsValue(nWhichSide
);
746 * @descr: Get extmargin value
747 * @param: nWhichSide - 0: left, 1: right, 2:top, 3: bottom
751 double LwpMiddleLayout::GetExtMarginsValue(const sal_uInt8
&nWhichSide
)
754 if(m_nOverrideFlag
& OVER_MARGINS
)
756 LwpLayoutMargins
* pMar1
= static_cast<LwpLayoutMargins
*> (m_LayMargins
.obj());
759 fValue
= pMar1
->GetExtMargins()->GetMarginsValue(nWhichSide
);
763 LwpVirtualLayout
* pStyle
= static_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj());
766 fValue
= pStyle
->GetExtMarginsValue(nWhichSide
);
769 return LwpVirtualLayout::GetExtMarginsValue(nWhichSide
);
772 * @descr: Get the LwpBorderStuff object according to m_LayBorderStuff id.
777 LwpBorderStuff
* LwpMiddleLayout::GetBorderStuff()
779 if(m_nOverrideFlag
& OVER_BORDERS
)
781 LwpLayoutBorder
* pLayoutBorder
= static_cast<LwpLayoutBorder
*>(m_LayBorderStuff
.obj());
782 return pLayoutBorder
->GetBorderStuff();
784 else if( !m_BasedOnStyle
.IsNull() )
786 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
787 return pLay
->GetBorderStuff();
793 * @descr: Get LwpBackgroundStuff object according to m_LayBackgroundStuff id;
798 LwpBackgroundStuff
* LwpMiddleLayout::GetBackgroundStuff()
800 if(m_nOverrideFlag
& OVER_BACKGROUND
)
802 LwpLayoutBackground
* pLayoutBackground
= static_cast<LwpLayoutBackground
*>(m_LayBackgroundStuff
.obj());
803 return pLayoutBackground
->GetBackgoudStuff();
805 else if( !m_BasedOnStyle
.IsNull() )
807 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
808 return pLay
->GetBackgroundStuff();
813 * @descr: create xfborder.
818 XFBorders
* LwpMiddleLayout::GetXFBorders()
820 LwpBorderStuff
* pBorderStuff
= GetBorderStuff();
821 if(pBorderStuff
&&pBorderStuff
->GetSide() != 0)
823 //copy from lwpparastyle.
824 XFBorders
*pXFBorders
= new XFBorders();
825 // apply 4 borders respectively
826 LwpBorderStuff::BorderType pType
[] = { LwpBorderStuff::LEFT
, LwpBorderStuff::RIGHT
,
827 LwpBorderStuff::TOP
, LwpBorderStuff::BOTTOM
};
829 for (sal_uInt8 nC
= 0; nC
< 4; nC
++)
831 if (pBorderStuff
->HasSide(pType
[nC
]))
833 LwpParaStyle::ApplySubBorder(pBorderStuff
, pType
[nC
], pXFBorders
);
842 * @descr: Get text direction settings.
847 enumXFTextDir
LwpMiddleLayout::GetTextDirection()
849 enumXFTextDir eTextDir
= enumXFTextDirNone
;
850 sal_uInt8 nDirection
= GetContentOrientation();
853 case TEXT_ORIENT_LRTB
:
855 eTextDir
= enumXFTextDirLR_TB
;
858 case TEXT_ORIENT_TBRL
:
860 eTextDir
= enumXFTextDirTB_RL
;
863 case TEXT_ORIENT_RLBT
: // not supported now
865 eTextDir
= enumXFTextDirNone
;
868 case TEXT_ORIENT_BTLR
: // not supported now
870 eTextDir
= enumXFTextDirNone
;
879 * @descr: Get back ground color.
884 LwpColor
* LwpMiddleLayout::GetBackColor()
886 LwpBackgroundStuff
* pBackgroundStuff
= GetBackgroundStuff();
887 if(pBackgroundStuff
&& !pBackgroundStuff
->IsTransparent())
889 LwpColor
* pColor
= pBackgroundStuff
->GetFillColor();
890 if(pColor
->IsValidColor())
899 * @descr: Add back color settings into xfpagemaster.
904 LwpTabOverride
* LwpMiddleLayout::GetTabOverride()
906 if(m_nAttributes
& OVER_TABS
)
908 if(!m_TabPiece
.IsNull())
909 return (LwpTabOverride
*)static_cast<LwpTabPiece
*>(m_TabPiece
.obj())->GetOverride();
912 else if( !m_BasedOnStyle
.IsNull() )
914 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
915 return pLay
->GetTabOverride();
921 * @descr: Layscale for graphic & watermark
926 sal_uInt16
LwpMiddleLayout::GetScaleMode(void)
928 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj())
929 return GetLayoutScale()->GetScaleMode();
930 else if (m_BasedOnStyle
.obj())
931 return static_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj())->GetScaleMode();
933 return (LwpLayoutScale::FIT_IN_FRAME
| LwpLayoutScale::MAINTAIN_ASPECT_RATIO
);
936 void LwpMiddleLayout::SetScaleMode(sal_uInt16 nVal
)
938 m_nOverrideFlag
|= OVER_SCALING
;
939 // nVal |= LwpLayoutScale::MAINTAIN_ASPECT_RATIO;
940 GetLayoutScale()->SetScaleMode(nVal
);
943 sal_uInt16
LwpMiddleLayout::GetScaleTile(void)
945 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj())
946 return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::TILED
)
948 else if (m_BasedOnStyle
.obj())
949 return static_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj())->GetScaleTile();
954 void LwpMiddleLayout::SetScaleTile(sal_uInt16 nVal
)
956 m_nOverrideFlag
|= OVER_SCALING
;
958 GetLayoutScale()->SetPlacement(GetLayoutScale()->GetPlacement() | LwpLayoutScale::TILED
);
960 GetLayoutScale()->SetPlacement(GetLayoutScale()->GetPlacement() & ~LwpLayoutScale::TILED
);
963 sal_uInt16
LwpMiddleLayout::GetScaleCenter(void)
965 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj())
966 return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::CENTERED
)
968 else if (m_BasedOnStyle
.obj())
969 return static_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj())->GetScaleCenter();
974 void LwpMiddleLayout::SetScaleCenter(sal_uInt16 nVal
)
976 m_nOverrideFlag
|= OVER_SCALING
;
978 GetLayoutScale()->SetPlacement(GetLayoutScale()->GetPlacement() | LwpLayoutScale::CENTERED
);
980 GetLayoutScale()->SetPlacement(GetLayoutScale()->GetPlacement() & ~LwpLayoutScale::CENTERED
);
983 sal_uInt32
LwpMiddleLayout::GetScalePercentage(void)
985 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj())
986 return GetLayoutScale()->GetScalePercentage()/10;//m_nScalePercentage 1000 = 100%
987 else if (m_BasedOnStyle
.obj())
988 return static_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj())->GetScalePercentage();
993 void LwpMiddleLayout::SetScalePercentage(sal_uInt32 nVal
)
995 m_nOverrideFlag
|= OVER_SCALING
;
996 GetLayoutScale()->SetScalePercentage(nVal
*10);
999 double LwpMiddleLayout::GetScaleWidth(void)
1001 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj())
1002 return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleWidth());
1003 else if (m_BasedOnStyle
.obj())
1004 return static_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj())->GetScaleWidth();
1009 void LwpMiddleLayout::SetScaleWidth(double fVal
)
1011 m_nOverrideFlag
|= OVER_SCALING
;
1012 GetLayoutScale()->SetScaleWidth(LwpTools::ConvertToUnits(fVal
));
1015 double LwpMiddleLayout::GetScaleHeight(void)
1017 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj())
1018 return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleHeight());
1019 else if (m_BasedOnStyle
.obj())
1020 return static_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj())->GetScaleHeight();
1024 sal_Bool
LwpMiddleLayout::CanSizeRight(void)
1026 sal_uInt8 RelType
= GetRelativeType();
1028 if (RelType
== LwpLayoutRelativityGuts::LAY_INLINE
|| RelType
== LwpLayoutRelativityGuts::LAY_PARA_RELATIVE
1029 || RelType
== LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL
)
1035 sal_Int32
LwpMiddleLayout::GetMinimumWidth()
1037 if (((m_nAttributes3
& STYLE3_WIDTHVALID
) != 0) && GetGeometry())
1039 return GetGeometry()->GetWidth();
1041 else if (m_nOverrideFlag
& OVER_SIZE
)
1043 return DetermineWidth();
1047 sal_Int32
LwpMiddleLayout::DetermineWidth()
1049 if (IsSizeRightToContent())
1053 else if (IsSizeRightToContainer())
1059 m_nAttributes3
|= STYLE3_WIDTHVALID
;
1060 return GetGeometry()->GetWidth();
1064 sal_Bool
LwpMiddleLayout::IsSizeRightToContainer(void)
1066 if (!CanSizeRight())
1069 if (m_nOverrideFlag
& OVER_SIZE
)
1071 return (m_nDirection
& ((LAY_USEDIRECTION
|LAY_AUTOSIZE
|LAY_TOCONTAINER
)
1073 == ((LAY_USEDIRECTION
| LAY_TOCONTAINER
| LAY_AUTOSIZE
) << SHIFT_RIGHT
);
1075 else if (m_BasedOnStyle
.obj())
1077 LwpMiddleLayout
* pLayout
= static_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj());
1078 return pLayout
->IsSizeRightToContainer();
1083 sal_Bool
LwpMiddleLayout::IsSizeRightToContent(void)
1085 if (!CanSizeRight())
1088 if (m_nOverrideFlag
& OVER_SIZE
)
1090 return (m_nDirection
& ((LAY_USEDIRECTION
|LAY_AUTOSIZE
|LAY_TOCONTAINER
)
1092 == ((LAY_USEDIRECTION
| LAY_AUTOSIZE
) << SHIFT_RIGHT
);
1094 else if (m_BasedOnStyle
.obj())
1096 LwpMiddleLayout
* pLayout
= static_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj());
1097 return pLayout
->IsSizeRightToContent();
1104 * @descr: Get layout height
1107 double LwpMiddleLayout::GetHeight()
1109 return GetGeometryHeight();
1113 * @descr: Get layout height
1116 double LwpMiddleLayout::GetWidth()
1118 return GetGeometryWidth();
1121 * @descr: Get layout orgin point
1124 LwpPoint
LwpMiddleLayout::GetOrigin()
1126 LwpLayoutGeometry
* pGeo
= GetGeometry();
1129 sal_uInt8 nType
= GetRelativeType();
1130 if(nType
== LwpLayoutRelativityGuts::LAY_INLINE
1131 || nType
== LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE
)
1133 return pGeo
->GetAbsoluteOrigin();
1136 return pGeo
->GetOrigin();
1143 void LwpMiddleLayout::SetScaleHeight(double fVal
)
1145 m_nOverrideFlag
|= OVER_SCALING
;
1146 GetLayoutScale()->SetScaleHeight(LwpTools::ConvertToUnits(fVal
));
1150 * @descr: Whether the fill is pattern fill or not
1151 * @return: True if yes, false if not.
1153 sal_Bool
LwpMiddleLayout::IsPatternFill()
1155 LwpBackgroundStuff
* pBackgroundStuff
= GetBackgroundStuff();
1156 if (pBackgroundStuff
)
1158 return pBackgroundStuff
->IsPatternFill();
1165 * @descr: Get the fill pattern style. Data are saved in a XFBGImage object
1166 * @return: the fill pattern style.
1168 XFBGImage
* LwpMiddleLayout::GetFillPattern()
1170 LwpBackgroundStuff
* pBackgroundStuff
= GetBackgroundStuff();
1171 if (pBackgroundStuff
)
1173 return pBackgroundStuff
->GetFillPattern();
1181 * @descr: Whether the height and width of layout is auto grow
1184 sal_Bool
LwpMiddleLayout::IsAutoGrow()
1186 if(m_nOverrideFlag
& OVER_SIZE
)
1188 return m_nDirection
&
1189 ((LAY_AUTOGROW
<< SHIFT_UP
) | (LAY_AUTOGROW
<< SHIFT_DOWN
) |
1190 (LAY_AUTOGROW
<< SHIFT_RIGHT
) | (LAY_AUTOGROW
<< SHIFT_LEFT
))
1191 ? sal_True
: sal_False
;
1193 else if( !m_BasedOnStyle
.IsNull() )
1195 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1196 return pLay
->IsAutoGrow();
1198 return LwpVirtualLayout::IsAutoGrow();
1202 * @descr: Whether the height of layout is auto grow down
1205 sal_Bool
LwpMiddleLayout::IsAutoGrowDown()
1207 if(m_nOverrideFlag
& OVER_SIZE
)
1209 return m_nDirection
& (LAY_AUTOGROW
<< SHIFT_DOWN
) ? sal_True
: sal_False
;
1211 else if( !m_BasedOnStyle
.IsNull() )
1213 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1214 return pLay
->IsAutoGrowDown();
1216 return LwpVirtualLayout::IsAutoGrowDown();
1220 * @descr: Whether the height of layout is auto grow up
1223 sal_Bool
LwpMiddleLayout::IsAutoGrowUp()
1225 if(m_nOverrideFlag
& OVER_SIZE
)
1227 return m_nDirection
& (LAY_AUTOGROW
<< SHIFT_UP
) ? sal_True
: sal_False
;
1229 else if( !m_BasedOnStyle
.IsNull() )
1231 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1232 return pLay
->IsAutoGrowUp();
1234 return LwpVirtualLayout::IsAutoGrowUp();
1238 * @descr: Whether the height of layout is auto grow down
1241 sal_Bool
LwpMiddleLayout::IsAutoGrowLeft()
1243 if(m_nOverrideFlag
& OVER_SIZE
)
1245 return m_nDirection
& (LAY_AUTOGROW
<< SHIFT_LEFT
) ? sal_True
: sal_False
;
1247 else if( !m_BasedOnStyle
.IsNull() )
1249 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1250 return pLay
->IsAutoGrowLeft();
1252 return LwpVirtualLayout::IsAutoGrowLeft();
1256 * @descr: Whether the height of layout is auto grow down
1259 sal_Bool
LwpMiddleLayout::IsAutoGrowRight()
1261 if(m_nOverrideFlag
& OVER_SIZE
)
1263 return m_nDirection
& (LAY_AUTOGROW
<< SHIFT_RIGHT
) ? sal_True
: sal_False
;
1265 else if( !m_BasedOnStyle
.IsNull() )
1267 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1268 return pLay
->IsAutoGrowRight();
1270 return LwpVirtualLayout::IsAutoGrowRight();
1275 * @descr: Get contents orientation
1278 sal_uInt8
LwpMiddleLayout::GetContentOrientation()
1280 //content orientation in Graphic objects and OLE objects not supported now
1281 if((m_nOverrideFlag
& OVER_ROTATION
)&& !m_LayGeometry
.IsNull())
1283 LwpLayoutGeometry
* pLayGeometry
= static_cast<LwpLayoutGeometry
*> (m_LayGeometry
.obj());
1284 return pLayGeometry
->GetContentOrientation();
1286 else if( !m_BasedOnStyle
.IsNull() )
1288 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1289 return pLay
->GetContentOrientation();
1291 return LwpVirtualLayout::GetContentOrientation();
1295 * @descr: Whether it is honoring protection
1298 sal_Bool
LwpMiddleLayout::HonorProtection()
1300 if(m_nOverrideFlag
& OVER_MISC
)
1302 if(!(m_nAttributes2
& STYLE2_HONORPROTECTION
))
1305 LwpVirtualLayout
* pParent
= static_cast<LwpVirtualLayout
*> (GetParent()->obj());
1306 if(pParent
&& !pParent
->IsHeader())
1308 return pParent
->HonorProtection();
1311 if(m_pFoundry
)//is null now
1313 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
1316 return pDoc
->HonorProtection();
1320 else if( !m_BasedOnStyle
.IsNull() )
1322 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1323 return pLay
->HonorProtection();
1326 return LwpVirtualLayout::HonorProtection();
1330 * @descr: Whether it is pretected
1333 sal_Bool
LwpMiddleLayout::IsProtected()
1335 sal_Bool bProtected
= sal_False
;
1336 if(m_nOverrideFlag
& OVER_MISC
)
1338 bProtected
= (m_nAttributes
& STYLE_PROTECTED
)!=0;
1340 else if( !m_BasedOnStyle
.IsNull() )
1342 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1343 bProtected
= pLay
->IsProtected();
1346 bProtected
= LwpVirtualLayout::IsProtected();
1348 LwpVirtualLayout
* pParent
= static_cast<LwpVirtualLayout
*> (GetParent()->obj());
1349 if(pParent
&& !pParent
->IsHeader())
1351 /* If a parent's protected then none of its children can be accessed. */
1352 if(pParent
->IsProtected())
1355 if(pParent
->HonorProtection())
1358 /* If our parent isn't honoring protection then we aren't protected. */
1362 if(m_pFoundry
)//is null now
1364 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
1367 if (pDoc
->HonorProtection())
1370 /* If the document isn't honoring protection then we aren't protected.*/
1379 * @descr: Get watermark layout
1382 LwpVirtualLayout
* LwpMiddleLayout::GetWaterMarkLayout()
1384 LwpVirtualLayout
* pLay
= static_cast<LwpVirtualLayout
*>(GetChildHead()->obj());
1387 if( pLay
->IsForWaterMark())
1391 pLay
= static_cast<LwpVirtualLayout
*> (pLay
->GetNext()->obj());
1397 * @descr: Create and reture xfbgimage object for watermark
1400 XFBGImage
* LwpMiddleLayout::GetXFBGImage()
1402 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*>(GetWaterMarkLayout());
1406 LwpGraphicObject
* pGrfObj
= static_cast<LwpGraphicObject
*>(pLay
->GetContent()->obj());
1409 XFBGImage
* pXFBGImage
= new XFBGImage();
1411 if(pGrfObj
->IsLinked())
1414 OUString linkedfilepath
= pGrfObj
->GetLinkedFilePath();
1415 OUString fileURL
= LwpTools::convertToFileUrl(OUStringToOString(linkedfilepath
, osl_getThreadTextEncoding()));
1416 pXFBGImage
->SetFileLink(fileURL
);
1420 sal_uInt8
* pGrafData
= NULL
;
1421 sal_uInt32 nDataLen
= pGrfObj
->GetRawGrafData(pGrafData
);
1422 pXFBGImage
->SetImageData(pGrafData
, nDataLen
);
1431 //automatic, top left
1432 pXFBGImage
->SetPosition(enumXFAlignStart
,enumXFAlignTop
);
1433 if(pLay
->GetScaleCenter())
1436 pXFBGImage
->SetPosition(enumXFAlignCenter
,enumXFAlignCenter
);
1438 else if(pLay
->GetScaleTile())
1441 pXFBGImage
->SetRepeate();
1443 //fit type, area type
1444 if((pLay
->GetScaleMode()& LwpLayoutScale::FIT_IN_FRAME
)!=0)
1446 if((pLay
->GetScaleMode()& LwpLayoutScale::MAINTAIN_ASPECT_RATIO
)==0)
1448 pXFBGImage
->SetStretch();
1458 * @descr: Whether the page uses the printer setting
1461 sal_Bool
LwpMiddleLayout::GetUsePrinterSettings()
1463 if(m_nOverrideFlag
& OVER_SIZE
)
1465 return (m_nAttributes3
& STYLE3_USEPRINTERSETTINGS
) != 0;
1467 else if( !m_BasedOnStyle
.IsNull() )
1469 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1470 return pLay
->GetUsePrinterSettings();
1476 //Check whether there are contents in the layout
1477 sal_Bool
LwpMiddleLayout::HasContent()
1479 LwpObject
* content
= m_Content
.obj();
1486 LwpLayout::LwpLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
) :
1487 LwpMiddleLayout(objHdr
, pStrm
), m_pUseWhen(new LwpUseWhen
)
1490 LwpLayout::~LwpLayout()
1498 void LwpLayout::Read()
1500 LwpObjectStream
* pStrm
= m_pObjStrm
;
1502 LwpMiddleLayout::Read();
1503 if (LwpFileHeader::m_nFileRevision
< 0x000B)
1505 // read PreRevBLayout...
1510 pStrm
->QuickRead(&nSimple
, 2);
1514 m_pUseWhen
->Read(pStrm
);
1517 pStrm
->QuickRead(&nFlag
, 1);
1520 m_Positon
.ReadIndexed(pStrm
);
1524 m_LayColumns
.ReadIndexed(pStrm
);
1525 m_LayGutterStuff
.ReadIndexed(pStrm
);
1526 m_LayJoinStuff
.ReadIndexed(pStrm
);
1527 m_LayShadow
.ReadIndexed(pStrm
);
1529 if (pStrm
->CheckExtra())
1531 m_LayExtJoinStuff
.ReadIndexed(pStrm
);
1538 * @descr: Get columns number
1541 sal_uInt16
LwpLayout::GetNumCols()
1543 if(m_nOverrideFlag
& OVER_COLUMNS
)
1545 LwpLayoutColumns
* pLayColumns
= static_cast<LwpLayoutColumns
*>(m_LayColumns
.obj());
1548 return pLayColumns
->GetNumCols();
1552 LwpVirtualLayout
* pStyle
= static_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj());
1555 return pStyle
->GetNumCols();
1558 return LwpVirtualLayout::GetNumCols();
1563 * @descr: Get column width
1564 * @param: the order of column
1566 double LwpLayout::GetColWidth(sal_uInt16 nIndex
)
1568 if((m_nOverrideFlag
& OVER_COLUMNS
)||(m_nAttributes2
& STYLE2_LOCALCOLUMNINFO
))
1570 LwpLayoutColumns
* pLayColumns
= static_cast<LwpLayoutColumns
*>(m_LayColumns
.obj());
1573 return pLayColumns
->GetColWidth(nIndex
);
1577 LwpVirtualLayout
* pStyle
= static_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj());
1580 return pStyle
->GetColWidth(nIndex
);
1583 return LwpVirtualLayout::GetColWidth(nIndex
);
1588 * @descr: Get gap between columns
1589 * @param: the order of column
1591 double LwpLayout::GetColGap(sal_uInt16 nIndex
)
1593 if((m_nOverrideFlag
& OVER_COLUMNS
)||(m_nAttributes2
& STYLE2_LOCALCOLUMNINFO
))
1595 LwpLayoutColumns
* pLayColumns
= static_cast<LwpLayoutColumns
*>(m_LayColumns
.obj());
1598 return pLayColumns
->GetColGap(nIndex
);
1602 LwpVirtualLayout
* pStyle
= static_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj());
1605 return pStyle
->GetColGap(nIndex
);
1608 return LwpVirtualLayout::GetColGap(nIndex
);
1612 * @descr: Create and return XFColumns object
1615 XFColumns
* LwpLayout::GetXFColumns()
1617 //if there is only one column, do not need insert columns
1618 sal_uInt16 nCols
= GetNumCols();
1624 XFColumns
* pColumns
= new XFColumns();
1626 XFColumnSep
* pColumnSep
= GetColumnSep();
1629 pColumns
->SetSeperator(*pColumnSep
);
1632 //set column count and column gap
1633 pColumns
->SetCount(nCols
);
1634 double fGap
= GetColGap(0);
1635 pColumns
->SetGap(fGap
);
1638 for(sal_uInt16 nIndex
= 0; nIndex
<nCols
; nIndex
++)
1640 XFColumn
* pColumn
= new XFColumn();
1641 sal_Int32 nWidth
= static_cast<sal_Int32
>(GetColWidth(nIndex
));
1642 nWidth
=8305/nCols
; //relative width
1643 pColumn
->SetRelWidth(nWidth
);
1645 //the left and right margins is 0;
1646 double nGap
= GetColGap(nIndex
)/2;
1648 pColumn
->SetMargins(nGap
,nGap
);
1651 pColumn
->SetMargins(0,nGap
);
1653 if(nIndex
==(nCols
-1))
1655 pColumn
->SetMargins(nGap
,0);
1657 pColumns
->AddColumn(*pColumn
);
1664 * @descr: Create and return XFColumnSep object
1667 XFColumnSep
* LwpLayout::GetColumnSep()
1670 //Get LwpLayoutGutters
1671 LwpLayoutGutters
* pLayoutGutters
= static_cast<LwpLayoutGutters
*>(m_LayGutterStuff
.obj());
1677 LwpBorderStuff
* pBorderStuff
= pLayoutGutters
->GetBorderStuff();
1681 LwpBorderStuff::BorderType eType
= LwpBorderStuff::LEFT
;
1682 LwpColor aColor
= pBorderStuff
->GetSideColor(eType
);
1683 double fWidth
= pBorderStuff
->GetSideWidth(eType
);
1684 //sal_uInt16 nType = pBorderStuff->GetSideType(eType);
1686 XFColumnSep
* pColumnSep
= new XFColumnSep();
1687 XFColor
aXFColor(aColor
.To24Color());
1688 pColumnSep
->SetColor(aXFColor
);
1689 pColumnSep
->SetWidth(fWidth
);
1690 pColumnSep
->SetRelHeight(100);
1691 pColumnSep
->SetVerticalAlign(enumXFAlignTop
);
1700 * @descr: Get use when type
1703 LwpLayout::UseWhenType
LwpLayout::GetUseWhenType()
1705 UseWhenType eType
= StartWithinPage
;
1706 LwpUseWhen
* pUseWhen
= GetUseWhen();
1709 if(pUseWhen
->IsStartOnThisHF())
1711 eType
= StartWithinColume
;
1713 else if(pUseWhen
->IsStartOnThisPage())
1715 eType
= StartWithinPage
;
1717 else if(pUseWhen
->IsStartOnNextPage())
1719 eType
= StartOnNextPage
;
1721 else if(pUseWhen
->IsStartOnNextOddPage())
1723 eType
= StartOnOddPage
;
1725 else if(pUseWhen
->IsStartOnNextEvenPage())
1727 eType
= StartOnEvenPage
;
1733 eType
= StartOnNextPage
;
1739 * @descr: Get use page
1742 sal_uInt16
LwpLayout::GetUsePage()
1744 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1746 LwpUseWhen
* pUseWhen
= GetUseWhen();
1748 return pUseWhen
->GetUsePage();
1752 else if( !m_BasedOnStyle
.IsNull() )
1754 LwpLayout
* pLay
= static_cast<LwpLayout
*> ( m_BasedOnStyle
.obj() );
1755 return pLay
->GetUsePage();
1761 * @descr: Get usewhen pointer
1764 LwpUseWhen
* LwpLayout::VirtualGetUseWhen()
1766 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1770 else if( !m_BasedOnStyle
.IsNull() )
1772 LwpLayout
* pLay
= static_cast<LwpLayout
*> ( m_BasedOnStyle
.obj() );
1773 return pLay
->VirtualGetUseWhen();
1775 return LwpVirtualLayout::VirtualGetUseWhen();
1779 * @descr: Whether it is use on all pages
1782 sal_Bool
LwpLayout::IsUseOnAllPages()
1784 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1786 LwpUseWhen
* pUseWhen
= GetUseWhen();
1788 return pUseWhen
->IsUseOnAllPages();
1792 else if( !m_BasedOnStyle
.IsNull() )
1794 LwpLayout
* pLay
= static_cast<LwpLayout
*> ( m_BasedOnStyle
.obj() );
1795 return pLay
->IsUseOnAllPages();
1797 return LwpVirtualLayout::IsUseOnAllPages();
1801 * @descr: Whether it is use on all even pages
1804 sal_Bool
LwpLayout::IsUseOnAllEvenPages()
1806 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1808 LwpUseWhen
* pUseWhen
= GetUseWhen();
1810 return pUseWhen
->IsUseOnAllEvenPages();
1814 else if( !m_BasedOnStyle
.IsNull() )
1816 LwpLayout
* pLay
= static_cast<LwpLayout
*> ( m_BasedOnStyle
.obj() );
1817 return pLay
->IsUseOnAllEvenPages();
1819 return LwpVirtualLayout::IsUseOnAllEvenPages();
1823 * @descr: Whether it is use on all odd pages
1826 sal_Bool
LwpLayout::IsUseOnAllOddPages()
1828 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1830 LwpUseWhen
* pUseWhen
= GetUseWhen();
1832 return pUseWhen
->IsUseOnAllOddPages();
1836 else if( !m_BasedOnStyle
.IsNull() )
1838 LwpLayout
* pLay
= static_cast<LwpLayout
*> ( m_BasedOnStyle
.obj() );
1839 return pLay
->IsUseOnAllOddPages();
1841 return LwpVirtualLayout::IsUseOnAllOddPages();
1845 * @descr: Whether it is use on current page
1848 sal_Bool
LwpLayout::IsUseOnPage()
1850 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1852 LwpUseWhen
* pUseWhen
= GetUseWhen();
1854 return pUseWhen
->IsUseOnPage();
1858 else if( !m_BasedOnStyle
.IsNull() )
1860 LwpLayout
* pLay
= static_cast<LwpLayout
*> ( m_BasedOnStyle
.obj() );
1861 return pLay
->IsUseOnPage();
1863 return LwpVirtualLayout::IsUseOnPage();
1867 * @descr: Get the LwpShadow object according to m_LayShadow id.
1872 LwpShadow
* LwpLayout::GetShadow()
1874 if(m_nOverrideFlag
& OVER_SHADOW
)
1876 LwpLayoutShadow
* pLayoutShadow
= static_cast<LwpLayoutShadow
*>(m_LayShadow
.obj());
1877 return pLayoutShadow
->GetShadow();
1879 else if( !m_BasedOnStyle
.IsNull() )
1881 LwpLayout
* pLay
= static_cast<LwpLayout
*> ( m_BasedOnStyle
.obj() );
1882 return pLay
->GetShadow();
1888 * @descr: create xfshadow
1893 XFShadow
* LwpLayout::GetXFShadow()
1895 LwpShadow
* pShadow
= GetShadow();
1898 LwpColor color
= pShadow
->GetColor();
1899 double offsetX
= pShadow
->GetOffsetX();
1900 double offsetY
= pShadow
->GetOffsetY();
1902 if( offsetX
&& offsetY
&& color
.IsValidColor() )
1904 XFShadow
* pXFShadow
= new XFShadow();
1905 enumXFShadowPos eXFShadowPos
= enumXFShadowLeftTop
;
1908 sal_Bool left
= sal_False
;
1909 sal_Bool top
= sal_False
;
1918 eXFShadowPos
= enumXFShadowLeftTop
;
1920 eXFShadowPos
= enumXFShadowLeftBottom
;
1926 eXFShadowPos
= enumXFShadowRightTop
;
1928 eXFShadowPos
= enumXFShadowRightBottom
;
1931 pXFShadow
->SetPosition(eXFShadowPos
);
1932 pXFShadow
->SetOffset(fOffset
);
1933 pXFShadow
->SetColor(XFColor(color
.To24Color()));
1942 * @descr get the layout that containers the current frame layout
1945 LwpVirtualLayout
* LwpLayout::GetContainerLayout()
1947 if(IsRelativeAnchored())
1950 LwpPara
* pPara
= static_cast<LwpPara
*>(GetPosition()->obj());
1953 LwpStory
* pStory
= pPara
->GetStory();
1954 return pStory
->GetTabLayout();
1957 return GetParentLayout();
1960 LwpPlacableLayout::LwpPlacableLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
1961 : LwpLayout(objHdr
, pStrm
),m_pFont(NULL
)
1964 LwpPlacableLayout::~LwpPlacableLayout()
1967 void LwpPlacableLayout::Read()
1969 LwpObjectStream
* pStrm
= m_pObjStrm
;
1971 if(LwpFileHeader::m_nFileRevision
< 0x000B)
1978 pStrm
->QuickRead(&simple
, sizeof(simple
));
1981 pStrm
->QuickRead(&m_nWrapType
, sizeof(m_nWrapType
));
1982 pStrm
->QuickRead(&m_nBuoyancy
, sizeof(m_nBuoyancy
));
1983 pStrm
->QuickRead(&m_nBaseLineOffset
, sizeof(m_nBaseLineOffset
));
1984 m_Script
.Read( pStrm
);
1988 m_nWrapType
= LAY_WRAP_AROUND
;
1989 m_nBuoyancy
= LAY_BUOYNEUTRAL
;
1990 m_nBaseLineOffset
= 0;
1992 m_LayRelativity
.ReadIndexed( pStrm
);
1993 if(pStrm
->CheckExtra())
1996 pStrm
->QuickRead(&count
, sizeof(count
));
1999 // temporily added by to avoid assertion
2013 * @descr: get wrap type
2018 sal_uInt8
LwpPlacableLayout::GetWrapType()
2020 if(m_nOverrideFlag
& OVER_PLACEMENT
)
2024 else if( !m_BasedOnStyle
.IsNull() )
2026 LwpPlacableLayout
* pLay
= static_cast<LwpPlacableLayout
*> ( m_BasedOnStyle
.obj() );
2027 return pLay
->GetWrapType();
2029 return LAY_WRAP_AROUND
;
2032 * @descr: get LayoutRelativity
2037 LwpLayoutRelativity
* LwpPlacableLayout::GetRelativityPiece()
2039 if(!m_LayRelativity
.IsNull())
2041 if(m_nOverrideFlag
& OVER_PLACEMENT
)
2043 return static_cast<LwpLayoutRelativity
*>(m_LayRelativity
.obj());
2046 else if( !m_BasedOnStyle
.IsNull() )
2048 LwpPlacableLayout
* pLay
= static_cast<LwpPlacableLayout
*> ( m_BasedOnStyle
.obj() );
2049 return pLay
->GetRelativityPiece();
2054 * @descr: Get relative type
2057 sal_uInt8
LwpPlacableLayout::GetRelativeType()
2059 LwpLayoutRelativity
* pLayRel
= GetRelativityPiece();
2062 return pLayRel
->GetRelGuts()->GetRelativeType();
2064 return LwpVirtualLayout::GetRelativeType();
2067 * @descr: Get relative from where type
2070 sal_uInt8
LwpPlacableLayout::GetRelativeFromWhere()
2072 LwpLayoutRelativity
* pLayRel
= GetRelativityPiece();
2075 return pLayRel
->GetRelGuts()->GetRelativeFromWhere();
2080 * @descr: Get relative distance
2083 LwpPoint
LwpPlacableLayout::GetRelativeDistance()
2086 LwpLayoutRelativity
* pLayRel
= GetRelativityPiece();
2089 aPoint
= pLayRel
->GetRelGuts()->GetRelativeDistance();
2094 * @descr: Get tether type
2097 sal_uInt8
LwpPlacableLayout::GetTetherType()
2099 LwpLayoutRelativity
* pLayRel
= GetRelativityPiece();
2102 return pLayRel
->GetRelGuts()->GetTetherType();
2107 * @descr: Get tether where type
2110 sal_uInt8
LwpPlacableLayout::GetTetherWhere()
2112 LwpLayoutRelativity
* pLayRel
= GetRelativityPiece();
2115 return pLayRel
->GetRelGuts()->GetTetherWhere();
2120 * @descr: Get offset from the baseline
2123 sal_Int32
LwpPlacableLayout::GetBaseLineOffset()
2125 /* The baseline is only valid if this is flow-with-text */
2126 if(GetRelativeType()!=LwpLayoutRelativityGuts::LAY_INLINE
)
2131 // First, ask our content if it has a baseline, ignore now
2133 if (Content && Content->GetBaseLineOffset(&Baseline))
2137 if(m_nOverrideFlag
& OVER_PLACEMENT
)
2139 return m_nBaseLineOffset
;
2141 else if( !m_BasedOnStyle
.IsNull() )
2143 LwpPlacableLayout
* pLay
= static_cast<LwpPlacableLayout
*> ( m_BasedOnStyle
.obj() );
2144 return pLay
->GetBaseLineOffset();
2151 * @descr: whether the parent layout is page layout
2154 sal_Bool
LwpPlacableLayout::IsAnchorPage()
2156 if(IsRelativeAnchored())
2159 LwpVirtualLayout
* pLayout
= GetParentLayout();
2160 if(pLayout
&& (pLayout
->IsPage() || pLayout
->IsHeader() || pLayout
->IsFooter()))
2161 //if(pLayout && pLayout->IsPage())
2168 * @descr: whether the parent layout is frame layout
2171 sal_Bool
LwpPlacableLayout::IsAnchorFrame()
2173 if(IsRelativeAnchored())
2176 LwpVirtualLayout
* pLayout
= GetParentLayout();
2177 if(pLayout
&& (pLayout
->IsFrame()||pLayout
->IsGroupHead()))
2184 * @descr: whether the parent layout is cell layout
2187 sal_Bool
LwpPlacableLayout::IsAnchorCell()
2189 if(IsRelativeAnchored())
2192 LwpVirtualLayout
* pLayout
= GetParentLayout();
2193 if(pLayout
&& pLayout
->IsCell())
2201 * @descr: Get font style for setting position of frame
2204 XFFont
* LwpPlacableLayout::GetFont()
2209 * @descr: Set font style for setting position of frame
2212 void LwpPlacableLayout::SetFont(XFFont
* pFont
)