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 ************************************************************************/
60 /*************************************************************************
63 Feb 2005 Process gemotry, margins
64 ************************************************************************/
66 #include "lwplayout.hxx"
67 #include "lwpusewhen.hxx"
68 #include "lwptools.hxx"
69 #include "xfilter/xfcolumns.hxx"
70 #include "lwpstory.hxx"
71 #include "lwpparastyle.hxx"
72 #include "lwpholder.hxx"
74 #include "lwppagehint.hxx"
75 #include "lwpdivinfo.hxx"
76 #include "lwpgrfobj.hxx"
77 #include <osl/thread.h>
79 LwpVirtualLayout::LwpVirtualLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
80 : LwpDLNFPVList(objHdr
, pStrm
)
90 void LwpVirtualLayout::Read()
92 LwpDLNFPVList::Read();
94 LwpObjectStream
* pStrm
= m_pObjStrm
;
95 m_nAttributes
= pStrm
->QuickReaduInt32();
96 m_nAttributes2
= pStrm
->QuickReaduInt32();
97 m_nAttributes3
= pStrm
->QuickReaduInt32();
98 m_nOverrideFlag
= pStrm
->QuickReaduInt32();
99 m_nDirection
= pStrm
->QuickReaduInt16();
101 //Note that two bytes is read into m_nEditorID instead of one byte.
102 m_nEditorID
= pStrm
->QuickReaduInt16();
104 m_NextEnumerated
.ReadIndexed(pStrm
);
105 m_PreviousEnumerated
.ReadIndexed(pStrm
);
110 bool LwpVirtualLayout::MarginsSameAsParent()
112 return m_nAttributes2
& STYLE2_MARGINSSAMEASPARENT
? sal_True
: sal_False
;
116 * @descr: Get column width
119 double LwpVirtualLayout::GetColWidth(sal_uInt16
/*nIndex*/)
121 //return GetContentWidth(); //not support now
122 //return LwpTools::ConvertToMetric(5); //test
127 * @descr: Get the gap between columns
130 double LwpVirtualLayout::GetColGap(sal_uInt16
/*nIndex*/)
132 //return DEFAULTGAPSIZE;
133 //return LwpTools::ConvertToMetric(0.17);//DEFAULTGAPSIZE=0.17
134 return LwpTools::ConvertToMetric(0.17);
138 * @descr: Whether it is honoring protection
141 bool LwpVirtualLayout::HonorProtection()
143 if(!(m_nAttributes2
& STYLE2_HONORPROTECTION
))
146 LwpVirtualLayout
* pParent
= dynamic_cast<LwpVirtualLayout
*> (GetParent()->obj());
147 if(pParent
&& !pParent
->IsHeader())
149 return pParent
->HonorProtection();
152 if(m_pFoundry
)//is null now
154 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
157 return pDoc->HonorProtection();
159 if(pDoc
&& pDoc
->GetRootDocument())
160 return pDoc
->GetRootDocument()->HonorProtection();
167 * @descr: Whether it is protected
170 bool LwpVirtualLayout::IsProtected()
172 bool bProtected
= (m_nAttributes
& STYLE_PROTECTED
)!=0;
174 LwpVirtualLayout
* pParent
= dynamic_cast<LwpVirtualLayout
*> (GetParent()->obj());
175 if(pParent
&& !pParent
->IsHeader())
177 if(pParent
->HonorProtection()&&(pParent
->HasProtection()||bProtected
))
182 else if(m_pFoundry
)//is null now
184 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
187 if (pDoc
->HonorProtection() && bProtected
)
198 * @descr: Whether it has protection
201 bool LwpVirtualLayout::HasProtection()
203 if(m_nAttributes
& STYLE_PROTECTED
)
206 LwpVirtualLayout
* pParent
= dynamic_cast<LwpVirtualLayout
*> (GetParent()->obj());
207 if(pParent
&& !pParent
->IsHeader())
209 return pParent
->HasProtection();
216 * @descr: Whether it is a mirror layout
219 bool LwpVirtualLayout::IsComplex()
221 return m_nAttributes
& STYLE_COMPLEX
? sal_True
: sal_False
;
225 * @descr: Get usewhen pointer
228 LwpUseWhen
* LwpVirtualLayout::GetUseWhen()
231 If we have a parent, and I'm not a page layout,
232 use my parents information.
234 if(GetLayoutType()!=LWP_PAGE_LAYOUT
)
237 LwpVirtualLayout
* pParent
= dynamic_cast<LwpVirtualLayout
*> (GetParent()->obj());
238 if(pParent
&& !pParent
->IsHeader()&& (pParent
->GetLayoutType()!=LWP_PAGE_LAYOUT
))
239 return pParent
->GetUseWhen();
243 return VirtualGetUseWhen();
246 * @descr: Whether this layout is page layout or not
250 bool LwpVirtualLayout::IsPage()
252 return (GetLayoutType() == LWP_PAGE_LAYOUT
);
255 * @descr: Whether this layout is heaer layout or not
259 bool LwpVirtualLayout::IsHeader()
261 return (GetLayoutType() == LWP_HEADER_LAYOUT
);
264 * @descr: Whether this layout is footer layout or not
268 bool LwpVirtualLayout::IsFooter()
270 return (GetLayoutType() == LWP_FOOTER_LAYOUT
);
273 * @descr: Whether this layout is frame layout or not
277 bool LwpVirtualLayout::IsFrame()
279 return (GetLayoutType() == LWP_FRAME_LAYOUT
);
283 * @descr: Whether this layout is cell layout or not
287 bool LwpVirtualLayout::IsCell()
289 return (GetLayoutType() == LWP_CELL_LAYOUT
290 || GetLayoutType() == LWP_CONNECTED_CELL_LAYOUT
291 || GetLayoutType() == LWP_HIDDEN_CELL_LAYOUT
);
294 * @descr: Whether this layout is supertable layout or not
298 bool LwpVirtualLayout::IsSuperTable()
300 return (GetLayoutType() == LWP_SUPERTABLE_LAYOUT
);
303 * @descr: Whether this layout is group layout or not
307 bool LwpVirtualLayout::IsGroupHead()
309 return (GetLayoutType() == LWP_GROUP_LAYOUT
);
312 * @descr: get the relative type
316 sal_uInt8
LwpVirtualLayout::GetRelativeType()
318 return LwpLayoutRelativityGuts::LAY_PARENT_RELATIVE
;
321 * @descr: whether it is relative anchored layout
325 bool LwpVirtualLayout::IsRelativeAnchored()
329 nType
= GetRelativeType();
330 return (nType
== LwpLayoutRelativityGuts::LAY_PARA_RELATIVE
) || (nType
== LwpLayoutRelativityGuts::LAY_INLINE
)
331 || (nType
== LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE
) || (nType
== LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL
);
334 * @descr: whether it is MinimumHeight layout
338 bool LwpVirtualLayout::IsMinimumHeight()
340 return ((m_nAttributes3
& STYLE3_MINHEIGHTVALID
) != 0);
344 * @descr: Get parent layout
347 LwpVirtualLayout
* LwpVirtualLayout::GetParentLayout()
349 return dynamic_cast<LwpVirtualLayout
*> (GetParent()->obj());
353 * @descr: Register child layout style
356 void LwpVirtualLayout::RegisterChildStyle()
358 //Register all children styles
359 LwpVirtualLayout
* pLayout
= dynamic_cast<LwpVirtualLayout
*>(GetChildHead()->obj());
362 pLayout
->SetFoundry(m_pFoundry
);
363 pLayout
->RegisterStyle();
364 pLayout
= dynamic_cast<LwpVirtualLayout
*>(pLayout
->GetNext()->obj());
368 bool LwpVirtualLayout::NoContentReference()
370 return (m_nAttributes2
& STYLE2_NOCONTENTREFERENCE
) != 0;
373 bool LwpVirtualLayout::IsStyleLayout()
375 if (m_nAttributes3
& STYLE3_STYLELAYOUT
)
378 LwpVirtualLayout
* pParent
= dynamic_cast<LwpVirtualLayout
*>(GetParent()->obj());
380 return pParent
->IsStyleLayout();
385 * @descr: Find child layout by layout type
388 LwpVirtualLayout
* LwpVirtualLayout::FindChildByType(LWP_LAYOUT_TYPE eType
)
390 LwpObjectID
*pID
= GetChildHead();
392 while(pID
&& !pID
->IsNull())
394 LwpVirtualLayout
* pLayout
= dynamic_cast<LwpVirtualLayout
*>(pID
->obj());
400 if (pLayout
&& pLayout
->GetLayoutType() == eType
)
404 pID
= pLayout
->GetNext();
411 * @descr: Whether the size of layout is fit the graphic
414 bool LwpVirtualLayout::IsFitGraphic()
416 return IsAutoGrowRight() && !IsAutoGrowLeft() && IsAutoGrowDown();
420 * @descr: Whether the width of layout is auto grow
423 bool LwpVirtualLayout::IsAutoGrowWidth()
425 return IsAutoGrowLeft() || IsAutoGrowRight();
429 * @descr: Determine whether the layout width is to margin
432 bool LwpVirtualLayout::IsInlineToMargin()
434 return (m_nAttributes3
& STYLE3_INLINETOMARGIN
) != 0;
437 void LwpAssociatedLayouts::Read(LwpObjectStream
* pStrm
)
439 m_OnlyLayout
.ReadIndexed(pStrm
);
440 m_Layouts
.Read(pStrm
);
445 * @descr: Looking for the layout which follows the pStartLayout
446 * @param: pStartLayout - the layout which is used for looking for its following layout
448 LwpVirtualLayout
* LwpAssociatedLayouts::GetLayout(LwpVirtualLayout
*pStartLayout
)
450 LwpVirtualLayout
* pLayout
= NULL
;
452 if (!pStartLayout
&& !m_OnlyLayout
.IsNull())
453 /* Looking for the first layout and there's only one layout in the list.*/
454 return dynamic_cast<LwpVirtualLayout
*>(m_OnlyLayout
.obj());
456 LwpObjectHolder
* pObjHolder
= dynamic_cast<LwpObjectHolder
*>(m_Layouts
.GetHead()->obj());
459 pLayout
= dynamic_cast<LwpVirtualLayout
*>(pObjHolder
->GetObject()->obj());
463 while(pObjHolder
&& pStartLayout
!= pLayout
)
465 pObjHolder
= dynamic_cast<LwpObjectHolder
*>(pObjHolder
->GetNext()->obj());
468 pLayout
= dynamic_cast<LwpVirtualLayout
*>(pObjHolder
->GetObject()->obj());
474 pObjHolder
= dynamic_cast<LwpObjectHolder
*>(pObjHolder
->GetNext()->obj());
477 pLayout
= dynamic_cast<LwpVirtualLayout
*>(pObjHolder
->GetObject()->obj());
488 LwpHeadLayout::LwpHeadLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
489 : LwpVirtualLayout(objHdr
, pStrm
)
492 void LwpHeadLayout::Read()
494 LwpVirtualLayout::Read();
495 //For PermissiveLayout
496 m_pObjStrm
->SkipExtra();
498 m_pObjStrm
->SkipExtra();
501 void LwpHeadLayout::RegisterStyle()
503 //Register all children styles
504 LwpVirtualLayout
* pLayout
= dynamic_cast<LwpVirtualLayout
*>(GetChildHead()->obj());
507 pLayout
->SetFoundry(m_pFoundry
);
508 //if the layout is relative to para, the layout will be registered in para
509 if(!pLayout
->IsRelativeAnchored())
513 OSL_FAIL("Layout points to itself");
516 pLayout
->RegisterStyle();
518 LwpVirtualLayout
*pNext
= dynamic_cast<LwpVirtualLayout
*>(pLayout
->GetNext()->obj());
519 if (pNext
== pLayout
)
521 OSL_FAIL("Layout points to itself");
529 * @descr find endnote supertable layout from the child layout list. Suppose that there is only one endnote supertablelayout in one division
530 * @return pointer to endnote supertable layout
532 LwpVirtualLayout
* LwpHeadLayout::FindEnSuperTableLayout()
534 LwpVirtualLayout
* pLayout
= dynamic_cast<LwpVirtualLayout
*>(GetChildHead()->obj());
537 if(pLayout
->GetLayoutType() == LWP_ENDNOTE_SUPERTABLE_LAYOUT
)
541 pLayout
= dynamic_cast<LwpVirtualLayout
*>(pLayout
->GetNext()->obj());
546 LwpLayoutStyle::LwpLayoutStyle()
547 : m_nStyleDefinition(0)
548 , m_pDescription(new LwpAtomHolder
)
553 LwpLayoutStyle::~LwpLayoutStyle()
555 delete m_pDescription
;
558 void LwpLayoutStyle::Read(LwpObjectStream
* pStrm
)
560 m_nStyleDefinition
= pStrm
->QuickReaduInt32();
561 m_pDescription
->Read(pStrm
);
562 if (pStrm
->CheckExtra())
564 m_nKey
= pStrm
->QuickReaduInt16();
569 LwpLayoutMisc::LwpLayoutMisc() :
570 m_nGridDistance(0), m_nGridType(0),
571 m_pContentStyle(new LwpAtomHolder
)
575 LwpLayoutMisc::~LwpLayoutMisc()
579 delete m_pContentStyle
;
583 void LwpLayoutMisc::Read(LwpObjectStream
* pStrm
)
585 m_nGridType
= pStrm
->QuickReaduInt16();
586 m_nGridDistance
= pStrm
->QuickReadInt32();
587 m_pContentStyle
->Read(pStrm
);
591 LwpMiddleLayout::LwpMiddleLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
592 : LwpVirtualLayout(objHdr
, pStrm
),
593 m_pStyleStuff(new LwpLayoutStyle
), m_pMiscStuff(new LwpLayoutMisc
)
596 LwpMiddleLayout::~LwpMiddleLayout()
600 delete m_pStyleStuff
;
607 void LwpMiddleLayout::Read()
609 LwpObjectStream
* pStrm
= m_pObjStrm
;
611 LwpVirtualLayout::Read();
613 //skip CLiteLayout data;
614 LwpAtomHolder ContentClass
;
615 ContentClass
.Read(pStrm
);
618 // before layout hierarchy rework
619 if(LwpFileHeader::m_nFileRevision
< 0x000B)
622 m_Content
.ReadIndexed(pStrm
);
625 m_BasedOnStyle
.ReadIndexed(pStrm
);
626 m_TabPiece
.ReadIndexed(pStrm
);
628 sal_uInt8 nWhatsItGot
= pStrm
->QuickReaduInt8();
630 if (nWhatsItGot
& DISK_GOT_STYLE_STUFF
)
632 m_pStyleStuff
->Read(pStrm
);
634 if (nWhatsItGot
& DISK_GOT_MISC_STUFF
)
636 m_pMiscStuff
->Read(pStrm
);
639 m_LayGeometry
.ReadIndexed(pStrm
);
640 m_LayScale
.ReadIndexed(pStrm
);
641 m_LayMargins
.ReadIndexed(pStrm
);
642 m_LayBorderStuff
.ReadIndexed(pStrm
);
643 m_LayBackgroundStuff
.ReadIndexed(pStrm
);
645 if (pStrm
->CheckExtra())
647 m_LayExtBorderStuff
.ReadIndexed(pStrm
);
653 #include "lwplaypiece.hxx"
656 * @descr: Get the geometry of current layout
659 LwpLayoutGeometry
* LwpMiddleLayout::GetGeometry()
661 if( !m_LayGeometry
.IsNull() )
663 return ( dynamic_cast<LwpLayoutGeometry
*> (m_LayGeometry
.obj()) );
665 else if( !m_BasedOnStyle
.IsNull() )
667 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
668 return pLay
? pLay
->GetGeometry() : NULL
;
674 * @descr: Get layout height, measured by "cm"
677 double LwpMiddleLayout::GetGeometryHeight()
679 LwpLayoutGeometry
* pGeo
= GetGeometry();
682 return ( LwpTools::ConvertFromUnitsToMetric( pGeo
->GetHeight() ) );
689 * @descr: Get layout width, measured by "cm"
692 double LwpMiddleLayout::GetGeometryWidth()
694 LwpLayoutGeometry
* pGeo
= GetGeometry();
697 return ( LwpTools::ConvertFromUnitsToMetric( pGeo
->GetWidth() ) );
704 * @descr: Whether the margins is same as parent layout
707 bool LwpMiddleLayout::MarginsSameAsParent()
709 if(m_nOverrideFlag
& OVER_MARGINS
)
711 return LwpVirtualLayout::MarginsSameAsParent();
713 if(!m_BasedOnStyle
.IsNull())
715 LwpVirtualLayout
* pLay
= dynamic_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj());
717 pLay
->MarginsSameAsParent();
719 return LwpVirtualLayout::MarginsSameAsParent();
725 * @param: nWhichSide - 0: left, 1: right, 2:top, 3: bottom
727 double LwpMiddleLayout::GetMarginsValue(const sal_uInt8
&nWhichSide
)
730 if((nWhichSide
==MARGIN_LEFT
)||(nWhichSide
==MARGIN_RIGHT
))
732 if ( MarginsSameAsParent() )
734 LwpVirtualLayout
* pParent
= dynamic_cast<LwpVirtualLayout
*> (GetParent()->obj());
735 if(pParent
&& !pParent
->IsHeader())
737 fValue
= pParent
->GetMarginsValue(nWhichSide
);
743 if(m_nOverrideFlag
& OVER_MARGINS
)
745 LwpLayoutMargins
* pMar1
= dynamic_cast<LwpLayoutMargins
*> (m_LayMargins
.obj());
748 fValue
= pMar1
->GetMargins()->GetMarginsValue(nWhichSide
);
752 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj());
755 fValue
= pStyle
->GetMarginsValue(nWhichSide
);
758 return LwpVirtualLayout::GetMarginsValue(nWhichSide
);
761 * @descr: Get extmargin value
762 * @param: nWhichSide - 0: left, 1: right, 2:top, 3: bottom
766 double LwpMiddleLayout::GetExtMarginsValue(const sal_uInt8
&nWhichSide
)
769 if(m_nOverrideFlag
& OVER_MARGINS
)
771 LwpLayoutMargins
* pMar1
= dynamic_cast<LwpLayoutMargins
*> (m_LayMargins
.obj());
774 fValue
= pMar1
->GetExtMargins()->GetMarginsValue(nWhichSide
);
778 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj());
781 fValue
= pStyle
->GetExtMarginsValue(nWhichSide
);
784 return LwpVirtualLayout::GetExtMarginsValue(nWhichSide
);
787 * @descr: Get the LwpBorderStuff object according to m_LayBorderStuff id.
792 LwpBorderStuff
* LwpMiddleLayout::GetBorderStuff()
794 if(m_nOverrideFlag
& OVER_BORDERS
)
796 LwpLayoutBorder
* pLayoutBorder
= dynamic_cast<LwpLayoutBorder
*>(m_LayBorderStuff
.obj());
797 return pLayoutBorder
? pLayoutBorder
->GetBorderStuff() : NULL
;
799 else if( !m_BasedOnStyle
.IsNull() )
801 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
802 return pLay
? pLay
->GetBorderStuff() : NULL
;
808 * @descr: Get LwpBackgroundStuff object according to m_LayBackgroundStuff id;
813 LwpBackgroundStuff
* LwpMiddleLayout::GetBackgroundStuff()
815 if(m_nOverrideFlag
& OVER_BACKGROUND
)
817 LwpLayoutBackground
* pLayoutBackground
= dynamic_cast<LwpLayoutBackground
*>(m_LayBackgroundStuff
.obj());
818 return pLayoutBackground
? pLayoutBackground
->GetBackgoudStuff() : NULL
;
820 else if( !m_BasedOnStyle
.IsNull() )
822 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
823 return pLay
? pLay
->GetBackgroundStuff() : NULL
;
828 * @descr: create xfborder.
833 XFBorders
* LwpMiddleLayout::GetXFBorders()
835 LwpBorderStuff
* pBorderStuff
= GetBorderStuff();
836 if(pBorderStuff
&&pBorderStuff
->GetSide() != 0)
838 //copy from lwpparastyle.
839 XFBorders
*pXFBorders
= new XFBorders();
840 // apply 4 borders respectively
841 LwpBorderStuff::BorderType pType
[] = { LwpBorderStuff::LEFT
, LwpBorderStuff::RIGHT
,
842 LwpBorderStuff::TOP
, LwpBorderStuff::BOTTOM
};
844 for (sal_uInt8 nC
= 0; nC
< 4; nC
++)
846 if (pBorderStuff
->HasSide(pType
[nC
]))
848 LwpParaStyle::ApplySubBorder(pBorderStuff
, pType
[nC
], pXFBorders
);
857 * @descr: Get text direction settings.
862 enumXFTextDir
LwpMiddleLayout::GetTextDirection()
864 enumXFTextDir eTextDir
= enumXFTextDirNone
;
865 sal_uInt8 nDirection
= GetContentOrientation();
868 case TEXT_ORIENT_LRTB
:
870 eTextDir
= enumXFTextDirLR_TB
;
873 case TEXT_ORIENT_TBRL
:
875 eTextDir
= enumXFTextDirTB_RL
;
878 case TEXT_ORIENT_RLBT
: // not supported now
880 eTextDir
= enumXFTextDirNone
;
883 case TEXT_ORIENT_BTLR
: // not supported now
885 eTextDir
= enumXFTextDirNone
;
894 * @descr: Get back ground color.
899 LwpColor
* LwpMiddleLayout::GetBackColor()
901 LwpBackgroundStuff
* pBackgroundStuff
= GetBackgroundStuff();
902 if(pBackgroundStuff
&& !pBackgroundStuff
->IsTransparent())
904 LwpColor
* pColor
= pBackgroundStuff
->GetFillColor();
905 if(pColor
->IsValidColor())
914 * @descr: Add back color settings into xfpagemaster.
919 LwpTabOverride
* LwpMiddleLayout::GetTabOverride()
921 if(m_nAttributes
& OVER_TABS
)
923 if(!m_TabPiece
.IsNull())
925 LwpTabPiece
*pPiece
= dynamic_cast<LwpTabPiece
*>(m_TabPiece
.obj());
926 return (LwpTabOverride
*)(pPiece
? pPiece
->GetOverride() : NULL
);
930 else if( !m_BasedOnStyle
.IsNull() )
932 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
933 return pLay
? pLay
->GetTabOverride() : NULL
;
939 * @descr: Layscale for graphic & watermark
944 sal_uInt16
LwpMiddleLayout::GetScaleMode(void)
946 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj())
947 return GetLayoutScale()->GetScaleMode();
948 else if (m_BasedOnStyle
.obj())
949 return dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj())->GetScaleMode();
951 return (LwpLayoutScale::FIT_IN_FRAME
| LwpLayoutScale::MAINTAIN_ASPECT_RATIO
);
954 sal_uInt16
LwpMiddleLayout::GetScaleTile(void)
956 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj())
957 return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::TILED
)
959 else if (m_BasedOnStyle
.obj())
960 return dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj())->GetScaleTile();
965 sal_uInt16
LwpMiddleLayout::GetScaleCenter(void)
967 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj())
968 return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::CENTERED
)
970 else if (m_BasedOnStyle
.obj())
971 return dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj())->GetScaleCenter();
976 sal_uInt32
LwpMiddleLayout::GetScalePercentage(void)
978 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj())
979 return GetLayoutScale()->GetScalePercentage()/10;//m_nScalePercentage 1000 = 100%
980 else if (m_BasedOnStyle
.obj())
981 return dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj())->GetScalePercentage();
986 double LwpMiddleLayout::GetScaleWidth(void)
988 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj())
989 return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleWidth());
990 else if (m_BasedOnStyle
.obj())
991 return dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj())->GetScaleWidth();
996 double LwpMiddleLayout::GetScaleHeight(void)
998 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj())
999 return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleHeight());
1000 else if (m_BasedOnStyle
.obj())
1001 return dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj())->GetScaleHeight();
1005 bool LwpMiddleLayout::CanSizeRight(void)
1007 sal_uInt8 RelType
= GetRelativeType();
1009 if (RelType
== LwpLayoutRelativityGuts::LAY_INLINE
|| RelType
== LwpLayoutRelativityGuts::LAY_PARA_RELATIVE
1010 || RelType
== LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL
)
1016 sal_Int32
LwpMiddleLayout::GetMinimumWidth()
1018 if (((m_nAttributes3
& STYLE3_WIDTHVALID
) != 0) && GetGeometry())
1020 return GetGeometry()->GetWidth();
1022 else if (m_nOverrideFlag
& OVER_SIZE
)
1024 return DetermineWidth();
1028 sal_Int32
LwpMiddleLayout::DetermineWidth()
1030 if (IsSizeRightToContent())
1034 else if (IsSizeRightToContainer())
1040 m_nAttributes3
|= STYLE3_WIDTHVALID
;
1041 return GetGeometry()->GetWidth();
1045 bool LwpMiddleLayout::IsSizeRightToContainer(void)
1047 if (!CanSizeRight())
1050 if (m_nOverrideFlag
& OVER_SIZE
)
1052 return (m_nDirection
& ((LAY_USEDIRECTION
|LAY_AUTOSIZE
|LAY_TOCONTAINER
)
1054 == ((LAY_USEDIRECTION
| LAY_TOCONTAINER
| LAY_AUTOSIZE
) << SHIFT_RIGHT
);
1056 else if (m_BasedOnStyle
.obj())
1058 LwpMiddleLayout
* pLayout
= dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj());
1059 return pLayout
? pLayout
->IsSizeRightToContainer() : sal_False
;
1064 bool LwpMiddleLayout::IsSizeRightToContent(void)
1066 if (!CanSizeRight())
1069 if (m_nOverrideFlag
& OVER_SIZE
)
1071 return (m_nDirection
& ((LAY_USEDIRECTION
|LAY_AUTOSIZE
|LAY_TOCONTAINER
)
1073 == ((LAY_USEDIRECTION
| LAY_AUTOSIZE
) << SHIFT_RIGHT
);
1075 else if (m_BasedOnStyle
.obj())
1077 LwpMiddleLayout
* pLayout
= dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj());
1078 return pLayout
? pLayout
->IsSizeRightToContent() : sal_False
;
1085 * @descr: Get layout height
1088 double LwpMiddleLayout::GetHeight()
1090 return GetGeometryHeight();
1094 * @descr: Get layout height
1097 double LwpMiddleLayout::GetWidth()
1099 return GetGeometryWidth();
1102 * @descr: Get layout orgin point
1105 LwpPoint
LwpMiddleLayout::GetOrigin()
1107 LwpLayoutGeometry
* pGeo
= GetGeometry();
1110 sal_uInt8 nType
= GetRelativeType();
1111 if(nType
== LwpLayoutRelativityGuts::LAY_INLINE
1112 || nType
== LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE
)
1114 return pGeo
->GetAbsoluteOrigin();
1117 return pGeo
->GetOrigin();
1125 * @descr: Whether the fill is pattern fill or not
1126 * @return: True if yes, false if not.
1128 bool LwpMiddleLayout::IsPatternFill()
1130 LwpBackgroundStuff
* pBackgroundStuff
= GetBackgroundStuff();
1131 if (pBackgroundStuff
)
1133 return pBackgroundStuff
->IsPatternFill();
1140 * @descr: Get the fill pattern style. Data are saved in a XFBGImage object
1141 * @return: the fill pattern style.
1143 XFBGImage
* LwpMiddleLayout::GetFillPattern()
1145 LwpBackgroundStuff
* pBackgroundStuff
= GetBackgroundStuff();
1146 if (pBackgroundStuff
)
1148 return pBackgroundStuff
->GetFillPattern();
1156 * @descr: Whether the height and width of layout is auto grow
1159 bool LwpMiddleLayout::IsAutoGrow()
1161 if(m_nOverrideFlag
& OVER_SIZE
)
1163 return m_nDirection
&
1164 ((LAY_AUTOGROW
<< SHIFT_UP
) | (LAY_AUTOGROW
<< SHIFT_DOWN
) |
1165 (LAY_AUTOGROW
<< SHIFT_RIGHT
) | (LAY_AUTOGROW
<< SHIFT_LEFT
))
1166 ? sal_True
: sal_False
;
1168 else if( !m_BasedOnStyle
.IsNull() )
1170 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1171 return pLay
? pLay
->IsAutoGrow() : sal_False
;
1173 return LwpVirtualLayout::IsAutoGrow();
1177 * @descr: Whether the height of layout is auto grow down
1180 bool LwpMiddleLayout::IsAutoGrowDown()
1182 if(m_nOverrideFlag
& OVER_SIZE
)
1184 return m_nDirection
& (LAY_AUTOGROW
<< SHIFT_DOWN
) ? sal_True
: sal_False
;
1186 else if( !m_BasedOnStyle
.IsNull() )
1188 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1189 return pLay
? pLay
->IsAutoGrowDown() : sal_False
;
1191 return LwpVirtualLayout::IsAutoGrowDown();
1195 * @descr: Whether the height of layout is auto grow up
1198 bool LwpMiddleLayout::IsAutoGrowUp()
1200 if(m_nOverrideFlag
& OVER_SIZE
)
1202 return m_nDirection
& (LAY_AUTOGROW
<< SHIFT_UP
) ? sal_True
: sal_False
;
1204 else if( !m_BasedOnStyle
.IsNull() )
1206 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1207 return pLay
? pLay
->IsAutoGrowUp() : sal_False
;
1209 return LwpVirtualLayout::IsAutoGrowUp();
1213 * @descr: Whether the height of layout is auto grow down
1216 bool LwpMiddleLayout::IsAutoGrowLeft()
1218 if(m_nOverrideFlag
& OVER_SIZE
)
1220 return m_nDirection
& (LAY_AUTOGROW
<< SHIFT_LEFT
) ? sal_True
: sal_False
;
1222 else if( !m_BasedOnStyle
.IsNull() )
1224 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1226 return pLay
->IsAutoGrowLeft();
1228 return LwpVirtualLayout::IsAutoGrowLeft();
1232 * @descr: Whether the height of layout is auto grow down
1235 bool LwpMiddleLayout::IsAutoGrowRight()
1237 if(m_nOverrideFlag
& OVER_SIZE
)
1239 return m_nDirection
& (LAY_AUTOGROW
<< SHIFT_RIGHT
) ? sal_True
: sal_False
;
1241 else if( !m_BasedOnStyle
.IsNull() )
1243 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1244 return pLay
? pLay
->IsAutoGrowRight() : sal_False
;
1246 return LwpVirtualLayout::IsAutoGrowRight();
1250 * @descr: Get contents orientation
1253 sal_uInt8
LwpMiddleLayout::GetContentOrientation()
1255 //content orientation in Graphic objects and OLE objects not supported now
1256 if((m_nOverrideFlag
& OVER_ROTATION
)&& !m_LayGeometry
.IsNull())
1258 LwpLayoutGeometry
* pLayGeometry
= dynamic_cast<LwpLayoutGeometry
*> (m_LayGeometry
.obj());
1260 return pLayGeometry
->GetContentOrientation();
1262 else if( !m_BasedOnStyle
.IsNull() )
1264 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1266 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 LwpVirtualLayout
* pParent
= dynamic_cast<LwpVirtualLayout
*> (GetParent()->obj());
1283 if(pParent
&& !pParent
->IsHeader())
1285 return pParent
->HonorProtection();
1288 if(m_pFoundry
)//is null now
1290 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
1293 return pDoc
->HonorProtection();
1297 else if( !m_BasedOnStyle
.IsNull() )
1299 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1301 return pLay
->HonorProtection();
1304 return LwpVirtualLayout::HonorProtection();
1308 * @descr: Whether it is pretected
1311 bool LwpMiddleLayout::IsProtected()
1313 bool bProtected
= false;
1314 if(m_nOverrideFlag
& OVER_MISC
)
1316 bProtected
= (m_nAttributes
& STYLE_PROTECTED
)!=0;
1318 else if( !m_BasedOnStyle
.IsNull() )
1320 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1321 bProtected
= pLay
? pLay
->IsProtected() : sal_False
;
1324 bProtected
= LwpVirtualLayout::IsProtected();
1326 LwpVirtualLayout
* pParent
= dynamic_cast<LwpVirtualLayout
*> (GetParent()->obj());
1327 if(pParent
&& !pParent
->IsHeader())
1329 /* If a parent's protected then none of its children can be accessed. */
1330 if(pParent
->IsProtected())
1333 if(pParent
->HonorProtection())
1336 /* If our parent isn't honoring protection then we aren't protected. */
1340 if(m_pFoundry
)//is null now
1342 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
1345 if (pDoc
->HonorProtection())
1348 /* If the document isn't honoring protection then we aren't protected.*/
1357 * @descr: Get watermark layout
1360 LwpVirtualLayout
* LwpMiddleLayout::GetWaterMarkLayout()
1362 LwpVirtualLayout
* pLay
= dynamic_cast<LwpVirtualLayout
*>(GetChildHead()->obj());
1365 if( pLay
->IsForWaterMark())
1369 pLay
= dynamic_cast<LwpVirtualLayout
*> (pLay
->GetNext()->obj());
1375 * @descr: Create and reture xfbgimage object for watermark
1378 XFBGImage
* LwpMiddleLayout::GetXFBGImage()
1380 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*>(GetWaterMarkLayout());
1384 LwpGraphicObject
* pGrfObj
= dynamic_cast<LwpGraphicObject
*>(pLay
->GetContent()->obj());
1387 XFBGImage
* pXFBGImage
= new XFBGImage();
1389 if(pGrfObj
->IsLinked())
1392 OUString linkedfilepath
= pGrfObj
->GetLinkedFilePath();
1393 OUString fileURL
= LwpTools::convertToFileUrl(OUStringToOString(linkedfilepath
, osl_getThreadTextEncoding()));
1394 pXFBGImage
->SetFileLink(fileURL
);
1398 sal_uInt8
* pGrafData
= NULL
;
1399 sal_uInt32 nDataLen
= pGrfObj
->GetRawGrafData(pGrafData
);
1400 pXFBGImage
->SetImageData(pGrafData
, nDataLen
);
1408 //automatic, top left
1409 pXFBGImage
->SetPosition(enumXFAlignStart
,enumXFAlignTop
);
1410 if(pLay
->GetScaleCenter())
1413 pXFBGImage
->SetPosition(enumXFAlignCenter
,enumXFAlignCenter
);
1415 else if(pLay
->GetScaleTile())
1418 pXFBGImage
->SetRepeate();
1420 //fit type, area type
1421 if((pLay
->GetScaleMode()& LwpLayoutScale::FIT_IN_FRAME
)!=0)
1423 if((pLay
->GetScaleMode()& LwpLayoutScale::MAINTAIN_ASPECT_RATIO
)==0)
1425 pXFBGImage
->SetStretch();
1435 * @descr: Whether the page uses the printer setting
1438 bool LwpMiddleLayout::GetUsePrinterSettings()
1440 if(m_nOverrideFlag
& OVER_SIZE
)
1442 return (m_nAttributes3
& STYLE3_USEPRINTERSETTINGS
) != 0;
1444 else if( !m_BasedOnStyle
.IsNull() )
1446 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj() );
1447 return pLay
? pLay
->GetUsePrinterSettings() : sal_False
;
1452 //Check whether there are contents in the layout
1453 bool LwpMiddleLayout::HasContent()
1455 LwpObject
* content
= m_Content
.obj();
1462 LwpLayout::LwpLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
) :
1463 LwpMiddleLayout(objHdr
, pStrm
), m_pUseWhen(new LwpUseWhen
)
1466 LwpLayout::~LwpLayout()
1474 void LwpLayout::Read()
1476 LwpObjectStream
* pStrm
= m_pObjStrm
;
1478 LwpMiddleLayout::Read();
1479 if (LwpFileHeader::m_nFileRevision
< 0x000B)
1481 // read PreRevBLayout...
1485 sal_uInt16 nSimple
= pStrm
->QuickReaduInt16();
1489 m_pUseWhen
->Read(pStrm
);
1491 sal_uInt8 nFlag
= pStrm
->QuickReaduInt8();
1493 m_Positon
.ReadIndexed(pStrm
);
1496 m_LayColumns
.ReadIndexed(pStrm
);
1497 m_LayGutterStuff
.ReadIndexed(pStrm
);
1498 m_LayJoinStuff
.ReadIndexed(pStrm
);
1499 m_LayShadow
.ReadIndexed(pStrm
);
1501 if (pStrm
->CheckExtra())
1503 m_LayExtJoinStuff
.ReadIndexed(pStrm
);
1510 * @descr: Get columns number
1513 sal_uInt16
LwpLayout::GetNumCols()
1515 if(m_nOverrideFlag
& OVER_COLUMNS
)
1517 LwpLayoutColumns
* pLayColumns
= dynamic_cast<LwpLayoutColumns
*>(m_LayColumns
.obj());
1520 return pLayColumns
->GetNumCols();
1524 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj());
1527 return pStyle
->GetNumCols();
1530 return LwpVirtualLayout::GetNumCols();
1535 * @descr: Get column width
1536 * @param: the order of column
1538 double LwpLayout::GetColWidth(sal_uInt16 nIndex
)
1540 if((m_nOverrideFlag
& OVER_COLUMNS
)||(m_nAttributes2
& STYLE2_LOCALCOLUMNINFO
))
1542 LwpLayoutColumns
* pLayColumns
= dynamic_cast<LwpLayoutColumns
*>(m_LayColumns
.obj());
1545 return pLayColumns
->GetColWidth(nIndex
);
1549 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj());
1552 return pStyle
->GetColWidth(nIndex
);
1555 return LwpVirtualLayout::GetColWidth(nIndex
);
1560 * @descr: Get gap between columns
1561 * @param: the order of column
1563 double LwpLayout::GetColGap(sal_uInt16 nIndex
)
1565 if((m_nOverrideFlag
& OVER_COLUMNS
)||(m_nAttributes2
& STYLE2_LOCALCOLUMNINFO
))
1567 LwpLayoutColumns
* pLayColumns
= dynamic_cast<LwpLayoutColumns
*>(m_LayColumns
.obj());
1570 return pLayColumns
->GetColGap(nIndex
);
1574 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj());
1577 return pStyle
->GetColGap(nIndex
);
1580 return LwpVirtualLayout::GetColGap(nIndex
);
1584 * @descr: Create and return XFColumns object
1587 XFColumns
* LwpLayout::GetXFColumns()
1589 //if there is only one column, do not need insert columns
1590 sal_uInt16 nCols
= GetNumCols();
1596 XFColumns
* pColumns
= new XFColumns();
1598 boost::scoped_ptr
<XFColumnSep
> pColumnSep(GetColumnSep());
1601 pColumns
->SetSeparator(*pColumnSep
);
1604 //set column count and column gap
1605 pColumns
->SetCount(nCols
);
1606 double fGap
= GetColGap(0);
1607 pColumns
->SetGap(fGap
);
1610 for(sal_uInt16 nIndex
= 0; nIndex
<nCols
; nIndex
++)
1613 sal_Int32 nWidth
= static_cast<sal_Int32
>(GetColWidth(nIndex
));
1614 nWidth
=8305/nCols
; //relative width
1615 aColumn
.SetRelWidth(nWidth
);
1617 //the left and right margins is 0;
1618 double nGap
= GetColGap(nIndex
)/2;
1620 aColumn
.SetMargins(nGap
,nGap
);
1623 aColumn
.SetMargins(0,nGap
);
1625 if(nIndex
==(nCols
-1))
1627 aColumn
.SetMargins(nGap
,0);
1629 pColumns
->AddColumn(aColumn
);
1636 * @descr: Create and return XFColumnSep object
1639 XFColumnSep
* LwpLayout::GetColumnSep()
1642 //Get LwpLayoutGutters
1643 LwpLayoutGutters
* pLayoutGutters
= dynamic_cast<LwpLayoutGutters
*>(m_LayGutterStuff
.obj());
1649 LwpBorderStuff
* pBorderStuff
= pLayoutGutters
->GetBorderStuff();
1653 LwpBorderStuff::BorderType eType
= LwpBorderStuff::LEFT
;
1654 LwpColor aColor
= pBorderStuff
->GetSideColor(eType
);
1655 double fWidth
= pBorderStuff
->GetSideWidth(eType
);
1656 //sal_uInt16 nType = pBorderStuff->GetSideType(eType);
1658 XFColumnSep
* pColumnSep
= new XFColumnSep();
1659 XFColor
aXFColor(aColor
.To24Color());
1660 pColumnSep
->SetColor(aXFColor
);
1661 pColumnSep
->SetWidth(fWidth
);
1662 pColumnSep
->SetRelHeight(100);
1663 pColumnSep
->SetVerticalAlign(enumXFAlignTop
);
1672 * @descr: Get use when type
1675 LwpLayout::UseWhenType
LwpLayout::GetUseWhenType()
1677 UseWhenType eType
= StartWithinPage
;
1678 LwpUseWhen
* pUseWhen
= GetUseWhen();
1681 if(pUseWhen
->IsStartOnThisHF())
1683 eType
= StartWithinColume
;
1685 else if(pUseWhen
->IsStartOnThisPage())
1687 eType
= StartWithinPage
;
1689 else if(pUseWhen
->IsStartOnNextPage())
1691 eType
= StartOnNextPage
;
1693 else if(pUseWhen
->IsStartOnNextOddPage())
1695 eType
= StartOnOddPage
;
1697 else if(pUseWhen
->IsStartOnNextEvenPage())
1699 eType
= StartOnEvenPage
;
1705 eType
= StartOnNextPage
;
1711 * @descr: Get use page
1714 sal_uInt16
LwpLayout::GetUsePage()
1716 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1718 LwpUseWhen
* pUseWhen
= GetUseWhen();
1720 return pUseWhen
->GetUsePage();
1724 else if( !m_BasedOnStyle
.IsNull() )
1726 LwpLayout
* pLay
= dynamic_cast<LwpLayout
*> ( m_BasedOnStyle
.obj() );
1727 return pLay
? pLay
->GetUsePage() : 0;
1733 * @descr: Get usewhen pointer
1736 LwpUseWhen
* LwpLayout::VirtualGetUseWhen()
1738 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1742 else if( !m_BasedOnStyle
.IsNull() )
1744 LwpLayout
* pLay
= dynamic_cast<LwpLayout
*> ( m_BasedOnStyle
.obj() );
1745 return pLay
? pLay
->VirtualGetUseWhen() : NULL
;
1747 return LwpVirtualLayout::VirtualGetUseWhen();
1751 * @descr: Whether it is use on all pages
1754 bool LwpLayout::IsUseOnAllPages()
1756 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1758 LwpUseWhen
* pUseWhen
= GetUseWhen();
1760 return pUseWhen
->IsUseOnAllPages();
1764 else if( !m_BasedOnStyle
.IsNull() )
1766 LwpLayout
* pLay
= dynamic_cast<LwpLayout
*> ( m_BasedOnStyle
.obj() );
1768 return pLay
->IsUseOnAllPages();
1770 return LwpVirtualLayout::IsUseOnAllPages();
1774 * @descr: Whether it is use on all even pages
1777 bool LwpLayout::IsUseOnAllEvenPages()
1779 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1781 LwpUseWhen
* pUseWhen
= GetUseWhen();
1783 return pUseWhen
->IsUseOnAllEvenPages();
1787 else if( !m_BasedOnStyle
.IsNull() )
1789 LwpLayout
* pLay
= dynamic_cast<LwpLayout
*> ( m_BasedOnStyle
.obj() );
1791 return pLay
->IsUseOnAllEvenPages();
1793 return LwpVirtualLayout::IsUseOnAllEvenPages();
1797 * @descr: Whether it is use on all odd pages
1800 bool LwpLayout::IsUseOnAllOddPages()
1802 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1804 LwpUseWhen
* pUseWhen
= GetUseWhen();
1806 return pUseWhen
->IsUseOnAllOddPages();
1810 else if( !m_BasedOnStyle
.IsNull() )
1812 LwpLayout
* pLay
= dynamic_cast<LwpLayout
*> ( m_BasedOnStyle
.obj() );
1814 return pLay
->IsUseOnAllOddPages();
1816 return LwpVirtualLayout::IsUseOnAllOddPages();
1820 * @descr: Whether it is use on current page
1823 bool LwpLayout::IsUseOnPage()
1825 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1827 LwpUseWhen
* pUseWhen
= GetUseWhen();
1829 return pUseWhen
->IsUseOnPage();
1833 else if( !m_BasedOnStyle
.IsNull() )
1835 LwpLayout
* pLay
= dynamic_cast<LwpLayout
*> ( m_BasedOnStyle
.obj() );
1837 return pLay
->IsUseOnPage();
1839 return LwpVirtualLayout::IsUseOnPage();
1843 * @descr: Get the LwpShadow object according to m_LayShadow id.
1848 LwpShadow
* LwpLayout::GetShadow()
1850 if(m_nOverrideFlag
& OVER_SHADOW
)
1852 LwpLayoutShadow
* pLayoutShadow
= dynamic_cast<LwpLayoutShadow
*>(m_LayShadow
.obj());
1853 return pLayoutShadow
? pLayoutShadow
->GetShadow() : NULL
;
1855 else if( !m_BasedOnStyle
.IsNull() )
1857 LwpLayout
* pLay
= dynamic_cast<LwpLayout
*> ( m_BasedOnStyle
.obj() );
1858 return pLay
? pLay
->GetShadow() : NULL
;
1864 * @descr: create xfshadow
1869 XFShadow
* LwpLayout::GetXFShadow()
1871 LwpShadow
* pShadow
= GetShadow();
1874 LwpColor color
= pShadow
->GetColor();
1875 double offsetX
= pShadow
->GetOffsetX();
1876 double offsetY
= pShadow
->GetOffsetY();
1878 if( offsetX
&& offsetY
&& color
.IsValidColor() )
1880 XFShadow
* pXFShadow
= new XFShadow();
1881 enumXFShadowPos eXFShadowPos
= enumXFShadowLeftTop
;
1894 eXFShadowPos
= enumXFShadowLeftTop
;
1896 eXFShadowPos
= enumXFShadowLeftBottom
;
1902 eXFShadowPos
= enumXFShadowRightTop
;
1904 eXFShadowPos
= enumXFShadowRightBottom
;
1907 pXFShadow
->SetPosition(eXFShadowPos
);
1908 pXFShadow
->SetOffset(fOffset
);
1909 pXFShadow
->SetColor(XFColor(color
.To24Color()));
1918 * @descr get the layout that containers the current frame layout
1921 LwpVirtualLayout
* LwpLayout::GetContainerLayout()
1923 if(IsRelativeAnchored())
1926 LwpPara
* pPara
= dynamic_cast<LwpPara
*>(GetPosition()->obj());
1929 LwpStory
* pStory
= pPara
->GetStory();
1930 return pStory
? pStory
->GetTabLayout() : NULL
;
1933 return GetParentLayout();
1936 LwpPlacableLayout::LwpPlacableLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
1937 : LwpLayout(objHdr
, pStrm
)
1940 , m_nBaseLineOffset(0)
1945 LwpPlacableLayout::~LwpPlacableLayout()
1948 void LwpPlacableLayout::Read()
1950 LwpObjectStream
* pStrm
= m_pObjStrm
;
1952 if(LwpFileHeader::m_nFileRevision
< 0x000B)
1958 sal_uInt16 simple
= pStrm
->QuickReaduInt16();
1961 m_nWrapType
= pStrm
->QuickReaduInt8();
1962 m_nBuoyancy
= pStrm
->QuickReaduInt8();
1963 m_nBaseLineOffset
= pStrm
->QuickReadInt32();
1964 m_Script
.Read( pStrm
);
1968 m_nWrapType
= LAY_WRAP_AROUND
;
1969 m_nBuoyancy
= LAY_BUOYNEUTRAL
;
1970 m_nBaseLineOffset
= 0;
1972 m_LayRelativity
.ReadIndexed( pStrm
);
1973 if(pStrm
->CheckExtra())
1975 sal_uInt16 count
= pStrm
->QuickReaduInt16();
1978 // temporily added by to avoid assertion
1992 * @descr: get wrap type
1997 sal_uInt8
LwpPlacableLayout::GetWrapType()
1999 if(m_nOverrideFlag
& OVER_PLACEMENT
)
2003 else if( !m_BasedOnStyle
.IsNull() )
2005 LwpPlacableLayout
* pLay
= dynamic_cast<LwpPlacableLayout
*> ( m_BasedOnStyle
.obj() );
2007 return pLay
->GetWrapType();
2009 return LAY_WRAP_AROUND
;
2012 * @descr: get LayoutRelativity
2017 LwpLayoutRelativity
* LwpPlacableLayout::GetRelativityPiece()
2019 if(!m_LayRelativity
.IsNull())
2021 if(m_nOverrideFlag
& OVER_PLACEMENT
)
2023 return dynamic_cast<LwpLayoutRelativity
*>(m_LayRelativity
.obj());
2026 else if( !m_BasedOnStyle
.IsNull() )
2028 LwpPlacableLayout
* pLay
= dynamic_cast<LwpPlacableLayout
*> ( m_BasedOnStyle
.obj() );
2029 return pLay
? pLay
->GetRelativityPiece() : NULL
;
2034 * @descr: Get relative type
2037 sal_uInt8
LwpPlacableLayout::GetRelativeType()
2039 LwpLayoutRelativity
* pLayRel
= GetRelativityPiece();
2042 return pLayRel
->GetRelGuts()->GetRelativeType();
2044 return LwpVirtualLayout::GetRelativeType();
2047 * @descr: Get offset from the baseline
2050 sal_Int32
LwpPlacableLayout::GetBaseLineOffset()
2052 /* The baseline is only valid if this is flow-with-text */
2053 if(GetRelativeType()!=LwpLayoutRelativityGuts::LAY_INLINE
)
2058 // First, ask our content if it has a baseline, ignore now
2060 if (Content && Content->GetBaseLineOffset(&Baseline))
2064 if(m_nOverrideFlag
& OVER_PLACEMENT
)
2066 return m_nBaseLineOffset
;
2068 else if( !m_BasedOnStyle
.IsNull() )
2070 LwpPlacableLayout
* pLay
= dynamic_cast<LwpPlacableLayout
*> ( m_BasedOnStyle
.obj() );
2071 return pLay
? pLay
->GetBaseLineOffset() : 0;
2077 * @descr: whether the parent layout is page layout
2080 bool LwpPlacableLayout::IsAnchorPage()
2082 if(IsRelativeAnchored())
2085 LwpVirtualLayout
* pLayout
= GetParentLayout();
2086 if(pLayout
&& (pLayout
->IsPage() || pLayout
->IsHeader() || pLayout
->IsFooter()))
2087 //if(pLayout && pLayout->IsPage())
2094 * @descr: whether the parent layout is frame layout
2097 bool LwpPlacableLayout::IsAnchorFrame()
2099 if(IsRelativeAnchored())
2102 LwpVirtualLayout
* pLayout
= GetParentLayout();
2103 if(pLayout
&& (pLayout
->IsFrame()||pLayout
->IsGroupHead()))
2110 * @descr: whether the parent layout is cell layout
2113 bool LwpPlacableLayout::IsAnchorCell()
2115 if(IsRelativeAnchored())
2118 LwpVirtualLayout
* pLayout
= GetParentLayout();
2119 if(pLayout
&& pLayout
->IsCell())
2127 * @descr: Get font style for setting position of frame
2130 XFFont
* LwpPlacableLayout::GetFont()
2135 * @descr: Set font style for setting position of frame
2138 void LwpPlacableLayout::SetFont(XFFont
* pFont
)
2143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */