cmcfixes76: #i113073# redundant dereferences
[LibreOffice.git] / sw / source / filter / rtf / wrtrtf.hxx
blob18486f5a32246e0fe1896c41f987e3bbd5ac7a6a
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 ************************************************************************/
27 #ifndef _WRTRTF_HXX
28 #define _WRTRTF_HXX
30 #include <shellio.hxx>
31 #include <wrt_fn.hxx>
32 #include "../inc/msfilter.hxx"
34 #include <com/sun/star/util/DateTime.hpp>
36 // einige Forward Deklarationen
37 class Color;
38 class Font;
39 class SvPtrarr;
40 class RTFColorTbl;
41 class SwFmt;
42 class SwFlyFrmFmt;
43 class SwPosFlyFrms;
44 class SwPageDesc;
45 class SwTableNode;
46 class SwTxtFmtColl;
47 class SwNumRule;
48 class SwNumRuleTbl;
49 class DateTime;
50 class RTFEndPosLst;
51 class SvxBorderLine;
53 extern SwAttrFnTab aRTFAttrFnTab;
54 extern SwNodeFnTab aRTFNodeFnTab;
56 // the default text encoding for the export, if it doesn't fit unicode will
57 // be used
58 #define DEF_ENCODING RTL_TEXTENCODING_ASCII_US
61 class RTF_WrtRedlineAuthor : public sw::util::WrtRedlineAuthor
63 public:
64 virtual void Write(Writer &rWrt);
67 // der RTF-Writer
69 class SwRTFWriter : public Writer
71 friend class RTFEndPosLst;
73 SvPtrarr* pFontRemoveLst;
74 RTFColorTbl* pColTbl;
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();
85 void OutRTFFontTab();
86 const rtl::OUString XlateFmtName( const rtl::OUString &rName, SwGetPoolIdFromName eFlags );
87 void OutRTFStyleTab();
88 void OutRTFListTab();
89 bool OutRTFRevTab();
91 void MakeHeader();
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();
103 public:
104 // --- public Member --------------------------------------------------
106 USHORT nCurRedline;
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;
117 #if defined(UNX)
118 static const sal_Char sNewLine; // nur \012 oder \015
119 #else
120 static const sal_Char __FAR_DATA sNewLine[]; // \015\012
121 #endif
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
141 // Header/Footer aus
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.
157 void OutFlyFrm();
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;
176 void OutPageDesc();
178 BOOL OutListNum( const SwTxtNode& rNd );
179 USHORT GetNumRuleId( const SwNumRule& rRule );
181 // fuer RTFSaveData
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.
210 struct RTFSaveData
212 SwRTFWriter& rWrt;
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 );
225 ~RTFSaveData();
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;
238 //class Bitmap;
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