Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : * Copyright 2010 Miklos Vajna.
8 : : *
9 : : * OpenOffice.org - a multi-platform office productivity suite
10 : : *
11 : : * This file is part of OpenOffice.org.
12 : : *
13 : : * OpenOffice.org is free software: you can redistribute it and/or modify
14 : : * it under the terms of the GNU Lesser General Public License version 3
15 : : * only, as published by the Free Software Foundation.
16 : : *
17 : : * OpenOffice.org is distributed in the hope that it will be useful,
18 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 : : * GNU Lesser General Public License version 3 for more details
21 : : * (a copy is included in the LICENSE file that accompanied this code).
22 : : *
23 : : * You should have received a copy of the GNU Lesser General Public License
24 : : * version 3 along with OpenOffice.org. If not, see
25 : : * <http://www.openoffice.org/license.html>
26 : : * for a copy of the LGPLv3 License.
27 : : *
28 : : ************************************************************************/
29 : :
30 : : #include "sal/config.h"
31 : :
32 : : #include <cstring>
33 : :
34 : : #include "rtfattributeoutput.hxx"
35 : : #include "rtfsdrexport.hxx"
36 : : #include "writerwordglue.hxx"
37 : : #include "ww8par.hxx"
38 : : #include "fmtcntnt.hxx"
39 : : #include "fchrfmt.hxx"
40 : :
41 : : #include <rtl/oustringostreaminserter.hxx>
42 : : #include <svtools/rtfkeywd.hxx>
43 : :
44 : : #include <editeng/fontitem.hxx>
45 : : #include <editeng/tstpitem.hxx>
46 : : #include <editeng/adjitem.hxx>
47 : : #include <editeng/spltitem.hxx>
48 : : #include <editeng/widwitem.hxx>
49 : : #include <editeng/keepitem.hxx>
50 : : #include <editeng/brshitem.hxx>
51 : : #include <editeng/postitem.hxx>
52 : : #include <editeng/wghtitem.hxx>
53 : : #include <editeng/kernitem.hxx>
54 : : #include <editeng/crsditem.hxx>
55 : : #include <editeng/cmapitem.hxx>
56 : : #include <editeng/wrlmitem.hxx>
57 : : #include <editeng/udlnitem.hxx>
58 : : #include <editeng/langitem.hxx>
59 : : #include <editeng/escpitem.hxx>
60 : : #include <editeng/fhgtitem.hxx>
61 : : #include <editeng/colritem.hxx>
62 : : #include <editeng/hyznitem.hxx>
63 : : #include <editeng/ulspitem.hxx>
64 : : #include <editeng/boxitem.hxx>
65 : : #include <editeng/cntritem.hxx>
66 : : #include <editeng/shdditem.hxx>
67 : : #include <editeng/akrnitem.hxx>
68 : : #include <editeng/emphitem.hxx>
69 : : #include <editeng/twolinesitem.hxx>
70 : : #include <editeng/charscaleitem.hxx>
71 : : #include <editeng/charrotateitem.hxx>
72 : : #include <editeng/charreliefitem.hxx>
73 : : #include <editeng/paravertalignitem.hxx>
74 : : #include <editeng/frmdiritem.hxx>
75 : : #include <editeng/blnkitem.hxx>
76 : : #include <editeng/charhiddenitem.hxx>
77 : : #include <svx/svdmodel.hxx>
78 : : #include <svx/fmglob.hxx>
79 : : #include <svx/svdouno.hxx>
80 : : #include <filter/msfilter/msoleexp.hxx>
81 : : #include <filter/msfilter/rtfutil.hxx>
82 : : #include <svtools/miscopt.hxx>
83 : : #include <sfx2/sfxbasemodel.hxx>
84 : :
85 : : #include <docufld.hxx>
86 : : #include <fmtclds.hxx>
87 : : #include <fmtinfmt.hxx>
88 : : #include <fmtftn.hxx>
89 : : #include <fmtrowsplt.hxx>
90 : : #include <fmtline.hxx>
91 : : #include <fmtanchr.hxx>
92 : : #include <frmatr.hxx>
93 : : #include <htmltbl.hxx>
94 : : #include <ndgrf.hxx>
95 : : #include <ndtxt.hxx>
96 : : #include <pagedesc.hxx>
97 : : #include <swmodule.hxx>
98 : : #include <swtable.hxx>
99 : : #include <txtftn.hxx>
100 : : #include <txtinet.hxx>
101 : : #include <grfatr.hxx>
102 : : #include <ndole.hxx>
103 : : #include <lineinfo.hxx>
104 : : #include <rtf.hxx>
105 : :
106 : : #include <vcl/cvtgrf.hxx>
107 : : #include <oox/mathml/export.hxx>
108 : :
109 : : #include <com/sun/star/i18n/ScriptType.hpp>
110 : :
111 : : using ::editeng::SvxBorderLine;
112 : : using namespace nsSwDocInfoSubType;
113 : : using namespace nsFieldFlags;
114 : : using namespace sw::util;
115 : : using namespace ::com::sun::star;
116 : :
117 : 0 : static OString OutTBLBorderLine(RtfExport &rExport, const SvxBorderLine* pLine, const sal_Char* pStr)
118 : : {
119 : 0 : OStringBuffer aRet;
120 [ # # ]: 0 : if ( !pLine->isEmpty() )
121 : : {
122 [ # # ]: 0 : aRet.append(pStr);
123 : : // single line
124 [ # # # # : 0 : switch (pLine->GetBorderLineStyle())
# # # # #
# # # # #
# ]
125 : : {
126 : : case table::BorderLineStyle::SOLID:
127 : : {
128 [ # # ]: 0 : if( DEF_LINE_WIDTH_0 == pLine->GetWidth() )
129 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRHAIR);
130 : : else
131 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRS);
132 : : }
133 : 0 : break;
134 : : case table::BorderLineStyle::DOTTED:
135 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRDOT);
136 : 0 : break;
137 : : case table::BorderLineStyle::DASHED:
138 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRDASH);
139 : 0 : break;
140 : : case table::BorderLineStyle::DOUBLE:
141 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRDB);
142 : 0 : break;
143 : : case table::BorderLineStyle::THINTHICK_SMALLGAP:
144 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTNTHSG);
145 : 0 : break;
146 : : case table::BorderLineStyle::THINTHICK_MEDIUMGAP:
147 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTNTHMG);
148 : 0 : break;
149 : : case table::BorderLineStyle::THINTHICK_LARGEGAP:
150 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTNTHLG);
151 : 0 : break;
152 : : case table::BorderLineStyle::THICKTHIN_SMALLGAP:
153 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTHTNSG);
154 : 0 : break;
155 : : case table::BorderLineStyle::THICKTHIN_MEDIUMGAP:
156 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTHTNMG);
157 : 0 : break;
158 : : case table::BorderLineStyle::THICKTHIN_LARGEGAP:
159 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTHTNLG);
160 : 0 : break;
161 : : case table::BorderLineStyle::EMBOSSED:
162 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDREMBOSS);
163 : 0 : break;
164 : : case table::BorderLineStyle::ENGRAVED:
165 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRENGRAVE);
166 : 0 : break;
167 : : case table::BorderLineStyle::OUTSET:
168 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDROUTSET);
169 : 0 : break;
170 : : case table::BorderLineStyle::INSET:
171 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRINSET);
172 : 0 : break;
173 : : case table::BorderLineStyle::NONE:
174 : : default:
175 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRNONE);
176 : 0 : break;
177 : : }
178 : :
179 : : double const fConverted( ::editeng::ConvertBorderWidthToWord(
180 [ # # ]: 0 : pLine->GetBorderLineStyle(), pLine->GetWidth()) );
181 [ # # ]: 0 : if ( 255 >= pLine->GetWidth() ) // That value comes from RTF specs
182 : : {
183 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRW).append(
184 [ # # ]: 0 : static_cast<sal_Int32>(fConverted));
185 : : }
186 : : else
187 : : { // use \brdrth to double the value range...
188 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTH OOO_STRING_SVTOOLS_RTF_BRDRW);
189 [ # # ]: 0 : aRet.append(static_cast<sal_Int32>(fConverted) / 2);
190 : : }
191 : :
192 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRCF);
193 [ # # ][ # # ]: 0 : aRet.append((sal_Int32)rExport.GetColor(pLine->GetColor()));
194 : : }
195 : 0 : return aRet.makeStringAndClear();
196 : : }
197 : :
198 : 0 : static OString OutBorderLine(RtfExport &rExport, const SvxBorderLine* pLine,
199 : : const sal_Char* pStr, sal_uInt16 nDist)
200 : : {
201 : 0 : OStringBuffer aRet;
202 [ # # ][ # # ]: 0 : aRet.append(OutTBLBorderLine(rExport, pLine, pStr));
203 [ # # ]: 0 : aRet.append(OOO_STRING_SVTOOLS_RTF_BRSP);
204 [ # # ]: 0 : aRet.append((sal_Int32)nDist);
205 : 0 : return aRet.makeStringAndClear();
206 : : }
207 : :
208 : 141 : void RtfAttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript )
209 : : {
210 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
211 : : /*
212 : : You would have thought that
213 : : m_rExport.Strm() << (bIsRTL ? OOO_STRING_SVTOOLS_RTF_RTLCH : OOO_STRING_SVTOOLS_RTF_LTRCH); would be sufficent here ,
214 : : but looks like word needs to see the other directional token to be
215 : : satisified that all is kosher, otherwise it seems in ver 2003 to go and
216 : : semi-randomlyly stick strike through about the place. Perhaps
217 : : strikethrough is some ms developers "something is wrong signal" debugging
218 : : code that we're triggering ?
219 : : */
220 [ - + ]: 141 : if (bIsRTL) {
221 : 0 : m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LTRCH);
222 : 0 : m_aStylesEnd.append(' ');
223 : 0 : m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_RTLCH);
224 : : } else {
225 : 141 : m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_RTLCH);
226 : 141 : m_aStylesEnd.append(' ');
227 : 141 : m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LTRCH);
228 : : }
229 : :
230 [ + - - + ]: 141 : switch (nScript) {
231 : : case i18n::ScriptType::LATIN:
232 : 54 : m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LOCH);
233 : 54 : break;
234 : : case i18n::ScriptType::ASIAN:
235 : 0 : m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_DBCH);
236 : 0 : break;
237 : : case i18n::ScriptType::COMPLEX:
238 : : /* noop */
239 : 0 : break;
240 : : default:
241 : : /* should not happen? */
242 : 87 : break;
243 : : }
244 : 141 : }
245 : :
246 : 126 : void RtfAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo )
247 : : {
248 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
249 : :
250 : : // Output table/table row/table cell starts if needed
251 [ - + ]: 126 : if ( pTextNodeInfo.get() )
252 : : {
253 : 0 : sal_uInt32 nRow = pTextNodeInfo->getRow();
254 : 0 : sal_uInt32 nCell = pTextNodeInfo->getCell();
255 : :
256 : : // New cell/row?
257 [ # # ][ # # ]: 0 : if ( m_nTableDepth > 0 && !m_bTableCellOpen )
258 : : {
259 [ # # ]: 0 : ww8::WW8TableNodeInfoInner::Pointer_t pDeepInner( pTextNodeInfo->getInnerForDepth( m_nTableDepth ) );
260 : : OSL_ENSURE( pDeepInner, "TableNodeInfoInner not found");
261 : : // Make sure we always start a row between ending one and starting a cell.
262 : : // In case of subtables, we may not get the first cell.
263 [ # # ][ # # ]: 0 : if (pDeepInner && (pDeepInner->getCell() == 0 || m_bTableRowEnded))
[ # # ][ # # ]
[ # # ]
264 : : {
265 : 0 : m_bTableRowEnded = false;
266 [ # # ][ # # ]: 0 : StartTableRow( pDeepInner );
[ # # ]
267 : : }
268 : :
269 [ # # ][ # # ]: 0 : StartTableCell( pDeepInner );
[ # # ][ # # ]
270 : : }
271 : :
272 : : // Again, if depth was incremented, start a new table even if we skipped the first cell.
273 [ # # ][ # # ]: 0 : if ((nRow == 0 && nCell == 0) || (m_nTableDepth == 0 && pTextNodeInfo->getDepth()))
[ # # ][ # # ]
[ # # ]
274 : : {
275 : : // Do we have to start the table?
276 : : // [If we are at the rigth depth already, it means that we
277 : : // continue the table cell]
278 : 0 : sal_uInt32 nCurrentDepth = pTextNodeInfo->getDepth();
279 : :
280 [ # # ]: 0 : if ( nCurrentDepth > m_nTableDepth )
281 : : {
282 : : // Start all the tables that begin here
283 [ # # ]: 0 : for ( sal_uInt32 nDepth = m_nTableDepth + 1; nDepth <= pTextNodeInfo->getDepth(); ++nDepth )
284 : : {
285 [ # # ]: 0 : ww8::WW8TableNodeInfoInner::Pointer_t pInner( pTextNodeInfo->getInnerForDepth( nDepth ) );
286 : :
287 [ # # ]: 0 : m_bLastTable = (nDepth == pTextNodeInfo->getDepth());
288 [ # # ][ # # ]: 0 : StartTable( pInner );
[ # # ]
289 [ # # ][ # # ]: 0 : StartTableRow( pInner );
[ # # ]
290 [ # # ][ # # ]: 0 : StartTableCell( pInner );
[ # # ]
291 [ # # ]: 0 : }
292 : :
293 : 0 : m_nTableDepth = nCurrentDepth;
294 : : }
295 : : }
296 : : }
297 : :
298 : : OSL_ENSURE(m_aRun.getLength() == 0, "m_aRun is not empty");
299 : 126 : }
300 : :
301 : 126 : void RtfAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner )
302 : : {
303 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
304 : :
305 [ + - ][ + - ]: 126 : FinishTableRowCell( pTextNodeInfoInner );
[ + - ]
306 : :
307 [ + - ]: 126 : RtfStringBuffer aParagraph;
308 : :
309 [ + - ]: 126 : aParagraph.appendAndClear(m_aRun);
310 [ + - ][ + - ]: 126 : aParagraph->append(m_aAfterRuns.makeStringAndClear());
311 [ - + ]: 126 : if (m_bTblAfterCell)
312 : 0 : m_bTblAfterCell = false;
313 : : else
314 : : {
315 [ + - ][ + - ]: 126 : aParagraph->append(m_rExport.sNewLine);
316 [ + - ][ + - ]: 126 : aParagraph->append(OOO_STRING_SVTOOLS_RTF_PAR);
317 [ + - ][ + - ]: 126 : aParagraph->append(' ');
318 : : }
319 [ - + ]: 126 : if (m_nColBreakNeeded)
320 : : {
321 [ # # ][ # # ]: 0 : aParagraph->append(OOO_STRING_SVTOOLS_RTF_COLUMN);
322 : 0 : m_nColBreakNeeded = false;
323 : : }
324 : :
325 [ + - ]: 126 : if (!m_bBufferSectionHeaders)
326 [ + - ]: 126 : aParagraph.makeStringAndClear(this);
327 : : else
328 [ # # ][ # # ]: 126 : m_aSectionHeaders.append(aParagraph.makeStringAndClear());
329 : 126 : }
330 : :
331 : 0 : void RtfAttributeOutput::EmptyParagraph()
332 : : {
333 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
334 : :
335 : 0 : m_rExport.Strm() << m_rExport.sNewLine << OOO_STRING_SVTOOLS_RTF_PAR << ' ';
336 : 0 : }
337 : :
338 : 126 : void RtfAttributeOutput::StartParagraphProperties( const SwTxtNode& rNode )
339 : : {
340 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
341 : : OSL_ENSURE(m_aStyles.getLength() == 0, "m_aStyles is not empty");
342 : :
343 : : // output page/section breaks
344 [ + - ]: 126 : SwNodeIndex aNextIndex( rNode, 1 );
345 [ + - ][ + - ]: 126 : m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear().getStr();
346 : 126 : m_bBufferSectionBreaks = true;
347 : :
348 : : // output section headers / footers
349 [ + - ]: 126 : if (!m_bBufferSectionHeaders)
350 [ + - ][ + - ]: 126 : m_rExport.Strm() << m_aSectionHeaders.makeStringAndClear().getStr();
351 : :
352 [ + + ]: 126 : if ( aNextIndex.GetNode().IsTxtNode() )
353 : : {
354 [ + - ]: 48 : const SwTxtNode* pTxtNode = static_cast< SwTxtNode* >( &aNextIndex.GetNode() );
355 [ + - ][ + - ]: 48 : m_rExport.OutputSectionBreaks( pTxtNode->GetpSwAttrSet(), *pTxtNode );
356 : : // Save the current page description for now, so later we will be able to access the previous one.
357 [ + - ]: 48 : m_pPrevPageDesc = pTxtNode->FindPageDesc(sal_False);
358 : : }
359 [ - + ]: 78 : else if ( aNextIndex.GetNode().IsTableNode() )
360 : : {
361 : 0 : const SwTableNode* pTableNode = static_cast< SwTableNode* >( &aNextIndex.GetNode() );
362 : 0 : const SwFrmFmt *pFmt = pTableNode->GetTable().GetFrmFmt();
363 [ # # ]: 0 : m_rExport.OutputSectionBreaks( &(pFmt->GetAttrSet()), *pTableNode );
364 : : }
365 : 126 : m_bBufferSectionBreaks = false;
366 : :
367 : 126 : OStringBuffer aPar;
368 [ + - ]: 126 : if (!m_rExport.bRTFFlySyntax)
369 : : {
370 [ + - ]: 126 : aPar.append(OOO_STRING_SVTOOLS_RTF_PARD);
371 [ + - ]: 126 : aPar.append(OOO_STRING_SVTOOLS_RTF_PLAIN);
372 [ + - ]: 126 : aPar.append(' ');
373 : : }
374 [ + - ]: 126 : if (!m_bBufferSectionHeaders)
375 [ + - ][ + - ]: 126 : m_rExport.Strm() << aPar.makeStringAndClear().getStr();
376 : : else
377 [ # # ][ + - ]: 126 : m_aSectionHeaders.append(aPar.makeStringAndClear());
378 : 126 : }
379 : :
380 : 126 : void RtfAttributeOutput::EndParagraphProperties()
381 : : {
382 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
383 [ + - ]: 126 : m_aStyles.append(m_aStylesEnd.makeStringAndClear());
384 [ + - ][ + - ]: 126 : m_rExport.Strm() << m_aStyles.makeStringAndClear().getStr();
385 : 126 : }
386 : :
387 : 141 : void RtfAttributeOutput::StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun )
388 : : {
389 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
390 : :
391 : 141 : m_bInRun = true;
392 : 141 : m_bSingleEmptyRun = bSingleEmptyRun;
393 [ + + ]: 141 : if (!m_bSingleEmptyRun)
394 : 129 : m_aRun->append('{');
395 : :
396 : : // if there is some redlining in the document, output it
397 : 141 : Redline( pRedlineData );
398 : :
399 : : OSL_ENSURE(m_aRunText.getLength() == 0, "m_aRunText is not empty");
400 : 141 : }
401 : :
402 : 141 : void RtfAttributeOutput::EndRun()
403 : : {
404 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
405 : 141 : m_aRun->append(m_rExport.sNewLine);
406 : 141 : m_aRun.appendAndClear(m_aRunText);
407 [ + - ][ + + ]: 141 : if (!m_bSingleEmptyRun && m_bInRun)
408 : 129 : m_aRun->append('}');
409 : 141 : m_bInRun = false;
410 : 141 : }
411 : :
412 : 141 : void RtfAttributeOutput::StartRunProperties()
413 : : {
414 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
415 : : OSL_ENSURE(m_aStyles.getLength() == 0, "m_aStyles is not empty");
416 : 141 : }
417 : :
418 : 141 : void RtfAttributeOutput::EndRunProperties( const SwRedlineData* /*pRedlineData*/ )
419 : : {
420 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
421 [ + - ]: 141 : m_aStyles.append(m_aStylesEnd.makeStringAndClear());
422 [ + - ][ + - ]: 141 : m_aRun->append(m_aStyles.makeStringAndClear());
423 : 141 : }
424 : :
425 : 39 : void RtfAttributeOutput::RunText( const String& rText, rtl_TextEncoding /*eCharSet*/ )
426 : : {
427 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
428 : 39 : RawText( rText, 0, m_rExport.eCurrentEncoding );
429 : 39 : }
430 : :
431 : 72 : OStringBuffer& RtfAttributeOutput::RunText()
432 : : {
433 : 72 : return m_aRunText.getLastBuffer();
434 : : }
435 : :
436 : 0 : OStringBuffer& RtfAttributeOutput::Styles()
437 : : {
438 : 0 : return m_aStyles;
439 : : }
440 : :
441 : 39 : void RtfAttributeOutput::RawText( const String& rText, bool /*bForceUnicode*/, rtl_TextEncoding eCharSet )
442 : : {
443 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
444 [ + - ][ + - ]: 39 : m_aRunText->append(msfilter::rtfutil::OutString(rText, eCharSet));
445 : 39 : }
446 : :
447 : 0 : void RtfAttributeOutput::StartRuby( const SwTxtNode& /*rNode*/, xub_StrLen /*nPos*/, const SwFmtRuby& /*rRuby*/ )
448 : : {
449 : : SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
450 : 0 : }
451 : :
452 : 0 : void RtfAttributeOutput::EndRuby()
453 : : {
454 : : SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
455 : 0 : }
456 : :
457 : 0 : bool RtfAttributeOutput::StartURL( const String& rUrl, const String& rTarget )
458 : : {
459 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
460 : :
461 [ # # ]: 0 : m_aStyles.append('{');
462 [ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FIELD);
463 [ # # ]: 0 : m_aStyles.append('{');
464 [ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE);
465 [ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FLDINST);
466 [ # # ]: 0 : m_aStyles.append(" HYPERLINK ");
467 : :
468 [ # # ]: 0 : String sURL( rUrl );
469 [ # # ]: 0 : if( sURL.Len() )
470 : : {
471 [ # # ]: 0 : m_aStyles.append("\"");
472 [ # # ][ # # ]: 0 : m_aStyles.append(msfilter::rtfutil::OutString( sURL, m_rExport.eCurrentEncoding));
473 [ # # ]: 0 : m_aStyles.append("\" ");
474 : : }
475 : :
476 [ # # ]: 0 : if( rTarget.Len() )
477 : : {
478 [ # # ]: 0 : m_aStyles.append("\\\\t \"");
479 [ # # ][ # # ]: 0 : m_aStyles.append(msfilter::rtfutil::OutString( rTarget, m_rExport.eCurrentEncoding));
480 [ # # ]: 0 : m_aStyles.append("\" ");
481 : : }
482 : :
483 [ # # ]: 0 : m_aStyles.append("}");
484 : 0 : m_bHadFieldResult = false;
485 [ # # ]: 0 : return true;
486 : : }
487 : :
488 : 0 : bool RtfAttributeOutput::EndURL()
489 : : {
490 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
491 : :
492 : : // close the fldrslt group
493 [ # # ]: 0 : if (m_bHadFieldResult)
494 : 0 : m_aRunText->append('}');
495 : : // close the field group
496 : 0 : m_aRunText->append('}');
497 : 0 : return true;
498 : : }
499 : :
500 : 0 : void RtfAttributeOutput::FieldVanish( const String& /*rTxt*/, ww::eField /*eType*/ )
501 : : {
502 : : SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
503 : 0 : }
504 : :
505 : 141 : void RtfAttributeOutput::Redline( const SwRedlineData* pRedline )
506 : : {
507 [ + - ]: 141 : if (!pRedline)
508 : 141 : return;
509 : :
510 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
511 : :
512 [ # # ]: 0 : if (pRedline->GetType() == nsRedlineType_t::REDLINE_INSERT)
513 : : {
514 : 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVISED);
515 : 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVAUTH);
516 : 0 : m_aRun->append((sal_Int32)m_rExport.GetRedline(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor())));
517 : 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVDTTM);
518 : : }
519 [ # # ]: 0 : else if(pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE)
520 : : {
521 : 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_DELETED);
522 : 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVAUTHDEL);
523 : 0 : m_aRun->append((sal_Int32)m_rExport.GetRedline(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor())));
524 : 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVDTTMDEL);
525 : : }
526 : 0 : m_aRun->append((sal_Int32)sw::ms::DateTime2DTTM(pRedline->GetTimeStamp()));
527 : 0 : m_aRun->append(' ');
528 : : }
529 : :
530 : 0 : void RtfAttributeOutput::FormatDrop( const SwTxtNode& /*rNode*/, const SwFmtDrop& /*rSwFmtDrop*/, sal_uInt16 /*nStyle*/, ww8::WW8TableNodeInfo::Pointer_t /*pTextNodeInfo*/, ww8::WW8TableNodeInfoInner::Pointer_t /*pTextNodeInfoInner*/ )
531 : : {
532 : : SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
533 : 0 : }
534 : :
535 : 126 : void RtfAttributeOutput::ParagraphStyle( sal_uInt16 nStyle )
536 : : {
537 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
538 : :
539 [ + - ]: 126 : OString *pStyle = m_rExport.GetStyle(nStyle);
540 : 126 : OStringBuffer aStyle;
541 [ + - ]: 126 : aStyle.append(OOO_STRING_SVTOOLS_RTF_S);
542 [ + - ]: 126 : aStyle.append((sal_Int32)nStyle);
543 [ + - ]: 126 : if (pStyle)
544 [ + - ]: 126 : aStyle.append(pStyle->getStr());
545 [ + - ]: 126 : if (!m_bBufferSectionHeaders)
546 [ + - ][ + - ]: 126 : m_rExport.Strm() << aStyle.makeStringAndClear().getStr();
547 : : else
548 [ # # ]: 126 : m_aSectionHeaders.append(aStyle.makeStringAndClear());
549 : 126 : }
550 : :
551 : 0 : void RtfAttributeOutput::TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
552 : : {
553 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
554 : :
555 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_INTBL);
556 [ # # ]: 0 : if ( m_nTableDepth > 1 )
557 : : {
558 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ITAP);
559 : 0 : m_aStyles.append((sal_Int32)m_nTableDepth);
560 : : }
561 : 0 : m_bWroteCellInfo = true;
562 : 0 : }
563 : :
564 : 0 : void RtfAttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfo*/ )
565 : : {
566 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
567 : :
568 : : /* noop */
569 : 0 : }
570 : :
571 : 0 : void RtfAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
572 : : {
573 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
574 : :
575 [ # # ]: 0 : if ( !m_pTableWrt )
576 [ # # ][ # # ]: 0 : InitTableHelper( pTableTextNodeInfoInner );
[ # # ]
577 : :
578 [ # # ]: 0 : const SwTable *pTbl = pTableTextNodeInfoInner->getTable();
579 : 0 : SwFrmFmt *pFmt = pTbl->GetFrmFmt( );
580 : :
581 [ # # ]: 0 : m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TROWD);
582 [ # # ][ # # ]: 0 : TableOrientation( pTableTextNodeInfoInner );
[ # # ]
583 [ # # ][ # # ]: 0 : TableBidi( pTableTextNodeInfoInner );
[ # # ]
584 [ # # ][ # # ]: 0 : TableHeight( pTableTextNodeInfoInner );
[ # # ]
585 [ # # ][ # # ]: 0 : TableCanSplit( pTableTextNodeInfoInner );
[ # # ]
586 : :
587 : : // Cell margins
588 [ # # ]: 0 : const SvxBoxItem& rBox = pFmt->GetBox( );
589 : : static const sal_uInt16 aBorders[] =
590 : : {
591 : : BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT
592 : : };
593 : :
594 : : static const char* aRowPadNames[] =
595 : : {
596 : : OOO_STRING_SVTOOLS_RTF_TRPADDT, OOO_STRING_SVTOOLS_RTF_TRPADDL, OOO_STRING_SVTOOLS_RTF_TRPADDB, OOO_STRING_SVTOOLS_RTF_TRPADDR
597 : : };
598 : :
599 : : static const char* aRowPadUnits[] =
600 : : {
601 : : OOO_STRING_SVTOOLS_RTF_TRPADDFT, OOO_STRING_SVTOOLS_RTF_TRPADDFL, OOO_STRING_SVTOOLS_RTF_TRPADDFB, OOO_STRING_SVTOOLS_RTF_TRPADDFR
602 : : };
603 : :
604 [ # # ]: 0 : for (int i = 0; i < 4; ++i)
605 : : {
606 [ # # ]: 0 : m_aRowDefs.append(aRowPadUnits[i]);
607 [ # # ]: 0 : m_aRowDefs.append((sal_Int32)3);
608 [ # # ]: 0 : m_aRowDefs.append(aRowPadNames[i]);
609 [ # # ][ # # ]: 0 : m_aRowDefs.append((sal_Int32)rBox.GetDistance(aBorders[i]));
610 : : }
611 : :
612 : : // The cell-dependent properties
613 : 0 : const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
614 [ # # ][ # # ]: 0 : SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
615 : 0 : SwTwips nSz = 0;
616 : 0 : Point aPt;
617 [ # # ]: 0 : SwRect aRect( pFmt->FindLayoutRect( false, &aPt ));
618 : 0 : SwTwips nPageSize = aRect.Width();
619 : :
620 : : // Handle the page size when not rendered
621 [ # # ]: 0 : if( 0 == nPageSize )
622 : : {
623 [ # # ]: 0 : const SwNode* pNode = pTableTextNodeInfoInner->getNode();
624 [ # # ][ # # ]: 0 : const SwFrmFmt* pFrmFmt = GetExport().mpParentFrame ? &GetExport().mpParentFrame->GetFrmFmt() :
625 [ # # ][ # # ]: 0 : GetExport().pDoc->GetPageDesc(0).GetPageFmtOfNode(*pNode, false);
[ # # ][ # # ]
626 : :
627 [ # # ]: 0 : const SvxLRSpaceItem& rLR = pFrmFmt->GetLRSpace();
628 [ # # ]: 0 : nPageSize = pFrmFmt->GetFrmSize().GetWidth() -
629 : 0 : rLR.GetLeft() - rLR.GetRight();
630 : : }
631 [ # # ]: 0 : SwTwips nTblSz = pFmt->GetFrmSize().GetWidth();
632 : : // Not using m_nTableDepth, which is not yet incremented here.
633 [ # # ]: 0 : sal_uInt32 nCurrentDepth = pTableTextNodeInfoInner->getDepth();
634 [ # # ]: 0 : m_aCells[nCurrentDepth] = pRow->GetCells().size();
635 [ # # ][ # # ]: 0 : for( sal_uInt16 i = 0; i < m_aCells[nCurrentDepth]; i++ )
636 : : {
637 [ # # ]: 0 : const SwWriteTableCell *pCell = &pRow->GetCells( )[ i ];
638 : 0 : const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
639 : :
640 [ # # ]: 0 : pTableTextNodeInfoInner->setCell( i );
641 [ # # ][ # # ]: 0 : TableCellProperties(pTableTextNodeInfoInner);
[ # # ]
642 : :
643 : : // Right boundary: this can't be in TableCellProperties as the old
644 : : // value of nSz is needed.
645 [ # # ]: 0 : nSz += pCellFmt->GetFrmSize().GetWidth();
646 [ # # ]: 0 : m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CELLX);
647 : 0 : SwTwips nCalc = nSz;
648 : 0 : nCalc *= nPageSize;
649 : 0 : nCalc /= nTblSz;
650 [ # # ][ # # ]: 0 : m_aRowDefs.append( (sal_Int32)(pFmt->GetLRSpace().GetLeft() + nCalc) );
651 : : }
652 : 0 : }
653 : :
654 : 0 : void RtfAttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
655 : : {
656 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
657 : :
658 : : /*
659 : : * The function name is a bit misleading: given that we write borders
660 : : * before each row, we just have borders, not default ones. Additionally,
661 : : * this function actually writes borders for a specific cell only and is
662 : : * called for each cell.
663 : : */
664 : :
665 [ # # ]: 0 : const SwTableBox *pTblBox = pTableTextNodeInfoInner->getTableBox( );
666 : 0 : SwFrmFmt *pFmt = pTblBox->GetFrmFmt( );
667 [ # # ]: 0 : const SvxBoxItem& rDefault = pFmt->GetBox( );
668 : 0 : const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
669 [ # # ][ # # ]: 0 : SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
670 [ # # ][ # # ]: 0 : const SwWriteTableCell *pCell = &pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ];
671 : 0 : const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
672 : : const SfxPoolItem* pItem;
673 [ # # ][ # # ]: 0 : if (pCellFmt->GetAttrSet().HasItem(RES_BOX, &pItem))
674 : : {
675 : 0 : const SvxBoxItem& rBox = (SvxBoxItem&)*pItem;
676 : : static const sal_uInt16 aBorders[] =
677 : : {
678 : : BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT
679 : : };
680 : : static const char* aBorderNames[] =
681 : : {
682 : : OOO_STRING_SVTOOLS_RTF_CLBRDRT, OOO_STRING_SVTOOLS_RTF_CLBRDRL, OOO_STRING_SVTOOLS_RTF_CLBRDRB, OOO_STRING_SVTOOLS_RTF_CLBRDRR
683 : : };
684 : : //Yes left and top are swapped with eachother for cell padding! Because
685 : : //that's what the thunderingly annoying rtf export/import word xp does.
686 : : static const char* aCellPadNames[] =
687 : : {
688 : : OOO_STRING_SVTOOLS_RTF_CLPADL, OOO_STRING_SVTOOLS_RTF_CLPADT, OOO_STRING_SVTOOLS_RTF_CLPADB, OOO_STRING_SVTOOLS_RTF_CLPADR
689 : : };
690 : : static const char* aCellPadUnits[] =
691 : : {
692 : : OOO_STRING_SVTOOLS_RTF_CLPADFL, OOO_STRING_SVTOOLS_RTF_CLPADFT, OOO_STRING_SVTOOLS_RTF_CLPADFB, OOO_STRING_SVTOOLS_RTF_CLPADFR
693 : : };
694 [ # # ]: 0 : for (int i = 0; i < 4; ++i)
695 : : {
696 [ # # ][ # # ]: 0 : if (const SvxBorderLine* pLn = rBox.GetLine(aBorders[i]))
697 [ # # ][ # # ]: 0 : m_aRowDefs.append(OutTBLBorderLine(m_rExport, pLn, aBorderNames[i]));
698 [ # # ][ # # ]: 0 : if (rDefault.GetDistance(aBorders[i]) !=
699 [ # # ]: 0 : rBox.GetDistance(aBorders[i]))
700 : : {
701 [ # # ]: 0 : m_aRowDefs.append(aCellPadUnits[i]);
702 [ # # ]: 0 : m_aRowDefs.append((sal_Int32)3);
703 [ # # ]: 0 : m_aRowDefs.append(aCellPadNames[i]);
704 [ # # ][ # # ]: 0 : m_aRowDefs.append((sal_Int32)rBox.GetDistance(aBorders[i]));
705 : : }
706 : : }
707 : : }
708 : 0 : }
709 : :
710 : 0 : void RtfAttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
711 : : {
712 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
713 : :
714 : 0 : const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
715 [ # # ][ # # ]: 0 : SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
716 [ # # ][ # # ]: 0 : const SwWriteTableCell *pCell = &pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ];
717 : 0 : const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
718 : : const SfxPoolItem* pItem;
719 [ # # ][ # # ]: 0 : if (pCellFmt->GetAttrSet().HasItem(RES_BACKGROUND, &pItem))
720 : : {
721 : 0 : const SvxBrushItem& rBack = (SvxBrushItem&)*pItem;
722 [ # # ]: 0 : if( !rBack.GetColor().GetTransparency() )
723 : : {
724 [ # # ]: 0 : m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLCBPAT);
725 [ # # ][ # # ]: 0 : m_aRowDefs.append((sal_Int32)m_rExport.GetColor(rBack.GetColor()));
726 : : }
727 : : }
728 : 0 : }
729 : :
730 : 0 : void RtfAttributeOutput::TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
731 : : {
732 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
733 : :
734 : 0 : const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
735 : 0 : const SwTableLine * pTabLine = pTabBox->GetUpper();
736 : 0 : const SwFrmFmt * pLineFmt = pTabLine->GetFrmFmt();
737 : 0 : const SwFmtFrmSize& rLSz = pLineFmt->GetFrmSize();
738 : :
739 [ # # ][ # # ]: 0 : if ( ATT_VAR_SIZE != rLSz.GetHeightSizeType() && rLSz.GetHeight() )
[ # # ]
740 : : {
741 : 0 : sal_Int32 nHeight = 0;
742 : :
743 [ # # # ]: 0 : switch ( rLSz.GetHeightSizeType() )
744 : : {
745 : 0 : case ATT_FIX_SIZE: nHeight = -rLSz.GetHeight(); break;
746 : 0 : case ATT_MIN_SIZE: nHeight = rLSz.GetHeight(); break;
747 : 0 : default: break;
748 : : }
749 : :
750 [ # # ]: 0 : if ( nHeight )
751 : : {
752 : 0 : m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TRRH);
753 : 0 : m_aRowDefs.append(nHeight);
754 : : }
755 : : }
756 : 0 : }
757 : :
758 : 0 : void RtfAttributeOutput::TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
759 : : {
760 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
761 : :
762 : 0 : const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
763 : 0 : const SwTableLine * pTabLine = pTabBox->GetUpper();
764 : 0 : const SwFrmFmt * pLineFmt = pTabLine->GetFrmFmt();
765 : 0 : const SwFmtRowSplit& rSplittable = pLineFmt->GetRowSplit( );
766 : :
767 : : // The rtf default is to allow a row to break
768 [ # # ]: 0 : if (rSplittable.GetValue() == 0)
769 : 0 : m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TRKEEP);
770 : 0 : }
771 : :
772 : 0 : void RtfAttributeOutput::TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
773 : : {
774 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
775 : :
776 : 0 : const SwTable * pTable = pTableTextNodeInfoInner->getTable();
777 : 0 : const SwFrmFmt * pFrmFmt = pTable->GetFrmFmt();
778 : :
779 [ # # ]: 0 : if ( m_rExport.TrueFrameDirection( *pFrmFmt ) != FRMDIR_HORI_RIGHT_TOP )
780 : 0 : m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_LTRROW);
781 : : else
782 : 0 : m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_RTLROW);
783 : 0 : }
784 : :
785 : 0 : void RtfAttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
786 : : {
787 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
788 : :
789 : 0 : const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
790 [ # # ][ # # ]: 0 : SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
791 [ # # ][ # # ]: 0 : const SwWriteTableCell *pCell = &pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ];
792 : 0 : const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
793 : : const SfxPoolItem* pItem;
794 : :
795 : : // vertical merges
796 [ # # ]: 0 : if (pCell->GetRowSpan() > 1)
797 [ # # ]: 0 : m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVMGF);
798 [ # # ]: 0 : else if (pCell->GetRowSpan() == 0)
799 [ # # ]: 0 : m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVMRG);
800 : :
801 : : // vertical alignment
802 [ # # ][ # # ]: 0 : if (pCellFmt->GetAttrSet().HasItem(RES_VERT_ORIENT, &pItem))
803 [ # # # ]: 0 : switch( ((SwFmtVertOrient*)pItem)->GetVertOrient() )
804 : : {
805 [ # # ]: 0 : case text::VertOrientation::CENTER: m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALC); break;
806 [ # # ]: 0 : case text::VertOrientation::BOTTOM: m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALB); break;
807 [ # # ]: 0 : default: m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALT); break;
808 : : }
809 : 0 : }
810 : :
811 : 0 : void RtfAttributeOutput::TableNodeInfo( ww8::WW8TableNodeInfo::Pointer_t /*pNodeInfo*/ )
812 : : {
813 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
814 : :
815 : : /* noop */
816 : 0 : }
817 : :
818 : 0 : void RtfAttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner )
819 : : {
820 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
821 : :
822 : : // This is called when the nested table ends in a cell, and there's no
823 : : // paragraph benhind that; so we must check for the ends of cell, rows,
824 : : // and tables
825 : : // ['true' to write an empty paragraph, MS Word insists on that]
826 [ # # ]: 0 : FinishTableRowCell( pNodeInfoInner, true );
827 : 0 : }
828 : :
829 : 0 : void RtfAttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
830 : : {
831 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
832 : :
833 [ # # ]: 0 : const SwTable *pTable = pTableTextNodeInfoInner->getTable();
834 : 0 : SwFrmFmt *pFmt = pTable->GetFrmFmt( );
835 : :
836 : 0 : OStringBuffer aTblAdjust( OOO_STRING_SVTOOLS_RTF_TRQL );
837 [ # # # # ]: 0 : switch (pFmt->GetHoriOrient().GetHoriOrient())
[ # # ]
838 : : {
839 : : case text::HoriOrientation::CENTER:
840 [ # # ]: 0 : aTblAdjust.setLength(0);
841 [ # # ]: 0 : aTblAdjust.append(OOO_STRING_SVTOOLS_RTF_TRQC);
842 : 0 : break;
843 : : case text::HoriOrientation::RIGHT:
844 [ # # ]: 0 : aTblAdjust.setLength(0);
845 [ # # ]: 0 : aTblAdjust.append(OOO_STRING_SVTOOLS_RTF_TRQR);
846 : 0 : break;
847 : : case text::HoriOrientation::NONE:
848 : : case text::HoriOrientation::LEFT_AND_WIDTH:
849 [ # # ]: 0 : aTblAdjust.append(OOO_STRING_SVTOOLS_RTF_TRLEFT);
850 [ # # ][ # # ]: 0 : aTblAdjust.append((sal_Int32)pFmt->GetLRSpace().GetLeft());
851 : 0 : break;
852 : : default:
853 : 0 : break;
854 : : }
855 : :
856 [ # # ]: 0 : m_aRowDefs.append(aTblAdjust.makeStringAndClear());
857 : 0 : }
858 : :
859 : 0 : void RtfAttributeOutput::TableSpacing( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
860 : : {
861 : : SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
862 : 0 : }
863 : :
864 : 0 : void RtfAttributeOutput::TableRowEnd( sal_uInt32 /*nDepth*/ )
865 : : {
866 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
867 : :
868 : : /* noop, see EndTableRow() */
869 : 0 : }
870 : :
871 : : /*
872 : : * Our private table methods.
873 : : */
874 : :
875 : 0 : void RtfAttributeOutput::InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
876 : : {
877 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
878 : :
879 : 0 : sal_uInt32 nPageSize = 0;
880 : 0 : bool bRelBoxSize = false;
881 : :
882 : : // Create the SwWriteTable instance to use col spans
883 [ # # ]: 0 : GetTablePageSize( pTableTextNodeInfoInner.get(), nPageSize, bRelBoxSize );
884 : :
885 [ # # ]: 0 : const SwTable* pTable = pTableTextNodeInfoInner->getTable( );
886 : 0 : const SwFrmFmt *pFmt = pTable->GetFrmFmt( );
887 [ # # ]: 0 : SwTwips nTblSz = pFmt->GetFrmSize( ).GetWidth( );
888 : :
889 : 0 : const SwHTMLTableLayout *pLayout = pTable->GetHTMLTableLayout();
890 [ # # ][ # # ]: 0 : if( pLayout && pLayout->IsExportable() )
[ # # ]
891 [ # # ][ # # ]: 0 : m_pTableWrt = new SwWriteTable( pLayout );
892 : : else
893 : : m_pTableWrt = new SwWriteTable( pTable->GetTabLines(), (sal_uInt16)nPageSize,
894 [ # # ][ # # ]: 0 : (sal_uInt16)nTblSz, false);
895 : 0 : }
896 : :
897 : 0 : void RtfAttributeOutput::StartTable( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
898 : : {
899 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
900 : :
901 : : // To trigger calling InitTableHelper()
902 [ # # ]: 0 : delete m_pTableWrt, m_pTableWrt = NULL;
903 : 0 : }
904 : :
905 : 0 : void RtfAttributeOutput::StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
906 : : {
907 [ # # ]: 0 : sal_uInt32 nCurrentDepth = pTableTextNodeInfoInner->getDepth();
908 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC << ", (depth is " << nCurrentDepth << ")");
909 : :
910 [ # # ][ # # ]: 0 : TableDefinition(pTableTextNodeInfoInner);
[ # # ]
911 : :
912 [ # # ]: 0 : SvtMiscOptions aMiscOptions;
913 [ # # ][ # # ]: 0 : if (aMiscOptions.IsExperimentalMode())
914 : : {
915 [ # # ]: 0 : m_aTables.push_back(m_aRowDefs.toString());
916 : : // Emit row properties at the start of the row as well for non-nested
917 : : // tables, to support old readers.
918 [ # # ]: 0 : if ( nCurrentDepth <= 1 )
919 [ # # ][ # # ]: 0 : m_rExport.Strm() << m_aRowDefs.makeStringAndClear().getStr();
920 [ # # ]: 0 : m_aRowDefs.setLength(0);
921 : : return;
922 : : }
923 : : else
924 : : {
925 [ # # ]: 0 : if (!m_bLastTable)
926 [ # # ]: 0 : m_aTables.push_back(m_aRowDefs.makeStringAndClear());
927 : :
928 : : // We'll write the table definition for nested tables later
929 [ # # ]: 0 : if ( nCurrentDepth > 1 )
930 : : return;
931 : : // Empty the previous row closing buffer before starting the new one,
932 : : // necessary for subtables.
933 [ # # ][ # # ]: 0 : m_rExport.Strm() << m_aAfterRuns.makeStringAndClear().getStr();
934 [ # # ][ # # ]: 0 : m_rExport.Strm() << m_aRowDefs.makeStringAndClear().getStr();
[ # # ]
935 [ # # ]: 0 : }
936 : : }
937 : :
938 : 0 : void RtfAttributeOutput::StartTableCell( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
939 : : {
940 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
941 : :
942 : 0 : m_bTableCellOpen = true;
943 : 0 : }
944 : :
945 : 0 : void RtfAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
946 : : {
947 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
948 : :
949 [ # # ]: 0 : TableDefaultBorders(pTableTextNodeInfoInner);
950 [ # # ]: 0 : TableBackgrounds(pTableTextNodeInfoInner);
951 [ # # ]: 0 : TableVerticalCell(pTableTextNodeInfoInner);
952 : 0 : }
953 : :
954 : 0 : void RtfAttributeOutput::EndTableCell( )
955 : : {
956 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC << ", (depth is " << m_nTableDepth << ")");
957 : :
958 [ # # ]: 0 : if (!m_bWroteCellInfo)
959 : : {
960 : 0 : m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_INTBL);
961 : 0 : m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_ITAP);
962 : 0 : m_aAfterRuns.append((sal_Int32)m_nTableDepth);
963 : : }
964 [ # # ]: 0 : if ( m_nTableDepth > 1 )
965 : 0 : m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_NESTCELL);
966 : : else
967 : 0 : m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_CELL);
968 : :
969 : 0 : m_bTableCellOpen = false;
970 : 0 : m_bTblAfterCell = true;
971 : 0 : m_bWroteCellInfo = false;
972 [ # # ]: 0 : if (m_aCells[m_nTableDepth] > 0)
973 : 0 : m_aCells[m_nTableDepth]--;
974 : 0 : }
975 : :
976 : 0 : void RtfAttributeOutput::EndTableRow( )
977 : : {
978 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC << ", (depth is " << m_nTableDepth << ")");
979 : :
980 : : // Trying to end the row without writing the required number of cells? Fill with empty ones.
981 [ # # ]: 0 : for( sal_uInt16 i = 0; i < m_aCells[m_nTableDepth]; i++ )
982 : 0 : m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_CELL);
983 : :
984 [ # # ]: 0 : if ( m_nTableDepth > 1 )
985 : : {
986 : 0 : m_aAfterRuns.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_NESTTABLEPROPRS);
987 [ # # ]: 0 : if (m_aRowDefs.getLength() > 0)
988 [ # # ]: 0 : m_aAfterRuns.append(m_aRowDefs.makeStringAndClear());
989 [ # # ]: 0 : else if (!m_aTables.empty())
990 : : {
991 : 0 : m_aAfterRuns.append(m_aTables.back());
992 : 0 : m_aTables.pop_back();
993 : : }
994 : 0 : m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_NESTROW "}" "{" OOO_STRING_SVTOOLS_RTF_NONESTTABLES OOO_STRING_SVTOOLS_RTF_PAR "}");
995 : : }
996 : : else
997 : : {
998 [ # # ]: 0 : if (!m_aTables.empty())
999 : : {
1000 : 0 : m_aAfterRuns.append(m_aTables.back());
1001 : 0 : m_aTables.pop_back();
1002 : : }
1003 : 0 : m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_ROW).append(OOO_STRING_SVTOOLS_RTF_PARD);
1004 : : }
1005 : 0 : m_bTableRowEnded = true;
1006 : 0 : }
1007 : :
1008 : 0 : void RtfAttributeOutput::EndTable()
1009 : : {
1010 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1011 : :
1012 [ # # ]: 0 : if ( m_nTableDepth > 0 ) {
1013 : 0 : m_nTableDepth--;
1014 [ # # ]: 0 : delete m_pTableWrt, m_pTableWrt = NULL;
1015 : : }
1016 : :
1017 : : // We closed the table; if it is a nested table, the cell that contains it
1018 : : // still continues
1019 : 0 : m_bTableCellOpen = true;
1020 : :
1021 : : // Cleans the table helper
1022 [ # # ]: 0 : delete m_pTableWrt, m_pTableWrt = NULL;
1023 : 0 : }
1024 : :
1025 : 126 : void RtfAttributeOutput::FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t pInner, bool /*bForceEmptyParagraph*/ )
1026 : : {
1027 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1028 : :
1029 [ - + ]: 126 : if ( pInner.get() )
1030 : : {
1031 : : // Where are we in the table
1032 : 0 : sal_uInt32 nRow = pInner->getRow( );
1033 : :
1034 : 0 : const SwTable *pTable = pInner->getTable( );
1035 : 0 : const SwTableLines& rLines = pTable->GetTabLines( );
1036 : 0 : sal_uInt16 nLinesCount = rLines.size( );
1037 : :
1038 [ # # ]: 0 : if ( pInner->isEndOfCell() )
1039 : 0 : EndTableCell();
1040 : :
1041 : : // This is a line end
1042 [ # # ]: 0 : if ( pInner->isEndOfLine() )
1043 : 0 : EndTableRow();
1044 : :
1045 : : // This is the end of the table
1046 [ # # ][ # # ]: 0 : if ( pInner->isEndOfLine( ) && ( nRow + 1 ) == nLinesCount )
[ # # ]
1047 : 0 : EndTable();
1048 : : }
1049 : 126 : }
1050 : :
1051 : 78 : void RtfAttributeOutput::StartStyles()
1052 : : {
1053 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1054 : 78 : m_rExport.Strm() << m_rExport.sNewLine << '{' << OOO_STRING_SVTOOLS_RTF_COLORTBL;
1055 : 78 : m_rExport.OutColorTable();
1056 : : OSL_ENSURE(m_aStylesheet.getLength() == 0, "m_aStylesheet is not empty");
1057 : 78 : m_aStylesheet.append(m_rExport.sNewLine);
1058 : 78 : m_aStylesheet.append('{');
1059 : 78 : m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_STYLESHEET);
1060 : 78 : }
1061 : :
1062 : 78 : void RtfAttributeOutput::EndStyles( sal_uInt16 /*nNumberOfStyles*/ )
1063 : : {
1064 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1065 : 78 : m_rExport.Strm() << '}';
1066 [ + - ][ + - ]: 78 : m_rExport.Strm() << m_aStylesheet.makeStringAndClear().getStr();
1067 : 78 : m_rExport.Strm() << '}';
1068 : 78 : }
1069 : :
1070 : 1092 : void RtfAttributeOutput::DefaultStyle( sal_uInt16 /*nStyle*/ )
1071 : : {
1072 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1073 : :
1074 : : /* noop, the default style is always 0 in RTF */
1075 : 1092 : }
1076 : :
1077 : 468 : void RtfAttributeOutput::StartStyle( const String& rName, bool bPapFmt,
1078 : : sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 /*nWwId*/, sal_uInt16 nId,
1079 : : bool /* bAutoUpdate */ )
1080 : : {
1081 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC << ", rName = '" << OUString(rName) << "'");
1082 : :
1083 : 468 : m_aStylesheet.append('{');
1084 [ + - ]: 468 : if (bPapFmt)
1085 : 468 : m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_S);
1086 : : else
1087 : 0 : m_aStylesheet.append( OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_CS);
1088 : 468 : m_aStylesheet.append( (sal_Int32)nId );
1089 : :
1090 [ + + ]: 468 : if ( nBase != 0x0FFF )
1091 : : {
1092 : 390 : m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_SBASEDON);
1093 : 390 : m_aStylesheet.append((sal_Int32)nBase);
1094 : : }
1095 : :
1096 : 468 : m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_SNEXT);
1097 : 468 : m_aStylesheet.append((sal_Int32)nNext);
1098 : :
1099 : 468 : m_rStyleName = rName;
1100 : 468 : m_nStyleId = nId;
1101 : 468 : }
1102 : :
1103 : 468 : void RtfAttributeOutput::EndStyle()
1104 : : {
1105 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1106 [ + - ]: 468 : m_aStyles.append(m_aStylesEnd.makeStringAndClear());
1107 : 468 : OString aStyles = m_aStyles.makeStringAndClear();
1108 [ + - ]: 468 : m_rExport.InsStyle(m_nStyleId, aStyles);
1109 [ + - ]: 468 : m_aStylesheet.append(aStyles);
1110 [ + - ]: 468 : m_aStylesheet.append(' ');
1111 [ + - ][ + - ]: 468 : m_aStylesheet.append(msfilter::rtfutil::OutString(m_rStyleName, m_rExport.eCurrentEncoding));
1112 [ + - ]: 468 : m_aStylesheet.append(";}");
1113 [ + - ]: 468 : m_aStylesheet.append(m_rExport.sNewLine);
1114 : 468 : }
1115 : :
1116 : 936 : void RtfAttributeOutput::StartStyleProperties( bool /*bParProp*/, sal_uInt16 /*nStyle*/ )
1117 : : {
1118 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1119 : : /* noop */
1120 : 936 : }
1121 : :
1122 : 936 : void RtfAttributeOutput::EndStyleProperties( bool /*bParProp*/ )
1123 : : {
1124 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1125 : : /* noop */
1126 : 936 : }
1127 : :
1128 : 0 : void RtfAttributeOutput::OutlineNumbering( sal_uInt8 nLvl, const SwNumFmt& /*rNFmt*/, const SwFmt& /*rFmt*/ )
1129 : : {
1130 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1131 : :
1132 [ # # ]: 0 : if ( nLvl >= WW8ListManager::nMaxLevel )
1133 : 0 : nLvl = WW8ListManager::nMaxLevel - 1;
1134 : :
1135 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ILVL);
1136 : 0 : m_aStyles.append((sal_Int32)nLvl);
1137 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_OUTLINELEVEL);
1138 : 0 : m_aStyles.append((sal_Int32)nLvl);
1139 : 0 : }
1140 : :
1141 : 0 : void RtfAttributeOutput::PageBreakBefore( bool bBreak )
1142 : : {
1143 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1144 : :
1145 [ # # ]: 0 : if (bBreak)
1146 : : {
1147 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_PAGEBB;
1148 : : }
1149 : 0 : }
1150 : :
1151 : 3 : void RtfAttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* pSectionInfo )
1152 : : {
1153 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1154 : :
1155 [ - + - ]: 3 : switch (nC)
1156 : : {
1157 : : case msword::ColumnBreak:
1158 : 0 : m_nColBreakNeeded = true;
1159 : 0 : break;
1160 : : case msword::PageBreak:
1161 [ + - ]: 3 : if ( pSectionInfo )
1162 : 3 : m_rExport.SectionProperties( *pSectionInfo );
1163 : 3 : break;
1164 : : }
1165 : 3 : }
1166 : :
1167 : 3 : void RtfAttributeOutput::StartSection()
1168 : : {
1169 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1170 : :
1171 : 3 : m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_SECT OOO_STRING_SVTOOLS_RTF_SECTD);
1172 [ - + ]: 3 : if (!m_bBufferSectionBreaks)
1173 [ # # ][ # # ]: 0 : m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear().getStr();
1174 : 3 : }
1175 : :
1176 : 3 : void RtfAttributeOutput::EndSection()
1177 : : {
1178 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1179 : :
1180 : : /*
1181 : : * noop, \sect must go to StartSection or Word won't notice multiple
1182 : : * columns...
1183 : : */
1184 : 3 : }
1185 : :
1186 : 3 : void RtfAttributeOutput::SectionFormProtection( bool bProtected )
1187 : : {
1188 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1189 : :
1190 : 3 : m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_SECTUNLOCKED);
1191 : 3 : m_aSectionBreaks.append((sal_Int32)!bProtected);
1192 : 3 : }
1193 : :
1194 : 0 : void RtfAttributeOutput::SectionLineNumbering( sal_uLong /*nRestartNo*/, const SwLineNumberInfo& rLnNumInfo )
1195 : : {
1196 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1197 : :
1198 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LINEMOD;
1199 : 0 : m_rExport.OutLong(rLnNumInfo.GetCountBy());
1200 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LINEX;
1201 : 0 : m_rExport.OutLong(rLnNumInfo.GetPosFromLeft());
1202 [ # # ]: 0 : if (!rLnNumInfo.IsRestartEachPage())
1203 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LINECONT;
1204 : 0 : }
1205 : :
1206 : 0 : void RtfAttributeOutput::SectionTitlePage()
1207 : : {
1208 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1209 : :
1210 : : /*
1211 : : * noop, handled in RtfExport::WriteHeaderFooter()
1212 : : */
1213 : 0 : }
1214 : :
1215 : 3 : void RtfAttributeOutput::SectionPageBorders( const SwFrmFmt* pFmt, const SwFrmFmt* /*pFirstPageFmt*/ )
1216 : : {
1217 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1218 : :
1219 : 3 : const SvxBoxItem& rBox = pFmt->GetBox();
1220 : 3 : const SvxBorderLine *pLine = rBox.GetTop();
1221 [ - + ]: 3 : if(pLine)
1222 : : m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
1223 : : OOO_STRING_SVTOOLS_RTF_PGBRDRT,
1224 [ # # ]: 0 : rBox.GetDistance(BOX_LINE_TOP) ));
1225 : 3 : pLine = rBox.GetBottom();
1226 [ - + ]: 3 : if(pLine)
1227 : : m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
1228 : : OOO_STRING_SVTOOLS_RTF_PGBRDRB,
1229 [ # # ]: 0 : rBox.GetDistance(BOX_LINE_BOTTOM) ));
1230 : 3 : pLine = rBox.GetLeft();
1231 [ - + ]: 3 : if(pLine)
1232 : : m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
1233 : : OOO_STRING_SVTOOLS_RTF_PGBRDRL,
1234 [ # # ]: 0 : rBox.GetDistance(BOX_LINE_LEFT) ));
1235 : 3 : pLine = rBox.GetRight();
1236 [ - + ]: 3 : if(pLine)
1237 : : m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
1238 : : OOO_STRING_SVTOOLS_RTF_PGBRDRR,
1239 [ # # ]: 0 : rBox.GetDistance(BOX_LINE_RIGHT) ));
1240 : 3 : }
1241 : :
1242 : 0 : void RtfAttributeOutput::SectionBiDi( bool bBiDi )
1243 : : {
1244 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1245 : :
1246 [ # # ]: 0 : m_rExport.Strm() << (bBiDi ? OOO_STRING_SVTOOLS_RTF_RTLSECT : OOO_STRING_SVTOOLS_RTF_LTRSECT);
1247 : 0 : }
1248 : :
1249 : 174 : void RtfAttributeOutput::SectionPageNumbering( sal_uInt16 nNumType, sal_uInt16 nPageRestartNumber )
1250 : : {
1251 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1252 : :
1253 [ - + ]: 174 : if (nPageRestartNumber > 0)
1254 : : {
1255 [ # # ]: 0 : m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGNSTARTS);
1256 [ # # ]: 0 : m_aSectionBreaks.append((sal_Int32)nPageRestartNumber);
1257 [ # # ]: 0 : m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGNRESTART);
1258 : : }
1259 : :
1260 : 174 : const char* pStr = 0;
1261 [ - - - - : 174 : switch ( nNumType )
+ - ]
1262 : : {
1263 : : case SVX_NUM_CHARS_UPPER_LETTER:
1264 : 0 : case SVX_NUM_CHARS_UPPER_LETTER_N: pStr = OOO_STRING_SVTOOLS_RTF_PGNUCLTR; break;
1265 : : case SVX_NUM_CHARS_LOWER_LETTER:
1266 : 0 : case SVX_NUM_CHARS_LOWER_LETTER_N: pStr = OOO_STRING_SVTOOLS_RTF_PGNLCLTR; break;
1267 : 0 : case SVX_NUM_ROMAN_UPPER: pStr = OOO_STRING_SVTOOLS_RTF_PGNUCRM; break;
1268 : 0 : case SVX_NUM_ROMAN_LOWER: pStr = OOO_STRING_SVTOOLS_RTF_PGNLCRM; break;
1269 : :
1270 : 174 : case SVX_NUM_ARABIC: pStr = OOO_STRING_SVTOOLS_RTF_PGNDEC; break;
1271 : : }
1272 [ + - ]: 174 : if (pStr)
1273 [ + - ]: 174 : m_aSectionBreaks.append(pStr);
1274 : 174 : }
1275 : :
1276 : 3 : void RtfAttributeOutput::SectionType( sal_uInt8 nBreakCode )
1277 : : {
1278 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC << ", nBreakCode = " << int(nBreakCode));
1279 : :
1280 : : /*
1281 : : * break code: 0 No break, 1 New column
1282 : : * 2 New page, 3 Even page, 4 Odd page
1283 : : */
1284 : 3 : const char* sType = NULL;
1285 [ - + - - : 3 : switch ( nBreakCode )
- ]
1286 : : {
1287 : 0 : case 1: sType = OOO_STRING_SVTOOLS_RTF_SBKCOL; break;
1288 : 3 : case 2: sType = OOO_STRING_SVTOOLS_RTF_SBKPAGE; break;
1289 : 0 : case 3: sType = OOO_STRING_SVTOOLS_RTF_SBKEVEN; break;
1290 : 0 : case 4: sType = OOO_STRING_SVTOOLS_RTF_SBKODD; break;
1291 : 0 : default: sType = OOO_STRING_SVTOOLS_RTF_SBKNONE; break;
1292 : : }
1293 [ + - ]: 3 : m_aSectionBreaks.append(sType);
1294 [ - + ]: 3 : if (!m_bBufferSectionBreaks)
1295 [ # # ][ # # ]: 0 : m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear().getStr();
1296 : 3 : }
1297 : :
1298 : 0 : void RtfAttributeOutput::NumberingDefinition( sal_uInt16 nId, const SwNumRule &/*rRule*/ )
1299 : : {
1300 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1301 : :
1302 : 0 : m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LISTOVERRIDE;
1303 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LISTID;
1304 : 0 : m_rExport.OutULong(nId);
1305 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LISTOVERRIDECOUNT << '0';
1306 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LS;
1307 : 0 : m_rExport.OutULong(nId) << '}';
1308 : 0 : }
1309 : :
1310 : 0 : void RtfAttributeOutput::StartAbstractNumbering( sal_uInt16 nId )
1311 : : {
1312 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1313 : :
1314 : 0 : m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LIST << OOO_STRING_SVTOOLS_RTF_LISTTEMPLATEID;
1315 : 0 : m_rExport.OutULong( nId );
1316 : 0 : m_nListId = nId;
1317 : 0 : }
1318 : :
1319 : 0 : void RtfAttributeOutput::EndAbstractNumbering()
1320 : : {
1321 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1322 : :
1323 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LISTID;
1324 : 0 : m_rExport.OutULong( m_nListId ) << '}' << m_rExport.sNewLine;
1325 : 0 : }
1326 : :
1327 : 0 : void RtfAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
1328 : : sal_uInt16 nStart,
1329 : : sal_uInt16 nNumberingType,
1330 : : SvxAdjust eAdjust,
1331 : : const sal_uInt8 * pNumLvlPos,
1332 : : sal_uInt8 nFollow,
1333 : : const wwFont * pFont,
1334 : : const SfxItemSet * pOutSet,
1335 : : sal_Int16 nIndentAt,
1336 : : sal_Int16 nFirstLineIndex,
1337 : : sal_Int16 /*nListTabPos*/,
1338 : : const String &rNumberingString )
1339 : : {
1340 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1341 : :
1342 : 0 : m_rExport.Strm() << m_rExport.sNewLine;
1343 [ # # ]: 0 : if( nLevel > 8 ) // RTF knows only 9 levels
1344 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_IGNORE << OOO_STRING_SVTOOLS_RTF_SOUTLVL;
1345 : :
1346 : 0 : m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LISTLEVEL;
1347 : :
1348 : 0 : sal_uInt16 nVal = 0;
1349 [ # # # # : 0 : switch( nNumberingType )
# # # ]
1350 : : {
1351 : 0 : case SVX_NUM_ROMAN_UPPER: nVal = 1; break;
1352 : 0 : case SVX_NUM_ROMAN_LOWER: nVal = 2; break;
1353 : : case SVX_NUM_CHARS_UPPER_LETTER:
1354 : 0 : case SVX_NUM_CHARS_UPPER_LETTER_N: nVal = 3; break;
1355 : : case SVX_NUM_CHARS_LOWER_LETTER:
1356 : 0 : case SVX_NUM_CHARS_LOWER_LETTER_N: nVal = 4; break;
1357 : :
1358 : : case SVX_NUM_BITMAP:
1359 : 0 : case SVX_NUM_CHAR_SPECIAL: nVal = 23; break;
1360 : 0 : case SVX_NUM_NUMBER_NONE: nVal = 255; break;
1361 : : }
1362 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELNFC;
1363 : 0 : m_rExport.OutULong( nVal );
1364 : :
1365 [ # # # ]: 0 : switch( eAdjust )
1366 : : {
1367 : 0 : case SVX_ADJUST_CENTER: nVal = 1; break;
1368 : 0 : case SVX_ADJUST_RIGHT: nVal = 2; break;
1369 : 0 : default: nVal = 0; break;
1370 : : }
1371 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELJC;
1372 : 0 : m_rExport.OutULong( nVal );
1373 : :
1374 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELSTARTAT;
1375 : 0 : m_rExport.OutULong( nStart );
1376 : :
1377 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELFOLLOW;
1378 : 0 : m_rExport.OutULong( nFollow );
1379 : :
1380 : : // leveltext group
1381 : 0 : m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LEVELTEXT << ' ';
1382 : :
1383 [ # # ][ # # ]: 0 : if( SVX_NUM_CHAR_SPECIAL == nNumberingType ||
1384 : : SVX_NUM_BITMAP == nNumberingType )
1385 : : {
1386 : 0 : m_rExport.Strm() << "\\'01";
1387 : 0 : sal_Unicode cChar = rNumberingString.GetChar(0);
1388 : 0 : m_rExport.Strm() << "\\u";
1389 : 0 : m_rExport.OutULong(cChar);
1390 : 0 : m_rExport.Strm() << " ?";
1391 : : }
1392 : : else
1393 : : {
1394 [ # # ][ # # ]: 0 : m_rExport.Strm() << "\\'" << msfilter::rtfutil::OutHex( rNumberingString.Len(), 2 ).getStr();
[ # # ]
1395 [ # # ][ # # ]: 0 : m_rExport.Strm() << msfilter::rtfutil::OutString( rNumberingString, m_rExport.eDefaultEncoding ).getStr();
1396 : : }
1397 : :
1398 : 0 : m_rExport.Strm() << ";}";
1399 : :
1400 : : // write the levelnumbers
1401 : 0 : m_rExport.Strm() << "{" << OOO_STRING_SVTOOLS_RTF_LEVELNUMBERS;
1402 [ # # ][ # # ]: 0 : for( sal_uInt8 i = 0; i <= nLevel && pNumLvlPos[ i ]; ++i )
[ # # ]
1403 : : {
1404 [ # # ][ # # ]: 0 : m_rExport.Strm() << "\\'" << msfilter::rtfutil::OutHex(pNumLvlPos[ i ], 2).getStr();
[ # # ]
1405 : : }
1406 : 0 : m_rExport.Strm() << ";}";
1407 : :
1408 [ # # ]: 0 : if( pOutSet )
1409 : : {
1410 [ # # ]: 0 : if (pFont)
1411 : : {
1412 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_F;
1413 : 0 : m_rExport.OutULong(m_rExport.maFontHelper.GetId(*pFont));
1414 : : }
1415 : 0 : m_rExport.OutputItemSet( *pOutSet, false, true, i18n::ScriptType::LATIN, m_rExport.mbExportModeRTF );
1416 [ # # ][ # # ]: 0 : m_rExport.Strm() << m_aStyles.makeStringAndClear().getStr();
1417 : : }
1418 : :
1419 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_FI;
1420 : 0 : m_rExport.OutLong( nFirstLineIndex ) << OOO_STRING_SVTOOLS_RTF_LI;
1421 : 0 : m_rExport.OutLong( nIndentAt );
1422 : :
1423 : 0 : m_rExport.Strm() << '}';
1424 [ # # ]: 0 : if( nLevel > 8 )
1425 : 0 : m_rExport.Strm() << '}';
1426 : 0 : }
1427 : :
1428 : 0 : void RtfAttributeOutput::WriteField_Impl( const SwField* pFld, ww::eField /*eType*/, const String& rFldCmd, sal_uInt8 /*nMode*/ )
1429 : : {
1430 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1431 : :
1432 : : // If there are no field instructions, don't export it as a field.
1433 : 0 : bool bHasInstructions = rFldCmd.Len() > 0;
1434 [ # # ]: 0 : if (bHasInstructions)
1435 : : {
1436 : 0 : m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_FIELD);
1437 : 0 : m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FLDINST " ");
1438 [ # # ][ # # ]: 0 : m_aRunText->append(msfilter::rtfutil::OutString(rFldCmd, m_rExport.eCurrentEncoding));
1439 : 0 : m_aRunText->append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
1440 : : }
1441 [ # # ]: 0 : if (pFld)
1442 [ # # ][ # # ]: 0 : m_aRunText->append(msfilter::rtfutil::OutString(pFld->ExpandField(true), m_rExport.eDefaultEncoding));
[ # # ]
1443 [ # # ]: 0 : if (bHasInstructions)
1444 : 0 : m_aRunText->append("}}");
1445 : 0 : }
1446 : :
1447 : 267 : void RtfAttributeOutput::WriteBookmarks_Impl( std::vector< rtl::OUString >& rStarts, std::vector< rtl::OUString >& rEnds )
1448 : : {
1449 [ + - ][ + - ]: 267 : for ( std::vector< OUString >::const_iterator it = rStarts.begin(), end = rStarts.end(); it != end; ++it )
[ + - ][ - + ]
1450 : : {
1451 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKSTART " ");
1452 [ # # ][ # # ]: 0 : m_aRun->append(msfilter::rtfutil::OutString(*it, m_rExport.eCurrentEncoding));
[ # # ][ # # ]
[ # # ]
1453 [ # # ][ # # ]: 0 : m_aRun->append('}');
1454 : : }
1455 : 267 : rStarts.clear();
1456 : :
1457 [ + - ][ + - ]: 267 : for ( std::vector< OUString >::const_iterator it = rEnds.begin(), end = rEnds.end(); it != end; ++it )
[ - + ][ + - ]
1458 : : {
1459 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKEND " ");
1460 [ # # ][ # # ]: 0 : m_aRun->append(msfilter::rtfutil::OutString(*it, m_rExport.eCurrentEncoding));
[ # # ][ # # ]
[ # # ]
1461 [ # # ][ # # ]: 0 : m_aRun->append('}');
1462 : : }
1463 : 267 : rEnds.clear();
1464 : 267 : }
1465 : :
1466 : 0 : void RtfAttributeOutput::WriteHeaderFooter_Impl( const SwFrmFmt& rFmt, bool bHeader, const sal_Char* pStr, bool bTitlepg )
1467 : : {
1468 [ # # ]: 0 : OStringBuffer aSectionBreaks = m_aSectionBreaks;
1469 [ # # ]: 0 : m_aSectionBreaks.setLength(0);
1470 [ # # ]: 0 : RtfStringBuffer aRun = m_aRun;
1471 [ # # ]: 0 : m_aRun.clear();
1472 : :
1473 [ # # ][ # # ]: 0 : m_aSectionHeaders.append(bHeader ? OOO_STRING_SVTOOLS_RTF_HEADERY : OOO_STRING_SVTOOLS_RTF_FOOTERY);
1474 [ # # ][ # # ]: 0 : m_aSectionHeaders.append((sal_Int32)m_rExport.pAktPageDesc->GetMaster().GetULSpace().GetUpper());
1475 [ # # ]: 0 : if (bTitlepg)
1476 [ # # ]: 0 : m_aSectionHeaders.append(OOO_STRING_SVTOOLS_RTF_TITLEPG);
1477 [ # # ]: 0 : m_aSectionHeaders.append('{');
1478 [ # # ]: 0 : m_aSectionHeaders.append(pStr);
1479 : 0 : m_bBufferSectionHeaders = true;
1480 [ # # ]: 0 : m_rExport.WriteHeaderFooterText(rFmt, bHeader);
1481 : 0 : m_bBufferSectionHeaders = false;
1482 [ # # ]: 0 : m_aSectionHeaders.append('}');
1483 : :
1484 [ # # ]: 0 : m_aSectionBreaks = aSectionBreaks;
1485 [ # # ]: 0 : m_aRun = aRun;
1486 : 0 : }
1487 : :
1488 : 90 : void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Point& /*rNdTopLeft*/ )
1489 : : {
1490 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1491 : :
1492 : 90 : const SwNode *pNode = rFrame.GetContent();
1493 [ + + ]: 90 : const SwGrfNode *pGrfNode = pNode ? pNode->GetGrfNode() : 0;
1494 : :
1495 [ - - + - : 90 : switch ( rFrame.GetWriterType() )
+ - ]
1496 : : {
1497 : : case sw::Frame::eTxtBox:
1498 : : OSL_ENSURE(m_aRunText.getLength() == 0, "m_aRunText is not empty");
1499 : 0 : m_rExport.mpParentFrame = &rFrame;
1500 : 0 : m_rExport.bOutFlyFrmAttrs = m_rExport.bRTFFlySyntax = true;
1501 : 0 : m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
1502 [ # # ][ # # ]: 0 : m_rExport.Strm() << m_aRunText.makeStringAndClear().getStr();
1503 [ # # ][ # # ]: 0 : m_rExport.Strm() << m_aStyles.makeStringAndClear().getStr();
1504 : 0 : m_rExport.bOutFlyFrmAttrs = m_rExport.bRTFFlySyntax = false;
1505 : 0 : m_rExport.Strm() << "{" OOO_STRING_SVTOOLS_RTF_IGNORE;
1506 : 0 : m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
1507 [ # # ][ # # ]: 0 : m_rExport.Strm() << m_aRunText.makeStringAndClear().getStr();
1508 [ # # ][ # # ]: 0 : m_rExport.Strm() << m_aStyles.makeStringAndClear().getStr();
1509 : 0 : m_rExport.Strm() << '}';
1510 : :
1511 : : {
1512 : : /*
1513 : : * Save m_aRun as we should not loose the opening brace.
1514 : : * OTOH, just drop the contents of m_aRunText in case something
1515 : : * would be there, causing a problem later.
1516 : : */
1517 [ # # ]: 0 : OString aSave = m_aRun.makeStringAndClear();
1518 : 0 : m_rExport.bRTFFlySyntax = true;
1519 : :
1520 : 0 : const SwFrmFmt& rFrmFmt = rFrame.GetFrmFmt( );
1521 [ # # ]: 0 : const SwNodeIndex* pNodeIndex = rFrmFmt.GetCntnt().GetCntntIdx();
1522 [ # # ]: 0 : sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex()+1 : 0;
1523 [ # # ]: 0 : sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0;
1524 [ # # ]: 0 : m_rExport.SaveData( nStt, nEnd );
1525 : 0 : m_rExport.mpParentFrame = &rFrame;
1526 [ # # ]: 0 : m_rExport.WriteText( );
1527 [ # # ]: 0 : m_rExport.RestoreData();
1528 : :
1529 [ # # ][ # # ]: 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_PARD;
1530 : 0 : m_rExport.bRTFFlySyntax = false;
1531 [ # # ][ # # ]: 0 : m_aRun->append(aSave);
1532 [ # # ]: 0 : m_aRunText.clear();
1533 : : }
1534 : :
1535 : 0 : m_rExport.mpParentFrame = NULL;
1536 : 0 : m_rExport.Strm() << RtfExport::sNewLine;
1537 : 0 : break;
1538 : : case sw::Frame::eGraphic:
1539 [ # # ]: 0 : if (!rFrame.IsInline())
1540 : : {
1541 : 0 : m_rExport.mpParentFrame = &rFrame;
1542 : 0 : m_rExport.bRTFFlySyntax = true;
1543 : 0 : m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
1544 : 0 : m_rExport.bRTFFlySyntax = false;
1545 : 0 : m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE);
1546 : 0 : m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
1547 : 0 : m_aRunText->append('}');
1548 : 0 : m_rExport.mpParentFrame = NULL;
1549 : : }
1550 : :
1551 [ # # ]: 0 : if ( pGrfNode )
1552 [ # # ]: 0 : m_aRunText.append(dynamic_cast<const SwFlyFrmFmt*>( &rFrame.GetFrmFmt() ), pGrfNode);
1553 : 0 : break;
1554 : : case sw::Frame::eDrawing:
1555 : : {
1556 : 3 : const SdrObject* pSdrObj = rFrame.GetFrmFmt().FindRealSdrObject();
1557 [ + - ]: 3 : if ( pSdrObj )
1558 : : {
1559 : 3 : bool bSwapInPage = false;
1560 [ - + ]: 3 : if ( !pSdrObj->GetPage() )
1561 : : {
1562 [ # # ]: 0 : if ( SdrModel* pModel = m_rExport.pDoc->GetDrawModel() )
1563 : : {
1564 [ # # ]: 0 : if ( SdrPage *pPage = pModel->GetPage( 0 ) )
1565 : : {
1566 : 0 : bSwapInPage = true;
1567 : 0 : const_cast< SdrObject* >( pSdrObj )->SetPage( pPage );
1568 : : }
1569 : : }
1570 : : }
1571 : :
1572 : 3 : m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_FIELD "{");
1573 : 3 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_IGNORE);
1574 : 3 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLDINST);
1575 : 3 : m_aRunText->append(" SHAPE ");
1576 : 3 : m_aRunText->append("}" "{" OOO_STRING_SVTOOLS_RTF_FLDRSLT);
1577 : :
1578 : 3 : m_rExport.SdrExporter().AddSdrObject( *pSdrObj );
1579 : :
1580 : 3 : m_aRunText->append('}');
1581 : 3 : m_aRunText->append('}');
1582 : :
1583 [ - + ]: 3 : if ( bSwapInPage )
1584 : 0 : const_cast< SdrObject* >( pSdrObj )->SetPage( 0 );
1585 : : }
1586 : : }
1587 : 3 : break;
1588 : : case sw::Frame::eFormControl:
1589 : : {
1590 : 0 : const SwFrmFmt &rFrmFmt = rFrame.GetFrmFmt();
1591 : 0 : const SdrObject *pObject = rFrmFmt.FindRealSdrObject();
1592 : :
1593 : 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_FIELD);
1594 : 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FLDINST);
1595 : :
1596 [ # # ][ # # ]: 0 : if (pObject && pObject->GetObjInventor() == FmFormInventor)
[ # # ]
1597 : : {
1598 [ # # ][ # # ]: 0 : if (SdrUnoObj *pFormObj = PTR_CAST(SdrUnoObj,pObject))
[ # # ]
1599 : : {
1600 : : uno::Reference< awt::XControlModel > xControlModel =
1601 [ # # ]: 0 : pFormObj->GetUnoControlModel();
1602 [ # # ]: 0 : uno::Reference< lang::XServiceInfo > xInfo(xControlModel, uno::UNO_QUERY);
1603 [ # # ]: 0 : uno::Reference<beans::XPropertySet> xPropSet(xControlModel, uno::UNO_QUERY);
1604 [ # # ][ # # ]: 0 : uno::Reference<beans::XPropertySetInfo> xPropSetInfo = xPropSet->getPropertySetInfo();
1605 : 0 : OUString sName;
1606 [ # # ][ # # ]: 0 : if (xInfo->supportsService("com.sun.star.form.component.CheckBox"))
[ # # ]
1607 : : {
1608 : :
1609 [ # # ][ # # ]: 0 : m_aRun->append(OUStringToOString(OUString(FieldString(ww::eFORMCHECKBOX)), m_rExport.eCurrentEncoding));
[ # # ][ # # ]
[ # # ][ # # ]
1610 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
1611 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFTYPE "1"); // 1 = checkbox
1612 : : // checkbox size in half points, this seems to be always 20, see WW8Export::DoCheckBox()
1613 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFHPS "20");
1614 : :
1615 : 0 : OUString aStr;
1616 : 0 : sName = "Name";
1617 [ # # ][ # # ]: 0 : if (xPropSetInfo->hasPropertyByName(sName))
[ # # ]
1618 : : {
1619 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(sName) >>= aStr;
1620 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFNAME " ");
1621 [ # # ][ # # ]: 0 : m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
[ # # ]
1622 [ # # ][ # # ]: 0 : m_aRun->append('}');
1623 : : }
1624 : :
1625 : 0 : sName = "HelpText";
1626 [ # # ][ # # ]: 0 : if (xPropSetInfo->hasPropertyByName(sName))
[ # # ]
1627 : : {
1628 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(sName) >>= aStr;
1629 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
1630 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
1631 [ # # ][ # # ]: 0 : m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
[ # # ]
1632 [ # # ][ # # ]: 0 : m_aRun->append('}');
1633 : : }
1634 : :
1635 : 0 : sName = "HelpF1Text";
1636 [ # # ][ # # ]: 0 : if (xPropSetInfo->hasPropertyByName(sName))
[ # # ]
1637 : : {
1638 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(sName) >>= aStr;
1639 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
1640 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
1641 [ # # ][ # # ]: 0 : m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
[ # # ]
1642 [ # # ][ # # ]: 0 : m_aRun->append('}');
1643 : : }
1644 : :
1645 : 0 : sal_Int16 nTemp = 0;
1646 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue("DefaultState") >>= nTemp;
1647 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFDEFRES);
1648 [ # # ][ # # ]: 0 : m_aRun->append((sal_Int32)nTemp);
1649 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue("State") >>= nTemp;
1650 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFRES);
1651 [ # # ][ # # ]: 0 : m_aRun->append((sal_Int32)nTemp);
1652 : :
1653 [ # # ][ # # ]: 0 : m_aRun->append("}}");
1654 : :
1655 : : // field result is empty, ffres already contains the form result
1656 [ # # ][ # # ]: 0 : m_aRun->append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
1657 : : }
1658 [ # # ][ # # ]: 0 : else if (xInfo->supportsService("com.sun.star.form.component.TextField"))
[ # # ]
1659 : : {
1660 : 0 : OStringBuffer aBuf;
1661 : 0 : OString aStr;
1662 : 0 : OUString aTmp;
1663 : : const sal_Char* pStr;
1664 : :
1665 [ # # ][ # # ]: 0 : m_aRun->append(OUStringToOString(OUString(FieldString(ww::eFORMTEXT)), m_rExport.eCurrentEncoding));
[ # # ][ # # ]
[ # # ][ # # ]
1666 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_DATAFIELD " ");
1667 [ # # ][ # # ]: 0 : for (int i = 0; i < 8; i++) aBuf.append((sal_Char)0x00);
1668 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue("Name") >>= aTmp;
1669 [ # # ]: 0 : aStr = OUStringToOString(aTmp, m_rExport.eCurrentEncoding);
1670 [ # # ]: 0 : aBuf.append((sal_Char)aStr.getLength());
1671 [ # # ]: 0 : aBuf.append(aStr);
1672 [ # # ]: 0 : aBuf.append((sal_Char)0x00);
1673 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue("DefaultText") >>= aTmp;
1674 [ # # ]: 0 : aStr = OUStringToOString(aTmp, m_rExport.eCurrentEncoding);
1675 [ # # ]: 0 : aBuf.append((sal_Char)aStr.getLength());
1676 [ # # ]: 0 : aBuf.append(aStr);
1677 [ # # ][ # # ]: 0 : for (int i = 0; i < 11; i++) aBuf.append((sal_Char)0x00);
1678 : 0 : aStr = aBuf.makeStringAndClear();
1679 : 0 : pStr = aStr.getStr();
1680 [ # # ]: 0 : for (int i = 0; i < aStr.getLength(); i++, pStr++)
1681 [ # # ][ # # ]: 0 : m_aRun->append(msfilter::rtfutil::OutHex(*pStr, 2));
[ # # ]
1682 [ # # ][ # # ]: 0 : m_aRun->append('}');
1683 [ # # ][ # # ]: 0 : m_aRun->append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
1684 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue("Text") >>= aTmp;
1685 [ # # ][ # # ]: 0 : m_aRun->append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
[ # # ]
1686 [ # # ][ # # ]: 0 : m_aRun->append('}');
1687 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
1688 : 0 : sName = "HelpText";
1689 [ # # ][ # # ]: 0 : if (xPropSetInfo->hasPropertyByName(sName))
[ # # ]
1690 : : {
1691 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(sName) >>= aTmp;
1692 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
1693 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
1694 [ # # ][ # # ]: 0 : m_aRun->append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
[ # # ]
1695 [ # # ][ # # ]: 0 : m_aRun->append('}');
1696 : : }
1697 : :
1698 : 0 : sName = "HelpF1Text";
1699 [ # # ][ # # ]: 0 : if (xPropSetInfo->hasPropertyByName(sName))
[ # # ]
1700 : : {
1701 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(sName) >>= aTmp;
1702 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
1703 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
1704 [ # # ][ # # ]: 0 : m_aRun->append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
[ # # ]
1705 [ # # ][ # # ]: 0 : m_aRun->append('}');
1706 : : }
1707 [ # # ][ # # ]: 0 : m_aRun->append("}");
1708 : : }
1709 [ # # ][ # # ]: 0 : else if (xInfo->supportsService("com.sun.star.form.component.ListBox"))
[ # # ]
1710 : : {
1711 : 0 : OUString aStr;
1712 [ # # ]: 0 : uno::Sequence<sal_Int16> aIntSeq;
1713 [ # # ]: 0 : uno::Sequence<OUString> aStrSeq;
1714 : :
1715 [ # # ][ # # ]: 0 : m_aRun->append(OUStringToOString(OUString(FieldString(ww::eFORMDROPDOWN)), m_rExport.eCurrentEncoding));
[ # # ][ # # ]
[ # # ][ # # ]
1716 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
1717 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFTYPE "2"); // 2 = list
1718 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFHASLISTBOX);
1719 : :
1720 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue("DefaultSelection") >>= aIntSeq;
[ # # ]
1721 [ # # ]: 0 : if( aIntSeq.getLength() )
1722 : : {
1723 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFDEFRES);
1724 : : // a dropdown list can have only one 'selected item by default'
1725 [ # # ][ # # ]: 0 : m_aRun->append((sal_Int32)aIntSeq[0]);
[ # # ]
1726 : : }
1727 : :
1728 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue("SelectedItems") >>= aIntSeq;
[ # # ]
1729 [ # # ]: 0 : if( aIntSeq.getLength() )
1730 : : {
1731 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFRES);
1732 : : // a dropdown list can have only one 'currently selected item'
1733 [ # # ][ # # ]: 0 : m_aRun->append((sal_Int32)aIntSeq[0]);
[ # # ]
1734 : : }
1735 : :
1736 : 0 : sName = "Name";
1737 [ # # ][ # # ]: 0 : if (xPropSetInfo->hasPropertyByName(sName))
[ # # ]
1738 : : {
1739 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(sName) >>= aStr;
1740 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFNAME " ");
1741 [ # # ][ # # ]: 0 : m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
[ # # ]
1742 [ # # ][ # # ]: 0 : m_aRun->append('}');
1743 : : }
1744 : :
1745 : 0 : sName = "HelpText";
1746 [ # # ][ # # ]: 0 : if (xPropSetInfo->hasPropertyByName(sName))
[ # # ]
1747 : : {
1748 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(sName) >>= aStr;
1749 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
1750 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
1751 [ # # ][ # # ]: 0 : m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
[ # # ]
1752 [ # # ][ # # ]: 0 : m_aRun->append('}');
1753 : : }
1754 : :
1755 : 0 : sName = "HelpF1Text";
1756 [ # # ][ # # ]: 0 : if (xPropSetInfo->hasPropertyByName(sName))
[ # # ]
1757 : : {
1758 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(sName) >>= aStr;
1759 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
1760 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
1761 [ # # ][ # # ]: 0 : m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
[ # # ]
1762 [ # # ][ # # ]: 0 : m_aRun->append('}');
1763 : : }
1764 : :
1765 : :
1766 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue("StringItemList") >>= aStrSeq;
[ # # ]
1767 : 0 : sal_uInt32 nListItems = aStrSeq.getLength();
1768 [ # # ]: 0 : for (sal_uInt32 i = 0; i < nListItems; i++)
1769 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFL " ")
1770 [ # # ][ # # ]: 0 : .append(OUStringToOString(aStrSeq[i], m_rExport.eCurrentEncoding)).append('}');
[ # # ][ # # ]
1771 : :
1772 [ # # ][ # # ]: 0 : m_aRun->append("}}");
1773 : :
1774 : : // field result is empty, ffres already contains the form result
1775 [ # # ][ # # ]: 0 : m_aRun->append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
[ # # ][ # # ]
1776 : : }
1777 : : else
1778 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC << " unhandled form control: '" << xInfo->getImplementationName()<< "'");
1779 [ # # ][ # # ]: 0 : m_aRun->append('}');
1780 : : }
1781 : : }
1782 : :
1783 : 0 : m_aRun->append('}');
1784 : : }
1785 : 0 : break;
1786 : : case sw::Frame::eOle:
1787 : : {
1788 : 87 : const SwFrmFmt &rFrmFmt = rFrame.GetFrmFmt();
1789 : 87 : const SdrObject *pSdrObj = rFrmFmt.FindRealSdrObject();
1790 [ + - ]: 87 : if ( pSdrObj )
1791 : : {
1792 [ + - ][ + - ]: 87 : SwNodeIndex aIdx(*rFrmFmt.GetCntnt().GetCntntIdx(), 1);
1793 : 87 : SwOLENode& rOLENd = *aIdx.GetNode().GetOLENode();
1794 [ + - ][ + - ]: 87 : FlyFrameOLE(dynamic_cast<const SwFlyFrmFmt*>( &rFrmFmt ), rOLENd, rFrame.GetLayoutSize());
[ - + ]
1795 : : }
1796 : : }
1797 : 87 : break;
1798 : : default:
1799 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC << ": unknown type (" << (int)rFrame.GetWriterType() << ")");
1800 : 0 : break;
1801 : : }
1802 : 90 : }
1803 : :
1804 : 0 : void RtfAttributeOutput::CharCaseMap( const SvxCaseMapItem& rCaseMap )
1805 : : {
1806 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1807 : :
1808 [ # # # ]: 0 : switch ( rCaseMap.GetValue() )
1809 : : {
1810 : : case SVX_CASEMAP_KAPITAELCHEN:
1811 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SCAPS);
1812 : 0 : break;
1813 : : case SVX_CASEMAP_VERSALIEN:
1814 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CAPS);
1815 : 0 : break;
1816 : : default: // Something that rtf does not support
1817 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SCAPS);
1818 : 0 : m_aStyles.append((sal_Int32)0);
1819 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CAPS);
1820 : 0 : m_aStyles.append((sal_Int32)0);
1821 : 0 : break;
1822 : : }
1823 : 0 : }
1824 : :
1825 : 78 : void RtfAttributeOutput::CharColor( const SvxColorItem& rColor )
1826 : : {
1827 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1828 : :
1829 : 78 : const Color aColor( rColor.GetValue() );
1830 : :
1831 [ + - ]: 78 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CF);
1832 [ + - ][ + - ]: 78 : m_aStyles.append( (sal_Int32)m_rExport.GetColor( aColor ));
1833 : 78 : }
1834 : :
1835 : 0 : void RtfAttributeOutput::CharContour( const SvxContourItem& rContour )
1836 : : {
1837 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1838 : :
1839 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_OUTL);
1840 [ # # ]: 0 : if ( !rContour.GetValue() )
1841 : 0 : m_aStyles.append((sal_Int32)0);
1842 : 0 : }
1843 : :
1844 : 0 : void RtfAttributeOutput::CharCrossedOut( const SvxCrossedOutItem& rCrossedOut )
1845 : : {
1846 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1847 : :
1848 [ # # # ]: 0 : switch ( rCrossedOut.GetStrikeout() )
1849 : : {
1850 : : case STRIKEOUT_NONE:
1851 [ # # ]: 0 : if (!m_bStrikeDouble)
1852 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKE);
1853 : : else
1854 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKED);
1855 : 0 : m_aStyles.append((sal_Int32)0);
1856 : 0 : break;
1857 : : case STRIKEOUT_DOUBLE:
1858 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKED);
1859 : 0 : m_aStyles.append((sal_Int32)1);
1860 : 0 : break;
1861 : : default:
1862 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKE);
1863 : 0 : break;
1864 : : }
1865 : 0 : }
1866 : :
1867 : 0 : void RtfAttributeOutput::CharEscapement( const SvxEscapementItem& rEsc )
1868 : : {
1869 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1870 : :
1871 : : const char * pUpDn;
1872 : :
1873 [ # # ]: 0 : SwTwips nH = ((SvxFontHeightItem&)m_rExport.GetItem( RES_CHRATR_FONTSIZE )).GetHeight();
1874 : :
1875 [ # # ]: 0 : if( 0 < rEsc.GetEsc() )
1876 : 0 : pUpDn = OOO_STRING_SVTOOLS_RTF_UP;
1877 [ # # ]: 0 : else if( 0 > rEsc.GetEsc() )
1878 : : {
1879 : 0 : pUpDn = OOO_STRING_SVTOOLS_RTF_DN;
1880 : 0 : nH = -nH;
1881 : : }
1882 : : else
1883 : 0 : return;
1884 : :
1885 : 0 : short nEsc = rEsc.GetEsc();
1886 : 0 : short nProp = rEsc.GetProp() * 100;
1887 [ # # ]: 0 : if( DFLT_ESC_AUTO_SUPER == nEsc )
1888 : : {
1889 : 0 : nEsc = 100 - rEsc.GetProp();
1890 : 0 : ++nProp;
1891 : : }
1892 [ # # ]: 0 : else if( DFLT_ESC_AUTO_SUB == nEsc )
1893 : : {
1894 : 0 : nEsc = - 100 + rEsc.GetProp();
1895 : 0 : ++nProp;
1896 : : }
1897 : :
1898 [ # # ]: 0 : m_aStyles.append('{');
1899 [ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE);
1900 [ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_UPDNPROP);
1901 [ # # ]: 0 : m_aStyles.append( (sal_Int32)nProp );
1902 [ # # ]: 0 : m_aStyles.append('}');
1903 [ # # ]: 0 : m_aStyles.append(pUpDn);
1904 : :
1905 : : /*
1906 : : * Calculate the act. FontSize and the percentage of the displacement;
1907 : : * RTF file expects half points, while internally it's in twips.
1908 : : * Formally : (FontSize * 1/20 ) pts x * 2
1909 : : * ----------------------- = ------------
1910 : : * 100% Escapement
1911 : : */
1912 : :
1913 [ # # ]: 0 : m_aStyles.append( (sal_Int32) ( (long( nEsc ) * nH) + 500L ) / 1000L );
1914 : : // 500L to round !!
1915 : : }
1916 : :
1917 : 378 : void RtfAttributeOutput::CharFont( const SvxFontItem& rFont)
1918 : : {
1919 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1920 : :
1921 : 378 : m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LOCH);
1922 : 378 : m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_F);
1923 : 378 : m_aStylesEnd.append((sal_Int32)m_rExport.maFontHelper.GetId(rFont));
1924 : 378 : m_rExport.eCurrentEncoding = rtl_getTextEncodingFromWindowsCharset(rtl_getBestWindowsCharsetFromTextEncoding(rFont.GetCharSet()));
1925 : 378 : }
1926 : :
1927 : 474 : void RtfAttributeOutput::CharFontSize( const SvxFontHeightItem& rFontSize)
1928 : : {
1929 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1930 : :
1931 [ + - + - ]: 474 : switch ( rFontSize.Which() )
1932 : : {
1933 : : case RES_CHRATR_FONTSIZE:
1934 : 240 : m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_FS);
1935 : 240 : m_aStylesEnd.append((sal_Int32)(rFontSize.GetHeight() / 10 ));
1936 : 240 : break;
1937 : : case RES_CHRATR_CJK_FONTSIZE:
1938 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FS);
1939 : 0 : m_aStyles.append((sal_Int32)(rFontSize.GetHeight() / 10 ));
1940 : 0 : break;
1941 : : case RES_CHRATR_CTL_FONTSIZE:
1942 : 234 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AFS);
1943 : 234 : m_aStyles.append((sal_Int32)(rFontSize.GetHeight() / 10 ));
1944 : 234 : break;
1945 : : }
1946 : 474 : }
1947 : :
1948 : 0 : void RtfAttributeOutput::CharKerning( const SvxKerningItem& rKerning )
1949 : : {
1950 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1951 : :
1952 : : // in quater points then in twips
1953 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_EXPND);
1954 : 0 : m_aStyles.append((sal_Int32)(rKerning.GetValue() / 5));
1955 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_EXPNDTW);
1956 : 0 : m_aStyles.append((sal_Int32)(rKerning.GetValue()));
1957 : 0 : }
1958 : :
1959 : 240 : void RtfAttributeOutput::CharLanguage( const SvxLanguageItem& rLanguage )
1960 : : {
1961 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1962 : :
1963 [ + + + - ]: 240 : switch (rLanguage.Which())
1964 : : {
1965 : : case RES_CHRATR_LANGUAGE:
1966 : 78 : m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LANG);
1967 : 78 : m_aStylesEnd.append((sal_Int32)rLanguage.GetLanguage());
1968 : 78 : break;
1969 : : case RES_CHRATR_CJK_LANGUAGE:
1970 : 78 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LANGFE);
1971 : 78 : m_aStyles.append((sal_Int32)rLanguage.GetLanguage());
1972 : 78 : break;
1973 : : case RES_CHRATR_CTL_LANGUAGE:
1974 : 84 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ALANG);
1975 : 84 : m_aStyles.append((sal_Int32)rLanguage.GetLanguage());
1976 : 84 : break;
1977 : : }
1978 : 240 : }
1979 : :
1980 : 78 : void RtfAttributeOutput::CharPosture( const SvxPostureItem& rPosture )
1981 : : {
1982 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1983 : :
1984 : 78 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_I);
1985 [ - + ]: 78 : if ( rPosture.GetPosture() == ITALIC_NONE )
1986 : 0 : m_aStyles.append((sal_Int32)0);
1987 : 78 : }
1988 : :
1989 : 0 : void RtfAttributeOutput::CharShadow( const SvxShadowedItem& rShadow )
1990 : : {
1991 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
1992 : :
1993 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SHAD);
1994 [ # # ]: 0 : if ( !rShadow.GetValue() )
1995 : 0 : m_aStyles.append((sal_Int32)0);
1996 : 0 : }
1997 : :
1998 : 0 : void RtfAttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline )
1999 : : {
2000 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2001 : :
2002 : 0 : const char* pStr = 0;
2003 [ # # ]: 0 : const SfxPoolItem* pItem = m_rExport.HasItem( RES_CHRATR_WORDLINEMODE );
2004 : 0 : bool bWord = false;
2005 [ # # ]: 0 : if (pItem)
2006 : 0 : bWord = ((const SvxWordLineModeItem*)pItem)->GetValue() ? true : false;
2007 [ # # # # : 0 : switch(rUnderline.GetLineStyle() )
# # # # #
# # # # #
# # # # ]
2008 : : {
2009 : : case UNDERLINE_SINGLE:
2010 [ # # ]: 0 : pStr = bWord ? OOO_STRING_SVTOOLS_RTF_ULW : OOO_STRING_SVTOOLS_RTF_UL;
2011 : 0 : break;
2012 : : case UNDERLINE_DOUBLE:
2013 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULDB;
2014 : 0 : break;
2015 : : case UNDERLINE_NONE:
2016 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULNONE;
2017 : 0 : break;
2018 : : case UNDERLINE_DOTTED:
2019 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULD;
2020 : 0 : break;
2021 : : case UNDERLINE_DASH:
2022 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULDASH;
2023 : 0 : break;
2024 : : case UNDERLINE_DASHDOT:
2025 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULDASHD;
2026 : 0 : break;
2027 : : case UNDERLINE_DASHDOTDOT:
2028 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULDASHDD;
2029 : 0 : break;
2030 : : case UNDERLINE_BOLD:
2031 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULTH;
2032 : 0 : break;
2033 : : case UNDERLINE_WAVE:
2034 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULWAVE;
2035 : 0 : break;
2036 : : case UNDERLINE_BOLDDOTTED:
2037 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULTHD;
2038 : 0 : break;
2039 : : case UNDERLINE_BOLDDASH:
2040 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULTHDASH;
2041 : 0 : break;
2042 : : case UNDERLINE_LONGDASH:
2043 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULLDASH;
2044 : 0 : break;
2045 : : case UNDERLINE_BOLDLONGDASH:
2046 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULTHLDASH;
2047 : 0 : break;
2048 : : case UNDERLINE_BOLDDASHDOT:
2049 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULTHDASHD;
2050 : 0 : break;
2051 : : case UNDERLINE_BOLDDASHDOTDOT:
2052 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULTHDASHDD;
2053 : 0 : break;
2054 : : case UNDERLINE_BOLDWAVE:
2055 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULHWAVE;
2056 : 0 : break;
2057 : : case UNDERLINE_DOUBLEWAVE:
2058 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_ULULDBWAVE;
2059 : 0 : break;
2060 : : default:
2061 : 0 : break;
2062 : : }
2063 : :
2064 [ # # ]: 0 : if( pStr )
2065 : : {
2066 [ # # ]: 0 : m_aStyles.append(pStr);
2067 : : // NEEDSWORK looks like here rUnderline.GetColor() is always black,
2068 : : // even if the color in the odt is for example green...
2069 [ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ULC);
2070 [ # # ][ # # ]: 0 : m_aStyles.append( (sal_Int32)m_rExport.GetColor(rUnderline.GetColor()) );
2071 : : }
2072 : 0 : }
2073 : :
2074 : 0 : void RtfAttributeOutput::CharWeight( const SvxWeightItem& rWeight )
2075 : : {
2076 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2077 : :
2078 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_B);
2079 [ # # ]: 0 : if ( rWeight.GetWeight() != WEIGHT_BOLD )
2080 : 0 : m_aStyles.append((sal_Int32)0);
2081 : 0 : }
2082 : :
2083 : 78 : void RtfAttributeOutput::CharAutoKern( const SvxAutoKernItem& rAutoKern)
2084 : : {
2085 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2086 : :
2087 : 78 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_KERNING);
2088 [ + - ]: 78 : m_aStyles.append((sal_Int32) (rAutoKern.GetValue() ? 1 : 0));
2089 : 78 : }
2090 : :
2091 : 0 : void RtfAttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink )
2092 : : {
2093 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2094 : :
2095 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ANIMTEXT);
2096 [ # # ]: 0 : m_aStyles.append((sal_Int32) (rBlink.GetValue() ? 2 : 0));
2097 : 0 : }
2098 : :
2099 : 0 : void RtfAttributeOutput::CharBackground( const SvxBrushItem& rBrush )
2100 : : {
2101 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2102 : :
2103 [ # # ]: 0 : if( !rBrush.GetColor().GetTransparency() )
2104 : : {
2105 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CHCBPAT);
2106 : 0 : m_aStyles.append((sal_Int32)m_rExport.GetColor(rBrush.GetColor()));
2107 : : }
2108 : 0 : }
2109 : :
2110 : 372 : void RtfAttributeOutput::CharFontCJK( const SvxFontItem& rFont )
2111 : : {
2112 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2113 : :
2114 : 372 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_DBCH);
2115 : 372 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AF);
2116 : 372 : m_aStyles.append((sal_Int32)m_rExport.maFontHelper.GetId(rFont));
2117 : 372 : }
2118 : :
2119 : 0 : void RtfAttributeOutput::CharFontSizeCJK( const SvxFontHeightItem& rFontSize )
2120 : : {
2121 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2122 : :
2123 : 0 : CharFontSize( rFontSize );
2124 : 0 : }
2125 : :
2126 : 78 : void RtfAttributeOutput::CharLanguageCJK( const SvxLanguageItem& rLanguageItem )
2127 : : {
2128 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2129 : :
2130 : 78 : CharLanguage( rLanguageItem );
2131 : 78 : }
2132 : :
2133 : 0 : void RtfAttributeOutput::CharPostureCJK( const SvxPostureItem& rPosture )
2134 : : {
2135 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2136 : :
2137 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_I);
2138 [ # # ]: 0 : if ( rPosture.GetPosture() == ITALIC_NONE )
2139 : 0 : m_aStyles.append((sal_Int32)0);
2140 : 0 : }
2141 : :
2142 : 0 : void RtfAttributeOutput::CharWeightCJK( const SvxWeightItem& rWeight )
2143 : : {
2144 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2145 : :
2146 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_B);
2147 [ # # ]: 0 : if ( rWeight.GetWeight() != WEIGHT_BOLD )
2148 : 0 : m_aStyles.append((sal_Int32)0);
2149 : 0 : }
2150 : :
2151 : 390 : void RtfAttributeOutput::CharFontCTL( const SvxFontItem& rFont )
2152 : : {
2153 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2154 : :
2155 : 390 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_DBCH);
2156 : 390 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AF);
2157 : 390 : m_aStyles.append((sal_Int32)m_rExport.maFontHelper.GetId(rFont));
2158 : 390 : }
2159 : :
2160 : 234 : void RtfAttributeOutput::CharFontSizeCTL( const SvxFontHeightItem& rFontSize )
2161 : : {
2162 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2163 : :
2164 : 234 : CharFontSize( rFontSize );
2165 : 234 : }
2166 : :
2167 : 84 : void RtfAttributeOutput::CharLanguageCTL( const SvxLanguageItem& rLanguageItem )
2168 : : {
2169 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2170 : :
2171 : 84 : CharLanguage( rLanguageItem );
2172 : 84 : }
2173 : :
2174 : 78 : void RtfAttributeOutput::CharPostureCTL( const SvxPostureItem& rPosture)
2175 : : {
2176 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2177 : :
2178 : 78 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AI);
2179 [ - + ]: 78 : if ( rPosture.GetPosture() == ITALIC_NONE )
2180 : 0 : m_aStyles.append((sal_Int32)0);
2181 : 78 : }
2182 : :
2183 : 0 : void RtfAttributeOutput::CharWeightCTL( const SvxWeightItem& rWeight )
2184 : : {
2185 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2186 : :
2187 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AB);
2188 [ # # ]: 0 : if ( rWeight.GetWeight() != WEIGHT_BOLD )
2189 : 0 : m_aStyles.append((sal_Int32)0);
2190 : 0 : }
2191 : :
2192 : 0 : void RtfAttributeOutput::CharRotate( const SvxCharRotateItem& rRotate)
2193 : : {
2194 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2195 : :
2196 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HORZVERT);
2197 [ # # ]: 0 : m_aStyles.append((sal_Int32)(rRotate.IsFitToLine() ? 1 : 0));
2198 : 0 : }
2199 : :
2200 : 0 : void RtfAttributeOutput::CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark )
2201 : : {
2202 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2203 : :
2204 : : const sal_Char* pStr;
2205 [ # # # ]: 0 : switch( rEmphasisMark.GetEmphasisMark())
2206 : : {
2207 : 0 : case EMPHASISMARK_NONE: pStr = OOO_STRING_SVTOOLS_RTF_ACCNONE; break;
2208 : 0 : case EMPHASISMARK_SIDE_DOTS: pStr = OOO_STRING_SVTOOLS_RTF_ACCCOMMA; break;
2209 : 0 : default: pStr = OOO_STRING_SVTOOLS_RTF_ACCDOT; break;
2210 : : }
2211 [ # # ]: 0 : m_aStyles.append(pStr);
2212 : 0 : }
2213 : :
2214 : 0 : void RtfAttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines )
2215 : : {
2216 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2217 : :
2218 [ # # ]: 0 : if( rTwoLines.GetValue() )
2219 : : {
2220 : 0 : sal_Unicode cStart = rTwoLines.GetStartBracket();
2221 : 0 : sal_Unicode cEnd = rTwoLines.GetEndBracket();
2222 : :
2223 : : sal_uInt16 nType;
2224 [ # # ][ # # ]: 0 : if( !cStart && !cEnd )
2225 : 0 : nType = 0;
2226 [ # # ][ # # ]: 0 : else if( '{' == cStart || '}' == cEnd )
2227 : 0 : nType = 4;
2228 [ # # ][ # # ]: 0 : else if( '<' == cStart || '>' == cEnd )
2229 : 0 : nType = 3;
2230 [ # # ][ # # ]: 0 : else if( '[' == cStart || ']' == cEnd )
2231 : 0 : nType = 2;
2232 : : else // all other kind of brackets
2233 : 0 : nType = 1;
2234 : :
2235 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TWOINONE);
2236 : 0 : m_aStyles.append((sal_Int32)nType);
2237 : : }
2238 : 0 : }
2239 : :
2240 : 0 : void RtfAttributeOutput::CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth )
2241 : : {
2242 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2243 : :
2244 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CHARSCALEX);
2245 : 0 : m_aStyles.append((sal_Int32)rScaleWidth.GetValue());
2246 : 0 : }
2247 : :
2248 : 0 : void RtfAttributeOutput::CharRelief( const SvxCharReliefItem& rRelief )
2249 : : {
2250 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2251 : :
2252 : : const sal_Char* pStr;
2253 [ # # # ]: 0 : switch (rRelief.GetValue())
2254 : : {
2255 : : case RELIEF_EMBOSSED:
2256 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_EMBO;
2257 : 0 : break;
2258 : : case RELIEF_ENGRAVED:
2259 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_IMPR;
2260 : 0 : break;
2261 : : default:
2262 : 0 : pStr = 0;
2263 : 0 : break;
2264 : : }
2265 : :
2266 [ # # ]: 0 : if (pStr)
2267 [ # # ]: 0 : m_aStyles.append(pStr);
2268 : 0 : }
2269 : :
2270 : 0 : void RtfAttributeOutput::CharHidden( const SvxCharHiddenItem& rHidden )
2271 : : {
2272 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2273 : :
2274 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_V);
2275 [ # # ]: 0 : if ( !rHidden.GetValue() )
2276 : 0 : m_aStyles.append((sal_Int32)0);
2277 : 0 : }
2278 : :
2279 : 0 : void RtfAttributeOutput::TextINetFormat( const SwFmtINetFmt& rURL )
2280 : : {
2281 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2282 : :
2283 [ # # ]: 0 : if( rURL.GetValue().Len() )
2284 : : {
2285 : : const SwCharFmt* pFmt;
2286 : 0 : const SwTxtINetFmt* pTxtAtr = rURL.GetTxtINetFmt();
2287 : :
2288 : 0 : m_aStyles.append("{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
2289 : 0 : m_bHadFieldResult = true;
2290 [ # # ][ # # ]: 0 : if( pTxtAtr && 0 != ( pFmt = pTxtAtr->GetCharFmt() ))
[ # # ]
2291 : : {
2292 : 0 : sal_uInt16 nStyle = m_rExport.GetId( *pFmt );
2293 : 0 : OString* pString = m_rExport.GetStyle(nStyle);
2294 [ # # ]: 0 : if (pString)
2295 : 0 : m_aStyles.append(*pString);
2296 : : }
2297 : : }
2298 : 0 : }
2299 : :
2300 : 0 : void RtfAttributeOutput::TextCharFormat( const SwFmtCharFmt& rCharFmt )
2301 : : {
2302 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2303 : :
2304 : 0 : sal_uInt16 nStyle = m_rExport.GetId( *rCharFmt.GetCharFmt() );
2305 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CS);
2306 : 0 : m_aStyles.append((sal_Int32)nStyle);
2307 : 0 : OString* pString = m_rExport.GetStyle(nStyle);
2308 [ # # ]: 0 : if (pString)
2309 : 0 : m_aStyles.append(*pString);
2310 : 0 : }
2311 : :
2312 : 0 : void RtfAttributeOutput::WriteTextFootnoteNumStr(const SwFmtFtn& rFootnote)
2313 : : {
2314 [ # # ]: 0 : if (!rFootnote.GetNumStr().Len())
2315 : 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_CHFTN);
2316 : : else
2317 [ # # ][ # # ]: 0 : m_aRun->append(msfilter::rtfutil::OutString(rFootnote.GetNumStr(), m_rExport.eCurrentEncoding));
2318 : 0 : }
2319 : :
2320 : 0 : void RtfAttributeOutput::TextFootnote_Impl( const SwFmtFtn& rFootnote )
2321 : : {
2322 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC << " start");
2323 : :
2324 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_SUPER " ");
2325 [ # # ]: 0 : WriteTextFootnoteNumStr(rFootnote);
2326 [ # # ][ # # ]: 0 : m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FOOTNOTE);
2327 [ # # ]: 0 : if( rFootnote.IsEndNote() )
2328 [ # # ][ # # ]: 0 : m_aRun->append(OOO_STRING_SVTOOLS_RTF_FTNALT);
2329 [ # # ][ # # ]: 0 : m_aRun->append(' ');
2330 [ # # ]: 0 : WriteTextFootnoteNumStr(rFootnote);
2331 : :
2332 : : /*
2333 : : * The footnote contains a whole paragraph, so we have to:
2334 : : * 1) Reset, then later restore the contents of our run buffer.
2335 : : * 2) Buffer the output of the whole paragraph, as we do so for section headers already.
2336 : : */
2337 : 0 : const SwNodeIndex* pIndex = rFootnote.GetTxtFtn()->GetStartNode();
2338 [ # # ]: 0 : RtfStringBuffer aRun = m_aRun;
2339 [ # # ]: 0 : m_aRun.clear();
2340 : 0 : m_bBufferSectionHeaders = true;
2341 : 0 : m_rExport.WriteSpecialText( pIndex->GetIndex() + 1,
2342 : 0 : pIndex->GetNode().EndOfSectionIndex(),
2343 [ # # ][ # # ]: 0 : !rFootnote.IsEndNote() ? TXT_FTN : TXT_EDN);
2344 : 0 : m_bBufferSectionHeaders = false;
2345 [ # # ]: 0 : m_aRun = aRun;
2346 [ # # ][ # # ]: 0 : m_aRun->append(m_aSectionHeaders.makeStringAndClear());
2347 : :
2348 [ # # ][ # # ]: 0 : m_aRun->append("}");
2349 [ # # ][ # # ]: 0 : m_aRun->append("}");
2350 : :
2351 : 0 : SAL_INFO("sw.rtf", OSL_THIS_FUNC << " end");
2352 : 0 : }
2353 : :
2354 : 0 : void RtfAttributeOutput::ParaLineSpacing_Impl( short nSpace, short nMulti )
2355 : : {
2356 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2357 : :
2358 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SL);
2359 : 0 : m_aStyles.append((sal_Int32)nSpace);
2360 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SLMULT);
2361 : 0 : m_aStyles.append((sal_Int32)nMulti);
2362 : :
2363 : 0 : }
2364 : :
2365 : 0 : void RtfAttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
2366 : : {
2367 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2368 : :
2369 [ # # # # : 0 : switch ( rAdjust.GetAdjust() )
# ]
2370 : : {
2371 : : case SVX_ADJUST_LEFT:
2372 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QL);
2373 : 0 : break;
2374 : : case SVX_ADJUST_RIGHT:
2375 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QR);
2376 : 0 : break;
2377 : : case SVX_ADJUST_BLOCKLINE:
2378 : : case SVX_ADJUST_BLOCK:
2379 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QJ);
2380 : 0 : break;
2381 : : case SVX_ADJUST_CENTER:
2382 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QC);
2383 : 0 : break;
2384 : : default:
2385 : 0 : break;
2386 : : }
2387 : 0 : }
2388 : :
2389 : 0 : void RtfAttributeOutput::ParaSplit( const SvxFmtSplitItem& rSplit )
2390 : : {
2391 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2392 : :
2393 [ # # ]: 0 : if( !rSplit.GetValue() )
2394 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_KEEP);
2395 : 0 : }
2396 : :
2397 : 78 : void RtfAttributeOutput::ParaWidows( const SvxWidowsItem& rWidows )
2398 : : {
2399 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2400 : :
2401 [ - + ]: 78 : if (rWidows.GetValue())
2402 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_WIDCTLPAR);
2403 : : else
2404 : 78 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_NOWIDCTLPAR);
2405 : 78 : }
2406 : :
2407 : 78 : void RtfAttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStop )
2408 : : {
2409 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2410 : :
2411 : 78 : long nOffset = ((SvxLRSpaceItem&)m_rExport.GetItem( RES_LR_SPACE )).GetTxtLeft();
2412 [ + + ]: 156 : for( sal_uInt16 n = 0; n < rTabStop.Count(); n++ )
2413 : : {
2414 : 78 : const SvxTabStop & rTS = rTabStop[ n ];
2415 [ - + ]: 78 : if( SVX_TAB_ADJUST_DEFAULT != rTS.GetAdjustment() )
2416 : : {
2417 : 0 : const char* pFill = 0;
2418 [ # # # # : 0 : switch( rTS.GetFill() )
# # ]
2419 : : {
2420 : : case cDfltFillChar:
2421 : 0 : break;
2422 : :
2423 : 0 : case '.': pFill = OOO_STRING_SVTOOLS_RTF_TLDOT; break;
2424 : 0 : case '_': pFill = OOO_STRING_SVTOOLS_RTF_TLUL; break;
2425 : 0 : case '-': pFill = OOO_STRING_SVTOOLS_RTF_TLTH; break;
2426 : 0 : case '=': pFill = OOO_STRING_SVTOOLS_RTF_TLEQ; break;
2427 : : default:
2428 : 0 : break;
2429 : : }
2430 [ # # ]: 0 : if( pFill )
2431 [ # # ]: 0 : m_aStyles.append(pFill);
2432 : :
2433 : 0 : const sal_Char* pAdjStr = 0;
2434 [ # # # # ]: 0 : switch (rTS.GetAdjustment())
2435 : : {
2436 : : case SVX_TAB_ADJUST_RIGHT:
2437 : 0 : pAdjStr = OOO_STRING_SVTOOLS_RTF_TQR;
2438 : 0 : break;
2439 : : case SVX_TAB_ADJUST_DECIMAL:
2440 : 0 : pAdjStr = OOO_STRING_SVTOOLS_RTF_TQDEC;
2441 : 0 : break;
2442 : : case SVX_TAB_ADJUST_CENTER:
2443 : 0 : pAdjStr = OOO_STRING_SVTOOLS_RTF_TQC;
2444 : 0 : break;
2445 : : default:
2446 : 0 : break;
2447 : : }
2448 [ # # ]: 0 : if (pAdjStr)
2449 [ # # ]: 0 : m_aStyles.append(pAdjStr);
2450 [ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TX);
2451 [ # # ]: 0 : m_aStyles.append((sal_Int32)(rTS.GetTabPos() + nOffset));
2452 : : }
2453 : : else
2454 : : {
2455 : 78 : m_aTabStop.append( OOO_STRING_SVTOOLS_RTF_DEFTAB );
2456 : 78 : m_aTabStop.append( (sal_Int32)rTabStop[0].GetTabPos() );
2457 : : }
2458 : : }
2459 : 78 : }
2460 : :
2461 : 78 : void RtfAttributeOutput::ParaHyphenZone( const SvxHyphenZoneItem& rHyphenZone )
2462 : : {
2463 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2464 : :
2465 [ - + ]: 78 : sal_Int32 nFlags = rHyphenZone.IsHyphen() ? 1 : 0;
2466 [ + - ]: 78 : if( rHyphenZone.IsPageEnd() )
2467 : 78 : nFlags += 2;
2468 : 78 : m_aStyles.append('{');
2469 : 78 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE);
2470 : 78 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHEN);
2471 : 78 : m_aStyles.append((sal_Int32)nFlags);
2472 : 78 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHLEAD);
2473 : 78 : m_aStyles.append((sal_Int32)rHyphenZone.GetMinLead());
2474 : 78 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHTRAIL);
2475 : 78 : m_aStyles.append((sal_Int32)rHyphenZone.GetMinTrail());
2476 : 78 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHMAX);
2477 : 78 : m_aStyles.append((sal_Int32)rHyphenZone.GetMaxHyphens());
2478 : 78 : m_aStyles.append('}');
2479 : 78 : }
2480 : :
2481 : 0 : void RtfAttributeOutput::ParaNumRule_Impl( const SwTxtNode* pTxtNd, sal_Int32 nLvl, sal_Int32 nNumId )
2482 : : {
2483 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2484 : :
2485 [ # # ][ # # ]: 0 : if ( USHRT_MAX == nNumId || 0 == nNumId || 0 == pTxtNd)
[ # # ]
2486 : 0 : return;
2487 : :
2488 : 0 : const SwNumRule* pRule = pTxtNd->GetNumRule();
2489 : :
2490 [ # # ][ # # ]: 0 : if( pRule && pTxtNd->IsInList() )
[ # # ]
2491 : : {
2492 : : OSL_ENSURE( pTxtNd->GetActualListLevel() >= 0 && pTxtNd->GetActualListLevel() < MAXLEVEL,
2493 : : "<SwRTFWriter::OutListNum(..)> - text node does not have valid list level. Serious defect -> please inform OD" );
2494 : :
2495 : 0 : const bool bExportNumRule = USHRT_MAX != nNumId;
2496 [ # # ]: 0 : const SwNumFmt* pFmt = pRule->GetNumFmt( nLvl );
2497 [ # # ]: 0 : if( !pFmt )
2498 [ # # ]: 0 : pFmt = &pRule->Get( nLvl );
2499 : :
2500 [ # # ]: 0 : const SfxItemSet& rNdSet = pTxtNd->GetSwAttrSet();
2501 : :
2502 [ # # ]: 0 : if ( bExportNumRule ) {
2503 [ # # ]: 0 : m_aStyles.append('{');
2504 [ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LISTTEXT);
2505 [ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_PARD);
2506 [ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_PLAIN);
2507 [ # # ]: 0 : m_aStyles.append(' ');
2508 : : }
2509 : :
2510 [ # # ][ # # ]: 0 : SvxLRSpaceItem aLR( (SvxLRSpaceItem&)rNdSet.Get( RES_LR_SPACE ) );
2511 [ # # ][ # # ]: 0 : aLR.SetTxtLeft( aLR.GetTxtLeft() + pFmt->GetIndentAt() );
2512 [ # # ][ # # ]: 0 : aLR.SetTxtFirstLineOfst( pFmt->GetFirstLineOffset() );
2513 : :
2514 [ # # ]: 0 : sal_uInt16 nStyle = m_rExport.GetId( *pFmt->GetCharFmt() );
2515 [ # # ]: 0 : OString* pString = m_rExport.GetStyle(nStyle);
2516 [ # # ]: 0 : if (pString)
2517 [ # # ]: 0 : m_aStyles.append(*pString);
2518 : :
2519 : : {
2520 [ # # ]: 0 : String sTxt;
2521 [ # # ][ # # ]: 0 : if( SVX_NUM_CHAR_SPECIAL == pFmt->GetNumberingType() || SVX_NUM_BITMAP == pFmt->GetNumberingType() )
[ # # ]
2522 [ # # ]: 0 : sTxt = pFmt->GetBulletChar();
2523 : : else
2524 [ # # ][ # # ]: 0 : sTxt = pTxtNd->GetNumString();
[ # # ]
2525 : :
2526 [ # # ]: 0 : if (sTxt.Len())
2527 : : {
2528 [ # # ]: 0 : m_aStyles.append(' ');
2529 [ # # ][ # # ]: 0 : m_aStyles.append(msfilter::rtfutil::OutString(sTxt, m_rExport.eDefaultEncoding));
2530 : : }
2531 : :
2532 [ # # ]: 0 : if( bExportNumRule )
2533 : : {
2534 [ # # ]: 0 : if( OUTLINE_RULE != pRule->GetRuleType() )
2535 : : {
2536 [ # # ]: 0 : if (sTxt.Len())
2537 [ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TAB);
2538 [ # # ]: 0 : m_aStyles.append('}');
2539 [ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ILVL);
2540 [ # # ]: 0 : if( nLvl > 8 ) // RTF knows only 9 levels
2541 : : {
2542 [ # # ]: 0 : m_aStyles.append((sal_Int32)8);
2543 [ # # ]: 0 : m_aStyles.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SOUTLVL);
2544 [ # # ]: 0 : m_aStyles.append((sal_Int32)nLvl);
2545 [ # # ]: 0 : m_aStyles.append('}');
2546 : : }
2547 : : else
2548 [ # # ]: 0 : m_aStyles.append((sal_Int32)nLvl);
2549 : : }
2550 : : else
2551 [ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TAB "}");
2552 [ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LS);
2553 [ # # ][ # # ]: 0 : m_aStyles.append((sal_Int32)m_rExport.GetId(*pRule)+1);
2554 [ # # ]: 0 : m_aStyles.append(' ');
2555 : : }
2556 [ # # ]: 0 : else if( sTxt.Len() )
2557 [ # # ][ # # ]: 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TAB);
2558 : : }
2559 [ # # ][ # # ]: 0 : FormatLRSpace(aLR);
2560 : : }
2561 : : }
2562 : :
2563 : 18 : void RtfAttributeOutput::ParaScriptSpace( const SfxBoolItem& rScriptSpace )
2564 : : {
2565 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2566 : :
2567 [ - + ]: 18 : if (!rScriptSpace.GetValue( ))
2568 : 18 : return;
2569 [ + + ]: 18 : switch ( rScriptSpace.Which( ) )
2570 : : {
2571 : : case RES_PARATR_SCRIPTSPACE:
2572 : 6 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ASPALPHA);
2573 : 6 : break;
2574 : :
2575 : : default:
2576 : 12 : break;
2577 : : }
2578 : : }
2579 : :
2580 : 0 : void RtfAttributeOutput::ParaVerticalAlign( const SvxParaVertAlignItem& rAlign )
2581 : : {
2582 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2583 : :
2584 : : const char* pStr;
2585 [ # # # # : 0 : switch ( rAlign.GetValue() )
# ]
2586 : : {
2587 : 0 : case SvxParaVertAlignItem::TOP: pStr = OOO_STRING_SVTOOLS_RTF_FAHANG; break;
2588 : 0 : case SvxParaVertAlignItem::BOTTOM: pStr = OOO_STRING_SVTOOLS_RTF_FAVAR; break;
2589 : 0 : case SvxParaVertAlignItem::CENTER: pStr = OOO_STRING_SVTOOLS_RTF_FACENTER; break;
2590 : 0 : case SvxParaVertAlignItem::BASELINE: pStr = OOO_STRING_SVTOOLS_RTF_FAROMAN; break;
2591 : :
2592 : 0 : default: pStr = OOO_STRING_SVTOOLS_RTF_FAAUTO; break;
2593 : : }
2594 [ # # ]: 0 : m_aStyles.append(pStr);
2595 : 0 : }
2596 : :
2597 : 0 : void RtfAttributeOutput::ParaSnapToGrid( const SvxParaGridItem& /*rGrid*/ )
2598 : : {
2599 : : SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
2600 : 0 : }
2601 : :
2602 : 174 : void RtfAttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize )
2603 : : {
2604 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2605 : :
2606 [ - + ][ # # ]: 174 : if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
2607 : : {
2608 [ # # ]: 0 : if( rSize.GetWidth() )
2609 : : {
2610 : 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_ABSW);
2611 : 0 : m_aRunText->append((sal_Int32)rSize.GetWidth());
2612 : : }
2613 : :
2614 [ # # ]: 0 : if( rSize.GetHeight() )
2615 : : {
2616 : 0 : long nH = rSize.GetHeight();
2617 [ # # ]: 0 : if( ATT_FIX_SIZE == rSize.GetHeightSizeType() )
2618 : 0 : nH = -nH;
2619 : 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_ABSH);
2620 : 0 : m_aRunText->append((sal_Int32)nH);
2621 : 0 : }
2622 : : }
2623 [ + - ]: 174 : else if (m_rExport.bOutPageDescs)
2624 : : {
2625 : 174 : m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGWSXN);
2626 : 174 : m_aSectionBreaks.append((sal_Int32)rSize.GetWidth());
2627 : 174 : m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGHSXN);
2628 : 174 : m_aSectionBreaks.append((sal_Int32)rSize.GetHeight());
2629 [ + + ]: 174 : if (!m_bBufferSectionBreaks)
2630 [ + - ][ + - ]: 171 : m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear().getStr();
2631 : : }
2632 : 174 : }
2633 : :
2634 : 0 : void RtfAttributeOutput::FormatPaperBin( const SvxPaperBinItem& )
2635 : : {
2636 : : SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
2637 : 0 : }
2638 : :
2639 : 174 : void RtfAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace )
2640 : : {
2641 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2642 : :
2643 [ + - ]: 174 : if ( !m_rExport.bOutFlyFrmAttrs )
2644 : : {
2645 [ + - ]: 174 : if( m_rExport.bOutPageDescs )
2646 : : {
2647 [ + - ]: 174 : if( rLRSpace.GetLeft() )
2648 : : {
2649 : 174 : m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGLSXN);
2650 : 174 : m_aSectionBreaks.append((sal_Int32)rLRSpace.GetLeft());
2651 : : }
2652 [ + - ]: 174 : if( rLRSpace.GetRight() )
2653 : : {
2654 : 174 : m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGRSXN);
2655 : 174 : m_aSectionBreaks.append((sal_Int32)rLRSpace.GetRight());
2656 : : }
2657 [ + + ]: 174 : if (!m_bBufferSectionBreaks)
2658 [ + - ]: 171 : m_rExport.Strm() <<
2659 [ + - ]: 342 : m_aSectionBreaks.makeStringAndClear().getStr();
2660 : : }
2661 : : else
2662 : : {
2663 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LI);
2664 : 0 : m_aStyles.append( (sal_Int32) rLRSpace.GetTxtLeft() );
2665 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RI);
2666 : 0 : m_aStyles.append( (sal_Int32) rLRSpace.GetRight() );
2667 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LIN);
2668 : 0 : m_aStyles.append( (sal_Int32) rLRSpace.GetTxtLeft() );
2669 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RIN);
2670 : 0 : m_aStyles.append( (sal_Int32) rLRSpace.GetRight() );
2671 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FI);
2672 : 0 : m_aStyles.append( (sal_Int32) rLRSpace.GetTxtFirstLineOfst() );
2673 : : }
2674 : : }
2675 [ # # ][ # # ]: 0 : else if (rLRSpace.GetLeft() == rLRSpace.GetRight() && m_rExport.bRTFFlySyntax)
[ # # ]
2676 : : {
2677 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_DFRMTXTX;
2678 : 0 : m_rExport.OutLong( rLRSpace.GetLeft() );
2679 : : }
2680 : 174 : }
2681 : :
2682 : 492 : void RtfAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
2683 : : {
2684 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2685 : :
2686 [ + - ]: 492 : if ( !m_rExport.bOutFlyFrmAttrs )
2687 : : {
2688 [ + + ]: 492 : if( m_rExport.bOutPageDescs )
2689 : : {
2690 : : OSL_ENSURE( m_rExport.GetCurItemSet(), "Impossible" );
2691 [ + - ]: 174 : if ( !m_rExport.GetCurItemSet() )
2692 : 492 : return;
2693 : :
2694 [ + - ]: 174 : HdFtDistanceGlue aDistances( *m_rExport.GetCurItemSet() );
2695 : :
2696 [ + - ]: 174 : if( aDistances.dyaTop )
2697 : : {
2698 [ + - ]: 174 : m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGTSXN);
2699 [ + - ]: 174 : m_aSectionBreaks.append((sal_Int32)aDistances.dyaTop);
2700 : : }
2701 [ - + ]: 174 : if ( aDistances.HasHeader() )
2702 : : {
2703 [ # # ]: 0 : m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_HEADERY);
2704 [ # # ]: 0 : m_aSectionBreaks.append((sal_Int32)aDistances.dyaHdrTop);
2705 : : }
2706 : :
2707 [ + - ]: 174 : if( aDistances.dyaBottom )
2708 : : {
2709 [ + - ]: 174 : m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGBSXN);
2710 [ + - ]: 174 : m_aSectionBreaks.append((sal_Int32)aDistances.dyaBottom);
2711 : : }
2712 [ - + ]: 174 : if( aDistances.HasFooter() )
2713 : : {
2714 [ # # ]: 0 : m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_FOOTERY);
2715 [ # # ]: 0 : m_aSectionBreaks.append((sal_Int32)aDistances.dyaHdrBottom);
2716 : : }
2717 [ + + ]: 174 : if (!m_bBufferSectionBreaks)
2718 [ + - ]: 171 : m_rExport.Strm() <<
2719 [ + - ]: 345 : m_aSectionBreaks.makeStringAndClear().getStr();
2720 : : }
2721 : : else
2722 : : {
2723 : 318 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SB);
2724 : 318 : m_aStyles.append( (sal_Int32) rULSpace.GetUpper() );
2725 : 318 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SA);
2726 : 318 : m_aStyles.append( (sal_Int32) rULSpace.GetLower() );
2727 [ - + ]: 318 : if (rULSpace.GetContext())
2728 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CONTEXTUALSPACE);
2729 : : }
2730 : : }
2731 [ # # ][ # # ]: 0 : else if (rULSpace.GetUpper() == rULSpace.GetLower() && m_rExport.bRTFFlySyntax)
[ # # ]
2732 : : {
2733 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_DFRMTXTY;
2734 : 0 : m_rExport.OutLong( rULSpace.GetLower() );
2735 : : }
2736 : : }
2737 : :
2738 : 0 : void RtfAttributeOutput::FormatSurround( const SwFmtSurround& rSurround )
2739 : : {
2740 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2741 : :
2742 [ # # ][ # # ]: 0 : if ( m_rExport.bOutFlyFrmAttrs && !m_rExport.bRTFFlySyntax )
2743 : : {
2744 : 0 : SwSurround eSurround = rSurround.GetSurround();
2745 : 0 : sal_Bool bGold = SURROUND_IDEAL == eSurround;
2746 [ # # ]: 0 : if( bGold )
2747 : 0 : eSurround = SURROUND_PARALLEL;
2748 : 0 : RTFSurround aMC( bGold, static_cast< sal_uInt8 >(eSurround) );
2749 [ # # ][ # # ]: 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYMAINCNT);
2750 [ # # ][ # # ]: 0 : m_aRunText->append( (sal_Int32) aMC.GetValue() );
2751 : : }
2752 : 0 : }
2753 : :
2754 : 0 : void RtfAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert )
2755 : : {
2756 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2757 : :
2758 [ # # ][ # # ]: 0 : if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
2759 : : {
2760 : 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_PVPARA);
2761 : :
2762 [ # # # # : 0 : switch (rFlyVert.GetVertOrient())
# ]
2763 : : {
2764 : : case text::VertOrientation::TOP:
2765 : : case text::VertOrientation::LINE_TOP:
2766 : 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSYT);
2767 : 0 : break;
2768 : : case text::VertOrientation::BOTTOM:
2769 : : case text::VertOrientation::LINE_BOTTOM:
2770 : 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSYB);
2771 : 0 : break;
2772 : : case text::VertOrientation::CENTER:
2773 : : case text::VertOrientation::LINE_CENTER:
2774 : 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSYC);
2775 : 0 : break;
2776 : : case text::VertOrientation::NONE:
2777 : 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSY);
2778 : 0 : m_aRunText->append((sal_Int32)rFlyVert.GetPos());
2779 : 0 : break;
2780 : : default:
2781 : 0 : break;
2782 : : }
2783 : : }
2784 [ # # ]: 0 : else if ( !m_rExport.bRTFFlySyntax )
2785 : : {
2786 : 0 : RTFVertOrient aVO( static_cast< sal_uInt16 >(rFlyVert.GetVertOrient()), static_cast< sal_uInt16 >(rFlyVert.GetRelationOrient()) );
2787 [ # # ][ # # ]: 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYVERT);
2788 [ # # ][ # # ]: 0 : m_aRunText->append((sal_Int32)aVO.GetValue());
2789 : : }
2790 : 0 : }
2791 : :
2792 : 0 : void RtfAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHori )
2793 : : {
2794 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2795 : :
2796 [ # # ][ # # ]: 0 : if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
2797 : : {
2798 [ # # ][ # # ]: 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_PHCOL);
2799 : :
2800 : 0 : const char* pS = 0;
2801 [ # # # # : 0 : switch(rFlyHori.GetHoriOrient())
# ]
2802 : : {
2803 : : case text::HoriOrientation::RIGHT:
2804 [ # # ]: 0 : pS = rFlyHori.IsPosToggle() ? OOO_STRING_SVTOOLS_RTF_POSXO : OOO_STRING_SVTOOLS_RTF_POSXR;
2805 : 0 : break;
2806 : : case text::HoriOrientation::LEFT:
2807 [ # # ]: 0 : pS = rFlyHori.IsPosToggle() ? OOO_STRING_SVTOOLS_RTF_POSXI : OOO_STRING_SVTOOLS_RTF_POSXL;
2808 : 0 : break;
2809 : : case text::HoriOrientation::CENTER:
2810 : 0 : pS = OOO_STRING_SVTOOLS_RTF_POSXC;
2811 : 0 : break;
2812 : : case text::HoriOrientation::NONE:
2813 [ # # ][ # # ]: 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSX);
2814 [ # # ][ # # ]: 0 : m_aRunText->append((sal_Int32)rFlyHori.GetPos());
2815 : 0 : break;
2816 : : default:
2817 : 0 : break;
2818 : : }
2819 [ # # ]: 0 : if (pS)
2820 [ # # ][ # # ]: 0 : m_aRunText->append(pS);
2821 [ # # ]: 0 : } else if ( !m_rExport.bRTFFlySyntax )
2822 : : {
2823 : 0 : RTFHoriOrient aHO( static_cast< sal_uInt16 >(rFlyHori.GetHoriOrient()),
2824 : 0 : static_cast< sal_uInt16 >(rFlyHori.GetRelationOrient()) );
2825 [ # # ][ # # ]: 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYHORZ);
2826 [ # # ][ # # ]: 0 : m_aRunText->append((sal_Int32)aHO.GetValue());
2827 : : }
2828 : 0 : }
2829 : :
2830 : 0 : void RtfAttributeOutput::FormatAnchor( const SwFmtAnchor& rAnchor )
2831 : : {
2832 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2833 : :
2834 [ # # ]: 0 : if ( !m_rExport.bRTFFlySyntax )
2835 : : {
2836 : 0 : sal_uInt16 nId = static_cast< sal_uInt16 >(rAnchor.GetAnchorId());
2837 : 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYANCHOR);
2838 : 0 : m_aRunText->append((sal_Int32)nId);
2839 [ # # # ]: 0 : switch( nId )
2840 : : {
2841 : : case FLY_AT_PAGE:
2842 : 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYPAGE);
2843 : 0 : m_aRunText->append((sal_Int32)rAnchor.GetPageNum());
2844 : 0 : break;
2845 : : case FLY_AT_PARA:
2846 : : case FLY_AS_CHAR:
2847 : 0 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYCNTNT);
2848 : 0 : break;
2849 : : }
2850 : : }
2851 : 0 : }
2852 : :
2853 : 0 : void RtfAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
2854 : : {
2855 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2856 : :
2857 [ # # ]: 0 : if( !rBrush.GetColor().GetTransparency() )
2858 : : {
2859 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CBPAT);
2860 : 0 : m_aStyles.append((sal_Int32)m_rExport.GetColor(rBrush.GetColor()));
2861 : : }
2862 : 0 : }
2863 : :
2864 : 0 : void RtfAttributeOutput::FormatBox( const SvxBoxItem& rBox )
2865 : : {
2866 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2867 : :
2868 : : static sal_uInt16 aBorders[] = {
2869 : : BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
2870 : : static const sal_Char* aBorderNames[] = {
2871 : : OOO_STRING_SVTOOLS_RTF_BRDRT, OOO_STRING_SVTOOLS_RTF_BRDRL, OOO_STRING_SVTOOLS_RTF_BRDRB, OOO_STRING_SVTOOLS_RTF_BRDRR };
2872 : :
2873 : 0 : sal_uInt16 nDist = rBox.GetDistance();
2874 : :
2875 [ # # ]: 0 : if ( m_rExport.bRTFFlySyntax )
2876 : 0 : return;
2877 : :
2878 [ # # ][ # # : 0 : if( rBox.GetTop() && rBox.GetBottom() &&
# # # # #
# # # # #
# # # # #
# # # ]
[ # # ]
2879 : 0 : rBox.GetLeft() && rBox.GetRight() &&
2880 : 0 : *rBox.GetTop() == *rBox.GetBottom() &&
2881 : 0 : *rBox.GetTop() == *rBox.GetLeft() &&
2882 : 0 : *rBox.GetTop() == *rBox.GetRight() &&
2883 : 0 : nDist == rBox.GetDistance( BOX_LINE_TOP ) &&
2884 : 0 : nDist == rBox.GetDistance( BOX_LINE_LEFT ) &&
2885 : 0 : nDist == rBox.GetDistance( BOX_LINE_BOTTOM ) &&
2886 : 0 : nDist == rBox.GetDistance( BOX_LINE_RIGHT ))
2887 [ # # ]: 0 : m_aSectionBreaks.append(OutBorderLine( m_rExport, rBox.GetTop(), OOO_STRING_SVTOOLS_RTF_BOX, nDist ));
2888 : : else
2889 : : {
2890 : 0 : const sal_uInt16* pBrd = aBorders;
2891 : 0 : const sal_Char** pBrdNms = (const sal_Char**)aBorderNames;
2892 [ # # ]: 0 : for(int i = 0; i < 4; ++i, ++pBrd, ++pBrdNms)
2893 : : {
2894 [ # # ]: 0 : if (const SvxBorderLine* pLn = rBox.GetLine(*pBrd))
2895 : : {
2896 : : m_aSectionBreaks.append(OutBorderLine(m_rExport, pLn, *pBrdNms,
2897 [ # # ]: 0 : rBox.GetDistance(*pBrd)));
2898 : : }
2899 : : }
2900 : : }
2901 : :
2902 [ # # ]: 0 : if (!m_bBufferSectionBreaks)
2903 [ # # ]: 0 : m_aStyles.append(m_aSectionBreaks.makeStringAndClear());
2904 : : }
2905 : :
2906 : 0 : void RtfAttributeOutput::FormatColumns_Impl( sal_uInt16 nCols, const SwFmtCol& rCol, bool bEven, SwTwips nPageSize )
2907 : : {
2908 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2909 : :
2910 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLS;
2911 : 0 : m_rExport.OutLong( nCols );
2912 : :
2913 [ # # ]: 0 : if( bEven )
2914 : : {
2915 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLSX;
2916 : 0 : m_rExport.OutLong( rCol.GetGutterWidth( sal_True ) );
2917 : : }
2918 : : else
2919 : : {
2920 : 0 : const SwColumns & rColumns = rCol.GetColumns( );
2921 [ # # ]: 0 : for( sal_uInt16 n = 0; n < nCols; )
2922 : : {
2923 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLNO;
2924 : 0 : m_rExport.OutLong( n+1 );
2925 : :
2926 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLW;
2927 : 0 : m_rExport.OutLong( rCol.CalcPrtColWidth( n, nPageSize ) );
2928 : :
2929 [ # # ]: 0 : if( ++n != nCols )
2930 : : {
2931 : 0 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLSR;
2932 : 0 : m_rExport.OutLong( rColumns[ n-1 ].GetRight() +
2933 : 0 : rColumns[ n ].GetLeft() );
2934 : : }
2935 : : }
2936 : : }
2937 : 0 : }
2938 : :
2939 : 78 : void RtfAttributeOutput::FormatKeep( const SvxFmtKeepItem& rItem )
2940 : : {
2941 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2942 : :
2943 [ + - ]: 78 : if( rItem.GetValue() )
2944 : 78 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_KEEPN);
2945 : 78 : }
2946 : :
2947 : 147 : void RtfAttributeOutput::FormatTextGrid( const SwTextGridItem& /*rGrid*/ )
2948 : : {
2949 : : SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
2950 : 147 : }
2951 : :
2952 : 156 : void RtfAttributeOutput::FormatLineNumbering( const SwFmtLineNumber& rNumbering )
2953 : : {
2954 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2955 : :
2956 [ + - ]: 156 : if ( !rNumbering.IsCount( ) )
2957 : 156 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_NOLINE);
2958 : 156 : }
2959 : :
2960 : 180 : void RtfAttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDirection )
2961 : : {
2962 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2963 : :
2964 [ + + ]: 180 : if (!m_rExport.bOutPageDescs)
2965 : : {
2966 [ - + ]: 6 : if (rDirection.GetValue() == FRMDIR_HORI_RIGHT_TOP)
2967 : 0 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RTLPAR);
2968 : : else
2969 : 6 : m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LTRPAR);
2970 : : }
2971 : 180 : }
2972 : :
2973 : 0 : void RtfAttributeOutput::WriteExpand( const SwField* pFld )
2974 : : {
2975 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2976 [ # # ]: 0 : String sCmd;
2977 [ # # ][ # # ]: 0 : m_rExport.OutputField(pFld, ww::eUNKNOWN, sCmd);
2978 : 0 : }
2979 : :
2980 : 0 : void RtfAttributeOutput::RefField( const SwField& /*rFld*/, const String& /*rRef*/ )
2981 : : {
2982 : : SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
2983 : 0 : }
2984 : :
2985 : 0 : void RtfAttributeOutput::HiddenField( const SwField& /*rFld*/ )
2986 : : {
2987 : : SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
2988 : 0 : }
2989 : :
2990 : 0 : void RtfAttributeOutput::SetField( const SwField& /*rFld*/, ww::eField /*eType*/, const String& /*rCmd*/ )
2991 : : {
2992 : : SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
2993 : 0 : }
2994 : :
2995 : 3 : void RtfAttributeOutput::PostitField( const SwField* pFld )
2996 : : {
2997 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
2998 : :
2999 : 3 : const SwPostItField& rPFld = *(SwPostItField*)pFld;
3000 : :
3001 : 3 : m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNID " ");
3002 [ + - ][ + - ]: 3 : m_aRunText->append(OUStringToOString(OUString(rPFld.GetInitials()), m_rExport.eCurrentEncoding));
[ + - ]
3003 : 3 : m_aRunText->append("}");
3004 : 3 : m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNAUTHOR " ");
3005 [ + - ][ + - ]: 3 : m_aRunText->append(OUStringToOString(OUString(rPFld.GetPar1()), m_rExport.eCurrentEncoding));
[ + - ]
3006 : 3 : m_aRunText->append("}");
3007 : 3 : m_aRunText->append(OOO_STRING_SVTOOLS_RTF_CHATN);
3008 : :
3009 : 3 : m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ANNOTATION);
3010 : 3 : m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNREF " ");
3011 : 3 : m_aRunText->append(sal_Int32(m_nPostitFieldsMaxId++));
3012 : 3 : m_aRunText->append('}');
3013 : 3 : m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNDATE " ");
3014 [ + - ][ + - ]: 3 : m_aRunText->append((sal_Int32)sw::ms::DateTime2DTTM(rPFld.GetDateTime()));
[ + - ]
3015 : 3 : m_aRunText->append('}');
3016 [ + - ][ + - ]: 3 : m_aRunText->append(OUStringToOString(OUString(rPFld.GetTxt()), m_rExport.eCurrentEncoding));
[ + - ]
3017 : 3 : m_aRunText->append('}');
3018 : 3 : }
3019 : :
3020 : 3 : void RtfAttributeOutput::WritePostitFieldStart()
3021 : : {
3022 : 3 : m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATRFSTART " ");
3023 : 3 : m_aRunText->append(sal_Int32(m_nPostitFieldsMaxId));
3024 : 3 : m_aRunText->append("}");
3025 : 3 : }
3026 : :
3027 : 3 : void RtfAttributeOutput::WritePostitFieldEnd()
3028 : : {
3029 : 3 : m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATRFEND " ");
3030 : 3 : m_aRunText->append(sal_Int32(m_nPostitFieldsMaxId));
3031 : 3 : m_aRunText->append("}");
3032 : 3 : }
3033 : :
3034 : 0 : bool RtfAttributeOutput::DropdownField( const SwField* /*pFld*/ )
3035 : : {
3036 : : // this is handled in OutputFlyFrame_Impl()
3037 : 0 : return true;
3038 : : }
3039 : :
3040 : 78 : RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport )
3041 : : : m_rExport( rExport ),
3042 : : m_bStrikeDouble( false ),
3043 : : m_pTableWrt( NULL ),
3044 : : m_bTableCellOpen( false ),
3045 : : m_nTableDepth( 0 ),
3046 : : m_bTblAfterCell( false ),
3047 : : m_nColBreakNeeded( false ),
3048 : : m_bBufferSectionBreaks( false ),
3049 : : m_bBufferSectionHeaders( false ),
3050 : : m_bLastTable( true ),
3051 : : m_bWroteCellInfo( false ),
3052 : : m_bHadFieldResult( false ),
3053 : : m_bTableRowEnded( false ),
3054 : : m_aCells(),
3055 : : m_bSingleEmptyRun(false),
3056 : : m_bInRun(false),
3057 : : m_nPostitFieldsMaxId(0),
3058 [ + - ][ + - ]: 78 : m_pPrevPageDesc(0)
[ + - ][ + - ]
[ + - ]
3059 : : {
3060 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
3061 : 78 : }
3062 : :
3063 [ + - ]: 78 : RtfAttributeOutput::~RtfAttributeOutput()
3064 : : {
3065 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
3066 [ - + ]: 156 : }
3067 : :
3068 : 342 : MSWordExportBase& RtfAttributeOutput::GetExport()
3069 : : {
3070 : 342 : return m_rExport;
3071 : : }
3072 : :
3073 : : // These are used by wwFont::WriteRtf()
3074 : :
3075 : : /// Start the font.
3076 : 705 : void RtfAttributeOutput::StartFont( const String& rFamilyName ) const
3077 : : {
3078 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
3079 : :
3080 [ + - ][ + - ]: 705 : m_rExport.Strm() << OUStringToOString( OUString( rFamilyName ), m_rExport.eCurrentEncoding ).getStr();
[ + - ]
3081 : 705 : }
3082 : :
3083 : : /// End the font.
3084 : 705 : void RtfAttributeOutput::EndFont() const
3085 : : {
3086 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
3087 : :
3088 : 705 : m_rExport.Strm() << ";}";
3089 : 705 : }
3090 : :
3091 : : /// Alternate name for the font.
3092 : 234 : void RtfAttributeOutput::FontAlternateName( const String& rName ) const
3093 : : {
3094 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
3095 : :
3096 : 234 : m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_IGNORE << OOO_STRING_SVTOOLS_RTF_FALT << ' ';
3097 [ + - ][ + - ]: 234 : m_rExport.Strm() << OUStringToOString( OUString( rName ), m_rExport.eCurrentEncoding ).getStr() << '}';
[ + - ][ + - ]
3098 : 234 : }
3099 : :
3100 : : /// Font charset.
3101 : 705 : void RtfAttributeOutput::FontCharset( sal_uInt8 nCharSet ) const
3102 : : {
3103 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
3104 : :
3105 : 705 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_FCHARSET;
3106 : 705 : m_rExport.OutULong( nCharSet );
3107 : 705 : m_rExport.Strm() << ' ';
3108 : 705 : }
3109 : :
3110 : : /// Font family.
3111 : 705 : void RtfAttributeOutput::FontFamilyType( FontFamily eFamily, const wwFont &rFont ) const
3112 : : {
3113 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
3114 : :
3115 : 705 : m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_F;
3116 : :
3117 : 705 : const char* pStr = OOO_STRING_SVTOOLS_RTF_FNIL;
3118 [ + + - - : 705 : switch (eFamily)
- + ]
3119 : : {
3120 : : case FAMILY_ROMAN:
3121 : 315 : pStr = OOO_STRING_SVTOOLS_RTF_FROMAN;
3122 : 315 : break;
3123 : : case FAMILY_SWISS:
3124 : 162 : pStr = OOO_STRING_SVTOOLS_RTF_FSWISS;
3125 : 162 : break;
3126 : : case FAMILY_MODERN:
3127 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_FMODERN;
3128 : 0 : break;
3129 : : case FAMILY_SCRIPT:
3130 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_FSCRIPT;
3131 : 0 : break;
3132 : : case FAMILY_DECORATIVE:
3133 : 0 : pStr = OOO_STRING_SVTOOLS_RTF_FDECOR;
3134 : 0 : break;
3135 : : default:
3136 : 228 : break;
3137 : : }
3138 : 705 : m_rExport.OutULong(m_rExport.maFontHelper.GetId(rFont)) << pStr;
3139 : 705 : }
3140 : :
3141 : : /// Font pitch.
3142 : 705 : void RtfAttributeOutput::FontPitchType( FontPitch ePitch ) const
3143 : : {
3144 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
3145 : :
3146 : 705 : m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_FPRQ;
3147 : :
3148 : 705 : sal_uInt16 nVal = 0;
3149 [ - + + ]: 705 : switch (ePitch)
3150 : : {
3151 : : case PITCH_FIXED:
3152 : 0 : nVal = 1;
3153 : 0 : break;
3154 : : case PITCH_VARIABLE:
3155 : 336 : nVal = 2;
3156 : 336 : break;
3157 : : default:
3158 : 369 : break;
3159 : : }
3160 : 705 : m_rExport.OutULong(nVal);
3161 : 705 : }
3162 : :
3163 : 0 : static bool IsEMF(const sal_uInt8 *pGraphicAry, unsigned long nSize)
3164 : : {
3165 [ # # ][ # # ]: 0 : if (pGraphicAry && (nSize > 0x2c ))
3166 : : {
3167 : : // check the magic number
3168 [ # # ][ # # ]: 0 : if (
[ # # ][ # # ]
3169 : 0 : (pGraphicAry[0x28] == 0x20 ) && (pGraphicAry[0x29] == 0x45) &&
3170 : 0 : (pGraphicAry[0x2a] == 0x4d ) && (pGraphicAry[0x2b] == 0x46)
3171 : : )
3172 : : {
3173 : : //emf detected
3174 : 0 : return true;
3175 : : }
3176 : : }
3177 : 0 : return false;
3178 : : }
3179 : :
3180 : 87 : static bool StripMetafileHeader(const sal_uInt8 *&rpGraphicAry, unsigned long &rSize)
3181 : : {
3182 [ + - ][ + - ]: 87 : if (rpGraphicAry && (rSize > 0x22))
3183 : : {
3184 [ - + ][ # # ]: 87 : if (
[ # # ][ # # ]
3185 : 87 : (rpGraphicAry[0] == 0xd7) && (rpGraphicAry[1] == 0xcd) &&
3186 : 0 : (rpGraphicAry[2] == 0xc6) && (rpGraphicAry[3] == 0x9a)
3187 : : )
3188 : : { // we have to get rid of the metafileheader
3189 : 0 : rpGraphicAry += 22;
3190 : 0 : rSize -= 22;
3191 : 0 : return true;
3192 : : }
3193 : : }
3194 : 87 : return false;
3195 : : }
3196 : :
3197 : 174 : OString RtfAttributeOutput::WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, SvStream* pStream, sal_uInt32 nLimit)
3198 : : {
3199 : 174 : OStringBuffer aRet;
3200 : :
3201 : 174 : sal_uInt32 nBreak = 0;
3202 [ + + ]: 943230 : for (sal_uInt32 i = 0; i < nSize; i++)
3203 : : {
3204 : 943056 : OString sNo = OString::valueOf(sal_Int32(pData[i]), 16);
3205 [ + + ]: 943056 : if (sNo.getLength() < 2)
3206 : : {
3207 [ - + ]: 595757 : if (pStream)
3208 [ # # ]: 0 : (*pStream) << '0';
3209 : : else
3210 [ + - ]: 595757 : aRet.append('0');
3211 : : }
3212 [ - + ]: 943056 : if (pStream)
3213 [ # # ]: 0 : (*pStream) << sNo.getStr();
3214 : : else
3215 [ + - ]: 943056 : aRet.append(sNo);
3216 [ + + ]: 943056 : if (++nBreak == nLimit)
3217 : : {
3218 [ - + ]: 14643 : if (pStream)
3219 [ # # ]: 0 : (*pStream) << RtfExport::sNewLine;
3220 : : else
3221 [ + - ]: 14643 : aRet.append(RtfExport::sNewLine);
3222 : 14643 : nBreak = 0;
3223 : : }
3224 : 943056 : }
3225 : :
3226 : 174 : return aRet.makeStringAndClear();
3227 : : }
3228 : :
3229 : 348 : void lcl_AppendSP( OStringBuffer& rBuffer,
3230 : : const char cName[],
3231 : : const ::rtl::OUString& rValue,
3232 : : const RtfExport& rExport )
3233 : : {
3234 : 348 : rBuffer.append( "{" OOO_STRING_SVTOOLS_RTF_SP "{" ); // "{\sp{"
3235 : 348 : rBuffer.append( OOO_STRING_SVTOOLS_RTF_SN " " );//" \sn "
3236 : 348 : rBuffer.append( cName ); //"PropName"
3237 : 348 : rBuffer.append( "}{" OOO_STRING_SVTOOLS_RTF_SV " " );
3238 : : // "}{ \sv "
3239 [ + - ][ + - ]: 348 : rBuffer.append( msfilter::rtfutil::OutString( rValue, rExport.eCurrentEncoding ) );
3240 : 348 : rBuffer.append( "}}" );
3241 : 348 : }
3242 : :
3243 : 174 : static OString ExportPICT( const SwFlyFrmFmt* pFlyFrmFmt, const Size &rOrig, const Size &rRendered, const Size &rMapped,
3244 : : const SwCropGrf &rCr, const char *pBLIPType, const sal_uInt8 *pGraphicAry,
3245 : : unsigned long nSize, const RtfExport& rExport, SvStream *pStream = 0 )
3246 : : {
3247 : 174 : OStringBuffer aRet;
3248 : 174 : bool bIsWMF = std::strcmp(pBLIPType, OOO_STRING_SVTOOLS_RTF_WMETAFILE) == 0;
3249 [ + - ][ + - ]: 174 : if (pBLIPType && nSize && pGraphicAry)
[ + - ]
3250 : : {
3251 [ + - ]: 174 : aRet.append("{" OOO_STRING_SVTOOLS_RTF_PICT);
3252 : :
3253 [ + - ]: 174 : if( pFlyFrmFmt )
3254 : : {
3255 [ + - ]: 174 : String sDescription = pFlyFrmFmt->GetObjDescription();
3256 : : //write picture properties - wzDescription at first
3257 : : //looks like: "{\*\picprop{\sp{\sn PropertyName}{\sv PropertyValue}}}"
3258 [ + - ]: 174 : aRet.append( "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_PICPROP );//"{\*\picprop
3259 [ + - ][ + - ]: 174 : lcl_AppendSP( aRet, "wzDescription", sDescription, rExport );
3260 [ + - ]: 174 : String sName = pFlyFrmFmt->GetObjTitle();
3261 [ + - ][ + - ]: 174 : lcl_AppendSP( aRet, "wzName", sName, rExport );
3262 [ + - ][ + - ]: 174 : aRet.append( "}" ); //"}"
[ + - ]
3263 : : }
3264 : :
3265 : 174 : long nXCroppedSize = rOrig.Width()-(rCr.GetLeft() + rCr.GetRight());
3266 : 174 : long nYCroppedSize = rOrig.Height()-(rCr.GetTop() + rCr.GetBottom());
3267 : : /* Graphic with a zero height or width, typically copied from webpages, caused crashes. */
3268 [ - + ]: 174 : if( !nXCroppedSize )
3269 : 0 : nXCroppedSize = 100;
3270 [ - + ]: 174 : if( !nYCroppedSize )
3271 : 0 : nYCroppedSize = 100;
3272 : :
3273 : : //Given the original size and taking cropping into account
3274 : : //first, how much has the original been scaled to get the
3275 : : //final rendered size
3276 [ + - ]: 174 : aRet.append(OOO_STRING_SVTOOLS_RTF_PICSCALEX);
3277 [ + - ]: 174 : aRet.append((sal_Int32)((100 * rRendered.Width()) / nXCroppedSize));
3278 [ + - ]: 174 : aRet.append(OOO_STRING_SVTOOLS_RTF_PICSCALEY);
3279 [ + - ]: 174 : aRet.append((sal_Int32)((100 * rRendered.Height()) / nYCroppedSize));
3280 : :
3281 [ + - ]: 174 : aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPL);
3282 [ + - ]: 174 : aRet.append((sal_Int32)rCr.GetLeft());
3283 [ + - ]: 174 : aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPR);
3284 [ + - ]: 174 : aRet.append((sal_Int32)rCr.GetRight());
3285 [ + - ]: 174 : aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPT);
3286 [ + - ]: 174 : aRet.append((sal_Int32)rCr.GetTop());
3287 [ + - ]: 174 : aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPB);
3288 [ + - ]: 174 : aRet.append((sal_Int32)rCr.GetBottom());
3289 : :
3290 [ + - ]: 174 : aRet.append(OOO_STRING_SVTOOLS_RTF_PICW);
3291 [ + - ]: 174 : aRet.append((sal_Int32)rMapped.Width());
3292 [ + - ]: 174 : aRet.append(OOO_STRING_SVTOOLS_RTF_PICH);
3293 [ + - ]: 174 : aRet.append((sal_Int32)rMapped.Height());
3294 : :
3295 [ + - ]: 174 : aRet.append(OOO_STRING_SVTOOLS_RTF_PICWGOAL);
3296 [ + - ]: 174 : aRet.append((sal_Int32)rOrig.Width());
3297 [ + - ]: 174 : aRet.append(OOO_STRING_SVTOOLS_RTF_PICHGOAL);
3298 [ + - ]: 174 : aRet.append((sal_Int32)rOrig.Height());
3299 : :
3300 [ + - ]: 174 : aRet.append(pBLIPType);
3301 [ + + ]: 174 : if (bIsWMF)
3302 : : {
3303 [ + - ]: 87 : aRet.append((sal_Int32)8);
3304 : 87 : StripMetafileHeader(pGraphicAry, nSize);
3305 : : }
3306 [ + - ]: 174 : aRet.append(RtfExport::sNewLine);
3307 [ - + ]: 174 : if (pStream)
3308 [ # # ]: 0 : (*pStream) << aRet.makeStringAndClear().getStr();
3309 [ - + ]: 174 : if (pStream)
3310 [ # # ]: 0 : RtfAttributeOutput::WriteHex(pGraphicAry, nSize, pStream);
3311 : : else
3312 [ + - ][ + - ]: 174 : aRet.append(RtfAttributeOutput::WriteHex(pGraphicAry, nSize));
3313 [ + - ]: 174 : aRet.append('}');
3314 [ - + ]: 174 : if (pStream)
3315 [ # # ]: 0 : (*pStream) << aRet.makeStringAndClear().getStr();
3316 : : }
3317 : 174 : return aRet.makeStringAndClear();
3318 : : }
3319 : :
3320 : 87 : void RtfAttributeOutput::FlyFrameOLEReplacement(const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode& rOLENode, const Size& rSize)
3321 : : {
3322 [ + - ][ + - ]: 87 : m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
3323 [ + - ]: 87 : Size aSize(sw::util::GetSwappedInSize(rOLENode));
3324 : 87 : Size aRendered(aSize);
3325 : 87 : aRendered.Width() = rSize.Width();
3326 : 87 : aRendered.Height() = rSize.Height();
3327 [ + - ]: 87 : Graphic* pGraphic = rOLENode.GetGraphic();
3328 [ + - ]: 87 : Size aMapped(pGraphic->GetPrefSize());
3329 [ + - ]: 87 : const SwCropGrf &rCr = (const SwCropGrf &)rOLENode.GetAttr(RES_GRFATR_CROPGRF);
3330 : 87 : const sal_Char* pBLIPType = OOO_STRING_SVTOOLS_RTF_PNGBLIP;
3331 : 87 : const sal_uInt8* pGraphicAry = 0;
3332 [ + - ]: 87 : SvMemoryStream aStream;
3333 [ + - ]: 87 : if (GraphicConverter::Export(aStream, *pGraphic, CVT_PNG) != ERRCODE_NONE)
3334 : : OSL_FAIL("failed to export the graphic");
3335 [ + - ]: 87 : aStream.Seek(STREAM_SEEK_TO_END);
3336 : 87 : sal_uInt32 nSize = aStream.Tell();
3337 [ + - ]: 87 : pGraphicAry = (sal_uInt8*)aStream.GetData();
3338 [ + - ][ + - ]: 87 : m_aRunText->append(ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
[ + - ]
3339 [ + - ][ + - ]: 87 : m_aRunText->append("}"); // shppict
3340 [ + - ][ + - ]: 87 : m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT);
3341 : 87 : pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
3342 [ + - ]: 87 : SvMemoryStream aWmfStream;
3343 [ + - ]: 87 : if (GraphicConverter::Export(aWmfStream, *pGraphic, CVT_WMF) != ERRCODE_NONE)
3344 : : OSL_FAIL("failed to export the graphic");
3345 [ + - ]: 87 : aWmfStream.Seek(STREAM_SEEK_TO_END);
3346 : 87 : nSize = aWmfStream.Tell();
3347 [ + - ]: 87 : pGraphicAry = (sal_uInt8*)aStream.GetData();
3348 [ + - ][ + - ]: 87 : m_aRunText->append(ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
[ + - ]
3349 [ + - ][ + - ]: 87 : m_aRunText->append("}"); // nonshppict
[ + - ][ + - ]
3350 : 87 : }
3351 : :
3352 : 87 : bool RtfAttributeOutput::FlyFrameOLEMath(const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode& rOLENode, const Size& rSize)
3353 : : {
3354 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
3355 : :
3356 [ + - ]: 87 : uno::Reference <embed::XEmbeddedObject> xObj(const_cast<SwOLENode&>(rOLENode).GetOLEObj().GetOleRef());
3357 [ + - ]: 87 : sal_Int64 nAspect = rOLENode.GetAspect();
3358 [ + - ]: 87 : svt::EmbeddedObjectRef aObjRef(xObj, nAspect);
3359 [ + - ][ + - ]: 87 : SvGlobalName aObjName(aObjRef->getClassID());
[ + - ][ + - ]
3360 : :
3361 [ + - ][ - + ]: 87 : if (!SotExchange::IsMath(aObjName))
3362 : 0 : return false;
3363 : :
3364 [ + - ][ + - ]: 87 : m_aRunText->append("{" LO_STRING_SVTOOLS_RTF_MMATH " ");
3365 [ + - ][ + - ]: 87 : uno::Reference<util::XCloseable> xClosable(xObj->getComponent(), uno::UNO_QUERY);
[ + - ]
3366 : : // gcc4.4 (and 4.3 and possibly older) have a problem with dynamic_cast directly to the target class,
3367 : : // so help it with an intermediate cast. I'm not sure what exactly the problem is, seems to be unrelated
3368 : : // to RTLD_GLOBAL, so most probably a gcc bug.
3369 [ + - ][ - + ]: 87 : oox::FormulaExportBase* pBase = dynamic_cast<oox::FormulaExportBase*>(dynamic_cast<SfxBaseModel*>(xClosable.get()));
[ + - ]
3370 : : assert( pBase != NULL );
3371 : 87 : OStringBuffer aBuf;
3372 [ + - ]: 87 : pBase->writeFormulaRtf(aBuf, m_rExport.eCurrentEncoding);
3373 [ + - ][ + - ]: 87 : m_aRunText->append(aBuf.makeStringAndClear());
3374 : : // Replacement graphic.
3375 [ + - ][ + - ]: 87 : m_aRunText->append("{" LO_STRING_SVTOOLS_RTF_MMATHPICT " ");
3376 [ + - ]: 87 : FlyFrameOLEReplacement(pFlyFrmFmt, rOLENode, rSize);
3377 [ + - ][ + - ]: 87 : m_aRunText->append("}"); // mmathPict
3378 [ + - ][ + - ]: 87 : m_aRunText->append("}"); // mmath
3379 : :
3380 [ + - ][ + - ]: 87 : return true;
3381 : : }
3382 : :
3383 : 87 : void RtfAttributeOutput::FlyFrameOLE( const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode& rOLENode, const Size& rSize )
3384 : : {
3385 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
3386 : :
3387 [ + - ]: 87 : if (FlyFrameOLEMath(pFlyFrmFmt, rOLENode, rSize))
3388 : 87 : return;
3389 : :
3390 : 0 : FlyFrameOLEReplacement(pFlyFrmFmt, rOLENode, rSize);
3391 : : }
3392 : :
3393 : 0 : void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode)
3394 : : {
3395 : : SAL_INFO("sw.rtf", OSL_THIS_FUNC);
3396 : :
3397 [ # # ]: 0 : SvMemoryStream aStream;
3398 : 0 : const sal_uInt8* pGraphicAry = 0;
3399 : 0 : sal_uInt32 nSize = 0;
3400 : :
3401 [ # # ][ # # ]: 0 : Graphic aGraphic(pGrfNode->GetGrf());
3402 : :
3403 : : // If there is no graphic there is not much point in parsing it
3404 [ # # ][ # # ]: 0 : if(aGraphic.GetType()==GRAPHIC_NONE)
3405 : 0 : return;
3406 : :
3407 [ # # ]: 0 : GfxLink aGraphicLink;
3408 : 0 : const sal_Char* pBLIPType = 0;
3409 [ # # ][ # # ]: 0 : if (aGraphic.IsLink())
3410 : : {
3411 [ # # ][ # # ]: 0 : aGraphicLink = aGraphic.GetLink();
[ # # ]
3412 [ # # ]: 0 : nSize = aGraphicLink.GetDataSize();
3413 [ # # ]: 0 : pGraphicAry = aGraphicLink.GetData();
3414 [ # # ]: 0 : switch (aGraphicLink.GetType())
[ # # # # ]
3415 : : {
3416 : : case GFX_LINK_TYPE_NATIVE_JPG:
3417 : 0 : pBLIPType = OOO_STRING_SVTOOLS_RTF_JPEGBLIP;
3418 : 0 : break;
3419 : : case GFX_LINK_TYPE_NATIVE_PNG:
3420 : 0 : pBLIPType = OOO_STRING_SVTOOLS_RTF_PNGBLIP;
3421 : 0 : break;
3422 : : case GFX_LINK_TYPE_NATIVE_WMF:
3423 : : pBLIPType =
3424 [ # # ]: 0 : IsEMF(pGraphicAry, nSize) ? OOO_STRING_SVTOOLS_RTF_EMFBLIP : OOO_STRING_SVTOOLS_RTF_WMETAFILE;
3425 : 0 : break;
3426 : : default:
3427 : 0 : break;
3428 : : }
3429 : : }
3430 : :
3431 [ # # ]: 0 : GraphicType eGraphicType = aGraphic.GetType();
3432 [ # # ]: 0 : if (!pGraphicAry)
3433 : : {
3434 [ # # ]: 0 : if (ERRCODE_NONE == GraphicConverter::Export(aStream, aGraphic,
3435 [ # # ][ # # ]: 0 : (eGraphicType == GRAPHIC_BITMAP) ? CVT_PNG : CVT_WMF))
3436 : : {
3437 : : pBLIPType = (eGraphicType == GRAPHIC_BITMAP) ?
3438 [ # # ]: 0 : OOO_STRING_SVTOOLS_RTF_PNGBLIP : OOO_STRING_SVTOOLS_RTF_WMETAFILE;
3439 [ # # ]: 0 : aStream.Seek(STREAM_SEEK_TO_END);
3440 : 0 : nSize = aStream.Tell();
3441 [ # # ]: 0 : pGraphicAry = (sal_uInt8*)aStream.GetData();
3442 : : }
3443 : : }
3444 : :
3445 [ # # ][ # # ]: 0 : Size aMapped(eGraphicType == GRAPHIC_BITMAP ? aGraphic.GetSizePixel() : aGraphic.GetPrefSize());
[ # # ]
3446 : :
3447 [ # # ]: 0 : const SwCropGrf &rCr = (const SwCropGrf &)pGrfNode->GetAttr(RES_GRFATR_CROPGRF);
3448 : :
3449 : : //Get original size in twips
3450 [ # # ]: 0 : Size aSize(sw::util::GetSwappedInSize(*pGrfNode));
3451 : 0 : Size aRendered(aSize);
3452 [ # # ]: 0 : if (pFlyFrmFmt)
3453 : : {
3454 [ # # ]: 0 : const SwFmtFrmSize& rS = pFlyFrmFmt->GetFrmSize();
3455 : 0 : aRendered.Width() = rS.GetWidth();
3456 : 0 : aRendered.Height() = rS.GetHeight();
3457 : : }
3458 : :
3459 : : /*
3460 : : If the graphic is not of type WMF then we will have to store two
3461 : : graphics, one in the native format wrapped in shppict, and the other in
3462 : : the wmf format wrapped in nonshppict, so as to keep wordpad happy. If its
3463 : : a wmf already then we don't need any such wrapping
3464 : : */
3465 [ # # ][ # # ]: 0 : bool bIsWMF = pBLIPType && std::strcmp(pBLIPType, OOO_STRING_SVTOOLS_RTF_WMETAFILE) == 0;
3466 [ # # ]: 0 : if (!bIsWMF)
3467 [ # # ][ # # ]: 0 : m_rExport.Strm() << "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT;
3468 : :
3469 [ # # ]: 0 : if (pBLIPType)
3470 [ # # ][ # # ]: 0 : ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm() );
3471 : : else
3472 : : {
3473 [ # # ]: 0 : aStream.Seek(0);
3474 [ # # ]: 0 : GraphicConverter::Export(aStream, aGraphic, CVT_WMF);
3475 : 0 : pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
3476 [ # # ]: 0 : aStream.Seek(STREAM_SEEK_TO_END);
3477 : 0 : nSize = aStream.Tell();
3478 [ # # ]: 0 : pGraphicAry = (sal_uInt8*)aStream.GetData();
3479 : :
3480 [ # # ][ # # ]: 0 : ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm() );
3481 : : }
3482 : :
3483 [ # # ]: 0 : if (!bIsWMF)
3484 : : {
3485 [ # # ][ # # ]: 0 : m_rExport.Strm() << "}" "{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT;
3486 : :
3487 [ # # ]: 0 : aStream.Seek(0);
3488 [ # # ]: 0 : GraphicConverter::Export(aStream, aGraphic, CVT_WMF);
3489 : 0 : pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
3490 [ # # ]: 0 : aStream.Seek(STREAM_SEEK_TO_END);
3491 : 0 : nSize = aStream.Tell();
3492 [ # # ]: 0 : pGraphicAry = (sal_uInt8*)aStream.GetData();
3493 : :
3494 [ # # ][ # # ]: 0 : ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm() );
3495 : :
3496 [ # # ][ # # ]: 0 : m_rExport.Strm() << '}';
3497 : : }
3498 : :
3499 [ # # ][ # # ]: 0 : m_rExport.Strm() << m_rExport.sNewLine;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
3500 [ + - ][ + - ]: 54 : }
3501 : :
3502 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|