merge the formfield patch from ooo-build
[ooovba.git] / svx / source / customshapes / EnhancedCustomShapeTypeNames.cxx
blob588e8a3207ebc280e8a08bab4ccc2d52ac774163
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: EnhancedCustomShapeTypeNames.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include "EnhancedCustomShapeTypeNames.hxx"
34 #include <osl/mutex.hxx>
35 #include <hash_map>
37 struct TCheck
39 bool operator()( const char* s1, const char* s2 ) const
41 return strcmp( s1, s2 ) == 0;
44 typedef std::hash_map< const char*, MSO_SPT, std::hash<const char*>, TCheck> TypeNameHashMap;
45 static TypeNameHashMap* pHashMap = NULL;
46 static ::osl::Mutex& getHashMapMutex()
48 static osl::Mutex s_aHashMapProtection;
49 return s_aHashMapProtection;
52 struct NameTypeTable
54 const char* pS;
55 MSO_SPT pE;
57 static const NameTypeTable pNameTypeTableArray[] =
59 { "non-primitive", mso_sptMin },
60 { "rectangle", mso_sptRectangle },
61 { "round-rectangle", mso_sptRoundRectangle },
62 { "ellipse", mso_sptEllipse },
63 { "diamond", mso_sptDiamond },
64 { "isosceles-triangle", mso_sptIsocelesTriangle },
65 { "right-triangle", mso_sptRightTriangle },
66 { "parallelogram", mso_sptParallelogram },
67 { "trapezoid", mso_sptTrapezoid },
68 { "hexagon", mso_sptHexagon },
69 { "octagon", mso_sptOctagon },
70 { "cross", mso_sptPlus },
71 { "star5", mso_sptStar },
72 { "right-arrow", mso_sptArrow },
73 { "mso-spt14", mso_sptThickArrow },
74 { "pentagon-right", mso_sptHomePlate },
75 { "cube", mso_sptCube },
76 { "mso-spt17", mso_sptBalloon },
77 { "mso-spt18", mso_sptSeal },
78 { "mso-spt19", mso_sptArc },
79 { "mso-spt20", mso_sptLine },
80 { "mso-spt21", mso_sptPlaque },
81 { "can", mso_sptCan },
82 { "ring", mso_sptDonut },
83 { "mso-spt24", mso_sptTextSimple },
84 { "mso-spt25", mso_sptTextOctagon },
85 { "mso-spt26", mso_sptTextHexagon },
86 { "mso-spt27", mso_sptTextCurve },
87 { "mso-spt28", mso_sptTextWave },
88 { "mso-spt29", mso_sptTextRing },
89 { "mso-spt30", mso_sptTextOnCurve },
90 { "mso-spt31", mso_sptTextOnRing },
91 { "mso-spt32", mso_sptStraightConnector1 },
92 { "mso-spt33", mso_sptBentConnector2 },
93 { "mso-spt34", mso_sptBentConnector3 },
94 { "mso-spt35", mso_sptBentConnector4 },
95 { "mso-spt36", mso_sptBentConnector5 },
96 { "mso-spt37", mso_sptCurvedConnector2 },
97 { "mso-spt38", mso_sptCurvedConnector3 },
98 { "mso-spt39", mso_sptCurvedConnector4 },
99 { "mso-spt40", mso_sptCurvedConnector5 },
100 { "mso-spt41", mso_sptCallout1 },
101 { "mso-spt42", mso_sptCallout2 },
102 { "mso-spt43", mso_sptCallout3 },
103 { "mso-spt44", mso_sptAccentCallout1 },
104 { "mso-spt45", mso_sptAccentCallout2 },
105 { "mso-spt46", mso_sptAccentCallout3 },
106 { "line-callout-1", mso_sptBorderCallout1 },
107 { "line-callout-2", mso_sptBorderCallout2 },
108 { "mso-spt49", mso_sptBorderCallout3 },
109 { "mso-spt50", mso_sptAccentBorderCallout1 },
110 { "mso-spt51", mso_sptAccentBorderCallout2 },
111 { "mso-spt52", mso_sptAccentBorderCallout3 },
112 { "mso-spt53", mso_sptRibbon },
113 { "mso-spt54", mso_sptRibbon2 },
114 { "chevron", mso_sptChevron },
115 { "pentagon", mso_sptPentagon },
116 { "forbidden", mso_sptNoSmoking },
117 { "star8", mso_sptSeal8 },
118 { "mso-spt59", mso_sptSeal16 },
119 { "mso-spt60", mso_sptSeal32 },
120 { "rectangular-callout", mso_sptWedgeRectCallout },
121 { "round-rectangular-callout", mso_sptWedgeRRectCallout },
122 { "round-callout", mso_sptWedgeEllipseCallout },
123 { "mso-spt64", mso_sptWave },
124 { "paper", mso_sptFoldedCorner },
125 { "left-arrow", mso_sptLeftArrow },
126 { "down-arrow", mso_sptDownArrow },
127 { "up-arrow", mso_sptUpArrow },
128 { "left-right-arrow", mso_sptLeftRightArrow },
129 { "up-down-arrow", mso_sptUpDownArrow },
130 { "mso-spt71", mso_sptIrregularSeal1 },
131 { "bang", mso_sptIrregularSeal2 },
132 { "lightning", mso_sptLightningBolt },
133 { "heart", mso_sptHeart },
134 { "mso-spt75", mso_sptPictureFrame },
135 { "quad-arrow", mso_sptQuadArrow },
136 { "left-arrow-callout", mso_sptLeftArrowCallout },
137 { "right-arrow-callout", mso_sptRightArrowCallout },
138 { "up-arrow-callout", mso_sptUpArrowCallout },
139 { "down-arrow-callout", mso_sptDownArrowCallout },
140 { "left-right-arrow-callout", mso_sptLeftRightArrowCallout },
141 { "up-down-arrow-callout", mso_sptUpDownArrowCallout },
142 { "quad-arrow-callout", mso_sptQuadArrowCallout },
143 { "quad-bevel", mso_sptBevel },
144 { "left-bracket", mso_sptLeftBracket },
145 { "right-bracket", mso_sptRightBracket },
146 { "left-brace", mso_sptLeftBrace },
147 { "right-brace", mso_sptRightBrace },
148 { "mso-spt89", mso_sptLeftUpArrow },
149 { "mso-spt90", mso_sptBentUpArrow },
150 { "mso-spt91", mso_sptBentArrow },
151 { "star24", mso_sptSeal24 },
152 { "striped-right-arrow", mso_sptStripedRightArrow },
153 { "notched-right-arrow", mso_sptNotchedRightArrow },
154 { "block-arc", mso_sptBlockArc },
155 { "smiley", mso_sptSmileyFace },
156 { "vertical-scroll", mso_sptVerticalScroll },
157 { "horizontal-scroll", mso_sptHorizontalScroll },
158 { "circular-arrow", mso_sptCircularArrow },
159 { "mso-spt100", mso_sptNotchedCircularArrow },
160 { "mso-spt101", mso_sptUturnArrow },
161 { "mso-spt102", mso_sptCurvedRightArrow },
162 { "mso-spt103", mso_sptCurvedLeftArrow },
163 { "mso-spt104", mso_sptCurvedUpArrow },
164 { "mso-spt105", mso_sptCurvedDownArrow },
165 { "cloud-callout", mso_sptCloudCallout },
166 { "mso-spt107", mso_sptEllipseRibbon },
167 { "mso-spt108", mso_sptEllipseRibbon2 },
168 { "flowchart-process", mso_sptFlowChartProcess },
169 { "flowchart-decision", mso_sptFlowChartDecision },
170 { "flowchart-data", mso_sptFlowChartInputOutput },
171 { "flowchart-predefined-process", mso_sptFlowChartPredefinedProcess },
172 { "flowchart-internal-storage", mso_sptFlowChartInternalStorage },
173 { "flowchart-document", mso_sptFlowChartDocument },
174 { "flowchart-multidocument", mso_sptFlowChartMultidocument },
175 { "flowchart-terminator", mso_sptFlowChartTerminator },
176 { "flowchart-preparation", mso_sptFlowChartPreparation },
177 { "flowchart-manual-input", mso_sptFlowChartManualInput },
178 { "flowchart-manual-operation", mso_sptFlowChartManualOperation },
179 { "flowchart-connector", mso_sptFlowChartConnector },
180 { "flowchart-card", mso_sptFlowChartPunchedCard },
181 { "flowchart-punched-tape", mso_sptFlowChartPunchedTape },
182 { "flowchart-summing-junction", mso_sptFlowChartSummingJunction },
183 { "flowchart-or", mso_sptFlowChartOr },
184 { "flowchart-collate", mso_sptFlowChartCollate },
185 { "flowchart-sort", mso_sptFlowChartSort },
186 { "flowchart-extract", mso_sptFlowChartExtract },
187 { "flowchart-merge", mso_sptFlowChartMerge },
188 { "mso-spt129", mso_sptFlowChartOfflineStorage },
189 { "flowchart-stored-data", mso_sptFlowChartOnlineStorage },
190 { "flowchart-sequential-access", mso_sptFlowChartMagneticTape },
191 { "flowchart-magnetic-disk", mso_sptFlowChartMagneticDisk },
192 { "flowchart-direct-access-storage", mso_sptFlowChartMagneticDrum },
193 { "flowchart-display", mso_sptFlowChartDisplay },
194 { "flowchart-delay", mso_sptFlowChartDelay },
195 { "fontwork-plain-text", mso_sptTextPlainText },
196 { "fontwork-stop", mso_sptTextStop },
197 { "fontwork-triangle-up", mso_sptTextTriangle },
198 { "fontwork-triangle-down", mso_sptTextTriangleInverted },
199 { "fontwork-chevron-up", mso_sptTextChevron },
200 { "fontwork-chevron-down", mso_sptTextChevronInverted },
201 { "mso-spt142", mso_sptTextRingInside },
202 { "mso-spt143", mso_sptTextRingOutside },
203 { "fontwork-arch-up-curve", mso_sptTextArchUpCurve },
204 { "fontwork-arch-down-curve", mso_sptTextArchDownCurve },
205 { "fontwork-circle-curve", mso_sptTextCircleCurve },
206 { "fontwork-open-circle-curve", mso_sptTextButtonCurve },
207 { "fontwork-arch-up-pour", mso_sptTextArchUpPour },
208 { "fontwork-arch-down-pour", mso_sptTextArchDownPour },
209 { "fontwork-circle-pour", mso_sptTextCirclePour },
210 { "fontwork-open-circle-pour", mso_sptTextButtonPour },
211 { "fontwork-curve-up", mso_sptTextCurveUp },
212 { "fontwork-curve-down", mso_sptTextCurveDown },
213 { "fontwork-fade-up-and-right", mso_sptTextCascadeUp },
214 { "fontwork-fade-up-and-left", mso_sptTextCascadeDown },
215 { "fontwork-wave", mso_sptTextWave1 },
216 { "mso-spt157", mso_sptTextWave2 },
217 { "mso-spt158", mso_sptTextWave3 },
218 { "mso-spt159", mso_sptTextWave4 },
219 { "fontwork-inflate", mso_sptTextInflate },
220 { "mso-spt161", mso_sptTextDeflate },
221 { "mso-spt162", mso_sptTextInflateBottom },
222 { "mso-spt163", mso_sptTextDeflateBottom },
223 { "mso-spt164", mso_sptTextInflateTop },
224 { "mso-spt165", mso_sptTextDeflateTop },
225 { "mso-spt166", mso_sptTextDeflateInflate },
226 { "mso-spt167", mso_sptTextDeflateInflateDeflate },
227 { "fontwork-fade-right", mso_sptTextFadeRight },
228 { "fontwork-fade-left", mso_sptTextFadeLeft },
229 { "fontwork-fade-up", mso_sptTextFadeUp },
230 { "fontwork-fade-down", mso_sptTextFadeDown },
231 { "fontwork-slant-up", mso_sptTextSlantUp },
232 { "fontwork-slant-down", mso_sptTextSlantDown },
233 { "mso-spt174", mso_sptTextCanUp },
234 { "mso-spt175", mso_sptTextCanDown },
235 { "flowchart-alternate-process", mso_sptFlowChartAlternateProcess },
236 { "flowchart-off-page-connector", mso_sptFlowChartOffpageConnector },
237 { "mso-spt178", mso_sptCallout90 },
238 { "mso-spt179", mso_sptAccentCallout90 },
239 { "mso-spt180", mso_sptBorderCallout90 },
240 { "line-callout-3", mso_sptAccentBorderCallout90 },
241 { "mso-spt182", mso_sptLeftRightUpArrow },
242 { "sun", mso_sptSun },
243 { "moon", mso_sptMoon },
244 { "bracket-pair", mso_sptBracketPair },
245 { "brace-pair", mso_sptBracePair },
246 { "star4", mso_sptSeal4 },
247 { "mso-spt188", mso_sptDoubleWave },
248 { "mso-spt189", mso_sptActionButtonBlank },
249 { "mso-spt190", mso_sptActionButtonHome },
250 { "mso-spt191", mso_sptActionButtonHelp },
251 { "mso-spt192", mso_sptActionButtonInformation },
252 { "mso-spt193", mso_sptActionButtonForwardNext },
253 { "mso-spt194", mso_sptActionButtonBackPrevious },
254 { "mso-spt195", mso_sptActionButtonEnd },
255 { "mso-spt196", mso_sptActionButtonBeginning },
256 { "mso-spt197", mso_sptActionButtonReturn },
257 { "mso-spt198", mso_sptActionButtonDocument },
258 { "mso-spt199", mso_sptActionButtonSound },
259 { "mso-spt200", mso_sptActionButtonMovie },
260 { "mso-spt201", mso_sptHostControl },
261 { "mso-spt202", mso_sptTextBox }
264 // gallery: quadrat
265 // gallery: round-quadrat
266 // gallery: circle
267 // gallery: circle-pie
268 // gallery: frame
269 // gallery: flower
270 // gallery: cloud
271 // gallery: puzzle
272 // gallery: octagon-bevel
273 // gallery: diamond-bevel
274 // gallery: up-right-arrow
275 // gallery: up-right-down-arrow
276 // gallery: corner-right-arrow
277 // gallery: split-arrow
278 // gallery: up-right-arrow-callout
279 // gallery: split-round-arrow
280 // gallery: s-sharped-arrow
281 // Gallery: star6
282 // Gallery: star12
283 // Gallery: concave-star6
284 // Gallery: signet
285 // Gallery: doorplate
286 // gallery: fontwork-arch-left-curve
287 // gallery: fontwork-arch-right-curve
288 // gallery: fontwork-arch-left-pour
289 // gallery: fontwork-arch-right-pour
291 MSO_SPT EnhancedCustomShapeTypeNames::Get( const rtl::OUString& rShapeType )
293 if ( !pHashMap )
294 { // init hash map
295 ::osl::MutexGuard aGuard( getHashMapMutex() );
296 if ( !pHashMap )
298 TypeNameHashMap* pH = new TypeNameHashMap;
299 const NameTypeTable* pPtr = pNameTypeTableArray;
300 const NameTypeTable* pEnd = pPtr + ( sizeof( pNameTypeTableArray ) / sizeof( NameTypeTable ) );
301 for ( ; pPtr < pEnd; pPtr++ )
302 (*pH)[ pPtr->pS ] = pPtr->pE;
303 pHashMap = pH;
306 MSO_SPT eRetValue = mso_sptNil;
307 int i, nLen = rShapeType.getLength();
308 char* pBuf = new char[ nLen + 1 ];
309 for ( i = 0; i < nLen; i++ )
310 pBuf[ i ] = (char)rShapeType[ i ];
311 pBuf[ i ] = 0;
312 TypeNameHashMap::iterator aHashIter( pHashMap->find( pBuf ) );
313 delete[] pBuf;
314 if ( aHashIter != pHashMap->end() )
315 eRetValue = (*aHashIter).second;
316 return eRetValue;
319 rtl::OUString EnhancedCustomShapeTypeNames::Get( const MSO_SPT eShapeType )
321 return eShapeType <= mso_sptTextBox
322 ? rtl::OUString::createFromAscii( pNameTypeTableArray[ eShapeType ].pS )
323 : rtl::OUString();