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