1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "svx/EnhancedCustomShapeTypeNames.hxx"
21 #include <osl/mutex.hxx>
22 #include <boost/unordered_map.hpp>
24 typedef boost::unordered_map
< const char*, MSO_SPT
, rtl::CStringHash
, rtl::CStringEqual
> TypeNameHashMap
;
26 static TypeNameHashMap
* pHashMap
= NULL
;
27 static ::osl::Mutex
& getHashMapMutex()
29 static osl::Mutex s_aHashMapProtection
;
30 return s_aHashMapProtection
;
38 static const NameTypeTable pNameTypeTableArray
[] =
40 { "non-primitive", mso_sptMin
},
41 { "rectangle", mso_sptRectangle
},
42 { "round-rectangle", mso_sptRoundRectangle
},
43 { "ellipse", mso_sptEllipse
},
44 { "diamond", mso_sptDiamond
},
45 { "isosceles-triangle", mso_sptIsocelesTriangle
},
46 { "right-triangle", mso_sptRightTriangle
},
47 { "parallelogram", mso_sptParallelogram
},
48 { "trapezoid", mso_sptTrapezoid
},
49 { "hexagon", mso_sptHexagon
},
50 { "octagon", mso_sptOctagon
},
51 { "cross", mso_sptPlus
},
52 { "star5", mso_sptStar
},
53 { "right-arrow", mso_sptArrow
},
54 { "mso-spt14", mso_sptThickArrow
},
55 { "pentagon-right", mso_sptHomePlate
},
56 { "cube", mso_sptCube
},
57 { "mso-spt17", mso_sptBalloon
},
58 { "mso-spt18", mso_sptSeal
},
59 { "mso-spt19", mso_sptArc
},
60 { "mso-spt20", mso_sptLine
},
61 { "mso-spt21", mso_sptPlaque
},
62 { "can", mso_sptCan
},
63 { "ring", mso_sptDonut
},
64 { "mso-spt24", mso_sptTextSimple
},
65 { "mso-spt25", mso_sptTextOctagon
},
66 { "mso-spt26", mso_sptTextHexagon
},
67 { "mso-spt27", mso_sptTextCurve
},
68 { "mso-spt28", mso_sptTextWave
},
69 { "mso-spt29", mso_sptTextRing
},
70 { "mso-spt30", mso_sptTextOnCurve
},
71 { "mso-spt31", mso_sptTextOnRing
},
72 { "mso-spt32", mso_sptStraightConnector1
},
73 { "mso-spt33", mso_sptBentConnector2
},
74 { "mso-spt34", mso_sptBentConnector3
},
75 { "mso-spt35", mso_sptBentConnector4
},
76 { "mso-spt36", mso_sptBentConnector5
},
77 { "mso-spt37", mso_sptCurvedConnector2
},
78 { "mso-spt38", mso_sptCurvedConnector3
},
79 { "mso-spt39", mso_sptCurvedConnector4
},
80 { "mso-spt40", mso_sptCurvedConnector5
},
81 { "mso-spt41", mso_sptCallout1
},
82 { "mso-spt42", mso_sptCallout2
},
83 { "mso-spt43", mso_sptCallout3
},
84 { "mso-spt44", mso_sptAccentCallout1
},
85 { "mso-spt45", mso_sptAccentCallout2
},
86 { "mso-spt46", mso_sptAccentCallout3
},
87 { "line-callout-1", mso_sptBorderCallout1
},
88 { "line-callout-2", mso_sptBorderCallout2
},
89 { "mso-spt49", mso_sptBorderCallout3
},
90 { "mso-spt50", mso_sptAccentBorderCallout1
},
91 { "mso-spt51", mso_sptAccentBorderCallout2
},
92 { "mso-spt52", mso_sptAccentBorderCallout3
},
93 { "mso-spt53", mso_sptRibbon
},
94 { "mso-spt54", mso_sptRibbon2
},
95 { "chevron", mso_sptChevron
},
96 { "pentagon", mso_sptPentagon
},
97 { "forbidden", mso_sptNoSmoking
},
98 { "star8", mso_sptSeal8
},
99 { "mso-spt59", mso_sptSeal16
},
100 { "mso-spt60", mso_sptSeal32
},
101 { "rectangular-callout", mso_sptWedgeRectCallout
},
102 { "round-rectangular-callout", mso_sptWedgeRRectCallout
},
103 { "round-callout", mso_sptWedgeEllipseCallout
},
104 { "mso-spt64", mso_sptWave
},
105 { "paper", mso_sptFoldedCorner
},
106 { "left-arrow", mso_sptLeftArrow
},
107 { "down-arrow", mso_sptDownArrow
},
108 { "up-arrow", mso_sptUpArrow
},
109 { "left-right-arrow", mso_sptLeftRightArrow
},
110 { "up-down-arrow", mso_sptUpDownArrow
},
111 { "mso-spt71", mso_sptIrregularSeal1
},
112 { "bang", mso_sptIrregularSeal2
},
113 { "lightning", mso_sptLightningBolt
},
114 { "heart", mso_sptHeart
},
115 { "mso-spt75", mso_sptPictureFrame
},
116 { "quad-arrow", mso_sptQuadArrow
},
117 { "left-arrow-callout", mso_sptLeftArrowCallout
},
118 { "right-arrow-callout", mso_sptRightArrowCallout
},
119 { "up-arrow-callout", mso_sptUpArrowCallout
},
120 { "down-arrow-callout", mso_sptDownArrowCallout
},
121 { "left-right-arrow-callout", mso_sptLeftRightArrowCallout
},
122 { "up-down-arrow-callout", mso_sptUpDownArrowCallout
},
123 { "quad-arrow-callout", mso_sptQuadArrowCallout
},
124 { "quad-bevel", mso_sptBevel
},
125 { "left-bracket", mso_sptLeftBracket
},
126 { "right-bracket", mso_sptRightBracket
},
127 { "left-brace", mso_sptLeftBrace
},
128 { "right-brace", mso_sptRightBrace
},
129 { "mso-spt89", mso_sptLeftUpArrow
},
130 { "mso-spt90", mso_sptBentUpArrow
},
131 { "mso-spt91", mso_sptBentArrow
},
132 { "star24", mso_sptSeal24
},
133 { "striped-right-arrow", mso_sptStripedRightArrow
},
134 { "notched-right-arrow", mso_sptNotchedRightArrow
},
135 { "block-arc", mso_sptBlockArc
},
136 { "smiley", mso_sptSmileyFace
},
137 { "vertical-scroll", mso_sptVerticalScroll
},
138 { "horizontal-scroll", mso_sptHorizontalScroll
},
139 { "circular-arrow", mso_sptCircularArrow
},
140 { "mso-spt100", mso_sptNotchedCircularArrow
},
141 { "mso-spt101", mso_sptUturnArrow
},
142 { "mso-spt102", mso_sptCurvedRightArrow
},
143 { "mso-spt103", mso_sptCurvedLeftArrow
},
144 { "mso-spt104", mso_sptCurvedUpArrow
},
145 { "mso-spt105", mso_sptCurvedDownArrow
},
146 { "cloud-callout", mso_sptCloudCallout
},
147 { "mso-spt107", mso_sptEllipseRibbon
},
148 { "mso-spt108", mso_sptEllipseRibbon2
},
149 { "flowchart-process", mso_sptFlowChartProcess
},
150 { "flowchart-decision", mso_sptFlowChartDecision
},
151 { "flowchart-data", mso_sptFlowChartInputOutput
},
152 { "flowchart-predefined-process", mso_sptFlowChartPredefinedProcess
},
153 { "flowchart-internal-storage", mso_sptFlowChartInternalStorage
},
154 { "flowchart-document", mso_sptFlowChartDocument
},
155 { "flowchart-multidocument", mso_sptFlowChartMultidocument
},
156 { "flowchart-terminator", mso_sptFlowChartTerminator
},
157 { "flowchart-preparation", mso_sptFlowChartPreparation
},
158 { "flowchart-manual-input", mso_sptFlowChartManualInput
},
159 { "flowchart-manual-operation", mso_sptFlowChartManualOperation
},
160 { "flowchart-connector", mso_sptFlowChartConnector
},
161 { "flowchart-card", mso_sptFlowChartPunchedCard
},
162 { "flowchart-punched-tape", mso_sptFlowChartPunchedTape
},
163 { "flowchart-summing-junction", mso_sptFlowChartSummingJunction
},
164 { "flowchart-or", mso_sptFlowChartOr
},
165 { "flowchart-collate", mso_sptFlowChartCollate
},
166 { "flowchart-sort", mso_sptFlowChartSort
},
167 { "flowchart-extract", mso_sptFlowChartExtract
},
168 { "flowchart-merge", mso_sptFlowChartMerge
},
169 { "mso-spt129", mso_sptFlowChartOfflineStorage
},
170 { "flowchart-stored-data", mso_sptFlowChartOnlineStorage
},
171 { "flowchart-sequential-access", mso_sptFlowChartMagneticTape
},
172 { "flowchart-magnetic-disk", mso_sptFlowChartMagneticDisk
},
173 { "flowchart-direct-access-storage", mso_sptFlowChartMagneticDrum
},
174 { "flowchart-display", mso_sptFlowChartDisplay
},
175 { "flowchart-delay", mso_sptFlowChartDelay
},
176 { "fontwork-plain-text", mso_sptTextPlainText
},
177 { "fontwork-stop", mso_sptTextStop
},
178 { "fontwork-triangle-up", mso_sptTextTriangle
},
179 { "fontwork-triangle-down", mso_sptTextTriangleInverted
},
180 { "fontwork-chevron-up", mso_sptTextChevron
},
181 { "fontwork-chevron-down", mso_sptTextChevronInverted
},
182 { "mso-spt142", mso_sptTextRingInside
},
183 { "mso-spt143", mso_sptTextRingOutside
},
184 { "fontwork-arch-up-curve", mso_sptTextArchUpCurve
},
185 { "fontwork-arch-down-curve", mso_sptTextArchDownCurve
},
186 { "fontwork-circle-curve", mso_sptTextCircleCurve
},
187 { "fontwork-open-circle-curve", mso_sptTextButtonCurve
},
188 { "fontwork-arch-up-pour", mso_sptTextArchUpPour
},
189 { "fontwork-arch-down-pour", mso_sptTextArchDownPour
},
190 { "fontwork-circle-pour", mso_sptTextCirclePour
},
191 { "fontwork-open-circle-pour", mso_sptTextButtonPour
},
192 { "fontwork-curve-up", mso_sptTextCurveUp
},
193 { "fontwork-curve-down", mso_sptTextCurveDown
},
194 { "fontwork-fade-up-and-right", mso_sptTextCascadeUp
},
195 { "fontwork-fade-up-and-left", mso_sptTextCascadeDown
},
196 { "fontwork-wave", mso_sptTextWave1
},
197 { "mso-spt157", mso_sptTextWave2
},
198 { "mso-spt158", mso_sptTextWave3
},
199 { "mso-spt159", mso_sptTextWave4
},
200 { "fontwork-inflate", mso_sptTextInflate
},
201 { "mso-spt161", mso_sptTextDeflate
},
202 { "mso-spt162", mso_sptTextInflateBottom
},
203 { "mso-spt163", mso_sptTextDeflateBottom
},
204 { "mso-spt164", mso_sptTextInflateTop
},
205 { "mso-spt165", mso_sptTextDeflateTop
},
206 { "mso-spt166", mso_sptTextDeflateInflate
},
207 { "mso-spt167", mso_sptTextDeflateInflateDeflate
},
208 { "fontwork-fade-right", mso_sptTextFadeRight
},
209 { "fontwork-fade-left", mso_sptTextFadeLeft
},
210 { "fontwork-fade-up", mso_sptTextFadeUp
},
211 { "fontwork-fade-down", mso_sptTextFadeDown
},
212 { "fontwork-slant-up", mso_sptTextSlantUp
},
213 { "fontwork-slant-down", mso_sptTextSlantDown
},
214 { "mso-spt174", mso_sptTextCanUp
},
215 { "mso-spt175", mso_sptTextCanDown
},
216 { "flowchart-alternate-process", mso_sptFlowChartAlternateProcess
},
217 { "flowchart-off-page-connector", mso_sptFlowChartOffpageConnector
},
218 { "mso-spt178", mso_sptCallout90
},
219 { "mso-spt179", mso_sptAccentCallout90
},
220 { "mso-spt180", mso_sptBorderCallout90
},
221 { "line-callout-3", mso_sptAccentBorderCallout90
},
222 { "mso-spt182", mso_sptLeftRightUpArrow
},
223 { "sun", mso_sptSun
},
224 { "moon", mso_sptMoon
},
225 { "bracket-pair", mso_sptBracketPair
},
226 { "brace-pair", mso_sptBracePair
},
227 { "star4", mso_sptSeal4
},
228 { "mso-spt188", mso_sptDoubleWave
},
229 { "mso-spt189", mso_sptActionButtonBlank
},
230 { "mso-spt190", mso_sptActionButtonHome
},
231 { "mso-spt191", mso_sptActionButtonHelp
},
232 { "mso-spt192", mso_sptActionButtonInformation
},
233 { "mso-spt193", mso_sptActionButtonForwardNext
},
234 { "mso-spt194", mso_sptActionButtonBackPrevious
},
235 { "mso-spt195", mso_sptActionButtonEnd
},
236 { "mso-spt196", mso_sptActionButtonBeginning
},
237 { "mso-spt197", mso_sptActionButtonReturn
},
238 { "mso-spt198", mso_sptActionButtonDocument
},
239 { "mso-spt199", mso_sptActionButtonSound
},
240 { "mso-spt200", mso_sptActionButtonMovie
},
241 { "mso-spt201", mso_sptHostControl
},
242 { "mso-spt202", mso_sptTextBox
}
246 // gallery: round-quadrat
248 // gallery: circle-pie
253 // gallery: octagon-bevel
254 // gallery: diamond-bevel
255 // gallery: up-right-arrow
256 // gallery: up-right-down-arrow
257 // gallery: corner-right-arrow
258 // gallery: split-arrow
259 // gallery: up-right-arrow-callout
260 // gallery: split-round-arrow
261 // gallery: s-sharped-arrow
264 // Gallery: concave-star6
266 // Gallery: doorplate
267 // gallery: fontwork-arch-left-curve
268 // gallery: fontwork-arch-right-curve
269 // gallery: fontwork-arch-left-pour
270 // gallery: fontwork-arch-right-pour
272 MSO_SPT
EnhancedCustomShapeTypeNames::Get( const OUString
& rShapeType
)
276 ::osl::MutexGuard
aGuard( getHashMapMutex() );
279 TypeNameHashMap
* pH
= new TypeNameHashMap
;
280 const NameTypeTable
* pPtr
= pNameTypeTableArray
;
281 const NameTypeTable
* pEnd
= pPtr
+ ( sizeof( pNameTypeTableArray
) / sizeof( NameTypeTable
) );
282 for ( ; pPtr
< pEnd
; pPtr
++ )
283 (*pH
)[ pPtr
->pS
] = pPtr
->pE
;
287 MSO_SPT eRetValue
= mso_sptNil
;
288 int i
, nLen
= rShapeType
.getLength();
289 char* pBuf
= new char[ nLen
+ 1 ];
290 for ( i
= 0; i
< nLen
; i
++ )
291 pBuf
[ i
] = (char)rShapeType
[ i
];
293 TypeNameHashMap::iterator
aHashIter( pHashMap
->find( pBuf
) );
295 if ( aHashIter
!= pHashMap
->end() )
296 eRetValue
= (*aHashIter
).second
;
300 OUString
EnhancedCustomShapeTypeNames::Get( const MSO_SPT eShapeType
)
302 return eShapeType
<= mso_sptTextBox
303 ? OUString::createFromAscii( pNameTypeTableArray
[ eShapeType
].pS
)
307 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */