tdf#131098 docx export: write fill property of graphic
[LibreOffice.git] / lotuswordpro / source / filter / lwplayout.hxx
blob99cd1b922eb4d9c485c031ee90005149477022b8
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,
29 * MA 02111-1307 USA
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 /*************************************************************************
57 * @file
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 <memory>
65 #include <sal/config.h>
66 #include <config_lgpl.h>
68 #include <rtl/ref.hxx>
70 #include <lwpobj.hxx>
71 #include <lwpobjhdr.hxx>
72 #include <lwpobjstrm.hxx>
73 #include <lwpobjid.hxx>
74 #include "lwpdlvlist.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/xfbgimage.hxx>
83 #include "lwpusewhen.hxx"
84 #include "lwplaypiece.hxx"
87 #define FIRST_LAYOUTPAGENO 0x0001
88 #define LAST_LAYOUTPAGENO 0xffff
90 #define LAY_BUOYNEUTRAL 0x02
91 #define LAY_BUOYLAYER 0x80
93 class LwpPara;
94 class LwpVirtualLayout : public LwpDLNFPVList
96 public:
97 LwpVirtualLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
98 virtual sal_uInt16 GetNumCols(){return 1;}
99 virtual double GetColGap(sal_uInt16 nIndex);
100 virtual bool IsAutoGrow(){ return false;}
101 virtual bool IsAutoGrowUp(){ return false;}
102 virtual bool IsAutoGrowLeft(){ return false;}
103 virtual bool IsAutoGrowRight(){ return false;}
104 bool IsFitGraphic();
105 bool IsAutoGrowWidth();
106 bool IsInlineToMargin() const;
107 virtual sal_uInt8 GetContentOrientation(){ return TEXT_ORIENT_LRTB;}
108 bool GetHonorProtection()
110 if (m_bGettingHonorProtection)
111 throw std::runtime_error("recursion in layout");
112 m_bGettingHonorProtection = true;
113 bool bRet = HonorProtection();
114 m_bGettingHonorProtection = false;
115 return bRet;
117 bool GetMarginsSameAsParent()
119 if (m_bGettingMarginsSameAsParent)
120 throw std::runtime_error("recursion in layout");
121 m_bGettingMarginsSameAsParent = true;
122 bool bRet = MarginsSameAsParent();
123 m_bGettingMarginsSameAsParent = false;
124 return bRet;
126 bool GetIsProtected()
128 if (m_bGettingIsProtected)
129 throw std::runtime_error("recursion in layout");
130 m_bGettingIsProtected = true;
131 bool bRet = IsProtected();
132 m_bGettingIsProtected = false;
133 return bRet;
135 bool GetIsAutoGrowDown()
137 if (m_bGettingIsAutoGrowDown)
138 throw std::runtime_error("recursion in layout");
139 m_bGettingIsAutoGrowDown = true;
140 bool bRet = IsAutoGrowDown();
141 m_bGettingIsAutoGrowDown = false;
142 return bRet;
144 bool GetHasProtection()
146 if (m_bGettingHasProtection)
147 throw std::runtime_error("recursion in layout");
148 m_bGettingHasProtection = true;
149 bool bRet = HasProtection();
150 m_bGettingHasProtection = false;
151 return bRet;
153 double GetMarginsValue(sal_uInt8 nWhichSide)
155 if (m_bGettingMarginsValue)
156 throw std::runtime_error("recursion in layout");
157 m_bGettingMarginsValue = true;
158 auto fRet = MarginsValue(nWhichSide);
159 m_bGettingMarginsValue = false;
160 return fRet;
162 double GetExtMarginsValue(sal_uInt8 nWhichSide)
164 if (m_bGettingExtMarginsValue)
165 throw std::runtime_error("recursion in layout");
166 m_bGettingExtMarginsValue = true;
167 auto fRet = ExtMarginsValue(nWhichSide);
168 m_bGettingExtMarginsValue = false;
169 return fRet;
171 const OUString& GetStyleName() const { return m_StyleName;}
172 bool IsComplex() const;
173 virtual bool IsAnchorPage(){ return false;}
174 virtual bool IsAnchorFrame(){ return false;}
175 virtual bool IsAnchorCell(){ return false;}
176 bool IsPage();
177 bool IsHeader();
178 bool IsFooter();
179 bool IsFrame();
180 bool IsCell();
181 bool IsSuperTable();
182 bool IsGroupHead();
183 virtual sal_uInt8 GetRelativeType();
184 bool IsRelativeAnchored();
185 LwpUseWhen* GetUseWhen();
186 virtual LwpUseWhen* VirtualGetUseWhen(){ return nullptr;}
187 virtual bool IsUseOnAllPages(){ return false;}
188 virtual bool IsUseOnAllEvenPages(){ return false;}
189 virtual bool IsUseOnAllOddPages(){ return false;}
190 virtual bool IsUseOnPage(){ return false;}
191 virtual sal_Int32 GetPageNumber(sal_uInt16 /*nLayoutNumber*/) { return -1;}
192 bool IsMinimumHeight() const;
193 virtual bool IsForWaterMark(){ return false;}
194 virtual LwpPara* GetLastParaOfPreviousStory() { return nullptr; }
195 rtl::Reference<LwpVirtualLayout> GetParentLayout();
196 virtual rtl::Reference<LwpVirtualLayout> GetContainerLayout() { return rtl::Reference<LwpVirtualLayout>(); }
197 void RegisterChildStyle();
198 bool NoContentReference();
199 bool IsStyleLayout();
200 enumXFAlignType GetVerticalAlignmentType() const
202 if (m_nAttributes & STYLE_CENTEREDVERTICALLY)
204 return enumXFAlignMiddle;
206 else if (m_nAttributes & STYLE_BOTTOMALIGNED)
208 return enumXFAlignBottom;
210 return enumXFAlignTop;
212 void SetStyleName(const OUString & str){ m_StyleName = str;}
213 virtual double GetWidth(){return -1;}
215 //Check whether there are contents in the layout
216 virtual bool HasContent(){return false;}
217 //End by
218 protected:
219 void Read() override;
220 bool HasProtection();
221 virtual bool HonorProtection();
222 virtual bool IsProtected();
223 virtual bool IsAutoGrowDown(){ return false;}
224 virtual double MarginsValue(sal_uInt8 /*nWhichSide*/){return 0;}
225 virtual double ExtMarginsValue(sal_uInt8 /*nWhichSide*/){return 0;}
226 virtual bool MarginsSameAsParent();
227 protected:
228 bool m_bGettingHonorProtection;
229 bool m_bGettingMarginsSameAsParent;
230 bool m_bGettingHasProtection;
231 bool m_bGettingIsProtected;
232 bool m_bGettingIsAutoGrowDown;
233 bool m_bGettingMarginsValue;
234 bool m_bGettingExtMarginsValue;
235 bool m_bGettingUsePrinterSettings;
236 bool m_bGettingScaleCenter;
237 bool m_bGettingBorderStuff;
238 bool m_bGettingUseWhen;
239 bool m_bGettingStyleLayout;
240 bool m_bGettingAutoGrowUp;
241 sal_uInt32 m_nAttributes;
242 sal_uInt32 m_nAttributes2;
243 sal_uInt32 m_nAttributes3;
244 sal_uInt32 m_nOverrideFlag;
245 sal_uInt16 m_nDirection;
246 sal_uInt16 m_nEditorID;
247 LwpObjectID m_NextEnumerated;
248 LwpObjectID m_PreviousEnumerated;
249 OUString m_StyleName;
250 enum LWP_LAYOUT_TYPE
252 LWP_VIRTUAL_LAYOUT,
253 LWP_HEAD_LAYOUT,
254 LWP_PAGE_LAYOUT,
255 LWP_HEADER_LAYOUT,
256 LWP_FOOTER_LAYOUT,
257 LWP_FRAME_LAYOUT,
258 LWP_SUPERTABLE_LAYOUT,
259 LWP_TABLE_LAYOUT,
260 LWP_ROW_LAYOUT,
261 LWP_COLUMN_LAYOUT,
262 LWP_CELL_LAYOUT,
263 LWP_CONNECTED_CELL_LAYOUT,
264 LWP_HIDDEN_CELL_LAYOUT,
265 LWP_TABLE_HEADING_LAYOUT,
266 LWP_ROW_HEADING_LAYOUT,
267 LWP_DROPCAP_LAYOUT,
268 LWP_GROUP_LAYOUT,
269 LWP_TOC_SUPERTABLE_LAYOUT,
270 LWP_FOOTNOTE_LAYOUT,
271 LWP_FOOTNOTE_ROW_LAYOUT,
272 LWP_FOOTNOTE_CELL_LAYOUT,
273 LWP_ENDNOTE_LAYOUT,
274 LWP_ENDNOTE_SUPERTABLE_LAYOUT,
275 LWP_FOOTNOTE_SUPERTABLE_LAYOUT,
276 LWP_NOTE_LAYOUT,
277 LWP_NOTEHEADER_LAYOUT,
278 LWP_NOTETEXT_LAYOUT,
279 LWP_VIEWPORT_LAYOUT
281 enum LayoutDirection
283 LAY_USEDIRECTION = 0x01,
284 LAY_AUTOGROW = 0x02,
285 LAY_AUTOSIZE = 0x04,
286 LAY_TOCONTAINER = 0x08,
287 LAY_DIRALLBITS = 0x0f
289 enum {SHIFT_UP = 0, SHIFT_DOWN = 4, SHIFT_LEFT = 8, SHIFT_RIGHT =12};
290 public:
291 virtual LWP_LAYOUT_TYPE GetLayoutType () { return LWP_VIRTUAL_LAYOUT;}
292 LwpVirtualLayout* FindChildByType(LWP_LAYOUT_TYPE eType);
295 class LwpAssociatedLayouts final
297 public:
298 LwpAssociatedLayouts(){}
299 void Read(LwpObjectStream* pStrm);
300 LwpObjectID& GetOnlyLayout() { return m_OnlyLayout;}
301 rtl::Reference<LwpVirtualLayout> GetLayout(LwpVirtualLayout const * pStartLayout);
302 private:
303 LwpObjectID m_OnlyLayout; //LwpVirtualLayout
304 LwpDLVListHeadTail m_Layouts;
307 class LwpHeadLayout : public LwpVirtualLayout
309 public:
310 LwpHeadLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
311 void RegisterStyle() override;
312 rtl::Reference<LwpVirtualLayout> FindEnSuperTableLayout();
313 protected:
314 void Read() override;
315 virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_HEAD_LAYOUT;}
318 class LwpLayoutStyle final
320 public:
321 LwpLayoutStyle();
322 ~LwpLayoutStyle();
323 void Read(LwpObjectStream* pStrm);
324 private:
325 sal_uInt32 m_nStyleDefinition;
326 LwpAtomHolder m_aDescription;
327 sal_uInt16 m_nKey;
330 class LwpLayoutMisc final
332 public:
333 LwpLayoutMisc();
334 ~LwpLayoutMisc();
335 void Read(LwpObjectStream* pStrm);
336 private:
337 sal_Int32 m_nGridDistance;
338 sal_uInt16 m_nGridType;
339 LwpAtomHolder m_aContentStyle;
342 class LwpMiddleLayout : public LwpVirtualLayout
344 public:
345 LwpMiddleLayout( LwpObjectHeader const &objHdr, LwpSvStream* pStrm );
346 virtual ~LwpMiddleLayout() override;
347 double GetGeometryHeight();
348 double GetGeometryWidth();
349 LwpBorderStuff* GetBorderStuff();
350 LwpBackgroundStuff* GetBackgroundStuff();
351 LwpLayoutGeometry* GetGeometry();
352 enumXFTextDir GetTextDirection();
353 std::unique_ptr<XFBorders> GetXFBorders();
354 LwpColor* GetBackColor();
355 virtual bool IsAutoGrow() override;
356 virtual bool IsAutoGrowUp() override;
357 virtual bool IsAutoGrowLeft() override;
358 virtual bool IsAutoGrowRight() override;
359 virtual sal_uInt8 GetContentOrientation() override;
360 virtual bool HonorProtection() override;
361 virtual bool IsProtected() override;
362 rtl::Reference<LwpVirtualLayout> GetWaterMarkLayout();
363 std::unique_ptr<XFBGImage> GetXFBGImage();
364 bool GetUsePrinterSettings();
366 LwpLayoutScale* GetLayoutScale(){return dynamic_cast<LwpLayoutScale*>(m_LayScale.obj().get());}
367 sal_uInt16 GetScaleMode();
368 sal_uInt16 GetScaleTile();
369 sal_uInt16 GetScaleCenter();
371 bool CanSizeRight();
372 virtual double GetWidth() override;
373 sal_Int32 GetMinimumWidth();
374 bool IsSizeRightToContent();
375 bool IsSizeRightToContainer();
376 sal_Int32 DetermineWidth();
377 virtual double GetHeight();
378 LwpPoint GetOrigin();
380 bool IsPatternFill();
381 std::unique_ptr<XFBGImage> GetFillPattern();
383 //Check whether there are contents in the layout
384 virtual bool HasContent() override;
386 protected:
387 void Read() override;
388 virtual bool MarginsSameAsParent() override;
389 virtual double MarginsValue(sal_uInt8 nWhichSide) override;
390 virtual double ExtMarginsValue(sal_uInt8 nWhichSide) override;
391 virtual bool IsAutoGrowDown() override;
392 private:
393 LwpObjectID m_BasedOnStyle;
394 protected:
395 enum
397 DISK_GOT_STYLE_STUFF = 0x01,
398 DISK_GOT_MISC_STUFF = 0x02
401 LwpObjectID m_Content;
402 rtl::Reference<LwpObject> GetBasedOnStyle() const;
403 LwpObjectID m_TabPiece;
404 LwpLayoutStyle m_aStyleStuff;
405 LwpLayoutMisc m_aMiscStuff;
406 LwpObjectID m_LayGeometry;
407 LwpObjectID m_LayScale;
408 LwpObjectID m_LayMargins;
409 LwpObjectID m_LayBorderStuff;
410 LwpObjectID m_LayBackgroundStuff;
411 LwpObjectID m_LayExtBorderStuff;
412 bool m_bGettingGeometry;
413 bool m_bGettingBackgroundStuff;
414 public:
415 LwpObjectID& GetContent() { return m_Content; }
416 LwpTabOverride* GetTabOverride();
419 class LwpLayout : public LwpMiddleLayout
421 public:
422 LwpLayout( LwpObjectHeader const &objHdr, LwpSvStream* pStrm );
423 virtual ~LwpLayout() override;
424 XFColumns* GetXFColumns();
425 XFColumnSep* GetColumnSep();
426 LwpShadow* GetShadow();
427 XFShadow* GetXFShadow();
428 protected:
429 void Read() override;
431 public:
432 LwpUseWhen* VirtualGetUseWhen() override;
433 virtual sal_uInt16 GetNumCols() override;
434 virtual double GetColGap(sal_uInt16 nIndex) override;
435 sal_uInt16 GetUsePage();
436 enum UseWhenType
438 StartWithinColume,
439 StartWithinPage,
440 StartOnNextPage,
441 StartOnOddPage,
442 StartOnEvenPage
444 UseWhenType GetUseWhenType();
445 virtual bool IsUseOnAllPages() override;
446 virtual bool IsUseOnAllEvenPages() override;
447 virtual bool IsUseOnAllOddPages() override;
448 virtual bool IsUseOnPage() override;
449 LwpObjectID& GetPosition(){ return m_Position;}
450 virtual rtl::Reference<LwpVirtualLayout> GetContainerLayout() override;
452 private:
453 bool m_bGettingShadow;
454 bool m_bGettingNumCols;
455 LwpUseWhen m_aUseWhen;
456 LwpObjectID m_Position;
457 LwpObjectID m_LayColumns;
458 LwpObjectID m_LayGutterStuff;
459 LwpObjectID m_LayJoinStuff;
460 LwpObjectID m_LayShadow;
461 LwpObjectID m_LayExtJoinStuff;
464 class LwpPlacableLayout : public LwpLayout
466 public:
467 LwpPlacableLayout( LwpObjectHeader const &objHdr, LwpSvStream* pStrm );
468 virtual ~LwpPlacableLayout() override;
469 sal_uInt8 GetWrapType();
470 LwpLayoutRelativity* GetRelativityPiece();
471 virtual sal_uInt8 GetRelativeType() override;
472 sal_Int32 GetBaseLineOffset();
473 virtual bool IsAnchorPage() override;
474 virtual bool IsAnchorFrame() override;
475 virtual bool IsAnchorCell() override;
476 virtual void XFConvertFrame(XFContentContainer* /*pCont*/, sal_Int32 /*nStart*/ = 0, sal_Int32 /*nEnd*/ = 0, bool /*bAll*/ = false) {}
478 * @descr: Get font style for setting position of frame
481 const rtl::Reference<XFFont>& GetFont() const { return m_pFont; }
482 void SetFont(rtl::Reference<XFFont> const & pFont);
483 enum WrapType
485 LAY_WRAP_AROUND = 1,
486 LAY_NO_WRAP_BESIDE,
487 LAY_NO_WRAP_AROUND,
488 LAY_WRAP_LEFT,
489 LAY_WRAP_RIGHT,
490 LAY_WRAP_BOTH,
491 LAY_WRAP_IRREG_BOTH,
492 LAY_WRAP_IRREG_LEFT,
493 LAY_WRAP_IRREG_RIGHT,
494 LAY_WRAP_IRREG_BIGGEST
496 protected:
497 void Read() override;
498 protected:
499 bool m_bGettingWrapType;
500 bool m_bGettingLayoutRelativity;
501 sal_uInt8 m_nWrapType;
502 sal_uInt8 m_nBuoyancy;
503 sal_Int32 m_nBaseLineOffset;
504 LwpAtomHolder m_Script;
505 LwpObjectID m_LayRelativity;
506 rtl::Reference<XFFont> m_pFont;//for frame position
508 #endif
510 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */