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