LibreOffice Module sw (master)  1
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
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 .
18  */
23 #include <memory>
24 #include "wrtww8.hxx"
26 class RtfAttributeOutput;
27 class RtfExportFilter;
28 class RtfSdrExport;
29 using RtfColorTable = std::map<sal_uInt16, Color>;
30 class SwNode;
31 class SwTextNode;
32 class SwGrfNode;
33 class SwOLENode;
37 {
43  std::unique_ptr<RtfAttributeOutput> m_pAttrOutput;
48  std::unique_ptr<RtfSdrExport> m_pSdrExport;
49  bool const m_bOutOutlineOnly;
51 public:
53  AttributeOutputBase& AttrOutput() const override;
56  MSWordSections& Sections() const override;
59  RtfSdrExport& SdrExporter() const;
61  bool SupportsOneColumnBreak() const override { return false; }
63  bool FieldsQuoted() const override { return true; }
65  bool AddSectionBreaksForTOX() const override { return false; }
67  bool PreferPageBreakBefore() const override { return true; }
70  bool CollapseScriptsforWordOk(sal_uInt16 nScript, sal_uInt16 nWhich) override;
72  void AppendBookmarks(const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen) override;
74  void AppendBookmark(const OUString& rName) override;
76  void AppendAnnotationMarks(const SwTextNode& rNode, sal_Int32 nCurrentPos,
77  sal_Int32 nLen) override;
79  //For i120928,add an interface to export graphic of bullet
80  void ExportGrfBullet(const SwTextNode& rNd) override;
82  void
84  Pointer_t /*pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t()*/)
85  override
86  {
87  /* no-op for rtf, most probably should not even be in MSWordExportBase */
88  }
89  void WriteChar(sal_Unicode c) override;
92  void WriteNumbering() override;
95  void WriteRevTab();
98  void WriteHeadersFooters(sal_uInt8 nHeadFootFlags, const SwFrameFormat& rFormat,
99  const SwFrameFormat& rLeftFormat,
100  const SwFrameFormat& rFirstPageFormat, sal_uInt8 nBreakCode) override;
103  void OutputField(const SwField* pField, ww::eField eFieldType, const OUString& rFieldCmd,
104  FieldFlags nMode = FieldFlags::All) override;
107  void WriteFormData(const ::sw::mark::IFieldmark& rFieldmark) override;
108  void WriteHyperlinkData(const ::sw::mark::IFieldmark& rFieldmark) override;
110  void DoComboBox(const OUString& rName, const OUString& rHelp, const OUString& ToolTip,
111  const OUString& rSelected, css::uno::Sequence<OUString>& rListItems) override;
113  void DoFormText(const SwInputField* pField) override;
115  sal_uLong ReplaceCr(sal_uInt8 nChar) override;
117  ExportFormat GetExportFormat() const override { return ExportFormat::RTF; }
119 protected:
121  ErrCode ExportDocument_Impl() override;
123  void SectionBreaksAndFrames(const SwTextNode& /*rNode*/) override {}
126  void PrepareNewPageDesc(const SfxItemSet* pSet, const SwNode& rNd,
127  const SwFormatPageDesc* pNewPgDescFormat,
128  const SwPageDesc* pNewPgDesc) override;
131  bool DisallowInheritingOutlineNumbering(const SwFormat& rFormat) override;
134  void OutputTextNode(SwTextNode& rNode) override;
137  void OutputEndNode(const SwEndNode& rEndNode) override;
140  void OutputGrfNode(const SwGrfNode& rGrfNode) override;
143  void OutputOLENode(const SwOLENode& rOLENode) override;
145  void OutputLinkedOLE(const OUString& rLink) override;
147  void AppendSection(const SwPageDesc* pPageDesc, const SwSectionFormat* pFormat,
148  sal_uLong nLnNum) override;
150 public:
152  RtfExport(RtfExportFilter* pFilter, SwDoc* pDocument, SwPaM* pCurrentPam, SwPaM* pOriginalPam,
153  Writer* pWriter, bool bOutOutlineOnly = false);
155  RtfExport(const RtfExport&) = delete;
157  RtfExport& operator=(const RtfExport&) = delete;
160  ~RtfExport() override;
162 private:
163  rtl_TextEncoding m_eDefaultEncoding;
164  rtl_TextEncoding m_eCurrentEncoding;
170 public:
171  rtl_TextEncoding GetDefaultEncoding() const { return m_eDefaultEncoding; }
172  void SetCurrentEncoding(rtl_TextEncoding eCurrentEncoding)
173  {
174  m_eCurrentEncoding = eCurrentEncoding;
175  }
176  rtl_TextEncoding GetCurrentEncoding() const { return m_eCurrentEncoding; }
177  void SetRTFFlySyntax(bool bRTFFlySyntax) { m_bRTFFlySyntax = bRTFFlySyntax; }
178  bool GetRTFFlySyntax() const { return m_bRTFFlySyntax; }
180  SvStream& Strm();
182  void setStream();
184  OString getStream();
186  void resetStream();
187  SvStream& OutULong(sal_uLong nVal);
188  SvStream& OutLong(long nVal);
189  void OutUnicode(const sal_Char* pToken, const OUString& rContent, bool bUpr = false);
190  void OutDateTime(const sal_Char* pStr, const css::util::DateTime& rDT);
191  void OutPageDescription(const SwPageDesc& rPgDsc, bool bCheckForFirstPage);
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);
200  void InsStyle(sal_uInt16 nId, const OString& rStyle);
201  OString* GetStyle(sal_uInt16 nId);
205 private:
206  void WriteFonts();
207  void WriteStyles();
208  void WriteFootnoteSettings();
209  void WriteMainText();
210  void WriteInfo();
212  void WriteUserPropType(int nType);
214  void WriteUserPropValue(const OUString& rValue);
216  void WriteUserProps();
218  void WritePageDescTable();
220  void BuildNumbering();
221  void WriteHeaderFooter(const SfxPoolItem& rItem, bool bHeader);
222  void WriteHeaderFooter(const SwFrameFormat& rFormat, bool bHeader, const sal_Char* pStr,
223  bool bTitlepg = false);
226  std::map<sal_uInt16, OString> m_aStyTable;
227  std::map<OUString, sal_uInt16> m_aRedlineTable;
229  std::unique_ptr<SvMemoryStream> m_pStream;
231  const SfxItemSet* m_pFirstPageItemSet = nullptr;
232 };
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
RtfExport & operator=(const RtfExport &)=delete
std::unique_ptr< SvMemoryStream > m_pStream
If set, then Strm() returns this tream, instead of m_pWriter's stream.
Definition: rtfexport.hxx:229
SvStream & OutULong(sal_uLong nVal)
Definition: rtfexport.cxx:1090
std::unique_ptr< RtfAttributeOutput > m_pAttrOutput
Attribute output for document.
Definition: rtfexport.hxx:43
Class to collect and output the sections/headers/footers.
Definition: wrtww8.hxx:198
void WriteMainText()
Definition: rtfexport.cxx:421
OString * GetStyle(sal_uInt16 nId)
Definition: rtfexport.cxx:1322
void WriteHeaderFooter(const SfxPoolItem &rItem, bool bHeader)
Definition: rtfexport.cxx:1400
void OutputEndNode(const SwEndNode &rEndNode) override
Output SwEndNode.
Definition: rtfexport.cxx:1005
rtl_TextEncoding m_eCurrentEncoding
Definition: rtfexport.hxx:164
void SectionBreaksAndFrames(const SwTextNode &) override
Definition: rtfexport.hxx:123
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
MSWordSections * m_pSections
Definition: rtfexport.hxx:46
rtl_TextEncoding GetCurrentEncoding() const
Definition: rtfexport.hxx:176
RtfColorTable m_aColTable
Definition: rtfexport.hxx:225
void OutputGrfNode(const SwGrfNode &rGrfNode) override
Output SwGrfNode.
Definition: rtfexport.cxx:1012
AttributeOutputBase & AttrOutput() const override
Access to the attribute output class.
Definition: rtfexport.cxx:78
ExportFormat GetExportFormat() const override
Definition: rtfexport.hxx:117
sal_uIntPtr sal_uLong
Base class of all fields.
Definition: fldbas.hxx:279
void WriteNumbering() override
Write the numbering table.
Definition: rtfexport.cxx:225
SvStream & Strm()
Definition: rtfexport.cxx:1068
Definition: doc.hxx:185
void DoFormText(const SwInputField *pField) override
Definition: rtfexport.cxx:338
bool GetRTFFlySyntax() const
Definition: rtfexport.hxx:178
std::map< sal_uInt16, Color > RtfColorTable
Definition: rtfexport.hxx:29
rtl_TextEncoding GetDefaultEncoding() const
Definition: rtfexport.hxx:171
rtl_TextEncoding m_eDefaultEncoding
Definition: rtfexport.hxx:163
sal_uInt16 GetRedline(const OUString &rAuthor)
Definition: rtfexport.cxx:1330
Writer * m_pWriter
Definition: rtfexport.hxx:40
void OutputField(const SwField *pField, ww::eField eFieldType, const OUString &rFieldCmd, FieldFlags nMode=FieldFlags::All) override
Write the field.
Definition: rtfexport.cxx:315
bool PreferPageBreakBefore() const override
If saving page break is preferred as a paragraph attribute (yes) or as a special character (no)...
Definition: rtfexport.hxx:67
bool FieldsQuoted() const override
Determines if the import filter already quoted fields or not.
Definition: rtfexport.hxx:63
sal_uInt16 sal_Unicode
void AppendBookmarks(const SwTextNode &rNode, sal_Int32 nCurrentPos, sal_Int32 nLen) override
Definition: rtfexport.cxx:118
Definition: wrtww8.hxx:146
void InsStyle(sal_uInt16 nId, const OString &rStyle)
Definition: rtfexport.cxx:1317
The class that does all the actual RTF export-related work.
Definition: rtfexport.hxx:36
void InsColorLine(const SvxBoxItem &rBox)
Definition: rtfexport.cxx:1160
bool AddSectionBreaksForTOX() const override
Determines the Section Breaks are to be added for TOX Section.
Definition: rtfexport.hxx:65
void WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t) override
Definition: rtfexport.hxx:83
void WriteUserPropType(int nType)
Writes a single user property type.
Definition: rtfexport.cxx:525
char sal_Char
The class that has handlers for various resource types when exporting as RTF.
void OutputTextNode(SwTextNode &rNode) override
Output SwTextNode is depending on outline export mode.
Definition: rtfexport.cxx:1024
const SfxItemSet * m_pFirstPageItemSet
Item set of the first page during export of a follow page format.
Definition: rtfexport.hxx:231
void OutputLinkedOLE(const OUString &rLink) override
Definition: rtfexport.cxx:1022
Definition: fields.hxx:26
bool DisallowInheritingOutlineNumbering(const SwFormat &rFormat) override
Return value indicates if an inherited outline numbering is suppressed.
Definition: rtfexport.cxx:983
bool CollapseScriptsforWordOk(sal_uInt16 nScript, sal_uInt16 nWhich) override
Guess the script (asian/western).
Definition: rtfexport.cxx:84
RtfExportFilter * m_pFilter
Pointer to the filter that owns us.
Definition: rtfexport.hxx:39
Base class for various Writer styles.
Definition: format.hxx:43
void InsColor(const Color &rCol)
Definition: rtfexport.cxx:1135
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
void SetCurrentEncoding(rtl_TextEncoding eCurrentEncoding)
Definition: rtfexport.hxx:172
std::map< sal_uInt16, OString > m_aStyTable
Definition: rtfexport.hxx:226
void WriteFormData(const ::sw::mark::IFieldmark &rFieldmark) override
Write the data of the form field.
Definition: rtfexport.cxx:321
bool m_bRTFFlySyntax
This is used by OutputFlyFrame_Impl() to control the written syntax.
Definition: rtfexport.hxx:166
Style of a layout element.
Definition: frmfmt.hxx:57
void AppendAnnotationMarks(const SwTextNode &rNode, sal_Int32 nCurrentPos, sal_Int32 nLen) override
Definition: rtfexport.cxx:153
void WriteHeadersFooters(sal_uInt8 nHeadFootFlags, const SwFrameFormat &rFormat, const SwFrameFormat &rLeftFormat, const SwFrameFormat &rFirstPageFormat, sal_uInt8 nBreakCode) override
Output the actual headers and footers.
Definition: rtfexport.cxx:290
void WriteUserProps()
Writes the userprops group: user defined document properties.
Definition: rtfexport.cxx:538
void setStream()
From now on, let Strm() return a memory stream, not a real one.
Definition: rtfexport.cxx:1076
void AppendBookmark(const OUString &rName) override
Definition: rtfexport.cxx:142
void DoComboBox(const OUString &rName, const OUString &rHelp, const OUString &ToolTip, const OUString &rSelected, css::uno::Sequence< OUString > &rListItems) override
Definition: rtfexport.cxx:331
void WriteRevTab()
Write the revision table.
Definition: rtfexport.cxx:257
RtfExport(RtfExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam, Writer *pWriter, bool bOutOutlineOnly=false)
Pass the pDocument, pCurrentPam and pOriginalPam to the base class.
Definition: rtfexport.cxx:1039
void WriteStyles()
Definition: rtfexport.cxx:399
void OutUnicode(const sal_Char *pToken, const OUString &rContent, bool bUpr=false)
Definition: rtfexport.cxx:1094
void OutPageDescription(const SwPageDesc &rPgDsc, bool bCheckForFirstPage)
Definition: rtfexport.cxx:1349
void WriteChar(sal_Unicode c) override
Definition: rtfexport.cxx:184
MSWordSections & Sections() const override
Access to the sections/headers/footres.
Definition: rtfexport.cxx:80
Handles export of drawings using RTF markup.
SvStream & OutLong(long nVal)
Definition: rtfexport.cxx:1092
void AppendSection(const SwPageDesc *pPageDesc, const SwSectionFormat *pFormat, sal_uLong nLnNum) override
Definition: rtfexport.cxx:1032
void WriteFonts()
Definition: rtfexport.cxx:389
void WriteFootnoteSettings()
Definition: rtfexport.cxx:406
void OutDateTime(const sal_Char *pStr, const css::util::DateTime &rDT)
Definition: rtfexport.cxx:1111
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
OString getStream()
Get the contents of the memory stream as a string.
Definition: rtfexport.cxx:1078
void SetRTFFlySyntax(bool bRTFFlySyntax)
Definition: rtfexport.hxx:177
void resetStream()
Return back to the real stream.
Definition: rtfexport.cxx:1088
std::unique_ptr< RtfSdrExport > m_pSdrExport
Definition: rtfexport.hxx:48
unsigned char sal_uInt8
void BuildNumbering()
This is necessary to have the numbering table ready before the main text is being processed...
Definition: rtfexport.cxx:206
void OutputOLENode(const SwOLENode &rOLENode) override
Output SwOLENode.
Definition: rtfexport.cxx:1017
void OutColorTable()
Definition: rtfexport.cxx:1183
~RtfExport() override
ErrCode ExportDocument_Impl() override
Format-dependent part of the actual export.
Definition: rtfexport.cxx:683
void ExportGrfBullet(const SwTextNode &rNd) override
Definition: rtfexport.cxx:179
sal_uLong GetCurrentNodeIndex() const
Definition: rtfexport.hxx:179
bool SupportsOneColumnBreak() const override
Determines if column break with one column should be exported or not.
Definition: rtfexport.hxx:61
sal_uLong ReplaceCr(sal_uInt8 nChar) override
Definition: rtfexport.cxx:381
void WriteHyperlinkData(const ::sw::mark::IFieldmark &rFieldmark) override
Definition: rtfexport.cxx:326
RtfSdrExport & SdrExporter() const
Access to the Rtf Sdr exporter.
Definition: rtfexport.cxx:82
Base class for WW8Export and DocxExport.
Definition: wrtww8.hxx:452
sal_uInt16 GetColor(const Color &rColor) const
Definition: rtfexport.cxx:1121
Ends a section of nodes in the document model.
Definition: node.hxx:333
bool const m_bOutOutlineOnly
Definition: rtfexport.hxx:49
void PrepareNewPageDesc(const SfxItemSet *pSet, const SwNode &rNd, const SwFormatPageDesc *pNewPgDescFormat, const SwPageDesc *pNewPgDesc) override
Get ready for a new section.
Definition: rtfexport.cxx:963
void WritePageDescTable()
Writes the writer-specific group.
Definition: rtfexport.cxx:637
std::map< OUString, sal_uInt16 > m_aRedlineTable
Definition: rtfexport.hxx:227
sal_uLong m_nCurrentNodeIndex
Index of the current SwTextNode, if any.
Definition: rtfexport.hxx:168
The physical access to the RTF document (for writing).
const SfxItemSet * GetFirstPageItemSet()
Definition: rtfexport.hxx:203
void WriteInfo()
Definition: rtfexport.cxx:467
void WriteUserPropValue(const OUString &rValue)
Writes a single user property value.
Definition: rtfexport.cxx:531
Base class of the Writer document model elements.
Definition: node.hxx:79