Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : * Copyright 2010 Miklos Vajna.
8 : : *
9 : : * OpenOffice.org - a multi-platform office productivity suite
10 : : *
11 : : * This file is part of OpenOffice.org.
12 : : *
13 : : * OpenOffice.org is free software: you can redistribute it and/or modify
14 : : * it under the terms of the GNU Lesser General Public License version 3
15 : : * only, as published by the Free Software Foundation.
16 : : *
17 : : * OpenOffice.org is distributed in the hope that it will be useful,
18 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 : : * GNU Lesser General Public License version 3 for more details
21 : : * (a copy is included in the LICENSE file that accompanied this code).
22 : : *
23 : : * You should have received a copy of the GNU Lesser General Public License
24 : : * version 3 along with OpenOffice.org. If not, see
25 : : * <http://www.openoffice.org/license.html>
26 : : * for a copy of the LGPLv3 License.
27 : : *
28 : : ************************************************************************/
29 : :
30 : : #ifndef _RTFEXPORT_HXX_
31 : : #define _RTFEXPORT_HXX_
32 : :
33 : : #include "wrtww8.hxx"
34 : :
35 : : class RtfAttributeOutput;
36 : : class RtfExportFilter;
37 : : class RtfSdrExport;
38 : : typedef std::map<sal_uInt16,Color> RtfColorTbl;
39 : : typedef std::map<sal_uInt16,rtl::OString> RtfStyleTbl;
40 : : typedef std::map<String,sal_uInt16> RtfRedlineTbl;
41 : : class SwNode;
42 : : class SwTxtNode;
43 : : class SwGrfNode;
44 : : class SwOLENode;
45 : :
46 : : namespace com { namespace sun { namespace star {
47 : : namespace frame { class XModel; }
48 : : } } }
49 : :
50 : : /// The class that does all the actual RTF export-related work.
51 : : class RtfExport : public MSWordExportBase
52 : : {
53 : : /// Pointer to the filter that owns us.
54 : : RtfExportFilter *m_pFilter;
55 : : Writer* m_pWriter;
56 : :
57 : : /// Attribute output for document.
58 : : RtfAttributeOutput *m_pAttrOutput;
59 : :
60 : : /// Sections/headers/footers
61 : : MSWordSections *m_pSections;
62 : :
63 : : RtfSdrExport *m_pSdrExport;
64 : : bool m_bOutOutlineOnly;
65 : :
66 : : public:
67 : : /// Access to the attribute output class.
68 : : virtual AttributeOutputBase& AttrOutput() const;
69 : :
70 : : /// Access to the sections/headers/footres.
71 : : virtual MSWordSections& Sections() const;
72 : :
73 : : /// Access to the Rtf Sdr exporter.
74 : : virtual RtfSdrExport& SdrExporter() const;
75 : :
76 : : /// Determines if the format is expected to support unicode.
77 : 471 : virtual bool SupportsUnicode() const { return true; }
78 : :
79 : : /// Guess the script (asian/western).
80 : : virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich );
81 : :
82 : : virtual void AppendBookmarks( const SwTxtNode& rNode, xub_StrLen nAktPos, xub_StrLen nLen );
83 : :
84 : : virtual void AppendBookmark( const rtl::OUString& rName, bool bSkip = false );
85 : :
86 : 126 : virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t()*/ ) { /* no-op for rtf, most probably should not even be in MSWordExportBase */ }
87 : : virtual void WriteChar( sal_Unicode );
88 : :
89 : : /// Write the numbering table.
90 : : virtual void WriteNumbering();
91 : :
92 : : /// Write the revision table.
93 : : virtual void WriteRevTab();
94 : :
95 : : /// Output the actual headers and footers.
96 : : virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
97 : : const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt, sal_uInt8 nBreakCode );
98 : :
99 : : /// Write the field
100 : : virtual void OutputField( const SwField* pFld, ww::eField eFldType,
101 : : const String& rFldCmd, sal_uInt8 nMode = nsFieldFlags::WRITEFIELD_ALL );
102 : :
103 : : /// Write the data of the form field
104 : : virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark );
105 : : virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark );
106 : :
107 : : virtual void DoComboBox(const rtl::OUString &rName,
108 : : const rtl::OUString &rHelp,
109 : : const rtl::OUString &ToolTip,
110 : : const rtl::OUString &rSelected,
111 : : com::sun::star::uno::Sequence<rtl::OUString> &rListItems);
112 : :
113 : : virtual void DoFormText(const SwInputField * pFld);
114 : :
115 : : virtual sal_uLong ReplaceCr( sal_uInt8 nChar );
116 : :
117 : : protected:
118 : : /// Format-dependant part of the actual export.
119 : : virtual void ExportDocument_Impl();
120 : :
121 : 126 : virtual void SectionBreaksAndFrames( const SwTxtNode& /*rNode*/ ) {}
122 : :
123 : : /// Get ready for a new section.
124 : : virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
125 : : const SwNode& rNd,
126 : : const SwFmtPageDesc* pNewPgDescFmt = 0,
127 : : const SwPageDesc* pNewPgDesc = 0 );
128 : :
129 : : /// Return value indicates if an inherited outline numbering is suppressed.
130 : : virtual bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt);
131 : :
132 : : /// Output SwTxtNode is depending on outline export mode
133 : : virtual void OutputTextNode( const SwTxtNode& );
134 : :
135 : : /// Output SwGrfNode
136 : : virtual void OutputGrfNode( const SwGrfNode& );
137 : :
138 : : /// Output SwOLENode
139 : : virtual void OutputOLENode( const SwOLENode& );
140 : :
141 : : virtual void OutputLinkedOLE(const rtl::OUString&);
142 : :
143 : : virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum );
144 : :
145 : : public:
146 : : /// Pass the pDocument, pCurrentPam and pOriginalPam to the base class.
147 : : RtfExport( RtfExportFilter *pFilter, SwDoc *pDocument,
148 : : SwPaM *pCurrentPam, SwPaM *pOriginalPam, Writer* pWriter,
149 : : bool bOutOutlineOnly = false );
150 : :
151 : : /// Destructor.
152 : : virtual ~RtfExport();
153 : :
154 : : #if defined(UNX)
155 : : static const sal_Char sNewLine; // \012 or \015
156 : : #else
157 : : static const sal_Char* const sNewLine; // \015\012
158 : : #endif
159 : :
160 : : rtl_TextEncoding eDefaultEncoding;
161 : : rtl_TextEncoding eCurrentEncoding;
162 : : /// This is used by OutputFlyFrame_Impl() to control the written syntax
163 : : bool bRTFFlySyntax;
164 : :
165 : : sal_Bool m_bOutStyleTab : 1;
166 : : SvStream& Strm();
167 : : SvStream& OutULong( sal_uLong nVal );
168 : : SvStream& OutLong( long nVal );
169 : : void OutUnicode(const sal_Char *pToken, const String &rContent);
170 : : void OutDateTime(const sal_Char* pStr, const util::DateTime& rDT );
171 : : void OutPageDescription( const SwPageDesc& rPgDsc, sal_Bool bWriteReset, sal_Bool bCheckForFirstPage );
172 : :
173 : : sal_uInt16 GetColor( const Color& rColor ) const;
174 : : void InsColor( const Color& rCol );
175 : : void InsColorLine( const SvxBoxItem& rBox );
176 : : void OutColorTable();
177 : : sal_uInt16 GetRedline( const String& rAuthor );
178 : : const String* GetRedline( sal_uInt16 nId );
179 : :
180 : : void InsStyle( sal_uInt16 nId, const rtl::OString& rStyle );
181 : : rtl::OString* GetStyle( sal_uInt16 nId );
182 : :
183 : : private:
184 : : /// No copying.
185 : : RtfExport( const RtfExport& );
186 : :
187 : : /// No copying.
188 : : RtfExport& operator=( const RtfExport& );
189 : :
190 : : void WriteFonts();
191 : : void WriteStyles();
192 : : void WriteMainText();
193 : : void WriteInfo();
194 : : /// Writes the writer-specific \pgdsctbl group.
195 : : void WritePageDescTable();
196 : : /// This is necessary to have the numbering table ready before the main text is being processed.
197 : : void BuildNumbering();
198 : : void WriteHeaderFooter(const SfxPoolItem& rItem, bool bHeader);
199 : : void WriteHeaderFooter(const SwFrmFmt& rFmt, bool bHeader, const sal_Char* pStr, bool bTitlepg = false);
200 : :
201 : : RtfColorTbl m_aColTbl;
202 : : RtfStyleTbl m_aStyTbl;
203 : : RtfRedlineTbl m_aRedlineTbl;
204 : : };
205 : :
206 : : #endif // _RTFEXPORT_HXX_
207 : :
208 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|