LibreOffice Module lotuswordpro (master) 1
lwptablelayout.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*************************************************************************
3 *
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
6 *
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
9 *
10 * Sun Microsystems Inc., October, 2000
11 *
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
16 *
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.
20 *
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.
25 *
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
30 *
31 *
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.
38 *
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.
45 *
46 * The Initial Developer of the Original Code is: IBM Corporation
47 *
48 * Copyright: 2008 by IBM Corporation
49 *
50 * All Rights Reserved.
51 *
52 * Contributor(s): _______________________________________
53 *
54 *
55 ************************************************************************/
61#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABLELAYOUT_HXX
62#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABLELAYOUT_HXX
63
64#include "lwplayout.hxx"
65#include <xfilter/xftable.hxx>
66#include <svl/hint.hxx>
67#include <svl/lstner.hxx>
68
69#include <mdds/rtree.hpp>
70
71#include <vector>
72#include <map>
73#include <memory>
74
75class XFTableStyle;
76class XFTable;
77class XFCell;
78class LwpTable;
79class LwpFrame;
81class LwpRowLayout;
82class LwpCellLayout;
86class LwpColumnLayout;
87
89{
90 sal_uInt16 mnStartRow;
91 sal_uInt16 mnEndRow;
94
95 TableConvertAttempt(sal_uInt16 nStartRow, sal_uInt16 nEndRow, sal_uInt8 nStartCol, sal_uInt8 nEndCol)
96 : mnStartRow(nStartRow), mnEndRow(nEndRow), mnStartCol(nStartCol), mnEndCol(nEndCol)
97 {
98 }
99};
100
102{
103public:
105 : m_pCell(pCell)
106 {
107 if (m_pCell)
109 }
110
112 {
113 return m_pCell;
114 }
115
116private:
118
119 virtual void Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint) override
120 {
121 if (rHint.GetId() == SfxHintId::Dying)
122 m_pCell = nullptr;
123 }
124};
125
131{
132public:
133 LwpTableLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
134 virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_TABLE_LAYOUT;}
136 void RegisterStyle() override;
137 LwpTable * GetTable();
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)
144 {
145 if (nRow >= m_nRows || nCol >= m_nCols)
146 return;
147 m_WordProCellsMap[static_cast<size_t>(nRow) * m_nCols + nCol] = pCell;
148 };
149protected:
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);
156
157public:
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);
166
167private:
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);
175
176 void SplitConflictCells();
177
178 void PutCellVals(LwpFoundry* pFoundry, LwpObjectID aTableID);
179
180 sal_uInt16 m_nRows;
181 sal_uInt16 m_nCols;
182
183 std::vector<TableConvertAttempt> m_aConvertingStack;
184
185 //CColumnLayoutHead cColumnLayout;
190
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;
198 using rt_type = mdds::rtree<int, XFCellListener>;
200};
201
207{
208public:
209 LwpSuperTableLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
210 virtual ~LwpSuperTableLayout() override;
212 void RegisterNewStyle();
213 // for table style
214 void ApplyPatternFill(XFTableStyle* pTableStyle);
215 void ApplyBackGround(XFTableStyle* pTableStyle);
216
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();
228protected:
229 void Read() override;
232 bool IsJustifiable();
233 std::unique_ptr<LwpFrame> m_pFrame;
234};
235
241{
242public:
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;}
249 void RegisterStyle(double dCalculatedWidth);
250 bool IsJustifiable() const {return (( m_nAttributes2 & STYLE2_JUSTIFIABLE) != 0);}
251protected:
252 void Read() override;
253private:
255 sal_Int32 cwidth;
256
257};
263{
264public:
266 virtual ~LwpTableHeadingLayout() override;
268 void GetStartEndRow(sal_uInt16& nStartRow, sal_uInt16& nEndRow);
269protected:
270 void Read() override;
271private:
272 sal_uInt16 cStartRow;
273 sal_uInt16 cEndRow;
274};
280{
281public:
283 virtual ~LwpSuperParallelColumnLayout() override;
284protected:
285 void Read() override;
286};
287
293{
294public:
296 virtual ~LwpParallelColumnsLayout() override;
297protected:
298 void Read() override;
299};
300
302{
303public:
305 virtual ~LwpSuperGlossaryLayout() override;
306protected:
307 void Read() override;
308};
309
310#endif
311
312/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
VO_CELLLAYOUT object.
VO_COLUMNLAYOUT object.
bool IsJustifiable() const
LwpColumnLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
double GetWidth() override
virtual LWP_LAYOUT_TYPE GetLayoutType() override
sal_uInt32 GetColumnID() const
virtual ~LwpColumnLayout() override
void Read() override
@descr Read name of LwpDLNFVList from object stream
VO_CONNECTEDCELLLAYOUT object.
For register frame style and parse frame.
Base class of all Lwp VO objects.
Definition: lwpobjhdr.hxx:71
object id class
Definition: lwpobjid.hxx:79
virtual void RegisterStyle()
@descr default register style function
Definition: lwpobj.cxx:100
VO_PCOLLAYOUT object.
LwpParallelColumnsLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
void Read() override
read table layout
virtual ~LwpParallelColumnsLayout() override
VO_ROWHEADINGLAYOUT obj.
VO_ROWLAYOUT obj.
void Read() override
Read super table layout record.
LwpSuperGlossaryLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
virtual ~LwpSuperGlossaryLayout() override
VO_SUPERPARALLELCOLUMNLAYOUT object.
void Read() override
Read super table layout record.
virtual ~LwpSuperParallelColumnLayout() override
LwpSuperParallelColumnLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
VO_SUPERTABLELAYOUT object.
void ApplyBackColor(XFTableStyle *pTableStyle)
Apply back color to table.
void ApplyBackGround(XFTableStyle *pTableStyle)
Apply background to table style.
void Read() override
Read super table layout record.
double GetWidth() override
Get width of frame outside table.
void RegisterNewStyle()
Register super table layout style.
void RegisterFrameStyle()
register frame style
bool IsSizeRightToContent()
Judge whether table size is according to content, borrowed from Word Pro code.
LwpSuperTableLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
void ApplyPatternFill(XFTableStyle *pTableStyle)
Apply pattern fill to table style.
void ApplyShadow(XFTableStyle *pTableStyle)
Apply shadow to table.
bool IsJustifiable()
Judge whether table is justifiable, borrowed from Word Pro code.
LwpTableHeadingLayout * GetTableHeadingLayout()
Get effective heading table layout, the one just before table layout is the only one which is effecti...
void XFConvert(XFContentContainer *pCont) override
Add table to container.
std::unique_ptr< LwpFrame > m_pFrame
void ApplyWatermark(XFTableStyle *pTableStyle)
Apply watermark to table.
double GetTableWidth()
Get width of table.
LwpTableLayout * GetTableLayout()
Get child table layout.
virtual LWP_LAYOUT_TYPE GetLayoutType() override
virtual void XFConvertFrame(XFContentContainer *pCont, sal_Int32 nStart=0, sal_Int32 nEnd=0, bool bAll=false) override
convert frame which anchor to page
virtual ~LwpSuperTableLayout() override
void ApplyAlignment(XFTableStyle *pTableStyle)
Apply alignment to table.
encapsulate XInputStream to provide SvStream like interfaces
Definition: lwpsvstream.hxx:69
VO_TABLEHEADINGLAYOUT object.
virtual LWP_LAYOUT_TYPE GetLayoutType() override
void Read() override
read table heading layout
virtual ~LwpTableHeadingLayout() override
void GetStartEndRow(sal_uInt16 &nStartRow, sal_uInt16 &nEndRow)
get start and end row number of table heading
LwpTableHeadingLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
VO_TABLELAYOUT object and functions for registering styles and converting tables.
void PutCellVals(LwpFoundry *pFoundry, LwpObjectID aTableID)
apply numeric value and formula to cell
LwpCellLayout * GetCellByRowCol(sal_uInt16 nRow, sal_uInt16 nCol)
Get neighbour cell by specifying ROW+COL.
std::vector< LwpCellLayout * > m_WordProCellsMap
std::map< sal_uInt16, LwpRowLayout * > m_RowsMap
void SplitConflictCells()
split conflict merged cells
LwpSuperTableLayout * GetSuperTableLayout()
Get parent super table layout of table layout.
sal_uInt16 ConvertHeadingRow(rtl::Reference< XFTable > const &pXFTable, sal_uInt16 nStartHeadRow, sal_uInt16 nEndHeadRow)
convert heading row
std::vector< LwpColumnLayout * > m_aColumns
OUString m_DefaultColumnStyleName
void RegisterRows()
register all row styles
virtual LWP_LAYOUT_TYPE GetLayoutType() override
LwpRowLayout * GetRowLayout(sal_uInt16 nRow)
@descr Get row layout by row id
static bool FindSplitColMark(XFTable *pXFTable, std::vector< sal_uInt8 > &rCellMark, sal_uInt8 &nMaxColSpan)
find if the heading rows can be split to 2 cells
void ConvertTable(rtl::Reference< XFTable > const &pXFTable, sal_uInt16 nStartRow, sal_uInt16 nEndRow, sal_uInt8 nStartCol, sal_uInt8 nEndCol)
convert word pro table to SODC table
LwpObjectID & GetColumnLayoutHead()
LwpObjectID m_ColumnLayout
sal_uInt16 m_nCols
void PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_uInt16 nColID)
1.
void SplitRowToCells(XFTable *pTmpTable, rtl::Reference< XFTable > const &pXFTable, sal_uInt8 nFirstColSpann, const sal_uInt8 *pCellMark)
void SetWordProCellMap(sal_uInt16 nRow, sal_uInt16 nCol, LwpCellLayout *pCell)
rtl::Reference< XFTable > m_pXFTable
void ConvertDefaultRow(rtl::Reference< XFTable > const &pXFTable, sal_uInt8 nStartCol, sal_uInt8 nEndCol, sal_uInt16 nRowID)
add default row which are missing in the file
void ParseTable()
read table layout
void RegisterColumns()
analyze all columns to get whole table width and width of all columns
const std::map< sal_uInt16, LwpRowLayout * > & GetRowsMap() const
void RegisterStyle() override
register table style, if needed, including frame style
LwpCellLayout * m_pDefaultCellLayout
void TraverseTable()
traverse all table cells
LwpObjectID * SearchCellStoryMap(sal_uInt16 nRow, sal_uInt16 nCol)
search the cell map
void SetCellsMap(sal_uInt16 nRow1, sal_uInt8 nCol1, sal_uInt16 nRow2, sal_uInt8 nCol2, XFCell *pXFCell)
set cell map info
OUString m_DefaultRowStyleName
LwpTable * GetTable()
Get table pointer.
LwpTableLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
OUString GetColumnWidth(sal_uInt16 nCol)
Get column style name by column ID.
mdds::rtree< int, XFCellListener > rt_type
void XFConvert(XFContentContainer *pCont) override
Convert table.
LwpCellLayout * GetDefaultCellLayout()
std::vector< TableConvertAttempt > m_aConvertingStack
XFCell * GetCellsMap(sal_uInt16 nRow, sal_uInt8 nCol)
get cell map info
const OUString & GetDefaultRowStyleName() const
void Read() override
read table layout
void ConvertColumn(rtl::Reference< XFTable > const &pXFTable, sal_uInt8 nStartCol, sal_uInt8 nEndCol)
Parse all cols of table.
sal_uInt16 m_nRows
VO_TABLE object.
Definition: lwptable.hxx:107
static double ConvertFromUnitsToMetric(sal_Int32 nUnits)
Definition: lwptools.hxx:117
sal_uInt32 m_nAttributes2
Definition: lwplayout.hxx:242
SfxHintId GetId() const
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
virtual void Notify(SfxBroadcaster &, const SfxHint &rHint) override
XFCellListener(XFCell *pCell)
XFCell * GetCell()
@descr Table cell object.
Definition: xfcell.hxx:76
A container for content.
#define STYLE2_JUSTIFIABLE
TableConvertAttempt(sal_uInt16 nStartRow, sal_uInt16 nEndRow, sal_uInt8 nStartCol, sal_uInt8 nEndCol)
unsigned char sal_uInt8