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