1efeef26fSAndrew Rist /**************************************************************
2efeef26fSAndrew Rist  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "rtfattributeoutput.hxx"
25cdf0e10cSrcweir #include "rtfexport.hxx"
26cdf0e10cSrcweir #include "rtfsdrexport.hxx"
27cdf0e10cSrcweir #include "writerwordglue.hxx"
28cdf0e10cSrcweir #include "wrtww8.hxx"
29cdf0e10cSrcweir #include "ww8par.hxx"
30cdf0e10cSrcweir #include "fmtcntnt.hxx"
31cdf0e10cSrcweir #include "fmtsrnd.hxx"
32cdf0e10cSrcweir #include "fchrfmt.hxx"
33cdf0e10cSrcweir #include "tgrditem.hxx"
34cdf0e10cSrcweir #include "fmtruby.hxx"
35cdf0e10cSrcweir #include "charfmt.hxx"
36cdf0e10cSrcweir #include "breakit.hxx"
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <hintids.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include <svl/poolitem.hxx>
43cdf0e10cSrcweir #include <svtools/rtfkeywd.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <editeng/fontitem.hxx>
46cdf0e10cSrcweir #include <editeng/tstpitem.hxx>
47cdf0e10cSrcweir #include <editeng/adjitem.hxx>
48cdf0e10cSrcweir #include <editeng/spltitem.hxx>
49cdf0e10cSrcweir #include <editeng/widwitem.hxx>
50cdf0e10cSrcweir #include <editeng/lspcitem.hxx>
51cdf0e10cSrcweir #include <editeng/keepitem.hxx>
52cdf0e10cSrcweir #include <editeng/shaditem.hxx>
53cdf0e10cSrcweir #include <editeng/brshitem.hxx>
54cdf0e10cSrcweir #include <editeng/postitem.hxx>
55cdf0e10cSrcweir #include <editeng/wghtitem.hxx>
56cdf0e10cSrcweir #include <editeng/kernitem.hxx>
57cdf0e10cSrcweir #include <editeng/crsditem.hxx>
58cdf0e10cSrcweir #include <editeng/cmapitem.hxx>
59cdf0e10cSrcweir #include <editeng/wrlmitem.hxx>
60cdf0e10cSrcweir #include <editeng/udlnitem.hxx>
61cdf0e10cSrcweir #include <editeng/langitem.hxx>
62cdf0e10cSrcweir #include <editeng/escpitem.hxx>
63cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
64cdf0e10cSrcweir #include <editeng/colritem.hxx>
65cdf0e10cSrcweir #include <editeng/hyznitem.hxx>
66cdf0e10cSrcweir #include <editeng/brkitem.hxx>
67cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
68cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
69cdf0e10cSrcweir #include <editeng/boxitem.hxx>
70cdf0e10cSrcweir #include <editeng/cntritem.hxx>
71cdf0e10cSrcweir #include <editeng/shdditem.hxx>
72cdf0e10cSrcweir #include <editeng/akrnitem.hxx>
73cdf0e10cSrcweir #include <editeng/pbinitem.hxx>
74cdf0e10cSrcweir #include <editeng/emphitem.hxx>
75cdf0e10cSrcweir #include <editeng/twolinesitem.hxx>
76cdf0e10cSrcweir #include <editeng/charscaleitem.hxx>
77cdf0e10cSrcweir #include <editeng/charrotateitem.hxx>
78cdf0e10cSrcweir #include <editeng/charreliefitem.hxx>
79cdf0e10cSrcweir #include <editeng/paravertalignitem.hxx>
80cdf0e10cSrcweir #include <editeng/pgrditem.hxx>
81cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
82cdf0e10cSrcweir #include <editeng/blnkitem.hxx>
83cdf0e10cSrcweir #include <editeng/charhiddenitem.hxx>
84cdf0e10cSrcweir #include <svx/svdmodel.hxx>
85cdf0e10cSrcweir #include <svx/svdobj.hxx>
86cdf0e10cSrcweir #include <svx/fmglob.hxx>
87cdf0e10cSrcweir #include <svx/svdouno.hxx>
88cdf0e10cSrcweir #include <filter/msfilter/msoleexp.hxx>
89cdf0e10cSrcweir 
90cdf0e10cSrcweir #include <docufld.hxx>
91cdf0e10cSrcweir #include <flddropdown.hxx>
92cdf0e10cSrcweir #include <format.hxx>
93cdf0e10cSrcweir #include <fmtclds.hxx>
94cdf0e10cSrcweir #include <fmtinfmt.hxx>
95cdf0e10cSrcweir #include <fmtfld.hxx>
96cdf0e10cSrcweir #include <fmtfsize.hxx>
97cdf0e10cSrcweir #include <fmtftn.hxx>
98cdf0e10cSrcweir #include <fmtrowsplt.hxx>
99cdf0e10cSrcweir #include <fmtline.hxx>
100cdf0e10cSrcweir #include <fmtanchr.hxx>
101cdf0e10cSrcweir #include <frmfmt.hxx>
102cdf0e10cSrcweir #include <frmatr.hxx>
103cdf0e10cSrcweir #include <ftninfo.hxx>
104cdf0e10cSrcweir #include <htmltbl.hxx>
105cdf0e10cSrcweir #include <ndgrf.hxx>
106cdf0e10cSrcweir #include <ndtxt.hxx>
107cdf0e10cSrcweir #include <node.hxx>
108cdf0e10cSrcweir #include <pagedesc.hxx>
109cdf0e10cSrcweir #include <paratr.hxx>
110cdf0e10cSrcweir #include <swmodule.hxx>
111cdf0e10cSrcweir #include <swtable.hxx>
112cdf0e10cSrcweir #include <txtftn.hxx>
113cdf0e10cSrcweir #include <txtinet.hxx>
114cdf0e10cSrcweir #include <numrule.hxx>
115cdf0e10cSrcweir #include <grfatr.hxx>
116cdf0e10cSrcweir #include <ndole.hxx>
117cdf0e10cSrcweir #include <lineinfo.hxx>
118cdf0e10cSrcweir #include <rtf.hxx>
119cdf0e10cSrcweir 
120cdf0e10cSrcweir #include <rtl/strbuf.hxx>
121cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
122cdf0e10cSrcweir #include <rtl/ustring.hxx>
123cdf0e10cSrcweir 
124cdf0e10cSrcweir #include <tools/color.hxx>
125cdf0e10cSrcweir 
126cdf0e10cSrcweir #include <vcl/cvtgrf.hxx>
127cdf0e10cSrcweir 
128cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hdl>
129cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp>
130cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
131cdf0e10cSrcweir #include <com/sun/star/chart2/XChartDocument.hpp>
132cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
133cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp>
134cdf0e10cSrcweir 
135cdf0e10cSrcweir #include <osl/diagnose.h>
136cdf0e10cSrcweir 
137cdf0e10cSrcweir using rtl::OString;
138cdf0e10cSrcweir using rtl::OStringBuffer;
139cdf0e10cSrcweir using rtl::OUString;
140cdf0e10cSrcweir using rtl::OUStringBuffer;
141cdf0e10cSrcweir using rtl::OUStringToOString;
142cdf0e10cSrcweir 
143cdf0e10cSrcweir using namespace nsSwDocInfoSubType;
144cdf0e10cSrcweir using namespace nsFieldFlags;
145cdf0e10cSrcweir using namespace sw::util;
146cdf0e10cSrcweir using namespace ::com::sun::star;
147cdf0e10cSrcweir 
14893996bb7SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
14993996bb7SArmin Le Grand 
15093996bb7SArmin Le Grand class MultiBufferEntry
15193996bb7SArmin Le Grand {
15293996bb7SArmin Le Grand private:
15393996bb7SArmin Le Grand public:
15493996bb7SArmin Le Grand     MultiBufferEntry();
15593996bb7SArmin Le Grand     virtual ~MultiBufferEntry();
15693996bb7SArmin Le Grand 
15793996bb7SArmin Le Grand     virtual void writeAndClear(SvStream& rTarget) = 0;
15893996bb7SArmin Le Grand };
15993996bb7SArmin Le Grand 
16093996bb7SArmin Le Grand MultiBufferEntry::MultiBufferEntry()
16193996bb7SArmin Le Grand {
16293996bb7SArmin Le Grand }
16393996bb7SArmin Le Grand 
16493996bb7SArmin Le Grand MultiBufferEntry::~MultiBufferEntry()
16593996bb7SArmin Le Grand {
16693996bb7SArmin Le Grand }
16793996bb7SArmin Le Grand 
16893996bb7SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
16993996bb7SArmin Le Grand 
17093996bb7SArmin Le Grand class MultiBufferString : public MultiBufferEntry
17193996bb7SArmin Le Grand {
17293996bb7SArmin Le Grand private:
17393996bb7SArmin Le Grand     rtl::OStringBuffer      maBuffer;
17493996bb7SArmin Le Grand 
17593996bb7SArmin Le Grand public:
17693996bb7SArmin Le Grand     MultiBufferString(rtl::OStringBuffer& rBuffer);
17793996bb7SArmin Le Grand     virtual ~MultiBufferString();
17893996bb7SArmin Le Grand 
17993996bb7SArmin Le Grand     rtl::OStringBuffer& getBuffer() { return maBuffer; }
18093996bb7SArmin Le Grand     virtual void writeAndClear(SvStream& rTarget);
18193996bb7SArmin Le Grand };
18293996bb7SArmin Le Grand 
18393996bb7SArmin Le Grand MultiBufferString::MultiBufferString(rtl::OStringBuffer& rBuffer)
18493996bb7SArmin Le Grand :   MultiBufferEntry(),
18593996bb7SArmin Le Grand     maBuffer(rBuffer)
18693996bb7SArmin Le Grand {
18793996bb7SArmin Le Grand }
18893996bb7SArmin Le Grand 
18993996bb7SArmin Le Grand MultiBufferString::~MultiBufferString()
19093996bb7SArmin Le Grand {
19193996bb7SArmin Le Grand }
19293996bb7SArmin Le Grand 
19393996bb7SArmin Le Grand void MultiBufferString::writeAndClear(SvStream& rTarget)
19493996bb7SArmin Le Grand {
19593996bb7SArmin Le Grand     rTarget << maBuffer.makeStringAndClear();
19693996bb7SArmin Le Grand }
19793996bb7SArmin Le Grand 
19893996bb7SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
19993996bb7SArmin Le Grand 
20093996bb7SArmin Le Grand class MultiBufferHex : public MultiBufferEntry
20193996bb7SArmin Le Grand {
20293996bb7SArmin Le Grand private:
20393996bb7SArmin Le Grand     sal_uInt8*              mpData;
20493996bb7SArmin Le Grand     sal_uInt32              mnSize;
20593996bb7SArmin Le Grand     sal_uInt32              mnLimit;
20693996bb7SArmin Le Grand 
20793996bb7SArmin Le Grand public:
20893996bb7SArmin Le Grand     MultiBufferHex(
20993996bb7SArmin Le Grand         const sal_uInt8* pData,
21093996bb7SArmin Le Grand         sal_uInt32 nSize,
21193996bb7SArmin Le Grand         sal_uInt32 nLimit = 64);
21293996bb7SArmin Le Grand     virtual ~MultiBufferHex();
21393996bb7SArmin Le Grand 
21493996bb7SArmin Le Grand     virtual void writeAndClear(SvStream& rTarget);
21593996bb7SArmin Le Grand };
21693996bb7SArmin Le Grand 
21793996bb7SArmin Le Grand MultiBufferHex::MultiBufferHex(
21893996bb7SArmin Le Grand     const sal_uInt8* pData,
21993996bb7SArmin Le Grand     sal_uInt32 nSize,
22093996bb7SArmin Le Grand     sal_uInt32 nLimit)
22193996bb7SArmin Le Grand :   MultiBufferEntry(),
22293996bb7SArmin Le Grand     mpData(0),
22393996bb7SArmin Le Grand     mnSize(nSize),
22493996bb7SArmin Le Grand     mnLimit(nLimit)
22593996bb7SArmin Le Grand {
22693996bb7SArmin Le Grand     if(mnSize)
22793996bb7SArmin Le Grand     {
22893996bb7SArmin Le Grand         mpData = new sal_uInt8[mnSize];
22993996bb7SArmin Le Grand         memcpy(mpData, pData, nSize);
23093996bb7SArmin Le Grand     }
23193996bb7SArmin Le Grand }
23293996bb7SArmin Le Grand 
23393996bb7SArmin Le Grand MultiBufferHex::~MultiBufferHex()
23493996bb7SArmin Le Grand {
23593996bb7SArmin Le Grand     if(mpData)
23693996bb7SArmin Le Grand     {
23793996bb7SArmin Le Grand         delete mpData;
23893996bb7SArmin Le Grand     }
23993996bb7SArmin Le Grand }
24093996bb7SArmin Le Grand 
24193996bb7SArmin Le Grand void MultiBufferHex::writeAndClear(SvStream& rTarget)
24293996bb7SArmin Le Grand {
24393996bb7SArmin Le Grand     if(mpData)
24493996bb7SArmin Le Grand     {
24593996bb7SArmin Le Grand         static OString hexArray[16] = {
24693996bb7SArmin Le Grand             OString('0'), OString('1'), OString('2'), OString('3'),
24793996bb7SArmin Le Grand             OString('4'), OString('5'), OString('6'), OString('7'),
24893996bb7SArmin Le Grand             OString('8'), OString('9'), OString('a'), OString('b'),
24993996bb7SArmin Le Grand             OString('c'), OString('d'), OString('e'), OString('f') };
25093996bb7SArmin Le Grand 
25193996bb7SArmin Le Grand         for(sal_uInt32 a(0), nBreak(0); a < mnSize; a++, nBreak++)
25293996bb7SArmin Le Grand         {
25393996bb7SArmin Le Grand             const sal_uInt8 aData(mpData[a]);
25493996bb7SArmin Le Grand 
25593996bb7SArmin Le Grand             rTarget << hexArray[aData >> 4];
25693996bb7SArmin Le Grand             rTarget << hexArray[aData & 0x0f];
25793996bb7SArmin Le Grand 
25893996bb7SArmin Le Grand             if(mnLimit == nBreak)
25993996bb7SArmin Le Grand             {
26093996bb7SArmin Le Grand                 static OString aNewLine = OString(RtfExport::sNewLine);
26193996bb7SArmin Le Grand                 nBreak = 0;
26293996bb7SArmin Le Grand                 rTarget << aNewLine;
26393996bb7SArmin Le Grand             }
26493996bb7SArmin Le Grand         }
26593996bb7SArmin Le Grand 
26693996bb7SArmin Le Grand         delete mpData;
26793996bb7SArmin Le Grand         mpData = 0;
26893996bb7SArmin Le Grand         mnSize = 0;
26993996bb7SArmin Le Grand     }
27093996bb7SArmin Le Grand }
27193996bb7SArmin Le Grand 
27293996bb7SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
27393996bb7SArmin Le Grand 
27493996bb7SArmin Le Grand void MultiBuffer::clearContentVector()
27593996bb7SArmin Le Grand {
27693996bb7SArmin Le Grand     while(!maContent.empty())
27793996bb7SArmin Le Grand     {
27893996bb7SArmin Le Grand         delete maContent.back();
27993996bb7SArmin Le Grand         maContent.pop_back();
28093996bb7SArmin Le Grand     }
28193996bb7SArmin Le Grand }
28293996bb7SArmin Le Grand 
28393996bb7SArmin Le Grand MultiBuffer::MultiBuffer()
28493996bb7SArmin Le Grand :   maBuffer(),
28593996bb7SArmin Le Grand     maContent()
28693996bb7SArmin Le Grand {
28793996bb7SArmin Le Grand }
28893996bb7SArmin Le Grand 
28993996bb7SArmin Le Grand MultiBuffer::~MultiBuffer()
29093996bb7SArmin Le Grand {
29193996bb7SArmin Le Grand     clearContentVector();
29293996bb7SArmin Le Grand }
29393996bb7SArmin Le Grand 
29493996bb7SArmin Le Grand bool MultiBuffer::empty() const
29593996bb7SArmin Le Grand {
29693996bb7SArmin Le Grand     return 0 == maBuffer.getLength() && maContent.empty();
29793996bb7SArmin Le Grand }
29893996bb7SArmin Le Grand 
29993996bb7SArmin Le Grand void MultiBuffer::writeAndClear(SvStream& rTarget)
30093996bb7SArmin Le Grand {
30193996bb7SArmin Le Grand     for(sal_uInt32 a(0); a < maContent.size(); a++)
30293996bb7SArmin Le Grand     {
30393996bb7SArmin Le Grand         maContent[a]->writeAndClear(rTarget);
30493996bb7SArmin Le Grand     }
30593996bb7SArmin Le Grand 
30693996bb7SArmin Le Grand     clearContentVector();
30793996bb7SArmin Le Grand     rTarget << maBuffer.makeStringAndClear();
30893996bb7SArmin Le Grand }
30993996bb7SArmin Le Grand 
31093996bb7SArmin Le Grand void MultiBuffer::appendAndClear(MultiBuffer& rSource)
31193996bb7SArmin Le Grand {
31293996bb7SArmin Le Grand     if(!rSource.maContent.empty())
31393996bb7SArmin Le Grand     {
31493996bb7SArmin Le Grand         if(maBuffer.getLength())
31593996bb7SArmin Le Grand         {
31693996bb7SArmin Le Grand             maContent.push_back(new MultiBufferString(maBuffer));
31793996bb7SArmin Le Grand             maBuffer.setLength(0);
31893996bb7SArmin Le Grand         }
31993996bb7SArmin Le Grand 
32093996bb7SArmin Le Grand         for(sal_uInt32 a(0); a < rSource.maContent.size(); a++)
32193996bb7SArmin Le Grand         {
32293996bb7SArmin Le Grand             maContent.push_back(rSource.maContent[a]);
32393996bb7SArmin Le Grand         }
32493996bb7SArmin Le Grand 
32593996bb7SArmin Le Grand         rSource.maContent.clear();
32693996bb7SArmin Le Grand     }
32793996bb7SArmin Le Grand 
32893996bb7SArmin Le Grand     maBuffer.append(rSource.maBuffer.getStr());
32993996bb7SArmin Le Grand     rSource.maBuffer.setLength(0);
33093996bb7SArmin Le Grand }
33193996bb7SArmin Le Grand 
33293996bb7SArmin Le Grand void MultiBuffer::clear()
33393996bb7SArmin Le Grand {
33493996bb7SArmin Le Grand     clearContentVector();
33593996bb7SArmin Le Grand     maBuffer.setLength(0);
33693996bb7SArmin Le Grand }
33793996bb7SArmin Le Grand 
33893996bb7SArmin Le Grand void MultiBuffer::appendHexData(const sal_uInt8 *pGraphicAry, sal_uInt32 nSize, sal_uInt32 nLimit)
33993996bb7SArmin Le Grand {
34093996bb7SArmin Le Grand     if(nSize)
34193996bb7SArmin Le Grand     {
34293996bb7SArmin Le Grand         if(maBuffer.getLength())
34393996bb7SArmin Le Grand         {
34493996bb7SArmin Le Grand             maContent.push_back(new MultiBufferString(maBuffer));
34593996bb7SArmin Le Grand             maBuffer.setLength(0);
34693996bb7SArmin Le Grand         }
34793996bb7SArmin Le Grand 
34893996bb7SArmin Le Grand         maContent.push_back(new MultiBufferHex(pGraphicAry, nSize, nLimit));
34993996bb7SArmin Le Grand     }
35093996bb7SArmin Le Grand }
35193996bb7SArmin Le Grand 
35293996bb7SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
35393996bb7SArmin Le Grand 
354cdf0e10cSrcweir static OString OutTBLBorderLine(RtfExport &rExport, const SvxBorderLine* pLine, const sal_Char* pStr)
355cdf0e10cSrcweir {
356cdf0e10cSrcweir     OStringBuffer aRet;
357cdf0e10cSrcweir     aRet.append(pStr);
358cdf0e10cSrcweir     if( pLine->GetInWidth() )
359cdf0e10cSrcweir     {
360cdf0e10cSrcweir         // double line
361cdf0e10cSrcweir         aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRDB);
362cdf0e10cSrcweir         switch( pLine->GetInWidth() )
363cdf0e10cSrcweir         {
364cdf0e10cSrcweir             case DEF_LINE_WIDTH_0:
365cdf0e10cSrcweir                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRW "15");
366cdf0e10cSrcweir                 break;
367cdf0e10cSrcweir             case DEF_LINE_WIDTH_1:
368cdf0e10cSrcweir                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRW "30");
369cdf0e10cSrcweir                 break;
370cdf0e10cSrcweir             case DEF_LINE_WIDTH_2:
371cdf0e10cSrcweir             case DEF_LINE_WIDTH_3:
372cdf0e10cSrcweir                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRW "45");
373cdf0e10cSrcweir                 break;
374cdf0e10cSrcweir         }
375cdf0e10cSrcweir     }
376cdf0e10cSrcweir     else
377cdf0e10cSrcweir     {
378cdf0e10cSrcweir         // single line
379cdf0e10cSrcweir         if( DEF_LINE_WIDTH_1 >= pLine->GetOutWidth() )
380cdf0e10cSrcweir             aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRS OOO_STRING_SVTOOLS_RTF_BRDRW).append((sal_Int32)pLine->GetOutWidth());
381cdf0e10cSrcweir         else
382cdf0e10cSrcweir             aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTH OOO_STRING_SVTOOLS_RTF_BRDRW).append((sal_Int32)pLine->GetOutWidth() / 2);
383cdf0e10cSrcweir     }
384cdf0e10cSrcweir 
385cdf0e10cSrcweir     aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRCF);
386cdf0e10cSrcweir     aRet.append((sal_Int32)rExport.GetColor(pLine->GetColor()));
387cdf0e10cSrcweir     return aRet.makeStringAndClear();
388cdf0e10cSrcweir }
389cdf0e10cSrcweir 
390cdf0e10cSrcweir static OString OutBorderLine(RtfExport &rExport, const SvxBorderLine* pLine,
391cdf0e10cSrcweir     const sal_Char* pStr, sal_uInt16 nDist)
392cdf0e10cSrcweir {
393cdf0e10cSrcweir     OStringBuffer aRet;
394cdf0e10cSrcweir     aRet.append(OutTBLBorderLine(rExport, pLine, pStr));
395cdf0e10cSrcweir     aRet.append(OOO_STRING_SVTOOLS_RTF_BRSP);
396cdf0e10cSrcweir     aRet.append((sal_Int32)nDist);
397cdf0e10cSrcweir     return aRet.makeStringAndClear();
398cdf0e10cSrcweir }
399cdf0e10cSrcweir 
400cdf0e10cSrcweir static OString OutBorderLine( RtfExport &rExport, const SvxBorderLine* pLine,
401cdf0e10cSrcweir                             const char* pStr )
402cdf0e10cSrcweir {
403cdf0e10cSrcweir     OStringBuffer aRet;
404cdf0e10cSrcweir     aRet.append(pStr);
405cdf0e10cSrcweir     aRet.append(OOO_STRING_SVTOOLS_RTF_BRDLNCOL);
406cdf0e10cSrcweir     aRet.append((sal_Int32)rExport.GetColor( pLine->GetColor() ) );
407cdf0e10cSrcweir     aRet.append(OOO_STRING_SVTOOLS_RTF_BRDLNIN);
408cdf0e10cSrcweir     aRet.append((sal_Int32)pLine->GetInWidth());
409cdf0e10cSrcweir     aRet.append(OOO_STRING_SVTOOLS_RTF_BRDLNOUT);
410cdf0e10cSrcweir     aRet.append((sal_Int32)pLine->GetOutWidth());
411cdf0e10cSrcweir     aRet.append(OOO_STRING_SVTOOLS_RTF_BRDLNDIST);
412cdf0e10cSrcweir     aRet.append((sal_Int32)pLine->GetDistance());
413cdf0e10cSrcweir     return aRet.makeStringAndClear();
414cdf0e10cSrcweir }
415cdf0e10cSrcweir 
416cdf0e10cSrcweir void RtfAttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript )
417cdf0e10cSrcweir {
418cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
419cdf0e10cSrcweir     /*
420cdf0e10cSrcweir        You would have thought that
421cdf0e10cSrcweir        m_rExport.Strm() << (bIsRTL ? OOO_STRING_SVTOOLS_RTF_RTLCH : OOO_STRING_SVTOOLS_RTF_LTRCH); would be sufficent here ,
422cdf0e10cSrcweir        but looks like word needs to see the other directional token to be
423cdf0e10cSrcweir        satisified that all is kosher, otherwise it seems in ver 2003 to go and
424cdf0e10cSrcweir        semi-randomlyly stick strike through about the place. Perhaps
425cdf0e10cSrcweir        strikethrough is some ms developers "something is wrong signal" debugging
426cdf0e10cSrcweir        code that we're triggering ?
427cdf0e10cSrcweir        */
428cdf0e10cSrcweir     if (bIsRTL) {
429cdf0e10cSrcweir         m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LTRCH);
430cdf0e10cSrcweir         m_aStylesEnd.append(' ');
431cdf0e10cSrcweir         m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_RTLCH);
432cdf0e10cSrcweir     } else {
433cdf0e10cSrcweir         m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_RTLCH);
434cdf0e10cSrcweir         m_aStylesEnd.append(' ');
435cdf0e10cSrcweir         m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LTRCH);
436cdf0e10cSrcweir     }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir     switch (nScript) {
439cdf0e10cSrcweir         case i18n::ScriptType::LATIN:
440cdf0e10cSrcweir             m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LOCH);
441cdf0e10cSrcweir             break;
442cdf0e10cSrcweir         case i18n::ScriptType::ASIAN:
443cdf0e10cSrcweir             m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_DBCH);
444cdf0e10cSrcweir             break;
445cdf0e10cSrcweir         case i18n::ScriptType::COMPLEX:
446cdf0e10cSrcweir             /* noop */
447cdf0e10cSrcweir             break;
448cdf0e10cSrcweir         default:
449cdf0e10cSrcweir             /* should not happen? */
450cdf0e10cSrcweir             break;
451cdf0e10cSrcweir     }
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
454cdf0e10cSrcweir void RtfAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo )
455cdf0e10cSrcweir {
456cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
457cdf0e10cSrcweir 
458cdf0e10cSrcweir     // Output table/table row/table cell starts if needed
459cdf0e10cSrcweir     if ( pTextNodeInfo.get() )
460cdf0e10cSrcweir     {
461cdf0e10cSrcweir         sal_uInt32 nRow = pTextNodeInfo->getRow();
462cdf0e10cSrcweir         sal_uInt32 nCell = pTextNodeInfo->getCell();
463cdf0e10cSrcweir 
464cdf0e10cSrcweir         // New cell/row?
465cdf0e10cSrcweir         if ( m_nTableDepth > 0 && !m_bTableCellOpen )
466cdf0e10cSrcweir         {
467cdf0e10cSrcweir             ww8::WW8TableNodeInfoInner::Pointer_t pDeepInner( pTextNodeInfo->getInnerForDepth( m_nTableDepth ) );
468cdf0e10cSrcweir             OSL_ENSURE( pDeepInner, "TableNodeInfoInner not found");
469cdf0e10cSrcweir             if ( pDeepInner && pDeepInner->getCell() == 0 )
470cdf0e10cSrcweir                 StartTableRow( pDeepInner );
471cdf0e10cSrcweir 
472cdf0e10cSrcweir             StartTableCell( pDeepInner );
473cdf0e10cSrcweir         }
474cdf0e10cSrcweir 
475cdf0e10cSrcweir         if ( nRow == 0 && nCell == 0 )
476cdf0e10cSrcweir         {
477cdf0e10cSrcweir             // Do we have to start the table?
478cdf0e10cSrcweir             // [If we are at the rigth depth already, it means that we
479cdf0e10cSrcweir             // continue the table cell]
480cdf0e10cSrcweir             sal_uInt32 nCurrentDepth = pTextNodeInfo->getDepth();
481cdf0e10cSrcweir 
482cdf0e10cSrcweir             if ( nCurrentDepth > m_nTableDepth )
483cdf0e10cSrcweir             {
484cdf0e10cSrcweir                 // Start all the tables that begin here
485cdf0e10cSrcweir                 for ( sal_uInt32 nDepth = m_nTableDepth + 1; nDepth <= pTextNodeInfo->getDepth(); ++nDepth )
486cdf0e10cSrcweir                 {
487cdf0e10cSrcweir                     ww8::WW8TableNodeInfoInner::Pointer_t pInner( pTextNodeInfo->getInnerForDepth( nDepth ) );
488cdf0e10cSrcweir 
489cdf0e10cSrcweir                     m_bLastTable = (nDepth == pTextNodeInfo->getDepth());
490cdf0e10cSrcweir                     StartTable( pInner );
491cdf0e10cSrcweir                     StartTableRow( pInner );
492cdf0e10cSrcweir                     StartTableCell( pInner );
493cdf0e10cSrcweir                 }
494cdf0e10cSrcweir 
495cdf0e10cSrcweir                 m_nTableDepth = nCurrentDepth;
496cdf0e10cSrcweir             }
497cdf0e10cSrcweir         }
498cdf0e10cSrcweir     }
499cdf0e10cSrcweir 
50093996bb7SArmin Le Grand     OSL_ENSURE(m_aRun.empty(), "m_aRun is not empty");
501cdf0e10cSrcweir }
502cdf0e10cSrcweir 
503cdf0e10cSrcweir void RtfAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner )
504cdf0e10cSrcweir {
505cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
506cdf0e10cSrcweir 
507cdf0e10cSrcweir     FinishTableRowCell( pTextNodeInfoInner );
508cdf0e10cSrcweir 
50993996bb7SArmin Le Grand     MultiBuffer aParagraph;
510cdf0e10cSrcweir 
51193996bb7SArmin Le Grand     aParagraph.appendAndClear(m_aRun);
51293996bb7SArmin Le Grand     aParagraph.getOStringBuffer().append(m_aAfterRuns.makeStringAndClear());
513cdf0e10cSrcweir     if (m_bTblAfterCell)
514cdf0e10cSrcweir         m_bTblAfterCell = false;
515cdf0e10cSrcweir     else
516cdf0e10cSrcweir     {
51793996bb7SArmin Le Grand         aParagraph.getOStringBuffer().append(m_rExport.sNewLine);
51893996bb7SArmin Le Grand         aParagraph.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_PAR);
51993996bb7SArmin Le Grand         aParagraph.getOStringBuffer().append(' ');
520cdf0e10cSrcweir     }
521cdf0e10cSrcweir     if (m_nColBreakNeeded)
522cdf0e10cSrcweir     {
52393996bb7SArmin Le Grand         aParagraph.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_COLUMN);
524cdf0e10cSrcweir         m_nColBreakNeeded = false;
525cdf0e10cSrcweir     }
526cdf0e10cSrcweir 
527cdf0e10cSrcweir     if (!m_bBufferSectionHeaders)
52893996bb7SArmin Le Grand     {
52993996bb7SArmin Le Grand         aParagraph.writeAndClear(m_rExport.Strm());
53093996bb7SArmin Le Grand     }
531cdf0e10cSrcweir     else
53293996bb7SArmin Le Grand     {
53393996bb7SArmin Le Grand         m_aSectionHeaders.appendAndClear(aParagraph);
53493996bb7SArmin Le Grand     }
535cdf0e10cSrcweir }
536cdf0e10cSrcweir 
537cdf0e10cSrcweir void RtfAttributeOutput::EmptyParagraph()
538cdf0e10cSrcweir {
539cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
540cdf0e10cSrcweir 
541cdf0e10cSrcweir     m_rExport.Strm() << m_rExport.sNewLine << OOO_STRING_SVTOOLS_RTF_PAR << ' ';
542cdf0e10cSrcweir }
543cdf0e10cSrcweir 
544cdf0e10cSrcweir void RtfAttributeOutput::StartParagraphProperties( const SwTxtNode& rNode )
545cdf0e10cSrcweir {
546cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
547cdf0e10cSrcweir     OSL_ENSURE(m_aStyles.getLength() == 0, "m_aStyles is not empty");
548cdf0e10cSrcweir 
549cdf0e10cSrcweir     // output page/section breaks
550cdf0e10cSrcweir     SwNodeIndex aNextIndex( rNode, 1 );
551cdf0e10cSrcweir     m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear();
552cdf0e10cSrcweir     m_bBufferSectionBreaks = true;
553cdf0e10cSrcweir 
554cdf0e10cSrcweir     // output section headers / footers
555cdf0e10cSrcweir     if (!m_bBufferSectionHeaders)
55693996bb7SArmin Le Grand     {
55793996bb7SArmin Le Grand         m_aSectionHeaders.writeAndClear(m_rExport.Strm());
55893996bb7SArmin Le Grand     }
559cdf0e10cSrcweir 
560cdf0e10cSrcweir     if ( aNextIndex.GetNode().IsTxtNode() )
561cdf0e10cSrcweir     {
562cdf0e10cSrcweir         const SwTxtNode* pTxtNode = static_cast< SwTxtNode* >( &aNextIndex.GetNode() );
563cdf0e10cSrcweir         m_rExport.OutputSectionBreaks( pTxtNode->GetpSwAttrSet(), *pTxtNode );
564cdf0e10cSrcweir     }
565cdf0e10cSrcweir     else if ( aNextIndex.GetNode().IsTableNode() )
566cdf0e10cSrcweir     {
567cdf0e10cSrcweir         const SwTableNode* pTableNode = static_cast< SwTableNode* >( &aNextIndex.GetNode() );
568cdf0e10cSrcweir         const SwFrmFmt *pFmt = pTableNode->GetTable().GetFrmFmt();
569cdf0e10cSrcweir         m_rExport.OutputSectionBreaks( &(pFmt->GetAttrSet()), *pTableNode );
570cdf0e10cSrcweir     }
571cdf0e10cSrcweir     m_bBufferSectionBreaks = false;
572cdf0e10cSrcweir 
57393996bb7SArmin Le Grand     MultiBuffer aPar;
57493996bb7SArmin Le Grand 
575cdf0e10cSrcweir     if (!m_rExport.bRTFFlySyntax)
576cdf0e10cSrcweir     {
57793996bb7SArmin Le Grand         aPar.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_PARD);
57893996bb7SArmin Le Grand         aPar.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_PLAIN);
57993996bb7SArmin Le Grand         aPar.getOStringBuffer().append(' ');
580cdf0e10cSrcweir     }
58193996bb7SArmin Le Grand 
582cdf0e10cSrcweir     if (!m_bBufferSectionHeaders)
58393996bb7SArmin Le Grand     {
58493996bb7SArmin Le Grand         aPar.writeAndClear(m_rExport.Strm());
58593996bb7SArmin Le Grand     }
586cdf0e10cSrcweir     else
58793996bb7SArmin Le Grand     {
58893996bb7SArmin Le Grand         m_aSectionHeaders.appendAndClear(aPar);
58993996bb7SArmin Le Grand     }
590cdf0e10cSrcweir }
591cdf0e10cSrcweir 
592cdf0e10cSrcweir void RtfAttributeOutput::EndParagraphProperties()
593cdf0e10cSrcweir {
594cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
595cdf0e10cSrcweir     m_aStyles.append(m_aStylesEnd.makeStringAndClear());
596cdf0e10cSrcweir     m_rExport.Strm() << m_aStyles.makeStringAndClear();
597cdf0e10cSrcweir }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir void RtfAttributeOutput::StartRun( const SwRedlineData* pRedlineData )
600cdf0e10cSrcweir {
601cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
602cdf0e10cSrcweir 
60393996bb7SArmin Le Grand     m_aRun.getOStringBuffer().append('{');
604cdf0e10cSrcweir 
605cdf0e10cSrcweir     // if there is some redlining in the document, output it
606cdf0e10cSrcweir     Redline( pRedlineData );
607cdf0e10cSrcweir 
60893996bb7SArmin Le Grand     OSL_ENSURE(m_aRunText.empty(), "m_aRunText is not empty");
609cdf0e10cSrcweir }
610cdf0e10cSrcweir 
611cdf0e10cSrcweir void RtfAttributeOutput::EndRun()
612cdf0e10cSrcweir {
613cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
61493996bb7SArmin Le Grand     m_aRun.getOStringBuffer().append(m_rExport.sNewLine);
61593996bb7SArmin Le Grand     m_aRun.appendAndClear(m_aRunText);
61693996bb7SArmin Le Grand     m_aRun.getOStringBuffer().append('}');
617cdf0e10cSrcweir }
618cdf0e10cSrcweir 
619cdf0e10cSrcweir void RtfAttributeOutput::StartRunProperties()
620cdf0e10cSrcweir {
621cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
622cdf0e10cSrcweir     OSL_ENSURE(m_aStyles.getLength() == 0, "m_aStyles is not empty");
623cdf0e10cSrcweir }
624cdf0e10cSrcweir 
625cdf0e10cSrcweir void RtfAttributeOutput::EndRunProperties( const SwRedlineData* /*pRedlineData*/ )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
628cdf0e10cSrcweir     m_aStyles.append(m_aStylesEnd.makeStringAndClear());
62993996bb7SArmin Le Grand     m_aRun.getOStringBuffer().append(m_aStyles.makeStringAndClear());
630cdf0e10cSrcweir }
631cdf0e10cSrcweir 
632cdf0e10cSrcweir void RtfAttributeOutput::RunText( const String& rText, rtl_TextEncoding eCharSet )
633cdf0e10cSrcweir {
634cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
635cdf0e10cSrcweir     RawText( rText, 0, eCharSet );
636cdf0e10cSrcweir }
637cdf0e10cSrcweir 
63893996bb7SArmin Le Grand rtl::OStringBuffer& RtfAttributeOutput::RunText()
639cdf0e10cSrcweir {
64093996bb7SArmin Le Grand     return m_aRunText.getOStringBuffer();
641cdf0e10cSrcweir }
642cdf0e10cSrcweir 
643cdf0e10cSrcweir OStringBuffer& RtfAttributeOutput::Styles()
644cdf0e10cSrcweir {
645cdf0e10cSrcweir     return m_aStyles;
646cdf0e10cSrcweir }
647cdf0e10cSrcweir 
648cdf0e10cSrcweir void RtfAttributeOutput::RawText( const String& rText, bool /*bForceUnicode*/, rtl_TextEncoding eCharSet )
649cdf0e10cSrcweir {
650cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
65193996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append(m_rExport.OutString(rText, eCharSet));
652cdf0e10cSrcweir }
653cdf0e10cSrcweir 
654cdf0e10cSrcweir void RtfAttributeOutput::StartRuby( const SwTxtNode& /*rNode*/, const SwFmtRuby& /*rRuby*/ )
655cdf0e10cSrcweir {
656cdf0e10cSrcweir     OSL_TRACE("TODO: %s", OSL_THIS_FUNC);
657cdf0e10cSrcweir }
658cdf0e10cSrcweir 
659cdf0e10cSrcweir void RtfAttributeOutput::EndRuby()
660cdf0e10cSrcweir {
661cdf0e10cSrcweir     OSL_TRACE("TODO: %s", OSL_THIS_FUNC);
662cdf0e10cSrcweir }
663cdf0e10cSrcweir 
664cdf0e10cSrcweir bool RtfAttributeOutput::StartURL( const String& rUrl, const String& rTarget )
665cdf0e10cSrcweir {
666cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
667cdf0e10cSrcweir 
668cdf0e10cSrcweir     m_aStyles.append('{');
669cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FIELD);
670cdf0e10cSrcweir     m_aStyles.append('{');
671cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE);
672cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FLDINST);
673cdf0e10cSrcweir     m_aStyles.append(" HYPERLINK ");
674cdf0e10cSrcweir 
675cdf0e10cSrcweir     String sURL( rUrl );
676cdf0e10cSrcweir     if( sURL.Len() )
677cdf0e10cSrcweir     {
678cdf0e10cSrcweir         m_aStyles.append("\"");
679cdf0e10cSrcweir         m_aStyles.append(m_rExport.OutString( sURL, m_rExport.eCurrentEncoding));
680cdf0e10cSrcweir         m_aStyles.append("\" ");
681cdf0e10cSrcweir     }
682cdf0e10cSrcweir 
683cdf0e10cSrcweir     if( rTarget.Len() )
684cdf0e10cSrcweir     {
685cdf0e10cSrcweir         m_aStyles.append("\\\\t \"");
686cdf0e10cSrcweir         m_aStyles.append(m_rExport.OutString( rTarget, m_rExport.eCurrentEncoding));
687cdf0e10cSrcweir         m_aStyles.append("\" ");
688cdf0e10cSrcweir     }
689cdf0e10cSrcweir 
690cdf0e10cSrcweir     m_aStyles.append("}");
691cdf0e10cSrcweir     return true;
692cdf0e10cSrcweir }
693cdf0e10cSrcweir 
694cdf0e10cSrcweir bool RtfAttributeOutput::EndURL()
695cdf0e10cSrcweir {
696cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
697cdf0e10cSrcweir 
698cdf0e10cSrcweir     // close the fldrslt group
69993996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append('}');
700cdf0e10cSrcweir     // close the field group
70193996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append('}');
702cdf0e10cSrcweir     return true;
703cdf0e10cSrcweir }
704cdf0e10cSrcweir 
705cdf0e10cSrcweir void RtfAttributeOutput::FieldVanish( const String& /*rTxt*/, ww::eField /*eType*/ )
706cdf0e10cSrcweir {
707cdf0e10cSrcweir     OSL_TRACE("TODO: %s", OSL_THIS_FUNC);
708cdf0e10cSrcweir }
709cdf0e10cSrcweir 
710cdf0e10cSrcweir void RtfAttributeOutput::Redline( const SwRedlineData* pRedline )
711cdf0e10cSrcweir {
712cdf0e10cSrcweir     if (!pRedline)
713cdf0e10cSrcweir         return;
714cdf0e10cSrcweir 
715cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
716cdf0e10cSrcweir 
717cdf0e10cSrcweir     if (pRedline->GetType() == nsRedlineType_t::REDLINE_INSERT)
718cdf0e10cSrcweir     {
71993996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_REVISED);
72093996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_REVAUTH);
72193996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append((sal_Int32)m_rExport.GetRedline(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor())));
72293996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_REVDTTM);
723cdf0e10cSrcweir     }
724cdf0e10cSrcweir     else if(pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE)
725cdf0e10cSrcweir     {
72693996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_DELETED);
72793996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_REVAUTHDEL);
72893996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append((sal_Int32)m_rExport.GetRedline(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor())));
72993996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_REVDTTMDEL);
730cdf0e10cSrcweir     }
73193996bb7SArmin Le Grand     m_aRun.getOStringBuffer().append((sal_Int32)sw::ms::DateTime2DTTM(pRedline->GetTimeStamp()));
73293996bb7SArmin Le Grand     m_aRun.getOStringBuffer().append(' ');
733cdf0e10cSrcweir }
734cdf0e10cSrcweir 
735cdf0e10cSrcweir void RtfAttributeOutput::FormatDrop( const SwTxtNode& /*rNode*/, const SwFmtDrop& /*rSwFmtDrop*/, sal_uInt16 /*nStyle*/, ww8::WW8TableNodeInfo::Pointer_t /*pTextNodeInfo*/, ww8::WW8TableNodeInfoInner::Pointer_t /*pTextNodeInfoInner*/ )
736cdf0e10cSrcweir {
737cdf0e10cSrcweir     OSL_TRACE("TODO: %s", OSL_THIS_FUNC);
738cdf0e10cSrcweir }
739cdf0e10cSrcweir 
740cdf0e10cSrcweir void RtfAttributeOutput::ParagraphStyle( sal_uInt16 nStyle )
741cdf0e10cSrcweir {
742cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
743cdf0e10cSrcweir 
744cdf0e10cSrcweir     OString *pStyle = m_rExport.GetStyle(nStyle);
74593996bb7SArmin Le Grand     MultiBuffer aStyle;
74693996bb7SArmin Le Grand 
74793996bb7SArmin Le Grand     aStyle.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_S);
74893996bb7SArmin Le Grand     aStyle.getOStringBuffer().append((sal_Int32)nStyle);
74993996bb7SArmin Le Grand 
750cdf0e10cSrcweir     if (pStyle)
75193996bb7SArmin Le Grand     {
75293996bb7SArmin Le Grand         aStyle.getOStringBuffer().append(pStyle->getStr());
75393996bb7SArmin Le Grand     }
75493996bb7SArmin Le Grand 
755cdf0e10cSrcweir     if (!m_bBufferSectionHeaders)
75693996bb7SArmin Le Grand     {
75793996bb7SArmin Le Grand         aStyle.writeAndClear(m_rExport.Strm());
75893996bb7SArmin Le Grand     }
759cdf0e10cSrcweir     else
76093996bb7SArmin Le Grand     {
76193996bb7SArmin Le Grand         m_aSectionHeaders.appendAndClear(aStyle);
76293996bb7SArmin Le Grand     }
763cdf0e10cSrcweir }
764cdf0e10cSrcweir 
765cdf0e10cSrcweir void RtfAttributeOutput::TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
766cdf0e10cSrcweir {
767cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
768cdf0e10cSrcweir 
769cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_INTBL);
770cdf0e10cSrcweir     if ( m_nTableDepth > 1 )
771cdf0e10cSrcweir     {
772cdf0e10cSrcweir         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ITAP);
773cdf0e10cSrcweir         m_aStyles.append((sal_Int32)m_nTableDepth);
774cdf0e10cSrcweir     }
775cdf0e10cSrcweir     m_bWroteCellInfo = true;
776cdf0e10cSrcweir }
777cdf0e10cSrcweir 
778cdf0e10cSrcweir void RtfAttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfo*/ )
779cdf0e10cSrcweir {
780cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
781cdf0e10cSrcweir 
782cdf0e10cSrcweir     /* noop */
783cdf0e10cSrcweir }
784cdf0e10cSrcweir 
785cdf0e10cSrcweir void RtfAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
786cdf0e10cSrcweir {
787cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
788cdf0e10cSrcweir 
789cdf0e10cSrcweir     if ( !m_pTableWrt )
790cdf0e10cSrcweir         InitTableHelper( pTableTextNodeInfoInner );
791cdf0e10cSrcweir 
792cdf0e10cSrcweir     const SwTableBox *pTblBox = pTableTextNodeInfoInner->getTableBox( );
793cdf0e10cSrcweir     SwFrmFmt *pFmt = pTblBox->GetFrmFmt( );
794cdf0e10cSrcweir 
795cdf0e10cSrcweir     m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TROWD);
796cdf0e10cSrcweir     TableOrientation( pTableTextNodeInfoInner );
797cdf0e10cSrcweir     TableBidi( pTableTextNodeInfoInner );
798cdf0e10cSrcweir     TableHeight( pTableTextNodeInfoInner );
799cdf0e10cSrcweir     TableCanSplit( pTableTextNodeInfoInner );
800cdf0e10cSrcweir 
801cdf0e10cSrcweir     // Cell margins
802cdf0e10cSrcweir     const SvxBoxItem& rBox = pFmt->GetBox( );
803cdf0e10cSrcweir     static const sal_uInt16 aBorders[] =
804cdf0e10cSrcweir     {
805cdf0e10cSrcweir         BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT
806cdf0e10cSrcweir     };
807cdf0e10cSrcweir 
808cdf0e10cSrcweir     static const char* aRowPadNames[] =
809cdf0e10cSrcweir     {
810cdf0e10cSrcweir         OOO_STRING_SVTOOLS_RTF_TRPADDT, OOO_STRING_SVTOOLS_RTF_TRPADDL, OOO_STRING_SVTOOLS_RTF_TRPADDB, OOO_STRING_SVTOOLS_RTF_TRPADDR
811cdf0e10cSrcweir     };
812cdf0e10cSrcweir 
813cdf0e10cSrcweir     static const char* aRowPadUnits[] =
814cdf0e10cSrcweir     {
815cdf0e10cSrcweir         OOO_STRING_SVTOOLS_RTF_TRPADDFT, OOO_STRING_SVTOOLS_RTF_TRPADDFL, OOO_STRING_SVTOOLS_RTF_TRPADDFB, OOO_STRING_SVTOOLS_RTF_TRPADDFR
816cdf0e10cSrcweir     };
817cdf0e10cSrcweir 
818cdf0e10cSrcweir     for (int i = 0; i < 4; ++i)
819cdf0e10cSrcweir     {
820cdf0e10cSrcweir         m_aRowDefs.append(aRowPadUnits[i]);
821cdf0e10cSrcweir         m_aRowDefs.append((sal_Int32)3);
822cdf0e10cSrcweir         m_aRowDefs.append(aRowPadNames[i]);
823cdf0e10cSrcweir         m_aRowDefs.append((sal_Int32)rBox.GetDistance(aBorders[i]));
824cdf0e10cSrcweir     }
825cdf0e10cSrcweir 
826cdf0e10cSrcweir     // The cell-dependent properties
827cdf0e10cSrcweir     const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
828cdf0e10cSrcweir     SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
829cdf0e10cSrcweir     SwTwips nSz = 0;
830cdf0e10cSrcweir     Point aPt;
831cdf0e10cSrcweir     SwRect aRect( pFmt->FindLayoutRect( false, &aPt ));
832cdf0e10cSrcweir     SwTwips nPageSize = aRect.Width();
833cdf0e10cSrcweir     SwTwips nTblSz = pFmt->GetFrmSize().GetWidth();
834cdf0e10cSrcweir     for( sal_uInt16 i = 0; i < pRow->GetCells().Count(); i++ )
835cdf0e10cSrcweir     {
836cdf0e10cSrcweir         SwWriteTableCell *pCell = pRow->GetCells( )[ i ];
837cdf0e10cSrcweir         const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
838cdf0e10cSrcweir 
839cdf0e10cSrcweir         pTableTextNodeInfoInner->setCell( i );
840cdf0e10cSrcweir         TableCellProperties(pTableTextNodeInfoInner);
841cdf0e10cSrcweir 
842cdf0e10cSrcweir         // Right boundary: this can't be in TableCellProperties as the old
843cdf0e10cSrcweir         // value of nSz is needed.
844cdf0e10cSrcweir         nSz += pCellFmt->GetFrmSize().GetWidth();
845cdf0e10cSrcweir         m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CELLX);
846cdf0e10cSrcweir         SwTwips nCalc = nSz;
847cdf0e10cSrcweir         nCalc *= nPageSize;
848cdf0e10cSrcweir         nCalc /= nTblSz;
849cdf0e10cSrcweir         m_aRowDefs.append( (sal_Int32)(pFmt->GetLRSpace().GetLeft() + nCalc) );
850cdf0e10cSrcweir     }
851cdf0e10cSrcweir }
852cdf0e10cSrcweir 
853cdf0e10cSrcweir void RtfAttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
854cdf0e10cSrcweir {
855cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
856cdf0e10cSrcweir 
857cdf0e10cSrcweir     /*
858cdf0e10cSrcweir      * The function name is a bit misleading: given that we write borders
859cdf0e10cSrcweir      * before each row, we just have borders, not default ones. Additionally,
860cdf0e10cSrcweir      * this function actually writes borders for a specific cell only and is
861cdf0e10cSrcweir      * called for each cell.
862cdf0e10cSrcweir      */
863cdf0e10cSrcweir 
864cdf0e10cSrcweir     const SwTableBox *pTblBox = pTableTextNodeInfoInner->getTableBox( );
865cdf0e10cSrcweir     SwFrmFmt *pFmt = pTblBox->GetFrmFmt( );
866cdf0e10cSrcweir     const SvxBoxItem& rDefault = pFmt->GetBox( );
867cdf0e10cSrcweir     const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
868cdf0e10cSrcweir     SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
869cdf0e10cSrcweir     SwWriteTableCell *pCell = pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ];
870cdf0e10cSrcweir     const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
871cdf0e10cSrcweir     const SfxPoolItem* pItem;
872cdf0e10cSrcweir     if (SFX_ITEM_SET == pCellFmt->GetAttrSet().GetItemState(RES_BOX, sal_True, &pItem))
873cdf0e10cSrcweir     {
874cdf0e10cSrcweir         const SvxBoxItem& rBox = (SvxBoxItem&)*pItem;
875cdf0e10cSrcweir         static const sal_uInt16 aBorders[] =
876cdf0e10cSrcweir         {
877cdf0e10cSrcweir             BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT
878cdf0e10cSrcweir         };
879cdf0e10cSrcweir         static const char* aBorderNames[] =
880cdf0e10cSrcweir         {
881cdf0e10cSrcweir             OOO_STRING_SVTOOLS_RTF_CLBRDRT, OOO_STRING_SVTOOLS_RTF_CLBRDRL, OOO_STRING_SVTOOLS_RTF_CLBRDRB, OOO_STRING_SVTOOLS_RTF_CLBRDRR
882cdf0e10cSrcweir         };
883cdf0e10cSrcweir         //Yes left and top are swapped with eachother for cell padding! Because
884cdf0e10cSrcweir         //that's what the thunderingly annoying rtf export/import word xp does.
885cdf0e10cSrcweir         static const char* aCellPadNames[] =
886cdf0e10cSrcweir         {
887cdf0e10cSrcweir             OOO_STRING_SVTOOLS_RTF_CLPADL, OOO_STRING_SVTOOLS_RTF_CLPADT, OOO_STRING_SVTOOLS_RTF_CLPADB, OOO_STRING_SVTOOLS_RTF_CLPADR
888cdf0e10cSrcweir         };
889cdf0e10cSrcweir         static const char* aCellPadUnits[] =
890cdf0e10cSrcweir         {
891cdf0e10cSrcweir             OOO_STRING_SVTOOLS_RTF_CLPADFL, OOO_STRING_SVTOOLS_RTF_CLPADFT, OOO_STRING_SVTOOLS_RTF_CLPADFB, OOO_STRING_SVTOOLS_RTF_CLPADFR
892cdf0e10cSrcweir         };
893cdf0e10cSrcweir         for (int i = 0; i < 4; ++i)
894cdf0e10cSrcweir         {
895cdf0e10cSrcweir             if (const SvxBorderLine* pLn = rBox.GetLine(aBorders[i]))
896cdf0e10cSrcweir                 m_aRowDefs.append(OutTBLBorderLine(m_rExport, pLn, aBorderNames[i]));
897cdf0e10cSrcweir             if (rDefault.GetDistance(aBorders[i]) !=
898cdf0e10cSrcweir                     rBox.GetDistance(aBorders[i]))
899cdf0e10cSrcweir             {
900cdf0e10cSrcweir                 m_aRowDefs.append(aCellPadUnits[i]);
901cdf0e10cSrcweir                 m_aRowDefs.append((sal_Int32)3);
902cdf0e10cSrcweir                 m_aRowDefs.append(aCellPadNames[i]);
903cdf0e10cSrcweir                 m_aRowDefs.append((sal_Int32)rBox.GetDistance(aBorders[i]));
904cdf0e10cSrcweir             }
905cdf0e10cSrcweir         }
906cdf0e10cSrcweir     }
907cdf0e10cSrcweir }
908cdf0e10cSrcweir 
909cdf0e10cSrcweir void RtfAttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
910cdf0e10cSrcweir {
911cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
912cdf0e10cSrcweir 
913cdf0e10cSrcweir     const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
914cdf0e10cSrcweir     SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
915cdf0e10cSrcweir     SwWriteTableCell *pCell = pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ];
916cdf0e10cSrcweir     const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
917cdf0e10cSrcweir     const SfxPoolItem* pItem;
918cdf0e10cSrcweir     if( SFX_ITEM_SET == pCellFmt->GetAttrSet().GetItemState(
919cdf0e10cSrcweir                 RES_BACKGROUND, sal_True, &pItem ))
920cdf0e10cSrcweir     {
921cdf0e10cSrcweir         const SvxBrushItem& rBack = (SvxBrushItem&)*pItem;
922cdf0e10cSrcweir         if( !rBack.GetColor().GetTransparency() )
923cdf0e10cSrcweir         {
924cdf0e10cSrcweir             m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLCBPAT);
925cdf0e10cSrcweir             m_aRowDefs.append((sal_Int32)m_rExport.GetColor(rBack.GetColor()));
926cdf0e10cSrcweir         }
927cdf0e10cSrcweir     }
928cdf0e10cSrcweir }
929cdf0e10cSrcweir 
930cdf0e10cSrcweir void RtfAttributeOutput::TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
931cdf0e10cSrcweir {
932cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
933cdf0e10cSrcweir 
934cdf0e10cSrcweir     const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
935cdf0e10cSrcweir     const SwTableLine * pTabLine = pTabBox->GetUpper();
936cdf0e10cSrcweir     const SwFrmFmt * pLineFmt = pTabLine->GetFrmFmt();
937cdf0e10cSrcweir     const SwFmtFrmSize& rLSz = pLineFmt->GetFrmSize();
938cdf0e10cSrcweir 
939cdf0e10cSrcweir     if ( ATT_VAR_SIZE != rLSz.GetHeightSizeType() && rLSz.GetHeight() )
940cdf0e10cSrcweir     {
941cdf0e10cSrcweir         sal_Int32 nHeight = 0;
942cdf0e10cSrcweir 
943cdf0e10cSrcweir         switch ( rLSz.GetHeightSizeType() )
944cdf0e10cSrcweir         {
945cdf0e10cSrcweir             case ATT_FIX_SIZE: nHeight = -rLSz.GetHeight(); break;
946cdf0e10cSrcweir             case ATT_MIN_SIZE: nHeight = rLSz.GetHeight(); break;
947cdf0e10cSrcweir             default:           break;
948cdf0e10cSrcweir         }
949cdf0e10cSrcweir 
950cdf0e10cSrcweir         if ( nHeight )
951cdf0e10cSrcweir         {
952cdf0e10cSrcweir             m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TRRH);
953cdf0e10cSrcweir             m_aRowDefs.append(nHeight);
954cdf0e10cSrcweir         }
955cdf0e10cSrcweir     }
956cdf0e10cSrcweir }
957cdf0e10cSrcweir 
958cdf0e10cSrcweir void RtfAttributeOutput::TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
959cdf0e10cSrcweir {
960cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
961cdf0e10cSrcweir 
962cdf0e10cSrcweir     const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
963cdf0e10cSrcweir     const SwTableLine * pTabLine = pTabBox->GetUpper();
964cdf0e10cSrcweir     const SwFrmFmt * pLineFmt = pTabLine->GetFrmFmt();
965cdf0e10cSrcweir     const SwFmtRowSplit& rSplittable = pLineFmt->GetRowSplit( );
966cdf0e10cSrcweir 
967cdf0e10cSrcweir     // The rtf default is to allow a row to break
968cdf0e10cSrcweir     if (rSplittable.GetValue() == 0)
969cdf0e10cSrcweir         m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TRKEEP);
970cdf0e10cSrcweir }
971cdf0e10cSrcweir 
972cdf0e10cSrcweir void RtfAttributeOutput::TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
973cdf0e10cSrcweir {
974cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
975cdf0e10cSrcweir 
976cdf0e10cSrcweir     const SwTable * pTable = pTableTextNodeInfoInner->getTable();
977cdf0e10cSrcweir     const SwFrmFmt * pFrmFmt = pTable->GetFrmFmt();
978cdf0e10cSrcweir 
979cdf0e10cSrcweir     if ( m_rExport.TrueFrameDirection( *pFrmFmt ) != FRMDIR_HORI_RIGHT_TOP )
980cdf0e10cSrcweir         m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_LTRROW);
981cdf0e10cSrcweir     else
982cdf0e10cSrcweir         m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_RTLROW);
983cdf0e10cSrcweir }
984cdf0e10cSrcweir 
985cdf0e10cSrcweir void RtfAttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
986cdf0e10cSrcweir {
987cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
988cdf0e10cSrcweir 
989cdf0e10cSrcweir     const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
990cdf0e10cSrcweir     SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
991cdf0e10cSrcweir     SwWriteTableCell *pCell = pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ];
992cdf0e10cSrcweir     const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
993cdf0e10cSrcweir     const SfxPoolItem* pItem;
994cdf0e10cSrcweir 
995cdf0e10cSrcweir     // vertical merges
996cdf0e10cSrcweir     if (pCell->GetRowSpan() > 1)
997cdf0e10cSrcweir         m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVMGF);
998cdf0e10cSrcweir     else if (pCell->GetRowSpan() == 0)
999cdf0e10cSrcweir         m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVMRG);
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir     // vertical alignment
1002cdf0e10cSrcweir     if( SFX_ITEM_SET == pCellFmt->GetAttrSet().GetItemState(
1003cdf0e10cSrcweir                 RES_VERT_ORIENT, sal_True, &pItem ) )
1004cdf0e10cSrcweir         switch( ((SwFmtVertOrient*)pItem)->GetVertOrient() )
1005cdf0e10cSrcweir         {
1006cdf0e10cSrcweir             case text::VertOrientation::CENTER: m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALC); break;
1007cdf0e10cSrcweir             case text::VertOrientation::BOTTOM: m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALB); break;
1008cdf0e10cSrcweir             default:                            m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALT); break;
1009cdf0e10cSrcweir         }
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir void RtfAttributeOutput::TableNodeInfo( ww8::WW8TableNodeInfo::Pointer_t /*pNodeInfo*/ )
1013cdf0e10cSrcweir {
1014cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir     /* noop */
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir 
1019cdf0e10cSrcweir void RtfAttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner )
1020cdf0e10cSrcweir {
1021cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir     // This is called when the nested table ends in a cell, and there's no
1024cdf0e10cSrcweir     // paragraph benhind that; so we must check for the ends of cell, rows,
1025cdf0e10cSrcweir     // and tables
1026cdf0e10cSrcweir     // ['true' to write an empty paragraph, MS Word insists on that]
1027cdf0e10cSrcweir     FinishTableRowCell( pNodeInfoInner, true );
1028cdf0e10cSrcweir }
1029cdf0e10cSrcweir 
1030cdf0e10cSrcweir void RtfAttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1031cdf0e10cSrcweir {
1032cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1033cdf0e10cSrcweir 
1034cdf0e10cSrcweir     const SwTable *pTable = pTableTextNodeInfoInner->getTable();
1035cdf0e10cSrcweir     SwFrmFmt *pFmt = pTable->GetFrmFmt( );
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir     OStringBuffer aTblAdjust( OOO_STRING_SVTOOLS_RTF_TRQL );
1038cdf0e10cSrcweir     switch (pFmt->GetHoriOrient().GetHoriOrient())
1039cdf0e10cSrcweir     {
1040cdf0e10cSrcweir         case text::HoriOrientation::CENTER:
1041cdf0e10cSrcweir             aTblAdjust.setLength(0);
1042cdf0e10cSrcweir             aTblAdjust.append(OOO_STRING_SVTOOLS_RTF_TRQC);
1043cdf0e10cSrcweir             break;
1044cdf0e10cSrcweir         case text::HoriOrientation::RIGHT:
1045cdf0e10cSrcweir             aTblAdjust.setLength(0);
1046cdf0e10cSrcweir             aTblAdjust.append(OOO_STRING_SVTOOLS_RTF_TRQR);
1047cdf0e10cSrcweir             break;
1048cdf0e10cSrcweir         case text::HoriOrientation::NONE:
1049cdf0e10cSrcweir         case text::HoriOrientation::LEFT_AND_WIDTH:
1050cdf0e10cSrcweir             aTblAdjust.append(OOO_STRING_SVTOOLS_RTF_TRLEFT);
1051cdf0e10cSrcweir             aTblAdjust.append((sal_Int32)pFmt->GetLRSpace().GetLeft());
1052cdf0e10cSrcweir             break;
1053cdf0e10cSrcweir         default:
1054cdf0e10cSrcweir             break;
1055cdf0e10cSrcweir     }
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir     m_aRowDefs.append(aTblAdjust.makeStringAndClear());
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir void RtfAttributeOutput::TableSpacing( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
1061cdf0e10cSrcweir {
1062cdf0e10cSrcweir     OSL_TRACE("TODO: %s", OSL_THIS_FUNC);
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir void RtfAttributeOutput::TableRowEnd( sal_uInt32 /*nDepth*/ )
1066cdf0e10cSrcweir {
1067cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1068cdf0e10cSrcweir 
1069cdf0e10cSrcweir     /* noop, see EndTableRow() */
1070cdf0e10cSrcweir }
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir /*
1073cdf0e10cSrcweir  * Our private table methods.
1074cdf0e10cSrcweir  */
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir void RtfAttributeOutput::InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1077cdf0e10cSrcweir {
1078cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1079cdf0e10cSrcweir 
1080cdf0e10cSrcweir     sal_uInt32 nPageSize = 0;
1081cdf0e10cSrcweir     bool bRelBoxSize = false;
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir     // Create the SwWriteTable instance to use col spans
1084cdf0e10cSrcweir     GetTablePageSize( pTableTextNodeInfoInner.get(), nPageSize, bRelBoxSize );
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir     const SwTable* pTable = pTableTextNodeInfoInner->getTable( );
1087cdf0e10cSrcweir     const SwFrmFmt *pFmt = pTable->GetFrmFmt( );
1088cdf0e10cSrcweir     SwTwips nTblSz = pFmt->GetFrmSize( ).GetWidth( );
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir     const SwHTMLTableLayout *pLayout = pTable->GetHTMLTableLayout();
1091cdf0e10cSrcweir     if( pLayout && pLayout->IsExportable() )
1092cdf0e10cSrcweir         m_pTableWrt = new SwWriteTable( pLayout );
1093cdf0e10cSrcweir     else
1094cdf0e10cSrcweir         m_pTableWrt = new SwWriteTable( pTable->GetTabLines(), (sal_uInt16)nPageSize,
1095cdf0e10cSrcweir                 (sal_uInt16)nTblSz, false);
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir void RtfAttributeOutput::StartTable( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
1099cdf0e10cSrcweir {
1100cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir     // To trigger calling InitTableHelper()
1103cdf0e10cSrcweir     delete m_pTableWrt, m_pTableWrt = NULL;
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir void RtfAttributeOutput::StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir     sal_uInt32 nCurrentDepth = pTableTextNodeInfoInner->getDepth();
1109cdf0e10cSrcweir     OSL_TRACE("%s, (depth is %d)", OSL_THIS_FUNC, (int)nCurrentDepth);
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir     TableDefinition(pTableTextNodeInfoInner);
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir     if (!m_bLastTable)
1114cdf0e10cSrcweir         m_aTables.push_back(m_aRowDefs.makeStringAndClear());
1115cdf0e10cSrcweir 
1116cdf0e10cSrcweir     // We'll write the table definition for nested tables later
1117cdf0e10cSrcweir     if ( nCurrentDepth > 1 )
1118cdf0e10cSrcweir         return;
1119cdf0e10cSrcweir     m_rExport.Strm() << m_aRowDefs.makeStringAndClear();
1120cdf0e10cSrcweir }
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir void RtfAttributeOutput::StartTableCell( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
1123cdf0e10cSrcweir {
1124cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir     m_bTableCellOpen = true;
1127cdf0e10cSrcweir }
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir void RtfAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
1130cdf0e10cSrcweir {
1131cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir     TableDefaultBorders(pTableTextNodeInfoInner);
1134cdf0e10cSrcweir     TableBackgrounds(pTableTextNodeInfoInner);
1135cdf0e10cSrcweir     TableVerticalCell(pTableTextNodeInfoInner);
1136cdf0e10cSrcweir }
1137cdf0e10cSrcweir 
1138cdf0e10cSrcweir void RtfAttributeOutput::EndTableCell( )
1139cdf0e10cSrcweir {
1140cdf0e10cSrcweir     OSL_TRACE("%s, (depth is %d)", OSL_THIS_FUNC, (int)m_nTableDepth);
1141cdf0e10cSrcweir 
1142cdf0e10cSrcweir     if (!m_bWroteCellInfo)
1143cdf0e10cSrcweir     {
1144cdf0e10cSrcweir         m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_INTBL);
1145cdf0e10cSrcweir         m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_ITAP);
1146cdf0e10cSrcweir         m_aAfterRuns.append((sal_Int32)m_nTableDepth);
1147cdf0e10cSrcweir     }
1148cdf0e10cSrcweir     if ( m_nTableDepth > 1 )
1149cdf0e10cSrcweir         m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_NESTCELL);
1150cdf0e10cSrcweir     else
1151cdf0e10cSrcweir         m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_CELL);
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir     m_bTableCellOpen = false;
1154cdf0e10cSrcweir     m_bTblAfterCell = true;
1155cdf0e10cSrcweir     m_bWroteCellInfo = false;
1156cdf0e10cSrcweir }
1157cdf0e10cSrcweir 
1158cdf0e10cSrcweir void RtfAttributeOutput::EndTableRow( )
1159cdf0e10cSrcweir {
1160cdf0e10cSrcweir     OSL_TRACE("%s, (depth is %d)", OSL_THIS_FUNC, (int)m_nTableDepth);
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir     if ( m_nTableDepth > 1 )
1163cdf0e10cSrcweir     {
1164cdf0e10cSrcweir         m_aAfterRuns.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_NESTTABLEPROPRS);
1165cdf0e10cSrcweir         if (m_aRowDefs.getLength() > 0)
1166cdf0e10cSrcweir             m_aAfterRuns.append(m_aRowDefs.makeStringAndClear());
1167cdf0e10cSrcweir         else if (m_aTables.size() > 0)
1168cdf0e10cSrcweir         {
1169cdf0e10cSrcweir             m_aAfterRuns.append(m_aTables.back());
1170cdf0e10cSrcweir             m_aTables.pop_back();
1171cdf0e10cSrcweir         }
1172cdf0e10cSrcweir         m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_NESTROW "}" "{" OOO_STRING_SVTOOLS_RTF_NONESTTABLES OOO_STRING_SVTOOLS_RTF_PAR "}");
1173cdf0e10cSrcweir     }
1174cdf0e10cSrcweir     else
1175cdf0e10cSrcweir     {
1176cdf0e10cSrcweir         if (m_aTables.size() > 0)
1177cdf0e10cSrcweir         {
1178cdf0e10cSrcweir             m_aAfterRuns.append(m_aTables.back());
1179cdf0e10cSrcweir             m_aTables.pop_back();
1180cdf0e10cSrcweir         }
1181cdf0e10cSrcweir         m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_ROW);
1182cdf0e10cSrcweir     }
1183cdf0e10cSrcweir }
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir void RtfAttributeOutput::EndTable()
1186cdf0e10cSrcweir {
1187cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir     if ( m_nTableDepth > 0 ) {
1190cdf0e10cSrcweir         m_nTableDepth--;
1191cdf0e10cSrcweir         delete m_pTableWrt, m_pTableWrt = NULL;
1192cdf0e10cSrcweir     }
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir     // We closed the table; if it is a nested table, the cell that contains it
1195cdf0e10cSrcweir     // still continues
1196cdf0e10cSrcweir     m_bTableCellOpen = true;
1197cdf0e10cSrcweir 
1198cdf0e10cSrcweir     // Cleans the table helper
1199cdf0e10cSrcweir     delete m_pTableWrt, m_pTableWrt = NULL;
1200cdf0e10cSrcweir }
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir void RtfAttributeOutput::FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t pInner, bool /*bForceEmptyParagraph*/ )
1203cdf0e10cSrcweir {
1204cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir     if ( pInner.get() )
1207cdf0e10cSrcweir     {
1208cdf0e10cSrcweir         // Where are we in the table
1209cdf0e10cSrcweir         sal_uInt32 nRow = pInner->getRow( );
1210cdf0e10cSrcweir 
1211cdf0e10cSrcweir         const SwTable *pTable = pInner->getTable( );
1212cdf0e10cSrcweir         const SwTableLines& rLines = pTable->GetTabLines( );
1213cdf0e10cSrcweir         sal_uInt16 nLinesCount = rLines.Count( );
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir         if ( pInner->isEndOfCell() )
1216cdf0e10cSrcweir             EndTableCell();
1217cdf0e10cSrcweir 
1218cdf0e10cSrcweir         // This is a line end
1219cdf0e10cSrcweir         if ( pInner->isEndOfLine() )
1220cdf0e10cSrcweir             EndTableRow();
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir         // This is the end of the table
1223cdf0e10cSrcweir         if ( pInner->isEndOfLine( ) && ( nRow + 1 ) == nLinesCount )
1224cdf0e10cSrcweir             EndTable();
1225cdf0e10cSrcweir     }
1226cdf0e10cSrcweir }
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir void RtfAttributeOutput::StartStyles()
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1231cdf0e10cSrcweir     m_rExport.Strm() << m_rExport.sNewLine << '{' << OOO_STRING_SVTOOLS_RTF_COLORTBL;
1232cdf0e10cSrcweir     m_rExport.OutColorTable();
1233cdf0e10cSrcweir     OSL_ENSURE(m_aStylesheet.getLength() == 0, "m_aStylesheet is not empty");
1234cdf0e10cSrcweir     m_aStylesheet.append(m_rExport.sNewLine);
1235cdf0e10cSrcweir     m_aStylesheet.append('{');
1236cdf0e10cSrcweir     m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_STYLESHEET);
1237cdf0e10cSrcweir }
1238cdf0e10cSrcweir 
1239cdf0e10cSrcweir void RtfAttributeOutput::EndStyles( sal_uInt16 /*nNumberOfStyles*/ )
1240cdf0e10cSrcweir {
1241cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1242cdf0e10cSrcweir     m_rExport.Strm() << '}';
1243cdf0e10cSrcweir     m_rExport.Strm() << m_aStylesheet.makeStringAndClear();
1244cdf0e10cSrcweir     m_rExport.Strm() << '}';
1245cdf0e10cSrcweir }
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir void RtfAttributeOutput::DefaultStyle( sal_uInt16 /*nStyle*/ )
1248cdf0e10cSrcweir {
1249cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1250cdf0e10cSrcweir 
1251cdf0e10cSrcweir     /* noop, the default style is always 0 in RTF */
1252cdf0e10cSrcweir }
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir void RtfAttributeOutput::StartStyle( const String& rName, bool bPapFmt,
1255cdf0e10cSrcweir         sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 /*nWwId*/, sal_uInt16 nId )
1256cdf0e10cSrcweir {
1257cdf0e10cSrcweir     OSL_TRACE("%s, rName = '%s'", OSL_THIS_FUNC,
1258cdf0e10cSrcweir             OUStringToOString( OUString( rName ), m_rExport.eCurrentEncoding ).getStr());
1259cdf0e10cSrcweir 
1260cdf0e10cSrcweir     m_aStylesheet.append('{');
1261cdf0e10cSrcweir     if (bPapFmt)
1262cdf0e10cSrcweir         m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_S);
1263cdf0e10cSrcweir     else
1264cdf0e10cSrcweir         m_aStylesheet.append( OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_CS);
1265cdf0e10cSrcweir     m_aStylesheet.append( (sal_Int32)nId );
1266cdf0e10cSrcweir 
1267cdf0e10cSrcweir     if ( nBase != 0x0FFF )
1268cdf0e10cSrcweir     {
1269cdf0e10cSrcweir         m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_SBASEDON);
1270cdf0e10cSrcweir         m_aStylesheet.append((sal_Int32)nBase);
1271cdf0e10cSrcweir     }
1272cdf0e10cSrcweir 
1273cdf0e10cSrcweir     m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_SNEXT);
1274cdf0e10cSrcweir     m_aStylesheet.append((sal_Int32)nNext);
1275cdf0e10cSrcweir 
1276cdf0e10cSrcweir     m_rStyleName = rName;
1277cdf0e10cSrcweir     m_nStyleId = nId;
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir 
1280cdf0e10cSrcweir void RtfAttributeOutput::EndStyle()
1281cdf0e10cSrcweir {
1282cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1283cdf0e10cSrcweir     m_aStyles.append(m_aStylesEnd.makeStringAndClear());
1284cdf0e10cSrcweir     OString aStyles = m_aStyles.makeStringAndClear();
1285cdf0e10cSrcweir     m_rExport.InsStyle(m_nStyleId, aStyles);
1286cdf0e10cSrcweir     m_aStylesheet.append(aStyles);
1287cdf0e10cSrcweir     m_aStylesheet.append(' ');
1288cdf0e10cSrcweir     m_aStylesheet.append(OUStringToOString( OUString( m_rStyleName ), m_rExport.eCurrentEncoding ));
1289cdf0e10cSrcweir     m_aStylesheet.append(";}");
1290cdf0e10cSrcweir     m_aStylesheet.append(m_rExport.sNewLine);
1291cdf0e10cSrcweir }
1292cdf0e10cSrcweir 
1293cdf0e10cSrcweir void RtfAttributeOutput::StartStyleProperties( bool /*bParProp*/, sal_uInt16 /*nStyle*/ )
1294cdf0e10cSrcweir {
1295cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1296cdf0e10cSrcweir     /* noop */
1297cdf0e10cSrcweir }
1298cdf0e10cSrcweir 
1299cdf0e10cSrcweir void RtfAttributeOutput::EndStyleProperties( bool /*bParProp*/ )
1300cdf0e10cSrcweir {
1301cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1302cdf0e10cSrcweir     /* noop */
1303cdf0e10cSrcweir }
1304cdf0e10cSrcweir 
1305cdf0e10cSrcweir void RtfAttributeOutput::OutlineNumbering( sal_uInt8 nLvl, const SwNumFmt& /*rNFmt*/, const SwFmt& /*rFmt*/ )
1306cdf0e10cSrcweir {
1307cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir     if ( nLvl >= WW8ListManager::nMaxLevel )
1310cdf0e10cSrcweir         nLvl = WW8ListManager::nMaxLevel - 1;
1311cdf0e10cSrcweir 
1312cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ILVL);
1313cdf0e10cSrcweir     m_aStyles.append((sal_Int32)nLvl);
1314cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_OUTLINELEVEL);
1315cdf0e10cSrcweir     m_aStyles.append((sal_Int32)nLvl);
1316cdf0e10cSrcweir }
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir void RtfAttributeOutput::PageBreakBefore( bool bBreak )
1319cdf0e10cSrcweir {
1320cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1321cdf0e10cSrcweir 
1322cdf0e10cSrcweir     if (bBreak)
1323cdf0e10cSrcweir     {
1324cdf0e10cSrcweir         m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_PAGEBB;
1325cdf0e10cSrcweir     }
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir void RtfAttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* pSectionInfo )
1329cdf0e10cSrcweir {
1330cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1331cdf0e10cSrcweir 
1332cdf0e10cSrcweir     switch (nC)
1333cdf0e10cSrcweir     {
1334cdf0e10cSrcweir         case msword::ColumnBreak:
1335cdf0e10cSrcweir             m_nColBreakNeeded = true;
1336cdf0e10cSrcweir             break;
1337cdf0e10cSrcweir         case msword::PageBreak:
1338cdf0e10cSrcweir             if ( pSectionInfo )
1339cdf0e10cSrcweir                 m_rExport.SectionProperties( *pSectionInfo );
1340cdf0e10cSrcweir             break;
1341cdf0e10cSrcweir     }
1342cdf0e10cSrcweir }
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir void RtfAttributeOutput::StartSection()
1345cdf0e10cSrcweir {
1346cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1347cdf0e10cSrcweir 
1348cdf0e10cSrcweir     m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_SECT OOO_STRING_SVTOOLS_RTF_SECTD);
1349cdf0e10cSrcweir     if (!m_bBufferSectionBreaks)
1350cdf0e10cSrcweir         m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear();
1351cdf0e10cSrcweir }
1352cdf0e10cSrcweir 
1353cdf0e10cSrcweir void RtfAttributeOutput::EndSection()
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir     /*
1358cdf0e10cSrcweir      * noop, \sect must go to StartSection or Word won't notice multiple
1359cdf0e10cSrcweir      * columns...
1360cdf0e10cSrcweir      */
1361cdf0e10cSrcweir }
1362cdf0e10cSrcweir 
1363cdf0e10cSrcweir void RtfAttributeOutput::SectionFormProtection( bool bProtected )
1364cdf0e10cSrcweir {
1365cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir     m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_SECTUNLOCKED);
1368cdf0e10cSrcweir     m_aSectionBreaks.append((sal_Int32)!bProtected);
1369cdf0e10cSrcweir }
1370cdf0e10cSrcweir 
1371cdf0e10cSrcweir void RtfAttributeOutput::SectionLineNumbering( sal_uLong /*nRestartNo*/, const SwLineNumberInfo& rLnNumInfo )
1372cdf0e10cSrcweir {
1373cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LINEMOD;
1376cdf0e10cSrcweir     m_rExport.OutLong(rLnNumInfo.GetCountBy());
1377cdf0e10cSrcweir     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LINEX;
1378cdf0e10cSrcweir     m_rExport.OutLong(rLnNumInfo.GetPosFromLeft());
1379cdf0e10cSrcweir     if (!rLnNumInfo.IsRestartEachPage())
1380cdf0e10cSrcweir         m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LINECONT;
1381cdf0e10cSrcweir }
1382cdf0e10cSrcweir 
1383cdf0e10cSrcweir void RtfAttributeOutput::SectionTitlePage()
1384cdf0e10cSrcweir {
1385cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir     /*
1388cdf0e10cSrcweir      * noop, handled in RtfExport::WriteHeaderFooter()
1389cdf0e10cSrcweir      */
1390cdf0e10cSrcweir }
1391cdf0e10cSrcweir 
1392cdf0e10cSrcweir void RtfAttributeOutput::SectionPageBorders( const SwFrmFmt* pFmt, const SwFrmFmt* /*pFirstPageFmt*/ )
1393cdf0e10cSrcweir {
1394cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1395cdf0e10cSrcweir 
1396cdf0e10cSrcweir     const SvxBoxItem& rBox = pFmt->GetBox();
1397cdf0e10cSrcweir     const SvxBorderLine *pLine = rBox.GetTop();
1398cdf0e10cSrcweir     if(pLine)
1399cdf0e10cSrcweir         m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
1400cdf0e10cSrcweir                     OOO_STRING_SVTOOLS_RTF_PGBRDRT,
1401cdf0e10cSrcweir                     rBox.GetDistance(BOX_LINE_TOP) ));
1402cdf0e10cSrcweir     pLine = rBox.GetBottom();
1403cdf0e10cSrcweir     if(pLine)
1404cdf0e10cSrcweir         m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
1405cdf0e10cSrcweir                     OOO_STRING_SVTOOLS_RTF_PGBRDRB,
1406cdf0e10cSrcweir                     rBox.GetDistance(BOX_LINE_BOTTOM) ));
1407cdf0e10cSrcweir     pLine = rBox.GetLeft();
1408cdf0e10cSrcweir     if(pLine)
1409cdf0e10cSrcweir         m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
1410cdf0e10cSrcweir                     OOO_STRING_SVTOOLS_RTF_PGBRDRL,
1411cdf0e10cSrcweir                     rBox.GetDistance(BOX_LINE_LEFT) ));
1412cdf0e10cSrcweir     pLine = rBox.GetRight();
1413cdf0e10cSrcweir     if(pLine)
1414cdf0e10cSrcweir         m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
1415cdf0e10cSrcweir                     OOO_STRING_SVTOOLS_RTF_PGBRDRR,
1416cdf0e10cSrcweir                     rBox.GetDistance(BOX_LINE_RIGHT) ));
1417cdf0e10cSrcweir }
1418cdf0e10cSrcweir 
1419cdf0e10cSrcweir void RtfAttributeOutput::SectionBiDi( bool bBiDi )
1420cdf0e10cSrcweir {
1421cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1422cdf0e10cSrcweir 
1423cdf0e10cSrcweir     m_rExport.Strm() << (bBiDi ? OOO_STRING_SVTOOLS_RTF_RTLSECT : OOO_STRING_SVTOOLS_RTF_LTRSECT);
1424cdf0e10cSrcweir }
1425cdf0e10cSrcweir 
1426cdf0e10cSrcweir void RtfAttributeOutput::SectionPageNumbering( sal_uInt16 nNumType, sal_uInt16 nPageRestartNumber )
1427cdf0e10cSrcweir {
1428cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir     if (nPageRestartNumber > 0)
1431cdf0e10cSrcweir     {
1432cdf0e10cSrcweir         m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGNSTARTS);
1433cdf0e10cSrcweir         m_aSectionBreaks.append((sal_Int32)nPageRestartNumber);
1434cdf0e10cSrcweir         m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGNRESTART);
1435cdf0e10cSrcweir     }
1436cdf0e10cSrcweir 
1437cdf0e10cSrcweir     const char* pStr = 0;
1438cdf0e10cSrcweir     switch ( nNumType )
1439cdf0e10cSrcweir     {
1440cdf0e10cSrcweir         case SVX_NUM_CHARS_UPPER_LETTER:
1441cdf0e10cSrcweir         case SVX_NUM_CHARS_UPPER_LETTER_N:  pStr = OOO_STRING_SVTOOLS_RTF_PGNUCLTR; break;
1442cdf0e10cSrcweir         case SVX_NUM_CHARS_LOWER_LETTER:
1443cdf0e10cSrcweir         case SVX_NUM_CHARS_LOWER_LETTER_N:  pStr = OOO_STRING_SVTOOLS_RTF_PGNLCLTR; break;
1444cdf0e10cSrcweir         case SVX_NUM_ROMAN_UPPER:           pStr = OOO_STRING_SVTOOLS_RTF_PGNUCRM;  break;
1445cdf0e10cSrcweir         case SVX_NUM_ROMAN_LOWER:           pStr = OOO_STRING_SVTOOLS_RTF_PGNLCRM;  break;
1446cdf0e10cSrcweir 
1447cdf0e10cSrcweir         case SVX_NUM_ARABIC:                pStr = OOO_STRING_SVTOOLS_RTF_PGNDEC;     break;
1448cdf0e10cSrcweir     }
1449cdf0e10cSrcweir     if (pStr)
1450cdf0e10cSrcweir         m_aSectionBreaks.append(pStr);
1451cdf0e10cSrcweir }
1452cdf0e10cSrcweir 
1453cdf0e10cSrcweir void RtfAttributeOutput::SectionType( sal_uInt8 nBreakCode )
1454cdf0e10cSrcweir {
1455cdf0e10cSrcweir     OSL_TRACE("%s, nBreakCode = %d", OSL_THIS_FUNC, nBreakCode);
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir     /*
1458cdf0e10cSrcweir      * break code:   0 No break, 1 New column
1459cdf0e10cSrcweir      * 2 New page, 3 Even page, 4 Odd page
1460cdf0e10cSrcweir      */
1461cdf0e10cSrcweir     const char* sType = NULL;
1462cdf0e10cSrcweir     switch ( nBreakCode )
1463cdf0e10cSrcweir     {
1464cdf0e10cSrcweir         case 1:  sType = OOO_STRING_SVTOOLS_RTF_SBKCOL; break;
1465cdf0e10cSrcweir         case 2:  sType = OOO_STRING_SVTOOLS_RTF_SBKPAGE; break;
1466cdf0e10cSrcweir         case 3:  sType = OOO_STRING_SVTOOLS_RTF_SBKEVEN; break;
1467cdf0e10cSrcweir         case 4:  sType = OOO_STRING_SVTOOLS_RTF_SBKODD; break;
1468cdf0e10cSrcweir         default: sType = OOO_STRING_SVTOOLS_RTF_SBKNONE; break;
1469cdf0e10cSrcweir     }
1470cdf0e10cSrcweir     m_aSectionBreaks.append(sType);
1471cdf0e10cSrcweir     if (!m_bBufferSectionBreaks)
1472cdf0e10cSrcweir         m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear();
1473cdf0e10cSrcweir }
1474cdf0e10cSrcweir 
1475cdf0e10cSrcweir void RtfAttributeOutput::NumberingDefinition( sal_uInt16 nId, const SwNumRule &/*rRule*/ )
1476cdf0e10cSrcweir {
1477cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1478cdf0e10cSrcweir 
1479cdf0e10cSrcweir     m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LISTOVERRIDE;
1480cdf0e10cSrcweir     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LISTID;
1481cdf0e10cSrcweir     m_rExport.OutULong(nId);
1482cdf0e10cSrcweir     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LISTOVERRIDECOUNT << '0';
1483cdf0e10cSrcweir     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LS;
1484cdf0e10cSrcweir     m_rExport.OutULong(nId) << '}';
1485cdf0e10cSrcweir }
1486cdf0e10cSrcweir 
1487cdf0e10cSrcweir void RtfAttributeOutput::StartAbstractNumbering( sal_uInt16 nId )
1488cdf0e10cSrcweir {
1489cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1490cdf0e10cSrcweir 
1491cdf0e10cSrcweir     m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LIST << OOO_STRING_SVTOOLS_RTF_LISTTEMPLATEID;
1492cdf0e10cSrcweir     m_rExport.OutULong( nId );
1493cdf0e10cSrcweir     m_nListId = nId;
1494cdf0e10cSrcweir }
1495cdf0e10cSrcweir 
1496cdf0e10cSrcweir void RtfAttributeOutput::EndAbstractNumbering()
1497cdf0e10cSrcweir {
1498cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LISTID;
1501cdf0e10cSrcweir     m_rExport.OutULong( m_nListId ) << '}' << m_rExport.sNewLine;
1502cdf0e10cSrcweir }
1503cdf0e10cSrcweir 
1504cdf0e10cSrcweir void RtfAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
1505cdf0e10cSrcweir         sal_uInt16 nStart,
1506cdf0e10cSrcweir         sal_uInt16 nNumberingType,
1507cdf0e10cSrcweir         SvxAdjust eAdjust,
1508cdf0e10cSrcweir         const sal_uInt8 * pNumLvlPos,
1509cdf0e10cSrcweir         sal_uInt8 /*nFollow*/,
1510cdf0e10cSrcweir         const wwFont * pFont,
1511cdf0e10cSrcweir         const SfxItemSet * pOutSet,
1512cdf0e10cSrcweir         sal_Int16 nIndentAt,
1513cdf0e10cSrcweir         sal_Int16 nFirstLineIndex,
1514cdf0e10cSrcweir         sal_Int16 /*nListTabPos*/,
151541623124SJian Hong Cheng         const String &rNumberingString,
151665f9e310SPavel Janík         const SvxBrushItem* /* pBrush */)
1517cdf0e10cSrcweir {
1518cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1519cdf0e10cSrcweir 
1520cdf0e10cSrcweir     m_rExport.Strm() << m_rExport.sNewLine;
1521cdf0e10cSrcweir     if( nLevel > 8 ) // RTF knows only 9 levels
1522cdf0e10cSrcweir         m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_IGNORE << OOO_STRING_SVTOOLS_RTF_SOUTLVL;
1523cdf0e10cSrcweir 
1524cdf0e10cSrcweir     m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LISTLEVEL;
1525cdf0e10cSrcweir 
1526cdf0e10cSrcweir     sal_uInt16 nVal = 0;
1527cdf0e10cSrcweir     switch( nNumberingType )
1528cdf0e10cSrcweir     {
1529cdf0e10cSrcweir         case SVX_NUM_ROMAN_UPPER:                   nVal = 1;       break;
1530cdf0e10cSrcweir         case SVX_NUM_ROMAN_LOWER:                   nVal = 2;       break;
1531cdf0e10cSrcweir         case SVX_NUM_CHARS_UPPER_LETTER:
1532cdf0e10cSrcweir         case SVX_NUM_CHARS_UPPER_LETTER_N:  nVal = 3;       break;
1533cdf0e10cSrcweir         case SVX_NUM_CHARS_LOWER_LETTER:
1534cdf0e10cSrcweir         case SVX_NUM_CHARS_LOWER_LETTER_N:  nVal = 4;       break;
1535cdf0e10cSrcweir 
1536cdf0e10cSrcweir         case SVX_NUM_BITMAP:
1537cdf0e10cSrcweir         case SVX_NUM_CHAR_SPECIAL:                  nVal = 23;      break;
1538cdf0e10cSrcweir     }
1539cdf0e10cSrcweir     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELNFC;
1540cdf0e10cSrcweir     m_rExport.OutULong( nVal );
1541cdf0e10cSrcweir 
1542cdf0e10cSrcweir     switch( eAdjust )
1543cdf0e10cSrcweir     {
1544cdf0e10cSrcweir         case SVX_ADJUST_CENTER:             nVal = 1;       break;
1545cdf0e10cSrcweir         case SVX_ADJUST_RIGHT:              nVal = 2;       break;
1546cdf0e10cSrcweir         default:                            nVal = 0;       break;
1547cdf0e10cSrcweir     }
1548cdf0e10cSrcweir     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELJC;
1549cdf0e10cSrcweir     m_rExport.OutULong( nVal );
1550cdf0e10cSrcweir 
1551cdf0e10cSrcweir     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELSTARTAT;
1552cdf0e10cSrcweir     m_rExport.OutULong( nStart );
1553cdf0e10cSrcweir 
1554cdf0e10cSrcweir     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELFOLLOW << "0";
1555cdf0e10cSrcweir 
1556cdf0e10cSrcweir     // leveltext group
1557cdf0e10cSrcweir     m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LEVELTEXT << ' ';
1558cdf0e10cSrcweir 
1559cdf0e10cSrcweir     if( SVX_NUM_CHAR_SPECIAL == nNumberingType ||
1560cdf0e10cSrcweir             SVX_NUM_BITMAP == nNumberingType )
1561cdf0e10cSrcweir     {
1562cdf0e10cSrcweir         m_rExport.Strm() << "\\'01";
1563cdf0e10cSrcweir         sal_Unicode cChar = rNumberingString.GetChar(0);
1564cdf0e10cSrcweir         m_rExport.Strm() << "\\u";
1565cdf0e10cSrcweir         m_rExport.OutULong(cChar);
1566cdf0e10cSrcweir         m_rExport.Strm() << " ?";
1567cdf0e10cSrcweir     }
1568cdf0e10cSrcweir     else
1569cdf0e10cSrcweir     {
1570cdf0e10cSrcweir         m_rExport.Strm() << "\\'" << m_rExport.OutHex( rNumberingString.Len(), 2 );
1571cdf0e10cSrcweir         m_rExport.Strm() << m_rExport.OutString( rNumberingString, m_rExport.eDefaultEncoding );
1572cdf0e10cSrcweir     }
1573cdf0e10cSrcweir 
1574cdf0e10cSrcweir     m_rExport.Strm() << ";}";
1575cdf0e10cSrcweir 
1576cdf0e10cSrcweir     // write the levelnumbers
1577cdf0e10cSrcweir     m_rExport.Strm() << "{" << OOO_STRING_SVTOOLS_RTF_LEVELNUMBERS;
1578cdf0e10cSrcweir     for( sal_uInt8 i = 0; i <= nLevel && pNumLvlPos[ i ]; ++i )
1579cdf0e10cSrcweir     {
1580cdf0e10cSrcweir         m_rExport.Strm() << "\\'" << m_rExport.OutHex(pNumLvlPos[ i ], 2).getStr();
1581cdf0e10cSrcweir     }
1582cdf0e10cSrcweir     m_rExport.Strm() << ";}";
1583cdf0e10cSrcweir 
1584cdf0e10cSrcweir     if( pOutSet )
1585cdf0e10cSrcweir     {
1586cdf0e10cSrcweir         if (pFont)
1587cdf0e10cSrcweir         {
1588cdf0e10cSrcweir             m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_F;
1589cdf0e10cSrcweir             m_rExport.OutULong(m_rExport.maFontHelper.GetId(*pFont));
1590cdf0e10cSrcweir         }
1591cdf0e10cSrcweir         m_rExport.OutputItemSet( *pOutSet, false, true, i18n::ScriptType::LATIN, m_rExport.mbExportModeRTF );
1592cdf0e10cSrcweir         m_rExport.Strm() << m_aStyles.makeStringAndClear();
1593cdf0e10cSrcweir     }
1594cdf0e10cSrcweir 
1595cdf0e10cSrcweir     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_FI;
1596cdf0e10cSrcweir     m_rExport.OutLong( nFirstLineIndex ) << OOO_STRING_SVTOOLS_RTF_LI;
1597cdf0e10cSrcweir     m_rExport.OutLong( nIndentAt );
1598cdf0e10cSrcweir 
1599cdf0e10cSrcweir     m_rExport.Strm() << '}';
1600cdf0e10cSrcweir     if( nLevel > 8 )
1601cdf0e10cSrcweir         m_rExport.Strm() << '}';
1602cdf0e10cSrcweir }
1603cdf0e10cSrcweir 
1604cdf0e10cSrcweir void RtfAttributeOutput::WriteField_Impl( const SwField* pFld, ww::eField /*eType*/, const String& rFldCmd, sal_uInt8 /*nMode*/ )
1605cdf0e10cSrcweir {
1606cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1607cdf0e10cSrcweir 
1608cdf0e10cSrcweir     // NEEDSWORK this has beeen tested only with page numbers
160993996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_FIELD);
161093996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FLDINST " ");
161193996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append(m_rExport.OutString(rFldCmd, m_rExport.eCurrentEncoding));
161293996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
1613cdf0e10cSrcweir     if (pFld)
161493996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(m_rExport.OutString(pFld->ExpandField(true), m_rExport.eDefaultEncoding));
161593996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("}}");
1616cdf0e10cSrcweir }
1617cdf0e10cSrcweir 
1618cdf0e10cSrcweir void RtfAttributeOutput::WriteBookmarks_Impl( std::vector< rtl::OUString >& rStarts, std::vector< rtl::OUString >& rEnds )
1619cdf0e10cSrcweir {
1620cdf0e10cSrcweir     for ( std::vector< OUString >::const_iterator it = rStarts.begin(), end = rStarts.end(); it < end; ++it )
1621cdf0e10cSrcweir     {
162293996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKSTART " ");
162393996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append(m_rExport.OutString(*it, m_rExport.eCurrentEncoding));
162493996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append('}');
1625cdf0e10cSrcweir     }
1626cdf0e10cSrcweir     rStarts.clear();
1627cdf0e10cSrcweir 
1628cdf0e10cSrcweir     for ( std::vector< OUString >::const_iterator it = rEnds.begin(), end = rEnds.end(); it < end; ++it )
1629cdf0e10cSrcweir     {
163093996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKEND " ");
163193996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append(m_rExport.OutString(*it, m_rExport.eCurrentEncoding));
163293996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append('}');
1633cdf0e10cSrcweir     }
1634cdf0e10cSrcweir     rEnds.clear();
1635cdf0e10cSrcweir }
1636cdf0e10cSrcweir 
1637cdf0e10cSrcweir void RtfAttributeOutput::WriteHeaderFooter_Impl( const SwFrmFmt& rFmt, bool bHeader, const sal_Char* pStr )
1638cdf0e10cSrcweir {
1639cdf0e10cSrcweir     OStringBuffer aSectionBreaks = m_aSectionBreaks;
1640cdf0e10cSrcweir     m_aSectionBreaks.setLength(0);
1641cdf0e10cSrcweir 
164293996bb7SArmin Le Grand     MultiBuffer aTemp;
164393996bb7SArmin Le Grand     aTemp.appendAndClear(m_aRun);
164493996bb7SArmin Le Grand 
164593996bb7SArmin Le Grand     m_aSectionHeaders.getOStringBuffer().append(bHeader ? OOO_STRING_SVTOOLS_RTF_HEADERY : OOO_STRING_SVTOOLS_RTF_FOOTERY);
164693996bb7SArmin Le Grand     m_aSectionHeaders.getOStringBuffer().append((sal_Int32)m_rExport.pAktPageDesc->GetMaster().GetULSpace().GetUpper());
164793996bb7SArmin Le Grand     m_aSectionHeaders.getOStringBuffer().append('{');
164893996bb7SArmin Le Grand     m_aSectionHeaders.getOStringBuffer().append(pStr);
1649cdf0e10cSrcweir     m_bBufferSectionHeaders = true;
1650cdf0e10cSrcweir     m_rExport.WriteHeaderFooterText(rFmt, bHeader);
1651cdf0e10cSrcweir     m_bBufferSectionHeaders = false;
165293996bb7SArmin Le Grand     m_aSectionHeaders.getOStringBuffer().append('}');
1653cdf0e10cSrcweir     m_aSectionBreaks = aSectionBreaks;
165493996bb7SArmin Le Grand 
165593996bb7SArmin Le Grand     m_aRun.clear();
165693996bb7SArmin Le Grand     m_aRun.appendAndClear(aTemp);
1657cdf0e10cSrcweir }
1658cdf0e10cSrcweir 
1659cdf0e10cSrcweir void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Point& /*rNdTopLeft*/ )
1660cdf0e10cSrcweir {
1661cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1662cdf0e10cSrcweir 
1663cdf0e10cSrcweir     const SwNode *pNode = rFrame.GetContent();
1664cdf0e10cSrcweir     const SwGrfNode *pGrfNode = pNode ? pNode->GetGrfNode() : 0;
1665cdf0e10cSrcweir 
1666cdf0e10cSrcweir     switch ( rFrame.GetWriterType() )
1667cdf0e10cSrcweir     {
1668cdf0e10cSrcweir         case sw::Frame::eTxtBox:
166993996bb7SArmin Le Grand             OSL_ENSURE(m_aRunText.empty(), "m_aRunText is not empty");
1670cdf0e10cSrcweir             m_rExport.mpParentFrame = &rFrame;
1671cdf0e10cSrcweir             m_rExport.bOutFlyFrmAttrs = m_rExport.bRTFFlySyntax = true;
1672cdf0e10cSrcweir             m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
167393996bb7SArmin Le Grand             m_aRunText.writeAndClear(m_rExport.Strm());
1674cdf0e10cSrcweir             m_rExport.Strm() << m_aStyles.makeStringAndClear();
1675cdf0e10cSrcweir             m_rExport.bOutFlyFrmAttrs = m_rExport.bRTFFlySyntax = false;
1676cdf0e10cSrcweir             m_rExport.Strm() << "{" OOO_STRING_SVTOOLS_RTF_IGNORE;
1677cdf0e10cSrcweir             m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
167893996bb7SArmin Le Grand             m_aRunText.writeAndClear(m_rExport.Strm());
1679cdf0e10cSrcweir             m_rExport.Strm() << m_aStyles.makeStringAndClear();
1680cdf0e10cSrcweir             m_rExport.Strm() << '}';
1681cdf0e10cSrcweir 
1682cdf0e10cSrcweir             {
1683cdf0e10cSrcweir                 /*
1684cdf0e10cSrcweir                  * Save m_aRun as we should not loose the opening brace.
1685cdf0e10cSrcweir                  * OTOH, just drop the contents of m_aRunText in case something
1686cdf0e10cSrcweir                  * would be there, causing a problem later.
1687cdf0e10cSrcweir                  */
168893996bb7SArmin Le Grand                 MultiBuffer aTemp;
168993996bb7SArmin Le Grand                 aTemp.appendAndClear(m_aRun);
169093996bb7SArmin Le Grand 
1691cdf0e10cSrcweir                 m_rExport.bRTFFlySyntax = true;
1692cdf0e10cSrcweir 
1693cdf0e10cSrcweir                 const SwFrmFmt& rFrmFmt = rFrame.GetFrmFmt( );
1694cdf0e10cSrcweir                 const SwNodeIndex* pNodeIndex = rFrmFmt.GetCntnt().GetCntntIdx();
1695cdf0e10cSrcweir                 sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex()+1                  : 0;
1696cdf0e10cSrcweir                 sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0;
1697cdf0e10cSrcweir                 m_rExport.SaveData( nStt, nEnd );
1698cdf0e10cSrcweir                 m_rExport.mpParentFrame = &rFrame;
1699cdf0e10cSrcweir                 m_rExport.WriteText( );
1700cdf0e10cSrcweir                 m_rExport.RestoreData();
1701cdf0e10cSrcweir                 m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_PARD;
1702cdf0e10cSrcweir                 m_rExport.bRTFFlySyntax = false;
170393996bb7SArmin Le Grand 
170493996bb7SArmin Le Grand                 m_aRun.appendAndClear(aTemp);
170593996bb7SArmin Le Grand                 m_aRunText.clear();
1706cdf0e10cSrcweir             }
1707cdf0e10cSrcweir 
1708cdf0e10cSrcweir             m_rExport.mpParentFrame = NULL;
1709cdf0e10cSrcweir             m_rExport.Strm() << RtfExport::sNewLine;
1710cdf0e10cSrcweir             break;
1711cdf0e10cSrcweir         case sw::Frame::eGraphic:
1712cdf0e10cSrcweir             if (!rFrame.IsInline())
1713cdf0e10cSrcweir             {
1714cdf0e10cSrcweir                 m_rExport.mpParentFrame = &rFrame;
1715cdf0e10cSrcweir                 m_rExport.bRTFFlySyntax = true;
1716cdf0e10cSrcweir                 m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
1717cdf0e10cSrcweir                 m_rExport.bRTFFlySyntax = false;
171893996bb7SArmin Le Grand                 m_aRunText.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE);
1719cdf0e10cSrcweir                 m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
172093996bb7SArmin Le Grand                 m_aRunText.getOStringBuffer().append('}');
1721cdf0e10cSrcweir                 m_rExport.mpParentFrame = NULL;
1722cdf0e10cSrcweir             }
1723cdf0e10cSrcweir 
1724cdf0e10cSrcweir             if ( pGrfNode )
1725cdf0e10cSrcweir                 FlyFrameGraphic( dynamic_cast<const SwFlyFrmFmt*>( &rFrame.GetFrmFmt() ), *pGrfNode, rFrame.GetLayoutSize() );
1726cdf0e10cSrcweir             break;
1727cdf0e10cSrcweir         case sw::Frame::eDrawing:
1728cdf0e10cSrcweir             {
1729cdf0e10cSrcweir                 const SdrObject* pSdrObj = rFrame.GetFrmFmt().FindRealSdrObject();
1730cdf0e10cSrcweir                 if ( pSdrObj )
1731cdf0e10cSrcweir                 {
1732cdf0e10cSrcweir                     bool bSwapInPage = false;
1733cdf0e10cSrcweir                     if ( !pSdrObj->GetPage() )
1734cdf0e10cSrcweir                     {
1735cdf0e10cSrcweir                         if ( SdrModel* pModel = m_rExport.pDoc->GetDrawModel() )
1736cdf0e10cSrcweir                         {
1737cdf0e10cSrcweir                             if ( SdrPage *pPage = pModel->GetPage( 0 ) )
1738cdf0e10cSrcweir                             {
1739cdf0e10cSrcweir                                 bSwapInPage = true;
1740cdf0e10cSrcweir                                 const_cast< SdrObject* >( pSdrObj )->SetPage( pPage );
1741cdf0e10cSrcweir                             }
1742cdf0e10cSrcweir                         }
1743cdf0e10cSrcweir                     }
1744cdf0e10cSrcweir 
174593996bb7SArmin Le Grand                     m_aRunText.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_FIELD "{");
174693996bb7SArmin Le Grand                     m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_IGNORE);
174793996bb7SArmin Le Grand                     m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FLDINST);
174893996bb7SArmin Le Grand                     m_aRunText.getOStringBuffer().append(" SHAPE ");
174993996bb7SArmin Le Grand                     m_aRunText.getOStringBuffer().append("}" "{" OOO_STRING_SVTOOLS_RTF_FLDRSLT);
1750cdf0e10cSrcweir 
1751cdf0e10cSrcweir                     m_rExport.SdrExporter().AddSdrObject( *pSdrObj );
1752cdf0e10cSrcweir 
175393996bb7SArmin Le Grand                     m_aRunText.getOStringBuffer().append('}');
175493996bb7SArmin Le Grand                     m_aRunText.getOStringBuffer().append('}');
1755cdf0e10cSrcweir 
1756cdf0e10cSrcweir                     if ( bSwapInPage )
1757cdf0e10cSrcweir                         const_cast< SdrObject* >( pSdrObj )->SetPage( 0 );
1758cdf0e10cSrcweir                 }
1759cdf0e10cSrcweir             }
1760cdf0e10cSrcweir             break;
1761cdf0e10cSrcweir         case sw::Frame::eFormControl:
1762cdf0e10cSrcweir             {
1763cdf0e10cSrcweir                 const SwFrmFmt &rFrmFmt = rFrame.GetFrmFmt();
1764cdf0e10cSrcweir                 const SdrObject *pObject = rFrmFmt.FindRealSdrObject();
1765cdf0e10cSrcweir 
176693996bb7SArmin Le Grand                 m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_FIELD);
176793996bb7SArmin Le Grand                 m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FLDINST);
1768cdf0e10cSrcweir 
1769cdf0e10cSrcweir                 if (pObject && pObject->GetObjInventor() == FmFormInventor)
1770cdf0e10cSrcweir                 {
1771cdf0e10cSrcweir                     if (SdrUnoObj *pFormObj = PTR_CAST(SdrUnoObj,pObject))
1772cdf0e10cSrcweir                     {
1773cdf0e10cSrcweir                         uno::Reference< awt::XControlModel > xControlModel =
1774cdf0e10cSrcweir                             pFormObj->GetUnoControlModel();
1775cdf0e10cSrcweir                         uno::Reference< lang::XServiceInfo > xInfo(xControlModel, uno::UNO_QUERY);
1776cdf0e10cSrcweir                         uno::Reference<beans::XPropertySet> xPropSet(xControlModel, uno::UNO_QUERY);
1777cdf0e10cSrcweir                         uno::Reference<beans::XPropertySetInfo> xPropSetInfo = xPropSet->getPropertySetInfo();
1778cdf0e10cSrcweir                         OUString sName;
1779cdf0e10cSrcweir                         if (xInfo->supportsService(C2U("com.sun.star.form.component.CheckBox")))
1780cdf0e10cSrcweir                         {
1781cdf0e10cSrcweir 
178293996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append(OUStringToOString(OUString(FieldString(ww::eFORMCHECKBOX)), m_rExport.eCurrentEncoding));
178393996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
178493996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FFTYPE "1"); // 1 = checkbox
1785cdf0e10cSrcweir                             // checkbox size in half points, this seems to be always 20, see WW8Export::DoCheckBox()
178693996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FFHPS "20");
1787cdf0e10cSrcweir 
1788cdf0e10cSrcweir                             OUString aStr;
1789cdf0e10cSrcweir                             sName = C2U("Name");
1790cdf0e10cSrcweir                             if (xPropSetInfo->hasPropertyByName(sName))
1791cdf0e10cSrcweir                             {
1792cdf0e10cSrcweir                                 xPropSet->getPropertyValue(sName) >>= aStr;
179393996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFNAME " ");
179493996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
179593996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append('}');
1796cdf0e10cSrcweir                             }
1797cdf0e10cSrcweir 
1798cdf0e10cSrcweir                             sName = C2U("HelpText");
1799cdf0e10cSrcweir                             if (xPropSetInfo->hasPropertyByName(sName))
1800cdf0e10cSrcweir                             {
1801cdf0e10cSrcweir                                 xPropSet->getPropertyValue(sName) >>= aStr;
180293996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
180393996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
180493996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
180593996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append('}');
1806cdf0e10cSrcweir                             }
1807cdf0e10cSrcweir 
1808cdf0e10cSrcweir                             sName = C2U("HelpF1Text");
1809cdf0e10cSrcweir                             if (xPropSetInfo->hasPropertyByName(sName))
1810cdf0e10cSrcweir                             {
1811cdf0e10cSrcweir                                 xPropSet->getPropertyValue(sName) >>= aStr;
181293996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
181393996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
181493996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
181593996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append('}');
1816cdf0e10cSrcweir                             }
1817cdf0e10cSrcweir 
1818cdf0e10cSrcweir                             sal_Int16 nTemp = 0;
1819cdf0e10cSrcweir                             xPropSet->getPropertyValue(C2U("DefaultState")) >>= nTemp;
182093996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FFDEFRES);
182193996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append((sal_Int32)nTemp);
1822cdf0e10cSrcweir                             xPropSet->getPropertyValue(C2U("State")) >>= nTemp;
182393996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FFRES);
182493996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append((sal_Int32)nTemp);
1825cdf0e10cSrcweir 
182693996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append("}}");
1827cdf0e10cSrcweir 
1828cdf0e10cSrcweir                             // field result is empty, ffres already contains the form result
182993996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
1830cdf0e10cSrcweir                         }
1831cdf0e10cSrcweir                         else if (xInfo->supportsService(C2U("com.sun.star.form.component.TextField")))
1832cdf0e10cSrcweir                         {
1833cdf0e10cSrcweir                             OStringBuffer aBuf;
1834cdf0e10cSrcweir                             OString aStr;
1835cdf0e10cSrcweir                             OUString aTmp;
1836cdf0e10cSrcweir                             const sal_Char* pStr;
1837cdf0e10cSrcweir 
183893996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append(OUStringToOString(OUString(FieldString(ww::eFORMTEXT)), m_rExport.eCurrentEncoding));
183993996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_DATAFIELD " ");
1840cdf0e10cSrcweir                             for (int i = 0; i < 8; i++) aBuf.append((sal_Char)0x00);
1841cdf0e10cSrcweir                             xPropSet->getPropertyValue(C2U("Name")) >>= aTmp;
1842cdf0e10cSrcweir                             aStr = OUStringToOString(aTmp, m_rExport.eCurrentEncoding);
1843cdf0e10cSrcweir                             aBuf.append((sal_Char)aStr.getLength());
1844cdf0e10cSrcweir                             aBuf.append(aStr);
1845cdf0e10cSrcweir                             aBuf.append((sal_Char)0x00);
1846cdf0e10cSrcweir                             xPropSet->getPropertyValue(C2U("DefaultText")) >>= aTmp;
1847cdf0e10cSrcweir                             aStr = OUStringToOString(aTmp, m_rExport.eCurrentEncoding);
1848cdf0e10cSrcweir                             aBuf.append((sal_Char)aStr.getLength());
1849cdf0e10cSrcweir                             aBuf.append(aStr);
1850cdf0e10cSrcweir                             for (int i = 0; i < 11; i++) aBuf.append((sal_Char)0x00);
1851cdf0e10cSrcweir                             aStr = aBuf.makeStringAndClear();
1852cdf0e10cSrcweir                             pStr = aStr.getStr();
1853cdf0e10cSrcweir                             for (int i = 0; i < aStr.getLength(); i++, pStr++)
185493996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(m_rExport.OutHex(*pStr, 2));
185593996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append('}');
185693996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
1857cdf0e10cSrcweir                             xPropSet->getPropertyValue(C2U("Text")) >>= aTmp;
185893996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
185993996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append('}');
186093996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
1861cdf0e10cSrcweir                             sName = C2U("HelpText");
1862cdf0e10cSrcweir                             if (xPropSetInfo->hasPropertyByName(sName))
1863cdf0e10cSrcweir                             {
1864cdf0e10cSrcweir                                 xPropSet->getPropertyValue(sName) >>= aTmp;
186593996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
186693996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
186793996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
186893996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append('}');
1869cdf0e10cSrcweir                             }
1870cdf0e10cSrcweir 
1871cdf0e10cSrcweir                             sName = C2U("HelpF1Text");
1872cdf0e10cSrcweir                             if (xPropSetInfo->hasPropertyByName(sName))
1873cdf0e10cSrcweir                             {
1874cdf0e10cSrcweir                                 xPropSet->getPropertyValue(sName) >>= aTmp;
187593996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
187693996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
187793996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
187893996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append('}');
1879cdf0e10cSrcweir                             }
188093996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append("}");
1881cdf0e10cSrcweir                         }
1882cdf0e10cSrcweir                         else if (xInfo->supportsService(C2U("com.sun.star.form.component.ListBox")))
1883cdf0e10cSrcweir                         {
1884cdf0e10cSrcweir                             OUString aStr;
1885cdf0e10cSrcweir                             uno::Sequence<sal_Int16> aIntSeq;
1886cdf0e10cSrcweir                             uno::Sequence<OUString> aStrSeq;
1887cdf0e10cSrcweir 
188893996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append(OUStringToOString(OUString(FieldString(ww::eFORMDROPDOWN)), m_rExport.eCurrentEncoding));
188993996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
189093996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FFTYPE "2"); // 2 = list
189193996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FFHASLISTBOX);
1892cdf0e10cSrcweir 
1893cdf0e10cSrcweir                             xPropSet->getPropertyValue(C2U("DefaultSelection")) >>= aIntSeq;
1894cdf0e10cSrcweir                             if( aIntSeq.getLength() )
1895cdf0e10cSrcweir                             {
189693996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FFDEFRES);
1897cdf0e10cSrcweir                                 // a dropdown list can have only one 'selected item by default'
189893996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append((sal_Int32)aIntSeq[0]);
1899cdf0e10cSrcweir                             }
1900cdf0e10cSrcweir 
1901cdf0e10cSrcweir                             xPropSet->getPropertyValue(C2U("SelectedItems")) >>= aIntSeq;
1902cdf0e10cSrcweir                             if( aIntSeq.getLength() )
1903cdf0e10cSrcweir                             {
190493996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FFRES);
1905cdf0e10cSrcweir                                 // a dropdown list can have only one 'currently selected item'
190693996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append((sal_Int32)aIntSeq[0]);
1907cdf0e10cSrcweir                             }
1908cdf0e10cSrcweir 
1909cdf0e10cSrcweir                             sName = C2U("Name");
1910cdf0e10cSrcweir                             if (xPropSetInfo->hasPropertyByName(sName))
1911cdf0e10cSrcweir                             {
1912cdf0e10cSrcweir                                 xPropSet->getPropertyValue(sName) >>= aStr;
191393996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFNAME " ");
191493996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
191593996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append('}');
1916cdf0e10cSrcweir                             }
1917cdf0e10cSrcweir 
1918cdf0e10cSrcweir                             sName = C2U("HelpText");
1919cdf0e10cSrcweir                             if (xPropSetInfo->hasPropertyByName(sName))
1920cdf0e10cSrcweir                             {
1921cdf0e10cSrcweir                                 xPropSet->getPropertyValue(sName) >>= aStr;
192293996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
192393996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
192493996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
192593996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append('}');
1926cdf0e10cSrcweir                             }
1927cdf0e10cSrcweir 
1928cdf0e10cSrcweir                             sName = C2U("HelpF1Text");
1929cdf0e10cSrcweir                             if (xPropSetInfo->hasPropertyByName(sName))
1930cdf0e10cSrcweir                             {
1931cdf0e10cSrcweir                                 xPropSet->getPropertyValue(sName) >>= aStr;
193293996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
193393996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
193493996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
193593996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append('}');
1936cdf0e10cSrcweir                             }
1937cdf0e10cSrcweir 
1938cdf0e10cSrcweir 
1939cdf0e10cSrcweir                             xPropSet->getPropertyValue(C2U("StringItemList")) >>= aStrSeq;
1940cdf0e10cSrcweir                             sal_uInt32 nListItems = aStrSeq.getLength();
1941cdf0e10cSrcweir                             for (sal_uInt32 i = 0; i < nListItems; i++)
194293996bb7SArmin Le Grand                                 m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFL " ")
1943cdf0e10cSrcweir                                     .append(OUStringToOString(aStrSeq[i], m_rExport.eCurrentEncoding)).append('}');
1944cdf0e10cSrcweir 
194593996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append("}}");
1946cdf0e10cSrcweir 
1947cdf0e10cSrcweir                             // field result is empty, ffres already contains the form result
194893996bb7SArmin Le Grand                             m_aRun.getOStringBuffer().append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
1949cdf0e10cSrcweir                         }
1950cdf0e10cSrcweir                         else
1951cdf0e10cSrcweir                             OSL_TRACE("%s unhandled form control: '%s'", OSL_THIS_FUNC,
1952cdf0e10cSrcweir                                     OUStringToOString(xInfo->getImplementationName(), m_rExport.eCurrentEncoding).getStr());
195393996bb7SArmin Le Grand                         m_aRun.getOStringBuffer().append('}');
1954cdf0e10cSrcweir                     }
1955cdf0e10cSrcweir                 }
1956cdf0e10cSrcweir 
195793996bb7SArmin Le Grand                 m_aRun.getOStringBuffer().append('}');
1958cdf0e10cSrcweir             }
1959cdf0e10cSrcweir             break;
1960cdf0e10cSrcweir         case sw::Frame::eOle:
1961cdf0e10cSrcweir             {
1962cdf0e10cSrcweir                 const SwFrmFmt &rFrmFmt = rFrame.GetFrmFmt();
1963cdf0e10cSrcweir                 const SdrObject *pSdrObj = rFrmFmt.FindRealSdrObject();
1964cdf0e10cSrcweir                 if ( pSdrObj )
1965cdf0e10cSrcweir                 {
1966cdf0e10cSrcweir                     SwNodeIndex aIdx(*rFrmFmt.GetCntnt().GetCntntIdx(), 1);
1967cdf0e10cSrcweir                     SwOLENode& rOLENd = *aIdx.GetNode().GetOLENode();
1968cdf0e10cSrcweir                     FlyFrameOLE(dynamic_cast<const SwFlyFrmFmt*>( &rFrmFmt ), rOLENd, rFrame.GetLayoutSize());
1969cdf0e10cSrcweir                 }
1970cdf0e10cSrcweir             }
1971cdf0e10cSrcweir             break;
1972cdf0e10cSrcweir         default:
1973cdf0e10cSrcweir             OSL_TRACE("%s: unknown type (%d)", OSL_THIS_FUNC, rFrame.GetWriterType());
1974cdf0e10cSrcweir             break;
1975cdf0e10cSrcweir     }
1976cdf0e10cSrcweir }
1977cdf0e10cSrcweir 
1978cdf0e10cSrcweir void RtfAttributeOutput::CharCaseMap( const SvxCaseMapItem& rCaseMap )
1979cdf0e10cSrcweir {
1980cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
1981cdf0e10cSrcweir 
1982cdf0e10cSrcweir     switch ( rCaseMap.GetValue() )
1983cdf0e10cSrcweir     {
1984cdf0e10cSrcweir         case SVX_CASEMAP_KAPITAELCHEN:
1985cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SCAPS);
1986cdf0e10cSrcweir             break;
1987cdf0e10cSrcweir         case SVX_CASEMAP_VERSALIEN:
1988cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CAPS);
1989cdf0e10cSrcweir             break;
1990cdf0e10cSrcweir         default: // Something that rtf does not support
1991cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SCAPS);
1992cdf0e10cSrcweir             m_aStyles.append((sal_Int32)0);
1993cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CAPS);
1994cdf0e10cSrcweir             m_aStyles.append((sal_Int32)0);
1995cdf0e10cSrcweir             break;
1996cdf0e10cSrcweir     }
1997cdf0e10cSrcweir }
1998cdf0e10cSrcweir 
1999cdf0e10cSrcweir void RtfAttributeOutput::CharColor( const SvxColorItem& rColor )
2000cdf0e10cSrcweir {
2001cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2002cdf0e10cSrcweir 
2003cdf0e10cSrcweir     const Color aColor( rColor.GetValue() );
2004cdf0e10cSrcweir 
2005cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CF);
2006cdf0e10cSrcweir     m_aStyles.append( (sal_Int32)m_rExport.GetColor( aColor ));
2007cdf0e10cSrcweir }
2008cdf0e10cSrcweir 
2009cdf0e10cSrcweir void RtfAttributeOutput::CharContour( const SvxContourItem& rContour )
2010cdf0e10cSrcweir {
2011cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2012cdf0e10cSrcweir 
2013cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_OUTL);
2014cdf0e10cSrcweir     if ( !rContour.GetValue() )
2015cdf0e10cSrcweir         m_aStyles.append((sal_Int32)0);
2016cdf0e10cSrcweir }
2017cdf0e10cSrcweir 
2018cdf0e10cSrcweir void RtfAttributeOutput::CharCrossedOut( const SvxCrossedOutItem& rCrossedOut )
2019cdf0e10cSrcweir {
2020cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2021cdf0e10cSrcweir 
2022cdf0e10cSrcweir     switch ( rCrossedOut.GetStrikeout() )
2023cdf0e10cSrcweir     {
2024cdf0e10cSrcweir         case STRIKEOUT_NONE:
2025cdf0e10cSrcweir             if (!m_bStrikeDouble)
2026cdf0e10cSrcweir                 m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKE);
2027cdf0e10cSrcweir             else
2028cdf0e10cSrcweir                 m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKED);
2029cdf0e10cSrcweir             m_aStyles.append((sal_Int32)0);
2030cdf0e10cSrcweir             break;
2031cdf0e10cSrcweir         case STRIKEOUT_DOUBLE:
2032cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKED);
2033cdf0e10cSrcweir             m_aStyles.append((sal_Int32)1);
2034cdf0e10cSrcweir             break;
2035cdf0e10cSrcweir         default:
2036cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKE);
2037cdf0e10cSrcweir             break;
2038cdf0e10cSrcweir     }
2039cdf0e10cSrcweir }
2040cdf0e10cSrcweir 
2041cdf0e10cSrcweir void RtfAttributeOutput::CharEscapement( const SvxEscapementItem& rEsc )
2042cdf0e10cSrcweir {
2043cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2044cdf0e10cSrcweir 
2045cdf0e10cSrcweir     const char * pUpDn;
2046cdf0e10cSrcweir 
2047cdf0e10cSrcweir     SwTwips nH = ((SvxFontHeightItem&)m_rExport.GetItem( RES_CHRATR_FONTSIZE )).GetHeight();
2048cdf0e10cSrcweir 
2049cdf0e10cSrcweir     if( 0 < rEsc.GetEsc() )
2050cdf0e10cSrcweir         pUpDn = OOO_STRING_SVTOOLS_RTF_UP;
2051cdf0e10cSrcweir     else if( 0 > rEsc.GetEsc() )
2052cdf0e10cSrcweir     {
2053cdf0e10cSrcweir         pUpDn = OOO_STRING_SVTOOLS_RTF_DN;
2054cdf0e10cSrcweir         nH = -nH;
2055cdf0e10cSrcweir     }
2056cdf0e10cSrcweir     else
2057cdf0e10cSrcweir         return;
2058cdf0e10cSrcweir 
2059cdf0e10cSrcweir     short nEsc = rEsc.GetEsc();
2060cdf0e10cSrcweir     short nProp = rEsc.GetProp() * 100;
2061cdf0e10cSrcweir     if( DFLT_ESC_AUTO_SUPER == nEsc )
2062cdf0e10cSrcweir     {
2063cdf0e10cSrcweir         nEsc = 100 - rEsc.GetProp();
2064cdf0e10cSrcweir         ++nProp;
2065cdf0e10cSrcweir     }
2066cdf0e10cSrcweir     else if( DFLT_ESC_AUTO_SUB == nEsc )
2067cdf0e10cSrcweir     {
2068cdf0e10cSrcweir         nEsc = - 100 + rEsc.GetProp();
2069cdf0e10cSrcweir         ++nProp;
2070cdf0e10cSrcweir     }
2071cdf0e10cSrcweir 
2072cdf0e10cSrcweir     m_aStyles.append('{');
2073cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE);
2074cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_UPDNPROP);
2075cdf0e10cSrcweir     m_aStyles.append( (sal_Int32)nProp );
2076cdf0e10cSrcweir     m_aStyles.append('}');
2077cdf0e10cSrcweir     m_aStyles.append(pUpDn);
2078cdf0e10cSrcweir 
2079cdf0e10cSrcweir     /*
2080cdf0e10cSrcweir      * Calculate the act. FontSize and the percentage of the displacement;
2081cdf0e10cSrcweir      * RTF file expects half points, while internally it's in twips.
2082cdf0e10cSrcweir      * Formally :            (FontSize * 1/20 ) pts         x * 2
2083cdf0e10cSrcweir      *                    -----------------------  = ------------
2084cdf0e10cSrcweir      *                      100%                       Escapement
2085cdf0e10cSrcweir      */
2086cdf0e10cSrcweir 
2087cdf0e10cSrcweir     m_aStyles.append( (sal_Int32) ( (long( nEsc ) * nH) + 500L ) / 1000L );
2088cdf0e10cSrcweir     // 500L to round !!
2089cdf0e10cSrcweir }
2090cdf0e10cSrcweir 
2091cdf0e10cSrcweir void RtfAttributeOutput::CharFont( const SvxFontItem& rFont)
2092cdf0e10cSrcweir {
2093cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2094cdf0e10cSrcweir 
2095cdf0e10cSrcweir     m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LOCH);
2096cdf0e10cSrcweir     m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_F);
2097cdf0e10cSrcweir     m_aStylesEnd.append((sal_Int32)m_rExport.maFontHelper.GetId(rFont));
2098cdf0e10cSrcweir     m_rExport.eCurrentEncoding = rtl_getTextEncodingFromWindowsCharset(sw::ms::rtl_TextEncodingToWinCharset(rFont.GetCharSet()));
2099cdf0e10cSrcweir }
2100cdf0e10cSrcweir 
2101cdf0e10cSrcweir void RtfAttributeOutput::CharFontSize( const SvxFontHeightItem& rFontSize)
2102cdf0e10cSrcweir {
2103cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2104cdf0e10cSrcweir 
2105cdf0e10cSrcweir     switch ( rFontSize.Which() )
2106cdf0e10cSrcweir     {
2107cdf0e10cSrcweir         case RES_CHRATR_FONTSIZE:
2108cdf0e10cSrcweir             m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_FS);
2109cdf0e10cSrcweir             m_aStylesEnd.append((sal_Int32)(rFontSize.GetHeight() / 10 ));
2110cdf0e10cSrcweir             break;
2111cdf0e10cSrcweir         case RES_CHRATR_CJK_FONTSIZE:
2112cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FS);
2113cdf0e10cSrcweir             m_aStyles.append((sal_Int32)(rFontSize.GetHeight() / 10 ));
2114cdf0e10cSrcweir             break;
2115cdf0e10cSrcweir         case RES_CHRATR_CTL_FONTSIZE:
2116cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AFS);
2117cdf0e10cSrcweir             m_aStyles.append((sal_Int32)(rFontSize.GetHeight() / 10 ));
2118cdf0e10cSrcweir             break;
2119cdf0e10cSrcweir     }
2120cdf0e10cSrcweir }
2121cdf0e10cSrcweir 
2122cdf0e10cSrcweir void RtfAttributeOutput::CharKerning( const SvxKerningItem& rKerning )
2123cdf0e10cSrcweir {
2124cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2125cdf0e10cSrcweir 
2126cdf0e10cSrcweir     // in quater points then in twips
2127cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_EXPND);
2128cdf0e10cSrcweir     m_aStyles.append((sal_Int32)(rKerning.GetValue() / 5));
2129cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_EXPNDTW);
2130cdf0e10cSrcweir     m_aStyles.append((sal_Int32)(rKerning.GetValue()));
2131cdf0e10cSrcweir }
2132cdf0e10cSrcweir 
2133cdf0e10cSrcweir void RtfAttributeOutput::CharLanguage( const SvxLanguageItem& rLanguage )
2134cdf0e10cSrcweir {
2135cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2136cdf0e10cSrcweir 
2137cdf0e10cSrcweir     switch (rLanguage.Which())
2138cdf0e10cSrcweir     {
2139cdf0e10cSrcweir         case RES_CHRATR_LANGUAGE:
2140cdf0e10cSrcweir             m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LANG);
2141cdf0e10cSrcweir             m_aStylesEnd.append((sal_Int32)rLanguage.GetLanguage());
2142cdf0e10cSrcweir             break;
2143cdf0e10cSrcweir         case RES_CHRATR_CJK_LANGUAGE:
2144cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LANGFE);
2145cdf0e10cSrcweir             m_aStyles.append((sal_Int32)rLanguage.GetLanguage());
2146cdf0e10cSrcweir             break;
2147cdf0e10cSrcweir         case RES_CHRATR_CTL_LANGUAGE:
2148cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LANG);
2149cdf0e10cSrcweir             m_aStyles.append((sal_Int32)rLanguage.GetLanguage());
2150cdf0e10cSrcweir             break;
2151cdf0e10cSrcweir     }
2152cdf0e10cSrcweir }
2153cdf0e10cSrcweir 
2154cdf0e10cSrcweir void RtfAttributeOutput::CharPosture( const SvxPostureItem& rPosture )
2155cdf0e10cSrcweir {
2156cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2157cdf0e10cSrcweir 
2158cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_I);
2159cdf0e10cSrcweir     if ( rPosture.GetPosture() == ITALIC_NONE )
2160cdf0e10cSrcweir         m_aStyles.append((sal_Int32)0);
2161cdf0e10cSrcweir }
2162cdf0e10cSrcweir 
2163cdf0e10cSrcweir void RtfAttributeOutput::CharShadow( const SvxShadowedItem& rShadow )
2164cdf0e10cSrcweir {
2165cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2166cdf0e10cSrcweir 
2167cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SHAD);
2168cdf0e10cSrcweir     if ( !rShadow.GetValue() )
2169cdf0e10cSrcweir         m_aStyles.append((sal_Int32)0);
2170cdf0e10cSrcweir }
2171cdf0e10cSrcweir 
2172cdf0e10cSrcweir void RtfAttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline )
2173cdf0e10cSrcweir {
2174cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2175cdf0e10cSrcweir 
2176cdf0e10cSrcweir     const char* pStr = 0;
2177cdf0e10cSrcweir     const SfxPoolItem* pItem = m_rExport.HasItem( RES_CHRATR_WORDLINEMODE );
2178cdf0e10cSrcweir     bool bWord = false;
2179cdf0e10cSrcweir     if (pItem)
2180cdf0e10cSrcweir         bWord = ((const SvxWordLineModeItem*)pItem)->GetValue() ? true : false;
2181cdf0e10cSrcweir     switch(rUnderline.GetLineStyle() )
2182cdf0e10cSrcweir     {
2183cdf0e10cSrcweir         case UNDERLINE_SINGLE:
2184cdf0e10cSrcweir             pStr = bWord ? OOO_STRING_SVTOOLS_RTF_ULW : OOO_STRING_SVTOOLS_RTF_UL;
2185cdf0e10cSrcweir             break;
2186cdf0e10cSrcweir         case UNDERLINE_DOUBLE:
2187cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULDB;
2188cdf0e10cSrcweir             break;
2189cdf0e10cSrcweir         case UNDERLINE_NONE:
2190cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULNONE;
2191cdf0e10cSrcweir             break;
2192cdf0e10cSrcweir         case UNDERLINE_DOTTED:
2193cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULD;
2194cdf0e10cSrcweir             break;
2195cdf0e10cSrcweir         case UNDERLINE_DASH:
2196cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULDASH;
2197cdf0e10cSrcweir             break;
2198cdf0e10cSrcweir         case UNDERLINE_DASHDOT:
2199cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULDASHD;
2200cdf0e10cSrcweir             break;
2201cdf0e10cSrcweir         case UNDERLINE_DASHDOTDOT:
2202cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULDASHDD;
2203cdf0e10cSrcweir             break;
2204cdf0e10cSrcweir         case UNDERLINE_BOLD:
2205cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULTH;
2206cdf0e10cSrcweir             break;
2207cdf0e10cSrcweir         case UNDERLINE_WAVE:
2208cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULWAVE;
2209cdf0e10cSrcweir             break;
2210cdf0e10cSrcweir         case UNDERLINE_BOLDDOTTED:
2211cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULTHD;
2212cdf0e10cSrcweir             break;
2213cdf0e10cSrcweir         case UNDERLINE_BOLDDASH:
2214cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULTHDASH;
2215cdf0e10cSrcweir             break;
2216cdf0e10cSrcweir         case UNDERLINE_LONGDASH:
2217cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULLDASH;
2218cdf0e10cSrcweir             break;
2219cdf0e10cSrcweir         case UNDERLINE_BOLDLONGDASH:
2220cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULTHLDASH;
2221cdf0e10cSrcweir             break;
2222cdf0e10cSrcweir         case UNDERLINE_BOLDDASHDOT:
2223cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULTHDASHD;
2224cdf0e10cSrcweir             break;
2225cdf0e10cSrcweir         case UNDERLINE_BOLDDASHDOTDOT:
2226cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULTHDASHDD;
2227cdf0e10cSrcweir             break;
2228cdf0e10cSrcweir         case UNDERLINE_BOLDWAVE:
2229cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULHWAVE;
2230cdf0e10cSrcweir             break;
2231cdf0e10cSrcweir         case UNDERLINE_DOUBLEWAVE:
2232cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_ULULDBWAVE;
2233cdf0e10cSrcweir             break;
2234cdf0e10cSrcweir         default:
2235cdf0e10cSrcweir             break;
2236cdf0e10cSrcweir     }
2237cdf0e10cSrcweir 
2238cdf0e10cSrcweir     if( pStr )
2239cdf0e10cSrcweir     {
2240cdf0e10cSrcweir         m_aStyles.append(pStr);
2241cdf0e10cSrcweir         // NEEDSWORK looks like here rUnderline.GetColor() is always black,
2242cdf0e10cSrcweir         // even if the color in the odt is for example green...
2243cdf0e10cSrcweir         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ULC);
2244cdf0e10cSrcweir         m_aStyles.append( (sal_Int32)m_rExport.GetColor(rUnderline.GetColor()) );
2245cdf0e10cSrcweir     }
2246cdf0e10cSrcweir }
2247cdf0e10cSrcweir 
2248cdf0e10cSrcweir void RtfAttributeOutput::CharWeight( const SvxWeightItem& rWeight )
2249cdf0e10cSrcweir {
2250cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2251cdf0e10cSrcweir 
2252cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_B);
2253cdf0e10cSrcweir     if ( rWeight.GetWeight() != WEIGHT_BOLD )
2254cdf0e10cSrcweir         m_aStyles.append((sal_Int32)0);
2255cdf0e10cSrcweir }
2256cdf0e10cSrcweir 
2257cdf0e10cSrcweir void RtfAttributeOutput::CharAutoKern( const SvxAutoKernItem& rAutoKern)
2258cdf0e10cSrcweir {
2259cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2260cdf0e10cSrcweir 
2261cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_KERNING);
2262cdf0e10cSrcweir     m_aStyles.append((sal_Int32) (rAutoKern.GetValue() ? 1 : 0));
2263cdf0e10cSrcweir }
2264cdf0e10cSrcweir 
2265cdf0e10cSrcweir void RtfAttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink )
2266cdf0e10cSrcweir {
2267cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2268cdf0e10cSrcweir 
2269cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ANIMTEXT);
2270cdf0e10cSrcweir     m_aStyles.append((sal_Int32) (rBlink.GetValue() ? 2 : 0));
2271cdf0e10cSrcweir }
2272cdf0e10cSrcweir 
2273cdf0e10cSrcweir void RtfAttributeOutput::CharBackground( const SvxBrushItem& rBrush )
2274cdf0e10cSrcweir {
2275cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2276cdf0e10cSrcweir 
2277cdf0e10cSrcweir     if( !rBrush.GetColor().GetTransparency() )
2278cdf0e10cSrcweir     {
2279cdf0e10cSrcweir         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CHCBPAT);
2280cdf0e10cSrcweir         m_aStyles.append((sal_Int32)m_rExport.GetColor(rBrush.GetColor()));
2281cdf0e10cSrcweir     }
2282cdf0e10cSrcweir }
2283cdf0e10cSrcweir 
2284cdf0e10cSrcweir void RtfAttributeOutput::CharFontCJK( const SvxFontItem& rFont )
2285cdf0e10cSrcweir {
2286cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2287cdf0e10cSrcweir 
2288cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HICH);
2289cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AF);
2290cdf0e10cSrcweir     m_aStyles.append((sal_Int32)m_rExport.maFontHelper.GetId(rFont));
2291cdf0e10cSrcweir }
2292cdf0e10cSrcweir 
2293cdf0e10cSrcweir void RtfAttributeOutput::CharFontSizeCJK( const SvxFontHeightItem& rFontSize )
2294cdf0e10cSrcweir {
2295cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2296cdf0e10cSrcweir 
2297cdf0e10cSrcweir     CharFontSize( rFontSize );
2298cdf0e10cSrcweir }
2299cdf0e10cSrcweir 
2300cdf0e10cSrcweir void RtfAttributeOutput::CharLanguageCJK( const SvxLanguageItem& rLanguageItem )
2301cdf0e10cSrcweir {
2302cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2303cdf0e10cSrcweir 
2304cdf0e10cSrcweir     CharLanguage( rLanguageItem );
2305cdf0e10cSrcweir }
2306cdf0e10cSrcweir 
2307cdf0e10cSrcweir void RtfAttributeOutput::CharPostureCJK( const SvxPostureItem& rPosture )
2308cdf0e10cSrcweir {
2309cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2310cdf0e10cSrcweir 
2311cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_I);
2312cdf0e10cSrcweir     if ( rPosture.GetPosture() == ITALIC_NONE )
2313cdf0e10cSrcweir         m_aStyles.append((sal_Int32)0);
2314cdf0e10cSrcweir }
2315cdf0e10cSrcweir 
2316cdf0e10cSrcweir void RtfAttributeOutput::CharWeightCJK( const SvxWeightItem& rWeight )
2317cdf0e10cSrcweir {
2318cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2319cdf0e10cSrcweir 
2320cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_B);
2321cdf0e10cSrcweir     if ( rWeight.GetWeight() != WEIGHT_BOLD )
2322cdf0e10cSrcweir         m_aStyles.append((sal_Int32)0);
2323cdf0e10cSrcweir }
2324cdf0e10cSrcweir 
2325cdf0e10cSrcweir void RtfAttributeOutput::CharFontCTL( const SvxFontItem& rFont )
2326cdf0e10cSrcweir {
2327cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2328cdf0e10cSrcweir 
2329cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_DBCH);
2330cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AF);
2331cdf0e10cSrcweir     m_aStyles.append((sal_Int32)m_rExport.maFontHelper.GetId(rFont));
2332cdf0e10cSrcweir }
2333cdf0e10cSrcweir 
2334cdf0e10cSrcweir void RtfAttributeOutput::CharFontSizeCTL( const SvxFontHeightItem& rFontSize )
2335cdf0e10cSrcweir {
2336cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2337cdf0e10cSrcweir 
2338cdf0e10cSrcweir     CharFontSize( rFontSize );
2339cdf0e10cSrcweir }
2340cdf0e10cSrcweir 
2341cdf0e10cSrcweir void RtfAttributeOutput::CharLanguageCTL( const SvxLanguageItem& rLanguageItem )
2342cdf0e10cSrcweir {
2343cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2344cdf0e10cSrcweir 
2345cdf0e10cSrcweir     CharLanguage( rLanguageItem );
2346cdf0e10cSrcweir }
2347cdf0e10cSrcweir 
2348cdf0e10cSrcweir void RtfAttributeOutput::CharPostureCTL( const SvxPostureItem& rPosture)
2349cdf0e10cSrcweir {
2350cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2351cdf0e10cSrcweir 
2352cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AI);
2353cdf0e10cSrcweir     if ( rPosture.GetPosture() == ITALIC_NONE )
2354cdf0e10cSrcweir         m_aStyles.append((sal_Int32)0);
2355cdf0e10cSrcweir }
2356cdf0e10cSrcweir 
2357cdf0e10cSrcweir void RtfAttributeOutput::CharWeightCTL( const SvxWeightItem& rWeight )
2358cdf0e10cSrcweir {
2359cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2360cdf0e10cSrcweir 
2361cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AB);
2362cdf0e10cSrcweir     if ( rWeight.GetWeight() != WEIGHT_BOLD )
2363cdf0e10cSrcweir         m_aStyles.append((sal_Int32)0);
2364cdf0e10cSrcweir }
2365ca2e0b95SLei De Bin void RtfAttributeOutput:: CharBidiRTL( const SfxPoolItem& )
2366ca2e0b95SLei De Bin {
2367ca2e0b95SLei De Bin }
2368ca2e0b95SLei De Bin 
2369ca2e0b95SLei De Bin void RtfAttributeOutput:: CharIdctHint( const SfxPoolItem&)
2370ca2e0b95SLei De Bin {
2371ca2e0b95SLei De Bin }
2372cdf0e10cSrcweir 
2373cdf0e10cSrcweir void RtfAttributeOutput::CharRotate( const SvxCharRotateItem& rRotate)
2374cdf0e10cSrcweir {
2375cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2376cdf0e10cSrcweir 
2377cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HORZVERT);
2378cdf0e10cSrcweir     m_aStyles.append((sal_Int32)(rRotate.IsFitToLine() ? 1 : 0));
2379cdf0e10cSrcweir }
2380cdf0e10cSrcweir 
2381cdf0e10cSrcweir void RtfAttributeOutput::CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark )
2382cdf0e10cSrcweir {
2383cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2384cdf0e10cSrcweir 
2385cdf0e10cSrcweir     const sal_Char* pStr;
2386cdf0e10cSrcweir     switch( rEmphasisMark.GetEmphasisMark())
2387cdf0e10cSrcweir     {
2388cdf0e10cSrcweir         case EMPHASISMARK_NONE:         pStr = OOO_STRING_SVTOOLS_RTF_ACCNONE;  break;
2389cdf0e10cSrcweir         case EMPHASISMARK_SIDE_DOTS:    pStr = OOO_STRING_SVTOOLS_RTF_ACCCOMMA; break;
2390cdf0e10cSrcweir         default:                        pStr = OOO_STRING_SVTOOLS_RTF_ACCDOT;   break;
2391cdf0e10cSrcweir     }
2392cdf0e10cSrcweir     m_aStyles.append(pStr);
2393cdf0e10cSrcweir }
2394cdf0e10cSrcweir 
2395cdf0e10cSrcweir void RtfAttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines )
2396cdf0e10cSrcweir {
2397cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2398cdf0e10cSrcweir 
2399cdf0e10cSrcweir     if( rTwoLines.GetValue() )
2400cdf0e10cSrcweir     {
2401cdf0e10cSrcweir         sal_Unicode cStart = rTwoLines.GetStartBracket();
2402cdf0e10cSrcweir         sal_Unicode cEnd =   rTwoLines.GetEndBracket();
2403cdf0e10cSrcweir 
2404cdf0e10cSrcweir         sal_uInt16 nType;
2405cdf0e10cSrcweir         if( !cStart && !cEnd )
2406cdf0e10cSrcweir             nType = 0;
2407cdf0e10cSrcweir         else if( '{' == cStart || '}' == cEnd )
2408cdf0e10cSrcweir             nType = 4;
2409cdf0e10cSrcweir         else if( '<' == cStart || '>' == cEnd )
2410cdf0e10cSrcweir             nType = 3;
2411cdf0e10cSrcweir         else if( '[' == cStart || ']' == cEnd )
2412cdf0e10cSrcweir             nType = 2;
2413cdf0e10cSrcweir         else                            // all other kind of brackets
2414cdf0e10cSrcweir             nType = 1;
2415cdf0e10cSrcweir 
2416cdf0e10cSrcweir         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TWOINONE);
2417cdf0e10cSrcweir         m_aStyles.append((sal_Int32)nType);
2418cdf0e10cSrcweir     }
2419cdf0e10cSrcweir }
2420cdf0e10cSrcweir 
2421cdf0e10cSrcweir void RtfAttributeOutput::CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth )
2422cdf0e10cSrcweir {
2423cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2424cdf0e10cSrcweir 
2425cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CHARSCALEX);
2426cdf0e10cSrcweir     m_aStyles.append((sal_Int32)rScaleWidth.GetValue());
2427cdf0e10cSrcweir }
2428cdf0e10cSrcweir 
2429cdf0e10cSrcweir void RtfAttributeOutput::CharRelief( const SvxCharReliefItem& rRelief )
2430cdf0e10cSrcweir {
2431cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2432cdf0e10cSrcweir 
2433cdf0e10cSrcweir     const sal_Char* pStr;
2434cdf0e10cSrcweir     switch (rRelief.GetValue())
2435cdf0e10cSrcweir     {
2436cdf0e10cSrcweir         case RELIEF_EMBOSSED:
2437cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_EMBO;
2438cdf0e10cSrcweir             break;
2439cdf0e10cSrcweir         case RELIEF_ENGRAVED:
2440cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_IMPR;
2441cdf0e10cSrcweir             break;
2442cdf0e10cSrcweir         default:
2443cdf0e10cSrcweir             pStr = 0;
2444cdf0e10cSrcweir             break;
2445cdf0e10cSrcweir     }
2446cdf0e10cSrcweir 
2447cdf0e10cSrcweir     if (pStr)
2448cdf0e10cSrcweir         m_aStyles.append(pStr);
2449cdf0e10cSrcweir }
2450cdf0e10cSrcweir 
2451cdf0e10cSrcweir void RtfAttributeOutput::CharHidden( const SvxCharHiddenItem& rHidden )
2452cdf0e10cSrcweir {
2453cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2454cdf0e10cSrcweir 
2455cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_V);
2456cdf0e10cSrcweir     if ( !rHidden.GetValue() )
2457cdf0e10cSrcweir         m_aStyles.append((sal_Int32)0);
2458cdf0e10cSrcweir }
2459cdf0e10cSrcweir 
2460cdf0e10cSrcweir void RtfAttributeOutput::TextINetFormat( const SwFmtINetFmt& rURL )
2461cdf0e10cSrcweir {
2462cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2463cdf0e10cSrcweir 
2464cdf0e10cSrcweir     if( rURL.GetValue().Len() )
2465cdf0e10cSrcweir     {
2466cdf0e10cSrcweir         const SwCharFmt* pFmt;
2467cdf0e10cSrcweir         const SwTxtINetFmt* pTxtAtr = rURL.GetTxtINetFmt();
2468cdf0e10cSrcweir 
2469cdf0e10cSrcweir         m_aStyles.append("{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
2470cdf0e10cSrcweir         if( pTxtAtr && 0 != ( pFmt = pTxtAtr->GetCharFmt() ))
2471cdf0e10cSrcweir         {
2472cdf0e10cSrcweir             sal_uInt16 nStyle = m_rExport.GetId( *pFmt );
2473cdf0e10cSrcweir             OString* pString = m_rExport.GetStyle(nStyle);
2474cdf0e10cSrcweir             if (pString)
2475cdf0e10cSrcweir                 m_aStyles.append(*pString);
2476cdf0e10cSrcweir         }
2477cdf0e10cSrcweir     }
2478cdf0e10cSrcweir }
2479cdf0e10cSrcweir 
2480cdf0e10cSrcweir void RtfAttributeOutput::TextCharFormat( const SwFmtCharFmt& rCharFmt )
2481cdf0e10cSrcweir {
2482cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2483cdf0e10cSrcweir 
2484cdf0e10cSrcweir     sal_uInt16 nStyle = m_rExport.GetId( *rCharFmt.GetCharFmt() );
2485cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_CS);
2486cdf0e10cSrcweir     m_aStyles.append((sal_Int32)nStyle);
2487cdf0e10cSrcweir     OString* pString = m_rExport.GetStyle(nStyle);
2488cdf0e10cSrcweir     if (pString)
2489cdf0e10cSrcweir         m_aStyles.append(*pString);
2490cdf0e10cSrcweir }
2491cdf0e10cSrcweir 
2492cdf0e10cSrcweir void RtfAttributeOutput::WriteTextFootnoteNumStr(const SwFmtFtn& rFootnote)
2493cdf0e10cSrcweir {
2494cdf0e10cSrcweir     if (!rFootnote.GetNumStr().Len())
249593996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_CHFTN);
2496cdf0e10cSrcweir     else
249793996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append(m_rExport.OutString(rFootnote.GetNumStr(), m_rExport.eCurrentEncoding));
2498cdf0e10cSrcweir }
2499cdf0e10cSrcweir 
2500cdf0e10cSrcweir void RtfAttributeOutput::TextFootnote_Impl( const SwFmtFtn& rFootnote )
2501cdf0e10cSrcweir {
2502cdf0e10cSrcweir     OSL_TRACE("%s start", OSL_THIS_FUNC);
2503cdf0e10cSrcweir 
250493996bb7SArmin Le Grand     m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_SUPER " ");
2505cdf0e10cSrcweir     WriteTextFootnoteNumStr(rFootnote);
250693996bb7SArmin Le Grand     m_aRun.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FOOTNOTE);
2507cdf0e10cSrcweir     if( rFootnote.IsEndNote() )
250893996bb7SArmin Le Grand         m_aRun.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FTNALT);
250993996bb7SArmin Le Grand     m_aRun.getOStringBuffer().append(' ');
2510cdf0e10cSrcweir     WriteTextFootnoteNumStr(rFootnote);
2511cdf0e10cSrcweir 
2512cdf0e10cSrcweir     /*
2513cdf0e10cSrcweir      * The footnote contains a whole paragraph, so we have to:
2514cdf0e10cSrcweir      * 1) Reset, then later restore the contents of our run buffer.
2515cdf0e10cSrcweir      * 2) Buffer the output of the whole paragraph, as we do so for section headers already.
2516cdf0e10cSrcweir      */
2517cdf0e10cSrcweir     const SwNodeIndex* pIndex = rFootnote.GetTxtFtn()->GetStartNode();
251893996bb7SArmin Le Grand     MultiBuffer aTemp;
251993996bb7SArmin Le Grand     aTemp.appendAndClear(m_aRun);
252093996bb7SArmin Le Grand 
2521cdf0e10cSrcweir     m_bBufferSectionHeaders = true;
2522cdf0e10cSrcweir     m_rExport.WriteSpecialText( pIndex->GetIndex() + 1,
2523cdf0e10cSrcweir             pIndex->GetNode().EndOfSectionIndex(),
2524cdf0e10cSrcweir             !rFootnote.IsEndNote() ? TXT_FTN : TXT_EDN);
2525cdf0e10cSrcweir     m_bBufferSectionHeaders = false;
2526cdf0e10cSrcweir 
252793996bb7SArmin Le Grand     m_aRun.clear();
252893996bb7SArmin Le Grand     m_aRun.appendAndClear(aTemp);
252993996bb7SArmin Le Grand 
253093996bb7SArmin Le Grand     m_aRun.appendAndClear(m_aSectionHeaders);
253193996bb7SArmin Le Grand 
253293996bb7SArmin Le Grand     m_aRun.getOStringBuffer().append("}");
253393996bb7SArmin Le Grand     m_aRun.getOStringBuffer().append("}");
2534cdf0e10cSrcweir 
2535cdf0e10cSrcweir     OSL_TRACE("%s end", OSL_THIS_FUNC);
2536cdf0e10cSrcweir }
2537cdf0e10cSrcweir 
2538cdf0e10cSrcweir void RtfAttributeOutput::ParaLineSpacing_Impl( short nSpace, short nMulti )
2539cdf0e10cSrcweir {
2540cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2541cdf0e10cSrcweir 
2542cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SL);
2543cdf0e10cSrcweir     m_aStyles.append((sal_Int32)nSpace);
2544cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SLMULT);
2545cdf0e10cSrcweir     m_aStyles.append((sal_Int32)nMulti);
2546cdf0e10cSrcweir 
2547cdf0e10cSrcweir }
2548cdf0e10cSrcweir 
2549cdf0e10cSrcweir void RtfAttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
2550cdf0e10cSrcweir {
2551cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2552cdf0e10cSrcweir 
2553cdf0e10cSrcweir     switch ( rAdjust.GetAdjust() )
2554cdf0e10cSrcweir     {
2555cdf0e10cSrcweir         case SVX_ADJUST_LEFT:
2556cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QL);
2557cdf0e10cSrcweir             break;
2558cdf0e10cSrcweir         case SVX_ADJUST_RIGHT:
2559cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QR);
2560cdf0e10cSrcweir             break;
2561cdf0e10cSrcweir         case SVX_ADJUST_BLOCKLINE:
2562cdf0e10cSrcweir         case SVX_ADJUST_BLOCK:
2563cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QJ);
2564cdf0e10cSrcweir             break;
2565cdf0e10cSrcweir         case SVX_ADJUST_CENTER:
2566cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QC);
2567cdf0e10cSrcweir             break;
2568cdf0e10cSrcweir         default:
2569cdf0e10cSrcweir             break;
2570cdf0e10cSrcweir     }
2571cdf0e10cSrcweir }
2572cdf0e10cSrcweir 
2573cdf0e10cSrcweir void RtfAttributeOutput::ParaSplit( const SvxFmtSplitItem& rSplit )
2574cdf0e10cSrcweir {
2575cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2576cdf0e10cSrcweir 
2577cdf0e10cSrcweir     if( !rSplit.GetValue() )
2578cdf0e10cSrcweir         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_KEEP);
2579cdf0e10cSrcweir }
2580cdf0e10cSrcweir 
2581cdf0e10cSrcweir void RtfAttributeOutput::ParaWidows( const SvxWidowsItem& rWidows )
2582cdf0e10cSrcweir {
2583cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2584cdf0e10cSrcweir 
2585cdf0e10cSrcweir     if (rWidows.GetValue())
2586cdf0e10cSrcweir         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_WIDCTLPAR);
2587cdf0e10cSrcweir     else
2588cdf0e10cSrcweir         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_NOWIDCTLPAR);
2589cdf0e10cSrcweir }
2590cdf0e10cSrcweir 
2591cdf0e10cSrcweir void RtfAttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStop )
2592cdf0e10cSrcweir {
2593cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2594cdf0e10cSrcweir 
2595cdf0e10cSrcweir     long nOffset = ((SvxLRSpaceItem&)m_rExport.GetItem( RES_LR_SPACE )).GetTxtLeft();
2596cdf0e10cSrcweir     for( sal_uInt16 n = 0; n < rTabStop.Count(); n++ )
2597cdf0e10cSrcweir     {
2598cdf0e10cSrcweir         const SvxTabStop & rTS = rTabStop[ n ];
2599cdf0e10cSrcweir         if( SVX_TAB_ADJUST_DEFAULT != rTS.GetAdjustment() )
2600cdf0e10cSrcweir         {
2601cdf0e10cSrcweir             const char* pFill = 0;
2602cdf0e10cSrcweir             switch( rTS.GetFill() )
2603cdf0e10cSrcweir             {
2604cdf0e10cSrcweir                 case cDfltFillChar:
2605cdf0e10cSrcweir                     break;
2606cdf0e10cSrcweir 
2607cdf0e10cSrcweir                 case '.':    pFill = OOO_STRING_SVTOOLS_RTF_TLDOT;    break;
2608cdf0e10cSrcweir                 case '_':    pFill = OOO_STRING_SVTOOLS_RTF_TLUL;    break;
2609cdf0e10cSrcweir                 case '-':    pFill = OOO_STRING_SVTOOLS_RTF_TLTH;    break;
2610cdf0e10cSrcweir                 case '=':    pFill = OOO_STRING_SVTOOLS_RTF_TLEQ;    break;
2611cdf0e10cSrcweir                 default:
2612cdf0e10cSrcweir                         break;
2613cdf0e10cSrcweir             }
2614cdf0e10cSrcweir             if( pFill )
2615cdf0e10cSrcweir                 m_aStyles.append(pFill);
2616cdf0e10cSrcweir 
2617cdf0e10cSrcweir             const sal_Char* pAdjStr = 0;
2618cdf0e10cSrcweir             switch (rTS.GetAdjustment())
2619cdf0e10cSrcweir             {
2620cdf0e10cSrcweir                 case SVX_TAB_ADJUST_RIGHT:
2621cdf0e10cSrcweir                     pAdjStr = OOO_STRING_SVTOOLS_RTF_TQR;
2622cdf0e10cSrcweir                     break;
2623cdf0e10cSrcweir                 case SVX_TAB_ADJUST_DECIMAL:
2624cdf0e10cSrcweir                     pAdjStr = OOO_STRING_SVTOOLS_RTF_TQDEC;
2625cdf0e10cSrcweir                     break;
2626cdf0e10cSrcweir                 case SVX_TAB_ADJUST_CENTER:
2627cdf0e10cSrcweir                     pAdjStr = OOO_STRING_SVTOOLS_RTF_TQC;
2628cdf0e10cSrcweir                     break;
2629cdf0e10cSrcweir                 default:
2630cdf0e10cSrcweir                     break;
2631cdf0e10cSrcweir             }
2632cdf0e10cSrcweir             if (pAdjStr)
2633cdf0e10cSrcweir                 m_aStyles.append(pAdjStr);
2634cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TX);
2635cdf0e10cSrcweir             m_aStyles.append((sal_Int32)(rTS.GetTabPos() + nOffset));
2636cdf0e10cSrcweir         }
2637cdf0e10cSrcweir         else
2638cdf0e10cSrcweir         {
2639cdf0e10cSrcweir             m_aTabStop.append( OOO_STRING_SVTOOLS_RTF_DEFTAB );
2640cdf0e10cSrcweir             m_aTabStop.append( (sal_Int32)rTabStop[0].GetTabPos() );
2641cdf0e10cSrcweir         }
2642cdf0e10cSrcweir     }
2643cdf0e10cSrcweir }
2644cdf0e10cSrcweir 
2645cdf0e10cSrcweir void RtfAttributeOutput::ParaHyphenZone( const SvxHyphenZoneItem& rHyphenZone )
2646cdf0e10cSrcweir {
2647cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2648cdf0e10cSrcweir 
2649cdf0e10cSrcweir     sal_Int32 nFlags = rHyphenZone.IsHyphen() ? 1 : 0;
2650cdf0e10cSrcweir     if( rHyphenZone.IsPageEnd() )
2651cdf0e10cSrcweir         nFlags += 2;
2652cdf0e10cSrcweir     m_aStyles.append('{');
2653cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE);
2654cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHEN);
2655cdf0e10cSrcweir     m_aStyles.append((sal_Int32)nFlags);
2656cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHLEAD);
2657cdf0e10cSrcweir     m_aStyles.append((sal_Int32)rHyphenZone.GetMinLead());
2658cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHTRAIL);
2659cdf0e10cSrcweir     m_aStyles.append((sal_Int32)rHyphenZone.GetMinTrail());
2660cdf0e10cSrcweir     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHMAX);
2661cdf0e10cSrcweir     m_aStyles.append((sal_Int32)rHyphenZone.GetMaxHyphens());
2662cdf0e10cSrcweir     m_aStyles.append('}');
2663cdf0e10cSrcweir }
2664cdf0e10cSrcweir 
2665cdf0e10cSrcweir void RtfAttributeOutput::ParaNumRule_Impl( const SwTxtNode* pTxtNd, sal_Int32 nLvl, sal_Int32 nNumId )
2666cdf0e10cSrcweir {
2667cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2668cdf0e10cSrcweir 
2669cdf0e10cSrcweir     if ( USHRT_MAX == nNumId || 0 == nNumId || 0 == pTxtNd)
2670cdf0e10cSrcweir         return;
2671cdf0e10cSrcweir 
2672cdf0e10cSrcweir     const SwNumRule* pRule = pTxtNd->GetNumRule();
2673cdf0e10cSrcweir 
2674cdf0e10cSrcweir     // --> OD 2008-03-18 #refactorlists#
2675cdf0e10cSrcweir     //    if( pRule && MAXLEVEL > pTxtNd->GetActualListLevel() )
2676cdf0e10cSrcweir     if( pRule && pTxtNd->IsInList() )
2677cdf0e10cSrcweir         // <--
2678cdf0e10cSrcweir     {
2679cdf0e10cSrcweir         // --> OD 2008-03-18 #refactorlists#
2680cdf0e10cSrcweir         ASSERT( pTxtNd->GetActualListLevel() >= 0 && pTxtNd->GetActualListLevel() < MAXLEVEL,
2681cdf0e10cSrcweir                 "<SwRTFWriter::OutListNum(..)> - text node does not have valid list level. Serious defect -> please inform OD" );
2682cdf0e10cSrcweir         // <--
2683cdf0e10cSrcweir 
2684cdf0e10cSrcweir         const bool bExportNumRule = USHRT_MAX != nNumId;
2685cdf0e10cSrcweir         const SwNumFmt* pFmt = pRule->GetNumFmt( nLvl );
2686cdf0e10cSrcweir         if( !pFmt )
2687cdf0e10cSrcweir             pFmt = &pRule->Get( nLvl );
2688cdf0e10cSrcweir 
2689cdf0e10cSrcweir         const SfxItemSet& rNdSet = pTxtNd->GetSwAttrSet();
2690cdf0e10cSrcweir 
2691cdf0e10cSrcweir         if ( bExportNumRule ) {
2692cdf0e10cSrcweir             m_aStyles.append('{');
2693cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LISTTEXT);
2694cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_PARD);
2695cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_PLAIN);
2696cdf0e10cSrcweir             m_aStyles.append(' ');
2697cdf0e10cSrcweir         }
2698cdf0e10cSrcweir 
2699cdf0e10cSrcweir         SvxLRSpaceItem aLR( (SvxLRSpaceItem&)rNdSet.Get( RES_LR_SPACE ) );
2700cdf0e10cSrcweir         aLR.SetTxtLeft( aLR.GetTxtLeft() + pFmt->GetIndentAt() );
2701cdf0e10cSrcweir         aLR.SetTxtFirstLineOfst( pFmt->GetFirstLineOffset() );
2702cdf0e10cSrcweir 
2703cdf0e10cSrcweir         sal_uInt16 nStyle = m_rExport.GetId( *pFmt->GetCharFmt() );
2704cdf0e10cSrcweir         OString* pString = m_rExport.GetStyle(nStyle);
2705cdf0e10cSrcweir         if (pString)
2706cdf0e10cSrcweir             m_aStyles.append(*pString);
2707cdf0e10cSrcweir 
2708cdf0e10cSrcweir         {
2709cdf0e10cSrcweir             String sTxt;
2710cdf0e10cSrcweir             if( SVX_NUM_CHAR_SPECIAL == pFmt->GetNumberingType() || SVX_NUM_BITMAP == pFmt->GetNumberingType() )
2711cdf0e10cSrcweir                 sTxt = pFmt->GetBulletChar();
2712cdf0e10cSrcweir             else
2713cdf0e10cSrcweir                 sTxt = pTxtNd->GetNumString();
2714cdf0e10cSrcweir 
2715cdf0e10cSrcweir             m_aStyles.append(' ');
2716cdf0e10cSrcweir 
2717cdf0e10cSrcweir             if (sTxt.Len())
2718cdf0e10cSrcweir             {
2719cdf0e10cSrcweir                 m_aStyles.append(m_rExport.OutString(sTxt, m_rExport.eDefaultEncoding));
2720cdf0e10cSrcweir             }
2721cdf0e10cSrcweir 
2722cdf0e10cSrcweir             if( bExportNumRule )
2723cdf0e10cSrcweir             {
2724cdf0e10cSrcweir                 if( OUTLINE_RULE != pRule->GetRuleType() )
2725cdf0e10cSrcweir                 {
2726cdf0e10cSrcweir                     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TAB);
2727cdf0e10cSrcweir                     m_aStyles.append('}');
2728cdf0e10cSrcweir                     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ILVL);
2729cdf0e10cSrcweir                     if( nLvl > 8 )            // RTF knows only 9 levels
2730cdf0e10cSrcweir                     {
2731cdf0e10cSrcweir                         m_aStyles.append((sal_Int32)8);
2732cdf0e10cSrcweir                         m_aStyles.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SOUTLVL);
2733cdf0e10cSrcweir                         m_aStyles.append((sal_Int32)nLvl);
2734cdf0e10cSrcweir                         m_aStyles.append('}');
2735cdf0e10cSrcweir                     }
2736cdf0e10cSrcweir                     else
2737cdf0e10cSrcweir                         m_aStyles.append((sal_Int32)nLvl);
2738cdf0e10cSrcweir                 }
2739cdf0e10cSrcweir                 else
2740cdf0e10cSrcweir                     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TAB "}");
2741cdf0e10cSrcweir                 m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LS);
2742cdf0e10cSrcweir                 m_aStyles.append((sal_Int32)m_rExport.GetId(*pRule)+1);
2743cdf0e10cSrcweir                 m_aStyles.append(' ');
2744cdf0e10cSrcweir             }
2745cdf0e10cSrcweir             else if( sTxt.Len() )
2746cdf0e10cSrcweir                 m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TAB);
2747cdf0e10cSrcweir         }
2748cdf0e10cSrcweir         FormatLRSpace(aLR);
2749cdf0e10cSrcweir     }
2750cdf0e10cSrcweir }
2751cdf0e10cSrcweir 
2752cdf0e10cSrcweir void RtfAttributeOutput::ParaScriptSpace( const SfxBoolItem& rScriptSpace )
2753cdf0e10cSrcweir {
2754cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2755cdf0e10cSrcweir 
2756cdf0e10cSrcweir     if (!rScriptSpace.GetValue( ))
2757cdf0e10cSrcweir         return;
2758cdf0e10cSrcweir     switch ( rScriptSpace.Which( ) )
2759cdf0e10cSrcweir     {
2760cdf0e10cSrcweir         case RES_PARATR_SCRIPTSPACE:
2761cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ASPALPHA);
2762cdf0e10cSrcweir             break;
2763cdf0e10cSrcweir         /* Is this needed?
2764cdf0e10cSrcweir         case RES_PARATR_HANGINGPUNCTUATION:
2765cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_NOOVERFLOW);
2766cdf0e10cSrcweir             break;
2767cdf0e10cSrcweir         case RES_PARATR_FORBIDDEN_RULES:
2768cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_NOCWRAP);
2769cdf0e10cSrcweir             break;*/
2770cdf0e10cSrcweir         default:
2771cdf0e10cSrcweir             break;
2772cdf0e10cSrcweir     }
2773cdf0e10cSrcweir }
2774cdf0e10cSrcweir 
2775cdf0e10cSrcweir void RtfAttributeOutput::ParaVerticalAlign( const SvxParaVertAlignItem& rAlign )
2776cdf0e10cSrcweir {
2777cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2778cdf0e10cSrcweir 
2779cdf0e10cSrcweir     const char* pStr;
2780cdf0e10cSrcweir     switch ( rAlign.GetValue() )
2781cdf0e10cSrcweir     {
2782cdf0e10cSrcweir         case SvxParaVertAlignItem::TOP:         pStr = OOO_STRING_SVTOOLS_RTF_FAHANG;       break;
2783cdf0e10cSrcweir         case SvxParaVertAlignItem::BOTTOM:      pStr = OOO_STRING_SVTOOLS_RTF_FAVAR;        break;
2784cdf0e10cSrcweir         case SvxParaVertAlignItem::CENTER:      pStr = OOO_STRING_SVTOOLS_RTF_FACENTER;     break;
2785cdf0e10cSrcweir         case SvxParaVertAlignItem::BASELINE:    pStr = OOO_STRING_SVTOOLS_RTF_FAROMAN;      break;
2786cdf0e10cSrcweir         // default == SvxParaVertAlignItem::AUTOMATIC
2787cdf0e10cSrcweir         default:                                pStr = OOO_STRING_SVTOOLS_RTF_FAAUTO;       break;
2788cdf0e10cSrcweir     }
2789cdf0e10cSrcweir     m_aStyles.append(pStr);
2790cdf0e10cSrcweir }
2791cdf0e10cSrcweir 
2792cdf0e10cSrcweir void RtfAttributeOutput::ParaSnapToGrid( const SvxParaGridItem& /*rGrid*/ )
2793cdf0e10cSrcweir {
2794cdf0e10cSrcweir     OSL_TRACE("TODO: %s", OSL_THIS_FUNC);
2795cdf0e10cSrcweir }
2796cdf0e10cSrcweir 
2797cdf0e10cSrcweir void RtfAttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize )
2798cdf0e10cSrcweir {
2799cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2800cdf0e10cSrcweir 
2801cdf0e10cSrcweir     if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
2802cdf0e10cSrcweir     {
2803cdf0e10cSrcweir         if( rSize.GetWidth() )
2804cdf0e10cSrcweir         {
280593996bb7SArmin Le Grand             m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_ABSW);
280693996bb7SArmin Le Grand             m_aRunText.getOStringBuffer().append((sal_Int32)rSize.GetWidth());
2807cdf0e10cSrcweir         }
2808cdf0e10cSrcweir 
2809cdf0e10cSrcweir         if( rSize.GetHeight() )
2810cdf0e10cSrcweir         {
2811cdf0e10cSrcweir             long nH = rSize.GetHeight();
2812cdf0e10cSrcweir             if( ATT_FIX_SIZE == rSize.GetHeightSizeType() )
2813cdf0e10cSrcweir                 nH = -nH;
281493996bb7SArmin Le Grand             m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_ABSH);
281593996bb7SArmin Le Grand             m_aRunText.getOStringBuffer().append((sal_Int32)nH);
2816cdf0e10cSrcweir         }
2817cdf0e10cSrcweir     }
2818cdf0e10cSrcweir     else if (m_rExport.bOutPageDescs)
2819cdf0e10cSrcweir     {
2820cdf0e10cSrcweir         m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGWSXN);
2821cdf0e10cSrcweir         m_aSectionBreaks.append((sal_Int32)rSize.GetWidth());
2822cdf0e10cSrcweir         m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGHSXN);
2823cdf0e10cSrcweir         m_aSectionBreaks.append((sal_Int32)rSize.GetHeight());
2824cdf0e10cSrcweir         if (!m_bBufferSectionBreaks)
2825cdf0e10cSrcweir             m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear();
2826cdf0e10cSrcweir     }
2827cdf0e10cSrcweir }
2828cdf0e10cSrcweir 
2829cdf0e10cSrcweir void RtfAttributeOutput::FormatPaperBin( const SvxPaperBinItem& )
2830cdf0e10cSrcweir {
2831cdf0e10cSrcweir     OSL_TRACE("TODO: %s", OSL_THIS_FUNC);
2832cdf0e10cSrcweir }
2833cdf0e10cSrcweir 
2834cdf0e10cSrcweir void RtfAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace )
2835cdf0e10cSrcweir {
2836cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2837cdf0e10cSrcweir 
2838cdf0e10cSrcweir     if ( !m_rExport.bOutFlyFrmAttrs )
2839cdf0e10cSrcweir     {
2840cdf0e10cSrcweir         if( m_rExport.bOutPageDescs )
2841cdf0e10cSrcweir         {
2842cdf0e10cSrcweir             if( rLRSpace.GetLeft() )
2843cdf0e10cSrcweir             {
2844cdf0e10cSrcweir                 m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGLSXN);
2845cdf0e10cSrcweir                 m_aSectionBreaks.append((sal_Int32)rLRSpace.GetLeft());
2846cdf0e10cSrcweir             }
2847cdf0e10cSrcweir             if( rLRSpace.GetRight() )
2848cdf0e10cSrcweir             {
2849cdf0e10cSrcweir                 m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGRSXN);
2850cdf0e10cSrcweir                 m_aSectionBreaks.append((sal_Int32)rLRSpace.GetRight());
2851cdf0e10cSrcweir             }
2852cdf0e10cSrcweir             if (!m_bBufferSectionBreaks)
2853cdf0e10cSrcweir                 m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear();
2854cdf0e10cSrcweir         }
2855cdf0e10cSrcweir         else
2856cdf0e10cSrcweir         {
2857cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LI);
2858cdf0e10cSrcweir             m_aStyles.append( (sal_Int32) rLRSpace.GetTxtLeft() );
2859cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RI);
2860cdf0e10cSrcweir             m_aStyles.append( (sal_Int32) rLRSpace.GetRight() );
2861cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LIN);
2862cdf0e10cSrcweir             m_aStyles.append( (sal_Int32) rLRSpace.GetTxtLeft() );
2863cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RIN);
2864cdf0e10cSrcweir             m_aStyles.append( (sal_Int32) rLRSpace.GetRight() );
2865cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FI);
2866cdf0e10cSrcweir             m_aStyles.append( (sal_Int32) rLRSpace.GetTxtFirstLineOfst() );
2867cdf0e10cSrcweir         }
2868cdf0e10cSrcweir     }
2869cdf0e10cSrcweir     else if (rLRSpace.GetLeft() == rLRSpace.GetRight() && m_rExport.bRTFFlySyntax)
2870cdf0e10cSrcweir     {
2871cdf0e10cSrcweir         m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_DFRMTXTX;
2872cdf0e10cSrcweir         m_rExport.OutLong( rLRSpace.GetLeft() );
2873cdf0e10cSrcweir     }
2874cdf0e10cSrcweir }
2875cdf0e10cSrcweir 
2876cdf0e10cSrcweir void RtfAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
2877cdf0e10cSrcweir {
2878cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2879cdf0e10cSrcweir 
2880cdf0e10cSrcweir     if ( !m_rExport.bOutFlyFrmAttrs )
2881cdf0e10cSrcweir     {
2882cdf0e10cSrcweir         if( m_rExport.bOutPageDescs )
2883cdf0e10cSrcweir         {
2884cdf0e10cSrcweir 
2885cdf0e10cSrcweir             ASSERT( m_rExport.GetCurItemSet(), "Impossible" );
2886cdf0e10cSrcweir             if ( !m_rExport.GetCurItemSet() )
2887cdf0e10cSrcweir                 return;
2888cdf0e10cSrcweir 
2889cdf0e10cSrcweir             HdFtDistanceGlue aDistances( *m_rExport.GetCurItemSet() );
2890cdf0e10cSrcweir 
289151cdef2aSMichael Stahl             if( aDistances.dyaTop )
289251cdef2aSMichael Stahl             {
289351cdef2aSMichael Stahl                 m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGTSXN);
289451cdef2aSMichael Stahl                 m_aSectionBreaks.append((sal_Int32)aDistances.dyaTop);
289551cdef2aSMichael Stahl             }
2896cdf0e10cSrcweir             if ( aDistances.HasHeader() )
2897cdf0e10cSrcweir             {
2898cdf0e10cSrcweir                 m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_HEADERY);
2899cdf0e10cSrcweir                 m_aSectionBreaks.append((sal_Int32)aDistances.dyaHdrTop);
2900cdf0e10cSrcweir             }
2901cdf0e10cSrcweir 
290251cdef2aSMichael Stahl             if( aDistances.dyaBottom )
290351cdef2aSMichael Stahl             {
290451cdef2aSMichael Stahl                 m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGBSXN);
290551cdef2aSMichael Stahl                 m_aSectionBreaks.append((sal_Int32)aDistances.dyaBottom);
290651cdef2aSMichael Stahl             }
2907cdf0e10cSrcweir             if( aDistances.HasFooter() )
2908cdf0e10cSrcweir             {
2909cdf0e10cSrcweir                 m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_FOOTERY);
2910cdf0e10cSrcweir                 m_aSectionBreaks.append((sal_Int32)aDistances.dyaHdrBottom);
2911cdf0e10cSrcweir             }
2912cdf0e10cSrcweir             if (!m_bBufferSectionBreaks)
2913cdf0e10cSrcweir                 m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear();
2914cdf0e10cSrcweir         }
2915cdf0e10cSrcweir         else
2916cdf0e10cSrcweir         {
2917cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SB);
2918cdf0e10cSrcweir             m_aStyles.append( (sal_Int32) rULSpace.GetUpper() );
2919cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SA);
2920cdf0e10cSrcweir             m_aStyles.append( (sal_Int32) rULSpace.GetLower() );
2921cdf0e10cSrcweir         }
2922cdf0e10cSrcweir     }
2923cdf0e10cSrcweir     else if (rULSpace.GetUpper() == rULSpace.GetLower() && m_rExport.bRTFFlySyntax)
2924cdf0e10cSrcweir     {
2925cdf0e10cSrcweir         m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_DFRMTXTY;
2926cdf0e10cSrcweir         m_rExport.OutLong( rULSpace.GetLower() );
2927cdf0e10cSrcweir     }
2928cdf0e10cSrcweir }
2929cdf0e10cSrcweir 
2930cdf0e10cSrcweir void RtfAttributeOutput::FormatSurround( const SwFmtSurround& rSurround )
2931cdf0e10cSrcweir {
2932cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2933cdf0e10cSrcweir 
2934cdf0e10cSrcweir     if ( m_rExport.bOutFlyFrmAttrs && !m_rExport.bRTFFlySyntax )
2935cdf0e10cSrcweir     {
2936cdf0e10cSrcweir         SwSurround eSurround = rSurround.GetSurround();
2937cdf0e10cSrcweir         sal_Bool bGold = SURROUND_IDEAL == eSurround;
2938cdf0e10cSrcweir         if( bGold )
2939cdf0e10cSrcweir             eSurround = SURROUND_PARALLEL;
2940cdf0e10cSrcweir         RTFSurround aMC( bGold, static_cast< sal_uInt8 >(eSurround) );
294193996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FLYMAINCNT);
294293996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append( (sal_Int32) aMC.GetValue() );
2943cdf0e10cSrcweir     }
2944cdf0e10cSrcweir }
2945cdf0e10cSrcweir 
2946cdf0e10cSrcweir void RtfAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert )
2947cdf0e10cSrcweir {
2948cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2949cdf0e10cSrcweir 
2950cdf0e10cSrcweir     if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
2951cdf0e10cSrcweir     {
295293996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_PVPARA);
2953cdf0e10cSrcweir 
2954cdf0e10cSrcweir         switch (rFlyVert.GetVertOrient())
2955cdf0e10cSrcweir         {
2956cdf0e10cSrcweir             case text::VertOrientation::TOP:
2957cdf0e10cSrcweir             case text::VertOrientation::LINE_TOP:
295893996bb7SArmin Le Grand                 m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_POSYT);
2959cdf0e10cSrcweir                 break;
2960cdf0e10cSrcweir             case text::VertOrientation::BOTTOM:
2961cdf0e10cSrcweir             case text::VertOrientation::LINE_BOTTOM:
296293996bb7SArmin Le Grand                 m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_POSYB);
2963cdf0e10cSrcweir                 break;
2964cdf0e10cSrcweir             case text::VertOrientation::CENTER:
2965cdf0e10cSrcweir             case text::VertOrientation::LINE_CENTER:
296693996bb7SArmin Le Grand                 m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_POSYC);
2967cdf0e10cSrcweir                 break;
2968cdf0e10cSrcweir             case text::VertOrientation::NONE:
296993996bb7SArmin Le Grand                 m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_POSY);
297093996bb7SArmin Le Grand                 m_aRunText.getOStringBuffer().append((sal_Int32)rFlyVert.GetPos());
2971cdf0e10cSrcweir                 break;
2972cdf0e10cSrcweir             default:
2973cdf0e10cSrcweir                 break;
2974cdf0e10cSrcweir         }
2975cdf0e10cSrcweir     }
2976cdf0e10cSrcweir     else if ( !m_rExport.bRTFFlySyntax )
2977cdf0e10cSrcweir     {
2978cdf0e10cSrcweir         RTFVertOrient aVO( static_cast< sal_uInt16 >(rFlyVert.GetVertOrient()), static_cast< sal_uInt16 >(rFlyVert.GetRelationOrient()) );
297993996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FLYVERT);
298093996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append((sal_Int32)aVO.GetValue());
2981cdf0e10cSrcweir     }
2982cdf0e10cSrcweir }
2983cdf0e10cSrcweir 
2984cdf0e10cSrcweir void RtfAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHori )
2985cdf0e10cSrcweir {
2986cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
2987cdf0e10cSrcweir 
2988cdf0e10cSrcweir     if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
2989cdf0e10cSrcweir     {
299093996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_PHCOL);
2991cdf0e10cSrcweir 
2992cdf0e10cSrcweir         const char* pS = 0;
2993cdf0e10cSrcweir         switch(rFlyHori.GetHoriOrient())
2994cdf0e10cSrcweir         {
2995cdf0e10cSrcweir             case text::HoriOrientation::RIGHT:
2996cdf0e10cSrcweir                 pS = rFlyHori.IsPosToggle() ? OOO_STRING_SVTOOLS_RTF_POSXO : OOO_STRING_SVTOOLS_RTF_POSXR;
2997cdf0e10cSrcweir                 break;
2998cdf0e10cSrcweir             case text::HoriOrientation::LEFT:
2999cdf0e10cSrcweir                 pS = rFlyHori.IsPosToggle() ? OOO_STRING_SVTOOLS_RTF_POSXI : OOO_STRING_SVTOOLS_RTF_POSXL;
3000cdf0e10cSrcweir                 break;
3001cdf0e10cSrcweir             case text::HoriOrientation::CENTER:
3002cdf0e10cSrcweir                 pS = OOO_STRING_SVTOOLS_RTF_POSXC;
3003cdf0e10cSrcweir                 break;
3004cdf0e10cSrcweir             case text::HoriOrientation::NONE:
300593996bb7SArmin Le Grand                 m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_POSX);
300693996bb7SArmin Le Grand                 m_aRunText.getOStringBuffer().append((sal_Int32)rFlyHori.GetPos());
3007cdf0e10cSrcweir                 break;
3008cdf0e10cSrcweir             default:
3009cdf0e10cSrcweir                 break;
3010cdf0e10cSrcweir         }
3011cdf0e10cSrcweir         if (pS)
301293996bb7SArmin Le Grand             m_aRunText.getOStringBuffer().append(pS);
3013cdf0e10cSrcweir     } else if ( !m_rExport.bRTFFlySyntax )
3014cdf0e10cSrcweir     {
3015cdf0e10cSrcweir         RTFHoriOrient aHO( static_cast< sal_uInt16 >(rFlyHori.GetHoriOrient()),
3016cdf0e10cSrcweir                 static_cast< sal_uInt16 >(rFlyHori.GetRelationOrient()) );
301793996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FLYHORZ);
301893996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append((sal_Int32)aHO.GetValue());
3019cdf0e10cSrcweir     }
3020cdf0e10cSrcweir }
3021cdf0e10cSrcweir 
3022cdf0e10cSrcweir void RtfAttributeOutput::FormatAnchor( const SwFmtAnchor& rAnchor )
3023cdf0e10cSrcweir {
3024cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3025cdf0e10cSrcweir 
3026cdf0e10cSrcweir     if ( !m_rExport.bRTFFlySyntax )
3027cdf0e10cSrcweir     {
3028cdf0e10cSrcweir         sal_uInt16 nId = static_cast< sal_uInt16 >(rAnchor.GetAnchorId());
302993996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FLYANCHOR);
303093996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append((sal_Int32)nId);
3031cdf0e10cSrcweir         switch( nId )
3032cdf0e10cSrcweir         {
3033cdf0e10cSrcweir             case FLY_AT_PAGE:
303493996bb7SArmin Le Grand                 m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FLYPAGE);
303593996bb7SArmin Le Grand                 m_aRunText.getOStringBuffer().append((sal_Int32)rAnchor.GetPageNum());
3036cdf0e10cSrcweir                 break;
3037cdf0e10cSrcweir             case FLY_AT_PARA:
3038cdf0e10cSrcweir             case FLY_AS_CHAR:
303993996bb7SArmin Le Grand                 m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_FLYCNTNT);
3040cdf0e10cSrcweir                 break;
3041cdf0e10cSrcweir         }
3042cdf0e10cSrcweir     }
3043cdf0e10cSrcweir }
3044cdf0e10cSrcweir 
3045cdf0e10cSrcweir void RtfAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
3046cdf0e10cSrcweir {
3047cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3048cdf0e10cSrcweir 
3049cdf0e10cSrcweir     if( !rBrush.GetColor().GetTransparency() )
3050cdf0e10cSrcweir     {
3051cdf0e10cSrcweir         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CBPAT);
3052cdf0e10cSrcweir         m_aStyles.append((sal_Int32)m_rExport.GetColor(rBrush.GetColor()));
3053cdf0e10cSrcweir     }
3054cdf0e10cSrcweir }
3055cdf0e10cSrcweir 
3056cdf0e10cSrcweir void RtfAttributeOutput::FormatBox( const SvxBoxItem& rBox )
3057cdf0e10cSrcweir {
3058cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3059cdf0e10cSrcweir 
3060cdf0e10cSrcweir     static sal_uInt16 __READONLY_DATA aBorders[] = {
3061cdf0e10cSrcweir         BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
3062cdf0e10cSrcweir     static const sal_Char* aBorderNames[] = {
3063cdf0e10cSrcweir         OOO_STRING_SVTOOLS_RTF_BRDRT, OOO_STRING_SVTOOLS_RTF_BRDRL, OOO_STRING_SVTOOLS_RTF_BRDRB, OOO_STRING_SVTOOLS_RTF_BRDRR };
3064cdf0e10cSrcweir 
3065cdf0e10cSrcweir     sal_uInt16 nDist = rBox.GetDistance();
3066cdf0e10cSrcweir 
3067cdf0e10cSrcweir     if ( m_rExport.bRTFFlySyntax )
3068cdf0e10cSrcweir         return;
3069cdf0e10cSrcweir 
3070cdf0e10cSrcweir     if( rBox.GetTop() && rBox.GetBottom() &&
3071cdf0e10cSrcweir             rBox.GetLeft() && rBox.GetRight() &&
3072cdf0e10cSrcweir             *rBox.GetTop() == *rBox.GetBottom() &&
3073cdf0e10cSrcweir             *rBox.GetTop() == *rBox.GetLeft() &&
3074cdf0e10cSrcweir             *rBox.GetTop() == *rBox.GetRight() &&
3075cdf0e10cSrcweir             nDist == rBox.GetDistance( BOX_LINE_TOP ) &&
3076cdf0e10cSrcweir             nDist == rBox.GetDistance( BOX_LINE_LEFT ) &&
3077cdf0e10cSrcweir             nDist == rBox.GetDistance( BOX_LINE_BOTTOM ) &&
3078cdf0e10cSrcweir             nDist == rBox.GetDistance( BOX_LINE_RIGHT ))
3079cdf0e10cSrcweir         m_aSectionBreaks.append(OutBorderLine( m_rExport, rBox.GetTop(), OOO_STRING_SVTOOLS_RTF_BOX, nDist ));
3080cdf0e10cSrcweir     else
3081cdf0e10cSrcweir     {
3082cdf0e10cSrcweir         const sal_uInt16* pBrd = aBorders;
3083cdf0e10cSrcweir         const sal_Char** pBrdNms = (const sal_Char**)aBorderNames;
3084cdf0e10cSrcweir         for(int i = 0; i < 4; ++i, ++pBrd, ++pBrdNms)
3085cdf0e10cSrcweir         {
3086cdf0e10cSrcweir             if (const SvxBorderLine* pLn = rBox.GetLine(*pBrd))
3087cdf0e10cSrcweir             {
3088cdf0e10cSrcweir                 m_aSectionBreaks.append(OutBorderLine(m_rExport, pLn, *pBrdNms,
3089cdf0e10cSrcweir                         rBox.GetDistance(*pBrd)));
3090cdf0e10cSrcweir             }
3091cdf0e10cSrcweir         }
3092cdf0e10cSrcweir     }
3093cdf0e10cSrcweir 
3094cdf0e10cSrcweir     const sal_uInt16* pBrd = aBorders;
3095cdf0e10cSrcweir     const sal_Char** pBrdNms = (const sal_Char**)aBorderNames;
3096cdf0e10cSrcweir     for( int i = 0; i < 4; ++i, ++pBrd, ++pBrdNms )
3097cdf0e10cSrcweir     {
3098cdf0e10cSrcweir         const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
3099cdf0e10cSrcweir         if( pLn )
3100cdf0e10cSrcweir         {
3101cdf0e10cSrcweir             m_aSectionBreaks.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE);
3102cdf0e10cSrcweir             m_aSectionBreaks.append(OutBorderLine( m_rExport, pLn, *pBrdNms ));
3103cdf0e10cSrcweir             m_aSectionBreaks.append("}" OOO_STRING_SVTOOLS_RTF_BRSP);
3104cdf0e10cSrcweir             m_aSectionBreaks.append((sal_Int32)rBox.GetDistance( *pBrd ));
3105cdf0e10cSrcweir         }
3106cdf0e10cSrcweir     }
3107cdf0e10cSrcweir 
3108cdf0e10cSrcweir     if (!m_bBufferSectionBreaks)
3109cdf0e10cSrcweir         m_aStyles.append(m_aSectionBreaks.makeStringAndClear());
3110cdf0e10cSrcweir }
3111cdf0e10cSrcweir 
3112cdf0e10cSrcweir void RtfAttributeOutput::FormatColumns_Impl( sal_uInt16 nCols, const SwFmtCol& rCol, bool bEven, SwTwips nPageSize )
3113cdf0e10cSrcweir {
3114cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3115cdf0e10cSrcweir 
3116cdf0e10cSrcweir     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLS;
3117cdf0e10cSrcweir     m_rExport.OutLong( nCols );
3118cdf0e10cSrcweir 
3119cdf0e10cSrcweir     if( bEven )
3120cdf0e10cSrcweir     {
3121cdf0e10cSrcweir         m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLSX;
3122cdf0e10cSrcweir         m_rExport.OutLong( rCol.GetGutterWidth( sal_True ) );
3123cdf0e10cSrcweir     }
3124cdf0e10cSrcweir     else
3125cdf0e10cSrcweir     {
3126cdf0e10cSrcweir         const SwColumns & rColumns = rCol.GetColumns( );
3127cdf0e10cSrcweir         for( sal_uInt16 n = 0; n < nCols; )
3128cdf0e10cSrcweir         {
3129cdf0e10cSrcweir             m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLNO;
3130cdf0e10cSrcweir             m_rExport.OutLong( n+1 );
3131cdf0e10cSrcweir 
3132cdf0e10cSrcweir             m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLW;
3133cdf0e10cSrcweir             m_rExport.OutLong( rCol.CalcPrtColWidth( n, nPageSize ) );
3134cdf0e10cSrcweir 
3135cdf0e10cSrcweir             if( ++n != nCols )
3136cdf0e10cSrcweir             {
3137cdf0e10cSrcweir                 m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLSR;
3138cdf0e10cSrcweir                 m_rExport.OutLong( rColumns[ n-1 ]->GetRight() +
3139cdf0e10cSrcweir                         rColumns[ n ]->GetLeft() );
3140cdf0e10cSrcweir             }
3141cdf0e10cSrcweir         }
3142cdf0e10cSrcweir     }
3143cdf0e10cSrcweir }
3144cdf0e10cSrcweir 
3145cdf0e10cSrcweir void RtfAttributeOutput::FormatKeep( const SvxFmtKeepItem& rItem )
3146cdf0e10cSrcweir {
3147cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3148cdf0e10cSrcweir 
3149cdf0e10cSrcweir     if( rItem.GetValue() )
3150cdf0e10cSrcweir         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_KEEPN);
3151cdf0e10cSrcweir }
3152cdf0e10cSrcweir 
3153cdf0e10cSrcweir void RtfAttributeOutput::FormatTextGrid( const SwTextGridItem& /*rGrid*/ )
3154cdf0e10cSrcweir {
3155cdf0e10cSrcweir     OSL_TRACE("TODO: %s", OSL_THIS_FUNC);
3156cdf0e10cSrcweir }
3157cdf0e10cSrcweir 
3158cdf0e10cSrcweir void RtfAttributeOutput::FormatLineNumbering( const SwFmtLineNumber& rNumbering )
3159cdf0e10cSrcweir {
3160cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3161cdf0e10cSrcweir 
3162cdf0e10cSrcweir     if ( !rNumbering.IsCount( ) )
3163cdf0e10cSrcweir         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_NOLINE);
3164cdf0e10cSrcweir }
3165cdf0e10cSrcweir 
3166cdf0e10cSrcweir void RtfAttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDirection )
3167cdf0e10cSrcweir {
3168cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3169cdf0e10cSrcweir 
3170cdf0e10cSrcweir     if (!m_rExport.bOutPageDescs)
3171cdf0e10cSrcweir     {
3172cdf0e10cSrcweir         if (rDirection.GetValue() == FRMDIR_HORI_RIGHT_TOP)
3173cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RTLPAR);
3174cdf0e10cSrcweir         else
3175cdf0e10cSrcweir             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LTRPAR);
3176cdf0e10cSrcweir     }
3177cdf0e10cSrcweir }
3178cdf0e10cSrcweir 
3179a8b9b12aSOliver-Rainer Wittmann void RtfAttributeOutput::WriteExpand( const SwField* pFld )
3180a8b9b12aSOliver-Rainer Wittmann {
3181a8b9b12aSOliver-Rainer Wittmann     String sStr;        // fuer optionale Parameter
3182a8b9b12aSOliver-Rainer Wittmann     switch (pFld->GetTyp()->Which())
3183a8b9b12aSOliver-Rainer Wittmann     {
3184a8b9b12aSOliver-Rainer Wittmann         //#119803# Export user field and DB field for RTF filter
3185a8b9b12aSOliver-Rainer Wittmann         case RES_DBFLD:
3186a8b9b12aSOliver-Rainer Wittmann             sStr = FieldString(ww::eMERGEFIELD);
3187a8b9b12aSOliver-Rainer Wittmann             // kein break !!
3188a8b9b12aSOliver-Rainer Wittmann         case RES_USERFLD:
3189a8b9b12aSOliver-Rainer Wittmann             sStr += pFld->GetTyp()->GetName();
3190a8b9b12aSOliver-Rainer Wittmann             m_rExport.OutputField(pFld, ww::eNONE, sStr);
3191a8b9b12aSOliver-Rainer Wittmann             break;
3192a8b9b12aSOliver-Rainer Wittmann     }
3193cdf0e10cSrcweir }
3194cdf0e10cSrcweir 
3195cdf0e10cSrcweir void RtfAttributeOutput::RefField( const SwField& /*rFld*/, const String& /*rRef*/ )
3196cdf0e10cSrcweir {
3197cdf0e10cSrcweir     OSL_TRACE("TODO: %s", OSL_THIS_FUNC);
3198cdf0e10cSrcweir }
3199cdf0e10cSrcweir 
3200cdf0e10cSrcweir void RtfAttributeOutput::HiddenField( const SwField& /*rFld*/ )
3201cdf0e10cSrcweir {
3202cdf0e10cSrcweir     OSL_TRACE("TODO: %s", OSL_THIS_FUNC);
3203cdf0e10cSrcweir }
3204cdf0e10cSrcweir 
3205cdf0e10cSrcweir void RtfAttributeOutput::SetField( const SwField& /*rFld*/, ww::eField /*eType*/, const String& /*rCmd*/ )
3206cdf0e10cSrcweir {
3207cdf0e10cSrcweir     OSL_TRACE("TODO: %s", OSL_THIS_FUNC);
3208cdf0e10cSrcweir }
3209cdf0e10cSrcweir 
3210cdf0e10cSrcweir void RtfAttributeOutput::PostitField( const SwField* pFld )
3211cdf0e10cSrcweir {
3212cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3213cdf0e10cSrcweir 
3214cdf0e10cSrcweir     const SwPostItField& rPFld = *(SwPostItField*)pFld;
3215cdf0e10cSrcweir 
321693996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNID " ");
321793996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append(OUStringToOString(OUString(rPFld.GetPar1()), m_rExport.eCurrentEncoding));
321893996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("}");
321993996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNAUTHOR " ");
322093996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append(OUStringToOString(OUString(rPFld.GetPar1()), m_rExport.eCurrentEncoding));
322193996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("}");
322293996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append(OOO_STRING_SVTOOLS_RTF_CHATN);
3223cdf0e10cSrcweir 
322493996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ANNOTATION);
322593996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNDATE " ");
322693996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append((sal_Int32)sw::ms::DateTime2DTTM(rPFld.GetDate()));
322793996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append('}');
32283b32dd21SOliver-Rainer Wittmann     m_aRunText.getOStringBuffer().append(OUStringToOString(OUString(rPFld.GetContent()), m_rExport.eCurrentEncoding));
322993996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append('}');
3230cdf0e10cSrcweir }
3231cdf0e10cSrcweir 
3232cdf0e10cSrcweir bool RtfAttributeOutput::DropdownField( const SwField* /*pFld*/ )
3233cdf0e10cSrcweir {
3234cdf0e10cSrcweir     // this is handled in OutputFlyFrame_Impl()
3235cdf0e10cSrcweir     return true;
3236cdf0e10cSrcweir }
3237cdf0e10cSrcweir 
3238cdf0e10cSrcweir RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport )
3239cdf0e10cSrcweir     : m_rExport( rExport ),
3240cdf0e10cSrcweir     m_pTableWrt( NULL ),
3241cdf0e10cSrcweir     m_bTableCellOpen( false ),
3242cdf0e10cSrcweir     m_nTableDepth( 0 ),
3243cdf0e10cSrcweir     m_bTblAfterCell( false ),
3244cdf0e10cSrcweir     m_nColBreakNeeded( false ),
3245cdf0e10cSrcweir     m_bBufferSectionBreaks( false ),
3246cdf0e10cSrcweir     m_bBufferSectionHeaders( false ),
3247cdf0e10cSrcweir     m_bLastTable( true ),
3248cdf0e10cSrcweir     m_bWroteCellInfo( false )
3249cdf0e10cSrcweir {
3250cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3251cdf0e10cSrcweir }
3252cdf0e10cSrcweir 
3253cdf0e10cSrcweir RtfAttributeOutput::~RtfAttributeOutput()
3254cdf0e10cSrcweir {
3255cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3256cdf0e10cSrcweir }
3257cdf0e10cSrcweir 
3258cdf0e10cSrcweir MSWordExportBase& RtfAttributeOutput::GetExport()
3259cdf0e10cSrcweir {
3260cdf0e10cSrcweir     return m_rExport;
3261cdf0e10cSrcweir }
3262cdf0e10cSrcweir 
3263cdf0e10cSrcweir // These are used by wwFont::WriteRtf()
3264cdf0e10cSrcweir 
3265cdf0e10cSrcweir /// Start the font.
3266cdf0e10cSrcweir void RtfAttributeOutput::StartFont( const String& rFamilyName ) const
3267cdf0e10cSrcweir {
3268cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3269cdf0e10cSrcweir 
3270cdf0e10cSrcweir     m_rExport.Strm() << OUStringToOString( OUString( rFamilyName ), m_rExport.eCurrentEncoding ).getStr();
3271cdf0e10cSrcweir }
3272cdf0e10cSrcweir 
3273cdf0e10cSrcweir /// End the font.
3274cdf0e10cSrcweir void RtfAttributeOutput::EndFont() const
3275cdf0e10cSrcweir {
3276cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3277cdf0e10cSrcweir 
3278cdf0e10cSrcweir     m_rExport.Strm() << ";}";
3279cdf0e10cSrcweir }
3280cdf0e10cSrcweir 
3281cdf0e10cSrcweir /// Alternate name for the font.
3282cdf0e10cSrcweir void RtfAttributeOutput::FontAlternateName( const String& rName ) const
3283cdf0e10cSrcweir {
3284cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3285cdf0e10cSrcweir 
3286cdf0e10cSrcweir     m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_IGNORE << OOO_STRING_SVTOOLS_RTF_FALT << ' ';
3287cdf0e10cSrcweir     m_rExport.Strm() << OUStringToOString( OUString( rName ), m_rExport.eCurrentEncoding ) << '}';
3288cdf0e10cSrcweir }
3289cdf0e10cSrcweir 
3290cdf0e10cSrcweir /// Font charset.
3291cdf0e10cSrcweir void RtfAttributeOutput::FontCharset( sal_uInt8 nCharSet ) const
3292cdf0e10cSrcweir {
3293cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3294cdf0e10cSrcweir 
3295cdf0e10cSrcweir     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_FCHARSET;
3296cdf0e10cSrcweir     m_rExport.OutULong( nCharSet );
3297cdf0e10cSrcweir     m_rExport.Strm() << ' ';
3298cdf0e10cSrcweir }
3299cdf0e10cSrcweir 
3300cdf0e10cSrcweir /// Font family.
3301cdf0e10cSrcweir void RtfAttributeOutput::FontFamilyType( FontFamily eFamily, const wwFont &rFont ) const
3302cdf0e10cSrcweir {
3303cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3304cdf0e10cSrcweir 
3305cdf0e10cSrcweir     m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_F;
3306cdf0e10cSrcweir 
3307cdf0e10cSrcweir     const char* pStr = OOO_STRING_SVTOOLS_RTF_FNIL;
3308cdf0e10cSrcweir     switch (eFamily)
3309cdf0e10cSrcweir     {
3310cdf0e10cSrcweir         case FAMILY_ROMAN:
3311cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_FROMAN;
3312cdf0e10cSrcweir             break;
3313cdf0e10cSrcweir         case FAMILY_SWISS:
3314cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_FSWISS;
3315cdf0e10cSrcweir             break;
3316cdf0e10cSrcweir         case FAMILY_MODERN:
3317cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_FMODERN;
3318cdf0e10cSrcweir             break;
3319cdf0e10cSrcweir         case FAMILY_SCRIPT:
3320cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_FSCRIPT;
3321cdf0e10cSrcweir             break;
3322cdf0e10cSrcweir         case FAMILY_DECORATIVE:
3323cdf0e10cSrcweir             pStr = OOO_STRING_SVTOOLS_RTF_FDECOR;
3324cdf0e10cSrcweir             break;
3325cdf0e10cSrcweir         default:
3326cdf0e10cSrcweir             break;
3327cdf0e10cSrcweir     }
3328cdf0e10cSrcweir     m_rExport.OutULong(m_rExport.maFontHelper.GetId(rFont)) << pStr;
3329cdf0e10cSrcweir }
3330cdf0e10cSrcweir 
3331cdf0e10cSrcweir /// Font pitch.
3332cdf0e10cSrcweir void RtfAttributeOutput::FontPitchType( FontPitch ePitch ) const
3333cdf0e10cSrcweir {
3334cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3335cdf0e10cSrcweir 
3336cdf0e10cSrcweir     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_FPRQ;
3337cdf0e10cSrcweir 
3338cdf0e10cSrcweir     sal_uInt16 nVal = 0;
3339cdf0e10cSrcweir     switch (ePitch)
3340cdf0e10cSrcweir     {
3341cdf0e10cSrcweir         case PITCH_FIXED:
3342cdf0e10cSrcweir             nVal = 1;
3343cdf0e10cSrcweir             break;
3344cdf0e10cSrcweir         case PITCH_VARIABLE:
3345cdf0e10cSrcweir             nVal = 2;
3346cdf0e10cSrcweir             break;
3347cdf0e10cSrcweir         default:
3348cdf0e10cSrcweir             break;
3349cdf0e10cSrcweir     }
3350cdf0e10cSrcweir     m_rExport.OutULong(nVal);
3351cdf0e10cSrcweir }
3352cdf0e10cSrcweir 
3353cdf0e10cSrcweir static bool IsEMF(const sal_uInt8 *pGraphicAry, unsigned long nSize)
3354cdf0e10cSrcweir {
3355cdf0e10cSrcweir     if (pGraphicAry && (nSize > 0x2c ))
3356cdf0e10cSrcweir     {
3357cdf0e10cSrcweir         // check the magic number
3358cdf0e10cSrcweir         if (
3359cdf0e10cSrcweir                 (pGraphicAry[0x28] == 0x20 ) && (pGraphicAry[0x29] == 0x45) &&
3360cdf0e10cSrcweir                 (pGraphicAry[0x2a] == 0x4d ) && (pGraphicAry[0x2b] == 0x46)
3361cdf0e10cSrcweir            )
3362cdf0e10cSrcweir         {
3363cdf0e10cSrcweir             //emf detected
3364cdf0e10cSrcweir             return true;
3365cdf0e10cSrcweir         }
3366cdf0e10cSrcweir     }
3367cdf0e10cSrcweir     return false;
3368cdf0e10cSrcweir }
3369cdf0e10cSrcweir 
3370cdf0e10cSrcweir static bool StripMetafileHeader(const sal_uInt8 *&rpGraphicAry, unsigned long &rSize)
3371cdf0e10cSrcweir {
3372cdf0e10cSrcweir     if (rpGraphicAry && (rSize > 0x22))
3373cdf0e10cSrcweir     {
3374cdf0e10cSrcweir         if (
3375cdf0e10cSrcweir              (rpGraphicAry[0] == 0xd7) && (rpGraphicAry[1] == 0xcd) &&
3376cdf0e10cSrcweir              (rpGraphicAry[2] == 0xc6) && (rpGraphicAry[3] == 0x9a)
3377cdf0e10cSrcweir            )
3378cdf0e10cSrcweir         {   // we have to get rid of the metafileheader
3379cdf0e10cSrcweir             rpGraphicAry += 22;
3380cdf0e10cSrcweir             rSize -= 22;
3381cdf0e10cSrcweir             return true;
3382cdf0e10cSrcweir         }
3383cdf0e10cSrcweir     }
3384cdf0e10cSrcweir     return false;
3385cdf0e10cSrcweir }
3386cdf0e10cSrcweir 
3387cdf0e10cSrcweir static OString WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, sal_uInt32 nLimit = 64)
3388cdf0e10cSrcweir {
3389cdf0e10cSrcweir     OStringBuffer aRet;
3390cdf0e10cSrcweir 
3391cdf0e10cSrcweir     sal_uInt32 nBreak = 0;
3392cdf0e10cSrcweir     for (sal_uInt32 i = 0; i < nSize; i++)
3393cdf0e10cSrcweir     {
3394cdf0e10cSrcweir         OString sNo = OString::valueOf(sal_Int32(pData[i]), 16);
3395cdf0e10cSrcweir         if (sNo.getLength() < 2)
3396cdf0e10cSrcweir             aRet.append('0');
3397cdf0e10cSrcweir         aRet.append(sNo);
3398cdf0e10cSrcweir         if (++nBreak == nLimit)
3399cdf0e10cSrcweir         {
3400cdf0e10cSrcweir             aRet.append(RtfExport::sNewLine);
3401cdf0e10cSrcweir             nBreak = 0;
3402cdf0e10cSrcweir         }
3403cdf0e10cSrcweir     }
3404cdf0e10cSrcweir 
3405cdf0e10cSrcweir     return aRet.makeStringAndClear();
3406cdf0e10cSrcweir }
3407cdf0e10cSrcweir 
3408cdf0e10cSrcweir static OString WriteHex(sal_Int32 nNum)
3409cdf0e10cSrcweir {
3410cdf0e10cSrcweir     return WriteHex((sal_uInt8*)&nNum, sizeof(sal_Int32));
3411cdf0e10cSrcweir }
3412cdf0e10cSrcweir 
3413cdf0e10cSrcweir static OString WriteHex(OString sString)
3414cdf0e10cSrcweir {
3415cdf0e10cSrcweir     OStringBuffer aRet;
3416cdf0e10cSrcweir 
3417cdf0e10cSrcweir     aRet.append(WriteHex(sString.getLength()+1));
3418cdf0e10cSrcweir     aRet.append(WriteHex((sal_uInt8*)sString.getStr(), sString.getLength()+1));
3419cdf0e10cSrcweir 
3420cdf0e10cSrcweir     return aRet.makeStringAndClear();
3421cdf0e10cSrcweir }
3422cdf0e10cSrcweir 
3423cdf0e10cSrcweir void lcl_AppendSP( OStringBuffer& rBuffer,
3424cdf0e10cSrcweir     const char cName[],
3425cdf0e10cSrcweir     const ::rtl::OUString& rValue,
3426cdf0e10cSrcweir     const RtfExport& rExport )
3427cdf0e10cSrcweir {
3428cdf0e10cSrcweir     rBuffer.append( "{" OOO_STRING_SVTOOLS_RTF_SP "{" ); // "{\sp{"
3429cdf0e10cSrcweir     rBuffer.append( OOO_STRING_SVTOOLS_RTF_SN " " );//" \sn "
3430cdf0e10cSrcweir     rBuffer.append( cName ); //"PropName"
3431cdf0e10cSrcweir     rBuffer.append( "}{" OOO_STRING_SVTOOLS_RTF_SV " " );
3432cdf0e10cSrcweir // "}{ \sv "
3433cdf0e10cSrcweir     rBuffer.append( rExport.OutString( rValue, rExport.eCurrentEncoding ) );
3434cdf0e10cSrcweir     rBuffer.append( "}}" );
3435cdf0e10cSrcweir }
3436cdf0e10cSrcweir 
343793996bb7SArmin Le Grand void ExportPICT(
343893996bb7SArmin Le Grand     MultiBuffer& rTarget,
343993996bb7SArmin Le Grand     const SwFlyFrmFmt* pFlyFrmFmt,
344093996bb7SArmin Le Grand     const Size &rOrig,
344193996bb7SArmin Le Grand     const Size &rRendered,
344293996bb7SArmin Le Grand     const Size &rMapped,
344393996bb7SArmin Le Grand     const SwCropGrf &rCr,
344493996bb7SArmin Le Grand     const char *pBLIPType,
344593996bb7SArmin Le Grand     const sal_uInt8 *pGraphicAry,
344693996bb7SArmin Le Grand     unsigned long nSize,
344793996bb7SArmin Le Grand     const RtfExport& rExport )
3448cdf0e10cSrcweir {
3449cdf0e10cSrcweir     bool bIsWMF = (const char *)pBLIPType == (const char *)OOO_STRING_SVTOOLS_RTF_WMETAFILE ? true : false;
3450cdf0e10cSrcweir     if (pBLIPType && nSize && pGraphicAry)
3451cdf0e10cSrcweir     {
345293996bb7SArmin Le Grand         rtl::OStringBuffer& rBuffer = rTarget.getOStringBuffer();
345393996bb7SArmin Le Grand         rBuffer.append("{" OOO_STRING_SVTOOLS_RTF_PICT);
3454cdf0e10cSrcweir 
3455cdf0e10cSrcweir         if( pFlyFrmFmt )
3456cdf0e10cSrcweir         {
3457cdf0e10cSrcweir             String sDescription = pFlyFrmFmt->GetObjDescription();
3458cdf0e10cSrcweir             //write picture properties - wzDescription at first
3459cdf0e10cSrcweir             //looks like: "{\*\picprop{\sp{\sn PropertyName}{\sv PropertyValue}}}"
346093996bb7SArmin Le Grand             rBuffer.append( "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_PICPROP );//"{\*\picprop
346193996bb7SArmin Le Grand             lcl_AppendSP( rBuffer, "wzDescription", sDescription, rExport );
3462cdf0e10cSrcweir             String sName = pFlyFrmFmt->GetObjTitle();
346393996bb7SArmin Le Grand             lcl_AppendSP( rBuffer, "wzName", sName, rExport );
346493996bb7SArmin Le Grand             rBuffer.append( "}" ); //"}"
3465cdf0e10cSrcweir         }
3466cdf0e10cSrcweir 
3467cdf0e10cSrcweir         long nXCroppedSize = rOrig.Width()-(rCr.GetLeft() + rCr.GetRight());
3468cdf0e10cSrcweir         long nYCroppedSize = rOrig.Height()-(rCr.GetTop() + rCr.GetBottom());
3469cdf0e10cSrcweir         /* #127543#: Graphic with a zero height or width, typically copied from webpages, caused
3470cdf0e10cSrcweir            crashes. */
3471cdf0e10cSrcweir         if( !nXCroppedSize )
3472cdf0e10cSrcweir             nXCroppedSize = 100;
3473cdf0e10cSrcweir         if( !nYCroppedSize )
3474cdf0e10cSrcweir             nYCroppedSize = 100;
3475cdf0e10cSrcweir 
3476cdf0e10cSrcweir         //Given the original size and taking cropping into account
3477cdf0e10cSrcweir         //first, how much has the original been scaled to get the
3478cdf0e10cSrcweir         //final rendered size
347993996bb7SArmin Le Grand         rBuffer.append(OOO_STRING_SVTOOLS_RTF_PICSCALEX);
348093996bb7SArmin Le Grand         rBuffer.append((sal_Int32)((100 * rRendered.Width()) / nXCroppedSize));
348193996bb7SArmin Le Grand         rBuffer.append(OOO_STRING_SVTOOLS_RTF_PICSCALEY);
348293996bb7SArmin Le Grand         rBuffer.append((sal_Int32)((100 * rRendered.Height()) / nYCroppedSize));
348393996bb7SArmin Le Grand 
348493996bb7SArmin Le Grand         rBuffer.append(OOO_STRING_SVTOOLS_RTF_PICCROPL);
348593996bb7SArmin Le Grand         rBuffer.append((sal_Int32)rCr.GetLeft());
348693996bb7SArmin Le Grand         rBuffer.append(OOO_STRING_SVTOOLS_RTF_PICCROPR);
348793996bb7SArmin Le Grand         rBuffer.append((sal_Int32)rCr.GetRight());
348893996bb7SArmin Le Grand         rBuffer.append(OOO_STRING_SVTOOLS_RTF_PICCROPT);
348993996bb7SArmin Le Grand         rBuffer.append((sal_Int32)rCr.GetTop());
349093996bb7SArmin Le Grand         rBuffer.append(OOO_STRING_SVTOOLS_RTF_PICCROPB);
349193996bb7SArmin Le Grand         rBuffer.append((sal_Int32)rCr.GetBottom());
349293996bb7SArmin Le Grand 
349393996bb7SArmin Le Grand         rBuffer.append(OOO_STRING_SVTOOLS_RTF_PICW);
349493996bb7SArmin Le Grand         rBuffer.append((sal_Int32)rMapped.Width());
349593996bb7SArmin Le Grand         rBuffer.append(OOO_STRING_SVTOOLS_RTF_PICH);
349693996bb7SArmin Le Grand         rBuffer.append((sal_Int32)rMapped.Height());
349793996bb7SArmin Le Grand 
349893996bb7SArmin Le Grand         rBuffer.append(OOO_STRING_SVTOOLS_RTF_PICWGOAL);
349993996bb7SArmin Le Grand         rBuffer.append((sal_Int32)rOrig.Width());
350093996bb7SArmin Le Grand         rBuffer.append(OOO_STRING_SVTOOLS_RTF_PICHGOAL);
350193996bb7SArmin Le Grand         rBuffer.append((sal_Int32)rOrig.Height());
350293996bb7SArmin Le Grand 
350393996bb7SArmin Le Grand         rBuffer.append(pBLIPType);
3504cdf0e10cSrcweir         if (bIsWMF)
3505cdf0e10cSrcweir         {
350693996bb7SArmin Le Grand             rBuffer.append((sal_Int32)8);
3507cdf0e10cSrcweir             StripMetafileHeader(pGraphicAry, nSize);
3508cdf0e10cSrcweir         }
350993996bb7SArmin Le Grand         rBuffer.append(RtfExport::sNewLine);
351093996bb7SArmin Le Grand 
351193996bb7SArmin Le Grand         // append binary data for later streaming
351293996bb7SArmin Le Grand         // anotation: it is okay to append further to the remembered rBuffer since
351393996bb7SArmin Le Grand         // the address of this basic buffer at MultiBuffer does not change; it will
351493996bb7SArmin Le Grand         // be reset to length zero, though, after this call
351593996bb7SArmin Le Grand         rTarget.appendHexData(pGraphicAry, nSize);
351693996bb7SArmin Le Grand 
351793996bb7SArmin Le Grand         rBuffer.append('}');
3518cdf0e10cSrcweir     }
3519cdf0e10cSrcweir }
3520cdf0e10cSrcweir 
3521cdf0e10cSrcweir void RtfAttributeOutput::FlyFrameOLEData( SwOLENode& rOLENode )
3522cdf0e10cSrcweir {
3523cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3524cdf0e10cSrcweir 
3525cdf0e10cSrcweir     uno::Reference < embed::XEmbeddedObject > xObj(const_cast<SwOLENode&>(rOLENode).GetOLEObj().GetOleRef());
3526cdf0e10cSrcweir     sal_Int64 nAspect = rOLENode.GetAspect();
3527cdf0e10cSrcweir     svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
3528cdf0e10cSrcweir     SvGlobalName aObjName(aObjRef->getClassID());
3529cdf0e10cSrcweir 
3530cdf0e10cSrcweir     if (SotExchange::IsMath(aObjName))
3531cdf0e10cSrcweir     {
3532cdf0e10cSrcweir         // ObjectHeader
353393996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(WriteHex(0x00000501)); // OLEVersion
353493996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(WriteHex(0x00000002)); // FormatID
353593996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(WriteHex(OString("Equation.3"))); // ClassName
353693996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(WriteHex(0x00000000)); // TopicName
353793996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(WriteHex(0x00000000)); // ItemName
3538cdf0e10cSrcweir 
3539cdf0e10cSrcweir         // NativeData
3540cdf0e10cSrcweir         SvMemoryStream *pStream = new SvMemoryStream;
3541cdf0e10cSrcweir         SvStorage* pStorage = new SvStorage(*pStream);
3542cdf0e10cSrcweir         m_rExport.pOLEExp->ExportOLEObject( aObjRef, *pStorage );
3543cdf0e10cSrcweir         pStream->Seek(STREAM_SEEK_TO_END);
3544cdf0e10cSrcweir         sal_uInt32 nNativeDataSize = pStream->Tell();
3545cdf0e10cSrcweir         const sal_uInt8* pNativeData = (sal_uInt8*)pStream->GetData();
354693996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(WriteHex(nNativeDataSize));
354793996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(RtfExport::sNewLine);
354893996bb7SArmin Le Grand 
354993996bb7SArmin Le Grand         // append binary data for later streaming
355093996bb7SArmin Le Grand         m_aRunText.appendHexData(pNativeData, nNativeDataSize, 126);
355193996bb7SArmin Le Grand 
355293996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append(RtfExport::sNewLine);
3553cdf0e10cSrcweir         delete pStream;
3554cdf0e10cSrcweir 
3555cdf0e10cSrcweir         // MetaFilePresentationObject
3556cdf0e10cSrcweir         pStream = new SvMemoryStream;
3557cdf0e10cSrcweir         Graphic* pGraphic = rOLENode.GetGraphic();
3558cdf0e10cSrcweir         if (GraphicConverter::Export(*pStream, *pGraphic, CVT_WMF) != ERRCODE_NONE)
3559cdf0e10cSrcweir             OSL_ENSURE(false, "failed to export the presentation data");
3560cdf0e10cSrcweir         pStream->Seek(STREAM_SEEK_TO_END);
3561cdf0e10cSrcweir         sal_uInt32 nPresentationDataSize = pStream->Tell();
3562cdf0e10cSrcweir         const sal_uInt8* pPresentationData = (sal_uInt8*)pStream->GetData();
356393996bb7SArmin Le Grand 
356493996bb7SArmin Le Grand         // append binary data for later streaming
356593996bb7SArmin Le Grand         m_aRunText.appendHexData(pPresentationData, nPresentationDataSize, 126);
3566cdf0e10cSrcweir     }
3567cdf0e10cSrcweir }
3568cdf0e10cSrcweir 
3569cdf0e10cSrcweir void RtfAttributeOutput::FlyFrameOLE( const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode& rOLENode, const Size& rSize )
3570cdf0e10cSrcweir {
3571cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3572cdf0e10cSrcweir 
3573cdf0e10cSrcweir     SvMemoryStream aStream;
3574cdf0e10cSrcweir     const sal_uInt8* pGraphicAry = 0;
3575cdf0e10cSrcweir     sal_uInt32 nSize = 0;
3576cdf0e10cSrcweir     Graphic* pGraphic = rOLENode.GetGraphic();
3577cdf0e10cSrcweir 
3578cdf0e10cSrcweir     Size aSize(sw::util::GetSwappedInSize(rOLENode));
3579cdf0e10cSrcweir     Size aRendered(aSize);
3580cdf0e10cSrcweir     aRendered.Width() = rSize.Width();
3581cdf0e10cSrcweir     aRendered.Height() = rSize.Height();
3582cdf0e10cSrcweir     Size aMapped(pGraphic->GetPrefSize());
3583cdf0e10cSrcweir     const SwCropGrf &rCr = (const SwCropGrf &)rOLENode.GetAttr(RES_GRFATR_CROPGRF);
3584cdf0e10cSrcweir     const sal_Char* pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
3585cdf0e10cSrcweir 
3586cdf0e10cSrcweir     if (GraphicConverter::Export(aStream, *pGraphic, CVT_WMF) != ERRCODE_NONE)
3587cdf0e10cSrcweir         OSL_ENSURE(false, "failed to export the graphic");
3588cdf0e10cSrcweir     aStream.Seek(STREAM_SEEK_TO_END);
3589cdf0e10cSrcweir     nSize = aStream.Tell();
3590cdf0e10cSrcweir     pGraphicAry = (sal_uInt8*)aStream.GetData();
3591cdf0e10cSrcweir 
359293996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_OBJECT OOO_STRING_SVTOOLS_RTF_OBJEMB);
3593cdf0e10cSrcweir 
3594cdf0e10cSrcweir     // export the object data in the appropriate format; RTF requires the usage of the OLE 1.0 format
359593996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_OBJDATA " ");
3596cdf0e10cSrcweir     FlyFrameOLEData(rOLENode);
359793996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("}{" OOO_STRING_SVTOOLS_RTF_RESULT);
3598cdf0e10cSrcweir 
3599cdf0e10cSrcweir     SwTwips nHeight = aSize.Height();
3600cdf0e10cSrcweir     nHeight/=20; //nHeight was in twips, want it in half points, but then half of total height.
3601cdf0e10cSrcweir     long nFontHeight = ((const SvxFontHeightItem&)m_rExport.GetItem(RES_CHRATR_FONTSIZE)).GetHeight();
3602cdf0e10cSrcweir     nHeight-=nFontHeight/20;
360393996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_DN).append(nHeight);
360493996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
360593996bb7SArmin Le Grand     ExportPICT( m_aRunText, pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport );
360693996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append("}}}}");
3607cdf0e10cSrcweir }
3608cdf0e10cSrcweir 
3609cdf0e10cSrcweir void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode& rGrfNode, const Size& rSize )
3610cdf0e10cSrcweir {
3611cdf0e10cSrcweir     OSL_TRACE("%s", OSL_THIS_FUNC);
3612cdf0e10cSrcweir 
3613cdf0e10cSrcweir     SvMemoryStream aStream;
3614cdf0e10cSrcweir     const sal_uInt8* pGraphicAry = 0;
3615cdf0e10cSrcweir     sal_uInt32 nSize = 0;
3616cdf0e10cSrcweir 
3617cdf0e10cSrcweir     Graphic aGraphic(rGrfNode.GetGrf());
3618cdf0e10cSrcweir 
3619cdf0e10cSrcweir     // If there is no graphic there is not much point in parsing it
3620cdf0e10cSrcweir     if(aGraphic.GetType()==GRAPHIC_NONE)
3621cdf0e10cSrcweir         return;
3622cdf0e10cSrcweir 
3623cdf0e10cSrcweir     GfxLink aGraphicLink;
3624cdf0e10cSrcweir     const sal_Char* pBLIPType = 0;
3625cdf0e10cSrcweir     if (aGraphic.IsLink())
3626cdf0e10cSrcweir     {
3627cdf0e10cSrcweir         aGraphicLink = aGraphic.GetLink();
3628cdf0e10cSrcweir         nSize = aGraphicLink.GetDataSize();
3629cdf0e10cSrcweir         pGraphicAry = aGraphicLink.GetData();
3630cdf0e10cSrcweir         switch (aGraphicLink.GetType())
3631cdf0e10cSrcweir         {
3632*270a30dfSArmin Le Grand             // #15508# trying to add BMP type for better exports, need to check if this works
3633*270a30dfSArmin Le Grand             // checked, does not work. Also need to reset pGraphicAry to NULL to force conversion
3634*270a30dfSArmin Le Grand             // to PNG, else the BMP array will be used.
3635*270a30dfSArmin Le Grand             // It may work using direct DIB data, but that needs to be checked eventually
3636*270a30dfSArmin Le Grand             //
3637*270a30dfSArmin Le Grand             // #15508# before GFX_LINK_TYPE_NATIVE_BMP was added the graphic data
3638*270a30dfSArmin Le Grand             // (to be hold in pGraphicAry) was not available; thus for now to stay
3639*270a30dfSArmin Le Grand             // compatible, keep it that way by assigning NULL value to pGraphicAry
3640*270a30dfSArmin Le Grand             case GFX_LINK_TYPE_NATIVE_BMP:
3641*270a30dfSArmin Le Grand             //    pBLIPType = OOO_STRING_SVTOOLS_RTF_WBITMAP;
3642*270a30dfSArmin Le Grand                 pGraphicAry = 0;
3643*270a30dfSArmin Le Grand                 break;
3644*270a30dfSArmin Le Grand 
3645cdf0e10cSrcweir             case GFX_LINK_TYPE_NATIVE_JPG:
3646cdf0e10cSrcweir                 pBLIPType = OOO_STRING_SVTOOLS_RTF_JPEGBLIP;
3647cdf0e10cSrcweir                 break;
3648cdf0e10cSrcweir             case GFX_LINK_TYPE_NATIVE_PNG:
3649cdf0e10cSrcweir                 pBLIPType = OOO_STRING_SVTOOLS_RTF_PNGBLIP;
3650cdf0e10cSrcweir                 break;
3651cdf0e10cSrcweir             case GFX_LINK_TYPE_NATIVE_WMF:
3652cdf0e10cSrcweir                 pBLIPType =
3653cdf0e10cSrcweir                     IsEMF(pGraphicAry, nSize) ? OOO_STRING_SVTOOLS_RTF_EMFBLIP : OOO_STRING_SVTOOLS_RTF_WMETAFILE;
3654cdf0e10cSrcweir                 break;
3655cdf0e10cSrcweir             default:
3656cdf0e10cSrcweir                 break;
3657cdf0e10cSrcweir         }
3658cdf0e10cSrcweir     }
3659cdf0e10cSrcweir 
3660cdf0e10cSrcweir     GraphicType eGraphicType = aGraphic.GetType();
3661cdf0e10cSrcweir     if (!pGraphicAry)
3662cdf0e10cSrcweir     {
3663cdf0e10cSrcweir         if (ERRCODE_NONE == GraphicConverter::Export(aStream, aGraphic,
3664cdf0e10cSrcweir                     (eGraphicType == GRAPHIC_BITMAP) ? CVT_PNG : CVT_WMF))
3665cdf0e10cSrcweir         {
3666cdf0e10cSrcweir             pBLIPType = (eGraphicType == GRAPHIC_BITMAP) ?
3667cdf0e10cSrcweir                 OOO_STRING_SVTOOLS_RTF_PNGBLIP : OOO_STRING_SVTOOLS_RTF_WMETAFILE;
3668cdf0e10cSrcweir             aStream.Seek(STREAM_SEEK_TO_END);
3669cdf0e10cSrcweir             nSize = aStream.Tell();
3670cdf0e10cSrcweir             pGraphicAry = (sal_uInt8*)aStream.GetData();
3671cdf0e10cSrcweir         }
3672cdf0e10cSrcweir     }
3673cdf0e10cSrcweir 
3674cdf0e10cSrcweir     Size aMapped(eGraphicType == GRAPHIC_BITMAP ? aGraphic.GetSizePixel() : aGraphic.GetPrefSize());
3675cdf0e10cSrcweir 
3676cdf0e10cSrcweir     const SwCropGrf &rCr = (const SwCropGrf &)rGrfNode.GetAttr(RES_GRFATR_CROPGRF);
3677cdf0e10cSrcweir 
3678cdf0e10cSrcweir     //Get original size in twips
3679cdf0e10cSrcweir     Size aSize(sw::util::GetSwappedInSize(rGrfNode));
3680cdf0e10cSrcweir     Size aRendered(aSize);
3681cdf0e10cSrcweir     aRendered.Width() = rSize.Width();
3682cdf0e10cSrcweir     aRendered.Height() = rSize.Height();
3683cdf0e10cSrcweir 
3684cdf0e10cSrcweir     /*
3685cdf0e10cSrcweir        If the graphic is not of type WMF then we will have to store two
3686cdf0e10cSrcweir        graphics, one in the native format wrapped in shppict, and the other in
3687cdf0e10cSrcweir        the wmf format wrapped in nonshppict, so as to keep wordpad happy. If its
3688cdf0e10cSrcweir        a wmf already then we don't need any such wrapping
3689cdf0e10cSrcweir        */
3690cdf0e10cSrcweir     bool bIsWMF = (const sal_Char*)pBLIPType == (const sal_Char*)OOO_STRING_SVTOOLS_RTF_WMETAFILE ? true : false;
3691cdf0e10cSrcweir     if (!bIsWMF)
369293996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
3693cdf0e10cSrcweir 
3694cdf0e10cSrcweir     if (pBLIPType)
369593996bb7SArmin Le Grand     {
369693996bb7SArmin Le Grand         ExportPICT( m_aRunText, pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport);
369793996bb7SArmin Le Grand     }
3698cdf0e10cSrcweir     else
3699cdf0e10cSrcweir     {
3700cdf0e10cSrcweir         aStream.Seek(0);
3701cdf0e10cSrcweir         GraphicConverter::Export(aStream, aGraphic, CVT_WMF);
3702cdf0e10cSrcweir         pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
3703cdf0e10cSrcweir         aStream.Seek(STREAM_SEEK_TO_END);
3704cdf0e10cSrcweir         nSize = aStream.Tell();
3705cdf0e10cSrcweir         pGraphicAry = (sal_uInt8*)aStream.GetData();
3706cdf0e10cSrcweir 
370793996bb7SArmin Le Grand         ExportPICT( m_aRunText, pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport );
3708cdf0e10cSrcweir     }
3709cdf0e10cSrcweir 
3710cdf0e10cSrcweir     if (!bIsWMF)
3711cdf0e10cSrcweir     {
371293996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append("}" "{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT);
3713cdf0e10cSrcweir 
3714cdf0e10cSrcweir         aStream.Seek(0);
3715cdf0e10cSrcweir         GraphicConverter::Export(aStream, aGraphic, CVT_WMF);
3716cdf0e10cSrcweir         pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
3717cdf0e10cSrcweir         aStream.Seek(STREAM_SEEK_TO_END);
3718cdf0e10cSrcweir         nSize = aStream.Tell();
3719cdf0e10cSrcweir         pGraphicAry = (sal_uInt8*)aStream.GetData();
3720cdf0e10cSrcweir 
372193996bb7SArmin Le Grand         ExportPICT( m_aRunText, pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport );
3722cdf0e10cSrcweir 
372393996bb7SArmin Le Grand         m_aRunText.getOStringBuffer().append('}');
3724cdf0e10cSrcweir     }
3725cdf0e10cSrcweir 
372693996bb7SArmin Le Grand     m_aRunText.getOStringBuffer().append(m_rExport.sNewLine);
3727cdf0e10cSrcweir }
3728cdf0e10cSrcweir 
3729cdf0e10cSrcweir /* vi:set shiftwidth=4 expandtab: */
3730