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 : /*
21 : * This file contains methods for the WW8 output
22 : * (nodes, attributes, formats und chars).
23 : */
24 :
25 : #include <hintids.hxx>
26 :
27 : #include <vcl/svapp.hxx>
28 : #include <vcl/salbtype.hxx>
29 : #include <vcl/settings.hxx>
30 :
31 : #include <svl/zformat.hxx>
32 : #include <svl/itemiter.hxx>
33 : #include <svl/whiter.hxx>
34 : #include <svl/grabbagitem.hxx>
35 : #include <editeng/fontitem.hxx>
36 : #include <editeng/tstpitem.hxx>
37 : #include <editeng/adjustitem.hxx>
38 : #include <editeng/spltitem.hxx>
39 : #include <editeng/widwitem.hxx>
40 : #include <editeng/lspcitem.hxx>
41 : #include <editeng/keepitem.hxx>
42 : #include <editeng/shaditem.hxx>
43 : #include <editeng/brushitem.hxx>
44 : #include <editeng/postitem.hxx>
45 : #include <editeng/wghtitem.hxx>
46 : #include <editeng/kernitem.hxx>
47 : #include <editeng/crossedoutitem.hxx>
48 : #include <editeng/cmapitem.hxx>
49 : #include <editeng/wrlmitem.hxx>
50 : #include <editeng/udlnitem.hxx>
51 : #include <editeng/langitem.hxx>
52 : #include <editeng/escapementitem.hxx>
53 : #include <editeng/fhgtitem.hxx>
54 : #include <editeng/colritem.hxx>
55 : #include <editeng/hyphenzoneitem.hxx>
56 : #include <editeng/formatbreakitem.hxx>
57 : #include <editeng/lrspitem.hxx>
58 : #include <editeng/ulspitem.hxx>
59 : #include <editeng/boxitem.hxx>
60 : #include <editeng/contouritem.hxx>
61 : #include <editeng/shdditem.hxx>
62 : #include <editeng/autokernitem.hxx>
63 : #include <editeng/pbinitem.hxx>
64 : #include <editeng/emphasismarkitem.hxx>
65 : #include <editeng/twolinesitem.hxx>
66 : #include <editeng/charscaleitem.hxx>
67 : #include <editeng/charrotateitem.hxx>
68 : #include <editeng/charreliefitem.hxx>
69 : #include <editeng/paravertalignitem.hxx>
70 : #include <editeng/pgrditem.hxx>
71 : #include <editeng/frmdiritem.hxx>
72 : #include <editeng/blinkitem.hxx>
73 : #include <editeng/charhiddenitem.hxx>
74 : #include <editeng/paperinf.hxx>
75 : #include <svx/xfillit0.hxx>
76 : #include <svx/xflgrit.hxx>
77 : #include <fmtfld.hxx>
78 : #include <fchrfmt.hxx>
79 : #include <fmtfsize.hxx>
80 : #include <fmtpdsc.hxx>
81 : #include <fmtornt.hxx>
82 : #include <fmtanchr.hxx>
83 : #include <fmtclds.hxx>
84 : #include <fmtsrnd.hxx>
85 : #include <fmtftn.hxx>
86 : #include <fmtflcnt.hxx>
87 : #include <frmatr.hxx>
88 : #include <swtable.hxx>
89 : #include <fmtinfmt.hxx>
90 : #include <txtfld.hxx>
91 : #include <txtftn.hxx>
92 : #include <poolfmt.hxx>
93 : #include <doc.hxx>
94 : #include <IDocumentSettingAccess.hxx>
95 : #include <IDocumentFieldsAccess.hxx>
96 : #include <IDocumentStylePoolAccess.hxx>
97 : #include <docary.hxx>
98 : #include <pam.hxx>
99 : #include <paratr.hxx>
100 : #include <fldbas.hxx>
101 : #include <docufld.hxx>
102 : #include <expfld.hxx>
103 : #include <pagedesc.hxx>
104 : #include <flddat.hxx>
105 : #include <ndtxt.hxx>
106 : #include <swrect.hxx>
107 : #include <reffld.hxx>
108 : #include <ftninfo.hxx>
109 : #include <charfmt.hxx>
110 : #include <section.hxx>
111 : #include <lineinfo.hxx>
112 : #include <fmtline.hxx>
113 : #include <tox.hxx>
114 : #include <fmtftntx.hxx>
115 : #include <breakit.hxx>
116 : #include <com/sun/star/i18n/ScriptType.hpp>
117 : #include <unotools/localedatawrapper.hxx>
118 : #include <svx/unobrushitemhelper.hxx>
119 : #include <svx/xenum.hxx>
120 : #include <tgrditem.hxx>
121 : #include <flddropdown.hxx>
122 : #include <chpfld.hxx>
123 : #include <fmthdft.hxx>
124 : #include <authfld.hxx>
125 :
126 : #include <sprmids.hxx>
127 :
128 : #include <fmtcntnt.hxx>
129 : #include "writerhelper.hxx"
130 : #include "writerwordglue.hxx"
131 : #include "wrtww8.hxx"
132 : #include "ww8par.hxx"
133 : #include "ww8attributeoutput.hxx"
134 : #include "fields.hxx"
135 : #include <vcl/outdev.hxx>
136 : #include <i18nlangtag/languagetag.hxx>
137 : #include <unotools/fltrcfg.hxx>
138 : #include <o3tl/enumrange.hxx>
139 :
140 : using ::editeng::SvxBorderLine;
141 : using namespace ::com::sun::star;
142 : using namespace nsFieldFlags;
143 : using namespace nsSwDocInfoSubType;
144 : using namespace sw::util;
145 : using namespace sw::types;
146 :
147 3387 : bool WW8Export::CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich )
148 : {
149 3387 : bool bRet = true;
150 3387 : if ( nScript == i18n::ScriptType::ASIAN )
151 : {
152 : //for asian in ww8, there is only one fontsize
153 : //and one fontstyle (posture/weight) for ww6
154 : //there is the additional problem that there
155 : //is only one font setting for all three scripts
156 0 : switch ( nWhich )
157 : {
158 : case RES_CHRATR_FONTSIZE:
159 : case RES_CHRATR_POSTURE:
160 : case RES_CHRATR_WEIGHT:
161 0 : bRet = false;
162 0 : break;
163 : case RES_CHRATR_LANGUAGE:
164 : case RES_CHRATR_CTL_FONT:
165 : case RES_CHRATR_CTL_FONTSIZE:
166 : case RES_CHRATR_CTL_LANGUAGE:
167 : case RES_CHRATR_CTL_POSTURE:
168 : case RES_CHRATR_CTL_WEIGHT:
169 0 : if (!bWrtWW8)
170 0 : bRet = false;
171 : default:
172 0 : break;
173 : }
174 : }
175 3387 : else if ( nScript == i18n::ScriptType::COMPLEX )
176 : {
177 : //Complex is ok in ww8, but for ww6 there is only
178 : //one font, one fontsize, one fontsize (weight/posture)
179 : //and only one language
180 0 : if ( !bWrtWW8 )
181 : {
182 0 : switch ( nWhich )
183 : {
184 : case RES_CHRATR_CJK_FONT:
185 : case RES_CHRATR_CJK_FONTSIZE:
186 : case RES_CHRATR_CJK_POSTURE:
187 : case RES_CHRATR_CJK_WEIGHT:
188 : case RES_CHRATR_CJK_LANGUAGE:
189 : case RES_CHRATR_FONT:
190 : case RES_CHRATR_FONTSIZE:
191 : case RES_CHRATR_POSTURE:
192 : case RES_CHRATR_WEIGHT:
193 : case RES_CHRATR_LANGUAGE:
194 0 : bRet = false;
195 0 : break;
196 : default:
197 0 : break;
198 : }
199 : }
200 : }
201 : else
202 : {
203 : //for western in ww8, there is only one fontsize
204 : //and one fontstyle (posture/weight) for ww6
205 : //there is the additional problem that there
206 : //is only one font setting for all three scripts
207 3387 : switch ( nWhich )
208 : {
209 : case RES_CHRATR_CJK_FONTSIZE:
210 : case RES_CHRATR_CJK_POSTURE:
211 : case RES_CHRATR_CJK_WEIGHT:
212 614 : bRet = false;
213 614 : break;
214 : case RES_CHRATR_CJK_LANGUAGE:
215 : case RES_CHRATR_CTL_FONT:
216 : case RES_CHRATR_CTL_FONTSIZE:
217 : case RES_CHRATR_CTL_LANGUAGE:
218 : case RES_CHRATR_CTL_POSTURE:
219 : case RES_CHRATR_CTL_WEIGHT:
220 1049 : if ( !bWrtWW8 )
221 0 : bRet = false;
222 : default:
223 2773 : break;
224 : }
225 : }
226 3387 : return bRet;
227 : }
228 :
229 : // Hilfsroutinen fuer Styles
230 :
231 19089 : void MSWordExportBase::ExportPoolItemsToCHP( sw::PoolItems &rItems, sal_uInt16 nScript )
232 : {
233 19089 : sw::cPoolItemIter aEnd = rItems.end();
234 109788 : for ( sw::cPoolItemIter aI = rItems.begin(); aI != aEnd; ++aI )
235 : {
236 90699 : const SfxPoolItem *pItem = aI->second;
237 90699 : sal_uInt16 nWhich = pItem->Which();
238 90699 : if ( ( isCHRATR( nWhich ) || isTXTATR( nWhich ) ) && CollapseScriptsforWordOk( nScript, nWhich ) )
239 : {
240 : //In the id definition, RES_TXTATR_INETFMT must precede RES_TXTATR_CHARFMT, so that link style can overwrite char style.
241 : //and in #i24291# it describes "All we want to do is ensure for now is that if a charfmt exist in the character
242 : //properties that it rises to the top and is exported first."
243 : //In bug 119649, it is in such situation, so we need to ignore the link style when doing ms word filter exports and
244 : //add the second judgement for #i24291# definition.
245 53160 : if ( nWhich == RES_TXTATR_INETFMT && ( rItems.begin()->second->Which() == RES_TXTATR_CHARFMT ) )
246 16 : continue;
247 53144 : AttrOutput().OutputItem( *pItem );
248 : }
249 : }
250 19089 : }
251 :
252 : /*
253 : * Format wie folgt ausgeben:
254 : * - gebe die Attribute aus; ohne Parents!
255 : */
256 :
257 28032 : void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, bool bChpFormat, sal_uInt16 nScript,
258 : bool bExportParentItemSet )
259 : {
260 28032 : if( bExportParentItemSet || rSet.Count() )
261 : {
262 : const SfxPoolItem* pItem;
263 26503 : m_pISet = &rSet; // fuer Doppel-Attribute
264 :
265 : // If frame dir is set, but not adjust, then force adjust as well
266 26503 : if ( bPapFormat && SfxItemState::SET == rSet.GetItemState( RES_FRAMEDIR, bExportParentItemSet ) )
267 : {
268 : // No explicit adjust set ?
269 1456 : if ( SfxItemState::SET != rSet.GetItemState( RES_PARATR_ADJUST, bExportParentItemSet ) )
270 : {
271 266 : if ( 0 != ( pItem = rSet.GetItem( RES_PARATR_ADJUST, bExportParentItemSet ) ) )
272 : {
273 : // then set the adjust used by the parent format
274 11 : AttrOutput().OutputItem( *pItem );
275 : }
276 : }
277 : }
278 :
279 26503 : if ( bPapFormat && SfxItemState::SET == rSet.GetItemState( RES_PARATR_NUMRULE, bExportParentItemSet, &pItem ) )
280 : {
281 1275 : AttrOutput().OutputItem( *pItem );
282 :
283 : // switch off the numerbering?
284 2728 : if ( static_cast<const SwNumRuleItem*>(pItem)->GetValue().isEmpty() &&
285 1442 : SfxItemState::SET != rSet.GetItemState( RES_LR_SPACE, false) &&
286 167 : SfxItemState::SET == rSet.GetItemState( RES_LR_SPACE, true, &pItem ) )
287 : {
288 : // the set the LR-Space of the parentformat!
289 18 : AttrOutput().OutputItem( *pItem );
290 : }
291 : }
292 :
293 26503 : sw::PoolItems aItems;
294 26503 : GetPoolItems( rSet, aItems, bExportParentItemSet );
295 26503 : if ( bChpFormat )
296 11486 : ExportPoolItemsToCHP(aItems, nScript);
297 26503 : if ( bPapFormat )
298 : {
299 15017 : sw::cPoolItemIter aEnd = aItems.end();
300 106814 : for ( sw::cPoolItemIter aI = aItems.begin(); aI != aEnd; ++aI )
301 : {
302 91797 : pItem = aI->second;
303 91797 : sal_uInt16 nWhich = pItem->Which();
304 : // Handle fill attributes just like frame attributes for now.
305 91797 : if ( (nWhich >= RES_PARATR_BEGIN && nWhich < RES_FRMATR_END && nWhich != RES_PARATR_NUMRULE ) ||
306 1649 : (nWhich >= XATTR_FILL_FIRST && nWhich < XATTR_FILL_LAST))
307 51905 : AttrOutput().OutputItem( *pItem );
308 : }
309 :
310 : // Has to be called after RES_PARATR_GRABBAG is processed.
311 15017 : const XFillStyleItem* pXFillStyleItem(static_cast<const XFillStyleItem*>(rSet.GetItem(XATTR_FILLSTYLE)));
312 15017 : if (pXFillStyleItem && pXFillStyleItem->GetValue() == drawing::FillStyle_SOLID && !rSet.HasItem(RES_BACKGROUND))
313 : {
314 : // Construct an SvxBrushItem, as expected by the exporters.
315 108 : AttrOutput().OutputItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
316 : }
317 : }
318 26503 : m_pISet = 0; // fuer Doppel-Attribute
319 : }
320 28032 : }
321 :
322 : #include <calbck.hxx>
323 :
324 610 : void MSWordExportBase::GatherChapterFields()
325 : {
326 : //If the header/footer contains a chapter field
327 610 : SwFieldType* pType = m_pDoc->getIDocumentFieldsAccess().GetSysFieldType( RES_CHAPTERFLD );
328 610 : SwIterator<SwFormatField,SwFieldType> aFormatFields( *pType );
329 613 : for ( SwFormatField* pField = aFormatFields.First(); pField; pField = aFormatFields.Next() )
330 : {
331 3 : if (const SwTextField *pTextField = pField->GetTextField())
332 : {
333 3 : const SwTextNode &rTextNode = pTextField->GetTextNode();
334 3 : m_aChapterFieldLocs.push_back(rTextNode.GetIndex());
335 : }
336 610 : }
337 610 : }
338 :
339 0 : bool MSWordExportBase::ContentContainsChapterField(const SwFormatContent &rContent) const
340 : {
341 0 : bool bRet = false;
342 0 : if ( const SwNodeIndex* pSttIdx = rContent.GetContentIdx() )
343 : {
344 0 : SwNodeIndex aIdx( *pSttIdx, 1 );
345 0 : SwNodeIndex aEnd( *pSttIdx->GetNode().EndOfSectionNode() );
346 0 : sal_uLong nStart = aIdx.GetIndex();
347 0 : sal_uLong nEnd = aEnd.GetIndex();
348 : //If the header/footer contains a chapter field
349 0 : mycCFIter aIEnd = m_aChapterFieldLocs.end();
350 0 : for ( mycCFIter aI = m_aChapterFieldLocs.begin(); aI != aIEnd; ++aI )
351 : {
352 0 : if ( ( nStart <= *aI ) && ( *aI <= nEnd ) )
353 : {
354 0 : bRet = true;
355 0 : break;
356 : }
357 0 : }
358 : }
359 0 : return bRet;
360 : }
361 :
362 83 : bool MSWordExportBase::FormatHdFtContainsChapterField(const SwFrameFormat &rFormat) const
363 : {
364 83 : if ( m_aChapterFieldLocs.empty() )
365 83 : return false;
366 :
367 0 : const SwFrameFormat *pFormat = 0;
368 :
369 0 : pFormat = rFormat.GetHeader().GetHeaderFormat();
370 0 : if ( pFormat && ContentContainsChapterField( pFormat->GetContent() ) )
371 0 : return true;
372 :
373 0 : pFormat = rFormat.GetFooter().GetFooterFormat();
374 0 : if ( pFormat && ContentContainsChapterField( pFormat->GetContent() ) )
375 0 : return true;
376 :
377 0 : return false;
378 : }
379 :
380 95 : bool MSWordExportBase::SetAktPageDescFromNode(const SwNode &rNd)
381 : {
382 95 : bool bNewPageDesc = false;
383 95 : const SwPageDesc* pCurrent = SwPageDesc::GetPageDescOfNode(rNd);
384 : OSL_ENSURE(pCurrent && m_pAktPageDesc, "Not possible surely");
385 95 : if (m_pAktPageDesc && pCurrent)
386 : {
387 95 : if (pCurrent != m_pAktPageDesc)
388 : {
389 12 : if (m_pAktPageDesc->GetFollow() != pCurrent)
390 0 : bNewPageDesc = true;
391 : else
392 : {
393 12 : const SwFrameFormat& rTitleFormat = m_pAktPageDesc->GetFirstMaster();
394 12 : const SwFrameFormat& rFollowFormat = pCurrent->GetMaster();
395 :
396 : bNewPageDesc = !IsPlausableSingleWordSection(rTitleFormat,
397 12 : rFollowFormat);
398 : }
399 12 : m_pAktPageDesc = pCurrent;
400 : }
401 : else
402 : {
403 83 : const SwFrameFormat &rFormat = pCurrent->GetMaster();
404 83 : bNewPageDesc = FormatHdFtContainsChapterField(rFormat);
405 : }
406 : }
407 95 : return bNewPageDesc;
408 : }
409 :
410 : // Da WW nur Break-After ( Pagebreak und Sectionbreaks ) kennt, im SW aber
411 : // Bagebreaks "vor" und "nach" und Pagedescs nur "vor" existieren, werden
412 : // die Breaks 2* durchgeklimpert, naemlich vor und hinter jeder Zeile.
413 : // Je nach BreakTyp werden sie vor oder nach der Zeile gesetzt.
414 : // Es duerfen nur Funktionen gerufen werden, die nicht in den
415 : // Ausgabebereich pO schreiben, da dieser nur einmal fuer CHP und PAP existiert
416 : // und damit im falschen landen wuerden.
417 5054 : void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd, bool isCellOpen, bool isTextNodeEmpty)
418 : {
419 5054 : if ( m_bStyDef || m_bOutKF || m_bInWriteEscher || m_bOutPageDescs )
420 5204 : return;
421 :
422 4904 : m_bBreakBefore = true;
423 4904 : bool bNewPageDesc = false;
424 4904 : const SfxPoolItem* pItem=0;
425 4904 : const SwFormatPageDesc *pPgDesc=0;
426 :
427 : //Output a sectionbreak if theres a new pagedesciptor. otherwise output a
428 : //pagebreak if there is a pagebreak here, unless the new page (follow
429 : //style) is different to the current one, in which case plump for a
430 : //section.
431 4904 : bool bBreakSet = false;
432 :
433 4904 : const SwPageDesc * pPageDesc = rNd.FindPageDesc(false);
434 :
435 : // Even if pAktPageDesc != pPageDesc ,it might be because of the different header & footer types.
436 4904 : if (m_pAktPageDesc != pPageDesc)
437 : {
438 72 : if ( ( isCellOpen && ( m_pAktPageDesc->GetName() != pPageDesc->GetName() )) ||
439 35 : ( isTextNodeEmpty || m_bPrevTextNodeIsEmpty ))
440 : {
441 : /* Do not output a section break in the following scenarios.
442 : 1) Table cell is open and page header types are different
443 : 2) PageBreak is present but text node has no string - it is an empty node.
444 : 3) If the previous node was an empty text node and current node is a non empty text node or vice versa.
445 : 4) If previous node and current node both are empty text nodes.
446 : Converting a page break to section break would cause serious issues while importing
447 : the RT files with different first page being set.
448 : */
449 23 : bNewPageDesc = false;
450 :
451 : /*
452 : * If Table cell is open and page header types are different
453 : * set pSet to NULL as we don't want to add any section breaks.
454 : */
455 23 : if ( isCellOpen && ( m_pAktPageDesc->GetName() != pPageDesc->GetName() ) )
456 1 : pSet = NULL;
457 : }
458 26 : else if (!sw::util::IsPlausableSingleWordSection(m_pAktPageDesc->GetFirstMaster(), pPageDesc->GetMaster()))
459 : {
460 8 : bBreakSet = true;
461 8 : bNewPageDesc = true;
462 8 : m_pAktPageDesc = pPageDesc;
463 : }
464 : }
465 :
466 4904 : if ( pSet && pSet->Count() )
467 : {
468 3501 : if ( SfxItemState::SET == pSet->GetItemState( RES_PAGEDESC, false, &pItem ) &&
469 53 : static_cast<const SwFormatPageDesc*>(pItem)->GetRegisteredIn() != NULL)
470 : {
471 51 : bBreakSet = true;
472 51 : bNewPageDesc = true;
473 51 : pPgDesc = static_cast<const SwFormatPageDesc*>(pItem);
474 51 : m_pAktPageDesc = pPgDesc->GetPageDesc();
475 : }
476 3397 : else if ( SfxItemState::SET == pSet->GetItemState( RES_BREAK, false, &pItem ) )
477 : {
478 : // Word does not like hard break attributes in some table cells
479 145 : bool bRemoveHardBreakInsideTable = false;
480 145 : if ( m_bOutTable )
481 : {
482 0 : const SwTableNode* pTableNode = rNd.FindTableNode();
483 0 : if ( pTableNode )
484 : {
485 0 : const SwTableBox* pBox = rNd.GetTableBox();
486 0 : const SwTableLine* pLine = pBox ? pBox->GetUpper() : 0;
487 : // but only for non-complex tables
488 0 : if ( pLine && !pLine->GetUpper() )
489 : {
490 : // check if box is not first in that line:
491 0 : if ( 0 < pLine->GetTabBoxes().GetPos( pBox ) && pBox->GetSttNd() )
492 : {
493 0 : bRemoveHardBreakInsideTable = true;
494 : }
495 : }
496 : }
497 : }
498 145 : bNewPageDesc = false; // if next node has RES_BREAK(page break) then bNewPageDesc value should be false.
499 145 : bBreakSet = true;
500 :
501 145 : if ( !bRemoveHardBreakInsideTable )
502 : {
503 : OSL_ENSURE(m_pAktPageDesc, "should not be possible");
504 : /*
505 : If because of this pagebreak the page desc following the page
506 : break is the follow style of the current page desc then output a
507 : section break using that style instead. At least in those cases
508 : we end up with the same style in word and writer, nothing can be
509 : done when it happens when we get a new pagedesc because we
510 : overflow from the first page style.
511 : */
512 145 : if ( m_pAktPageDesc )
513 : {
514 : // #i76301# - assure that there is a page break before set at the node.
515 145 : const SvxFormatBreakItem* pBreak = dynamic_cast<const SvxFormatBreakItem*>(pItem);
516 290 : if ( pBreak &&
517 145 : pBreak->GetBreak() == SVX_BREAK_PAGE_BEFORE )
518 : {
519 92 : bNewPageDesc |= SetAktPageDescFromNode( rNd );
520 : }
521 145 : if( isTextNodeEmpty )
522 35 : bNewPageDesc = false;
523 : }
524 145 : if ( !bNewPageDesc )
525 145 : AttrOutput().OutputItem( *pItem );
526 : }
527 : }
528 : }
529 :
530 : /*
531 : #i9301#
532 : No explicit page break, lets see if the style had one and we've moved to a
533 : new page style because of it, if we have to then we take the opportunity to
534 : set the equivalent word section here. We *could* do it for every paragraph
535 : that moves onto a new page because of layout, but that would be insane.
536 : */
537 4904 : bool bHackInBreak = false;
538 4904 : if ( !bBreakSet )
539 : {
540 4707 : if ( const SwContentNode *pNd = rNd.GetContentNode() )
541 : {
542 : const SvxFormatBreakItem &rBreak =
543 4632 : ItemGet<SvxFormatBreakItem>( *pNd, RES_BREAK );
544 4632 : if ( rBreak.GetBreak() == SVX_BREAK_PAGE_BEFORE )
545 3 : bHackInBreak = true;
546 : else
547 : { // Even a pagedesc item is set, the break item can be set 'NONE',
548 : // but a pagedesc item is an implicit page break before...
549 : const SwFormatPageDesc &rPageDesc =
550 4629 : ItemGet<SwFormatPageDesc>( *pNd, RES_PAGEDESC );
551 4629 : if ( rPageDesc.KnowsPageDesc() )
552 0 : bHackInBreak = true;
553 : }
554 : }
555 : }
556 :
557 4904 : if ( bHackInBreak )
558 : {
559 : OSL_ENSURE( m_pAktPageDesc, "should not be possible" );
560 3 : if ( m_pAktPageDesc )
561 3 : bNewPageDesc = SetAktPageDescFromNode( rNd );
562 : }
563 :
564 4904 : if ( bNewPageDesc && m_pAktPageDesc )
565 : {
566 52 : PrepareNewPageDesc( pSet, rNd, pPgDesc, m_pAktPageDesc );
567 : }
568 4904 : m_bBreakBefore = false;
569 4904 : m_bPrevTextNodeIsEmpty = isTextNodeEmpty ;
570 : }
571 :
572 : // #i76300#
573 0 : bool MSWordExportBase::OutputFollowPageDesc( const SfxItemSet* pSet, const SwTextNode* pNd )
574 : {
575 0 : bool bRet = false;
576 :
577 0 : if ( pNd &&
578 0 : m_pAktPageDesc &&
579 0 : m_pAktPageDesc != m_pAktPageDesc->GetFollow() )
580 : {
581 0 : PrepareNewPageDesc( pSet, *pNd, 0, m_pAktPageDesc->GetFollow() );
582 0 : bRet = true;
583 : }
584 :
585 0 : return bRet;
586 : }
587 :
588 30 : const SwSectionFormat* MSWordExportBase::GetSectionFormat( const SwNode& rNd )
589 : {
590 30 : const SwSectionFormat* pFormat = NULL;
591 30 : const SwSectionNode* pSect = rNd.FindSectionNode();
592 31 : if ( pSect &&
593 1 : CONTENT_SECTION == pSect->GetSection().GetType() )
594 : {
595 0 : pFormat = pSect->GetSection().GetFormat();
596 : }
597 :
598 30 : return pFormat;
599 : }
600 :
601 30 : sal_uLong MSWordExportBase::GetSectionLineNo( const SfxItemSet* pSet, const SwNode& rNd )
602 : {
603 30 : const SwFormatLineNumber* pNItem = 0;
604 30 : if ( pSet )
605 : {
606 30 : pNItem = &( ItemGet<SwFormatLineNumber>( *pSet, RES_LINENUMBER ) );
607 : }
608 0 : else if ( const SwContentNode *pNd = rNd.GetContentNode() )
609 : {
610 0 : pNItem = &( ItemGet<SwFormatLineNumber>( *pNd, RES_LINENUMBER ) );
611 : }
612 :
613 30 : return pNItem? pNItem->GetStartValue() : 0;
614 : }
615 :
616 25 : void WW8Export::PrepareNewPageDesc( const SfxItemSet*pSet,
617 : const SwNode& rNd,
618 : const SwFormatPageDesc* pNewPgDescFormat,
619 : const SwPageDesc* pNewPgDesc )
620 : {
621 : // Die PageDescs werden beim Auftreten von PageDesc-Attributen nur in
622 : // WW8Writer::pSepx mit der entsprechenden Position eingetragen. Das
623 : // Aufbauen und die Ausgabe der am PageDesc haengenden Attribute und
624 : // Kopf/Fusszeilen passiert nach dem Haupttext und seinen Attributen.
625 :
626 25 : sal_uLong nFcPos = ReplaceCr( msword::PageBreak ); // Page/Section-Break
627 :
628 : // tatsaechlich wird hier NOCH NICHTS ausgegeben, sondern
629 : // nur die Merk-Arrays aCps, aSects entsprechend ergaenzt
630 25 : if ( !nFcPos )
631 47 : return;
632 :
633 3 : const SwSectionFormat* pFormat = GetSectionFormat( rNd );
634 3 : const sal_uLong nLnNm = GetSectionLineNo( pSet, rNd );
635 :
636 : OSL_ENSURE( pNewPgDescFormat || pNewPgDesc, "Neither page desc format nor page desc provided." );
637 :
638 3 : if ( pNewPgDescFormat )
639 : {
640 2 : pSepx->AppendSep( Fc2Cp( nFcPos ), *pNewPgDescFormat, rNd, pFormat, nLnNm );
641 : }
642 1 : else if ( pNewPgDesc )
643 : {
644 1 : pSepx->AppendSep( Fc2Cp( nFcPos ), pNewPgDesc, rNd, pFormat, nLnNm );
645 : }
646 : }
647 :
648 145 : void MSWordExportBase::CorrectTabStopInSet( SfxItemSet& rSet, sal_uInt16 nAbsLeft )
649 : {
650 : const SvxTabStopItem *pItem =
651 145 : sw::util::HasItem<SvxTabStopItem>( rSet, RES_PARATR_TABSTOP );
652 :
653 145 : if ( pItem )
654 : {
655 : // dann muss das fuer die Ausgabe korrigiert werden
656 145 : SvxTabStopItem aTStop(*pItem);
657 317 : for ( sal_uInt16 nCnt = 0; nCnt < aTStop.Count(); ++nCnt )
658 : {
659 172 : SvxTabStop& rTab = (SvxTabStop&)aTStop[ nCnt ];
660 294 : if ( SVX_TAB_ADJUST_DEFAULT != rTab.GetAdjustment() &&
661 122 : rTab.GetTabPos() >= nAbsLeft )
662 : {
663 121 : rTab.GetTabPos() -= nAbsLeft;
664 : }
665 : else
666 : {
667 51 : aTStop.Remove( nCnt );
668 51 : --nCnt;
669 : }
670 : }
671 145 : rSet.Put( aTStop );
672 : }
673 145 : }
674 :
675 99 : sal_uInt8 WW8Export::GetNumId( sal_uInt16 eNumType )
676 : {
677 99 : sal_uInt8 nRet = 0;
678 99 : switch( eNumType )
679 : {
680 : case SVX_NUM_CHARS_UPPER_LETTER:
681 0 : case SVX_NUM_CHARS_UPPER_LETTER_N: nRet = 3; break;
682 : case SVX_NUM_CHARS_LOWER_LETTER:
683 0 : case SVX_NUM_CHARS_LOWER_LETTER_N: nRet = 4; break;
684 0 : case SVX_NUM_ROMAN_UPPER: nRet = 1; break;
685 32 : case SVX_NUM_ROMAN_LOWER: nRet = 2; break;
686 :
687 : case SVX_NUM_BITMAP:
688 0 : case SVX_NUM_CHAR_SPECIAL: nRet = 23; break;
689 :
690 : // nix, macht WW undokumentiert auch so
691 0 : case SVX_NUM_NUMBER_NONE: nRet = 0xff; break;
692 : }
693 99 : return nRet;
694 : }
695 :
696 5 : void WW8AttributeOutput::OutlineNumbering( sal_uInt8 nLvl, const SwNumFormat &rNFormat, const SwFormat &rFormat )
697 : {
698 5 : if ( nLvl >= WW8ListManager::nMaxLevel )
699 0 : nLvl = WW8ListManager::nMaxLevel-1;
700 :
701 5 : if ( m_rWW8Export.bWrtWW8 )
702 : {
703 : // write sprmPOutLvl sprmPIlvl and sprmPIlfo
704 5 : SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_POutLvl );
705 5 : m_rWW8Export.pO->push_back( nLvl );
706 5 : SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_PIlvl );
707 5 : m_rWW8Export.pO->push_back( nLvl );
708 5 : SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_PIlfo );
709 : SwWW8Writer::InsUInt16( *m_rWW8Export.pO,
710 5 : 1 + m_rWW8Export.GetId( *m_rWW8Export.m_pDoc->GetOutlineNumRule() ) );
711 : }
712 : else
713 : {
714 0 : m_rWW8Export.Out_SwNumLvl( nLvl );
715 0 : if ( rNFormat.GetPositionAndSpaceMode() ==
716 0 : SvxNumberFormat::LABEL_WIDTH_AND_POSITION &&
717 0 : rNFormat.GetAbsLSpace() )
718 : {
719 0 : SwNumFormat aNumFormat( rNFormat );
720 : const SvxLRSpaceItem& rLR =
721 0 : ItemGet<SvxLRSpaceItem>( rFormat, RES_LR_SPACE );
722 :
723 : aNumFormat.SetAbsLSpace( writer_cast<short>(
724 0 : aNumFormat.GetAbsLSpace() + rLR.GetLeft() ) );
725 : m_rWW8Export.Out_NumRuleAnld(
726 0 : *m_rWW8Export.m_pDoc->GetOutlineNumRule(),
727 0 : aNumFormat, nLvl );
728 : }
729 : else
730 : m_rWW8Export.Out_NumRuleAnld(
731 0 : *m_rWW8Export.m_pDoc->GetOutlineNumRule(),
732 0 : rNFormat, nLvl );
733 : }
734 5 : }
735 :
736 : // #i77805#
737 290 : bool WW8Export::DisallowInheritingOutlineNumbering(const SwFormat &rFormat)
738 : {
739 290 : bool bRet( false );
740 :
741 : //If there is no numbering on this fmt, but its parent was outline
742 : //numbered, then in writer this is no inheritied, but in word it would
743 : //be, so we must export "no numbering" and "body level" to make word
744 : //behave like writer (see #i25755)
745 290 : if (SfxItemState::SET != rFormat.GetItemState(RES_PARATR_NUMRULE, false))
746 : {
747 281 : if (const SwFormat *pParent = rFormat.DerivedFrom())
748 : {
749 281 : if (static_cast<const SwTextFormatColl*>(pParent)->IsAssignedToListLevelOfOutlineStyle())
750 : {
751 0 : if (bWrtWW8)
752 : {
753 0 : SwWW8Writer::InsUInt16(*pO, NS_sprm::LN_POutLvl);
754 0 : pO->push_back(sal_uInt8(9));
755 0 : SwWW8Writer::InsUInt16(*pO, NS_sprm::LN_PIlfo);
756 0 : SwWW8Writer::InsUInt16(*pO, 0);
757 :
758 0 : bRet = true;
759 : }
760 : /*whats the winword 6 way to do this ?*/
761 : }
762 : }
763 : }
764 :
765 290 : return bRet;
766 : }
767 :
768 21090 : void MSWordExportBase::OutputFormat( const SwFormat& rFormat, bool bPapFormat, bool bChpFormat, bool bFlyFormat )
769 : {
770 21090 : bool bCallOutSet = true;
771 21090 : const SwModify* pOldMod = m_pOutFormatNode;
772 21090 : m_pOutFormatNode = &rFormat;
773 :
774 21090 : switch( rFormat.Which() )
775 : {
776 : case RES_CONDTXTFMTCOLL:
777 : case RES_TXTFMTCOLL:
778 16862 : if( bPapFormat )
779 : {
780 8431 : int nLvl = MAXLEVEL;
781 :
782 8431 : if (static_cast<const SwTextFormatColl&>(rFormat).IsAssignedToListLevelOfOutlineStyle())
783 153 : nLvl = static_cast<const SwTextFormatColl&>(rFormat).GetAssignedOutlineStyleLevel();
784 :
785 8431 : if (nLvl >= 0 && nLvl < MAXLEVEL)
786 : {
787 : //if outline numbered
788 : // if Write StyleDefinition then write the OutlineRule
789 153 : const SwNumFormat& rNFormat = m_pDoc->GetOutlineNumRule()->Get( static_cast<sal_uInt16>( nLvl ) );
790 153 : if ( m_bStyDef )
791 153 : AttrOutput().OutlineNumbering( static_cast< sal_uInt8 >( nLvl ), rNFormat, rFormat );
792 :
793 306 : if ( rNFormat.GetPositionAndSpaceMode() ==
794 198 : SvxNumberFormat::LABEL_WIDTH_AND_POSITION &&
795 45 : rNFormat.GetAbsLSpace() )
796 : {
797 25 : SfxItemSet aSet( rFormat.GetAttrSet() );
798 : SvxLRSpaceItem aLR(
799 50 : ItemGet<SvxLRSpaceItem>(aSet, RES_LR_SPACE));
800 :
801 25 : aLR.SetTextLeft( aLR.GetTextLeft() + rNFormat.GetAbsLSpace() );
802 25 : aLR.SetTextFirstLineOfst( GetWordFirstLineOffset(rNFormat));
803 :
804 25 : aSet.Put( aLR );
805 25 : CorrectTabStopInSet( aSet, rNFormat.GetAbsLSpace() );
806 : OutputItemSet( aSet, bPapFormat, bChpFormat,
807 25 : i18n::ScriptType::LATIN, m_bExportModeRTF);
808 50 : bCallOutSet = false;
809 153 : }
810 : }
811 : else
812 : {
813 : //otherwise we might have to remove outline numbering from
814 : //what gets exported if the parent style was outline numbered
815 : // #i77805#
816 : // If inherited outline numbering is suppress, the left/right
817 : // margins has to be exported explicitly.
818 8278 : if ( m_bStyDef && DisallowInheritingOutlineNumbering(rFormat) )
819 : {
820 0 : SfxItemSet aSet( rFormat.GetAttrSet() );
821 : SvxLRSpaceItem aLR(
822 0 : ItemGet<SvxLRSpaceItem>(aSet, RES_LR_SPACE));
823 0 : aSet.Put( aLR );
824 : OutputItemSet( aSet, bPapFormat, bChpFormat,
825 0 : com::sun::star::i18n::ScriptType::LATIN, m_bExportModeRTF);
826 0 : bCallOutSet = false;
827 : }
828 : }
829 : }
830 16862 : break;
831 :
832 : case RES_CHRFMT:
833 3765 : break;
834 : case RES_FLYFRMFMT:
835 249 : if (bFlyFormat)
836 : {
837 : OSL_ENSURE(m_pParentFrame, "No parent frame, all broken");
838 :
839 249 : if (m_pParentFrame)
840 : {
841 249 : const SwFrameFormat &rFrameFormat = m_pParentFrame->GetFrameFormat();
842 :
843 249 : SfxItemSet aSet(m_pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
844 : RES_FRMATR_END-1,
845 : XATTR_FILL_FIRST, XATTR_FILL_LAST,
846 249 : 0);
847 249 : aSet.Set(rFrameFormat.GetAttrSet());
848 :
849 : // Fly als Zeichen werden bei uns zu Absatz-gebundenen
850 : // jetzt den Abstand vom Absatz-Rand setzen
851 249 : if (m_pFlyOffset)
852 : {
853 0 : aSet.Put(SwFormatHoriOrient(m_pFlyOffset->X()));
854 0 : aSet.Put(SwFormatVertOrient(m_pFlyOffset->Y()));
855 0 : SwFormatAnchor aAnchor(rFrameFormat.GetAnchor());
856 0 : aAnchor.SetType(m_eNewAnchorType);
857 0 : aSet.Put(aAnchor);
858 : }
859 :
860 249 : if (SfxItemState::SET != aSet.GetItemState(RES_SURROUND))
861 0 : aSet.Put(SwFormatSurround(SURROUND_NONE));
862 :
863 249 : const XFillStyleItem* pXFillStyleItem(static_cast< const XFillStyleItem* >(rFrameFormat.GetAttrSet().GetItem(XATTR_FILLSTYLE)));
864 249 : if (pXFillStyleItem)
865 : {
866 249 : switch (pXFillStyleItem->GetValue())
867 : {
868 : case drawing::FillStyle_NONE:
869 195 : break;
870 : case drawing::FillStyle_SOLID:
871 : {
872 : // Construct an SvxBrushItem, as expected by the exporters.
873 46 : aSet.Put(getSvxBrushItemFromSourceSet(rFrameFormat.GetAttrSet(), RES_BACKGROUND));
874 46 : break;
875 : }
876 : default:
877 8 : break;
878 : }
879 : }
880 :
881 249 : m_bOutFlyFrmAttrs = true;
882 : //script doesn't matter if not exporting chp
883 : OutputItemSet(aSet, true, false,
884 249 : i18n::ScriptType::LATIN, m_bExportModeRTF);
885 249 : m_bOutFlyFrmAttrs = false;
886 :
887 249 : bCallOutSet = false;
888 : }
889 : }
890 249 : break;
891 : case RES_FRMFMT:
892 214 : break;
893 : default:
894 : OSL_ENSURE( false, "Which format is exported here?" );
895 0 : break;
896 : }
897 :
898 21090 : if( bCallOutSet )
899 20816 : OutputItemSet( rFormat.GetAttrSet(), bPapFormat, bChpFormat,
900 41632 : i18n::ScriptType::LATIN, m_bExportModeRTF);
901 21090 : m_pOutFormatNode = pOldMod;
902 21090 : }
903 :
904 13 : bool MSWordExportBase::HasRefToObject( sal_uInt16 nTyp, const OUString* pName, sal_uInt16 nSeqNo )
905 : {
906 :
907 13 : SwFieldType* pType = m_pDoc->getIDocumentFieldsAccess().GetSysFieldType( RES_GETREFFLD );
908 13 : SwIterator<SwFormatField, SwFieldType> aFormatFields( *pType );
909 13 : for ( SwFormatField* pFormatField = aFormatFields.First(); pFormatField; pFormatField = aFormatFields.Next() )
910 : {
911 0 : const SwTextNode* pNd = pFormatField->GetTextField()->GetpTextNode();
912 0 : if ( pFormatField->GetTextField() && nTyp == pFormatField->GetField()->GetSubType() &&
913 0 : 0 != pNd && pNd->GetNodes().IsDocNodes() )
914 : {
915 0 : const SwGetRefField& rRField = *static_cast< SwGetRefField* >( pFormatField->GetField() );
916 0 : switch ( nTyp )
917 : {
918 : case REF_BOOKMARK:
919 : case REF_SETREFATTR:
920 0 : if ( pName && *pName == rRField.GetSetRefName() )
921 0 : return true;
922 0 : break;
923 : case REF_FOOTNOTE:
924 : case REF_ENDNOTE:
925 0 : if ( nSeqNo == rRField.GetSeqNo() )
926 0 : return true;
927 0 : break;
928 : case REF_SEQUENCEFLD:
929 0 : break; // ???
930 : case REF_OUTLINE:
931 0 : break; // ???
932 : }
933 : }
934 : }
935 :
936 13 : return false;
937 : }
938 :
939 6 : OUString MSWordExportBase::GetBookmarkName( sal_uInt16 nTyp, const OUString* pName, sal_uInt16 nSeqNo )
940 : {
941 6 : OUString sRet;
942 6 : switch ( nTyp )
943 : {
944 : case REF_SETREFATTR:
945 3 : if ( pName )
946 : {
947 3 : sRet += "Ref_";
948 3 : sRet += *pName;
949 : }
950 3 : break;
951 : case REF_SEQUENCEFLD:
952 0 : break; // ???
953 : case REF_BOOKMARK:
954 3 : if ( pName )
955 3 : sRet = *pName;
956 3 : break;
957 : case REF_OUTLINE:
958 0 : break; // ???
959 : case REF_FOOTNOTE:
960 0 : sRet += "_RefF";
961 0 : sRet += OUString::number( nSeqNo );
962 0 : break;
963 : case REF_ENDNOTE:
964 0 : sRet += "_RefE";
965 0 : sRet += OUString::number( nSeqNo );
966 0 : break;
967 : }
968 6 : return BookmarkToWord( sRet ); // #i43956# - encode bookmark accordingly
969 : }
970 :
971 : /* File CHRATR.HXX: */
972 567 : void WW8AttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript )
973 : {
974 567 : if ( m_rWW8Export.bWrtWW8 && bIsRTL )
975 : {
976 0 : if( m_rWW8Export.m_pDoc->GetDocumentType() != SwDoc::DOCTYPE_MSWORD )
977 : {
978 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_CFBiDi );
979 0 : m_rWW8Export.pO->push_back( (sal_uInt8)1 );
980 : }
981 : }
982 :
983 : // #i46087# patch from james_clark; complex texts needs the undocumented SPRM CComplexScript with param 0x81.
984 567 : if ( m_rWW8Export.bWrtWW8 && nScript == i18n::ScriptType::COMPLEX && !bIsRTL )
985 : {
986 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_CComplexScript );
987 0 : m_rWW8Export.pO->push_back( (sal_uInt8)0x81 );
988 0 : m_rWW8Export.pDop->bUseThaiLineBreakingRules = true;
989 : }
990 567 : }
991 :
992 439 : void WW8AttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner )
993 : {
994 439 : m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell() - (mbOnTOXEnding?2:0), m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
995 439 : mbOnTOXEnding = false;
996 439 : m_rWW8Export.pO->clear();
997 :
998 439 : if ( pTextNodeInfoInner.get() != NULL )
999 : {
1000 245 : if ( pTextNodeInfoInner->isEndOfLine() )
1001 : {
1002 37 : TableRowEnd( pTextNodeInfoInner->getDepth() );
1003 :
1004 : SVBT16 nSty;
1005 37 : ShortToSVBT16( 0, nSty );
1006 37 : m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), nSty, nSty+2 ); // Style #
1007 37 : TableInfoRow( pTextNodeInfoInner );
1008 37 : m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data());
1009 37 : m_rWW8Export.pO->clear();
1010 : //For Bug 119650, should break the properties of CHP PLC after a paragraph end.
1011 37 : m_rWW8Export.m_pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data());
1012 : }
1013 : }
1014 439 : }
1015 :
1016 567 : void WW8AttributeOutput::StartRunProperties()
1017 : {
1018 567 : WW8_WrPlcField* pCurrentFields = m_rWW8Export.CurrentFieldPlc();
1019 567 : m_nFieldResults = pCurrentFields ? pCurrentFields->ResultCount() : 0;
1020 567 : }
1021 :
1022 573 : void WW8AttributeOutput::StartRun( const SwRedlineData* pRedlineData, bool /*bSingleEmptyRun*/ )
1023 : {
1024 573 : if (pRedlineData)
1025 : {
1026 3 : const OUString &rComment = pRedlineData->GetComment();
1027 : //Only possible to export to main text
1028 3 : if (!rComment.isEmpty() && (m_rWW8Export.m_nTextTyp == TXT_MAINTEXT))
1029 : {
1030 0 : if (m_rWW8Export.m_pAtn->IsNewRedlineComment(pRedlineData))
1031 : {
1032 0 : m_rWW8Export.m_pAtn->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), pRedlineData );
1033 0 : m_rWW8Export.WritePostItBegin( m_rWW8Export.pO );
1034 : }
1035 : }
1036 : }
1037 573 : }
1038 :
1039 0 : void WW8AttributeOutput::OnTOXEnding()
1040 : {
1041 0 : mbOnTOXEnding = true;
1042 0 : }
1043 :
1044 567 : void WW8AttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData )
1045 : {
1046 567 : Redline( pRedlineData );
1047 :
1048 567 : WW8_WrPlcField* pCurrentFields = m_rWW8Export.CurrentFieldPlc();
1049 567 : sal_uInt16 nNewFieldResults = pCurrentFields ? pCurrentFields->ResultCount() : 0;
1050 :
1051 567 : bool bExportedFieldResult = ( m_nFieldResults != nNewFieldResults );
1052 :
1053 : // If we have exported a field result, then we will have been forced to
1054 : // split up the text into a 0x13, 0x14, <result> 0x15 sequence with the
1055 : // properties forced out at the end of the result, so the 0x15 itself
1056 : // should remain clean of all other attributes to avoid #iXXXXX#
1057 567 : if ( !bExportedFieldResult )
1058 : {
1059 563 : m_rWW8Export.m_pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(),
1060 1126 : m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
1061 : }
1062 567 : m_rWW8Export.pO->clear();
1063 567 : }
1064 :
1065 370 : void WW8AttributeOutput::RunText( const OUString& rText, rtl_TextEncoding eCharSet )
1066 : {
1067 370 : RawText( rText, m_rWW8Export.bWrtWW8, eCharSet );
1068 370 : }
1069 :
1070 370 : void WW8AttributeOutput::RawText( const OUString& rText, bool bForceUnicode, rtl_TextEncoding eCharSet )
1071 : {
1072 370 : m_rWW8Export.OutSwString( rText, 0, rText.getLength(), bForceUnicode, eCharSet );
1073 370 : }
1074 :
1075 444 : void WW8AttributeOutput::OutputFKP(bool bForce)
1076 : {
1077 444 : if (!m_rWW8Export.pO->empty() || bForce)
1078 : {
1079 5 : m_rWW8Export.m_pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(),
1080 10 : m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
1081 5 : m_rWW8Export.pO->clear();
1082 : }
1083 444 : }
1084 :
1085 439 : void WW8AttributeOutput::ParagraphStyle( sal_uInt16 nStyle )
1086 : {
1087 : OSL_ENSURE( m_rWW8Export.pO->empty(), " pO ist am ZeilenEnde nicht leer" );
1088 :
1089 : SVBT16 nSty;
1090 439 : ShortToSVBT16( nStyle, nSty );
1091 439 : m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), nSty, nSty+2 ); // Style #
1092 439 : }
1093 :
1094 199 : void WW8AttributeOutput::OutputWW8Attribute( sal_uInt8 nId, bool bVal )
1095 : {
1096 199 : if ( m_rWW8Export.bWrtWW8 )
1097 199 : m_rWW8Export.InsUInt16( 8 == nId ? NS_sprm::LN_CFDStrike : NS_sprm::LN_CFBold + nId );
1098 0 : else if (8 == nId )
1099 199 : return; // no such attribute in WW6
1100 : else
1101 0 : m_rWW8Export.pO->push_back( 85 + nId );
1102 :
1103 199 : m_rWW8Export.pO->push_back( bVal ? 1 : 0 );
1104 : }
1105 :
1106 80 : void WW8AttributeOutput::OutputWW8AttributeCTL( sal_uInt8 nId, bool bVal )
1107 : {
1108 : OSL_ENSURE( nId <= 1, "out of range" );
1109 80 : if ( !m_rWW8Export.bWrtWW8 || nId > 1 )
1110 80 : return;
1111 :
1112 80 : m_rWW8Export.InsUInt16( NS_sprm::LN_CFBoldBi + nId );
1113 80 : m_rWW8Export.pO->push_back( bVal ? 1 : 0 );
1114 : }
1115 :
1116 450 : void WW8AttributeOutput::CharFont( const SvxFontItem& rFont )
1117 : {
1118 450 : sal_uInt16 nFontID = m_rWW8Export.GetId( rFont );
1119 :
1120 450 : if ( m_rWW8Export.bWrtWW8 )
1121 : {
1122 450 : m_rWW8Export.InsUInt16( NS_sprm::LN_CRgFtc0 );
1123 450 : m_rWW8Export.InsUInt16( nFontID );
1124 450 : m_rWW8Export.InsUInt16( NS_sprm::LN_CRgFtc2 );
1125 : }
1126 : else
1127 0 : m_rWW8Export.pO->push_back( 93 );
1128 :
1129 450 : m_rWW8Export.InsUInt16( nFontID );
1130 450 : }
1131 :
1132 569 : void WW8AttributeOutput::CharFontCTL( const SvxFontItem& rFont )
1133 : {
1134 : //Can only export in 8+, in 7- export as normal variant and expect that
1135 : //upperlevel code has blocked exporting clobbering attributes
1136 569 : sal_uInt16 nFontID = m_rWW8Export.GetId( rFont );
1137 569 : if ( m_rWW8Export.bWrtWW8 )
1138 569 : m_rWW8Export.InsUInt16( NS_sprm::LN_CFtcBi );
1139 : else
1140 0 : m_rWW8Export.pO->push_back( 93 );
1141 569 : m_rWW8Export.InsUInt16( nFontID );
1142 569 : }
1143 :
1144 98 : void WW8AttributeOutput::CharFontCJK( const SvxFontItem& rFont )
1145 : {
1146 : //Can only export in 8+, in 7- export as normal variant and expect that
1147 : //upperlevel code has blocked exporting clobbering attributes
1148 98 : sal_uInt16 nFontID = m_rWW8Export.GetId( rFont );
1149 98 : if ( m_rWW8Export.bWrtWW8 )
1150 98 : m_rWW8Export.InsUInt16( NS_sprm::LN_CRgFtc1 );
1151 : else
1152 0 : m_rWW8Export.pO->push_back( 93 );
1153 98 : m_rWW8Export.InsUInt16( nFontID );
1154 98 : }
1155 :
1156 32 : void WW8AttributeOutput::CharWeightCTL( const SvxWeightItem& rWeight )
1157 : {
1158 : //Can only export in 8+, in 7- export as normal variant and expect that
1159 : //upperlevel code has blocked exporting clobbering attributes
1160 32 : if (m_rWW8Export.bWrtWW8)
1161 : {
1162 32 : OutputWW8AttributeCTL( 0, WEIGHT_BOLD == rWeight.GetWeight());
1163 : }
1164 : else
1165 : {
1166 0 : OutputWW8Attribute( 0, WEIGHT_BOLD == rWeight.GetWeight());
1167 : }
1168 32 : }
1169 :
1170 48 : void WW8AttributeOutput::CharPostureCTL( const SvxPostureItem& rPosture )
1171 : {
1172 : // Can only export in 8+, in 7- export as normal variant and expect that
1173 : // upperlevel code has blocked exporting clobbering attributes
1174 48 : if (m_rWW8Export.bWrtWW8)
1175 : {
1176 48 : OutputWW8AttributeCTL( 1, ITALIC_NONE != rPosture.GetPosture() );
1177 : }
1178 : else
1179 : {
1180 0 : OutputWW8Attribute( 1, ITALIC_NONE != rPosture.GetPosture() );
1181 : }
1182 48 : }
1183 :
1184 60 : void WW8AttributeOutput::CharPosture( const SvxPostureItem& rPosture )
1185 : {
1186 60 : OutputWW8Attribute( 1, ITALIC_NONE != rPosture.GetPosture() );
1187 60 : }
1188 :
1189 87 : void WW8AttributeOutput::CharWeight( const SvxWeightItem& rWeight )
1190 : {
1191 87 : OutputWW8Attribute( 0, WEIGHT_BOLD == rWeight.GetWeight() );
1192 87 : }
1193 :
1194 : // Shadowed und Contour are not in WW-UI. JP: ??
1195 7 : void WW8AttributeOutput::CharContour( const SvxContourItem& rContour )
1196 : {
1197 7 : OutputWW8Attribute( 3, rContour.GetValue() );
1198 7 : }
1199 :
1200 7 : void WW8AttributeOutput::CharShadow( const SvxShadowedItem& rShadow )
1201 : {
1202 7 : OutputWW8Attribute( 4, rShadow.GetValue() );
1203 7 : }
1204 :
1205 11 : void WW8AttributeOutput::CharKerning( const SvxKerningItem& rKerning )
1206 : {
1207 11 : if ( m_rWW8Export.bWrtWW8 )
1208 11 : m_rWW8Export.InsUInt16( NS_sprm::LN_CDxaSpace );
1209 : else
1210 0 : m_rWW8Export.pO->push_back( 96 );
1211 :
1212 11 : m_rWW8Export.InsUInt16( rKerning.GetValue() );
1213 11 : }
1214 :
1215 44 : void WW8AttributeOutput::CharAutoKern( const SvxAutoKernItem& rAutoKern )
1216 : {
1217 44 : if ( m_rWW8Export.bWrtWW8 )
1218 44 : m_rWW8Export.InsUInt16( NS_sprm::LN_CHpsKern );
1219 : else
1220 0 : m_rWW8Export.pO->push_back( 107 );
1221 :
1222 44 : m_rWW8Export.InsUInt16( rAutoKern.GetValue() ? 1 : 0 );
1223 44 : }
1224 :
1225 0 : void WW8AttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink )
1226 : {
1227 0 : if ( m_rWW8Export.bWrtWW8 )
1228 : {
1229 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_CSfxText );
1230 : // At the moment the only animated text effect we support is blinking
1231 0 : m_rWW8Export.InsUInt16( rBlink.GetValue() ? 2 : 0 );
1232 : }
1233 0 : }
1234 :
1235 7 : void WW8AttributeOutput::CharCrossedOut( const SvxCrossedOutItem& rCrossed )
1236 : {
1237 7 : FontStrikeout eSt = rCrossed.GetStrikeout();
1238 7 : if ( STRIKEOUT_DOUBLE == eSt )
1239 : {
1240 0 : OutputWW8Attribute( 8, true );
1241 0 : return;
1242 : }
1243 7 : if ( STRIKEOUT_NONE != eSt )
1244 : {
1245 0 : OutputWW8Attribute( 2, true );
1246 0 : return;
1247 : }
1248 :
1249 : // otherwise both off
1250 7 : OutputWW8Attribute( 8, false );
1251 7 : OutputWW8Attribute( 2, false );
1252 : }
1253 :
1254 10 : void WW8AttributeOutput::CharCaseMap( const SvxCaseMapItem& rCaseMap )
1255 : {
1256 10 : sal_uInt16 eSt = rCaseMap.GetValue();
1257 10 : switch ( eSt )
1258 : {
1259 : case SVX_CASEMAP_KAPITAELCHEN:
1260 0 : OutputWW8Attribute( 5, true );
1261 0 : return;
1262 : case SVX_CASEMAP_VERSALIEN:
1263 4 : OutputWW8Attribute( 6, true );
1264 4 : return;
1265 : case SVX_CASEMAP_TITEL:
1266 : // no such feature in word
1267 0 : break;
1268 : default:
1269 : // otherwise both off
1270 6 : OutputWW8Attribute( 5, false );
1271 6 : OutputWW8Attribute( 6, false );
1272 6 : return;
1273 : }
1274 : }
1275 :
1276 8 : void WW8AttributeOutput::CharHidden( const SvxCharHiddenItem& rHidden )
1277 : {
1278 8 : OutputWW8Attribute( 7, rHidden.GetValue() );
1279 8 : }
1280 :
1281 4 : void WW8AttributeOutput::CharBorder( const SvxBorderLine* pAllBorder, const sal_uInt16 /*nDist*/, const bool bShadow )
1282 : {
1283 4 : m_rWW8Export.Out_BorderLine( *m_rWW8Export.pO, pAllBorder, 0, NS_sprm::LN_CBrc80, NS_sprm::LN_CBrc, bShadow );
1284 4 : }
1285 :
1286 64 : void WW8AttributeOutput::CharHighlight( const SvxBrushItem& rBrush )
1287 : {
1288 64 : if( m_rWW8Export.bWrtWW8 && rBrush.GetColor() != COL_TRANSPARENT )
1289 : {
1290 60 : sal_uInt8 nColor = msfilter::util::TransColToIco( rBrush.GetColor() );
1291 : // sprmCHighlight
1292 60 : m_rWW8Export.InsUInt16( NS_sprm::LN_CHighlight );
1293 60 : m_rWW8Export.pO->push_back( nColor );
1294 : }
1295 64 : }
1296 :
1297 52 : void WW8AttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline )
1298 : {
1299 52 : if ( m_rWW8Export.bWrtWW8 )
1300 52 : m_rWW8Export.InsUInt16( NS_sprm::LN_CKul );
1301 : else
1302 0 : m_rWW8Export.pO->push_back( 94 );
1303 :
1304 52 : const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_CHRATR_WORDLINEMODE );
1305 52 : bool bWord = false;
1306 52 : if (pItem)
1307 6 : bWord = static_cast<const SvxWordLineModeItem*>(pItem)->GetValue();
1308 :
1309 : // WW95 - parameters: 0 = none, 1 = single, 2 = by Word,
1310 : // 3 = double, 4 = dotted, 5 = hidden
1311 : // WW97 - additional parameters:
1312 : // 6 = thick, 7 = dash, 8 = dot(not used)
1313 : // 9 = dotdash 10 = dotdotdash, 11 = wave
1314 52 : sal_uInt8 b = 0;
1315 52 : switch ( rUnderline.GetLineStyle() )
1316 : {
1317 : case UNDERLINE_SINGLE:
1318 23 : b = ( bWord ) ? 2 : 1;
1319 23 : break;
1320 : case UNDERLINE_BOLD:
1321 0 : b = m_rWW8Export.bWrtWW8 ? 6 : 1;
1322 0 : break;
1323 : case UNDERLINE_DOUBLE:
1324 0 : b = 3;
1325 0 : break;
1326 : case UNDERLINE_DOTTED:
1327 0 : b = 4;
1328 0 : break;
1329 : case UNDERLINE_DASH:
1330 0 : b = m_rWW8Export.bWrtWW8 ? 7 : 4;
1331 0 : break;
1332 : case UNDERLINE_DASHDOT:
1333 0 : b = m_rWW8Export.bWrtWW8 ? 9 : 4;
1334 0 : break;
1335 : case UNDERLINE_DASHDOTDOT:
1336 0 : b = m_rWW8Export.bWrtWW8 ? 10 : 4;
1337 0 : break;
1338 : case UNDERLINE_WAVE:
1339 0 : b = m_rWW8Export.bWrtWW8 ? 11 : 3;
1340 0 : break;
1341 : // new in WW2000
1342 : case UNDERLINE_BOLDDOTTED:
1343 0 : b = m_rWW8Export.bWrtWW8 ? 20 : 4;
1344 0 : break;
1345 : case UNDERLINE_BOLDDASH:
1346 0 : b = m_rWW8Export.bWrtWW8 ? 23 : 4;
1347 0 : break;
1348 : case UNDERLINE_LONGDASH:
1349 0 : b = m_rWW8Export.bWrtWW8 ? 39 : 4;
1350 0 : break;
1351 : case UNDERLINE_BOLDLONGDASH:
1352 0 : b = m_rWW8Export.bWrtWW8 ? 55 : 4;
1353 0 : break;
1354 : case UNDERLINE_BOLDDASHDOT:
1355 0 : b = m_rWW8Export.bWrtWW8 ? 25 : 4;
1356 0 : break;
1357 : case UNDERLINE_BOLDDASHDOTDOT:
1358 0 : b = m_rWW8Export.bWrtWW8 ? 26 : 4;
1359 0 : break;
1360 : case UNDERLINE_BOLDWAVE:
1361 0 : b = m_rWW8Export.bWrtWW8 ? 27 : 3;
1362 0 : break;
1363 : case UNDERLINE_DOUBLEWAVE:
1364 0 : b = m_rWW8Export.bWrtWW8 ? 43 : 3;
1365 0 : break;
1366 : case UNDERLINE_NONE:
1367 29 : b = 0;
1368 29 : break;
1369 : default:
1370 : OSL_ENSURE( rUnderline.GetLineStyle() == UNDERLINE_NONE, "Unhandled underline type" );
1371 0 : break;
1372 : }
1373 :
1374 52 : m_rWW8Export.pO->push_back( b );
1375 52 : Color aColor = rUnderline.GetColor();
1376 52 : if( aColor != COL_TRANSPARENT )
1377 : {
1378 0 : if( m_rWW8Export.bWrtWW8 )
1379 : {
1380 0 : m_rWW8Export.InsUInt16( 0x6877 );
1381 :
1382 0 : m_rWW8Export.InsUInt32( wwUtility::RGBToBGR( aColor.GetColor() ) );
1383 : }
1384 : }
1385 52 : }
1386 :
1387 224 : void WW8AttributeOutput::CharLanguage( const SvxLanguageItem& rLanguage )
1388 : {
1389 224 : sal_uInt16 nId = 0;
1390 224 : if ( m_rWW8Export.bWrtWW8 )
1391 : {
1392 224 : switch ( rLanguage.Which() )
1393 : {
1394 : case RES_CHRATR_LANGUAGE:
1395 97 : nId = NS_sprm::LN_CRgLid0_80;
1396 97 : break;
1397 : case RES_CHRATR_CJK_LANGUAGE:
1398 68 : nId = NS_sprm::LN_CRgLid1_80;
1399 68 : break;
1400 : case RES_CHRATR_CTL_LANGUAGE:
1401 59 : nId = NS_sprm::LN_CLidBi;
1402 59 : break;
1403 : }
1404 : }
1405 : else
1406 0 : nId = 97;
1407 :
1408 224 : if ( nId )
1409 : {
1410 224 : if ( m_rWW8Export.bWrtWW8 ) // use sprmCRgLid0_80 rather than sprmCLid
1411 224 : m_rWW8Export.InsUInt16( nId );
1412 : else
1413 0 : m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(nId) );
1414 224 : m_rWW8Export.InsUInt16( rLanguage.GetLanguage() );
1415 :
1416 : // Word 2000 and above apparently require both old and new versions of
1417 : // these sprms to be set, without it spellchecking doesn't work
1418 224 : if ( nId == NS_sprm::LN_CRgLid0_80 )
1419 : {
1420 97 : m_rWW8Export.InsUInt16( NS_sprm::LN_CRgLid0 );
1421 97 : m_rWW8Export.InsUInt16( rLanguage.GetLanguage() );
1422 : }
1423 127 : else if ( nId == NS_sprm::LN_CRgLid1_80 )
1424 : {
1425 68 : m_rWW8Export.InsUInt16( NS_sprm::LN_CRgLid1 );
1426 68 : m_rWW8Export.InsUInt16( rLanguage.GetLanguage() );
1427 : }
1428 : }
1429 224 : }
1430 :
1431 11 : void WW8AttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement )
1432 : {
1433 11 : sal_uInt8 b = 0xFF;
1434 11 : short nEsc = rEscapement.GetEsc(), nProp = rEscapement.GetProp();
1435 11 : if ( !nEsc )
1436 : {
1437 7 : b = 0;
1438 7 : nEsc = 0;
1439 7 : nProp = 100;
1440 : }
1441 4 : else if ( DFLT_ESC_PROP == nProp )
1442 : {
1443 4 : if ( DFLT_ESC_SUB == nEsc || DFLT_ESC_AUTO_SUB == nEsc )
1444 0 : b = 2;
1445 4 : else if ( DFLT_ESC_SUPER == nEsc || DFLT_ESC_AUTO_SUPER == nEsc )
1446 4 : b = 1;
1447 : }
1448 :
1449 11 : if ( 0xFF != b )
1450 : {
1451 11 : if ( m_rWW8Export.bWrtWW8 )
1452 11 : m_rWW8Export.InsUInt16( NS_sprm::LN_CIss );
1453 : else
1454 0 : m_rWW8Export.pO->push_back( 104 );
1455 :
1456 11 : m_rWW8Export.pO->push_back( b );
1457 : }
1458 :
1459 11 : if ( 0 == b || 0xFF == b )
1460 : {
1461 : long nHeight = static_cast<const SvxFontHeightItem&>(m_rWW8Export.GetItem(
1462 7 : RES_CHRATR_FONTSIZE )).GetHeight();
1463 7 : if( m_rWW8Export.bWrtWW8 )
1464 7 : m_rWW8Export.InsUInt16( NS_sprm::LN_CHpsPos );
1465 : else
1466 0 : m_rWW8Export.pO->push_back( 101 );
1467 :
1468 7 : m_rWW8Export.InsUInt16( (short)(( nHeight * nEsc + 500 ) / 1000 ));
1469 :
1470 7 : if( 100 != nProp || !b )
1471 : {
1472 7 : if( m_rWW8Export.bWrtWW8 )
1473 7 : m_rWW8Export.InsUInt16( NS_sprm::LN_CHps );
1474 : else
1475 0 : m_rWW8Export.pO->push_back( 99 );
1476 :
1477 : m_rWW8Export.InsUInt16(
1478 7 : msword_cast<sal_uInt16>((nHeight * nProp + 500 ) / 1000));
1479 : }
1480 : }
1481 11 : }
1482 :
1483 704 : void WW8AttributeOutput::CharFontSize( const SvxFontHeightItem& rHeight )
1484 : {
1485 704 : sal_uInt16 nId = 0;
1486 704 : if ( m_rWW8Export.bWrtWW8 )
1487 : {
1488 704 : switch ( rHeight.Which() )
1489 : {
1490 : case RES_CHRATR_FONTSIZE:
1491 : case RES_CHRATR_CJK_FONTSIZE:
1492 431 : nId = NS_sprm::LN_CHps;
1493 431 : break;
1494 : case RES_CHRATR_CTL_FONTSIZE:
1495 273 : nId = NS_sprm::LN_CHpsBi;
1496 273 : break;
1497 : }
1498 : }
1499 : else
1500 0 : nId = 99;
1501 :
1502 704 : if ( nId )
1503 : {
1504 704 : if ( m_rWW8Export.bWrtWW8 )
1505 704 : m_rWW8Export.InsUInt16( nId );
1506 : else
1507 0 : m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(nId) );
1508 :
1509 704 : m_rWW8Export.InsUInt16( (sal_uInt16)(( rHeight.GetHeight() + 5 ) / 10 ) );
1510 : }
1511 704 : }
1512 :
1513 7 : void WW8AttributeOutput::CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth )
1514 : {
1515 7 : if ( m_rWW8Export.bWrtWW8 )
1516 : {
1517 7 : m_rWW8Export.InsUInt16( NS_sprm::LN_CCharScale );
1518 7 : m_rWW8Export.InsUInt16( rScaleWidth.GetValue() );
1519 : }
1520 7 : }
1521 :
1522 6 : void WW8AttributeOutput::CharRelief( const SvxCharReliefItem& rRelief )
1523 : {
1524 6 : if ( m_rWW8Export.bWrtWW8 )
1525 : {
1526 : sal_uInt16 nId;
1527 6 : switch ( rRelief.GetValue() )
1528 : {
1529 0 : case RELIEF_EMBOSSED: nId = NS_sprm::LN_CFEmboss; break;
1530 0 : case RELIEF_ENGRAVED: nId = NS_sprm::LN_CFImprint; break;
1531 6 : default: nId = 0; break;
1532 : }
1533 :
1534 6 : if( nId )
1535 : {
1536 0 : m_rWW8Export.InsUInt16( nId );
1537 0 : m_rWW8Export.pO->push_back( (sal_uInt8)0x81 );
1538 : }
1539 : else
1540 : {
1541 : // switch both flags off
1542 6 : m_rWW8Export.InsUInt16( NS_sprm::LN_CFEmboss );
1543 6 : m_rWW8Export.pO->push_back( (sal_uInt8)0x0 );
1544 6 : m_rWW8Export.InsUInt16( NS_sprm::LN_CFImprint );
1545 6 : m_rWW8Export.pO->push_back( (sal_uInt8)0x0 );
1546 : }
1547 : }
1548 6 : }
1549 :
1550 0 : void WW8AttributeOutput::CharBidiRTL( const SfxPoolItem& rHt )
1551 : {
1552 0 : const SfxInt16Item& rAttr = static_cast<const SfxInt16Item&>(rHt);
1553 0 : if( rAttr.GetValue() == 1 )
1554 : {
1555 0 : m_rWW8Export.InsUInt16(0x85a);
1556 0 : m_rWW8Export.pO->push_back((sal_uInt8)(1));
1557 : }
1558 0 : }
1559 :
1560 8 : void WW8AttributeOutput::CharIdctHint( const SfxPoolItem& rHt )
1561 : {
1562 8 : const SfxInt16Item& rAttr = static_cast<const SfxInt16Item&>(rHt);
1563 8 : m_rWW8Export.InsUInt16(0x286F);
1564 8 : m_rWW8Export.pO->push_back((sal_uInt8)(rAttr.GetValue()));
1565 8 : }
1566 :
1567 0 : void WW8AttributeOutput::CharRotate( const SvxCharRotateItem& rRotate )
1568 : {
1569 : // #i28331# - check that a Value is set
1570 0 : if ( !rRotate.GetValue() )
1571 0 : return;
1572 :
1573 0 : if ( m_rWW8Export.bWrtWW8 && !m_rWW8Export.IsInTable() )
1574 : {
1575 : // #i36867 In word the text in a table is rotated via the TC or NS_sprm::LN_TTextFlow
1576 : // This means you can only rotate all or none of the text adding NS_sprm::LN_CFELayout
1577 : // here corrupts the table, hence !m_rWW8Export.bIsInTable
1578 :
1579 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_CFELayout );
1580 0 : m_rWW8Export.pO->push_back( (sal_uInt8)0x06 ); //len 6
1581 0 : m_rWW8Export.pO->push_back( (sal_uInt8)0x01 );
1582 :
1583 0 : m_rWW8Export.InsUInt16( rRotate.IsFitToLine() ? 1 : 0 );
1584 : static const sal_uInt8 aZeroArr[ 3 ] = { 0, 0, 0 };
1585 0 : m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), aZeroArr, aZeroArr+3);
1586 : }
1587 : }
1588 :
1589 7 : void WW8AttributeOutput::CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark )
1590 : {
1591 7 : if ( m_rWW8Export.bWrtWW8 )
1592 : {
1593 : sal_uInt8 nVal;
1594 7 : switch ( rEmphasisMark.GetValue() )
1595 : {
1596 7 : case EMPHASISMARK_NONE: nVal = 0; break;
1597 0 : case EMPHASISMARK_SIDE_DOTS: nVal = 2; break;
1598 0 : case EMPHASISMARK_CIRCLE_ABOVE: nVal = 3; break;
1599 0 : case EMPHASISMARK_DOTS_BELOW: nVal = 4; break;
1600 : // case 1:
1601 0 : default: nVal = 1; break;
1602 : }
1603 :
1604 7 : m_rWW8Export.InsUInt16( NS_sprm::LN_CKcd );
1605 7 : m_rWW8Export.pO->push_back( nVal );
1606 : }
1607 7 : }
1608 :
1609 : // TransBrush uebersetzt SW-Brushes in WW. Heraus kommt WW8_SHD.
1610 : // Nicht-Standardfarben des SW werden noch nicht in die
1611 : // Misch-Werte ( 0 .. 95% ) vom WW uebersetzt.
1612 : // Return: Echte Brush ( nicht transparent )
1613 : // auch bei Transparent wird z.B. fuer Tabellen eine transparente Brush
1614 : // geliefert
1615 181 : bool WW8Export::TransBrush(const Color& rCol, WW8_SHD& rShd)
1616 : {
1617 181 : if( rCol.GetTransparency() )
1618 113 : rShd = WW8_SHD(); // alles Nullen : transparent
1619 : else
1620 : {
1621 68 : rShd.SetFore( 0);
1622 68 : rShd.SetBack( msfilter::util::TransColToIco( rCol ) );
1623 68 : rShd.SetStyle( bWrtWW8, 0 );
1624 : }
1625 181 : return !rCol.GetTransparency();
1626 : }
1627 :
1628 45 : sal_uInt32 SuitableBGColor(sal_uInt32 nIn)
1629 : {
1630 45 : if (nIn == COL_AUTO)
1631 0 : return 0xFF000000;
1632 45 : return wwUtility::RGBToBGR(nIn);
1633 : }
1634 :
1635 124 : void WW8AttributeOutput::CharColor( const SvxColorItem& rColor )
1636 : {
1637 124 : if ( m_rWW8Export.bWrtWW8 )
1638 124 : m_rWW8Export.InsUInt16( NS_sprm::LN_CIco );
1639 : else
1640 0 : m_rWW8Export.pO->push_back( 98 );
1641 :
1642 124 : sal_uInt8 nColor = msfilter::util::TransColToIco( rColor.GetValue() );
1643 124 : m_rWW8Export.pO->push_back( nColor );
1644 :
1645 124 : if ( m_rWW8Export.bWrtWW8 && nColor )
1646 : {
1647 72 : m_rWW8Export.InsUInt16( NS_sprm::LN_CCv );
1648 72 : m_rWW8Export.InsUInt32( wwUtility::RGBToBGR( rColor.GetValue().GetColor() ) );
1649 : }
1650 124 : }
1651 :
1652 36 : void WW8AttributeOutput::CharBackground( const SvxBrushItem& rBrush )
1653 : {
1654 36 : if( m_rWW8Export.bWrtWW8 ) // nur WW8 kann ZeichenHintergrund
1655 : {
1656 36 : WW8_SHD aSHD;
1657 :
1658 36 : m_rWW8Export.TransBrush( rBrush.GetColor(), aSHD );
1659 : // sprmCShd80
1660 36 : m_rWW8Export.InsUInt16( NS_sprm::LN_CShd80 );
1661 36 : m_rWW8Export.InsUInt16( aSHD.GetValue() );
1662 :
1663 : //Quite a few unknowns, some might be transparency or something
1664 : //of that nature...
1665 36 : m_rWW8Export.InsUInt16( NS_sprm::LN_CShd );
1666 36 : m_rWW8Export.pO->push_back( 10 );
1667 36 : m_rWW8Export.InsUInt32( 0xFF000000 );
1668 36 : m_rWW8Export.InsUInt32( SuitableBGColor( rBrush.GetColor().GetColor() ) );
1669 36 : m_rWW8Export.InsUInt16( 0x0000);
1670 : }
1671 36 : }
1672 :
1673 0 : void WW8AttributeOutput::TextINetFormat( const SwFormatINetFormat& rINet )
1674 : {
1675 0 : if ( !rINet.GetValue().isEmpty() )
1676 : {
1677 0 : const sal_uInt16 nId = rINet.GetINetFormatId();
1678 0 : const OUString& rStr = rINet.GetINetFormat();
1679 0 : if (rStr.isEmpty())
1680 : {
1681 : OSL_ENSURE( false, "WW8AttributeOutput::TextINetFormat(..) - missing unvisited character format at hyperlink attribute" );
1682 : }
1683 :
1684 0 : const SwCharFormat* pFormat = IsPoolUserFormat( nId )
1685 0 : ? m_rWW8Export.m_pDoc->FindCharFormatByName( rStr )
1686 0 : : m_rWW8Export.m_pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool( nId );
1687 :
1688 0 : if ( m_rWW8Export.bWrtWW8 )
1689 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_CIstd );
1690 : else
1691 0 : m_rWW8Export.pO->push_back( 80 );
1692 :
1693 0 : m_rWW8Export.InsUInt16( m_rWW8Export.GetId( pFormat ) );
1694 : }
1695 0 : }
1696 :
1697 : // #i43956# - add optional parameter <pLinkStr>
1698 : // It's needed to write the hyperlink data for a certain cross-reference
1699 : // - it contains the name of the link target, which is a bookmark.
1700 : // add optional parameter <bIncludeEmptyPicLocation>
1701 : // It is needed to write an empty picture location for page number field separators
1702 22 : static void InsertSpecialChar( WW8Export& rWrt, sal_uInt8 c,
1703 : OUString* pLinkStr = 0L,
1704 : bool bIncludeEmptyPicLocation = false )
1705 : {
1706 22 : ww::bytes aItems;
1707 22 : rWrt.GetCurrentItems(aItems);
1708 :
1709 22 : if (c == 0x13)
1710 7 : rWrt.m_pChpPlc->AppendFkpEntry(rWrt.Strm().Tell());
1711 : else
1712 15 : rWrt.m_pChpPlc->AppendFkpEntry(rWrt.Strm().Tell(), aItems.size(), aItems.data());
1713 :
1714 22 : rWrt.WriteChar(c);
1715 :
1716 : // store empty sprmCPicLocation for field separator
1717 22 : if ( bIncludeEmptyPicLocation &&
1718 2 : ( c == 0x13 || c == 0x14 || c == 0x15 ) )
1719 : {
1720 3 : SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CPicLocation );
1721 3 : SwWW8Writer::InsUInt32( aItems, 0x00000000 );
1722 : }
1723 :
1724 : // #i43956# - write hyperlink data and attributes
1725 22 : if ( rWrt.bWrtWW8 && c == 0x01 && pLinkStr )
1726 : {
1727 : // write hyperlink data to data stream
1728 1 : SvStream& rStrm = *rWrt.pDataStrm;
1729 : // position of hyperlink data
1730 1 : const sal_uInt32 nLinkPosInDataStrm = rStrm.Tell();
1731 : // write empty header
1732 1 : const sal_uInt16 nEmptyHdrLen = 0x44;
1733 1 : sal_uInt8 aEmptyHeader[ nEmptyHdrLen ] = { 0 };
1734 1 : aEmptyHeader[ 4 ] = 0x44;
1735 1 : rStrm.Write( aEmptyHeader, nEmptyHdrLen );
1736 : // writer fixed header
1737 1 : const sal_uInt16 nFixHdrLen = 0x19;
1738 : sal_uInt8 aFixHeader[ nFixHdrLen ] =
1739 : {
1740 : 0x08, 0xD0, 0xC9, 0xEA, 0x79, 0xF9, 0xBA, 0xCE,
1741 : 0x11, 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9,
1742 : 0x0B, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
1743 : 0x00,
1744 1 : };
1745 1 : rStrm.Write( aFixHeader, nFixHdrLen );
1746 : // write reference string including length+1
1747 1 : sal_uInt32 nStrLen( pLinkStr->getLength() + 1 );
1748 1 : SwWW8Writer::WriteLong( rStrm, nStrLen );
1749 1 : SwWW8Writer::WriteString16( rStrm, *(pLinkStr), false );
1750 : // write additional two NULL Bytes
1751 1 : SwWW8Writer::WriteLong( rStrm, 0 );
1752 : // write length of hyperlink data
1753 1 : const sal_uInt32 nCurrPos = rStrm.Tell();
1754 1 : rStrm.Seek( nLinkPosInDataStrm );
1755 : SVBT32 nLen;
1756 1 : UInt32ToSVBT32( nCurrPos - nLinkPosInDataStrm, nLen );
1757 1 : rStrm.Write( nLen, 4 );
1758 1 : rStrm.Seek( nCurrPos );
1759 :
1760 : // write attributes of hyperlink character 0x01
1761 1 : SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CFFieldVanish );
1762 1 : aItems.push_back( (sal_uInt8)0x81 );
1763 1 : SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CPicLocation );
1764 1 : SwWW8Writer::InsUInt32( aItems, nLinkPosInDataStrm );
1765 1 : SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CFData );
1766 1 : aItems.push_back( (sal_uInt8)0x01 );
1767 : }
1768 :
1769 : //Technically we should probably Remove all attribs
1770 : //here for the 0x13, 0x14, 0x15, but our import
1771 : //is slightly lacking
1772 : //aItems.Remove(0, aItems.Count());
1773 : // fSpec-Attribute true
1774 22 : if( rWrt.bWrtWW8 )
1775 : {
1776 22 : SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CFSpec );
1777 22 : aItems.push_back( 1 );
1778 : }
1779 : else
1780 : {
1781 0 : aItems.push_back( 117 ); //sprmCFSpec
1782 0 : aItems.push_back( 1 );
1783 : }
1784 :
1785 22 : rWrt.m_pChpPlc->AppendFkpEntry(rWrt.Strm().Tell(), aItems.size(), aItems.data());
1786 22 : }
1787 :
1788 5 : static OUString lcl_GetExpandedField(const SwField &rField)
1789 : {
1790 5 : OUString sRet(rField.ExpandField(true));
1791 :
1792 : //replace LF 0x0A with VT 0x0B
1793 5 : return sRet.replace(0x0A, 0x0B);
1794 : }
1795 :
1796 1146 : WW8_WrPlcField* WW8Export::CurrentFieldPlc() const
1797 : {
1798 1146 : WW8_WrPlcField* pFieldP = NULL;
1799 1146 : switch (m_nTextTyp)
1800 : {
1801 : case TXT_MAINTEXT:
1802 1000 : pFieldP = m_pFieldMain;
1803 1000 : break;
1804 : case TXT_HDFT:
1805 114 : pFieldP = m_pFieldHdFt;
1806 114 : break;
1807 : case TXT_FTN:
1808 2 : pFieldP = m_pFieldFootnote;
1809 2 : break;
1810 : case TXT_EDN:
1811 0 : pFieldP = m_pFieldEdn;
1812 0 : break;
1813 : case TXT_ATN:
1814 0 : pFieldP = m_pFieldAtn;
1815 0 : break;
1816 : case TXT_TXTBOX:
1817 30 : pFieldP = m_pFieldTextBxs;
1818 30 : break;
1819 : case TXT_HFTXTBOX:
1820 0 : pFieldP = m_pFieldHFTextBxs;
1821 0 : break;
1822 : default:
1823 : OSL_ENSURE( false, "was ist das fuer ein SubDoc-Type?" );
1824 : }
1825 1146 : return pFieldP;
1826 : }
1827 :
1828 12 : void WW8Export::OutputField( const SwField* pField, ww::eField eFieldType,
1829 : const OUString& rFieldCmd, sal_uInt8 nMode )
1830 : {
1831 12 : bool bUnicode = IsUnicode();
1832 12 : WW8_WrPlcField* pFieldP = CurrentFieldPlc();
1833 :
1834 12 : const bool bIncludeEmptyPicLocation = ( eFieldType == ww::ePAGE );
1835 12 : if (WRITEFIELD_START & nMode)
1836 : {
1837 7 : sal_uInt8 aField13[2] = { 0x13, 0x00 }; // will change
1838 : //#i3958#, Needed to make this field work correctly in Word 2000
1839 7 : if (eFieldType == ww::eSHAPE)
1840 0 : aField13[0] |= 0x80;
1841 7 : aField13[1] = static_cast< sal_uInt8 >(eFieldType); // Typ nachtragen
1842 7 : pFieldP->Append( Fc2Cp( Strm().Tell() ), aField13 );
1843 7 : InsertSpecialChar( *this, 0x13, 0, bIncludeEmptyPicLocation );
1844 : }
1845 12 : if (WRITEFIELD_CMD_START & nMode)
1846 : {
1847 7 : if (bUnicode)
1848 7 : SwWW8Writer::WriteString16(Strm(), rFieldCmd, false);
1849 : else
1850 : {
1851 0 : SwWW8Writer::WriteString8(Strm(), rFieldCmd, false,
1852 0 : RTL_TEXTENCODING_MS_1252);
1853 : }
1854 : // #i43956# - write hyperlink character including
1855 : // attributes and corresponding binary data for certain reference fields.
1856 7 : bool bHandleBookmark = false;
1857 :
1858 7 : if (pField)
1859 : {
1860 5 : if (pField->GetTyp()->Which() == RES_GETREFFLD &&
1861 0 : ( eFieldType == ww::ePAGEREF || eFieldType == ww::eREF ||
1862 0 : eFieldType == ww::eNOTEREF || eFieldType == ww::eFOOTREF ))
1863 1 : bHandleBookmark = true;
1864 : }
1865 :
1866 7 : if ( bHandleBookmark )
1867 : {
1868 : // retrieve reference destination - the name of the bookmark
1869 1 : OUString aLinkStr;
1870 1 : const sal_uInt16 nSubType = pField->GetSubType();
1871 1 : const SwGetRefField& rRField = *(static_cast<const SwGetRefField*>(pField));
1872 1 : if ( nSubType == REF_SETREFATTR ||
1873 : nSubType == REF_BOOKMARK )
1874 : {
1875 1 : const OUString aRefName(rRField.GetSetRefName());
1876 1 : aLinkStr = GetBookmarkName( nSubType, &aRefName, 0 );
1877 : }
1878 0 : else if ( nSubType == REF_FOOTNOTE ||
1879 : nSubType == REF_ENDNOTE )
1880 : {
1881 0 : aLinkStr = GetBookmarkName( nSubType, 0, rRField.GetSeqNo() );
1882 : }
1883 0 : else if ( nSubType == REF_SEQUENCEFLD )
1884 : {
1885 0 : aLinkStr = pField->GetPar2();
1886 : }
1887 : // insert hyperlink character including attributes and data.
1888 1 : InsertSpecialChar( *this, 0x01, &aLinkStr );
1889 : }
1890 : }
1891 12 : if (WRITEFIELD_CMD_END & nMode)
1892 : {
1893 : static const sal_uInt8 aField14[2] = { 0x14, 0xff };
1894 7 : pFieldP->Append( Fc2Cp( Strm().Tell() ), aField14 );
1895 7 : pFieldP->ResultAdded();
1896 7 : InsertSpecialChar( *this, 0x14, 0, bIncludeEmptyPicLocation );
1897 : }
1898 12 : if (WRITEFIELD_END & nMode)
1899 : {
1900 5 : OUString sOut;
1901 5 : if( pField )
1902 4 : sOut = lcl_GetExpandedField(*pField);
1903 : else
1904 1 : sOut = rFieldCmd;
1905 5 : if( !sOut.isEmpty() )
1906 : {
1907 4 : if( bUnicode )
1908 4 : SwWW8Writer::WriteString16(Strm(), sOut, false);
1909 : else
1910 : {
1911 0 : SwWW8Writer::WriteString8(Strm(), sOut, false,
1912 0 : RTL_TEXTENCODING_MS_1252);
1913 : }
1914 :
1915 4 : if (pField)
1916 : {
1917 4 : if (pField->GetTyp()->Which() == RES_INPUTFLD &&
1918 : eFieldType == ww::eFORMTEXT)
1919 : {
1920 : sal_uInt8 aArr[12];
1921 0 : sal_uInt8 *pArr = aArr;
1922 :
1923 0 : if ( bWrtWW8 )
1924 : {
1925 0 : Set_UInt16( pArr, NS_sprm::LN_CPicLocation );
1926 0 : Set_UInt32( pArr, 0x0 );
1927 :
1928 0 : Set_UInt16( pArr, NS_sprm::LN_CFSpec );
1929 0 : Set_UInt8( pArr, 1 );
1930 :
1931 0 : Set_UInt16( pArr, NS_sprm::LN_CFNoProof );
1932 0 : Set_UInt8( pArr, 1 );
1933 : }
1934 : else
1935 : {
1936 0 : Set_UInt8(pArr, 0x68); //sprmCPicLocation
1937 0 : Set_UInt32(pArr, 0x0);
1938 :
1939 0 : Set_UInt8( pArr, 117 ); //sprmCFSpec
1940 0 : Set_UInt8( pArr, 1 );
1941 : }
1942 0 : m_pChpPlc->AppendFkpEntry( Strm().Tell(), static_cast< short >(pArr - aArr), aArr );
1943 : }
1944 : }
1945 5 : }
1946 : }
1947 12 : if (WRITEFIELD_CLOSE & nMode)
1948 : {
1949 7 : sal_uInt8 aField15[2] = { 0x15, 0x80 };
1950 :
1951 7 : if (pField)
1952 : {
1953 4 : if (pField->GetTyp()->Which() == RES_INPUTFLD &&
1954 : eFieldType == ww::eFORMTEXT)
1955 : {
1956 0 : sal_uInt16 nSubType = pField->GetSubType();
1957 :
1958 0 : if (nSubType == REF_SEQUENCEFLD)
1959 0 : aField15[0] |= (0x4 << 5);
1960 : }
1961 : }
1962 :
1963 7 : pFieldP->Append( Fc2Cp( Strm().Tell() ), aField15 );
1964 7 : InsertSpecialChar( *this, 0x15, 0, bIncludeEmptyPicLocation );
1965 : }
1966 12 : }
1967 :
1968 0 : void WW8Export::StartCommentOutput(const OUString& rName)
1969 : {
1970 0 : OUString sStr(FieldString(ww::eQUOTE));
1971 0 : sStr += "[" + rName + "] ";
1972 0 : OutputField(0, ww::eQUOTE, sStr, WRITEFIELD_START | WRITEFIELD_CMD_START);
1973 0 : }
1974 :
1975 0 : void WW8Export::EndCommentOutput(const OUString& rName)
1976 : {
1977 0 : OUString sStr(" [");
1978 0 : sStr += rName + "] ";
1979 : OutputField(0, ww::eQUOTE, sStr, WRITEFIELD_CMD_END | WRITEFIELD_END |
1980 0 : WRITEFIELD_CLOSE);
1981 0 : }
1982 :
1983 0 : sal_uInt16 MSWordExportBase::GetId( const SwTOXType& rTOXType )
1984 : {
1985 : std::vector<const SwTOXType*>::iterator it
1986 0 : = std::find( m_aTOXArr.begin(), m_aTOXArr.end(), &rTOXType );
1987 0 : if ( it != m_aTOXArr.end() )
1988 : {
1989 0 : return it - m_aTOXArr.begin();
1990 : }
1991 0 : m_aTOXArr.push_back( &rTOXType );
1992 0 : return m_aTOXArr.size() - 1;
1993 : }
1994 :
1995 : // return values: 1 - no PageNum,
1996 : // 2 - TabStop before PageNum,
1997 : // 3 - Text before PageNum - rText hold the text
1998 : // 4 - no Text and no TabStop before PageNum
1999 104 : static int lcl_CheckForm( const SwForm& rForm, sal_uInt8 nLvl, OUString& rText )
2000 : {
2001 104 : int nRet = 4;
2002 104 : rText.clear();
2003 :
2004 : // #i21237#
2005 104 : SwFormTokens aPattern = rForm.GetPattern(nLvl);
2006 104 : SwFormTokens::iterator aIt = aPattern.begin();
2007 : FormTokenType eTType;
2008 :
2009 : // #i61362#
2010 104 : if (! aPattern.empty())
2011 : {
2012 103 : bool bPgNumFnd = false;
2013 :
2014 : // #i21237#
2015 602 : while( ++aIt != aPattern.end() && !bPgNumFnd )
2016 : {
2017 396 : eTType = aIt->eTokenType;
2018 :
2019 396 : switch( eTType )
2020 : {
2021 : case TOKEN_PAGE_NUMS:
2022 97 : bPgNumFnd = true;
2023 97 : break;
2024 :
2025 : case TOKEN_TAB_STOP:
2026 102 : nRet = 2;
2027 102 : break;
2028 : case TOKEN_TEXT:
2029 : {
2030 0 : nRet = 3;
2031 0 : sal_Int32 nCount = std::min<sal_Int32>(5, aIt->sText.getLength());
2032 0 : rText = aIt->sText.copy(0, nCount); // #i21237#
2033 0 : break;
2034 : }
2035 : case TOKEN_LINK_START:
2036 : case TOKEN_LINK_END:
2037 58 : break;
2038 :
2039 : default:
2040 139 : nRet = 4;
2041 139 : break;
2042 : }
2043 : }
2044 :
2045 103 : if( !bPgNumFnd )
2046 6 : nRet = 1;
2047 : }
2048 :
2049 104 : return nRet;
2050 : }
2051 :
2052 18 : static bool lcl_IsHyperlinked(const SwForm& rForm, sal_uInt16 nTOXLvl)
2053 : {
2054 18 : bool bRes = false;
2055 84 : for (sal_uInt16 nI = 1; nI < nTOXLvl; ++nI)
2056 : {
2057 : // #i21237#
2058 66 : SwFormTokens aPattern = rForm.GetPattern(nI);
2059 :
2060 66 : if ( !aPattern.empty() )
2061 : {
2062 65 : SwFormTokens::iterator aIt = aPattern.begin();
2063 :
2064 : FormTokenType eTType;
2065 :
2066 : // #i21237#
2067 488 : while ( ++aIt != aPattern.end() )
2068 : {
2069 358 : eTType = aIt->eTokenType;
2070 358 : switch (eTType)
2071 : {
2072 : case TOKEN_LINK_START:
2073 : case TOKEN_LINK_END:
2074 119 : bRes = true;
2075 119 : break;
2076 : default:
2077 : ;
2078 : }
2079 : }
2080 : }
2081 66 : }
2082 18 : return bRes;
2083 : }
2084 :
2085 31 : void AttributeOutputBase::StartTOX( const SwSection& rSect )
2086 : {
2087 31 : if ( const SwTOXBase* pTOX = rSect.GetTOXBase() )
2088 : {
2089 : static const sal_Char sEntryEnd[] = "\" ";
2090 :
2091 31 : ww::eField eCode = ww::eTOC;
2092 31 : OUString sStr = pTOX ->GetMSTOCExpression();
2093 31 : if ( sStr.isEmpty() )
2094 : {
2095 31 : switch (pTOX->GetType())
2096 : {
2097 : case TOX_INDEX:
2098 6 : eCode = ww::eINDEX;
2099 6 : sStr = FieldString(eCode);
2100 :
2101 : {
2102 6 : const SwFormatCol& rCol = static_cast<const SwFormatCol&>( rSect.GetFormat()->GetFormatAttr( RES_COL ) );
2103 6 : const SwColumns& rColumns = rCol.GetColumns();
2104 6 : sal_Int32 nCol = rColumns.size();
2105 :
2106 6 : if ( 0 < nCol )
2107 : {
2108 : // Add a continuous section break
2109 3 : if( GetExport().AddSectionBreaksForTOX() )
2110 : {
2111 3 : sal_uLong nRstLnNum = 0;
2112 3 : SwSection *pParent = rSect.GetParent();
2113 3 : WW8_SepInfo rInfo(&GetExport( ).m_pDoc->GetPageDesc(0),
2114 6 : pParent ? pParent->GetFormat() : NULL, nRstLnNum);
2115 3 : GetExport( ).AttrOutput().SectionBreak( msword::PageBreak, &rInfo );
2116 : }
2117 :
2118 3 : sStr += "\\c \"" + OUString::number( nCol ) + "\"";
2119 : }
2120 : }
2121 :
2122 6 : if (pTOX->GetTOXForm().IsCommaSeparated())
2123 0 : sStr += "\\r ";
2124 :
2125 6 : if (nsSwTOIOptions::TOI_ALPHA_DELIMITTER & pTOX->GetOptions())
2126 1 : sStr += "\\h \"A\" ";
2127 :
2128 6 : if(nsSwTOXElement::TOX_INDEX_ENTRY_TYPE & pTOX->GetCreateType())
2129 : {
2130 1 : sStr += "\\f ";
2131 1 : OUString sName = pTOX->GetEntryTypeName();
2132 1 : if(!sName.isEmpty())
2133 : {
2134 1 : sStr += sName;
2135 1 : sStr += sEntryEnd;
2136 1 : }
2137 : }
2138 :
2139 6 : if (!pTOX->GetTOXForm().IsCommaSeparated())
2140 : {
2141 : // In case of Run-in style no separators are added.
2142 6 : OUString aFillText;
2143 24 : for (sal_uInt8 n = 1; n <= 3; ++n)
2144 : {
2145 18 : OUString aText;
2146 18 : int nRet = ::lcl_CheckForm(pTOX->GetTOXForm(), n, aText);
2147 :
2148 18 : if( 3 == nRet )
2149 0 : aFillText = aText;
2150 18 : else if ((4 == nRet) || (2 == nRet)) //#109414#
2151 12 : aFillText = "\t";
2152 : else
2153 6 : aFillText.clear();
2154 18 : }
2155 6 : sStr += "\\e \"";
2156 6 : sStr += aFillText;
2157 6 : sStr += sEntryEnd;
2158 : }
2159 6 : break;
2160 :
2161 : case TOX_ILLUSTRATIONS:
2162 : case TOX_OBJECTS:
2163 : case TOX_TABLES:
2164 2 : if (!pTOX->IsFromObjectNames())
2165 : {
2166 2 : sStr = FieldString(eCode);
2167 :
2168 2 : sStr += "\\c ";
2169 2 : OUString seqName = pTOX->GetSequenceName();
2170 2 : if(!seqName.isEmpty())
2171 : {
2172 1 : sStr += "\"";
2173 1 : sStr += seqName;
2174 1 : sStr += sEntryEnd;
2175 : }
2176 4 : OUString aText;
2177 2 : int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(), 1, aText );
2178 2 : if (1 == nRet)
2179 0 : sStr += "\\n ";
2180 2 : else if( 3 == nRet || 4 == nRet )
2181 : {
2182 0 : sStr += "\\p \"";
2183 0 : sStr += aText;
2184 0 : sStr += sEntryEnd;
2185 2 : }
2186 : }
2187 2 : break;
2188 :
2189 : case TOX_AUTHORITIES:
2190 5 : eCode = ww::eBIBLIOGRPAHY;
2191 5 : sStr = FieldString(eCode);
2192 5 : break;
2193 : // case TOX_USER:
2194 : // case TOX_CONTENT:
2195 : default:
2196 : {
2197 18 : sStr = FieldString(eCode);
2198 :
2199 18 : OUString sTOption;
2200 18 : sal_uInt16 n, nTOXLvl = pTOX->GetLevel();
2201 18 : if( !nTOXLvl )
2202 0 : ++nTOXLvl;
2203 :
2204 18 : if(nsSwTOXElement::TOX_TABLEADER & pTOX->GetCreateType())
2205 : {
2206 13 : sStr +="\\z " ;
2207 13 : GetExport( ).m_bHideTabLeaderAndPageNumbers = true ;
2208 : }
2209 18 : if(nsSwTOXElement::TOX_TAB_IN_TOC & pTOX->GetCreateType())
2210 : {
2211 1 : sStr +="\\w " ;
2212 1 : GetExport( ).m_bTabInTOC = true ;
2213 : }
2214 18 : if(nsSwTOXElement::TOX_NEWLINE & pTOX->GetCreateType())
2215 : {
2216 1 : sStr +="\\x " ;
2217 : }
2218 18 : if( nsSwTOXElement::TOX_MARK & pTOX->GetCreateType() )
2219 : {
2220 6 : sStr += "\\f ";
2221 :
2222 6 : if( TOX_USER == pTOX->GetType() )
2223 : {
2224 0 : sStr += "\"";
2225 0 : sStr += OUString((sal_Char)( 'A' + GetExport( ).GetId( *pTOX->GetTOXType() ) ));
2226 0 : sStr += sEntryEnd;
2227 : }
2228 : }
2229 18 : if(nsSwTOXElement::TOX_BOOKMARK & pTOX->GetCreateType())
2230 : {
2231 1 : sStr += "\\b ";
2232 1 : OUString bName = pTOX->GetBookmarkName();
2233 1 : sStr += bName;
2234 1 : sStr += sEntryEnd;
2235 : }
2236 :
2237 18 : if( nsSwTOXElement::TOX_OUTLINELEVEL & pTOX->GetCreateType() )
2238 : {
2239 : // Take the TOC value of the max level to evaluate to as
2240 : // the starting point for the \o flag, but reduce it to the
2241 : // value of the highest outline level filled by a *standard*
2242 : // Heading 1 - 9 style because \o "Builds a table of
2243 : // contents from paragraphs formatted with built-in heading
2244 : // styles". And afterward fill in any outline styles left
2245 : // uncovered by that range to the \t flag
2246 :
2247 : // i.e. for
2248 : // Heading 1
2249 : // Heading 2
2250 : // custom-style
2251 : // Heading 4
2252 : // output
2253 : // \o 1-2 \tcustom-style,3,Heading 3,4
2254 :
2255 : // Search over all the outline styles used and figure out
2256 : // what is the minimum outline level (if any) filled by a
2257 : // non-standard style for that level, i.e. ignore headline
2258 : // styles 1-9 and find the lowest valid outline level
2259 17 : sal_uInt8 nPosOfLowestNonStandardLvl = MAXLEVEL;
2260 17 : const SwTextFormatColls& rColls = *GetExport().m_pDoc->GetTextFormatColls();
2261 612 : for( n = rColls.size(); n; )
2262 : {
2263 578 : const SwTextFormatColl* pColl = rColls[ --n ];
2264 578 : sal_uInt16 nPoolId = pColl->GetPoolFormatId();
2265 578 : if (
2266 : //Is a Non-Standard Outline Style
2267 1034 : (RES_POOLCOLL_HEADLINE1 > nPoolId || RES_POOLCOLL_HEADLINE9 < nPoolId) &&
2268 : //Has a valid outline level
2269 1097 : (pColl->IsAssignedToListLevelOfOutlineStyle()) &&
2270 : // Is less than the lowest known non-standard level
2271 3 : (pColl->GetAssignedOutlineStyleLevel() < nPosOfLowestNonStandardLvl)
2272 : )
2273 : {
2274 3 : nPosOfLowestNonStandardLvl = ::sal::static_int_cast<sal_uInt8>(pColl->GetAssignedOutlineStyleLevel());
2275 : }
2276 : }
2277 :
2278 17 : sal_uInt8 nMaxMSAutoEvaluate = nPosOfLowestNonStandardLvl < nTOXLvl ? nPosOfLowestNonStandardLvl : (sal_uInt8)nTOXLvl;
2279 :
2280 : //output \o 1-X where X is the highest normal outline style to be included in the toc
2281 17 : if ( nMaxMSAutoEvaluate )
2282 : {
2283 17 : if (nMaxMSAutoEvaluate > WW8ListManager::nMaxLevel)
2284 1 : nMaxMSAutoEvaluate = WW8ListManager::nMaxLevel;
2285 :
2286 17 : sStr += "\\o \"1-";
2287 17 : sStr += OUString::number(nMaxMSAutoEvaluate);
2288 17 : sStr += sEntryEnd;
2289 : }
2290 :
2291 : //collect up any other styles in the writer TOC which will
2292 : //not already appear in the MS TOC and place then into the
2293 : //\t option
2294 17 : if( nMaxMSAutoEvaluate < nTOXLvl )
2295 : {
2296 : // collect this templates into the \t otion
2297 58 : for( n = rColls.size(); n;)
2298 : {
2299 54 : const SwTextFormatColl* pColl = rColls[ --n ];
2300 54 : if (!pColl->IsAssignedToListLevelOfOutlineStyle())
2301 46 : continue;
2302 8 : sal_uInt8 nTestLvl = ::sal::static_int_cast<sal_uInt8>(pColl->GetAssignedOutlineStyleLevel());
2303 8 : if (nTestLvl < nTOXLvl && nTestLvl >= nMaxMSAutoEvaluate)
2304 : {
2305 8 : if (!sTOption.isEmpty())
2306 7 : sTOption += ",";
2307 8 : sTOption += pColl->GetName() + "," + OUString::number( nTestLvl + 1 );
2308 : }
2309 : }
2310 : }
2311 : }
2312 :
2313 18 : if( nsSwTOXElement::TOX_PARAGRAPH_OUTLINE_LEVEL & pTOX->GetCreateType() )
2314 : {
2315 11 : sStr +="\\u " ;
2316 : }
2317 :
2318 18 : if( nsSwTOXElement::TOX_TEMPLATE & pTOX->GetCreateType() )
2319 : {
2320 : // #i99641# - Consider additional styles regardless of TOX-outlinelevel
2321 11 : for( n = 0; n < MAXLEVEL; ++n )
2322 : {
2323 10 : const OUString& rStyles = pTOX->GetStyleNames( n );
2324 10 : if( !rStyles.isEmpty() )
2325 : {
2326 1 : sal_Int32 nPos = 0;
2327 1 : OUString sLvl = OUString(',');
2328 1 : sLvl += OUString::number( n + 1 );
2329 1 : do {
2330 1 : OUString sStyle( rStyles.getToken( 0, TOX_STYLE_DELIMITER, nPos ));
2331 1 : if( !sStyle.isEmpty() )
2332 : {
2333 1 : SwTextFormatColl* pColl = GetExport().m_pDoc->FindTextFormatCollByName(sStyle);
2334 1 : if (pColl)
2335 : {
2336 1 : if (!pColl->IsAssignedToListLevelOfOutlineStyle() || pColl->GetAssignedOutlineStyleLevel() < nTOXLvl)
2337 : {
2338 1 : if( !sTOption.isEmpty() )
2339 0 : sTOption += ",";
2340 1 : sTOption += sStyle + sLvl;
2341 : }
2342 : }
2343 1 : }
2344 2 : } while( -1 != nPos );
2345 : }
2346 10 : }
2347 : }
2348 :
2349 : // No 'else' branch; why the below snippet is a block I have no idea.
2350 : {
2351 18 : OUString aFillText;
2352 18 : sal_uInt8 nNoPgStt = MAXLEVEL, nNoPgEnd = MAXLEVEL;
2353 18 : bool bFirstFillText = true, bOnlyText = true;
2354 102 : for( n = 0; n < nTOXLvl; ++n )
2355 : {
2356 84 : OUString aText;
2357 84 : int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(),
2358 168 : static_cast< sal_uInt8 >(n+1), aText );
2359 84 : if( 1 == nRet )
2360 : {
2361 0 : bOnlyText = false;
2362 0 : if( MAXLEVEL == nNoPgStt )
2363 0 : nNoPgStt = static_cast< sal_uInt8 >(n+1);
2364 : }
2365 : else
2366 : {
2367 84 : if( MAXLEVEL != nNoPgStt &&
2368 : MAXLEVEL == nNoPgEnd )
2369 0 : nNoPgEnd = sal_uInt8(n);
2370 :
2371 84 : bOnlyText = bOnlyText && 3 == nRet;
2372 84 : if( 3 == nRet || 4 == nRet )
2373 : {
2374 1 : if( bFirstFillText )
2375 1 : aFillText = aText;
2376 0 : else if( aFillText != aText )
2377 0 : aFillText.clear();
2378 1 : bFirstFillText = false;
2379 : }
2380 : }
2381 84 : }
2382 18 : if( MAXLEVEL != nNoPgStt )
2383 : {
2384 0 : if (WW8ListManager::nMaxLevel < nNoPgEnd)
2385 0 : nNoPgEnd = WW8ListManager::nMaxLevel;
2386 0 : sStr += "\\n ";
2387 0 : sStr += OUString::number( nNoPgStt );
2388 0 : sStr += "-";
2389 0 : sStr += OUString::number( nNoPgEnd );
2390 0 : sStr += " ";
2391 : }
2392 18 : if( bOnlyText )
2393 : {
2394 0 : sStr += "\\p \"";
2395 0 : sStr += aFillText;
2396 0 : sStr += sEntryEnd;
2397 18 : }
2398 : }
2399 :
2400 18 : if( !sTOption.isEmpty() )
2401 : {
2402 2 : sStr += "\\t \"";
2403 2 : sStr += sTOption;
2404 2 : sStr += sEntryEnd;
2405 : }
2406 :
2407 18 : if (lcl_IsHyperlinked(pTOX->GetTOXForm(), nTOXLvl))
2408 16 : sStr += "\\h";
2409 18 : break;
2410 : }
2411 : }
2412 : }
2413 :
2414 31 : if (!sStr.isEmpty())
2415 : {
2416 31 : GetExport( ).m_bInWriteTOX = true;
2417 31 : GetExport( ).OutputField( 0, eCode, sStr, WRITEFIELD_START | WRITEFIELD_CMD_START |
2418 31 : WRITEFIELD_CMD_END );
2419 31 : }
2420 : }
2421 :
2422 31 : GetExport( ).m_bStartTOX = false;
2423 31 : }
2424 :
2425 31 : void AttributeOutputBase::EndTOX( const SwSection& rSect,bool bCareEnd )
2426 : {
2427 31 : const SwTOXBase* pTOX = rSect.GetTOXBase();
2428 31 : if ( pTOX )
2429 : {
2430 31 : ww::eField eCode = TOX_INDEX == pTOX->GetType() ? ww::eINDEX : ww::eTOC;
2431 31 : GetExport( ).OutputField( 0, eCode, OUString(), WRITEFIELD_CLOSE );
2432 :
2433 31 : if ( pTOX->GetType() == TOX_INDEX && GetExport().AddSectionBreaksForTOX() )
2434 : {
2435 6 : const SwFormatCol& rCol = static_cast<const SwFormatCol&>( rSect.GetFormat()->GetFormatAttr( RES_COL ) );
2436 6 : const SwColumns& rColumns = rCol.GetColumns();
2437 6 : sal_Int32 nCol = rColumns.size();
2438 :
2439 6 : if ( 0 < nCol )
2440 : {
2441 3 : sal_uLong nRstLnNum = 0;
2442 3 : WW8_SepInfo rInfo( &GetExport( ).m_pDoc->GetPageDesc( 0 ), rSect.GetFormat() , nRstLnNum );
2443 3 : GetExport( ).AttrOutput().SectionBreak( msword::PageBreak, &rInfo );
2444 : }
2445 : }
2446 : }
2447 31 : GetExport( ).m_bInWriteTOX = false;
2448 31 : if (bCareEnd)
2449 1 : OnTOXEnding();
2450 31 : }
2451 :
2452 8 : bool MSWordExportBase::GetNumberFormat(const SwField& rField, OUString& rStr)
2453 : {
2454 : // Returns a date or time format string by using the US NfKeywordTable
2455 8 : bool bHasFormat = false;
2456 8 : SvNumberFormatter* pNFormatr = m_pDoc->GetNumberFormatter();
2457 8 : sal_uInt32 nFormatIdx = rField.GetFormat();
2458 8 : const SvNumberformat* pNumFormat = pNFormatr->GetEntry( nFormatIdx );
2459 8 : if( pNumFormat )
2460 : {
2461 8 : sal_uInt16 nLng = rField.GetLanguage();
2462 : LocaleDataWrapper aLocDat(pNFormatr->GetComponentContext(),
2463 8 : LanguageTag(nLng));
2464 :
2465 8 : OUString sFormat(pNumFormat->GetMappedFormatstring(GetNfKeywordTable(),
2466 16 : aLocDat));
2467 :
2468 8 : if (!sFormat.isEmpty())
2469 : {
2470 7 : sw::ms::SwapQuotesInField(sFormat);
2471 :
2472 7 : rStr = "\\@\"" + sFormat + "\" " ;
2473 7 : bHasFormat = true;
2474 8 : }
2475 : }
2476 8 : return bHasFormat;
2477 : }
2478 :
2479 115 : void AttributeOutputBase::GetNumberPara( OUString& rStr, const SwField& rField )
2480 : {
2481 115 : switch(rField.GetFormat())
2482 : {
2483 : case SVX_NUM_CHARS_UPPER_LETTER:
2484 : case SVX_NUM_CHARS_UPPER_LETTER_N:
2485 0 : rStr += "\\* ALPHABETIC ";
2486 0 : break;
2487 : case SVX_NUM_CHARS_LOWER_LETTER:
2488 : case SVX_NUM_CHARS_LOWER_LETTER_N:
2489 0 : rStr += "\\* alphabetic ";
2490 0 : break;
2491 : case SVX_NUM_ROMAN_UPPER:
2492 1 : rStr += "\\* ROMAN ";
2493 1 : break;
2494 : case SVX_NUM_ROMAN_LOWER:
2495 0 : rStr += "\\* roman ";
2496 0 : break;
2497 : default:
2498 : OSL_ENSURE(rField.GetFormat() == SVX_NUM_ARABIC,
2499 : "Unknown numbering type exported as default of Arabic\n");
2500 : //fallthrough
2501 : case SVX_NUM_ARABIC:
2502 23 : rStr += "\\* ARABIC ";
2503 23 : break;
2504 : case SVX_NUM_PAGEDESC:
2505 : //Nothing, use word's default
2506 91 : break;
2507 : }
2508 115 : }
2509 :
2510 24 : void WW8Export::WritePostItBegin( ww::bytes* pOut )
2511 : {
2512 : sal_uInt8 aArr[ 3 ];
2513 24 : sal_uInt8* pArr = aArr;
2514 :
2515 : // sprmCFSpec true
2516 24 : if( bWrtWW8 )
2517 24 : Set_UInt16( pArr, NS_sprm::LN_CFSpec );
2518 : else
2519 0 : Set_UInt8( pArr, 117 ); //sprmCFSpec
2520 24 : Set_UInt8( pArr, 1 );
2521 :
2522 24 : m_pChpPlc->AppendFkpEntry( Strm().Tell() );
2523 24 : WriteChar( 0x05 ); // Annotation reference
2524 :
2525 24 : if( pOut )
2526 12 : pOut->insert( pOut->end(), aArr, pArr );
2527 : else
2528 12 : m_pChpPlc->AppendFkpEntry( Strm().Tell(), static_cast< short >(pArr - aArr), aArr );
2529 24 : }
2530 :
2531 329 : OUString FieldString(ww::eField eIndex)
2532 : {
2533 329 : if (const char *pField = ww::GetEnglishFieldName(eIndex))
2534 329 : return " " + OUString::createFromAscii(pField) + " ";
2535 0 : return OUString(" ");
2536 : }
2537 :
2538 0 : void WW8AttributeOutput::HiddenField( const SwField& rField )
2539 : {
2540 0 : OUString sExpand(rField.GetPar2());
2541 :
2542 : //replace LF 0x0A with VT 0x0B
2543 0 : sExpand = sExpand.replace(0x0A, 0x0B);
2544 0 : m_rWW8Export.m_pChpPlc->AppendFkpEntry(m_rWW8Export.Strm().Tell());
2545 0 : if (m_rWW8Export.IsUnicode())
2546 : {
2547 0 : SwWW8Writer::WriteString16(m_rWW8Export.Strm(), sExpand, false);
2548 : static sal_uInt8 aArr[] =
2549 : {
2550 : 0x3C, 0x08, 0x1
2551 : };
2552 0 : m_rWW8Export.m_pChpPlc->AppendFkpEntry(m_rWW8Export.Strm().Tell(), sizeof(aArr), aArr);
2553 : }
2554 : else
2555 : {
2556 0 : SwWW8Writer::WriteString8(m_rWW8Export.Strm(), sExpand, false,
2557 0 : RTL_TEXTENCODING_MS_1252);
2558 : static sal_uInt8 aArr[] =
2559 : {
2560 : 92, 0x1
2561 : };
2562 0 : m_rWW8Export.m_pChpPlc->AppendFkpEntry(m_rWW8Export.Strm().Tell(), sizeof(aArr), aArr);
2563 0 : }
2564 0 : }
2565 :
2566 0 : void WW8AttributeOutput::SetField( const SwField& rField, ww::eField eType, const OUString& rCmd )
2567 : {
2568 0 : const SwSetExpField* pSet = static_cast<const SwSetExpField*>(&rField);
2569 0 : const OUString &rVar = pSet->GetPar2();
2570 :
2571 0 : sal_uLong nFrom = m_rWW8Export.Fc2Cp(m_rWW8Export.Strm().Tell());
2572 :
2573 0 : GetExport().OutputField(&rField, eType, rCmd, WRITEFIELD_START |
2574 0 : WRITEFIELD_CMD_START | WRITEFIELD_CMD_END);
2575 :
2576 : /*
2577 : Is there a bookmark at the start position of this field, if so
2578 : move it to the 0x14 of the result of the field. This is what word
2579 : does. MoveFieldMarks moves any bookmarks at this position to
2580 : the beginning of the field result, and marks the bookmark as a
2581 : fieldbookmark which is to be ended before the field end mark
2582 : instead of after it like a normal bookmark.
2583 : */
2584 0 : m_rWW8Export.MoveFieldMarks(nFrom,m_rWW8Export.Fc2Cp(m_rWW8Export.Strm().Tell()));
2585 :
2586 0 : if (!rVar.isEmpty())
2587 : {
2588 0 : if (m_rWW8Export.IsUnicode())
2589 0 : SwWW8Writer::WriteString16(m_rWW8Export.Strm(), rVar, false);
2590 : else
2591 : {
2592 0 : SwWW8Writer::WriteString8(m_rWW8Export.Strm(), rVar, false,
2593 0 : RTL_TEXTENCODING_MS_1252);
2594 : }
2595 : }
2596 0 : GetExport().OutputField(&rField, eType, rCmd, WRITEFIELD_CLOSE);
2597 0 : }
2598 :
2599 12 : void WW8AttributeOutput::PostitField( const SwField* pField )
2600 : {
2601 12 : const SwPostItField *pPField = static_cast<const SwPostItField*>(pField);
2602 12 : m_rWW8Export.m_pAtn->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), pPField );
2603 12 : m_rWW8Export.WritePostItBegin( m_rWW8Export.pO );
2604 12 : }
2605 :
2606 0 : bool WW8AttributeOutput::DropdownField( const SwField* pField )
2607 : {
2608 0 : bool bExpand = true;
2609 0 : if ( m_rWW8Export.bWrtWW8 )
2610 : {
2611 0 : const SwDropDownField& rField2 = *static_cast<const SwDropDownField*>(pField);
2612 : uno::Sequence<OUString> aItems =
2613 0 : rField2.GetItemSequence();
2614 0 : GetExport().DoComboBox(rField2.GetName(),
2615 0 : rField2.GetHelp(),
2616 0 : rField2.GetToolTip(),
2617 0 : rField2.GetSelectedItem(), aItems);
2618 0 : bExpand = false;
2619 : }
2620 0 : return bExpand;
2621 : }
2622 :
2623 0 : bool WW8AttributeOutput::PlaceholderField( const SwField* )
2624 : {
2625 0 : return true; // expand to text?
2626 : }
2627 :
2628 0 : void WW8AttributeOutput::RefField( const SwField &rField, const OUString &rRef)
2629 : {
2630 0 : OUString sStr( FieldString( ww::eREF ) );
2631 0 : sStr += "\"" + rRef + "\" ";
2632 : m_rWW8Export.OutputField( &rField, ww::eREF, sStr, WRITEFIELD_START |
2633 0 : WRITEFIELD_CMD_START | WRITEFIELD_CMD_END );
2634 0 : OUString sVar = lcl_GetExpandedField( rField );
2635 0 : if ( !sVar.isEmpty() )
2636 : {
2637 0 : if ( m_rWW8Export.IsUnicode() )
2638 0 : SwWW8Writer::WriteString16( m_rWW8Export.Strm(), sVar, false );
2639 : else
2640 : {
2641 0 : SwWW8Writer::WriteString8( m_rWW8Export.Strm(), sVar, false,
2642 0 : RTL_TEXTENCODING_MS_1252 );
2643 : }
2644 : }
2645 0 : m_rWW8Export.OutputField( &rField, ww::eREF, sStr, WRITEFIELD_CLOSE );
2646 0 : }
2647 :
2648 0 : void WW8AttributeOutput::WriteExpand( const SwField* pField )
2649 : {
2650 0 : OUString sExpand( lcl_GetExpandedField( *pField ) );
2651 0 : if ( m_rWW8Export.IsUnicode() )
2652 0 : SwWW8Writer::WriteString16( m_rWW8Export.Strm(), sExpand, false );
2653 : else
2654 : {
2655 0 : SwWW8Writer::WriteString8( m_rWW8Export.Strm(), sExpand, false,
2656 0 : RTL_TEXTENCODING_MS_1252 );
2657 0 : }
2658 0 : }
2659 :
2660 216 : void AttributeOutputBase::TextField( const SwFormatField& rField )
2661 : {
2662 216 : const SwField* pField = rField.GetField();
2663 216 : bool bWriteExpand = false;
2664 216 : const sal_uInt16 nSubType = pField->GetSubType();
2665 :
2666 216 : switch (pField->GetTyp()->Which())
2667 : {
2668 : case RES_GETEXPFLD:
2669 0 : if (nSubType == nsSwGetSetExpType::GSE_STRING)
2670 : {
2671 0 : const SwGetExpField *pGet = static_cast<const SwGetExpField*>(pField);
2672 0 : RefField( *pGet, pGet->GetFormula() );
2673 : }
2674 : else
2675 0 : bWriteExpand = true;
2676 0 : break;
2677 : case RES_SETEXPFLD:
2678 22 : if (nsSwGetSetExpType::GSE_SEQ == nSubType)
2679 : {
2680 21 : OUString sStr;
2681 21 : if (GetExport().FieldsQuoted())
2682 21 : sStr = FieldString(ww::eSEQ) + pField->GetTyp()->GetName() + " ";
2683 : else
2684 0 : sStr = FieldString(ww::eSEQ) + "\"" + pField->GetTyp()->GetName() +"\" ";
2685 21 : GetNumberPara( sStr, *pField );
2686 21 : GetExport().OutputField(pField, ww::eSEQ, sStr);
2687 : }
2688 1 : else if (nSubType & nsSwGetSetExpType::GSE_STRING)
2689 : {
2690 1 : bool bShowAsWell = false;
2691 : ww::eField eFieldNo;
2692 1 : const SwSetExpField *pSet = static_cast<const SwSetExpField*>(pField);
2693 1 : const OUString sVar = pSet->GetPar2();
2694 2 : OUString sStr;
2695 1 : if (pSet->GetInputFlag())
2696 : {
2697 4 : sStr = FieldString(ww::eASK) + "\""
2698 4 : + pSet->GetPar1() + "\" "
2699 4 : + pSet->GetPromptText() + " \\d "
2700 3 : + sVar;
2701 1 : eFieldNo = ww::eASK;
2702 : }
2703 : else
2704 : {
2705 0 : sStr = FieldString(ww::eSET)
2706 0 : + pSet->GetPar1() + " \""
2707 0 : + sVar + "\" ";
2708 0 : eFieldNo = ww::eSET;
2709 0 : bShowAsWell = (nSubType & nsSwExtendedSubType::SUB_INVISIBLE) == 0;
2710 : }
2711 :
2712 1 : SetField( *pField, eFieldNo, sStr );
2713 :
2714 1 : if (bShowAsWell)
2715 1 : RefField( *pSet, pSet->GetPar1() );
2716 : }
2717 : else
2718 0 : bWriteExpand = true;
2719 22 : break;
2720 : case RES_PAGENUMBERFLD:
2721 : {
2722 83 : OUString sStr = FieldString(ww::ePAGE);
2723 83 : GetNumberPara(sStr, *pField);
2724 83 : GetExport().OutputField(pField, ww::ePAGE, sStr);
2725 : }
2726 83 : break;
2727 : case RES_FILENAMEFLD:
2728 : {
2729 9 : OUString sStr = FieldString(ww::eFILENAME);
2730 9 : if (pField->GetFormat() == FF_PATHNAME)
2731 2 : sStr += "\\p ";
2732 9 : GetExport().OutputField(pField, ww::eFILENAME, sStr);
2733 : }
2734 9 : break;
2735 : case RES_DBNAMEFLD:
2736 : {
2737 0 : SwDBData aData = GetExport().m_pDoc->GetDBData();
2738 : const OUString sStr = FieldString(ww::eDATABASE)
2739 0 : + aData.sDataSource
2740 0 : + OUString(DB_DELIM)
2741 0 : + aData.sCommand;
2742 0 : GetExport().OutputField(pField, ww::eDATABASE, sStr);
2743 : }
2744 0 : break;
2745 : case RES_AUTHORFLD:
2746 : {
2747 : ww::eField eField =
2748 1 : (AF_SHORTCUT & pField->GetFormat() ? ww::eUSERINITIALS : ww::eUSERNAME);
2749 1 : GetExport().OutputField(pField, eField, FieldString(eField));
2750 : }
2751 1 : break;
2752 : case RES_TEMPLNAMEFLD:
2753 0 : GetExport().OutputField(pField, ww::eTEMPLATE, FieldString(ww::eTEMPLATE));
2754 0 : break;
2755 : case RES_DOCINFOFLD: // Last printed, last edited,...
2756 11 : if( DI_SUB_FIXED & nSubType )
2757 0 : bWriteExpand = true;
2758 : else
2759 : {
2760 11 : OUString sStr;
2761 11 : ww::eField eField(ww::eNONE);
2762 11 : switch (0xff & nSubType)
2763 : {
2764 : case DI_TITEL:
2765 6 : eField = ww::eTITLE;
2766 6 : break;
2767 : case DI_THEMA:
2768 0 : eField = ww::eSUBJECT;
2769 0 : break;
2770 : case DI_KEYS:
2771 0 : eField = ww::eKEYWORDS;
2772 0 : break;
2773 : case DI_COMMENT:
2774 0 : eField = ww::eCOMMENTS;
2775 0 : break;
2776 : case DI_DOCNO:
2777 1 : eField = ww::eREVNUM;
2778 1 : break;
2779 : case DI_CREATE:
2780 0 : if (DI_SUB_AUTHOR == (nSubType & DI_SUB_MASK))
2781 0 : eField = ww::eAUTHOR;
2782 0 : else if (GetExport().GetNumberFormat(*pField, sStr))
2783 0 : eField = ww::eCREATEDATE;
2784 0 : break;
2785 :
2786 : case DI_CHANGE:
2787 3 : if (DI_SUB_AUTHOR == (nSubType & DI_SUB_MASK))
2788 1 : eField = ww::eLASTSAVEDBY;
2789 2 : else if (GetExport().GetNumberFormat(*pField, sStr))
2790 2 : eField = ww::eSAVEDATE;
2791 3 : break;
2792 :
2793 : case DI_PRINT:
2794 0 : if (DI_SUB_AUTHOR != (nSubType & DI_SUB_MASK) &&
2795 0 : GetExport().GetNumberFormat(*pField, sStr))
2796 0 : eField = ww::ePRINTDATE;
2797 0 : break;
2798 : case DI_EDIT:
2799 2 : if( DI_SUB_AUTHOR != (nSubType & DI_SUB_MASK ) &&
2800 1 : GetExport().GetNumberFormat( *pField, sStr ))
2801 0 : eField = ww::eSAVEDATE;
2802 : else
2803 1 : eField = ww::eEDITTIME;
2804 1 : break;
2805 : case DI_CUSTOM:
2806 0 : eField = ww::eDOCPROPERTY;
2807 : {
2808 0 : OUString sQuotes('\"');
2809 : const SwDocInfoField * pDocInfoField =
2810 0 : dynamic_cast<const SwDocInfoField *> (pField);
2811 :
2812 0 : if (pDocInfoField != NULL)
2813 : {
2814 0 : OUString sFieldname = pDocInfoField->GetFieldName();
2815 0 : sal_Int32 nIndex = sFieldname.indexOf(':');
2816 :
2817 0 : if (nIndex != sFieldname.getLength())
2818 0 : sFieldname = sFieldname.copy(nIndex + 1);
2819 :
2820 0 : sStr = sQuotes + sFieldname + sQuotes;
2821 0 : }
2822 : }
2823 0 : break;
2824 : default:
2825 0 : break;
2826 : }
2827 :
2828 11 : if (eField != ww::eNONE)
2829 : {
2830 11 : GetExport().OutputField(pField, eField, FieldString(eField) + sStr);
2831 : }
2832 : else
2833 0 : bWriteExpand = true;
2834 : }
2835 11 : break;
2836 : case RES_DATETIMEFLD:
2837 : {
2838 5 : OUString sStr;
2839 5 : if (!GetExport().GetNumberFormat(*pField, sStr))
2840 0 : bWriteExpand = true;
2841 : else
2842 : {
2843 5 : ww::eField eField = (DATEFLD & nSubType) ? ww::eDATE : ww::eTIME;
2844 5 : GetExport().OutputField(pField, eField, FieldString(eField) + sStr);
2845 5 : }
2846 : }
2847 5 : break;
2848 : case RES_DOCSTATFLD:
2849 : {
2850 11 : ww::eField eField = ww::eNONE;
2851 :
2852 11 : switch (nSubType)
2853 : {
2854 : case DS_PAGE:
2855 11 : eField = ww::eNUMPAGE;
2856 11 : break;
2857 : case DS_WORD:
2858 0 : eField = ww::eNUMWORDS;
2859 0 : break;
2860 : case DS_CHAR:
2861 0 : eField = ww::eNUMCHARS;
2862 0 : break;
2863 : }
2864 :
2865 11 : if (eField != ww::eNONE)
2866 : {
2867 11 : OUString sStr = FieldString(eField);
2868 11 : GetNumberPara(sStr, *pField);
2869 11 : GetExport().OutputField(pField, eField, sStr);
2870 : }
2871 : else
2872 0 : bWriteExpand = true;
2873 : }
2874 11 : break;
2875 : case RES_EXTUSERFLD:
2876 : {
2877 6 : ww::eField eField = ww::eNONE;
2878 6 : switch (0xFF & nSubType)
2879 : {
2880 : case EU_FIRSTNAME:
2881 : case EU_NAME:
2882 0 : eField = ww::eUSERNAME;
2883 0 : break;
2884 : case EU_SHORTCUT:
2885 0 : eField = ww::eUSERINITIALS;
2886 0 : break;
2887 : case EU_STREET:
2888 : case EU_COUNTRY:
2889 : case EU_ZIP:
2890 : case EU_CITY:
2891 3 : eField = ww::eUSERADDRESS;
2892 3 : break;
2893 : }
2894 :
2895 6 : if (eField != ww::eNONE)
2896 : {
2897 3 : GetExport().OutputField(pField, eField, FieldString(eField));
2898 : }
2899 : else
2900 3 : bWriteExpand = true;
2901 : }
2902 6 : break;
2903 : case RES_AUTHORITY:
2904 : {
2905 7 : OUString sRet(pField->ExpandCitation(AUTH_FIELD_IDENTIFIER));
2906 7 : GetExport().OutputField( pField, ww::eCITATION, sRet );
2907 : }
2908 7 : break;
2909 : case RES_POSTITFLD:
2910 : //Sadly only possible for word in main document text
2911 25 : if (GetExport().m_nTextTyp == TXT_MAINTEXT)
2912 : {
2913 25 : PostitField( pField );
2914 : }
2915 25 : break;
2916 : case RES_INPUTFLD:
2917 : {
2918 0 : const SwInputField * pInputField = dynamic_cast<const SwInputField *>(pField);
2919 :
2920 0 : if (pInputField && pInputField->isFormField())
2921 0 : GetExport().DoFormText(pInputField);
2922 : else
2923 : {
2924 0 : const OUString sStr = FieldString(ww::eFILLIN) + "\""
2925 0 : + pField->GetPar2() + "\"";
2926 :
2927 0 : GetExport().OutputField(pField, ww::eFILLIN, sStr);
2928 : }
2929 : }
2930 0 : break;
2931 : case RES_GETREFFLD:
2932 : {
2933 7 : ww::eField eField = ww::eNONE;
2934 7 : OUString sStr;
2935 7 : const SwGetRefField& rRField = *static_cast<const SwGetRefField*>(pField);
2936 7 : switch (nSubType)
2937 : {
2938 : case REF_SETREFATTR:
2939 : case REF_BOOKMARK:
2940 5 : switch (pField->GetFormat())
2941 : {
2942 : case REF_PAGE_PGDESC:
2943 : case REF_PAGE:
2944 2 : eField = ww::ePAGEREF;
2945 2 : break;
2946 : default:
2947 3 : eField = ww::eREF;
2948 3 : break;
2949 : }
2950 : {
2951 5 : const OUString aRefName(rRField.GetSetRefName());
2952 10 : sStr = FieldString(eField)
2953 15 : + MSWordExportBase::GetBookmarkName(nSubType, &aRefName, 0);
2954 : }
2955 5 : switch (pField->GetFormat())
2956 : {
2957 : case REF_NUMBER:
2958 0 : sStr += " \\r";
2959 0 : break;
2960 : case REF_NUMBER_NO_CONTEXT:
2961 0 : sStr += " \\n";
2962 0 : break;
2963 : case REF_NUMBER_FULL_CONTEXT:
2964 0 : sStr += " \\w";
2965 0 : break;
2966 : }
2967 5 : break;
2968 : case REF_FOOTNOTE:
2969 : case REF_ENDNOTE:
2970 0 : switch (pField->GetFormat())
2971 : {
2972 : case REF_PAGE_PGDESC:
2973 : case REF_PAGE:
2974 0 : eField = ww::ePAGEREF;
2975 0 : break;
2976 : case REF_UPDOWN:
2977 0 : eField = ww::eREF;
2978 0 : break;
2979 : default:
2980 : eField =
2981 0 : REF_ENDNOTE == nSubType ? ww::eNOTEREF : ww::eFOOTREF;
2982 0 : break;
2983 : }
2984 0 : sStr = FieldString(eField)
2985 0 : + MSWordExportBase::GetBookmarkName(nSubType, 0, rRField.GetSeqNo());
2986 0 : break;
2987 : }
2988 :
2989 7 : if (eField != ww::eNONE)
2990 : {
2991 5 : switch (pField->GetFormat())
2992 : {
2993 : case REF_UPDOWN:
2994 1 : sStr += " \\p \\h "; // with hyperlink
2995 1 : break;
2996 : case REF_CHAPTER:
2997 1 : sStr += " \\n \\h "; // with hyperlink
2998 1 : break;
2999 : default:
3000 3 : sStr += " \\h "; // insert hyperlink
3001 3 : break;
3002 : }
3003 5 : GetExport().OutputField(pField, eField, sStr);
3004 : }
3005 : else
3006 2 : bWriteExpand = true;
3007 : }
3008 7 : break;
3009 : case RES_COMBINED_CHARS:
3010 : {
3011 : /*
3012 : We need a font size to fill in the defaults, if these are overridden
3013 : (as they generally are) by character properties then those properties
3014 : win.
3015 :
3016 : The fontsize that is used in MS for determing the defaults is always
3017 : the CJK fontsize even if the text is not in that language, in OOo the
3018 : largest fontsize used in the field is the one we should take, but
3019 : whatever we do, word will actually render using the fontsize set for
3020 : CJK text. Nevertheless we attempt to guess whether the script is in
3021 : asian or western text based up on the first character and use the
3022 : font size of that script as our default.
3023 : */
3024 : sal_uInt16 nScript;
3025 0 : if( g_pBreakIt->GetBreakIter().is() )
3026 0 : nScript = g_pBreakIt->GetBreakIter()->getScriptType( pField->GetPar1(), 0);
3027 : else
3028 0 : nScript = i18n::ScriptType::ASIAN;
3029 :
3030 0 : long nHeight = static_cast<const SvxFontHeightItem&>((GetExport().GetItem(
3031 0 : GetWhichOfScript(RES_CHRATR_FONTSIZE,nScript)))).GetHeight();
3032 :
3033 0 : nHeight = (nHeight + 10) / 20; //Font Size in points;
3034 :
3035 : /*
3036 : Divide the combined char string into its up and down part. Get the
3037 : font size and fill in the defaults as up == half the font size and
3038 : down == a fifth the font size
3039 : */
3040 0 : const sal_Int32 nAbove = (pField->GetPar1().getLength()+1)/2;
3041 : const OUString sStr = FieldString(ww::eEQ)
3042 0 : + "\\o (\\s\\up "
3043 0 : + OUString::number(nHeight/2)
3044 0 : + "("
3045 0 : + pField->GetPar1().copy(0, nAbove)
3046 0 : + "), \\s\\do "
3047 0 : + OUString::number(nHeight/5)
3048 0 : + "("
3049 0 : + pField->GetPar1().copy(nAbove)
3050 0 : + "))";
3051 0 : GetExport().OutputField(pField, ww::eEQ, sStr);
3052 : }
3053 0 : break;
3054 : case RES_DROPDOWN:
3055 0 : bWriteExpand = DropdownField( pField );
3056 0 : break;
3057 : case RES_CHAPTERFLD:
3058 0 : bWriteExpand = true;
3059 0 : if (GetExport().m_bOutKF && rField.GetTextField())
3060 : {
3061 0 : const SwTextNode *pTextNd = GetExport().GetHdFtPageRoot();
3062 0 : if (!pTextNd)
3063 : {
3064 0 : pTextNd = GetExport().m_pCurPam->GetNode().GetTextNode();
3065 : }
3066 :
3067 0 : if (pTextNd)
3068 : {
3069 0 : SwChapterField aCopy(*static_cast<const SwChapterField*>(pField));
3070 0 : aCopy.ChangeExpansion(*pTextNd, false);
3071 0 : WriteExpand( &aCopy );
3072 0 : bWriteExpand = false;
3073 : }
3074 : }
3075 0 : break;
3076 : case RES_HIDDENTXTFLD:
3077 : {
3078 0 : OUString sExpand(pField->GetPar2());
3079 0 : if (!sExpand.isEmpty())
3080 : {
3081 0 : HiddenField( *pField );
3082 0 : }
3083 : }
3084 0 : break;
3085 : case RES_JUMPEDITFLD:
3086 27 : bWriteExpand = PlaceholderField( pField );
3087 27 : break;
3088 : case RES_MACROFLD:
3089 : {
3090 : const OUString sStr = " MACROBUTTON"
3091 2 : + pField->GetPar1().replaceFirst("StarOffice.Standard.Modul1.", " ")
3092 2 : + " "
3093 3 : + lcl_GetExpandedField(*pField);
3094 1 : GetExport().OutputField( pField, ww::eMACROBUTTON, sStr );
3095 : }
3096 1 : break;
3097 : default:
3098 1 : bWriteExpand = true;
3099 1 : break;
3100 : }
3101 :
3102 216 : if (bWriteExpand)
3103 6 : WriteExpand( pField );
3104 216 : }
3105 :
3106 315 : void AttributeOutputBase::TextFlyContent( const SwFormatFlyCnt& rFlyContent )
3107 : {
3108 315 : if ( GetExport().m_pOutFormatNode && GetExport().m_pOutFormatNode->ISA( SwContentNode ) )
3109 : {
3110 315 : const SwTextNode* pTextNd = static_cast<const SwTextNode*>(GetExport().m_pOutFormatNode);
3111 :
3112 315 : Point aLayPos;
3113 315 : aLayPos = pTextNd->FindLayoutRect( false, &aLayPos ).Pos();
3114 :
3115 315 : SwPosition aPos( *pTextNd );
3116 630 : sw::Frame aFrm( *rFlyContent.GetFrameFormat(), aPos );
3117 :
3118 630 : OutputFlyFrame_Impl( aFrm, aLayPos );
3119 : }
3120 315 : }
3121 :
3122 : // TOXMarks fehlen noch
3123 :
3124 : // Detaillierte Einstellungen zur Trennung erlaubt WW nur dokumentenweise.
3125 : // Man koennte folgende Mimik einbauen: Die Werte des Style "Standard" werden,
3126 : // falls vorhanden, in die Document Properties ( DOP ) gesetzt.
3127 :
3128 : // ACK. Dieser Vorschlag passt exakt zu unserer Implementierung des Import,
3129 : // daher setze ich das gleich mal um. (KHZ, 07/15/2000)
3130 41 : void WW8AttributeOutput::ParaHyphenZone( const SvxHyphenZoneItem& rHyphenZone )
3131 : {
3132 : // sprmPFNoAutoHyph
3133 41 : if( m_rWW8Export.bWrtWW8 )
3134 41 : m_rWW8Export.InsUInt16( NS_sprm::LN_PFNoAutoHyph );
3135 : else
3136 0 : m_rWW8Export.pO->push_back( 44 );
3137 :
3138 41 : m_rWW8Export.pO->push_back( rHyphenZone.IsHyphen() ? 0 : 1 );
3139 41 : }
3140 :
3141 30 : void WW8AttributeOutput::ParaScriptSpace( const SfxBoolItem& rScriptSpace )
3142 : {
3143 30 : if ( !m_rWW8Export.bWrtWW8 )
3144 30 : return;
3145 :
3146 30 : m_rWW8Export.InsUInt16( NS_sprm::LN_PFAutoSpaceDE );
3147 30 : m_rWW8Export.pO->push_back( rScriptSpace.GetValue() ? 1 : 0 );
3148 : }
3149 :
3150 26 : void WW8AttributeOutput::ParaHangingPunctuation( const SfxBoolItem& rItem )
3151 : {
3152 26 : if ( !m_rWW8Export.bWrtWW8 )
3153 26 : return;
3154 :
3155 26 : m_rWW8Export.InsUInt16( NS_sprm::LN_PFOverflowPunct );
3156 26 : m_rWW8Export.pO->push_back( rItem.GetValue() ? 1 : 0 );
3157 : }
3158 :
3159 26 : void WW8AttributeOutput::ParaForbiddenRules( const SfxBoolItem& rItem )
3160 : {
3161 26 : if ( !m_rWW8Export.bWrtWW8 )
3162 26 : return;
3163 :
3164 26 : m_rWW8Export.InsUInt16( NS_sprm::LN_PFKinsoku );
3165 26 : m_rWW8Export.pO->push_back( rItem.GetValue() ? 1 : 0 );
3166 : }
3167 :
3168 78 : void WW8AttributeOutput::ParaSnapToGrid( const SvxParaGridItem& rGrid )
3169 : {
3170 : // sprmPFUsePgsuSettings
3171 : // 97+ only
3172 78 : if ( !m_rWW8Export.bWrtWW8 )
3173 78 : return;
3174 :
3175 78 : m_rWW8Export.InsUInt16( NS_sprm::LN_PFUsePgsuSettings );
3176 78 : m_rWW8Export.pO->push_back( rGrid.GetValue() ? 1 : 0 );
3177 : }
3178 :
3179 0 : void WW8AttributeOutput::ParaVerticalAlign( const SvxParaVertAlignItem& rAlign )
3180 : {
3181 : // sprmPWAlignFont
3182 : // 97+ only
3183 0 : if( !m_rWW8Export.bWrtWW8 )
3184 0 : return;
3185 :
3186 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_PWAlignFont );
3187 :
3188 0 : sal_Int16 nVal = rAlign.GetValue();
3189 0 : switch ( nVal )
3190 : {
3191 : case SvxParaVertAlignItem::BASELINE:
3192 0 : nVal = 2;
3193 0 : break;
3194 : case SvxParaVertAlignItem::TOP:
3195 0 : nVal = 0;
3196 0 : break;
3197 : case SvxParaVertAlignItem::CENTER:
3198 0 : nVal = 1;
3199 0 : break;
3200 : case SvxParaVertAlignItem::BOTTOM:
3201 0 : nVal = 3;
3202 0 : break;
3203 : case SvxParaVertAlignItem::AUTOMATIC:
3204 0 : nVal = 4;
3205 0 : break;
3206 : default:
3207 0 : nVal = 4;
3208 : OSL_FAIL( "Unknown vert alignment" );
3209 0 : break;
3210 : }
3211 0 : m_rWW8Export.InsUInt16( nVal );
3212 : }
3213 :
3214 : // NoHyphen: ich habe keine Entsprechung in der SW-UI und WW-UI gefunden
3215 :
3216 : // RefMark, NoLineBreakHere fehlen noch
3217 :
3218 2 : void WW8Export::WriteFootnoteBegin( const SwFormatFootnote& rFootnote, ww::bytes* pOutArr )
3219 : {
3220 2 : ww::bytes aAttrArr;
3221 2 : const bool bAutoNum = rFootnote.GetNumStr().isEmpty(); // Auto-Nummer
3222 2 : if( bAutoNum )
3223 : {
3224 2 : if( bWrtWW8 )
3225 : {
3226 : static const sal_uInt8 aSpec[] =
3227 : {
3228 : 0x03, 0x6a, 0, 0, 0, 0, // sprmCObjLocation
3229 : 0x55, 0x08, 1 // sprmCFSpec
3230 : };
3231 :
3232 2 : aAttrArr.insert(aAttrArr.end(), aSpec, aSpec+sizeof(aSpec));
3233 : }
3234 : else
3235 : {
3236 : static sal_uInt8 const aSpec[] =
3237 : {
3238 : 117, 1, // sprmCFSpec
3239 : 68, 4, 0, 0, 0, 0 // sprmCObjLocation
3240 : };
3241 :
3242 0 : aAttrArr.insert(aAttrArr.end(), aSpec, aSpec+sizeof(aSpec));
3243 : }
3244 : }
3245 :
3246 : // sprmCIstd
3247 : const SwEndNoteInfo* pInfo;
3248 2 : if( rFootnote.IsEndNote() )
3249 0 : pInfo = &m_pDoc->GetEndNoteInfo();
3250 : else
3251 2 : pInfo = &m_pDoc->GetFootnoteInfo();
3252 : const SwCharFormat* pCFormat = pOutArr
3253 1 : ? pInfo->GetAnchorCharFormat( *m_pDoc )
3254 3 : : pInfo->GetCharFormat( *m_pDoc );
3255 2 : if( bWrtWW8 )
3256 2 : SwWW8Writer::InsUInt16( aAttrArr, NS_sprm::LN_CIstd );
3257 : else
3258 0 : aAttrArr.push_back( 80 );
3259 2 : SwWW8Writer::InsUInt16( aAttrArr, GetId( pCFormat ) );
3260 :
3261 : // fSpec-Attribut true
3262 : // Fuer Auto-Nummer muss ein Spezial-Zeichen
3263 : // in den Text und darum ein fSpec-Attribut
3264 2 : m_pChpPlc->AppendFkpEntry( Strm().Tell() );
3265 2 : if( bAutoNum )
3266 2 : WriteChar( 0x02 ); // Auto-Nummer-Zeichen
3267 : else
3268 : // User-Nummerierung
3269 : OutSwString( rFootnote.GetNumStr(), 0, rFootnote.GetNumStr().getLength(),
3270 0 : IsUnicode(), RTL_TEXTENCODING_MS_1252 );
3271 :
3272 2 : if( pOutArr )
3273 : {
3274 : // insert at start of array, so the "hard" attribute overrule the
3275 : // attributes of the character template
3276 1 : pOutArr->insert( pOutArr->begin(), aAttrArr.begin(), aAttrArr.end() );
3277 : }
3278 : else
3279 : {
3280 1 : ww::bytes aOutArr;
3281 :
3282 : // insert at start of array, so the "hard" attribute overrule the
3283 : // attributes of the character template
3284 1 : aOutArr.insert( aOutArr.begin(), aAttrArr.begin(), aAttrArr.end() );
3285 :
3286 : // write for the ftn number in the content, the font of the anchor
3287 1 : const SwTextFootnote* pTextFootnote = rFootnote.GetTextFootnote();
3288 1 : if( pTextFootnote )
3289 : {
3290 1 : ww::bytes* pOld = pO;
3291 1 : pO = &aOutArr;
3292 1 : SfxItemSet aSet( m_pDoc->GetAttrPool(), RES_CHRATR_FONT,
3293 1 : RES_CHRATR_FONT );
3294 :
3295 1 : pCFormat = pInfo->GetCharFormat( *m_pDoc );
3296 1 : aSet.Set( pCFormat->GetAttrSet() );
3297 :
3298 2 : pTextFootnote->GetTextNode().GetAttr( aSet, pTextFootnote->GetStart(),
3299 3 : (pTextFootnote->GetStart()) + 1 );
3300 1 : m_pAttrOutput->OutputItem( aSet.Get( RES_CHRATR_FONT ) );
3301 1 : pO = pOld;
3302 : }
3303 2 : m_pChpPlc->AppendFkpEntry( Strm().Tell(), aOutArr.size(),
3304 3 : aOutArr.data() );
3305 2 : }
3306 2 : }
3307 :
3308 10 : static bool lcl_IsAtTextEnd(const SwFormatFootnote& rFootnote)
3309 : {
3310 10 : bool bRet = true;
3311 10 : if( rFootnote.GetTextFootnote() )
3312 : {
3313 10 : sal_uInt16 nWh = static_cast< sal_uInt16 >(rFootnote.IsEndNote() ? RES_END_AT_TXTEND
3314 10 : : RES_FTN_AT_TXTEND);
3315 10 : const SwSectionNode* pSectNd = rFootnote.GetTextFootnote()->GetTextNode().
3316 10 : FindSectionNode();
3317 24 : while( pSectNd && FTNEND_ATPGORDOCEND ==
3318 2 : static_cast<const SwFormatFootnoteEndAtTextEnd&>(pSectNd->GetSection().GetFormat()->
3319 4 : GetFormatAttr( nWh, true)).GetValue() )
3320 2 : pSectNd = pSectNd->StartOfSectionNode()->FindSectionNode();
3321 :
3322 10 : if (!pSectNd)
3323 10 : bRet = false; // the is ftn/end collected at Page- or Doc-End
3324 : }
3325 10 : return bRet;
3326 : }
3327 :
3328 13 : void AttributeOutputBase::TextFootnote( const SwFormatFootnote& rFootnote )
3329 : {
3330 : sal_uInt16 nTyp;
3331 13 : if ( rFootnote.IsEndNote() )
3332 : {
3333 3 : nTyp = REF_ENDNOTE;
3334 3 : if ( GetExport().m_bEndAtTextEnd )
3335 2 : GetExport().m_bEndAtTextEnd = lcl_IsAtTextEnd( rFootnote );
3336 : }
3337 : else
3338 : {
3339 10 : nTyp = REF_FOOTNOTE;
3340 10 : if ( GetExport().m_bFootnoteAtTextEnd )
3341 8 : GetExport().m_bFootnoteAtTextEnd = lcl_IsAtTextEnd( rFootnote );
3342 : }
3343 :
3344 : // if any reference to this footnote/endnote then insert an internal
3345 : // Bookmark.
3346 13 : OUString sBkmkNm;
3347 13 : if ( GetExport().HasRefToObject( nTyp, 0, rFootnote.GetTextFootnote()->GetSeqRefNo() ))
3348 : {
3349 0 : sBkmkNm = MSWordExportBase::GetBookmarkName( nTyp, 0,
3350 0 : rFootnote.GetTextFootnote()->GetSeqRefNo() );
3351 0 : GetExport().AppendBookmark( sBkmkNm );
3352 : }
3353 :
3354 13 : TextFootnote_Impl( rFootnote );
3355 :
3356 13 : if ( !sBkmkNm.isEmpty() )
3357 0 : GetExport().AppendBookmark( sBkmkNm ); // FIXME: Why is it added twice? Shouldn't this one go to WW8AttributeOuput::TextFootnote_Impl()?
3358 13 : }
3359 :
3360 1 : void WW8AttributeOutput::TextFootnote_Impl( const SwFormatFootnote& rFootnote )
3361 : {
3362 : WW8_WrPlcFootnoteEdn* pFootnoteEnd;
3363 1 : if ( rFootnote.IsEndNote() )
3364 0 : pFootnoteEnd = m_rWW8Export.pEdn;
3365 : else
3366 1 : pFootnoteEnd = m_rWW8Export.pFootnote;
3367 :
3368 1 : pFootnoteEnd->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), rFootnote );
3369 1 : m_rWW8Export.WriteFootnoteBegin( rFootnote, m_rWW8Export.pO );
3370 1 : }
3371 :
3372 2 : void WW8AttributeOutput::TextCharFormat( const SwFormatCharFormat& rCharFormat )
3373 : {
3374 2 : if( rCharFormat.GetCharFormat() )
3375 : {
3376 2 : if( m_rWW8Export.bWrtWW8 )
3377 2 : m_rWW8Export.InsUInt16( NS_sprm::LN_CIstd );
3378 : else
3379 0 : m_rWW8Export.pO->push_back( 80 );
3380 :
3381 2 : m_rWW8Export.InsUInt16( m_rWW8Export.GetId( rCharFormat.GetCharFormat() ) );
3382 : }
3383 2 : }
3384 :
3385 : /*
3386 : See ww8par6.cxx Read_DoubleLine for some more info
3387 : */
3388 0 : void WW8AttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines )
3389 : {
3390 : // #i28331# - check that bOn is set
3391 0 : if ( rTwoLines.GetValue() )
3392 : {
3393 : //97+ only
3394 0 : if( !m_rWW8Export.bWrtWW8 )
3395 0 : return;
3396 :
3397 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_CFELayout );
3398 0 : m_rWW8Export.pO->push_back( (sal_uInt8)0x06 ); //len 6
3399 0 : m_rWW8Export.pO->push_back( (sal_uInt8)0x02 );
3400 :
3401 0 : sal_Unicode cStart = rTwoLines.GetStartBracket();
3402 0 : sal_Unicode cEnd = rTwoLines.GetEndBracket();
3403 :
3404 : /*
3405 : As per usual we have problems. We can have separate left and right brackets
3406 : in OOo, it doesn't appear that you can in word. Also in word there appear
3407 : to only be a limited number of possibilities, we can use pretty much
3408 : anything.
3409 :
3410 : So if we have none, we export none, if either bracket is set to a known
3411 : word type we export both as that type (with the bracket winning out in
3412 : the case of a conflict simply being the order of test here.
3413 :
3414 : Upshot being a documented created in word will be reexported with no
3415 : ill effects.
3416 : */
3417 :
3418 : sal_uInt16 nType;
3419 0 : if (!cStart && !cEnd)
3420 0 : nType = 0;
3421 0 : else if ((cStart == '{') || (cEnd == '}'))
3422 0 : nType = 4;
3423 0 : else if ((cStart == '<') || (cEnd == '>'))
3424 0 : nType = 3;
3425 0 : else if ((cStart == '[') || (cEnd == ']'))
3426 0 : nType = 2;
3427 : else
3428 0 : nType = 1;
3429 0 : m_rWW8Export.InsUInt16( nType );
3430 : static const sal_uInt8 aZeroArr[ 3 ] = { 0, 0, 0 };
3431 0 : m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), aZeroArr, aZeroArr+3);
3432 : }
3433 : }
3434 :
3435 1275 : void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule )
3436 : {
3437 1275 : const SwTextNode* pTextNd = 0;
3438 : sal_uInt16 nNumId;
3439 1275 : sal_uInt8 nLvl = 0;
3440 1275 : if (!rNumRule.GetValue().isEmpty())
3441 : {
3442 1097 : const SwNumRule* pRule = GetExport().m_pDoc->FindNumRulePtr(
3443 2194 : rNumRule.GetValue() );
3444 1097 : if ( pRule && USHRT_MAX != ( nNumId = GetExport().GetId( *pRule ) ) )
3445 : {
3446 1097 : ++nNumId;
3447 1097 : if ( GetExport().m_pOutFormatNode )
3448 : {
3449 1097 : if ( GetExport().m_pOutFormatNode->ISA( SwContentNode ) )
3450 : {
3451 915 : pTextNd = static_cast<const SwTextNode*>(GetExport().m_pOutFormatNode);
3452 :
3453 915 : if( pTextNd->IsCountedInList())
3454 : {
3455 888 : int nLevel = pTextNd->GetActualListLevel();
3456 :
3457 888 : if (nLevel < 0)
3458 0 : nLevel = 0;
3459 :
3460 888 : if (nLevel >= MAXLEVEL)
3461 0 : nLevel = MAXLEVEL - 1;
3462 :
3463 888 : nLvl = static_cast< sal_uInt8 >(nLevel);
3464 :
3465 888 : if ( pTextNd->IsListRestart() )
3466 : {
3467 6 : sal_uInt16 nStartWith = static_cast< sal_uInt16 >( pTextNd->GetActualListStartValue() );
3468 6 : nNumId = GetExport().DuplicateNumRule( pRule, nLvl, nStartWith );
3469 6 : if ( USHRT_MAX != nNumId )
3470 6 : ++nNumId;
3471 : }
3472 : }
3473 : else
3474 : {
3475 : // #i44815# adjust numbering for numbered paragraphs
3476 : // without number (NO_NUMLEVEL). These paragraphs
3477 : // will receive a list id 0, which WW interprets as
3478 : // 'no number'.
3479 27 : nNumId = 0;
3480 : }
3481 : }
3482 182 : else if ( GetExport().m_pOutFormatNode->ISA( SwTextFormatColl ) )
3483 : {
3484 182 : const SwTextFormatColl* pC = static_cast<const SwTextFormatColl*>(GetExport().m_pOutFormatNode);
3485 182 : if ( pC && pC->IsAssignedToListLevelOfOutlineStyle() )
3486 153 : nLvl = static_cast< sal_uInt8 >( pC->GetAssignedOutlineStyleLevel() );
3487 : }
3488 : }
3489 : }
3490 : else
3491 0 : nNumId = USHRT_MAX;
3492 : }
3493 : else
3494 178 : nNumId = 0;
3495 :
3496 1275 : if ( USHRT_MAX != nNumId )
3497 : {
3498 1275 : if ( nLvl >= WW8ListManager::nMaxLevel )
3499 1 : nLvl = WW8ListManager::nMaxLevel - 1;
3500 :
3501 1275 : ParaNumRule_Impl( pTextNd, nLvl, nNumId );
3502 : }
3503 1275 : }
3504 :
3505 109 : void WW8AttributeOutput::ParaNumRule_Impl( const SwTextNode* pTextNd, sal_Int32 nLvl, sal_Int32 nNumId )
3506 : {
3507 109 : if ( m_rWW8Export.bWrtWW8 )
3508 : {
3509 : // write sprmPIlvl and sprmPIlfo
3510 109 : SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_PIlvl );
3511 109 : m_rWW8Export.pO->push_back( ::sal::static_int_cast<sal_uInt8>(nLvl) );
3512 109 : SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_PIlfo );
3513 109 : SwWW8Writer::InsUInt16( *m_rWW8Export.pO, ::sal::static_int_cast<sal_uInt16>(nNumId) );
3514 : }
3515 0 : else if ( pTextNd && m_rWW8Export.Out_SwNum( pTextNd ) ) // NumRules
3516 0 : m_rWW8Export.pSepx->SetNum( pTextNd );
3517 109 : }
3518 :
3519 : /* File FRMATR.HXX */
3520 :
3521 35 : void WW8AttributeOutput::FormatFrameSize( const SwFormatFrmSize& rSize )
3522 : {
3523 35 : if( m_rWW8Export.m_bOutFlyFrmAttrs ) // Flys
3524 : {
3525 0 : if( m_rWW8Export.m_bOutGrf )
3526 35 : return; // Fly um Grafik -> Auto-Groesse
3527 :
3528 : //???? was ist bei Prozentangaben ???
3529 0 : if ( rSize.GetWidth() && rSize.GetWidthSizeType() == ATT_FIX_SIZE)
3530 : {
3531 : //"sprmPDxaWidth"
3532 0 : if( m_rWW8Export.bWrtWW8 )
3533 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_PDxaWidth );
3534 : else
3535 0 : m_rWW8Export.pO->push_back( 28 );
3536 0 : m_rWW8Export.InsUInt16( (sal_uInt16)rSize.GetWidth() );
3537 : }
3538 :
3539 0 : if ( rSize.GetHeight() )
3540 : {
3541 : // sprmPWHeightAbs
3542 0 : if( m_rWW8Export.bWrtWW8 )
3543 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_PWHeightAbs );
3544 : else
3545 0 : m_rWW8Export.pO->push_back( 45 );
3546 :
3547 0 : sal_uInt16 nH = 0;
3548 0 : switch ( rSize.GetHeightSizeType() )
3549 : {
3550 0 : case ATT_VAR_SIZE: break;
3551 0 : case ATT_FIX_SIZE: nH = (sal_uInt16)rSize.GetHeight() & 0x7fff; break;
3552 0 : default: nH = (sal_uInt16)rSize.GetHeight() | 0x8000; break;
3553 : }
3554 0 : m_rWW8Export.InsUInt16( nH );
3555 : }
3556 : }
3557 35 : else if( m_rWW8Export.m_bOutPageDescs ) // PageDesc : Breite + Hoehe
3558 : {
3559 35 : if( m_rWW8Export.m_pAktPageDesc->GetLandscape() )
3560 : {
3561 : /*sprmSBOrientation*/
3562 2 : if( m_rWW8Export.bWrtWW8 )
3563 2 : m_rWW8Export.InsUInt16( NS_sprm::LN_SBOrientation );
3564 : else
3565 0 : m_rWW8Export.pO->push_back( 162 );
3566 2 : m_rWW8Export.pO->push_back( 2 );
3567 : }
3568 :
3569 : /*sprmSXaPage*/
3570 35 : if( m_rWW8Export.bWrtWW8 )
3571 35 : m_rWW8Export.InsUInt16( NS_sprm::LN_SXaPage );
3572 : else
3573 0 : m_rWW8Export.pO->push_back( 164 );
3574 : m_rWW8Export.InsUInt16(
3575 35 : msword_cast<sal_uInt16>(SvxPaperInfo::GetSloppyPaperDimension(rSize.GetWidth())));
3576 :
3577 : /*sprmSYaPage*/
3578 35 : if( m_rWW8Export.bWrtWW8 )
3579 35 : m_rWW8Export.InsUInt16( NS_sprm::LN_SYaPage );
3580 : else
3581 0 : m_rWW8Export.pO->push_back( 165 );
3582 : m_rWW8Export.InsUInt16(
3583 35 : msword_cast<sal_uInt16>(SvxPaperInfo::GetSloppyPaperDimension(rSize.GetHeight())));
3584 : }
3585 : }
3586 :
3587 : // FillOrder fehlt noch
3588 :
3589 : // ReplaceCr() wird fuer Pagebreaks und Pagedescs gebraucht. Es wird ein
3590 : // bereits geschriebenes CR durch ein Break-Zeichen ersetzt. Replace muss
3591 : // direkt nach Schreiben des CR gerufen werden.
3592 : // Rueckgabe: FilePos des ersetzten CRs + 1 oder 0 fuer nicht ersetzt
3593 :
3594 25 : sal_uLong WW8Export::ReplaceCr( sal_uInt8 nChar )
3595 : {
3596 : OSL_ENSURE( nChar, "gegen 0 ersetzt bringt WW97/95 zum Absturz" );
3597 :
3598 25 : bool bReplaced = false;
3599 25 : SvStream& rStrm = Strm();
3600 25 : sal_uLong nRetPos = 0, nPos = rStrm.Tell();
3601 : //If there is at least two characters already output
3602 25 : if (nPos - (IsUnicode() ? 2 : 1) >= sal_uLong(pFib->fcMin))
3603 : {
3604 3 : sal_uInt8 nBCode=0;
3605 3 : sal_uInt16 nUCode=0;
3606 :
3607 3 : rStrm.SeekRel(IsUnicode() ? -2 : -1);
3608 3 : if (IsUnicode())
3609 3 : rStrm.ReadUInt16( nUCode );
3610 : else
3611 : {
3612 0 : rStrm.ReadUChar( nBCode );
3613 0 : nUCode = nBCode;
3614 : }
3615 : //If the last char was a cr
3616 3 : if (nUCode == 0x0d) // CR ?
3617 : {
3618 4 : if ((nChar == 0x0c) &&
3619 2 : (nPos - (IsUnicode() ? 4 : 2) >= sal_uLong(pFib->fcMin)))
3620 : {
3621 2 : rStrm.SeekRel( IsUnicode() ? -4 : -2 );
3622 2 : if (IsUnicode())
3623 2 : rStrm.ReadUInt16( nUCode );
3624 : else
3625 : {
3626 0 : rStrm.ReadUInt16( nUCode );
3627 0 : nUCode = nBCode;
3628 : }
3629 : }
3630 : else
3631 : {
3632 0 : rStrm.SeekRel( IsUnicode() ? -2 : -1 );
3633 0 : nUCode = 0x0;
3634 : }
3635 : //And the para is not of len 0, then replace this cr with the mark
3636 : //#120140# If there is a cr before a column break, need replace the cr. So remove the "nChar==0x0e" check.
3637 2 : if( nUCode == 0x0d )
3638 0 : bReplaced = false;
3639 : else
3640 : {
3641 2 : bReplaced = true;
3642 2 : WriteChar(nChar);
3643 2 : nRetPos = nPos;
3644 : }
3645 : }
3646 1 : else if ((nUCode == 0x0c) && (nChar == 0x0e))
3647 : {
3648 : // a column break after a section has no effect in writer
3649 0 : bReplaced = true;
3650 : }
3651 3 : rStrm.Seek( nPos );
3652 : }
3653 : else
3654 22 : bReplaced = true;
3655 :
3656 25 : if (!bReplaced)
3657 : {
3658 : // then write as normal char
3659 1 : WriteChar(nChar);
3660 1 : m_pPiece->SetParaBreak();
3661 1 : m_pPapPlc->AppendFkpEntry(rStrm.Tell());
3662 1 : m_pChpPlc->AppendFkpEntry(rStrm.Tell());
3663 1 : nRetPos = rStrm.Tell();
3664 : }
3665 25 : return nRetPos;
3666 : }
3667 :
3668 37 : void WW8AttributeOutput::TableRowEnd(sal_uInt32 nDepth)
3669 : {
3670 37 : if ( nDepth == 1 )
3671 37 : m_rWW8Export.WriteChar( 0x07 );
3672 0 : else if ( nDepth > 1 )
3673 0 : m_rWW8Export.WriteChar( 0x0d );
3674 :
3675 : //Technically in a word document this is a different value for a row ends
3676 : //that are not row ends directly after a cell with a graphic. But it
3677 : //doesn't seem to make a difference
3678 : //pMagicTable->Append(Fc2Cp(Strm().Tell()),0x1B6);
3679 37 : }
3680 :
3681 580 : void AttributeOutputBase::FormatPageDescription( const SwFormatPageDesc& rPageDesc )
3682 : {
3683 580 : if ( GetExport().m_bStyDef && GetExport().m_pOutFormatNode && GetExport().m_pOutFormatNode->ISA( SwTextFormatColl ) )
3684 : {
3685 37 : const SwTextFormatColl* pC = static_cast<const SwTextFormatColl*>(GetExport().m_pOutFormatNode);
3686 37 : if ( (SfxItemState::SET != pC->GetItemState( RES_BREAK, false ) ) && rPageDesc.KnowsPageDesc() )
3687 2 : FormatBreak( SvxFormatBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ) );
3688 : }
3689 580 : }
3690 :
3691 5 : void WW8AttributeOutput::PageBreakBefore( bool bBreak )
3692 : {
3693 : // sprmPPageBreakBefore/sprmPFPageBreakBefore
3694 5 : if ( m_rWW8Export.bWrtWW8 )
3695 5 : m_rWW8Export.InsUInt16( NS_sprm::LN_PFPageBreakBefore );
3696 : else
3697 0 : m_rWW8Export.pO->push_back( 9 );
3698 :
3699 5 : m_rWW8Export.pO->push_back( bBreak ? 1 : 0 );
3700 5 : }
3701 :
3702 : // Breaks schreiben nichts in das Ausgabe-Feld rWrt.pO,
3703 : // sondern nur in den Text-Stream ( Bedingung dafuer, dass sie von Out_Break...
3704 : // gerufen werden duerfen )
3705 350 : void AttributeOutputBase::FormatBreak( const SvxFormatBreakItem& rBreak )
3706 : {
3707 350 : if ( GetExport().m_bStyDef )
3708 : {
3709 46 : switch ( rBreak.GetBreak() )
3710 : {
3711 : case SVX_BREAK_NONE:
3712 : case SVX_BREAK_PAGE_BEFORE:
3713 : case SVX_BREAK_PAGE_BOTH:
3714 46 : PageBreakBefore( rBreak.GetValue() );
3715 46 : break;
3716 : default:
3717 0 : break;
3718 : }
3719 : }
3720 304 : else if ( !GetExport().m_pParentFrame )
3721 : {
3722 304 : sal_uInt8 nC = 0;
3723 304 : bool bBefore = false;
3724 : // #i76300# - Note: Can only be <true>, if <bBefore> equals <false>.
3725 304 : bool bCheckForFollowPageDesc = false;
3726 :
3727 304 : switch ( rBreak.GetBreak() )
3728 : {
3729 : case SVX_BREAK_NONE: // Ausgeschaltet
3730 2 : if ( !GetExport().m_bBreakBefore )
3731 2 : PageBreakBefore( false );
3732 352 : return;
3733 :
3734 : case SVX_BREAK_COLUMN_BEFORE: // ColumnBreak
3735 110 : bBefore = true;
3736 : // no break;
3737 : case SVX_BREAK_COLUMN_AFTER:
3738 : case SVX_BREAK_COLUMN_BOTH:
3739 110 : if ( GetExport().Sections().CurrentNumberOfColumns( *GetExport().m_pDoc ) > 1 || GetExport().SupportsOneColumnBreak() )
3740 : {
3741 107 : nC = msword::ColumnBreak;
3742 : }
3743 110 : break;
3744 :
3745 : case SVX_BREAK_PAGE_BEFORE: // PageBreak
3746 : // From now on(fix for #i77900#) we prefer to save a page break
3747 : // as paragraph attribute (if the exporter is OK with that),
3748 : // this has to be done after the export of the paragraph ( =>
3749 : // !GetExport().bBreakBefore )
3750 192 : if (GetExport().PreferPageBreakBefore())
3751 : {
3752 19 : if (!GetExport().m_bBreakBefore)
3753 10 : PageBreakBefore(true);
3754 19 : break;
3755 : }
3756 : case SVX_BREAK_PAGE_AFTER:
3757 : case SVX_BREAK_PAGE_BOTH:
3758 173 : nC = msword::PageBreak;
3759 : // #i76300# - check for follow page description,
3760 : // if current writing attributes of a paragraph.
3761 435 : if ( dynamic_cast< const SwTextNode* >( GetExport().m_pOutFormatNode ) &&
3762 262 : GetExport().GetCurItemSet() )
3763 : {
3764 89 : bCheckForFollowPageDesc = true;
3765 : }
3766 173 : break;
3767 :
3768 : default:
3769 0 : break;
3770 : }
3771 :
3772 658 : if ( (( bBefore != GetExport().m_bBreakBefore ) && ( nC == msword::PageBreak)) ||
3773 372 : (( bBefore == GetExport().m_bBreakBefore ) && ( nC == msword::ColumnBreak)) )
3774 : {
3775 : // #i76300#
3776 138 : bool bFollowPageDescWritten = false;
3777 138 : if ( bCheckForFollowPageDesc && !bBefore )
3778 : {
3779 : bFollowPageDescWritten =
3780 0 : GetExport().OutputFollowPageDesc( GetExport().GetCurItemSet(),
3781 0 : dynamic_cast<const SwTextNode*>( GetExport().m_pOutFormatNode ) );
3782 : }
3783 138 : if ( !bFollowPageDescWritten )
3784 : {
3785 138 : SectionBreak( nC );
3786 : }
3787 : }
3788 : }
3789 : }
3790 :
3791 0 : void WW8AttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* /*pSectionInfo*/ )
3792 : {
3793 0 : m_rWW8Export.ReplaceCr( nC );
3794 0 : }
3795 :
3796 501 : sal_uInt32 AttributeOutputBase::GridCharacterPitch( const SwTextGridItem& rGrid ) const
3797 : {
3798 501 : MSWordStyles * pStyles = GetExport().m_pStyles;
3799 501 : const SwFormat * pSwFormat = pStyles->GetSwFormat(0);
3800 :
3801 501 : sal_uInt32 nPageCharSize = 0;
3802 :
3803 501 : if (pSwFormat != NULL)
3804 : {
3805 : nPageCharSize = ItemGet<SvxFontHeightItem>
3806 501 : (*pSwFormat, RES_CHRATR_FONTSIZE).GetHeight();
3807 : }
3808 501 : sal_uInt16 nPitch = rGrid.IsSquaredMode() ? rGrid.GetBaseHeight() :
3809 501 : rGrid.GetBaseWidth( );
3810 :
3811 501 : sal_Int32 nCharWidth = nPitch - nPageCharSize;
3812 501 : sal_Int32 nFraction = nCharWidth % 20;
3813 501 : if ( nCharWidth < 0 )
3814 430 : nFraction = 20 + nFraction;
3815 501 : nFraction = ( nFraction * 0xFFF ) / 20;
3816 501 : nFraction = ( nFraction & 0x00000FFF );
3817 :
3818 501 : sal_Int32 nMain = nCharWidth / 20;
3819 501 : if ( nCharWidth < 0 )
3820 430 : nMain -= 1;
3821 501 : nMain = nMain * 0x1000;
3822 501 : nMain = ( nMain & 0xFFFFF000 );
3823 :
3824 501 : return sal_uInt32( nFraction + nMain );
3825 : }
3826 :
3827 55 : void WW8AttributeOutput::FormatTextGrid( const SwTextGridItem& rGrid )
3828 : {
3829 55 : if ( m_rWW8Export.m_bOutPageDescs && m_rWW8Export.bWrtWW8 )
3830 : {
3831 28 : sal_uInt16 nGridType = 0;
3832 28 : switch ( rGrid.GetGridType() )
3833 : {
3834 : default:
3835 : OSL_FAIL("Unknown grid type");
3836 : //fall-through
3837 : case GRID_NONE:
3838 24 : nGridType = 0;
3839 24 : break;
3840 : case GRID_LINES_ONLY:
3841 4 : nGridType = 2;
3842 4 : break;
3843 : case GRID_LINES_CHARS:
3844 0 : if ( rGrid.IsSnapToChars() )
3845 0 : nGridType = 3;
3846 : else
3847 0 : nGridType = 1;
3848 0 : break;
3849 : }
3850 28 : m_rWW8Export.InsUInt16( NS_sprm::LN_SClm );
3851 28 : m_rWW8Export.InsUInt16( nGridType );
3852 :
3853 28 : sal_uInt16 nHeight = rGrid.GetBaseHeight() + rGrid.GetRubyHeight();
3854 28 : m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaLinePitch );
3855 28 : m_rWW8Export.InsUInt16( nHeight );
3856 :
3857 28 : m_rWW8Export.InsUInt16( NS_sprm::LN_SDxtCharSpace );
3858 28 : m_rWW8Export.InsUInt32( GridCharacterPitch( rGrid ) );
3859 : }
3860 55 : }
3861 :
3862 0 : void WW8AttributeOutput::FormatPaperBin( const SvxPaperBinItem& rPaperBin )
3863 : {
3864 0 : if ( m_rWW8Export.m_bOutPageDescs )
3865 : {
3866 : sal_uInt16 nVal;
3867 0 : switch ( rPaperBin.GetValue() )
3868 : {
3869 0 : case 0: nVal = 15; break; // Automatically select
3870 0 : case 1: nVal = 1; break; // Upper paper tray
3871 0 : case 2: nVal = 4; break; // Manual paper feed
3872 0 : default: nVal = 0; break;
3873 : }
3874 :
3875 0 : if ( nVal )
3876 : {
3877 0 : if( m_rWW8Export.bWrtWW8 )
3878 0 : m_rWW8Export.InsUInt16( m_rWW8Export.m_bOutFirstPage? NS_sprm::LN_SDmBinFirst: NS_sprm::LN_SDmBinOther );
3879 : else
3880 0 : m_rWW8Export.pO->push_back( m_rWW8Export.m_bOutFirstPage? 140: 141 );
3881 :
3882 0 : m_rWW8Export.InsUInt16( nVal );
3883 : }
3884 : }
3885 0 : }
3886 :
3887 90 : void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR )
3888 : {
3889 : // Flys fehlen noch ( siehe RTF )
3890 :
3891 90 : if ( m_rWW8Export.m_bOutFlyFrmAttrs ) // Flys
3892 : {
3893 : // sprmPDxaFromText10
3894 0 : if( m_rWW8Export.bWrtWW8 )
3895 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_PDxaFromText10 );
3896 : else
3897 0 : m_rWW8Export.pO->push_back( 49 );
3898 : // Mittelwert nehmen, da WW nur 1 Wert kennt
3899 0 : m_rWW8Export.InsUInt16( (sal_uInt16) ( ( rLR.GetLeft() + rLR.GetRight() ) / 2 ) );
3900 : }
3901 90 : else if ( m_rWW8Export.m_bOutPageDescs ) // PageDescs
3902 : {
3903 : sal_uInt16 nLDist, nRDist;
3904 35 : const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_BOX );
3905 35 : if ( pItem )
3906 : {
3907 1 : nRDist = static_cast<const SvxBoxItem*>(pItem)->CalcLineSpace( SvxBoxItemLine::LEFT );
3908 1 : nLDist = static_cast<const SvxBoxItem*>(pItem)->CalcLineSpace( SvxBoxItemLine::RIGHT );
3909 : }
3910 : else
3911 34 : nLDist = nRDist = 0;
3912 35 : nLDist = nLDist + (sal_uInt16)rLR.GetLeft();
3913 35 : nRDist = nRDist + (sal_uInt16)rLR.GetRight();
3914 :
3915 : // sprmSDxaLeft
3916 35 : if( m_rWW8Export.bWrtWW8 )
3917 35 : m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaLeft );
3918 : else
3919 0 : m_rWW8Export.pO->push_back( 166 );
3920 35 : m_rWW8Export.InsUInt16( nLDist );
3921 :
3922 : // sprmSDxaRight
3923 35 : if( m_rWW8Export.bWrtWW8 )
3924 35 : m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaRight );
3925 : else
3926 0 : m_rWW8Export.pO->push_back( 167 );
3927 35 : m_rWW8Export.InsUInt16( nRDist );
3928 : }
3929 : else
3930 : { // normale Absaetze
3931 : // sprmPDxaLeft
3932 55 : if( m_rWW8Export.bWrtWW8 )
3933 : {
3934 55 : m_rWW8Export.InsUInt16( 0x845E ); //asian version ?
3935 55 : m_rWW8Export.InsUInt16( (sal_uInt16)rLR.GetTextLeft() );
3936 : }
3937 : else
3938 : {
3939 0 : m_rWW8Export.pO->push_back( 17 );
3940 0 : m_rWW8Export.InsUInt16( (sal_uInt16)rLR.GetTextLeft() );
3941 : }
3942 :
3943 : // sprmPDxaRight
3944 55 : if( m_rWW8Export.bWrtWW8 )
3945 : {
3946 55 : m_rWW8Export.InsUInt16( 0x845D ); //asian version ?
3947 55 : m_rWW8Export.InsUInt16( (sal_uInt16)rLR.GetRight() );
3948 : }
3949 : else
3950 : {
3951 0 : m_rWW8Export.pO->push_back( 16 );
3952 0 : m_rWW8Export.InsUInt16( (sal_uInt16)rLR.GetRight() );
3953 : }
3954 :
3955 : // sprmPDxaLeft1
3956 55 : if( m_rWW8Export.bWrtWW8 )
3957 : {
3958 55 : m_rWW8Export.InsUInt16( 0x8460 ); //asian version ?
3959 55 : m_rWW8Export.InsUInt16( rLR.GetTextFirstLineOfst() );
3960 : }
3961 : else
3962 : {
3963 0 : m_rWW8Export.pO->push_back( 19 );
3964 0 : m_rWW8Export.InsUInt16( rLR.GetTextFirstLineOfst() );
3965 : }
3966 : }
3967 90 : }
3968 :
3969 272 : void WW8AttributeOutput::FormatULSpace( const SvxULSpaceItem& rUL )
3970 : {
3971 : // Flys fehlen noch ( siehe RTF )
3972 :
3973 272 : if ( m_rWW8Export.m_bOutFlyFrmAttrs ) // Flys
3974 : {
3975 : // sprmPDyaFromText
3976 0 : if( m_rWW8Export.bWrtWW8 )
3977 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaFromText );
3978 : else
3979 0 : m_rWW8Export.pO->push_back( 48 );
3980 : // Mittelwert nehmen, da WW nur 1 Wert kennt
3981 0 : m_rWW8Export.InsUInt16( (sal_uInt16) ( ( rUL.GetUpper() + rUL.GetLower() ) / 2 ) );
3982 : }
3983 272 : else if ( m_rWW8Export.m_bOutPageDescs ) // Page-UL
3984 : {
3985 : OSL_ENSURE( m_rWW8Export.GetCurItemSet(), "Impossible" );
3986 35 : if ( !m_rWW8Export.GetCurItemSet() )
3987 272 : return;
3988 :
3989 35 : HdFtDistanceGlue aDistances( *m_rWW8Export.GetCurItemSet() );
3990 :
3991 35 : if ( aDistances.HasHeader() )
3992 : {
3993 : //sprmSDyaHdrTop
3994 8 : if ( m_rWW8Export.bWrtWW8 )
3995 8 : m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaHdrTop );
3996 : else
3997 0 : m_rWW8Export.pO->push_back( 156 );
3998 8 : m_rWW8Export.InsUInt16( aDistances.dyaHdrTop );
3999 : }
4000 :
4001 : // sprmSDyaTop
4002 35 : if ( m_rWW8Export.bWrtWW8 )
4003 35 : m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaTop );
4004 : else
4005 0 : m_rWW8Export.pO->push_back( 168 );
4006 35 : m_rWW8Export.InsUInt16( aDistances.dyaTop );
4007 :
4008 35 : if ( aDistances.HasFooter() )
4009 : {
4010 : //sprmSDyaHdrBottom
4011 8 : if ( m_rWW8Export.bWrtWW8 )
4012 8 : m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaHdrBottom );
4013 : else
4014 0 : m_rWW8Export.pO->push_back( 157 );
4015 8 : m_rWW8Export.InsUInt16( aDistances.dyaHdrBottom );
4016 : }
4017 :
4018 : //sprmSDyaBottom
4019 35 : if ( m_rWW8Export.bWrtWW8 )
4020 35 : m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaBottom );
4021 : else
4022 0 : m_rWW8Export.pO->push_back( 169 );
4023 35 : m_rWW8Export.InsUInt16( aDistances.dyaBottom );
4024 : }
4025 : else
4026 : {
4027 : // sprmPDyaBefore
4028 237 : if ( m_rWW8Export.bWrtWW8 )
4029 237 : m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaBefore );
4030 : else
4031 0 : m_rWW8Export.pO->push_back( 21 );
4032 237 : m_rWW8Export.InsUInt16( rUL.GetUpper() );
4033 : // sprmPDyaAfter
4034 237 : if( m_rWW8Export.bWrtWW8 )
4035 237 : m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaAfter );
4036 : else
4037 0 : m_rWW8Export.pO->push_back( 22 );
4038 237 : m_rWW8Export.InsUInt16( rUL.GetLower() );
4039 : // sprmPFContextualSpacing
4040 237 : if (m_rWW8Export.bWrtWW8 && rUL.GetContext())
4041 : {
4042 0 : m_rWW8Export.InsUInt16(NS_sprm::LN_PContextualSpacing);
4043 0 : m_rWW8Export.pO->push_back( (sal_uInt8)rUL.GetContext() );
4044 : }
4045 : }
4046 : }
4047 :
4048 : // Print, Opaque, Protect fehlen noch
4049 :
4050 0 : void WW8AttributeOutput::FormatSurround( const SwFormatSurround& rSurround )
4051 : {
4052 0 : if ( m_rWW8Export.m_bOutFlyFrmAttrs )
4053 : {
4054 0 : if ( m_rWW8Export.bWrtWW8 )
4055 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_PWr );
4056 : else
4057 0 : m_rWW8Export.pO->push_back( 37 );
4058 :
4059 : m_rWW8Export.pO->push_back(
4060 0 : ( SURROUND_NONE != rSurround.GetSurround() ) ? 2 : 1 );
4061 : }
4062 0 : }
4063 :
4064 0 : void WW8AttributeOutput::FormatVertOrientation( const SwFormatVertOrient& rFlyVert )
4065 : {
4066 : //!!!! Ankertyp und entsprechende Umrechnung fehlt noch
4067 :
4068 0 : if ( m_rWW8Export.m_bOutFlyFrmAttrs )
4069 : {
4070 : short nPos;
4071 0 : switch( rFlyVert.GetVertOrient() )
4072 : {
4073 : case text::VertOrientation::NONE:
4074 0 : nPos = (short)rFlyVert.GetPos();
4075 0 : break;
4076 : case text::VertOrientation::CENTER:
4077 : case text::VertOrientation::LINE_CENTER:
4078 0 : nPos = -8;
4079 0 : break;
4080 : case text::VertOrientation::BOTTOM:
4081 : case text::VertOrientation::LINE_BOTTOM:
4082 0 : nPos = -12;
4083 0 : break;
4084 : case text::VertOrientation::TOP:
4085 : case text::VertOrientation::LINE_TOP:
4086 : default:
4087 0 : nPos = -4;
4088 0 : break;
4089 : }
4090 :
4091 : // sprmPDyaAbs
4092 0 : if ( m_rWW8Export.bWrtWW8 )
4093 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaAbs );
4094 : else
4095 0 : m_rWW8Export.pO->push_back( 27 );
4096 0 : m_rWW8Export.InsUInt16( nPos );
4097 : }
4098 0 : }
4099 :
4100 0 : void WW8AttributeOutput::FormatHorizOrientation( const SwFormatHoriOrient& rFlyHori )
4101 : {
4102 0 : if ( !m_rWW8Export.m_pParentFrame )
4103 : {
4104 : OSL_ENSURE( m_rWW8Export.m_pParentFrame, "HoriOrient without mpParentFrame !!" );
4105 0 : return;
4106 : }
4107 :
4108 : //!!!! Ankertyp und entsprechende Umrechnung fehlt noch
4109 0 : if ( m_rWW8Export.m_bOutFlyFrmAttrs )
4110 : {
4111 : short nPos;
4112 0 : switch( rFlyHori.GetHoriOrient() )
4113 : {
4114 : case text::HoriOrientation::NONE:
4115 0 : nPos = (short)rFlyHori.GetPos();
4116 0 : if( !nPos )
4117 0 : nPos = 1; // WW: 0 ist reserviert
4118 0 : break;
4119 : case text::HoriOrientation::LEFT:
4120 0 : nPos = rFlyHori.IsPosToggle() ? -12 : 0;
4121 0 : break;
4122 : case text::HoriOrientation::RIGHT:
4123 0 : nPos = rFlyHori.IsPosToggle() ? -16 : -8;
4124 0 : break;
4125 : case text::HoriOrientation::CENTER:
4126 : case text::HoriOrientation::FULL: // FULL nur fuer Tabellen
4127 : default:
4128 0 : nPos = -4;
4129 0 : break;
4130 : }
4131 :
4132 : // sprmPDxaAbs
4133 0 : if( m_rWW8Export.bWrtWW8 )
4134 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_PDxaAbs );
4135 : else
4136 0 : m_rWW8Export.pO->push_back( 26 );
4137 0 : m_rWW8Export.InsUInt16( nPos );
4138 : }
4139 : }
4140 :
4141 0 : void WW8AttributeOutput::FormatAnchor( const SwFormatAnchor& rAnchor )
4142 : {
4143 : OSL_ENSURE( m_rWW8Export.m_pParentFrame, "Anchor without mpParentFrame !!" );
4144 :
4145 0 : if ( m_rWW8Export.m_bOutFlyFrmAttrs )
4146 : {
4147 0 : sal_uInt8 nP = 0;
4148 0 : switch ( rAnchor.GetAnchorId() )
4149 : {
4150 : case FLY_AT_PAGE:
4151 : // Vert: Page | Horz: Page
4152 0 : nP |= (1 << 4) | (2 << 6);
4153 0 : break;
4154 : // Im Fall eine Flys als Zeichen: Absatz-gebunden setzen!!!
4155 : case FLY_AT_FLY:
4156 : case FLY_AT_CHAR:
4157 : case FLY_AT_PARA:
4158 : case FLY_AS_CHAR:
4159 : // Vert: Page | Horz: Page
4160 0 : nP |= (2 << 4) | (0 << 6);
4161 0 : break;
4162 : default:
4163 0 : break;
4164 : }
4165 :
4166 : // sprmPPc
4167 0 : if ( m_rWW8Export.bWrtWW8 )
4168 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_PPc );
4169 : else
4170 0 : m_rWW8Export.pO->push_back( 29 );
4171 0 : m_rWW8Export.pO->push_back( nP );
4172 : }
4173 0 : }
4174 :
4175 9 : void WW8AttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
4176 : {
4177 : // WW cannot have background in a section
4178 9 : if ( !m_rWW8Export.m_bOutPageDescs )
4179 : {
4180 9 : WW8_SHD aSHD;
4181 :
4182 9 : m_rWW8Export.TransBrush( rBrush.GetColor(), aSHD );
4183 : // sprmPShd
4184 9 : if ( m_rWW8Export.bWrtWW8 )
4185 9 : m_rWW8Export.InsUInt16( NS_sprm::LN_PShd );
4186 : else
4187 0 : m_rWW8Export.pO->push_back(47);
4188 9 : m_rWW8Export.InsUInt16( aSHD.GetValue() );
4189 :
4190 : // Quite a few unknowns, some might be transparency or something
4191 : // of that nature...
4192 9 : if ( m_rWW8Export.bWrtWW8 )
4193 : {
4194 9 : m_rWW8Export.InsUInt16( 0xC64D );
4195 9 : m_rWW8Export.pO->push_back( 10 );
4196 9 : m_rWW8Export.InsUInt32( 0xFF000000 );
4197 9 : m_rWW8Export.InsUInt32( SuitableBGColor( rBrush.GetColor().GetColor() ) );
4198 9 : m_rWW8Export.InsUInt16( 0x0000 );
4199 : }
4200 : }
4201 9 : }
4202 :
4203 42 : void WW8AttributeOutput::FormatFillStyle( const XFillStyleItem& /*rFillStyle*/ )
4204 : {
4205 42 : }
4206 :
4207 0 : void WW8AttributeOutput::FormatFillGradient( const XFillGradientItem& /*rFillGradient*/ )
4208 : {
4209 0 : }
4210 :
4211 392 : WW8_BRCVer9 WW8Export::TranslateBorderLine(const SvxBorderLine& rLine,
4212 : sal_uInt16 nDist, bool bShadow)
4213 : {
4214 392 : sal_uInt32 nColBGR = 0;
4215 : sal_uInt16 nWidth = ::editeng::ConvertBorderWidthToWord(
4216 392 : rLine.GetBorderLineStyle(), rLine.GetWidth());
4217 392 : sal_uInt8 brcType = 0;
4218 :
4219 392 : if( nWidth ) // Linie ?
4220 : {
4221 : // BRC.brcType
4222 392 : bool bThick = !rLine.isDouble() && !bWrtWW8 && nWidth > 75;
4223 392 : if( bThick )
4224 0 : brcType = 2;
4225 : else
4226 : {
4227 392 : brcType = 0;
4228 392 : if ( bWrtWW8 )
4229 : {
4230 : // All the border types values are available on
4231 : // http://msdn.microsoft.com/en-us/library/dd908142%28v=office.12%29.aspx
4232 392 : switch (rLine.GetBorderLineStyle())
4233 : {
4234 : case table::BorderLineStyle::SOLID:
4235 : {
4236 331 : if ( rLine.GetWidth( ) == DEF_LINE_WIDTH_0 )
4237 0 : brcType = 5;
4238 : else
4239 331 : brcType = 1;
4240 : }
4241 331 : break;
4242 : case table::BorderLineStyle::DOTTED:
4243 25 : brcType = 6;
4244 25 : break;
4245 : case table::BorderLineStyle::DASHED:
4246 2 : brcType = 7;
4247 2 : break;
4248 : case table::BorderLineStyle::DOUBLE:
4249 13 : brcType = 3;
4250 13 : break;
4251 : case table::BorderLineStyle::THINTHICK_SMALLGAP:
4252 16 : brcType = 11;
4253 16 : break;
4254 : case table::BorderLineStyle::THINTHICK_MEDIUMGAP:
4255 0 : brcType = 14;
4256 0 : break;
4257 : case table::BorderLineStyle::THINTHICK_LARGEGAP:
4258 0 : brcType = 17;
4259 0 : break;
4260 : case table::BorderLineStyle::THICKTHIN_SMALLGAP:
4261 0 : brcType = 12;
4262 0 : break;
4263 : case table::BorderLineStyle::THICKTHIN_MEDIUMGAP:
4264 0 : brcType = 15;
4265 0 : break;
4266 : case table::BorderLineStyle::THICKTHIN_LARGEGAP:
4267 0 : brcType = 18;
4268 0 : break;
4269 : case table::BorderLineStyle::EMBOSSED:
4270 0 : brcType = 24;
4271 0 : break;
4272 : case table::BorderLineStyle::ENGRAVED:
4273 0 : brcType = 25;
4274 0 : break;
4275 : case table::BorderLineStyle::OUTSET:
4276 0 : brcType = 26;
4277 0 : break;
4278 : case table::BorderLineStyle::INSET:
4279 0 : brcType = 27;
4280 0 : break;
4281 : case table::BorderLineStyle::FINE_DASHED:
4282 5 : brcType = 22;
4283 5 : break;
4284 : case table::BorderLineStyle::DASH_DOT:
4285 0 : brcType = 8;
4286 0 : break;
4287 : case table::BorderLineStyle::DASH_DOT_DOT:
4288 0 : brcType = 9;
4289 0 : break;
4290 : default:
4291 0 : break;
4292 : }
4293 : }
4294 : }
4295 :
4296 : // BRC.dptLineWidth
4297 392 : if( bThick )
4298 0 : nWidth /= 2;
4299 :
4300 : // convert width from twips (1/20 pt) to eighths of a point
4301 392 : nWidth = (( nWidth * 8 ) + 10 ) / 20;
4302 392 : if( 0xff < nWidth )
4303 0 : nWidth = 0xff;
4304 :
4305 392 : if( 0 == nWidth ) // ganz duenne Linie
4306 0 : nWidth = 1; // nicht weglassen
4307 :
4308 : // BRC.cv
4309 392 : nColBGR = wwUtility::RGBToBGR(rLine.GetColor().GetRGBColor());
4310 : }
4311 :
4312 : // BRC.dptSpace
4313 392 : sal_uInt16 nLDist = nDist;
4314 392 : nLDist /= 20; // Masseinheit : pt
4315 392 : if( nLDist > 0x1f )
4316 4 : nLDist = 0x1f;
4317 :
4318 : return WW8_BRCVer9(nColBGR, sal_uInt8(nWidth), brcType, sal_uInt8(nLDist),
4319 392 : bShadow, false);
4320 : }
4321 :
4322 : // MakeBorderLine() bekommt einen WW8Bytes* uebergeben, um die Funktion
4323 : // auch fuer die Tabellen-Umrandungen zu benutzen.
4324 : // Wenn nSprmNo == 0, dann wird der Opcode nicht ausgegeben.
4325 : // bShadow darf bei Tabellenzellen *nicht* gesetzt sein !
4326 572 : void WW8Export::Out_BorderLine(ww::bytes& rO, const SvxBorderLine* pLine,
4327 : sal_uInt16 nDist, sal_uInt16 nSprmNo, sal_uInt16 nSprmNoVer9, bool bShadow)
4328 : {
4329 : OSL_ENSURE( ( nSprmNo == 0 ) ||
4330 : ( nSprmNo >= 38 && nSprmNo <= 41 ) ||
4331 : ( nSprmNo >= NS_sprm::LN_PBrcTop80
4332 : && nSprmNo <= NS_sprm::LN_PBrcRight80 ) ||
4333 : ( nSprmNo >= NS_sprm::LN_SBrcTop80
4334 : && nSprmNo <= NS_sprm::LN_SBrcRight80 ),
4335 : "Sprm for border out is of range" );
4336 :
4337 572 : WW8_BRCVer9 aBrcVer9;
4338 572 : WW8_BRC aBrcVer8;
4339 :
4340 572 : if( pLine && pLine->GetBorderLineStyle() != table::BorderLineStyle::NONE )
4341 : {
4342 215 : aBrcVer9 = TranslateBorderLine( *pLine, nDist, bShadow );
4343 215 : sal_uInt8 ico = msfilter::util::TransColToIco( msfilter::util::BGRToRGB(aBrcVer9.cv()) );
4344 430 : aBrcVer8 = WW8_BRC( aBrcVer9.dptLineWidth(), aBrcVer9.brcType(), ico,
4345 645 : aBrcVer9.dptSpace(), aBrcVer9.fShadow(), aBrcVer9.fFrame() );
4346 : }
4347 :
4348 572 : if( bWrtWW8 )
4349 : {
4350 : // WW97-SprmIds
4351 572 : if ( nSprmNo != 0 )
4352 28 : SwWW8Writer::InsUInt16( rO, nSprmNo );
4353 :
4354 572 : rO.insert( rO.end(), aBrcVer8.aBits1, aBrcVer8.aBits2+2 );
4355 :
4356 572 : if ( nSprmNoVer9 != 0 )
4357 : {
4358 28 : SwWW8Writer::InsUInt16( rO, nSprmNoVer9 );
4359 28 : rO.push_back(sizeof(WW8_BRCVer9));
4360 28 : rO.insert( rO.end(), aBrcVer9.aBits1, aBrcVer9.aBits2+4);
4361 : }
4362 : }
4363 : else
4364 : {
4365 0 : WW8_BRCVer6 aBrcVer6(aBrcVer8);
4366 : // WW95-SprmIds
4367 0 : if ( nSprmNo != 0 )
4368 0 : rO.push_back( static_cast<sal_uInt8>( nSprmNo ) );
4369 0 : rO.insert( rO.end(), aBrcVer6.aBits1, aBrcVer6.aBits1+2 );
4370 : }
4371 572 : }
4372 :
4373 : // FormatBox1() ist fuer alle Boxen ausser in Tabellen.
4374 : // es wird pO des WW8Writers genommen
4375 6 : void WW8Export::Out_SwFormatBox(const SvxBoxItem& rBox, bool bShadow)
4376 : {
4377 6 : if ( m_bOutPageDescs && !bWrtWW8 )
4378 6 : return; // no page ouline in WW6
4379 :
4380 : static const SvxBoxItemLine aBorders[] =
4381 : {
4382 : SvxBoxItemLine::TOP, SvxBoxItemLine::LEFT, SvxBoxItemLine::BOTTOM, SvxBoxItemLine::RIGHT
4383 : };
4384 : static const sal_uInt16 aPBrc[] =
4385 : {
4386 : // WW8 SPRMs
4387 : NS_sprm::LN_PBrcTop80, NS_sprm::LN_PBrcLeft80,
4388 : NS_sprm::LN_PBrcBottom80, NS_sprm::LN_PBrcRight80,
4389 : // WW9 SPRMs
4390 : NS_sprm::LN_PBrcTop, NS_sprm::LN_PBrcLeft,
4391 : NS_sprm::LN_PBrcBottom, NS_sprm::LN_PBrcRight
4392 : };
4393 : static const sal_uInt16 aSBrc[] =
4394 : {
4395 : // WW8 SPRMs
4396 : NS_sprm::LN_SBrcTop80, NS_sprm::LN_SBrcLeft80,
4397 : NS_sprm::LN_SBrcBottom80, NS_sprm::LN_SBrcRight80,
4398 : // WW9 SPRMs
4399 : NS_sprm::LN_SBrcTop, NS_sprm::LN_SBrcLeft,
4400 : NS_sprm::LN_SBrcBottom, NS_sprm::LN_SBrcRight
4401 : };
4402 : static const sal_uInt16 aWW6PBrc[] =
4403 : {
4404 : 38, 39, 40, 41
4405 : };
4406 :
4407 6 : const SvxBoxItemLine* pBrd = aBorders;
4408 30 : for( sal_uInt16 i = 0; i < 4; ++i, ++pBrd )
4409 : {
4410 24 : const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
4411 :
4412 24 : sal_uInt16 nSprmNo, nSprmNoVer9 = 0;
4413 24 : if ( !bWrtWW8 )
4414 0 : nSprmNo = aWW6PBrc[i];
4415 24 : else if ( m_bOutPageDescs )
4416 : {
4417 4 : nSprmNo = aSBrc[i];
4418 4 : nSprmNoVer9 = aSBrc[i+4];
4419 : }
4420 : else
4421 : {
4422 20 : nSprmNo = aPBrc[i];
4423 20 : nSprmNoVer9 = aPBrc[i+4];
4424 : }
4425 :
4426 24 : Out_BorderLine( *pO, pLn, rBox.GetDistance( *pBrd ), nSprmNo,
4427 48 : nSprmNoVer9, bShadow );
4428 : }
4429 : }
4430 :
4431 : // FormatBox2() ist fuer TC-Strukturen in Tabellen. Der Sprm-Opcode
4432 : // wird nicht geschrieben, da es in der TC-Structur ohne Opcode gepackt ist.
4433 : // dxpSpace wird immer 0, da WW das in Tabellen so verlangt
4434 : // ( Tabellenumrandungen fransen sonst aus )
4435 : // Ein WW8Bytes-Ptr wird als Ausgabe-Parameter uebergeben
4436 :
4437 136 : void WW8Export::Out_SwFormatTableBox( ww::bytes& rO, const SvxBoxItem * pBox )
4438 : {
4439 : // moeglich und vielleicht besser waere 0xffff
4440 136 : static const SvxBorderLine aBorderLine;
4441 :
4442 680 : for( SvxBoxItemLine i : o3tl::enumrange<SvxBoxItemLine>() )
4443 : {
4444 : const SvxBorderLine* pLn;
4445 544 : if (pBox != NULL)
4446 544 : pLn = pBox->GetLine( i );
4447 : else
4448 0 : pLn = & aBorderLine;
4449 :
4450 544 : Out_BorderLine(rO, pLn, 0, 0, 0, false);
4451 : }
4452 136 : }
4453 :
4454 94 : void WW8Export::Out_CellRangeBorders( const SvxBoxItem * pBox, sal_uInt8 nStart,
4455 : sal_uInt8 nLimit )
4456 : {
4457 : static const SvxBoxItemLine aBorders[] =
4458 : {
4459 : SvxBoxItemLine::TOP, SvxBoxItemLine::LEFT, SvxBoxItemLine::BOTTOM, SvxBoxItemLine::RIGHT
4460 : };
4461 :
4462 470 : for( int i = 0; i < 4; ++i )
4463 : {
4464 376 : const SvxBorderLine* pLn = 0;
4465 376 : if (pBox != NULL)
4466 376 : pLn = pBox->GetLine( aBorders[i] );
4467 376 : if (!pLn)
4468 203 : continue;
4469 :
4470 173 : InsUInt16( NS_sprm::LN_TSetBrc );
4471 173 : pO->push_back( 11 );
4472 173 : pO->push_back( nStart );
4473 173 : pO->push_back( nLimit );
4474 173 : pO->push_back( 1<<i );
4475 173 : WW8_BRCVer9 aBrcVer9 = TranslateBorderLine( *pLn, 0, false );
4476 173 : pO->insert( pO->end(), aBrcVer9.aBits1, aBrcVer9.aBits2+4 );
4477 : }
4478 94 : }
4479 :
4480 6 : void WW8AttributeOutput::FormatBox( const SvxBoxItem& rBox )
4481 : {
4482 : // Fly um Grafik-> keine Umrandung hier, da
4483 : // der GrafikHeader bereits die Umrandung hat
4484 6 : if ( !m_rWW8Export.m_bOutGrf )
4485 : {
4486 6 : bool bShadow = false;
4487 6 : const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_SHADOW );
4488 6 : if ( pItem )
4489 : {
4490 0 : const SvxShadowItem* p = static_cast<const SvxShadowItem*>(pItem);
4491 0 : bShadow = ( p->GetLocation() != SVX_SHADOW_NONE )
4492 0 : && ( p->GetWidth() != 0 );
4493 : }
4494 :
4495 6 : m_rWW8Export.Out_SwFormatBox( rBox, bShadow );
4496 : }
4497 6 : }
4498 :
4499 0 : SwTwips WW8Export::CurrentPageWidth(SwTwips &rLeft, SwTwips &rRight) const
4500 : {
4501 0 : const SwFrameFormat* pFormat = m_pAktPageDesc ? &m_pAktPageDesc->GetMaster()
4502 0 : : &m_pDoc->GetPageDesc(0).GetMaster();
4503 :
4504 0 : const SvxLRSpaceItem& rLR = pFormat->GetLRSpace();
4505 0 : SwTwips nPageSize = pFormat->GetFrmSize().GetWidth();
4506 0 : rLeft = rLR.GetLeft();
4507 0 : rRight = rLR.GetRight();
4508 0 : return nPageSize;
4509 : }
4510 :
4511 0 : void WW8AttributeOutput::FormatColumns_Impl( sal_uInt16 nCols, const SwFormatCol & rCol, bool bEven, SwTwips nPageSize )
4512 : {
4513 : // CColumns
4514 0 : if ( m_rWW8Export.bWrtWW8 )
4515 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_SCcolumns );
4516 : else
4517 0 : m_rWW8Export.pO->push_back( 144 );
4518 0 : m_rWW8Export.InsUInt16( nCols - 1 );
4519 :
4520 : // DxaColumns
4521 0 : if ( m_rWW8Export.bWrtWW8 )
4522 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaColumns );
4523 : else
4524 0 : m_rWW8Export.pO->push_back( 145 );
4525 0 : m_rWW8Export.InsUInt16( rCol.GetGutterWidth( true ) );
4526 :
4527 : // LBetween
4528 0 : if ( m_rWW8Export.bWrtWW8 )
4529 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_SLBetween );
4530 : else
4531 0 : m_rWW8Export.pO->push_back( 158 );
4532 0 : m_rWW8Export.pO->push_back( COLADJ_NONE == rCol.GetLineAdj( )? 0 : 1 );
4533 :
4534 0 : const SwColumns & rColumns = rCol.GetColumns( );
4535 :
4536 : // FEvenlySpaced
4537 0 : if ( m_rWW8Export.bWrtWW8 )
4538 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_SFEvenlySpaced );
4539 : else
4540 0 : m_rWW8Export.pO->push_back( 138 );
4541 0 : m_rWW8Export.pO->push_back( bEven ? 1 : 0 );
4542 :
4543 0 : if ( !bEven )
4544 : {
4545 0 : for ( sal_uInt16 n = 0; n < nCols; ++n )
4546 : {
4547 : //sprmSDxaColWidth
4548 0 : if ( m_rWW8Export.bWrtWW8 )
4549 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaColWidth );
4550 : else
4551 0 : m_rWW8Export.pO->push_back( 136 );
4552 0 : m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(n) );
4553 : m_rWW8Export.InsUInt16( rCol.
4554 : CalcPrtColWidth( n,
4555 0 : ( sal_uInt16 ) nPageSize ) );
4556 :
4557 0 : if ( n + 1 != nCols )
4558 : {
4559 : //sprmSDxaColSpacing
4560 0 : if ( m_rWW8Export.bWrtWW8 )
4561 0 : m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaColSpacing );
4562 : else
4563 0 : m_rWW8Export.pO->push_back( 137 );
4564 0 : m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(n) );
4565 0 : m_rWW8Export.InsUInt16( rColumns[n].GetRight( ) +
4566 0 : rColumns[n + 1].GetLeft( ) );
4567 : }
4568 : }
4569 : }
4570 0 : }
4571 :
4572 46 : void AttributeOutputBase::FormatColumns( const SwFormatCol& rCol )
4573 : {
4574 46 : const SwColumns& rColumns = rCol.GetColumns();
4575 :
4576 46 : sal_uInt16 nCols = rColumns.size();
4577 46 : if ( 1 < nCols && !GetExport( ).m_bOutFlyFrmAttrs )
4578 : {
4579 : // dann besorge mal die Seitenbreite ohne Raender !!
4580 :
4581 20 : const SwFrameFormat* pFormat = GetExport( ).m_pAktPageDesc ? &GetExport( ).m_pAktPageDesc->GetMaster() : &const_cast<const SwDoc *>(GetExport( ).m_pDoc)->GetPageDesc(0).GetMaster();
4582 20 : const SvxFrameDirectionItem &frameDirection = pFormat->GetFrmDir();
4583 : SwTwips nPageSize;
4584 20 : if ( frameDirection.GetValue() == FRMDIR_VERT_TOP_RIGHT || frameDirection.GetValue() == FRMDIR_VERT_TOP_LEFT )
4585 : {
4586 0 : const SvxULSpaceItem &rUL = pFormat->GetULSpace();
4587 0 : nPageSize = pFormat->GetFrmSize().GetHeight();
4588 0 : nPageSize -= rUL.GetUpper() + rUL.GetLower();
4589 :
4590 0 : const SwFormatHeader *header = dynamic_cast<const SwFormatHeader *>(pFormat->GetAttrSet().GetItem(RES_HEADER));
4591 0 : if ( header )
4592 : {
4593 0 : const SwFrameFormat *headerFormat = header->GetHeaderFormat();
4594 0 : if (headerFormat)
4595 : {
4596 0 : nPageSize -= headerFormat->GetFrmSize().GetHeight();
4597 : }
4598 : }
4599 0 : const SwFormatFooter *footer = dynamic_cast<const SwFormatFooter *>(pFormat->GetAttrSet().GetItem(RES_FOOTER));
4600 0 : if ( footer )
4601 : {
4602 0 : const SwFrameFormat *footerFormat = footer->GetFooterFormat();
4603 0 : if ( footerFormat )
4604 : {
4605 0 : nPageSize -= footerFormat->GetFrmSize().GetHeight();
4606 : }
4607 : }
4608 : }
4609 : else
4610 : {
4611 20 : const SvxLRSpaceItem &rLR = pFormat->GetLRSpace();
4612 20 : nPageSize = pFormat->GetFrmSize().GetWidth();
4613 20 : nPageSize -= rLR.GetLeft() + rLR.GetRight();
4614 : //i120133: The Section width should consider page indent value.
4615 20 : nPageSize -= rCol.GetAdjustValue();
4616 :
4617 : }
4618 :
4619 : // Nachsehen, ob alle Spalten gleich sind
4620 20 : bool bEven = true;
4621 : sal_uInt16 n;
4622 20 : sal_uInt16 nColWidth = rCol.CalcPrtColWidth( 0, (sal_uInt16)nPageSize );
4623 34 : for ( n = 1; n < nCols; n++ )
4624 : {
4625 : short nDiff = nColWidth -
4626 20 : rCol.CalcPrtColWidth( n, (sal_uInt16)nPageSize );
4627 :
4628 20 : if ( nDiff > 10 || nDiff < -10 ) // Toleranz: 10 tw
4629 : {
4630 6 : bEven = false;
4631 6 : break;
4632 : }
4633 : }
4634 :
4635 20 : FormatColumns_Impl( nCols, rCol, bEven, nPageSize );
4636 : }
4637 46 : }
4638 :
4639 : // "Paragraphs together"
4640 44 : void WW8AttributeOutput::FormatKeep( const SvxFormatKeepItem& rKeep )
4641 : {
4642 : // sprmFKeepFollow
4643 44 : if ( m_rWW8Export.bWrtWW8 )
4644 44 : m_rWW8Export.InsUInt16( NS_sprm::LN_PFKeepFollow );
4645 : else
4646 0 : m_rWW8Export.pO->push_back( 8 );
4647 :
4648 44 : m_rWW8Export.pO->push_back( rKeep.GetValue() ? 1 : 0 );
4649 44 : }
4650 :
4651 : // exclude a paragraph from Line Numbering
4652 91 : void WW8AttributeOutput::FormatLineNumbering( const SwFormatLineNumber& rNumbering )
4653 : {
4654 : // sprmPFNoLineNumb
4655 91 : if( m_rWW8Export.bWrtWW8 )
4656 91 : m_rWW8Export.InsUInt16( NS_sprm::LN_PFNoLineNumb );
4657 : else
4658 0 : m_rWW8Export.pO->push_back( 14 );
4659 :
4660 91 : m_rWW8Export.pO->push_back( rNumbering.IsCount() ? 0 : 1 );
4661 91 : }
4662 :
4663 : /* File PARATR.HXX */
4664 :
4665 96 : void WW8AttributeOutput::ParaLineSpacing_Impl( short nSpace, short nMulti )
4666 : {
4667 : // sprmPDyaLine
4668 96 : if ( m_rWW8Export.bWrtWW8 )
4669 96 : m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaLine );
4670 : else
4671 0 : m_rWW8Export.pO->push_back( 20 );
4672 :
4673 96 : m_rWW8Export.InsUInt16( nSpace );
4674 96 : m_rWW8Export.InsUInt16( nMulti );
4675 96 : }
4676 :
4677 4140 : void AttributeOutputBase::ParaLineSpacing( const SvxLineSpacingItem& rSpacing )
4678 : {
4679 4140 : short nSpace = 240, nMulti = 0;
4680 :
4681 4140 : switch ( rSpacing.GetLineSpaceRule() )
4682 : {
4683 : default:
4684 0 : break;
4685 : case SVX_LINE_SPACE_FIX: // Fix
4686 187 : nSpace = -(short)rSpacing.GetLineHeight();
4687 187 : break;
4688 : case SVX_LINE_SPACE_MIN: // At least
4689 313 : nSpace = (short)rSpacing.GetLineHeight();
4690 313 : break;
4691 : case SVX_LINE_SPACE_AUTO:
4692 : {
4693 3640 : if( rSpacing.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_FIX ) // Leading
4694 : {
4695 : // gibt es aber nicht in WW - also wie kommt man an
4696 : // die MaxLineHeight heran?
4697 0 : nSpace = (short)rSpacing.GetInterLineSpace();
4698 : sal_uInt16 nScript =
4699 0 : i18n::ScriptType::LATIN;
4700 0 : const SwAttrSet *pSet = 0;
4701 0 : if ( GetExport().m_pOutFormatNode && GetExport().m_pOutFormatNode->ISA( SwFormat ) )
4702 : {
4703 0 : const SwFormat *pFormat = static_cast<const SwFormat*>( GetExport().m_pOutFormatNode );
4704 0 : pSet = &pFormat->GetAttrSet();
4705 : }
4706 0 : else if ( GetExport().m_pOutFormatNode && GetExport().m_pOutFormatNode->ISA( SwTextNode ) )
4707 : {
4708 0 : const SwTextNode* pNd = static_cast<const SwTextNode*>(GetExport().m_pOutFormatNode);
4709 0 : pSet = &pNd->GetSwAttrSet();
4710 0 : if ( g_pBreakIt->GetBreakIter().is() )
4711 : {
4712 0 : nScript = g_pBreakIt->GetBreakIter()->
4713 0 : getScriptType(pNd->GetText(), 0);
4714 : }
4715 : }
4716 : OSL_ENSURE( pSet, "No attrset for lineheight :-(" );
4717 0 : if ( pSet )
4718 : {
4719 0 : nSpace = nSpace + (short)( AttrSetToLineHeight( GetExport().m_pDoc->getIDocumentSettingAccess(),
4720 0 : *pSet, *Application::GetDefaultDevice(), nScript ) );
4721 : }
4722 : }
4723 : else // Proportional
4724 : {
4725 3640 : nSpace = (short)( ( 240L * rSpacing.GetPropLineSpace() ) / 100L );
4726 3640 : nMulti = 1;
4727 3640 : break;
4728 : }
4729 : }
4730 0 : break;
4731 : }
4732 : // if nSpace is negative, it is a fixed size in 1/20 of a point
4733 : // if nSpace is positive and nMulti is 1, it is 1/240 of a single line height
4734 : // otherwise, it is a minimum size in 1/20 of a point
4735 4140 : ParaLineSpacing_Impl( nSpace, nMulti );
4736 4140 : }
4737 :
4738 58 : void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
4739 : {
4740 : // sprmPJc
4741 58 : sal_uInt8 nAdj = 255;
4742 58 : sal_uInt8 nAdjBiDi = 255;
4743 58 : switch ( rAdjust.GetAdjust() )
4744 : {
4745 : case SVX_ADJUST_LEFT:
4746 14 : nAdj = 0;
4747 14 : nAdjBiDi = 2;
4748 14 : break;
4749 : case SVX_ADJUST_RIGHT:
4750 5 : nAdj = 2;
4751 5 : nAdjBiDi = 0;
4752 5 : break;
4753 : case SVX_ADJUST_BLOCKLINE:
4754 : case SVX_ADJUST_BLOCK:
4755 7 : nAdj = nAdjBiDi = 3;
4756 7 : break;
4757 : case SVX_ADJUST_CENTER:
4758 32 : nAdj = nAdjBiDi = 1;
4759 32 : break;
4760 : default:
4761 58 : return; // not a supported Attribut
4762 : }
4763 :
4764 58 : if ( 255 != nAdj ) // supported Attribut?
4765 : {
4766 58 : if ( m_rWW8Export.bWrtWW8 )
4767 : {
4768 58 : m_rWW8Export.InsUInt16( NS_sprm::LN_PJc );
4769 58 : m_rWW8Export.pO->push_back( nAdj );
4770 :
4771 : /*
4772 : Sadly for left to right paragraphs both these values are the same,
4773 : for right to left paragraphs the bidi one is the reverse of the
4774 : normal one.
4775 : */
4776 58 : m_rWW8Export.InsUInt16( NS_sprm::LN_PJcExtra ); //bidi version ?
4777 58 : bool bBiDiSwap = false;
4778 58 : if ( m_rWW8Export.m_pOutFormatNode )
4779 : {
4780 51 : short nDirection = FRMDIR_HORI_LEFT_TOP;
4781 51 : if ( m_rWW8Export.m_pOutFormatNode->ISA( SwTextNode ) )
4782 : {
4783 33 : SwPosition aPos(*static_cast<const SwContentNode*>(m_rWW8Export.m_pOutFormatNode));
4784 33 : nDirection = m_rWW8Export.m_pDoc->GetTextDirection(aPos);
4785 : }
4786 18 : else if ( m_rWW8Export.m_pOutFormatNode->ISA( SwTextFormatColl ) )
4787 : {
4788 : const SwTextFormatColl* pC =
4789 18 : static_cast<const SwTextFormatColl*>(m_rWW8Export.m_pOutFormatNode);
4790 : const SvxFrameDirectionItem &rItem =
4791 18 : ItemGet<SvxFrameDirectionItem>(*pC, RES_FRAMEDIR);
4792 18 : nDirection = rItem.GetValue();
4793 : }
4794 51 : if ( ( nDirection == FRMDIR_HORI_RIGHT_TOP ) ||
4795 0 : ( nDirection == FRMDIR_ENVIRONMENT && AllSettings::GetLayoutRTL() ) )
4796 : {
4797 0 : bBiDiSwap = true;
4798 : }
4799 : }
4800 :
4801 58 : if ( bBiDiSwap )
4802 0 : m_rWW8Export.pO->push_back( nAdjBiDi );
4803 : else
4804 58 : m_rWW8Export.pO->push_back( nAdj );
4805 : }
4806 : else
4807 : {
4808 0 : m_rWW8Export.pO->push_back( 5 );
4809 0 : m_rWW8Export.pO->push_back( nAdj );
4810 : }
4811 : }
4812 : }
4813 :
4814 93 : void WW8AttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDirection )
4815 : {
4816 93 : if ( !m_rWW8Export.bWrtWW8 ) //8+ only
4817 93 : return;
4818 :
4819 93 : sal_uInt16 nTextFlow=0;
4820 93 : bool bBiDi = false;
4821 93 : short nDir = rDirection.GetValue();
4822 :
4823 93 : if ( nDir == FRMDIR_ENVIRONMENT )
4824 : {
4825 7 : if ( m_rWW8Export.m_bOutPageDescs )
4826 0 : nDir = m_rWW8Export.GetCurrentPageDirection();
4827 7 : else if ( m_rWW8Export.m_pOutFormatNode )
4828 : {
4829 7 : if ( m_rWW8Export.m_bOutFlyFrmAttrs ) //frame
4830 : {
4831 : nDir = m_rWW8Export.TrueFrameDirection(
4832 0 : *static_cast<const SwFrameFormat*>(m_rWW8Export.m_pOutFormatNode) );
4833 : }
4834 7 : else if ( m_rWW8Export.m_pOutFormatNode->ISA( SwContentNode ) ) //pagagraph
4835 : {
4836 : const SwContentNode* pNd =
4837 0 : static_cast<const SwContentNode*>(m_rWW8Export.m_pOutFormatNode);
4838 0 : SwPosition aPos( *pNd );
4839 0 : nDir = m_rWW8Export.m_pDoc->GetTextDirection( aPos );
4840 : }
4841 7 : else if ( m_rWW8Export.m_pOutFormatNode->ISA( SwTextFormatColl ) )
4842 7 : nDir = FRMDIR_HORI_LEFT_TOP; //what else can we do :-(
4843 : }
4844 :
4845 7 : if ( nDir == FRMDIR_ENVIRONMENT )
4846 0 : nDir = FRMDIR_HORI_LEFT_TOP; //Set something
4847 : }
4848 :
4849 93 : switch ( nDir )
4850 : {
4851 : default:
4852 : //Can't get an unknown type here
4853 : OSL_FAIL("Unknown frame direction");
4854 : //fall-through
4855 : case FRMDIR_HORI_LEFT_TOP:
4856 93 : nTextFlow = 0;
4857 93 : break;
4858 : case FRMDIR_HORI_RIGHT_TOP:
4859 0 : nTextFlow = 0;
4860 0 : bBiDi = true;
4861 0 : break;
4862 : case FRMDIR_VERT_TOP_LEFT: //word doesn't have this
4863 : case FRMDIR_VERT_TOP_RIGHT:
4864 0 : nTextFlow = 1;
4865 0 : break;
4866 : }
4867 :
4868 93 : if ( m_rWW8Export.m_bOutPageDescs )
4869 : {
4870 35 : m_rWW8Export.InsUInt16( NS_sprm::LN_STextFlow );
4871 35 : m_rWW8Export.InsUInt16( nTextFlow );
4872 35 : m_rWW8Export.InsUInt16( NS_sprm::LN_SFBiDi );
4873 35 : m_rWW8Export.pO->push_back( bBiDi ? 1 : 0 );
4874 : }
4875 58 : else if ( !m_rWW8Export.m_bOutFlyFrmAttrs ) //paragraph/style
4876 : {
4877 58 : m_rWW8Export.InsUInt16( NS_sprm::LN_PFBiDi );
4878 58 : m_rWW8Export.pO->push_back( bBiDi ? 1 : 0 );
4879 : }
4880 : }
4881 :
4882 0 : void WW8AttributeOutput::ParaGrabBag(const SfxGrabBagItem& /*rItem*/)
4883 : {
4884 0 : }
4885 :
4886 275 : void WW8AttributeOutput::CharGrabBag(const SfxGrabBagItem& /*rItem*/)
4887 : {
4888 275 : }
4889 :
4890 28 : void WW8AttributeOutput::ParaOutlineLevel(const SfxUInt16Item& /*rItem*/)
4891 : {
4892 28 : }
4893 :
4894 : // "Separate paragraphs"
4895 3 : void WW8AttributeOutput::ParaSplit( const SvxFormatSplitItem& rSplit )
4896 : {
4897 : // sprmPFKeep
4898 3 : if ( m_rWW8Export.bWrtWW8 )
4899 3 : m_rWW8Export.InsUInt16( NS_sprm::LN_PFKeep );
4900 : else
4901 0 : m_rWW8Export.pO->push_back( 7 );
4902 3 : m_rWW8Export.pO->push_back( rSplit.GetValue() ? 0 : 1 );
4903 3 : }
4904 :
4905 : // Es wird nur das Item "SvxWidowItem" und nicht die Orphans uebersetzt,
4906 : // da es fuer beides im WW nur ein Attribut "Absatzkontrolle" gibt und
4907 : // im SW wahrscheinlich vom Anwender immer Beide oder keiner gesetzt werden.
4908 50 : void WW8AttributeOutput::ParaWidows( const SvxWidowsItem& rWidows )
4909 : {
4910 : // sprmPFWidowControl
4911 50 : if( m_rWW8Export.bWrtWW8 )
4912 50 : m_rWW8Export.InsUInt16( NS_sprm::LN_PFWidowControl );
4913 : else
4914 0 : m_rWW8Export.pO->push_back( 51 );
4915 50 : m_rWW8Export.pO->push_back( rWidows.GetValue() ? 1 : 0 );
4916 50 : }
4917 :
4918 : class SwWW8WrTabu
4919 : {
4920 : sal_uInt8* pDel; // DelArray
4921 : sal_uInt8* pAddPos; // AddPos-Array
4922 : sal_uInt8* pAddTyp; // AddTyp-Array
4923 : sal_uInt16 nAdd; // so viele Tabs kommen hinzu
4924 : sal_uInt16 nDel; // so viele Tabs fallen weg
4925 : public:
4926 : SwWW8WrTabu(sal_uInt16 nDelMax, sal_uInt16 nAddMax);
4927 : ~SwWW8WrTabu();
4928 :
4929 : void Add(const SvxTabStop &rTS, long nAdjustment);
4930 : void Del(const SvxTabStop &rTS, long nAdjustment);
4931 : void PutAll(WW8Export& rWW8Wrt);
4932 : };
4933 :
4934 79 : SwWW8WrTabu::SwWW8WrTabu(sal_uInt16 nDelMax, sal_uInt16 nAddMax)
4935 79 : : nAdd(0), nDel(0)
4936 : {
4937 79 : pDel = nDelMax ? new sal_uInt8[nDelMax * 2] : 0;
4938 79 : pAddPos = new sal_uInt8[nAddMax * 2];
4939 79 : pAddTyp = new sal_uInt8[nAddMax];
4940 79 : }
4941 :
4942 79 : SwWW8WrTabu::~SwWW8WrTabu()
4943 : {
4944 79 : delete[] pAddTyp;
4945 79 : delete[] pAddPos;
4946 79 : delete[] pDel;
4947 79 : }
4948 :
4949 : // Add( const SvxTabStop & rTS ) fuegt einen Tab in die WW-Struktur ein
4950 50 : void SwWW8WrTabu::Add(const SvxTabStop & rTS, long nAdjustment)
4951 : {
4952 : // Tab-Position eintragen
4953 50 : ShortToSVBT16(msword_cast<sal_Int16>(rTS.GetTabPos() + nAdjustment),
4954 100 : pAddPos + (nAdd * 2));
4955 :
4956 : // Tab-Typ eintragen
4957 50 : sal_uInt8 nPara = 0;
4958 50 : switch (rTS.GetAdjustment())
4959 : {
4960 : case SVX_TAB_ADJUST_RIGHT:
4961 24 : nPara = 2;
4962 24 : break;
4963 : case SVX_TAB_ADJUST_CENTER:
4964 20 : nPara = 1;
4965 20 : break;
4966 : case SVX_TAB_ADJUST_DECIMAL:
4967 : /*
4968 : Theres nothing we can do btw the decimal separator has been
4969 : customized, but if you think different remember that different
4970 : locales have different separators, i.e. german is a , while english
4971 : is a .
4972 : */
4973 0 : nPara = 3;
4974 0 : break;
4975 : default:
4976 6 : break;
4977 : }
4978 :
4979 50 : switch( rTS.GetFill() )
4980 : {
4981 : case '.': // dotted leader
4982 3 : nPara |= 1 << 3;
4983 3 : break;
4984 : case '_': // Single line leader
4985 0 : nPara |= 3 << 3;
4986 0 : break;
4987 : case '-': // hyphenated leader
4988 0 : nPara |= 2 << 3;
4989 0 : break;
4990 : case '=': // heavy line leader
4991 0 : nPara |= 4 << 3;
4992 0 : break;
4993 : }
4994 :
4995 50 : pAddTyp[nAdd] = nPara;
4996 50 : ++nAdd;
4997 50 : }
4998 :
4999 : // Del( const SvxTabStop & rTS ) fuegt einen zu loeschenden Tab
5000 : // in die WW-Struktur ein
5001 13 : void SwWW8WrTabu::Del(const SvxTabStop &rTS, long nAdjustment)
5002 : {
5003 : // Tab-Position eintragen
5004 13 : ShortToSVBT16(msword_cast<sal_Int16>(rTS.GetTabPos() + nAdjustment),
5005 26 : pDel + (nDel * 2));
5006 13 : ++nDel;
5007 13 : }
5008 :
5009 : // PutAll( WW8Export& rWW8Wrt ) schreibt das Attribut nach rWrt.pO
5010 79 : void SwWW8WrTabu::PutAll(WW8Export& rWrt)
5011 : {
5012 79 : if (!nAdd && !nDel) //If it's a no-op
5013 124 : return;
5014 : OSL_ENSURE(nAdd <= 255, "more than 255 added tabstops?");
5015 : OSL_ENSURE(nDel <= 255, "more than 244 removed tabstops?");
5016 34 : if (nAdd > 255)
5017 0 : nAdd = 255;
5018 34 : if (nDel > 255)
5019 0 : nDel = 255;
5020 :
5021 34 : sal_uInt16 nSiz = 2 * nDel + 3 * nAdd + 2;
5022 34 : if (nSiz > 255)
5023 0 : nSiz = 255;
5024 :
5025 34 : if (rWrt.bWrtWW8)
5026 34 : rWrt.InsUInt16(NS_sprm::LN_PChgTabsPapx);
5027 : else
5028 0 : rWrt.pO->push_back(15);
5029 : // cch eintragen
5030 34 : rWrt.pO->push_back(msword_cast<sal_uInt8>(nSiz));
5031 : // DelArr schreiben
5032 34 : rWrt.pO->push_back(msword_cast<sal_uInt8>(nDel));
5033 34 : rWrt.OutSprmBytes(pDel, nDel * 2);
5034 : // InsArr schreiben
5035 34 : rWrt.pO->push_back(msword_cast<sal_uInt8>(nAdd));
5036 34 : rWrt.OutSprmBytes(pAddPos, 2 * nAdd); // AddPosArray
5037 34 : rWrt.OutSprmBytes(pAddTyp, nAdd); // AddTypArray
5038 : }
5039 :
5040 44 : static void ParaTabStopAdd( WW8Export& rWrt,
5041 : const SvxTabStopItem& rTStops,
5042 : const long nLParaMgn )
5043 : {
5044 44 : SwWW8WrTabu aTab( 0, rTStops.Count());
5045 :
5046 82 : for( sal_uInt16 n = 0; n < rTStops.Count(); n++ )
5047 : {
5048 38 : const SvxTabStop& rTS = rTStops[n];
5049 : // Def-Tabs ignorieren
5050 38 : if (SVX_TAB_ADJUST_DEFAULT != rTS.GetAdjustment())
5051 0 : aTab.Add(rTS, nLParaMgn);
5052 : }
5053 44 : aTab.PutAll( rWrt );
5054 44 : }
5055 :
5056 1 : static bool lcl_IsEqual(long nOneLeft, const SvxTabStop &rOne,
5057 : long nTwoLeft, const SvxTabStop &rTwo)
5058 : {
5059 : return(
5060 1 : nOneLeft == nTwoLeft &&
5061 2 : rOne.GetAdjustment() == rTwo.GetAdjustment() &&
5062 3 : rOne.GetDecimal() == rTwo.GetDecimal() &&
5063 1 : rOne.GetFill() == rTwo.GetFill()
5064 1 : );
5065 : }
5066 :
5067 35 : static void ParaTabStopDelAdd( WW8Export& rWrt,
5068 : const SvxTabStopItem& rTStyle,
5069 : const long nLStypeMgn,
5070 : const SvxTabStopItem& rTNew,
5071 : const long nLParaMgn )
5072 : {
5073 35 : SwWW8WrTabu aTab(rTStyle.Count(), rTNew.Count());
5074 :
5075 35 : sal_uInt16 nO = 0; // rTStyle Index
5076 35 : sal_uInt16 nN = 0; // rTNew Index
5077 :
5078 : do {
5079 : const SvxTabStop* pTO;
5080 : long nOP;
5081 127 : if( nO < rTStyle.Count() ) // alt noch nicht am Ende ?
5082 : {
5083 43 : pTO = &rTStyle[ nO ];
5084 43 : nOP = pTO->GetTabPos() + nLStypeMgn;
5085 43 : if( SVX_TAB_ADJUST_DEFAULT == pTO->GetAdjustment() )
5086 : {
5087 28 : nO++; // Default-Tab ignorieren
5088 28 : continue;
5089 : }
5090 : }
5091 : else
5092 : {
5093 84 : pTO = 0;
5094 84 : nOP = LONG_MAX;
5095 : }
5096 :
5097 : const SvxTabStop* pTN;
5098 : long nNP;
5099 99 : if( nN < rTNew.Count() ) // neu noch nicht am Ende
5100 : {
5101 54 : pTN = &rTNew[ nN ];
5102 54 : nNP = pTN->GetTabPos() + nLParaMgn;
5103 54 : if( SVX_TAB_ADJUST_DEFAULT == pTN->GetAdjustment() )
5104 : {
5105 0 : nN++; // Default-Tab ignorieren
5106 0 : continue;
5107 : }
5108 : }
5109 : else
5110 : {
5111 45 : pTN = 0;
5112 45 : nNP = LONG_MAX;
5113 : }
5114 :
5115 99 : if( nOP == LONG_MAX && nNP == LONG_MAX )
5116 35 : break; // alles fertig
5117 :
5118 64 : if( nOP < nNP ) // naechster Tab ist alt
5119 : {
5120 13 : aTab.Del(*pTO, nLStypeMgn); // muss geloescht werden
5121 13 : nO++;
5122 : }
5123 51 : else if( nNP < nOP ) // naechster Tab ist neu
5124 : {
5125 50 : aTab.Add(*pTN, nLParaMgn); // muss eigefuegt werden
5126 50 : nN++;
5127 : }
5128 1 : else if (lcl_IsEqual(nOP, *pTO, nNP, *pTN)) // Tabs sind gleich:
5129 : {
5130 1 : nO++; // nichts zu tun
5131 1 : nN++;
5132 : }
5133 : else // Tabs selbe Pos, diff Typ
5134 : {
5135 0 : aTab.Del(*pTO, nLStypeMgn); // alten loeschen
5136 0 : aTab.Add(*pTN, nLParaMgn); // neuen einfuegen
5137 0 : nO++;
5138 0 : nN++;
5139 : }
5140 : } while( true );
5141 :
5142 35 : aTab.PutAll( rWrt );
5143 35 : }
5144 :
5145 79 : void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops )
5146 : {
5147 79 : const bool bTabsRelativeToIndex = m_rWW8Export.m_pCurPam->GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::TABS_RELATIVE_TO_INDENT );
5148 :
5149 79 : long nCurrentLeft = 0;
5150 79 : if ( bTabsRelativeToIndex )
5151 : {
5152 15 : const SfxPoolItem* pLR = m_rWW8Export.HasItem( RES_LR_SPACE );
5153 :
5154 15 : if ( pLR != NULL )
5155 6 : nCurrentLeft = static_cast<const SvxLRSpaceItem*>(pLR)->GetTextLeft();
5156 : }
5157 :
5158 : // #i100264#
5159 141 : if ( m_rWW8Export.m_bStyDef &&
5160 103 : m_rWW8Export.m_pCurrentStyle != NULL &&
5161 24 : m_rWW8Export.m_pCurrentStyle->DerivedFrom() != NULL )
5162 : {
5163 24 : SvxTabStopItem aParentTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
5164 24 : const SwFormat *pParentStyle = m_rWW8Export.m_pCurrentStyle->DerivedFrom();
5165 : {
5166 24 : const SvxTabStopItem* pParentTabs = HasItem<SvxTabStopItem>( pParentStyle->GetAttrSet(), RES_PARATR_TABSTOP );
5167 24 : if ( pParentTabs )
5168 : {
5169 24 : aParentTabs.Insert( pParentTabs );
5170 : }
5171 : }
5172 :
5173 : // #i120938# - consider left indentation of style and its parent style
5174 24 : long nParentLeft = 0;
5175 24 : if ( bTabsRelativeToIndex )
5176 : {
5177 1 : const SvxLRSpaceItem &rStyleLR = ItemGet<SvxLRSpaceItem>( pParentStyle->GetAttrSet(), RES_LR_SPACE );
5178 1 : nParentLeft = rStyleLR.GetTextLeft();
5179 : }
5180 :
5181 24 : ParaTabStopDelAdd( m_rWW8Export, aParentTabs, nParentLeft, rTabStops, nCurrentLeft );
5182 103 : return;
5183 : }
5184 :
5185 55 : const SvxTabStopItem* pStyleTabs = 0;
5186 55 : if ( !m_rWW8Export.m_bStyDef && m_rWW8Export.m_pStyAttr )
5187 : {
5188 11 : pStyleTabs = HasItem<SvxTabStopItem>( *m_rWW8Export.m_pStyAttr, RES_PARATR_TABSTOP );
5189 : }
5190 :
5191 55 : if ( !pStyleTabs )
5192 : {
5193 44 : ParaTabStopAdd(m_rWW8Export, rTabStops, nCurrentLeft);
5194 : }
5195 : else
5196 : {
5197 11 : long nStyleLeft = 0;
5198 11 : if ( bTabsRelativeToIndex )
5199 : {
5200 0 : const SvxLRSpaceItem &rStyleLR = ItemGet<SvxLRSpaceItem>(*m_rWW8Export.m_pStyAttr, RES_LR_SPACE);
5201 0 : nStyleLeft = rStyleLR.GetTextLeft();
5202 : }
5203 :
5204 : ParaTabStopDelAdd( m_rWW8Export,
5205 : *pStyleTabs, nStyleLeft,
5206 11 : rTabStops, nCurrentLeft);
5207 : }
5208 : }
5209 :
5210 158514 : void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt )
5211 : {
5212 : // FIXME maybe use 'item_cast', like 'item_cast<SvxCharHiddenItem>( rHt )'?
5213 158514 : switch ( rHt.Which() )
5214 : {
5215 : case RES_CHRATR_CASEMAP:
5216 361 : CharCaseMap( static_cast< const SvxCaseMapItem& >( rHt ) );
5217 361 : break;
5218 : case RES_CHRATR_COLOR:
5219 6090 : CharColor( static_cast< const SvxColorItem& >( rHt ) );
5220 6090 : break;
5221 : case RES_CHRATR_CONTOUR:
5222 65 : CharContour( static_cast< const SvxContourItem& >( rHt ) );
5223 65 : break;
5224 : case RES_CHRATR_CROSSEDOUT:
5225 158 : CharCrossedOut( static_cast< const SvxCrossedOutItem& >( rHt ) );
5226 158 : break;
5227 : case RES_CHRATR_ESCAPEMENT:
5228 276 : CharEscapement( static_cast< const SvxEscapementItem& >( rHt ) );
5229 276 : break;
5230 : case RES_CHRATR_FONT:
5231 9404 : CharFont( static_cast< const SvxFontItem& >( rHt ) );
5232 9404 : break;
5233 : case RES_CHRATR_FONTSIZE:
5234 11678 : CharFontSize( static_cast< const SvxFontHeightItem& >( rHt ) );
5235 11678 : break;
5236 : case RES_CHRATR_KERNING:
5237 409 : CharKerning( static_cast< const SvxKerningItem& >( rHt ) );
5238 409 : break;
5239 : case RES_CHRATR_LANGUAGE:
5240 3439 : CharLanguage( static_cast< const SvxLanguageItem& >( rHt ) );
5241 3439 : break;
5242 : case RES_CHRATR_POSTURE:
5243 2107 : CharPosture( static_cast< const SvxPostureItem& >( rHt ) );
5244 2107 : break;
5245 : case RES_CHRATR_SHADOWED:
5246 57 : CharShadow( static_cast< const SvxShadowedItem& >( rHt ) );
5247 57 : break;
5248 : case RES_CHRATR_UNDERLINE:
5249 746 : CharUnderline( static_cast< const SvxUnderlineItem& >( rHt ) );
5250 746 : break;
5251 : case RES_CHRATR_WEIGHT:
5252 5353 : CharWeight( static_cast< const SvxWeightItem& >( rHt ) );
5253 5353 : break;
5254 : case RES_CHRATR_AUTOKERN:
5255 2009 : CharAutoKern( static_cast< const SvxAutoKernItem& >( rHt ) );
5256 2009 : break;
5257 : case RES_CHRATR_BLINK:
5258 8 : CharAnimatedText( static_cast< const SvxBlinkItem& >( rHt ) );
5259 8 : break;
5260 : case RES_CHRATR_BACKGROUND:
5261 401 : CharBackgroundBase( static_cast< const SvxBrushItem& >( rHt ) );
5262 401 : break;
5263 :
5264 : case RES_CHRATR_CJK_FONT:
5265 4578 : CharFontCJK( static_cast< const SvxFontItem& >( rHt ) );
5266 4578 : break;
5267 : case RES_CHRATR_CJK_FONTSIZE:
5268 4 : CharFontSizeCJK( static_cast< const SvxFontHeightItem& >( rHt ) );
5269 4 : break;
5270 : case RES_CHRATR_CJK_LANGUAGE:
5271 2535 : CharLanguageCJK( static_cast< const SvxLanguageItem& >( rHt ) );
5272 2535 : break;
5273 : case RES_CHRATR_CJK_POSTURE:
5274 265 : CharPostureCJK( static_cast< const SvxPostureItem& >( rHt ) );
5275 265 : break;
5276 : case RES_CHRATR_CJK_WEIGHT:
5277 1519 : CharWeightCJK( static_cast< const SvxWeightItem& >( rHt ) );
5278 1519 : break;
5279 :
5280 : case RES_CHRATR_CTL_FONT:
5281 9409 : CharFontCTL( static_cast< const SvxFontItem& >( rHt ) );
5282 9409 : break;
5283 : case RES_CHRATR_CTL_FONTSIZE:
5284 10492 : CharFontSizeCTL( static_cast< const SvxFontHeightItem& >( rHt ) );
5285 10492 : break;
5286 : case RES_CHRATR_CTL_LANGUAGE:
5287 2266 : CharLanguageCTL( static_cast< const SvxLanguageItem& >( rHt ) );
5288 2266 : break;
5289 : case RES_CHRATR_CTL_POSTURE:
5290 1382 : CharPostureCTL( static_cast< const SvxPostureItem& >( rHt ) );
5291 1382 : break;
5292 : case RES_CHRATR_CTL_WEIGHT:
5293 2616 : CharWeightCTL( static_cast< const SvxWeightItem& >( rHt ) );
5294 2616 : break;
5295 :
5296 : case RES_CHRATR_ROTATE:
5297 15 : CharRotate( static_cast< const SvxCharRotateItem& >( rHt ) );
5298 15 : break;
5299 : case RES_CHRATR_EMPHASIS_MARK:
5300 54 : CharEmphasisMark( static_cast< const SvxEmphasisMarkItem& >( rHt ) );
5301 54 : break;
5302 : case RES_CHRATR_TWO_LINES:
5303 0 : CharTwoLines( static_cast< const SvxTwoLinesItem& >( rHt ) );
5304 0 : break;
5305 : case RES_CHRATR_SCALEW:
5306 18 : CharScaleWidth( static_cast< const SvxCharScaleWidthItem& >( rHt ) );
5307 18 : break;
5308 : case RES_CHRATR_RELIEF:
5309 58 : CharRelief( static_cast< const SvxCharReliefItem& >( rHt ) );
5310 58 : break;
5311 : case RES_CHRATR_HIDDEN:
5312 152 : CharHidden( static_cast< const SvxCharHiddenItem& >( rHt ) );
5313 152 : break;
5314 : case RES_CHRATR_BOX:
5315 79 : FormatCharBorder( static_cast< const SvxBoxItem& >( rHt ) );
5316 79 : break;
5317 : case RES_CHRATR_HIGHLIGHT:
5318 118 : CharHighlight( static_cast< const SvxBrushItem& >( rHt ) );
5319 118 : break;
5320 : case RES_CHRATR_BIDIRTL:
5321 482 : CharBidiRTL( static_cast< const SfxPoolItem& >( rHt ) );
5322 482 : break;
5323 : case RES_CHRATR_IDCTHINT:
5324 517 : CharIdctHint( static_cast< const SfxPoolItem& >( rHt ) );
5325 517 : break;
5326 : case RES_TXTATR_INETFMT:
5327 348 : TextINetFormat( static_cast< const SwFormatINetFormat& >( rHt ) );
5328 348 : break;
5329 : case RES_TXTATR_CHARFMT:
5330 1381 : TextCharFormat( static_cast< const SwFormatCharFormat& >( rHt ) );
5331 1381 : break;
5332 :
5333 : case RES_TXTATR_FIELD:
5334 : case RES_TXTATR_ANNOTATION:
5335 : case RES_TXTATR_INPUTFIELD:
5336 216 : TextField( static_cast< const SwFormatField& >( rHt ) );
5337 216 : break;
5338 :
5339 : case RES_TXTATR_FLYCNT:
5340 315 : TextFlyContent( static_cast< const SwFormatFlyCnt& >( rHt ) );
5341 315 : break;
5342 : case RES_TXTATR_FTN:
5343 13 : TextFootnote( static_cast< const SwFormatFootnote& >( rHt ) );
5344 13 : break;
5345 :
5346 : case RES_PARATR_LINESPACING:
5347 4140 : ParaLineSpacing( static_cast< const SvxLineSpacingItem& >( rHt ) );
5348 4140 : break;
5349 : case RES_PARATR_ADJUST:
5350 3871 : ParaAdjust( static_cast< const SvxAdjustItem& >( rHt ) );
5351 3871 : break;
5352 : case RES_PARATR_SPLIT:
5353 266 : ParaSplit( static_cast< const SvxFormatSplitItem& >( rHt ) );
5354 266 : break;
5355 : case RES_PARATR_WIDOWS:
5356 1560 : ParaWidows( static_cast< const SvxWidowsItem& >( rHt ) );
5357 1560 : break;
5358 : case RES_PARATR_TABSTOP:
5359 3420 : ParaTabStop( static_cast< const SvxTabStopItem& >( rHt ) );
5360 3420 : break;
5361 : case RES_PARATR_HYPHENZONE:
5362 300 : ParaHyphenZone( static_cast< const SvxHyphenZoneItem& >( rHt ) );
5363 300 : break;
5364 : case RES_PARATR_NUMRULE:
5365 1275 : ParaNumRule( static_cast< const SwNumRuleItem& >( rHt ) );
5366 1275 : break;
5367 : case RES_PARATR_SCRIPTSPACE:
5368 184 : ParaScriptSpace( static_cast< const SfxBoolItem& >( rHt ) );
5369 184 : break;
5370 : case RES_PARATR_HANGINGPUNCTUATION:
5371 289 : ParaHangingPunctuation( static_cast< const SfxBoolItem& >( rHt ) );
5372 289 : break;
5373 : case RES_PARATR_FORBIDDEN_RULES:
5374 176 : ParaForbiddenRules( static_cast< const SfxBoolItem& >( rHt ) );
5375 176 : break;
5376 : case RES_PARATR_VERTALIGN:
5377 421 : ParaVerticalAlign( static_cast< const SvxParaVertAlignItem& >( rHt ) );
5378 421 : break;
5379 : case RES_PARATR_SNAPTOGRID:
5380 101 : ParaSnapToGrid( static_cast< const SvxParaGridItem& >( rHt ) );
5381 101 : break;
5382 :
5383 : case RES_FRM_SIZE:
5384 1040 : FormatFrameSize( static_cast< const SwFormatFrmSize& >( rHt ) );
5385 1040 : break;
5386 : case RES_PAPER_BIN:
5387 1 : FormatPaperBin( static_cast< const SvxPaperBinItem& >( rHt ) );
5388 1 : break;
5389 : case RES_LR_SPACE:
5390 4260 : FormatLRSpace( static_cast< const SvxLRSpaceItem& >( rHt ) );
5391 4260 : break;
5392 : case RES_UL_SPACE:
5393 7766 : FormatULSpace( static_cast< const SvxULSpaceItem& >( rHt ) );
5394 7766 : break;
5395 : case RES_PAGEDESC:
5396 580 : FormatPageDescription( static_cast< const SwFormatPageDesc& >( rHt ) );
5397 580 : break;
5398 : case RES_BREAK:
5399 348 : FormatBreak( static_cast< const SvxFormatBreakItem& >( rHt ) );
5400 348 : break;
5401 : case RES_SURROUND:
5402 249 : FormatSurround( static_cast< const SwFormatSurround& >( rHt ) );
5403 249 : break;
5404 : case RES_VERT_ORIENT:
5405 249 : FormatVertOrientation( static_cast< const SwFormatVertOrient& >( rHt ) );
5406 249 : break;
5407 : case RES_HORI_ORIENT:
5408 249 : FormatHorizOrientation( static_cast< const SwFormatHoriOrient& >( rHt ) );
5409 249 : break;
5410 : case RES_ANCHOR:
5411 249 : FormatAnchor( static_cast< const SwFormatAnchor& >( rHt ) );
5412 249 : break;
5413 : case RES_BACKGROUND:
5414 158 : FormatBackground( static_cast< const SvxBrushItem& >( rHt ) );
5415 158 : break;
5416 : case XATTR_FILLSTYLE:
5417 1879 : FormatFillStyle( static_cast< const XFillStyleItem& >( rHt ) );
5418 1879 : break;
5419 : case XATTR_FILLGRADIENT:
5420 8 : FormatFillGradient( static_cast< const XFillGradientItem& >( rHt ) );
5421 8 : break;
5422 : case RES_BOX:
5423 602 : FormatBox( static_cast< const SvxBoxItem& >( rHt ) );
5424 602 : break;
5425 : case RES_COL:
5426 46 : FormatColumns( static_cast< const SwFormatCol& >( rHt ) );
5427 46 : break;
5428 : case RES_KEEP:
5429 1183 : FormatKeep( static_cast< const SvxFormatKeepItem& >( rHt ) );
5430 1183 : break;
5431 : case RES_TEXTGRID:
5432 768 : FormatTextGrid( static_cast< const SwTextGridItem& >( rHt ) );
5433 768 : break;
5434 : case RES_LINENUMBER:
5435 1404 : FormatLineNumbering( static_cast< const SwFormatLineNumber& >( rHt ) );
5436 1404 : break;
5437 : case RES_FRAMEDIR:
5438 2225 : FormatFrameDirection( static_cast< const SvxFrameDirectionItem& >( rHt ) );
5439 2225 : break;
5440 : case RES_PARATR_GRABBAG:
5441 955 : ParaGrabBag(static_cast<const SfxGrabBagItem&>(rHt));
5442 955 : break;
5443 : case RES_PARATR_OUTLINELEVEL:
5444 5502 : ParaOutlineLevel(static_cast<const SfxUInt16Item&>(rHt));
5445 5502 : break;
5446 : case RES_CHRATR_GRABBAG:
5447 5991 : CharGrabBag(static_cast<const SfxGrabBagItem&>(rHt));
5448 5991 : break;
5449 :
5450 : default:
5451 : SAL_INFO("sw.ww8", "Unhandled SfxPoolItem with id " << rHt.Which() );
5452 25406 : break;
5453 : }
5454 158514 : }
5455 :
5456 577 : void AttributeOutputBase::OutputStyleItemSet( const SfxItemSet& rSet, bool bDeep, bool bTestForDefault )
5457 : {
5458 : // based on OutputItemSet() from wrt_fn.cxx
5459 :
5460 577 : const SfxItemPool& rPool = *rSet.GetPool();
5461 577 : const SfxItemSet* pSet = &rSet;
5462 577 : if ( !pSet->Count() )
5463 : {
5464 0 : if ( !bDeep )
5465 0 : return;
5466 :
5467 0 : while ( 0 != ( pSet = pSet->GetParent() ) && !pSet->Count() )
5468 : ;
5469 :
5470 0 : if ( !pSet )
5471 0 : return;
5472 : }
5473 :
5474 : const SfxPoolItem* pItem;
5475 577 : if ( !bDeep || !pSet->GetParent() )
5476 : {
5477 : OSL_ENSURE( rSet.Count(), "Wurde doch schon behandelt oder?" );
5478 0 : SfxItemIter aIter( *pSet );
5479 0 : pItem = aIter.GetCurItem();
5480 0 : do {
5481 0 : OutputItem( *pItem );
5482 0 : } while ( !aIter.IsAtEnd() && 0 != ( pItem = aIter.NextItem() ) );
5483 : }
5484 : else
5485 : {
5486 577 : SfxWhichIter aIter( *pSet );
5487 577 : sal_uInt16 nWhich = aIter.FirstWhich();
5488 38082 : while ( nWhich )
5489 : {
5490 46152 : if ( SfxItemState::SET == pSet->GetItemState( nWhich, bDeep, &pItem ) &&
5491 4734 : ( !bTestForDefault ||
5492 136 : *pItem != rPool.GetDefaultItem( nWhich ) ||
5493 56 : ( pSet->GetParent() && *pItem != pSet->GetParent()->Get( nWhich ) ) ) )
5494 : {
5495 4598 : OutputItem( *pItem );
5496 : }
5497 36928 : nWhich = aIter.NextWhich();
5498 577 : }
5499 : }
5500 : }
5501 :
5502 79 : void AttributeOutputBase::FormatCharBorder( const SvxBoxItem& rBox )
5503 : {
5504 : // Get one of the borders (if there is any border then in docx also will be)
5505 79 : const SvxBorderLine* pBorderLine = 0;
5506 79 : sal_uInt16 nDist = 0;
5507 79 : if( rBox.GetTop() )
5508 : {
5509 12 : pBorderLine = rBox.GetTop();
5510 12 : nDist = rBox.GetDistance( SvxBoxItemLine::TOP );
5511 : }
5512 67 : else if( rBox.GetLeft() )
5513 : {
5514 6 : pBorderLine = rBox.GetLeft();
5515 6 : nDist = rBox.GetDistance( SvxBoxItemLine::LEFT );
5516 : }
5517 61 : else if( rBox.GetBottom() )
5518 : {
5519 0 : pBorderLine = rBox.GetBottom();
5520 0 : nDist = rBox.GetDistance( SvxBoxItemLine::BOTTOM );
5521 : }
5522 61 : else if( rBox.GetRight() )
5523 : {
5524 0 : pBorderLine = rBox.GetRight();
5525 0 : nDist = rBox.GetDistance( SvxBoxItemLine::RIGHT );
5526 : }
5527 :
5528 79 : if( pBorderLine )
5529 : {
5530 18 : const SfxPoolItem* pItem = GetExport().HasItem( RES_CHRATR_SHADOW );
5531 18 : const SvxShadowItem* pShadowItem = static_cast<const SvxShadowItem*>(pItem);
5532 : const bool bShadow =
5533 25 : pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE &&
5534 25 : pShadowItem->GetWidth() > 0;
5535 :
5536 18 : CharBorder( pBorderLine, nDist, bShadow );
5537 : }
5538 79 : }
5539 :
5540 : /*
5541 : * This function is used to check if the current SwTextNode (paragraph) has a redline object
5542 : * that is attached to the paragraph marker.
5543 : * This is done by checking if the range (SwPaM) of the redline is :
5544 : * - Start = the last character of the current paragraph
5545 : * - End = the first character of the next paragraph
5546 : */
5547 16956 : const SwRedlineData* AttributeOutputBase::GetParagraphMarkerRedline( const SwTextNode& rNode, RedlineType_t aRedlineType)
5548 : {
5549 : // ToDo : this is not the most ideal ... should start maybe from 'nCurRedlinePos'
5550 40094 : for( size_t nRedlinePos = 0; nRedlinePos < GetExport().m_pDoc->getIDocumentRedlineAccess().GetRedlineTable().size(); ++nRedlinePos )
5551 : {
5552 23143 : const SwRangeRedline* pRedl = GetExport().m_pDoc->getIDocumentRedlineAccess().GetRedlineTable()[ nRedlinePos ];
5553 :
5554 : // Only check redlines that are of type 'Delete'
5555 23143 : if ( pRedl->GetRedlineData().GetType() != aRedlineType )
5556 11679 : continue;
5557 :
5558 11464 : const SwPosition* pCheckedStt = pRedl->Start();
5559 11464 : const SwPosition* pCheckedEnd = pRedl->End();
5560 :
5561 11464 : if( pCheckedStt->nNode == rNode )
5562 : {
5563 36 : if ( !pCheckedEnd )
5564 0 : continue;
5565 :
5566 36 : sal_uLong uStartNodeIndex = pCheckedStt->nNode.GetIndex();
5567 36 : sal_uLong uStartCharIndex = pCheckedStt->nContent.GetIndex();
5568 36 : sal_uLong uEndNodeIndex = pCheckedEnd->nNode.GetIndex();
5569 36 : sal_uLong uEndCharIndex = pCheckedEnd->nContent.GetIndex();
5570 :
5571 : // Maybe add here a check that also the start & end of the redline is the entire paragraph
5572 79 : if ( ( uStartNodeIndex == uEndNodeIndex - 1 ) &&
5573 42 : ( uStartCharIndex == (sal_uLong)rNode.Len() ) &&
5574 : ( uEndCharIndex == 0)
5575 : )
5576 : {
5577 5 : return &( pRedl->GetRedlineData() );
5578 : }
5579 : }
5580 : }
5581 16951 : return NULL;
5582 : }
5583 :
5584 401 : void AttributeOutputBase::CharBackgroundBase( const SvxBrushItem& rBrush )
5585 : {
5586 401 : bool bConvertToShading = SvtFilterOptions::Get().IsCharBackground2Shading();
5587 401 : bool bHasShadingMarker = false;
5588 :
5589 : // Check shading marker
5590 : {
5591 401 : const SfxGrabBagItem& aGrabBag = static_cast< const SfxGrabBagItem& >( GetExport().GetItem( RES_CHRATR_GRABBAG ) );
5592 401 : const std::map<OUString, com::sun::star::uno::Any>& rMap = aGrabBag.GetGrabBag();
5593 401 : auto aIterator = rMap.find("CharShadingMarker");
5594 401 : if( aIterator != rMap.end() )
5595 : {
5596 222 : aIterator->second >>= bHasShadingMarker;
5597 : }
5598 : }
5599 :
5600 401 : if( bConvertToShading || bHasShadingMarker )
5601 : {
5602 216 : CharBackground(rBrush);
5603 : }
5604 : else
5605 : {
5606 185 : CharHighlight(rBrush);
5607 : }
5608 461 : }
5609 :
5610 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|