1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*efeef26fSAndrew Rist * distributed with this work for additional information
6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10*efeef26fSAndrew Rist *
11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist *
13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17*efeef26fSAndrew Rist * specific language governing permissions and limitations
18*efeef26fSAndrew Rist * under the License.
19*efeef26fSAndrew Rist *
20*efeef26fSAndrew Rist *************************************************************/
21*efeef26fSAndrew Rist
22*efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <com/sun/star/text/XTextTable.hpp>
28cdf0e10cSrcweir #include <com/sun/star/text/XTextSection.hpp>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <hintids.hxx>
31cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
32cdf0e10cSrcweir #include <xmloff/xmlnmspe.hxx>
33cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
34cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
35cdf0e10cSrcweir #include <xmloff/numehelp.hxx>
36cdf0e10cSrcweir #include <svl/cntnrsrt.hxx>
37cdf0e10cSrcweir #include <svl/zforlist.hxx>
38cdf0e10cSrcweir #include <editeng/brshitem.hxx>
39cdf0e10cSrcweir #include <editeng/boxitem.hxx>
40cdf0e10cSrcweir #include <fmtrowsplt.hxx>
41cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
42cdf0e10cSrcweir #include <list>
43cdf0e10cSrcweir #include "swtable.hxx"
44cdf0e10cSrcweir #include "doc.hxx"
45cdf0e10cSrcweir #include "pam.hxx"
46cdf0e10cSrcweir #include "frmfmt.hxx"
47cdf0e10cSrcweir #include "wrtswtbl.hxx"
48cdf0e10cSrcweir #include "fmtfsize.hxx"
49cdf0e10cSrcweir #include "fmtornt.hxx"
50cdf0e10cSrcweir #include "cellatr.hxx"
51cdf0e10cSrcweir #include "ddefld.hxx"
52cdf0e10cSrcweir #include "swddetbl.hxx"
53cdf0e10cSrcweir #include <ndole.hxx>
54cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
55cdf0e10cSrcweir #include <sfx2/linkmgr.hxx> // for cTokenSeperator
56cdf0e10cSrcweir #include "unotbl.hxx"
57cdf0e10cSrcweir #include "xmltexte.hxx"
58cdf0e10cSrcweir #include "xmlexp.hxx"
59cdf0e10cSrcweir
60cdf0e10cSrcweir
61cdf0e10cSrcweir using ::rtl::OUString;
62cdf0e10cSrcweir using ::rtl::OUStringBuffer;
63cdf0e10cSrcweir using namespace ::com::sun::star;
64cdf0e10cSrcweir using namespace ::com::sun::star::uno;
65cdf0e10cSrcweir using namespace ::com::sun::star::text;
66cdf0e10cSrcweir using namespace ::com::sun::star::beans;
67cdf0e10cSrcweir using namespace ::com::sun::star::lang;
68cdf0e10cSrcweir using namespace ::com::sun::star::container;
69cdf0e10cSrcweir using namespace ::xmloff::token;
70cdf0e10cSrcweir using table::XCell;
71cdf0e10cSrcweir
72cdf0e10cSrcweir
73cdf0e10cSrcweir class SwXMLTableColumn_Impl : public SwWriteTableCol
74cdf0e10cSrcweir {
75cdf0e10cSrcweir OUString sStyleName;
76cdf0e10cSrcweir sal_uInt32 nRelWidth;
77cdf0e10cSrcweir
78cdf0e10cSrcweir public:
79cdf0e10cSrcweir
80cdf0e10cSrcweir
SwXMLTableColumn_Impl(sal_uInt32 nPosition)81cdf0e10cSrcweir SwXMLTableColumn_Impl( sal_uInt32 nPosition ) :
82cdf0e10cSrcweir SwWriteTableCol( nPosition ),
83cdf0e10cSrcweir nRelWidth( 0UL )
84cdf0e10cSrcweir {};
85cdf0e10cSrcweir
SetStyleName(const OUString & rName)86cdf0e10cSrcweir void SetStyleName( const OUString& rName ) { sStyleName = rName; }
GetStyleName() const87cdf0e10cSrcweir const OUString& GetStyleName() const { return sStyleName; }
88cdf0e10cSrcweir
SetRelWidth(sal_uInt32 nSet)89cdf0e10cSrcweir void SetRelWidth( sal_uInt32 nSet ) { nRelWidth = nSet; }
GetRelWidth() const90cdf0e10cSrcweir sal_uInt32 GetRelWidth() const { return nRelWidth; }
91cdf0e10cSrcweir };
92cdf0e10cSrcweir
SwXMLTableColumnCmpWidth_Impl(const SwXMLTableColumn_Impl & r1,const SwXMLTableColumn_Impl & r2)93cdf0e10cSrcweir sal_Int32 SwXMLTableColumnCmpWidth_Impl( const SwXMLTableColumn_Impl& r1,
94cdf0e10cSrcweir const SwXMLTableColumn_Impl& r2 )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir sal_Int32 n = (sal_Int32)r1.GetWidthOpt() - (sal_Int32)r2.GetWidthOpt();
97cdf0e10cSrcweir if( !n )
98cdf0e10cSrcweir n = (sal_Int32)r1.GetRelWidth() - (sal_Int32)r2.GetRelWidth();
99cdf0e10cSrcweir return n;
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
102cdf0e10cSrcweir // ---------------------------------------------------------------------
103cdf0e10cSrcweir
104cdf0e10cSrcweir typedef SwXMLTableColumn_Impl *SwXMLTableColumnPtr;
105cdf0e10cSrcweir SV_DECL_PTRARR_SORT_DEL( SwXMLTableColumns_Impl, SwXMLTableColumnPtr, 5, 5 )
106cdf0e10cSrcweir SV_IMPL_OP_PTRARR_SORT( SwXMLTableColumns_Impl, SwXMLTableColumnPtr )
107cdf0e10cSrcweir
108cdf0e10cSrcweir DECLARE_CONTAINER_SORT( SwXMLTableColumnsSortByWidth_Impl,
109cdf0e10cSrcweir SwXMLTableColumn_Impl )
110cdf0e10cSrcweir IMPL_CONTAINER_SORT( SwXMLTableColumnsSortByWidth_Impl, SwXMLTableColumn_Impl,
111cdf0e10cSrcweir SwXMLTableColumnCmpWidth_Impl )
112cdf0e10cSrcweir
113cdf0e10cSrcweir class SwXMLTableLines_Impl
114cdf0e10cSrcweir {
115cdf0e10cSrcweir SwXMLTableColumns_Impl aCols;
116cdf0e10cSrcweir const SwTableLines *pLines;
117cdf0e10cSrcweir sal_uInt32 nWidth;
118cdf0e10cSrcweir
119cdf0e10cSrcweir public:
120cdf0e10cSrcweir
121cdf0e10cSrcweir SwXMLTableLines_Impl( const SwTableLines& rLines );
122cdf0e10cSrcweir
~SwXMLTableLines_Impl()123cdf0e10cSrcweir ~SwXMLTableLines_Impl() {}
124cdf0e10cSrcweir
GetWidth() const125cdf0e10cSrcweir sal_uInt32 GetWidth() const { return nWidth; }
GetLines() const126cdf0e10cSrcweir const SwTableLines *GetLines() const { return pLines; }
127cdf0e10cSrcweir
GetColumns() const128cdf0e10cSrcweir const SwXMLTableColumns_Impl& GetColumns() const { return aCols; }
129cdf0e10cSrcweir };
130cdf0e10cSrcweir
SwXMLTableLines_Impl(const SwTableLines & rLines)131cdf0e10cSrcweir SwXMLTableLines_Impl::SwXMLTableLines_Impl( const SwTableLines& rLines ) :
132cdf0e10cSrcweir pLines( &rLines ),
133cdf0e10cSrcweir nWidth( 0UL )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir #ifdef DBG_UTIL
136cdf0e10cSrcweir sal_uInt32 nEndCPos = 0U;
137cdf0e10cSrcweir #endif
138cdf0e10cSrcweir sal_uInt16 nLines = rLines.Count();
139cdf0e10cSrcweir sal_uInt16 nLine;
140cdf0e10cSrcweir for( nLine=0U; nLine<nLines; nLine++ )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir const SwTableLine *pLine = rLines[nLine];
143cdf0e10cSrcweir const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
144cdf0e10cSrcweir sal_uInt16 nBoxes = rBoxes.Count();
145cdf0e10cSrcweir
146cdf0e10cSrcweir sal_uInt32 nCPos = 0U;
147cdf0e10cSrcweir for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir const SwTableBox *pBox = rBoxes[nBox];
150cdf0e10cSrcweir
151cdf0e10cSrcweir if( nBox < nBoxes-1U || nWidth==0UL )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir nCPos = nCPos + SwWriteTable::GetBoxWidth( pBox );
154cdf0e10cSrcweir SwXMLTableColumn_Impl *pCol =
155cdf0e10cSrcweir new SwXMLTableColumn_Impl( nCPos );
156cdf0e10cSrcweir
157cdf0e10cSrcweir if( !aCols.Insert( pCol ) )
158cdf0e10cSrcweir delete pCol;
159cdf0e10cSrcweir
160cdf0e10cSrcweir if( nBox==nBoxes-1U )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir ASSERT( nLine==0U && nWidth==0UL,
163cdf0e10cSrcweir "parent width will be lost" );
164cdf0e10cSrcweir nWidth = nCPos;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir }
167cdf0e10cSrcweir else
168cdf0e10cSrcweir {
169cdf0e10cSrcweir #ifdef DBG_UTIL
170cdf0e10cSrcweir sal_uInt32 nCheckPos =
171cdf0e10cSrcweir nCPos + SwWriteTable::GetBoxWidth( pBox );
172cdf0e10cSrcweir if( !nEndCPos )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir nEndCPos = nCheckPos;
175cdf0e10cSrcweir }
176cdf0e10cSrcweir else
177cdf0e10cSrcweir {
178cdf0e10cSrcweir /*
179cdf0e10cSrcweir ASSERT( SwXMLTableColumn_impl(nCheckPos) ==
180cdf0e10cSrcweir SwXMLTableColumn_Impl(nEndCPos),
181cdf0e10cSrcweir "rows have different total widths" );
182cdf0e10cSrcweir */
183cdf0e10cSrcweir }
184cdf0e10cSrcweir #endif
185cdf0e10cSrcweir nCPos = nWidth;
186cdf0e10cSrcweir #ifdef DBG_UTIL
187cdf0e10cSrcweir SwXMLTableColumn_Impl aCol( nWidth );
188cdf0e10cSrcweir ASSERT( aCols.Seek_Entry(&aCol), "couldn't find last column" );
189cdf0e10cSrcweir ASSERT( SwXMLTableColumn_Impl(nCheckPos) ==
190cdf0e10cSrcweir SwXMLTableColumn_Impl(nCPos),
191cdf0e10cSrcweir "rows have different total widths" );
192cdf0e10cSrcweir #endif
193cdf0e10cSrcweir }
194cdf0e10cSrcweir }
195cdf0e10cSrcweir }
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
198cdf0e10cSrcweir typedef SwXMLTableLines_Impl *SwXMLTableLinesPtr;
199cdf0e10cSrcweir DECLARE_LIST( SwXMLTableLinesCache_Impl, SwXMLTableLinesPtr )
200cdf0e10cSrcweir
201cdf0e10cSrcweir // ---------------------------------------------------------------------
202cdf0e10cSrcweir
203cdf0e10cSrcweir typedef SwFrmFmt *SwFrmFmtPtr;
204cdf0e10cSrcweir DECLARE_LIST( SwXMLFrmFmts_Impl, SwFrmFmtPtr )
205cdf0e10cSrcweir
206cdf0e10cSrcweir class SwXMLTableFrmFmtsSort_Impl : public SwXMLFrmFmts_Impl
207cdf0e10cSrcweir {
208cdf0e10cSrcweir public:
SwXMLTableFrmFmtsSort_Impl(sal_uInt16 nInit,sal_uInt16 nGrow)209cdf0e10cSrcweir SwXMLTableFrmFmtsSort_Impl ( sal_uInt16 nInit, sal_uInt16 nGrow ) :
210cdf0e10cSrcweir SwXMLFrmFmts_Impl( nInit, nGrow )
211cdf0e10cSrcweir {}
212cdf0e10cSrcweir
213cdf0e10cSrcweir sal_Bool AddRow( SwFrmFmt& rFrmFmt, const OUString& rNamePrefix, sal_uInt32 nLine );
214cdf0e10cSrcweir sal_Bool AddCell( SwFrmFmt& rFrmFmt, const OUString& rNamePrefix,
215cdf0e10cSrcweir sal_uInt32 nCol, sal_uInt32 nRow, sal_Bool bTop );
216cdf0e10cSrcweir };
217cdf0e10cSrcweir
AddRow(SwFrmFmt & rFrmFmt,const OUString & rNamePrefix,sal_uInt32 nLine)218cdf0e10cSrcweir sal_Bool SwXMLTableFrmFmtsSort_Impl::AddRow( SwFrmFmt& rFrmFmt,
219cdf0e10cSrcweir const OUString& rNamePrefix,
220cdf0e10cSrcweir sal_uInt32 nLine )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir const SwFmtFrmSize *pFrmSize = 0;
223cdf0e10cSrcweir const SwFmtRowSplit* pRowSplit = 0;
224cdf0e10cSrcweir const SvxBrushItem *pBrush = 0;
225cdf0e10cSrcweir
226cdf0e10cSrcweir const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
227cdf0e10cSrcweir const SfxPoolItem *pItem;
228cdf0e10cSrcweir if( SFX_ITEM_SET == rItemSet.GetItemState( RES_FRM_SIZE, sal_False, &pItem ) )
229cdf0e10cSrcweir pFrmSize = (const SwFmtFrmSize *)pItem;
230cdf0e10cSrcweir
231cdf0e10cSrcweir if( SFX_ITEM_SET == rItemSet.GetItemState( RES_ROW_SPLIT, sal_False, &pItem ) )
232cdf0e10cSrcweir pRowSplit = (const SwFmtRowSplit *)pItem;
233cdf0e10cSrcweir
234cdf0e10cSrcweir if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, sal_False, &pItem ) )
235cdf0e10cSrcweir pBrush = (const SvxBrushItem *)pItem;
236cdf0e10cSrcweir
237cdf0e10cSrcweir // empty styles have not to be exported
238cdf0e10cSrcweir if( !pFrmSize && !pBrush && !pRowSplit )
239cdf0e10cSrcweir return sal_False;
240cdf0e10cSrcweir
241cdf0e10cSrcweir // order is: -/brush, size/-, size/brush
242cdf0e10cSrcweir sal_uInt32 nCount2 = Count();
243cdf0e10cSrcweir sal_Bool bInsert = sal_True;
244cdf0e10cSrcweir sal_uInt32 i;
245cdf0e10cSrcweir for( i = 0; i < nCount2; ++i )
246cdf0e10cSrcweir {
247cdf0e10cSrcweir const SwFmtFrmSize *pTestFrmSize = 0;
248cdf0e10cSrcweir const SwFmtRowSplit* pTestRowSplit = 0;
249cdf0e10cSrcweir const SvxBrushItem *pTestBrush = 0;
250cdf0e10cSrcweir const SwFrmFmt *pTestFmt = GetObject(i);
251cdf0e10cSrcweir const SfxItemSet& rTestSet = pTestFmt->GetAttrSet();
252cdf0e10cSrcweir if( SFX_ITEM_SET == rTestSet.GetItemState( RES_FRM_SIZE, sal_False,
253cdf0e10cSrcweir &pItem ) )
254cdf0e10cSrcweir {
255cdf0e10cSrcweir if( !pFrmSize )
256cdf0e10cSrcweir break;
257cdf0e10cSrcweir
258cdf0e10cSrcweir pTestFrmSize = (const SwFmtFrmSize *)pItem;
259cdf0e10cSrcweir }
260cdf0e10cSrcweir else
261cdf0e10cSrcweir {
262cdf0e10cSrcweir if( pFrmSize )
263cdf0e10cSrcweir continue;
264cdf0e10cSrcweir }
265cdf0e10cSrcweir
266cdf0e10cSrcweir if( SFX_ITEM_SET == rTestSet.GetItemState( RES_BACKGROUND, sal_False,
267cdf0e10cSrcweir &pItem ) )
268cdf0e10cSrcweir {
269cdf0e10cSrcweir if( !pBrush )
270cdf0e10cSrcweir break;
271cdf0e10cSrcweir
272cdf0e10cSrcweir pTestBrush = (const SvxBrushItem *)pItem;
273cdf0e10cSrcweir }
274cdf0e10cSrcweir else
275cdf0e10cSrcweir {
276cdf0e10cSrcweir if( pBrush )
277cdf0e10cSrcweir continue;
278cdf0e10cSrcweir }
279cdf0e10cSrcweir
280cdf0e10cSrcweir if( SFX_ITEM_SET == rTestSet.GetItemState( RES_ROW_SPLIT, sal_False,
281cdf0e10cSrcweir &pItem ) )
282cdf0e10cSrcweir {
283cdf0e10cSrcweir if( !pRowSplit )
284cdf0e10cSrcweir break;
285cdf0e10cSrcweir
286cdf0e10cSrcweir pTestRowSplit = (const SwFmtRowSplit *)pItem;
287cdf0e10cSrcweir }
288cdf0e10cSrcweir else
289cdf0e10cSrcweir {
290cdf0e10cSrcweir if( pRowSplit )
291cdf0e10cSrcweir continue;
292cdf0e10cSrcweir }
293cdf0e10cSrcweir
294cdf0e10cSrcweir
295cdf0e10cSrcweir if( pFrmSize &&
296cdf0e10cSrcweir ( pFrmSize->GetHeightSizeType() != pTestFrmSize->GetHeightSizeType() ||
297cdf0e10cSrcweir pFrmSize->GetHeight() != pTestFrmSize->GetHeight() ) )
298cdf0e10cSrcweir continue;
299cdf0e10cSrcweir
300cdf0e10cSrcweir if( pBrush && (*pBrush != *pTestBrush) )
301cdf0e10cSrcweir continue;
302cdf0e10cSrcweir
303cdf0e10cSrcweir if( pRowSplit && (!pRowSplit->GetValue() != !pTestRowSplit->GetValue()) )
304cdf0e10cSrcweir continue;
305cdf0e10cSrcweir
306cdf0e10cSrcweir // found!
307cdf0e10cSrcweir const String& rFmtName = pTestFmt->GetName();
308cdf0e10cSrcweir rFrmFmt.SetName( rFmtName );
309cdf0e10cSrcweir bInsert = sal_False;
310cdf0e10cSrcweir break;
311cdf0e10cSrcweir }
312cdf0e10cSrcweir
313cdf0e10cSrcweir if( bInsert )
314cdf0e10cSrcweir {
315cdf0e10cSrcweir OUStringBuffer sBuffer( rNamePrefix.getLength() + 4UL );
316cdf0e10cSrcweir sBuffer.append( rNamePrefix );
317cdf0e10cSrcweir sBuffer.append( (sal_Unicode)'.' );
318cdf0e10cSrcweir sBuffer.append( (sal_Int32)(nLine+1UL) );
319cdf0e10cSrcweir
320cdf0e10cSrcweir rFrmFmt.SetName( sBuffer.makeStringAndClear() );
321cdf0e10cSrcweir Insert( &rFrmFmt, i );
322cdf0e10cSrcweir }
323cdf0e10cSrcweir
324cdf0e10cSrcweir return bInsert;
325cdf0e10cSrcweir }
326cdf0e10cSrcweir
327cdf0e10cSrcweir void lcl_GetTblBoxColStr( sal_uInt16 nCol, String& rNm );
lcl_xmltble_appendBoxPrefix(OUStringBuffer & rBuffer,const OUString & rNamePrefix,sal_uInt32 nCol,sal_uInt32 nRow,sal_Bool bTop)328cdf0e10cSrcweir void lcl_xmltble_appendBoxPrefix( OUStringBuffer& rBuffer,
329cdf0e10cSrcweir const OUString& rNamePrefix,
330cdf0e10cSrcweir sal_uInt32 nCol, sal_uInt32 nRow, sal_Bool bTop )
331cdf0e10cSrcweir {
332cdf0e10cSrcweir rBuffer.append( rNamePrefix );
333cdf0e10cSrcweir rBuffer.append( (sal_Unicode)'.' );
334cdf0e10cSrcweir if( bTop )
335cdf0e10cSrcweir {
336cdf0e10cSrcweir String sTmp;
337cdf0e10cSrcweir lcl_GetTblBoxColStr( (sal_uInt16)nCol, sTmp );
338cdf0e10cSrcweir rBuffer.append( sTmp );
339cdf0e10cSrcweir }
340cdf0e10cSrcweir else
341cdf0e10cSrcweir {
342cdf0e10cSrcweir rBuffer.append( (sal_Int32)(nCol + 1));
343cdf0e10cSrcweir rBuffer.append( (sal_Unicode)'.' );
344cdf0e10cSrcweir }
345cdf0e10cSrcweir rBuffer.append( (sal_Int32)(nRow + 1));
346cdf0e10cSrcweir }
347cdf0e10cSrcweir
AddCell(SwFrmFmt & rFrmFmt,const OUString & rNamePrefix,sal_uInt32 nCol,sal_uInt32 nRow,sal_Bool bTop)348cdf0e10cSrcweir sal_Bool SwXMLTableFrmFmtsSort_Impl::AddCell( SwFrmFmt& rFrmFmt,
349cdf0e10cSrcweir const OUString& rNamePrefix,
350cdf0e10cSrcweir sal_uInt32 nCol, sal_uInt32 nRow, sal_Bool bTop )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir const SwFmtVertOrient *pVertOrient = 0;
353cdf0e10cSrcweir const SvxBrushItem *pBrush = 0;
354cdf0e10cSrcweir const SvxBoxItem *pBox = 0;
355cdf0e10cSrcweir const SwTblBoxNumFormat *pNumFmt = 0;
356cdf0e10cSrcweir const SvxFrameDirectionItem *pFrameDir = 0;
357cdf0e10cSrcweir
358cdf0e10cSrcweir const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
359cdf0e10cSrcweir const SfxPoolItem *pItem;
360cdf0e10cSrcweir if( SFX_ITEM_SET == rItemSet.GetItemState( RES_VERT_ORIENT, sal_False,
361cdf0e10cSrcweir &pItem ) )
362cdf0e10cSrcweir pVertOrient = (const SwFmtVertOrient *)pItem;
363cdf0e10cSrcweir
364cdf0e10cSrcweir if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, sal_False, &pItem ) )
365cdf0e10cSrcweir pBrush = (const SvxBrushItem *)pItem;
366cdf0e10cSrcweir
367cdf0e10cSrcweir if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BOX, sal_False, &pItem ) )
368cdf0e10cSrcweir pBox = (const SvxBoxItem *)pItem;
369cdf0e10cSrcweir
370cdf0e10cSrcweir if ( SFX_ITEM_SET == rItemSet.GetItemState( RES_BOXATR_FORMAT,
371cdf0e10cSrcweir sal_False, &pItem ) )
372cdf0e10cSrcweir pNumFmt = (const SwTblBoxNumFormat *)pItem;
373cdf0e10cSrcweir if ( SFX_ITEM_SET == rItemSet.GetItemState( RES_FRAMEDIR,
374cdf0e10cSrcweir sal_False, &pItem ) )
375cdf0e10cSrcweir pFrameDir = (const SvxFrameDirectionItem *)pItem;
376cdf0e10cSrcweir
377cdf0e10cSrcweir // empty styles have not to be exported
378cdf0e10cSrcweir if( !pVertOrient && !pBrush && !pBox && !pNumFmt && !pFrameDir )
379cdf0e10cSrcweir return sal_False;
380cdf0e10cSrcweir
381cdf0e10cSrcweir // order is: -/-/-/num,
382cdf0e10cSrcweir // -/-/box/-, --/-/box/num,
383cdf0e10cSrcweir // -/brush/-/-, -/brush/-/num, -/brush/box/-, -/brush/box/num,
384cdf0e10cSrcweir // vert/-/-/-, vert/-/-/num, vert/-/box/-, ver/-/box/num,
385cdf0e10cSrcweir // vert/brush/-/-, vert/brush/-/num, vert/brush/box/-,
386cdf0e10cSrcweir // vert/brush/box/num
387cdf0e10cSrcweir sal_uInt32 nCount2 = Count();
388cdf0e10cSrcweir sal_Bool bInsert = sal_True;
389cdf0e10cSrcweir sal_uInt32 i;
390cdf0e10cSrcweir for( i = 0; i < nCount2; ++i )
391cdf0e10cSrcweir {
392cdf0e10cSrcweir const SwFmtVertOrient *pTestVertOrient = 0;
393cdf0e10cSrcweir const SvxBrushItem *pTestBrush = 0;
394cdf0e10cSrcweir const SvxBoxItem *pTestBox = 0;
395cdf0e10cSrcweir const SwTblBoxNumFormat *pTestNumFmt = 0;
396cdf0e10cSrcweir const SvxFrameDirectionItem *pTestFrameDir = 0;
397cdf0e10cSrcweir const SwFrmFmt *pTestFmt = GetObject(i);
398cdf0e10cSrcweir const SfxItemSet& rTestSet = pTestFmt->GetAttrSet();
399cdf0e10cSrcweir if( SFX_ITEM_SET == rTestSet.GetItemState( RES_VERT_ORIENT, sal_False,
400cdf0e10cSrcweir &pItem ) )
401cdf0e10cSrcweir {
402cdf0e10cSrcweir if( !pVertOrient )
403cdf0e10cSrcweir break;
404cdf0e10cSrcweir
405cdf0e10cSrcweir pTestVertOrient = (const SwFmtVertOrient *)pItem;
406cdf0e10cSrcweir }
407cdf0e10cSrcweir else
408cdf0e10cSrcweir {
409cdf0e10cSrcweir if( pVertOrient )
410cdf0e10cSrcweir continue;
411cdf0e10cSrcweir }
412cdf0e10cSrcweir
413cdf0e10cSrcweir if( SFX_ITEM_SET == rTestSet.GetItemState( RES_BACKGROUND, sal_False,
414cdf0e10cSrcweir &pItem ) )
415cdf0e10cSrcweir {
416cdf0e10cSrcweir if( !pBrush )
417cdf0e10cSrcweir break;
418cdf0e10cSrcweir
419cdf0e10cSrcweir pTestBrush = (const SvxBrushItem *)pItem;
420cdf0e10cSrcweir }
421cdf0e10cSrcweir else
422cdf0e10cSrcweir {
423cdf0e10cSrcweir if( pBrush )
424cdf0e10cSrcweir continue;
425cdf0e10cSrcweir }
426cdf0e10cSrcweir
427cdf0e10cSrcweir if( SFX_ITEM_SET == rTestSet.GetItemState( RES_BOX, sal_False, &pItem ) )
428cdf0e10cSrcweir {
429cdf0e10cSrcweir if( !pBox )
430cdf0e10cSrcweir break;
431cdf0e10cSrcweir
432cdf0e10cSrcweir pTestBox = (const SvxBoxItem *)pItem;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir else
435cdf0e10cSrcweir {
436cdf0e10cSrcweir if( pBox )
437cdf0e10cSrcweir continue;
438cdf0e10cSrcweir }
439cdf0e10cSrcweir
440cdf0e10cSrcweir if ( SFX_ITEM_SET == rTestSet.GetItemState( RES_BOXATR_FORMAT,
441cdf0e10cSrcweir sal_False, &pItem ) )
442cdf0e10cSrcweir {
443cdf0e10cSrcweir if( !pNumFmt )
444cdf0e10cSrcweir break;
445cdf0e10cSrcweir
446cdf0e10cSrcweir pTestNumFmt = (const SwTblBoxNumFormat *)pItem;
447cdf0e10cSrcweir }
448cdf0e10cSrcweir else
449cdf0e10cSrcweir {
450cdf0e10cSrcweir if( pNumFmt )
451cdf0e10cSrcweir continue;
452cdf0e10cSrcweir
453cdf0e10cSrcweir }
454cdf0e10cSrcweir
455cdf0e10cSrcweir if ( SFX_ITEM_SET == rTestSet.GetItemState( RES_FRAMEDIR,
456cdf0e10cSrcweir sal_False, &pItem ) )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir if( !pFrameDir )
459cdf0e10cSrcweir break;
460cdf0e10cSrcweir
461cdf0e10cSrcweir pTestFrameDir = (const SvxFrameDirectionItem *)pItem;
462cdf0e10cSrcweir }
463cdf0e10cSrcweir else
464cdf0e10cSrcweir {
465cdf0e10cSrcweir if( pFrameDir )
466cdf0e10cSrcweir continue;
467cdf0e10cSrcweir
468cdf0e10cSrcweir }
469cdf0e10cSrcweir
470cdf0e10cSrcweir if( pVertOrient &&
471cdf0e10cSrcweir pVertOrient->GetVertOrient() != pTestVertOrient->GetVertOrient() )
472cdf0e10cSrcweir continue;
473cdf0e10cSrcweir
474cdf0e10cSrcweir if( pBrush && ( *pBrush != *pTestBrush ) )
475cdf0e10cSrcweir continue;
476cdf0e10cSrcweir
477cdf0e10cSrcweir if( pBox && ( *pBox != *pTestBox ) )
478cdf0e10cSrcweir continue;
479cdf0e10cSrcweir
480cdf0e10cSrcweir if( pNumFmt && pNumFmt->GetValue() != pTestNumFmt->GetValue() )
481cdf0e10cSrcweir continue;
482cdf0e10cSrcweir
483cdf0e10cSrcweir if( pFrameDir && pFrameDir->GetValue() != pTestFrameDir->GetValue() )
484cdf0e10cSrcweir continue;
485cdf0e10cSrcweir
486cdf0e10cSrcweir // found!
487cdf0e10cSrcweir const String& rFmtName = pTestFmt->GetName();
488cdf0e10cSrcweir rFrmFmt.SetName( rFmtName );
489cdf0e10cSrcweir bInsert = sal_False;
490cdf0e10cSrcweir break;
491cdf0e10cSrcweir }
492cdf0e10cSrcweir
493cdf0e10cSrcweir if( bInsert )
494cdf0e10cSrcweir {
495cdf0e10cSrcweir OUStringBuffer sBuffer( rNamePrefix.getLength() + 8UL );
496cdf0e10cSrcweir lcl_xmltble_appendBoxPrefix( sBuffer, rNamePrefix, nCol, nRow, bTop );
497cdf0e10cSrcweir rFrmFmt.SetName( sBuffer.makeStringAndClear() );
498cdf0e10cSrcweir Insert( &rFrmFmt, i );
499cdf0e10cSrcweir }
500cdf0e10cSrcweir
501cdf0e10cSrcweir return bInsert;
502cdf0e10cSrcweir }
503cdf0e10cSrcweir // ---------------------------------------------------------------------
504cdf0e10cSrcweir
505cdf0e10cSrcweir class SwXMLTableInfo_Impl
506cdf0e10cSrcweir {
507cdf0e10cSrcweir const SwTable *pTable;
508cdf0e10cSrcweir Reference < XTextSection > xBaseSection;
509cdf0e10cSrcweir sal_Bool bBaseSectionValid;
510cdf0e10cSrcweir
511cdf0e10cSrcweir public:
512cdf0e10cSrcweir
513cdf0e10cSrcweir inline SwXMLTableInfo_Impl( const SwTable *pTbl );
514cdf0e10cSrcweir
GetTable() const515cdf0e10cSrcweir const SwTable *GetTable() const { return pTable; }
GetTblFmt() const516cdf0e10cSrcweir const SwFrmFmt *GetTblFmt() const { return pTable->GetFrmFmt(); }
517cdf0e10cSrcweir
IsBaseSectionValid() const518cdf0e10cSrcweir sal_Bool IsBaseSectionValid() const { return bBaseSectionValid; }
GetBaseSection() const519cdf0e10cSrcweir const Reference < XTextSection >& GetBaseSection() const { return xBaseSection; }
520cdf0e10cSrcweir inline void SetBaseSection( const Reference < XTextSection >& rBase );
521cdf0e10cSrcweir };
522cdf0e10cSrcweir
SwXMLTableInfo_Impl(const SwTable * pTbl)523cdf0e10cSrcweir inline SwXMLTableInfo_Impl::SwXMLTableInfo_Impl( const SwTable *pTbl ) :
524cdf0e10cSrcweir pTable( pTbl ),
525cdf0e10cSrcweir bBaseSectionValid( sal_False )
526cdf0e10cSrcweir {
527cdf0e10cSrcweir }
528cdf0e10cSrcweir
SetBaseSection(const Reference<XTextSection> & rBaseSection)529cdf0e10cSrcweir inline void SwXMLTableInfo_Impl::SetBaseSection(
530cdf0e10cSrcweir const Reference < XTextSection >& rBaseSection )
531cdf0e10cSrcweir {
532cdf0e10cSrcweir xBaseSection = rBaseSection;
533cdf0e10cSrcweir bBaseSectionValid = sal_True;
534cdf0e10cSrcweir }
535cdf0e10cSrcweir
536cdf0e10cSrcweir // ---------------------------------------------------------------------
537cdf0e10cSrcweir
538cdf0e10cSrcweir
ExportTableColumnStyle(const SwXMLTableColumn_Impl & rCol)539cdf0e10cSrcweir void SwXMLExport::ExportTableColumnStyle( const SwXMLTableColumn_Impl& rCol )
540cdf0e10cSrcweir {
541cdf0e10cSrcweir // <style:style ...>
542cdf0e10cSrcweir CheckAttrList();
543cdf0e10cSrcweir
544cdf0e10cSrcweir // style:name="..."
545cdf0e10cSrcweir sal_Bool bEncoded = sal_False;
546cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_STYLE, XML_NAME,
547cdf0e10cSrcweir EncodeStyleName( rCol.GetStyleName(), &bEncoded ) );
548cdf0e10cSrcweir if( bEncoded )
549cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, rCol.GetStyleName() );
550cdf0e10cSrcweir
551cdf0e10cSrcweir // style:family="table-column"
552cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_STYLE, XML_FAMILY, XML_TABLE_COLUMN );
553cdf0e10cSrcweir
554cdf0e10cSrcweir {
555cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, XML_STYLE, sal_True,
556cdf0e10cSrcweir sal_True );
557cdf0e10cSrcweir OUStringBuffer sValue;
558cdf0e10cSrcweir if( rCol.GetWidthOpt() )
559cdf0e10cSrcweir {
560cdf0e10cSrcweir GetTwipUnitConverter().convertMeasure( sValue, rCol.GetWidthOpt() );
561cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_STYLE, XML_COLUMN_WIDTH,
562cdf0e10cSrcweir sValue.makeStringAndClear() );
563cdf0e10cSrcweir }
564cdf0e10cSrcweir if( rCol.GetRelWidth() )
565cdf0e10cSrcweir {
566cdf0e10cSrcweir sValue.append( (sal_Int32)rCol.GetRelWidth() );
567cdf0e10cSrcweir sValue.append( (sal_Unicode)'*' );
568cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_STYLE, XML_REL_COLUMN_WIDTH,
569cdf0e10cSrcweir sValue.makeStringAndClear() );
570cdf0e10cSrcweir }
571cdf0e10cSrcweir
572cdf0e10cSrcweir {
573cdf0e10cSrcweir SvXMLElementExport aElemExport( *this, XML_NAMESPACE_STYLE,
574cdf0e10cSrcweir XML_TABLE_COLUMN_PROPERTIES,
575cdf0e10cSrcweir sal_True, sal_True );
576cdf0e10cSrcweir }
577cdf0e10cSrcweir }
578cdf0e10cSrcweir }
579cdf0e10cSrcweir
ExportTableLinesAutoStyles(const SwTableLines & rLines,sal_uInt32 nAbsWidth,sal_uInt32 nBaseWidth,const OUString & rNamePrefix,SwXMLTableColumnsSortByWidth_Impl & rExpCols,SwXMLTableFrmFmtsSort_Impl & rExpRows,SwXMLTableFrmFmtsSort_Impl & rExpCells,SwXMLTableInfo_Impl & rTblInfo,sal_Bool bTop)580cdf0e10cSrcweir void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
581cdf0e10cSrcweir sal_uInt32 nAbsWidth, sal_uInt32 nBaseWidth,
582cdf0e10cSrcweir const OUString& rNamePrefix,
583cdf0e10cSrcweir SwXMLTableColumnsSortByWidth_Impl& rExpCols,
584cdf0e10cSrcweir SwXMLTableFrmFmtsSort_Impl& rExpRows,
585cdf0e10cSrcweir SwXMLTableFrmFmtsSort_Impl& rExpCells,
586cdf0e10cSrcweir SwXMLTableInfo_Impl& rTblInfo,
587cdf0e10cSrcweir sal_Bool bTop )
588cdf0e10cSrcweir {
589cdf0e10cSrcweir // pass 1: calculate columns
590cdf0e10cSrcweir SwXMLTableLines_Impl *pLines =
591cdf0e10cSrcweir new SwXMLTableLines_Impl( rLines );
592cdf0e10cSrcweir if( !pTableLines )
593cdf0e10cSrcweir pTableLines = new SwXMLTableLinesCache_Impl( 5, 5 );
594cdf0e10cSrcweir pTableLines->Insert( pLines, pTableLines->Count() );
595cdf0e10cSrcweir
596cdf0e10cSrcweir OUStringBuffer sBuffer( rNamePrefix.getLength() + 8L );
597cdf0e10cSrcweir
598cdf0e10cSrcweir // pass 2: export column styles
599cdf0e10cSrcweir {
600cdf0e10cSrcweir const SwXMLTableColumns_Impl& rCols = pLines->GetColumns();
601cdf0e10cSrcweir sal_uInt32 nCPos = 0U;
602cdf0e10cSrcweir sal_uInt16 nColumns = rCols.Count();
603cdf0e10cSrcweir for( sal_uInt16 nColumn=0U; nColumn<nColumns; nColumn++ )
604cdf0e10cSrcweir {
605cdf0e10cSrcweir SwXMLTableColumn_Impl *pColumn = rCols[nColumn];
606cdf0e10cSrcweir
607cdf0e10cSrcweir sal_uInt32 nOldCPos = nCPos;
608cdf0e10cSrcweir nCPos = pColumn->GetPos();
609cdf0e10cSrcweir
610cdf0e10cSrcweir sal_uInt32 nWidth = nCPos - nOldCPos;
611cdf0e10cSrcweir
612cdf0e10cSrcweir // If a base width is given, the table has either an automatic
613cdf0e10cSrcweir // or margin alignment, or an percentage width. In either case,
614cdf0e10cSrcweir // relative widths should be exported.
615cdf0e10cSrcweir if( nBaseWidth )
616cdf0e10cSrcweir {
617cdf0e10cSrcweir pColumn->SetRelWidth( nWidth );
618cdf0e10cSrcweir }
619cdf0e10cSrcweir
620cdf0e10cSrcweir // If an absolute width is given, the table either has a fixed
621cdf0e10cSrcweir // width, or the current width is known from the layout. In the
622cdf0e10cSrcweir // later case, a base width is set in addition and must be used
623cdf0e10cSrcweir // to "absoultize" the relative column width.
624cdf0e10cSrcweir if( nAbsWidth )
625cdf0e10cSrcweir {
626cdf0e10cSrcweir sal_uInt32 nColAbsWidth = nWidth;
627cdf0e10cSrcweir if( nBaseWidth )
628cdf0e10cSrcweir {
629cdf0e10cSrcweir nColAbsWidth *= nAbsWidth;
630cdf0e10cSrcweir nColAbsWidth += (nBaseWidth/2UL);
631cdf0e10cSrcweir nColAbsWidth /= nBaseWidth;
632cdf0e10cSrcweir }
633cdf0e10cSrcweir pColumn->SetWidthOpt( nColAbsWidth, sal_False );
634cdf0e10cSrcweir }
635cdf0e10cSrcweir
636cdf0e10cSrcweir sal_uLong nExpPos = 0;
637cdf0e10cSrcweir if( rExpCols.Seek_Entry( pColumn, &nExpPos ) )
638cdf0e10cSrcweir {
639cdf0e10cSrcweir pColumn->SetStyleName(
640cdf0e10cSrcweir rExpCols.GetObject(nExpPos)->GetStyleName() );
641cdf0e10cSrcweir }
642cdf0e10cSrcweir else
643cdf0e10cSrcweir {
644cdf0e10cSrcweir sBuffer.append( rNamePrefix );
645cdf0e10cSrcweir sBuffer.append( (sal_Unicode)'.' );
646cdf0e10cSrcweir if( bTop )
647cdf0e10cSrcweir {
648cdf0e10cSrcweir String sTmp;
649cdf0e10cSrcweir lcl_GetTblBoxColStr( nColumn, sTmp );
650cdf0e10cSrcweir sBuffer.append( sTmp );
651cdf0e10cSrcweir }
652cdf0e10cSrcweir else
653cdf0e10cSrcweir {
654cdf0e10cSrcweir sBuffer.append( (sal_Int32)(nColumn + 1U) );
655cdf0e10cSrcweir }
656cdf0e10cSrcweir
657cdf0e10cSrcweir pColumn->SetStyleName( sBuffer.makeStringAndClear() );
658cdf0e10cSrcweir ExportTableColumnStyle( *pColumn );
659cdf0e10cSrcweir rExpCols.Insert( pColumn );
660cdf0e10cSrcweir }
661cdf0e10cSrcweir }
662cdf0e10cSrcweir }
663cdf0e10cSrcweir
664cdf0e10cSrcweir // pass 3: export line/rows
665cdf0e10cSrcweir sal_uInt16 nLines = rLines.Count();
666cdf0e10cSrcweir for( sal_uInt16 nLine=0U; nLine<nLines; nLine++ )
667cdf0e10cSrcweir {
668cdf0e10cSrcweir SwTableLine *pLine = rLines[nLine];
669cdf0e10cSrcweir
670cdf0e10cSrcweir SwFrmFmt *pFrmFmt = pLine->GetFrmFmt();
671cdf0e10cSrcweir if( rExpRows.AddRow( *pFrmFmt, rNamePrefix, nLine ) )
672cdf0e10cSrcweir ExportFmt( *pFrmFmt, XML_TABLE_ROW );
673cdf0e10cSrcweir
674cdf0e10cSrcweir const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
675cdf0e10cSrcweir sal_uInt16 nBoxes = rBoxes.Count();
676cdf0e10cSrcweir
677cdf0e10cSrcweir sal_uInt32 nCPos = 0U;
678cdf0e10cSrcweir sal_uInt16 nCol = 0U;
679cdf0e10cSrcweir for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
680cdf0e10cSrcweir {
681cdf0e10cSrcweir SwTableBox *pBox = rBoxes[nBox];
682cdf0e10cSrcweir
683cdf0e10cSrcweir if( nBox < nBoxes-1U )
684cdf0e10cSrcweir nCPos = nCPos + SwWriteTable::GetBoxWidth( pBox );
685cdf0e10cSrcweir else
686cdf0e10cSrcweir nCPos = pLines->GetWidth();
687cdf0e10cSrcweir
688cdf0e10cSrcweir
689cdf0e10cSrcweir // Und ihren Index
690cdf0e10cSrcweir sal_uInt16 nOldCol = nCol;
691cdf0e10cSrcweir SwXMLTableColumn_Impl aCol( nCPos );
692cdf0e10cSrcweir #ifdef DBG_UTIL
693cdf0e10cSrcweir sal_Bool bFound =
694cdf0e10cSrcweir #endif
695cdf0e10cSrcweir pLines->GetColumns().Seek_Entry( &aCol, &nCol );
696cdf0e10cSrcweir ASSERT( bFound, "couldn't find column" );
697cdf0e10cSrcweir
698cdf0e10cSrcweir const SwStartNode *pBoxSttNd = pBox->GetSttNd();
699cdf0e10cSrcweir if( pBoxSttNd )
700cdf0e10cSrcweir {
701cdf0e10cSrcweir SwFrmFmt *pFrmFmt2 = pBox->GetFrmFmt();
702cdf0e10cSrcweir if( rExpCells.AddCell( *pFrmFmt2, rNamePrefix, nOldCol, nLine,
703cdf0e10cSrcweir bTop) )
704cdf0e10cSrcweir ExportFmt( *pFrmFmt2, XML_TABLE_CELL );
705cdf0e10cSrcweir
706cdf0e10cSrcweir Reference < XCell > xCell = SwXCell::CreateXCell(
707cdf0e10cSrcweir (SwFrmFmt *)rTblInfo.GetTblFmt(),
708cdf0e10cSrcweir pBox,
709cdf0e10cSrcweir (SwTable *)rTblInfo.GetTable() );
710cdf0e10cSrcweir if (xCell.is())
711cdf0e10cSrcweir {
712cdf0e10cSrcweir Reference < XText > xText( xCell, UNO_QUERY );
713cdf0e10cSrcweir if( !rTblInfo.IsBaseSectionValid() )
714cdf0e10cSrcweir {
715cdf0e10cSrcweir Reference<XPropertySet> xCellPropertySet( xCell,
716cdf0e10cSrcweir UNO_QUERY );
717cdf0e10cSrcweir OUString sTextSection( RTL_CONSTASCII_USTRINGPARAM("TextSection") );
718cdf0e10cSrcweir Any aAny = xCellPropertySet->getPropertyValue(sTextSection);
719cdf0e10cSrcweir Reference < XTextSection > xTextSection;
720cdf0e10cSrcweir aAny >>= xTextSection;
721cdf0e10cSrcweir rTblInfo.SetBaseSection( xTextSection );
722cdf0e10cSrcweir }
723cdf0e10cSrcweir
724cdf0e10cSrcweir const bool bExportContent = (getExportFlags() & EXPORT_CONTENT ) != 0;
725cdf0e10cSrcweir if ( !bExportContent )
726cdf0e10cSrcweir {
727cdf0e10cSrcweir // AUTOSTYLES - not needed anymore if we are currently exporting content.xml
728cdf0e10cSrcweir GetTextParagraphExport()->collectTextAutoStyles(
729cdf0e10cSrcweir xText, rTblInfo.GetBaseSection(), IsShowProgress() );
730cdf0e10cSrcweir }
731cdf0e10cSrcweir }
732cdf0e10cSrcweir else {
733cdf0e10cSrcweir DBG_ERROR("here should be a XCell");
734cdf0e10cSrcweir }
735cdf0e10cSrcweir }
736cdf0e10cSrcweir else
737cdf0e10cSrcweir {
738cdf0e10cSrcweir lcl_xmltble_appendBoxPrefix( sBuffer, rNamePrefix, nOldCol,
739cdf0e10cSrcweir nLine, bTop );
740cdf0e10cSrcweir
741cdf0e10cSrcweir ExportTableLinesAutoStyles( pBox->GetTabLines(),
742cdf0e10cSrcweir nAbsWidth, nBaseWidth,
743cdf0e10cSrcweir sBuffer.makeStringAndClear(),
744cdf0e10cSrcweir rExpCols, rExpRows, rExpCells,
745cdf0e10cSrcweir rTblInfo );
746cdf0e10cSrcweir }
747cdf0e10cSrcweir
748cdf0e10cSrcweir nCol++;
749cdf0e10cSrcweir }
750cdf0e10cSrcweir }
751cdf0e10cSrcweir }
752cdf0e10cSrcweir
ExportTableAutoStyles(const SwTableNode & rTblNd)753cdf0e10cSrcweir void SwXMLExport::ExportTableAutoStyles( const SwTableNode& rTblNd )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir const SwTable& rTbl = rTblNd.GetTable();
756cdf0e10cSrcweir const SwFrmFmt *pTblFmt = rTbl.GetFrmFmt();
757cdf0e10cSrcweir
758cdf0e10cSrcweir if( pTblFmt )
759cdf0e10cSrcweir {
760cdf0e10cSrcweir sal_Int16 eTabHoriOri = pTblFmt->GetHoriOrient().GetHoriOrient();
761cdf0e10cSrcweir const SwFmtFrmSize& rFrmSize = pTblFmt->GetFrmSize();
762cdf0e10cSrcweir
763cdf0e10cSrcweir sal_uInt32 nAbsWidth = rFrmSize.GetSize().Width();
764cdf0e10cSrcweir sal_uInt32 nBaseWidth = 0UL;
765cdf0e10cSrcweir sal_Int8 nPrcWidth = rFrmSize.GetWidthPercent();
766cdf0e10cSrcweir
767cdf0e10cSrcweir sal_Bool bFixAbsWidth = nPrcWidth != 0 || /*text::*/HoriOrientation::NONE == eTabHoriOri
768cdf0e10cSrcweir || /*text::*/HoriOrientation::FULL == eTabHoriOri;
769cdf0e10cSrcweir if( bFixAbsWidth )
770cdf0e10cSrcweir {
771cdf0e10cSrcweir nBaseWidth = nAbsWidth;
772cdf0e10cSrcweir nAbsWidth = pTblFmt->FindLayoutRect(sal_True).Width();
773cdf0e10cSrcweir if( !nAbsWidth )
774cdf0e10cSrcweir {
775cdf0e10cSrcweir // TODO???
776cdf0e10cSrcweir }
777cdf0e10cSrcweir }
778cdf0e10cSrcweir ExportTableFmt( *pTblFmt, nAbsWidth );
779cdf0e10cSrcweir
780cdf0e10cSrcweir OUString sName( pTblFmt->GetName() );
781cdf0e10cSrcweir SwXMLTableColumnsSortByWidth_Impl aExpCols( 10, 10 );
782cdf0e10cSrcweir SwXMLTableFrmFmtsSort_Impl aExpRows( 10, 10 );
783cdf0e10cSrcweir SwXMLTableFrmFmtsSort_Impl aExpCells( 10, 10 );
784cdf0e10cSrcweir SwXMLTableInfo_Impl aTblInfo( &rTbl );
785cdf0e10cSrcweir ExportTableLinesAutoStyles( rTbl.GetTabLines(), nAbsWidth, nBaseWidth,
786cdf0e10cSrcweir sName, aExpCols, aExpRows, aExpCells,
787cdf0e10cSrcweir aTblInfo, sal_True);
788cdf0e10cSrcweir }
789cdf0e10cSrcweir }
790cdf0e10cSrcweir
791cdf0e10cSrcweir // ---------------------------------------------------------------------
792cdf0e10cSrcweir
ExportTableBox(const SwTableBox & rBox,sal_uInt16 nColSpan,sal_uInt16 nRowSpan,SwXMLTableInfo_Impl & rTblInfo)793cdf0e10cSrcweir void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
794cdf0e10cSrcweir sal_uInt16 nColSpan,
795cdf0e10cSrcweir sal_uInt16 nRowSpan,
796cdf0e10cSrcweir SwXMLTableInfo_Impl& rTblInfo )
797cdf0e10cSrcweir {
798cdf0e10cSrcweir const SwStartNode *pBoxSttNd = rBox.GetSttNd();
799cdf0e10cSrcweir if( pBoxSttNd )
800cdf0e10cSrcweir {
801cdf0e10cSrcweir const SwFrmFmt *pFrmFmt = rBox.GetFrmFmt();
802cdf0e10cSrcweir if( pFrmFmt )
803cdf0e10cSrcweir {
804cdf0e10cSrcweir const String& rName = pFrmFmt->GetName();
805cdf0e10cSrcweir if( rName.Len() )
806cdf0e10cSrcweir {
807cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME, EncodeStyleName(rName) );
808cdf0e10cSrcweir }
809cdf0e10cSrcweir }
810cdf0e10cSrcweir }
811cdf0e10cSrcweir
812cdf0e10cSrcweir if( nRowSpan != 1 )
813cdf0e10cSrcweir {
814cdf0e10cSrcweir OUStringBuffer sTmp;
815cdf0e10cSrcweir sTmp.append( (sal_Int32)nRowSpan );
816cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED,
817cdf0e10cSrcweir sTmp.makeStringAndClear() );
818cdf0e10cSrcweir }
819cdf0e10cSrcweir
820cdf0e10cSrcweir if( nColSpan != 1 )
821cdf0e10cSrcweir {
822cdf0e10cSrcweir OUStringBuffer sTmp;
823cdf0e10cSrcweir sTmp.append( (sal_Int32)nColSpan );
824cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED,
825cdf0e10cSrcweir sTmp.makeStringAndClear() );
826cdf0e10cSrcweir }
827cdf0e10cSrcweir
828cdf0e10cSrcweir {
829cdf0e10cSrcweir if( pBoxSttNd )
830cdf0e10cSrcweir {
831cdf0e10cSrcweir // start node -> normal cell
832cdf0e10cSrcweir
833cdf0e10cSrcweir // get cell range for table
834cdf0e10cSrcweir Reference<XCell> xCell = SwXCell::CreateXCell( (SwFrmFmt *)rTblInfo.GetTblFmt(),
835cdf0e10cSrcweir (SwTableBox *)&rBox,
836cdf0e10cSrcweir (SwTable *)rTblInfo.GetTable() );
837cdf0e10cSrcweir
838cdf0e10cSrcweir if (xCell.is())
839cdf0e10cSrcweir {
840cdf0e10cSrcweir Reference<XText> xText( xCell, UNO_QUERY );
841cdf0e10cSrcweir
842cdf0e10cSrcweir // get formula (and protection)
843cdf0e10cSrcweir OUString sCellFormula = xCell->getFormula();
844cdf0e10cSrcweir
845cdf0e10cSrcweir // if this cell has a formula, export it
846cdf0e10cSrcweir // (with value and number format)
847cdf0e10cSrcweir if (sCellFormula.getLength()>0)
848cdf0e10cSrcweir {
849cdf0e10cSrcweir OUString sQValue =
850cdf0e10cSrcweir GetNamespaceMap().GetQNameByKey(
851cdf0e10cSrcweir XML_NAMESPACE_OOOW, sCellFormula, sal_False );
852cdf0e10cSrcweir // formula
853cdf0e10cSrcweir AddAttribute(XML_NAMESPACE_TABLE, XML_FORMULA, sQValue );
854cdf0e10cSrcweir }
855cdf0e10cSrcweir
856cdf0e10cSrcweir // value and format (if NumberFormat != -1)
857cdf0e10cSrcweir Reference<XPropertySet> xCellPropertySet(xCell,
858cdf0e10cSrcweir UNO_QUERY);
859cdf0e10cSrcweir if (xCellPropertySet.is())
860cdf0e10cSrcweir {
861cdf0e10cSrcweir sal_Int32 nNumberFormat = 0;
862cdf0e10cSrcweir Any aAny = xCellPropertySet->getPropertyValue(sNumberFormat);
863cdf0e10cSrcweir aAny >>= nNumberFormat;
864cdf0e10cSrcweir
865cdf0e10cSrcweir if (NUMBERFORMAT_TEXT == nNumberFormat)
866cdf0e10cSrcweir {
867cdf0e10cSrcweir // text format
868cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_OFFICE,
869cdf0e10cSrcweir XML_VALUE_TYPE, XML_STRING );
870cdf0e10cSrcweir }
871cdf0e10cSrcweir else if ( (-1 != nNumberFormat) && (xText->getString().getLength() > 0) )
872cdf0e10cSrcweir {
873cdf0e10cSrcweir // number format key:
874cdf0e10cSrcweir // (export values only if cell contains text;
875cdf0e10cSrcweir // cf. #83755#)
876cdf0e10cSrcweir XMLNumberFormatAttributesExportHelper::
877cdf0e10cSrcweir SetNumberFormatAttributes(
878cdf0e10cSrcweir *this, nNumberFormat, xCell->getValue(),
879cdf0e10cSrcweir sal_True );
880cdf0e10cSrcweir }
881cdf0e10cSrcweir // else: invalid key; ignore
882cdf0e10cSrcweir
883cdf0e10cSrcweir // cell protection
884cdf0e10cSrcweir aAny = xCellPropertySet->getPropertyValue(sIsProtected);
885cdf0e10cSrcweir if (*(sal_Bool*)aAny.getValue())
886cdf0e10cSrcweir {
887cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_TABLE, XML_PROTECTED,
888cdf0e10cSrcweir XML_TRUE );
889cdf0e10cSrcweir }
890cdf0e10cSrcweir
891cdf0e10cSrcweir if( !rTblInfo.IsBaseSectionValid() )
892cdf0e10cSrcweir {
893cdf0e10cSrcweir OUString sTextSection( RTL_CONSTASCII_USTRINGPARAM("TextSection") );
894cdf0e10cSrcweir aAny = xCellPropertySet->getPropertyValue(sTextSection);
895cdf0e10cSrcweir Reference < XTextSection > xTextSection;
896cdf0e10cSrcweir aAny >>= xTextSection;
897cdf0e10cSrcweir rTblInfo.SetBaseSection( xTextSection );
898cdf0e10cSrcweir }
899cdf0e10cSrcweir }
900cdf0e10cSrcweir
901cdf0e10cSrcweir // export cell element
902cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
903cdf0e10cSrcweir XML_TABLE_CELL, sal_True, sal_True );
904cdf0e10cSrcweir
905cdf0e10cSrcweir // export cell content
906cdf0e10cSrcweir GetTextParagraphExport()->exportText( xText,
907cdf0e10cSrcweir rTblInfo.GetBaseSection(),
908cdf0e10cSrcweir IsShowProgress() );
909cdf0e10cSrcweir }
910cdf0e10cSrcweir else
911cdf0e10cSrcweir {
912cdf0e10cSrcweir DBG_ERROR("here should be a XCell");
913cdf0e10cSrcweir ClearAttrList();
914cdf0e10cSrcweir }
915cdf0e10cSrcweir }
916cdf0e10cSrcweir else
917cdf0e10cSrcweir {
918cdf0e10cSrcweir // no start node -> merged cells: export subtable in cell
919cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
920cdf0e10cSrcweir XML_TABLE_CELL, sal_True, sal_True );
921cdf0e10cSrcweir {
922cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_TABLE, XML_IS_SUB_TABLE,
923cdf0e10cSrcweir GetXMLToken( XML_TRUE ) );
924cdf0e10cSrcweir
925cdf0e10cSrcweir SvXMLElementExport aElemExport( *this, XML_NAMESPACE_TABLE,
926cdf0e10cSrcweir XML_TABLE, sal_True, sal_True );
927cdf0e10cSrcweir ExportTableLines( rBox.GetTabLines(), rTblInfo );
928cdf0e10cSrcweir }
929cdf0e10cSrcweir }
930cdf0e10cSrcweir }
931cdf0e10cSrcweir }
932cdf0e10cSrcweir
ExportTableLine(const SwTableLine & rLine,const SwXMLTableLines_Impl & rLines,SwXMLTableInfo_Impl & rTblInfo)933cdf0e10cSrcweir void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
934cdf0e10cSrcweir const SwXMLTableLines_Impl& rLines,
935cdf0e10cSrcweir SwXMLTableInfo_Impl& rTblInfo )
936cdf0e10cSrcweir {
937cdf0e10cSrcweir if( rLine.hasSoftPageBreak() )
938cdf0e10cSrcweir {
939cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT,
940cdf0e10cSrcweir XML_SOFT_PAGE_BREAK, sal_True, sal_True );
941cdf0e10cSrcweir }
942cdf0e10cSrcweir const SwFrmFmt *pFrmFmt = rLine.GetFrmFmt();
943cdf0e10cSrcweir if( pFrmFmt )
944cdf0e10cSrcweir {
945cdf0e10cSrcweir const String& rName = pFrmFmt->GetName();
946cdf0e10cSrcweir if( rName.Len() )
947cdf0e10cSrcweir {
948cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME, EncodeStyleName(rName) );
949cdf0e10cSrcweir }
950cdf0e10cSrcweir }
951cdf0e10cSrcweir
952cdf0e10cSrcweir {
953cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
954cdf0e10cSrcweir XML_TABLE_ROW, sal_True, sal_True );
955cdf0e10cSrcweir const SwTableBoxes& rBoxes = rLine.GetTabBoxes();
956cdf0e10cSrcweir sal_uInt16 nBoxes = rBoxes.Count();
957cdf0e10cSrcweir
958cdf0e10cSrcweir sal_uInt32 nCPos = 0U;
959cdf0e10cSrcweir sal_uInt16 nCol = 0U;
960cdf0e10cSrcweir for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
961cdf0e10cSrcweir {
962cdf0e10cSrcweir const SwTableBox *pBox = rBoxes[nBox];
963cdf0e10cSrcweir
964cdf0e10cSrcweir // NEW TABLES
965cdf0e10cSrcweir const long nRowSpan = pBox->getRowSpan();
966cdf0e10cSrcweir if( nRowSpan < 1 )
967cdf0e10cSrcweir {
968cdf0e10cSrcweir SvXMLElementExport aElem2( *this, XML_NAMESPACE_TABLE,
969cdf0e10cSrcweir XML_COVERED_TABLE_CELL, sal_True,
970cdf0e10cSrcweir sal_False );
971cdf0e10cSrcweir }
972cdf0e10cSrcweir
973cdf0e10cSrcweir if( nBox < nBoxes-1U )
974cdf0e10cSrcweir nCPos = nCPos + SwWriteTable::GetBoxWidth( pBox );
975cdf0e10cSrcweir else
976cdf0e10cSrcweir nCPos = rLines.GetWidth();
977cdf0e10cSrcweir
978cdf0e10cSrcweir // Und ihren Index
979cdf0e10cSrcweir const sal_uInt16 nOldCol = nCol;
980cdf0e10cSrcweir {
981cdf0e10cSrcweir SwXMLTableColumn_Impl aCol( nCPos );
982cdf0e10cSrcweir #ifdef DBG_UTIL
983cdf0e10cSrcweir const sal_Bool bFound =
984cdf0e10cSrcweir #endif
985cdf0e10cSrcweir rLines.GetColumns().Seek_Entry( &aCol, &nCol );
986cdf0e10cSrcweir ASSERT( bFound, "couldn't find column" );
987cdf0e10cSrcweir }
988cdf0e10cSrcweir
989cdf0e10cSrcweir // --> OD 2009-03-19 #i95726#
990cdf0e10cSrcweir // Some fault tolerance, if table is somehow corrupted.
991cdf0e10cSrcweir if ( nCol < nOldCol )
992cdf0e10cSrcweir {
993cdf0e10cSrcweir ASSERT( false, "table and/or table information seems to be corrupted." );
994cdf0e10cSrcweir if ( nBox == nBoxes - 1 )
995cdf0e10cSrcweir {
996cdf0e10cSrcweir nCol = rLines.GetColumns().Count() - 1;
997cdf0e10cSrcweir }
998cdf0e10cSrcweir else
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir nCol = nOldCol;
1001cdf0e10cSrcweir }
1002cdf0e10cSrcweir }
1003cdf0e10cSrcweir // <--
1004cdf0e10cSrcweir
1005cdf0e10cSrcweir sal_uInt16 nColSpan = nCol - nOldCol + 1U;
1006cdf0e10cSrcweir
1007cdf0e10cSrcweir if ( nRowSpan >= 1 )
1008cdf0e10cSrcweir ExportTableBox( *pBox, nColSpan, static_cast< sal_uInt16 >(nRowSpan), rTblInfo );
1009cdf0e10cSrcweir
1010cdf0e10cSrcweir for( sal_uInt16 i=nOldCol; i<nCol; i++ )
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir SvXMLElementExport aElemExport( *this, XML_NAMESPACE_TABLE,
1013cdf0e10cSrcweir XML_COVERED_TABLE_CELL, sal_True,
1014cdf0e10cSrcweir sal_False );
1015cdf0e10cSrcweir }
1016cdf0e10cSrcweir
1017cdf0e10cSrcweir nCol++;
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir }
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir
ExportTableLines(const SwTableLines & rLines,SwXMLTableInfo_Impl & rTblInfo,sal_uInt16 nHeaderRows)1022cdf0e10cSrcweir void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
1023cdf0e10cSrcweir SwXMLTableInfo_Impl& rTblInfo,
1024cdf0e10cSrcweir sal_uInt16 nHeaderRows )
1025cdf0e10cSrcweir {
1026cdf0e10cSrcweir ASSERT( pTableLines && pTableLines->Count(),
1027cdf0e10cSrcweir "SwXMLExport::ExportTableLines: table columns infos missing" );
1028cdf0e10cSrcweir if( !pTableLines || 0 == pTableLines->Count() )
1029cdf0e10cSrcweir return;
1030cdf0e10cSrcweir
1031cdf0e10cSrcweir SwXMLTableLines_Impl *pLines = 0;
1032cdf0e10cSrcweir sal_uInt16 nInfoPos;
1033cdf0e10cSrcweir for( nInfoPos=0; nInfoPos < pTableLines->Count(); nInfoPos++ )
1034cdf0e10cSrcweir {
1035cdf0e10cSrcweir if( pTableLines->GetObject( nInfoPos )->GetLines() == &rLines )
1036cdf0e10cSrcweir {
1037cdf0e10cSrcweir pLines = pTableLines->GetObject( nInfoPos );
1038cdf0e10cSrcweir break;
1039cdf0e10cSrcweir }
1040cdf0e10cSrcweir }
1041cdf0e10cSrcweir ASSERT( pLines,
1042cdf0e10cSrcweir "SwXMLExport::ExportTableLines: table columns info missing" );
1043cdf0e10cSrcweir ASSERT( 0==nInfoPos,
1044cdf0e10cSrcweir "SwXMLExport::ExportTableLines: table columns infos are unsorted" );
1045cdf0e10cSrcweir if( !pLines )
1046cdf0e10cSrcweir return;
1047cdf0e10cSrcweir
1048cdf0e10cSrcweir pTableLines->Remove( nInfoPos );
1049cdf0e10cSrcweir if( 0 == pTableLines->Count() )
1050cdf0e10cSrcweir {
1051cdf0e10cSrcweir delete pTableLines ;
1052cdf0e10cSrcweir pTableLines = 0;
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir
1055cdf0e10cSrcweir // pass 2: export columns
1056cdf0e10cSrcweir const SwXMLTableColumns_Impl& rCols = pLines->GetColumns();
1057cdf0e10cSrcweir sal_uInt16 nColumn = 0U;
1058cdf0e10cSrcweir sal_uInt16 nColumns = rCols.Count();
1059cdf0e10cSrcweir sal_uInt16 nColRep = 1U;
1060cdf0e10cSrcweir SwXMLTableColumn_Impl *pColumn = (nColumns > 0) ? rCols[0U] : 0;
1061cdf0e10cSrcweir while( pColumn )
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir nColumn++;
1064cdf0e10cSrcweir SwXMLTableColumn_Impl *pNextColumn =
1065cdf0e10cSrcweir (nColumn < nColumns) ? rCols[nColumn] : 0;
1066cdf0e10cSrcweir if( pNextColumn &&
1067cdf0e10cSrcweir pNextColumn->GetStyleName() == pColumn->GetStyleName() )
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir nColRep++;
1070cdf0e10cSrcweir }
1071cdf0e10cSrcweir else
1072cdf0e10cSrcweir {
1073cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME,
1074cdf0e10cSrcweir EncodeStyleName(pColumn->GetStyleName()) );
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir if( nColRep > 1U )
1077cdf0e10cSrcweir {
1078cdf0e10cSrcweir OUStringBuffer sTmp(4);
1079cdf0e10cSrcweir sTmp.append( (sal_Int32)nColRep );
1080cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED,
1081cdf0e10cSrcweir sTmp.makeStringAndClear() );
1082cdf0e10cSrcweir }
1083cdf0e10cSrcweir
1084cdf0e10cSrcweir {
1085cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
1086cdf0e10cSrcweir XML_TABLE_COLUMN, sal_True, sal_True );
1087cdf0e10cSrcweir }
1088cdf0e10cSrcweir
1089cdf0e10cSrcweir nColRep = 1U;
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir pColumn = pNextColumn;
1092cdf0e10cSrcweir }
1093cdf0e10cSrcweir
1094cdf0e10cSrcweir // pass 3: export line/rows
1095cdf0e10cSrcweir sal_uInt16 nLines = rLines.Count();
1096cdf0e10cSrcweir // export header rows, if present
1097cdf0e10cSrcweir if( nHeaderRows > 0 )
1098cdf0e10cSrcweir {
1099cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
1100cdf0e10cSrcweir XML_TABLE_HEADER_ROWS, sal_True, sal_True );
1101cdf0e10cSrcweir
1102cdf0e10cSrcweir DBG_ASSERT( nHeaderRows <= nLines, "more headers then lines?" );
1103cdf0e10cSrcweir for( sal_uInt16 nLine = 0U; nLine < nHeaderRows; nLine++ )
1104cdf0e10cSrcweir ExportTableLine( *(rLines[nLine]), *pLines, rTblInfo );
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir // export remaining rows
1107cdf0e10cSrcweir for( sal_uInt16 nLine = nHeaderRows; nLine < nLines; nLine++ )
1108cdf0e10cSrcweir {
1109cdf0e10cSrcweir ExportTableLine( *(rLines[nLine]), *pLines, rTblInfo );
1110cdf0e10cSrcweir }
1111cdf0e10cSrcweir
1112cdf0e10cSrcweir delete pLines;
1113cdf0e10cSrcweir }
1114cdf0e10cSrcweir
1115cdf0e10cSrcweir sal_Bool lcl_xmltble_ClearName_Line( const SwTableLine*& rpLine, void* );
1116cdf0e10cSrcweir
lcl_xmltble_ClearName_Box(const SwTableBox * & rpBox,void *)1117cdf0e10cSrcweir sal_Bool lcl_xmltble_ClearName_Box( const SwTableBox*& rpBox, void* )
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir if( !rpBox->GetSttNd() )
1120cdf0e10cSrcweir {
1121cdf0e10cSrcweir ((SwTableBox *)rpBox)->GetTabLines().ForEach(
1122cdf0e10cSrcweir &lcl_xmltble_ClearName_Line, 0 );
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir else
1125cdf0e10cSrcweir {
1126cdf0e10cSrcweir SwFrmFmt *pFrmFmt = ((SwTableBox *)rpBox)->GetFrmFmt();
1127cdf0e10cSrcweir if( pFrmFmt && pFrmFmt->GetName().Len() )
1128cdf0e10cSrcweir pFrmFmt->SetName( aEmptyStr );
1129cdf0e10cSrcweir }
1130cdf0e10cSrcweir
1131cdf0e10cSrcweir return sal_True;
1132cdf0e10cSrcweir }
1133cdf0e10cSrcweir
lcl_xmltble_ClearName_Line(const SwTableLine * & rpLine,void *)1134cdf0e10cSrcweir sal_Bool lcl_xmltble_ClearName_Line( const SwTableLine*& rpLine, void* )
1135cdf0e10cSrcweir {
1136cdf0e10cSrcweir ((SwTableLine *)rpLine)->GetTabBoxes().ForEach(
1137cdf0e10cSrcweir &lcl_xmltble_ClearName_Box, 0 );
1138cdf0e10cSrcweir
1139cdf0e10cSrcweir return sal_True;
1140cdf0e10cSrcweir }
1141cdf0e10cSrcweir
ExportTable(const SwTableNode & rTblNd)1142cdf0e10cSrcweir void SwXMLExport::ExportTable( const SwTableNode& rTblNd )
1143cdf0e10cSrcweir {
1144cdf0e10cSrcweir const SwTable& rTbl = rTblNd.GetTable();
1145cdf0e10cSrcweir const SwFrmFmt *pTblFmt = rTbl.GetFrmFmt();
1146cdf0e10cSrcweir if( pTblFmt && pTblFmt->GetName().Len() )
1147cdf0e10cSrcweir {
1148cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_TABLE, XML_NAME, pTblFmt->GetName() );
1149cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME,
1150cdf0e10cSrcweir EncodeStyleName( pTblFmt->GetName() ) );
1151cdf0e10cSrcweir }
1152cdf0e10cSrcweir
1153cdf0e10cSrcweir {
1154cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_TABLE,
1155cdf0e10cSrcweir sal_True, sal_True );
1156cdf0e10cSrcweir
1157cdf0e10cSrcweir // export DDE source (if this is a DDE table)
1158cdf0e10cSrcweir if ( rTbl.ISA(SwDDETable) )
1159cdf0e10cSrcweir {
1160cdf0e10cSrcweir // get DDE Field Type (contains the DDE connection)
1161cdf0e10cSrcweir const SwDDEFieldType* pDDEFldType =
1162cdf0e10cSrcweir ((SwDDETable&)rTbl).GetDDEFldType();
1163cdf0e10cSrcweir
1164cdf0e10cSrcweir // connection name
1165cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_OFFICE, XML_NAME,
1166cdf0e10cSrcweir pDDEFldType->GetName() );
1167cdf0e10cSrcweir
1168cdf0e10cSrcweir // DDE command
1169cdf0e10cSrcweir const String sCmd = pDDEFldType->GetCmd();
1170cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_OFFICE, XML_DDE_APPLICATION,
1171cdf0e10cSrcweir sCmd.GetToken(0, sfx2::cTokenSeperator) );
1172cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_OFFICE, XML_DDE_ITEM,
1173cdf0e10cSrcweir sCmd.GetToken(1, sfx2::cTokenSeperator) );
1174cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_OFFICE, XML_DDE_TOPIC,
1175cdf0e10cSrcweir sCmd.GetToken(2, sfx2::cTokenSeperator) );
1176cdf0e10cSrcweir
1177cdf0e10cSrcweir // auto update
1178cdf0e10cSrcweir if (pDDEFldType->GetType() == sfx2::LINKUPDATE_ALWAYS)
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_OFFICE,
1181cdf0e10cSrcweir XML_AUTOMATIC_UPDATE, XML_TRUE );
1182cdf0e10cSrcweir }
1183cdf0e10cSrcweir
1184cdf0e10cSrcweir // DDE source element (always empty)
1185cdf0e10cSrcweir SvXMLElementExport aSource(*this, XML_NAMESPACE_OFFICE,
1186cdf0e10cSrcweir XML_DDE_SOURCE, sal_True, sal_False);
1187cdf0e10cSrcweir }
1188cdf0e10cSrcweir
1189cdf0e10cSrcweir SwXMLTableInfo_Impl aTblInfo( &rTbl );
1190cdf0e10cSrcweir ExportTableLines( rTbl.GetTabLines(), aTblInfo, rTbl.GetRowsToRepeat() );
1191cdf0e10cSrcweir
1192cdf0e10cSrcweir ((SwTable &)rTbl).GetTabLines().ForEach( &lcl_xmltble_ClearName_Line,
1193cdf0e10cSrcweir 0 );
1194cdf0e10cSrcweir }
1195cdf0e10cSrcweir }
1196cdf0e10cSrcweir
exportTable(const Reference<XTextContent> & rTextContent,sal_Bool bAutoStyles,sal_Bool _bProgress)1197cdf0e10cSrcweir void SwXMLTextParagraphExport::exportTable(
1198cdf0e10cSrcweir const Reference < XTextContent > & rTextContent,
1199cdf0e10cSrcweir sal_Bool bAutoStyles, sal_Bool _bProgress )
1200cdf0e10cSrcweir {
1201cdf0e10cSrcweir sal_Bool bOldShowProgress = ((SwXMLExport&)GetExport()).IsShowProgress();
1202cdf0e10cSrcweir ((SwXMLExport&)GetExport()).SetShowProgress( _bProgress );
1203cdf0e10cSrcweir
1204cdf0e10cSrcweir Reference < XTextTable > xTxtTbl( rTextContent, UNO_QUERY );
1205cdf0e10cSrcweir DBG_ASSERT( xTxtTbl.is(), "text table missing" );
1206cdf0e10cSrcweir if( xTxtTbl.is() )
1207cdf0e10cSrcweir {
1208cdf0e10cSrcweir const SwXTextTable *pXTable = 0;
1209cdf0e10cSrcweir Reference<XUnoTunnel> xTableTunnel( rTextContent, UNO_QUERY);
1210cdf0e10cSrcweir if( xTableTunnel.is() )
1211cdf0e10cSrcweir {
1212cdf0e10cSrcweir pXTable = reinterpret_cast< SwXTextTable * >(
1213cdf0e10cSrcweir sal::static_int_cast< sal_IntPtr >( xTableTunnel->getSomething( SwXTextTable::getUnoTunnelId() )));
1214cdf0e10cSrcweir ASSERT( pXTable, "SwXTextTable missing" );
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir if( pXTable )
1217cdf0e10cSrcweir {
1218cdf0e10cSrcweir SwFrmFmt *pFmt = pXTable->GetFrmFmt();
1219cdf0e10cSrcweir ASSERT( pFmt, "table format missing" );
1220cdf0e10cSrcweir const SwTable *pTbl = SwTable::FindTable( pFmt );
1221cdf0e10cSrcweir ASSERT( pTbl, "table missing" );
1222cdf0e10cSrcweir const SwTableNode *pTblNd = pTbl->GetTableNode();
1223cdf0e10cSrcweir ASSERT( pTblNd, "table node missing" );
1224cdf0e10cSrcweir if( bAutoStyles )
1225cdf0e10cSrcweir {
1226cdf0e10cSrcweir SwNodeIndex aIdx( *pTblNd );
1227cdf0e10cSrcweir // AUTOSTYLES: Optimization: Do not export table autostyle if
1228cdf0e10cSrcweir // we are currently exporting the content.xml stuff and
1229cdf0e10cSrcweir // the table is located in header/footer:
1230cdf0e10cSrcweir // #144704: During the flat XML export (used e.g. by .sdw-export)
1231cdf0e10cSrcweir // ALL flags are set at the same time.
1232cdf0e10cSrcweir const bool bExportStyles = ( GetExport().getExportFlags() & EXPORT_STYLES ) != 0;
1233cdf0e10cSrcweir if ( bExportStyles || !pFmt->GetDoc()->IsInHeaderFooter( aIdx ) )
1234cdf0e10cSrcweir ((SwXMLExport&)GetExport()).ExportTableAutoStyles( *pTblNd );
1235cdf0e10cSrcweir }
1236cdf0e10cSrcweir else
1237cdf0e10cSrcweir {
1238cdf0e10cSrcweir ((SwXMLExport&)GetExport()).ExportTable( *pTblNd );
1239cdf0e10cSrcweir }
1240cdf0e10cSrcweir }
1241cdf0e10cSrcweir }
1242cdf0e10cSrcweir
1243cdf0e10cSrcweir ((SwXMLExport&)GetExport()).SetShowProgress( bOldShowProgress );
1244cdf0e10cSrcweir }
1245cdf0e10cSrcweir
1246cdf0e10cSrcweir
1247