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