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 ************************************************************************/
30 #include <shellio.hxx>
32 #include "../inc/msfilter.hxx"
34 #include <com/sun/star/util/DateTime.hpp>
36 // einige Forward Deklarationen
53 extern SwAttrFnTab aRTFAttrFnTab
;
54 extern SwNodeFnTab aRTFNodeFnTab
;
56 // the default text encoding for the export, if it doesn't fit unicode will
58 #define DEF_ENCODING RTL_TEXTENCODING_ASCII_US
61 class RTF_WrtRedlineAuthor
: public sw::util::WrtRedlineAuthor
64 virtual void Write(Writer
&rWrt
);
69 class SwRTFWriter
: public Writer
71 friend class RTFEndPosLst
;
73 SvPtrarr
* pFontRemoveLst
;
75 SwPosFlyFrms
* pFlyPos
; // Pointer auf die aktuelle "FlyFrmTabelle"
76 RTFEndPosLst
* pCurEndPosLst
;
77 const SfxItemSet
* pAttrSet
; // akt. Format/Collection vom Node
78 // fuer den Zugriff auf einige Attribute
79 // z.B. Font-Size, LR-Space,..
80 SwNumRuleTbl
* pNumRuleTbl
; // list of all exported numrules
81 RTF_WrtRedlineAuthor
*pRedlAuthors
;
83 USHORT nAktFlyPos
; // Index auf das naechste "FlyFrmFmt"
84 void OutRTFColorTab();
86 const rtl::OUString
XlateFmtName( const rtl::OUString
&rName
, SwGetPoolIdFromName eFlags
);
87 void OutRTFStyleTab();
92 void OutUnicodeSafeRecord(const sal_Char
*pToken
,
93 const String
&rContent
);
94 void OutDocInfoStat();
95 void OutInfoDateTime( const sal_Char
*,
96 const ::com::sun::star::util::DateTime
& );
97 void CheckEndNodeForSection( const SwNode
& rNd
);
99 void BuildNumRuleTbl();
104 // --- public Member --------------------------------------------------
109 const SwFlyFrmFmt
* pFlyFmt
; // liegt der Node in einem FlyFrame,
110 // ist das Format gesetzt, sonst 0
111 const SwPageDesc
* pAktPageDesc
; // aktuell gesetzter PageDesc.
112 sal_Int32 nBkmkTabPos
; // akt. Position in der Bookmark-Tabelle
113 USHORT nCurScript
; // actual scripttype
114 rtl_TextEncoding eDefaultEncoding
;
115 rtl_TextEncoding eCurrentEncoding
;
118 static const sal_Char sNewLine
; // nur \012 oder \015
120 static const sal_Char __FAR_DATA sNewLine
[]; // \015\012
124 BOOL bFirstLine
: 1; // wird die 1. Zeile ausgegeben ?
125 BOOL bOutFmtAttr
: 1; // TRUE: beim Schreiben eines Formates
126 // existierte mindestens ein Attribut
127 BOOL bRTFFlySyntax
: 1; // gebe nur original RTFSyntax aus
128 // (nur fuer die fliegenden Rahmen)
129 BOOL bOutPageDesc
: 1; // gebe einen PageDescriptor aus
130 BOOL bOutPageDescTbl
: 1; // gebe die PageDescriptor-Tabelle aus
131 BOOL bOutTable
: 1; // gebe eine Tabelle aus
132 BOOL bTxtAttr
: 1; // werden TextAttribute ausgegeben ?
133 BOOL bWriteHelpFmt
: 1; // schreibe Win-RTF-HelpFileFmt
134 BOOL bOutStyleTab
: 1; // gebe die StyleSheet-Tabelle aus
135 BOOL bOutPageAttr
: 1; // PageDescAttribut ausgeben?
136 BOOL bAutoAttrSet
: 1; // TRUE: pAttrSet ist harte Attributierung
137 // FALSE: pAttrSet ist vom Format/Collection
138 BOOL bOutOutlineOnly
: 1; // TRUE: nur Gliederungs-Absaetze schreiben
139 BOOL bOutListNumTxt
: 1; // TRUE: der ListNumText wird ausgegeben
140 BOOL bOutLeftHeadFoot
: 1; // gebe vom PageDesc. den linkten
142 BOOL bOutSection
: 1; // TRUE: Section PageDesc ausgeben
143 BOOL bIgnoreNextPgBreak
: 1; // TRUE: naechsten PageDesc/Break ignorieren
144 BOOL bAssociated
: 1; // use associated tokens
146 BOOL bNonStandard
: 1; // use non-standard tags (for cut and paste)
148 // --- public Methoden ------------------------------------------------
150 SwRTFWriter( const String
& rFilterName
, const String
& rBaseURL
);
151 virtual ~SwRTFWriter();
152 virtual ULONG
WriteStream();
154 void Out_SwDoc( SwPaM
* ); // schreibe den makierten Bereich
156 // gebe die evt. an der akt. Position stehenden FlyFrame aus.
158 void OutRTFFlyFrms( const SwFlyFrmFmt
& );
159 // gebe alle an der Position stehenden Bookmarks aus
160 void OutBookmarks( xub_StrLen nCntntPos
);
161 // gebe die PageDesc-Daten im normalen RTF-Format aus
162 void OutRTFPageDescription( const SwPageDesc
&, BOOL
, BOOL
);
163 void OutRTFBorders( SvxBoxItem aBox
);
164 void OutRTFBorder( const SvxBorderLine
* aLine
, const USHORT nSpace
);
165 BOOL
OutBreaks( const SfxItemSet
& rSet
);
166 void OutRedline( xub_StrLen nCntntPos
);
168 // gebe die PageDescriptoren aus
169 USHORT
GetId( const Color
& ) const;
170 USHORT
GetId( const SvxFontItem
& ) const;
171 USHORT
GetId( const Font
& ) const;
172 USHORT
GetId( const SwTxtFmtColl
& ) const;
173 USHORT
GetId( const SwCharFmt
& ) const;
174 USHORT
GetId( const SwNumRuleItem
& rItem
) const;
178 BOOL
OutListNum( const SwTxtNode
& rNd
);
179 USHORT
GetNumRuleId( const SwNumRule
& rRule
);
182 SwPaM
* GetEndPaM() { return pOrigPam
; }
183 void SetEndPaM( SwPaM
* pPam
) { pOrigPam
= pPam
; }
185 const SfxPoolItem
& GetItem( USHORT nWhich
) const;
187 const SfxItemSet
* GetAttrSet() const { return pAttrSet
; }
188 void SetAttrSet( const SfxItemSet
* p
) { pAttrSet
= p
; }
190 const RTFEndPosLst
* GetEndPosLst() const { return pCurEndPosLst
; }
192 void SetAssociatedFlag( BOOL b
) { bAssociated
= b
; }
193 BOOL
IsAssociatedFlag() const { return bAssociated
; }
195 void SetCurrScriptType( USHORT n
) { nCurScript
= n
; }
196 USHORT
GetCurrScriptType() const { return nCurScript
; }
198 short TrueFrameDirection(const SwFrmFmt
&rFlyFmt
) const;
199 short GetCurrentPageDirection() const;
203 // Struktur speichert die aktuellen Daten des Writers zwischen, um
204 // einen anderen Dokument-Teil auszugeben, wie z.B. Header/Footer
205 // Mit den beiden USHORTs im CTOR wird ein neuer PaM erzeugt und auf
206 // die Position im Dokument gesetzt.
207 // Im Destructor werden alle Daten wieder restauriert und der angelegte
208 // Pam wieder geloescht.
213 SwPaM
* pOldPam
, *pOldEnd
;
214 const SwFlyFrmFmt
* pOldFlyFmt
;
215 const SwPageDesc
* pOldPageDesc
;
216 const SfxItemSet
* pOldAttrSet
; // akt. Attribute vom Node
218 BOOL bOldWriteAll
: 1;
219 BOOL bOldOutTable
: 1;
220 BOOL bOldOutPageAttr
: 1;
221 BOOL bOldAutoAttrSet
: 1;
222 BOOL bOldOutSection
: 1;
224 RTFSaveData( SwRTFWriter
&, ULONG nStt
, ULONG nEnd
);
229 // einige Funktions-Deklarationen
230 Writer
& OutRTF_AsByteString( Writer
& rWrt
, const String
& rStr
, rtl_TextEncoding eEncoding
);
231 Writer
& OutRTF_SwFmt( Writer
& rWrt
, const SwFmt
& );
232 Writer
& OutRTF_SwTblNode(Writer
& , const SwTableNode
&);
233 Writer
& OutRTF_SwSectionNode( Writer
& , SwSectionNode
& );
236 // Augabe von RTF-Bitmaps (steht im File "wrtpict.cxx")
237 //struct SvxRTFPictureType;
239 //USHORT WriteRTFPict( const SwPictureType&, Bitmap&, SvStream& );
241 // Ausagbe von Footer-/Headers
242 Writer
& OutRTF_SwFmtHeader( Writer
& , const SfxPoolItem
& );
243 Writer
& OutRTF_SwFmtFooter( Writer
& , const SfxPoolItem
& );
245 // Kommentar und zusaetzlichen String ausgeben
246 SvStream
& OutComment( Writer
& rWrt
, const sal_Char
* pStr
);
247 // zusaetzlich das bOutFmtAttr-Flag manipulieren
248 SvStream
& OutComment( Writer
& rWrt
, const sal_Char
* pStr
, BOOL bSetFlag
);
249 bool ExportAsInline(const SwFlyFrmFmt
& rFlyFrmFmt
);
251 #endif // _WRTRTF_HXX