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 : #ifndef INCLUDED_SW_SOURCE_FILTER_WW8_RTFEXPORT_HXX
21 : #define INCLUDED_SW_SOURCE_FILTER_WW8_RTFEXPORT_HXX
22 :
23 : #include "wrtww8.hxx"
24 :
25 : class RtfAttributeOutput;
26 : class RtfExportFilter;
27 : class RtfSdrExport;
28 : typedef std::map<sal_uInt16,Color> RtfColorTbl;
29 : typedef std::map<sal_uInt16,OString> RtfStyleTbl;
30 : typedef std::map<OUString,sal_uInt16> RtfRedlineTbl;
31 : class SwNode;
32 : class SwTxtNode;
33 : class SwGrfNode;
34 : class SwOLENode;
35 :
36 : /// The class that does all the actual RTF export-related work.
37 : class RtfExport : public MSWordExportBase
38 : {
39 : /// Pointer to the filter that owns us.
40 : RtfExportFilter* m_pFilter;
41 : Writer* m_pWriter;
42 :
43 : /// Attribute output for document.
44 : boost::shared_ptr<RtfAttributeOutput> m_pAttrOutput;
45 :
46 : /// Sections/headers/footers
47 : MSWordSections* m_pSections;
48 :
49 : boost::shared_ptr<RtfSdrExport> m_pSdrExport;
50 : bool m_bOutOutlineOnly;
51 :
52 : public:
53 : /// Access to the attribute output class.
54 : virtual AttributeOutputBase& AttrOutput() const SAL_OVERRIDE;
55 :
56 : /// Access to the sections/headers/footres.
57 : virtual MSWordSections& Sections() const SAL_OVERRIDE;
58 :
59 : /// Access to the Rtf Sdr exporter.
60 : virtual RtfSdrExport& SdrExporter() const;
61 :
62 : /// Determines if the format is expected to support unicode.
63 6260 : virtual bool SupportsUnicode() const SAL_OVERRIDE
64 : {
65 6260 : return true;
66 : }
67 :
68 6 : virtual bool SupportsOneColumnBreak() const SAL_OVERRIDE
69 : {
70 6 : return false;
71 : }
72 :
73 0 : virtual bool FieldsQuoted() const SAL_OVERRIDE
74 : {
75 0 : return true;
76 : }
77 :
78 0 : virtual bool AddSectionBreaksForTOX() const SAL_OVERRIDE
79 : {
80 0 : return false;
81 : }
82 :
83 14 : virtual bool PreferPageBreakBefore() const SAL_OVERRIDE
84 : {
85 14 : return true;
86 : }
87 :
88 : /// Guess the script (asian/western).
89 : virtual bool CollapseScriptsforWordOk(sal_uInt16 nScript, sal_uInt16 nWhich) SAL_OVERRIDE;
90 :
91 : virtual void AppendBookmarks(const SwTxtNode& rNode, sal_Int32 nAktPos, sal_Int32 nLen) SAL_OVERRIDE;
92 :
93 : virtual void AppendBookmark(const OUString& rName, bool bSkip = false) SAL_OVERRIDE;
94 :
95 : virtual void AppendAnnotationMarks(const SwTxtNode& rNode, sal_Int32 nAktPos, sal_Int32 nLen) SAL_OVERRIDE;
96 :
97 : //For i120928,add an interface to export graphic of bullet
98 : virtual void ExportGrfBullet(const SwTxtNode& rNd) SAL_OVERRIDE;
99 :
100 1174 : virtual void WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t()*/) SAL_OVERRIDE { /* no-op for rtf, most probably should not even be in MSWordExportBase */ }
101 : virtual void WriteChar(sal_Unicode) SAL_OVERRIDE;
102 :
103 : /// Write the numbering table.
104 : virtual void WriteNumbering() SAL_OVERRIDE;
105 :
106 : /// Write the revision table.
107 : virtual void WriteRevTab();
108 :
109 : /// Output the actual headers and footers.
110 : virtual void WriteHeadersFooters(sal_uInt8 nHeadFootFlags,
111 : const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt, sal_uInt8 nBreakCode) SAL_OVERRIDE;
112 :
113 : /// Write the field
114 : virtual void OutputField(const SwField* pFld, ww::eField eFldType,
115 : const OUString& rFldCmd, sal_uInt8 nMode = nsFieldFlags::WRITEFIELD_ALL) SAL_OVERRIDE;
116 :
117 : /// Write the data of the form field
118 : virtual void WriteFormData(const ::sw::mark::IFieldmark& rFieldmark) SAL_OVERRIDE;
119 : virtual void WriteHyperlinkData(const ::sw::mark::IFieldmark& rFieldmark) SAL_OVERRIDE;
120 :
121 : virtual void DoComboBox(const OUString& rName,
122 : const OUString& rHelp,
123 : const OUString& ToolTip,
124 : const OUString& rSelected,
125 : com::sun::star::uno::Sequence<OUString>& rListItems) SAL_OVERRIDE;
126 :
127 : virtual void DoFormText(const SwInputField* pFld) SAL_OVERRIDE;
128 :
129 : virtual sal_uLong ReplaceCr(sal_uInt8 nChar) SAL_OVERRIDE;
130 :
131 : protected:
132 : /// Format-dependent part of the actual export.
133 : virtual void ExportDocument_Impl() SAL_OVERRIDE;
134 :
135 1174 : virtual void SectionBreaksAndFrames(const SwTxtNode& /*rNode*/) SAL_OVERRIDE {}
136 :
137 : /// Get ready for a new section.
138 : virtual void PrepareNewPageDesc(const SfxItemSet* pSet,
139 : const SwNode& rNd,
140 : const SwFmtPageDesc* pNewPgDescFmt = 0,
141 : const SwPageDesc* pNewPgDesc = 0) SAL_OVERRIDE;
142 :
143 : /// Return value indicates if an inherited outline numbering is suppressed.
144 : virtual bool DisallowInheritingOutlineNumbering(const SwFmt& rFmt) SAL_OVERRIDE;
145 :
146 : /// Output SwTxtNode is depending on outline export mode
147 : virtual void OutputTextNode(const SwTxtNode&) SAL_OVERRIDE;
148 :
149 : /// Output SwGrfNode
150 : virtual void OutputGrfNode(const SwGrfNode&) SAL_OVERRIDE;
151 :
152 : /// Output SwOLENode
153 : virtual void OutputOLENode(const SwOLENode&) SAL_OVERRIDE;
154 :
155 : virtual void OutputLinkedOLE(const OUString&) SAL_OVERRIDE;
156 :
157 : virtual void AppendSection(const SwPageDesc* pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum) SAL_OVERRIDE;
158 :
159 : public:
160 : /// Pass the pDocument, pCurrentPam and pOriginalPam to the base class.
161 : RtfExport(RtfExportFilter* pFilter, SwDoc* pDocument,
162 : SwPaM* pCurrentPam, SwPaM* pOriginalPam, Writer* pWriter,
163 : bool bOutOutlineOnly = false);
164 :
165 : /// Destructor.
166 : virtual ~RtfExport();
167 :
168 : rtl_TextEncoding eDefaultEncoding;
169 : rtl_TextEncoding eCurrentEncoding;
170 : /// This is used by OutputFlyFrame_Impl() to control the written syntax
171 : bool bRTFFlySyntax;
172 : /// Index of the current SwTxtNode, if any.
173 : sal_uLong m_nCurrentNodeIndex;
174 :
175 : SvStream& Strm();
176 : /// From now on, let Strm() return a memory stream, not a real one.
177 : void setStream();
178 : /// Get the contents of the memory stream as a string.
179 : OString getStream();
180 : /// Return back to the real stream.
181 : void resetStream();
182 : SvStream& OutULong(sal_uLong nVal);
183 : SvStream& OutLong(long nVal);
184 : void OutUnicode(const sal_Char* pToken, const OUString& rContent, bool bUpr = false);
185 : void OutDateTime(const sal_Char* pStr, const css::util::DateTime& rDT);
186 : void OutPageDescription(const SwPageDesc& rPgDsc, bool bWriteReset, bool bCheckForFirstPage);
187 :
188 : sal_uInt16 GetColor(const Color& rColor) const;
189 : void InsColor(const Color& rCol);
190 : void InsColorLine(const SvxBoxItem& rBox);
191 : void OutColorTable();
192 : sal_uInt16 GetRedline(const OUString& rAuthor);
193 : const OUString* GetRedline(sal_uInt16 nId);
194 :
195 : void InsStyle(sal_uInt16 nId, const OString& rStyle);
196 : OString* GetStyle(sal_uInt16 nId);
197 :
198 : private:
199 : /// No copying.
200 : RtfExport(const RtfExport&);
201 :
202 : /// No copying.
203 : RtfExport& operator=(const RtfExport&);
204 :
205 : void WriteFonts();
206 : void WriteStyles();
207 : void WriteFootnoteSettings();
208 : void WriteMainText();
209 : void WriteInfo();
210 : /// Writes the writer-specific \pgdsctbl group.
211 : void WritePageDescTable();
212 : /// This is necessary to have the numbering table ready before the main text is being processed.
213 : void BuildNumbering();
214 : void WriteHeaderFooter(const SfxPoolItem& rItem, bool bHeader);
215 : void WriteHeaderFooter(const SwFrmFmt& rFmt, bool bHeader, const sal_Char* pStr, bool bTitlepg = false);
216 :
217 : RtfColorTbl m_aColTbl;
218 : RtfStyleTbl m_aStyTbl;
219 : RtfRedlineTbl m_aRedlineTbl;
220 : /// If set, then Strm() returns this tream, instead of m_pWriter's stream.
221 : std::unique_ptr<SvMemoryStream> m_pStream;
222 : };
223 :
224 : #endif // INCLUDED_SW_SOURCE_FILTER_WW8_RTFEXPORT_HXX
225 :
226 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|