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 <comphelper/mediadescriptor.hxx>
21 : #include "oox/core/xmlfilterbase.hxx"
22 : #include "oox/export/shapes.hxx"
23 : #include "oox/export/utils.hxx"
24 : #include <oox/token/tokens.hxx>
25 :
26 : #include <cstdio>
27 : #include <com/sun/star/awt/CharSet.hpp>
28 : #include <com/sun/star/awt/FontDescriptor.hpp>
29 : #include <com/sun/star/awt/FontSlant.hpp>
30 : #include <com/sun/star/awt/FontWeight.hpp>
31 : #include <com/sun/star/awt/FontUnderline.hpp>
32 : #include <com/sun/star/awt/Gradient.hpp>
33 : #include <com/sun/star/beans/XPropertySet.hpp>
34 : #include <com/sun/star/beans/XPropertySetInfo.hpp>
35 : #include <com/sun/star/beans/XPropertyState.hpp>
36 : #include <com/sun/star/container/XEnumerationAccess.hpp>
37 : #include <com/sun/star/document/XExporter.hpp>
38 : #include <com/sun/star/drawing/FillStyle.hpp>
39 : #include <com/sun/star/drawing/BitmapMode.hpp>
40 : #include <com/sun/star/drawing/ConnectorType.hpp>
41 : #include <com/sun/star/drawing/LineDash.hpp>
42 : #include <com/sun/star/drawing/LineJoint.hpp>
43 : #include <com/sun/star/drawing/LineStyle.hpp>
44 : #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
45 : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
46 : #include <com/sun/star/graphic/XGraphic.hpp>
47 : #include <com/sun/star/i18n/ScriptType.hpp>
48 : #include <com/sun/star/io/XOutputStream.hpp>
49 : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
50 : #include <com/sun/star/style/ParagraphAdjust.hpp>
51 : #include <com/sun/star/text/XSimpleText.hpp>
52 : #include <com/sun/star/text/XText.hpp>
53 : #include <com/sun/star/text/XTextContent.hpp>
54 : #include <com/sun/star/text/XTextField.hpp>
55 : #include <com/sun/star/text/XTextRange.hpp>
56 : #include <com/sun/star/table/XTable.hpp>
57 : #include <com/sun/star/table/XColumnRowRange.hpp>
58 : #include <com/sun/star/table/XCellRange.hpp>
59 : #include <com/sun/star/table/XMergeableCell.hpp>
60 : #include <com/sun/star/chart2/XChartDocument.hpp>
61 : #include <com/sun/star/frame/XModel.hpp>
62 : #include <tools/stream.hxx>
63 : #include <tools/string.hxx>
64 : #include <vcl/cvtgrf.hxx>
65 : #include <unotools/fontcvt.hxx>
66 : #include <vcl/graph.hxx>
67 : #include <vcl/outdev.hxx>
68 : #include <svtools/grfmgr.hxx>
69 : #include <rtl/strbuf.hxx>
70 : #include <sfx2/app.hxx>
71 : #include <svl/languageoptions.hxx>
72 : #include <filter/msfilter/escherex.hxx>
73 : #include <svx/svdoashp.hxx>
74 : #include <svx/svdoole2.hxx>
75 : #include <editeng/svxenum.hxx>
76 : #include <svx/unoapi.hxx>
77 : #include <oox/export/chartexport.hxx>
78 :
79 : using namespace ::com::sun::star;
80 : using namespace ::com::sun::star::beans;
81 : using namespace ::com::sun::star::uno;
82 : using namespace ::com::sun::star::drawing;
83 : using namespace ::com::sun::star::i18n;
84 : using namespace ::com::sun::star::table;
85 : using ::com::sun::star::beans::PropertyState;
86 : using ::com::sun::star::beans::PropertyValue;
87 : using ::com::sun::star::beans::XPropertySet;
88 : using ::com::sun::star::beans::XPropertyState;
89 : using ::com::sun::star::container::XEnumeration;
90 : using ::com::sun::star::container::XEnumerationAccess;
91 : using ::com::sun::star::container::XIndexAccess;
92 : using ::com::sun::star::document::XExporter;
93 : using ::com::sun::star::document::XFilter;
94 : using ::com::sun::star::drawing::FillStyle;
95 : using ::com::sun::star::graphic::XGraphic;
96 : using ::com::sun::star::io::XOutputStream;
97 : using ::com::sun::star::lang::XComponent;
98 : using ::com::sun::star::text::XSimpleText;
99 : using ::com::sun::star::text::XText;
100 : using ::com::sun::star::text::XTextContent;
101 : using ::com::sun::star::text::XTextField;
102 : using ::com::sun::star::text::XTextRange;
103 : using ::oox::core::XmlFilterBase;
104 : using ::com::sun::star::chart2::XChartDocument;
105 : using ::com::sun::star::frame::XModel;
106 : using ::com::sun::star::sheet::XSpreadsheetDocument;
107 : using ::comphelper::MediaDescriptor;
108 : using ::oox::core::XmlFilterBase;
109 : using ::sax_fastparser::FSHelperPtr;
110 :
111 : #define IDS(x) OString(OStringLiteral(#x " ") + OString::valueOf( mnShapeIdMax++ )).getStr()
112 :
113 : struct CustomShapeTypeTranslationTable
114 : {
115 : const char* sOOo;
116 : const char* sMSO;
117 : };
118 :
119 : static const CustomShapeTypeTranslationTable pCustomShapeTypeTranslationTable[] =
120 : {
121 : // { "non-primitive", mso_sptMin },
122 : { "rectangle", "rect" },
123 : { "round-rectangle", "roundRect" },
124 : { "ellipse", "ellipse" },
125 : { "diamond", "diamond" },
126 : { "isosceles-triangle", "triangle" },
127 : { "right-triangle", "rtTriangle" },
128 : { "parallelogram", "parallelogram" },
129 : { "trapezoid", "trapezoid" },
130 : { "hexagon", "hexagon" },
131 : { "octagon", "octagon" },
132 : { "cross", "plus" },
133 : { "star5", "star5" },
134 : { "right-arrow", "rightArrow" },
135 : // { "mso-spt14", mso_sptThickArrow },
136 : { "pentagon-right", "homePlate" },
137 : { "cube", "cube" },
138 : // { "mso-spt17", mso_sptBalloon },
139 : // { "mso-spt18", mso_sptSeal },
140 : { "mso-spt19", "arc" },
141 : { "mso-spt20", "line" },
142 : { "mso-spt21", "plaque" },
143 : { "can", "can" },
144 : { "ring", "donut" },
145 : { "mso-spt24", "textSimple" },
146 : { "mso-spt25", "textOctagon" },
147 : { "mso-spt26", "textHexagon" },
148 : { "mso-spt27", "textCurve" },
149 : { "mso-spt28", "textWave" },
150 : { "mso-spt29", "textRing" },
151 : { "mso-spt30", "textOnCurve" },
152 : { "mso-spt31", "textOnRing" },
153 : { "mso-spt32", "straightConnector1" },
154 : { "mso-spt33", "bentConnector2" },
155 : { "mso-spt34", "bentConnector3" },
156 : { "mso-spt35", "bentConnector4" },
157 : { "mso-spt36", "bentConnector5" },
158 : { "mso-spt37", "curvedConnector2" },
159 : { "mso-spt38", "curvedConnector3" },
160 : { "mso-spt39", "curvedConnector4" },
161 : { "mso-spt40", "curvedConnector5" },
162 : { "mso-spt41", "callout1" },
163 : { "mso-spt42", "callout2" },
164 : { "mso-spt43", "callout3" },
165 : { "mso-spt44", "accentCallout1" },
166 : { "mso-spt45", "accentCallout2" },
167 : { "mso-spt46", "accentCallout3" },
168 : { "line-callout-1", "borderCallout1" },
169 : { "line-callout-2", "borderCallout2" },
170 : { "line-callout-3", "borderCallout3" },
171 : { "mso-spt49", "accentBorderCallout90" },
172 : { "mso-spt50", "accentBorderCallout1" },
173 : { "mso-spt51", "accentBorderCallout2" },
174 : { "mso-spt52", "accentBorderCallout3" },
175 : { "mso-spt53", "ribbon" },
176 : { "mso-spt54", "ribbon2" },
177 : { "chevron", "chevron" },
178 : { "pentagon", "pentagon" },
179 : { "forbidden", "noSmoking" },
180 : { "star8", "seal8" },
181 : { "mso-spt59", "seal16" },
182 : { "mso-spt60", "seal32" },
183 : { "rectangular-callout", "wedgeRectCallout" },
184 : { "round-rectangular-callout", "wedgeRoundRectCallout" },
185 : { "round-callout", "wedgeEllipseCallout" },
186 : { "mso-spt64", "wave" },
187 : { "paper", "foldedCorner" },
188 : { "left-arrow", "leftArrow" },
189 : { "down-arrow", "downArrow" },
190 : { "up-arrow", "upArrow" },
191 : { "left-right-arrow", "leftRightArrow" },
192 : { "up-down-arrow", "upDownArrow" },
193 : { "mso-spt71", "irregularSeal1" },
194 : { "bang", "irregularSeal2" },
195 : { "lightning", "lightningBolt" },
196 : { "heart", "heart" },
197 : { "mso-spt75", "pictureFrame" },
198 : { "quad-arrow", "quadArrow" },
199 : { "left-arrow-callout", "leftArrowCallout" },
200 : { "right-arrow-callout", "rightArrowCallout" },
201 : { "up-arrow-callout", "upArrowCallout" },
202 : { "down-arrow-callout", "downArrowCallout" },
203 : { "left-right-arrow-callout", "leftRightArrowCallout" },
204 : { "up-down-arrow-callout", "upDownArrowCallout" },
205 : { "quad-arrow-callout", "quadArrowCallout" },
206 : { "quad-bevel", "bevel" },
207 : { "left-bracket", "leftBracket" },
208 : { "right-bracket", "rightBracket" },
209 : { "left-brace", "leftBrace" },
210 : { "right-brace", "rightBrace" },
211 : { "mso-spt89", "leftUpArrow" },
212 : { "mso-spt90", "bentUpArrow" },
213 : { "mso-spt91", "bentArrow" },
214 : { "star24", "seal24" },
215 : { "striped-right-arrow", "stripedRightArrow" },
216 : { "notched-right-arrow", "notchedRightArrow" },
217 : { "block-arc", "blockArc" },
218 : { "smiley", "smileyFace" },
219 : { "vertical-scroll", "verticalScroll" },
220 : { "horizontal-scroll", "horizontalScroll" },
221 : { "circular-arrow", "circularArrow" },
222 : { "mso-spt100", "pie" }, // looks like MSO_SPT is wrong here
223 : { "mso-spt101", "uturnArrow" },
224 : { "mso-spt102", "curvedRightArrow" },
225 : { "mso-spt103", "curvedLeftArrow" },
226 : { "mso-spt104", "curvedUpArrow" },
227 : { "mso-spt105", "curvedDownArrow" },
228 : { "cloud-callout", "cloudCallout" },
229 : { "mso-spt107", "ellipseRibbon" },
230 : { "mso-spt108", "ellipseRibbon2" },
231 : { "flowchart-process", "flowChartProcess" },
232 : { "flowchart-decision", "flowChartDecision" },
233 : { "flowchart-data", "flowChartInputOutput" },
234 : { "flowchart-predefined-process", "flowChartPredefinedProcess" },
235 : { "flowchart-internal-storage", "flowChartInternalStorage" },
236 : { "flowchart-document", "flowChartDocument" },
237 : { "flowchart-multidocument", "flowChartMultidocument" },
238 : { "flowchart-terminator", "flowChartTerminator" },
239 : { "flowchart-preparation", "flowChartPreparation" },
240 : { "flowchart-manual-input", "flowChartManualInput" },
241 : { "flowchart-manual-operation", "flowChartManualOperation" },
242 : { "flowchart-connector", "flowChartConnector" },
243 : { "flowchart-card", "flowChartPunchedCard" },
244 : { "flowchart-punched-tape", "flowChartPunchedTape" },
245 : { "flowchart-summing-junction", "flowChartSummingJunction" },
246 : { "flowchart-or", "flowChartOr" },
247 : { "flowchart-collate", "flowChartCollate" },
248 : { "flowchart-sort", "flowChartSort" },
249 : { "flowchart-extract", "flowChartExtract" },
250 : { "flowchart-merge", "flowChartMerge" },
251 : { "mso-spt129", "flowChartOfflineStorage" },
252 : { "flowchart-stored-data", "flowChartOnlineStorage" },
253 : { "flowchart-sequential-access", "flowChartMagneticTape" },
254 : { "flowchart-magnetic-disk", "flowChartMagneticDisk" },
255 : { "flowchart-direct-access-storage", "flowChartMagneticDrum" },
256 : { "flowchart-display", "flowChartDisplay" },
257 : { "flowchart-delay", "flowChartDelay" },
258 : { "fontwork-plain-text", "textPlainText" },
259 : { "fontwork-stop", "textStop" },
260 : { "fontwork-triangle-up", "textTriangle" },
261 : { "fontwork-triangle-down", "textTriangleInverted" },
262 : { "fontwork-chevron-up", "textChevron" },
263 : { "fontwork-chevron-down", "textChevronInverted" },
264 : { "mso-spt142", "textRingInside" },
265 : { "mso-spt143", "textRingOutside" },
266 : { "fontwork-arch-up-curve", "textArchUpCurve" },
267 : { "fontwork-arch-down-curve", "textArchDownCurve" },
268 : { "fontwork-circle-curve", "textCircleCurve" },
269 : { "fontwork-open-circle-curve", "textButtonCurve" },
270 : { "fontwork-arch-up-pour", "textArchUpPour" },
271 : { "fontwork-arch-down-pour", "textArchDownPour" },
272 : { "fontwork-circle-pour", "textCirclePour" },
273 : { "fontwork-open-circle-pour", "textButtonPour" },
274 : { "fontwork-curve-up", "textCurveUp" },
275 : { "fontwork-curve-down", "textCurveDown" },
276 : { "fontwork-fade-up-and-right", "textCascadeUp" },
277 : { "fontwork-fade-up-and-left", "textCascadeDown" },
278 : { "fontwork-wave", "textWave1" },
279 : { "mso-spt157", "textWave2" },
280 : { "mso-spt158", "textWave3" },
281 : { "mso-spt159", "textWave4" },
282 : { "fontwork-inflate", "textInflate" },
283 : { "mso-spt161", "textDeflate" },
284 : { "mso-spt162", "textInflateBottom" },
285 : { "mso-spt163", "textDeflateBottom" },
286 : { "mso-spt164", "textInflateTop" },
287 : { "mso-spt165", "textDeflateTop" },
288 : { "mso-spt166", "textDeflateInflate" },
289 : { "mso-spt167", "textDeflateInflateDeflate" },
290 : { "fontwork-fade-right", "textFadeRight" },
291 : { "fontwork-fade-left", "textFadeLeft" },
292 : { "fontwork-fade-up", "textFadeUp" },
293 : { "fontwork-fade-down", "textFadeDown" },
294 : { "fontwork-slant-up", "textSlantUp" },
295 : { "fontwork-slant-down", "textSlantDown" },
296 : { "mso-spt174", "textCanUp" },
297 : { "mso-spt175", "textCanDown" },
298 : { "flowchart-alternate-process", "flowChartAlternateProcess" },
299 : { "flowchart-off-page-connector", "flowChartOffpageConnector" },
300 : { "mso-spt178", "callout90" },
301 : { "mso-spt179", "accentCallout90" },
302 : { "mso-spt180", "borderCallout90" },
303 : { "mso-spt182", "leftRightUpArrow" },
304 : { "sun", "sun" },
305 : { "moon", "moon" },
306 : { "bracket-pair", "bracketPair" },
307 : { "brace-pair", "bracePair" },
308 : { "star4", "seal4" },
309 : { "mso-spt188", "doubleWave" },
310 : { "mso-spt189", "actionButtonBlank" },
311 : { "mso-spt190", "actionButtonHome" },
312 : { "mso-spt191", "actionButtonHelp" },
313 : { "mso-spt192", "actionButtonInformation" },
314 : { "mso-spt193", "actionButtonForwardNext" },
315 : { "mso-spt194", "actionButtonBackPrevious" },
316 : { "mso-spt195", "actionButtonEnd" },
317 : { "mso-spt196", "actionButtonBeginning" },
318 : { "mso-spt197", "actionButtonReturn" },
319 : { "mso-spt198", "actionButtonDocument" },
320 : { "mso-spt199", "actionButtonSound" },
321 : { "mso-spt200", "actionButtonMovie" },
322 : { "mso-spt201", "hostControl" },
323 : { "mso-spt202", "rect" },
324 : { "ooxml-actionButtonSound", "actionButtonSound" },
325 : { "ooxml-borderCallout1", "borderCallout1" },
326 : { "ooxml-plaqueTabs", "plaqueTabs" },
327 : { "ooxml-curvedLeftArrow", "curvedLeftArrow" },
328 : { "ooxml-octagon", "octagon" },
329 : { "ooxml-leftRightRibbon", "leftRightRibbon" },
330 : { "ooxml-actionButtonInformation", "actionButtonInformation" },
331 : { "ooxml-bentConnector5", "bentConnector5" },
332 : { "ooxml-circularArrow", "circularArrow" },
333 : { "ooxml-downArrowCallout", "downArrowCallout" },
334 : { "ooxml-mathMinus", "mathMinus" },
335 : { "ooxml-gear9", "gear9" },
336 : { "ooxml-round1Rect", "round1Rect" },
337 : { "ooxml-sun", "sun" },
338 : { "ooxml-plaque", "plaque" },
339 : { "ooxml-chevron", "chevron" },
340 : { "ooxml-flowChartPreparation", "flowChartPreparation" },
341 : { "ooxml-diagStripe", "diagStripe" },
342 : { "ooxml-pentagon", "pentagon" },
343 : { "ooxml-funnel", "funnel" },
344 : { "ooxml-chartStar", "chartStar" },
345 : { "ooxml-accentBorderCallout1", "accentBorderCallout1" },
346 : { "ooxml-notchedRightArrow", "notchedRightArrow" },
347 : { "ooxml-rightBracket", "rightBracket" },
348 : { "ooxml-flowChartOffpageConnector", "flowChartOffpageConnector" },
349 : { "ooxml-leftRightArrow", "leftRightArrow" },
350 : { "ooxml-decagon", "decagon" },
351 : { "ooxml-actionButtonHelp", "actionButtonHelp" },
352 : { "ooxml-star24", "star24" },
353 : { "ooxml-mathDivide", "mathDivide" },
354 : { "ooxml-curvedConnector4", "curvedConnector4" },
355 : { "ooxml-flowChartOr", "flowChartOr" },
356 : { "ooxml-borderCallout3", "borderCallout3" },
357 : { "ooxml-upDownArrowCallout", "upDownArrowCallout" },
358 : { "ooxml-flowChartDecision", "flowChartDecision" },
359 : { "ooxml-leftRightArrowCallout", "leftRightArrowCallout" },
360 : { "ooxml-flowChartManualOperation", "flowChartManualOperation" },
361 : { "ooxml-snipRoundRect", "snipRoundRect" },
362 : { "ooxml-mathPlus", "mathPlus" },
363 : { "ooxml-actionButtonForwardNext", "actionButtonForwardNext" },
364 : { "ooxml-can", "can" },
365 : { "ooxml-foldedCorner", "foldedCorner" },
366 : { "ooxml-star32", "star32" },
367 : { "ooxml-flowChartInternalStorage", "flowChartInternalStorage" },
368 : { "ooxml-upDownArrow", "upDownArrow" },
369 : { "ooxml-irregularSeal2", "irregularSeal2" },
370 : { "ooxml-mathEqual", "mathEqual" },
371 : { "ooxml-star12", "star12" },
372 : { "ooxml-uturnArrow", "uturnArrow" },
373 : { "ooxml-squareTabs", "squareTabs" },
374 : { "ooxml-leftRightUpArrow", "leftRightUpArrow" },
375 : { "ooxml-homePlate", "homePlate" },
376 : { "ooxml-dodecagon", "dodecagon" },
377 : { "ooxml-leftArrowCallout", "leftArrowCallout" },
378 : { "ooxml-chord", "chord" },
379 : { "ooxml-quadArrowCallout", "quadArrowCallout" },
380 : { "ooxml-actionButtonBeginning", "actionButtonBeginning" },
381 : { "ooxml-ellipse", "ellipse" },
382 : { "ooxml-actionButtonEnd", "actionButtonEnd" },
383 : { "ooxml-arc", "arc" },
384 : { "ooxml-star16", "star16" },
385 : { "ooxml-parallelogram", "parallelogram" },
386 : { "ooxml-bevel", "bevel" },
387 : { "ooxml-roundRect", "roundRect" },
388 : { "ooxml-accentCallout1", "accentCallout1" },
389 : { "ooxml-flowChartSort", "flowChartSort" },
390 : { "ooxml-star8", "star8" },
391 : { "ooxml-flowChartAlternateProcess", "flowChartAlternateProcess" },
392 : { "ooxml-moon", "moon" },
393 : { "ooxml-star6", "star6" },
394 : { "ooxml-round2SameRect", "round2SameRect" },
395 : { "ooxml-nonIsoscelesTrapezoid", "nonIsoscelesTrapezoid" },
396 : { "ooxml-diamond", "diamond" },
397 : { "ooxml-ellipseRibbon", "ellipseRibbon" },
398 : { "ooxml-callout2", "callout2" },
399 : { "ooxml-pie", "pie" },
400 : { "ooxml-star4", "star4" },
401 : { "ooxml-flowChartPredefinedProcess", "flowChartPredefinedProcess" },
402 : { "ooxml-flowChartPunchedTape", "flowChartPunchedTape" },
403 : { "ooxml-curvedConnector2", "curvedConnector2" },
404 : { "ooxml-bentConnector3", "bentConnector3" },
405 : { "ooxml-cornerTabs", "cornerTabs" },
406 : { "ooxml-hexagon", "hexagon" },
407 : { "ooxml-flowChartConnector", "flowChartConnector" },
408 : { "ooxml-flowChartMagneticDisk", "flowChartMagneticDisk" },
409 : { "ooxml-heart", "heart" },
410 : { "ooxml-ribbon2", "ribbon2" },
411 : { "ooxml-bracePair", "bracePair" },
412 : { "ooxml-flowChartExtract", "flowChartExtract" },
413 : { "ooxml-actionButtonHome", "actionButtonHome" },
414 : { "ooxml-accentBorderCallout3", "accentBorderCallout3" },
415 : { "ooxml-flowChartOfflineStorage", "flowChartOfflineStorage" },
416 : { "ooxml-irregularSeal1", "irregularSeal1" },
417 : { "ooxml-quadArrow", "quadArrow" },
418 : { "ooxml-leftBrace", "leftBrace" },
419 : { "ooxml-leftBracket", "leftBracket" },
420 : { "ooxml-blockArc", "blockArc" },
421 : { "ooxml-curvedConnector3", "curvedConnector3" },
422 : { "ooxml-wedgeRoundRectCallout", "wedgeRoundRectCallout" },
423 : { "ooxml-actionButtonMovie", "actionButtonMovie" },
424 : { "ooxml-flowChartOnlineStorage", "flowChartOnlineStorage" },
425 : { "ooxml-gear6", "gear6" },
426 : { "ooxml-halfFrame", "halfFrame" },
427 : { "ooxml-snip2SameRect", "snip2SameRect" },
428 : { "ooxml-triangle", "triangle" },
429 : { "ooxml-teardrop", "teardrop" },
430 : { "ooxml-flowChartDocument", "flowChartDocument" },
431 : { "ooxml-rightArrowCallout", "rightArrowCallout" },
432 : { "ooxml-rightBrace", "rightBrace" },
433 : { "ooxml-chartPlus", "chartPlus" },
434 : { "ooxml-flowChartManualInput", "flowChartManualInput" },
435 : { "ooxml-flowChartMerge", "flowChartMerge" },
436 : { "ooxml-line", "line" },
437 : { "ooxml-downArrow", "downArrow" },
438 : { "ooxml-curvedDownArrow", "curvedDownArrow" },
439 : { "ooxml-actionButtonReturn", "actionButtonReturn" },
440 : { "ooxml-flowChartInputOutput", "flowChartInputOutput" },
441 : { "ooxml-bracketPair", "bracketPair" },
442 : { "ooxml-smileyFace", "smileyFace" },
443 : { "ooxml-actionButtonBlank", "actionButtonBlank" },
444 : { "ooxml-wave", "wave" },
445 : { "ooxml-swooshArrow", "swooshArrow" },
446 : { "ooxml-flowChartSummingJunction", "flowChartSummingJunction" },
447 : { "ooxml-lightningBolt", "lightningBolt" },
448 : { "ooxml-flowChartDisplay", "flowChartDisplay" },
449 : { "ooxml-actionButtonBackPrevious", "actionButtonBackPrevious" },
450 : { "ooxml-frame", "frame" },
451 : { "ooxml-rtTriangle", "rtTriangle" },
452 : { "ooxml-flowChartMagneticTape", "flowChartMagneticTape" },
453 : { "ooxml-curvedRightArrow", "curvedRightArrow" },
454 : { "ooxml-leftUpArrow", "leftUpArrow" },
455 : { "ooxml-wedgeEllipseCallout", "wedgeEllipseCallout" },
456 : { "ooxml-doubleWave", "doubleWave" },
457 : { "ooxml-bentArrow", "bentArrow" },
458 : { "ooxml-star10", "star10" },
459 : { "ooxml-leftArrow", "leftArrow" },
460 : { "ooxml-curvedUpArrow", "curvedUpArrow" },
461 : { "ooxml-snip1Rect", "snip1Rect" },
462 : { "ooxml-ellipseRibbon2", "ellipseRibbon2" },
463 : { "ooxml-plus", "plus" },
464 : { "ooxml-accentCallout3", "accentCallout3" },
465 : { "ooxml-leftCircularArrow", "leftCircularArrow" },
466 : { "ooxml-rightArrow", "rightArrow" },
467 : { "ooxml-flowChartPunchedCard", "flowChartPunchedCard" },
468 : { "ooxml-snip2DiagRect", "snip2DiagRect" },
469 : { "ooxml-verticalScroll", "verticalScroll" },
470 : { "ooxml-star7", "star7" },
471 : { "ooxml-chartX", "chartX" },
472 : { "ooxml-cloud", "cloud" },
473 : { "ooxml-cube", "cube" },
474 : { "ooxml-round2DiagRect", "round2DiagRect" },
475 : { "ooxml-flowChartMultidocument", "flowChartMultidocument" },
476 : { "ooxml-actionButtonDocument", "actionButtonDocument" },
477 : { "ooxml-flowChartTerminator", "flowChartTerminator" },
478 : { "ooxml-flowChartDelay", "flowChartDelay" },
479 : { "ooxml-curvedConnector5", "curvedConnector5" },
480 : { "ooxml-horizontalScroll", "horizontalScroll" },
481 : { "ooxml-bentConnector4", "bentConnector4" },
482 : { "ooxml-leftRightCircularArrow", "leftRightCircularArrow" },
483 : { "ooxml-wedgeRectCallout", "wedgeRectCallout" },
484 : { "ooxml-accentCallout2", "accentCallout2" },
485 : { "ooxml-flowChartMagneticDrum", "flowChartMagneticDrum" },
486 : { "ooxml-corner", "corner" },
487 : { "ooxml-borderCallout2", "borderCallout2" },
488 : { "ooxml-donut", "donut" },
489 : { "ooxml-flowChartCollate", "flowChartCollate" },
490 : { "ooxml-mathNotEqual", "mathNotEqual" },
491 : { "ooxml-bentConnector2", "bentConnector2" },
492 : { "ooxml-mathMultiply", "mathMultiply" },
493 : { "ooxml-heptagon", "heptagon" },
494 : { "ooxml-rect", "rect" },
495 : { "ooxml-accentBorderCallout2", "accentBorderCallout2" },
496 : { "ooxml-pieWedge", "pieWedge" },
497 : { "ooxml-upArrowCallout", "upArrowCallout" },
498 : { "ooxml-flowChartProcess", "flowChartProcess" },
499 : { "ooxml-star5", "star5" },
500 : { "ooxml-lineInv", "lineInv" },
501 : { "ooxml-straightConnector1", "straightConnector1" },
502 : { "ooxml-stripedRightArrow", "stripedRightArrow" },
503 : { "ooxml-callout3", "callout3" },
504 : { "ooxml-bentUpArrow", "bentUpArrow" },
505 : { "ooxml-noSmoking", "noSmoking" },
506 : { "ooxml-trapezoid", "trapezoid" },
507 : { "ooxml-cloudCallout", "cloudCallout" },
508 : { "ooxml-callout1", "callout1" },
509 : { "ooxml-ribbon", "ribbon" },
510 : };
511 :
512 : struct StringHash
513 : {
514 0 : size_t operator()( const char* s ) const
515 : {
516 0 : return rtl_str_hashCode(s);
517 : }
518 : };
519 :
520 : struct StringCheck
521 : {
522 0 : bool operator()( const char* s1, const char* s2 ) const
523 : {
524 0 : return strcmp( s1, s2 ) == 0;
525 : }
526 : };
527 :
528 : typedef boost::unordered_map< const char*, const char*, StringHash, StringCheck> CustomShapeTypeTranslationHashMap;
529 : static CustomShapeTypeTranslationHashMap* pCustomShapeTypeTranslationHashMap = NULL;
530 :
531 0 : static const char* lcl_GetPresetGeometry( const char* sShapeType )
532 : {
533 : const char* sPresetGeo;
534 :
535 0 : if( pCustomShapeTypeTranslationHashMap == NULL )
536 : {
537 0 : pCustomShapeTypeTranslationHashMap = new CustomShapeTypeTranslationHashMap ();
538 0 : for( unsigned int i = 0; i < sizeof( pCustomShapeTypeTranslationTable )/sizeof( CustomShapeTypeTranslationTable ); i ++ )
539 : {
540 0 : (*pCustomShapeTypeTranslationHashMap)[ pCustomShapeTypeTranslationTable[ i ].sOOo ] = pCustomShapeTypeTranslationTable[ i ].sMSO;
541 : //DBG(printf("type OOo: %s MSO: %s\n", pCustomShapeTypeTranslationTable[ i ].sOOo, pCustomShapeTypeTranslationTable[ i ].sMSO));
542 : }
543 : }
544 :
545 0 : sPresetGeo = (*pCustomShapeTypeTranslationHashMap)[ sShapeType ];
546 :
547 0 : if( sPresetGeo == NULL )
548 0 : sPresetGeo = "rect";
549 :
550 0 : return sPresetGeo;
551 : }
552 :
553 : namespace oox { namespace drawingml {
554 :
555 : #define GETA(propName) \
556 : GetProperty( rXPropSet, OUString(#propName))
557 :
558 : #define GETAD(propName) \
559 : ( GetPropertyAndState( rXPropSet, rXPropState, OUString(#propName), eState ) && eState == beans::PropertyState_DIRECT_VALUE )
560 :
561 : #define GET(variable, propName) \
562 : if ( GETA(propName) ) \
563 : mAny >>= variable;
564 :
565 : // not thread safe
566 : int ShapeExport::mnSpreadsheetCounter = 1;
567 :
568 0 : ShapeExport::ShapeExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, ShapeHashMap* pShapeMap, XmlFilterBase* pFB, DocumentType eDocumentType )
569 : : DrawingML( pFS, pFB, eDocumentType )
570 : , mnShapeIdMax( 1 )
571 : , mnPictureIdMax( 1 )
572 : , mnXmlNamespace( nXmlNamespace )
573 : , maFraction( 1, 576 )
574 : , maMapModeSrc( MAP_100TH_MM )
575 : , maMapModeDest( MAP_INCH, Point(), maFraction, maFraction )
576 0 : , mpShapeMap( pShapeMap ? pShapeMap : &maShapeMap )
577 : {
578 0 : }
579 :
580 0 : awt::Size ShapeExport::MapSize( const awt::Size& rSize ) const
581 : {
582 0 : Size aRetSize( OutputDevice::LogicToLogic( Size( rSize.Width, rSize.Height ), maMapModeSrc, maMapModeDest ) );
583 :
584 0 : if ( !aRetSize.Width() )
585 0 : aRetSize.Width()++;
586 0 : if ( !aRetSize.Height() )
587 0 : aRetSize.Height()++;
588 0 : return awt::Size( aRetSize.Width(), aRetSize.Height() );
589 : }
590 :
591 0 : sal_Bool ShapeExport::NonEmptyText( Reference< XInterface > xIface )
592 : {
593 0 : Reference< XPropertySet > xPropSet( xIface, UNO_QUERY );
594 :
595 0 : if( xPropSet.is() )
596 : {
597 0 : Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
598 0 : if ( xPropSetInfo.is() )
599 : {
600 0 : if ( xPropSetInfo->hasPropertyByName( S( "IsEmptyPresentationObject" ) ) )
601 : {
602 0 : sal_Bool bIsEmptyPresObj = sal_False;
603 0 : if ( xPropSet->getPropertyValue( S( "IsEmptyPresentationObject" ) ) >>= bIsEmptyPresObj )
604 : {
605 : DBG(printf("empty presentation object %d, props:\n", bIsEmptyPresObj));
606 0 : if( bIsEmptyPresObj )
607 0 : return sal_True;
608 : }
609 : }
610 :
611 0 : if ( xPropSetInfo->hasPropertyByName( S( "IsPresentationObject" ) ) )
612 : {
613 0 : sal_Bool bIsPresObj = sal_False;
614 0 : if ( xPropSet->getPropertyValue( S( "IsPresentationObject" ) ) >>= bIsPresObj )
615 : {
616 : DBG(printf("presentation object %d, props:\n", bIsPresObj));
617 0 : if( bIsPresObj )
618 0 : return sal_True;
619 : }
620 : }
621 0 : }
622 : }
623 :
624 0 : Reference< XSimpleText > xText( xIface, UNO_QUERY );
625 :
626 0 : if( xText.is() )
627 0 : return xText->getString().getLength();
628 :
629 0 : return sal_False;
630 : }
631 :
632 0 : ShapeExport& ShapeExport::WriteBezierShape( Reference< XShape > xShape, sal_Bool bClosed )
633 : {
634 : DBG(printf("write open bezier shape\n"));
635 :
636 0 : FSHelperPtr pFS = GetFS();
637 0 : pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
638 :
639 0 : PolyPolygon aPolyPolygon = EscherPropertyContainer::GetPolyPolygon( xShape );
640 0 : Rectangle aRect( aPolyPolygon.GetBoundRect() );
641 :
642 : #if OSL_DEBUG_LEVEL > 0
643 : awt::Size size = MapSize( awt::Size( aRect.GetWidth(), aRect.GetHeight() ) );
644 : DBG(printf("poly count %d\nsize: %d x %d", aPolyPolygon.Count(), int( size.Width ), int( size.Height )));
645 : #endif
646 :
647 : // non visual shape properties
648 0 : pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
649 : pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
650 : XML_id, I32S( GetNewShapeID( xShape ) ),
651 0 : XML_name, IDS( Freeform ),
652 0 : FSEND );
653 0 : pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
654 0 : WriteNonVisualProperties( xShape );
655 0 : pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
656 :
657 : // visual shape properties
658 0 : pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
659 0 : WriteTransformation( aRect, XML_a );
660 0 : WritePolyPolygon( aPolyPolygon );
661 0 : Reference< XPropertySet > xProps( xShape, UNO_QUERY );
662 0 : if( xProps.is() ) {
663 0 : if( bClosed )
664 0 : WriteFill( xProps );
665 0 : WriteOutline( xProps );
666 : }
667 :
668 0 : pFS->endElementNS( mnXmlNamespace, XML_spPr );
669 :
670 : // write text
671 0 : WriteTextBox( xShape, mnXmlNamespace );
672 :
673 0 : pFS->endElementNS( mnXmlNamespace, XML_sp );
674 :
675 0 : return *this;
676 : }
677 :
678 0 : ShapeExport& ShapeExport::WriteClosedBezierShape( Reference< XShape > xShape )
679 : {
680 0 : return WriteBezierShape( xShape, sal_True );
681 : }
682 :
683 0 : ShapeExport& ShapeExport::WriteOpenBezierShape( Reference< XShape > xShape )
684 : {
685 0 : return WriteBezierShape( xShape, sal_False );
686 : }
687 :
688 0 : ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
689 : {
690 : DBG(printf("write custom shape\n"));
691 :
692 0 : Reference< XPropertySet > rXPropSet( xShape, UNO_QUERY );
693 0 : SdrObjCustomShape* pShape = (SdrObjCustomShape*) GetSdrObjectFromXShape( xShape );
694 0 : sal_Bool bIsDefaultObject = EscherPropertyContainer::IsDefaultObject( pShape );
695 0 : sal_Bool bPredefinedHandlesUsed = sal_True;
696 0 : OUString sShapeType;
697 0 : sal_uInt32 nMirrorFlags = 0;
698 0 : MSO_SPT eShapeType = EscherPropertyContainer::GetCustomShapeType( xShape, nMirrorFlags, sShapeType );
699 0 : const char* sPresetShape = lcl_GetPresetGeometry( USS( sShapeType ) );
700 : DBG(printf("custom shape type: %s ==> %s\n", USS( sShapeType ), sPresetShape));
701 0 : Sequence< PropertyValue > aGeometrySeq;
702 0 : sal_Int32 nAdjustmentValuesIndex = -1;
703 :
704 0 : sal_Bool bFlipH = false;
705 0 : sal_Bool bFlipV = false;
706 :
707 0 : if( GETA( CustomShapeGeometry ) ) {
708 : DBG(printf("got custom shape geometry\n"));
709 0 : if( mAny >>= aGeometrySeq ) {
710 :
711 : DBG(printf("got custom shape geometry sequence\n"));
712 0 : for( int i = 0; i < aGeometrySeq.getLength(); i++ ) {
713 0 : const PropertyValue& rProp = aGeometrySeq[ i ];
714 : DBG(printf("geometry property: %s\n", USS( rProp.Name )));
715 :
716 0 : if ( rProp.Name == "MirroredX" )
717 0 : rProp.Value >>= bFlipH;
718 :
719 0 : if ( rProp.Name == "MirroredY" )
720 0 : rProp.Value >>= bFlipV;
721 0 : if ( rProp.Name == "AdjustmentValues" )
722 0 : nAdjustmentValuesIndex = i;
723 0 : else if ( rProp.Name == "Handles" ) {
724 0 : if( !bIsDefaultObject )
725 0 : bPredefinedHandlesUsed = sal_False;
726 : // TODO: update nAdjustmentsWhichNeedsToBeConverted here
727 : }
728 : }
729 : }
730 : }
731 :
732 0 : FSHelperPtr pFS = GetFS();
733 0 : pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
734 :
735 : // non visual shape properties
736 0 : pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
737 : pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
738 : XML_id, I32S( GetNewShapeID( xShape ) ),
739 0 : XML_name, IDS( CustomShape ),
740 0 : FSEND );
741 0 : pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
742 0 : WriteNonVisualProperties( xShape );
743 0 : pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
744 :
745 : // visual shape properties
746 0 : pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
747 0 : WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV, false);
748 0 : if( nAdjustmentValuesIndex != -1 )
749 : {
750 0 : sal_Int32 nAdjustmentsWhichNeedsToBeConverted = 0;
751 : WritePresetShape( sPresetShape, eShapeType, bPredefinedHandlesUsed,
752 0 : nAdjustmentsWhichNeedsToBeConverted, aGeometrySeq[ nAdjustmentValuesIndex ] );
753 : }
754 : else
755 0 : WritePresetShape( sPresetShape );
756 0 : if( rXPropSet.is() )
757 : {
758 0 : WriteFill( rXPropSet );
759 0 : WriteOutline( rXPropSet );
760 : }
761 :
762 0 : pFS->endElementNS( mnXmlNamespace, XML_spPr );
763 :
764 : // write text
765 0 : WriteTextBox( xShape, mnXmlNamespace );
766 :
767 0 : pFS->endElementNS( mnXmlNamespace, XML_sp );
768 :
769 0 : return *this;
770 : }
771 :
772 0 : ShapeExport& ShapeExport::WriteEllipseShape( Reference< XShape > xShape )
773 : {
774 : DBG(printf("write ellipse shape\n"));
775 :
776 0 : FSHelperPtr pFS = GetFS();
777 :
778 0 : pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
779 :
780 : // TODO: arc, section, cut, connector
781 :
782 : // non visual shape properties
783 0 : pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
784 : pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
785 : XML_id, I32S( GetNewShapeID( xShape ) ),
786 0 : XML_name, IDS( Ellipse ),
787 0 : FSEND );
788 0 : pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
789 0 : WriteNonVisualProperties( xShape );
790 0 : pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
791 :
792 : // visual shape properties
793 0 : pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
794 0 : WriteShapeTransformation( xShape, XML_a,0,0,false);
795 0 : WritePresetShape( "ellipse" );
796 0 : Reference< XPropertySet > xProps( xShape, UNO_QUERY );
797 0 : if( xProps.is() )
798 : {
799 0 : WriteFill( xProps );
800 0 : WriteOutline( xProps );
801 : }
802 0 : pFS->endElementNS( mnXmlNamespace, XML_spPr );
803 :
804 : // write text
805 0 : WriteTextBox( xShape, mnXmlNamespace );
806 :
807 0 : pFS->endElementNS( mnXmlNamespace, XML_sp );
808 :
809 0 : return *this;
810 : }
811 :
812 0 : ShapeExport& ShapeExport::WriteGraphicObjectShape( Reference< XShape > xShape )
813 : {
814 0 : WriteGraphicObjectShapePart( xShape );
815 :
816 0 : return *this;
817 : }
818 :
819 0 : void ShapeExport::WriteGraphicObjectShapePart( Reference< XShape > xShape, Graphic* pGraphic )
820 : {
821 : DBG(printf("write graphic object shape\n"));
822 :
823 0 : if( NonEmptyText( xShape ) )
824 : {
825 0 : WriteTextShape( xShape );
826 :
827 : //DBG(dump_pset(mXPropSet));
828 :
829 : return;
830 : }
831 :
832 : DBG(printf("graphicObject without text\n"));
833 :
834 0 : OUString sGraphicURL;
835 0 : Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
836 0 : if( !pGraphic && ( !xShapeProps.is() || !( xShapeProps->getPropertyValue( S( "GraphicURL" ) ) >>= sGraphicURL ) ) )
837 : {
838 : DBG(printf("no graphic URL found\n"));
839 : return;
840 : }
841 :
842 0 : FSHelperPtr pFS = GetFS();
843 :
844 0 : pFS->startElementNS( mnXmlNamespace, XML_pic, FSEND );
845 :
846 0 : pFS->startElementNS( mnXmlNamespace, XML_nvPicPr, FSEND );
847 :
848 0 : OUString sName, sDescr;
849 : bool bHaveName, bHaveDesc;
850 :
851 0 : if ( ( bHaveName= GetProperty( xShapeProps, S( "Name" ) ) ) )
852 0 : mAny >>= sName;
853 0 : if ( ( bHaveDesc = GetProperty( xShapeProps, S( "Description" ) ) ) )
854 0 : mAny >>= sDescr;
855 :
856 : pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
857 : XML_id, I32S( GetNewShapeID( xShape ) ),
858 0 : XML_name, bHaveName ? USS( sName ) : OString( "Picture " + OString::valueOf( mnPictureIdMax++ )).getStr(),
859 0 : XML_descr, bHaveDesc ? USS( sDescr ) : NULL,
860 0 : FSEND );
861 : // OOXTODO: //cNvPr children: XML_extLst, XML_hlinkClick, XML_hlinkHover
862 :
863 : pFS->singleElementNS( mnXmlNamespace, XML_cNvPicPr,
864 : // OOXTODO: XML_preferRelativeSize
865 0 : FSEND );
866 :
867 0 : WriteNonVisualProperties( xShape );
868 :
869 0 : pFS->endElementNS( mnXmlNamespace, XML_nvPicPr );
870 :
871 0 : pFS->startElementNS( mnXmlNamespace, XML_blipFill, FSEND );
872 :
873 0 : WriteBlip( xShapeProps, sGraphicURL, pGraphic );
874 :
875 : // now we stretch always when we get pGraphic (when changing that
876 : // behavior, test n#780830 for regression, where the OLE sheet might get tiled
877 0 : bool bStretch = false;
878 0 : if( !pGraphic && GetProperty( xShapeProps, S( "FillBitmapStretch" ) ) )
879 0 : mAny >>= bStretch;
880 :
881 0 : if ( pGraphic || bStretch )
882 0 : WriteStretch();
883 :
884 0 : pFS->endElementNS( mnXmlNamespace, XML_blipFill );
885 :
886 : // visual shape properties
887 0 : pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
888 0 : WriteShapeTransformation( xShape, XML_a,0,0,false);
889 0 : WritePresetShape( "rect" );
890 : // graphic object can come with the frame (bnc#654525)
891 0 : WriteOutline( xShapeProps );
892 0 : pFS->endElementNS( mnXmlNamespace, XML_spPr );
893 :
894 0 : pFS->endElementNS( mnXmlNamespace, XML_pic );
895 : }
896 :
897 0 : ShapeExport& ShapeExport::WriteConnectorShape( Reference< XShape > xShape )
898 : {
899 0 : sal_Bool bFlipH = false;
900 0 : sal_Bool bFlipV = false;
901 :
902 : DBG(printf("write connector shape\n"));
903 :
904 0 : FSHelperPtr pFS = GetFS();
905 :
906 0 : const char* sGeometry = "line";
907 0 : Reference< XPropertySet > rXPropSet( xShape, UNO_QUERY );
908 0 : Reference< XPropertyState > rXPropState( xShape, UNO_QUERY );
909 0 : awt::Point aStartPoint, aEndPoint;
910 0 : Reference< XShape > rXShapeA;
911 0 : Reference< XShape > rXShapeB;
912 : PropertyState eState;
913 : ConnectorType eConnectorType;
914 0 : if( GETAD( EdgeKind ) ) {
915 0 : mAny >>= eConnectorType;
916 :
917 0 : switch( eConnectorType ) {
918 : case ConnectorType_CURVE:
919 0 : sGeometry = "curvedConnector3";
920 0 : break;
921 : case ConnectorType_STANDARD:
922 0 : sGeometry = "bentConnector3";
923 0 : break;
924 : default:
925 : case ConnectorType_LINE:
926 : case ConnectorType_LINES:
927 0 : sGeometry = "straightConnector1";
928 0 : break;
929 : }
930 :
931 0 : if( GETAD( EdgeStartPoint ) ) {
932 0 : mAny >>= aStartPoint;
933 0 : if( GETAD( EdgeEndPoint ) ) {
934 0 : mAny >>= aEndPoint;
935 : }
936 : }
937 0 : GET( rXShapeA, EdgeStartConnection );
938 0 : GET( rXShapeB, EdgeEndConnection );
939 : }
940 0 : EscherConnectorListEntry aConnectorEntry( xShape, aStartPoint, rXShapeA, aEndPoint, rXShapeB );
941 :
942 0 : Rectangle aRect( Point( aStartPoint.X, aStartPoint.Y ), Point( aEndPoint.X, aEndPoint.Y ) );
943 0 : if( aRect.getWidth() < 0 ) {
944 0 : bFlipH = sal_True;
945 0 : aRect.setX( aEndPoint.X );
946 0 : aRect.setWidth( aStartPoint.X - aEndPoint.X );
947 : }
948 :
949 0 : if( aRect.getHeight() < 0 ) {
950 0 : bFlipV = sal_True;
951 0 : aRect.setY( aEndPoint.Y );
952 0 : aRect.setHeight( aStartPoint.Y - aEndPoint.Y );
953 : }
954 :
955 0 : pFS->startElementNS( mnXmlNamespace, XML_cxnSp, FSEND );
956 :
957 : // non visual shape properties
958 0 : pFS->startElementNS( mnXmlNamespace, XML_nvCxnSpPr, FSEND );
959 : pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
960 : XML_id, I32S( GetNewShapeID( xShape ) ),
961 0 : XML_name, IDS( Line ),
962 0 : FSEND );
963 : // non visual connector shape drawing properties
964 0 : pFS->startElementNS( mnXmlNamespace, XML_cNvCxnSpPr, FSEND );
965 0 : WriteConnectorConnections( aConnectorEntry, GetShapeID( rXShapeA ), GetShapeID( rXShapeB ) );
966 0 : pFS->endElementNS( mnXmlNamespace, XML_cNvCxnSpPr );
967 0 : pFS->singleElementNS( mnXmlNamespace, XML_nvPr, FSEND );
968 0 : pFS->endElementNS( mnXmlNamespace, XML_nvCxnSpPr );
969 :
970 : // visual shape properties
971 0 : pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
972 0 : WriteTransformation( aRect, XML_a, bFlipH, bFlipV );
973 : // TODO: write adjustments (ppt export doesn't work well there either)
974 0 : WritePresetShape( sGeometry );
975 0 : Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
976 0 : if( xShapeProps.is() )
977 0 : WriteOutline( xShapeProps );
978 0 : pFS->endElementNS( mnXmlNamespace, XML_spPr );
979 :
980 : // write text
981 0 : WriteTextBox( xShape, mnXmlNamespace );
982 :
983 0 : pFS->endElementNS( mnXmlNamespace, XML_cxnSp );
984 :
985 0 : return *this;
986 : }
987 :
988 0 : ShapeExport& ShapeExport::WriteLineShape( Reference< XShape > xShape )
989 : {
990 0 : sal_Bool bFlipH = false;
991 0 : sal_Bool bFlipV = false;
992 :
993 : DBG(printf("write line shape\n"));
994 :
995 0 : FSHelperPtr pFS = GetFS();
996 :
997 0 : pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
998 :
999 0 : PolyPolygon aPolyPolygon = EscherPropertyContainer::GetPolyPolygon( xShape );
1000 0 : if( aPolyPolygon.Count() == 1 && aPolyPolygon[ 0 ].GetSize() == 2)
1001 : {
1002 0 : const Polygon& rPoly = aPolyPolygon[ 0 ];
1003 :
1004 0 : bFlipH = ( rPoly[ 0 ].X() > rPoly[ 1 ].X() );
1005 0 : bFlipV = ( rPoly[ 0 ].Y() > rPoly[ 1 ].Y() );
1006 : }
1007 :
1008 : // non visual shape properties
1009 0 : pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
1010 : pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
1011 : XML_id, I32S( GetNewShapeID( xShape ) ),
1012 0 : XML_name, IDS( Line ),
1013 0 : FSEND );
1014 0 : pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
1015 0 : WriteNonVisualProperties( xShape );
1016 0 : pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
1017 :
1018 : // visual shape properties
1019 0 : pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
1020 0 : WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV, true);
1021 0 : WritePresetShape( "line" );
1022 0 : Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
1023 0 : if( xShapeProps.is() )
1024 0 : WriteOutline( xShapeProps );
1025 0 : pFS->endElementNS( mnXmlNamespace, XML_spPr );
1026 :
1027 : // write text
1028 0 : WriteTextBox( xShape, mnXmlNamespace );
1029 :
1030 0 : pFS->endElementNS( mnXmlNamespace, XML_sp );
1031 :
1032 0 : return *this;
1033 : }
1034 :
1035 0 : ShapeExport& ShapeExport::WriteNonVisualDrawingProperties( Reference< XShape > xShape, const char* pName )
1036 : {
1037 : GetFS()->singleElementNS( mnXmlNamespace, XML_cNvPr,
1038 : XML_id, I32S( GetNewShapeID( xShape ) ),
1039 : XML_name, pName,
1040 0 : FSEND );
1041 :
1042 0 : return *this;
1043 : }
1044 :
1045 0 : ShapeExport& ShapeExport::WriteNonVisualProperties( Reference< XShape > )
1046 : {
1047 : // Override to generate //nvPr elements.
1048 0 : return *this;
1049 : }
1050 :
1051 0 : ShapeExport& ShapeExport::WriteRectangleShape( Reference< XShape > xShape )
1052 : {
1053 : DBG(printf("write rectangle shape\n"));
1054 :
1055 0 : FSHelperPtr pFS = GetFS();
1056 :
1057 0 : pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
1058 :
1059 0 : sal_Int32 nRadius = 0;
1060 :
1061 0 : Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
1062 0 : if( xShapeProps.is() )
1063 : {
1064 0 : xShapeProps->getPropertyValue( S( "CornerRadius" ) ) >>= nRadius;
1065 : }
1066 :
1067 0 : if( nRadius )
1068 : {
1069 0 : nRadius = MapSize( awt::Size( nRadius, 0 ) ).Width;
1070 : }
1071 :
1072 : // non visual shape properties
1073 0 : pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
1074 : pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
1075 : XML_id, I32S( GetNewShapeID( xShape ) ),
1076 0 : XML_name, IDS( Rectangle ),
1077 0 : FSEND );
1078 0 : pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
1079 0 : WriteNonVisualProperties( xShape );
1080 0 : pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
1081 :
1082 : // visual shape properties
1083 0 : pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
1084 0 : WriteShapeTransformation( xShape, XML_a,0,0,false);
1085 0 : WritePresetShape( "rect" );
1086 0 : Reference< XPropertySet > xProps( xShape, UNO_QUERY );
1087 0 : if( xProps.is() )
1088 : {
1089 0 : WriteFill( xProps );
1090 0 : WriteOutline( xProps );
1091 : }
1092 0 : pFS->endElementNS( mnXmlNamespace, XML_spPr );
1093 :
1094 : // write text
1095 0 : WriteTextBox( xShape, mnXmlNamespace );
1096 :
1097 0 : pFS->endElementNS( mnXmlNamespace, XML_sp );
1098 :
1099 0 : return *this;
1100 : }
1101 :
1102 : typedef ShapeExport& (ShapeExport::*ShapeConverter)( Reference< XShape > );
1103 : typedef boost::unordered_map< const char*, ShapeConverter, StringHash, StringCheck> NameToConvertMapType;
1104 :
1105 0 : static const NameToConvertMapType& lcl_GetConverters()
1106 : {
1107 : static bool shape_map_inited = false;
1108 0 : static NameToConvertMapType shape_converters;
1109 0 : if( shape_map_inited )
1110 : {
1111 0 : return shape_converters;
1112 : }
1113 :
1114 0 : shape_converters[ "com.sun.star.drawing.ClosedBezierShape" ] = &ShapeExport::WriteClosedBezierShape;
1115 0 : shape_converters[ "com.sun.star.drawing.ConnectorShape" ] = &ShapeExport::WriteConnectorShape;
1116 0 : shape_converters[ "com.sun.star.drawing.CustomShape" ] = &ShapeExport::WriteCustomShape;
1117 0 : shape_converters[ "com.sun.star.drawing.EllipseShape" ] = &ShapeExport::WriteEllipseShape;
1118 0 : shape_converters[ "com.sun.star.drawing.GraphicObjectShape" ] = &ShapeExport::WriteGraphicObjectShape;
1119 0 : shape_converters[ "com.sun.star.drawing.LineShape" ] = &ShapeExport::WriteLineShape;
1120 0 : shape_converters[ "com.sun.star.drawing.OpenBezierShape" ] = &ShapeExport::WriteOpenBezierShape;
1121 0 : shape_converters[ "com.sun.star.drawing.RectangleShape" ] = &ShapeExport::WriteRectangleShape;
1122 0 : shape_converters[ "com.sun.star.drawing.OLE2Shape" ] = &ShapeExport::WriteOLE2Shape;
1123 0 : shape_converters[ "com.sun.star.drawing.TableShape" ] = &ShapeExport::WriteTableShape;
1124 0 : shape_converters[ "com.sun.star.drawing.TextShape" ] = &ShapeExport::WriteTextShape;
1125 0 : shape_converters[ "com.sun.star.presentation.DateTimeShape" ] = &ShapeExport::WriteTextShape;
1126 0 : shape_converters[ "com.sun.star.presentation.FooterShape" ] = &ShapeExport::WriteTextShape;
1127 0 : shape_converters[ "com.sun.star.presentation.HeaderShape" ] = &ShapeExport::WriteTextShape;
1128 0 : shape_converters[ "com.sun.star.presentation.NotesShape" ] = &ShapeExport::WriteTextShape;
1129 0 : shape_converters[ "com.sun.star.presentation.OutlinerShape" ] = &ShapeExport::WriteTextShape;
1130 0 : shape_converters[ "com.sun.star.presentation.SlideNumberShape" ] = &ShapeExport::WriteTextShape;
1131 0 : shape_converters[ "com.sun.star.presentation.TitleTextShape" ] = &ShapeExport::WriteTextShape;
1132 0 : shape_map_inited = true;
1133 :
1134 0 : return shape_converters;
1135 : }
1136 :
1137 0 : ShapeExport& ShapeExport::WriteShape( Reference< XShape > xShape )
1138 : {
1139 0 : OUString sShapeType = xShape->getShapeType();
1140 : DBG( printf( "write shape: %s\n", USS( sShapeType ) ) );
1141 0 : NameToConvertMapType::const_iterator aConverter = lcl_GetConverters().find( USS( sShapeType ) );
1142 0 : if( aConverter == lcl_GetConverters().end() )
1143 : {
1144 : DBG( printf( "unknown shape\n" ) );
1145 0 : return WriteUnknownShape( xShape );
1146 : }
1147 0 : (this->*(aConverter->second))( xShape );
1148 :
1149 0 : return *this;
1150 : }
1151 :
1152 0 : ShapeExport& ShapeExport::WriteTextBox( Reference< XInterface > xIface, sal_Int32 nXmlNamespace )
1153 : {
1154 0 : if( NonEmptyText( xIface ) )
1155 : {
1156 0 : FSHelperPtr pFS = GetFS();
1157 :
1158 0 : pFS->startElementNS( nXmlNamespace, XML_txBody, FSEND );
1159 0 : WriteText( xIface );
1160 0 : pFS->endElementNS( nXmlNamespace, XML_txBody );
1161 : }
1162 :
1163 0 : return *this;
1164 : }
1165 :
1166 0 : void ShapeExport::WriteTable( Reference< XShape > rXShape )
1167 : {
1168 : OSL_TRACE("write table");
1169 :
1170 0 : Reference< XTable > xTable;
1171 0 : Reference< XPropertySet > xPropSet( rXShape, UNO_QUERY );
1172 :
1173 0 : mpFS->startElementNS( XML_a, XML_graphic, FSEND );
1174 0 : mpFS->startElementNS( XML_a, XML_graphicData, XML_uri, "http://schemas.openxmlformats.org/drawingml/2006/table", FSEND );
1175 :
1176 0 : if ( xPropSet.is() && ( xPropSet->getPropertyValue( S("Model") ) >>= xTable ) )
1177 : {
1178 0 : mpFS->startElementNS( XML_a, XML_tbl, FSEND );
1179 0 : mpFS->singleElementNS( XML_a, XML_tblPr, FSEND );
1180 :
1181 0 : Reference< XColumnRowRange > xColumnRowRange( xTable, UNO_QUERY_THROW );
1182 0 : Reference< container::XIndexAccess > xColumns( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
1183 0 : Reference< container::XIndexAccess > xRows( xColumnRowRange->getRows(), UNO_QUERY_THROW );
1184 0 : sal_uInt16 nRowCount = static_cast< sal_uInt16 >( xRows->getCount() );
1185 0 : sal_uInt16 nColumnCount = static_cast< sal_uInt16 >( xColumns->getCount() );
1186 :
1187 0 : mpFS->startElementNS( XML_a, XML_tblGrid, FSEND );
1188 :
1189 0 : for ( sal_Int32 x = 0; x < nColumnCount; x++ )
1190 : {
1191 0 : Reference< XPropertySet > xColPropSet( xColumns->getByIndex( x ), UNO_QUERY_THROW );
1192 0 : sal_Int32 nWidth(0);
1193 0 : xColPropSet->getPropertyValue( S("Width") ) >>= nWidth;
1194 :
1195 0 : mpFS->singleElementNS( XML_a, XML_gridCol, XML_w, I64S(MM100toEMU(nWidth)), FSEND );
1196 0 : }
1197 :
1198 0 : mpFS->endElementNS( XML_a, XML_tblGrid );
1199 :
1200 0 : Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW );
1201 0 : for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
1202 : {
1203 0 : Reference< XPropertySet > xRowPropSet( xRows->getByIndex( nRow ), UNO_QUERY_THROW );
1204 0 : sal_Int32 nRowHeight(0);
1205 :
1206 0 : xRowPropSet->getPropertyValue( S("Height") ) >>= nRowHeight;
1207 :
1208 0 : mpFS->startElementNS( XML_a, XML_tr, XML_h, I64S( MM100toEMU( nRowHeight ) ), FSEND );
1209 :
1210 0 : for( sal_Int32 nColumn = 0; nColumn < nColumnCount; nColumn++ )
1211 : {
1212 0 : Reference< XMergeableCell > xCell( xCellRange->getCellByPosition( nColumn, nRow ), UNO_QUERY_THROW );
1213 0 : if ( !xCell->isMerged() )
1214 : {
1215 0 : mpFS->startElementNS( XML_a, XML_tc, FSEND );
1216 :
1217 0 : WriteTextBox( xCell, XML_a );
1218 :
1219 0 : mpFS->singleElementNS( XML_a, XML_tcPr, FSEND );
1220 0 : mpFS->endElementNS( XML_a, XML_tc );
1221 : }
1222 0 : }
1223 :
1224 0 : mpFS->endElementNS( XML_a, XML_tr );
1225 0 : }
1226 :
1227 0 : mpFS->endElementNS( XML_a, XML_tbl );
1228 : }
1229 :
1230 0 : mpFS->endElementNS( XML_a, XML_graphicData );
1231 0 : mpFS->endElementNS( XML_a, XML_graphic );
1232 0 : }
1233 :
1234 0 : ShapeExport& ShapeExport::WriteTableShape( Reference< XShape > xShape )
1235 : {
1236 0 : FSHelperPtr pFS = GetFS();
1237 :
1238 : OSL_TRACE("write table shape");
1239 :
1240 0 : pFS->startElementNS( mnXmlNamespace, XML_graphicFrame, FSEND );
1241 :
1242 0 : pFS->startElementNS( mnXmlNamespace, XML_nvGraphicFramePr, FSEND );
1243 :
1244 : pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
1245 : XML_id, I32S( GetNewShapeID( xShape ) ),
1246 0 : XML_name, IDS(Table),
1247 0 : FSEND );
1248 :
1249 : pFS->singleElementNS( mnXmlNamespace, XML_cNvGraphicFramePr,
1250 0 : FSEND );
1251 :
1252 0 : if( GetDocumentType() == DOCUMENT_PPTX )
1253 : pFS->singleElementNS( mnXmlNamespace, XML_nvPr,
1254 0 : FSEND );
1255 0 : pFS->endElementNS( mnXmlNamespace, XML_nvGraphicFramePr );
1256 :
1257 0 : WriteShapeTransformation( xShape, mnXmlNamespace, false);
1258 0 : WriteTable( xShape );
1259 :
1260 0 : pFS->endElementNS( mnXmlNamespace, XML_graphicFrame );
1261 :
1262 0 : return *this;
1263 : }
1264 :
1265 0 : ShapeExport& ShapeExport::WriteTextShape( Reference< XShape > xShape )
1266 : {
1267 0 : FSHelperPtr pFS = GetFS();
1268 :
1269 0 : pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
1270 :
1271 : // non visual shape properties
1272 0 : pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
1273 0 : WriteNonVisualDrawingProperties( xShape, IDS( TextShape ) );
1274 0 : pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, XML_txBox, "1", FSEND );
1275 0 : WriteNonVisualProperties( xShape );
1276 0 : pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
1277 :
1278 : // visual shape properties
1279 0 : pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
1280 0 : WriteShapeTransformation( xShape, XML_a,0,0,false);
1281 0 : WritePresetShape( "rect" );
1282 0 : WriteBlipFill( Reference< XPropertySet >(xShape, UNO_QUERY ), S( "GraphicURL" ) );
1283 0 : pFS->endElementNS( mnXmlNamespace, XML_spPr );
1284 :
1285 0 : WriteTextBox( xShape, mnXmlNamespace );
1286 :
1287 0 : pFS->endElementNS( mnXmlNamespace, XML_sp );
1288 :
1289 0 : return *this;
1290 : }
1291 :
1292 0 : ShapeExport& ShapeExport::WriteOLE2Shape( Reference< XShape > xShape )
1293 : {
1294 0 : Reference< XPropertySet > xPropSet( xShape, UNO_QUERY );
1295 0 : if( xPropSet.is() ) {
1296 0 : if( GetProperty( xPropSet, S("Model") ) )
1297 : {
1298 0 : Reference< XChartDocument > xChartDoc;
1299 0 : mAny >>= xChartDoc;
1300 0 : if( xChartDoc.is() )
1301 : {
1302 : //export the chart
1303 0 : Reference< XModel > xModel( xChartDoc, UNO_QUERY );
1304 0 : ChartExport aChartExport( mnXmlNamespace, GetFS(), xModel, GetFB(), GetDocumentType() );
1305 : static sal_Int32 nChartCount = 0;
1306 0 : aChartExport.WriteChartObj( xShape, ++nChartCount );
1307 : }
1308 : else
1309 : {
1310 : // this part now supports only embedded spreadsheets, it can be extended to support remaining ooxml documents
1311 : // only exporter, counter and object filename are specific to spreadsheet
1312 0 : Reference< XSpreadsheetDocument > xSheetDoc( mAny, UNO_QUERY );
1313 0 : if( xSheetDoc.is() )
1314 : {
1315 0 : Reference< XComponent > xDocument( mAny, UNO_QUERY );
1316 0 : Reference< XExporter > xExporter( mpFB->getServiceFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.comp.oox.ExcelFilterExport" ) ), UNO_QUERY );
1317 0 : if( xDocument.is() && xExporter.is() && mpFB )
1318 : {
1319 : Reference< XOutputStream > xOutStream = mpFB->openFragmentStream( OUStringBuffer()
1320 0 : .appendAscii( GetComponentDir() )
1321 0 : .appendAscii( "/embeddings/spreadsheet" )
1322 0 : .append( (sal_Int32) mnSpreadsheetCounter )
1323 0 : .appendAscii( ".xlsx" )
1324 : .makeStringAndClear(),
1325 0 : S("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") );
1326 : // export the embedded document
1327 0 : Sequence< PropertyValue > rMedia(1);
1328 :
1329 0 : rMedia[0].Name = MediaDescriptor::PROP_STREAMFOROUTPUT();
1330 0 : rMedia[0].Value <<= xOutStream;
1331 :
1332 0 : Reference< XFilter > xFilter( xExporter, UNO_QUERY );
1333 :
1334 0 : if( xFilter.is() )
1335 : {
1336 0 : xExporter->setSourceDocument( xDocument );
1337 0 : xFilter->filter( rMedia );
1338 : }
1339 :
1340 0 : xOutStream->closeOutput();
1341 :
1342 : OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(),
1343 : US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package" ),
1344 : OUStringBuffer()
1345 0 : .appendAscii( GetRelationCompPrefix() )
1346 0 : .appendAscii( "embeddings/spreadsheet" )
1347 0 : .append( (sal_Int32) mnSpreadsheetCounter ++ )
1348 0 : .appendAscii( ".xlsx" )
1349 0 : .makeStringAndClear() );
1350 :
1351 0 : mpFS->startElementNS( mnXmlNamespace, XML_graphicFrame, FSEND );
1352 :
1353 0 : mpFS->startElementNS( mnXmlNamespace, XML_nvGraphicFramePr, FSEND );
1354 :
1355 : mpFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
1356 : XML_id, I32S( GetNewShapeID( xShape ) ),
1357 0 : XML_name, IDS(Object),
1358 0 : FSEND );
1359 :
1360 : mpFS->singleElementNS( mnXmlNamespace, XML_cNvGraphicFramePr,
1361 0 : FSEND );
1362 :
1363 0 : if( GetDocumentType() == DOCUMENT_PPTX )
1364 : mpFS->singleElementNS( mnXmlNamespace, XML_nvPr,
1365 0 : FSEND );
1366 0 : mpFS->endElementNS( mnXmlNamespace, XML_nvGraphicFramePr );
1367 :
1368 0 : WriteShapeTransformation( xShape, mnXmlNamespace );
1369 :
1370 0 : mpFS->startElementNS( XML_a, XML_graphic, FSEND );
1371 : mpFS->startElementNS( XML_a, XML_graphicData,
1372 : XML_uri, "http://schemas.openxmlformats.org/presentationml/2006/ole",
1373 0 : FSEND );
1374 : mpFS->startElementNS( mnXmlNamespace, XML_oleObj,
1375 : XML_name, "Spreadsheet",
1376 : FSNS(XML_r, XML_id), USS( sRelId ),
1377 0 : FSEND );
1378 :
1379 0 : mpFS->singleElementNS( mnXmlNamespace, XML_embed, FSEND );
1380 :
1381 : // pic element
1382 0 : SdrObject* pSdrOLE2( GetSdrObjectFromXShape( xShape ) );
1383 0 : if ( pSdrOLE2 && pSdrOLE2->ISA( SdrOle2Obj ) )
1384 : {
1385 0 : Graphic* pGraphic = ((SdrOle2Obj*)pSdrOLE2)->GetGraphic();
1386 0 : if ( pGraphic )
1387 0 : WriteGraphicObjectShapePart( xShape, pGraphic );
1388 : }
1389 :
1390 0 : mpFS->endElementNS( mnXmlNamespace, XML_oleObj );
1391 :
1392 0 : mpFS->endElementNS( XML_a, XML_graphicData );
1393 0 : mpFS->endElementNS( XML_a, XML_graphic );
1394 :
1395 0 : mpFS->endElementNS( mnXmlNamespace, XML_graphicFrame );
1396 0 : }
1397 0 : }
1398 0 : }
1399 : }
1400 : }
1401 0 : return *this;
1402 : }
1403 :
1404 0 : ShapeExport& ShapeExport::WriteUnknownShape( Reference< XShape > )
1405 : {
1406 : // Override this method to do something useful.
1407 0 : return *this;
1408 : }
1409 :
1410 0 : size_t ShapeExport::ShapeHash::operator()( const Reference < XShape > rXShape ) const
1411 : {
1412 0 : return rXShape->getShapeType().hashCode();
1413 : }
1414 :
1415 0 : sal_Int32 ShapeExport::GetNewShapeID( const Reference< XShape > rXShape )
1416 : {
1417 0 : return GetNewShapeID( rXShape, GetFB() );
1418 : }
1419 :
1420 0 : sal_Int32 ShapeExport::GetNewShapeID( const Reference< XShape > rXShape, XmlFilterBase* pFB )
1421 : {
1422 0 : if( !rXShape.is() )
1423 0 : return -1;
1424 :
1425 0 : sal_Int32 nID = pFB->GetUniqueId();
1426 :
1427 0 : (*mpShapeMap)[ rXShape ] = nID;
1428 :
1429 0 : return nID;
1430 : }
1431 :
1432 0 : sal_Int32 ShapeExport::GetShapeID( const Reference< XShape > rXShape )
1433 : {
1434 0 : return GetShapeID( rXShape, mpShapeMap );
1435 : }
1436 :
1437 0 : sal_Int32 ShapeExport::GetShapeID( const Reference< XShape > rXShape, ShapeHashMap* pShapeMap )
1438 : {
1439 0 : if( !rXShape.is() )
1440 0 : return -1;
1441 :
1442 0 : ShapeHashMap::const_iterator aIter = pShapeMap->find( rXShape );
1443 :
1444 0 : if( aIter == pShapeMap->end() )
1445 0 : return -1;
1446 :
1447 0 : return aIter->second;
1448 : }
1449 :
1450 51 : } }
1451 :
1452 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|