Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include "docxattributeoutput.hxx"
21 : : #include "docxexport.hxx"
22 : : #include "docxexportfilter.hxx"
23 : : #include "docxfootnotes.hxx"
24 : : #include "writerwordglue.hxx"
25 : : #include "wrtww8.hxx"
26 : : #include "ww8par.hxx"
27 : : #include "fmtcntnt.hxx"
28 : : #include "fmtsrnd.hxx"
29 : : #include "fchrfmt.hxx"
30 : : #include "tgrditem.hxx"
31 : : #include "fmtruby.hxx"
32 : : #include "charfmt.hxx"
33 : : #include "breakit.hxx"
34 : :
35 : : #include <comphelper/string.hxx>
36 : : #include <oox/token/tokens.hxx>
37 : : #include <oox/export/drawingml.hxx>
38 : : #include <oox/export/utils.hxx>
39 : : #include <oox/mathml/export.hxx>
40 : :
41 : : #include <i18npool/mslangid.hxx>
42 : :
43 : : #include <hintids.hxx>
44 : :
45 : : #include <svl/poolitem.hxx>
46 : :
47 : : #include <editeng/fontitem.hxx>
48 : : #include <editeng/tstpitem.hxx>
49 : : #include <editeng/adjitem.hxx>
50 : : #include <editeng/spltitem.hxx>
51 : : #include <editeng/widwitem.hxx>
52 : : #include <editeng/lspcitem.hxx>
53 : : #include <editeng/keepitem.hxx>
54 : : #include <editeng/shaditem.hxx>
55 : : #include <editeng/brshitem.hxx>
56 : : #include <editeng/postitem.hxx>
57 : : #include <editeng/wghtitem.hxx>
58 : : #include <editeng/kernitem.hxx>
59 : : #include <editeng/crsditem.hxx>
60 : : #include <editeng/cmapitem.hxx>
61 : : #include <editeng/wrlmitem.hxx>
62 : : #include <editeng/udlnitem.hxx>
63 : : #include <editeng/langitem.hxx>
64 : : #include <editeng/escpitem.hxx>
65 : : #include <editeng/fhgtitem.hxx>
66 : : #include <editeng/colritem.hxx>
67 : : #include <editeng/hyznitem.hxx>
68 : : #include <editeng/brkitem.hxx>
69 : : #include <editeng/lrspitem.hxx>
70 : : #include <editeng/ulspitem.hxx>
71 : : #include <editeng/boxitem.hxx>
72 : : #include <editeng/cntritem.hxx>
73 : : #include <editeng/shdditem.hxx>
74 : : #include <editeng/akrnitem.hxx>
75 : : #include <editeng/pbinitem.hxx>
76 : : #include <editeng/emphitem.hxx>
77 : : #include <editeng/twolinesitem.hxx>
78 : : #include <editeng/charscaleitem.hxx>
79 : : #include <editeng/charrotateitem.hxx>
80 : : #include <editeng/charreliefitem.hxx>
81 : : #include <editeng/paravertalignitem.hxx>
82 : : #include <editeng/pgrditem.hxx>
83 : : #include <editeng/frmdiritem.hxx>
84 : : #include <editeng/blnkitem.hxx>
85 : : #include <editeng/charhiddenitem.hxx>
86 : : #include <editeng/opaqitem.hxx>
87 : : #include <editeng/editobj.hxx>
88 : : #include <svx/svdmodel.hxx>
89 : : #include <svx/svdobj.hxx>
90 : : #include <sfx2/sfxbasemodel.hxx>
91 : :
92 : : #include <anchoredobject.hxx>
93 : : #include <docufld.hxx>
94 : : #include <flddropdown.hxx>
95 : : #include <format.hxx>
96 : : #include <fmtanchr.hxx>
97 : : #include <fmtclds.hxx>
98 : : #include <fmtinfmt.hxx>
99 : : #include <fmtfld.hxx>
100 : : #include <fmtfsize.hxx>
101 : : #include <fmtftn.hxx>
102 : : #include <fmtrowsplt.hxx>
103 : : #include <fmtline.hxx>
104 : : #include <frmfmt.hxx>
105 : : #include <frmatr.hxx>
106 : : #include <ftninfo.hxx>
107 : : #include <htmltbl.hxx>
108 : : #include <lineinfo.hxx>
109 : : #include <ndgrf.hxx>
110 : : #include <ndole.hxx>
111 : : #include <ndtxt.hxx>
112 : : #include <node.hxx>
113 : : #include <pagedesc.hxx>
114 : : #include <paratr.hxx>
115 : : #include <swmodule.hxx>
116 : : #include <swtable.hxx>
117 : : #include <txtftn.hxx>
118 : : #include <txtinet.hxx>
119 : : #include <numrule.hxx>
120 : :
121 : : #include <rtl/strbuf.hxx>
122 : : #include <rtl/ustrbuf.hxx>
123 : : #include <rtl/ustring.hxx>
124 : :
125 : : #include <tools/color.hxx>
126 : :
127 : : #include <com/sun/star/i18n/ScriptType.hpp>
128 : : #include <com/sun/star/drawing/XShape.hpp>
129 : : #include <com/sun/star/frame/XModel.hpp>
130 : : #include <com/sun/star/chart2/XChartDocument.hpp>
131 : : #include <com/sun/star/beans/XPropertySet.hpp>
132 : : #include <com/sun/star/container/XNamed.hpp>
133 : : #include <IMark.hxx>
134 : :
135 : : #if OSL_DEBUG_LEVEL > 1
136 : : #include <stdio.h>
137 : : #endif
138 : :
139 : : using ::editeng::SvxBorderLine;
140 : :
141 : : using namespace oox;
142 : : using namespace docx;
143 : : using namespace sax_fastparser;
144 : : using namespace nsSwDocInfoSubType;
145 : : using namespace nsFieldFlags;
146 : : using namespace sw::util;
147 : : using namespace ::com::sun::star;
148 : :
149 : 0 : class FFDataWriterHelper
150 : : {
151 : : ::sax_fastparser::FSHelperPtr m_pSerializer;
152 : 0 : void writeCommonStart( const rtl::OUString& rName )
153 : : {
154 : 0 : m_pSerializer->startElementNS( XML_w, XML_ffData, FSEND );
155 : : m_pSerializer->singleElementNS( XML_w, XML_name,
156 : : FSNS( XML_w, XML_val ), OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr(),
157 [ # # ]: 0 : FSEND );
158 : 0 : m_pSerializer->singleElementNS( XML_w, XML_enabled, FSEND );
159 : : m_pSerializer->singleElementNS( XML_w, XML_calcOnExit,
160 : : FSNS( XML_w, XML_val ),
161 : 0 : "0", FSEND );
162 : 0 : }
163 : 0 : void writeFinish()
164 : : {
165 : 0 : m_pSerializer->endElementNS( XML_w, XML_ffData );
166 : 0 : }
167 : : public:
168 : 0 : FFDataWriterHelper( const ::sax_fastparser::FSHelperPtr pSerializer ) : m_pSerializer( pSerializer ){}
169 : 0 : void WriteFormCheckbox( const rtl::OUString& rName, const rtl::OUString& rDefault, bool bChecked )
170 : : {
171 : 0 : writeCommonStart( rName );
172 : : // Checkbox specific bits
173 : 0 : m_pSerializer->startElementNS( XML_w, XML_checkBox, FSEND );
174 : : // currently hardcoding autosize
175 : : // #TODO check if this defaulted
176 : 0 : m_pSerializer->startElementNS( XML_w, XML_sizeAuto, FSEND );
177 : 0 : m_pSerializer->endElementNS( XML_w, XML_sizeAuto );
178 [ # # ]: 0 : if ( !rDefault.isEmpty() )
179 : : {
180 : : m_pSerializer->singleElementNS( XML_w, XML_default,
181 : : FSNS( XML_w, XML_val ),
182 [ # # ]: 0 : rtl::OUStringToOString( rDefault, RTL_TEXTENCODING_UTF8 ).getStr(), FSEND );
183 : : }
184 [ # # ]: 0 : if ( bChecked )
185 : 0 : m_pSerializer->singleElementNS( XML_w, XML_checked, FSEND );
186 : 0 : m_pSerializer->endElementNS( XML_w, XML_checkBox );
187 : 0 : writeFinish();
188 : 0 : }
189 : 0 : void WriteFormText( const rtl::OUString& rName, const rtl::OUString& rDefault )
190 : : {
191 : 0 : writeCommonStart( rName );
192 [ # # ]: 0 : if ( !rDefault.isEmpty() )
193 : : {
194 : 0 : m_pSerializer->startElementNS( XML_w, XML_textInput, FSEND );
195 : : m_pSerializer->singleElementNS( XML_w, XML_default,
196 : : FSNS( XML_w, XML_val ),
197 [ # # ]: 0 : rtl::OUStringToOString( rDefault, RTL_TEXTENCODING_UTF8 ).getStr(), FSEND );
198 : 0 : m_pSerializer->endElementNS( XML_w, XML_textInput );
199 : : }
200 : 0 : writeFinish();
201 : 0 : }
202 : : };
203 : :
204 : : class FieldMarkParamsHelper
205 : : {
206 : : const sw::mark::IFieldmark& mrFieldmark;
207 : : public:
208 : 0 : FieldMarkParamsHelper( const sw::mark::IFieldmark& rFieldmark ) : mrFieldmark( rFieldmark ) {}
209 : 0 : rtl::OUString getName() { return mrFieldmark.GetName(); }
210 : : template < typename T >
211 : 0 : bool extractParam( const rtl::OUString& rKey, T& rResult )
212 : : {
213 : 0 : bool bResult = false;
214 [ # # ][ # # ]: 0 : if ( mrFieldmark.GetParameters() )
[ # # ]
215 : : {
216 [ # # ][ # # ]: 0 : sw::mark::IFieldmark::parameter_map_t::const_iterator it = mrFieldmark.GetParameters()->find( rKey );
[ # # ][ # # ]
[ # # ][ # # ]
217 [ # # ][ # # ]: 0 : if ( it != mrFieldmark.GetParameters()->end() )
[ # # ][ # # ]
[ # # ][ # # ]
218 [ # # ]: 0 : bResult = ( it->second >>= rResult );
219 : : }
220 : 0 : return bResult;
221 : : }
222 : : };
223 : 162 : void DocxAttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 /*nScript*/ )
224 : : {
225 [ - + ]: 162 : if (bIsRTL)
226 : 0 : m_pSerializer->singleElementNS( XML_w, XML_rtl, FSNS( XML_w, XML_val ), "true", FSEND );
227 : 162 : }
228 : :
229 : 105 : void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo )
230 : : {
231 [ - + ]: 105 : if ( m_nColBreakStatus == COLBRK_POSTPONE )
232 : 0 : m_nColBreakStatus = COLBRK_WRITE;
233 : :
234 : : // Output table/table row/table cell starts if needed
235 [ - + ]: 105 : if ( pTextNodeInfo.get() )
236 : : {
237 : 0 : sal_uInt32 nRow = pTextNodeInfo->getRow();
238 : 0 : sal_uInt32 nCell = pTextNodeInfo->getCell();
239 : :
240 : : // New cell/row?
241 [ # # ][ # # ]: 0 : if ( m_nTableDepth > 0 && !m_bTableCellOpen )
242 : : {
243 [ # # ]: 0 : ww8::WW8TableNodeInfoInner::Pointer_t pDeepInner( pTextNodeInfo->getInnerForDepth( m_nTableDepth ) );
244 [ # # ][ # # ]: 0 : if ( pDeepInner->getCell() == 0 )
245 [ # # ][ # # ]: 0 : StartTableRow( pDeepInner );
[ # # ]
246 : :
247 [ # # ][ # # ]: 0 : StartTableCell( pDeepInner );
[ # # ][ # # ]
248 : : }
249 : :
250 [ # # ][ # # ]: 0 : if ( nRow == 0 && nCell == 0 )
251 : : {
252 : : // Do we have to start the table?
253 : : // [If we are at the rigth depth already, it means that we
254 : : // continue the table cell]
255 : 0 : sal_uInt32 nCurrentDepth = pTextNodeInfo->getDepth();
256 : :
257 [ # # ]: 0 : if ( nCurrentDepth > m_nTableDepth )
258 : : {
259 : : // Start all the tables that begin here
260 [ # # ]: 0 : for ( sal_uInt32 nDepth = m_nTableDepth + 1; nDepth <= pTextNodeInfo->getDepth(); ++nDepth )
261 : : {
262 [ # # ]: 0 : ww8::WW8TableNodeInfoInner::Pointer_t pInner( pTextNodeInfo->getInnerForDepth( nDepth ) );
263 : :
264 [ # # ][ # # ]: 0 : StartTable( pInner );
[ # # ]
265 [ # # ][ # # ]: 0 : StartTableRow( pInner );
[ # # ]
266 [ # # ][ # # ]: 0 : StartTableCell( pInner );
[ # # ]
267 [ # # ]: 0 : }
268 : :
269 : 0 : m_nTableDepth = nCurrentDepth;
270 : : }
271 : : }
272 : : }
273 : :
274 : 105 : m_pSerializer->startElementNS( XML_w, XML_p, FSEND );
275 : :
276 : : // postpone the output of the run (we get it before the paragraph
277 : : // properties, but must write it after them)
278 [ + - ]: 105 : m_pSerializer->mark();
279 : :
280 : : // no section break in this paragraph yet; can be set in SectionBreak()
281 : 105 : m_pSectionInfo.reset();
282 : :
283 : 105 : m_bParagraphOpened = true;
284 : 105 : }
285 : :
286 : 105 : void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner )
287 : : {
288 : : // write the paragraph properties + the run, already in the correct order
289 : 105 : m_pSerializer->mergeTopMarks();
290 : 105 : m_pSerializer->endElementNS( XML_w, XML_p );
291 : :
292 : : // Check for end of cell, rows, tables here
293 [ + - ]: 105 : FinishTableRowCell( pTextNodeInfoInner );
294 : :
295 : 105 : m_bParagraphOpened = false;
296 : :
297 : : // Write the anchored frame if any
298 [ - + ]: 105 : if ( m_pParentFrame )
299 : : {
300 : 0 : const SwFrmFmt& rFrmFmt = m_pParentFrame->GetFrmFmt( );
301 : 0 : const SwNodeIndex* pNodeIndex = rFrmFmt.GetCntnt().GetCntntIdx();
302 : :
303 [ # # ]: 0 : sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex()+1 : 0;
304 [ # # ]: 0 : sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0;
305 : :
306 : 0 : m_rExport.SaveData( nStt, nEnd );
307 : :
308 : 0 : m_rExport.mpParentFrame = m_pParentFrame;
309 : 0 : m_pParentFrame = NULL;
310 : :
311 : 0 : m_rExport.WriteText( );
312 : :
313 : 0 : m_rExport.RestoreData();
314 : : }
315 : 105 : }
316 : :
317 : 105 : void DocxAttributeOutput::FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t pInner, bool bForceEmptyParagraph )
318 : : {
319 [ - + ]: 105 : if ( pInner.get() )
320 : : {
321 : : // Where are we in the table
322 : 0 : sal_uInt32 nRow = pInner->getRow( );
323 : :
324 : 0 : const SwTable *pTable = pInner->getTable( );
325 : 0 : const SwTableLines& rLines = pTable->GetTabLines( );
326 : 0 : sal_uInt16 nLinesCount = rLines.size( );
327 : : // HACK
328 : : // msoffice seems to have an internal limitation of 63 columns for tables
329 : : // and refuses to load .docx with more, even though the spec seems to allow that;
330 : : // so simply if there are more columns, don't close the last one msoffice will handle
331 : : // and merge the contents of the remaining ones into it (since we don't close the cell
332 : : // here, following ones will not be opened)
333 [ # # ][ # # ]: 0 : bool limitWorkaround = ( pInner->getCell() >= 62 && !pInner->isEndOfLine());
334 : :
335 [ # # ][ # # ]: 0 : if ( pInner->isEndOfCell() && !limitWorkaround )
[ # # ]
336 : : {
337 [ # # ]: 0 : if ( bForceEmptyParagraph )
338 : 0 : m_pSerializer->singleElementNS( XML_w, XML_p, FSEND );
339 : :
340 : 0 : EndTableCell();
341 : : }
342 : :
343 : : // This is a line end
344 [ # # ]: 0 : if ( pInner->isEndOfLine() )
345 : 0 : EndTableRow();
346 : :
347 : : // This is the end of the table
348 [ # # ][ # # ]: 0 : if ( pInner->isEndOfLine( ) && ( nRow + 1 ) == nLinesCount )
[ # # ]
349 : 0 : EndTable();
350 : : }
351 : 105 : }
352 : :
353 : 0 : void DocxAttributeOutput::EmptyParagraph()
354 : : {
355 : 0 : m_pSerializer->singleElementNS( XML_w, XML_p, FSEND );
356 : 0 : }
357 : :
358 : 102 : void DocxAttributeOutput::StartParagraphProperties( const SwTxtNode& rNode )
359 : : {
360 : : // output page/section breaks
361 : : // Writer can have them at the beginning of a paragraph, or at the end, but
362 : : // in docx, we have to output them in the paragraph properties of the last
363 : : // paragraph in a section. To get it right, we have to switch to the next
364 : : // paragraph, and detect the section breaks there.
365 [ + - ]: 102 : SwNodeIndex aNextIndex( rNode, 1 );
366 [ + + ]: 102 : if ( aNextIndex.GetNode().IsTxtNode() )
367 : : {
368 [ + - ]: 45 : const SwTxtNode* pTxtNode = static_cast< SwTxtNode* >( &aNextIndex.GetNode() );
369 [ + - ][ + - ]: 45 : m_rExport.OutputSectionBreaks( pTxtNode->GetpSwAttrSet(), *pTxtNode );
370 : : }
371 [ - + ]: 57 : else if ( aNextIndex.GetNode().IsTableNode() )
372 : : {
373 : 0 : const SwTableNode* pTableNode = static_cast< SwTableNode* >( &aNextIndex.GetNode() );
374 : 0 : const SwFrmFmt *pFmt = pTableNode->GetTable().GetFrmFmt();
375 [ # # ]: 0 : m_rExport.OutputSectionBreaks( &(pFmt->GetAttrSet()), *pTableNode );
376 : : }
377 : :
378 [ + - ][ + - ]: 102 : m_pSerializer->mark( );
[ + - ]
379 : :
380 [ + - ]: 102 : m_pSerializer->startElementNS( XML_w, XML_pPr, FSEND );
381 : :
382 : : // and output the section break now (if it appeared)
383 [ - + ]: 102 : if ( m_pSectionInfo )
384 : : {
385 [ # # ]: 0 : m_rExport.SectionProperties( *m_pSectionInfo );
386 [ # # ]: 0 : m_pSectionInfo.reset();
387 : : }
388 : :
389 [ + - ][ + - ]: 102 : InitCollectedParagraphProperties();
390 : 102 : }
391 : :
392 : 459 : void DocxAttributeOutput::InitCollectedParagraphProperties()
393 : : {
394 : 459 : m_pParagraphSpacingAttrList = NULL;
395 : :
396 : : // Write the elements in the spec order
397 : : static const sal_Int32 aOrder[] =
398 : : {
399 : : FSNS( XML_w, XML_pStyle ),
400 : : FSNS( XML_w, XML_keepNext ),
401 : : FSNS( XML_w, XML_keepLines ),
402 : : FSNS( XML_w, XML_pageBreakBefore ),
403 : : FSNS( XML_w, XML_framePr ),
404 : : FSNS( XML_w, XML_widowControl ),
405 : : FSNS( XML_w, XML_numPr ),
406 : : FSNS( XML_w, XML_suppressLineNumbers ),
407 : : FSNS( XML_w, XML_pBdr ),
408 : : FSNS( XML_w, XML_shd ),
409 : : FSNS( XML_w, XML_tabs ),
410 : : FSNS( XML_w, XML_suppressAutoHyphens ),
411 : : FSNS( XML_w, XML_kinsoku ),
412 : : FSNS( XML_w, XML_wordWrap ),
413 : : FSNS( XML_w, XML_overflowPunct ),
414 : : FSNS( XML_w, XML_topLinePunct ),
415 : : FSNS( XML_w, XML_autoSpaceDE ),
416 : : FSNS( XML_w, XML_autoSpaceDN ),
417 : : FSNS( XML_w, XML_bidi ),
418 : : FSNS( XML_w, XML_adjustRightInd ),
419 : : FSNS( XML_w, XML_snapToGrid ),
420 : : FSNS( XML_w, XML_spacing ),
421 : : FSNS( XML_w, XML_ind ),
422 : : FSNS( XML_w, XML_contextualSpacing ),
423 : : FSNS( XML_w, XML_mirrorIndents ),
424 : : FSNS( XML_w, XML_suppressOverlap ),
425 : : FSNS( XML_w, XML_jc ),
426 : : FSNS( XML_w, XML_textDirection ),
427 : : FSNS( XML_w, XML_textAlignment ),
428 : : FSNS( XML_w, XML_textboxTightWrap ),
429 : : FSNS( XML_w, XML_outlineLvl ),
430 : : FSNS( XML_w, XML_divId ),
431 : : FSNS( XML_w, XML_cnfStyle ),
432 : : FSNS( XML_w, XML_rPr ),
433 : : FSNS( XML_w, XML_sectPr ),
434 : : FSNS( XML_w, XML_pPrChange )
435 : : };
436 : :
437 : : // postpone the output so that we can later [in EndParagraphProperties()]
438 : : // prepend the properties before the run
439 : 459 : sal_Int32 len = sizeof ( aOrder ) / sizeof( sal_Int32 );
440 [ + - ]: 459 : uno::Sequence< sal_Int32 > aSeqOrder( len );
441 [ + + ]: 16983 : for ( sal_Int32 i = 0; i < len; i++ )
442 [ + - ]: 16524 : aSeqOrder[i] = aOrder[i];
443 : :
444 [ + - ][ + - ]: 459 : m_pSerializer->mark( aSeqOrder );
[ + - ][ + - ]
445 : 459 : }
446 : :
447 : 459 : void DocxAttributeOutput::WriteCollectedParagraphProperties()
448 : : {
449 [ - + ]: 459 : if ( m_pFlyAttrList )
450 : : {
451 [ # # ][ # # ]: 0 : XFastAttributeListRef xAttrList( m_pFlyAttrList );
452 : 0 : m_pFlyAttrList = NULL;
453 : :
454 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_w, XML_framePr, xAttrList );
455 : : }
456 : :
457 [ + + ]: 459 : if ( m_pParagraphSpacingAttrList )
458 : : {
459 [ + - ][ + - ]: 195 : XFastAttributeListRef xAttrList( m_pParagraphSpacingAttrList );
460 : 195 : m_pParagraphSpacingAttrList = NULL;
461 : :
462 [ + - ]: 195 : m_pSerializer->singleElementNS( XML_w, XML_spacing, xAttrList );
463 : : }
464 : :
465 : : // Merge the marks for the ordered elements
466 : 459 : m_pSerializer->mergeTopMarks( );
467 : 459 : }
468 : :
469 : 102 : void DocxAttributeOutput::EndParagraphProperties()
470 : : {
471 : 102 : WriteCollectedParagraphProperties();
472 : :
473 : 102 : m_pSerializer->endElementNS( XML_w, XML_pPr );
474 : :
475 [ - + ]: 102 : if ( m_nColBreakStatus == COLBRK_WRITE )
476 : : {
477 : 0 : m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
478 : : m_pSerializer->singleElementNS( XML_w, XML_br,
479 : 0 : FSNS( XML_w, XML_type ), "column", FSEND );
480 : 0 : m_pSerializer->endElementNS( XML_w, XML_r );
481 : :
482 : 0 : m_nColBreakStatus = COLBRK_NONE;
483 : : }
484 : :
485 : : // merge the properties _before_ the run (strictly speaking, just
486 : : // after the start of the paragraph)
487 : 102 : m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND );
488 : 102 : }
489 : :
490 : 165 : void DocxAttributeOutput::StartRun( const SwRedlineData* pRedlineData, bool /*bSingleEmptyRun*/ )
491 : : {
492 : : // if there is some redlining in the document, output it
493 : 165 : StartRedline( pRedlineData );
494 : :
495 : : // postpone the output of the start of a run (there are elements that need
496 : : // to be written before the start of the run, but we learn which they are
497 : : // _inside_ of the run)
498 [ + - ]: 165 : m_pSerializer->mark(); // let's call it "postponed run start"
499 : :
500 : : // postpone the output of the text (we get it before the run properties,
501 : : // but must write it after them)
502 [ + - ]: 165 : m_pSerializer->mark(); // let's call it "postponed text"
503 : 165 : }
504 : :
505 : 165 : void DocxAttributeOutput::EndRun()
506 : : {
507 : : // Write field starts
508 [ + - ][ + + ]: 168 : for ( std::vector<FieldInfos>::iterator pIt = m_Fields.begin(); pIt != m_Fields.end(); )
509 : : {
510 : : // Add the fields starts for all but hyperlinks and TOCs
511 [ + - ][ - + ]: 3 : if ( pIt->bOpen && pIt->pField )
[ - + ]
512 : : {
513 [ # # ]: 0 : StartField_Impl( *pIt );
514 : :
515 : : // Remove the field from the stack if only the start has to be written
516 : : // Unknown fields sould be removed too
517 [ # # ][ # # ]: 0 : if ( !pIt->bClose || ( pIt->eType == ww::eUNKNOWN ) )
[ # # ]
518 : : {
519 [ # # ]: 0 : pIt = m_Fields.erase( pIt );
520 : 0 : continue;
521 : : }
522 : : }
523 : 3 : ++pIt;
524 : : }
525 : :
526 : : // write the run properties + the text, already in the correct order
527 : 165 : m_pSerializer->mergeTopMarks(); // merges with "postponed text", see above
528 : :
529 : : // level down, to be able to prepend the actual run start attribute (just
530 : : // before "postponed run start")
531 [ + - ]: 165 : m_pSerializer->mark(); // let's call it "actual run start"
532 : :
533 [ - + ]: 165 : if ( m_closeHyperlinkInPreviousRun )
534 : : {
535 : 0 : m_pSerializer->endElementNS( XML_w, XML_hyperlink );
536 : 0 : m_closeHyperlinkInPreviousRun = false;
537 : : }
538 : :
539 : : // Write the hyperlink and toc fields starts
540 [ + - ][ + + ]: 168 : for ( std::vector<FieldInfos>::iterator pIt = m_Fields.begin(); pIt != m_Fields.end(); )
541 : : {
542 : : // Add the fields starts for hyperlinks, TOCs and index marks
543 [ + - ][ + - ]: 3 : if ( pIt->bOpen && !pIt->pField )
[ + - ]
544 : : {
545 [ + - ]: 3 : StartField_Impl( *pIt, sal_True );
546 : :
547 : : // Remove the field if no end needs to be written
548 [ - + ]: 3 : if ( !pIt->bClose ) {
549 [ # # ]: 0 : pIt = m_Fields.erase( pIt );
550 : 0 : continue;
551 : : }
552 : : }
553 : 3 : ++pIt;
554 : : }
555 : :
556 : : // Start the hyperlink after the fields separators or we would generate invalid file
557 [ - + ]: 165 : if ( m_pHyperlinkAttrList )
558 : : {
559 [ # # ][ # # ]: 0 : XFastAttributeListRef xAttrList ( m_pHyperlinkAttrList );
560 : :
561 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_hyperlink, xAttrList );
562 : 0 : m_pHyperlinkAttrList = NULL;
563 : 0 : m_startedHyperlink = true;
564 : : }
565 : :
566 : 165 : DoWriteBookmarks( );
567 : 165 : WriteCommentRanges();
568 : :
569 : 165 : m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
570 : 165 : m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND ); // merges with "postponed run start", see above
571 : :
572 : : // write the run start + the run content
573 : 165 : m_pSerializer->mergeTopMarks(); // merges the "actual run start"
574 : :
575 : : // append the actual run end
576 : 165 : m_pSerializer->endElementNS( XML_w, XML_r );
577 : :
578 : 165 : WritePostponedMath();
579 : :
580 [ + + ]: 165 : if ( m_closeHyperlinkInThisRun )
581 : : {
582 [ - + ]: 3 : if ( m_startedHyperlink )
583 : : {
584 : 0 : m_pSerializer->endElementNS( XML_w, XML_hyperlink );
585 : 0 : m_startedHyperlink = false;
586 : : }
587 : 3 : m_closeHyperlinkInThisRun = false;
588 : : }
589 : :
590 [ + - ][ + + ]: 168 : while ( m_Fields.begin() != m_Fields.end() )
591 : : {
592 : 3 : EndField_Impl( m_Fields.front( ) );
593 : 3 : m_Fields.erase( m_Fields.begin( ) );
594 : : }
595 : :
596 : : // if there is some redlining in the document, output it
597 : 165 : EndRedline();
598 : 165 : }
599 : :
600 : 165 : void DocxAttributeOutput::WriteCommentRanges()
601 : : {
602 [ + + ]: 165 : if (m_bPostitStart)
603 : : {
604 : 3 : m_bPostitStart = false;
605 : 3 : OString idstr = OString::valueOf( sal_Int32( m_postitFieldsMaxId ));
606 [ + - ]: 3 : m_pSerializer->singleElementNS( XML_w, XML_commentRangeStart, FSNS( XML_w, XML_id ), idstr.getStr(), FSEND );
607 : : }
608 [ + + ]: 165 : if (m_bPostitEnd)
609 : : {
610 : 3 : m_bPostitEnd = false;
611 : 3 : OString idstr = OString::valueOf( sal_Int32( m_postitFieldsMaxId ));
612 [ + - ]: 3 : m_pSerializer->singleElementNS( XML_w, XML_commentRangeEnd, FSNS( XML_w, XML_id ), idstr.getStr(), FSEND );
613 : : }
614 : 165 : }
615 : :
616 : 165 : void DocxAttributeOutput::DoWriteBookmarks()
617 : : {
618 : : // Write the start bookmarks
619 [ + - ][ + - ]: 168 : for ( std::vector< OString >::const_iterator it = m_rMarksStart.begin(), end = m_rMarksStart.end();
[ + - ][ + + ]
620 : : it != end; ++it )
621 : : {
622 : 3 : const OString& rName = *it;
623 : :
624 : : // Output the bookmark
625 : 3 : sal_uInt16 nId = m_nNextMarkId++;
626 [ + - ]: 3 : m_rOpenedMarksIds[rName] = nId;
627 : : m_pSerializer->singleElementNS( XML_w, XML_bookmarkStart,
628 : : FSNS( XML_w, XML_id ), OString::valueOf( sal_Int32( nId ) ).getStr( ),
629 : : FSNS( XML_w, XML_name ), rName.getStr(),
630 [ + - ]: 3 : FSEND );
631 : : }
632 : 165 : m_rMarksStart.clear();
633 : :
634 : : // export the end bookmarks
635 [ + - ][ + - ]: 168 : for ( std::vector< OString >::const_iterator it = m_rMarksEnd.begin(), end = m_rMarksEnd.end();
[ + + ][ + - ]
636 : : it != end; ++it )
637 : : {
638 : 3 : const OString& rName = *it;
639 : :
640 : : // Get the id of the bookmark
641 [ + - ]: 3 : std::map< OString, sal_uInt16 >::iterator pPos = m_rOpenedMarksIds.find( rName );
642 [ + - ]: 3 : if ( pPos != m_rOpenedMarksIds.end( ) )
643 : : {
644 : 3 : sal_uInt16 nId = ( *pPos ).second;
645 : : m_pSerializer->singleElementNS( XML_w, XML_bookmarkEnd,
646 : : FSNS( XML_w, XML_id ), OString::valueOf( sal_Int32( nId ) ).getStr( ),
647 [ + - ]: 3 : FSEND );
648 [ + - ]: 3 : m_rOpenedMarksIds.erase( rName );
649 : : }
650 : : }
651 : 165 : m_rMarksEnd.clear();
652 : 165 : }
653 : :
654 : 0 : void DocxAttributeOutput::WriteFFData( const FieldInfos& rInfos )
655 : : {
656 : 0 : const ::sw::mark::IFieldmark& rFieldmark = *rInfos.pFieldmark;
657 [ # # ]: 0 : if ( rInfos.eType == ww::eFORMDROPDOWN )
658 : : {
659 [ # # ]: 0 : uno::Sequence< ::rtl::OUString> vListEntries;
660 : 0 : rtl::OUString sName, sHelp, sToolTip, sSelected;
661 : :
662 : 0 : FieldMarkParamsHelper params( rFieldmark );
663 [ # # ]: 0 : params.extractParam( ODF_FORMDROPDOWN_LISTENTRY, vListEntries );
664 [ # # ]: 0 : sName = params.getName();
665 : 0 : sal_Int32 nSelectedIndex = 0;
666 : :
667 [ # # ][ # # ]: 0 : if ( params.extractParam( ODF_FORMDROPDOWN_RESULT, nSelectedIndex ) )
668 : : {
669 [ # # ]: 0 : if (nSelectedIndex < vListEntries.getLength() )
670 [ # # ]: 0 : sSelected = vListEntries[ nSelectedIndex ];
671 : : }
672 : :
673 [ # # ][ # # ]: 0 : GetExport().DoComboBox( sName, sHelp, sToolTip, sSelected, vListEntries );
[ # # ]
674 : : }
675 [ # # ]: 0 : else if ( rInfos.eType == ww::eFORMCHECKBOX )
676 : : {
677 : 0 : rtl::OUString sName, sDefault;
678 : 0 : bool bChecked = false;
679 : :
680 : 0 : FieldMarkParamsHelper params( rFieldmark );
681 [ # # ]: 0 : params.extractParam( ODF_FORMCHECKBOX_NAME, sName );
682 : :
683 [ # # ]: 0 : const sw::mark::ICheckboxFieldmark* pCheckboxFm = dynamic_cast<const sw::mark::ICheckboxFieldmark*>(&rFieldmark);
684 [ # # ][ # # ]: 0 : if ( pCheckboxFm && pCheckboxFm->IsChecked() )
[ # # ][ # # ]
685 : 0 : bChecked = true;
686 : :
687 [ # # ][ # # ]: 0 : FFDataWriterHelper ffdataOut( m_pSerializer );
[ # # ]
688 [ # # ][ # # ]: 0 : ffdataOut.WriteFormCheckbox( sName, rtl::OUString(), bChecked );
689 : : }
690 [ # # ]: 0 : else if ( rInfos.eType == ww::eFORMTEXT )
691 : : {
692 : 0 : FieldMarkParamsHelper params( rFieldmark );
693 [ # # ][ # # ]: 0 : FFDataWriterHelper ffdataOut( m_pSerializer );
[ # # ]
694 [ # # ][ # # ]: 0 : ffdataOut.WriteFormText( params.getName(), rtl::OUString() );
[ # # ]
695 : : }
696 : 0 : }
697 : :
698 : 3 : void DocxAttributeOutput::StartField_Impl( FieldInfos& rInfos, bool bWriteRun )
699 : : {
700 [ - + ][ # # ]: 3 : if ( rInfos.pField && rInfos.eType == ww::eUNKNOWN )
701 : : {
702 : : // Expand unsupported fields
703 [ # # ]: 0 : RunText( rInfos.pField->GetFieldName() );
704 : : }
705 [ + - ]: 3 : else if ( rInfos.eType != ww::eNONE ) // HYPERLINK fields are just commands
706 : : {
707 [ + - ]: 3 : if ( bWriteRun )
708 : 3 : m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
709 : :
710 [ - + ]: 3 : if ( rInfos.eType == ww::eFORMDROPDOWN )
711 : : {
712 : : m_pSerializer->startElementNS( XML_w, XML_fldChar,
713 : : FSNS( XML_w, XML_fldCharType ), "begin",
714 : 0 : FSEND );
715 [ # # ][ # # ]: 0 : if ( rInfos.pFieldmark && !rInfos.pField )
716 : 0 : WriteFFData( rInfos );
717 [ # # ]: 0 : if ( rInfos.pField )
718 : : {
719 : 0 : const SwDropDownField& rFld2 = *(SwDropDownField*)rInfos.pField;
720 : : uno::Sequence<rtl::OUString> aItems =
721 [ # # ]: 0 : rFld2.GetItemSequence();
722 [ # # ][ # # ]: 0 : GetExport().DoComboBox(rFld2.GetName(),
723 [ # # ]: 0 : rFld2.GetHelp(),
724 [ # # ]: 0 : rFld2.GetToolTip(),
725 [ # # ][ # # ]: 0 : rFld2.GetSelectedItem(), aItems);
[ # # ]
726 : : }
727 : 0 : m_pSerializer->endElementNS( XML_w, XML_fldChar );
728 : :
729 [ # # ]: 0 : if ( bWriteRun )
730 : 0 : m_pSerializer->endElementNS( XML_w, XML_r );
731 [ # # ]: 0 : if ( !rInfos.pField )
732 : 0 : CmdField_Impl( rInfos );
733 : :
734 : : }
735 : : else
736 : : {
737 : : // Write the field start
738 : : m_pSerializer->startElementNS( XML_w, XML_fldChar,
739 : : FSNS( XML_w, XML_fldCharType ), "begin",
740 : 3 : FSEND );
741 : :
742 [ - + ]: 3 : if ( rInfos.pFieldmark )
743 : 0 : WriteFFData( rInfos );
744 : :
745 : 3 : m_pSerializer->endElementNS( XML_w, XML_fldChar );
746 : :
747 [ + - ]: 3 : if ( bWriteRun )
748 : 3 : m_pSerializer->endElementNS( XML_w, XML_r );
749 : :
750 : : // The hyperlinks fields can't be expanded: the value is
751 : : // normally in the text run
752 [ + - ]: 3 : if ( !rInfos.pField )
753 : 3 : CmdField_Impl( rInfos );
754 : : }
755 : : }
756 : 3 : }
757 : :
758 : 3 : void DocxAttributeOutput::DoWriteCmd( String& rCmd )
759 : : {
760 : : // Write the Field command
761 : 3 : m_pSerializer->startElementNS( XML_w, XML_instrText, FSEND );
762 [ + - ]: 3 : m_pSerializer->writeEscaped( OUString( rCmd ) );
763 : 3 : m_pSerializer->endElementNS( XML_w, XML_instrText );
764 : :
765 : 3 : }
766 : :
767 : 3 : void DocxAttributeOutput::CmdField_Impl( FieldInfos& rInfos )
768 : : {
769 : 3 : m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
770 [ + - ]: 3 : xub_StrLen nNbToken = comphelper::string::getTokenCount(rInfos.sCmd, '\t');
771 : :
772 [ + + ]: 6 : for ( xub_StrLen i = 0; i < nNbToken; i++ )
773 : : {
774 [ + - ]: 3 : String sToken = rInfos.sCmd.GetToken( i, '\t' );
775 [ + - ][ + - ]: 3 : if ( rInfos.eType == ww::eCREATEDATE
[ + - ][ + - ]
[ - + ]
776 : : || rInfos.eType == ww::eSAVEDATE
777 : : || rInfos.eType == ww::ePRINTDATE
778 : : || rInfos.eType == ww::eDATE
779 : : || rInfos.eType == ww::eTIME )
780 : : {
781 [ # # ][ # # ]: 0 : sToken.SearchAndReplaceAll( String( "NNNN" ), String( "dddd" ) );
[ # # ][ # # ]
[ # # ]
782 [ # # ][ # # ]: 0 : sToken.SearchAndReplaceAll( String( "NN" ), String( "ddd" ) );
[ # # ][ # # ]
[ # # ]
783 : : }
784 : : // Write the Field command
785 [ + - ]: 3 : DoWriteCmd( sToken );
786 : :
787 : : // Replace tabs by </instrText><tab/><instrText>
788 [ - + ]: 3 : if ( i < ( nNbToken - 1 ) )
789 [ # # ][ # # ]: 0 : RunText( rtl::OUString( "\t" ) );
[ # # ]
790 [ + - ]: 3 : }
791 : :
792 : 3 : m_pSerializer->endElementNS( XML_w, XML_r );
793 : :
794 : : // Write the Field separator
795 : 3 : m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
796 : : m_pSerializer->singleElementNS( XML_w, XML_fldChar,
797 : : FSNS( XML_w, XML_fldCharType ), "separate",
798 : 3 : FSEND );
799 : 3 : m_pSerializer->endElementNS( XML_w, XML_r );
800 : 3 : }
801 : :
802 : 3 : void DocxAttributeOutput::EndField_Impl( FieldInfos& rInfos )
803 : : {
804 : : // The command has to be written before for the hyperlinks
805 [ - + ]: 3 : if ( rInfos.pField )
806 : : {
807 [ # # ]: 0 : CmdField_Impl( rInfos );
808 : : }
809 : :
810 : : // Write the bookmark start if any
811 [ + - ]: 3 : OUString aBkmName( m_sFieldBkm );
812 [ - + ]: 3 : if ( !aBkmName.isEmpty() )
813 : : {
814 : : m_pSerializer->singleElementNS( XML_w, XML_bookmarkStart,
815 : : FSNS( XML_w, XML_id ), OString::valueOf( sal_Int32( m_nNextMarkId ) ).getStr( ),
816 : : FSNS( XML_w, XML_name ), OUStringToOString( aBkmName, RTL_TEXTENCODING_UTF8 ).getStr( ),
817 [ # # ][ # # ]: 0 : FSEND );
818 : : }
819 : :
820 [ - + ]: 3 : if (rInfos.pField ) // For hyperlinks and TOX
821 : : {
822 : : // Write the Field latest value
823 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
824 : :
825 [ # # ]: 0 : String sExpand( rInfos.pField->ExpandField( true ) );
826 : : // newlines embedded in fields are 0x0B in MSO and 0x0A for us
827 [ # # ]: 0 : sExpand.SearchAndReplaceAll( 0x0A, 0x0B );
828 [ # # ]: 0 : RunText( sExpand );
829 : :
830 [ # # ][ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_r );
831 : : }
832 : :
833 : : // Write the bookmark end if any
834 [ - + ]: 3 : if ( !aBkmName.isEmpty() )
835 : : {
836 : : m_pSerializer->singleElementNS( XML_w, XML_bookmarkEnd,
837 : : FSNS( XML_w, XML_id ), OString::valueOf( sal_Int32( m_nNextMarkId ) ).getStr( ),
838 [ # # ]: 0 : FSEND );
839 : :
840 : 0 : m_nNextMarkId++;
841 : : }
842 : :
843 : : // Write the Field end
844 [ + - ]: 3 : if ( rInfos.bClose )
845 : : {
846 [ + - ]: 3 : m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
847 : : m_pSerializer->singleElementNS( XML_w, XML_fldChar,
848 : : FSNS( XML_w, XML_fldCharType ), "end",
849 [ + - ]: 3 : FSEND );
850 [ + - ]: 3 : m_pSerializer->endElementNS( XML_w, XML_r );
851 : : }
852 : : // Write the ref field if a bookmark had to be set and the field
853 : : // should be visible
854 [ - + ]: 3 : if ( rInfos.pField )
855 : : {
856 [ # # ]: 0 : sal_uInt16 nSubType = rInfos.pField->GetSubType( );
857 : 0 : bool bIsSetField = rInfos.pField->GetTyp( )->Which( ) == RES_SETEXPFLD;
858 [ # # ][ # # ]: 0 : bool bShowRef = ( !bIsSetField || ( nSubType & nsSwExtendedSubType::SUB_INVISIBLE ) ) ? false : true;
859 : :
860 [ # # ][ # # ]: 0 : if ( ( m_sFieldBkm.Len( ) > 0 ) && bShowRef )
[ # # ]
861 : : {
862 : : // Write the field beginning
863 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
864 : : m_pSerializer->singleElementNS( XML_w, XML_fldChar,
865 : : FSNS( XML_w, XML_fldCharType ), "begin",
866 [ # # ]: 0 : FSEND );
867 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_r );
868 : :
869 [ # # ][ # # ]: 0 : rInfos.sCmd = FieldString( ww::eREF );
[ # # ]
870 [ # # ]: 0 : rInfos.sCmd.APPEND_CONST_ASC( "\"" );
871 [ # # ]: 0 : rInfos.sCmd += m_sFieldBkm;
872 [ # # ]: 0 : rInfos.sCmd.APPEND_CONST_ASC( "\" " );
873 : :
874 : : // Clean the field bookmark data to avoid infinite loop
875 [ # # ][ # # ]: 0 : m_sFieldBkm = String( );
[ # # ]
876 : :
877 : : // Write the end of the field
878 [ # # ]: 0 : EndField_Impl( rInfos );
879 : : }
880 : 3 : }
881 : 3 : }
882 : :
883 : 165 : void DocxAttributeOutput::StartRunProperties()
884 : : {
885 : : // postpone the output so that we can later [in EndRunProperties()]
886 : : // prepend the properties before the text
887 [ + - ]: 165 : m_pSerializer->mark();
888 : :
889 : 165 : m_pSerializer->startElementNS( XML_w, XML_rPr, FSEND );
890 : :
891 : 165 : InitCollectedRunProperties();
892 : :
893 : : OSL_ASSERT( m_postponedGraphic == NULL );
894 [ + - ]: 165 : m_postponedGraphic = new std::list< PostponedGraphic >;
895 : 165 : }
896 : :
897 : 552 : void DocxAttributeOutput::InitCollectedRunProperties()
898 : : {
899 : 552 : m_pFontsAttrList = NULL;
900 : 552 : m_pEastAsianLayoutAttrList = NULL;
901 : 552 : m_pCharLangAttrList = NULL;
902 : :
903 : : // Write the elements in the spec order
904 : : static const sal_Int32 aOrder[] =
905 : : {
906 : : FSNS( XML_w, XML_rStyle ),
907 : : FSNS( XML_w, XML_rFonts ),
908 : : FSNS( XML_w, XML_b ),
909 : : FSNS( XML_w, XML_bCs ),
910 : : FSNS( XML_w, XML_i ),
911 : : FSNS( XML_w, XML_iCs ),
912 : : FSNS( XML_w, XML_caps ),
913 : : FSNS( XML_w, XML_smallCaps ),
914 : : FSNS( XML_w, XML_strike ),
915 : : FSNS( XML_w, XML_dstrike ),
916 : : FSNS( XML_w, XML_outline ),
917 : : FSNS( XML_w, XML_shadow ),
918 : : FSNS( XML_w, XML_emboss ),
919 : : FSNS( XML_w, XML_imprint ),
920 : : FSNS( XML_w, XML_noProof ),
921 : : FSNS( XML_w, XML_snapToGrid ),
922 : : FSNS( XML_w, XML_vanish ),
923 : : FSNS( XML_w, XML_webHidden ),
924 : : FSNS( XML_w, XML_color ),
925 : : FSNS( XML_w, XML_spacing ),
926 : : FSNS( XML_w, XML_w ),
927 : : FSNS( XML_w, XML_kern ),
928 : : FSNS( XML_w, XML_position ),
929 : : FSNS( XML_w, XML_sz ),
930 : : FSNS( XML_w, XML_szCs ),
931 : : FSNS( XML_w, XML_highlight ),
932 : : FSNS( XML_w, XML_u ),
933 : : FSNS( XML_w, XML_effect ),
934 : : FSNS( XML_w, XML_bdr ),
935 : : FSNS( XML_w, XML_shd ),
936 : : FSNS( XML_w, XML_fitText ),
937 : : FSNS( XML_w, XML_vertAlign ),
938 : : FSNS( XML_w, XML_rtl ),
939 : : FSNS( XML_w, XML_cs ),
940 : : FSNS( XML_w, XML_em ),
941 : : FSNS( XML_w, XML_lang ),
942 : : FSNS( XML_w, XML_eastAsianLayout ),
943 : : FSNS( XML_w, XML_specVanish ),
944 : : FSNS( XML_w, XML_oMath ),
945 : : FSNS( XML_w, XML_rPrChange )
946 : : };
947 : :
948 : : // postpone the output so that we can later [in EndParagraphProperties()]
949 : : // prepend the properties before the run
950 : 552 : sal_Int32 len = sizeof ( aOrder ) / sizeof( sal_Int32 );
951 [ + - ]: 552 : uno::Sequence< sal_Int32 > aSeqOrder( len );
952 [ + + ]: 22632 : for ( sal_Int32 i = 0; i < len; i++ )
953 [ + - ]: 22080 : aSeqOrder[i] = aOrder[i];
954 : :
955 [ + - ][ + - ]: 552 : m_pSerializer->mark( aSeqOrder );
[ + - ][ + - ]
956 : :
957 : 552 : }
958 : :
959 : 552 : void DocxAttributeOutput::WriteCollectedRunProperties()
960 : : {
961 : : // Write all differed properties
962 [ + + ]: 552 : if ( m_pFontsAttrList )
963 : : {
964 [ + - ][ + - ]: 303 : XFastAttributeListRef xAttrList( m_pFontsAttrList );
965 : 303 : m_pFontsAttrList = NULL;
966 : :
967 [ + - ]: 303 : m_pSerializer->singleElementNS( XML_w, XML_rFonts, xAttrList );
968 : : }
969 : :
970 [ - + ]: 552 : if ( m_pEastAsianLayoutAttrList )
971 : : {
972 [ # # ][ # # ]: 0 : XFastAttributeListRef xAttrList( m_pEastAsianLayoutAttrList );
973 : 0 : m_pEastAsianLayoutAttrList = NULL;
974 : :
975 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_w, XML_eastAsianLayout, xAttrList );
976 : : }
977 : :
978 [ + + ]: 552 : if ( m_pCharLangAttrList )
979 : : {
980 [ + - ][ + - ]: 60 : XFastAttributeListRef xAttrList( m_pCharLangAttrList );
981 : 60 : m_pCharLangAttrList = NULL;
982 : :
983 [ + - ]: 60 : m_pSerializer->singleElementNS( XML_w, XML_lang, xAttrList );
984 : : }
985 : :
986 : : // Merge the marks for the ordered elements
987 : 552 : m_pSerializer->mergeTopMarks();
988 : 552 : }
989 : :
990 : 165 : void DocxAttributeOutput::EndRunProperties( const SwRedlineData* /*pRedlineData*/ )
991 : : {
992 : 165 : WriteCollectedRunProperties();
993 : :
994 : 165 : m_pSerializer->endElementNS( XML_w, XML_rPr );
995 : :
996 : : // write footnotes/endnotes if we have any
997 : 165 : FootnoteEndnoteReference();
998 : :
999 : 165 : WritePostponedGraphic();
1000 : :
1001 : : // merge the properties _before_ the run text (strictly speaking, just
1002 : : // after the start of the run)
1003 : 165 : m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND );
1004 : 165 : }
1005 : :
1006 : 165 : void DocxAttributeOutput::WritePostponedGraphic()
1007 : : {
1008 [ - + ]: 330 : for( std::list< PostponedGraphic >::const_iterator it = m_postponedGraphic->begin();
1009 : 165 : it != m_postponedGraphic->end();
1010 : : ++it )
1011 [ # # ]: 0 : FlyFrameGraphic( *( it->grfNode ), it->size );
1012 [ + - ]: 165 : delete m_postponedGraphic;
1013 : 165 : m_postponedGraphic = NULL;
1014 : 165 : }
1015 : :
1016 : 0 : void DocxAttributeOutput::FootnoteEndnoteRefTag()
1017 : : {
1018 [ # # ]: 0 : if( m_footnoteEndnoteRefTag == 0 )
1019 : 0 : return;
1020 : 0 : m_pSerializer->singleElementNS( XML_w, m_footnoteEndnoteRefTag, FSEND );
1021 : 0 : m_footnoteEndnoteRefTag = 0;
1022 : : }
1023 : :
1024 : : /** Output sal_Unicode* as a run text (<t>the text</t>).
1025 : :
1026 : : When bMove is true, update rBegin to point _after_ the end of the text +
1027 : : 1, meaning that it skips one character after the text. This is to make
1028 : : the switch in DocxAttributeOutput::RunText() nicer ;-)
1029 : : */
1030 : 24 : static void impl_WriteRunText( FSHelperPtr pSerializer, sal_Int32 nTextToken,
1031 : : const sal_Unicode* &rBegin, const sal_Unicode* pEnd, bool bMove = true )
1032 : : {
1033 : 24 : const sal_Unicode *pBegin = rBegin;
1034 : :
1035 : : // skip one character after the end
1036 [ - + ]: 24 : if ( bMove )
1037 : 0 : rBegin = pEnd + 1;
1038 : :
1039 [ + + ]: 24 : if ( pBegin >= pEnd )
1040 : 24 : return; // we want to write at least one character
1041 : :
1042 : : // we have to add 'preserve' when starting/ending with space
1043 [ + + ][ + + ]: 21 : if ( *pBegin == sal_Unicode( ' ' ) || *( pEnd - 1 ) == sal_Unicode( ' ' ) )
1044 : : {
1045 : 6 : pSerializer->startElementNS( XML_w, nTextToken, FSNS( XML_xml, XML_space ), "preserve", FSEND );
1046 : : }
1047 : : else
1048 : 15 : pSerializer->startElementNS( XML_w, nTextToken, FSEND );
1049 : :
1050 [ + - ]: 21 : pSerializer->writeEscaped( OUString( pBegin, pEnd - pBegin ) );
1051 : :
1052 : 21 : pSerializer->endElementNS( XML_w, nTextToken );
1053 : : }
1054 : :
1055 : 24 : void DocxAttributeOutput::RunText( const String& rText, rtl_TextEncoding /*eCharSet*/ )
1056 : : {
1057 [ - + ]: 24 : if( m_closeHyperlinkInThisRun )
1058 : : {
1059 : 0 : m_closeHyperlinkInPreviousRun = true;
1060 : 0 : m_closeHyperlinkInThisRun = false;
1061 : : }
1062 [ + - ]: 24 : OUString aText( rText );
1063 : :
1064 : : // one text can be split into more <w:t>blah</w:t>'s by line breaks etc.
1065 : 24 : const sal_Unicode *pBegin = aText.getStr();
1066 : 24 : const sal_Unicode *pEnd = pBegin + aText.getLength();
1067 : :
1068 : : // the text run is usually XML_t, with the exception of the deleted text
1069 : 24 : sal_Int32 nTextToken = XML_t;
1070 [ # # ][ - + ]: 24 : if ( m_pRedlineData && m_pRedlineData->GetType() == nsRedlineType_t::REDLINE_DELETE )
[ - + ]
1071 : 0 : nTextToken = XML_delText;
1072 : :
1073 [ + + ]: 873 : for ( const sal_Unicode *pIt = pBegin; pIt < pEnd; ++pIt )
1074 : : {
1075 [ - - + ]: 849 : switch ( *pIt )
1076 : : {
1077 : : case 0x09: // tab
1078 [ # # ][ # # ]: 0 : impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt );
[ # # ]
1079 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_w, XML_tab, FSEND );
1080 : 0 : break;
1081 : : case 0x0b: // line break
1082 [ # # ][ # # ]: 0 : impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt );
[ # # ]
1083 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_w, XML_br, FSEND );
1084 : 0 : break;
1085 : : default:
1086 [ - + ]: 849 : if ( *pIt < 0x0020 ) // filter out the control codes
1087 : : {
1088 [ # # ][ # # ]: 0 : impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt );
[ # # ]
1089 : : OSL_TRACE( "Ignored control code %x in a text run.", *pIt );
1090 : : }
1091 : 849 : break;
1092 : : }
1093 : : }
1094 : :
1095 [ + - ][ + - ]: 24 : impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pEnd, false );
[ + - ]
1096 : 24 : }
1097 : :
1098 : 0 : void DocxAttributeOutput::RawText( const String& /*rText*/, bool /*bForceUnicode*/, rtl_TextEncoding /*eCharSet*/ )
1099 : : {
1100 : : OSL_TRACE("TODO DocxAttributeOutput::RawText( const String& rText, bool bForceUnicode, rtl_TextEncoding eCharSet )" );
1101 : 0 : }
1102 : :
1103 : 0 : void DocxAttributeOutput::StartRuby( const SwTxtNode& rNode, xub_StrLen nPos, const SwFmtRuby& rRuby )
1104 : : {
1105 : : OSL_TRACE("TODO DocxAttributeOutput::StartRuby( const SwTxtNode& rNode, const SwFmtRuby& rRuby )" );
1106 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_ruby, FSEND );
1107 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_rubyPr, FSEND );
1108 : : // hps
1109 : : // hpsBaseText
1110 : : // hpsRaise
1111 : : // lid
1112 : : lang::Locale aLocale( SwBreakIt::Get()->GetLocale(
1113 [ # # ][ # # ]: 0 : rNode.GetLang( nPos ) ) );
[ # # ]
1114 : 0 : OUString sLang( aLocale.Language );
1115 [ # # ]: 0 : if ( !aLocale.Country.isEmpty() )
1116 : 0 : sLang += OUString( "-" ) + OUString( aLocale.Country );
1117 : : m_pSerializer->singleElementNS( XML_w, XML_lid,
1118 : : FSNS( XML_w, XML_val ),
1119 [ # # ][ # # ]: 0 : OUStringToOString( sLang, RTL_TEXTENCODING_UTF8 ).getStr( ), FSEND );
1120 : :
1121 : 0 : OString sAlign ( "center" );
1122 [ # # # # : 0 : switch ( rRuby.GetAdjustment( ) )
# # ]
1123 : : {
1124 : : case 0:
1125 : 0 : sAlign = OString( "left" );
1126 : 0 : break;
1127 : : case 1:
1128 : : // Defaults to center
1129 : 0 : break;
1130 : : case 2:
1131 : 0 : sAlign = OString( "right" );
1132 : 0 : break;
1133 : : case 3:
1134 : 0 : sAlign = OString( "distributeLetter" );
1135 : 0 : break;
1136 : : case 4:
1137 : 0 : sAlign = OString( "distributeSpace" );
1138 : 0 : break;
1139 : : default:
1140 : 0 : break;
1141 : : }
1142 : : m_pSerializer->singleElementNS( XML_w, XML_rubyAlign,
1143 [ # # ]: 0 : FSNS( XML_w, XML_val ), sAlign.getStr(), FSEND );
1144 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_rubyPr );
1145 : :
1146 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_rt, FSEND );
1147 [ # # ]: 0 : StartRun( NULL );
1148 [ # # ]: 0 : StartRunProperties( );
1149 [ # # ]: 0 : SwWW8AttrIter aAttrIt( m_rExport, rNode );
1150 [ # # ]: 0 : aAttrIt.OutAttr( nPos, true );
1151 [ # # ][ # # ]: 0 : sal_uInt16 nStyle = m_rExport.GetId( *rRuby.GetTxtRuby()->GetCharFmt() );
1152 : 0 : OString aStyleId( "style" );
1153 : 0 : aStyleId += OString::valueOf( sal_Int32( nStyle ) );
1154 : : m_pSerializer->singleElementNS( XML_w, XML_rStyle,
1155 [ # # ]: 0 : FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND );
1156 [ # # ]: 0 : EndRunProperties( NULL );
1157 [ # # ]: 0 : RunText( rRuby.GetText( ) );
1158 [ # # ]: 0 : EndRun( );
1159 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_rt );
1160 : :
1161 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_rubyBase, FSEND );
1162 [ # # ][ # # ]: 0 : StartRun( NULL );
1163 : 0 : }
1164 : :
1165 : 0 : void DocxAttributeOutput::EndRuby()
1166 : : {
1167 : : OSL_TRACE( "TODO DocxAttributeOutput::EndRuby()" );
1168 : 0 : EndRun( );
1169 : 0 : m_pSerializer->endElementNS( XML_w, XML_rubyBase );
1170 : 0 : m_pSerializer->endElementNS( XML_w, XML_ruby );
1171 : 0 : }
1172 : :
1173 : 3 : bool DocxAttributeOutput::AnalyzeURL( const String& rUrl, const String& rTarget, String* pLinkURL, String* pMark )
1174 : : {
1175 [ + - ]: 3 : bool bBookMarkOnly = AttributeOutputBase::AnalyzeURL( rUrl, rTarget, pLinkURL, pMark );
1176 : :
1177 [ + - ]: 3 : String sURL = *pLinkURL;
1178 [ + - ]: 3 : String sMark = *pMark;
1179 : :
1180 : 3 : bool bOutputField = sMark.Len();
1181 : :
1182 [ + - ]: 3 : if ( bOutputField )
1183 : : {
1184 [ - + ]: 3 : if ( bBookMarkOnly )
1185 [ # # ][ # # ]: 0 : sURL = FieldString( ww::eHYPERLINK );
[ # # ]
1186 : : else
1187 : : {
1188 [ + - ]: 3 : String sFld( FieldString( ww::eHYPERLINK ) );
1189 [ + - ]: 3 : sFld.APPEND_CONST_ASC( "\"" );
1190 [ + - ]: 3 : sURL.Insert( sFld, 0 );
1191 [ + - ][ + - ]: 3 : sURL += '\"';
1192 : : }
1193 : :
1194 [ + - ]: 3 : if ( sMark.Len() )
1195 [ + - ][ + - ]: 3 : ( ( sURL.APPEND_CONST_ASC( " \\l \"" ) ) += sMark ) += '\"';
[ + - ]
1196 : :
1197 [ - + ]: 3 : if ( rTarget.Len() )
1198 [ # # ][ # # ]: 0 : ( sURL.APPEND_CONST_ASC( " \\n " ) ) += rTarget;
1199 : : }
1200 : :
1201 [ + - ]: 3 : *pLinkURL = sURL;
1202 [ + - ]: 3 : *pMark = sMark;
1203 : :
1204 [ + - ][ + - ]: 3 : return bBookMarkOnly;
1205 : : }
1206 : :
1207 : 3 : bool DocxAttributeOutput::StartURL( const String& rUrl, const String& rTarget )
1208 : : {
1209 [ + - ]: 3 : String sMark;
1210 [ + - ]: 3 : String sUrl;
1211 : :
1212 [ + - ]: 3 : bool bBookmarkOnly = AnalyzeURL( rUrl, rTarget, &sUrl, &sMark );
1213 : :
1214 [ + - ][ + - ]: 3 : if ( sMark.Len() && !bBookmarkOnly )
[ + - ]
1215 : : {
1216 [ + - ]: 3 : m_rExport.OutputField( NULL, ww::eHYPERLINK, sUrl );
1217 : : }
1218 : : else
1219 : : {
1220 : : // Output a hyperlink XML element
1221 [ # # ]: 0 : m_pHyperlinkAttrList = m_pSerializer->createAttrList();
1222 : :
1223 [ # # ]: 0 : if ( !bBookmarkOnly )
1224 : : {
1225 [ # # ]: 0 : OUString osUrl( sUrl );
1226 : :
1227 [ # # ]: 0 : OString sId = rtl::OUStringToOString( GetExport().GetFilter().addRelation( m_pSerializer->getOutputStream(),
1228 : : S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" ),
1229 [ # # ][ # # ]: 0 : osUrl, true ), RTL_TEXTENCODING_UTF8 );
[ # # # # ]
[ # # ][ # # ]
1230 : :
1231 [ # # ]: 0 : m_pHyperlinkAttrList->add( FSNS( XML_r, XML_id), sId.getStr());
1232 : : }
1233 : : else
1234 : : m_pHyperlinkAttrList->add( FSNS( XML_w, XML_anchor ),
1235 [ # # ][ # # ]: 0 : OUStringToOString( OUString( sMark ), RTL_TEXTENCODING_UTF8 ).getStr( ) );
[ # # ]
1236 : :
1237 [ # # ]: 0 : OUString sTarget( rTarget );
1238 [ # # ]: 0 : if ( !sTarget.isEmpty() )
1239 : : {
1240 [ # # ]: 0 : OString soTarget = OUStringToOString( sTarget, RTL_TEXTENCODING_UTF8 );
1241 [ # # ]: 0 : m_pHyperlinkAttrList->add(FSNS( XML_w, XML_tgtFrame ), soTarget.getStr());
1242 : 0 : }
1243 : : }
1244 : :
1245 [ + - ][ + - ]: 3 : return true;
1246 : : }
1247 : :
1248 : 3 : bool DocxAttributeOutput::EndURL()
1249 : : {
1250 : 3 : m_closeHyperlinkInThisRun = true;
1251 : 3 : return true;
1252 : : }
1253 : :
1254 : 0 : void DocxAttributeOutput::FieldVanish( const String& rTxt, ww::eField eType )
1255 : : {
1256 : 0 : WriteField_Impl( NULL, eType, rTxt, WRITEFIELD_ALL );
1257 : 0 : }
1258 : :
1259 : 0 : void DocxAttributeOutput::Redline( const SwRedlineData* /*pRedline*/ )
1260 : : {
1261 : : OSL_TRACE( "TODO DocxAttributeOutput::Redline( const SwRedlineData* pRedline )" );
1262 : 0 : }
1263 : :
1264 : 165 : void DocxAttributeOutput::StartRedline( const SwRedlineData* pRedlineData )
1265 : : {
1266 : 165 : m_pRedlineData = pRedlineData;
1267 : :
1268 [ - + ]: 165 : if ( !m_pRedlineData )
1269 : 165 : return;
1270 : :
1271 : : // FIXME check if it's necessary to travel over the Next()'s in pRedlineData
1272 : :
1273 : 0 : OString aId( OString::valueOf( m_nRedlineId++ ) );
1274 : :
1275 [ # # ][ # # ]: 0 : const String &rAuthor( SW_MOD()->GetRedlineAuthor( pRedlineData->GetAuthor() ) );
1276 [ # # ][ # # ]: 0 : OString aAuthor( OUStringToOString( rAuthor, RTL_TEXTENCODING_UTF8 ) );
1277 : :
1278 [ # # ]: 0 : OString aDate( msfilter::util::DateTimeToOString( pRedlineData->GetTimeStamp() ) );
1279 : :
1280 [ # # # ]: 0 : switch ( pRedlineData->GetType() )
1281 : : {
1282 : : case nsRedlineType_t::REDLINE_INSERT:
1283 : : m_pSerializer->startElementNS( XML_w, XML_ins,
1284 : : FSNS( XML_w, XML_id ), aId.getStr(),
1285 : : FSNS( XML_w, XML_author ), aAuthor.getStr(),
1286 : : FSNS( XML_w, XML_date ), aDate.getStr(),
1287 [ # # ]: 0 : FSEND );
1288 : 0 : break;
1289 : :
1290 : : case nsRedlineType_t::REDLINE_DELETE:
1291 : : m_pSerializer->startElementNS( XML_w, XML_del,
1292 : : FSNS( XML_w, XML_id ), aId.getStr(),
1293 : : FSNS( XML_w, XML_author ), aAuthor.getStr(),
1294 : : FSNS( XML_w, XML_date ), aDate.getStr(),
1295 [ # # ]: 0 : FSEND );
1296 : 0 : break;
1297 : :
1298 : : case nsRedlineType_t::REDLINE_FORMAT:
1299 : : OSL_TRACE( "TODO DocxAttributeOutput::StartRedline()" );
1300 : : default:
1301 : 0 : break;
1302 : 165 : }
1303 : : }
1304 : :
1305 : 165 : void DocxAttributeOutput::EndRedline()
1306 : : {
1307 [ + - ]: 165 : if ( !m_pRedlineData )
1308 : 165 : return;
1309 : :
1310 [ # # # # ]: 0 : switch ( m_pRedlineData->GetType() )
1311 : : {
1312 : : case nsRedlineType_t::REDLINE_INSERT:
1313 : 0 : m_pSerializer->endElementNS( XML_w, XML_ins );
1314 : 0 : break;
1315 : :
1316 : : case nsRedlineType_t::REDLINE_DELETE:
1317 : 0 : m_pSerializer->endElementNS( XML_w, XML_del );
1318 : 0 : break;
1319 : :
1320 : : case nsRedlineType_t::REDLINE_FORMAT:
1321 : : OSL_TRACE( "TODO DocxAttributeOutput::EndRedline()" );
1322 : 0 : break;
1323 : : default:
1324 : 0 : break;
1325 : : }
1326 : :
1327 : 0 : m_pRedlineData = NULL;
1328 : : }
1329 : :
1330 : 0 : void DocxAttributeOutput::FormatDrop( const SwTxtNode& /*rNode*/, const SwFmtDrop& /*rSwFmtDrop*/, sal_uInt16 /*nStyle*/, ww8::WW8TableNodeInfo::Pointer_t /*pTextNodeInfo*/, ww8::WW8TableNodeInfoInner::Pointer_t )
1331 : : {
1332 : : OSL_TRACE( "TODO DocxAttributeOutput::FormatDrop( const SwTxtNode& rNode, const SwFmtDrop& rSwFmtDrop, sal_uInt16 nStyle )" );
1333 : 0 : }
1334 : :
1335 : 102 : void DocxAttributeOutput::ParagraphStyle( sal_uInt16 nStyle )
1336 : : {
1337 : 102 : OString aStyleId( "style" );
1338 : 102 : aStyleId += OString::valueOf( sal_Int32( nStyle ) );
1339 : :
1340 [ + - ]: 102 : m_pSerializer->singleElementNS( XML_w, XML_pStyle, FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND );
1341 : 102 : }
1342 : :
1343 : 60 : static OString impl_ConvertColor( const Color &rColor )
1344 : : {
1345 : 60 : OString color( "auto" );
1346 [ + + ]: 60 : if ( rColor.GetColor() != COL_AUTO )
1347 : : {
1348 : 45 : const char pHexDigits[] = "0123456789ABCDEF";
1349 : 45 : char pBuffer[] = "000000";
1350 : :
1351 : 45 : pBuffer[0] = pHexDigits[ ( rColor.GetRed() >> 4 ) & 0x0F ];
1352 : 45 : pBuffer[1] = pHexDigits[ rColor.GetRed() & 0x0F ];
1353 : 45 : pBuffer[2] = pHexDigits[ ( rColor.GetGreen() >> 4 ) & 0x0F ];
1354 : 45 : pBuffer[3] = pHexDigits[ rColor.GetGreen() & 0x0F ];
1355 : 45 : pBuffer[4] = pHexDigits[ ( rColor.GetBlue() >> 4 ) & 0x0F ];
1356 : 45 : pBuffer[5] = pHexDigits[ rColor.GetBlue() & 0x0F ];
1357 : :
1358 : 45 : color = OString( pBuffer );
1359 : : }
1360 : 60 : return color;
1361 : : }
1362 : :
1363 : 0 : static void impl_borderLine( FSHelperPtr pSerializer, sal_Int32 elementToken, const SvxBorderLine* pBorderLine, sal_uInt16 nDist )
1364 : : {
1365 [ # # ]: 0 : FastAttributeList* pAttr = pSerializer->createAttrList();
1366 : :
1367 : :
1368 : : // Compute val attribute value
1369 : : // Can be one of:
1370 : : // single, double,
1371 : : // basicWideOutline, basicWideInline
1372 : : // OOXml also supports those types of borders, but we'll try to play with the first ones.
1373 : : // thickThinMediumGap, thickThinLargeGap, thickThinSmallGap
1374 : : // thinThickLargeGap, thinThickMediumGap, thinThickSmallGap
1375 : 0 : const char* pVal = "none";
1376 [ # # ]: 0 : if ( !pBorderLine->isEmpty( ) )
1377 : : {
1378 [ # # # # : 0 : switch (pBorderLine->GetBorderLineStyle())
# # # # #
# # # # #
# ]
1379 : : {
1380 : : case table::BorderLineStyle::SOLID:
1381 : 0 : pVal = ( sal_Char* )"single";
1382 : 0 : break;
1383 : : case table::BorderLineStyle::DOTTED:
1384 : 0 : pVal = ( sal_Char* )"dotted";
1385 : 0 : break;
1386 : : case table::BorderLineStyle::DASHED:
1387 : 0 : pVal = ( sal_Char* )"dashed";
1388 : 0 : break;
1389 : : case table::BorderLineStyle::DOUBLE:
1390 : 0 : pVal = ( sal_Char* )"double";
1391 : 0 : break;
1392 : : case table::BorderLineStyle::THINTHICK_SMALLGAP:
1393 : 0 : pVal = ( sal_Char* )"thinThickSmallGap";
1394 : 0 : break;
1395 : : case table::BorderLineStyle::THINTHICK_MEDIUMGAP:
1396 : 0 : pVal = ( sal_Char* )"thinThickMediumGap";
1397 : 0 : break;
1398 : : case table::BorderLineStyle::THINTHICK_LARGEGAP:
1399 : 0 : pVal = ( sal_Char* )"thinThickLargeGap";
1400 : 0 : break;
1401 : : case table::BorderLineStyle::THICKTHIN_SMALLGAP:
1402 : 0 : pVal = ( sal_Char* )"thickThinSmallGap";
1403 : 0 : break;
1404 : : case table::BorderLineStyle::THICKTHIN_MEDIUMGAP:
1405 : 0 : pVal = ( sal_Char* )"thickThinMediumGap";
1406 : 0 : break;
1407 : : case table::BorderLineStyle::THICKTHIN_LARGEGAP:
1408 : 0 : pVal = ( sal_Char* )"thickThinLargeGap";
1409 : 0 : break;
1410 : : case table::BorderLineStyle::EMBOSSED:
1411 : 0 : pVal = ( sal_Char* )"threeDEmboss";
1412 : 0 : break;
1413 : : case table::BorderLineStyle::ENGRAVED:
1414 : 0 : pVal = ( sal_Char* )"threeDEngrave";
1415 : 0 : break;
1416 : : case table::BorderLineStyle::OUTSET:
1417 : 0 : pVal = ( sal_Char* )"outset";
1418 : 0 : break;
1419 : : case table::BorderLineStyle::INSET:
1420 : 0 : pVal = ( sal_Char* )"inset";
1421 : 0 : break;
1422 : : case table::BorderLineStyle::NONE:
1423 : : default:
1424 : 0 : break;
1425 : : }
1426 : : }
1427 : :
1428 [ # # ]: 0 : pAttr->add( FSNS( XML_w, XML_val ), OString( pVal ) );
1429 : :
1430 [ # # ]: 0 : if ( !pBorderLine->isEmpty() )
1431 : : {
1432 : : // Compute the sz attribute
1433 : :
1434 : : double const fConverted( ::editeng::ConvertBorderWidthToWord(
1435 [ # # ]: 0 : pBorderLine->GetBorderLineStyle(), pBorderLine->GetWidth()));
1436 : : // The unit is the 8th of point
1437 : 0 : sal_Int32 nWidth = sal_Int32( fConverted / 2.5 );
1438 : 0 : sal_uInt16 nMinWidth = 2;
1439 : 0 : sal_uInt16 nMaxWidth = 96;
1440 : :
1441 [ # # ]: 0 : if ( nWidth > nMaxWidth )
1442 : 0 : nWidth = nMaxWidth;
1443 [ # # ]: 0 : else if ( nWidth < nMinWidth )
1444 : 0 : nWidth = nMinWidth;
1445 : :
1446 [ # # ]: 0 : pAttr->add( FSNS( XML_w, XML_sz ), OString::valueOf( sal_Int32( nWidth ) ) );
1447 : :
1448 : : // Get the distance (in pt)
1449 [ # # ]: 0 : pAttr->add( FSNS( XML_w, XML_space ), OString::valueOf( sal_Int32( nDist / 20 ) ) );
1450 : :
1451 : : // Get the color code as an RRGGBB hex value
1452 [ # # ]: 0 : OString sColor( impl_ConvertColor( pBorderLine->GetColor( ) ) );
1453 [ # # ]: 0 : pAttr->add( FSNS( XML_w, XML_color ), sColor );
1454 : : }
1455 : :
1456 [ # # ][ # # ]: 0 : XFastAttributeListRef xAttrs( pAttr );
1457 [ # # ]: 0 : pSerializer->singleElementNS( XML_w, elementToken, xAttrs );
1458 : 0 : }
1459 : :
1460 : 0 : static void impl_pageBorders( FSHelperPtr pSerializer, const SvxBoxItem& rBox, bool bUseStartEnd = false )
1461 : : {
1462 : : static const sal_uInt16 aBorders[] =
1463 : : {
1464 : : BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT
1465 : : };
1466 : :
1467 : : const sal_Int32 aXmlElements[] =
1468 : : {
1469 : : XML_top,
1470 : : bUseStartEnd ? XML_start : XML_left,
1471 : : XML_bottom,
1472 : : bUseStartEnd ? XML_end : XML_right
1473 [ # # ][ # # ]: 0 : };
1474 : 0 : const sal_uInt16* pBrd = aBorders;
1475 [ # # ]: 0 : for( int i = 0; i < 4; ++i, ++pBrd )
1476 : : {
1477 [ # # ]: 0 : const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
1478 [ # # ]: 0 : if ( pLn )
1479 [ # # ][ # # ]: 0 : impl_borderLine( pSerializer, aXmlElements[i], pLn, 0 );
[ # # ]
1480 : : }
1481 : 0 : }
1482 : :
1483 : 0 : void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1484 : : {
1485 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_tcPr, FSEND );
1486 : :
1487 [ # # ]: 0 : const SwTableBox *pTblBox = pTableTextNodeInfoInner->getTableBox( );
1488 : :
1489 [ # # ][ # # ]: 0 : bool bEcma = GetExport().GetFilter().getVersion( ) == oox::core::ECMA_DIALECT;
1490 : :
1491 : : // Cell prefered width
1492 [ # # ][ # # ]: 0 : SwTwips nWidth = GetGridCols( pTableTextNodeInfoInner )->at( pTableTextNodeInfoInner->getCell() );
[ # # ][ # # ]
[ # # ][ # # ]
1493 [ # # ][ # # ]: 0 : if ( pTableTextNodeInfoInner->getCell() )
1494 [ # # ][ # # ]: 0 : nWidth = nWidth - GetGridCols( pTableTextNodeInfoInner )->at( pTableTextNodeInfoInner->getCell() - 1 );
[ # # ][ # # ]
[ # # ][ # # ]
1495 : : m_pSerializer->singleElementNS( XML_w, XML_tcW,
1496 : : FSNS( XML_w, XML_w ), OString::valueOf( sal_Int32( nWidth ) ).getStr( ),
1497 : : FSNS( XML_w, XML_type ), "dxa",
1498 [ # # ]: 0 : FSEND );
1499 : :
1500 : : // Horizontal spans
1501 : 0 : const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
1502 [ # # ][ # # ]: 0 : SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
1503 [ # # ][ # # ]: 0 : const SwWriteTableCell *pCell = &pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ];
1504 : :
1505 : 0 : sal_uInt16 nColSpan = pCell->GetColSpan();
1506 [ # # ]: 0 : if ( nColSpan > 1 )
1507 : : m_pSerializer->singleElementNS( XML_w, XML_gridSpan,
1508 : : FSNS( XML_w, XML_val ), OString::valueOf( sal_Int32( nColSpan ) ).getStr(),
1509 [ # # ]: 0 : FSEND );
1510 : :
1511 : : // Vertical merges
1512 [ # # ]: 0 : long vSpan = pTblBox->getRowSpan( );
1513 [ # # ]: 0 : if ( vSpan > 1 )
1514 : : {
1515 : : m_pSerializer->singleElementNS( XML_w, XML_vMerge,
1516 : : FSNS( XML_w, XML_val ), "restart",
1517 [ # # ]: 0 : FSEND );
1518 : : }
1519 [ # # ]: 0 : else if ( vSpan < 0 )
1520 : : {
1521 : : m_pSerializer->singleElementNS( XML_w, XML_vMerge,
1522 : : FSNS( XML_w, XML_val ), "continue",
1523 [ # # ]: 0 : FSEND );
1524 : : }
1525 : :
1526 : : // The cell borders
1527 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_tcBorders, FSEND );
1528 : 0 : SwFrmFmt *pFmt = pTblBox->GetFrmFmt( );
1529 [ # # ][ # # ]: 0 : impl_pageBorders( m_pSerializer, pFmt->GetBox( ), !bEcma );
[ # # ][ # # ]
1530 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_tcBorders );
1531 : :
1532 [ # # ][ # # ]: 0 : TableBackgrounds( pTableTextNodeInfoInner );
[ # # ]
1533 : :
1534 : : // Cell margins
1535 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_tcMar, FSEND );
1536 [ # # ]: 0 : const SvxBoxItem& rBox = pFmt->GetBox( );
1537 : : static const sal_uInt16 aBorders[] =
1538 : : {
1539 : : BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT
1540 : : };
1541 : :
1542 : : const sal_Int32 aXmlElements[] =
1543 : : {
1544 : : XML_top,
1545 : : bEcma ? XML_left : XML_start,
1546 : : XML_bottom,
1547 : : bEcma ? XML_right : XML_end
1548 [ # # ][ # # ]: 0 : };
1549 : 0 : const sal_uInt16* pBrd = aBorders;
1550 [ # # ]: 0 : for( int i = 0; i < 4; ++i, ++pBrd )
1551 : : {
1552 [ # # ]: 0 : sal_Int32 nDist = sal_Int32( rBox.GetDistance( *pBrd ) );
1553 : 0 : m_pSerializer->singleElementNS( XML_w, aXmlElements[i],
1554 : : FSNS( XML_w, XML_w ), OString::valueOf( nDist ).getStr( ),
1555 : : FSNS( XML_w, XML_type ), "dxa",
1556 [ # # ]: 0 : FSEND );
1557 : : }
1558 : :
1559 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_tcMar );
1560 : :
1561 [ # # ][ # # ]: 0 : TableVerticalCell( pTableTextNodeInfoInner );
[ # # ]
1562 : :
1563 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_tcPr );
1564 : 0 : }
1565 : :
1566 : 0 : void DocxAttributeOutput::InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1567 : : {
1568 : 0 : sal_uInt32 nPageSize = 0;
1569 : 0 : bool bRelBoxSize = false;
1570 : :
1571 : : // Create the SwWriteTable instance to use col spans (and maybe other infos)
1572 [ # # ]: 0 : GetTablePageSize( pTableTextNodeInfoInner.get(), nPageSize, bRelBoxSize );
1573 : :
1574 [ # # ]: 0 : const SwTable* pTable = pTableTextNodeInfoInner->getTable( );
1575 : 0 : const SwFrmFmt *pFmt = pTable->GetFrmFmt( );
1576 [ # # ]: 0 : SwTwips nTblSz = pFmt->GetFrmSize( ).GetWidth( );
1577 : :
1578 : 0 : const SwHTMLTableLayout *pLayout = pTable->GetHTMLTableLayout();
1579 [ # # ][ # # ]: 0 : if( pLayout && pLayout->IsExportable() )
[ # # ]
1580 [ # # ][ # # ]: 0 : m_pTableWrt = new SwWriteTable( pLayout );
1581 : : else
1582 : : m_pTableWrt = new SwWriteTable( pTable->GetTabLines(), (sal_uInt16)nPageSize,
1583 [ # # ][ # # ]: 0 : (sal_uInt16)nTblSz, false);
1584 : 0 : }
1585 : :
1586 : 0 : void DocxAttributeOutput::StartTable( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1587 : : {
1588 : 0 : m_pSerializer->startElementNS( XML_w, XML_tbl, FSEND );
1589 : :
1590 [ # # ]: 0 : InitTableHelper( pTableTextNodeInfoInner );
1591 [ # # ]: 0 : TableDefinition( pTableTextNodeInfoInner );
1592 : 0 : }
1593 : :
1594 : 0 : void DocxAttributeOutput::EndTable()
1595 : : {
1596 : 0 : m_pSerializer->endElementNS( XML_w, XML_tbl );
1597 : :
1598 [ # # ]: 0 : if ( m_nTableDepth > 0 )
1599 : 0 : --m_nTableDepth;
1600 : :
1601 : : // We closed the table; if it is a nested table, the cell that contains it
1602 : : // still continues
1603 : 0 : m_bTableCellOpen = true;
1604 : :
1605 : : // Cleans the table helper
1606 [ # # ]: 0 : delete m_pTableWrt, m_pTableWrt = NULL;
1607 : 0 : }
1608 : :
1609 : 0 : void DocxAttributeOutput::StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1610 : : {
1611 : 0 : m_pSerializer->startElementNS( XML_w, XML_tr, FSEND );
1612 : :
1613 : : // Output the row properties
1614 : 0 : m_pSerializer->startElementNS( XML_w, XML_trPr, FSEND );
1615 : :
1616 : : // Header row: tblHeader
1617 : 0 : const SwTable *pTable = pTableTextNodeInfoInner->getTable( );
1618 [ # # ]: 0 : if ( pTable->GetRowsToRepeat( ) > pTableTextNodeInfoInner->getRow( ) )
1619 : : m_pSerializer->singleElementNS( XML_w, XML_tblHeader,
1620 : : FSNS( XML_w, XML_val ), "true",
1621 : 0 : FSEND );
1622 : :
1623 [ # # ]: 0 : TableHeight( pTableTextNodeInfoInner );
1624 [ # # ]: 0 : TableCanSplit( pTableTextNodeInfoInner );
1625 : :
1626 : 0 : m_pSerializer->endElementNS( XML_w, XML_trPr );
1627 : 0 : }
1628 : :
1629 : 0 : void DocxAttributeOutput::EndTableRow( )
1630 : : {
1631 : 0 : m_pSerializer->endElementNS( XML_w, XML_tr );
1632 : 0 : }
1633 : :
1634 : 0 : void DocxAttributeOutput::StartTableCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1635 : : {
1636 [ # # ]: 0 : if ( !m_pTableWrt )
1637 [ # # ]: 0 : InitTableHelper( pTableTextNodeInfoInner );
1638 : :
1639 : 0 : m_pSerializer->startElementNS( XML_w, XML_tc, FSEND );
1640 : :
1641 : : // Write the cell properties here
1642 [ # # ]: 0 : TableCellProperties( pTableTextNodeInfoInner );
1643 : :
1644 : 0 : m_bTableCellOpen = true;
1645 : 0 : }
1646 : :
1647 : 0 : void DocxAttributeOutput::EndTableCell( )
1648 : : {
1649 : 0 : m_pSerializer->endElementNS( XML_w, XML_tc );
1650 : :
1651 : 0 : m_bTableCellOpen = false;
1652 : 0 : }
1653 : :
1654 : 0 : void DocxAttributeOutput::TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
1655 : : {
1656 : 0 : }
1657 : :
1658 : 0 : void DocxAttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfo*/ )
1659 : : {
1660 : 0 : }
1661 : :
1662 : 0 : void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1663 : : {
1664 [ # # ][ # # ]: 0 : bool bEcma = GetExport().GetFilter().getVersion( ) == oox::core::ECMA_DIALECT;
1665 : :
1666 : : // Write the table properties
1667 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_tblPr, FSEND );
1668 : :
1669 : : static const sal_Int32 aOrder[] =
1670 : : {
1671 : : FSNS( XML_w, XML_tblStyle ),
1672 : : FSNS( XML_w, XML_tblpPr ),
1673 : : FSNS( XML_w, XML_tblOverlap ),
1674 : : FSNS( XML_w, XML_bidiVisual ),
1675 : : FSNS( XML_w, XML_tblStyleRowBandSize ),
1676 : : FSNS( XML_w, XML_tblStyleColBandSize ),
1677 : : FSNS( XML_w, XML_tblW ),
1678 : : FSNS( XML_w, XML_jc ),
1679 : : FSNS( XML_w, XML_tblCellSpacing ),
1680 : : FSNS( XML_w, XML_tblInd ),
1681 : : FSNS( XML_w, XML_tblBorders ),
1682 : : FSNS( XML_w, XML_shd ),
1683 : : FSNS( XML_w, XML_tblLayout ),
1684 : : FSNS( XML_w, XML_tblCellMar ),
1685 : : FSNS( XML_w, XML_tblLook ),
1686 : : FSNS( XML_w, XML_tblPrChange )
1687 : : };
1688 : :
1689 : : // postpone the output so that we can later []
1690 : : // prepend the properties before the run
1691 : 0 : sal_Int32 len = sizeof ( aOrder ) / sizeof( sal_Int32 );
1692 [ # # ]: 0 : uno::Sequence< sal_Int32 > aSeqOrder( len );
1693 [ # # ]: 0 : for ( sal_Int32 i = 0; i < len; i++ )
1694 [ # # ]: 0 : aSeqOrder[i] = aOrder[i];
1695 : :
1696 [ # # ][ # # ]: 0 : m_pSerializer->mark( aSeqOrder );
[ # # ]
1697 : :
1698 : 0 : sal_uInt32 nPageSize = 0;
1699 : 0 : bool bRelBoxSize = false;
1700 : :
1701 : : // Create the SwWriteTable instance to use col spans (and maybe other infos)
1702 [ # # ]: 0 : GetTablePageSize( pTableTextNodeInfoInner.get(), nPageSize, bRelBoxSize );
1703 : :
1704 : : // Output the table prefered width
1705 [ # # ]: 0 : if ( nPageSize != 0 )
1706 : : m_pSerializer->singleElementNS( XML_w, XML_tblW,
1707 : : FSNS( XML_w, XML_w ), OString::valueOf( sal_Int32( nPageSize ) ).getStr( ),
1708 : : FSNS( XML_w, XML_type ), "dxa",
1709 [ # # ]: 0 : FSEND );
1710 : :
1711 : : // Output the table alignement
1712 [ # # ]: 0 : const SwTable *pTable = pTableTextNodeInfoInner->getTable();
1713 : 0 : SwFrmFmt *pTblFmt = pTable->GetFrmFmt( );
1714 : : const char* pJcVal;
1715 : 0 : sal_Int32 nIndent = 0;
1716 [ # # # ]: 0 : switch ( pTblFmt->GetHoriOrient( ).GetHoriOrient( ) )
[ # # ]
1717 : : {
1718 : : case text::HoriOrientation::CENTER:
1719 : 0 : pJcVal = "center";
1720 : 0 : break;
1721 : : case text::HoriOrientation::RIGHT:
1722 [ # # ]: 0 : if ( bEcma )
1723 : 0 : pJcVal = "right";
1724 : : else
1725 : 0 : pJcVal = "end";
1726 : 0 : break;
1727 : : default:
1728 : : case text::HoriOrientation::NONE:
1729 : : case text::HoriOrientation::LEFT_AND_WIDTH:
1730 : : {
1731 [ # # ]: 0 : if ( bEcma )
1732 : 0 : pJcVal = "left";
1733 : : else
1734 : 0 : pJcVal = "start";
1735 [ # # ]: 0 : nIndent = sal_Int32( pTblFmt->GetLRSpace( ).GetLeft( ) );
1736 : 0 : break;
1737 : : }
1738 : : }
1739 : : m_pSerializer->singleElementNS( XML_w, XML_jc,
1740 : : FSNS( XML_w, XML_val ), pJcVal,
1741 [ # # ]: 0 : FSEND );
1742 : :
1743 : : // Output the table borders
1744 [ # # ][ # # ]: 0 : TableDefaultBorders( pTableTextNodeInfoInner );
[ # # ]
1745 [ # # ][ # # ]: 0 : TableBidi( pTableTextNodeInfoInner );
[ # # ]
1746 : :
1747 : : // Table indent
1748 [ # # ]: 0 : if ( nIndent != 0 )
1749 : : m_pSerializer->singleElementNS( XML_w, XML_tblInd,
1750 : : FSNS( XML_w, XML_w ), OString::valueOf( nIndent ).getStr( ),
1751 : : FSNS( XML_w, XML_type ), "dxa",
1752 [ # # ]: 0 : FSEND );
1753 : :
1754 : : // Merge the marks for the ordered elements
1755 [ # # ]: 0 : m_pSerializer->mergeTopMarks( );
1756 : :
1757 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_tblPr );
1758 : :
1759 : : // Write the table grid infos
1760 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_tblGrid, FSEND );
1761 : 0 : sal_Int32 nPrv = 0;
1762 [ # # ][ # # ]: 0 : ww8::GridColsPtr pGridCols = GetGridCols( pTableTextNodeInfoInner );
[ # # ]
1763 [ # # ][ # # ]: 0 : for ( ww8::GridCols::const_iterator it = pGridCols->begin(); it != pGridCols->end(); ++it )
[ # # ][ # # ]
1764 : : {
1765 [ # # ]: 0 : sal_Int32 nWidth = sal_Int32( *it ) - nPrv;
1766 : : m_pSerializer->singleElementNS( XML_w, XML_gridCol,
1767 : : FSNS( XML_w, XML_w ), OString::valueOf( nWidth ).getStr( ),
1768 [ # # ]: 0 : FSEND );
1769 [ # # ]: 0 : nPrv = sal_Int32( *it );
1770 : : }
1771 : :
1772 [ # # ][ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_tblGrid );
[ # # ]
1773 : 0 : }
1774 : :
1775 : 0 : void DocxAttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1776 : : {
1777 : 0 : const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
1778 : 0 : const SwFrmFmt * pFrmFmt = pTabBox->GetFrmFmt();
1779 : :
1780 : 0 : bool bEcma = GetExport().GetFilter().getVersion( ) == oox::core::ECMA_DIALECT;
1781 : :
1782 : : // the defaults of the table are taken from the top-left cell
1783 : 0 : m_pSerializer->startElementNS( XML_w, XML_tblBorders, FSEND );
1784 [ # # ]: 0 : impl_pageBorders( m_pSerializer, pFrmFmt->GetBox( ), !bEcma );
1785 : 0 : m_pSerializer->endElementNS( XML_w, XML_tblBorders );
1786 : 0 : }
1787 : :
1788 : 0 : void DocxAttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1789 : : {
1790 [ # # ]: 0 : const SwTableBox *pTblBox = pTableTextNodeInfoInner->getTableBox( );
1791 : 0 : const SwFrmFmt *pFmt = pTblBox->GetFrmFmt( );
1792 : 0 : const SfxPoolItem *pI = NULL;
1793 : :
1794 : 0 : Color aColor;
1795 [ # # ][ # # ]: 0 : if ( SFX_ITEM_ON == pFmt->GetAttrSet().GetItemState( RES_BACKGROUND, false, &pI ) )
1796 [ # # ]: 0 : aColor = dynamic_cast<const SvxBrushItem *>(pI)->GetColor();
1797 : : else
1798 : 0 : aColor = COL_AUTO;
1799 : :
1800 [ # # ]: 0 : OString sColor = impl_ConvertColor( aColor );
1801 : : m_pSerializer->singleElementNS( XML_w, XML_shd,
1802 : : FSNS( XML_w, XML_fill ), sColor.getStr( ),
1803 : : FSNS( XML_w, XML_val ), "clear",
1804 [ # # ]: 0 : FSEND );
1805 : 0 : }
1806 : :
1807 : 0 : void DocxAttributeOutput::TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1808 : : {
1809 : 0 : const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
1810 : 0 : const SwTableLine * pTabLine = pTabBox->GetUpper();
1811 : 0 : const SwFrmFmt * pLineFmt = pTabLine->GetFrmFmt();
1812 : :
1813 : 0 : const SwFmtFrmSize& rLSz = pLineFmt->GetFrmSize();
1814 [ # # ][ # # ]: 0 : if ( ATT_VAR_SIZE != rLSz.GetHeightSizeType() && rLSz.GetHeight() )
[ # # ]
1815 : : {
1816 : 0 : sal_Int32 nHeight = rLSz.GetHeight();
1817 : 0 : const char *pRule = NULL;
1818 : :
1819 [ # # # ]: 0 : switch ( rLSz.GetHeightSizeType() )
1820 : : {
1821 : 0 : case ATT_FIX_SIZE: pRule = "exact"; break;
1822 : 0 : case ATT_MIN_SIZE: pRule = "atLeast"; break;
1823 : 0 : default: break;
1824 : : }
1825 : :
1826 [ # # ]: 0 : if ( pRule )
1827 : : m_pSerializer->singleElementNS( XML_w, XML_trHeight,
1828 : : FSNS( XML_w, XML_val ), OString::valueOf( nHeight ).getStr( ),
1829 : : FSNS( XML_w, XML_hRule ), pRule,
1830 [ # # ]: 0 : FSEND );
1831 : : }
1832 : 0 : }
1833 : :
1834 : 0 : void DocxAttributeOutput::TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1835 : : {
1836 : 0 : const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
1837 : 0 : const SwTableLine * pTabLine = pTabBox->GetUpper();
1838 : 0 : const SwFrmFmt * pLineFmt = pTabLine->GetFrmFmt();
1839 : :
1840 : 0 : const SwFmtRowSplit& rSplittable = pLineFmt->GetRowSplit( );
1841 [ # # ]: 0 : const char* pCantSplit = ( !rSplittable.GetValue( ) ) ? "true" : "false";
1842 : :
1843 : : m_pSerializer->singleElementNS( XML_w, XML_cantSplit,
1844 : : FSNS( XML_w, XML_val ), pCantSplit,
1845 : 0 : FSEND );
1846 : 0 : }
1847 : :
1848 : 0 : void DocxAttributeOutput::TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1849 : : {
1850 : 0 : const SwTable * pTable = pTableTextNodeInfoInner->getTable();
1851 : 0 : const SwFrmFmt * pFrmFmt = pTable->GetFrmFmt();
1852 : :
1853 [ # # ]: 0 : if ( m_rExport.TrueFrameDirection( *pFrmFmt ) == FRMDIR_HORI_RIGHT_TOP )
1854 : : {
1855 : : m_pSerializer->singleElementNS( XML_w, XML_bidiVisual,
1856 : : FSNS( XML_w, XML_val ), "true",
1857 : 0 : FSEND );
1858 : : }
1859 : 0 : }
1860 : :
1861 : 0 : void DocxAttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1862 : : {
1863 : 0 : const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
1864 : 0 : const SwFrmFmt *pFrmFmt = pTabBox->GetFrmFmt( );
1865 : :
1866 [ # # ]: 0 : if ( FRMDIR_VERT_TOP_RIGHT == m_rExport.TrueFrameDirection( *pFrmFmt ) )
1867 : : m_pSerializer->singleElementNS( XML_w, XML_textDirection,
1868 : : FSNS( XML_w, XML_val ), "tbRl",
1869 : 0 : FSEND );
1870 : :
1871 : 0 : const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
1872 : 0 : SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
1873 : 0 : const SwWriteTableCell *pCell = &pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ];
1874 [ # # # # ]: 0 : switch( pCell->GetVertOri())
1875 : : {
1876 : : case text::VertOrientation::TOP:
1877 : 0 : break;
1878 : : case text::VertOrientation::CENTER:
1879 : : m_pSerializer->singleElementNS( XML_w, XML_vAlign,
1880 : 0 : FSNS( XML_w, XML_val ), "center", FSEND );
1881 : 0 : break;
1882 : : case text::VertOrientation::BOTTOM:
1883 : : m_pSerializer->singleElementNS( XML_w, XML_vAlign,
1884 : 0 : FSNS( XML_w, XML_val ), "bottom", FSEND );
1885 : 0 : break;
1886 : : }
1887 : 0 : }
1888 : :
1889 : 0 : void DocxAttributeOutput::TableNodeInfo( ww8::WW8TableNodeInfo::Pointer_t /*pNodeInfo*/ )
1890 : : {
1891 : : OSL_TRACE( "TODO: DocxAttributeOutput::TableNodeInfo( ww8::WW8TableNodeInfo::Pointer_t pNodeInfo )" );
1892 : 0 : }
1893 : :
1894 : 0 : void DocxAttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner )
1895 : : {
1896 : : // This is called when the nested table ends in a cell, and there's no
1897 : : // paragraph benhind that; so we must check for the ends of cell, rows,
1898 : : // tables
1899 : : // ['true' to write an empty paragraph, MS Word insists on that]
1900 [ # # ]: 0 : FinishTableRowCell( pNodeInfoInner, true );
1901 : 0 : }
1902 : :
1903 : 0 : void DocxAttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
1904 : : {
1905 : : OSL_TRACE( "TODO: DocxAttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )" );
1906 : 0 : }
1907 : :
1908 : 0 : void DocxAttributeOutput::TableSpacing( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
1909 : : {
1910 : : #if OSL_DEBUG_LEVEL > 1
1911 : : fprintf( stderr, "TODO: DocxAttributeOutput::TableSpacing( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )\n" );
1912 : : #endif
1913 : 0 : }
1914 : :
1915 : 0 : void DocxAttributeOutput::TableRowEnd( sal_uInt32 /*nDepth*/ )
1916 : : {
1917 : : OSL_TRACE( "TODO: DocxAttributeOutput::TableRowEnd( sal_uInt32 nDepth = 1 )" );
1918 : 0 : }
1919 : :
1920 : 57 : void DocxAttributeOutput::StartStyles()
1921 : : {
1922 : : m_pSerializer->startElementNS( XML_w, XML_styles,
1923 : : FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
1924 : 57 : FSEND );
1925 : 57 : }
1926 : :
1927 : 57 : void DocxAttributeOutput::EndStyles( sal_uInt16 /*nNumberOfStyles*/ )
1928 : : {
1929 : 57 : m_pSerializer->endElementNS( XML_w, XML_styles );
1930 : 57 : }
1931 : :
1932 : 798 : void DocxAttributeOutput::DefaultStyle( sal_uInt16 nStyle )
1933 : : {
1934 : : // are these the values of enum ww::sti (see ../inc/wwstyles.hxx)?
1935 : : #if OSL_DEBUG_LEVEL > 1
1936 : : OSL_TRACE( "TODO DocxAttributeOutput::DefaultStyle( sal_uInt16 nStyle )- %d", nStyle );
1937 : : #else
1938 : : (void) nStyle; // to quiet the warning
1939 : : #endif
1940 : 798 : }
1941 : :
1942 : 0 : void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size& rSize )
1943 : : {
1944 : : OSL_TRACE( "TODO DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size& rSize ) - some stuff still missing" );
1945 : : // create the relation ID
1946 : 0 : OString aRelId;
1947 : : sal_Int32 nImageType;
1948 [ # # ]: 0 : if ( rGrfNode.IsLinkedFile() )
1949 : : {
1950 : : // linked image, just create the relation
1951 [ # # ]: 0 : String aFileName;
1952 [ # # ]: 0 : rGrfNode.GetFileFilterNms( &aFileName, 0 );
1953 : :
1954 : : // TODO Convert the file name to relative for better interoperability
1955 : :
1956 : : aRelId = m_rExport.AddRelation(
1957 : : S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" ),
1958 [ # # ][ # # ]: 0 : OUString( aFileName ) );
[ # # ][ # # ]
[ # # ]
1959 : :
1960 [ # # ]: 0 : nImageType = XML_link;
1961 : : }
1962 : : else
1963 : : {
1964 : : // inline, we also have to write the image itself
1965 [ # # ]: 0 : Graphic& rGraphic = const_cast< Graphic& >( rGrfNode.GetGrf() );
1966 : :
1967 [ # # ][ # # ]: 0 : m_rDrawingML.SetFS( m_pSerializer ); // to be sure that we write to the right stream
[ # # ]
1968 [ # # ]: 0 : OUString aImageId = m_rDrawingML.WriteImage( rGraphic );
1969 : :
1970 [ # # ]: 0 : aRelId = OUStringToOString( aImageId, RTL_TEXTENCODING_UTF8 );
1971 : :
1972 : 0 : nImageType = XML_embed;
1973 : : }
1974 : :
1975 [ # # ]: 0 : if ( aRelId.isEmpty() )
1976 : 0 : return;
1977 : :
1978 : : m_pSerializer->startElementNS( XML_w, XML_drawing,
1979 [ # # ]: 0 : FSEND );
1980 [ # # ][ # # ]: 0 : bool isAnchor = rGrfNode.GetFlyFmt()->GetAnchor().GetAnchorId() != FLY_AS_CHAR;
1981 [ # # ]: 0 : if( isAnchor )
1982 : : {
1983 [ # # ]: 0 : ::sax_fastparser::FastAttributeList* attrList = m_pSerializer->createAttrList();
1984 [ # # ][ # # ]: 0 : attrList->add( XML_behindDoc, rGrfNode.GetFlyFmt()->GetOpaque().GetValue() ? "0" : "1" );
[ # # ][ # # ]
1985 [ # # ]: 0 : attrList->add( XML_distT, "0" );
1986 [ # # ]: 0 : attrList->add( XML_distB, "0" );
1987 [ # # ]: 0 : attrList->add( XML_distL, "0" );
1988 [ # # ]: 0 : attrList->add( XML_distR, "0" );
1989 [ # # ]: 0 : attrList->add( XML_simplePos, "0" );
1990 [ # # ]: 0 : attrList->add( XML_locked, "0" );
1991 [ # # ]: 0 : attrList->add( XML_layoutInCell, "1" );
1992 [ # # ]: 0 : attrList->add( XML_allowOverlap, "1" ); // TODO
1993 [ # # ][ # # ]: 0 : if( const SdrObject* pObj = rGrfNode.GetFlyFmt()->FindRealSdrObject())
[ # # ]
1994 [ # # ][ # # ]: 0 : attrList->add( XML_relativeHeight, OString::valueOf( sal_Int32( pObj->GetOrdNum())));
1995 [ # # ][ # # ]: 0 : m_pSerializer->startElementNS( XML_wp, XML_anchor, XFastAttributeListRef( attrList ));
[ # # ]
1996 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_wp, XML_simplePos, XML_x, "0", XML_y, "0", FSEND ); // required, unused
1997 : : const char* relativeFromH;
1998 : : const char* relativeFromV;
1999 [ # # ][ # # ]: 0 : switch( rGrfNode.GetFlyFmt()->GetAnchor().GetAnchorId())
[ # # # ]
2000 : : {
2001 : : case FLY_AT_PAGE:
2002 : 0 : relativeFromV = relativeFromH = "page";
2003 : 0 : break;
2004 : : case FLY_AT_PARA:
2005 : 0 : relativeFromH = "column";
2006 : 0 : relativeFromV = "paragraph";
2007 : 0 : break;
2008 : : case FLY_AT_CHAR:
2009 : : default:
2010 : 0 : relativeFromH = "character";
2011 : 0 : relativeFromV = "line";
2012 : 0 : break;
2013 : : };
2014 : 0 : Point pos( 0, 0 );
2015 [ # # ][ # # ]: 0 : if( SwFlyFrmFmt* flyfmt = dynamic_cast<SwFlyFrmFmt*>(rGrfNode.GetFlyFmt())) // TODO is always true?
[ # # ]
2016 [ # # ][ # # ]: 0 : pos = flyfmt->GetAnchoredObj()->GetCurrRelPos();
2017 : 0 : OString x( OString::valueOf( TwipsToEMU( pos.X())));
2018 : 0 : OString y( OString::valueOf( TwipsToEMU( pos.Y())));
2019 [ # # ]: 0 : m_pSerializer->startElementNS( XML_wp, XML_positionH, XML_relativeFrom, relativeFromH, FSEND );
2020 [ # # ]: 0 : m_pSerializer->startElementNS( XML_wp, XML_posOffset, FSEND );
2021 [ # # ]: 0 : m_pSerializer->write( x.getStr() );
2022 [ # # ]: 0 : m_pSerializer->endElementNS( XML_wp, XML_posOffset );
2023 [ # # ]: 0 : m_pSerializer->endElementNS( XML_wp, XML_positionH );
2024 [ # # ]: 0 : m_pSerializer->startElementNS( XML_wp, XML_positionV, XML_relativeFrom, relativeFromV, FSEND );
2025 [ # # ]: 0 : m_pSerializer->startElementNS( XML_wp, XML_posOffset, FSEND );
2026 [ # # ]: 0 : m_pSerializer->write( y.getStr() );
2027 [ # # ]: 0 : m_pSerializer->endElementNS( XML_wp, XML_posOffset );
2028 [ # # ]: 0 : m_pSerializer->endElementNS( XML_wp, XML_positionV );
2029 : : }
2030 : : else
2031 : : {
2032 : : m_pSerializer->startElementNS( XML_wp, XML_inline,
2033 : : XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0",
2034 [ # # ]: 0 : FSEND );
2035 : : }
2036 : : // now the common parts
2037 : : // extent of the image
2038 : 0 : OString aWidth( OString::valueOf( TwipsToEMU( rSize.Width() ) ) );
2039 : 0 : OString aHeight( OString::valueOf( TwipsToEMU( rSize.Height() ) ) );
2040 : : m_pSerializer->singleElementNS( XML_wp, XML_extent,
2041 : : XML_cx, aWidth.getStr(),
2042 : : XML_cy, aHeight.getStr(),
2043 [ # # ]: 0 : FSEND );
2044 : : // TODO - the right effectExtent, extent including the effect
2045 : : m_pSerializer->singleElementNS( XML_wp, XML_effectExtent,
2046 : : XML_l, "0", XML_t, "0", XML_r, "0", XML_b, "0",
2047 [ # # ]: 0 : FSEND );
2048 : :
2049 [ # # ]: 0 : if( isAnchor )
2050 : : {
2051 [ # # ][ # # ]: 0 : switch( rGrfNode.GetFlyFmt()->GetSurround().GetValue())
[ # # # # ]
2052 : : {
2053 : : case SURROUND_NONE:
2054 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_wp, XML_wrapTopAndBottom, FSEND );
2055 : 0 : break;
2056 : : case SURROUND_THROUGHT:
2057 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_wp, XML_wrapNone, FSEND );
2058 : 0 : break;
2059 : : case SURROUND_PARALLEL:
2060 : : m_pSerializer->singleElementNS( XML_wp, XML_wrapSquare,
2061 [ # # ]: 0 : XML_wrapText, "bothSides", FSEND );
2062 : 0 : break;
2063 : : case SURROUND_IDEAL:
2064 : : default:
2065 : : m_pSerializer->singleElementNS( XML_wp, XML_wrapSquare,
2066 [ # # ]: 0 : XML_wrapText, "largest", FSEND );
2067 : 0 : break;
2068 : : }
2069 : : }
2070 : : // picture description (used for pic:cNvPr later too)
2071 [ # # ]: 0 : ::sax_fastparser::FastAttributeList* docPrattrList = m_pSerializer->createAttrList();
2072 [ # # ]: 0 : docPrattrList->add( XML_id, OString::valueOf( sal_Int32( m_anchorId++ )).getStr());
2073 [ # # ]: 0 : docPrattrList->add( XML_name, "Picture" );
2074 [ # # ][ # # ]: 0 : docPrattrList->add( XML_descr, OUStringToOString( rGrfNode.GetDescription(), RTL_TEXTENCODING_UTF8 ).getStr());
[ # # ][ # # ]
[ # # ]
2075 [ # # ][ # # ]: 0 : if( GetExport().GetFilter().getVersion( ) != oox::core::ECMA_DIALECT )
[ # # ]
2076 [ # # ][ # # ]: 0 : docPrattrList->add( XML_title, OUStringToOString( rGrfNode.GetTitle(), RTL_TEXTENCODING_UTF8 ).getStr());
[ # # ][ # # ]
[ # # ]
2077 [ # # ][ # # ]: 0 : XFastAttributeListRef docPrAttrListRef( docPrattrList );
2078 [ # # ]: 0 : m_pSerializer->startElementNS( XML_wp, XML_docPr, docPrAttrListRef );
2079 : : // TODO hyperlink
2080 : : // m_pSerializer->singleElementNS( XML_a, XML_hlinkClick,
2081 : : // FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main",
2082 : : // FSNS( XML_r, XML_id ), "rId4",
2083 : : // FSEND );
2084 [ # # ]: 0 : m_pSerializer->endElementNS( XML_wp, XML_docPr );
2085 : :
2086 : : m_pSerializer->startElementNS( XML_wp, XML_cNvGraphicFramePr,
2087 [ # # ]: 0 : FSEND );
2088 : : // TODO change aspect?
2089 : : m_pSerializer->singleElementNS( XML_a, XML_graphicFrameLocks,
2090 : : FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main",
2091 : : XML_noChangeAspect, "1",
2092 [ # # ]: 0 : FSEND );
2093 [ # # ]: 0 : m_pSerializer->endElementNS( XML_wp, XML_cNvGraphicFramePr );
2094 : :
2095 : : m_pSerializer->startElementNS( XML_a, XML_graphic,
2096 : : FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main",
2097 [ # # ]: 0 : FSEND );
2098 : : m_pSerializer->startElementNS( XML_a, XML_graphicData,
2099 : : XML_uri, "http://schemas.openxmlformats.org/drawingml/2006/picture",
2100 [ # # ]: 0 : FSEND );
2101 : :
2102 : : m_pSerializer->startElementNS( XML_pic, XML_pic,
2103 : : FSNS( XML_xmlns, XML_pic ), "http://schemas.openxmlformats.org/drawingml/2006/picture",
2104 [ # # ]: 0 : FSEND );
2105 : :
2106 : : m_pSerializer->startElementNS( XML_pic, XML_nvPicPr,
2107 [ # # ]: 0 : FSEND );
2108 : : // It seems pic:cNvpr and wp:docPr are pretty much the same thing with the same attributes
2109 [ # # ]: 0 : m_pSerializer->startElementNS( XML_pic, XML_cNvPr, docPrAttrListRef );
2110 : :
2111 : : // TODO hyperlink
2112 : : // m_pSerializer->singleElementNS( XML_a, XML_hlinkClick,
2113 : : // FSNS( XML_r, XML_id ), "rId4",
2114 : : // FSEND );
2115 [ # # ]: 0 : m_pSerializer->endElementNS( XML_pic, XML_cNvPr );
2116 : :
2117 : : m_pSerializer->startElementNS( XML_pic, XML_cNvPicPr,
2118 [ # # ]: 0 : FSEND );
2119 : : // TODO change aspect?
2120 : : m_pSerializer->singleElementNS( XML_a, XML_picLocks,
2121 : : XML_noChangeAspect, "1", XML_noChangeArrowheads, "1",
2122 [ # # ]: 0 : FSEND );
2123 [ # # ]: 0 : m_pSerializer->endElementNS( XML_pic, XML_cNvPicPr );
2124 [ # # ]: 0 : m_pSerializer->endElementNS( XML_pic, XML_nvPicPr );
2125 : :
2126 : : // the actual picture
2127 : : m_pSerializer->startElementNS( XML_pic, XML_blipFill,
2128 [ # # ]: 0 : FSEND );
2129 : : m_pSerializer->singleElementNS( XML_a, XML_blip,
2130 : : FSNS( XML_r, nImageType ), aRelId.getStr(),
2131 [ # # ]: 0 : FSEND );
2132 : : m_pSerializer->singleElementNS( XML_a, XML_srcRect,
2133 [ # # ]: 0 : FSEND );
2134 : : m_pSerializer->startElementNS( XML_a, XML_stretch,
2135 [ # # ]: 0 : FSEND );
2136 : : m_pSerializer->singleElementNS( XML_a, XML_fillRect,
2137 [ # # ]: 0 : FSEND );
2138 [ # # ]: 0 : m_pSerializer->endElementNS( XML_a, XML_stretch );
2139 [ # # ]: 0 : m_pSerializer->endElementNS( XML_pic, XML_blipFill );
2140 : :
2141 : : // TODO setup the right values below
2142 : : m_pSerializer->startElementNS( XML_pic, XML_spPr,
2143 : : XML_bwMode, "auto",
2144 [ # # ]: 0 : FSEND );
2145 : : m_pSerializer->startElementNS( XML_a, XML_xfrm,
2146 [ # # ]: 0 : FSEND );
2147 : : m_pSerializer->singleElementNS( XML_a, XML_off,
2148 : : XML_x, "0", XML_y, "0",
2149 [ # # ]: 0 : FSEND );
2150 : : m_pSerializer->singleElementNS( XML_a, XML_ext,
2151 : : XML_cx, aWidth.getStr(),
2152 : : XML_cy, aHeight.getStr(),
2153 [ # # ]: 0 : FSEND );
2154 [ # # ]: 0 : m_pSerializer->endElementNS( XML_a, XML_xfrm );
2155 : : m_pSerializer->startElementNS( XML_a, XML_prstGeom,
2156 : : XML_prst, "rect",
2157 [ # # ]: 0 : FSEND );
2158 : : m_pSerializer->singleElementNS( XML_a, XML_avLst,
2159 [ # # ]: 0 : FSEND );
2160 [ # # ]: 0 : m_pSerializer->endElementNS( XML_a, XML_prstGeom );
2161 : : m_pSerializer->singleElementNS( XML_a, XML_noFill,
2162 [ # # ]: 0 : FSEND );
2163 : : m_pSerializer->startElementNS( XML_a, XML_ln,
2164 : : XML_w, "9525",
2165 [ # # ]: 0 : FSEND );
2166 : : m_pSerializer->singleElementNS( XML_a, XML_noFill,
2167 [ # # ]: 0 : FSEND );
2168 : : m_pSerializer->singleElementNS( XML_a, XML_miter,
2169 : : XML_lim, "800000",
2170 [ # # ]: 0 : FSEND );
2171 : : m_pSerializer->singleElementNS( XML_a, XML_headEnd,
2172 [ # # ]: 0 : FSEND );
2173 : : m_pSerializer->singleElementNS( XML_a, XML_tailEnd,
2174 [ # # ]: 0 : FSEND );
2175 [ # # ]: 0 : m_pSerializer->endElementNS( XML_a, XML_ln );
2176 [ # # ]: 0 : m_pSerializer->endElementNS( XML_pic, XML_spPr );
2177 : :
2178 [ # # ]: 0 : m_pSerializer->endElementNS( XML_pic, XML_pic );
2179 : :
2180 [ # # ]: 0 : m_pSerializer->endElementNS( XML_a, XML_graphicData );
2181 [ # # ]: 0 : m_pSerializer->endElementNS( XML_a, XML_graphic );
2182 [ # # ][ # # ]: 0 : m_pSerializer->endElementNS( XML_wp, isAnchor ? XML_anchor : XML_inline );
2183 : :
2184 [ # # ][ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_drawing );
2185 : : }
2186 : :
2187 : 126 : void DocxAttributeOutput::WriteOLE2Obj( const SdrObject* pSdrObj, const SwOLENode& rOLENode, const Size& rSize )
2188 : : {
2189 [ - + ]: 126 : if( WriteOLEChart( pSdrObj, rSize ))
2190 : 0 : return;
2191 [ + - ]: 126 : if( WriteOLEMath( pSdrObj, rOLENode, rSize ))
2192 : 126 : return;
2193 : : }
2194 : :
2195 : 126 : bool DocxAttributeOutput::WriteOLEChart( const SdrObject* pSdrObj, const Size& rSize )
2196 : : {
2197 : 126 : uno::Reference< chart2::XChartDocument > xChartDoc;
2198 [ + - ][ + - ]: 126 : uno::Reference< drawing::XShape > xShape( ((SdrObject*)pSdrObj)->getUnoShape(), uno::UNO_QUERY );
2199 [ + - ]: 126 : if( xShape.is() )
2200 : : {
2201 [ + - ]: 126 : uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
2202 [ + - ]: 126 : if( xPropSet.is() )
2203 [ + - ][ + - ]: 126 : xChartDoc.set( xPropSet->getPropertyValue( "Model" ), uno::UNO_QUERY );
[ + - ]
2204 : : }
2205 : :
2206 [ - + ]: 126 : if( xChartDoc.is() )
2207 : : {
2208 : : OSL_TRACE("DocxAttributeOutput::WriteOLE2Obj: export chart ");
2209 : : m_pSerializer->startElementNS( XML_w, XML_drawing,
2210 [ # # ]: 0 : FSEND );
2211 : : m_pSerializer->startElementNS( XML_wp, XML_inline,
2212 : : XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0",
2213 [ # # ]: 0 : FSEND );
2214 : :
2215 : 0 : OString aWidth( OString::valueOf( TwipsToEMU( rSize.Width() ) ) );
2216 : 0 : OString aHeight( OString::valueOf( TwipsToEMU( rSize.Height() ) ) );
2217 : : m_pSerializer->singleElementNS( XML_wp, XML_extent,
2218 : : XML_cx, aWidth.getStr(),
2219 : : XML_cy, aHeight.getStr(),
2220 [ # # ]: 0 : FSEND );
2221 : : // TODO - the right effectExtent, extent including the effect
2222 : : m_pSerializer->singleElementNS( XML_wp, XML_effectExtent,
2223 : : XML_l, "0", XML_t, "0", XML_r, "0", XML_b, "0",
2224 [ # # ]: 0 : FSEND );
2225 : :
2226 : : // should get the unique id
2227 : 0 : sal_Int32 nID = 1;
2228 : 0 : OUString sName("Object 1");
2229 [ # # ]: 0 : uno::Reference< container::XNamed > xNamed( xShape, uno::UNO_QUERY );
2230 [ # # ]: 0 : if( xNamed.is() )
2231 [ # # ][ # # ]: 0 : sName = xNamed->getName();
2232 : :
2233 : : m_pSerializer->singleElementNS( XML_wp, XML_docPr,
2234 : : XML_id, I32S( nID ),
2235 : : XML_name, USS( sName ),
2236 [ # # ][ # # ]: 0 : FSEND );
2237 : :
2238 : : m_pSerializer->singleElementNS( XML_wp, XML_cNvGraphicFramePr,
2239 [ # # ]: 0 : FSEND );
2240 : :
2241 : : m_pSerializer->startElementNS( XML_a, XML_graphic,
2242 : : FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main",
2243 [ # # ]: 0 : FSEND );
2244 : :
2245 : : m_pSerializer->startElementNS( XML_a, XML_graphicData,
2246 : : XML_uri, "http://schemas.openxmlformats.org/drawingml/2006/chart",
2247 [ # # ]: 0 : FSEND );
2248 : :
2249 : 0 : OString aRelId;
2250 : : static sal_Int32 nChartCount = 0;
2251 : 0 : nChartCount++;
2252 [ # # ]: 0 : uno::Reference< frame::XModel > xModel( xChartDoc, uno::UNO_QUERY );
2253 [ # # ]: 0 : aRelId = m_rExport.OutputChart( xModel, nChartCount );
2254 : :
2255 : : m_pSerializer->singleElementNS( XML_c, XML_chart,
2256 : : FSNS( XML_xmlns, XML_c ), "http://schemas.openxmlformats.org/drawingml/2006/chart",
2257 : : FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
2258 : : FSNS( XML_r, XML_id ), aRelId.getStr(),
2259 [ # # ]: 0 : FSEND );
2260 : :
2261 [ # # ]: 0 : m_pSerializer->endElementNS( XML_a, XML_graphicData );
2262 [ # # ]: 0 : m_pSerializer->endElementNS( XML_a, XML_graphic );
2263 [ # # ]: 0 : m_pSerializer->endElementNS( XML_wp, XML_inline );
2264 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_drawing );
2265 : :
2266 : 0 : return true;
2267 : : }
2268 : 126 : return false;
2269 : : }
2270 : :
2271 : 126 : bool DocxAttributeOutput::WriteOLEMath( const SdrObject*, const SwOLENode& rOLENode, const Size& )
2272 : : {
2273 [ + - ]: 126 : uno::Reference < embed::XEmbeddedObject > xObj(const_cast<SwOLENode&>(rOLENode).GetOLEObj().GetOleRef());
2274 [ + - ]: 126 : sal_Int64 nAspect = rOLENode.GetAspect();
2275 [ + - ]: 126 : svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
2276 [ + - ][ + - ]: 126 : SvGlobalName aObjName(aObjRef->getClassID());
[ + - ][ + - ]
2277 : :
2278 [ + - ][ - + ]: 126 : if( !SotExchange::IsMath(aObjName) )
2279 : 0 : return false;
2280 : : assert( m_postponedMath == NULL ); // make it a list if there can be more inside one run
2281 : 126 : m_postponedMath = &rOLENode;
2282 [ + - ][ + - ]: 126 : return true;
2283 : : }
2284 : :
2285 : 165 : void DocxAttributeOutput::WritePostponedMath()
2286 : : {
2287 [ + + ]: 165 : if( m_postponedMath == NULL )
2288 : 165 : return;
2289 [ + - ]: 126 : uno::Reference < embed::XEmbeddedObject > xObj(const_cast<SwOLENode*>(m_postponedMath)->GetOLEObj().GetOleRef());
2290 [ + - ][ + - ]: 126 : uno::Reference< uno::XInterface > xInterface( xObj->getComponent(), uno::UNO_QUERY );
[ + - ]
2291 : : // gcc4.4 (and 4.3 and possibly older) have a problem with dynamic_cast directly to the target class,
2292 : : // so help it with an intermediate cast. I'm not sure what exactly the problem is, seems to be unrelated
2293 : : // to RTLD_GLOBAL, so most probably a gcc bug.
2294 [ + - ][ - + ]: 126 : oox::FormulaExportBase* formulaexport = dynamic_cast<oox::FormulaExportBase*>(dynamic_cast<SfxBaseModel*>(xInterface.get()));
[ + - ]
2295 : : assert( formulaexport != NULL );
2296 [ + - ][ + - ]: 126 : formulaexport->writeFormulaOoxml( m_pSerializer, GetExport().GetFilter().getVersion());
[ + - ][ + - ]
[ + - ]
2297 : 165 : m_postponedMath = NULL;
2298 : : }
2299 : :
2300 : 126 : void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Point& /*rNdTopLeft*/ )
2301 : : {
2302 [ + - ]: 126 : m_pSerializer->mark();
2303 : :
2304 [ - - - + : 126 : switch ( rFrame.GetWriterType() )
- ]
2305 : : {
2306 : : case sw::Frame::eGraphic:
2307 : : {
2308 : 0 : const SwNode *pNode = rFrame.GetContent();
2309 [ # # ]: 0 : const SwGrfNode *pGrfNode = pNode ? pNode->GetGrfNode() : 0;
2310 [ # # ]: 0 : if ( pGrfNode )
2311 : : {
2312 [ # # ]: 0 : if( m_postponedGraphic == NULL )
2313 [ # # ]: 0 : FlyFrameGraphic( *pGrfNode, rFrame.GetLayoutSize() );
2314 : : else // we are writting out attributes, but w:drawing should not be inside w:rPr,
2315 : : { // so write it out later
2316 [ # # ]: 0 : m_postponedGraphic->push_back( PostponedGraphic( pGrfNode, rFrame.GetLayoutSize()));
2317 : : }
2318 : : }
2319 : : }
2320 : 0 : break;
2321 : : case sw::Frame::eDrawing:
2322 : : {
2323 : 0 : const SdrObject* pSdrObj = rFrame.GetFrmFmt().FindRealSdrObject();
2324 [ # # ]: 0 : if ( pSdrObj )
2325 : : {
2326 : 0 : bool bSwapInPage = false;
2327 [ # # ]: 0 : if ( !pSdrObj->GetPage() )
2328 : : {
2329 [ # # ]: 0 : if ( SdrModel* pModel = m_rExport.pDoc->GetDrawModel() )
2330 : : {
2331 [ # # ]: 0 : if ( SdrPage *pPage = pModel->GetPage( 0 ) )
2332 : : {
2333 : 0 : bSwapInPage = true;
2334 : 0 : const_cast< SdrObject* >( pSdrObj )->SetPage( pPage );
2335 : : }
2336 : : }
2337 : : }
2338 : :
2339 : : m_pSerializer->startElementNS( XML_w, XML_pict,
2340 : 0 : FSEND );
2341 : :
2342 : 0 : m_rExport.VMLExporter().AddSdrObject( *pSdrObj );
2343 : :
2344 : 0 : m_pSerializer->endElementNS( XML_w, XML_pict );
2345 : :
2346 [ # # ]: 0 : if ( bSwapInPage )
2347 : 0 : const_cast< SdrObject* >( pSdrObj )->SetPage( 0 );
2348 : : }
2349 : : }
2350 : 0 : break;
2351 : : case sw::Frame::eTxtBox:
2352 : : {
2353 : : // The frame output is postponed at the end of the anchor paragraph
2354 : 0 : m_pParentFrame = &rFrame;
2355 : : }
2356 : 0 : break;
2357 : : case sw::Frame::eOle:
2358 : : {
2359 : 126 : const SwFrmFmt &rFrmFmt = rFrame.GetFrmFmt();
2360 : 126 : const SdrObject *pSdrObj = rFrmFmt.FindRealSdrObject();
2361 [ + - ]: 126 : if ( pSdrObj )
2362 : : {
2363 [ + - ][ + - ]: 126 : SwNodeIndex aIdx(*rFrmFmt.GetCntnt().GetCntntIdx(), 1);
2364 : 126 : SwOLENode& rOLENd = *aIdx.GetNode().GetOLENode();
2365 [ + - ][ + - ]: 126 : WriteOLE2Obj( pSdrObj, rOLENd, rFrame.GetLayoutSize() );
2366 : : }
2367 : : }
2368 : 126 : break;
2369 : : default:
2370 : : OSL_TRACE( "TODO DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Point& rNdTopLeft ) - frame type '%s'\n",
2371 : : rFrame.GetWriterType() == sw::Frame::eTxtBox? "eTxtBox":
2372 : : ( rFrame.GetWriterType() == sw::Frame::eOle? "eOle":
2373 : : ( rFrame.GetWriterType() == sw::Frame::eFormControl? "eFormControl": "???" ) ) );
2374 : 0 : break;
2375 : : }
2376 : :
2377 : 126 : m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_POSTPONE );
2378 : 126 : }
2379 : :
2380 : 0 : void DocxAttributeOutput::WriteOutliner(const OutlinerParaObject& rParaObj)
2381 : : {
2382 [ # # ]: 0 : const EditTextObject& rEditObj = rParaObj.GetTextObject();
2383 [ # # ]: 0 : MSWord_SdrAttrIter aAttrIter( m_rExport, rEditObj, TXT_HFTXTBOX );
2384 : :
2385 [ # # ]: 0 : sal_uInt16 nPara = rEditObj.GetParagraphCount();
2386 : :
2387 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_textbox, FSEND );
2388 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_txbxContent, FSEND );
2389 [ # # ]: 0 : for (sal_uInt16 n = 0; n < nPara; ++n)
2390 : : {
2391 [ # # ]: 0 : if( n )
2392 [ # # ]: 0 : aAttrIter.NextPara( n );
2393 : :
2394 [ # # ]: 0 : String aStr( rEditObj.GetText( n ));
2395 : 0 : xub_StrLen nAktPos = 0;
2396 : 0 : xub_StrLen nEnd = aStr.Len();
2397 : :
2398 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_p, FSEND );
2399 [ # # ]: 0 : do {
2400 : 0 : xub_StrLen nNextAttr = aAttrIter.WhereNext();
2401 [ # # ]: 0 : if( nNextAttr > nEnd )
2402 : 0 : nNextAttr = nEnd;
2403 : :
2404 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
2405 [ # # ]: 0 : bool bTxtAtr = aAttrIter.IsTxtAttr( nAktPos );
2406 [ # # ]: 0 : if( !bTxtAtr )
2407 : : {
2408 [ # # ]: 0 : String aOut( aStr.Copy( nAktPos, nNextAttr - nAktPos ) );
2409 [ # # ][ # # ]: 0 : RunText(aOut);
2410 : : }
2411 : :
2412 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_r );
2413 : :
2414 : 0 : nAktPos = nNextAttr;
2415 [ # # ]: 0 : aAttrIter.NextPos();
2416 : : }
2417 : : while( nAktPos < nEnd );
2418 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_p );
2419 [ # # ]: 0 : }
2420 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_txbxContent );
2421 [ # # ][ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_textbox );
2422 : 0 : }
2423 : :
2424 : 0 : oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML()
2425 : : {
2426 : 0 : return m_rDrawingML;
2427 : : }
2428 : :
2429 : 387 : void DocxAttributeOutput::StartStyle( const String& rName, bool bPapFmt,
2430 : : sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 /*nWwId*/, sal_uInt16 nId, bool bAutoUpdate )
2431 : : {
2432 : 387 : OString aStyle( "style" );
2433 : :
2434 : : m_pSerializer->startElementNS( XML_w, XML_style,
2435 : : FSNS( XML_w, XML_type ), bPapFmt? "paragraph": "character", // FIXME is this correct?
2436 : : FSNS( XML_w, XML_styleId ), ( aStyle + OString::valueOf( sal_Int32( nId ) ) ).getStr(),
2437 [ + - ][ + + ]: 387 : FSEND );
2438 : :
2439 : : m_pSerializer->singleElementNS( XML_w, XML_name,
2440 : : FSNS( XML_w, XML_val ), OUStringToOString( OUString( rName ), RTL_TEXTENCODING_UTF8 ).getStr(),
2441 [ + - ][ + - ]: 387 : FSEND );
[ + - ]
2442 : :
2443 [ + + ]: 387 : if ( nBase != 0x0FFF )
2444 : : {
2445 : : m_pSerializer->singleElementNS( XML_w, XML_basedOn,
2446 : : FSNS( XML_w, XML_val ), ( aStyle + OString::valueOf( sal_Int32( nBase ) ) ).getStr(),
2447 [ + - ]: 318 : FSEND );
2448 : : }
2449 : :
2450 : : m_pSerializer->singleElementNS( XML_w, XML_next,
2451 : : FSNS( XML_w, XML_val ), ( aStyle + OString::valueOf( sal_Int32( nNext ) ) ).getStr(),
2452 [ + - ]: 387 : FSEND );
2453 : :
2454 [ - + ]: 387 : if ( bAutoUpdate )
2455 [ # # ]: 387 : m_pSerializer->singleElementNS( XML_w, XML_autoRedefine, FSEND );
2456 : 387 : }
2457 : :
2458 : 387 : void DocxAttributeOutput::EndStyle()
2459 : : {
2460 : 387 : m_pSerializer->endElementNS( XML_w, XML_style );
2461 : 387 : }
2462 : :
2463 : 744 : void DocxAttributeOutput::StartStyleProperties( bool bParProp, sal_uInt16 /*nStyle*/ )
2464 : : {
2465 [ + + ]: 744 : if ( bParProp )
2466 : : {
2467 : 357 : m_pSerializer->startElementNS( XML_w, XML_pPr, FSEND );
2468 : 357 : InitCollectedParagraphProperties();
2469 : : }
2470 : : else
2471 : : {
2472 : 387 : m_pSerializer->startElementNS( XML_w, XML_rPr, FSEND );
2473 : 387 : InitCollectedRunProperties();
2474 : : }
2475 : 744 : }
2476 : :
2477 : 744 : void DocxAttributeOutput::EndStyleProperties( bool bParProp )
2478 : : {
2479 [ + + ]: 744 : if ( bParProp )
2480 : : {
2481 : 357 : WriteCollectedParagraphProperties();
2482 : 357 : m_pSerializer->endElementNS( XML_w, XML_pPr );
2483 : : }
2484 : : else
2485 : : {
2486 : 387 : WriteCollectedRunProperties();
2487 : 387 : m_pSerializer->endElementNS( XML_w, XML_rPr );
2488 : : }
2489 : 744 : }
2490 : :
2491 : 0 : void DocxAttributeOutput::OutlineNumbering( sal_uInt8 nLvl, const SwNumFmt& /*rNFmt*/, const SwFmt& /*rFmt*/ )
2492 : : {
2493 [ # # ]: 0 : if ( nLvl >= WW8ListManager::nMaxLevel )
2494 : 0 : nLvl = WW8ListManager::nMaxLevel - 1;
2495 : :
2496 : : m_pSerializer->singleElementNS( XML_w, XML_outlineLvl,
2497 : : FSNS( XML_w, XML_val ), OString::valueOf( sal_Int32( nLvl ) ).getStr( ),
2498 [ # # ]: 0 : FSEND );
2499 : 0 : }
2500 : :
2501 : 0 : void DocxAttributeOutput::PageBreakBefore( bool bBreak )
2502 : : {
2503 [ # # ]: 0 : if ( bBreak )
2504 : 0 : m_pSerializer->singleElementNS( XML_w, XML_pageBreakBefore, FSEND );
2505 : : else
2506 : : m_pSerializer->singleElementNS( XML_w, XML_pageBreakBefore,
2507 : : FSNS( XML_w, XML_val ), "false",
2508 : 0 : FSEND );
2509 : 0 : }
2510 : :
2511 : 0 : void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* pSectionInfo )
2512 : : {
2513 [ # # # ]: 0 : switch ( nC )
2514 : : {
2515 : : case msword::ColumnBreak:
2516 : : // The column break should be output in the next paragraph...
2517 : 0 : m_nColBreakStatus = COLBRK_POSTPONE;
2518 : 0 : break;
2519 : : case msword::PageBreak:
2520 [ # # ]: 0 : if ( pSectionInfo )
2521 : : {
2522 [ # # ]: 0 : if ( !m_bParagraphOpened )
2523 : : {
2524 : : // Create a dummy paragraph if needed
2525 : 0 : m_pSerializer->startElementNS( XML_w, XML_p, FSEND );
2526 : 0 : m_pSerializer->startElementNS( XML_w, XML_pPr, FSEND );
2527 : :
2528 : 0 : m_rExport.SectionProperties( *pSectionInfo );
2529 : :
2530 : 0 : m_pSerializer->endElementNS( XML_w, XML_pPr );
2531 : 0 : m_pSerializer->endElementNS( XML_w, XML_p );
2532 : : }
2533 : : else
2534 : : {
2535 : : // postpone the output of this; it has to be done inside the
2536 : : // paragraph properties, so remember it until then
2537 : 0 : m_pSectionInfo.reset( new WW8_SepInfo( *pSectionInfo ));
2538 : : }
2539 : : }
2540 : : else
2541 : : {
2542 : 0 : m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
2543 : : m_pSerializer->singleElementNS( XML_w, XML_br,
2544 : 0 : FSNS( XML_w, XML_type ), "page", FSEND );
2545 : 0 : m_pSerializer->endElementNS( XML_w, XML_r );
2546 : : }
2547 : 0 : break;
2548 : : default:
2549 : : OSL_TRACE( "Unknown section break to write: %d", nC );
2550 : 0 : break;
2551 : : }
2552 : 0 : }
2553 : :
2554 : 57 : void DocxAttributeOutput::StartSection()
2555 : : {
2556 [ + - ]: 57 : m_pSerializer->startElementNS( XML_w, XML_sectPr, FSEND );
2557 : 57 : m_bOpenedSectPr = true;
2558 : :
2559 : : // Write the elements in the spec order
2560 : : static const sal_Int32 aOrder[] =
2561 : : {
2562 : : FSNS( XML_w, XML_headerReference ),
2563 : : FSNS( XML_w, XML_footerReference ),
2564 : : FSNS( XML_w, XML_footnotePr ),
2565 : : FSNS( XML_w, XML_endnotePr ),
2566 : : FSNS( XML_w, XML_type ),
2567 : : FSNS( XML_w, XML_pgSz ),
2568 : : FSNS( XML_w, XML_pgMar ),
2569 : : FSNS( XML_w, XML_paperSrc ),
2570 : : FSNS( XML_w, XML_pgBorders ),
2571 : : FSNS( XML_w, XML_lnNumType ),
2572 : : FSNS( XML_w, XML_pgNumType ),
2573 : : FSNS( XML_w, XML_cols ),
2574 : : FSNS( XML_w, XML_formProt ),
2575 : : FSNS( XML_w, XML_vAlign ),
2576 : : FSNS( XML_w, XML_noEndnote ),
2577 : : FSNS( XML_w, XML_titlePg ),
2578 : : FSNS( XML_w, XML_textDirection ),
2579 : : FSNS( XML_w, XML_bidi ),
2580 : : FSNS( XML_w, XML_rtlGutter ),
2581 : : FSNS( XML_w, XML_docGrid ),
2582 : : FSNS( XML_w, XML_printerSettings ),
2583 : : FSNS( XML_w, XML_sectPrChange )
2584 : : };
2585 : :
2586 : : // postpone the output so that we can later [in EndParagraphProperties()]
2587 : : // prepend the properties before the run
2588 : 57 : sal_Int32 len = sizeof ( aOrder ) / sizeof( sal_Int32 );
2589 [ + - ]: 57 : uno::Sequence< sal_Int32 > aSeqOrder( len );
2590 [ + + ]: 1311 : for ( sal_Int32 i = 0; i < len; i++ )
2591 [ + - ]: 1254 : aSeqOrder[i] = aOrder[i];
2592 : :
2593 [ + - ][ + - ]: 57 : m_pSerializer->mark( aSeqOrder );
[ + - ][ + - ]
2594 : 57 : }
2595 : :
2596 : 57 : void DocxAttributeOutput::EndSection()
2597 : : {
2598 : : // Write the section properties
2599 [ + - ]: 57 : if ( m_pSectionSpacingAttrList )
2600 : : {
2601 [ + - ][ + - ]: 57 : XFastAttributeListRef xAttrList( m_pSectionSpacingAttrList );
2602 : 57 : m_pSectionSpacingAttrList = NULL;
2603 : :
2604 [ + - ]: 57 : m_pSerializer->singleElementNS( XML_w, XML_pgMar, xAttrList );
2605 : : }
2606 : :
2607 : : // Order the elements
2608 : 57 : m_pSerializer->mergeTopMarks( );
2609 : :
2610 : 57 : m_pSerializer->endElementNS( XML_w, XML_sectPr );
2611 : 57 : m_bOpenedSectPr = false;
2612 : 57 : }
2613 : :
2614 : 57 : void DocxAttributeOutput::SectionFormProtection( bool bProtected )
2615 : : {
2616 [ - + ]: 57 : if ( bProtected )
2617 : 0 : m_pSerializer->singleElementNS( XML_w, XML_formProt, FSEND );
2618 : : else
2619 : : m_pSerializer->singleElementNS( XML_w, XML_formProt,
2620 : 57 : FSNS( XML_w, XML_val ), "false", FSEND );
2621 : 57 : }
2622 : :
2623 : 0 : void DocxAttributeOutput::SectionLineNumbering( sal_uLong nRestartNo, const SwLineNumberInfo& rLnNumInfo )
2624 : : {
2625 [ # # ]: 0 : FastAttributeList* pAttr = m_pSerializer->createAttrList();
2626 [ # # ]: 0 : pAttr->add( FSNS( XML_w, XML_countBy ), OString::valueOf(static_cast<sal_Int32>(rLnNumInfo.GetCountBy())).getStr());
2627 [ # # ][ # # ]: 0 : pAttr->add( FSNS( XML_w, XML_restart ), rLnNumInfo.IsRestartEachPage() ? "newPage" : "continuous" );
2628 [ # # ]: 0 : if( rLnNumInfo.GetPosFromLeft())
2629 [ # # ]: 0 : pAttr->add( FSNS( XML_w, XML_distance ), OString::valueOf(static_cast<sal_Int32>(rLnNumInfo.GetPosFromLeft())).getStr());
2630 [ # # ]: 0 : if( nRestartNo )
2631 [ # # ]: 0 : pAttr->add( FSNS( XML_w, XML_start ), OString::valueOf( long( nRestartNo )).getStr());
2632 [ # # ][ # # ]: 0 : XFastAttributeListRef xAttrs( pAttr );
2633 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_w, XML_lnNumType, xAttrs );
2634 : 0 : }
2635 : :
2636 : 0 : void DocxAttributeOutput::SectionTitlePage()
2637 : : {
2638 : 0 : m_pSerializer->singleElementNS( XML_w, XML_titlePg, FSEND );
2639 : 0 : }
2640 : :
2641 : 57 : void DocxAttributeOutput::SectionPageBorders( const SwFrmFmt* pFmt, const SwFrmFmt* /*pFirstPageFmt*/ )
2642 : : {
2643 : : // Output the margins
2644 : :
2645 : 57 : const SvxBoxItem& rBox = pFmt->GetBox( );
2646 : :
2647 : 57 : const SvxBorderLine* pBottom = rBox.GetBottom( );
2648 : 57 : const SvxBorderLine* pTop = rBox.GetTop( );
2649 : 57 : const SvxBorderLine* pLeft = rBox.GetLeft( );
2650 : 57 : const SvxBorderLine* pRight = rBox.GetRight( );
2651 : :
2652 [ + - ][ + - ]: 57 : if ( pBottom || pTop || pLeft || pRight )
[ - + ][ + - ]
2653 : : {
2654 : : // All distances are relative to the text margins
2655 : : m_pSerializer->startElementNS( XML_w, XML_pgBorders,
2656 : : FSNS( XML_w, XML_display ), "allPages",
2657 : : FSNS( XML_w, XML_offsetFrom ), "text",
2658 : 0 : FSEND );
2659 : :
2660 [ # # ]: 0 : m_pSerializer->mark();
2661 : :
2662 : 0 : m_pSerializer->endElementNS( XML_w, XML_pgBorders );
2663 [ # # ]: 0 : m_pSerializer->mark();
2664 : : }
2665 : 57 : }
2666 : :
2667 : 0 : void DocxAttributeOutput::SectionBiDi( bool bBiDi )
2668 : : {
2669 [ # # ]: 0 : if ( bBiDi )
2670 : 0 : m_pSerializer->singleElementNS( XML_w, XML_bidi, FSEND );
2671 : 0 : }
2672 : :
2673 : 57 : static OString impl_NumberingType( sal_uInt16 nNumberingType )
2674 : : {
2675 : 57 : OString aType;
2676 : :
2677 [ - - - - : 57 : switch ( nNumberingType )
+ - - ]
2678 : : {
2679 : : case SVX_NUM_CHARS_UPPER_LETTER:
2680 : 0 : case SVX_NUM_CHARS_UPPER_LETTER_N: aType = "upperLetter"; break;
2681 : : case SVX_NUM_CHARS_LOWER_LETTER:
2682 : 0 : case SVX_NUM_CHARS_LOWER_LETTER_N: aType = "lowerLetter"; break;
2683 : 0 : case SVX_NUM_ROMAN_UPPER: aType = "upperRoman"; break;
2684 : 0 : case SVX_NUM_ROMAN_LOWER: aType = "lowerRoman"; break;
2685 : :
2686 : 57 : case SVX_NUM_ARABIC: aType = "decimal"; break;
2687 : :
2688 : : case SVX_NUM_BITMAP:
2689 : 0 : case SVX_NUM_CHAR_SPECIAL: aType = "bullet"; break;
2690 : :
2691 : 0 : default: aType = "none"; break;
2692 : : }
2693 : :
2694 : 57 : return aType;
2695 : : }
2696 : :
2697 : 57 : void DocxAttributeOutput::SectionPageNumbering( sal_uInt16 nNumType, sal_uInt16 nPageRestartNumber )
2698 : : {
2699 : : // FIXME Not called properly with page styles like "First Page"
2700 : :
2701 [ + - ]: 57 : FastAttributeList* pAttr = m_pSerializer->createAttrList();
2702 : :
2703 : : // 0 means no restart: then don't output that attribute if 0
2704 [ - + ]: 57 : if ( nPageRestartNumber > 0 )
2705 [ # # ]: 0 : pAttr->add( FSNS( XML_w, XML_start ), OString::valueOf( sal_Int32( nPageRestartNumber ) ) );
2706 : :
2707 : : // nNumType corresponds to w:fmt. See WW8Export::GetNumId() for more precisions
2708 [ + - ]: 57 : OString aFmt( impl_NumberingType( nNumType ) );
2709 [ + - ]: 57 : if ( !aFmt.isEmpty() )
2710 [ + - ]: 57 : pAttr->add( FSNS( XML_w, XML_fmt ), aFmt.getStr() );
2711 : :
2712 [ + - ][ + - ]: 57 : XFastAttributeListRef xAttrs( pAttr );
2713 [ + - ]: 57 : m_pSerializer->singleElementNS( XML_w, XML_pgNumType, xAttrs );
2714 : :
2715 : : // see 2.6.12 pgNumType (Page Numbering Settings)
2716 : 57 : OSL_TRACE( "TODO DocxAttributeOutput::SectionPageNumbering()" );
2717 : 57 : }
2718 : :
2719 : 57 : void DocxAttributeOutput::SectionType( sal_uInt8 nBreakCode )
2720 : : {
2721 : : /* break code: 0 No break, 1 New column
2722 : : 2 New page, 3 Even page, 4 Odd page
2723 : : */
2724 : 57 : const char* pType = NULL;
2725 [ - + - - : 57 : switch ( nBreakCode )
- ]
2726 : : {
2727 : 0 : case 1: pType = "nextColumn"; break;
2728 : 57 : case 2: pType = "nextPage"; break;
2729 : 0 : case 3: pType = "evenPage"; break;
2730 : 0 : case 4: pType = "oddPage"; break;
2731 : 0 : default: pType = "continuous"; break;
2732 : : }
2733 : :
2734 [ + - ]: 57 : if ( pType )
2735 : : m_pSerializer->singleElementNS( XML_w, XML_type,
2736 : : FSNS( XML_w, XML_val ), pType,
2737 : 57 : FSEND );
2738 : 57 : }
2739 : :
2740 : 285 : void DocxAttributeOutput::StartFont( const String& rFamilyName ) const
2741 : : {
2742 : : m_pSerializer->startElementNS( XML_w, XML_font,
2743 : : FSNS( XML_w, XML_name ), OUStringToOString( OUString( rFamilyName ), RTL_TEXTENCODING_UTF8 ).getStr(),
2744 [ + - ][ + - ]: 285 : FSEND );
2745 : 285 : }
2746 : :
2747 : 285 : void DocxAttributeOutput::EndFont() const
2748 : : {
2749 : 285 : m_pSerializer->endElementNS( XML_w, XML_font );
2750 : 285 : }
2751 : :
2752 : 102 : void DocxAttributeOutput::FontAlternateName( const String& rName ) const
2753 : : {
2754 : : m_pSerializer->singleElementNS( XML_w, XML_altName,
2755 : : FSNS( XML_w, XML_val ), OUStringToOString( OUString( rName ), RTL_TEXTENCODING_UTF8 ).getStr(),
2756 [ + - ][ + - ]: 102 : FSEND );
2757 : 102 : }
2758 : :
2759 : 285 : void DocxAttributeOutput::FontCharset( sal_uInt8 nCharSet, rtl_TextEncoding nEncoding ) const
2760 : : {
2761 [ + - ]: 285 : FastAttributeList* pAttr = m_pSerializer->createAttrList();
2762 : :
2763 : 285 : OString aCharSet( OString::valueOf( sal_Int32( nCharSet ), 16 ) );
2764 [ + + ]: 285 : if ( aCharSet.getLength() == 1 )
2765 : 171 : aCharSet = OString( "0" ) + aCharSet;
2766 [ + - ]: 285 : pAttr->add( FSNS( XML_w, XML_val ), aCharSet.getStr());
2767 : :
2768 [ + - ][ + - ]: 285 : if( GetExport().GetFilter().getVersion( ) != oox::core::ECMA_DIALECT )
[ + - ]
2769 : : {
2770 [ + - ][ + + ]: 285 : if( const char* charset = rtl_getMimeCharsetFromTextEncoding( nEncoding ))
2771 [ + - ]: 285 : pAttr->add( FSNS( XML_w, XML_characterSet ), charset );
2772 : : }
2773 : :
2774 [ + - ][ + - ]: 285 : m_pSerializer->singleElementNS( XML_w, XML_charset, XFastAttributeListRef( pAttr ));
[ + - ]
2775 : 285 : }
2776 : :
2777 : 285 : void DocxAttributeOutput::FontFamilyType( FontFamily eFamily ) const
2778 : : {
2779 : 285 : const char *pFamily = NULL;
2780 [ + + - - : 285 : switch ( eFamily )
- - ]
2781 : : {
2782 : 228 : case FAMILY_ROMAN: pFamily = "roman"; break;
2783 : 57 : case FAMILY_SWISS: pFamily = "swiss"; break;
2784 : 0 : case FAMILY_MODERN: pFamily = "modern"; break;
2785 : 0 : case FAMILY_SCRIPT: pFamily = "script"; break;
2786 : 0 : case FAMILY_DECORATIVE: pFamily = "decorative"; break;
2787 : 0 : default: pFamily = "auto"; break; // no font family
2788 : : }
2789 : :
2790 [ + - ]: 285 : if ( pFamily )
2791 : : m_pSerializer->singleElementNS( XML_w, XML_family,
2792 : : FSNS( XML_w, XML_val ), pFamily,
2793 : 285 : FSEND );
2794 : 285 : }
2795 : :
2796 : 285 : void DocxAttributeOutput::FontPitchType( FontPitch ePitch ) const
2797 : : {
2798 : 285 : const char *pPitch = NULL;
2799 [ + - + ]: 285 : switch ( ePitch )
2800 : : {
2801 : 234 : case PITCH_VARIABLE: pPitch = "variable"; break;
2802 : 0 : case PITCH_FIXED: pPitch = "fixed"; break;
2803 : 51 : default: pPitch = "default"; break; // no info about the pitch
2804 : : }
2805 : :
2806 [ + - ]: 285 : if ( pPitch )
2807 : : m_pSerializer->singleElementNS( XML_w, XML_pitch,
2808 : : FSNS( XML_w, XML_val ), pPitch,
2809 : 285 : FSEND );
2810 : 285 : }
2811 : :
2812 : 0 : void DocxAttributeOutput::NumberingDefinition( sal_uInt16 nId, const SwNumRule &rRule )
2813 : : {
2814 : : // nId is the same both for abstract numbering definition as well as the
2815 : : // numbering definition itself
2816 : : // TODO check that this is actually true & fix if not ;-)
2817 : 0 : OString aId( OString::valueOf( sal_Int32( nId ) ) );
2818 : :
2819 : : m_pSerializer->startElementNS( XML_w, XML_num,
2820 : : FSNS( XML_w, XML_numId ), aId.getStr(),
2821 [ # # ]: 0 : FSEND );
2822 : :
2823 : : m_pSerializer->singleElementNS( XML_w, XML_abstractNumId,
2824 : : FSNS( XML_w, XML_val ), aId.getStr(),
2825 [ # # ]: 0 : FSEND );
2826 : :
2827 : : #if OSL_DEBUG_LEVEL > 1
2828 : : // TODO ww8 version writes this, anything to do about it here?
2829 : : if ( rRule.IsContinusNum() )
2830 : : OSL_TRACE( "TODO DocxAttributeOutput::NumberingDefinition()" );
2831 : : #else
2832 : : (void) rRule; // to quiet the warning...
2833 : : #endif
2834 : :
2835 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_num );
2836 : 0 : }
2837 : :
2838 : 0 : void DocxAttributeOutput::StartAbstractNumbering( sal_uInt16 nId )
2839 : : {
2840 : : m_pSerializer->startElementNS( XML_w, XML_abstractNum,
2841 : : FSNS( XML_w, XML_abstractNumId ), OString::valueOf( sal_Int32( nId ) ).getStr(),
2842 [ # # ]: 0 : FSEND );
2843 : 0 : }
2844 : :
2845 : 0 : void DocxAttributeOutput::EndAbstractNumbering()
2846 : : {
2847 : 0 : m_pSerializer->endElementNS( XML_w, XML_abstractNum );
2848 : 0 : }
2849 : :
2850 : 0 : void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
2851 : : sal_uInt16 nStart,
2852 : : sal_uInt16 nNumberingType,
2853 : : SvxAdjust eAdjust,
2854 : : const sal_uInt8 * /*pNumLvlPos*/,
2855 : : sal_uInt8 nFollow,
2856 : : const wwFont *pFont,
2857 : : const SfxItemSet *pOutSet,
2858 : : sal_Int16 nIndentAt,
2859 : : sal_Int16 nFirstLineIndex,
2860 : : sal_Int16 nListTabPos,
2861 : : const String &rNumberingString )
2862 : : {
2863 : : m_pSerializer->startElementNS( XML_w, XML_lvl,
2864 : : FSNS( XML_w, XML_ilvl ), OString::valueOf( sal_Int32( nLevel ) ).getStr(),
2865 [ # # ]: 0 : FSEND );
2866 : :
2867 : : // start with the nStart value
2868 : : m_pSerializer->singleElementNS( XML_w, XML_start,
2869 : : FSNS( XML_w, XML_val ), OString::valueOf( sal_Int32( nStart ) ).getStr(),
2870 [ # # ]: 0 : FSEND );
2871 : :
2872 : : // format
2873 [ # # ]: 0 : OString aFmt( impl_NumberingType( nNumberingType ) );
2874 : :
2875 [ # # ]: 0 : if ( !aFmt.isEmpty() )
2876 : : m_pSerializer->singleElementNS( XML_w, XML_numFmt,
2877 : : FSNS( XML_w, XML_val ), aFmt.getStr(),
2878 [ # # ]: 0 : FSEND );
2879 : :
2880 : : // suffix
2881 : 0 : const char *pSuffix = NULL;
2882 [ # # # ]: 0 : switch ( nFollow )
2883 : : {
2884 : 0 : case 1: pSuffix = "space"; break;
2885 : 0 : case 2: pSuffix = "nothing"; break;
2886 : 0 : default: /*pSuffix = "tab";*/ break;
2887 : : }
2888 [ # # ]: 0 : if ( pSuffix )
2889 : : m_pSerializer->singleElementNS( XML_w, XML_suff,
2890 : : FSNS( XML_w, XML_val ), pSuffix,
2891 [ # # ]: 0 : FSEND );
2892 : :
2893 : : // text
2894 [ # # ]: 0 : OUString aText( rNumberingString );
2895 : 0 : OUStringBuffer aBuffer( aText.getLength() + WW8ListManager::nMaxLevel );
2896 : :
2897 : 0 : const sal_Unicode *pPrev = aText.getStr();
2898 : 0 : const sal_Unicode *pIt = aText.getStr();
2899 [ # # ]: 0 : while ( pIt < aText.getStr() + aText.getLength() )
2900 : : {
2901 : : // convert the level values to %NUMBER form
2902 : : // (we don't use pNumLvlPos at all)
2903 : : // FIXME so far we support the ww8 limit of levels only
2904 [ # # ]: 0 : if ( *pIt < sal_Unicode( WW8ListManager::nMaxLevel ) )
2905 : : {
2906 [ # # ]: 0 : aBuffer.append( pPrev, pIt - pPrev );
2907 [ # # ]: 0 : aBuffer.append( '%' );
2908 [ # # ]: 0 : aBuffer.append( OUString::valueOf( sal_Int32( *pIt ) + 1 ) );
2909 : :
2910 : 0 : pPrev = pIt + 1;
2911 : : }
2912 : 0 : ++pIt;
2913 : : }
2914 [ # # ]: 0 : if ( pPrev < pIt )
2915 [ # # ]: 0 : aBuffer.append( pPrev, pIt - pPrev );
2916 : :
2917 : : m_pSerializer->singleElementNS( XML_w, XML_lvlText,
2918 : : FSNS( XML_w, XML_val ), OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ).getStr(),
2919 [ # # ][ # # ]: 0 : FSEND );
[ # # ]
2920 : :
2921 : : // justification
2922 : : const char *pJc;
2923 [ # # ]: 0 : bool ecmaDialect = ( m_rExport.GetFilter().getVersion() == oox::core::ECMA_DIALECT );
2924 [ # # # ]: 0 : switch ( eAdjust )
2925 : : {
2926 : 0 : case SVX_ADJUST_CENTER: pJc = "center"; break;
2927 [ # # ]: 0 : case SVX_ADJUST_RIGHT: pJc = !ecmaDialect ? "end" : "right"; break;
2928 [ # # ]: 0 : default: pJc = !ecmaDialect ? "start" : "left"; break;
2929 : : }
2930 : : m_pSerializer->singleElementNS( XML_w, XML_lvlJc,
2931 : : FSNS( XML_w, XML_val ), pJc,
2932 [ # # ]: 0 : FSEND );
2933 : :
2934 : : // indentation
2935 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_pPr, FSEND );
2936 [ # # ]: 0 : if( nListTabPos != 0 )
2937 : : {
2938 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_tabs, FSEND );
2939 : : m_pSerializer->singleElementNS( XML_w, XML_tab,
2940 : : FSNS( XML_w, XML_val ), "num",
2941 : : FSNS( XML_w, XML_pos ), OString::valueOf( static_cast<sal_Int32>(nListTabPos) ).getStr(),
2942 [ # # ]: 0 : FSEND );
2943 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_tabs );
2944 : : }
2945 : :
2946 [ # # ]: 0 : sal_Int32 nToken = ecmaDialect ? XML_left : XML_start;
2947 : : m_pSerializer->singleElementNS( XML_w, XML_ind,
2948 : : FSNS( XML_w, nToken ), OString::valueOf( sal_Int32( nIndentAt ) ).getStr(),
2949 : : FSNS( XML_w, XML_hanging ), OString::valueOf( sal_Int32( -nFirstLineIndex ) ).getStr(),
2950 [ # # ]: 0 : FSEND );
2951 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_pPr );
2952 : :
2953 : : // font
2954 [ # # ]: 0 : if ( pOutSet )
2955 : : {
2956 [ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_rPr, FSEND );
2957 : :
2958 [ # # ]: 0 : if ( pFont )
2959 : : {
2960 [ # # ][ # # ]: 0 : GetExport().GetId( *pFont ); // ensure font info is written to fontTable.xml
2961 [ # # ][ # # ]: 0 : OString aFamilyName( OUStringToOString( OUString( pFont->GetFamilyName() ), RTL_TEXTENCODING_UTF8 ) );
2962 : : m_pSerializer->singleElementNS( XML_w, XML_rFonts,
2963 : : FSNS( XML_w, XML_ascii ), aFamilyName.getStr(),
2964 : : FSNS( XML_w, XML_hAnsi ), aFamilyName.getStr(),
2965 : : FSNS( XML_w, XML_cs ), aFamilyName.getStr(),
2966 : : FSNS( XML_w, XML_hint ), "default",
2967 [ # # ]: 0 : FSEND );
2968 : : }
2969 [ # # ]: 0 : m_rExport.OutputItemSet( *pOutSet, false, true, i18n::ScriptType::LATIN, m_rExport.mbExportModeRTF );
2970 : :
2971 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_rPr );
2972 : : }
2973 : :
2974 : : // TODO anything to do about nListTabPos?
2975 : :
2976 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_lvl );
2977 : 0 : }
2978 : :
2979 : 0 : void DocxAttributeOutput::CharCaseMap( const SvxCaseMapItem& rCaseMap )
2980 : : {
2981 [ # # # ]: 0 : switch ( rCaseMap.GetValue() )
2982 : : {
2983 : : case SVX_CASEMAP_KAPITAELCHEN:
2984 : 0 : m_pSerializer->singleElementNS( XML_w, XML_smallCaps, FSEND );
2985 : 0 : break;
2986 : : case SVX_CASEMAP_VERSALIEN:
2987 : 0 : m_pSerializer->singleElementNS( XML_w, XML_caps, FSEND );
2988 : 0 : break;
2989 : : default: // Something that ooxml does not support
2990 : 0 : m_pSerializer->singleElementNS( XML_w, XML_smallCaps, FSNS( XML_w, XML_val ), "false", FSEND );
2991 : 0 : m_pSerializer->singleElementNS( XML_w, XML_caps, FSNS( XML_w, XML_val ), "false", FSEND );
2992 : 0 : break;
2993 : : }
2994 : 0 : }
2995 : :
2996 : 60 : void DocxAttributeOutput::CharColor( const SvxColorItem& rColor )
2997 : : {
2998 : 60 : const Color aColor( rColor.GetValue() );
2999 : 60 : OString aColorString;
3000 : :
3001 [ + - ]: 60 : aColorString = impl_ConvertColor( aColor );
3002 : :
3003 : : m_pSerializer->singleElementNS( XML_w, XML_color,
3004 [ + - ]: 60 : FSNS( XML_w, XML_val ), aColorString.getStr(), FSEND );
3005 : 60 : }
3006 : :
3007 : 0 : void DocxAttributeOutput::CharContour( const SvxContourItem& rContour )
3008 : : {
3009 [ # # ]: 0 : if ( rContour.GetValue() )
3010 : 0 : m_pSerializer->singleElementNS( XML_w, XML_outline, FSEND );
3011 : : else
3012 : 0 : m_pSerializer->singleElementNS( XML_w, XML_outline, FSNS( XML_w, XML_val ), "false", FSEND );
3013 : 0 : }
3014 : :
3015 : 0 : void DocxAttributeOutput::CharCrossedOut( const SvxCrossedOutItem& rCrossedOut )
3016 : : {
3017 [ # # # ]: 0 : switch ( rCrossedOut.GetStrikeout() )
3018 : : {
3019 : : case STRIKEOUT_DOUBLE:
3020 : 0 : m_pSerializer->singleElementNS( XML_w, XML_dstrike, FSEND );
3021 : 0 : break;
3022 : : case STRIKEOUT_NONE:
3023 : 0 : m_pSerializer->singleElementNS( XML_w, XML_dstrike, FSNS( XML_w, XML_val ), "false", FSEND );
3024 : 0 : m_pSerializer->singleElementNS( XML_w, XML_strike, FSNS( XML_w, XML_val ), "false", FSEND );
3025 : 0 : break;
3026 : : default:
3027 : 0 : m_pSerializer->singleElementNS( XML_w, XML_strike, FSEND );
3028 : 0 : break;
3029 : : }
3030 : 0 : }
3031 : :
3032 : 0 : void DocxAttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement )
3033 : : {
3034 : 0 : OString sIss;
3035 : 0 : short nEsc = rEscapement.GetEsc(), nProp = rEscapement.GetProp();
3036 [ # # ]: 0 : if ( !nEsc )
3037 : : {
3038 : 0 : sIss = OString( "baseline" );
3039 : 0 : nEsc = 0;
3040 : 0 : nProp = 100;
3041 : : }
3042 [ # # ]: 0 : else if ( DFLT_ESC_PROP == nProp )
3043 : : {
3044 [ # # ][ # # ]: 0 : if ( DFLT_ESC_SUB == nEsc || DFLT_ESC_AUTO_SUB == nEsc )
3045 : 0 : sIss = OString( "subscript" );
3046 [ # # ][ # # ]: 0 : else if ( DFLT_ESC_SUPER == nEsc || DFLT_ESC_AUTO_SUPER == nEsc )
3047 : 0 : sIss = OString( "superscript" );
3048 : : }
3049 : :
3050 [ # # ]: 0 : if ( !sIss.isEmpty() )
3051 : : m_pSerializer->singleElementNS( XML_w, XML_vertAlign,
3052 [ # # ]: 0 : FSNS( XML_w, XML_val ), sIss.getStr(), FSEND );
3053 : :
3054 [ # # ][ # # ]: 0 : if ( sIss.isEmpty() || sIss.match( OString( "baseline" ) ) )
[ # # ][ # # ]
[ # # ]
3055 : : {
3056 : : long nHeight = ((SvxFontHeightItem&)m_rExport.GetItem(
3057 [ # # ]: 0 : RES_CHRATR_FONTSIZE )).GetHeight();
3058 : 0 : OString sPos = OString::valueOf( ( nHeight * nEsc + 500 ) / 1000 );
3059 : : m_pSerializer->singleElementNS( XML_w, XML_position,
3060 [ # # ]: 0 : FSNS( XML_w, XML_val ), sPos.getStr( ), FSEND );
3061 : :
3062 [ # # ][ # # ]: 0 : if( 100 != nProp || sIss.match( OString( "baseline" ) ) )
[ # # ][ # # ]
[ # # ]
3063 : : {
3064 : 0 : OString sSize = OString::valueOf( ( nHeight * nProp + 500 ) / 1000 );
3065 : : m_pSerializer->singleElementNS( XML_w, XML_sz,
3066 [ # # ]: 0 : FSNS( XML_w, XML_val ), sSize.getStr( ), FSEND );
3067 : 0 : }
3068 : 0 : }
3069 : 0 : }
3070 : :
3071 : 285 : void DocxAttributeOutput::CharFont( const SvxFontItem& rFont)
3072 : : {
3073 [ + - ]: 285 : if (!m_pFontsAttrList)
3074 [ + - ]: 285 : m_pFontsAttrList = m_pSerializer->createAttrList();
3075 [ + - ]: 285 : OUString sFontName(rFont.GetFamilyName());
3076 [ + - ]: 285 : OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8);
3077 [ + - ]: 285 : m_pFontsAttrList->add(FSNS(XML_w, XML_ascii), sFontNameUtf8);
3078 [ + - ]: 285 : m_pFontsAttrList->add(FSNS(XML_w, XML_hAnsi), sFontNameUtf8);
3079 : 285 : }
3080 : :
3081 : 396 : void DocxAttributeOutput::CharFontSize( const SvxFontHeightItem& rFontSize)
3082 : : {
3083 : 396 : OString fontSize = OString::valueOf( sal_Int32( ( rFontSize.GetHeight() + 5 ) / 10 ) );
3084 : :
3085 [ + + - ]: 396 : switch ( rFontSize.Which() )
3086 : : {
3087 : : case RES_CHRATR_FONTSIZE:
3088 : : case RES_CHRATR_CJK_FONTSIZE:
3089 [ + - ]: 198 : m_pSerializer->singleElementNS( XML_w, XML_sz, FSNS( XML_w, XML_val ), fontSize.getStr(), FSEND );
3090 : 198 : break;
3091 : : case RES_CHRATR_CTL_FONTSIZE:
3092 [ + - ]: 198 : m_pSerializer->singleElementNS( XML_w, XML_szCs, FSNS( XML_w, XML_val ), fontSize.getStr(), FSEND );
3093 : 198 : break;
3094 : 396 : }
3095 : 396 : }
3096 : :
3097 : 0 : void DocxAttributeOutput::CharKerning( const SvxKerningItem& rKerning )
3098 : : {
3099 : 0 : OString aKerning = OString::valueOf( ( sal_Int32 ) rKerning.GetValue() );
3100 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_w, XML_spacing, FSNS(XML_w, XML_val), aKerning.getStr(), FSEND );
3101 : 0 : }
3102 : :
3103 : 180 : void DocxAttributeOutput::CharLanguage( const SvxLanguageItem& rLanguage )
3104 : : {
3105 [ + + ]: 180 : if (!m_pCharLangAttrList)
3106 [ + - ]: 60 : m_pCharLangAttrList = m_pSerializer->createAttrList();
3107 : :
3108 [ + - ]: 180 : ::com::sun::star::lang::Locale xLocale= MsLangId::convertLanguageToLocale( rLanguage.GetLanguage( ) );
3109 [ + - ]: 180 : OString sLanguage = OUStringToOString(xLocale.Language, RTL_TEXTENCODING_UTF8);
3110 [ + - ]: 180 : OString sCountry = OUStringToOString(xLocale.Country, RTL_TEXTENCODING_UTF8);
3111 : :
3112 : 180 : OString aLanguageCode = sLanguage + "-" + sCountry;
3113 : :
3114 [ + + + - ]: 180 : switch ( rLanguage.Which() )
3115 : : {
3116 : : case RES_CHRATR_LANGUAGE:
3117 [ + - ]: 60 : m_pCharLangAttrList->add(FSNS(XML_w, XML_val), aLanguageCode);
3118 : 60 : break;
3119 : : case RES_CHRATR_CJK_LANGUAGE:
3120 [ + - ]: 60 : m_pCharLangAttrList->add(FSNS(XML_w, XML_eastAsia), aLanguageCode);
3121 : 60 : break;
3122 : : case RES_CHRATR_CTL_LANGUAGE:
3123 [ + - ]: 60 : m_pCharLangAttrList->add(FSNS(XML_w, XML_bidi), aLanguageCode);
3124 : 60 : break;
3125 : 180 : }
3126 : 180 : }
3127 : :
3128 : 57 : void DocxAttributeOutput::CharPosture( const SvxPostureItem& rPosture )
3129 : : {
3130 [ + - ]: 57 : if ( rPosture.GetPosture() != ITALIC_NONE )
3131 : 57 : m_pSerializer->singleElementNS( XML_w, XML_i, FSEND );
3132 : : else
3133 : 0 : m_pSerializer->singleElementNS( XML_w, XML_i, FSNS( XML_w, XML_val ), "false", FSEND );
3134 : 57 : }
3135 : :
3136 : 0 : void DocxAttributeOutput::CharShadow( const SvxShadowedItem& rShadow )
3137 : : {
3138 [ # # ]: 0 : if ( rShadow.GetValue() )
3139 : 0 : m_pSerializer->singleElementNS( XML_w, XML_shadow, FSEND );
3140 : : else
3141 : 0 : m_pSerializer->singleElementNS( XML_w, XML_shadow, FSNS( XML_w, XML_val ), "false", FSEND );
3142 : 0 : }
3143 : :
3144 : 3 : void DocxAttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline )
3145 : : {
3146 : : const char *pUnderline;
3147 : :
3148 [ + - - - : 3 : switch ( rUnderline.GetLineStyle() )
- - - - -
- - - - -
- - - ]
3149 : : {
3150 : 3 : case UNDERLINE_SINGLE: pUnderline = "single"; break;
3151 : 0 : case UNDERLINE_BOLD: pUnderline = "thick"; break;
3152 : 0 : case UNDERLINE_DOUBLE: pUnderline = "double"; break;
3153 : 0 : case UNDERLINE_DOTTED: pUnderline = "dotted"; break;
3154 : 0 : case UNDERLINE_DASH: pUnderline = "dash"; break;
3155 : 0 : case UNDERLINE_DASHDOT: pUnderline = "dotDash"; break;
3156 : 0 : case UNDERLINE_DASHDOTDOT: pUnderline = "dotDotDash"; break;
3157 : 0 : case UNDERLINE_WAVE: pUnderline = "wave"; break;
3158 : 0 : case UNDERLINE_BOLDDOTTED: pUnderline = "dottedHeavy"; break;
3159 : 0 : case UNDERLINE_BOLDDASH: pUnderline = "dashedHeavy"; break;
3160 : 0 : case UNDERLINE_LONGDASH: pUnderline = "dashLongHeavy"; break;
3161 : 0 : case UNDERLINE_BOLDLONGDASH: pUnderline = "dashLongHeavy"; break;
3162 : 0 : case UNDERLINE_BOLDDASHDOT: pUnderline = "dashDotHeavy"; break;
3163 : 0 : case UNDERLINE_BOLDDASHDOTDOT: pUnderline = "dashDotDotHeavy"; break;
3164 : 0 : case UNDERLINE_BOLDWAVE: pUnderline = "wavyHeavy"; break;
3165 : 0 : case UNDERLINE_DOUBLEWAVE: pUnderline = "wavyDouble"; break;
3166 : : case UNDERLINE_NONE: // fall through
3167 : 0 : default: pUnderline = "none"; break;
3168 : : }
3169 : :
3170 : 3 : m_pSerializer->singleElementNS( XML_w, XML_u, FSNS( XML_w, XML_val ), pUnderline, FSEND );
3171 : 3 : }
3172 : :
3173 : 6 : void DocxAttributeOutput::CharWeight( const SvxWeightItem& rWeight )
3174 : : {
3175 [ + - ]: 6 : if ( rWeight.GetWeight() == WEIGHT_BOLD )
3176 : 6 : m_pSerializer->singleElementNS( XML_w, XML_b, FSEND );
3177 : : else
3178 : 0 : m_pSerializer->singleElementNS( XML_w, XML_b, FSNS( XML_w, XML_val ), "false", FSEND );
3179 : 6 : }
3180 : :
3181 : 57 : void DocxAttributeOutput::CharAutoKern( const SvxAutoKernItem& )
3182 : : {
3183 : : OSL_TRACE( "TODO DocxAttributeOutput::CharAutoKern()" );
3184 : 57 : }
3185 : :
3186 : 0 : void DocxAttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink )
3187 : : {
3188 [ # # ]: 0 : if ( rBlink.GetValue() )
3189 : 0 : m_pSerializer->singleElementNS(XML_w, XML_effect, FSNS( XML_w, XML_val ), "blinkBackground", FSEND );
3190 : : else
3191 : 0 : m_pSerializer->singleElementNS(XML_w, XML_effect, FSNS( XML_w, XML_val ), "none", FSEND );
3192 : 0 : }
3193 : :
3194 : 0 : void DocxAttributeOutput::CharBackground( const SvxBrushItem& rBrush )
3195 : : {
3196 : : m_pSerializer->singleElementNS( XML_w, XML_shd,
3197 : 0 : FSNS( XML_w, XML_fill ), impl_ConvertColor( rBrush.GetColor() ).getStr(),
3198 : : FSNS( XML_w, XML_val ), "clear",
3199 [ # # ]: 0 : FSEND );
3200 : 0 : }
3201 : :
3202 : 267 : void DocxAttributeOutput::CharFontCJK( const SvxFontItem& rFont )
3203 : : {
3204 [ - + ]: 267 : if (!m_pFontsAttrList)
3205 [ # # ]: 0 : m_pFontsAttrList = m_pSerializer->createAttrList();
3206 [ + - ]: 267 : OUString sFontName(rFont.GetFamilyName());
3207 [ + - ]: 267 : OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8);
3208 [ + - ]: 267 : m_pFontsAttrList->add(FSNS(XML_w, XML_eastAsia), sFontNameUtf8);
3209 : 267 : }
3210 : :
3211 : 0 : void DocxAttributeOutput::CharPostureCJK( const SvxPostureItem& rPosture )
3212 : : {
3213 [ # # ]: 0 : if ( rPosture.GetPosture() != ITALIC_NONE )
3214 : 0 : m_pSerializer->singleElementNS( XML_w, XML_i, FSEND );
3215 : : else
3216 : 0 : m_pSerializer->singleElementNS( XML_w, XML_i, FSNS( XML_w, XML_val ), "false", FSEND );
3217 : 0 : }
3218 : :
3219 : 0 : void DocxAttributeOutput::CharWeightCJK( const SvxWeightItem& rWeight )
3220 : : {
3221 [ # # ]: 0 : if ( rWeight.GetWeight() == WEIGHT_BOLD )
3222 : 0 : m_pSerializer->singleElementNS( XML_w, XML_b, FSEND );
3223 : : else
3224 : 0 : m_pSerializer->singleElementNS( XML_w, XML_b, FSNS( XML_w, XML_val ), "false", FSEND );
3225 : 0 : }
3226 : :
3227 : 297 : void DocxAttributeOutput::CharFontCTL( const SvxFontItem& rFont )
3228 : : {
3229 [ + + ]: 297 : if (!m_pFontsAttrList)
3230 [ + - ]: 18 : m_pFontsAttrList = m_pSerializer->createAttrList();
3231 [ + - ]: 297 : OUString sFontName(rFont.GetFamilyName());
3232 [ + - ]: 297 : OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8);
3233 [ + - ]: 297 : m_pFontsAttrList->add(FSNS(XML_w, XML_cs), sFontNameUtf8);
3234 : :
3235 : 297 : }
3236 : :
3237 : 57 : void DocxAttributeOutput::CharPostureCTL( const SvxPostureItem& rPosture)
3238 : : {
3239 [ + - ]: 57 : if ( rPosture.GetPosture() != ITALIC_NONE )
3240 : 57 : m_pSerializer->singleElementNS( XML_w, XML_iCs, FSEND );
3241 : : else
3242 : 0 : m_pSerializer->singleElementNS( XML_w, XML_iCs, FSNS( XML_w, XML_val ), "false", FSEND );
3243 : 57 : }
3244 : :
3245 : 6 : void DocxAttributeOutput::CharWeightCTL( const SvxWeightItem& rWeight )
3246 : : {
3247 [ + - ]: 6 : if ( rWeight.GetWeight() == WEIGHT_BOLD )
3248 : 6 : m_pSerializer->singleElementNS( XML_w, XML_bCs, FSEND );
3249 : : else
3250 : 0 : m_pSerializer->singleElementNS( XML_w, XML_bCs, FSNS( XML_w, XML_val ), "false", FSEND );
3251 : 6 : }
3252 : :
3253 : 0 : void DocxAttributeOutput::CharRotate( const SvxCharRotateItem& rRotate)
3254 : : {
3255 [ # # ]: 0 : if ( !rRotate.GetValue() )
3256 : 0 : return;
3257 : :
3258 [ # # ]: 0 : if (!m_pEastAsianLayoutAttrList)
3259 [ # # ]: 0 : m_pEastAsianLayoutAttrList = m_pSerializer->createAttrList();
3260 : 0 : OString sTrue((sal_Char *)"true");
3261 [ # # ]: 0 : m_pEastAsianLayoutAttrList->add(FSNS(XML_w, XML_vert), sTrue);
3262 : :
3263 [ # # ]: 0 : if (rRotate.IsFitToLine())
3264 [ # # ]: 0 : m_pEastAsianLayoutAttrList->add(FSNS(XML_w, XML_vertCompress), sTrue);
3265 : : }
3266 : :
3267 : 0 : void DocxAttributeOutput::CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark )
3268 : : {
3269 : : const char *pEmphasis;
3270 : :
3271 [ # # # # : 0 : switch ( rEmphasisMark.GetValue() )
# ]
3272 : : {
3273 : 0 : case EMPHASISMARK_NONE: pEmphasis = "none"; break;
3274 : 0 : case EMPHASISMARK_SIDE_DOTS: pEmphasis = "dot"; break;
3275 : 0 : case EMPHASISMARK_CIRCLE_ABOVE: pEmphasis = "circle"; break;
3276 : 0 : case EMPHASISMARK_DOTS_BELOW: pEmphasis = "underDot"; break;
3277 : 0 : default: pEmphasis = "comma"; break;
3278 : : }
3279 : :
3280 : 0 : m_pSerializer->singleElementNS( XML_w, XML_em, FSNS( XML_w, XML_val ), pEmphasis, FSEND );
3281 : 0 : }
3282 : :
3283 : 0 : void DocxAttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines )
3284 : : {
3285 [ # # ]: 0 : if ( !rTwoLines.GetValue() )
3286 : : return;
3287 : :
3288 [ # # ]: 0 : if (!m_pEastAsianLayoutAttrList)
3289 [ # # ]: 0 : m_pEastAsianLayoutAttrList = m_pSerializer->createAttrList();
3290 : 0 : OString sTrue((sal_Char *)"true");
3291 [ # # ]: 0 : m_pEastAsianLayoutAttrList->add(FSNS(XML_w, XML_combine), sTrue);
3292 : :
3293 : 0 : sal_Unicode cStart = rTwoLines.GetStartBracket();
3294 : 0 : sal_Unicode cEnd = rTwoLines.GetEndBracket();
3295 : :
3296 [ # # ][ # # ]: 0 : if (!cStart && !cEnd)
3297 : : return;
3298 : :
3299 : 0 : OString sBracket;
3300 [ # # ][ # # ]: 0 : if ((cStart == '{') || (cEnd == '}'))
3301 : 0 : sBracket = (sal_Char *)"curly";
3302 [ # # ][ # # ]: 0 : else if ((cStart == '<') || (cEnd == '>'))
3303 : 0 : sBracket = (sal_Char *)"angle";
3304 [ # # ][ # # ]: 0 : else if ((cStart == '[') || (cEnd == ']'))
3305 : 0 : sBracket = (sal_Char *)"square";
3306 : : else
3307 : 0 : sBracket = (sal_Char *)"round";
3308 [ # # ][ # # ]: 0 : m_pEastAsianLayoutAttrList->add(FSNS(XML_w, XML_combineBrackets), sBracket);
3309 : : }
3310 : :
3311 : 0 : void DocxAttributeOutput::CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth )
3312 : : {
3313 : : m_pSerializer->singleElementNS( XML_w, XML_w,
3314 [ # # ]: 0 : FSNS( XML_w, XML_val ), rtl::OString::valueOf( sal_Int32( rScaleWidth.GetValue() ) ).getStr(), FSEND );
3315 : 0 : }
3316 : :
3317 : 0 : void DocxAttributeOutput::CharRelief( const SvxCharReliefItem& rRelief )
3318 : : {
3319 [ # # # ]: 0 : switch ( rRelief.GetValue() )
3320 : : {
3321 : : case RELIEF_EMBOSSED:
3322 : 0 : m_pSerializer->singleElementNS( XML_w, XML_emboss, FSEND );
3323 : 0 : break;
3324 : : case RELIEF_ENGRAVED:
3325 : 0 : m_pSerializer->singleElementNS( XML_w, XML_imprint, FSEND );
3326 : 0 : break;
3327 : : default:
3328 : 0 : m_pSerializer->singleElementNS( XML_w, XML_emboss, FSNS( XML_w, XML_val ), "false", FSEND );
3329 : 0 : m_pSerializer->singleElementNS( XML_w, XML_imprint, FSNS( XML_w, XML_val ), "false", FSEND );
3330 : 0 : break;
3331 : : }
3332 : 0 : }
3333 : :
3334 : 0 : void DocxAttributeOutput::CharHidden( const SvxCharHiddenItem& rHidden )
3335 : : {
3336 [ # # ]: 0 : if ( rHidden.GetValue() )
3337 : 0 : m_pSerializer->singleElementNS( XML_w, XML_vanish, FSEND );
3338 : : else
3339 : 0 : m_pSerializer->singleElementNS( XML_w, XML_vanish, FSNS( XML_w, XML_val ), "false", FSEND );
3340 : 0 : }
3341 : :
3342 : 3 : void DocxAttributeOutput::TextINetFormat( const SwFmtINetFmt& rLink )
3343 : : {
3344 : 3 : const SwTxtINetFmt* pINetFmt = rLink.GetTxtINetFmt();
3345 [ + - ]: 3 : const SwCharFmt* pCharFmt = pINetFmt->GetCharFmt();
3346 : :
3347 : 3 : OString aStyleId( "style" );
3348 [ + - ]: 3 : aStyleId += OString::valueOf( sal_Int32( m_rExport.GetId( *pCharFmt ) ) );
3349 : :
3350 [ + - ]: 3 : m_pSerializer->singleElementNS( XML_w, XML_rStyle, FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND );
3351 : 3 : }
3352 : :
3353 : 0 : void DocxAttributeOutput::TextCharFormat( const SwFmtCharFmt& rCharFmt )
3354 : : {
3355 : 0 : OString aStyleId( "style" );
3356 [ # # ]: 0 : aStyleId += OString::valueOf( sal_Int32( m_rExport.GetId( *rCharFmt.GetCharFmt() ) ) );
3357 : :
3358 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_w, XML_rStyle, FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND );
3359 : 0 : }
3360 : :
3361 : 0 : void DocxAttributeOutput::RefField( const SwField& rFld, const String& rRef )
3362 : : {
3363 : 0 : sal_uInt16 nType = rFld.GetTyp( )->Which( );
3364 [ # # ]: 0 : if ( nType == RES_GETEXPFLD )
3365 : : {
3366 [ # # ]: 0 : String sCmd = FieldString( ww::eREF );
3367 [ # # ]: 0 : sCmd.APPEND_CONST_ASC( "\"" );
3368 [ # # ]: 0 : sCmd += rRef;
3369 [ # # ]: 0 : sCmd.APPEND_CONST_ASC( "\" " );
3370 : :
3371 [ # # ][ # # ]: 0 : m_rExport.OutputField( &rFld, ww::eREF, sCmd );
3372 : : }
3373 : :
3374 : : // There is nothing to do here for the set fields
3375 : 0 : }
3376 : :
3377 : 0 : void DocxAttributeOutput::HiddenField( const SwField& /*rFld*/ )
3378 : : {
3379 : : OSL_TRACE( "TODO DocxAttributeOutput::HiddenField()" );
3380 : 0 : }
3381 : :
3382 : 3 : void DocxAttributeOutput::PostitField( const SwField* pFld )
3383 : : {
3384 : : assert( dynamic_cast< const SwPostItField* >( pFld ));
3385 [ + - ]: 3 : m_postitFields.push_back( static_cast< const SwPostItField* >( pFld ));
3386 : 3 : }
3387 : :
3388 : 162 : void DocxAttributeOutput::WritePostitFieldReference()
3389 : : {
3390 [ + + ]: 165 : while( m_postitFieldsMaxId < m_postitFields.size())
3391 : : {
3392 : 3 : OString idstr = OString::valueOf( sal_Int32( m_postitFieldsMaxId ));
3393 [ + - ]: 3 : m_pSerializer->singleElementNS( XML_w, XML_commentReference, FSNS( XML_w, XML_id ), idstr.getStr(), FSEND );
3394 : 3 : ++m_postitFieldsMaxId;
3395 : 3 : }
3396 : 162 : }
3397 : :
3398 : 3 : void DocxAttributeOutput::WritePostitFieldStart()
3399 : : {
3400 : 3 : m_bPostitStart = true;
3401 : 3 : }
3402 : :
3403 : 3 : void DocxAttributeOutput::WritePostitFieldEnd()
3404 : : {
3405 : 3 : m_bPostitEnd = true;
3406 : 3 : }
3407 : :
3408 : 3 : void DocxAttributeOutput::WritePostitFields()
3409 : : {
3410 [ + + ]: 12 : for( unsigned int i = 0;
3411 : 6 : i < m_postitFields.size();
3412 : : ++i )
3413 : : {
3414 : 3 : OString idstr = OString::valueOf( sal_Int32( i ));
3415 : 3 : const SwPostItField* f = m_postitFields[ i ];
3416 : : m_pSerializer->startElementNS( XML_w, XML_comment, FSNS( XML_w, XML_id ), idstr.getStr(),
3417 [ + - ]: 3 : FSNS( XML_w, XML_author ), rtl::OUStringToOString( f->GetPar1(), RTL_TEXTENCODING_UTF8 ).getStr(),
3418 : : FSNS( XML_w, XML_date ), msfilter::util::DateTimeToOString(f->GetDateTime()).getStr(),
3419 [ + - ][ + - ]: 6 : FSNS( XML_w, XML_initials ), rtl::OUStringToOString( f->GetInitials(), RTL_TEXTENCODING_UTF8 ).getStr(), FSEND );
[ + - ][ + - ]
[ + - ][ + - ]
3420 : : // Check for the text object existing, it seems that it can be NULL when saving a newly created
3421 : : // comment without giving focus back to the main document. As GetTxt() is empty in that case as well,
3422 : : // that is probably a bug in the Writer core.
3423 [ + - ][ + - ]: 3 : if( f->GetTextObject() != NULL )
3424 [ + - ][ + - ]: 3 : GetExport().WriteOutliner( *f->GetTextObject(), TXT_ATN );
[ + - ]
3425 [ + - ]: 3 : m_pSerializer->endElementNS( XML_w, XML_comment );
3426 : 3 : }
3427 : 3 : }
3428 : :
3429 : 0 : bool DocxAttributeOutput::DropdownField( const SwField* pFld )
3430 : : {
3431 : 0 : bool bExpand = false;
3432 : :
3433 : 0 : ww::eField eType = ww::eFORMDROPDOWN;
3434 [ # # ]: 0 : String sCmd = FieldString( eType );
3435 [ # # ][ # # ]: 0 : GetExport( ).OutputField( pFld, eType, sCmd );
3436 : :
3437 [ # # ]: 0 : return bExpand;
3438 : : }
3439 : :
3440 : 0 : void DocxAttributeOutput::SetField( const SwField& rFld, ww::eField eType, const String& rCmd )
3441 : : {
3442 : : // field bookmarks are handled in the EndRun method
3443 : 0 : GetExport().OutputField(&rFld, eType, rCmd );
3444 : 0 : }
3445 : :
3446 : 0 : void DocxAttributeOutput::WriteExpand( const SwField* pFld )
3447 : : {
3448 : : // Will be written in the next End Run
3449 [ # # ]: 0 : String sCmd;
3450 [ # # ][ # # ]: 0 : m_rExport.OutputField( pFld, ww::eUNKNOWN, sCmd );
3451 : 0 : }
3452 : :
3453 : 3 : void DocxAttributeOutput::WriteField_Impl( const SwField* pFld, ww::eField eType, const String& rFldCmd, sal_uInt8 nMode )
3454 : : {
3455 [ + - ]: 3 : struct FieldInfos infos;
3456 : 3 : infos.pField = pFld;
3457 [ + - ]: 3 : infos.sCmd = rFldCmd;
3458 : 3 : infos.eType = eType;
3459 : 3 : infos.bClose = WRITEFIELD_CLOSE & nMode;
3460 : 3 : infos.bOpen = WRITEFIELD_START & nMode;
3461 [ + - ]: 3 : m_Fields.push_back( infos );
3462 : :
3463 [ - + ]: 3 : if ( pFld )
3464 : : {
3465 : 0 : sal_uInt16 nType = pFld->GetTyp( )->Which( );
3466 [ # # ]: 0 : sal_uInt16 nSubType = pFld->GetSubType();
3467 : :
3468 : : // TODO Any other field types here ?
3469 [ # # ][ # # ]: 0 : if ( ( nType == RES_SETEXPFLD ) && ( nSubType & nsSwGetSetExpType::GSE_STRING ) )
3470 : : {
3471 : 0 : const SwSetExpField *pSet = ( const SwSetExpField* )( pFld );
3472 [ # # ][ # # ]: 0 : m_sFieldBkm = pSet->GetPar1( );
3473 : : }
3474 [ # # ]: 0 : else if ( nType == RES_DROPDOWN )
3475 : : {
3476 : 0 : const SwDropDownField* pDropDown = ( const SwDropDownField* )( pFld );
3477 [ # # ][ # # ]: 0 : m_sFieldBkm = pDropDown->GetName( );
3478 : : }
3479 [ + - ]: 3 : }
3480 : 3 : }
3481 : :
3482 : 0 : void DocxAttributeOutput::WriteFormData_Impl( const ::sw::mark::IFieldmark& rFieldmark )
3483 : : {
3484 [ # # ]: 0 : if ( !m_Fields.empty() )
3485 : 0 : m_Fields.begin()->pFieldmark = &rFieldmark;
3486 : 0 : }
3487 : :
3488 : 264 : void DocxAttributeOutput::WriteBookmarks_Impl( std::vector< OUString >& rStarts,
3489 : : std::vector< OUString >& rEnds )
3490 : : {
3491 [ + - ][ + - ]: 267 : for ( std::vector< OUString >::const_iterator it = rStarts.begin(), end = rStarts.end(); it != end; ++it )
[ + - ][ + + ]
3492 : : {
3493 [ + - ]: 3 : OString rName = OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr( );
3494 [ + - ]: 3 : m_rMarksStart.push_back( rName );
3495 : 3 : }
3496 : 264 : rStarts.clear();
3497 : :
3498 [ + - ][ + - ]: 267 : for ( std::vector< OUString >::const_iterator it = rEnds.begin(), end = rEnds.end(); it != end; ++it )
[ + + ][ + - ]
3499 : : {
3500 [ + - ]: 3 : OString rName = OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr( );
3501 [ + - ]: 3 : m_rMarksEnd.push_back( rName );
3502 : 3 : }
3503 : 264 : rEnds.clear();
3504 : 264 : }
3505 : :
3506 : 0 : void DocxAttributeOutput::TextFootnote_Impl( const SwFmtFtn& rFootnote )
3507 : : {
3508 : 0 : const SwEndNoteInfo& rInfo = rFootnote.IsEndNote()?
3509 [ # # ]: 0 : m_rExport.pDoc->GetEndNoteInfo(): m_rExport.pDoc->GetFtnInfo();
3510 : :
3511 : : // footnote/endnote run properties
3512 [ # # ]: 0 : const SwCharFmt* pCharFmt = rInfo.GetAnchorCharFmt( *m_rExport.pDoc );
3513 : :
3514 : 0 : OString aStyleId( "style" );
3515 [ # # ]: 0 : aStyleId += OString::valueOf( sal_Int32( m_rExport.GetId( *pCharFmt ) ) );
3516 : :
3517 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_w, XML_rStyle, FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND );
3518 : :
3519 : : // remember the footnote/endnote to
3520 : : // 1) write the footnoteReference/endnoteReference in EndRunProperties()
3521 : : // 2) be able to dump them all to footnotes.xml/endnotes.xml
3522 [ # # ]: 0 : if ( !rFootnote.IsEndNote() )
3523 [ # # ]: 0 : m_pFootnotesList->add( rFootnote );
3524 : : else
3525 [ # # ]: 0 : m_pEndnotesList->add( rFootnote );
3526 : 0 : }
3527 : :
3528 : 165 : void DocxAttributeOutput::FootnoteEndnoteReference()
3529 : : {
3530 : : sal_Int32 nId;
3531 [ + - ]: 165 : const SwFmtFtn *pFootnote = m_pFootnotesList->getCurrent( nId );
3532 : :
3533 : : // both cannot be set at the same time - if they are, it's a bug
3534 [ + - ]: 165 : if ( !pFootnote )
3535 [ + - ]: 165 : pFootnote = m_pEndnotesList->getCurrent( nId );
3536 : :
3537 [ - + ]: 165 : if ( !pFootnote )
3538 : 165 : return;
3539 : :
3540 [ # # ]: 0 : sal_Int32 nToken = pFootnote->IsEndNote()? XML_endnoteReference: XML_footnoteReference;
3541 : :
3542 : : // write it
3543 [ # # ]: 0 : if ( pFootnote->GetNumStr().Len() == 0 )
3544 : : {
3545 : : // autonumbered
3546 : : m_pSerializer->singleElementNS( XML_w, nToken,
3547 : : FSNS( XML_w, XML_id ), ::rtl::OString::valueOf( nId ).getStr(),
3548 [ # # ]: 0 : FSEND );
3549 : : }
3550 : : else
3551 : : {
3552 : : // not autonumbered
3553 : : m_pSerializer->singleElementNS( XML_w, nToken,
3554 : : FSNS( XML_w, XML_customMarkFollows ), "1",
3555 : : FSNS( XML_w, XML_id ), ::rtl::OString::valueOf( nId ).getStr(),
3556 [ # # ]: 0 : FSEND );
3557 : :
3558 [ # # ]: 165 : RunText( pFootnote->GetNumStr() );
3559 : : }
3560 : : }
3561 : :
3562 : 0 : void DocxAttributeOutput::FootnotesEndnotes( bool bFootnotes )
3563 : : {
3564 [ # # ]: 0 : const FootnotesVector& rVector = bFootnotes? m_pFootnotesList->getVector(): m_pEndnotesList->getVector();
3565 : :
3566 [ # # ]: 0 : sal_Int32 nBody = bFootnotes? XML_footnotes: XML_endnotes;
3567 [ # # ]: 0 : sal_Int32 nItem = bFootnotes? XML_footnote: XML_endnote;
3568 : :
3569 : : m_pSerializer->startElementNS( XML_w, nBody,
3570 : : FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
3571 : : FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
3572 : 0 : FSEND );
3573 : :
3574 : 0 : sal_Int32 nIndex = 0;
3575 : :
3576 : : // separator
3577 : : m_pSerializer->startElementNS( XML_w, nItem,
3578 : : FSNS( XML_w, XML_id ), OString::valueOf( nIndex++ ).getStr(),
3579 : : FSNS( XML_w, XML_type ), "separator",
3580 [ # # ]: 0 : FSEND );
3581 : 0 : m_pSerializer->startElementNS( XML_w, XML_p, FSEND );
3582 : 0 : m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
3583 : 0 : m_pSerializer->singleElementNS( XML_w, XML_separator, FSEND );
3584 : 0 : m_pSerializer->endElementNS( XML_w, XML_r );
3585 : 0 : m_pSerializer->endElementNS( XML_w, XML_p );
3586 : 0 : m_pSerializer->endElementNS( XML_w, nItem );
3587 : :
3588 : : // separator
3589 : : m_pSerializer->startElementNS( XML_w, nItem,
3590 : : FSNS( XML_w, XML_id ), OString::valueOf( nIndex++ ).getStr(),
3591 : : FSNS( XML_w, XML_type ), "continuationSeparator",
3592 [ # # ]: 0 : FSEND );
3593 : 0 : m_pSerializer->startElementNS( XML_w, XML_p, FSEND );
3594 : 0 : m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
3595 : 0 : m_pSerializer->singleElementNS( XML_w, XML_continuationSeparator, FSEND );
3596 : 0 : m_pSerializer->endElementNS( XML_w, XML_r );
3597 : 0 : m_pSerializer->endElementNS( XML_w, XML_p );
3598 : 0 : m_pSerializer->endElementNS( XML_w, nItem );
3599 : :
3600 : : // if new special ones are added, update also WriteFootnoteEndnotePr()
3601 : :
3602 : : // footnotes/endnotes themselves
3603 [ # # ][ # # ]: 0 : for ( FootnotesVector::const_iterator i = rVector.begin(); i != rVector.end(); ++i, ++nIndex )
[ # # ]
3604 : : {
3605 : : m_pSerializer->startElementNS( XML_w, nItem,
3606 : : FSNS( XML_w, XML_id ), OString::valueOf( nIndex ).getStr(),
3607 [ # # ]: 0 : FSEND );
3608 : :
3609 [ # # ]: 0 : const SwNodeIndex* pIndex = (*i)->GetTxtFtn()->GetStartNode();
3610 : : // tag required at the start of each footnote/endnote
3611 [ # # ]: 0 : m_footnoteEndnoteRefTag = bFootnotes ? XML_footnoteRef : XML_endnoteRef;
3612 : :
3613 : 0 : m_rExport.WriteSpecialText( pIndex->GetIndex() + 1,
3614 : 0 : pIndex->GetNode().EndOfSectionIndex(),
3615 [ # # ][ # # ]: 0 : bFootnotes? TXT_FTN: TXT_EDN );
3616 : :
3617 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, nItem );
3618 : : }
3619 : :
3620 : 0 : m_pSerializer->endElementNS( XML_w, nBody );
3621 : :
3622 : 0 : }
3623 : :
3624 : 0 : void DocxAttributeOutput::WriteFootnoteEndnotePr( ::sax_fastparser::FSHelperPtr fs, int tag,
3625 : : const SwEndNoteInfo& info, int listtag )
3626 : : {
3627 : 0 : fs->startElementNS( XML_w, tag, FSEND );
3628 : 0 : const char* fmt = NULL;
3629 [ # # # # : 0 : switch( info.aFmt.GetNumberingType())
# # # # ]
3630 : : {
3631 : : case SVX_NUM_CHARS_UPPER_LETTER_N: // fall through, map to upper letters
3632 : : case SVX_NUM_CHARS_UPPER_LETTER:
3633 : 0 : fmt = "upperLetter";
3634 : 0 : break;
3635 : : case SVX_NUM_CHARS_LOWER_LETTER_N: // fall through, map to lower letters
3636 : : case SVX_NUM_CHARS_LOWER_LETTER:
3637 : 0 : fmt = "lowerLetter";
3638 : 0 : break;
3639 : : case SVX_NUM_ROMAN_UPPER:
3640 : 0 : fmt = "upperRoman";
3641 : 0 : break;
3642 : : case SVX_NUM_ROMAN_LOWER:
3643 : 0 : fmt = "lowerRoman";
3644 : 0 : break;
3645 : : case SVX_NUM_ARABIC:
3646 : 0 : fmt = "decimal";
3647 : 0 : break;
3648 : : case SVX_NUM_NUMBER_NONE:
3649 : 0 : fmt = "none";
3650 : 0 : break;
3651 : : case SVX_NUM_CHAR_SPECIAL:
3652 : 0 : fmt = "bullet";
3653 : 0 : break;
3654 : : case SVX_NUM_PAGEDESC:
3655 : : case SVX_NUM_BITMAP:
3656 : : default:
3657 : 0 : break; // no format
3658 : : }
3659 [ # # ]: 0 : if( fmt != NULL )
3660 : 0 : fs->singleElementNS( XML_w, XML_numFmt, FSNS( XML_w, XML_val ), fmt, FSEND );
3661 [ # # ]: 0 : if( info.nFtnOffset != 0 )
3662 : : fs->singleElementNS( XML_w, XML_numStart, FSNS( XML_w, XML_val ),
3663 [ # # ]: 0 : rtl::OString::valueOf( sal_Int32( info.nFtnOffset + 1 )).getStr(), FSEND );
3664 [ # # ]: 0 : if( listtag != 0 ) // we are writting to settings.xml, write also special footnote/endnote list
3665 : : { // there are currently only two hardcoded ones ( see FootnotesEndnotes())
3666 : 0 : fs->singleElementNS( XML_w, listtag, FSNS( XML_w, XML_id ), "0", FSEND );
3667 : 0 : fs->singleElementNS( XML_w, listtag, FSNS( XML_w, XML_id ), "1", FSEND );
3668 : : }
3669 : 0 : fs->endElementNS( XML_w, tag );
3670 : 0 : }
3671 : :
3672 : 57 : void DocxAttributeOutput::SectFootnoteEndnotePr()
3673 : : {
3674 [ - + ]: 57 : if( HasFootnotes())
3675 [ # # ]: 0 : WriteFootnoteEndnotePr( m_pSerializer, XML_footnotePr, m_rExport.pDoc->GetFtnInfo(), 0 );
3676 [ - + ]: 57 : if( HasEndnotes())
3677 [ # # ]: 0 : WriteFootnoteEndnotePr( m_pSerializer, XML_endnotePr, m_rExport.pDoc->GetEndNoteInfo(), 0 );
3678 : 57 : }
3679 : :
3680 : 24 : void DocxAttributeOutput::ParaLineSpacing_Impl( short nSpace, short nMulti )
3681 : : {
3682 [ + - ]: 24 : if ( !m_pParagraphSpacingAttrList )
3683 : 24 : m_pParagraphSpacingAttrList = m_pSerializer->createAttrList();
3684 : :
3685 [ - + ]: 24 : if ( nSpace < 0 )
3686 : : {
3687 [ # # ]: 0 : m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_lineRule ), "exact" );
3688 [ # # ]: 0 : m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_line ), OString::valueOf( sal_Int32( -nSpace ) ) );
3689 : : }
3690 [ + + ]: 24 : else if( nMulti )
3691 : : {
3692 [ + - ]: 9 : m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_lineRule ), "auto" );
3693 [ + - ]: 9 : m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_line ), OString::valueOf( sal_Int32( nSpace ) ) );
3694 : : }
3695 [ + - ]: 15 : else if ( nSpace > 0 )
3696 : : {
3697 [ + - ]: 15 : m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_lineRule ), "atLeast" );
3698 [ + - ]: 15 : m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_line ), OString::valueOf( sal_Int32( nSpace ) ) );
3699 : : }
3700 : : else
3701 [ # # ]: 0 : m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_lineRule ), "auto" );
3702 : 24 : }
3703 : :
3704 : 0 : void DocxAttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
3705 : : {
3706 : : const char *pAdjustString;
3707 : :
3708 : 0 : bool bEcma = GetExport().GetFilter().getVersion( ) == oox::core::ECMA_DIALECT;
3709 : :
3710 : 0 : const SfxItemSet* pItems = GetExport().GetCurItemSet();
3711 : 0 : const SvxFrameDirectionItem* rFrameDir = static_cast< const SvxFrameDirectionItem* >( pItems->GetItem( RES_FRAMEDIR ) );
3712 : :
3713 : 0 : short nDir = FRMDIR_ENVIRONMENT;
3714 [ # # ]: 0 : if( rFrameDir != NULL )
3715 : 0 : nDir = rFrameDir->GetValue();
3716 [ # # ]: 0 : if ( nDir == FRMDIR_ENVIRONMENT )
3717 : 0 : nDir = GetExport( ).GetDefaultFrameDirection( );
3718 : 0 : bool bRtl = ( nDir == FRMDIR_HORI_RIGHT_TOP );
3719 : :
3720 [ # # # # : 0 : switch ( rAdjust.GetAdjust() )
# ]
3721 : : {
3722 : : case SVX_ADJUST_LEFT:
3723 [ # # ]: 0 : if ( bEcma )
3724 : 0 : pAdjustString = "left";
3725 [ # # ]: 0 : else if ( bRtl )
3726 : 0 : pAdjustString = "end";
3727 : : else
3728 : 0 : pAdjustString = "start";
3729 : 0 : break;
3730 : : case SVX_ADJUST_RIGHT:
3731 [ # # ]: 0 : if ( bEcma )
3732 : 0 : pAdjustString = "right";
3733 [ # # ]: 0 : else if ( bRtl )
3734 : 0 : pAdjustString = "start";
3735 : : else
3736 : 0 : pAdjustString = "end";
3737 : 0 : break;
3738 : : case SVX_ADJUST_BLOCKLINE:
3739 : : case SVX_ADJUST_BLOCK:
3740 : 0 : pAdjustString = "both";
3741 : 0 : break;
3742 : : case SVX_ADJUST_CENTER:
3743 : 0 : pAdjustString = "center";
3744 : 0 : break;
3745 : : default:
3746 : 0 : return; // not supported attribute
3747 : : }
3748 : 0 : m_pSerializer->singleElementNS( XML_w, XML_jc, FSNS( XML_w, XML_val ), pAdjustString, FSEND );
3749 : : }
3750 : :
3751 : 0 : void DocxAttributeOutput::ParaSplit( const SvxFmtSplitItem& rSplit )
3752 : : {
3753 [ # # ]: 0 : if (rSplit.GetValue())
3754 : 0 : m_pSerializer->singleElementNS( XML_w, XML_keepLines, FSNS( XML_w, XML_val ), "false", FSEND );
3755 : : else
3756 : 0 : m_pSerializer->singleElementNS( XML_w, XML_keepLines, FSEND );
3757 : 0 : }
3758 : :
3759 : 60 : void DocxAttributeOutput::ParaWidows( const SvxWidowsItem& rWidows )
3760 : : {
3761 [ + + ]: 60 : if (rWidows.GetValue())
3762 : 9 : m_pSerializer->singleElementNS( XML_w, XML_widowControl, FSEND );
3763 : : else
3764 : 51 : m_pSerializer->singleElementNS( XML_w, XML_widowControl, FSNS( XML_w, XML_val ), "false", FSEND );
3765 : 60 : }
3766 : :
3767 : 42 : static void impl_WriteTabElement( FSHelperPtr pSerializer,
3768 : : const SvxTabStop& rTab, long nCurrentLeft )
3769 : : {
3770 : 42 : FastAttributeList *pTabElementAttrList = pSerializer->createAttrList();
3771 : :
3772 [ - - - + ]: 42 : switch (rTab.GetAdjustment())
3773 : : {
3774 : : case SVX_TAB_ADJUST_RIGHT:
3775 [ # # ]: 0 : pTabElementAttrList->add( FSNS( XML_w, XML_val ), OString( (sal_Char *)"right") );
3776 : 0 : break;
3777 : : case SVX_TAB_ADJUST_DECIMAL:
3778 [ # # ]: 0 : pTabElementAttrList->add( FSNS( XML_w, XML_val ), OString( (sal_Char *)"decimal") );
3779 : 0 : break;
3780 : : case SVX_TAB_ADJUST_CENTER:
3781 [ # # ]: 0 : pTabElementAttrList->add( FSNS( XML_w, XML_val ), OString( (sal_Char *)"center") );
3782 : 0 : break;
3783 : : case SVX_TAB_ADJUST_DEFAULT:
3784 : : case SVX_TAB_ADJUST_LEFT:
3785 : : default:
3786 [ + - ]: 42 : pTabElementAttrList->add( FSNS( XML_w, XML_val ), OString( (sal_Char *)"left") );
3787 : 42 : break;
3788 : : }
3789 : :
3790 [ + - ]: 42 : pTabElementAttrList->add( FSNS( XML_w, XML_pos ), OString::valueOf( rTab.GetTabPos() + nCurrentLeft ) );
3791 : :
3792 : 42 : sal_Unicode cFillChar = rTab.GetFill();
3793 : :
3794 [ - + ]: 42 : if (sal_Unicode('.') == cFillChar )
3795 [ # # ]: 0 : pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( (sal_Char *) "dot" ) );
3796 [ - + ]: 42 : else if ( sal_Unicode('-') == cFillChar )
3797 [ # # ]: 0 : pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( (sal_Char *) "hyphen" ) );
3798 [ - + ]: 42 : else if ( sal_Unicode(0xB7) == cFillChar ) // middle dot
3799 [ # # ]: 0 : pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( (sal_Char *) "middleDot" ) );
3800 [ - + ]: 42 : else if ( sal_Unicode('_') == cFillChar )
3801 [ # # ]: 0 : pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( (sal_Char *) "underscore" ) );
3802 : : else
3803 [ + - ]: 42 : pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( (sal_Char *) "none" ) );
3804 : :
3805 [ + - ][ + - ]: 42 : pSerializer->singleElementNS( XML_w, XML_tab, pTabElementAttrList );
3806 : 42 : }
3807 : :
3808 : 57 : void DocxAttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStop )
3809 : : {
3810 : 57 : const SfxPoolItem* pLR = m_rExport.HasItem( RES_LR_SPACE );
3811 [ - + ]: 57 : long nCurrentLeft = pLR ? ((const SvxLRSpaceItem*)pLR)->GetTxtLeft() : 0;
3812 : :
3813 : 57 : sal_uInt16 nCount = rTabStop.Count();
3814 : :
3815 : : // <w:tabs> must contain at least one <w:tab>, so don't write it empty
3816 [ - + ]: 57 : if( nCount == 0 )
3817 : 0 : return;
3818 [ + - ][ + + ]: 57 : if( nCount == 1 && rTabStop[ 0 ].GetAdjustment() == SVX_TAB_ADJUST_DEFAULT )
[ + + ]
3819 : : {
3820 : 15 : GetExport().setDefaultTabStop( rTabStop[ 0 ].GetTabPos());
3821 : 15 : return;
3822 : : }
3823 : :
3824 : 42 : m_pSerializer->startElementNS( XML_w, XML_tabs, FSEND );
3825 : :
3826 [ + + ]: 84 : for (sal_uInt16 i = 0; i < nCount; i++ )
3827 : : {
3828 [ + - ]: 42 : if( rTabStop[i].GetAdjustment() != SVX_TAB_ADJUST_DEFAULT )
3829 [ + - ]: 42 : impl_WriteTabElement( m_pSerializer, rTabStop[i], nCurrentLeft );
3830 : : else
3831 : 0 : GetExport().setDefaultTabStop( rTabStop[i].GetTabPos());
3832 : : }
3833 : :
3834 : 57 : m_pSerializer->endElementNS( XML_w, XML_tabs );
3835 : : }
3836 : :
3837 : 57 : void DocxAttributeOutput::ParaHyphenZone( const SvxHyphenZoneItem& rHyphenZone )
3838 : : {
3839 : : m_pSerializer->singleElementNS( XML_w, XML_suppressAutoHyphens,
3840 : 57 : FSNS( XML_w, XML_val ), rHyphenZone.IsHyphen( ) ? "false" : "true" ,
3841 [ - + ]: 57 : FSEND );
3842 : 57 : }
3843 : :
3844 : 0 : void DocxAttributeOutput::ParaNumRule_Impl( const SwTxtNode* /*pTxtNd*/, sal_Int32 nLvl, sal_Int32 nNumId )
3845 : : {
3846 [ # # ][ # # ]: 0 : if ( USHRT_MAX != nNumId && 0 != nNumId )
3847 : : {
3848 : 0 : m_pSerializer->startElementNS( XML_w, XML_numPr, FSEND );
3849 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_w, XML_ilvl, FSNS( XML_w, XML_val ), OString::valueOf( sal_Int32( nLvl )).getStr(), FSEND );
3850 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_w, XML_numId, FSNS( XML_w, XML_val ), OString::valueOf( sal_Int32( nNumId )).getStr(), FSEND );
3851 : 0 : m_pSerializer->endElementNS( XML_w, XML_numPr );
3852 : : }
3853 : 0 : }
3854 : :
3855 : 21 : void DocxAttributeOutput::ParaScriptSpace( const SfxBoolItem& rScriptSpace )
3856 : : {
3857 : 21 : sal_uInt16 nXmlElement = 0;
3858 : :
3859 [ + + + - ]: 21 : switch ( rScriptSpace.Which( ) )
3860 : : {
3861 : : case RES_PARATR_SCRIPTSPACE:
3862 : 6 : nXmlElement = XML_autoSpaceDE;
3863 : 6 : break;
3864 : : case RES_PARATR_HANGINGPUNCTUATION:
3865 : 9 : nXmlElement = XML_overflowPunct;
3866 : 9 : break;
3867 : : case RES_PARATR_FORBIDDEN_RULES:
3868 : 6 : nXmlElement = XML_kinsoku;
3869 : 6 : break;
3870 : : }
3871 : :
3872 [ + - ]: 21 : if ( nXmlElement )
3873 : : {
3874 : : m_pSerializer->singleElementNS( XML_w, nXmlElement,
3875 : 21 : FSNS( XML_w, XML_val ), rScriptSpace.GetValue( ) ? "true": "false",
3876 [ + + ]: 21 : FSEND );
3877 : : }
3878 : 21 : }
3879 : :
3880 : 0 : void DocxAttributeOutput::ParaVerticalAlign( const SvxParaVertAlignItem& rAlign )
3881 : : {
3882 : : const char *pAlignString;
3883 : :
3884 [ # # # # : 0 : switch ( rAlign.GetValue() )
# # ]
3885 : : {
3886 : : case SvxParaVertAlignItem::BASELINE:
3887 : 0 : pAlignString = "baseline";
3888 : 0 : break;
3889 : : case SvxParaVertAlignItem::TOP:
3890 : 0 : pAlignString = "top";
3891 : 0 : break;
3892 : : case SvxParaVertAlignItem::CENTER:
3893 : 0 : pAlignString = "center";
3894 : 0 : break;
3895 : : case SvxParaVertAlignItem::BOTTOM:
3896 : 0 : pAlignString = "bottom";
3897 : 0 : break;
3898 : : case SvxParaVertAlignItem::AUTOMATIC:
3899 : 0 : pAlignString = "auto";
3900 : 0 : break;
3901 : : default:
3902 : 0 : return; // not supported attribute
3903 : : }
3904 : 0 : m_pSerializer->singleElementNS( XML_w, XML_textAlignment, FSNS( XML_w, XML_val ), pAlignString, FSEND );
3905 : : }
3906 : :
3907 : 0 : void DocxAttributeOutput::ParaSnapToGrid( const SvxParaGridItem& rGrid )
3908 : : {
3909 : : m_pSerializer->singleElementNS( XML_w, XML_snapToGrid,
3910 : 0 : FSNS( XML_w, XML_val ), rGrid.GetValue( ) ? "true": "false",
3911 [ # # ]: 0 : FSEND );
3912 : 0 : }
3913 : :
3914 : 57 : void DocxAttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize )
3915 : : {
3916 [ - + ]: 57 : if ( m_rExport.bOutFlyFrmAttrs )
3917 : : {
3918 [ # # ]: 0 : if ( !m_pFlyAttrList )
3919 : 0 : m_pFlyAttrList = m_pSerializer->createAttrList( );
3920 : :
3921 [ # # ][ # # ]: 0 : if ( rSize.GetWidth() && rSize.GetWidthSizeType() == ATT_FIX_SIZE )
[ # # ]
3922 : : {
3923 [ # # ]: 0 : m_pFlyAttrList->add( FSNS( XML_w, XML_w ), OString::valueOf( rSize.GetWidth( ) ) );
3924 : : }
3925 : :
3926 [ # # ]: 0 : if ( rSize.GetHeight() )
3927 : : {
3928 : 0 : OString sRule( "exact" );
3929 [ # # ]: 0 : if ( rSize.GetHeightSizeType() == ATT_MIN_SIZE )
3930 : 0 : sRule = OString( "atLeast" );
3931 [ # # ]: 0 : m_pFlyAttrList->add( FSNS( XML_w, XML_hRule ), sRule );
3932 [ # # ]: 0 : m_pFlyAttrList->add( FSNS( XML_w, XML_h ), OString::valueOf( rSize.GetHeight( ) ) );
3933 : : }
3934 : : }
3935 [ + - ]: 57 : else if ( m_rExport.bOutPageDescs )
3936 : : {
3937 [ + - ]: 57 : FastAttributeList *attrList = m_pSerializer->createAttrList( );
3938 [ - + ]: 57 : if ( m_rExport.pAktPageDesc->GetLandscape( ) )
3939 [ # # ]: 0 : attrList->add( FSNS( XML_w, XML_orient ), "landscape" );
3940 : :
3941 [ + - ]: 57 : attrList->add( FSNS( XML_w, XML_w ), OString::valueOf( rSize.GetWidth( ) ) );
3942 [ + - ]: 57 : attrList->add( FSNS( XML_w, XML_h ), OString::valueOf( rSize.GetHeight( ) ) );
3943 : :
3944 [ + - ][ + - ]: 57 : XFastAttributeListRef xAttrList( attrList );
3945 : 57 : attrList = NULL;
3946 : :
3947 [ + - ]: 57 : m_pSerializer->singleElementNS( XML_w, XML_pgSz, xAttrList );
3948 : : }
3949 : 57 : }
3950 : :
3951 : 0 : void DocxAttributeOutput::FormatPaperBin( const SvxPaperBinItem& )
3952 : : {
3953 : : OSL_TRACE( "TODO DocxAttributeOutput::FormatPaperBin()" );
3954 : 0 : }
3955 : :
3956 : 57 : void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace )
3957 : : {
3958 : 57 : bool bEcma = m_rExport.GetFilter().getVersion( ) == oox::core::ECMA_DIALECT;
3959 : :
3960 [ - + ]: 57 : if ( m_rExport.bOutFlyFrmAttrs )
3961 : : {
3962 [ # # ]: 0 : if ( !m_pFlyAttrList )
3963 : 0 : m_pFlyAttrList = m_pSerializer->createAttrList();
3964 : :
3965 : : m_pFlyAttrList->add( FSNS( XML_w, XML_hSpace ),
3966 : : OString::valueOf(
3967 [ # # ]: 0 : sal_Int32( ( rLRSpace.GetLeft() + rLRSpace.GetRight() ) / 2 ) ) );
3968 : : }
3969 [ + - ]: 57 : else if ( m_rExport.bOutPageDescs )
3970 : : {
3971 [ + - ]: 57 : if ( !m_pSectionSpacingAttrList )
3972 : 57 : m_pSectionSpacingAttrList = m_pSerializer->createAttrList();
3973 : :
3974 : : sal_uInt16 nLDist, nRDist;
3975 : 57 : const SfxPoolItem* pItem = m_rExport.HasItem( RES_BOX );
3976 [ - + ]: 57 : if ( pItem )
3977 : : {
3978 : 0 : nRDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_LEFT );
3979 : 0 : nLDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_RIGHT );
3980 : : }
3981 : : else
3982 : 57 : nLDist = nRDist = 0;
3983 : 57 : nLDist = nLDist + (sal_uInt16)rLRSpace.GetLeft();
3984 : 57 : nRDist = nRDist + (sal_uInt16)rLRSpace.GetRight();
3985 : :
3986 [ + - ]: 57 : m_pSectionSpacingAttrList->add( FSNS( XML_w, XML_left ), OString::valueOf( sal_Int32( nLDist ) ) );
3987 [ + - ]: 57 : m_pSectionSpacingAttrList->add( FSNS( XML_w, XML_right ), OString::valueOf( sal_Int32( nRDist ) ) );
3988 : : }
3989 : : else
3990 : : {
3991 : 0 : FastAttributeList *pLRSpaceAttrList = m_pSerializer->createAttrList();
3992 : :
3993 [ # # ][ # # ]: 0 : pLRSpaceAttrList->add( FSNS( XML_w, ( bEcma ? XML_left : XML_start ) ), OString::valueOf( (sal_Int32) rLRSpace.GetTxtLeft() ) );
3994 [ # # ][ # # ]: 0 : pLRSpaceAttrList->add( FSNS( XML_w, ( bEcma ? XML_right : XML_end ) ), OString::valueOf( (sal_Int32) rLRSpace.GetRight() ) );
3995 : :
3996 : 0 : sal_Int32 nFirstLineAdjustment = rLRSpace.GetTxtFirstLineOfst();
3997 [ # # ]: 0 : if (nFirstLineAdjustment > 0)
3998 [ # # ]: 0 : pLRSpaceAttrList->add( FSNS( XML_w, XML_firstLine ), OString::valueOf( nFirstLineAdjustment ) );
3999 : : else
4000 [ # # ]: 0 : pLRSpaceAttrList->add( FSNS( XML_w, XML_hanging ), OString::valueOf( - nFirstLineAdjustment ) );
4001 [ # # ][ # # ]: 0 : m_pSerializer->singleElementNS( XML_w, XML_ind, pLRSpaceAttrList );
4002 : : }
4003 : 57 : }
4004 : :
4005 : 249 : void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
4006 : : {
4007 : :
4008 [ - + ]: 249 : if ( m_rExport.bOutFlyFrmAttrs )
4009 : : {
4010 [ # # ]: 0 : if ( !m_pFlyAttrList )
4011 : 0 : m_pFlyAttrList = m_pSerializer->createAttrList();
4012 : :
4013 : : m_pFlyAttrList->add( FSNS( XML_w, XML_vSpace ),
4014 : : OString::valueOf(
4015 [ # # ]: 0 : sal_Int32( ( rULSpace.GetLower() + rULSpace.GetUpper() ) / 2 ) ) );
4016 : : }
4017 [ + + ]: 249 : else if (m_rExport.bOutPageDescs )
4018 : : {
4019 : : OSL_ENSURE( m_rExport.GetCurItemSet(), "Impossible" );
4020 [ + - ]: 57 : if ( !m_rExport.GetCurItemSet() )
4021 : 249 : return;
4022 : :
4023 [ - + ]: 57 : if ( !m_pSectionSpacingAttrList )
4024 [ # # ]: 0 : m_pSectionSpacingAttrList = m_pSerializer->createAttrList();
4025 : :
4026 [ + - ]: 57 : HdFtDistanceGlue aDistances( *m_rExport.GetCurItemSet() );
4027 : :
4028 : 57 : sal_Int32 nHeader = 0;
4029 [ - + ]: 57 : if ( aDistances.HasHeader() )
4030 : 0 : nHeader = sal_Int32( aDistances.dyaHdrTop );
4031 [ + - ]: 57 : m_pSectionSpacingAttrList->add( FSNS( XML_w, XML_header ), OString::valueOf( nHeader ) );
4032 : :
4033 : : // Page top
4034 : : m_pSectionSpacingAttrList->add( FSNS( XML_w, XML_top ),
4035 [ + - ]: 57 : OString::valueOf( sal_Int32( aDistances.dyaTop ) ) );
4036 : :
4037 : 57 : sal_Int32 nFooter = 0;
4038 [ - + ]: 57 : if ( aDistances.HasFooter() )
4039 : 0 : nFooter = sal_Int32( aDistances.dyaHdrBottom );
4040 [ + - ]: 57 : m_pSectionSpacingAttrList->add( FSNS( XML_w, XML_footer ), OString::valueOf( nFooter ) );
4041 : :
4042 : : // Page Bottom
4043 : : m_pSectionSpacingAttrList->add( FSNS( XML_w, XML_bottom ),
4044 [ + - ]: 57 : OString::valueOf( sal_Int32( aDistances.dyaBottom ) ) );
4045 : :
4046 : : // FIXME Page Gutter is not handled ATM, setting to 0 as it's mandatory for OOXML
4047 : : m_pSectionSpacingAttrList->add( FSNS( XML_w, XML_gutter ),
4048 [ + - ]: 57 : OString::valueOf( sal_Int32( 0 ) ) );
4049 : :
4050 : : }
4051 : : else
4052 : : {
4053 [ + + ]: 192 : if ( !m_pParagraphSpacingAttrList )
4054 : 171 : m_pParagraphSpacingAttrList = m_pSerializer->createAttrList();
4055 : : m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_before ),
4056 [ + - ]: 192 : OString::valueOf( (sal_Int32)rULSpace.GetUpper() ) );
4057 : : m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_after ),
4058 [ + - ]: 192 : OString::valueOf( (sal_Int32)rULSpace.GetLower() ) );
4059 [ - + ]: 192 : if (rULSpace.GetContext())
4060 : 0 : m_pSerializer->singleElementNS( XML_w, XML_contextualSpacing, FSEND );
4061 : : else
4062 : 192 : m_pSerializer->singleElementNS( XML_w, XML_contextualSpacing, FSNS( XML_w, XML_val ), "false", FSEND );
4063 : : }
4064 : : }
4065 : :
4066 : 0 : void DocxAttributeOutput::FormatSurround( const SwFmtSurround& rSurround )
4067 : : {
4068 [ # # ]: 0 : if ( m_rExport.bOutFlyFrmAttrs )
4069 : : {
4070 [ # # ]: 0 : if ( !m_pFlyAttrList )
4071 [ # # ]: 0 : m_pFlyAttrList = m_pSerializer->createAttrList();
4072 : :
4073 : 0 : OString sWrap( "auto" );
4074 [ # # # ]: 0 : switch ( rSurround.GetSurround( ) )
4075 : : {
4076 : : case SURROUND_NONE:
4077 : 0 : sWrap = OString( "none" );
4078 : 0 : break;
4079 : : case SURROUND_THROUGHT:
4080 : 0 : sWrap = OString( "through" );
4081 : 0 : break;
4082 : : case SURROUND_IDEAL:
4083 : : case SURROUND_PARALLEL:
4084 : : case SURROUND_LEFT:
4085 : : case SURROUND_RIGHT:
4086 : : default:
4087 : 0 : sWrap = OString( "around" );
4088 : : }
4089 : :
4090 [ # # ]: 0 : m_pFlyAttrList->add( FSNS( XML_w, XML_wrap ), sWrap );
4091 : : }
4092 : 0 : }
4093 : :
4094 : 0 : void DocxAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert )
4095 : : {
4096 [ # # ]: 0 : if ( m_rExport.bOutFlyFrmAttrs )
4097 : : {
4098 [ # # ]: 0 : if ( !m_pFlyAttrList )
4099 [ # # ]: 0 : m_pFlyAttrList = m_pSerializer->createAttrList();
4100 : :
4101 : 0 : OString sAlign;
4102 [ # # # # ]: 0 : switch( rFlyVert.GetVertOrient() )
4103 : : {
4104 : : case text::VertOrientation::NONE:
4105 : 0 : break;
4106 : : case text::VertOrientation::CENTER:
4107 : : case text::VertOrientation::LINE_CENTER:
4108 : 0 : sAlign = OString( "center" );
4109 : 0 : break;
4110 : : case text::VertOrientation::BOTTOM:
4111 : : case text::VertOrientation::LINE_BOTTOM:
4112 : 0 : sAlign = OString( "bottom" );
4113 : 0 : break;
4114 : : case text::VertOrientation::TOP:
4115 : : case text::VertOrientation::LINE_TOP:
4116 : : default:
4117 : 0 : sAlign = OString( "top" );
4118 : 0 : break;
4119 : : }
4120 : :
4121 [ # # ]: 0 : if ( !sAlign.isEmpty() )
4122 [ # # ]: 0 : m_pFlyAttrList->add( FSNS( XML_w, XML_yAlign ), sAlign );
4123 : : else
4124 : : m_pFlyAttrList->add( FSNS( XML_w, XML_y ),
4125 [ # # ]: 0 : OString::valueOf( sal_Int32( rFlyVert.GetPos() ) ) );
4126 : :
4127 : 0 : OString sVAnchor( "page" );
4128 [ # # # ]: 0 : switch ( rFlyVert.GetRelationOrient( ) )
4129 : : {
4130 : : case text::RelOrientation::CHAR:
4131 : : case text::RelOrientation::PRINT_AREA:
4132 : : case text::RelOrientation::TEXT_LINE:
4133 : 0 : sVAnchor = OString( "column" );
4134 : 0 : break;
4135 : : case text::RelOrientation::FRAME:
4136 : : case text::RelOrientation::PAGE_LEFT:
4137 : : case text::RelOrientation::PAGE_RIGHT:
4138 : : case text::RelOrientation::FRAME_LEFT:
4139 : : case text::RelOrientation::FRAME_RIGHT:
4140 : 0 : sVAnchor = OString( "margin" );
4141 : 0 : break;
4142 : : case text::RelOrientation::PAGE_FRAME:
4143 : : case text::RelOrientation::PAGE_PRINT_AREA:
4144 : : default:
4145 : 0 : break;
4146 : : }
4147 : :
4148 [ # # ]: 0 : m_pFlyAttrList->add( FSNS( XML_w, XML_vAnchor ), sVAnchor );
4149 : : }
4150 : 0 : }
4151 : :
4152 : 0 : void DocxAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHori )
4153 : : {
4154 [ # # ]: 0 : if ( m_rExport.bOutFlyFrmAttrs )
4155 : : {
4156 [ # # ]: 0 : if ( !m_pFlyAttrList )
4157 [ # # ]: 0 : m_pFlyAttrList = m_pSerializer->createAttrList();
4158 : :
4159 : 0 : OString sAlign;
4160 [ # # # # ]: 0 : switch( rFlyHori.GetHoriOrient() )
4161 : : {
4162 : : case text::HoriOrientation::NONE:
4163 : 0 : break;
4164 : : case text::HoriOrientation::LEFT:
4165 [ # # ]: 0 : sAlign = OString( rFlyHori.IsPosToggle( ) ? "inside" : "left" );
4166 : 0 : break;
4167 : : case text::HoriOrientation::RIGHT:
4168 [ # # ]: 0 : sAlign = OString( rFlyHori.IsPosToggle( ) ? "outside" : "right" );
4169 : 0 : break;
4170 : : case text::HoriOrientation::CENTER:
4171 : : case text::HoriOrientation::FULL: // FULL only for tables
4172 : : default:
4173 : 0 : sAlign = OString( "center" );
4174 : 0 : break;
4175 : : }
4176 : :
4177 [ # # ]: 0 : if ( !sAlign.isEmpty() )
4178 [ # # ]: 0 : m_pFlyAttrList->add( FSNS( XML_w, XML_xAlign ), sAlign );
4179 : : else
4180 : : m_pFlyAttrList->add( FSNS( XML_w, XML_x ),
4181 [ # # ]: 0 : OString::valueOf( sal_Int32( rFlyHori.GetPos() ) ) );
4182 : :
4183 : 0 : OString sHAnchor( "page" );
4184 [ # # # ]: 0 : switch ( rFlyHori.GetRelationOrient( ) )
4185 : : {
4186 : : case text::RelOrientation::CHAR:
4187 : : case text::RelOrientation::PRINT_AREA:
4188 : 0 : sHAnchor = OString( "text" );
4189 : 0 : break;
4190 : : case text::RelOrientation::FRAME:
4191 : : case text::RelOrientation::PAGE_LEFT:
4192 : : case text::RelOrientation::PAGE_RIGHT:
4193 : : case text::RelOrientation::FRAME_LEFT:
4194 : : case text::RelOrientation::FRAME_RIGHT:
4195 : 0 : sHAnchor = OString( "margin" );
4196 : 0 : break;
4197 : : case text::RelOrientation::PAGE_FRAME:
4198 : : case text::RelOrientation::PAGE_PRINT_AREA:
4199 : : default:
4200 : 0 : break;
4201 : : }
4202 : :
4203 [ # # ]: 0 : m_pFlyAttrList->add( FSNS( XML_w, XML_hAnchor ), sHAnchor );
4204 : : }
4205 : 0 : }
4206 : :
4207 : 0 : void DocxAttributeOutput::FormatAnchor( const SwFmtAnchor& )
4208 : : {
4209 : : // Fly frames: anchors here aren't matching the anchors in docx
4210 : 0 : }
4211 : :
4212 : 0 : void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
4213 : : {
4214 [ # # ]: 0 : if ( !m_rExport.bOutPageDescs )
4215 : : {
4216 [ # # ]: 0 : OString sColor = impl_ConvertColor( rBrush.GetColor( ) );
4217 : : m_pSerializer->singleElementNS( XML_w, XML_shd,
4218 : : FSNS( XML_w, XML_fill ), sColor.getStr( ),
4219 : : FSNS( XML_w, XML_val ), "clear",
4220 [ # # ]: 0 : FSEND );
4221 : : }
4222 : 0 : }
4223 : :
4224 : 0 : void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox )
4225 : : {
4226 : :
4227 [ # # ]: 0 : if ( !m_bOpenedSectPr )
4228 : : {
4229 : : // Normally open the borders tag for paragraphs
4230 : 0 : m_pSerializer->startElementNS( XML_w, XML_pBdr, FSEND );
4231 : : }
4232 : :
4233 [ # # ]: 0 : impl_pageBorders( m_pSerializer, rBox );
4234 : :
4235 [ # # ]: 0 : if ( m_bOpenedSectPr )
4236 : : {
4237 : : // Special handling for pgBorder
4238 : 0 : m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND );
4239 : 0 : m_pSerializer->mergeTopMarks( );
4240 : : }
4241 : : else
4242 : : {
4243 : : // Normally close the borders tag for paragraphs
4244 : 0 : m_pSerializer->endElementNS( XML_w, XML_pBdr );
4245 : : }
4246 : 0 : }
4247 : :
4248 : 0 : void DocxAttributeOutput::FormatColumns_Impl( sal_uInt16 nCols, const SwFmtCol& rCol, bool bEven, SwTwips nPageSize )
4249 : : {
4250 : : // Get the columns attributes
4251 [ # # ]: 0 : FastAttributeList *pColsAttrList = m_pSerializer->createAttrList();
4252 : :
4253 : : pColsAttrList->add( FSNS( XML_w, XML_num ),
4254 [ # # ]: 0 : OString::valueOf( sal_Int32( nCols ) ). getStr( ) );
4255 : :
4256 : 0 : const char* pEquals = "false";
4257 [ # # ]: 0 : if ( bEven )
4258 : : {
4259 [ # # ]: 0 : sal_uInt16 nWidth = rCol.GetGutterWidth( true );
4260 : : pColsAttrList->add( FSNS( XML_w, XML_space ),
4261 [ # # ]: 0 : OString::valueOf( sal_Int32( nWidth ) ).getStr( ) );
4262 : :
4263 : 0 : pEquals = "true";
4264 : : }
4265 : :
4266 [ # # ]: 0 : pColsAttrList->add( FSNS( XML_w, XML_equalWidth ), pEquals );
4267 : :
4268 : 0 : bool bHasSep = COLADJ_NONE == rCol.GetLineAdj( );
4269 [ # # ][ # # ]: 0 : pColsAttrList->add( FSNS( XML_w, XML_sep ), bHasSep ? "true" : "false" );
4270 : :
4271 : : // Write the element
4272 [ # # ][ # # ]: 0 : m_pSerializer->startElementNS( XML_w, XML_cols, pColsAttrList );
[ # # ]
4273 : :
4274 : : // Write the columns width if non-equals
4275 : 0 : const SwColumns & rColumns = rCol.GetColumns( );
4276 [ # # ]: 0 : if ( !bEven )
4277 : : {
4278 [ # # ]: 0 : for ( sal_uInt16 n = 0; n < nCols; ++n )
4279 : : {
4280 [ # # ]: 0 : FastAttributeList *pColAttrList = m_pSerializer->createAttrList();
4281 [ # # ]: 0 : sal_uInt16 nWidth = rCol.CalcPrtColWidth( n, ( sal_uInt16 ) nPageSize );
4282 : : pColAttrList->add( FSNS( XML_w, XML_w ),
4283 [ # # ]: 0 : OString::valueOf( sal_Int32( nWidth ) ).getStr( ) );
4284 : :
4285 [ # # ]: 0 : if ( n + 1 != nCols )
4286 : : {
4287 [ # # ][ # # ]: 0 : sal_uInt16 nSpacing = rColumns[n].GetRight( ) + rColumns[n + 1].GetLeft( );
4288 : : pColAttrList->add( FSNS( XML_w, XML_space ),
4289 [ # # ]: 0 : OString::valueOf( sal_Int32( nSpacing ) ).getStr( ) );
4290 : : }
4291 : :
4292 [ # # ][ # # ]: 0 : m_pSerializer->singleElementNS( XML_w, XML_col, pColAttrList );
[ # # ]
4293 : : }
4294 : : }
4295 : :
4296 [ # # ]: 0 : m_pSerializer->endElementNS( XML_w, XML_cols );
4297 : 0 : }
4298 : :
4299 : 57 : void DocxAttributeOutput::FormatKeep( const SvxFmtKeepItem& )
4300 : : {
4301 : 57 : m_pSerializer->singleElementNS( XML_w, XML_keepNext, FSEND );
4302 : 57 : }
4303 : :
4304 : 48 : void DocxAttributeOutput::FormatTextGrid( const SwTextGridItem& rGrid )
4305 : : {
4306 [ + - ]: 48 : FastAttributeList *pGridAttrList = m_pSerializer->createAttrList();
4307 : :
4308 : 48 : OString sGridType;
4309 [ + - - ]: 48 : switch ( rGrid.GetGridType( ) )
4310 : : {
4311 : : default:
4312 : : case GRID_NONE:
4313 : 48 : sGridType = OString( "default" );
4314 : 48 : break;
4315 : : case GRID_LINES_ONLY:
4316 : 0 : sGridType = OString( "lines" );
4317 : 0 : break;
4318 : : case GRID_LINES_CHARS:
4319 [ # # ]: 0 : if ( rGrid.IsSnapToChars( ) )
4320 : 0 : sGridType = OString( "snapToChars" );
4321 : : else
4322 : 0 : sGridType = OString( "linesAndChars" );
4323 : 0 : break;
4324 : : }
4325 [ + - ]: 48 : pGridAttrList->add( FSNS( XML_w, XML_type ), sGridType.getStr( ) );
4326 : :
4327 : 48 : sal_uInt16 nHeight = rGrid.GetBaseHeight() + rGrid.GetRubyHeight();
4328 : : pGridAttrList->add( FSNS( XML_w, XML_linePitch ),
4329 [ + - ]: 48 : OString::valueOf( sal_Int32( nHeight ) ).getStr( ) );
4330 : :
4331 : : pGridAttrList->add( FSNS( XML_w, XML_charSpace ),
4332 [ + - ][ + - ]: 48 : OString::valueOf( sal_Int32( GridCharacterPitch( rGrid ) ) ).getStr( ) );
4333 : :
4334 [ + - ][ + - ]: 48 : m_pSerializer->singleElementNS( XML_w, XML_docGrid, pGridAttrList );
[ + - ]
4335 : 48 : }
4336 : :
4337 : 114 : void DocxAttributeOutput::FormatLineNumbering( const SwFmtLineNumber& rNumbering )
4338 : : {
4339 [ + - ]: 114 : if ( !rNumbering.IsCount( ) )
4340 : 114 : m_pSerializer->singleElementNS( XML_w, XML_suppressLineNumbers, FSEND );
4341 : 114 : }
4342 : :
4343 : 114 : void DocxAttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDirection )
4344 : : {
4345 : 114 : OString sTextFlow;
4346 : 114 : bool bBiDi = false;
4347 : 114 : short nDir = rDirection.GetValue();
4348 : :
4349 [ + + ]: 114 : if ( nDir == FRMDIR_ENVIRONMENT )
4350 [ + - ][ + - ]: 6 : nDir = GetExport( ).GetDefaultFrameDirection( );
4351 : :
4352 [ + - - ]: 114 : switch ( nDir )
4353 : : {
4354 : : default:
4355 : : case FRMDIR_HORI_LEFT_TOP:
4356 : 114 : sTextFlow = OString( "lrTb" );
4357 : 114 : break;
4358 : : case FRMDIR_HORI_RIGHT_TOP:
4359 : 0 : sTextFlow = OString( "lrTb" );
4360 : 0 : bBiDi = true;
4361 : 0 : break;
4362 : : case FRMDIR_VERT_TOP_LEFT: // many things but not this one
4363 : : case FRMDIR_VERT_TOP_RIGHT:
4364 : 0 : sTextFlow = OString( "tbRl" );
4365 : 0 : break;
4366 : : }
4367 : :
4368 [ + + ]: 114 : if ( m_rExport.bOutPageDescs )
4369 : : {
4370 : : m_pSerializer->singleElementNS( XML_w, XML_textDirection,
4371 : : FSNS( XML_w, XML_val ), sTextFlow.getStr( ),
4372 [ + - ]: 57 : FSEND );
4373 [ - + ]: 57 : if ( bBiDi )
4374 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_w, XML_bidi, FSEND );
4375 : : }
4376 [ + - ]: 57 : else if ( !m_rExport.bOutFlyFrmAttrs )
4377 : : {
4378 [ - + ]: 57 : if ( bBiDi )
4379 [ # # ]: 0 : m_pSerializer->singleElementNS( XML_w, XML_bidi, FSEND );
4380 : 114 : }
4381 : 114 : }
4382 : :
4383 : 57 : DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML )
4384 : : : m_rExport( rExport ),
4385 : : m_pSerializer( pSerializer ),
4386 : : m_rDrawingML( *pDrawingML ),
4387 : : m_pFontsAttrList( NULL ),
4388 : : m_pEastAsianLayoutAttrList( NULL ),
4389 : : m_pCharLangAttrList( NULL ),
4390 : : m_pSectionSpacingAttrList( NULL ),
4391 : : m_pParagraphSpacingAttrList( NULL ),
4392 : : m_pHyperlinkAttrList( NULL ),
4393 : : m_pFlyAttrList( NULL ),
4394 : 0 : m_pFootnotesList( new ::docx::FootnotesList() ),
4395 : 0 : m_pEndnotesList( new ::docx::FootnotesList() ),
4396 : : m_footnoteEndnoteRefTag( 0 ),
4397 : : m_pSectionInfo( NULL ),
4398 : : m_pRedlineData( NULL ),
4399 : : m_nRedlineId( 0 ),
4400 : : m_bOpenedSectPr( false ),
4401 : : m_sFieldBkm( ),
4402 : : m_nNextMarkId( 0 ),
4403 : : m_bPostitStart(false),
4404 : : m_bPostitEnd(false),
4405 : : m_pTableWrt( NULL ),
4406 : : m_bTableCellOpen( false ),
4407 : : m_nTableDepth( 0 ),
4408 : : m_bParagraphOpened( false ),
4409 : : m_nColBreakStatus( COLBRK_NONE ),
4410 : : m_pParentFrame( NULL ),
4411 : : m_closeHyperlinkInThisRun( false ),
4412 : : m_closeHyperlinkInPreviousRun( false ),
4413 : : m_startedHyperlink( false ),
4414 : : m_postponedGraphic( NULL ),
4415 : : m_postponedMath( NULL ),
4416 : : m_postitFieldsMaxId( 0 ),
4417 [ + - ][ + - ]: 57 : m_anchorId( 0 )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
4418 : : {
4419 : 57 : }
4420 : :
4421 [ + - ][ + - ]: 57 : DocxAttributeOutput::~DocxAttributeOutput()
[ + - ]
4422 : : {
4423 [ - + ][ # # ]: 57 : delete m_pFontsAttrList, m_pFontsAttrList = NULL;
4424 [ - + ][ # # ]: 57 : delete m_pEastAsianLayoutAttrList, m_pEastAsianLayoutAttrList = NULL;
4425 [ - + ][ # # ]: 57 : delete m_pCharLangAttrList, m_pCharLangAttrList = NULL;
4426 [ - + ][ # # ]: 57 : delete m_pSectionSpacingAttrList, m_pSectionSpacingAttrList = NULL;
4427 [ - + ][ # # ]: 57 : delete m_pParagraphSpacingAttrList, m_pParagraphSpacingAttrList = NULL;
4428 [ - + ][ # # ]: 57 : delete m_pHyperlinkAttrList, m_pHyperlinkAttrList = NULL;
4429 [ - + ][ # # ]: 57 : delete m_pFlyAttrList, m_pFlyAttrList = NULL;
4430 : :
4431 [ + - ]: 57 : delete m_pFootnotesList, m_pFootnotesList = NULL;
4432 [ + - ]: 57 : delete m_pEndnotesList, m_pEndnotesList = NULL;
4433 : :
4434 [ - + ][ # # ]: 57 : delete m_pTableWrt, m_pTableWrt = NULL;
4435 : 57 : m_pParentFrame = NULL;
4436 [ - + ]: 114 : }
4437 : :
4438 : 912 : DocxExport& DocxAttributeOutput::GetExport()
4439 : : {
4440 : 912 : return m_rExport;
4441 : : }
4442 : :
4443 : 171 : bool DocxAttributeOutput::HasFootnotes() const
4444 : : {
4445 : 171 : return !m_pFootnotesList->isEmpty();
4446 : : }
4447 : :
4448 : 171 : bool DocxAttributeOutput::HasEndnotes() const
4449 : : {
4450 : 171 : return !m_pEndnotesList->isEmpty();
4451 : : }
4452 : :
4453 : 57 : bool DocxAttributeOutput::HasPostitFields() const
4454 : : {
4455 : 57 : return !m_postitFields.empty();
4456 [ + - ][ + - ]: 54 : }
4457 : :
4458 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|