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