1ca5ec200SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3ca5ec200SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4ca5ec200SAndrew Rist * or more contributor license agreements. See the NOTICE file
5ca5ec200SAndrew Rist * distributed with this work for additional information
6ca5ec200SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7ca5ec200SAndrew Rist * to you under the Apache License, Version 2.0 (the
8ca5ec200SAndrew Rist * "License"); you may not use this file except in compliance
9ca5ec200SAndrew Rist * with the License. You may obtain a copy of the License at
10ca5ec200SAndrew Rist *
11ca5ec200SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12ca5ec200SAndrew Rist *
13ca5ec200SAndrew Rist * Unless required by applicable law or agreed to in writing,
14ca5ec200SAndrew Rist * software distributed under the License is distributed on an
15ca5ec200SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ca5ec200SAndrew Rist * KIND, either express or implied. See the License for the
17ca5ec200SAndrew Rist * specific language governing permissions and limitations
18ca5ec200SAndrew Rist * under the License.
19ca5ec200SAndrew Rist *
20ca5ec200SAndrew Rist *************************************************************/
21ca5ec200SAndrew Rist
22ca5ec200SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include "oox/core/xmlfilterbase.hxx"
25cdf0e10cSrcweir #include "oox/export/shapes.hxx"
26cdf0e10cSrcweir #include "oox/export/utils.hxx"
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <cstdio>
29cdf0e10cSrcweir #include <com/sun/star/awt/CharSet.hpp>
30cdf0e10cSrcweir #include <com/sun/star/awt/FontDescriptor.hpp>
31cdf0e10cSrcweir #include <com/sun/star/awt/FontSlant.hpp>
32cdf0e10cSrcweir #include <com/sun/star/awt/FontWeight.hpp>
33cdf0e10cSrcweir #include <com/sun/star/awt/FontUnderline.hpp>
34cdf0e10cSrcweir #include <com/sun/star/awt/Gradient.hpp>
35cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
36cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp>
37cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp>
38cdf0e10cSrcweir #include <com/sun/star/drawing/FillStyle.hpp>
39cdf0e10cSrcweir #include <com/sun/star/drawing/BitmapMode.hpp>
40cdf0e10cSrcweir #include <com/sun/star/drawing/ConnectorType.hpp>
41cdf0e10cSrcweir #include <com/sun/star/drawing/LineDash.hpp>
42cdf0e10cSrcweir #include <com/sun/star/drawing/LineJoint.hpp>
43cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp>
44cdf0e10cSrcweir #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
45cdf0e10cSrcweir #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
46cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hpp>
47cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
48cdf0e10cSrcweir #include <com/sun/star/style/ParagraphAdjust.hpp>
49cdf0e10cSrcweir #include <com/sun/star/text/XSimpleText.hpp>
50cdf0e10cSrcweir #include <com/sun/star/text/XText.hpp>
51cdf0e10cSrcweir #include <com/sun/star/text/XTextContent.hpp>
52cdf0e10cSrcweir #include <com/sun/star/text/XTextField.hpp>
53cdf0e10cSrcweir #include <com/sun/star/text/XTextRange.hpp>
54cdf0e10cSrcweir #include <tools/stream.hxx>
55cdf0e10cSrcweir #include <tools/string.hxx>
56cdf0e10cSrcweir #include <vcl/cvtgrf.hxx>
57cdf0e10cSrcweir #include <unotools/fontcvt.hxx>
58cdf0e10cSrcweir #include <vcl/graph.hxx>
59cdf0e10cSrcweir #include <vcl/outdev.hxx>
60cdf0e10cSrcweir #include <svtools/grfmgr.hxx>
61cdf0e10cSrcweir #include <rtl/strbuf.hxx>
62cdf0e10cSrcweir #include <sfx2/app.hxx>
63cdf0e10cSrcweir #include <svl/languageoptions.hxx>
64cdf0e10cSrcweir #include <svx/escherex.hxx>
65cdf0e10cSrcweir #include <svx/svdoashp.hxx>
66cdf0e10cSrcweir #include <svx/svxenum.hxx>
67cdf0e10cSrcweir #include <svx/unoapi.hxx>
68cdf0e10cSrcweir
69cdf0e10cSrcweir using namespace ::com::sun::star;
70cdf0e10cSrcweir using namespace ::com::sun::star::uno;
71cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
72cdf0e10cSrcweir using namespace ::com::sun::star::i18n;
73cdf0e10cSrcweir using ::com::sun::star::beans::PropertyState;
74cdf0e10cSrcweir using ::com::sun::star::beans::PropertyValue;
75cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet;
76cdf0e10cSrcweir using ::com::sun::star::beans::XPropertyState;
77cdf0e10cSrcweir using ::com::sun::star::container::XEnumeration;
78cdf0e10cSrcweir using ::com::sun::star::container::XEnumerationAccess;
79cdf0e10cSrcweir using ::com::sun::star::container::XIndexAccess;
80cdf0e10cSrcweir using ::com::sun::star::drawing::FillStyle;
81cdf0e10cSrcweir using ::com::sun::star::io::XOutputStream;
82cdf0e10cSrcweir using ::com::sun::star::text::XSimpleText;
83cdf0e10cSrcweir using ::com::sun::star::text::XText;
84cdf0e10cSrcweir using ::com::sun::star::text::XTextContent;
85cdf0e10cSrcweir using ::com::sun::star::text::XTextField;
86cdf0e10cSrcweir using ::com::sun::star::text::XTextRange;
87cdf0e10cSrcweir using ::rtl::OString;
88cdf0e10cSrcweir using ::rtl::OStringBuffer;
89cdf0e10cSrcweir using ::rtl::OUString;
90cdf0e10cSrcweir using ::rtl::OUStringBuffer;
91cdf0e10cSrcweir using ::sax_fastparser::FSHelperPtr;
92cdf0e10cSrcweir
93cdf0e10cSrcweir DBG(extern void dump_pset(Reference< XPropertySet > rXPropSet));
94cdf0e10cSrcweir
95cdf0e10cSrcweir #define IDS(x) (OString(#x " ") + OString::valueOf( mnShapeIdMax++ )).getStr()
96cdf0e10cSrcweir
97cdf0e10cSrcweir struct CustomShapeTypeTranslationTable
98cdf0e10cSrcweir {
99cdf0e10cSrcweir const char* sOOo;
100cdf0e10cSrcweir const char* sMSO;
101cdf0e10cSrcweir };
102cdf0e10cSrcweir
103cdf0e10cSrcweir static const CustomShapeTypeTranslationTable pCustomShapeTypeTranslationTable[] =
104cdf0e10cSrcweir {
105cdf0e10cSrcweir // { "non-primitive", mso_sptMin },
106cdf0e10cSrcweir { "rectangle", "rect" },
107cdf0e10cSrcweir { "round-rectangle", "roundRect" },
108cdf0e10cSrcweir { "ellipse", "ellipse" },
109cdf0e10cSrcweir { "diamond", "diamond" },
110cdf0e10cSrcweir { "isosceles-triangle", "triangle" },
111cdf0e10cSrcweir { "right-triangle", "rtTriangle" },
112cdf0e10cSrcweir { "parallelogram", "parallelogram" },
113cdf0e10cSrcweir { "trapezoid", "trapezoid" },
114cdf0e10cSrcweir { "hexagon", "hexagon" },
115cdf0e10cSrcweir { "octagon", "octagon" },
116cdf0e10cSrcweir { "cross", "plus" },
117cdf0e10cSrcweir { "star5", "star5" },
118cdf0e10cSrcweir { "right-arrow", "rightArrow" },
119cdf0e10cSrcweir // { "mso-spt14", mso_sptThickArrow },
120cdf0e10cSrcweir { "pentagon-right", "homePlate" },
121cdf0e10cSrcweir { "cube", "cube" },
122cdf0e10cSrcweir // { "mso-spt17", mso_sptBalloon },
123cdf0e10cSrcweir // { "mso-spt18", mso_sptSeal },
124cdf0e10cSrcweir { "mso-spt19", "arc" },
125cdf0e10cSrcweir { "mso-spt20", "line" },
126cdf0e10cSrcweir { "mso-spt21", "plaque" },
127cdf0e10cSrcweir { "can", "can" },
128cdf0e10cSrcweir { "ring", "donut" },
129cdf0e10cSrcweir { "mso-spt24", "textSimple" },
130cdf0e10cSrcweir { "mso-spt25", "textOctagon" },
131cdf0e10cSrcweir { "mso-spt26", "textHexagon" },
132cdf0e10cSrcweir { "mso-spt27", "textCurve" },
133cdf0e10cSrcweir { "mso-spt28", "textWave" },
134cdf0e10cSrcweir { "mso-spt29", "textRing" },
135cdf0e10cSrcweir { "mso-spt30", "textOnCurve" },
136cdf0e10cSrcweir { "mso-spt31", "textOnRing" },
137cdf0e10cSrcweir { "mso-spt32", "straightConnector1" },
138cdf0e10cSrcweir { "mso-spt33", "bentConnector2" },
139cdf0e10cSrcweir { "mso-spt34", "bentConnector3" },
140cdf0e10cSrcweir { "mso-spt35", "bentConnector4" },
141cdf0e10cSrcweir { "mso-spt36", "bentConnector5" },
142cdf0e10cSrcweir { "mso-spt37", "curvedConnector2" },
143cdf0e10cSrcweir { "mso-spt38", "curvedConnector3" },
144cdf0e10cSrcweir { "mso-spt39", "curvedConnector4" },
145cdf0e10cSrcweir { "mso-spt40", "curvedConnector5" },
146cdf0e10cSrcweir { "mso-spt41", "callout1" },
147cdf0e10cSrcweir { "mso-spt42", "callout2" },
148cdf0e10cSrcweir { "mso-spt43", "callout3" },
149cdf0e10cSrcweir { "mso-spt44", "accentCallout1" },
150cdf0e10cSrcweir { "mso-spt45", "accentCallout2" },
151cdf0e10cSrcweir { "mso-spt46", "accentCallout3" },
152cdf0e10cSrcweir { "line-callout-1", "borderCallout1" },
153cdf0e10cSrcweir { "line-callout-2", "borderCallout2" },
154cdf0e10cSrcweir { "line-callout-3", "borderCallout3" },
155cdf0e10cSrcweir { "mso-spt49", "accentBorderCallout90" },
156cdf0e10cSrcweir { "mso-spt50", "accentBorderCallout1" },
157cdf0e10cSrcweir { "mso-spt51", "accentBorderCallout2" },
158cdf0e10cSrcweir { "mso-spt52", "accentBorderCallout3" },
159cdf0e10cSrcweir { "mso-spt53", "ribbon" },
160cdf0e10cSrcweir { "mso-spt54", "ribbon2" },
161cdf0e10cSrcweir { "chevron", "chevron" },
162cdf0e10cSrcweir { "pentagon", "pentagon" },
163cdf0e10cSrcweir { "forbidden", "noSmoking" },
164cdf0e10cSrcweir { "star8", "seal8" },
165cdf0e10cSrcweir { "mso-spt59", "seal16" },
166cdf0e10cSrcweir { "mso-spt60", "seal32" },
167cdf0e10cSrcweir { "rectangular-callout", "wedgeRectCallout" },
168cdf0e10cSrcweir { "round-rectangular-callout", "wedgeRoundRectCallout" },
169cdf0e10cSrcweir { "round-callout", "wedgeEllipseCallout" },
170cdf0e10cSrcweir { "mso-spt64", "wave" },
171cdf0e10cSrcweir { "paper", "foldedCorner" },
172cdf0e10cSrcweir { "left-arrow", "leftArrow" },
173cdf0e10cSrcweir { "down-arrow", "downArrow" },
174cdf0e10cSrcweir { "up-arrow", "upArrow" },
175cdf0e10cSrcweir { "left-right-arrow", "leftRightArrow" },
176cdf0e10cSrcweir { "up-down-arrow", "upDownArrow" },
177cdf0e10cSrcweir { "mso-spt71", "irregularSeal1" },
178cdf0e10cSrcweir { "bang", "irregularSeal2" },
179cdf0e10cSrcweir { "lightning", "lightningBolt" },
180cdf0e10cSrcweir { "heart", "heart" },
181cdf0e10cSrcweir { "mso-spt75", "pictureFrame" },
182cdf0e10cSrcweir { "quad-arrow", "quadArrow" },
183cdf0e10cSrcweir { "left-arrow-callout", "leftArrowCallout" },
184cdf0e10cSrcweir { "right-arrow-callout", "rightArrowCallout" },
185cdf0e10cSrcweir { "up-arrow-callout", "upArrowCallout" },
186cdf0e10cSrcweir { "down-arrow-callout", "downArrowCallout" },
187cdf0e10cSrcweir { "left-right-arrow-callout", "leftRightArrowCallout" },
188cdf0e10cSrcweir { "up-down-arrow-callout", "upDownArrowCallout" },
189cdf0e10cSrcweir { "quad-arrow-callout", "quadArrowCallout" },
190cdf0e10cSrcweir { "quad-bevel", "bevel" },
191cdf0e10cSrcweir { "left-bracket", "leftBracket" },
192cdf0e10cSrcweir { "right-bracket", "rightBracket" },
193cdf0e10cSrcweir { "left-brace", "leftBrace" },
194cdf0e10cSrcweir { "right-brace", "rightBrace" },
195cdf0e10cSrcweir { "mso-spt89", "leftUpArrow" },
196cdf0e10cSrcweir { "mso-spt90", "bentUpArrow" },
197cdf0e10cSrcweir { "mso-spt91", "bentArrow" },
198cdf0e10cSrcweir { "star24", "seal24" },
199cdf0e10cSrcweir { "striped-right-arrow", "stripedRightArrow" },
200cdf0e10cSrcweir { "notched-right-arrow", "notchedRightArrow" },
201cdf0e10cSrcweir { "block-arc", "blockArc" },
202cdf0e10cSrcweir { "smiley", "smileyFace" },
203cdf0e10cSrcweir { "vertical-scroll", "verticalScroll" },
204cdf0e10cSrcweir { "horizontal-scroll", "horizontalScroll" },
205cdf0e10cSrcweir { "circular-arrow", "circularArrow" },
206cdf0e10cSrcweir { "mso-spt100", "pie" }, // looks like MSO_SPT is wrong here
207cdf0e10cSrcweir { "mso-spt101", "uturnArrow" },
208cdf0e10cSrcweir { "mso-spt102", "curvedRightArrow" },
209cdf0e10cSrcweir { "mso-spt103", "curvedLeftArrow" },
210cdf0e10cSrcweir { "mso-spt104", "curvedUpArrow" },
211cdf0e10cSrcweir { "mso-spt105", "curvedDownArrow" },
212cdf0e10cSrcweir { "cloud-callout", "cloudCallout" },
213cdf0e10cSrcweir { "mso-spt107", "ellipseRibbon" },
214cdf0e10cSrcweir { "mso-spt108", "ellipseRibbon2" },
215cdf0e10cSrcweir { "flowchart-process", "flowChartProcess" },
216cdf0e10cSrcweir { "flowchart-decision", "flowChartDecision" },
217cdf0e10cSrcweir { "flowchart-data", "flowChartInputOutput" },
218cdf0e10cSrcweir { "flowchart-predefined-process", "flowChartPredefinedProcess" },
219cdf0e10cSrcweir { "flowchart-internal-storage", "flowChartInternalStorage" },
220cdf0e10cSrcweir { "flowchart-document", "flowChartDocument" },
221cdf0e10cSrcweir { "flowchart-multidocument", "flowChartMultidocument" },
222cdf0e10cSrcweir { "flowchart-terminator", "flowChartTerminator" },
223cdf0e10cSrcweir { "flowchart-preparation", "flowChartPreparation" },
224cdf0e10cSrcweir { "flowchart-manual-input", "flowChartManualInput" },
225cdf0e10cSrcweir { "flowchart-manual-operation", "flowChartManualOperation" },
226cdf0e10cSrcweir { "flowchart-connector", "flowChartConnector" },
227cdf0e10cSrcweir { "flowchart-card", "flowChartPunchedCard" },
228cdf0e10cSrcweir { "flowchart-punched-tape", "flowChartPunchedTape" },
229cdf0e10cSrcweir { "flowchart-summing-junction", "flowChartSummingJunction" },
230cdf0e10cSrcweir { "flowchart-or", "flowChartOr" },
231cdf0e10cSrcweir { "flowchart-collate", "flowChartCollate" },
232cdf0e10cSrcweir { "flowchart-sort", "flowChartSort" },
233cdf0e10cSrcweir { "flowchart-extract", "flowChartExtract" },
234cdf0e10cSrcweir { "flowchart-merge", "flowChartMerge" },
235cdf0e10cSrcweir { "mso-spt129", "flowChartOfflineStorage" },
236cdf0e10cSrcweir { "flowchart-stored-data", "flowChartOnlineStorage" },
237cdf0e10cSrcweir { "flowchart-sequential-access", "flowChartMagneticTape" },
238cdf0e10cSrcweir { "flowchart-magnetic-disk", "flowChartMagneticDisk" },
239cdf0e10cSrcweir { "flowchart-direct-access-storage", "flowChartMagneticDrum" },
240cdf0e10cSrcweir { "flowchart-display", "flowChartDisplay" },
241cdf0e10cSrcweir { "flowchart-delay", "flowChartDelay" },
242cdf0e10cSrcweir { "fontwork-plain-text", "textPlainText" },
243cdf0e10cSrcweir { "fontwork-stop", "textStop" },
244cdf0e10cSrcweir { "fontwork-triangle-up", "textTriangle" },
245cdf0e10cSrcweir { "fontwork-triangle-down", "textTriangleInverted" },
246cdf0e10cSrcweir { "fontwork-chevron-up", "textChevron" },
247cdf0e10cSrcweir { "fontwork-chevron-down", "textChevronInverted" },
248cdf0e10cSrcweir { "mso-spt142", "textRingInside" },
249cdf0e10cSrcweir { "mso-spt143", "textRingOutside" },
250cdf0e10cSrcweir { "fontwork-arch-up-curve", "textArchUpCurve" },
251cdf0e10cSrcweir { "fontwork-arch-down-curve", "textArchDownCurve" },
252cdf0e10cSrcweir { "fontwork-circle-curve", "textCircleCurve" },
253cdf0e10cSrcweir { "fontwork-open-circle-curve", "textButtonCurve" },
254cdf0e10cSrcweir { "fontwork-arch-up-pour", "textArchUpPour" },
255cdf0e10cSrcweir { "fontwork-arch-down-pour", "textArchDownPour" },
256cdf0e10cSrcweir { "fontwork-circle-pour", "textCirclePour" },
257cdf0e10cSrcweir { "fontwork-open-circle-pour", "textButtonPour" },
258cdf0e10cSrcweir { "fontwork-curve-up", "textCurveUp" },
259cdf0e10cSrcweir { "fontwork-curve-down", "textCurveDown" },
260cdf0e10cSrcweir { "fontwork-fade-up-and-right", "textCascadeUp" },
261cdf0e10cSrcweir { "fontwork-fade-up-and-left", "textCascadeDown" },
262cdf0e10cSrcweir { "fontwork-wave", "textWave1" },
263cdf0e10cSrcweir { "mso-spt157", "textWave2" },
264cdf0e10cSrcweir { "mso-spt158", "textWave3" },
265cdf0e10cSrcweir { "mso-spt159", "textWave4" },
266cdf0e10cSrcweir { "fontwork-inflate", "textInflate" },
267cdf0e10cSrcweir { "mso-spt161", "textDeflate" },
268cdf0e10cSrcweir { "mso-spt162", "textInflateBottom" },
269cdf0e10cSrcweir { "mso-spt163", "textDeflateBottom" },
270cdf0e10cSrcweir { "mso-spt164", "textInflateTop" },
271cdf0e10cSrcweir { "mso-spt165", "textDeflateTop" },
272cdf0e10cSrcweir { "mso-spt166", "textDeflateInflate" },
273cdf0e10cSrcweir { "mso-spt167", "textDeflateInflateDeflate" },
274cdf0e10cSrcweir { "fontwork-fade-right", "textFadeRight" },
275cdf0e10cSrcweir { "fontwork-fade-left", "textFadeLeft" },
276cdf0e10cSrcweir { "fontwork-fade-up", "textFadeUp" },
277cdf0e10cSrcweir { "fontwork-fade-down", "textFadeDown" },
278cdf0e10cSrcweir { "fontwork-slant-up", "textSlantUp" },
279cdf0e10cSrcweir { "fontwork-slant-down", "textSlantDown" },
280cdf0e10cSrcweir { "mso-spt174", "textCanUp" },
281cdf0e10cSrcweir { "mso-spt175", "textCanDown" },
282cdf0e10cSrcweir { "flowchart-alternate-process", "flowChartAlternateProcess" },
283cdf0e10cSrcweir { "flowchart-off-page-connector", "flowChartOffpageConnector" },
284cdf0e10cSrcweir { "mso-spt178", "callout90" },
285cdf0e10cSrcweir { "mso-spt179", "accentCallout90" },
286cdf0e10cSrcweir { "mso-spt180", "borderCallout90" },
287cdf0e10cSrcweir { "mso-spt182", "leftRightUpArrow" },
288cdf0e10cSrcweir { "sun", "sun" },
289cdf0e10cSrcweir { "moon", "moon" },
290cdf0e10cSrcweir { "bracket-pair", "bracketPair" },
291cdf0e10cSrcweir { "brace-pair", "bracePair" },
292cdf0e10cSrcweir { "star4", "seal4" },
293cdf0e10cSrcweir { "mso-spt188", "doubleWave" },
294cdf0e10cSrcweir { "mso-spt189", "actionButtonBlank" },
295cdf0e10cSrcweir { "mso-spt190", "actionButtonHome" },
296cdf0e10cSrcweir { "mso-spt191", "actionButtonHelp" },
297cdf0e10cSrcweir { "mso-spt192", "actionButtonInformation" },
298cdf0e10cSrcweir { "mso-spt193", "actionButtonForwardNext" },
299cdf0e10cSrcweir { "mso-spt194", "actionButtonBackPrevious" },
300cdf0e10cSrcweir { "mso-spt195", "actionButtonEnd" },
301cdf0e10cSrcweir { "mso-spt196", "actionButtonBeginning" },
302cdf0e10cSrcweir { "mso-spt197", "actionButtonReturn" },
303cdf0e10cSrcweir { "mso-spt198", "actionButtonDocument" },
304cdf0e10cSrcweir { "mso-spt199", "actionButtonSound" },
305cdf0e10cSrcweir { "mso-spt200", "actionButtonMovie" },
306cdf0e10cSrcweir { "mso-spt201", "hostControl" },
307cdf0e10cSrcweir { "mso-spt202", "rect" }
308cdf0e10cSrcweir };
309cdf0e10cSrcweir
310*fda69661SHerbert Dürr typedef std::hash_map< const char*, const char*, CStringHash, CStringEqual> CustomShapeTypeTranslationHashMap;
311cdf0e10cSrcweir static CustomShapeTypeTranslationHashMap* pCustomShapeTypeTranslationHashMap = NULL;
312cdf0e10cSrcweir
lcl_GetPresetGeometry(const char * sShapeType)313cdf0e10cSrcweir static const char* lcl_GetPresetGeometry( const char* sShapeType )
314cdf0e10cSrcweir {
315cdf0e10cSrcweir const char* sPresetGeo;
316cdf0e10cSrcweir
317cdf0e10cSrcweir if( pCustomShapeTypeTranslationHashMap == NULL )
318cdf0e10cSrcweir {
319cdf0e10cSrcweir pCustomShapeTypeTranslationHashMap = new CustomShapeTypeTranslationHashMap ();
320cdf0e10cSrcweir for( unsigned int i = 0; i < sizeof( pCustomShapeTypeTranslationTable )/sizeof( CustomShapeTypeTranslationTable ); i ++ )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir (*pCustomShapeTypeTranslationHashMap)[ pCustomShapeTypeTranslationTable[ i ].sOOo ] = pCustomShapeTypeTranslationTable[ i ].sMSO;
323cdf0e10cSrcweir //DBG(printf("type OOo: %s MSO: %s\n", pCustomShapeTypeTranslationTable[ i ].sOOo, pCustomShapeTypeTranslationTable[ i ].sMSO));
324cdf0e10cSrcweir }
325cdf0e10cSrcweir }
326cdf0e10cSrcweir
327cdf0e10cSrcweir sPresetGeo = (*pCustomShapeTypeTranslationHashMap)[ sShapeType ];
328cdf0e10cSrcweir
329cdf0e10cSrcweir if( sPresetGeo == NULL )
330cdf0e10cSrcweir sPresetGeo = "rect";
331cdf0e10cSrcweir
332cdf0e10cSrcweir return sPresetGeo;
333cdf0e10cSrcweir }
334cdf0e10cSrcweir
335cdf0e10cSrcweir namespace oox { namespace drawingml {
336cdf0e10cSrcweir
337cdf0e10cSrcweir #define GETA(propName) \
338cdf0e10cSrcweir GetProperty( rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( #propName ) ) )
339cdf0e10cSrcweir
340cdf0e10cSrcweir #define GETAD(propName) \
341cdf0e10cSrcweir ( GetPropertyAndState( rXPropSet, rXPropState, String( RTL_CONSTASCII_USTRINGPARAM( #propName ) ), eState ) && eState == beans::PropertyState_DIRECT_VALUE )
342cdf0e10cSrcweir
343cdf0e10cSrcweir #define GET(variable, propName) \
344cdf0e10cSrcweir if ( GETA(propName) ) \
345cdf0e10cSrcweir mAny >>= variable;
346cdf0e10cSrcweir
ShapeExport(sal_Int32 nXmlNamespace,FSHelperPtr pFS,::oox::core::XmlFilterBase * pFB,DocumentType eDocumentType)347cdf0e10cSrcweir ShapeExport::ShapeExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB, DocumentType eDocumentType )
348cdf0e10cSrcweir : DrawingML( pFS, pFB, eDocumentType )
349cdf0e10cSrcweir , mnXmlNamespace( nXmlNamespace )
350cdf0e10cSrcweir , mnShapeIdMax( 1 )
351cdf0e10cSrcweir , mnPictureIdMax( 1 )
352cdf0e10cSrcweir , maFraction( 1, 576 )
353cdf0e10cSrcweir , maMapModeSrc( MAP_100TH_MM )
354cdf0e10cSrcweir , maMapModeDest( MAP_INCH, Point(), maFraction, maFraction )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir }
357cdf0e10cSrcweir
GetXmlNamespace() const358cdf0e10cSrcweir sal_Int32 ShapeExport::GetXmlNamespace() const
359cdf0e10cSrcweir {
360cdf0e10cSrcweir return mnXmlNamespace;
361cdf0e10cSrcweir }
362cdf0e10cSrcweir
SetXmlNamespace(sal_Int32 nXmlNamespace)363cdf0e10cSrcweir ShapeExport& ShapeExport::SetXmlNamespace( sal_Int32 nXmlNamespace )
364cdf0e10cSrcweir {
365cdf0e10cSrcweir mnXmlNamespace = nXmlNamespace;
366cdf0e10cSrcweir return *this;
367cdf0e10cSrcweir }
368cdf0e10cSrcweir
MapSize(const awt::Size & rSize) const369cdf0e10cSrcweir awt::Size ShapeExport::MapSize( const awt::Size& rSize ) const
370cdf0e10cSrcweir {
371cdf0e10cSrcweir Size aRetSize( OutputDevice::LogicToLogic( Size( rSize.Width, rSize.Height ), maMapModeSrc, maMapModeDest ) );
372cdf0e10cSrcweir
373cdf0e10cSrcweir if ( !aRetSize.Width() )
374cdf0e10cSrcweir aRetSize.Width()++;
375cdf0e10cSrcweir if ( !aRetSize.Height() )
376cdf0e10cSrcweir aRetSize.Height()++;
377cdf0e10cSrcweir return awt::Size( aRetSize.Width(), aRetSize.Height() );
378cdf0e10cSrcweir }
379cdf0e10cSrcweir
NonEmptyText(Reference<XShape> xShape)380cdf0e10cSrcweir sal_Bool ShapeExport::NonEmptyText( Reference< XShape > xShape )
381cdf0e10cSrcweir {
382cdf0e10cSrcweir Reference< XSimpleText > xText( xShape, UNO_QUERY );
383cdf0e10cSrcweir
384cdf0e10cSrcweir return ( xText.is() && xText->getString().getLength() );
385cdf0e10cSrcweir }
386cdf0e10cSrcweir
WriteBezierShape(Reference<XShape> xShape,sal_Bool bClosed)387cdf0e10cSrcweir ShapeExport& ShapeExport::WriteBezierShape( Reference< XShape > xShape, sal_Bool bClosed )
388cdf0e10cSrcweir {
389cdf0e10cSrcweir DBG(printf("write open bezier shape\n"));
390cdf0e10cSrcweir
391cdf0e10cSrcweir FSHelperPtr pFS = GetFS();
392cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
393cdf0e10cSrcweir
394cdf0e10cSrcweir PolyPolygon aPolyPolygon = EscherPropertyContainer::GetPolyPolygon( xShape );
395cdf0e10cSrcweir Rectangle aRect( aPolyPolygon.GetBoundRect() );
396cdf0e10cSrcweir awt::Size size = MapSize( awt::Size( aRect.GetWidth(), aRect.GetHeight() ) );
397cdf0e10cSrcweir
398cdf0e10cSrcweir DBG(printf("poly count %d\nsize: %d x %d", aPolyPolygon.Count(), int( size.Width ), int( size.Height )));
399cdf0e10cSrcweir
400cdf0e10cSrcweir // non visual shape properties
401cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
402cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
403cdf0e10cSrcweir XML_id, I32S( GetNewShapeID( xShape ) ),
404cdf0e10cSrcweir XML_name, IDS( Freeform ),
405cdf0e10cSrcweir FSEND );
406cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
407cdf0e10cSrcweir WriteNonVisualProperties( xShape );
408cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
409cdf0e10cSrcweir
410cdf0e10cSrcweir // visual shape properties
411cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
412cdf0e10cSrcweir WriteTransformation( aRect );
413cdf0e10cSrcweir WritePolyPolygon( aPolyPolygon );
414cdf0e10cSrcweir Reference< XPropertySet > xProps( xShape, UNO_QUERY );
415cdf0e10cSrcweir if( xProps.is() ) {
416cdf0e10cSrcweir if( bClosed )
417cdf0e10cSrcweir WriteFill( xProps );
418cdf0e10cSrcweir WriteOutline( xProps );
419cdf0e10cSrcweir }
420cdf0e10cSrcweir
421cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_spPr );
422cdf0e10cSrcweir
423cdf0e10cSrcweir // write text
424cdf0e10cSrcweir WriteTextBox( xShape );
425cdf0e10cSrcweir
426cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_sp );
427cdf0e10cSrcweir
428cdf0e10cSrcweir return *this;
429cdf0e10cSrcweir }
430cdf0e10cSrcweir
WriteClosedBezierShape(Reference<XShape> xShape)431cdf0e10cSrcweir ShapeExport& ShapeExport::WriteClosedBezierShape( Reference< XShape > xShape )
432cdf0e10cSrcweir {
433cdf0e10cSrcweir return WriteBezierShape( xShape, TRUE );
434cdf0e10cSrcweir }
435cdf0e10cSrcweir
WriteOpenBezierShape(Reference<XShape> xShape)436cdf0e10cSrcweir ShapeExport& ShapeExport::WriteOpenBezierShape( Reference< XShape > xShape )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir return WriteBezierShape( xShape, FALSE );
439cdf0e10cSrcweir }
440cdf0e10cSrcweir
WriteCustomShape(Reference<XShape> xShape)441cdf0e10cSrcweir ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
442cdf0e10cSrcweir {
443cdf0e10cSrcweir DBG(printf("write custom shape\n"));
444cdf0e10cSrcweir
445cdf0e10cSrcweir Reference< XPropertySet > rXPropSet( xShape, UNO_QUERY );
446cdf0e10cSrcweir SdrObjCustomShape* pShape = (SdrObjCustomShape*) GetSdrObjectFromXShape( xShape );
447cdf0e10cSrcweir sal_Bool bIsDefaultObject = EscherPropertyContainer::IsDefaultObject( pShape );
448cdf0e10cSrcweir sal_Bool bPredefinedHandlesUsed = TRUE;
449cdf0e10cSrcweir OUString sShapeType;
450cdf0e10cSrcweir sal_uInt32 nMirrorFlags = 0;
451cdf0e10cSrcweir MSO_SPT eShapeType = EscherPropertyContainer::GetCustomShapeType( xShape, nMirrorFlags, sShapeType );
452cdf0e10cSrcweir const char* sPresetShape = lcl_GetPresetGeometry( USS( sShapeType ) );
453cdf0e10cSrcweir DBG(printf("custom shape type: %s ==> %s\n", USS( sShapeType ), sPresetShape));
454cdf0e10cSrcweir Sequence< PropertyValue > aGeometrySeq;
455cdf0e10cSrcweir sal_Int32 nAdjustmentValuesIndex = -1;
456cdf0e10cSrcweir sal_Int32 nAdjustmentsWhichNeedsToBeConverted = 0;
457cdf0e10cSrcweir
458cdf0e10cSrcweir if( GETA( CustomShapeGeometry ) ) {
459cdf0e10cSrcweir DBG(printf("got custom shape geometry\n"));
460cdf0e10cSrcweir if( mAny >>= aGeometrySeq ) {
461cdf0e10cSrcweir
462cdf0e10cSrcweir DBG(printf("got custom shape geometry sequence\n"));
463cdf0e10cSrcweir for( int i = 0; i < aGeometrySeq.getLength(); i++ ) {
464cdf0e10cSrcweir const PropertyValue& rProp = aGeometrySeq[ i ];
465cdf0e10cSrcweir DBG(printf("geometry property: %s\n", USS( rProp.Name )));
466cdf0e10cSrcweir
467cdf0e10cSrcweir if( rProp.Name.equalsAscii( "AdjustmentValues" ))
468cdf0e10cSrcweir nAdjustmentValuesIndex = i;
469cdf0e10cSrcweir else if( rProp.Name.equalsAscii( "Handles" )) {
470cdf0e10cSrcweir if( !bIsDefaultObject )
471cdf0e10cSrcweir bPredefinedHandlesUsed = FALSE;
472cdf0e10cSrcweir // TODO: update nAdjustmentsWhichNeedsToBeConverted here
473cdf0e10cSrcweir }
474cdf0e10cSrcweir }
475cdf0e10cSrcweir }
476cdf0e10cSrcweir }
477cdf0e10cSrcweir
478cdf0e10cSrcweir FSHelperPtr pFS = GetFS();
479cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
480cdf0e10cSrcweir
481cdf0e10cSrcweir // non visual shape properties
482cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
483cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
484cdf0e10cSrcweir XML_id, I32S( GetNewShapeID( xShape ) ),
485cdf0e10cSrcweir XML_name, IDS( CustomShape ),
486cdf0e10cSrcweir FSEND );
487cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
488cdf0e10cSrcweir WriteNonVisualProperties( xShape );
489cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
490cdf0e10cSrcweir
491cdf0e10cSrcweir // visual shape properties
492cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
493cdf0e10cSrcweir WriteShapeTransformation( xShape );
494cdf0e10cSrcweir if( nAdjustmentValuesIndex != -1 )
495cdf0e10cSrcweir WritePresetShape( sPresetShape, eShapeType, bPredefinedHandlesUsed, nAdjustmentsWhichNeedsToBeConverted, aGeometrySeq[ nAdjustmentValuesIndex ] );
496cdf0e10cSrcweir else
497cdf0e10cSrcweir WritePresetShape( sPresetShape );
498cdf0e10cSrcweir if( rXPropSet.is() )
499cdf0e10cSrcweir {
500cdf0e10cSrcweir WriteFill( rXPropSet );
501cdf0e10cSrcweir WriteOutline( rXPropSet );
502cdf0e10cSrcweir }
503cdf0e10cSrcweir
504cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_spPr );
505cdf0e10cSrcweir
506cdf0e10cSrcweir // write text
507cdf0e10cSrcweir WriteTextBox( xShape );
508cdf0e10cSrcweir
509cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_sp );
510cdf0e10cSrcweir
511cdf0e10cSrcweir return *this;
512cdf0e10cSrcweir }
513cdf0e10cSrcweir
WriteEllipseShape(Reference<XShape> xShape)514cdf0e10cSrcweir ShapeExport& ShapeExport::WriteEllipseShape( Reference< XShape > xShape )
515cdf0e10cSrcweir {
516cdf0e10cSrcweir DBG(printf("write ellipse shape\n"));
517cdf0e10cSrcweir
518cdf0e10cSrcweir FSHelperPtr pFS = GetFS();
519cdf0e10cSrcweir
520cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
521cdf0e10cSrcweir
522cdf0e10cSrcweir // TODO: arc, section, cut, connector
523cdf0e10cSrcweir
524cdf0e10cSrcweir // non visual shape properties
525cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
526cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
527cdf0e10cSrcweir XML_id, I32S( GetNewShapeID( xShape ) ),
528cdf0e10cSrcweir XML_name, IDS( Ellipse ),
529cdf0e10cSrcweir FSEND );
530cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
531cdf0e10cSrcweir WriteNonVisualProperties( xShape );
532cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
533cdf0e10cSrcweir
534cdf0e10cSrcweir // visual shape properties
535cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
536cdf0e10cSrcweir WriteShapeTransformation( xShape );
537cdf0e10cSrcweir WritePresetShape( "ellipse" );
538cdf0e10cSrcweir Reference< XPropertySet > xProps( xShape, UNO_QUERY );
539cdf0e10cSrcweir if( xProps.is() )
540cdf0e10cSrcweir {
541cdf0e10cSrcweir WriteFill( xProps );
542cdf0e10cSrcweir WriteOutline( xProps );
543cdf0e10cSrcweir }
544cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_spPr );
545cdf0e10cSrcweir
546cdf0e10cSrcweir // write text
547cdf0e10cSrcweir WriteTextBox( xShape );
548cdf0e10cSrcweir
549cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_sp );
550cdf0e10cSrcweir
551cdf0e10cSrcweir return *this;
552cdf0e10cSrcweir }
553cdf0e10cSrcweir
WriteFill(Reference<XPropertySet> xPropSet)554cdf0e10cSrcweir ShapeExport& ShapeExport::WriteFill( Reference< XPropertySet > xPropSet )
555cdf0e10cSrcweir {
556cdf0e10cSrcweir FillStyle aFillStyle( FillStyle_NONE );
557cdf0e10cSrcweir xPropSet->getPropertyValue( S( "FillStyle" ) ) >>= aFillStyle;
558cdf0e10cSrcweir
559cdf0e10cSrcweir if( aFillStyle == FillStyle_BITMAP )
560cdf0e10cSrcweir {
561cdf0e10cSrcweir //DBG(printf ("FillStyle_BITMAP properties\n"));
562cdf0e10cSrcweir //DBG(dump_pset(rXPropSet));
563cdf0e10cSrcweir }
564cdf0e10cSrcweir
565cdf0e10cSrcweir if( aFillStyle == FillStyle_NONE ||
566cdf0e10cSrcweir aFillStyle == FillStyle_HATCH )
567cdf0e10cSrcweir return *this;
568cdf0e10cSrcweir
569cdf0e10cSrcweir switch( aFillStyle )
570cdf0e10cSrcweir {
571cdf0e10cSrcweir case ::com::sun::star::drawing::FillStyle_SOLID :
572cdf0e10cSrcweir WriteSolidFill( xPropSet );
573cdf0e10cSrcweir break;
574cdf0e10cSrcweir case ::com::sun::star::drawing::FillStyle_GRADIENT :
575cdf0e10cSrcweir WriteGradientFill( xPropSet );
576cdf0e10cSrcweir break;
577cdf0e10cSrcweir case ::com::sun::star::drawing::FillStyle_BITMAP :
578cdf0e10cSrcweir WriteBlipFill( xPropSet, S( "FillBitmapURL" ) );
579cdf0e10cSrcweir break;
580cdf0e10cSrcweir default:
581cdf0e10cSrcweir ;
582cdf0e10cSrcweir }
583cdf0e10cSrcweir
584cdf0e10cSrcweir return *this;
585cdf0e10cSrcweir }
586cdf0e10cSrcweir
WriteGraphicObjectShape(Reference<XShape> xShape)587cdf0e10cSrcweir ShapeExport& ShapeExport::WriteGraphicObjectShape( Reference< XShape > xShape )
588cdf0e10cSrcweir {
589cdf0e10cSrcweir DBG(printf("write graphic object shape\n"));
590cdf0e10cSrcweir
591cdf0e10cSrcweir if( NonEmptyText( xShape ) )
592cdf0e10cSrcweir {
593cdf0e10cSrcweir WriteTextShape( xShape );
594cdf0e10cSrcweir
595cdf0e10cSrcweir //DBG(dump_pset(mXPropSet));
596cdf0e10cSrcweir
597cdf0e10cSrcweir return *this;
598cdf0e10cSrcweir }
599cdf0e10cSrcweir
600cdf0e10cSrcweir DBG(printf("graphicObject without text\n"));
601cdf0e10cSrcweir
602cdf0e10cSrcweir OUString sGraphicURL;
603cdf0e10cSrcweir Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
604cdf0e10cSrcweir if( !xShapeProps.is() || !( xShapeProps->getPropertyValue( S( "GraphicURL" ) ) >>= sGraphicURL ) )
605cdf0e10cSrcweir {
606cdf0e10cSrcweir DBG(printf("no graphic URL found\n"));
607cdf0e10cSrcweir return *this;
608cdf0e10cSrcweir }
609cdf0e10cSrcweir
610cdf0e10cSrcweir FSHelperPtr pFS = GetFS();
611cdf0e10cSrcweir
612cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_pic, FSEND );
613cdf0e10cSrcweir
614cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_nvPicPr, FSEND );
615cdf0e10cSrcweir
616cdf0e10cSrcweir OUString sName, sDescr;
617cdf0e10cSrcweir bool bHaveName = xShapeProps->getPropertyValue( S( "Name" ) ) >>= sName;
618cdf0e10cSrcweir bool bHaveDesc = xShapeProps->getPropertyValue( S( "Description" ) ) >>= sDescr;
619cdf0e10cSrcweir
620cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
621cdf0e10cSrcweir XML_id, I32S( GetNewShapeID( xShape ) ),
622cdf0e10cSrcweir XML_name, bHaveName ? USS( sName ) : (OString("Picture ") + OString::valueOf( mnPictureIdMax++ )).getStr(),
623cdf0e10cSrcweir XML_descr, bHaveDesc ? USS( sDescr ) : NULL,
624cdf0e10cSrcweir FSEND );
625cdf0e10cSrcweir // OOXTODO: //cNvPr children: XML_extLst, XML_hlinkClick, XML_hlinkHover
626cdf0e10cSrcweir
627cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_cNvPicPr,
628cdf0e10cSrcweir // OOXTODO: XML_preferRelativeSize
629cdf0e10cSrcweir FSEND );
630cdf0e10cSrcweir
631cdf0e10cSrcweir WriteNonVisualProperties( xShape );
632cdf0e10cSrcweir
633cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_nvPicPr );
634cdf0e10cSrcweir
635cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_blipFill, FSEND );
636cdf0e10cSrcweir
637cdf0e10cSrcweir WriteBlip( sGraphicURL );
638cdf0e10cSrcweir
639cdf0e10cSrcweir bool bStretch = false;
640cdf0e10cSrcweir if( ( xShapeProps->getPropertyValue( S( "FillBitmapStretch" ) ) >>= bStretch ) && bStretch )
641cdf0e10cSrcweir {
642cdf0e10cSrcweir WriteStretch();
643cdf0e10cSrcweir }
644cdf0e10cSrcweir
645cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_blipFill );
646cdf0e10cSrcweir
647cdf0e10cSrcweir // visual shape properties
648cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
649cdf0e10cSrcweir WriteShapeTransformation( xShape );
650cdf0e10cSrcweir WritePresetShape( "rect" );
651cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_spPr );
652cdf0e10cSrcweir
653cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_pic );
654cdf0e10cSrcweir
655cdf0e10cSrcweir return *this;
656cdf0e10cSrcweir }
657cdf0e10cSrcweir
WriteConnectorShape(Reference<XShape> xShape)658cdf0e10cSrcweir ShapeExport& ShapeExport::WriteConnectorShape( Reference< XShape > xShape )
659cdf0e10cSrcweir {
660cdf0e10cSrcweir sal_Bool bFlipH = false;
661cdf0e10cSrcweir sal_Bool bFlipV = false;
662cdf0e10cSrcweir
663cdf0e10cSrcweir DBG(printf("write connector shape\n"));
664cdf0e10cSrcweir
665cdf0e10cSrcweir FSHelperPtr pFS = GetFS();
666cdf0e10cSrcweir
667cdf0e10cSrcweir const char* sGeometry = "line";
668cdf0e10cSrcweir Reference< XPropertySet > rXPropSet( xShape, UNO_QUERY );
669cdf0e10cSrcweir Reference< XPropertyState > rXPropState( xShape, UNO_QUERY );
670cdf0e10cSrcweir awt::Point aStartPoint, aEndPoint;
671cdf0e10cSrcweir Reference< XShape > rXShapeA;
672cdf0e10cSrcweir Reference< XShape > rXShapeB;
673cdf0e10cSrcweir PropertyState eState;
674cdf0e10cSrcweir ConnectorType eConnectorType;
675cdf0e10cSrcweir if( GETAD( EdgeKind ) ) {
676cdf0e10cSrcweir mAny >>= eConnectorType;
677cdf0e10cSrcweir
678cdf0e10cSrcweir switch( eConnectorType ) {
679cdf0e10cSrcweir case ConnectorType_CURVE:
680cdf0e10cSrcweir sGeometry = "curvedConnector3";
681cdf0e10cSrcweir break;
682cdf0e10cSrcweir case ConnectorType_STANDARD:
683cdf0e10cSrcweir sGeometry = "bentConnector3";
684cdf0e10cSrcweir break;
685cdf0e10cSrcweir default:
686cdf0e10cSrcweir case ConnectorType_LINE:
687cdf0e10cSrcweir case ConnectorType_LINES:
688cdf0e10cSrcweir sGeometry = "straightConnector1";
689cdf0e10cSrcweir break;
690cdf0e10cSrcweir }
691cdf0e10cSrcweir
692cdf0e10cSrcweir if( GETAD( EdgeStartPoint ) ) {
693cdf0e10cSrcweir mAny >>= aStartPoint;
694cdf0e10cSrcweir if( GETAD( EdgeEndPoint ) ) {
695cdf0e10cSrcweir mAny >>= aEndPoint;
696cdf0e10cSrcweir }
697cdf0e10cSrcweir }
698cdf0e10cSrcweir GET( rXShapeA, EdgeStartConnection );
699cdf0e10cSrcweir GET( rXShapeB, EdgeEndConnection );
700cdf0e10cSrcweir }
701cdf0e10cSrcweir EscherConnectorListEntry aConnectorEntry( xShape, aStartPoint, rXShapeA, aEndPoint, rXShapeB );
702cdf0e10cSrcweir
703cdf0e10cSrcweir Rectangle aRect( Point( aStartPoint.X, aStartPoint.Y ), Point( aEndPoint.X, aEndPoint.Y ) );
704cdf0e10cSrcweir if( aRect.getWidth() < 0 ) {
705cdf0e10cSrcweir bFlipH = TRUE;
706cdf0e10cSrcweir aRect.setX( aEndPoint.X );
707cdf0e10cSrcweir aRect.setWidth( aStartPoint.X - aEndPoint.X );
708cdf0e10cSrcweir }
709cdf0e10cSrcweir
710cdf0e10cSrcweir if( aRect.getHeight() < 0 ) {
711cdf0e10cSrcweir bFlipV = TRUE;
712cdf0e10cSrcweir aRect.setY( aEndPoint.Y );
713cdf0e10cSrcweir aRect.setHeight( aStartPoint.Y - aEndPoint.Y );
714cdf0e10cSrcweir }
715cdf0e10cSrcweir
716cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_cxnSp, FSEND );
717cdf0e10cSrcweir
718cdf0e10cSrcweir // non visual shape properties
719cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_nvCxnSpPr, FSEND );
720cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
721cdf0e10cSrcweir XML_id, I32S( GetNewShapeID( xShape ) ),
722cdf0e10cSrcweir XML_name, IDS( Line ),
723cdf0e10cSrcweir FSEND );
724cdf0e10cSrcweir // non visual connector shape drawing properties
725cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_cNvCxnSpPr, FSEND );
726cdf0e10cSrcweir WriteConnectorConnections( aConnectorEntry, GetShapeID( rXShapeA ), GetShapeID( rXShapeB ) );
727cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_cNvCxnSpPr );
728cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_nvPr, FSEND );
729cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_nvCxnSpPr );
730cdf0e10cSrcweir
731cdf0e10cSrcweir // visual shape properties
732cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
733cdf0e10cSrcweir WriteTransformation( aRect, bFlipH, bFlipV );
734cdf0e10cSrcweir // TODO: write adjustments (ppt export doesn't work well there either)
735cdf0e10cSrcweir WritePresetShape( sGeometry );
736cdf0e10cSrcweir Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
737cdf0e10cSrcweir if( xShapeProps.is() )
738cdf0e10cSrcweir WriteOutline( xShapeProps );
739cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_spPr );
740cdf0e10cSrcweir
741cdf0e10cSrcweir // write text
742cdf0e10cSrcweir WriteTextBox( xShape );
743cdf0e10cSrcweir
744cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_cxnSp );
745cdf0e10cSrcweir
746cdf0e10cSrcweir return *this;
747cdf0e10cSrcweir }
748cdf0e10cSrcweir
WriteLineShape(Reference<XShape> xShape)749cdf0e10cSrcweir ShapeExport& ShapeExport::WriteLineShape( Reference< XShape > xShape )
750cdf0e10cSrcweir {
751cdf0e10cSrcweir sal_Bool bFlipH = false;
752cdf0e10cSrcweir sal_Bool bFlipV = false;
753cdf0e10cSrcweir
754cdf0e10cSrcweir DBG(printf("write line shape\n"));
755cdf0e10cSrcweir
756cdf0e10cSrcweir FSHelperPtr pFS = GetFS();
757cdf0e10cSrcweir
758cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
759cdf0e10cSrcweir
760cdf0e10cSrcweir PolyPolygon aPolyPolygon = EscherPropertyContainer::GetPolyPolygon( xShape );
761cdf0e10cSrcweir if( aPolyPolygon.Count() == 1 && aPolyPolygon[ 0 ].GetSize() == 2)
762cdf0e10cSrcweir {
763cdf0e10cSrcweir const Polygon& rPoly = aPolyPolygon[ 0 ];
764cdf0e10cSrcweir
765cdf0e10cSrcweir bFlipH = ( rPoly[ 0 ].X() > rPoly[ 1 ].X() );
766cdf0e10cSrcweir bFlipV = ( rPoly[ 0 ].Y() > rPoly[ 1 ].Y() );
767cdf0e10cSrcweir }
768cdf0e10cSrcweir
769cdf0e10cSrcweir // non visual shape properties
770cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
771cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
772cdf0e10cSrcweir XML_id, I32S( GetNewShapeID( xShape ) ),
773cdf0e10cSrcweir XML_name, IDS( Line ),
774cdf0e10cSrcweir FSEND );
775cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
776cdf0e10cSrcweir WriteNonVisualProperties( xShape );
777cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
778cdf0e10cSrcweir
779cdf0e10cSrcweir // visual shape properties
780cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
781cdf0e10cSrcweir WriteShapeTransformation( xShape, bFlipH, bFlipV );
782cdf0e10cSrcweir WritePresetShape( "line" );
783cdf0e10cSrcweir Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
784cdf0e10cSrcweir if( xShapeProps.is() )
785cdf0e10cSrcweir WriteOutline( xShapeProps );
786cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_spPr );
787cdf0e10cSrcweir
788cdf0e10cSrcweir // write text
789cdf0e10cSrcweir WriteTextBox( xShape );
790cdf0e10cSrcweir
791cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_sp );
792cdf0e10cSrcweir
793cdf0e10cSrcweir return *this;
794cdf0e10cSrcweir }
795cdf0e10cSrcweir
WriteNonVisualDrawingProperties(Reference<XShape> xShape,const char * pName)796cdf0e10cSrcweir ShapeExport& ShapeExport::WriteNonVisualDrawingProperties( Reference< XShape > xShape, const char* pName )
797cdf0e10cSrcweir {
798cdf0e10cSrcweir GetFS()->singleElementNS( mnXmlNamespace, XML_cNvPr,
799cdf0e10cSrcweir XML_id, I32S( GetNewShapeID( xShape ) ),
800cdf0e10cSrcweir XML_name, pName,
801cdf0e10cSrcweir FSEND );
802cdf0e10cSrcweir
803cdf0e10cSrcweir return *this;
804cdf0e10cSrcweir }
805cdf0e10cSrcweir
WriteNonVisualProperties(Reference<XShape>)806cdf0e10cSrcweir ShapeExport& ShapeExport::WriteNonVisualProperties( Reference< XShape > )
807cdf0e10cSrcweir {
808cdf0e10cSrcweir // Override to generate //nvPr elements.
809cdf0e10cSrcweir return *this;
810cdf0e10cSrcweir }
811cdf0e10cSrcweir
WriteRectangleShape(Reference<XShape> xShape)812cdf0e10cSrcweir ShapeExport& ShapeExport::WriteRectangleShape( Reference< XShape > xShape )
813cdf0e10cSrcweir {
814cdf0e10cSrcweir DBG(printf("write rectangle shape\n"));
815cdf0e10cSrcweir
816cdf0e10cSrcweir FSHelperPtr pFS = GetFS();
817cdf0e10cSrcweir
818cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
819cdf0e10cSrcweir
820cdf0e10cSrcweir sal_Int32 nRadius = 0;
821cdf0e10cSrcweir
822cdf0e10cSrcweir Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
823cdf0e10cSrcweir if( xShapeProps.is() )
824cdf0e10cSrcweir {
825cdf0e10cSrcweir xShapeProps->getPropertyValue( S( "CornerRadius" ) ) >>= nRadius;
826cdf0e10cSrcweir }
827cdf0e10cSrcweir
828cdf0e10cSrcweir if( nRadius )
829cdf0e10cSrcweir {
830cdf0e10cSrcweir nRadius = MapSize( awt::Size( nRadius, 0 ) ).Width;
831cdf0e10cSrcweir }
832cdf0e10cSrcweir
833cdf0e10cSrcweir // non visual shape properties
834cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
835cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
836cdf0e10cSrcweir XML_id, I32S( GetNewShapeID( xShape ) ),
837cdf0e10cSrcweir XML_name, IDS( Rectangle ),
838cdf0e10cSrcweir FSEND );
839cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
840cdf0e10cSrcweir WriteNonVisualProperties( xShape );
841cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
842cdf0e10cSrcweir
843cdf0e10cSrcweir // visual shape properties
844cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
845cdf0e10cSrcweir WriteShapeTransformation( xShape );
846cdf0e10cSrcweir WritePresetShape( "rect" );
847cdf0e10cSrcweir Reference< XPropertySet > xProps( xShape, UNO_QUERY );
848cdf0e10cSrcweir if( xProps.is() )
849cdf0e10cSrcweir {
850cdf0e10cSrcweir WriteFill( xProps );
851cdf0e10cSrcweir WriteOutline( xProps );
852cdf0e10cSrcweir }
853cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_spPr );
854cdf0e10cSrcweir
855cdf0e10cSrcweir // write text
856cdf0e10cSrcweir WriteTextBox( xShape );
857cdf0e10cSrcweir
858cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_sp );
859cdf0e10cSrcweir
860cdf0e10cSrcweir return *this;
861cdf0e10cSrcweir }
862cdf0e10cSrcweir
863cdf0e10cSrcweir typedef ShapeExport& (ShapeExport::*ShapeConverter)( Reference< XShape > );
864*fda69661SHerbert Dürr typedef std::hash_map< const char*, ShapeConverter, CStringHash, CStringEqual> NameToConvertMapType;
865cdf0e10cSrcweir
lcl_GetConverters()866cdf0e10cSrcweir static const NameToConvertMapType& lcl_GetConverters()
867cdf0e10cSrcweir {
868cdf0e10cSrcweir static bool shape_map_inited = false;
869cdf0e10cSrcweir static NameToConvertMapType shape_converters;
870cdf0e10cSrcweir if( shape_map_inited )
871cdf0e10cSrcweir {
872cdf0e10cSrcweir return shape_converters;
873cdf0e10cSrcweir }
874cdf0e10cSrcweir
875cdf0e10cSrcweir shape_converters[ "com.sun.star.drawing.ClosedBezierShape" ] = &ShapeExport::WriteClosedBezierShape;
876cdf0e10cSrcweir shape_converters[ "com.sun.star.drawing.ConnectorShape" ] = &ShapeExport::WriteConnectorShape;
877cdf0e10cSrcweir shape_converters[ "com.sun.star.drawing.CustomShape" ] = &ShapeExport::WriteCustomShape;
878cdf0e10cSrcweir shape_converters[ "com.sun.star.drawing.EllipseShape" ] = &ShapeExport::WriteEllipseShape;
879cdf0e10cSrcweir shape_converters[ "com.sun.star.drawing.GraphicObjectShape" ] = &ShapeExport::WriteGraphicObjectShape;
880cdf0e10cSrcweir shape_converters[ "com.sun.star.drawing.LineShape" ] = &ShapeExport::WriteLineShape;
881cdf0e10cSrcweir shape_converters[ "com.sun.star.drawing.OpenBezierShape" ] = &ShapeExport::WriteOpenBezierShape;
882cdf0e10cSrcweir shape_converters[ "com.sun.star.drawing.RectangleShape" ] = &ShapeExport::WriteRectangleShape;
883cdf0e10cSrcweir shape_converters[ "com.sun.star.drawing.TextShape" ] = &ShapeExport::WriteTextShape;
884cdf0e10cSrcweir shape_converters[ "com.sun.star.presentation.DateTimeShape" ] = &ShapeExport::WriteTextShape;
885cdf0e10cSrcweir shape_converters[ "com.sun.star.presentation.FooterShape" ] = &ShapeExport::WriteTextShape;
886cdf0e10cSrcweir shape_converters[ "com.sun.star.presentation.HeaderShape" ] = &ShapeExport::WriteTextShape;
887cdf0e10cSrcweir shape_converters[ "com.sun.star.presentation.NotesShape" ] = &ShapeExport::WriteTextShape;
888cdf0e10cSrcweir shape_converters[ "com.sun.star.presentation.OutlinerShape" ] = &ShapeExport::WriteTextShape;
889cdf0e10cSrcweir shape_converters[ "com.sun.star.presentation.SlideNumberShape" ] = &ShapeExport::WriteTextShape;
890cdf0e10cSrcweir shape_converters[ "com.sun.star.presentation.TitleTextShape" ] = &ShapeExport::WriteTextShape;
891cdf0e10cSrcweir shape_map_inited = true;
892cdf0e10cSrcweir
893cdf0e10cSrcweir return shape_converters;
894cdf0e10cSrcweir }
895cdf0e10cSrcweir
WriteShape(Reference<XShape> xShape)896cdf0e10cSrcweir ShapeExport& ShapeExport::WriteShape( Reference< XShape > xShape )
897cdf0e10cSrcweir {
898cdf0e10cSrcweir OUString sShapeType = xShape->getShapeType();
899cdf0e10cSrcweir DBG( printf( "write shape: %s\n", USS( sShapeType ) ) );
900cdf0e10cSrcweir NameToConvertMapType::const_iterator aConverter = lcl_GetConverters().find( USS( sShapeType ) );
901cdf0e10cSrcweir if( aConverter == lcl_GetConverters().end() )
902cdf0e10cSrcweir {
903cdf0e10cSrcweir DBG( printf( "unknown shape\n" ) );
904cdf0e10cSrcweir return WriteUnknownShape( xShape );
905cdf0e10cSrcweir }
906cdf0e10cSrcweir (this->*(aConverter->second))( xShape );
907cdf0e10cSrcweir
908cdf0e10cSrcweir return *this;
909cdf0e10cSrcweir }
910cdf0e10cSrcweir
WriteTextBox(Reference<XShape> xShape)911cdf0e10cSrcweir ShapeExport& ShapeExport::WriteTextBox( Reference< XShape > xShape )
912cdf0e10cSrcweir {
913cdf0e10cSrcweir if( NonEmptyText( xShape ) )
914cdf0e10cSrcweir {
915cdf0e10cSrcweir FSHelperPtr pFS = GetFS();
916cdf0e10cSrcweir
917cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_txBody, FSEND );
918cdf0e10cSrcweir WriteText( xShape );
919cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_txBody );
920cdf0e10cSrcweir }
921cdf0e10cSrcweir
922cdf0e10cSrcweir return *this;
923cdf0e10cSrcweir }
924cdf0e10cSrcweir
WriteTextShape(Reference<XShape> xShape)925cdf0e10cSrcweir ShapeExport& ShapeExport::WriteTextShape( Reference< XShape > xShape )
926cdf0e10cSrcweir {
927cdf0e10cSrcweir FSHelperPtr pFS = GetFS();
928cdf0e10cSrcweir
929cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
930cdf0e10cSrcweir
931cdf0e10cSrcweir // non visual shape properties
932cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
933cdf0e10cSrcweir WriteNonVisualDrawingProperties( xShape, IDS( TextShape ) );
934cdf0e10cSrcweir pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, XML_txBox, "1", FSEND );
935cdf0e10cSrcweir WriteNonVisualProperties( xShape );
936cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
937cdf0e10cSrcweir
938cdf0e10cSrcweir // visual shape properties
939cdf0e10cSrcweir pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
940cdf0e10cSrcweir WriteShapeTransformation( xShape );
941cdf0e10cSrcweir WritePresetShape( "rect" );
942cdf0e10cSrcweir WriteBlipFill( Reference< XPropertySet >(xShape, UNO_QUERY ), S( "GraphicURL" ) );
943cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_spPr );
944cdf0e10cSrcweir
945cdf0e10cSrcweir WriteTextBox( xShape );
946cdf0e10cSrcweir
947cdf0e10cSrcweir pFS->endElementNS( mnXmlNamespace, XML_sp );
948cdf0e10cSrcweir
949cdf0e10cSrcweir return *this;
950cdf0e10cSrcweir }
951cdf0e10cSrcweir
WriteUnknownShape(Reference<XShape>)952cdf0e10cSrcweir ShapeExport& ShapeExport::WriteUnknownShape( Reference< XShape > )
953cdf0e10cSrcweir {
954cdf0e10cSrcweir // Override this method to do something useful.
955cdf0e10cSrcweir return *this;
956cdf0e10cSrcweir }
957cdf0e10cSrcweir
operator ()(const::com::sun::star::uno::Reference<::com::sun::star::drawing::XShape> rXShape) const958cdf0e10cSrcweir size_t ShapeExport::ShapeHash::operator()( const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape > rXShape ) const
959cdf0e10cSrcweir {
960cdf0e10cSrcweir return maHashFunction( USS( rXShape->getShapeType() ) );
961cdf0e10cSrcweir }
962cdf0e10cSrcweir
GetNewShapeID(const Reference<XShape> rXShape)963cdf0e10cSrcweir sal_Int32 ShapeExport::GetNewShapeID( const Reference< XShape > rXShape )
964cdf0e10cSrcweir {
965cdf0e10cSrcweir sal_Int32 nID = GetFB()->GetUniqueId();
966cdf0e10cSrcweir
967cdf0e10cSrcweir maShapeMap[ rXShape ] = nID;
968cdf0e10cSrcweir
969cdf0e10cSrcweir return nID;
970cdf0e10cSrcweir }
971cdf0e10cSrcweir
GetShapeID(const Reference<XShape> rXShape)972cdf0e10cSrcweir sal_Int32 ShapeExport::GetShapeID( const Reference< XShape > rXShape )
973cdf0e10cSrcweir {
974cdf0e10cSrcweir ShapeHashMap::const_iterator aIter = maShapeMap.find( rXShape );
975cdf0e10cSrcweir
976cdf0e10cSrcweir if( aIter == maShapeMap.end() )
977cdf0e10cSrcweir return -1;
978cdf0e10cSrcweir
979cdf0e10cSrcweir return aIter->second;
980cdf0e10cSrcweir }
981cdf0e10cSrcweir
982cdf0e10cSrcweir } }
983