1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
31 #include <hintids.hxx>
33 #include <comphelper/string.hxx>
34 #include <tools/stream.hxx>
35 #include <tools/datetime.hxx>
36 #include <unotools/fontcvt.hxx>
37 #include <rtl/tencinfo.h>
38 #include <svtools/rtfkeywd.hxx>
39 #include <svtools/rtfout.hxx>
40 #include <editeng/paperinf.hxx>
41 #include <editeng/fontitem.hxx>
42 #include <editeng/shaditem.hxx>
43 #include <editeng/brshitem.hxx>
44 #include <editeng/colritem.hxx>
45 #include <editeng/boxitem.hxx>
46 #include <editeng/tstpitem.hxx>
47 #include <editeng/ulspitem.hxx>
48 #include <editeng/lrspitem.hxx>
49 #include <editeng/frmdiritem.hxx>
50 #include <editeng/udlnitem.hxx>
51 #include <fmtpdsc.hxx>
52 #include <fmtcntnt.hxx>
53 #include <fmtfsize.hxx>
54 #include <fmthdft.hxx>
56 #include <fmtanchr.hxx>
66 #include <pagedesc.hxx> // fuer SwPageDesc...
67 #include <ftninfo.hxx>
68 #include <charfmt.hxx>
69 #include <SwStyleNameMapper.hxx>
70 #include <section.hxx>
71 #include <swtable.hxx> // fuer SwPageDesc ...
72 #include <swmodule.hxx>
74 #include <mdiexp.hxx> // ...Percent()
75 #include <statstr.hrc> // ResId fuer Statusleiste
78 #include <com/sun/star/document/XDocumentProperties.hpp>
79 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
83 const sal_Char
SwRTFWriter::sNewLine
= '\012';
85 const sal_Char __FAR_DATA
SwRTFWriter::sNewLine
[] = "\015\012";
88 SV_DECL_VARARR( RTFColorTbl
, Color
, 5, 8 )
89 SV_IMPL_VARARR( RTFColorTbl
, Color
)
92 SwRTFWriter::SwRTFWriter( const String
& rFltName
, const String
& rBaseURL
) :
94 rtl_getTextEncodingFromWindowsCharset(
95 sw::ms::rtl_TextEncodingToWinCharset(DEF_ENCODING
))),
96 eCurrentEncoding(eDefaultEncoding
)
98 SetBaseURL( rBaseURL
);
99 // schreibe Win-RTF-HelpFileFmt
100 bWriteHelpFmt
= 'W' == rFltName
.GetChar( 0 );
101 // schreibe nur Gliederungs Absaetze
102 bOutOutlineOnly
= 'O' == rFltName
.GetChar( 0 );
103 // enable non-standard tags for cut and paste
104 bNonStandard
= '\0' == rFltName
.GetChar( 0 );
108 SwRTFWriter::~SwRTFWriter()
112 ULONG
SwRTFWriter::WriteStream()
114 bOutPageAttr
= bOutSection
= TRUE
;
116 bOutStyleTab
= bOutTable
= bOutPageDesc
= bOutPageDescTbl
=
117 bAutoAttrSet
= bOutListNumTxt
= bOutLeftHeadFoot
= bIgnoreNextPgBreak
=
118 bTxtAttr
= bAssociated
= FALSE
;
120 nCurScript
= 1; // latin - ask the doc??
122 nCurRedline
= USHRT_MAX
;
123 if(pDoc
->GetRedlineTbl().Count())
131 pFlyFmt
= 0; // kein FlyFrmFormat gesetzt
133 pColTbl
= new RTFColorTbl
;
136 BYTE nSz
= (BYTE
)Min( pDoc
->GetSpzFrmFmts()->Count(), USHORT(255) );
137 SwPosFlyFrms
aFlyPos( nSz
, nSz
);
139 //Abkuerzung wenn nur Gliederung ausgegeben werden soll, und keine
140 //Gliederungsabsaetze ausserhalb des Body stehen.
141 if ( bOutOutlineOnly
&&
142 pDoc
->GetNodes().GetOutLineNds().Count() &&
143 pDoc
->GetNodes().GetOutLineNds()[0]->GetIndex() >
144 pDoc
->GetNodes().GetEndOfExtras().GetIndex() )
150 const SwOutlineNodes
&rOutLine
= pDoc
->GetNodes().GetOutLineNds();
151 for ( USHORT i
= 0; i
< rOutLine
.Count(); ++i
)
153 const SwNode
*pNd
= pDoc
->GetNodes()[*rOutLine
[i
]];
154 ASSERT( pNd
->IsCntntNode(), "Outlinenode and no CntNode!?" );
156 SwCntntNode
* pCNd
= (SwCntntNode
*)pNd
;
158 // erfrage den aktuellen PageDescriptor.
159 const SwPageDesc
* pTmp
= pCNd
->GetSwAttrSet().GetPageDesc().GetPageDesc();
162 pCurPam
->GetPoint()->nContent
.Assign( pCNd
, 0 );
163 Out( aRTFNodeFnTab
, *pCNd
, *this );
168 long nMaxNode
= pDoc
->GetNodes().Count();
171 ::StartProgress( STR_STATSTR_W4WWRITE
, 0, nMaxNode
, pDoc
->GetDocShell() );
173 // Tabelle am Doc.-Anfang beachten
175 SwTableNode
* pTNd
= pCurPam
->GetNode()->FindTableNode();
176 if( pTNd
&& bWriteAll
)
178 // mit dem TabellenNode anfangen !!
179 pCurPam
->GetPoint()->nNode
= *pTNd
;
181 if( bWriteOnlyFirstTable
)
182 pCurPam
->GetMark()->nNode
= *pTNd
->EndOfSectionNode();
186 // Tabelle fuer die freifliegenden Rahmen erzeugen, aber nur wenn
187 // das gesamte Dokument geschrieben wird
189 pDoc
->GetAllFlyFmts( aFlyPos
, bWriteAll
? 0 : pOrigPam
);
191 // sollten nur Rahmen vorhanden sein?
192 // (Moeglich, wenn eine Rahmen-Selektion ins Clipboard
196 *pCurPam
->GetPoint() == *pCurPam
->GetMark() &&
198 pDoc
->GetSpzFrmFmts()->Count() && !aFlyPos
.Count() &&
199 // nur ein Node im Array
200 pDoc
->GetNodes().GetEndOfExtras().GetIndex() + 3 ==
201 pDoc
->GetNodes().GetEndOfContent().GetIndex() &&
202 // und genau der ist selektiert
203 pDoc
->GetNodes().GetEndOfContent().GetIndex() - 1 ==
204 pCurPam
->GetPoint()->nNode
.GetIndex() )
206 // dann den Inhalt vom Rahmen ausgeben.
207 // dieser steht immer an Position 0 !!
208 SwFrmFmt
* pFmt
= (*pDoc
->GetSpzFrmFmts())[ 0 ];
209 const SwNodeIndex
* pIdx
= pFmt
->GetCntnt().GetCntntIdx();
212 SwPosFlyFrm
* pFPos
= new SwPosFlyFrm( pCurPam
->GetPoint()->nNode
,
213 pFmt
, aFlyPos
.Count() );
214 aFlyPos
.Insert( pFPos
);
220 // schreibe die StyleTabelle, allgemeine Angaben,Header/Footer/Footnotes
223 Out_SwDoc( pOrigPam
);
226 ::EndProgress( pDoc
->GetDocShell() );
231 // loesche die Tabelle mit den freifliegenden Rahmen
232 for( USHORT i
= aFlyPos
.Count(); i
> 0; )
233 delete aFlyPos
[ --i
];
239 // don't destroy the numrule pointers in the DTOR.
240 pNumRuleTbl
->Remove( 0, pNumRuleTbl
->Count() );
245 // schreibe Win-RTF-HelpFileFmt
246 bOutOutlineOnly
= bWriteHelpFmt
= FALSE
;
253 void SwRTFWriter::Out_SwDoc( SwPaM
* pPam
)
255 BOOL bSaveWriteAll
= bWriteAll
; // sichern
256 // suche die naechste Bookmark-Position aus der Bookmark-Tabelle
257 nBkmkTabPos
= bWriteAll
? FindPos_Bkmk( *pCurPam
->GetPoint() ) : -1;
259 // gebe alle Bereiche des Pams in das RTF-File aus.
261 bWriteAll
= bSaveWriteAll
;
264 // suche den ersten am Pam-auszugebenen FlyFrame
267 while( pCurPam
->GetPoint()->nNode
< pCurPam
->GetMark()->nNode
||
268 (pCurPam
->GetPoint()->nNode
== pCurPam
->GetMark()->nNode
&&
269 pCurPam
->GetPoint()->nContent
.GetIndex() <= pCurPam
->GetMark()->nContent
.GetIndex()) )
271 SwNode
& rNd
= pCurPam
->GetPoint()->nNode
.GetNode();
273 if( &rNd
== &pDoc
->GetNodes().GetEndOfContent() )
276 if( rNd
.IsCntntNode() )
278 SwCntntNode
& rCNd
= (SwCntntNode
&)rNd
;
280 OutBreaks( rCNd
.GetSwAttrSet() );
284 pCurPam
->GetPoint()->nContent
.Assign( &rCNd
, 0 );
286 if( !bOutOutlineOnly
||
287 //( rCNd.IsTxtNode() && NO_NUMBERING != //#outline level,removed by zhaojianwei
288 //((SwTxtNode&)rCNd).GetTxtColl()->GetOutlineLevel() ))
289 ( rCNd
.IsTxtNode() && //->add by zhaojianwei
290 ((SwTxtNode
&)rCNd
).GetTxtColl()->IsAssignedToListLevelOfOutlineStyle()))//<-end,zhaojianwei
291 Out( aRTFNodeFnTab
, rCNd
, *this );
294 else if( !bOutOutlineOnly
)
296 if (rNd
.IsTableNode())
299 if (const SwTableNode
*pNd
= rNd
.GetTableNode())
301 if (const SwFrmFmt
*pFmt
= pNd
->GetTable().GetFrmFmt())
303 OutBreaks(pFmt
->GetAttrSet());
306 OutRTF_SwTblNode(*this, *pNd
);
308 ASSERT(bAllOk
, "Unexpected missing properties from tables");
310 else if( rNd
.IsSectionNode() )
312 OutBreaks( ((SwSectionNode
&)rNd
).GetSection().GetFmt()
314 OutRTF_SwSectionNode( *this, (SwSectionNode
&)rNd
);
316 else if( rNd
.IsEndNode() )
317 CheckEndNodeForSection( rNd
);
320 ULONG nPos
= pCurPam
->GetPoint()->nNode
++; // Bewegen
323 ::SetProgressState( nPos
, pDoc
->GetDocShell() ); // Wie weit ?
325 /* sollen nur die Selectierten Bereiche gesichert werden, so
326 * duerfen nur die vollstaendigen Nodes gespeichert werde,
327 * d.H. der 1. und n. Node teilweise, der 2. bis n-1. Node
328 * vollstaendig. (vollstaendig heisst mit allen Formaten! )
330 bWriteAll
= bSaveWriteAll
||
331 pCurPam
->GetPoint()->nNode
!= pCurPam
->GetMark()->nNode
;
334 } while( CopyNextPam( &pPam
) ); // bis alle PaM's bearbeitet
336 bWriteAll
= bSaveWriteAll
; // wieder auf alten Wert zurueck
340 // schreibe die StyleTabelle, algemeine Angaben,Header/Footer/Footnotes
343 void SwRTFWriter::MakeHeader()
345 // baue den Vorspann wie Header, ColorTbl, FontTbl
346 Strm() << '{' << OOO_STRING_SVTOOLS_RTF_RTF
<< '1'
347 << OOO_STRING_SVTOOLS_RTF_ANSI
;
350 Strm() << OOO_STRING_SVTOOLS_RTF_DEFF
;
351 OutULong( GetId( (SvxFontItem
&)pDoc
->GetAttrPool().GetDefaultItem(
352 RES_CHRATR_FONT
) ));
354 // JP 13.02.2001 - if this not exist, MS don't understand our ansi
355 // characters (0x80-0xff).
356 Strm() << "\\adeflang1025";
364 Strm() << SwRTFWriter::sNewLine
; // ein Trenner
366 // wenn teilweise ausgegeben wird, die globalen Daten nicht speichern
370 // Ausgeben der Doc-Info/-Statistik
373 // einige globale Daten Schreiben
375 const SvxTabStopItem
& rTabs
= (const SvxTabStopItem
&)
376 pDoc
->GetAttrPool().GetDefaultItem( RES_PARATR_TABSTOP
);
377 Strm() << OOO_STRING_SVTOOLS_RTF_DEFTAB
;
378 OutLong( rTabs
[0].GetTabPos() );
379 if ( !pDoc
->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE
) )
380 Strm() << OOO_STRING_SVTOOLS_RTF_LYTPRTMET
;
383 // PageDescriptor ausgeben (??nur wenn das gesamte Dokument??)
386 // gebe die Groesse und die Raender der Seite aus
387 if( pDoc
->GetPageDescCnt() )
389 //JP 06.04.99: Bug 64361 - suche den ersten SwFmtPageDesc. Ist
390 // keiner gesetzt, so ist der Standard gueltig
391 const SwFmtPageDesc
* pSttPgDsc
= 0;
393 const SwNode
& rSttNd
= *pDoc
->GetNodes()[
394 pDoc
->GetNodes().GetEndOfExtras().GetIndex() + 2 ];
395 const SfxItemSet
* pSet
= 0;
397 if( rSttNd
.IsCntntNode() )
398 pSet
= &rSttNd
.GetCntntNode()->GetSwAttrSet();
399 else if( rSttNd
.IsTableNode() )
400 pSet
= &rSttNd
.GetTableNode()->GetTable().
401 GetFrmFmt()->GetAttrSet();
402 else if( rSttNd
.IsSectionNode() )
403 pSet
= &rSttNd
.GetSectionNode()->GetSection().
404 GetFmt()->GetAttrSet();
409 pSttPgDsc
= (SwFmtPageDesc
*)&pSet
->Get( RES_PAGEDESC
);
410 if( !pSttPgDsc
->GetPageDesc() )
412 else if( pDoc
->FindPageDescByName( pSttPgDsc
->
413 GetPageDesc()->GetName(), &nPosInDoc
))
415 // FALSE wegen schliessender Klammer !!
416 OutComment( *this, OOO_STRING_SVTOOLS_RTF_PGDSCNO
, FALSE
);
417 OutULong( nPosInDoc
) << '}';
421 const SwPageDesc
& rPageDesc
= pSttPgDsc
? *pSttPgDsc
->GetPageDesc()
422 : const_cast<const SwDoc
*>(pDoc
)->GetPageDesc( 0 );
423 const SwFrmFmt
&rFmtPage
= rPageDesc
.GetMaster();
426 if( rPageDesc
.GetLandscape() )
427 Strm() << OOO_STRING_SVTOOLS_RTF_LANDSCAPE
;
429 const SwFmtFrmSize
& rSz
= rFmtPage
.GetFrmSize();
430 // Clipboard-Dokument wird immer ohne Drucker angelegt, so ist
431 // der Std.PageDesc immer aug LONG_MAX !! Mappe dann auf DIN A4
432 if( LONG_MAX
== rSz
.GetHeight() || LONG_MAX
== rSz
.GetWidth() )
434 Strm() << OOO_STRING_SVTOOLS_RTF_PAPERH
;
435 Size a4
= SvxPaperInfo::GetPaperSize(PAPER_A4
);
436 OutULong( a4
.Height() ) << OOO_STRING_SVTOOLS_RTF_PAPERW
;
437 OutULong( a4
.Width() );
441 Strm() << OOO_STRING_SVTOOLS_RTF_PAPERH
;
442 OutULong( rSz
.GetHeight() ) << OOO_STRING_SVTOOLS_RTF_PAPERW
;
443 OutULong( rSz
.GetWidth() );
448 const SvxLRSpaceItem
& rLR
= rFmtPage
.GetLRSpace();
449 Strm() << OOO_STRING_SVTOOLS_RTF_MARGL
;
450 OutLong( rLR
.GetLeft() ) << OOO_STRING_SVTOOLS_RTF_MARGR
;
451 OutLong( rLR
.GetRight() );
455 const SvxULSpaceItem
& rUL
= rFmtPage
.GetULSpace();
456 Strm() << OOO_STRING_SVTOOLS_RTF_MARGT
;
457 OutLong( rUL
.GetUpper() ) << OOO_STRING_SVTOOLS_RTF_MARGB
;
458 OutLong( rUL
.GetLower() );
461 Strm() << OOO_STRING_SVTOOLS_RTF_SECTD
<< OOO_STRING_SVTOOLS_RTF_SBKNONE
;
462 OutRTFPageDescription( rPageDesc
, FALSE
, TRUE
); // Changed bCheckForFirstPage to TRUE so headers
463 // following title page are correctly added - i13107
466 bIgnoreNextPgBreak
= TRUE
;
467 pAktPageDesc
= &rPageDesc
;
473 // schreibe die Fussnoten- und Endnoten-Info raus
474 const SwFtnInfo
& rFtnInfo
= pDoc
->GetFtnInfo();
476 const char* pOut
= FTNPOS_CHAPTER
== rFtnInfo
.ePos
477 ? OOO_STRING_SVTOOLS_RTF_ENDDOC
478 : OOO_STRING_SVTOOLS_RTF_FTNBJ
;
479 Strm() << pOut
<< OOO_STRING_SVTOOLS_RTF_FTNSTART
;
480 OutLong( rFtnInfo
.nFtnOffset
+ 1 );
482 switch( rFtnInfo
.eNum
)
484 case FTNNUM_PAGE
: pOut
= OOO_STRING_SVTOOLS_RTF_FTNRSTPG
; break;
485 case FTNNUM_DOC
: pOut
= OOO_STRING_SVTOOLS_RTF_FTNRSTCONT
; break;
486 // case FTNNUM_CHAPTER:
487 default: pOut
= OOO_STRING_SVTOOLS_RTF_FTNRESTART
; break;
491 switch( rFtnInfo
.aFmt
.GetNumberingType() )
493 case SVX_NUM_CHARS_LOWER_LETTER
:
494 case SVX_NUM_CHARS_LOWER_LETTER_N
: pOut
= OOO_STRING_SVTOOLS_RTF_FTNNALC
; break;
495 case SVX_NUM_CHARS_UPPER_LETTER
:
496 case SVX_NUM_CHARS_UPPER_LETTER_N
: pOut
= OOO_STRING_SVTOOLS_RTF_FTNNAUC
; break;
497 case SVX_NUM_ROMAN_LOWER
: pOut
= OOO_STRING_SVTOOLS_RTF_FTNNRLC
; break;
498 case SVX_NUM_ROMAN_UPPER
: pOut
= OOO_STRING_SVTOOLS_RTF_FTNNRUC
; break;
499 case SVX_NUM_CHAR_SPECIAL
: pOut
= OOO_STRING_SVTOOLS_RTF_FTNNCHI
; break;
500 // case SVX_NUM_ARABIC:
501 default: pOut
= OOO_STRING_SVTOOLS_RTF_FTNNAR
; break;
506 const SwEndNoteInfo
& rEndNoteInfo
= pDoc
->GetEndNoteInfo();
508 Strm() << OOO_STRING_SVTOOLS_RTF_AENDDOC
<< OOO_STRING_SVTOOLS_RTF_AFTNRSTCONT
509 << OOO_STRING_SVTOOLS_RTF_AFTNSTART
;
510 OutLong( rEndNoteInfo
.nFtnOffset
+ 1 );
512 switch( rEndNoteInfo
.aFmt
.GetNumberingType() )
514 case SVX_NUM_CHARS_LOWER_LETTER
:
515 case SVX_NUM_CHARS_LOWER_LETTER_N
: pOut
= OOO_STRING_SVTOOLS_RTF_AFTNNALC
; break;
516 case SVX_NUM_CHARS_UPPER_LETTER
:
517 case SVX_NUM_CHARS_UPPER_LETTER_N
: pOut
= OOO_STRING_SVTOOLS_RTF_AFTNNAUC
; break;
518 case SVX_NUM_ROMAN_LOWER
: pOut
= OOO_STRING_SVTOOLS_RTF_AFTNNRLC
; break;
519 case SVX_NUM_ROMAN_UPPER
: pOut
= OOO_STRING_SVTOOLS_RTF_AFTNNRUC
; break;
520 case SVX_NUM_CHAR_SPECIAL
: pOut
= OOO_STRING_SVTOOLS_RTF_AFTNNCHI
; break;
521 // case SVX_NUM_ARABIC:
522 default: pOut
= OOO_STRING_SVTOOLS_RTF_AFTNNAR
; break;
527 if( pDoc
->_GetDBDesc().sDataSource
.getLength() )
529 // stelle erstmal fest, ob ueberhaupt Datenbankfelder benutzt werden!
530 const SwFldTypes
* pTypes
= pDoc
->GetFldTypes();
531 for( USHORT nCnt
= pTypes
->Count(); nCnt
>= INIT_FLDTYPES
; )
532 if( RES_DBFLD
== (*pTypes
)[ --nCnt
]->Which() &&
533 (*pTypes
)[ nCnt
]->GetDepends() )
535 Strm() << '{' << OOO_STRING_SVTOOLS_RTF_FIELD
;
536 OutComment( *this, OOO_STRING_SVTOOLS_RTF_FLDINST
) << " DATA ";
537 SwDBData aData
= pDoc
->GetDBData();
538 String
sOut(aData
.sDataSource
);
540 sOut
+= (String
)aData
.sCommand
;
541 RTFOutFuncs::Out_String( Strm(), sOut
,
542 eDefaultEncoding
, bWriteHelpFmt
);
543 Strm() << "}{" << OOO_STRING_SVTOOLS_RTF_FLDRSLT
<< " }}";
550 Strm() << SwRTFWriter::sNewLine
; // ein Trenner
553 void SwRTFWriter::OutInfoDateTime( const sal_Char
* i_pStr
,
554 const util::DateTime
& i_rDT
)
556 Strm() << '{' << i_pStr
<< OOO_STRING_SVTOOLS_RTF_YR
;
557 OutLong( Strm(), i_rDT
.Year
) << OOO_STRING_SVTOOLS_RTF_MO
;
558 OutLong( Strm(), i_rDT
.Month
) << OOO_STRING_SVTOOLS_RTF_DY
;
559 OutLong( Strm(), i_rDT
.Day
) << OOO_STRING_SVTOOLS_RTF_HR
;
560 OutLong( Strm(), i_rDT
.Hours
) << OOO_STRING_SVTOOLS_RTF_MIN
;
561 OutLong( Strm(), i_rDT
.Minutes
) << '}';
564 bool CharsetSufficient(const String
&rString
, rtl_TextEncoding eChrSet
)
566 const sal_uInt32 nFlags
=
567 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
|
568 RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
;
570 rtl::OUString
sStr(rString
);
571 return sStr
.convertToString(&sDummy
, eChrSet
, nFlags
);
574 void SwRTFWriter::OutUnicodeSafeRecord(const sal_Char
*pToken
,
575 const String
&rContent
)
579 bool bNeedUnicodeWrapper
= !CharsetSufficient(rContent
, eDefaultEncoding
);
581 if (bNeedUnicodeWrapper
)
582 Strm() << '{' << OOO_STRING_SVTOOLS_RTF_UPR
;
584 Strm() << '{' << pToken
<< ' ';
585 OutRTF_AsByteString(*this, rContent
, eDefaultEncoding
);
588 if (bNeedUnicodeWrapper
)
590 OutComment(*this, OOO_STRING_SVTOOLS_RTF_UD
);
591 Strm() << '{' << pToken
<< ' ';
592 RTFOutFuncs::Out_String(Strm(), rContent
, eDefaultEncoding
,
600 void SwRTFWriter::OutDocInfoStat()
602 Strm() << '{' << OOO_STRING_SVTOOLS_RTF_INFO
;
604 SwDocShell
*pDocShell(pDoc
->GetDocShell());
605 uno::Reference
<document::XDocumentProperties
> xDocProps
;
607 uno::Reference
<document::XDocumentPropertiesSupplier
> xDPS(
608 pDocShell
->GetModel(), uno::UNO_QUERY_THROW
);
609 xDocProps
.set(xDPS
->getDocumentProperties());
612 // may be null (in case of copying)
615 OutUnicodeSafeRecord(OOO_STRING_SVTOOLS_RTF_TITLE
, xDocProps
->getTitle());
616 OutUnicodeSafeRecord(OOO_STRING_SVTOOLS_RTF_SUBJECT
, xDocProps
->getSubject());
618 OutUnicodeSafeRecord(OOO_STRING_SVTOOLS_RTF_KEYWORDS
,
619 ::comphelper::string::convertCommaSeparated(xDocProps
->getKeywords()));
620 OutUnicodeSafeRecord(OOO_STRING_SVTOOLS_RTF_DOCCOMM
, xDocProps
->getDescription());
622 OutUnicodeSafeRecord(OOO_STRING_SVTOOLS_RTF_AUTHOR
, xDocProps
->getAuthor() );
623 OutInfoDateTime(OOO_STRING_SVTOOLS_RTF_CREATIM
, xDocProps
->getCreationDate());
625 OutUnicodeSafeRecord(OOO_STRING_SVTOOLS_RTF_AUTHOR
, xDocProps
->getModifiedBy() );
626 OutInfoDateTime(OOO_STRING_SVTOOLS_RTF_REVTIM
, xDocProps
->getModificationDate());
628 OutInfoDateTime(OOO_STRING_SVTOOLS_RTF_PRINTIM
, xDocProps
->getPrintDate());
632 // fuer interne Zwecke - Versionsnummer rausschreiben
633 Strm() << '{' << OOO_STRING_SVTOOLS_RTF_COMMENT
<< " StarWriter}{" << OOO_STRING_SVTOOLS_RTF_VERN
;
634 OutLong( Strm(), SUPD
*10 ) << '}';
639 static void InsColor( RTFColorTbl
& rTbl
, const Color
& rCol
)
642 for( n
= 0; n
< rTbl
.Count(); ++n
)
643 if( rTbl
[n
] == rCol
)
644 return; // schon vorhanden, zurueck
646 n
= COL_AUTO
== rCol
.GetColor() ? 0 : rTbl
.Count();
647 rTbl
.Insert( rCol
, n
);
650 static void InsColorLine( RTFColorTbl
& rTbl
, const SvxBoxItem
& rBox
)
652 const SvxBorderLine
* pLine
= 0;
655 InsColor( rTbl
, (pLine
= rBox
.GetTop())->GetColor() );
656 if( rBox
.GetBottom() && pLine
!= rBox
.GetBottom() )
657 InsColor( rTbl
, (pLine
= rBox
.GetBottom())->GetColor() );
658 if( rBox
.GetLeft() && pLine
!= rBox
.GetLeft() )
659 InsColor( rTbl
, (pLine
= rBox
.GetLeft())->GetColor() );
660 if( rBox
.GetRight() && pLine
!= rBox
.GetRight() )
661 InsColor( rTbl
, rBox
.GetRight()->GetColor() );
664 void SwRTFWriter::OutRTFColorTab()
666 ASSERT( pColTbl
, "Wo ist meine Color-Tabelle?" );
668 // dann baue die ColorTabelle aus allen Attributen, die Colors
669 // enthalten und im Pool angemeldet sind auf.
671 const SfxItemPool
& rPool
= pDoc
->GetAttrPool();
673 // das Charakter - Color Attribut
675 const SvxColorItem
* pCol
= (const SvxColorItem
*)GetDfltAttr(
677 InsColor( *pColTbl
, pCol
->GetValue() );
678 if( 0 != ( pCol
= (const SvxColorItem
*)rPool
.GetPoolDefaultItem(
679 RES_CHRATR_COLOR
) ))
680 InsColor( *pColTbl
, pCol
->GetValue() );
681 nMaxItem
= rPool
.GetItemCount(RES_CHRATR_COLOR
);
682 for( n
= 0; n
< nMaxItem
; ++n
)
684 if( 0 != (pCol
= (const SvxColorItem
*)rPool
.GetItem(
685 RES_CHRATR_COLOR
, n
) ) )
686 InsColor( *pColTbl
, pCol
->GetValue() );
689 const SvxUnderlineItem
* pUnder
= (const SvxUnderlineItem
*)GetDfltAttr( RES_CHRATR_UNDERLINE
);
690 InsColor( *pColTbl
, pUnder
->GetColor() );
691 nMaxItem
= rPool
.GetItemCount(RES_CHRATR_UNDERLINE
);
692 for( n
= 0; n
< nMaxItem
;n
++)
694 if( 0 != (pUnder
= (const SvxUnderlineItem
*)rPool
.GetItem( RES_CHRATR_UNDERLINE
, n
) ) )
695 InsColor( *pColTbl
, pUnder
->GetColor() );
699 const SvxOverlineItem
* pOver
= (const SvxOverlineItem
*)GetDfltAttr( RES_CHRATR_OVERLINE
);
700 InsColor( *pColTbl
, pOver
->GetColor() );
701 nMaxItem
= rPool
.GetItemCount(RES_CHRATR_OVERLINE
);
702 for( n
= 0; n
< nMaxItem
;n
++)
704 if( 0 != (pOver
= (const SvxOverlineItem
*)rPool
.GetItem( RES_CHRATR_OVERLINE
, n
) ) )
705 InsColor( *pColTbl
, pOver
->GetColor() );
711 // das Frame Hintergrund - Attribut
712 static const USHORT aBrushIds
[] = {
713 RES_BACKGROUND
, RES_CHRATR_BACKGROUND
, 0 };
715 for( const USHORT
* pIds
= aBrushIds
; *pIds
; ++pIds
)
717 const SvxBrushItem
* pBkgrd
= (const SvxBrushItem
*)GetDfltAttr( *pIds
);
718 InsColor( *pColTbl
, pBkgrd
->GetColor() );
719 if( 0 != ( pBkgrd
= (const SvxBrushItem
*)rPool
.GetPoolDefaultItem(
722 InsColor( *pColTbl
, pBkgrd
->GetColor() );
724 nMaxItem
= rPool
.GetItemCount( *pIds
);
725 for( n
= 0; n
< nMaxItem
; ++n
)
726 if( 0 != (pBkgrd
= (const SvxBrushItem
*)rPool
.GetItem(
729 InsColor( *pColTbl
, pBkgrd
->GetColor() );
733 // das Frame Schatten - Attribut
735 const SvxShadowItem
* pShadow
= (const SvxShadowItem
*)GetDfltAttr(
737 InsColor( *pColTbl
, pShadow
->GetColor() );
738 if( 0 != ( pShadow
= (const SvxShadowItem
*)rPool
.GetPoolDefaultItem(
741 InsColor( *pColTbl
, pShadow
->GetColor() );
743 nMaxItem
= rPool
.GetItemCount(RES_SHADOW
);
744 for( n
= 0; n
< nMaxItem
; ++n
)
745 if( 0 != (pShadow
= (const SvxShadowItem
*)rPool
.GetItem(
748 InsColor( *pColTbl
, pShadow
->GetColor() );
752 // das Frame Umrandungs - Attribut
754 // Box muesste noch gemacht werden, aber default nie eine Line gesetzt!
755 const SvxBoxItem
* pBox
;
756 if( 0 != ( pBox
= (const SvxBoxItem
*)rPool
.GetPoolDefaultItem(
758 InsColorLine( *pColTbl
, *pBox
);
759 nMaxItem
= rPool
.GetItemCount(RES_BOX
);
760 for( n
= 0; n
< nMaxItem
; ++n
)
761 if( 0 != (pBox
= (const SvxBoxItem
*)rPool
.GetItem( RES_BOX
, n
) ))
762 InsColorLine( *pColTbl
, *pBox
);
766 Strm() << SwRTFWriter::sNewLine
<< '{' << OOO_STRING_SVTOOLS_RTF_COLORTBL
;
768 for( n
= 0; n
< pColTbl
->Count(); n
++ )
770 const Color
& rCol
= (*pColTbl
)[ n
];
771 if( n
|| COL_AUTO
!= rCol
.GetColor() )
773 Strm() << OOO_STRING_SVTOOLS_RTF_RED
;
774 OutULong( rCol
.GetRed() ) << OOO_STRING_SVTOOLS_RTF_GREEN
;
775 OutULong( rCol
.GetGreen() ) << OOO_STRING_SVTOOLS_RTF_BLUE
;
776 OutULong( rCol
.GetBlue() );
783 bool FontCharsetSufficient(const String
&rFntNm
, const String
&rAltNm
,
784 rtl_TextEncoding eChrSet
)
786 bool bRet
= CharsetSufficient(rFntNm
, eChrSet
);
788 bRet
= CharsetSufficient(rAltNm
, eChrSet
);
792 static void _OutFont( SwRTFWriter
& rWrt
, const SvxFontItem
& rFont
, USHORT nNo
)
794 rWrt
.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_F
;
796 const char* pStr
= OOO_STRING_SVTOOLS_RTF_FNIL
;
797 switch (rFont
.GetFamily())
800 pStr
= OOO_STRING_SVTOOLS_RTF_FROMAN
;
803 pStr
= OOO_STRING_SVTOOLS_RTF_FSWISS
;
806 pStr
= OOO_STRING_SVTOOLS_RTF_FMODERN
;
809 pStr
= OOO_STRING_SVTOOLS_RTF_FSCRIPT
;
811 case FAMILY_DECORATIVE
:
812 pStr
= OOO_STRING_SVTOOLS_RTF_FDECOR
;
817 rWrt
.OutULong(nNo
) << pStr
<< OOO_STRING_SVTOOLS_RTF_FPRQ
;
820 switch (rFont
.GetPitch())
834 sw::util::FontMapExport
aRes(rFont
.GetFamilyName());
838 In rtf the fontname is in the fontcharset, so if that isn't possible
839 then bump the charset up to unicode
841 sal_uInt8 nChSet
= 0;
842 rtl_TextEncoding eChrSet
= rFont
.GetCharSet();
843 nChSet
= sw::ms::rtl_TextEncodingToWinCharset(eChrSet
);
844 eChrSet
= rtl_getTextEncodingFromWindowsCharset(nChSet
);
845 if (!FontCharsetSufficient(aRes
.msPrimary
, aRes
.msSecondary
, eChrSet
))
847 eChrSet
= RTL_TEXTENCODING_UNICODE
;
848 nChSet
= sw::ms::rtl_TextEncodingToWinCharset(eChrSet
);
849 eChrSet
= rtl_getTextEncodingFromWindowsCharset(nChSet
);
852 rWrt
.Strm() << OOO_STRING_SVTOOLS_RTF_FCHARSET
;
853 rWrt
.OutULong( nChSet
);
855 if (aRes
.HasDistinctSecondary())
857 RTFOutFuncs::Out_Fontname(rWrt
.Strm(), aRes
.msPrimary
, eChrSet
,
859 OutComment(rWrt
, OOO_STRING_SVTOOLS_RTF_FALT
) << ' ';
860 RTFOutFuncs::Out_Fontname(rWrt
.Strm(), aRes
.msSecondary
, eChrSet
,
861 rWrt
.bWriteHelpFmt
) << '}';
865 RTFOutFuncs::Out_Fontname(rWrt
.Strm(), aRes
.msPrimary
, eChrSet
,
871 void SwRTFWriter::OutRTFFontTab()
874 const SfxItemPool
& rPool
= pDoc
->GetAttrPool();
875 const SvxFontItem
* pFont
= (const SvxFontItem
*)GetDfltAttr(RES_CHRATR_FONT
);
877 Strm() << SwRTFWriter::sNewLine
<< '{' << OOO_STRING_SVTOOLS_RTF_FONTTBL
;
878 _OutFont( *this, *pFont
, n
++ );
880 pFont
= (const SvxFontItem
*)rPool
.GetPoolDefaultItem(RES_CHRATR_FONT
);
882 _OutFont(*this, *pFont
, n
++);
884 PutNumFmtFontsInAttrPool();
885 PutCJKandCTLFontsInAttrPool();
887 USHORT nMaxItem
= rPool
.GetItemCount(RES_CHRATR_FONT
);
888 for (USHORT nGet
= 0; nGet
< nMaxItem
; ++nGet
)
890 pFont
= (const SvxFontItem
*)rPool
.GetItem(RES_CHRATR_FONT
, nGet
);
892 _OutFont(*this, *pFont
, n
++);
898 void RTF_WrtRedlineAuthor::Write(Writer
&rWrt
)
900 SwRTFWriter
& rRTFWrt
= (SwRTFWriter
&)rWrt
;
902 rRTFWrt
.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_IGNORE
<< OOO_STRING_SVTOOLS_RTF_REVTBL
<< ' ';
903 typedef std::vector
<String
>::iterator myiter
;
905 for(std::vector
<String
>::iterator aIter
= maAuthors
.begin(); aIter
!= maAuthors
.end(); ++aIter
)
907 rRTFWrt
.Strm() << '{';
908 // rWrt.bWriteHelpFmt
909 RTFOutFuncs::Out_String( rRTFWrt
.Strm(), *aIter
, rRTFWrt
.eDefaultEncoding
, rRTFWrt
.bWriteHelpFmt
) << ";}";
911 rRTFWrt
.Strm() << '}' << SwRTFWriter::sNewLine
;
914 bool SwRTFWriter::OutRTFRevTab()
916 // Writes the revision author table
917 int nRevAuthors
= pDoc
->GetRedlineTbl().Count();
919 pRedlAuthors
= new RTF_WrtRedlineAuthor
;
920 // RTF always seems to use Unknown as the default first entry
921 String
sUnknown(RTL_CONSTASCII_STRINGPARAM("Unknown"));
922 pRedlAuthors
->AddName(sUnknown
);
927 // pull out all the redlines and make a vector of all the author names
928 for( USHORT i
= 0; i
< pDoc
->GetRedlineTbl().Count(); ++i
)
930 const SwRedline
* pRedl
= pDoc
->GetRedlineTbl()[ i
];
931 const String sAuthor
= SW_MOD()->GetRedlineAuthor( pRedl
->GetAuthor() );
932 pRedlAuthors
->AddName(sAuthor
);
935 pRedlAuthors
->Write(*this);
939 //Takashi Ono for CJK
940 const rtl::OUString
SwRTFWriter::XlateFmtName( const rtl::OUString
&rName
, SwGetPoolIdFromName eFlags
)
942 #define RES_NONE RES_POOLCOLL_DOC_END
944 static const RES_POOL_COLLFMT_TYPE aArr
[]={
945 RES_POOLCOLL_STANDARD
, RES_POOLCOLL_HEADLINE1
, RES_POOLCOLL_HEADLINE2
,
946 RES_POOLCOLL_HEADLINE3
, RES_POOLCOLL_HEADLINE4
, RES_POOLCOLL_HEADLINE5
,
947 RES_POOLCOLL_HEADLINE6
, RES_POOLCOLL_HEADLINE7
, RES_POOLCOLL_HEADLINE8
,
948 RES_POOLCOLL_HEADLINE9
,
950 RES_POOLCOLL_TOX_IDX1
, RES_POOLCOLL_TOX_IDX2
, RES_POOLCOLL_TOX_IDX3
,
951 RES_NONE
, RES_NONE
, RES_NONE
, RES_NONE
, RES_NONE
, RES_NONE
,
952 RES_POOLCOLL_TOX_CNTNT1
,
954 RES_POOLCOLL_TOX_CNTNT2
, RES_POOLCOLL_TOX_CNTNT3
, RES_POOLCOLL_TOX_CNTNT4
,
955 RES_POOLCOLL_TOX_CNTNT5
, RES_POOLCOLL_TOX_CNTNT6
, RES_POOLCOLL_TOX_CNTNT7
,
956 RES_POOLCOLL_TOX_CNTNT8
, RES_POOLCOLL_TOX_CNTNT9
,
957 RES_POOLCOLL_TEXT_IDENT
, RES_POOLCOLL_FOOTNOTE
,
959 RES_NONE
, RES_POOLCOLL_HEADER
, RES_POOLCOLL_FOOTER
, RES_POOLCOLL_TOX_IDXH
,
960 RES_POOLCOLL_LABEL
, RES_POOLCOLL_TOX_ILLUSH
, RES_POOLCOLL_JAKETADRESS
, RES_POOLCOLL_SENDADRESS
,
963 RES_NONE
, RES_NONE
, RES_NONE
, RES_POOLCOLL_ENDNOTE
, RES_POOLCOLL_TOX_AUTHORITIESH
, RES_NONE
, RES_NONE
,
964 RES_POOLCOLL_BUL_LEVEL1
, RES_POOLCOLL_BUL_LEVEL1
, RES_POOLCOLL_NUM_LEVEL1
,
966 RES_POOLCOLL_BUL_LEVEL2
, RES_POOLCOLL_BUL_LEVEL3
, RES_POOLCOLL_BUL_LEVEL4
, RES_POOLCOLL_BUL_LEVEL5
,
967 RES_POOLCOLL_BUL_LEVEL2
, RES_POOLCOLL_BUL_LEVEL3
, RES_POOLCOLL_BUL_LEVEL4
, RES_POOLCOLL_BUL_LEVEL5
,
968 RES_POOLCOLL_NUM_LEVEL2
, RES_POOLCOLL_NUM_LEVEL3
, RES_POOLCOLL_NUM_LEVEL4
, RES_POOLCOLL_NUM_LEVEL5
,
970 RES_POOLCOLL_DOC_TITEL
, RES_NONE
, RES_POOLCOLL_SIGNATURE
, RES_NONE
,
971 RES_POOLCOLL_TEXT
, RES_POOLCOLL_TEXT_MOVE
, RES_NONE
, RES_NONE
,
973 RES_NONE
, RES_NONE
, RES_NONE
, RES_NONE
, RES_POOLCOLL_DOC_SUBTITEL
};
975 static const sal_Char
*stiName
[] = {
976 "Normal", "heading 1", "heading 2",
977 "heading 3", "heading 4", "heading 5",
978 "heading 6", "heading 7", "heading 8",
981 "index 1", "index 2", "index 3",
982 "index 4", "index 5", "index 6",
983 "index 7", "index 8", "index 9",
985 "toc 1", "toc 2", "toc 3",
986 "toc 4", "toc 5", "toc 6",
987 "toc 7", "toc 8", "toc 9",
988 "Normal Indent", "footnote text",
990 "annotation text", "header", "footer", "index heading",
991 "caption", "table of figures", "envelope address", "envelope return",
992 "footnote reference", "annotation reference",
994 "line number", "page number", "endnote reference", "endnote text", "table of authorities", "macro", "toa heading",
995 "List", "List Bullet", "List Number",
997 "List 2", "List 3", "List 4", "List 5",
998 "List Bullet 2", "List Bullet 3", "List Bullet 4", "List Bullet 5",
999 "List Number 2", "List Number 3", "List Number 4", "List Number 5",
1001 "Title", "Closing", "Signature", "Default Paragraph Font",
1002 "Body Text", "Body Text Indent", "List Continue",
1004 "List Continue 2", "List Continue 3", "List Continue 4", "List Continue 5", "Message Header", "Subtitle"};
1006 ASSERT( ( sizeof( aArr
) / sizeof( RES_POOL_COLLFMT_TYPE
) == 75 ),
1007 "Style-UEbersetzungstabelle hat falsche Groesse" );
1008 ASSERT( ( sizeof( stiName
) / sizeof( *stiName
) == 75 ),
1009 "Style-UEbersetzungstabelle hat falsche Groesse" );
1011 sal_uInt16 idcol
= ::SwStyleNameMapper::GetPoolIdFromUIName( rName
, eFlags
);
1012 if (idcol
==USHRT_MAX
) //#i40770# user defined style names get lost
1015 for (size_t i
= 0; i
< sizeof( aArr
) / sizeof( *aArr
); i
++)
1017 if ( idcol
== aArr
[i
] )
1019 return rtl::OUString::createFromAscii(stiName
[i
]);
1022 return ::SwStyleNameMapper::GetProgName( idcol
, String() );
1025 void SwRTFWriter::OutRTFStyleTab()
1029 // das 0-Style ist das Default, wird nie ausgegeben !!
1030 USHORT nArrLen
= pDoc
->GetTxtFmtColls()->Count();
1031 if( nArrLen
<= 1 && pDoc
->GetCharFmts()->Count() <= 1 )
1034 bOutStyleTab
= TRUE
;
1035 Strm() << SwRTFWriter::sNewLine
<< '{' << OOO_STRING_SVTOOLS_RTF_STYLESHEET
;
1037 // das Default-TextStyle wird nicht mit ausgegeben !!
1038 for( n
= 1; n
< nArrLen
; ++n
)
1040 const SwTxtFmtColl
* pColl
= (*pDoc
->GetTxtFmtColls())[ n
];
1041 pAttrSet
= &pColl
->GetAttrSet();
1044 // gebe Attribute aus
1045 OutRTF_SwFmt( *this, *pColl
);
1047 if( pColl
->DerivedFrom() )
1048 // suche die Id vom "Parent" Format
1049 for( USHORT nBasedOn
=1; nBasedOn
< nArrLen
; nBasedOn
++)
1050 if( (*pDoc
->GetTxtFmtColls())[ nBasedOn
] ==
1051 pColl
->DerivedFrom() )
1053 // die Ableitung vom Format
1054 Strm() << OOO_STRING_SVTOOLS_RTF_SBASEDON
;
1055 OutULong( nBasedOn
);
1059 if( pColl
== &pColl
->GetNextTxtFmtColl() )
1061 Strm() << OOO_STRING_SVTOOLS_RTF_SNEXT
;
1065 // suche die Id vom "Naechsten" Format
1066 for( USHORT nNext
=1; nNext
< nArrLen
; nNext
++)
1067 if( (*pDoc
->GetTxtFmtColls())[ nNext
] ==
1068 &pColl
->GetNextTxtFmtColl() )
1070 // die Ableitung vom Format
1071 Strm() << OOO_STRING_SVTOOLS_RTF_SNEXT
;
1076 //if( NO_NUMBERING != pColl->GetOutlineLevel() )//#outline level,zhaojianwei
1077 if(pColl
->IsAssignedToListLevelOfOutlineStyle())//<-end,zhaojianwei
1079 Strm() << '{' << OOO_STRING_SVTOOLS_RTF_IGNORE
<< OOO_STRING_SVTOOLS_RTF_SOUTLVL
;
1080 //OutULong( pColl->GetOutlineLevel() ) << '}';//#outline level,zhaojianwei
1081 OutULong( pColl
->GetAssignedOutlineStyleLevel() ) << '}';//<-end,zhaojianwei
1085 RTFOutFuncs::Out_String( Strm(), XlateFmtName( pColl
->GetName(), nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
), eDefaultEncoding
,
1086 bWriteHelpFmt
) << ";}" << SwRTFWriter::sNewLine
;
1089 USHORT nChrArrLen
= pDoc
->GetCharFmts()->Count();
1090 for( n
= 1; n
< nChrArrLen
; ++n
)
1092 const SwCharFmt
* pFmt
= (*pDoc
->GetCharFmts())[ n
];
1093 pAttrSet
= &pFmt
->GetAttrSet();
1096 // gebe Attribute aus
1097 OutRTF_SwFmt( *this, *pFmt
);
1099 if( pFmt
->DerivedFrom() )
1100 // suche die Id vom "Parent" Format
1101 for( USHORT nBasedOn
=1; nBasedOn
< nChrArrLen
; nBasedOn
++)
1102 if( (*pDoc
->GetCharFmts())[ nBasedOn
] ==
1103 pFmt
->DerivedFrom() )
1105 // die Ableitung vom Format
1106 Strm() << OOO_STRING_SVTOOLS_RTF_SBASEDON
;
1107 OutULong( nArrLen
+ nBasedOn
);
1112 RTFOutFuncs::Out_String( Strm(), XlateFmtName( pFmt
->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
), eDefaultEncoding
,
1113 bWriteHelpFmt
) << ";}" << SwRTFWriter::sNewLine
;
1117 bOutStyleTab
= FALSE
;
1120 bool ExportAsInline(const SwFlyFrmFmt
& rFlyFrmFmt
)
1122 //if not an inline element (hack in our limitations here as to only
1123 //graphics like this!!!!
1124 return rFlyFrmFmt
.GetAnchor().GetAnchorId() == FLY_AS_CHAR
;
1127 void SwRTFWriter::OutRTFFlyFrms(const SwFlyFrmFmt
& rFlyFrmFmt
)
1129 // ein FlyFrame wurde erkannt, gebe erstmal den aus
1131 // Hole vom Node und vom letzten Node die Position in der Section
1132 const SwFmtCntnt
& rFlyCntnt
= rFlyFrmFmt
.GetCntnt();
1134 ULONG nStt
= rFlyCntnt
.GetCntntIdx()->GetIndex()+1;
1135 ULONG nEnd
= pDoc
->GetNodes()[ nStt
- 1 ]->EndOfSectionIndex();
1137 if( nStt
>= nEnd
) // kein Bereich, also kein gueltiger Node
1140 if (!ExportAsInline(rFlyFrmFmt
))
1141 Strm() << SwRTFWriter::sNewLine
<< OOO_STRING_SVTOOLS_RTF_PARD
<< OOO_STRING_SVTOOLS_RTF_PLAIN
;
1142 //If we are only exporting an inline graphic/object then we
1143 //only need the its pFlyFmt for the duration of exporting it
1144 //for floating objects its a little more complex at the moment
1145 const SwFlyFrmFmt
*pOldFlyFmt
= pFlyFmt
;
1146 pFlyFmt
= &rFlyFrmFmt
;
1149 RTFSaveData
aSaveData( *this, nStt
, nEnd
);
1150 Out_SwDoc( pCurPam
);
1153 if (!ExportAsInline(rFlyFrmFmt
))
1154 Strm() << OOO_STRING_SVTOOLS_RTF_PARD
<< SwRTFWriter::sNewLine
;
1156 pFlyFmt
= pOldFlyFmt
;
1161 void SwRTFWriter::OutRedline( xub_StrLen nCntntPos
)
1163 const SwRedline
*pCurRedline
= 0;
1164 USHORT nCount
= pDoc
->GetRedlineTbl().Count();
1166 if (nCurRedline
< nCount
)
1168 pCurRedline
= pDoc
->GetRedlineTbl()[nCurRedline
];
1171 const SwPosition
* pStartPos
= pCurRedline
->Start();
1172 const SwPosition
* pEndPos
= pStartPos
== pCurRedline
->GetPoint()
1173 ? pCurRedline
->GetMark()
1174 : pCurRedline
->GetPoint();
1176 USHORT nStart
= pStartPos
->nContent
.GetIndex();
1177 USHORT nEnd
= pEndPos
->nContent
.GetIndex();
1179 ULONG nCurPam
= pCurPam
->GetPoint()->nNode
.GetIndex();
1180 ULONG nStartIndex
= pStartPos
->nNode
.GetIndex();
1181 ULONG nEndIndex
= pEndPos
->nNode
.GetIndex();
1182 const String
& rStr
= pCurPam
->GetNode()->GetTxtNode()->GetTxt();
1183 xub_StrLen nEnde
= rStr
.Len();
1185 bool bSpanRedline
= (nCurPam
>= nStartIndex
) && (nCurPam
<= nEndIndex
) && (nStartIndex
!= nEndIndex
);
1187 if ((bSpanRedline
&& nCntntPos
== 0) ||
1188 (nStartIndex
== nCurPam
&& nStart
== nCntntPos
))
1190 // We are at the start of a redline just need to find out which type
1192 if(pCurRedline
->GetType() == nsRedlineType_t::REDLINE_INSERT
)
1194 Strm() << OOO_STRING_SVTOOLS_RTF_REVISED
;
1195 Strm() << OOO_STRING_SVTOOLS_RTF_REVAUTH
;
1196 String sName
= SW_MOD()->GetRedlineAuthor(pCurRedline
->GetAuthor());
1197 OutLong( pRedlAuthors
->AddName(sName
) );
1198 Strm() << OOO_STRING_SVTOOLS_RTF_REVDTTM
;
1199 OutLong( sw::ms::DateTime2DTTM(pCurRedline
->GetTimeStamp()) );
1202 else if(pCurRedline
->GetType() == nsRedlineType_t::REDLINE_DELETE
)
1204 Strm() << OOO_STRING_SVTOOLS_RTF_DELETED
;
1205 Strm() << OOO_STRING_SVTOOLS_RTF_REVAUTHDEL
;
1206 String sDelName
= SW_MOD()->GetRedlineAuthor(pCurRedline
->GetAuthor());
1207 OutLong( pRedlAuthors
->AddName(sDelName
) );
1208 Strm() << OOO_STRING_SVTOOLS_RTF_REVDTTMDEL
;
1209 OutLong( sw::ms::DateTime2DTTM(pCurRedline
->GetTimeStamp()) );
1214 // this is either then of the end of the node or the end of the redline
1215 // time to close off this one
1216 if( (bSpanRedline
&& nCntntPos
== nEnde
) ||
1217 (nEndIndex
== nCurPam
&& nEnd
== nCntntPos
) )
1222 // We have come to the end of a redline move to the next one
1223 // and use resursion to see if another redline starts here
1224 if (nEndIndex
== nCurPam
&& nEnd
== nCntntPos
)
1227 OutRedline(nCntntPos
);
1233 void SwRTFWriter::OutBookmarks( xub_StrLen nCntntPos
)
1235 IDocumentMarkAccess
* const pMarkAccess
= pDoc
->getIDocumentMarkAccess();
1236 if (-1 == nBkmkTabPos
)
1239 const ::sw::mark::IMark
* pBookmark
= (pMarkAccess
->getMarksBegin() + nBkmkTabPos
)->get();
1243 const SwPosition
* pStartPos
= &pBookmark
->GetMarkStart();
1244 const SwPosition
* pEndPos
= &pBookmark
->GetMarkEnd();
1246 ASSERT(pStartPos
&& pEndPos
, "Impossible");
1247 if (!(pStartPos
&& pEndPos
))
1250 if (pStartPos
->nNode
.GetIndex() == pCurPam
->GetPoint()->nNode
.GetIndex() &&
1251 pStartPos
->nContent
.GetIndex() == nCntntPos
)
1253 // zur Zeit umspannt das SwBookmark keinen Bereich also kann
1254 // es hier vollstaendig ausgegeben werden.
1256 // erst die SWG spezifischen Daten:
1257 const ::sw::mark::IBookmark
* const pAsBookmark
= dynamic_cast< const ::sw::mark::IBookmark
* >(pBookmark
);
1258 if(pAsBookmark
&& (pAsBookmark
->GetShortName().getLength() || pAsBookmark
->GetKeyCode().GetCode()))
1260 OutComment( *this, OOO_STRING_SVTOOLS_RTF_BKMKKEY
);
1261 OutULong( ( pAsBookmark
->GetKeyCode().GetCode() |
1262 pAsBookmark
->GetKeyCode().GetModifier() ));
1263 if( !pAsBookmark
->GetShortName().getLength() )
1268 OutRTF_AsByteString( *this, pAsBookmark
->GetShortName(), eDefaultEncoding
);
1272 OutComment( *this, OOO_STRING_SVTOOLS_RTF_BKMKSTART
) << ' ';
1273 RTFOutFuncs::Out_String( Strm(), pBookmark
->GetName(),
1274 eDefaultEncoding
, bWriteHelpFmt
) << '}';
1277 if (pEndPos
->nNode
.GetIndex() == pCurPam
->GetPoint()->nNode
.GetIndex() &&
1278 pEndPos
->nContent
.GetIndex() == nCntntPos
)
1280 // zur Zeit umspannt das SwBookmark keinen Bereich also kann
1281 // es hier vollstaendig ausgegeben werden.
1283 // erst die SWG spezifischen Daten:
1284 const ::sw::mark::IBookmark
* const pAsBookmark
= dynamic_cast< const ::sw::mark::IBookmark
* >(pBookmark
);
1285 if(pAsBookmark
&& (pAsBookmark
->GetShortName().getLength() || pAsBookmark
->GetKeyCode().GetCode()))
1287 OutComment( *this, OOO_STRING_SVTOOLS_RTF_BKMKKEY
);
1288 OutULong( ( pAsBookmark
->GetKeyCode().GetCode() |
1289 pAsBookmark
->GetKeyCode().GetModifier() ));
1290 if( !pAsBookmark
->GetShortName().getLength() )
1295 OutRTF_AsByteString( *this, pAsBookmark
->GetShortName(), eDefaultEncoding
);
1299 OutComment( *this, OOO_STRING_SVTOOLS_RTF_BKMKEND
) << ' ';
1302 ::rtl::OUString aEmpty
;
1303 ::rtl::OUString
& rBookmarkName
= aEmpty
;
1306 rBookmarkName
= pAsBookmark
->GetName();
1308 RTFOutFuncs::Out_String( Strm(), rBookmarkName
,
1309 eDefaultEncoding
, bWriteHelpFmt
) << '}';
1312 if(++nBkmkTabPos
>= pMarkAccess
->getMarksCount())
1315 pBookmark
= (pMarkAccess
->getMarksBegin() + nBkmkTabPos
)->get();
1319 void SwRTFWriter::OutFlyFrm()
1326 // gebe alle freifliegenden Rahmen die sich auf den akt. Absatz
1327 // und evt. auf das aktuelle Zeichen beziehen, aus.
1329 // suche nach dem Anfang der FlyFrames
1330 for( n
= 0; n
< pFlyPos
->Count() &&
1331 (*pFlyPos
)[n
]->GetNdIndex().GetIndex() <
1332 pCurPam
->GetPoint()->nNode
.GetIndex(); ++n
)
1334 if( n
< pFlyPos
->Count() )
1335 while( n
< pFlyPos
->Count() &&
1336 pCurPam
->GetPoint()->nNode
.GetIndex() ==
1337 (*pFlyPos
)[n
]->GetNdIndex().GetIndex() )
1339 // den Array-Iterator weiterschalten, damit nicht doppelt
1340 // ausgegeben wird !!
1341 OutRTFFlyFrms( (const SwFlyFrmFmt
&)(*pFlyPos
)[n
++]->GetFmt() );
1346 USHORT
SwRTFWriter::GetId( const Color
& rColor
) const
1348 ASSERT( pColTbl
, "Wo ist meine Color-Tabelle?" );
1349 for( USHORT n
= 0; n
< pColTbl
->Count(); n
++ )
1350 if( rColor
== (*pColTbl
)[ n
] )
1353 ASSERT( FALSE
, "Color nicht in der Tabelle" );
1357 USHORT
SwRTFWriter::GetId( const SvxFontItem
& rFont
) const
1359 const SfxItemPool
& rPool
= pDoc
->GetAttrPool();
1360 const SvxFontItem
* pFont
= (const SvxFontItem
*)GetDfltAttr( RES_CHRATR_FONT
);
1361 if( rFont
== *pFont
)
1365 if( 0 != ( pFont
= (const SvxFontItem
*)rPool
.GetPoolDefaultItem(
1368 if( rFont
== *pFont
)
1373 USHORT nMaxItem
= rPool
.GetItemCount( RES_CHRATR_FONT
);
1374 for( USHORT nGet
= 0; nGet
< nMaxItem
; ++nGet
)
1375 if( 0 != (pFont
= (const SvxFontItem
*)rPool
.GetItem(
1376 RES_CHRATR_FONT
, nGet
)) )
1378 if( rFont
== *pFont
)
1383 ASSERT( FALSE
, "Font nicht in der Tabelle" );
1387 USHORT
SwRTFWriter::GetId( const Font
& rFont
) const
1389 return GetId( SvxFontItem( rFont
.GetFamily(), rFont
.GetName(),
1390 rFont
.GetStyleName(), rFont
.GetPitch(),
1392 RES_CHRATR_FONT
) );
1395 USHORT
SwRTFWriter::GetId( const SwTxtFmtColl
& rColl
) const
1397 // suche das angegebene Format
1398 const SvPtrarr
& rArr
= *pDoc
->GetTxtFmtColls();
1399 for( USHORT n
= 0; n
< rArr
.Count(); n
++ )
1400 if( (SwTxtFmtColl
*)rArr
[ n
] == &rColl
)
1402 ASSERT( FALSE
, "TextCollection nicht in der Tabelle" );
1406 USHORT
SwRTFWriter::GetId( const SwCharFmt
& rFmt
) const
1408 // suche das angegebene Format
1409 const SvPtrarr
& rArr
= *pDoc
->GetCharFmts();
1410 for( USHORT n
= 0; n
< rArr
.Count(); n
++ )
1411 if( (SwCharFmt
*)rArr
[ n
] == &rFmt
)
1412 return n
+ pDoc
->GetTxtFmtColls()->Count();
1413 ASSERT( FALSE
, "CharDFFormat nicht in der Tabelle" );
1417 void SwRTFWriter::OutPageDesc()
1419 // Ausgabe der Page-Descriptoren
1420 USHORT nSize
= pDoc
->GetPageDescCnt();
1424 Strm() << SwRTFWriter::sNewLine
; // ein Trenner
1425 bOutPageDesc
= bOutPageDescTbl
= TRUE
;
1426 OutComment( *this, OOO_STRING_SVTOOLS_RTF_PGDSCTBL
);
1427 for( USHORT n
= 0; n
< nSize
; ++n
)
1429 const SwPageDesc
& rPageDesc
=
1430 const_cast<const SwDoc
*>(pDoc
)->GetPageDesc( n
);
1432 Strm() << SwRTFWriter::sNewLine
<< '{' << OOO_STRING_SVTOOLS_RTF_PGDSC
;
1433 OutULong( n
) << OOO_STRING_SVTOOLS_RTF_PGDSCUSE
;
1434 OutULong( rPageDesc
.ReadUseOn() );
1436 OutRTFPageDescription( rPageDesc
, FALSE
, FALSE
);
1438 // suche den Folge-PageDescriptor:
1441 if( rPageDesc
.GetFollow() ==
1442 &const_cast<const SwDoc
*>(pDoc
)->GetPageDesc( --i
) )
1444 Strm() << OOO_STRING_SVTOOLS_RTF_PGDSCNXT
;
1445 OutULong( i
) << ' ';
1446 RTFOutFuncs::Out_String( Strm(), XlateFmtName( rPageDesc
.GetName(), nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC
), eDefaultEncoding
,
1447 bWriteHelpFmt
) << ";}";
1449 Strm() << '}' << SwRTFWriter::sNewLine
;
1450 bOutPageDesc
= bOutPageDescTbl
= FALSE
;
1453 void SwRTFWriter::OutRTFBorder(const SvxBorderLine
* aLine
, const USHORT nSpace
)
1455 // M.M. This function writes out border lines in RTF similar to what
1456 // WW8_BRC SwWW8Writer::TranslateBorderLine does in the winword filter
1457 // Eventually it would be nice if all this functionality was in the one place
1458 int nDistance
= aLine
->GetDistance();
1459 int nOutWidth
= aLine
->GetOutWidth();
1460 int nInWidth
= aLine
->GetInWidth();
1461 int nWidth
= aLine
->GetOutWidth();
1463 if(nDistance
== 0) // Single Line
1464 Strm() << OOO_STRING_SVTOOLS_RTF_BRDRS
;
1467 if(nOutWidth
== nInWidth
)
1468 Strm() << OOO_STRING_SVTOOLS_RTF_BRDRDB
;
1469 else if (nOutWidth
> nInWidth
)
1470 Strm() << OOO_STRING_SVTOOLS_RTF_BRDRTNTHSG
;
1471 else if (nOutWidth
< nInWidth
)
1472 Strm() << OOO_STRING_SVTOOLS_RTF_BRDRTHTNSG
;
1474 Strm() << OOO_STRING_SVTOOLS_RTF_BRDRW
;
1477 Strm() << OOO_STRING_SVTOOLS_RTF_BRSP
;
1481 void SwRTFWriter::OutRTFBorders(SvxBoxItem aBox
)
1483 const SvxBorderLine
*pLine
= aBox
.GetTop();
1486 Strm() << OOO_STRING_SVTOOLS_RTF_PGBRDRT
;
1487 OutRTFBorder(pLine
, aBox
.GetDistance(BOX_LINE_TOP
));
1490 pLine
= aBox
.GetBottom();
1493 Strm() << OOO_STRING_SVTOOLS_RTF_PGBRDRB
;
1494 OutRTFBorder(pLine
, aBox
.GetDistance(BOX_LINE_BOTTOM
));
1497 pLine
= aBox
.GetRight();
1500 Strm() << OOO_STRING_SVTOOLS_RTF_PGBRDRR
;
1501 OutRTFBorder(pLine
, aBox
.GetDistance(BOX_LINE_LEFT
));
1504 pLine
= aBox
.GetLeft();
1507 Strm() << OOO_STRING_SVTOOLS_RTF_PGBRDRL
;
1508 OutRTFBorder(pLine
, aBox
.GetDistance(BOX_LINE_RIGHT
));
1512 void SwRTFWriter::OutRTFPageDescription( const SwPageDesc
& rPgDsc
,
1514 BOOL bCheckForFirstPage
)
1516 // jetzt noch den Teil fuer alle anderen Applikationen:
1517 const SwPageDesc
*pSave
= pAktPageDesc
;
1518 bool bOldOut
= bOutPageDesc
;
1519 bool bOldHDFT
= bOutLeftHeadFoot
;
1521 // falls es einen Follow gibt,
1522 pAktPageDesc
= &rPgDsc
;
1523 if( bCheckForFirstPage
&& pAktPageDesc
->GetFollow() &&
1524 pAktPageDesc
->GetFollow() != pAktPageDesc
)
1525 pAktPageDesc
= pAktPageDesc
->GetFollow();
1527 bOutPageDesc
= TRUE
;
1528 bOutLeftHeadFoot
= FALSE
;
1532 if( bFirstLine
&& bWriteAll
&&
1533 pCurPam
->GetPoint()->nNode
== pOrigPam
->Start()->nNode
)
1534 Strm() << OOO_STRING_SVTOOLS_RTF_SECTD
<< OOO_STRING_SVTOOLS_RTF_SBKNONE
;
1536 Strm() << OOO_STRING_SVTOOLS_RTF_SECT
<< OOO_STRING_SVTOOLS_RTF_SECTD
;
1539 if( pAktPageDesc
->GetLandscape() )
1540 Strm() << OOO_STRING_SVTOOLS_RTF_LNDSCPSXN
;
1542 const SwFmt
*pFmt
= &pAktPageDesc
->GetMaster(); //GetLeft();
1543 OutRTF_SwFmt( *this, *pFmt
);
1545 SvxBoxItem aBox
= pFmt
->GetAttrSet().GetBox();
1546 OutRTFBorders(pFmt
->GetAttrSet().GetBox());
1548 // falls es gesharte Heaer/Footer gibt, so gebe diese auch noch aus
1550 (nsUseOnPage::PD_MIRROR
& pAktPageDesc
->GetUseOn()) &&
1551 (!pAktPageDesc
->IsFooterShared() || !pAktPageDesc
->IsHeaderShared())
1554 bOutLeftHeadFoot
= TRUE
;
1555 const SfxPoolItem
* pHt
;
1556 if( !pAktPageDesc
->IsHeaderShared() &&
1557 SFX_ITEM_SET
== pAktPageDesc
->GetLeft().GetAttrSet().
1558 GetItemState( RES_HEADER
, FALSE
, &pHt
))
1559 OutRTF_SwFmtHeader( *this, *pHt
);
1561 if( !pAktPageDesc
->IsFooterShared() &&
1562 SFX_ITEM_SET
== pAktPageDesc
->GetLeft().GetAttrSet().
1563 GetItemState( RES_FOOTER
, FALSE
, &pHt
))
1564 OutRTF_SwFmtFooter( *this, *pHt
);
1565 bOutLeftHeadFoot
= FALSE
;
1568 if( pAktPageDesc
!= &rPgDsc
)
1570 pAktPageDesc
= &rPgDsc
;
1571 Strm() << OOO_STRING_SVTOOLS_RTF_TITLEPG
;
1573 // die Header/Footer der 1. Seite ausgeben
1574 const SfxPoolItem
* pHt
;
1575 if( SFX_ITEM_SET
== pAktPageDesc
->GetMaster().GetAttrSet().
1576 GetItemState( RES_HEADER
, FALSE
, &pHt
))
1577 OutRTF_SwFmtHeader( *this, *pHt
);
1579 if( SFX_ITEM_SET
== pAktPageDesc
->GetMaster().GetAttrSet().
1580 GetItemState( RES_FOOTER
, FALSE
, &pHt
))
1581 OutRTF_SwFmtFooter( *this, *pHt
);
1584 pAktPageDesc
= pSave
;
1585 bOutPageDesc
= bOldOut
;
1586 bOutLeftHeadFoot
= bOldHDFT
;
1589 BOOL
SwRTFWriter::OutBreaks( const SfxItemSet
& rSet
)
1591 // dann nie Seitenumbrueche ausgeben
1592 BOOL bPgDscWrite
= FALSE
;
1594 if( !bOutOutlineOnly
&& bOutPageAttr
&& !bIgnoreNextPgBreak
)
1596 const SfxPoolItem
*pItem
;
1597 if( SFX_ITEM_SET
== rSet
.GetItemState( RES_PAGEDESC
, TRUE
, &pItem
)
1598 && ((SwFmtPageDesc
*)pItem
)->GetPageDesc() )
1600 const SwFmtPageDesc
& rPgDsc
= *(SwFmtPageDesc
*)pItem
;
1601 for( USHORT nPos
= pDoc
->GetPageDescCnt(); nPos
; )
1602 if( &const_cast<const SwDoc
*>(pDoc
)
1603 ->GetPageDesc( --nPos
) == rPgDsc
.GetPageDesc() )
1605 pAktPageDesc
= ((SwFmtPageDesc
*)pItem
)->GetPageDesc();
1606 // FALSE wegen schliessender Klammer !!
1607 OutComment( *this, OOO_STRING_SVTOOLS_RTF_PGDSCNO
, FALSE
);
1608 OutULong( nPos
) << '}';
1610 // nicht weiter, in Styles gibts keine SectionControls !!
1612 OutRTFPageDescription( *rPgDsc
.GetPageDesc(),
1618 else if( SFX_ITEM_SET
== rSet
.GetItemState( RES_BREAK
, TRUE
, &pItem
) )
1620 const SvxFmtBreakItem
&rBreak
= *(SvxFmtBreakItem
*)pItem
;
1623 if( SVX_BREAK_PAGE_BEFORE
== rBreak
.GetBreak() ||
1624 SVX_BREAK_PAGE_AFTER
== rBreak
.GetBreak() ||
1625 SVX_BREAK_PAGE_BOTH
== rBreak
.GetBreak() )
1628 Strm() << OOO_STRING_SVTOOLS_RTF_PAGE
;
1633 switch( rBreak
.GetBreak() )
1635 case SVX_BREAK_COLUMN_BEFORE
:
1636 case SVX_BREAK_COLUMN_AFTER
:
1637 case SVX_BREAK_COLUMN_BOTH
:
1639 case SVX_BREAK_PAGE_BEFORE
:
1641 Strm() << OOO_STRING_SVTOOLS_RTF_PAGE
;
1643 case SVX_BREAK_PAGE_AFTER
:
1644 OutComment(*this, OOO_STRING_SVTOOLS_RTF_PGBRK
, false) << "0}";
1646 case SVX_BREAK_PAGE_BOTH
:
1647 OutComment(*this, OOO_STRING_SVTOOLS_RTF_PGBRK
, false) << "1}";
1655 bIgnoreNextPgBreak
= false;
1660 void SwRTFWriter::CheckEndNodeForSection( const SwNode
& rNd
)
1662 const SwSectionNode
* pSectNd
= rNd
.StartOfSectionNode()->GetSectionNode();
1663 if( pSectNd
/*&& CONTENT_SECTION == pSectNd->GetSection().GetType()*/ )
1665 const SwSectionFmt
* pSectFmt
= pSectNd
->GetSection().GetFmt();
1667 // diese Section hatte den akt. Abschnitt bestimmt
1668 // wer bestimmt den nachsten??
1669 SwNodeIndex
aIdx( rNd
, 1 );
1670 pSectNd
= aIdx
.GetNode().GetSectionNode();
1671 if( !( ( pSectNd
|| (aIdx
.GetNode().IsEndNode() &&
1672 0 != ( pSectNd
= aIdx
.GetNode().StartOfSectionNode()->GetSectionNode() )) )
1673 /*&& CONTENT_SECTION == pSectNd->GetSection().GetType()*/ ))
1675 // wer bestimmt denn nun den neuen Abschnitt?
1676 // PageDesc oder eine uebergeordnete Section?
1677 SwSection
* pParent
= pSectFmt
->GetParentSection();
1678 // while( pParent /*&& CONTENT_SECTION != pParent->GetType()*/ )
1679 // pParent = pParent->GetParent();
1681 if( pParent
/*&& CONTENT_SECTION == pParent->GetType()*/ )
1682 OutRTF_SwSectionNode( *this, *pParent
->
1683 GetFmt()->GetSectionNode( TRUE
) );
1688 Strm() << OOO_STRING_SVTOOLS_RTF_SECT
<< OOO_STRING_SVTOOLS_RTF_SECTD
<< OOO_STRING_SVTOOLS_RTF_SBKNONE
;
1689 OutRTFPageDescription( ( pAktPageDesc
1691 : const_cast<const SwDoc
*>(pDoc
)
1694 Strm() << SwRTFWriter::sNewLine
;
1699 // weiter machen, der naechste definiert den neuen Abschnitt
1703 // Struktur speichert die aktuellen Daten des Writers zwischen, um
1704 // einen anderen Dokument-Teil auszugeben, wie z.B. Header/Footer
1705 RTFSaveData::RTFSaveData( SwRTFWriter
& rWriter
, ULONG nStt
, ULONG nEnd
)
1707 pOldPam( rWrt
.pCurPam
), pOldEnd( rWrt
.GetEndPaM() ),
1708 pOldFlyFmt( rWrt
.pFlyFmt
), pOldPageDesc( rWrt
.pAktPageDesc
),
1709 pOldAttrSet( rWrt
.GetAttrSet() )
1711 bOldWriteAll
= rWrt
.bWriteAll
;
1712 bOldOutTable
= rWrt
.bOutTable
;
1713 bOldOutPageAttr
= rWrt
.bOutPageAttr
;
1714 bOldAutoAttrSet
= rWrt
.bAutoAttrSet
;
1715 bOldOutSection
= rWrt
.bOutSection
;
1717 rWrt
.pCurPam
= rWrt
.NewSwPaM( *rWrt
.pDoc
, nStt
, nEnd
);
1719 // Tabelle in Sonderbereichen erkennen
1720 if( nStt
!= rWrt
.pCurPam
->GetMark()->nNode
.GetIndex() &&
1721 rWrt
.pDoc
->GetNodes()[ nStt
]->IsTableNode() )
1722 rWrt
.pCurPam
->GetMark()->nNode
= nStt
;
1724 rWrt
.SetEndPaM( rWrt
.pCurPam
);
1725 rWrt
.pCurPam
->Exchange( );
1726 rWrt
.bWriteAll
= TRUE
;
1727 rWrt
.bOutTable
= FALSE
;
1728 rWrt
.bOutPageAttr
= FALSE
;
1729 rWrt
.SetAttrSet( 0 );
1730 rWrt
.bAutoAttrSet
= FALSE
;
1731 rWrt
.bOutSection
= FALSE
;
1735 RTFSaveData::~RTFSaveData()
1737 delete rWrt
.pCurPam
; // Pam wieder loeschen
1739 rWrt
.pCurPam
= pOldPam
;
1740 rWrt
.SetEndPaM( pOldEnd
);
1741 rWrt
.bWriteAll
= bOldWriteAll
;
1742 rWrt
.bOutTable
= bOldOutTable
;
1743 rWrt
.pFlyFmt
= pOldFlyFmt
;
1744 rWrt
.pAktPageDesc
= pOldPageDesc
;
1745 rWrt
.SetAttrSet( pOldAttrSet
);
1746 rWrt
.bAutoAttrSet
= bOldAutoAttrSet
;
1747 rWrt
.bOutPageAttr
= bOldOutPageAttr
;
1748 rWrt
.bOutSection
= bOldOutSection
;
1751 extern "C" SAL_DLLPUBLIC_EXPORT
void SAL_CALL
ExportRTF( const String
& rFltName
, const String
& rBaseURL
, WriterRef
& xRet
)
1753 xRet
= new SwRTFWriter( rFltName
, rBaseURL
);
1756 short SwRTFWriter::GetCurrentPageDirection() const
1758 const SwFrmFmt
&rFmt
= pAktPageDesc
1759 ? pAktPageDesc
->GetMaster()
1760 : const_cast<const SwDoc
*>(pDoc
)
1761 ->GetPageDesc(0).GetMaster();
1762 const SvxFrameDirectionItem
* pItem
= &rFmt
.GetFrmDir();
1766 pItem
= (const SvxFrameDirectionItem
*)
1767 &pDoc
->GetAttrPool().GetDefaultItem(RES_FRAMEDIR
);
1769 return pItem
->GetValue();
1772 short SwRTFWriter::TrueFrameDirection(const SwFrmFmt
&rFlyFmt
) const
1774 const SwFrmFmt
*pFlyFmt2
= &rFlyFmt
;
1775 const SvxFrameDirectionItem
* pItem
= 0;
1778 pItem
= &pFlyFmt2
->GetFrmDir();
1779 if (FRMDIR_ENVIRONMENT
== pItem
->GetValue())
1782 const SwFmtAnchor
* pAnchor
= &pFlyFmt2
->GetAnchor();
1783 if ((FLY_AT_PAGE
!= pAnchor
->GetAnchorId()) &&
1784 pAnchor
->GetCntntAnchor() )
1786 pFlyFmt2
= pAnchor
->GetCntntAnchor()->nNode
.
1787 GetNode().GetFlyFmt();
1798 nRet
= pItem
->GetValue();
1800 nRet
= GetCurrentPageDirection();
1802 ASSERT(nRet
!= FRMDIR_ENVIRONMENT
, "leaving with environment direction");
1806 /* vi:set tabstop=4 shiftwidth=4 expandtab: */