1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
10 * Sun Microsystems Inc., October, 2000
12 * GNU Lesser General Public License Version 2.1
13 * =============================================
14 * Copyright 2000 by Sun Microsystems, Inc.
15 * 901 San Antonio Road, Palo Alto, CA 94303, USA
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License version 2.1, as published by the Free Software Foundation.
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with this library; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * Sun Industry Standards Source License Version 1.1
33 * =================================================
34 * The contents of this file are subject to the Sun Industry Standards
35 * Source License Version 1.1 (the "License"); You may not use this file
36 * except in compliance with the License. You may obtain a copy of the
37 * License at http://www.openoffice.org/license.html.
39 * Software provided under this License is provided on an "AS IS" basis,
40 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 * See the License for the specific provisions governing your rights and
44 * obligations concerning the Software.
46 * The Initial Developer of the Original Code is: IBM Corporation
48 * Copyright: 2008 by IBM Corporation
50 * All Rights Reserved.
52 * Contributor(s): _______________________________________
55 ************************************************************************/
56 /*************************************************************************
58 * For LWP filter architecture prototype
59 ************************************************************************/
61 #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPLAYOUT_HXX
62 #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPLAYOUT_HXX
64 #include <sal/config.h>
66 #include <rtl/ref.hxx>
68 #include "lwpheader.hxx"
70 #include "lwpobjhdr.hxx"
71 #include "lwpobjstrm.hxx"
72 #include "lwpobjid.hxx"
73 #include "lwpdlvlist.hxx"
74 #include "lwpfilehdr.hxx"
76 #include "lwplayoutdef.hxx"
77 #include "xfilter/xfdefs.hxx"
78 #include "xfilter/xffont.hxx"
79 #include "xfilter/xfpagemaster.hxx"
80 #include "xfilter/xfcolumns.hxx"
81 #include "xfilter/xfborders.hxx"
82 #include "xfilter/xfframestyle.hxx"
83 #include "xfilter/xfframe.hxx"
84 #include "xfilter/xfbgimage.hxx"
85 #include "lwpusewhen.hxx"
86 #include "lwplaypiece.hxx"
89 #define FIRST_LAYOUTPAGENO 0x0001
90 #define LAST_LAYOUTPAGENO 0xffff
92 #define LAY_BUOYNEUTRAL 0x02
93 #define LAY_BUOYLAYER 0x80
96 class LwpVirtualLayout
: public LwpDLNFPVList
99 LwpVirtualLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
);
100 virtual ~LwpVirtualLayout() override
{}
101 inline virtual sal_uInt16
GetNumCols(){return 1;}
102 virtual double GetColWidth(sal_uInt16 nIndex
);
103 virtual double GetColGap(sal_uInt16 nIndex
);
104 virtual bool IsAutoGrow(){ return false;}
105 virtual bool IsAutoGrowUp(){ return false;}
106 virtual bool IsAutoGrowLeft(){ return false;}
107 virtual bool IsAutoGrowRight(){ return false;}
109 bool IsAutoGrowWidth();
110 bool IsInlineToMargin();
111 virtual sal_uInt8
GetContentOrientation(){ return TEXT_ORIENT_LRTB
;}
112 bool GetHonorProtection()
114 if (m_bGettingHonorProtection
)
115 throw std::runtime_error("recursion in layout");
116 m_bGettingHonorProtection
= true;
117 bool bRet
= HonorProtection();
118 m_bGettingHonorProtection
= false;
121 bool GetMarginsSameAsParent()
123 if (m_bGettingMarginsSameAsParent
)
124 throw std::runtime_error("recursion in layout");
125 m_bGettingMarginsSameAsParent
= true;
126 bool bRet
= MarginsSameAsParent();
127 m_bGettingMarginsSameAsParent
= false;
130 bool GetIsProtected()
132 if (m_bGettingIsProtected
)
133 throw std::runtime_error("recursion in layout");
134 m_bGettingIsProtected
= true;
135 bool bRet
= IsProtected();
136 m_bGettingIsProtected
= false;
139 bool GetIsAutoGrowDown()
141 if (m_bGettingIsAutoGrowDown
)
142 throw std::runtime_error("recursion in layout");
143 m_bGettingIsAutoGrowDown
= true;
144 bool bRet
= IsAutoGrowDown();
145 m_bGettingIsAutoGrowDown
= false;
148 bool GetHasProtection()
150 if (m_bGettingHasProtection
)
151 throw std::runtime_error("recursion in layout");
152 m_bGettingHasProtection
= true;
153 bool bRet
= HasProtection();
154 m_bGettingHasProtection
= false;
157 double GetMarginsValue(sal_uInt8 nWhichSide
)
159 if (m_bGettingMarginsValue
)
160 throw std::runtime_error("recursion in layout");
161 m_bGettingMarginsValue
= true;
162 auto fRet
= MarginsValue(nWhichSide
);
163 m_bGettingMarginsValue
= false;
166 double GetExtMarginsValue(sal_uInt8 nWhichSide
)
168 if (m_bGettingExtMarginsValue
)
169 throw std::runtime_error("recursion in layout");
170 m_bGettingExtMarginsValue
= true;
171 auto fRet
= ExtMarginsValue(nWhichSide
);
172 m_bGettingExtMarginsValue
= false;
175 const OUString
& GetStyleName(){ return m_StyleName
;}
177 virtual bool IsAnchorPage(){ return false;}
178 virtual bool IsAnchorFrame(){ return false;}
179 virtual bool IsAnchorCell(){ return false;}
187 virtual sal_uInt8
GetRelativeType();
188 bool IsRelativeAnchored();
189 LwpUseWhen
* GetUseWhen();
190 virtual LwpUseWhen
* VirtualGetUseWhen(){ return nullptr;}
191 virtual bool IsUseOnAllPages(){ return false;}
192 virtual bool IsUseOnAllEvenPages(){ return false;}
193 virtual bool IsUseOnAllOddPages(){ return false;}
194 virtual bool IsUseOnPage(){ return false;}
195 virtual sal_Int32
GetPageNumber(sal_uInt16
/*nLayoutNumber*/) { return -1;}
196 bool IsMinimumHeight();
197 virtual bool IsForWaterMark(){ return false;}
198 virtual LwpPara
* GetLastParaOfPreviousStory() { return nullptr; }
199 rtl::Reference
<LwpVirtualLayout
> GetParentLayout();
200 virtual rtl::Reference
<LwpVirtualLayout
> GetContainerLayout() { return rtl::Reference
<LwpVirtualLayout
>(); }
201 void RegisterChildStyle();
202 bool NoContentReference();
203 bool IsStyleLayout();
204 enumXFAlignType
GetVerticalAlignmentType()
206 if (m_nAttributes
& STYLE_CENTEREDVERTICALLY
)
208 return enumXFAlignMiddle
;
210 else if (m_nAttributes
& STYLE_BOTTOMALIGNED
)
212 return enumXFAlignBottom
;
214 return enumXFAlignTop
;
216 void SetStyleName(const OUString
& str
){ m_StyleName
= str
;}
217 virtual double GetWidth(){return -1;}
219 //Check whether there are contents in the layout
220 virtual bool HasContent(){return false;}
223 void Read() override
;
224 bool HasProtection();
225 virtual bool HonorProtection();
226 virtual bool IsProtected();
227 virtual bool IsAutoGrowDown(){ return false;}
228 virtual double MarginsValue(sal_uInt8
/*nWhichSide*/){return 0;}
229 virtual double ExtMarginsValue(sal_uInt8
/*nWhichSide*/){return 0;}
230 virtual bool MarginsSameAsParent();
232 bool m_bGettingHonorProtection
;
233 bool m_bGettingMarginsSameAsParent
;
234 bool m_bGettingHasProtection
;
235 bool m_bGettingIsProtected
;
236 bool m_bGettingIsAutoGrowDown
;
237 bool m_bGettingMarginsValue
;
238 bool m_bGettingExtMarginsValue
;
239 sal_uInt32 m_nAttributes
;
240 sal_uInt32 m_nAttributes2
;
241 sal_uInt32 m_nAttributes3
;
242 sal_uInt32 m_nOverrideFlag
;
243 sal_uInt16 m_nDirection
;
244 sal_uInt16 m_nEditorID
;
245 LwpObjectID m_NextEnumerated
;
246 LwpObjectID m_PreviousEnumerated
;
247 OUString m_StyleName
;
256 LWP_SUPERTABLE_LAYOUT
,
261 LWP_CONNECTED_CELL_LAYOUT
,
262 LWP_HIDDEN_CELL_LAYOUT
,
263 LWP_TABLE_HEADING_LAYOUT
,
264 LWP_ROW_HEADING_LAYOUT
,
267 LWP_TOC_SUPERTABLE_LAYOUT
,
269 LWP_FOOTNOTE_ROW_LAYOUT
,
270 LWP_FOOTNOTE_CELL_LAYOUT
,
272 LWP_ENDNOTE_SUPERTABLE_LAYOUT
,
273 LWP_FOOTNOTE_SUPERTABLE_LAYOUT
,
275 LWP_NOTEHEADER_LAYOUT
,
281 LAY_USEDIRECTION
= 0x01,
284 LAY_TOCONTAINER
= 0x08,
285 LAY_DIRALLBITS
= 0x0f
287 enum {SHIFT_UP
= 0, SHIFT_DOWN
= 4, SHIFT_LEFT
= 8, SHIFT_RIGHT
=12};
289 virtual LWP_LAYOUT_TYPE
GetLayoutType () { return LWP_VIRTUAL_LAYOUT
;}
290 LwpVirtualLayout
* FindChildByType(LWP_LAYOUT_TYPE eType
);
293 class LwpAssociatedLayouts
296 LwpAssociatedLayouts(){}
297 void Read(LwpObjectStream
* pStrm
);
298 LwpObjectID
& GetOnlyLayout() { return m_OnlyLayout
;}
299 rtl::Reference
<LwpVirtualLayout
> GetLayout(LwpVirtualLayout
* pStartLayout
);
301 LwpObjectID m_OnlyLayout
; //LwpVirtualLayout
302 LwpDLVListHeadTail m_Layouts
;
305 class LwpHeadLayout
: public LwpVirtualLayout
308 LwpHeadLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
);
309 virtual ~LwpHeadLayout() override
{}
310 void RegisterStyle() override
;
311 rtl::Reference
<LwpVirtualLayout
> FindEnSuperTableLayout();
313 void Read() override
;
314 virtual LWP_LAYOUT_TYPE
GetLayoutType () override
{ return LWP_HEAD_LAYOUT
;}
317 class LwpLayoutStyle final
322 void Read(LwpObjectStream
* pStrm
);
324 sal_uInt32 m_nStyleDefinition
;
325 std::unique_ptr
<LwpAtomHolder
> m_pDescription
;
329 class LwpLayoutMisc final
334 void Read(LwpObjectStream
* pStrm
);
336 sal_Int32 m_nGridDistance
;
337 sal_uInt16 m_nGridType
;
338 LwpAtomHolder
* m_pContentStyle
;
341 class LwpMiddleLayout
: public LwpVirtualLayout
344 LwpMiddleLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
);
345 virtual ~LwpMiddleLayout() override
;
346 LwpLayoutGeometry
* GetGeometry()
348 if (m_bGettingGeometry
)
349 throw std::runtime_error("recursion in layout");
350 m_bGettingGeometry
= true;
351 auto pRet
= Geometry();
352 m_bGettingGeometry
= false;
355 double GetGeometryHeight();
356 double GetGeometryWidth();
357 LwpBorderStuff
* GetBorderStuff();
358 LwpBackgroundStuff
* GetBackgroundStuff();
359 enumXFTextDir
GetTextDirection();
360 XFBorders
* GetXFBorders();
361 LwpColor
* GetBackColor();
362 virtual bool IsAutoGrow() override
;
363 virtual bool IsAutoGrowUp() override
;
364 virtual bool IsAutoGrowLeft() override
;
365 virtual bool IsAutoGrowRight() override
;
366 virtual sal_uInt8
GetContentOrientation() override
;
367 virtual bool HonorProtection() override
;
368 virtual bool IsProtected() override
;
369 rtl::Reference
<LwpVirtualLayout
> GetWaterMarkLayout();
370 XFBGImage
* GetXFBGImage();
371 bool GetUsePrinterSettings();
373 LwpLayoutScale
* GetLayoutScale(){return dynamic_cast<LwpLayoutScale
*>(m_LayScale
.obj().get());}
374 sal_uInt16
GetScaleMode();
375 sal_uInt16
GetScaleTile();
376 sal_uInt16
GetScaleCenter();
377 sal_uInt32
GetScalePercentage();
378 double GetScaleWidth();
379 double GetScaleHeight();
382 virtual double GetWidth() override
;
383 sal_Int32
GetMinimumWidth();
384 bool IsSizeRightToContent();
385 bool IsSizeRightToContainer();
386 sal_Int32
DetermineWidth();
387 virtual double GetHeight();
388 LwpPoint
GetOrigin();
390 bool IsPatternFill();
391 XFBGImage
* GetFillPattern();
393 //Check whether there are contents in the layout
394 virtual bool HasContent() override
;
397 void Read() override
;
398 virtual bool MarginsSameAsParent() override
;
399 virtual double MarginsValue(sal_uInt8 nWhichSide
) override
;
400 virtual double ExtMarginsValue(sal_uInt8 nWhichSide
) override
;
401 virtual bool IsAutoGrowDown() override
;
403 LwpObjectID m_BasedOnStyle
;
404 LwpLayoutGeometry
* Geometry();
408 DISK_GOT_STYLE_STUFF
= 0x01,
409 DISK_GOT_MISC_STUFF
= 0x02
412 LwpObjectID m_Content
;
413 rtl::Reference
<LwpObject
> GetBasedOnStyle();
414 LwpObjectID m_TabPiece
;
415 LwpLayoutStyle
* m_pStyleStuff
;
416 LwpLayoutMisc
* m_pMiscStuff
;
417 LwpObjectID m_LayGeometry
;
418 LwpObjectID m_LayScale
;
419 LwpObjectID m_LayMargins
;
420 LwpObjectID m_LayBorderStuff
;
421 LwpObjectID m_LayBackgroundStuff
;
422 LwpObjectID m_LayExtBorderStuff
;
423 bool m_bGettingGeometry
;
425 LwpObjectID
& GetContent() { return m_Content
; }
426 LwpTabOverride
* GetTabOverride();
429 class LwpLayout
: public LwpMiddleLayout
432 LwpLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
);
433 virtual ~LwpLayout() override
;
434 XFColumns
* GetXFColumns();
435 XFColumnSep
* GetColumnSep();
436 LwpShadow
* GetShadow();
437 XFShadow
* GetXFShadow();
439 void Read() override
;
441 LwpUseWhen
* m_pUseWhen
;
442 LwpObjectID m_Position
;
443 LwpObjectID m_LayColumns
;
444 LwpObjectID m_LayGutterStuff
;
445 LwpObjectID m_LayJoinStuff
;
446 LwpObjectID m_LayShadow
;
447 LwpObjectID m_LayExtJoinStuff
;
450 LwpUseWhen
* VirtualGetUseWhen() override
;
451 virtual sal_uInt16
GetNumCols() override
;
452 virtual double GetColWidth(sal_uInt16 nIndex
) override
;
453 virtual double GetColGap(sal_uInt16 nIndex
) override
;
454 sal_uInt16
GetUsePage();
465 UseWhenType
GetUseWhenType();
466 virtual bool IsUseOnAllPages() override
;
467 virtual bool IsUseOnAllEvenPages() override
;
468 virtual bool IsUseOnAllOddPages() override
;
469 virtual bool IsUseOnPage() override
;
470 LwpObjectID
& GetPosition(){ return m_Position
;}
471 virtual rtl::Reference
<LwpVirtualLayout
> GetContainerLayout() override
;
474 class LwpPlacableLayout
: public LwpLayout
477 LwpPlacableLayout( LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
);
478 virtual ~LwpPlacableLayout() override
;
479 sal_uInt8
GetWrapType();
480 LwpLayoutRelativity
* GetRelativityPiece();
481 virtual sal_uInt8
GetRelativeType() override
;
482 sal_Int32
GetBaseLineOffset();
483 virtual bool IsAnchorPage() override
;
484 virtual bool IsAnchorFrame() override
;
485 virtual bool IsAnchorCell() override
;
486 virtual void XFConvertFrame(XFContentContainer
* /*pCont*/, sal_Int32
/*nStart*/ = 0, sal_Int32
/*nEnd*/ = 0, bool /*bAll*/ = false) {}
488 * @descr: Get font style for setting position of frame
491 const rtl::Reference
<XFFont
>& GetFont() { return m_pFont
; }
492 void SetFont(rtl::Reference
<XFFont
> const & pFont
);
503 LAY_WRAP_IRREG_RIGHT
,
504 LAY_WRAP_IRREG_BIGGEST
507 void Read() override
;
509 sal_uInt8 m_nWrapType
;
510 sal_uInt8 m_nBuoyancy
;
511 sal_Int32 m_nBaseLineOffset
;
512 LwpAtomHolder m_Script
;
513 LwpObjectID m_LayRelativity
;
514 rtl::Reference
<XFFont
> m_pFont
;//for frame position
518 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */