tdf#131098 docx export: write fill property of graphic
[LibreOffice.git] / lotuswordpro / source / filter / lwptablelayout.hxx
blobf54c82b8e1f94319c14cbf6ba0ddc19b6ee9be65
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 - table layouts
61 #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABLELAYOUT_HXX
62 #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABLELAYOUT_HXX
64 #include "lwplayout.hxx"
65 #include <xfilter/xftable.hxx>
66 #include <svl/hint.hxx>
67 #include <svl/lstner.hxx>
69 #include <mdds/rtree.hpp>
71 #include <vector>
72 #include <map>
73 #include <memory>
75 class XFTableStyle;
76 class XFTable;
77 class XFCell;
78 class LwpTable;
79 class LwpFrame;
80 class LwpSuperTableLayout;
81 class LwpRowLayout;
82 class LwpCellLayout;
83 class LwpTableHeadingLayout;
84 class LwpRowHeadingLayout;
85 class LwpConnectedCellLayout;
86 class LwpColumnLayout;
88 struct TableConvertAttempt
90 sal_uInt16 mnStartRow;
91 sal_uInt16 mnEndRow;
92 sal_uInt8 mnStartCol;
93 sal_uInt8 mnEndCol;
95 TableConvertAttempt(sal_uInt16 nStartRow, sal_uInt16 nEndRow, sal_uInt8 nStartCol, sal_uInt8 nEndCol)
96 : mnStartRow(nStartRow), mnEndRow(nEndRow), mnStartCol(nStartCol), mnEndCol(nEndCol)
101 class XFCellListener : public SfxListener
103 public:
104 XFCellListener(XFCell* pCell)
105 : m_pCell(pCell)
107 if (m_pCell)
108 StartListening(*m_pCell);
111 XFCell* GetCell()
113 return m_pCell;
116 private:
117 XFCell* m_pCell;
119 virtual void Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint) override
121 if (rHint.GetId() == SfxHintId::Dying)
122 m_pCell = nullptr;
127 * @brief
128 * VO_TABLELAYOUT object and functions for registering styles and converting tables
130 class LwpTableLayout: public LwpLayout
132 public:
133 LwpTableLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
134 virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_TABLE_LAYOUT;}
135 LwpObjectID& GetColumnLayoutHead(){return m_ColumnLayout;}
136 void RegisterStyle() override;
137 LwpTable * GetTable();
138 LwpCellLayout * GetDefaultCellLayout(){return m_pDefaultCellLayout;}
139 LwpSuperTableLayout * GetSuperTableLayout();
140 LwpObjectID * SearchCellStoryMap(sal_uInt16 nRow, sal_uInt16 nCol);
141 LwpCellLayout * GetCellByRowCol(sal_uInt16 nRow, sal_uInt16 nCol);
142 OUString GetColumnWidth(sal_uInt16 nCol);
143 void SetWordProCellMap(sal_uInt16 nRow, sal_uInt16 nCol, LwpCellLayout * pCell)
145 if (nRow >= m_nRows || nCol >= m_nCols)
146 return;
147 m_WordProCellsMap[static_cast<size_t>(nRow) * m_nCols + nCol] = pCell;
149 protected:
150 void Read() override;
151 void TraverseTable();
152 void RegisterColumns();
153 void RegisterRows();
154 void ParseTable();
155 void PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_uInt16 nColID);
157 public:
158 void XFConvert(XFContentContainer* pCont) override;
159 void ConvertTable(rtl::Reference<XFTable> const & pXFTable, sal_uInt16 nStartRow,
160 sal_uInt16 nEndRow,sal_uInt8 nStartCol,sal_uInt8 nEndCol);
161 const OUString& GetDefaultRowStyleName() const {return m_DefaultRowStyleName;}
162 void SetCellsMap(sal_uInt16 nRow1, sal_uInt8 nCol1, sal_uInt16 nRow2, sal_uInt8 nCol2, XFCell* pXFCell);
163 XFCell* GetCellsMap(sal_uInt16 nRow,sal_uInt8 nCol);
164 const std::map<sal_uInt16,LwpRowLayout*>& GetRowsMap() const {return m_RowsMap;}
165 LwpRowLayout* GetRowLayout(sal_uInt16 nRow);
167 private:
168 void ConvertDefaultRow(rtl::Reference<XFTable> const & pXFTable, sal_uInt8 nStartCol,
169 sal_uInt8 nEndCol, sal_uInt16 nRowID);
170 void ConvertColumn(rtl::Reference<XFTable> const & pXFTable, sal_uInt8 nStartCol, sal_uInt8 nEndCol);
171 sal_uInt16 ConvertHeadingRow(rtl::Reference<XFTable> const & pXFTable,sal_uInt16 nStartHeadRow,sal_uInt16 nEndHeadRow);
172 static bool FindSplitColMark(XFTable* pXFTable, std::vector<sal_uInt8>& rCellMark, sal_uInt8& nMaxColSpan);
173 void SplitRowToCells(XFTable* pTmpTable, rtl::Reference<XFTable> const & pXFTable,
174 sal_uInt8 nFirstColSpann, const sal_uInt8* pCellMark);
176 void SplitConflictCells();
178 void PutCellVals(LwpFoundry* pFoundry, LwpObjectID aTableID);
180 sal_uInt16 m_nRows;
181 sal_uInt16 m_nCols;
183 std::vector<TableConvertAttempt> m_aConvertingStack;
185 //CColumnLayoutHead cColumnLayout;
186 LwpObjectID m_ColumnLayout;
187 LwpCellLayout * m_pDefaultCellLayout;
188 OUString m_DefaultColumnStyleName;
189 OUString m_DefaultRowStyleName;
191 // wordpro cell map
192 std::vector<LwpCellLayout*> m_WordProCellsMap;
193 // column vector
194 std::vector<LwpColumnLayout*> m_aColumns;
195 std::map<sal_uInt16,LwpRowLayout*> m_RowsMap;
196 rtl::Reference<XFTable> m_pXFTable;
197 bool m_bConverted;
198 using rt_type = mdds::rtree<int, XFCellListener>;
199 rt_type m_CellsMap;
203 * @brief
204 * VO_SUPERTABLELAYOUT object
206 class LwpSuperTableLayout: public LwpPlacableLayout
208 public:
209 LwpSuperTableLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
210 virtual ~LwpSuperTableLayout() override;
211 virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_SUPERTABLE_LAYOUT;}
212 void RegisterNewStyle();
213 // for table style
214 void ApplyPatternFill(XFTableStyle* pTableStyle);
215 void ApplyBackGround(XFTableStyle* pTableStyle);
217 void ApplyBackColor(XFTableStyle *pTableStyle);
218 void ApplyShadow(XFTableStyle *pTableStyle);
219 double GetWidth() override;
220 double GetTableWidth();
221 void ApplyWatermark(XFTableStyle *pTableStyle);
222 void ApplyAlignment(XFTableStyle * pTableStyle);
223 void XFConvert(XFContentContainer* pCont) override;
224 // for frame style
225 virtual void XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart = 0, sal_Int32 nEnd = 0, bool bAll = false) override;
226 void RegisterFrameStyle();
227 LwpTableHeadingLayout* GetTableHeadingLayout();
228 protected:
229 void Read() override;
230 LwpTableLayout* GetTableLayout();
231 bool IsSizeRightToContent();
232 bool IsJustifiable();
233 std::unique_ptr<LwpFrame> m_pFrame;
237 * @brief
238 * VO_COLUMNLAYOUT object
240 class LwpColumnLayout : public LwpVirtualLayout
242 public:
243 LwpColumnLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
244 virtual ~LwpColumnLayout() override;
245 virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_COLUMN_LAYOUT;}
246 sal_uInt32 GetColumnID() const {return ccolid;}
247 double GetWidth() override { return LwpTools::ConvertFromUnits(cwidth); }
248 using LwpVirtualLayout::RegisterStyle;
249 void RegisterStyle(double dCalculatedWidth);
250 bool IsJustifiable() const {return (( m_nAttributes2 & STYLE2_JUSTIFIABLE) != 0);}
251 protected:
252 void Read() override;
253 private:
254 sal_uInt8 ccolid;
255 sal_Int32 cwidth;
259 * @brief
260 * VO_TABLEHEADINGLAYOUT object
262 class LwpTableHeadingLayout : public LwpTableLayout
264 public:
265 LwpTableHeadingLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
266 virtual ~LwpTableHeadingLayout() override;
267 virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_TABLE_HEADING_LAYOUT;}
268 void GetStartEndRow(sal_uInt16& nStartRow, sal_uInt16& nEndRow);
269 protected:
270 void Read() override;
271 private:
272 sal_uInt16 cStartRow;
273 sal_uInt16 cEndRow;
276 * @brief
277 * VO_SUPERPARALLELCOLUMNLAYOUT object
279 class LwpSuperParallelColumnLayout : public LwpSuperTableLayout
281 public:
282 LwpSuperParallelColumnLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
283 virtual ~LwpSuperParallelColumnLayout() override;
284 protected:
285 void Read() override;
289 * @brief
290 * VO_PCOLLAYOUT object
292 class LwpParallelColumnsLayout : public LwpTableLayout
294 public:
295 LwpParallelColumnsLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
296 virtual ~LwpParallelColumnsLayout() override;
297 protected:
298 void Read() override;
301 class LwpSuperGlossaryLayout : public LwpSuperTableLayout
303 public:
304 LwpSuperGlossaryLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
305 virtual ~LwpSuperGlossaryLayout() override;
306 protected:
307 void Read() override;
310 #endif
312 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */