1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <drawinglayer/tools/primitive2dxmldump.hxx>
#include <rtl/string.hxx>
#include <tools/stream.hxx>
#include <tools/XmlWriter.hxx>
#include <memory>
#include <sal/log.hxx>
#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
#include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx>
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
#include <drawinglayer/primitive2d/Tools.hxx>
#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
#include <drawinglayer/primitive2d/PolyPolygonStrokePrimitive2D.hxx>
#include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx>
#include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
#include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx>
#include <primitive2d/textlineprimitive2d.hxx>
#include <drawinglayer/primitive2d/textprimitive2d.hxx>
#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
#include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
#include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
#include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
#include <drawinglayer/geometry/viewinformation2d.hxx>
#include <drawinglayer/attribute/lineattribute.hxx>
#include <drawinglayer/attribute/fontattribute.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
#include <toolkit/helper/vclunohelper.hxx>
using namespace drawinglayer::primitive2d;
namespace drawinglayer
{
namespace
{
const size_t constMaxActionType = 513;
OUString convertColorToString(const basegfx::BColor& rColor)
{
OUString aRGBString = Color(rColor).AsRGBHexString();
return "#" + aRGBString;
}
void writeMatrix(::tools::XmlWriter& rWriter, const basegfx::B2DHomMatrix& rMatrix)
{
rWriter.attribute("xy11", rMatrix.get(0, 0));
rWriter.attribute("xy12", rMatrix.get(0, 1));
rWriter.attribute("xy13", rMatrix.get(0, 2));
rWriter.attribute("xy21", rMatrix.get(1, 0));
rWriter.attribute("xy22", rMatrix.get(1, 1));
rWriter.attribute("xy23", rMatrix.get(1, 2));
rWriter.attribute("xy31", rMatrix.get(2, 0));
rWriter.attribute("xy32", rMatrix.get(2, 1));
rWriter.attribute("xy33", rMatrix.get(2, 2));
}
void writePolyPolygon(::tools::XmlWriter& rWriter, const basegfx::B2DPolyPolygon& rB2DPolyPolygon)
{
rWriter.startElement("polypolygon");
const basegfx::B2DRange aB2DRange(rB2DPolyPolygon.getB2DRange());
rWriter.attributeDouble("height", aB2DRange.getHeight());
rWriter.attributeDouble("width", aB2DRange.getWidth());
rWriter.attributeDouble("minx", aB2DRange.getMinX());
rWriter.attributeDouble("miny", aB2DRange.getMinY());
rWriter.attributeDouble("maxx", aB2DRange.getMaxX());
rWriter.attributeDouble("maxy", aB2DRange.getMaxY());
rWriter.attribute("path", basegfx::utils::exportToSvgD(rB2DPolyPolygon, true, true, false));
for (basegfx::B2DPolygon const& rPolygon : rB2DPolyPolygon)
{
rWriter.startElement("polygon");
for (sal_uInt32 i = 0; i < rPolygon.count(); ++i)
{
basegfx::B2DPoint const& rPoint = rPolygon.getB2DPoint(i);
rWriter.startElement("point");
rWriter.attribute("x", OUString::number(rPoint.getX()));
rWriter.attribute("y", OUString::number(rPoint.getY()));
rWriter.endElement();
}
rWriter.endElement();
}
rWriter.endElement();
}
void writeLineAttribute(::tools::XmlWriter& rWriter,
const drawinglayer::attribute::LineAttribute& rLineAttribute)
{
rWriter.startElement("line");
rWriter.attribute("color", convertColorToString(rLineAttribute.getColor()));
rWriter.attribute("width", rLineAttribute.getWidth());
switch (rLineAttribute.getLineJoin())
{
case basegfx::B2DLineJoin::NONE:
rWriter.attribute("linejoin", "NONE");
break;
case basegfx::B2DLineJoin::Bevel:
rWriter.attribute("linejoin", "Bevel");
break;
case basegfx::B2DLineJoin::Miter:
rWriter.attribute("linejoin", "Miter");
break;
case basegfx::B2DLineJoin::Round:
rWriter.attribute("linejoin", "Round");
break;
default:
rWriter.attribute("linejoin", "Unknown");
break;
}
switch (rLineAttribute.getLineCap())
{
case css::drawing::LineCap::LineCap_BUTT:
rWriter.attribute("linecap", "BUTT");
break;
case css::drawing::LineCap::LineCap_ROUND:
rWriter.attribute("linecap", "ROUND");
break;
case css::drawing::LineCap::LineCap_SQUARE:
rWriter.attribute("linecap", "SQUARE");
break;
default:
rWriter.attribute("linecap", "Unknown");
break;
}
rWriter.endElement();
}
} // end anonymous namespace
Primitive2dXmlDump::Primitive2dXmlDump()
: maFilter(constMaxActionType, false)
{
}
Primitive2dXmlDump::~Primitive2dXmlDump() = default;
void Primitive2dXmlDump::dump(
const drawinglayer::primitive2d::Primitive2DContainer& rPrimitive2DSequence,
const OUString& rStreamName)
{
std::unique_ptr<SvStream> pStream;
if (rStreamName.isEmpty())
pStream.reset(new SvMemoryStream());
else
pStream.reset(new SvFileStream(rStreamName, StreamMode::STD_READWRITE | StreamMode::TRUNC));
::tools::XmlWriter aWriter(pStream.get());
aWriter.startDocument();
aWriter.startElement("primitive2D");
decomposeAndWrite(rPrimitive2DSequence, aWriter);
aWriter.endElement();
aWriter.endDocument();
pStream->Seek(STREAM_SEEK_TO_BEGIN);
}
xmlDocUniquePtr Primitive2dXmlDump::dumpAndParse(
const drawinglayer::primitive2d::Primitive2DContainer& rPrimitive2DSequence,
const OUString& rStreamName)
{
std::unique_ptr<SvStream> pStream;
if (rStreamName.isEmpty())
pStream.reset(new SvMemoryStream());
else
pStream.reset(new SvFileStream(rStreamName, StreamMode::STD_READWRITE | StreamMode::TRUNC));
::tools::XmlWriter aWriter(pStream.get());
aWriter.startDocument();
aWriter.startElement("primitive2D");
decomposeAndWrite(rPrimitive2DSequence, aWriter);
aWriter.endElement();
aWriter.endDocument();
pStream->Seek(STREAM_SEEK_TO_BEGIN);
std::size_t nSize = pStream->remainingSize();
std::unique_ptr<sal_uInt8[]> pBuffer(new sal_uInt8[nSize + 1]);
pStream->ReadBytes(pBuffer.get(), nSize);
pBuffer[nSize] = 0;
SAL_INFO("drawinglayer", "Parsed XML: " << pBuffer.get());
return xmlDocUniquePtr(xmlParseDoc(reinterpret_cast<xmlChar*>(pBuffer.get())));
}
void Primitive2dXmlDump::decomposeAndWrite(
const drawinglayer::primitive2d::Primitive2DContainer& rPrimitive2DSequence,
::tools::XmlWriter& rWriter)
{
for (size_t i = 0; i < rPrimitive2DSequence.size(); i++)
{
drawinglayer::primitive2d::Primitive2DReference xPrimitive2DReference
= rPrimitive2DSequence[i];
const BasePrimitive2D* pBasePrimitive
= dynamic_cast<const BasePrimitive2D*>(xPrimitive2DReference.get());
if (!pBasePrimitive)
continue;
sal_uInt32 nId = pBasePrimitive->getPrimitive2DID();
if (nId < maFilter.size() && maFilter[nId])
continue;
OUString sCurrentElementTag = drawinglayer::primitive2d::idToString(nId);
switch (nId)
{
case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D:
{
const BitmapPrimitive2D& rBitmapPrimitive2D
= dynamic_cast<const BitmapPrimitive2D&>(*pBasePrimitive);
rWriter.startElement("bitmap");
writeMatrix(rWriter, rBitmapPrimitive2D.getTransform());
const BitmapEx aBitmapEx(VCLUnoHelper::GetBitmap(rBitmapPrimitive2D.getXBitmap()));
const Size& rSizePixel(aBitmapEx.GetSizePixel());
rWriter.attribute("height", rSizePixel.getHeight());
rWriter.attribute("width", rSizePixel.getWidth());
rWriter.attribute("checksum", OString(std::to_string(aBitmapEx.GetChecksum())));
for (tools::Long y = 0; y < rSizePixel.getHeight(); y++)
{
rWriter.startElement("data");
OUString aBitmapData = "";
for (tools::Long x = 0; x < rSizePixel.getHeight(); x++)
{
if (x != 0)
aBitmapData = aBitmapData + ",";
aBitmapData = aBitmapData + aBitmapEx.GetPixelColor(x, y).AsRGBHexString();
}
rWriter.attribute("row", aBitmapData);
rWriter.endElement();
}
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D:
{
const HiddenGeometryPrimitive2D& rHiddenGeometryPrimitive2D
= dynamic_cast<const HiddenGeometryPrimitive2D&>(*pBasePrimitive);
rWriter.startElement("hiddengeometry");
decomposeAndWrite(rHiddenGeometryPrimitive2D.getChildren(), rWriter);
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D:
{
const TransformPrimitive2D& rTransformPrimitive2D
= dynamic_cast<const TransformPrimitive2D&>(*pBasePrimitive);
rWriter.startElement("transform");
writeMatrix(rWriter, rTransformPrimitive2D.getTransformation());
decomposeAndWrite(rTransformPrimitive2D.getChildren(), rWriter);
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D:
{
const PolyPolygonColorPrimitive2D& rPolyPolygonColorPrimitive2D
= dynamic_cast<const PolyPolygonColorPrimitive2D&>(*pBasePrimitive);
rWriter.startElement("polypolygoncolor");
rWriter.attribute("color",
convertColorToString(rPolyPolygonColorPrimitive2D.getBColor()));
const basegfx::B2DPolyPolygon& aB2DPolyPolygon(
rPolyPolygonColorPrimitive2D.getB2DPolyPolygon());
writePolyPolygon(rWriter, aB2DPolyPolygon);
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D:
{
const PointArrayPrimitive2D& rPointArrayPrimitive2D
= dynamic_cast<const PointArrayPrimitive2D&>(*pBasePrimitive);
rWriter.startElement("pointarray");
rWriter.attribute("color",
convertColorToString(rPointArrayPrimitive2D.getRGBColor()));
const std::vector<basegfx::B2DPoint> aPositions
= rPointArrayPrimitive2D.getPositions();
for (std::vector<basegfx::B2DPoint>::const_iterator iter = aPositions.begin();
iter != aPositions.end(); ++iter)
{
rWriter.startElement("point");
rWriter.attribute("x", OUString::number(iter->getX()));
rWriter.attribute("y", OUString::number(iter->getY()));
rWriter.endElement();
}
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D:
{
const PolygonStrokePrimitive2D& rPolygonStrokePrimitive2D
= dynamic_cast<const PolygonStrokePrimitive2D&>(*pBasePrimitive);
rWriter.startElement("polygonstroke");
rWriter.startElement("polygon");
rWriter.content(
basegfx::utils::exportToSvgPoints(rPolygonStrokePrimitive2D.getB2DPolygon()));
rWriter.endElement();
writeLineAttribute(rWriter, rPolygonStrokePrimitive2D.getLineAttribute());
rWriter.startElement("stroke");
const drawinglayer::attribute::StrokeAttribute& aStrokeAttribute
= rPolygonStrokePrimitive2D.getStrokeAttribute();
rWriter.attribute("fulldotdashlen", aStrokeAttribute.getFullDotDashLen());
//rWriter.attribute("dotdasharray", aStrokeAttribute.getDotDashArray());
rWriter.endElement();
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_POLYPOLYGONSTROKEPRIMITIVE2D:
{
const PolyPolygonStrokePrimitive2D& rPolyPolygonStrokePrimitive2D
= dynamic_cast<const PolyPolygonStrokePrimitive2D&>(*pBasePrimitive);
rWriter.startElement("polypolygonstroke");
writeLineAttribute(rWriter, rPolyPolygonStrokePrimitive2D.getLineAttribute());
//getStrokeAttribute()
writePolyPolygon(rWriter, rPolyPolygonStrokePrimitive2D.getB2DPolyPolygon());
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D:
{
const PolygonHairlinePrimitive2D& rPolygonHairlinePrimitive2D
= dynamic_cast<const PolygonHairlinePrimitive2D&>(*pBasePrimitive);
rWriter.startElement("polygonhairline");
rWriter.attribute("color",
convertColorToString(rPolygonHairlinePrimitive2D.getBColor()));
rWriter.startElement("polygon");
rWriter.content(
basegfx::utils::exportToSvgPoints(rPolygonHairlinePrimitive2D.getB2DPolygon()));
rWriter.endElement();
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D:
{
const TextDecoratedPortionPrimitive2D& rTextDecoratedPortionPrimitive2D
= dynamic_cast<const TextDecoratedPortionPrimitive2D&>(*pBasePrimitive);
rWriter.startElement("textdecoratedportion");
writeMatrix(rWriter, rTextDecoratedPortionPrimitive2D.getTextTransform());
rWriter.attribute("text", rTextDecoratedPortionPrimitive2D.getText());
rWriter.attribute(
"fontcolor",
convertColorToString(rTextDecoratedPortionPrimitive2D.getFontColor()));
const drawinglayer::attribute::FontAttribute& aFontAttribute
= rTextDecoratedPortionPrimitive2D.getFontAttribute();
rWriter.attribute("familyname", aFontAttribute.getFamilyName());
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_TEXTLINEPRIMITIVE2D:
{
const TextLinePrimitive2D& rTextLinePrimitive2D
= dynamic_cast<const TextLinePrimitive2D&>(*pBasePrimitive);
rWriter.startElement("textline");
writeMatrix(rWriter, rTextLinePrimitive2D.getObjectTransformation());
rWriter.attribute("width", rTextLinePrimitive2D.getWidth());
rWriter.attribute("offset", rTextLinePrimitive2D.getOffset());
rWriter.attribute("height", rTextLinePrimitive2D.getHeight());
rWriter.attribute("color",
convertColorToString(rTextLinePrimitive2D.getLineColor()));
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D:
{
const TextSimplePortionPrimitive2D& rTextSimplePortionPrimitive2D
= dynamic_cast<const TextSimplePortionPrimitive2D&>(*pBasePrimitive);
rWriter.startElement("textsimpleportion");
basegfx::B2DVector aScale, aTranslate;
double fRotate, fShearX;
if (rTextSimplePortionPrimitive2D.getTextTransform().decompose(aScale, aTranslate,
fRotate, fShearX))
{
rWriter.attribute("width", aScale.getX());
rWriter.attribute("height", aScale.getY());
}
rWriter.attribute("x", aTranslate.getX());
rWriter.attribute("y", aTranslate.getY());
OUString aText = rTextSimplePortionPrimitive2D.getText();
// TODO share code with sax_fastparser::FastSaxSerializer::write().
rWriter.attribute("text", aText.replaceAll("", "	"));
rWriter.attribute("fontcolor", convertColorToString(
rTextSimplePortionPrimitive2D.getFontColor()));
const drawinglayer::attribute::FontAttribute& aFontAttribute
= rTextSimplePortionPrimitive2D.getFontAttribute();
rWriter.attribute("familyname", aFontAttribute.getFamilyName());
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_GROUPPRIMITIVE2D:
{
const GroupPrimitive2D& rGroupPrimitive2D
= dynamic_cast<const GroupPrimitive2D&>(*pBasePrimitive);
rWriter.startElement("group");
decomposeAndWrite(rGroupPrimitive2D.getChildren(), rWriter);
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_MASKPRIMITIVE2D:
{
const MaskPrimitive2D& rMaskPrimitive2D
= dynamic_cast<const MaskPrimitive2D&>(*pBasePrimitive);
rWriter.startElement("mask");
writePolyPolygon(rWriter, rMaskPrimitive2D.getMask());
decomposeAndWrite(rMaskPrimitive2D.getChildren(), rWriter);
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D:
{
const UnifiedTransparencePrimitive2D& rUnifiedTransparencePrimitive2D
= dynamic_cast<const UnifiedTransparencePrimitive2D&>(*pBasePrimitive);
rWriter.startElement("unifiedtransparence");
rWriter.attribute(
"transparence",
std::lround(100 * rUnifiedTransparencePrimitive2D.getTransparence()));
decomposeAndWrite(rUnifiedTransparencePrimitive2D.getChildren(), rWriter);
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_OBJECTINFOPRIMITIVE2D:
{
const ObjectInfoPrimitive2D& rObjectInfoPrimitive2D
= dynamic_cast<const ObjectInfoPrimitive2D&>(*pBasePrimitive);
rWriter.startElement("objectinfo");
decomposeAndWrite(rObjectInfoPrimitive2D.getChildren(), rWriter);
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_SVGRADIALGRADIENTPRIMITIVE2D:
{
const SvgRadialGradientPrimitive2D& rSvgRadialGradientPrimitive2D
= dynamic_cast<const SvgRadialGradientPrimitive2D&>(*pBasePrimitive);
rWriter.startElement("svgradialgradient");
basegfx::B2DPoint aFocusAttribute = rSvgRadialGradientPrimitive2D.getFocal();
rWriter.attribute("radius",
OString::number(rSvgRadialGradientPrimitive2D.getRadius()));
rWriter.attribute("focusx", aFocusAttribute.getX());
rWriter.attribute("focusy", aFocusAttribute.getY());
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_SVGLINEARGRADIENTPRIMITIVE2D:
{
const SvgLinearGradientPrimitive2D& rSvgLinearGradientPrimitive2D
= dynamic_cast<const SvgLinearGradientPrimitive2D&>(*pBasePrimitive);
rWriter.startElement("svglineargradient");
basegfx::B2DPoint aStartAttribute = rSvgLinearGradientPrimitive2D.getStart();
basegfx::B2DPoint aEndAttribute = rSvgLinearGradientPrimitive2D.getEnd();
rWriter.attribute("startx", aStartAttribute.getX());
rWriter.attribute("starty", aStartAttribute.getY());
rWriter.attribute("endx", aEndAttribute.getX());
rWriter.attribute("endy", aEndAttribute.getY());
//rWriter.attribute("spreadmethod", (int)rSvgLinearGradientPrimitive2D.getSpreadMethod());
rWriter.attributeDouble(
"opacity",
rSvgLinearGradientPrimitive2D.getGradientEntries().front().getOpacity());
rWriter.startElement("transform");
writeMatrix(rWriter, rSvgLinearGradientPrimitive2D.getGradientTransform());
rWriter.endElement();
writePolyPolygon(rWriter, rSvgLinearGradientPrimitive2D.getPolyPolygon());
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D:
{
const MetafilePrimitive2D& rMetafilePrimitive2D
= dynamic_cast<const MetafilePrimitive2D&>(*pBasePrimitive);
rWriter.startElement("metafile");
drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
// since the graphic is not rendered in a document, we do not need a concrete view information
rMetafilePrimitive2D.get2DDecomposition(
aPrimitiveContainer, drawinglayer::geometry::ViewInformation2D());
decomposeAndWrite(aPrimitiveContainer, rWriter);
rWriter.endElement();
}
break;
case PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D:
{
// SdrRectanglePrimitive2D is private to us.
rWriter.startElement("sdrrectangle");
drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
drawinglayer::geometry::ViewInformation2D());
decomposeAndWrite(aPrimitiveContainer, rWriter);
rWriter.endElement();
break;
}
case PRIMITIVE2D_ID_SDRBLOCKTEXTPRIMITIVE2D:
{
// SdrBlockTextPrimitive2D is private to us.
rWriter.startElement("sdrblocktext");
drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
drawinglayer::geometry::ViewInformation2D());
decomposeAndWrite(aPrimitiveContainer, rWriter);
rWriter.endElement();
break;
}
case PRIMITIVE2D_ID_TEXTHIERARCHYBLOCKPRIMITIVE2D:
{
// TextHierarchyBlockPrimitive2D.
rWriter.startElement("texthierarchyblock");
drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
drawinglayer::geometry::ViewInformation2D());
decomposeAndWrite(aPrimitiveContainer, rWriter);
rWriter.endElement();
break;
}
case PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D:
{
// TextHierarchyParagraphPrimitive2D.
rWriter.startElement("texthierarchyparagraph");
drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
drawinglayer::geometry::ViewInformation2D());
decomposeAndWrite(aPrimitiveContainer, rWriter);
rWriter.endElement();
break;
}
case PRIMITIVE2D_ID_TEXTHIERARCHYLINEPRIMITIVE2D:
{
// TextHierarchyLinePrimitive2D.
rWriter.startElement("texthierarchyline");
drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
drawinglayer::geometry::ViewInformation2D());
decomposeAndWrite(aPrimitiveContainer, rWriter);
rWriter.endElement();
break;
}
case PRIMITIVE2D_ID_SHADOWPRIMITIVE2D:
{
// ShadowPrimitive2D.
rWriter.startElement("shadow");
drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
drawinglayer::geometry::ViewInformation2D());
decomposeAndWrite(aPrimitiveContainer, rWriter);
rWriter.endElement();
break;
}
default:
{
rWriter.startElement("unhandled");
rWriter.attribute("id",
OUStringToOString(sCurrentElementTag, RTL_TEXTENCODING_UTF8));
rWriter.attribute("idNumber", nId);
drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer;
pBasePrimitive->get2DDecomposition(aPrimitiveContainer,
drawinglayer::geometry::ViewInformation2D());
decomposeAndWrite(aPrimitiveContainer, rWriter);
rWriter.endElement();
}
break;
}
}
}
} // end namespace drawinglayer
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|