Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "doctok/resources.hxx"
21 : #include "WW8DocumentImpl.hxx"
22 :
23 : namespace writerfilter {
24 : namespace doctok
25 : {
26 :
27 0 : class ShapeTypeToString
28 : {
29 : typedef boost::shared_ptr<ShapeTypeToString> Pointer_t;
30 :
31 : static Pointer_t pInstance;
32 :
33 : typedef map<sal_uInt32, string> Map_t;
34 : Map_t mMap;
35 :
36 : protected:
37 : ShapeTypeToString();
38 :
39 : public:
40 0 : static Pointer_t Instance()
41 : {
42 0 : if (pInstance == NULL)
43 0 : pInstance = Pointer_t(new ShapeTypeToString());
44 :
45 0 : return pInstance;
46 : }
47 :
48 0 : string operator()(sal_uInt32 nShapeType)
49 : {
50 0 : return mMap[nShapeType];
51 : }
52 : };
53 :
54 5 : ShapeTypeToString::Pointer_t ShapeTypeToString::pInstance;
55 :
56 0 : ShapeTypeToString::ShapeTypeToString()
57 : {
58 0 : mMap[0]="NotPrimitive";
59 0 : mMap[1]="Rectangle";
60 0 : mMap[2]="RoundRectangle";
61 0 : mMap[3]="Ellipse";
62 0 : mMap[4]="Diamond";
63 0 : mMap[5]="IsocelesTriangle";
64 0 : mMap[6]="RightTriangle";
65 0 : mMap[7]="Parallelogram";
66 0 : mMap[8]="Trapezoid";
67 0 : mMap[9]="Hexagon";
68 0 : mMap[10]="Octagon";
69 0 : mMap[11]="Plus";
70 0 : mMap[12]="Star";
71 0 : mMap[13]="Arrow";
72 0 : mMap[14]="ThickArrow";
73 0 : mMap[15]="HomePlate";
74 0 : mMap[16]="Cube";
75 0 : mMap[17]="Balloon";
76 0 : mMap[18]="Seal";
77 0 : mMap[19]="Arc";
78 0 : mMap[20]="Line";
79 0 : mMap[21]="Plaque";
80 0 : mMap[22]="Can";
81 0 : mMap[23]="Donut";
82 0 : mMap[24]="TextSimple";
83 0 : mMap[25]="TextOctagon";
84 0 : mMap[26]="TextHexagon";
85 0 : mMap[27]="TextCurve";
86 0 : mMap[28]="TextWave";
87 0 : mMap[29]="TextRing";
88 0 : mMap[30]="TextOnCurve";
89 0 : mMap[31]="TextOnRing";
90 0 : mMap[32]="StraightConnector1";
91 0 : mMap[33]="BentConnector2";
92 0 : mMap[34]="BentConnector3";
93 0 : mMap[35]="BentConnector4";
94 0 : mMap[36]="BentConnector5";
95 0 : mMap[37]="CurvedConnector2";
96 0 : mMap[38]="CurvedConnector3";
97 0 : mMap[39]="CurvedConnector4";
98 0 : mMap[40]="CurvedConnector5";
99 0 : mMap[41]="Callout1";
100 0 : mMap[42]="Callout2";
101 0 : mMap[43]="Callout3";
102 0 : mMap[44]="AccentCallout1";
103 0 : mMap[45]="AccentCallout2";
104 0 : mMap[46]="AccentCallout3";
105 0 : mMap[47]="BorderCallout1";
106 0 : mMap[48]="BorderCallout2";
107 0 : mMap[49]="BorderCallout3";
108 0 : mMap[50]="AccentBorderCallout1";
109 0 : mMap[51]="AccentBorderCallout2";
110 0 : mMap[52]="AccentBorderCallout3";
111 0 : mMap[53]="Ribbon";
112 0 : mMap[54]="Ribbon2";
113 0 : mMap[55]="Chevron";
114 0 : mMap[56]="Pentagon";
115 0 : mMap[57]="NoSmoking";
116 0 : mMap[58]="Seal8";
117 0 : mMap[59]="Seal16";
118 0 : mMap[60]="Seal32";
119 0 : mMap[61]="WedgeRectCallout";
120 0 : mMap[62]="WedgeRRectCallout";
121 0 : mMap[63]="WedgeEllipseCallout";
122 0 : mMap[64]="Wave";
123 0 : mMap[65]="FoldedCorner";
124 0 : mMap[66]="LeftArrow";
125 0 : mMap[67]="DownArrow";
126 0 : mMap[68]="UpArrow";
127 0 : mMap[69]="LeftRightArrow";
128 0 : mMap[70]="UpDownArrow";
129 0 : mMap[71]="IrregularSeal1";
130 0 : mMap[72]="IrregularSeal2";
131 0 : mMap[73]="LightningBolt";
132 0 : mMap[74]="Heart";
133 0 : mMap[75]="PictureFrame";
134 0 : mMap[76]="QuadArrow";
135 0 : mMap[77]="LeftArrowCallout";
136 0 : mMap[78]="RightArrowCallout";
137 0 : mMap[79]="UpArrowCallout";
138 0 : mMap[80]="DownArrowCallout";
139 0 : mMap[81]="LeftRightArrowCallout";
140 0 : mMap[82]="UpDownArrowCallout";
141 0 : mMap[83]="QuadArrowCallout";
142 0 : mMap[84]="Bevel";
143 0 : mMap[85]="LeftBracket";
144 0 : mMap[86]="RightBracket";
145 0 : mMap[87]="LeftBrace";
146 0 : mMap[88]="RightBrace";
147 0 : mMap[89]="LeftUpArrow";
148 0 : mMap[90]="BentUpArrow";
149 0 : mMap[91]="BentArrow";
150 0 : mMap[92]="Seal24";
151 0 : mMap[93]="StripedRightArrow";
152 0 : mMap[94]="NotchedRightArrow";
153 0 : mMap[95]="BlockArc";
154 0 : mMap[96]="SmileyFace";
155 0 : mMap[97]="VerticalScroll";
156 0 : mMap[98]="HorizontalScroll";
157 0 : mMap[99]="CircularArrow";
158 0 : mMap[100]="NotchedCircularArrow";
159 0 : mMap[101]="UturnArrow";
160 0 : mMap[102]="CurvedRightArrow";
161 0 : mMap[103]="CurvedLeftArrow";
162 0 : mMap[104]="CurvedUpArrow";
163 0 : mMap[105]="CurvedDownArrow";
164 0 : mMap[106]="CloudCallout";
165 0 : mMap[107]="EllipseRibbon";
166 0 : mMap[108]="EllipseRibbon2";
167 0 : mMap[109]="FlowChartProcess";
168 0 : mMap[110]="FlowChartDecision";
169 0 : mMap[111]="FlowChartInputOutput";
170 0 : mMap[112]="FlowChartPredefinedProcess";
171 0 : mMap[113]="FlowChartInternalStorage";
172 0 : mMap[114]="FlowChartDocument";
173 0 : mMap[115]="FlowChartMultidocument";
174 0 : mMap[116]="FlowChartTerminator";
175 0 : mMap[117]="FlowChartPreparation";
176 0 : mMap[118]="FlowChartManualInput";
177 0 : mMap[119]="FlowChartManualOperation";
178 0 : mMap[120]="FlowChartConnector";
179 0 : mMap[121]="FlowChartPunchedCard";
180 0 : mMap[122]="FlowChartPunchedTape";
181 0 : mMap[123]="FlowChartSummingJunction";
182 0 : mMap[124]="FlowChartOr";
183 0 : mMap[125]="FlowChartCollate";
184 0 : mMap[126]="FlowChartSort";
185 0 : mMap[127]="FlowChartExtract";
186 0 : mMap[128]="FlowChartMerge";
187 0 : mMap[129]="FlowChartOfflineStorage";
188 0 : mMap[130]="FlowChartOnlineStorage";
189 0 : mMap[131]="FlowChartMagneticTape";
190 0 : mMap[132]="FlowChartMagneticDisk";
191 0 : mMap[133]="FlowChartMagneticDrum";
192 0 : mMap[134]="FlowChartDisplay";
193 0 : mMap[135]="FlowChartDelay";
194 0 : mMap[136]="TextPlainText";
195 0 : mMap[137]="TextStop";
196 0 : mMap[138]="TextTriangle";
197 0 : mMap[139]="TextTriangleInverted";
198 0 : mMap[140]="TextChevron";
199 0 : mMap[141]="TextChevronInverted";
200 0 : mMap[142]="TextRingInside";
201 0 : mMap[143]="TextRingOutside";
202 0 : mMap[144]="TextArchUpCurve";
203 0 : mMap[145]="TextArchDownCurve";
204 0 : mMap[146]="TextCircleCurve";
205 0 : mMap[147]="TextButtonCurve";
206 0 : mMap[148]="TextArchUpPour";
207 0 : mMap[149]="TextArchDownPour";
208 0 : mMap[150]="TextCirclePour";
209 0 : mMap[151]="TextButtonPour";
210 0 : mMap[152]="TextCurveUp";
211 0 : mMap[153]="TextCurveDown";
212 0 : mMap[154]="TextCascadeUp";
213 0 : mMap[155]="TextCascadeDown";
214 0 : mMap[156]="TextWave1";
215 0 : mMap[157]="TextWave2";
216 0 : mMap[158]="TextWave3";
217 0 : mMap[159]="TextWave4";
218 0 : mMap[160]="TextInflate";
219 0 : mMap[161]="TextDeflate";
220 0 : mMap[162]="TextInflateBottom";
221 0 : mMap[163]="TextDeflateBottom";
222 0 : mMap[164]="TextInflateTop";
223 0 : mMap[165]="TextDeflateTop";
224 0 : mMap[166]="TextDeflateInflate";
225 0 : mMap[167]="TextDeflateInflateDeflate";
226 0 : mMap[168]="TextFadeRight";
227 0 : mMap[169]="TextFadeLeft";
228 0 : mMap[170]="TextFadeUp";
229 0 : mMap[171]="TextFadeDown";
230 0 : mMap[172]="TextSlantUp";
231 0 : mMap[173]="TextSlantDown";
232 0 : mMap[174]="TextCanUp";
233 0 : mMap[175]="TextCanDown";
234 0 : mMap[176]="FlowChartAlternateProcess";
235 0 : mMap[177]="FlowChartOffpageConnector";
236 0 : mMap[178]="Callout90";
237 0 : mMap[179]="AccentCallout90";
238 0 : mMap[180]="BorderCallout90";
239 0 : mMap[181]="AccentBorderCallout90";
240 0 : mMap[182]="LeftRightUpArrow";
241 0 : mMap[183]="Sun";
242 0 : mMap[184]="Moon";
243 0 : mMap[185]="BracketPair";
244 0 : mMap[186]="BracePair";
245 0 : mMap[187]="Seal4";
246 0 : mMap[188]="DoubleWave";
247 0 : mMap[189]="ActionButtonBlank";
248 0 : mMap[190]="ActionButtonHome";
249 0 : mMap[191]="ActionButtonHelp";
250 0 : mMap[192]="ActionButtonInformation";
251 0 : mMap[193]="ActionButtonForwardNext";
252 0 : mMap[194]="ActionButtonBackPrevious";
253 0 : mMap[195]="ActionButtonEnd";
254 0 : mMap[196]="ActionButtonBeginning";
255 0 : mMap[197]="ActionButtonReturn";
256 0 : mMap[198]="ActionButtonDocument";
257 0 : mMap[199]="ActionButtonSound";
258 0 : mMap[200]="ActionButtonMovie";
259 0 : mMap[201]="HostControl";
260 0 : mMap[202]="TextBox";
261 0 : }
262 :
263 : // DffOPT
264 :
265 0 : sal_uInt32 DffOPT::get_property_count()
266 : {
267 0 : return getInstance();
268 : }
269 :
270 : writerfilter::Reference<Properties>::Pointer_t
271 0 : DffOPT::get_property(sal_uInt32 nPos)
272 : {
273 0 : WW8FOPTE * pTmp = new WW8FOPTE(this, 0x8 + nPos * WW8FOPTE::getSize());
274 0 : pTmp->setIndex(nPos);
275 :
276 0 : return writerfilter::Reference<Properties>::Pointer_t(pTmp);
277 : }
278 :
279 0 : sal_uInt32 DffOPT::get_extraoffset(sal_uInt32 pos)
280 : {
281 : sal_uInt32 nResult;
282 0 : sal_uInt32 nCount = get_property_count();
283 :
284 0 : if (pos < nCount)
285 : {
286 0 : nResult = 0x8 + nCount * WW8FOPTE::getSize();
287 :
288 0 : for (sal_uInt32 n = 0; n < pos; ++n)
289 : {
290 0 : WW8FOPTE aFOPTE(this, 0x8 + n * WW8FOPTE::getSize());
291 :
292 0 : if (aFOPTE.get_fComplex())
293 : {
294 0 : sal_uInt32 nValue = aFOPTE.get_op();
295 0 : nResult += nValue;
296 : }
297 0 : }
298 : }
299 : else
300 0 : nResult = getCount();
301 :
302 0 : return nResult;
303 : }
304 :
305 : //DffDGG
306 :
307 0 : sal_uInt32 DffDGG::get_fidcl_count()
308 : {
309 0 : return (getCount() - 0x18) / WW8FIDCL::getSize();
310 : }
311 :
312 : writerfilter::Reference<Properties>::Pointer_t
313 0 : DffDGG::get_fidcl(sal_uInt32 pos)
314 : {
315 : return writerfilter::Reference<Properties>::Pointer_t
316 0 : (new WW8FIDCL(this, 0x18 + pos * WW8FIDCL::getSize()));
317 : }
318 :
319 :
320 : // DffBSE
321 :
322 0 : OUString DffBSE::get_blipname()
323 : {
324 0 : OUString sResult;
325 0 : WW8FBSE aFBSE(this, 0x8);
326 :
327 0 : if (aFBSE.get_cbName() > 0)
328 0 : sResult = getString(0x24, aFBSE.get_cbName());
329 :
330 0 : return sResult;
331 : }
332 :
333 : writerfilter::Reference<Properties>::Pointer_t
334 0 : DffBSE::get_blip()
335 : {
336 0 : writerfilter::Reference<Properties>::Pointer_t pResult;
337 :
338 0 : WW8FBSE aFBSE(this, 8);
339 0 : sal_uInt32 nOffset = 8 + WW8FBSE::getSize() + aFBSE.get_cbName();
340 :
341 0 : if (nOffset + 8 < getCount())
342 : {
343 0 : WW8StructBase aTmp(this, nOffset, 0x8);
344 :
345 0 : sal_uInt32 nCount = getCount() - 8;
346 :
347 0 : if (aTmp.getU32(0x4) - 8 < nCount)
348 0 : nCount = aTmp.getU32(0x4) - 8;
349 :
350 0 : if (nCount)
351 : {
352 0 : DffRecord * pRecord = createDffRecord(this, nOffset);
353 :
354 0 : pResult = writerfilter::Reference<Properties>::Pointer_t(pRecord);
355 0 : }
356 : }
357 : else
358 : {
359 0 : nOffset = sal::static_int_cast<sal_Int32>(aFBSE.get_foDelay());
360 0 : if (! (nOffset & 1 << 31) && nOffset > 0 && getDocument() != NULL)
361 : {
362 0 : WW8StructBase aStructBase(*getDocument()->getDocStream(),
363 0 : nOffset, 0x8);
364 :
365 : DffRecord * pRecord =
366 0 : createDffRecord(*getDocument()->getDocStream(),
367 0 : aFBSE.get_foDelay());
368 :
369 0 : pResult = writerfilter::Reference<Properties>::Pointer_t(pRecord);
370 : }
371 : }
372 :
373 0 : return pResult;
374 : }
375 :
376 : // WW8FOPTE
377 0 : void WW8FOPTE::resolveNoAuto(Properties & rHandler)
378 : {
379 0 : sal_uInt16 nId = get_pid() + 1;
380 0 : sal_uInt32 nOp = get_op();
381 0 : sal_uInt32 nMask = 2;
382 :
383 0 : while (isBooleanDffOpt(nId))
384 : {
385 0 : WW8Value::Pointer_t pVal = createValue(getDffOptName(nId));
386 0 : rHandler.attribute(NS_rtf::LN_shpname, *pVal);
387 :
388 0 : pVal = createValue((nOp & nMask) != 0);
389 0 : rHandler.attribute(NS_rtf::LN_shpvalue, *pVal);
390 :
391 0 : --nId;
392 0 : nMask = nMask << 1;
393 0 : }
394 0 : }
395 :
396 : // DffFSP
397 :
398 0 : OUString DffFSP::get_shptypename()
399 : {
400 0 : string aName = (*ShapeTypeToString::Instance())(get_shptype());
401 :
402 0 : return OUString::createFromAscii(aName.c_str());
403 : }
404 :
405 : // DffSpContainer
406 :
407 : writerfilter::Reference<Properties>::Pointer_t
408 0 : DffSpContainer::get_blip()
409 : {
410 0 : writerfilter::Reference<Properties>::Pointer_t pResult;
411 :
412 0 : if (getShapeType() == 75)
413 : {
414 0 : sal_uInt32 nBid = getShapeBid();
415 :
416 0 : if (getDocument() != NULL && nBid > 0)
417 0 : pResult = getDocument()->getBlip(nBid);
418 : }
419 :
420 0 : return pResult;
421 : }
422 :
423 : writerfilter::Reference<Stream>::Pointer_t
424 0 : DffSpContainer::get_shptxt()
425 : {
426 0 : writerfilter::Reference<Stream>::Pointer_t pResult;
427 :
428 0 : if (getShapeType() == 202)
429 : {
430 0 : sal_uInt32 nShpId = getShapeId();
431 :
432 0 : if (getDocument() != NULL)
433 0 : pResult = getDocument()->getTextboxText(nShpId);
434 : }
435 :
436 0 : return pResult;
437 : }
438 :
439 : // DffUDefProp
440 :
441 0 : void DffUDefProp::resolveNoAuto(Properties & rHandler)
442 : {
443 0 : sal_uInt32 nOffset = 0x8;
444 0 : sal_uInt32 nCount = getCount();
445 :
446 0 : while (nOffset + 6 <= nCount)
447 : {
448 0 : sal_uInt16 nPid = getU16(nOffset);
449 0 : sal_uInt32 nValue = getU32(nOffset + 2);
450 :
451 0 : sal_uInt32 nAttrid = 0;
452 0 : switch (nPid)
453 : {
454 0 : case 0x38f: nAttrid = NS_rtf::LN_XAlign; break;
455 0 : case 0x390: nAttrid = NS_rtf::LN_XRelTo; break;
456 0 : case 0x391: nAttrid = NS_rtf::LN_YAlign; break;
457 0 : case 0x392: nAttrid = NS_rtf::LN_YRelTo; break;
458 0 : case 0x3bf: nAttrid = NS_rtf::LN_LayoutInTableCell; break;
459 0 : case 0x53f: nAttrid = NS_rtf::LN_Inline; break;
460 : default:
461 0 : break;
462 : }
463 :
464 0 : if (nAttrid != 0)
465 : {
466 0 : WW8Value::Pointer_t pVal = createValue(nValue);
467 0 : rHandler.attribute(nAttrid, *pVal);
468 : }
469 :
470 0 : nOffset += 6;
471 : }
472 0 : }
473 :
474 15 : }}
475 :
476 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|