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
) != 0;
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().get());
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().get());
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().get());
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
) != 0;
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().get());
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().get());
353 * @descr: Register child layout style
356 void LwpVirtualLayout::RegisterChildStyle()
358 //Register all children styles
359 LwpVirtualLayout
* pLayout
= dynamic_cast<LwpVirtualLayout
*>(GetChildHead().obj().get());
362 pLayout
->SetFoundry(m_pFoundry
);
363 pLayout
->RegisterStyle();
364 pLayout
= dynamic_cast<LwpVirtualLayout
*>(pLayout
->GetNext().obj().get());
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().get());
380 return pParent
->IsStyleLayout();
385 * @descr: Find child layout by layout type
388 LwpVirtualLayout
* LwpVirtualLayout::FindChildByType(LWP_LAYOUT_TYPE eType
)
390 LwpObjectID
& rID
= GetChildHead();
394 LwpVirtualLayout
* pLayout
= dynamic_cast<LwpVirtualLayout
*>(rID
.obj().get());
400 if (pLayout
&& pLayout
->GetLayoutType() == eType
)
404 rID
= 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 if (!pStartLayout
&& !m_OnlyLayout
.IsNull())
451 /* Looking for the first layout and there's only one layout in the list.*/
452 return dynamic_cast<LwpVirtualLayout
*>(m_OnlyLayout
.obj().get());
454 LwpObjectHolder
* pObjHolder
= dynamic_cast<LwpObjectHolder
*>(m_Layouts
.GetHead().obj().get());
457 LwpVirtualLayout
* pLayout
= dynamic_cast<LwpVirtualLayout
*>(pObjHolder
->GetObject().obj().get());
461 while(pObjHolder
&& pStartLayout
!= pLayout
)
463 pObjHolder
= dynamic_cast<LwpObjectHolder
*>(pObjHolder
->GetNext().obj().get());
466 pLayout
= dynamic_cast<LwpVirtualLayout
*>(pObjHolder
->GetObject().obj().get());
472 pObjHolder
= dynamic_cast<LwpObjectHolder
*>(pObjHolder
->GetNext().obj().get());
475 pLayout
= dynamic_cast<LwpVirtualLayout
*>(pObjHolder
->GetObject().obj().get());
486 LwpHeadLayout::LwpHeadLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
487 : LwpVirtualLayout(objHdr
, pStrm
)
490 void LwpHeadLayout::Read()
492 LwpVirtualLayout::Read();
493 //For PermissiveLayout
494 m_pObjStrm
->SkipExtra();
496 m_pObjStrm
->SkipExtra();
499 void LwpHeadLayout::RegisterStyle()
501 //Register all children styles
502 LwpVirtualLayout
* pLayout
= dynamic_cast<LwpVirtualLayout
*>(GetChildHead().obj().get());
505 pLayout
->SetFoundry(m_pFoundry
);
506 //if the layout is relative to para, the layout will be registered in para
507 if(!pLayout
->IsRelativeAnchored())
511 OSL_FAIL("Layout points to itself");
514 pLayout
->RegisterStyle();
516 LwpVirtualLayout
*pNext
= dynamic_cast<LwpVirtualLayout
*>(pLayout
->GetNext().obj().get());
517 if (pNext
== pLayout
)
519 OSL_FAIL("Layout points to itself");
527 * @descr find endnote supertable layout from the child layout list. Suppose that there is only one endnote supertablelayout in one division
528 * @return pointer to endnote supertable layout
530 LwpVirtualLayout
* LwpHeadLayout::FindEnSuperTableLayout()
532 LwpVirtualLayout
* pLayout
= dynamic_cast<LwpVirtualLayout
*>(GetChildHead().obj().get());
535 if(pLayout
->GetLayoutType() == LWP_ENDNOTE_SUPERTABLE_LAYOUT
)
539 pLayout
= dynamic_cast<LwpVirtualLayout
*>(pLayout
->GetNext().obj().get());
544 LwpLayoutStyle::LwpLayoutStyle()
545 : m_nStyleDefinition(0)
546 , m_pDescription(new LwpAtomHolder
)
551 LwpLayoutStyle::~LwpLayoutStyle()
553 delete m_pDescription
;
556 void LwpLayoutStyle::Read(LwpObjectStream
* pStrm
)
558 m_nStyleDefinition
= pStrm
->QuickReaduInt32();
559 m_pDescription
->Read(pStrm
);
560 if (pStrm
->CheckExtra())
562 m_nKey
= pStrm
->QuickReaduInt16();
567 LwpLayoutMisc::LwpLayoutMisc() :
568 m_nGridDistance(0), m_nGridType(0),
569 m_pContentStyle(new LwpAtomHolder
)
573 LwpLayoutMisc::~LwpLayoutMisc()
577 delete m_pContentStyle
;
581 void LwpLayoutMisc::Read(LwpObjectStream
* pStrm
)
583 m_nGridType
= pStrm
->QuickReaduInt16();
584 m_nGridDistance
= pStrm
->QuickReadInt32();
585 m_pContentStyle
->Read(pStrm
);
589 LwpMiddleLayout::LwpMiddleLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
590 : LwpVirtualLayout(objHdr
, pStrm
),
591 m_pStyleStuff(new LwpLayoutStyle
), m_pMiscStuff(new LwpLayoutMisc
)
594 LwpMiddleLayout::~LwpMiddleLayout()
598 delete m_pStyleStuff
;
605 void LwpMiddleLayout::Read()
607 LwpObjectStream
* pStrm
= m_pObjStrm
;
609 LwpVirtualLayout::Read();
611 //skip CLiteLayout data;
612 LwpAtomHolder ContentClass
;
613 ContentClass
.Read(pStrm
);
616 // before layout hierarchy rework
617 if(LwpFileHeader::m_nFileRevision
< 0x000B)
620 m_Content
.ReadIndexed(pStrm
);
623 m_BasedOnStyle
.ReadIndexed(pStrm
);
624 m_TabPiece
.ReadIndexed(pStrm
);
626 sal_uInt8 nWhatsItGot
= pStrm
->QuickReaduInt8();
628 if (nWhatsItGot
& DISK_GOT_STYLE_STUFF
)
630 m_pStyleStuff
->Read(pStrm
);
632 if (nWhatsItGot
& DISK_GOT_MISC_STUFF
)
634 m_pMiscStuff
->Read(pStrm
);
637 m_LayGeometry
.ReadIndexed(pStrm
);
638 m_LayScale
.ReadIndexed(pStrm
);
639 m_LayMargins
.ReadIndexed(pStrm
);
640 m_LayBorderStuff
.ReadIndexed(pStrm
);
641 m_LayBackgroundStuff
.ReadIndexed(pStrm
);
643 if (pStrm
->CheckExtra())
645 m_LayExtBorderStuff
.ReadIndexed(pStrm
);
651 #include "lwplaypiece.hxx"
654 * @descr: Get the geometry of current layout
657 LwpLayoutGeometry
* LwpMiddleLayout::GetGeometry()
659 if( !m_LayGeometry
.IsNull() )
661 return ( dynamic_cast<LwpLayoutGeometry
*> (m_LayGeometry
.obj().get()) );
663 else if( !m_BasedOnStyle
.IsNull() )
665 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj().get() );
666 return pLay
? pLay
->GetGeometry() : NULL
;
672 * @descr: Get layout height, measured by "cm"
675 double LwpMiddleLayout::GetGeometryHeight()
677 LwpLayoutGeometry
* pGeo
= GetGeometry();
680 return ( LwpTools::ConvertFromUnitsToMetric( pGeo
->GetHeight() ) );
687 * @descr: Get layout width, measured by "cm"
690 double LwpMiddleLayout::GetGeometryWidth()
692 LwpLayoutGeometry
* pGeo
= GetGeometry();
695 return ( LwpTools::ConvertFromUnitsToMetric( pGeo
->GetWidth() ) );
702 * @descr: Whether the margins is same as parent layout
705 bool LwpMiddleLayout::MarginsSameAsParent()
707 if(m_nOverrideFlag
& OVER_MARGINS
)
709 return LwpVirtualLayout::MarginsSameAsParent();
711 if(!m_BasedOnStyle
.IsNull())
713 LwpVirtualLayout
* pLay
= dynamic_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj().get());
715 pLay
->MarginsSameAsParent();
717 return LwpVirtualLayout::MarginsSameAsParent();
723 * @param: nWhichSide - 0: left, 1: right, 2:top, 3: bottom
725 double LwpMiddleLayout::GetMarginsValue(const sal_uInt8
&nWhichSide
)
728 if((nWhichSide
==MARGIN_LEFT
)||(nWhichSide
==MARGIN_RIGHT
))
730 if ( MarginsSameAsParent() )
732 LwpVirtualLayout
* pParent
= dynamic_cast<LwpVirtualLayout
*> (GetParent().obj().get());
733 if(pParent
&& !pParent
->IsHeader())
735 fValue
= pParent
->GetMarginsValue(nWhichSide
);
741 if(m_nOverrideFlag
& OVER_MARGINS
)
743 LwpLayoutMargins
* pMar1
= dynamic_cast<LwpLayoutMargins
*> (m_LayMargins
.obj().get());
746 fValue
= pMar1
->GetMargins().GetMarginsValue(nWhichSide
);
750 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj().get());
753 fValue
= pStyle
->GetMarginsValue(nWhichSide
);
756 return LwpVirtualLayout::GetMarginsValue(nWhichSide
);
759 * @descr: Get extmargin value
760 * @param: nWhichSide - 0: left, 1: right, 2:top, 3: bottom
764 double LwpMiddleLayout::GetExtMarginsValue(const sal_uInt8
&nWhichSide
)
767 if(m_nOverrideFlag
& OVER_MARGINS
)
769 LwpLayoutMargins
* pMar1
= dynamic_cast<LwpLayoutMargins
*> (m_LayMargins
.obj().get());
772 fValue
= pMar1
->GetExtMargins().GetMarginsValue(nWhichSide
);
776 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj().get());
779 fValue
= pStyle
->GetExtMarginsValue(nWhichSide
);
782 return LwpVirtualLayout::GetExtMarginsValue(nWhichSide
);
785 * @descr: Get the LwpBorderStuff object according to m_LayBorderStuff id.
790 LwpBorderStuff
* LwpMiddleLayout::GetBorderStuff()
792 if(m_nOverrideFlag
& OVER_BORDERS
)
794 LwpLayoutBorder
* pLayoutBorder
= dynamic_cast<LwpLayoutBorder
*>(m_LayBorderStuff
.obj().get());
795 return pLayoutBorder
? &pLayoutBorder
->GetBorderStuff() : NULL
;
797 else if( !m_BasedOnStyle
.IsNull() )
799 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj().get() );
800 return pLay
? pLay
->GetBorderStuff() : NULL
;
806 * @descr: Get LwpBackgroundStuff object according to m_LayBackgroundStuff id;
811 LwpBackgroundStuff
* LwpMiddleLayout::GetBackgroundStuff()
813 if(m_nOverrideFlag
& OVER_BACKGROUND
)
815 LwpLayoutBackground
* pLayoutBackground
= dynamic_cast<LwpLayoutBackground
*>(m_LayBackgroundStuff
.obj().get());
816 return pLayoutBackground
? &pLayoutBackground
->GetBackgoudStuff() : NULL
;
818 else if( !m_BasedOnStyle
.IsNull() )
820 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj().get() );
821 return pLay
? pLay
->GetBackgroundStuff() : NULL
;
826 * @descr: create xfborder.
831 XFBorders
* LwpMiddleLayout::GetXFBorders()
833 LwpBorderStuff
* pBorderStuff
= GetBorderStuff();
834 if(pBorderStuff
&&pBorderStuff
->GetSide() != 0)
836 //copy from lwpparastyle.
837 XFBorders
*pXFBorders
= new XFBorders();
838 // apply 4 borders respectively
839 LwpBorderStuff::BorderType pType
[] = { LwpBorderStuff::LEFT
, LwpBorderStuff::RIGHT
,
840 LwpBorderStuff::TOP
, LwpBorderStuff::BOTTOM
};
842 for (sal_uInt8 nC
= 0; nC
< 4; nC
++)
844 if (pBorderStuff
->HasSide(pType
[nC
]))
846 LwpParaStyle::ApplySubBorder(pBorderStuff
, pType
[nC
], pXFBorders
);
855 * @descr: Get text direction settings.
860 enumXFTextDir
LwpMiddleLayout::GetTextDirection()
862 enumXFTextDir eTextDir
= enumXFTextDirNone
;
863 sal_uInt8 nDirection
= GetContentOrientation();
866 case TEXT_ORIENT_LRTB
:
868 eTextDir
= enumXFTextDirLR_TB
;
871 case TEXT_ORIENT_TBRL
:
873 eTextDir
= enumXFTextDirTB_RL
;
876 case TEXT_ORIENT_RLBT
: // not supported now
878 eTextDir
= enumXFTextDirNone
;
881 case TEXT_ORIENT_BTLR
: // not supported now
883 eTextDir
= enumXFTextDirNone
;
892 * @descr: Get back ground color.
897 LwpColor
* LwpMiddleLayout::GetBackColor()
899 LwpBackgroundStuff
* pBackgroundStuff
= GetBackgroundStuff();
900 if(pBackgroundStuff
&& !pBackgroundStuff
->IsTransparent())
902 LwpColor
* pColor
= pBackgroundStuff
->GetFillColor();
903 if(pColor
->IsValidColor())
912 * @descr: Add back color settings into xfpagemaster.
917 LwpTabOverride
* LwpMiddleLayout::GetTabOverride()
919 if(m_nAttributes
& OVER_TABS
)
921 if(!m_TabPiece
.IsNull())
923 LwpTabPiece
*pPiece
= dynamic_cast<LwpTabPiece
*>(m_TabPiece
.obj().get());
924 return static_cast<LwpTabOverride
*>(pPiece
? pPiece
->GetOverride() : NULL
);
928 else if( !m_BasedOnStyle
.IsNull() )
930 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj().get() );
931 return pLay
? pLay
->GetTabOverride() : NULL
;
937 * @descr: Layscale for graphic & watermark
942 sal_uInt16
LwpMiddleLayout::GetScaleMode()
944 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj().is())
945 return GetLayoutScale()->GetScaleMode();
946 else if (m_BasedOnStyle
.obj().is())
947 return dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj().get())->GetScaleMode();
949 return (LwpLayoutScale::FIT_IN_FRAME
| LwpLayoutScale::MAINTAIN_ASPECT_RATIO
);
952 sal_uInt16
LwpMiddleLayout::GetScaleTile()
954 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj().is())
955 return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::TILED
)
957 else if (m_BasedOnStyle
.obj().is())
958 return dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj().get())->GetScaleTile();
963 sal_uInt16
LwpMiddleLayout::GetScaleCenter()
965 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj().is())
966 return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::CENTERED
)
968 else if (m_BasedOnStyle
.obj().is())
969 return dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj().get())->GetScaleCenter();
974 sal_uInt32
LwpMiddleLayout::GetScalePercentage()
976 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj().is())
977 return GetLayoutScale()->GetScalePercentage()/10;//m_nScalePercentage 1000 = 100%
978 else if (m_BasedOnStyle
.obj().is())
979 return dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj().get())->GetScalePercentage();
984 double LwpMiddleLayout::GetScaleWidth()
986 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj().is())
987 return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleWidth());
988 else if (m_BasedOnStyle
.obj().is())
989 return dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj().get())->GetScaleWidth();
994 double LwpMiddleLayout::GetScaleHeight()
996 if ((m_nOverrideFlag
& OVER_SCALING
) && m_LayScale
.obj().is())
997 return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleHeight());
998 else if (m_BasedOnStyle
.obj().is())
999 return dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj().get())->GetScaleHeight();
1003 bool LwpMiddleLayout::CanSizeRight()
1005 sal_uInt8 RelType
= GetRelativeType();
1007 if (RelType
== LwpLayoutRelativityGuts::LAY_INLINE
|| RelType
== LwpLayoutRelativityGuts::LAY_PARA_RELATIVE
1008 || RelType
== LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL
)
1014 sal_Int32
LwpMiddleLayout::GetMinimumWidth()
1016 if (((m_nAttributes3
& STYLE3_WIDTHVALID
) != 0) && GetGeometry())
1018 return GetGeometry()->GetWidth();
1020 else if (m_nOverrideFlag
& OVER_SIZE
)
1022 return DetermineWidth();
1026 sal_Int32
LwpMiddleLayout::DetermineWidth()
1028 if (IsSizeRightToContent())
1032 else if (IsSizeRightToContainer())
1038 m_nAttributes3
|= STYLE3_WIDTHVALID
;
1039 return GetGeometry()->GetWidth();
1043 bool LwpMiddleLayout::IsSizeRightToContainer()
1045 if (!CanSizeRight())
1048 if (m_nOverrideFlag
& OVER_SIZE
)
1050 return (m_nDirection
& ((LAY_USEDIRECTION
|LAY_AUTOSIZE
|LAY_TOCONTAINER
)
1052 == ((LAY_USEDIRECTION
| LAY_TOCONTAINER
| LAY_AUTOSIZE
) << SHIFT_RIGHT
);
1054 else if (m_BasedOnStyle
.obj().is())
1056 LwpMiddleLayout
* pLayout
= dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj().get());
1057 return pLayout
&& pLayout
->IsSizeRightToContainer();
1062 bool LwpMiddleLayout::IsSizeRightToContent()
1064 if (!CanSizeRight())
1067 if (m_nOverrideFlag
& OVER_SIZE
)
1069 return (m_nDirection
& ((LAY_USEDIRECTION
|LAY_AUTOSIZE
|LAY_TOCONTAINER
)
1071 == ((LAY_USEDIRECTION
| LAY_AUTOSIZE
) << SHIFT_RIGHT
);
1073 else if (m_BasedOnStyle
.obj().is())
1075 LwpMiddleLayout
* pLayout
= dynamic_cast<LwpMiddleLayout
*>(m_BasedOnStyle
.obj().get());
1076 return pLayout
&& pLayout
->IsSizeRightToContent();
1083 * @descr: Get layout height
1086 double LwpMiddleLayout::GetHeight()
1088 return GetGeometryHeight();
1092 * @descr: Get layout height
1095 double LwpMiddleLayout::GetWidth()
1097 return GetGeometryWidth();
1100 * @descr: Get layout origin point
1103 LwpPoint
LwpMiddleLayout::GetOrigin()
1105 LwpLayoutGeometry
* pGeo
= GetGeometry();
1108 sal_uInt8 nType
= GetRelativeType();
1109 if(nType
== LwpLayoutRelativityGuts::LAY_INLINE
1110 || nType
== LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE
)
1112 return pGeo
->GetAbsoluteOrigin();
1115 return pGeo
->GetOrigin();
1123 * @descr: Whether the fill is pattern fill or not
1124 * @return: True if yes, false if not.
1126 bool LwpMiddleLayout::IsPatternFill()
1128 LwpBackgroundStuff
* pBackgroundStuff
= GetBackgroundStuff();
1129 if (pBackgroundStuff
)
1131 return pBackgroundStuff
->IsPatternFill();
1138 * @descr: Get the fill pattern style. Data are saved in a XFBGImage object
1139 * @return: the fill pattern style.
1141 XFBGImage
* LwpMiddleLayout::GetFillPattern()
1143 LwpBackgroundStuff
* pBackgroundStuff
= GetBackgroundStuff();
1144 if (pBackgroundStuff
)
1146 return pBackgroundStuff
->GetFillPattern();
1154 * @descr: Whether the height and width of layout is auto grow
1157 bool LwpMiddleLayout::IsAutoGrow()
1159 if(m_nOverrideFlag
& OVER_SIZE
)
1161 return (m_nDirection
&
1162 ((LAY_AUTOGROW
<< SHIFT_UP
) | (LAY_AUTOGROW
<< SHIFT_DOWN
) |
1163 (LAY_AUTOGROW
<< SHIFT_RIGHT
) | (LAY_AUTOGROW
<< SHIFT_LEFT
))) != 0;
1165 else if( !m_BasedOnStyle
.IsNull() )
1167 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj().get() );
1168 return pLay
&& pLay
->IsAutoGrow();
1170 return LwpVirtualLayout::IsAutoGrow();
1174 * @descr: Whether the height of layout is auto grow down
1177 bool LwpMiddleLayout::IsAutoGrowDown()
1179 if(m_nOverrideFlag
& OVER_SIZE
)
1181 return (m_nDirection
& (LAY_AUTOGROW
<< SHIFT_DOWN
)) != 0;
1183 else if( !m_BasedOnStyle
.IsNull() )
1185 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj().get() );
1186 return pLay
&& pLay
->IsAutoGrowDown();
1188 return LwpVirtualLayout::IsAutoGrowDown();
1192 * @descr: Whether the height of layout is auto grow up
1195 bool LwpMiddleLayout::IsAutoGrowUp()
1197 if(m_nOverrideFlag
& OVER_SIZE
)
1199 return (m_nDirection
& (LAY_AUTOGROW
<< SHIFT_UP
)) != 0;
1201 else if( !m_BasedOnStyle
.IsNull() )
1203 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj().get() );
1204 return pLay
&& pLay
->IsAutoGrowUp();
1206 return LwpVirtualLayout::IsAutoGrowUp();
1210 * @descr: Whether the height of layout is auto grow down
1213 bool LwpMiddleLayout::IsAutoGrowLeft()
1215 if(m_nOverrideFlag
& OVER_SIZE
)
1217 return (m_nDirection
& (LAY_AUTOGROW
<< SHIFT_LEFT
)) != 0;
1219 else if( !m_BasedOnStyle
.IsNull() )
1221 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj().get() );
1223 return pLay
->IsAutoGrowLeft();
1225 return LwpVirtualLayout::IsAutoGrowLeft();
1229 * @descr: Whether the height of layout is auto grow down
1232 bool LwpMiddleLayout::IsAutoGrowRight()
1234 if(m_nOverrideFlag
& OVER_SIZE
)
1236 return (m_nDirection
& (LAY_AUTOGROW
<< SHIFT_RIGHT
)) != 0;
1238 else if( !m_BasedOnStyle
.IsNull() )
1240 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj().get() );
1241 return pLay
&& pLay
->IsAutoGrowRight();
1243 return LwpVirtualLayout::IsAutoGrowRight();
1247 * @descr: Get contents orientation
1250 sal_uInt8
LwpMiddleLayout::GetContentOrientation()
1252 //content orientation in Graphic objects and OLE objects not supported now
1253 if((m_nOverrideFlag
& OVER_ROTATION
)&& !m_LayGeometry
.IsNull())
1255 LwpLayoutGeometry
* pLayGeometry
= dynamic_cast<LwpLayoutGeometry
*> (m_LayGeometry
.obj().get());
1257 return pLayGeometry
->GetContentOrientation();
1259 else if( !m_BasedOnStyle
.IsNull() )
1261 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj().get() );
1263 return pLay
->GetContentOrientation();
1265 return LwpVirtualLayout::GetContentOrientation();
1269 * @descr: Whether it is honoring protection
1272 bool LwpMiddleLayout::HonorProtection()
1274 if(m_nOverrideFlag
& OVER_MISC
)
1276 if(!(m_nAttributes2
& STYLE2_HONORPROTECTION
))
1279 LwpVirtualLayout
* pParent
= dynamic_cast<LwpVirtualLayout
*> (GetParent().obj().get());
1280 if(pParent
&& !pParent
->IsHeader())
1282 return pParent
->HonorProtection();
1285 if(m_pFoundry
)//is null now
1287 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
1290 return pDoc
->HonorProtection();
1294 else if( !m_BasedOnStyle
.IsNull() )
1296 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj().get() );
1298 return pLay
->HonorProtection();
1301 return LwpVirtualLayout::HonorProtection();
1305 * @descr: Whether it is pretected
1308 bool LwpMiddleLayout::IsProtected()
1310 bool bProtected
= false;
1311 if(m_nOverrideFlag
& OVER_MISC
)
1313 bProtected
= (m_nAttributes
& STYLE_PROTECTED
)!=0;
1315 else if( !m_BasedOnStyle
.IsNull() )
1317 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj().get() );
1318 bProtected
= pLay
&& pLay
->IsProtected();
1321 bProtected
= LwpVirtualLayout::IsProtected();
1323 LwpVirtualLayout
* pParent
= dynamic_cast<LwpVirtualLayout
*> (GetParent().obj().get());
1324 if(pParent
&& !pParent
->IsHeader())
1326 /* If a parent's protected then none of its children can be accessed. */
1327 if(pParent
->IsProtected())
1330 if(pParent
->HonorProtection())
1333 /* If our parent isn't honoring protection then we aren't protected. */
1337 if(m_pFoundry
)//is null now
1339 LwpDocument
* pDoc
= m_pFoundry
->GetDocument();
1342 if (pDoc
->HonorProtection())
1345 /* If the document isn't honoring protection then we aren't protected.*/
1354 * @descr: Get watermark layout
1357 LwpVirtualLayout
* LwpMiddleLayout::GetWaterMarkLayout()
1359 LwpVirtualLayout
* pLay
= dynamic_cast<LwpVirtualLayout
*>(GetChildHead().obj().get());
1362 if( pLay
->IsForWaterMark())
1366 pLay
= dynamic_cast<LwpVirtualLayout
*> (pLay
->GetNext().obj().get());
1372 * @descr: Create and reture xfbgimage object for watermark
1375 XFBGImage
* LwpMiddleLayout::GetXFBGImage()
1377 LwpMiddleLayout
* pLay
= static_cast<LwpMiddleLayout
*>(GetWaterMarkLayout());
1381 LwpGraphicObject
* pGrfObj
= dynamic_cast<LwpGraphicObject
*>(pLay
->GetContent().obj().get());
1384 XFBGImage
* pXFBGImage
= new XFBGImage();
1386 if(pGrfObj
->IsLinked())
1389 OUString linkedfilepath
= pGrfObj
->GetLinkedFilePath();
1390 OUString fileURL
= LwpTools::convertToFileUrl(OUStringToOString(linkedfilepath
, osl_getThreadTextEncoding()));
1391 pXFBGImage
->SetFileLink(fileURL
);
1395 sal_uInt8
* pGrafData
= NULL
;
1396 sal_uInt32 nDataLen
= pGrfObj
->GetRawGrafData(pGrafData
);
1397 pXFBGImage
->SetImageData(pGrafData
, nDataLen
);
1405 //automatic, top left
1406 pXFBGImage
->SetPosition(enumXFAlignStart
,enumXFAlignTop
);
1407 if(pLay
->GetScaleCenter())
1410 pXFBGImage
->SetPosition(enumXFAlignCenter
,enumXFAlignCenter
);
1412 else if(pLay
->GetScaleTile())
1415 pXFBGImage
->SetRepeate();
1417 //fit type, area type
1418 if((pLay
->GetScaleMode()& LwpLayoutScale::FIT_IN_FRAME
)!=0)
1420 if((pLay
->GetScaleMode()& LwpLayoutScale::MAINTAIN_ASPECT_RATIO
)==0)
1422 pXFBGImage
->SetStretch();
1432 * @descr: Whether the page uses the printer setting
1435 bool LwpMiddleLayout::GetUsePrinterSettings()
1437 if(m_nOverrideFlag
& OVER_SIZE
)
1439 return (m_nAttributes3
& STYLE3_USEPRINTERSETTINGS
) != 0;
1441 else if( !m_BasedOnStyle
.IsNull() )
1443 LwpMiddleLayout
* pLay
= dynamic_cast<LwpMiddleLayout
*> ( m_BasedOnStyle
.obj().get() );
1444 return pLay
&& pLay
->GetUsePrinterSettings();
1449 //Check whether there are contents in the layout
1450 bool LwpMiddleLayout::HasContent()
1452 rtl::Reference
<LwpObject
> content
= m_Content
.obj();
1459 LwpLayout::LwpLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
) :
1460 LwpMiddleLayout(objHdr
, pStrm
), m_pUseWhen(new LwpUseWhen
)
1463 LwpLayout::~LwpLayout()
1471 void LwpLayout::Read()
1473 LwpObjectStream
* pStrm
= m_pObjStrm
;
1475 LwpMiddleLayout::Read();
1476 if (LwpFileHeader::m_nFileRevision
< 0x000B)
1478 // read PreRevBLayout...
1482 sal_uInt16 nSimple
= pStrm
->QuickReaduInt16();
1486 m_pUseWhen
->Read(pStrm
);
1488 sal_uInt8 nFlag
= pStrm
->QuickReaduInt8();
1490 m_Positon
.ReadIndexed(pStrm
);
1493 m_LayColumns
.ReadIndexed(pStrm
);
1494 m_LayGutterStuff
.ReadIndexed(pStrm
);
1495 m_LayJoinStuff
.ReadIndexed(pStrm
);
1496 m_LayShadow
.ReadIndexed(pStrm
);
1498 if (pStrm
->CheckExtra())
1500 m_LayExtJoinStuff
.ReadIndexed(pStrm
);
1507 * @descr: Get columns number
1510 sal_uInt16
LwpLayout::GetNumCols()
1512 if(m_nOverrideFlag
& OVER_COLUMNS
)
1514 LwpLayoutColumns
* pLayColumns
= dynamic_cast<LwpLayoutColumns
*>(m_LayColumns
.obj().get());
1517 return pLayColumns
->GetNumCols();
1521 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj().get());
1524 return pStyle
->GetNumCols();
1527 return LwpVirtualLayout::GetNumCols();
1532 * @descr: Get column width
1533 * @param: the order of column
1535 double LwpLayout::GetColWidth(sal_uInt16 nIndex
)
1537 if((m_nOverrideFlag
& OVER_COLUMNS
)||(m_nAttributes2
& STYLE2_LOCALCOLUMNINFO
))
1539 LwpLayoutColumns
* pLayColumns
= dynamic_cast<LwpLayoutColumns
*>(m_LayColumns
.obj().get());
1542 return pLayColumns
->GetColWidth(nIndex
);
1546 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj().get());
1549 return pStyle
->GetColWidth(nIndex
);
1552 return LwpVirtualLayout::GetColWidth(nIndex
);
1557 * @descr: Get gap between columns
1558 * @param: the order of column
1560 double LwpLayout::GetColGap(sal_uInt16 nIndex
)
1562 if((m_nOverrideFlag
& OVER_COLUMNS
)||(m_nAttributes2
& STYLE2_LOCALCOLUMNINFO
))
1564 LwpLayoutColumns
* pLayColumns
= dynamic_cast<LwpLayoutColumns
*>(m_LayColumns
.obj().get());
1567 return pLayColumns
->GetColGap(nIndex
);
1571 LwpVirtualLayout
* pStyle
= dynamic_cast<LwpVirtualLayout
*> (m_BasedOnStyle
.obj().get());
1574 return pStyle
->GetColGap(nIndex
);
1577 return LwpVirtualLayout::GetColGap(nIndex
);
1581 * @descr: Create and return XFColumns object
1584 XFColumns
* LwpLayout::GetXFColumns()
1586 //if there is only one column, do not need insert columns
1587 sal_uInt16 nCols
= GetNumCols();
1593 XFColumns
* pColumns
= new XFColumns();
1595 boost::scoped_ptr
<XFColumnSep
> pColumnSep(GetColumnSep());
1598 pColumns
->SetSeparator(*pColumnSep
);
1601 //set column count and column gap
1602 pColumns
->SetCount(nCols
);
1603 double fGap
= GetColGap(0);
1604 pColumns
->SetGap(fGap
);
1607 for(sal_uInt16 nIndex
= 0; nIndex
<nCols
; nIndex
++)
1610 sal_Int32 nWidth
= static_cast<sal_Int32
>(GetColWidth(nIndex
));
1611 nWidth
=8305/nCols
; //relative width
1612 aColumn
.SetRelWidth(nWidth
);
1614 //the left and right margins is 0;
1615 double nGap
= GetColGap(nIndex
)/2;
1617 aColumn
.SetMargins(nGap
,nGap
);
1620 aColumn
.SetMargins(0,nGap
);
1622 if(nIndex
==(nCols
-1))
1624 aColumn
.SetMargins(nGap
,0);
1626 pColumns
->AddColumn(aColumn
);
1633 * @descr: Create and return XFColumnSep object
1636 XFColumnSep
* LwpLayout::GetColumnSep()
1639 //Get LwpLayoutGutters
1640 LwpLayoutGutters
* pLayoutGutters
= dynamic_cast<LwpLayoutGutters
*>(m_LayGutterStuff
.obj().get());
1646 LwpBorderStuff
& pBorderStuff
= pLayoutGutters
->GetBorderStuff();
1648 LwpBorderStuff::BorderType eType
= LwpBorderStuff::LEFT
;
1649 LwpColor aColor
= pBorderStuff
.GetSideColor(eType
);
1650 double fWidth
= pBorderStuff
.GetSideWidth(eType
);
1651 //sal_uInt16 nType = pBorderStuff->GetSideType(eType);
1653 XFColumnSep
* pColumnSep
= new XFColumnSep();
1654 XFColor
aXFColor(aColor
.To24Color());
1655 pColumnSep
->SetColor(aXFColor
);
1656 pColumnSep
->SetWidth(fWidth
);
1657 pColumnSep
->SetRelHeight(100);
1658 pColumnSep
->SetVerticalAlign(enumXFAlignTop
);
1664 * @descr: Get use when type
1667 LwpLayout::UseWhenType
LwpLayout::GetUseWhenType()
1669 UseWhenType eType
= StartWithinPage
;
1670 LwpUseWhen
* pUseWhen
= GetUseWhen();
1673 if(pUseWhen
->IsStartOnThisHF())
1675 eType
= StartWithinColume
;
1677 else if(pUseWhen
->IsStartOnThisPage())
1679 eType
= StartWithinPage
;
1681 else if(pUseWhen
->IsStartOnNextPage())
1683 eType
= StartOnNextPage
;
1685 else if(pUseWhen
->IsStartOnNextOddPage())
1687 eType
= StartOnOddPage
;
1689 else if(pUseWhen
->IsStartOnNextEvenPage())
1691 eType
= StartOnEvenPage
;
1697 eType
= StartOnNextPage
;
1703 * @descr: Get use page
1706 sal_uInt16
LwpLayout::GetUsePage()
1708 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1710 LwpUseWhen
* pUseWhen
= GetUseWhen();
1712 return pUseWhen
->GetUsePage();
1716 else if( !m_BasedOnStyle
.IsNull() )
1718 LwpLayout
* pLay
= dynamic_cast<LwpLayout
*> ( m_BasedOnStyle
.obj().get() );
1719 return pLay
? pLay
->GetUsePage() : 0;
1725 * @descr: Get usewhen pointer
1728 LwpUseWhen
* LwpLayout::VirtualGetUseWhen()
1730 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1734 else if( !m_BasedOnStyle
.IsNull() )
1736 LwpLayout
* pLay
= dynamic_cast<LwpLayout
*> ( m_BasedOnStyle
.obj().get() );
1737 return pLay
? pLay
->VirtualGetUseWhen() : NULL
;
1739 return LwpVirtualLayout::VirtualGetUseWhen();
1743 * @descr: Whether it is use on all pages
1746 bool LwpLayout::IsUseOnAllPages()
1748 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1750 LwpUseWhen
* pUseWhen
= GetUseWhen();
1752 return pUseWhen
->IsUseOnAllPages();
1756 else if( !m_BasedOnStyle
.IsNull() )
1758 LwpLayout
* pLay
= dynamic_cast<LwpLayout
*> ( m_BasedOnStyle
.obj().get() );
1760 return pLay
->IsUseOnAllPages();
1762 return LwpVirtualLayout::IsUseOnAllPages();
1766 * @descr: Whether it is use on all even pages
1769 bool LwpLayout::IsUseOnAllEvenPages()
1771 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1773 LwpUseWhen
* pUseWhen
= GetUseWhen();
1775 return pUseWhen
->IsUseOnAllEvenPages();
1779 else if( !m_BasedOnStyle
.IsNull() )
1781 LwpLayout
* pLay
= dynamic_cast<LwpLayout
*> ( m_BasedOnStyle
.obj().get() );
1783 return pLay
->IsUseOnAllEvenPages();
1785 return LwpVirtualLayout::IsUseOnAllEvenPages();
1789 * @descr: Whether it is use on all odd pages
1792 bool LwpLayout::IsUseOnAllOddPages()
1794 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1796 LwpUseWhen
* pUseWhen
= GetUseWhen();
1798 return pUseWhen
->IsUseOnAllOddPages();
1802 else if( !m_BasedOnStyle
.IsNull() )
1804 LwpLayout
* pLay
= dynamic_cast<LwpLayout
*> ( m_BasedOnStyle
.obj().get() );
1806 return pLay
->IsUseOnAllOddPages();
1808 return LwpVirtualLayout::IsUseOnAllOddPages();
1812 * @descr: Whether it is use on current page
1815 bool LwpLayout::IsUseOnPage()
1817 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1819 LwpUseWhen
* pUseWhen
= GetUseWhen();
1821 return pUseWhen
->IsUseOnPage();
1825 else if( !m_BasedOnStyle
.IsNull() )
1827 LwpLayout
* pLay
= dynamic_cast<LwpLayout
*> ( m_BasedOnStyle
.obj().get() );
1829 return pLay
->IsUseOnPage();
1831 return LwpVirtualLayout::IsUseOnPage();
1835 * @descr: Get the LwpShadow object according to m_LayShadow id.
1840 LwpShadow
* LwpLayout::GetShadow()
1842 if(m_nOverrideFlag
& OVER_SHADOW
)
1844 LwpLayoutShadow
* pLayoutShadow
= dynamic_cast<LwpLayoutShadow
*>(m_LayShadow
.obj().get());
1845 return pLayoutShadow
? &pLayoutShadow
->GetShadow() : NULL
;
1847 else if( !m_BasedOnStyle
.IsNull() )
1849 LwpLayout
* pLay
= dynamic_cast<LwpLayout
*> ( m_BasedOnStyle
.obj().get() );
1850 return pLay
? pLay
->GetShadow() : NULL
;
1856 * @descr: create xfshadow
1861 XFShadow
* LwpLayout::GetXFShadow()
1863 LwpShadow
* pShadow
= GetShadow();
1866 LwpColor color
= pShadow
->GetColor();
1867 double offsetX
= pShadow
->GetOffsetX();
1868 double offsetY
= pShadow
->GetOffsetY();
1870 if( offsetX
&& offsetY
&& color
.IsValidColor() )
1872 XFShadow
* pXFShadow
= new XFShadow();
1873 enumXFShadowPos eXFShadowPos
= enumXFShadowLeftTop
;
1886 eXFShadowPos
= enumXFShadowLeftTop
;
1888 eXFShadowPos
= enumXFShadowLeftBottom
;
1894 eXFShadowPos
= enumXFShadowRightTop
;
1896 eXFShadowPos
= enumXFShadowRightBottom
;
1899 pXFShadow
->SetPosition(eXFShadowPos
);
1900 pXFShadow
->SetOffset(fOffset
);
1901 pXFShadow
->SetColor(XFColor(color
.To24Color()));
1910 * @descr get the layout that containers the current frame layout
1913 LwpVirtualLayout
* LwpLayout::GetContainerLayout()
1915 if(IsRelativeAnchored())
1918 LwpPara
* pPara
= dynamic_cast<LwpPara
*>(GetPosition().obj().get());
1921 LwpStory
* pStory
= pPara
->GetStory();
1922 return pStory
? pStory
->GetTabLayout() : NULL
;
1925 return GetParentLayout();
1928 LwpPlacableLayout::LwpPlacableLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
1929 : LwpLayout(objHdr
, pStrm
)
1932 , m_nBaseLineOffset(0)
1936 LwpPlacableLayout::~LwpPlacableLayout()
1939 void LwpPlacableLayout::Read()
1941 LwpObjectStream
* pStrm
= m_pObjStrm
;
1943 if(LwpFileHeader::m_nFileRevision
< 0x000B)
1949 sal_uInt16 simple
= pStrm
->QuickReaduInt16();
1952 m_nWrapType
= pStrm
->QuickReaduInt8();
1953 m_nBuoyancy
= pStrm
->QuickReaduInt8();
1954 m_nBaseLineOffset
= pStrm
->QuickReadInt32();
1955 m_Script
.Read( pStrm
);
1959 m_nWrapType
= LAY_WRAP_AROUND
;
1960 m_nBuoyancy
= LAY_BUOYNEUTRAL
;
1961 m_nBaseLineOffset
= 0;
1963 m_LayRelativity
.ReadIndexed( pStrm
);
1964 if(pStrm
->CheckExtra())
1966 sal_uInt16 count
= pStrm
->QuickReaduInt16();
1969 // temporily added by to avoid assertion
1983 * @descr: get wrap type
1988 sal_uInt8
LwpPlacableLayout::GetWrapType()
1990 if(m_nOverrideFlag
& OVER_PLACEMENT
)
1994 else if( !m_BasedOnStyle
.IsNull() )
1996 LwpPlacableLayout
* pLay
= dynamic_cast<LwpPlacableLayout
*> ( m_BasedOnStyle
.obj().get() );
1998 return pLay
->GetWrapType();
2000 return LAY_WRAP_AROUND
;
2003 * @descr: get LayoutRelativity
2008 LwpLayoutRelativity
* LwpPlacableLayout::GetRelativityPiece()
2010 if(!m_LayRelativity
.IsNull())
2012 if(m_nOverrideFlag
& OVER_PLACEMENT
)
2014 return dynamic_cast<LwpLayoutRelativity
*>(m_LayRelativity
.obj().get());
2017 else if( !m_BasedOnStyle
.IsNull() )
2019 LwpPlacableLayout
* pLay
= dynamic_cast<LwpPlacableLayout
*> ( m_BasedOnStyle
.obj().get() );
2020 return pLay
? pLay
->GetRelativityPiece() : NULL
;
2025 * @descr: Get relative type
2028 sal_uInt8
LwpPlacableLayout::GetRelativeType()
2030 LwpLayoutRelativity
* pLayRel
= GetRelativityPiece();
2033 return pLayRel
->GetRelGuts().GetRelativeType();
2035 return LwpVirtualLayout::GetRelativeType();
2038 * @descr: Get offset from the baseline
2041 sal_Int32
LwpPlacableLayout::GetBaseLineOffset()
2043 /* The baseline is only valid if this is flow-with-text */
2044 if(GetRelativeType()!=LwpLayoutRelativityGuts::LAY_INLINE
)
2049 // First, ask our content if it has a baseline, ignore now
2051 if (Content && Content->GetBaseLineOffset(&Baseline))
2055 if(m_nOverrideFlag
& OVER_PLACEMENT
)
2057 return m_nBaseLineOffset
;
2059 else if( !m_BasedOnStyle
.IsNull() )
2061 LwpPlacableLayout
* pLay
= dynamic_cast<LwpPlacableLayout
*> ( m_BasedOnStyle
.obj().get() );
2062 return pLay
? pLay
->GetBaseLineOffset() : 0;
2068 * @descr: whether the parent layout is page layout
2071 bool LwpPlacableLayout::IsAnchorPage()
2073 if(IsRelativeAnchored())
2076 LwpVirtualLayout
* pLayout
= GetParentLayout();
2077 if(pLayout
&& (pLayout
->IsPage() || pLayout
->IsHeader() || pLayout
->IsFooter()))
2078 //if(pLayout && pLayout->IsPage())
2085 * @descr: whether the parent layout is frame layout
2088 bool LwpPlacableLayout::IsAnchorFrame()
2090 if(IsRelativeAnchored())
2093 LwpVirtualLayout
* pLayout
= GetParentLayout();
2094 if(pLayout
&& (pLayout
->IsFrame()||pLayout
->IsGroupHead()))
2101 * @descr: whether the parent layout is cell layout
2104 bool LwpPlacableLayout::IsAnchorCell()
2106 if(IsRelativeAnchored())
2109 LwpVirtualLayout
* pLayout
= GetParentLayout();
2110 if(pLayout
&& pLayout
->IsCell())
2118 * @descr: Set font style for setting position of frame
2121 void LwpPlacableLayout::SetFont(rtl::Reference
<XFFont
> const & pFont
)
2126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */