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