1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "doctok/resources.hxx"
21 #include "WW8DocumentImpl.hxx"
23 namespace writerfilter
{
27 class ShapeTypeToString
29 typedef boost::shared_ptr
<ShapeTypeToString
> Pointer_t
;
31 static Pointer_t pInstance
;
33 typedef map
<sal_uInt32
, string
> Map_t
;
40 static Pointer_t
Instance()
42 if (pInstance
== NULL
)
43 pInstance
= Pointer_t(new ShapeTypeToString());
48 string
operator()(sal_uInt32 nShapeType
)
50 return mMap
[nShapeType
];
54 ShapeTypeToString::Pointer_t
ShapeTypeToString::pInstance
;
56 ShapeTypeToString::ShapeTypeToString()
58 mMap
[0]="NotPrimitive";
60 mMap
[2]="RoundRectangle";
63 mMap
[5]="IsocelesTriangle";
64 mMap
[6]="RightTriangle";
65 mMap
[7]="Parallelogram";
72 mMap
[14]="ThickArrow";
82 mMap
[24]="TextSimple";
83 mMap
[25]="TextOctagon";
84 mMap
[26]="TextHexagon";
88 mMap
[30]="TextOnCurve";
89 mMap
[31]="TextOnRing";
90 mMap
[32]="StraightConnector1";
91 mMap
[33]="BentConnector2";
92 mMap
[34]="BentConnector3";
93 mMap
[35]="BentConnector4";
94 mMap
[36]="BentConnector5";
95 mMap
[37]="CurvedConnector2";
96 mMap
[38]="CurvedConnector3";
97 mMap
[39]="CurvedConnector4";
98 mMap
[40]="CurvedConnector5";
102 mMap
[44]="AccentCallout1";
103 mMap
[45]="AccentCallout2";
104 mMap
[46]="AccentCallout3";
105 mMap
[47]="BorderCallout1";
106 mMap
[48]="BorderCallout2";
107 mMap
[49]="BorderCallout3";
108 mMap
[50]="AccentBorderCallout1";
109 mMap
[51]="AccentBorderCallout2";
110 mMap
[52]="AccentBorderCallout3";
115 mMap
[57]="NoSmoking";
119 mMap
[61]="WedgeRectCallout";
120 mMap
[62]="WedgeRRectCallout";
121 mMap
[63]="WedgeEllipseCallout";
123 mMap
[65]="FoldedCorner";
124 mMap
[66]="LeftArrow";
125 mMap
[67]="DownArrow";
127 mMap
[69]="LeftRightArrow";
128 mMap
[70]="UpDownArrow";
129 mMap
[71]="IrregularSeal1";
130 mMap
[72]="IrregularSeal2";
131 mMap
[73]="LightningBolt";
133 mMap
[75]="PictureFrame";
134 mMap
[76]="QuadArrow";
135 mMap
[77]="LeftArrowCallout";
136 mMap
[78]="RightArrowCallout";
137 mMap
[79]="UpArrowCallout";
138 mMap
[80]="DownArrowCallout";
139 mMap
[81]="LeftRightArrowCallout";
140 mMap
[82]="UpDownArrowCallout";
141 mMap
[83]="QuadArrowCallout";
143 mMap
[85]="LeftBracket";
144 mMap
[86]="RightBracket";
145 mMap
[87]="LeftBrace";
146 mMap
[88]="RightBrace";
147 mMap
[89]="LeftUpArrow";
148 mMap
[90]="BentUpArrow";
149 mMap
[91]="BentArrow";
151 mMap
[93]="StripedRightArrow";
152 mMap
[94]="NotchedRightArrow";
154 mMap
[96]="SmileyFace";
155 mMap
[97]="VerticalScroll";
156 mMap
[98]="HorizontalScroll";
157 mMap
[99]="CircularArrow";
158 mMap
[100]="NotchedCircularArrow";
159 mMap
[101]="UturnArrow";
160 mMap
[102]="CurvedRightArrow";
161 mMap
[103]="CurvedLeftArrow";
162 mMap
[104]="CurvedUpArrow";
163 mMap
[105]="CurvedDownArrow";
164 mMap
[106]="CloudCallout";
165 mMap
[107]="EllipseRibbon";
166 mMap
[108]="EllipseRibbon2";
167 mMap
[109]="FlowChartProcess";
168 mMap
[110]="FlowChartDecision";
169 mMap
[111]="FlowChartInputOutput";
170 mMap
[112]="FlowChartPredefinedProcess";
171 mMap
[113]="FlowChartInternalStorage";
172 mMap
[114]="FlowChartDocument";
173 mMap
[115]="FlowChartMultidocument";
174 mMap
[116]="FlowChartTerminator";
175 mMap
[117]="FlowChartPreparation";
176 mMap
[118]="FlowChartManualInput";
177 mMap
[119]="FlowChartManualOperation";
178 mMap
[120]="FlowChartConnector";
179 mMap
[121]="FlowChartPunchedCard";
180 mMap
[122]="FlowChartPunchedTape";
181 mMap
[123]="FlowChartSummingJunction";
182 mMap
[124]="FlowChartOr";
183 mMap
[125]="FlowChartCollate";
184 mMap
[126]="FlowChartSort";
185 mMap
[127]="FlowChartExtract";
186 mMap
[128]="FlowChartMerge";
187 mMap
[129]="FlowChartOfflineStorage";
188 mMap
[130]="FlowChartOnlineStorage";
189 mMap
[131]="FlowChartMagneticTape";
190 mMap
[132]="FlowChartMagneticDisk";
191 mMap
[133]="FlowChartMagneticDrum";
192 mMap
[134]="FlowChartDisplay";
193 mMap
[135]="FlowChartDelay";
194 mMap
[136]="TextPlainText";
195 mMap
[137]="TextStop";
196 mMap
[138]="TextTriangle";
197 mMap
[139]="TextTriangleInverted";
198 mMap
[140]="TextChevron";
199 mMap
[141]="TextChevronInverted";
200 mMap
[142]="TextRingInside";
201 mMap
[143]="TextRingOutside";
202 mMap
[144]="TextArchUpCurve";
203 mMap
[145]="TextArchDownCurve";
204 mMap
[146]="TextCircleCurve";
205 mMap
[147]="TextButtonCurve";
206 mMap
[148]="TextArchUpPour";
207 mMap
[149]="TextArchDownPour";
208 mMap
[150]="TextCirclePour";
209 mMap
[151]="TextButtonPour";
210 mMap
[152]="TextCurveUp";
211 mMap
[153]="TextCurveDown";
212 mMap
[154]="TextCascadeUp";
213 mMap
[155]="TextCascadeDown";
214 mMap
[156]="TextWave1";
215 mMap
[157]="TextWave2";
216 mMap
[158]="TextWave3";
217 mMap
[159]="TextWave4";
218 mMap
[160]="TextInflate";
219 mMap
[161]="TextDeflate";
220 mMap
[162]="TextInflateBottom";
221 mMap
[163]="TextDeflateBottom";
222 mMap
[164]="TextInflateTop";
223 mMap
[165]="TextDeflateTop";
224 mMap
[166]="TextDeflateInflate";
225 mMap
[167]="TextDeflateInflateDeflate";
226 mMap
[168]="TextFadeRight";
227 mMap
[169]="TextFadeLeft";
228 mMap
[170]="TextFadeUp";
229 mMap
[171]="TextFadeDown";
230 mMap
[172]="TextSlantUp";
231 mMap
[173]="TextSlantDown";
232 mMap
[174]="TextCanUp";
233 mMap
[175]="TextCanDown";
234 mMap
[176]="FlowChartAlternateProcess";
235 mMap
[177]="FlowChartOffpageConnector";
236 mMap
[178]="Callout90";
237 mMap
[179]="AccentCallout90";
238 mMap
[180]="BorderCallout90";
239 mMap
[181]="AccentBorderCallout90";
240 mMap
[182]="LeftRightUpArrow";
243 mMap
[185]="BracketPair";
244 mMap
[186]="BracePair";
246 mMap
[188]="DoubleWave";
247 mMap
[189]="ActionButtonBlank";
248 mMap
[190]="ActionButtonHome";
249 mMap
[191]="ActionButtonHelp";
250 mMap
[192]="ActionButtonInformation";
251 mMap
[193]="ActionButtonForwardNext";
252 mMap
[194]="ActionButtonBackPrevious";
253 mMap
[195]="ActionButtonEnd";
254 mMap
[196]="ActionButtonBeginning";
255 mMap
[197]="ActionButtonReturn";
256 mMap
[198]="ActionButtonDocument";
257 mMap
[199]="ActionButtonSound";
258 mMap
[200]="ActionButtonMovie";
259 mMap
[201]="HostControl";
265 sal_uInt32
DffOPT::get_property_count()
267 return getInstance();
270 writerfilter::Reference
<Properties
>::Pointer_t
271 DffOPT::get_property(sal_uInt32 nPos
)
273 WW8FOPTE
* pTmp
= new WW8FOPTE(this, 0x8 + nPos
* WW8FOPTE::getSize());
274 pTmp
->setIndex(nPos
);
276 return writerfilter::Reference
<Properties
>::Pointer_t(pTmp
);
279 sal_uInt32
DffOPT::get_extraoffset(sal_uInt32 pos
)
282 sal_uInt32 nCount
= get_property_count();
286 nResult
= 0x8 + nCount
* WW8FOPTE::getSize();
288 for (sal_uInt32 n
= 0; n
< pos
; ++n
)
290 WW8FOPTE
aFOPTE(this, 0x8 + n
* WW8FOPTE::getSize());
292 if (aFOPTE
.get_fComplex())
294 sal_uInt32 nValue
= aFOPTE
.get_op();
300 nResult
= getCount();
307 sal_uInt32
DffDGG::get_fidcl_count()
309 return (getCount() - 0x18) / WW8FIDCL::getSize();
312 writerfilter::Reference
<Properties
>::Pointer_t
313 DffDGG::get_fidcl(sal_uInt32 pos
)
315 return writerfilter::Reference
<Properties
>::Pointer_t
316 (new WW8FIDCL(this, 0x18 + pos
* WW8FIDCL::getSize()));
322 OUString
DffBSE::get_blipname()
325 WW8FBSE
aFBSE(this, 0x8);
327 if (aFBSE
.get_cbName() > 0)
328 sResult
= getString(0x24, aFBSE
.get_cbName());
333 writerfilter::Reference
<Properties
>::Pointer_t
336 writerfilter::Reference
<Properties
>::Pointer_t pResult
;
338 WW8FBSE
aFBSE(this, 8);
339 sal_uInt32 nOffset
= 8 + WW8FBSE::getSize() + aFBSE
.get_cbName();
341 if (nOffset
+ 8 < getCount())
343 WW8StructBase
aTmp(this, nOffset
, 0x8);
345 sal_uInt32 nCount
= getCount() - 8;
347 if (aTmp
.getU32(0x4) - 8 < nCount
)
348 nCount
= aTmp
.getU32(0x4) - 8;
352 DffRecord
* pRecord
= createDffRecord(this, nOffset
);
354 pResult
= writerfilter::Reference
<Properties
>::Pointer_t(pRecord
);
359 nOffset
= sal::static_int_cast
<sal_Int32
>(aFBSE
.get_foDelay());
360 if (! (nOffset
& 1 << 31) && nOffset
> 0 && getDocument() != NULL
)
362 WW8StructBase
aStructBase(*getDocument()->getDocStream(),
365 DffRecord
* pRecord
=
366 createDffRecord(*getDocument()->getDocStream(),
367 aFBSE
.get_foDelay());
369 pResult
= writerfilter::Reference
<Properties
>::Pointer_t(pRecord
);
377 void WW8FOPTE::resolveNoAuto(Properties
& rHandler
)
379 sal_uInt16 nId
= get_pid() + 1;
380 sal_uInt32 nOp
= get_op();
381 sal_uInt32 nMask
= 2;
383 while (isBooleanDffOpt(nId
))
385 WW8Value::Pointer_t pVal
= createValue(getDffOptName(nId
));
386 rHandler
.attribute(NS_rtf::LN_shpname
, *pVal
);
388 pVal
= createValue((nOp
& nMask
) != 0);
389 rHandler
.attribute(NS_rtf::LN_shpvalue
, *pVal
);
398 OUString
DffFSP::get_shptypename()
400 string aName
= (*ShapeTypeToString::Instance())(get_shptype());
402 return OUString::createFromAscii(aName
.c_str());
407 writerfilter::Reference
<Properties
>::Pointer_t
408 DffSpContainer::get_blip()
410 writerfilter::Reference
<Properties
>::Pointer_t pResult
;
412 if (getShapeType() == 75)
414 sal_uInt32 nBid
= getShapeBid();
416 if (getDocument() != NULL
&& nBid
> 0)
417 pResult
= getDocument()->getBlip(nBid
);
423 writerfilter::Reference
<Stream
>::Pointer_t
424 DffSpContainer::get_shptxt()
426 writerfilter::Reference
<Stream
>::Pointer_t pResult
;
428 if (getShapeType() == 202)
430 sal_uInt32 nShpId
= getShapeId();
432 if (getDocument() != NULL
)
433 pResult
= getDocument()->getTextboxText(nShpId
);
441 void DffUDefProp::resolveNoAuto(Properties
& rHandler
)
443 sal_uInt32 nOffset
= 0x8;
444 sal_uInt32 nCount
= getCount();
446 while (nOffset
+ 6 <= nCount
)
448 sal_uInt16 nPid
= getU16(nOffset
);
449 sal_uInt32 nValue
= getU32(nOffset
+ 2);
451 sal_uInt32 nAttrid
= 0;
454 case 0x38f: nAttrid
= NS_rtf::LN_XAlign
; break;
455 case 0x390: nAttrid
= NS_rtf::LN_XRelTo
; break;
456 case 0x391: nAttrid
= NS_rtf::LN_YAlign
; break;
457 case 0x392: nAttrid
= NS_rtf::LN_YRelTo
; break;
458 case 0x3bf: nAttrid
= NS_rtf::LN_LayoutInTableCell
; break;
459 case 0x53f: nAttrid
= NS_rtf::LN_Inline
; break;
466 WW8Value::Pointer_t pVal
= createValue(nValue
);
467 rHandler
.attribute(nAttrid
, *pVal
);
476 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */