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