LibreOffice Module sw (master) 1
rtfexport.hxx
Go to the documentation of this file.
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 <memory>
24#include "wrtww8.hxx"
25
27class RtfExportFilter;
28class RtfSdrExport;
29using RtfColorTable = std::map<sal_uInt16, Color>;
30class SwNode;
31class SwTextNode;
32class SwGrfNode;
33class SwOLENode;
34
37{
41
43 std::unique_ptr<RtfAttributeOutput> m_pAttrOutput;
44
46 std::unique_ptr<MSWordSections> m_pSections;
47
48 std::unique_ptr<RtfSdrExport> m_pSdrExport;
50
51public:
53 AttributeOutputBase& AttrOutput() const override;
54
56 MSWordSections& Sections() const override;
57
60
61 bool FieldsQuoted() const override { return true; }
62
63 bool AddSectionBreaksForTOX() const override { return false; }
64
65 bool PreferPageBreakBefore() const override { return true; }
66
68 bool CollapseScriptsforWordOk(sal_uInt16 nScript, sal_uInt16 nWhich) override;
69
70 void AppendBookmarks(const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen,
71 const SwRedlineData* pSwRedlineData = nullptr) override;
72
73 void AppendBookmark(const OUString& rName) override;
74
75 void AppendAnnotationMarks(const SwWW8AttrIter& rAttrs, sal_Int32 nCurrentPos,
76 sal_Int32 nLen) override;
77
78 //For i120928,add an interface to export graphic of bullet
79 void ExportGrfBullet(const SwTextNode& rNd) override;
80
81 void
83 Pointer_t /*pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t()*/)
84 override
85 {
86 /* no-op for rtf, most probably should not even be in MSWordExportBase */
87 }
88 void WriteChar(sal_Unicode c) override;
89
91 void WriteNumbering() override;
92
94 void WriteRevTab();
95
97 void WriteHeadersFooters(sal_uInt8 nHeadFootFlags, const SwFrameFormat& rFormat,
98 const SwFrameFormat& rLeftHeaderFormat,
99 const SwFrameFormat& rLeftFooterFormat,
100 const SwFrameFormat& rFirstPageFormat, sal_uInt8 nBreakCode,
101 bool bEvenAndOddHeaders) override;
102
104 void OutputField(const SwField* pField, ww::eField eFieldType, const OUString& rFieldCmd,
105 FieldFlags nMode = FieldFlags::All) override;
106
108 void WriteFormData(const ::sw::mark::IFieldmark& rFieldmark) override;
109 void WriteHyperlinkData(const ::sw::mark::IFieldmark& rFieldmark) override;
110
111 void DoComboBox(const OUString& rName, const OUString& rHelp, const OUString& ToolTip,
112 const OUString& rSelected,
113 const css::uno::Sequence<OUString>& rListItems) override;
114
115 void DoFormText(const SwInputField* pField) override;
116
117 sal_uInt64 ReplaceCr(sal_uInt8 nChar) override;
118
119 ExportFormat GetExportFormat() const override { return ExportFormat::RTF; }
120
121protected:
123 ErrCode ExportDocument_Impl() override;
124
125 void SectionBreaksAndFrames(const SwTextNode& /*rNode*/) override {}
126
128 void PrepareNewPageDesc(const SfxItemSet* pSet, const SwNode& rNd,
129 const SwFormatPageDesc* pNewPgDescFormat, const SwPageDesc* pNewPgDesc,
130 bool bExtraPageBreak = false) override;
131
133 bool DisallowInheritingOutlineNumbering(const SwFormat& rFormat) override;
134
136 void OutputTextNode(SwTextNode& rNode) override;
137
139 void OutputEndNode(const SwEndNode& rEndNode) override;
140
142 void OutputGrfNode(const SwGrfNode& rGrfNode) override;
143
145 void OutputOLENode(const SwOLENode& rOLENode) override;
146
147 void OutputLinkedOLE(const OUString& rLink) override;
148
149 void AppendSection(const SwPageDesc* pPageDesc, const SwSectionFormat* pFormat,
150 sal_uLong nLnNum) override;
151
152public:
154 RtfExport(RtfExportFilter* pFilter, SwDoc& rDocument, std::shared_ptr<SwUnoCursor>& pCurrentPam,
155 SwPaM& rOriginalPam, Writer* pWriter, bool bOutOutlineOnly = false);
156
157 RtfExport(const RtfExport&) = delete;
158
159 RtfExport& operator=(const RtfExport&) = delete;
160
162 ~RtfExport() override;
163
164private:
165 rtl_TextEncoding m_eDefaultEncoding;
166 rtl_TextEncoding m_eCurrentEncoding;
171
172public:
173 rtl_TextEncoding GetDefaultEncoding() const { return m_eDefaultEncoding; }
174 void SetCurrentEncoding(rtl_TextEncoding eCurrentEncoding)
175 {
176 m_eCurrentEncoding = eCurrentEncoding;
177 }
178 rtl_TextEncoding GetCurrentEncoding() const { return m_eCurrentEncoding; }
179 void SetRTFFlySyntax(bool bRTFFlySyntax) { m_bRTFFlySyntax = bRTFFlySyntax; }
180 bool GetRTFFlySyntax() const { return m_bRTFFlySyntax; }
182 SvStream& Strm();
184 void setStream();
186 OString getStream();
188 void resetStream();
189 void OutUnicode(std::string_view pToken, std::u16string_view rContent, bool bUpr = false);
190 void OutDateTime(std::string_view pStr, const css::util::DateTime& rDT);
191 void OutPageDescription(const SwPageDesc& rPgDsc, bool bCheckForFirstPage);
192
193 sal_uInt16 GetColor(const Color& rColor) const;
194 void InsColor(const Color& rCol);
195 void InsColorLine(const SvxBoxItem& rBox);
196 void OutColorTable();
197 sal_uInt16 GetRedline(const OUString& rAuthor);
198 const OUString* GetRedline(sal_uInt16 nId);
199
200 void InsStyle(sal_uInt16 nId, const OString& rStyle);
201 OString* GetStyle(sal_uInt16 nId);
202
204
205private:
206 void WriteFonts();
207 void WriteStyles();
209 void WriteMainText();
210 void WriteInfo();
212 void WriteUserPropType(int nType);
214 void WriteUserPropValue(std::u16string_view rValue);
216 void WriteUserProps();
218 void WriteDocVars();
220 void WritePageDescTable();
222 void BuildNumbering();
223 void WriteHeaderFooter(const SfxPoolItem& rItem, bool bHeader);
224 void WriteHeaderFooter(const SwFrameFormat& rFormat, bool bHeader, const char* pStr,
225 bool bTitlepg = false);
226
228 std::map<sal_uInt16, OString> m_aStyTable;
229 std::map<OUString, sal_uInt16> m_aRedlineTable;
231 std::unique_ptr<SvMemoryStream> m_pStream;
234};
235
236#endif // INCLUDED_SW_SOURCE_FILTER_WW8_RTFEXPORT_HXX
237
238/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class for WW8Export and DocxExport.
Definition: wrtww8.hxx:451
Class to collect and output the sections/headers/footers.
Definition: wrtww8.hxx:196
The class that has handlers for various resource types when exporting as RTF.
The physical access to the RTF document (for writing).
The class that does all the actual RTF export-related work.
Definition: rtfexport.hxx:37
void WriteNumbering() override
Write the numbering table.
Definition: rtfexport.cxx:225
void OutDateTime(std::string_view pStr, const css::util::DateTime &rDT)
Definition: rtfexport.cxx:1208
sal_uInt16 GetColor(const Color &rColor) const
Definition: rtfexport.cxx:1218
void WriteUserPropValue(std::u16string_view rValue)
Writes a single user property value.
Definition: rtfexport.cxx:578
void SetCurrentEncoding(rtl_TextEncoding eCurrentEncoding)
Definition: rtfexport.hxx:174
void OutputGrfNode(const SwGrfNode &rGrfNode) override
Output SwGrfNode.
Definition: rtfexport.cxx:1115
void WriteStyles()
Definition: rtfexport.cxx:448
SwNodeOffset m_nCurrentNodeIndex
Index of the current SwTextNode, if any.
Definition: rtfexport.hxx:170
void WriteRevTab()
Write the revision table.
Definition: rtfexport.cxx:257
void OutputEndNode(const SwEndNode &rEndNode) override
Output SwEndNode.
Definition: rtfexport.cxx:1108
std::unique_ptr< MSWordSections > m_pSections
Sections/headers/footers.
Definition: rtfexport.hxx:46
std::unique_ptr< RtfAttributeOutput > m_pAttrOutput
Attribute output for document.
Definition: rtfexport.hxx:43
bool m_bOutOutlineOnly
Definition: rtfexport.hxx:49
void WriteFormData(const ::sw::mark::IFieldmark &rFieldmark) override
Write the data of the form field.
Definition: rtfexport.cxx:322
void WriteHeaderFooter(const SfxPoolItem &rItem, bool bHeader)
Definition: rtfexport.cxx:1505
RtfExport & operator=(const RtfExport &)=delete
RtfColorTable m_aColTable
Definition: rtfexport.hxx:227
Writer * m_pWriter
Definition: rtfexport.hxx:40
void WriteChar(sal_Unicode c) override
Definition: rtfexport.cxx:184
RtfExport(const RtfExport &)=delete
void setStream()
From now on, let Strm() return a memory stream, not a real one.
Definition: rtfexport.cxx:1179
rtl_TextEncoding GetDefaultEncoding() const
Definition: rtfexport.hxx:173
std::map< OUString, sal_uInt16 > m_aRedlineTable
Definition: rtfexport.hxx:229
std::unique_ptr< RtfSdrExport > m_pSdrExport
Definition: rtfexport.hxx:48
void OutPageDescription(const SwPageDesc &rPgDsc, bool bCheckForFirstPage)
Definition: rtfexport.cxx:1454
const SfxItemSet * m_pFirstPageItemSet
Item set of the first page during export of a follow page format.
Definition: rtfexport.hxx:233
void OutputOLENode(const SwOLENode &rOLENode) override
Output SwOLENode.
Definition: rtfexport.cxx:1120
RtfExport(RtfExportFilter *pFilter, SwDoc &rDocument, std::shared_ptr< SwUnoCursor > &pCurrentPam, SwPaM &rOriginalPam, Writer *pWriter, bool bOutOutlineOnly=false)
Pass the pDocument, pCurrentPam and pOriginalPam to the base class.
Definition: rtfexport.cxx:1142
MSWordSections & Sections() const override
Access to the sections/headers/footres.
Definition: rtfexport.cxx:82
void AppendAnnotationMarks(const SwWW8AttrIter &rAttrs, sal_Int32 nCurrentPos, sal_Int32 nLen) override
Definition: rtfexport.cxx:153
void WriteHeadersFooters(sal_uInt8 nHeadFootFlags, const SwFrameFormat &rFormat, const SwFrameFormat &rLeftHeaderFormat, const SwFrameFormat &rLeftFooterFormat, const SwFrameFormat &rFirstPageFormat, sal_uInt8 nBreakCode, bool bEvenAndOddHeaders) override
Output the actual headers and footers.
Definition: rtfexport.cxx:289
std::unique_ptr< SvMemoryStream > m_pStream
If set, then Strm() returns this stream, instead of m_pWriter's stream.
Definition: rtfexport.hxx:231
void OutUnicode(std::string_view pToken, std::u16string_view rContent, bool bUpr=false)
Definition: rtfexport.cxx:1193
void OutputTextNode(SwTextNode &rNode) override
Output SwTextNode is depending on outline export mode.
Definition: rtfexport.cxx:1127
void InsColorLine(const SvxBoxItem &rBox)
Definition: rtfexport.cxx:1257
void AppendBookmark(const OUString &rName) override
Definition: rtfexport.cxx:145
void WriteUserPropType(int nType)
Writes a single user property type.
Definition: rtfexport.cxx:573
void AppendBookmarks(const SwTextNode &rNode, sal_Int32 nCurrentPos, sal_Int32 nLen, const SwRedlineData *pSwRedlineData=nullptr) override
Definition: rtfexport.cxx:120
bool GetRTFFlySyntax() const
Definition: rtfexport.hxx:180
OString getStream()
Get the contents of the memory stream as a string.
Definition: rtfexport.cxx:1181
void WriteFonts()
Definition: rtfexport.cxx:438
void OutColorTable()
Definition: rtfexport.cxx:1280
void WriteInfo()
Definition: rtfexport.cxx:515
void WriteUserProps()
Writes the userprops group: user defined document properties.
Definition: rtfexport.cxx:585
rtl_TextEncoding m_eCurrentEncoding
Definition: rtfexport.hxx:166
bool FieldsQuoted() const override
Determines if the import filter already quoted fields or not.
Definition: rtfexport.hxx:61
AttributeOutputBase & AttrOutput() const override
Access to the attribute output class.
Definition: rtfexport.cxx:80
void DoFormText(const SwInputField *pField) override
Definition: rtfexport.cxx:392
void OutputField(const SwField *pField, ww::eField eFieldType, const OUString &rFieldCmd, FieldFlags nMode=FieldFlags::All) override
Write the field.
Definition: rtfexport.cxx:316
ExportFormat GetExportFormat() const override
Definition: rtfexport.hxx:119
bool PreferPageBreakBefore() const override
If saving page break is preferred as a paragraph attribute (yes) or as a special character (no).
Definition: rtfexport.hxx:65
SvStream & Strm()
Definition: rtfexport.cxx:1171
void BuildNumbering()
This is necessary to have the numbering table ready before the main text is being processed.
Definition: rtfexport.cxx:206
ErrCode ExportDocument_Impl() override
Format-dependent part of the actual export.
Definition: rtfexport.cxx:777
void PrepareNewPageDesc(const SfxItemSet *pSet, const SwNode &rNd, const SwFormatPageDesc *pNewPgDescFormat, const SwPageDesc *pNewPgDesc, bool bExtraPageBreak=false) override
Get ready for a new section.
Definition: rtfexport.cxx:1065
void OutputLinkedOLE(const OUString &rLink) override
Definition: rtfexport.cxx:1125
void AppendSection(const SwPageDesc *pPageDesc, const SwSectionFormat *pFormat, sal_uLong nLnNum) override
Definition: rtfexport.cxx:1135
sal_uInt16 GetRedline(const OUString &rAuthor)
Definition: rtfexport.cxx:1437
rtl_TextEncoding GetCurrentEncoding() const
Definition: rtfexport.hxx:178
bool m_bRTFFlySyntax
This is used by OutputFlyFrame_Impl() to control the written syntax.
Definition: rtfexport.hxx:168
bool AddSectionBreaksForTOX() const override
Determines the Section Breaks are to be added for TOX Section.
Definition: rtfexport.hxx:63
bool DisallowInheritingOutlineNumbering(const SwFormat &rFormat) override
Return value indicates if an inherited outline numbering is suppressed.
Definition: rtfexport.cxx:1086
void SectionBreaksAndFrames(const SwTextNode &) override
Definition: rtfexport.hxx:125
void resetStream()
Return back to the real stream.
Definition: rtfexport.cxx:1191
void WritePageDescTable()
Writes the writer-specific \pgdsctbl group.
Definition: rtfexport.cxx:732
void DoComboBox(const OUString &rName, const OUString &rHelp, const OUString &ToolTip, const OUString &rSelected, const css::uno::Sequence< OUString > &rListItems) override
Definition: rtfexport.cxx:385
void WriteFootnoteSettings()
Definition: rtfexport.cxx:455
RtfSdrExport & SdrExporter() const
Access to the Rtf Sdr exporter.
Definition: rtfexport.cxx:84
void InsColor(const Color &rCol)
Definition: rtfexport.cxx:1232
void ExportGrfBullet(const SwTextNode &rNd) override
Definition: rtfexport.cxx:179
~RtfExport() override
Destructor.
void SetRTFFlySyntax(bool bRTFFlySyntax)
Definition: rtfexport.hxx:179
RtfExportFilter * m_pFilter
Pointer to the filter that owns us.
Definition: rtfexport.hxx:39
std::map< sal_uInt16, OString > m_aStyTable
Definition: rtfexport.hxx:228
void WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t) override
Definition: rtfexport.hxx:82
bool CollapseScriptsforWordOk(sal_uInt16 nScript, sal_uInt16 nWhich) override
Guess the script (asian/western).
Definition: rtfexport.cxx:86
void WriteHyperlinkData(const ::sw::mark::IFieldmark &rFieldmark) override
Definition: rtfexport.cxx:380
void WriteMainText()
Definition: rtfexport.cxx:470
void WriteDocVars()
Writes document variables.
Definition: rtfexport.cxx:681
OString * GetStyle(sal_uInt16 nId)
Definition: rtfexport.cxx:1429
sal_uInt64 ReplaceCr(sal_uInt8 nChar) override
Definition: rtfexport.cxx:430
SwNodeOffset GetCurrentNodeIndex() const
Definition: rtfexport.hxx:181
const SfxItemSet * GetFirstPageItemSet() const
Definition: rtfexport.hxx:203
void InsStyle(sal_uInt16 nId, const OString &rStyle)
Definition: rtfexport.cxx:1424
rtl_TextEncoding m_eDefaultEncoding
Definition: rtfexport.hxx:165
Handles export of drawings using RTF markup.
Definition: doc.hxx:197
Ends a section of nodes in the document model.
Definition: node.hxx:378
Base class of all fields.
Definition: fldbas.hxx:296
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:36
Base class for various Writer styles.
Definition: format.hxx:47
Style of a layout element.
Definition: frmfmt.hxx:72
Base class of the Writer document model elements.
Definition: node.hxx:98
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
std::map< sal_uInt16, Color > RtfColorTable
Definition: rtfexport.hxx:29
sal_uIntPtr sal_uLong
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
FieldFlags
Definition: wrtww8.hxx:143