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 ************************************************************************/
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>
80 class LwpSuperTableLayout
;
83 class LwpTableHeadingLayout
;
84 class LwpRowHeadingLayout
;
85 class LwpConnectedCellLayout
;
86 class LwpColumnLayout
;
88 struct TableConvertAttempt
90 sal_uInt16 mnStartRow
;
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
104 XFCellListener(XFCell
* pCell
)
108 StartListening(*m_pCell
);
119 virtual void Notify(SfxBroadcaster
& /*rBC*/, const SfxHint
& rHint
) override
121 if (rHint
.GetId() == SfxHintId::Dying
)
128 * VO_TABLELAYOUT object and functions for registering styles and converting tables
130 class LwpTableLayout
: public LwpLayout
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
)
147 m_WordProCellsMap
[static_cast<size_t>(nRow
) * m_nCols
+ nCol
] = pCell
;
150 void Read() override
;
151 void TraverseTable();
152 void RegisterColumns();
155 void PostProcessParagraph(XFCell
*pCell
, sal_uInt16 nRowID
, sal_uInt16 nColID
);
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
);
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
);
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
;
192 std::vector
<LwpCellLayout
*> m_WordProCellsMap
;
194 std::vector
<LwpColumnLayout
*> m_aColumns
;
195 std::map
<sal_uInt16
,LwpRowLayout
*> m_RowsMap
;
196 rtl::Reference
<XFTable
> m_pXFTable
;
198 using rt_type
= mdds::rtree
<int, XFCellListener
>;
204 * VO_SUPERTABLELAYOUT object
206 class LwpSuperTableLayout
: public LwpPlacableLayout
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();
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
;
225 virtual void XFConvertFrame(XFContentContainer
* pCont
, sal_Int32 nStart
= 0, sal_Int32 nEnd
= 0, bool bAll
= false) override
;
226 void RegisterFrameStyle();
227 LwpTableHeadingLayout
* GetTableHeadingLayout();
229 void Read() override
;
230 LwpTableLayout
* GetTableLayout();
231 bool IsSizeRightToContent();
232 bool IsJustifiable();
233 std::unique_ptr
<LwpFrame
> m_pFrame
;
238 * VO_COLUMNLAYOUT object
240 class LwpColumnLayout
: public LwpVirtualLayout
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);}
252 void Read() override
;
260 * VO_TABLEHEADINGLAYOUT object
262 class LwpTableHeadingLayout
: public LwpTableLayout
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
);
270 void Read() override
;
272 sal_uInt16 cStartRow
;
277 * VO_SUPERPARALLELCOLUMNLAYOUT object
279 class LwpSuperParallelColumnLayout
: public LwpSuperTableLayout
282 LwpSuperParallelColumnLayout(LwpObjectHeader
const &objHdr
, LwpSvStream
* pStrm
);
283 virtual ~LwpSuperParallelColumnLayout() override
;
285 void Read() override
;
290 * VO_PCOLLAYOUT object
292 class LwpParallelColumnsLayout
: public LwpTableLayout
295 LwpParallelColumnsLayout(LwpObjectHeader
const &objHdr
, LwpSvStream
* pStrm
);
296 virtual ~LwpParallelColumnsLayout() override
;
298 void Read() override
;
301 class LwpSuperGlossaryLayout
: public LwpSuperTableLayout
304 LwpSuperGlossaryLayout(LwpObjectHeader
const &objHdr
, LwpSvStream
* pStrm
);
305 virtual ~LwpSuperGlossaryLayout() override
;
307 void Read() override
;
312 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */