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 2738 : virtual bool SupportsUnicode() const SAL_OVERRIDE { return true; }
64 :
65 3 : virtual bool SupportsOneColumnBreak() const SAL_OVERRIDE { return false; }
66 :
67 0 : virtual bool FieldsQuoted() const SAL_OVERRIDE { return true; }
68 :
69 0 : virtual bool AddSectionBreaksForTOX() const SAL_OVERRIDE { return false; }
70 :
71 : /// Guess the script (asian/western).
72 : virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) SAL_OVERRIDE;
73 :
74 : virtual void AppendBookmarks( const SwTxtNode& rNode, sal_Int32 nAktPos, sal_Int32 nLen ) SAL_OVERRIDE;
75 :
76 : virtual void AppendBookmark( const OUString& rName, bool bSkip = false ) SAL_OVERRIDE;
77 :
78 : virtual void AppendAnnotationMarks( const SwTxtNode& rNode, sal_Int32 nAktPos, sal_Int32 nLen ) SAL_OVERRIDE;
79 :
80 : //For i120928,add an interface to export graphic of bullet
81 : virtual void ExportGrfBullet(const SwTxtNode& rNd) SAL_OVERRIDE;
82 :
83 521 : 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 */ }
84 : virtual void WriteChar( sal_Unicode ) SAL_OVERRIDE;
85 :
86 : /// Write the numbering table.
87 : virtual void WriteNumbering() SAL_OVERRIDE;
88 :
89 : /// Write the revision table.
90 : virtual void WriteRevTab();
91 :
92 : /// Output the actual headers and footers.
93 : virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
94 : const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt, sal_uInt8 nBreakCode ) SAL_OVERRIDE;
95 :
96 : /// Write the field
97 : virtual void OutputField( const SwField* pFld, ww::eField eFldType,
98 : const OUString& rFldCmd, sal_uInt8 nMode = nsFieldFlags::WRITEFIELD_ALL ) SAL_OVERRIDE;
99 :
100 : /// Write the data of the form field
101 : virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) SAL_OVERRIDE;
102 : virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ) SAL_OVERRIDE;
103 :
104 : virtual void DoComboBox(const OUString &rName,
105 : const OUString &rHelp,
106 : const OUString &ToolTip,
107 : const OUString &rSelected,
108 : com::sun::star::uno::Sequence<OUString> &rListItems) SAL_OVERRIDE;
109 :
110 : virtual void DoFormText(const SwInputField * pFld) SAL_OVERRIDE;
111 :
112 : virtual sal_uLong ReplaceCr( sal_uInt8 nChar ) SAL_OVERRIDE;
113 :
114 : protected:
115 : /// Format-dependent part of the actual export.
116 : virtual void ExportDocument_Impl() SAL_OVERRIDE;
117 :
118 521 : virtual void SectionBreaksAndFrames( const SwTxtNode& /*rNode*/ ) SAL_OVERRIDE {}
119 :
120 : /// Get ready for a new section.
121 : virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
122 : const SwNode& rNd,
123 : const SwFmtPageDesc* pNewPgDescFmt = 0,
124 : const SwPageDesc* pNewPgDesc = 0 ) SAL_OVERRIDE;
125 :
126 : /// Return value indicates if an inherited outline numbering is suppressed.
127 : virtual bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt) SAL_OVERRIDE;
128 :
129 : /// Output SwTxtNode is depending on outline export mode
130 : virtual void OutputTextNode( const SwTxtNode& ) SAL_OVERRIDE;
131 :
132 : /// Output SwGrfNode
133 : virtual void OutputGrfNode( const SwGrfNode& ) SAL_OVERRIDE;
134 :
135 : /// Output SwOLENode
136 : virtual void OutputOLENode( const SwOLENode& ) SAL_OVERRIDE;
137 :
138 : virtual void OutputLinkedOLE(const OUString&) SAL_OVERRIDE;
139 :
140 : virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum ) SAL_OVERRIDE;
141 :
142 : public:
143 : /// Pass the pDocument, pCurrentPam and pOriginalPam to the base class.
144 : RtfExport( RtfExportFilter *pFilter, SwDoc *pDocument,
145 : SwPaM *pCurrentPam, SwPaM *pOriginalPam, Writer* pWriter,
146 : bool bOutOutlineOnly = false );
147 :
148 : /// Destructor.
149 : virtual ~RtfExport();
150 :
151 : rtl_TextEncoding eDefaultEncoding;
152 : rtl_TextEncoding eCurrentEncoding;
153 : /// This is used by OutputFlyFrame_Impl() to control the written syntax
154 : bool bRTFFlySyntax;
155 : /// Index of the current SwTxtNode, if any.
156 : sal_uLong m_nCurrentNodeIndex;
157 :
158 : SvStream& Strm();
159 : SvStream& OutULong( sal_uLong nVal );
160 : SvStream& OutLong( long nVal );
161 : void OutUnicode(const sal_Char *pToken, const OUString &rContent, bool bUpr = false);
162 : void OutDateTime(const sal_Char* pStr, const css::util::DateTime& rDT );
163 : void OutPageDescription( const SwPageDesc& rPgDsc, bool bWriteReset, bool bCheckForFirstPage );
164 :
165 : sal_uInt16 GetColor( const Color& rColor ) const;
166 : void InsColor( const Color& rCol );
167 : void InsColorLine( const SvxBoxItem& rBox );
168 : void OutColorTable();
169 : sal_uInt16 GetRedline( const OUString& rAuthor );
170 : const OUString* GetRedline( sal_uInt16 nId );
171 :
172 : void InsStyle( sal_uInt16 nId, const OString& rStyle );
173 : OString* GetStyle( sal_uInt16 nId );
174 :
175 : private:
176 : /// No copying.
177 : RtfExport( const RtfExport& );
178 :
179 : /// No copying.
180 : RtfExport& operator=( const RtfExport& );
181 :
182 : void WriteFonts();
183 : void WriteStyles();
184 : void WriteFootnoteSettings();
185 : void WriteMainText();
186 : void WriteInfo();
187 : /// Writes the writer-specific \pgdsctbl group.
188 : void WritePageDescTable();
189 : /// This is necessary to have the numbering table ready before the main text is being processed.
190 : void BuildNumbering();
191 : void WriteHeaderFooter(const SfxPoolItem& rItem, bool bHeader);
192 : void WriteHeaderFooter(const SwFrmFmt& rFmt, bool bHeader, const sal_Char* pStr, bool bTitlepg = false);
193 :
194 : RtfColorTbl m_aColTbl;
195 : RtfStyleTbl m_aStyTbl;
196 : RtfRedlineTbl m_aRedlineTbl;
197 : };
198 :
199 : #endif // INCLUDED_SW_SOURCE_FILTER_WW8_RTFEXPORT_HXX
200 :
201 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|