nss: upgrade to release 3.73
[LibreOffice.git] / unodevtools / source / skeletonmaker / cppcompskeleton.cxx
blob3bbcee31dbf7bf31b3e314b417a894c279f0edfe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <sal/config.h>
22 #include <codemaker/commoncpp.hxx>
23 #include <codemaker/global.hxx>
25 #include "skeletoncommon.hxx"
26 #include "skeletoncpp.hxx"
28 #include <iostream>
30 using namespace ::codemaker::cpp;
32 namespace skeletonmaker::cpp {
34 static void generateIncludes(std::ostream & o,
35 const std::set< OUString >& interfaces,
36 const OUString & propertyhelper, const bool serviceobject,
37 const bool supportxcomponent)
39 o << "#include \"sal/config.h\"\n";
40 if (serviceobject) {
41 o << "#include \"cppuhelper/factory.hxx\"\n"
42 "#include \"cppuhelper/implementationentry.hxx\"\n";
43 } else {
44 o << "#include \"com/sun/star/uno/XComponentContext.hpp\"\n";
46 if (supportxcomponent) {
47 o << "#include \"cppuhelper/compbase" << interfaces.size() << ".hxx\"\n";
48 o << "#include \"cppuhelper/basemutex.hxx\"\n";
49 } else {
50 o << "#include \"cppuhelper/implbase" << interfaces.size() << ".hxx\"\n";
53 if (propertyhelper.getLength() > 1) {
54 if (propertyhelper == "_")
55 o << "#include \"cppuhelper/rpopshlp.hxx\"\n";
56 else
57 o << "#include \"cppuhelper/propertysetmixin.hxx\"\n";
60 for (const auto& rIface : interfaces)
62 o << "#include \""
63 << rIface.replace('.', '/')
64 << ".hpp\"\n";
68 static short generateNamespace(std::ostream & o,
69 const OString & implname,
70 bool serviceobject,
71 OString & nm)
73 short count=0;
74 sal_Int32 index = implname.lastIndexOf('.');
75 if (serviceobject) {
76 o << "\n\n// component helper namespace\n";
77 } else {
78 o << "\n";
80 OStringBuffer buf;
81 if (index == -1) {
82 if (serviceobject) {
83 buf.append("comp_");
84 buf.append(implname);
85 nm = buf.makeStringAndClear();
86 o << "namespace comp_" << implname << " {\n\n";
87 count=1;
88 } else {
89 nm.clear();
91 } else {
92 sal_Int32 nPos=0;
93 do {
94 OString token(implname.getToken(0, '.', nPos));
95 if (nPos < 0 && serviceobject) {
96 buf.append("::comp_");
97 buf.append(token);
98 o << "namespace comp_" << token << " { ";
99 count++;
100 } else {
101 buf.append("::");
102 buf.append(token);
103 o << "namespace " << token << " { ";
104 count++;
106 } while( nPos <= index );
107 nm = buf.makeStringAndClear();
108 o << "\n\n";
110 return count;
113 static OString generateCompHelperDeclaration(std::ostream & o,
114 const OString & implname)
116 OString nm;
117 short nbrackets = generateNamespace(o, implname, true, nm);
119 o << "namespace css = ::com::sun::star;\n\n";
121 // generate component/service helper functions
122 o << "// component and service helper functions:\n"
123 "OUString SAL_CALL _getImplementationName();\n"
124 "css::uno::Sequence< OUString > SAL_CALL "
125 "_getSupportedServiceNames();\n"
126 "css::uno::Reference< css::uno::XInterface > SAL_CALL _create("
127 " css::uno::Reference< css::uno::XComponentContext > const & "
128 "context );\n\n";
130 // close namespace
131 for (short i=0; i < nbrackets; i++)
132 o << "} ";
133 o << "// closing component helper namespace\n\n";
135 return nm;
138 static void generateCompHelperDefinition(std::ostream & o,
139 const OString & implname,
140 const OString & classname,
141 const std::set< OUString >& services)
143 OString nm;
144 short nbrackets = generateNamespace(o, implname, true, nm);
146 o << "OUString SAL_CALL _getImplementationName() {\n"
147 " return OUString(\n"
148 " \"" << implname << "\");\n}\n\n";
150 o << "css::uno::Sequence< OUString > SAL_CALL "
151 "_getSupportedServiceNames()\n{\n css::uno::Sequence< "
152 "OUString > s(" << services.size() << ");\n";
154 short i=0;
155 for (const auto& rService : services)
157 o << " s[" << i++ << "] = OUString(\""
158 << rService << "\");\n";
160 o << " return s;\n}\n\n";
162 o << "css::uno::Reference< css::uno::XInterface > SAL_CALL _create("
163 "\n const css::uno::Reference< css::uno::XComponentContext > & "
164 "context)\n{\n"
165 " return static_cast< ::cppu::OWeakObject * >(new "
166 << classname << "(context));\n}\n\n";
168 // close namespace
169 for (short j=0; j < nbrackets; j++)
170 o << "} ";
171 o << "// closing component helper namespace\n\n";
175 static void generateCompFunctions(std::ostream & o, const OString & nmspace)
177 o << "static ::cppu::ImplementationEntry const entries[] = {\n"
178 " { &" << nmspace << "::_create,\n &"
179 << nmspace << "::_getImplementationName,\n &"
180 << nmspace << "::_getSupportedServiceNames,\n"
181 " &::cppu::createSingleComponentFactory, 0, 0 },\n"
182 " { 0, 0, 0, 0, 0, 0 }\n};\n\n";
184 o << "extern \"C\" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(\n"
185 " const char * implName, void * serviceManager, void * registryKey)\n{\n"
186 " return ::cppu::component_getFactoryHelper(\n"
187 " implName, serviceManager, registryKey, entries);\n}\n\n";
189 o << "extern \"C\" sal_Bool SAL_CALL component_writeInfo(\n"
190 " void * serviceManager, void * registryKey)\n{\n"
191 " return ::cppu::component_writeInfoHelper("
192 "serviceManager, registryKey, entries);\n}\n";
195 void generateXPropertySetBodies(std::ostream& o,
196 const OString & classname,
197 const OString & propertyhelper)
199 o << "// com.sun.star.beans.XPropertySet:\n";
201 o << "css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL "
202 << classname << "getPropertySetInfo() throw ("
203 "css::uno::RuntimeException)\n{\n return ::cppu::PropertySetMixin< "
204 << propertyhelper
205 << " >::getPropertySetInfo();\n}\n\n";
207 o << "void SAL_CALL " << classname << "setPropertyValue(const OUString"
208 " & aPropertyName, const css::uno::Any & aValue) throw ("
209 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
210 "css::beans::PropertyVetoException, css::lang::IllegalArgumentException, "
211 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
212 << propertyhelper << " >::setPropertyValue(aPropertyName, aValue);\n}\n\n";
215 o << "css::uno::Any SAL_CALL " << classname << "getPropertyValue(const "
216 "OUString & aPropertyName) throw (css::uno::RuntimeException, "
217 "css::beans::UnknownPropertyException, css::lang::WrappedTargetException)"
218 "\n{\n return ::cppu::PropertySetMixin< "
219 << propertyhelper << " >::getPropertyValue(aPropertyName);\n}\n\n";
221 o << "void SAL_CALL " << classname << "addPropertyChangeListener(const "
222 "OUString & aPropertyName, const css::uno::Reference< "
223 "css::beans::XPropertyChangeListener > & xListener) throw ("
224 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
225 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
226 << propertyhelper
227 << " >::addPropertyChangeListener(aPropertyName, xListener);\n}\n\n";
229 o << "void SAL_CALL " << classname << "removePropertyChangeListener(const "
230 "OUString & aPropertyName, const css::uno::Reference< "
231 "css::beans::XPropertyChangeListener > & xListener) throw ("
232 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
233 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
234 << propertyhelper
235 << " >::removePropertyChangeListener(aPropertyName, xListener);\n}\n\n";
237 o << "void SAL_CALL " << classname << "addVetoableChangeListener(const "
238 "OUString & aPropertyName, const css::uno::Reference< "
239 "css::beans::XVetoableChangeListener > & xListener) throw ("
240 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
241 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
242 << propertyhelper
243 << " >::addVetoableChangeListener(aPropertyName, xListener);\n}\n\n";
245 o << "void SAL_CALL " << classname << "removeVetoableChangeListener(const "
246 "OUString & aPropertyName, const css::uno::Reference< "
247 "css::beans::XVetoableChangeListener > & xListener) throw ("
248 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
249 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
250 << propertyhelper
251 << " >::removeVetoableChangeListener(aPropertyName, xListener);\n}\n\n";
254 void generateXFastPropertySetBodies(std::ostream& o,
255 const OString & classname,
256 const OString & propertyhelper)
258 o << "// com.sun.star.beans.XFastPropertySet:\n";
260 o << "void SAL_CALL " << classname << "setFastPropertyValue( ::sal_Int32 "
261 "nHandle, const css::uno::Any& aValue ) throw ("
262 "css::beans::UnknownPropertyException, css::beans::PropertyVetoException, "
263 "css::lang::IllegalArgumentException, css::lang::WrappedTargetException, "
264 "css::uno::RuntimeException)\n{\n ::cppu::PropertySetMixin< "
265 << propertyhelper << " >::setFastPropertyValue(nHandle, aValue);\n}\n\n";
268 o << "css::uno::Any SAL_CALL " << classname << "getFastPropertyValue( "
269 "::sal_Int32 nHandle ) throw (css::beans::UnknownPropertyException, "
270 "css::lang::WrappedTargetException, css::uno::RuntimeException)\n{\n"
271 " return ::cppu::PropertySetMixin< "
272 << propertyhelper << " >::getFastPropertyValue(nHandle);\n}\n\n";
275 void generateXPropertyAccessBodies(std::ostream& o,
276 const OString & classname,
277 const OString & propertyhelper)
279 o << " // com.sun.star.beans.XPropertyAccess:\n";
281 o << "css::uno::Sequence< css::beans::PropertyValue > SAL_CALL "
282 << classname << "getPropertyValues( ) throw ("
283 "css::uno::RuntimeException)\n{\n"
284 " return ::cppu::PropertySetMixin< "
285 << propertyhelper << " >::getPropertyValues();\n}\n\n";
287 o << "void SAL_CALL " << classname << "setPropertyValues( const "
288 "css::uno::Sequence< css::beans::PropertyValue >& aProps ) throw ("
289 "css::beans::UnknownPropertyException, css::beans::PropertyVetoException, "
290 "css::lang::IllegalArgumentException, css::lang::WrappedTargetException, "
291 "css::uno::RuntimeException)\n{\n"
292 " ::cppu::PropertySetMixin< "
293 << propertyhelper << " >::setPropertyValues(aProps);\n}\n\n";
296 void generateXLocalizable(std::ostream& o, const OString & classname)
298 o << "// css::lang::XLocalizable:\n"
299 "void SAL_CALL " << classname << "setLocale(const css::lang::"
300 "Locale & eLocale) throw (css::uno::RuntimeException)\n{\n"
301 " m_locale = eLocale;\n}\n\n"
302 "css::lang::Locale SAL_CALL " << classname << "getLocale() "
303 "throw (css::uno::RuntimeException)\n{\n return m_locale;\n}\n\n";
306 void generateXAddInBodies(std::ostream& o, const OString & classname)
308 o << "// css::sheet::XAddIn:\n";
310 o << "OUString SAL_CALL " << classname << "getProgrammaticFuntionName("
311 "const OUString & aDisplayName) throw (css::uno::RuntimeException)"
312 "\n{\n OUString ret;\n try {\n css::uno::Reference< "
313 "css::container::XNameAccess > xNAccess(m_xHAccess, css::uno::UNO_QUERY);\n"
314 " css::uno::Sequence< OUString > functions = "
315 "xNAccess->getElementNames();\n sal_Int32 len = functions."
316 "getLength();\n OUString sDisplayName;\n"
317 " for (sal_Int32 i=0; i < len; ++i) {\n"
318 " sDisplayName = getAddinProperty(functions[i], "
319 "OUString(),\n "
320 "sDISPLAYNAME);\n if (sDisplayName.equals(aDisplayName))\n"
321 " return functions[i];\n }\n }\n"
322 " catch ( const css::uno::RuntimeException & e ) {\n throw e;\n }\n"
323 " catch ( css::uno::Exception & ) {\n }\n return ret;\n}\n\n";
325 o << "OUString SAL_CALL " << classname << "getDisplayFunctionName(const "
326 "OUString & aProgrammaticName) throw (css::uno::RuntimeException)\n"
327 "{\n return getAddinProperty(aProgrammaticName, OUString(), "
328 "sDISPLAYNAME);\n}\n\n";
330 o << "OUString SAL_CALL " << classname << "getFunctionDescription(const "
331 "OUString & aProgrammaticName) throw (css::uno::RuntimeException)\n"
332 "{\n return getAddinProperty(aProgrammaticName, OUString(), "
333 "sDESCRIPTION);\n}\n\n";
335 o << "OUString SAL_CALL " << classname << "getDisplayArgumentName(const "
336 "OUString & aProgrammaticFunctionName, ::sal_Int32 nArgument) throw "
337 "(css::uno::RuntimeException)\n{\n return getAddinProperty("
338 "aProgrammaticFunctionName,\n m_functionMap["
339 "aProgrammaticFunctionName][nArgument],\n"
340 " sDISPLAYNAME);\n}\n\n";
342 o << "OUString SAL_CALL " << classname << "getArgumentDescription(const "
343 "OUString & aProgrammaticFunctionName, ::sal_Int32 nArgument) throw "
344 "(css::uno::RuntimeException)\n{\n return getAddinProperty("
345 "aProgrammaticFunctionName,\n "
346 "m_functionMap[aProgrammaticFunctionName][nArgument],\n"
347 " sDESCRIPTION);\n}\n\n";
349 o << "OUString SAL_CALL " << classname << "getProgrammaticCategoryName("
350 "const OUString & aProgrammaticFunctionName) throw ("
351 "css::uno::RuntimeException)\n{\n return getAddinProperty("
352 "aProgrammaticFunctionName, OUString(), sCATEGORY);\n}\n\n";
354 o << "OUString SAL_CALL " << classname << "getDisplayCategoryName(const "
355 "OUString & aProgrammaticFunctionName) throw ("
356 "css::uno::RuntimeException)\n{\n return getAddinProperty("
357 "aProgrammaticFunctionName, OUString(), "
358 "sCATEGORYDISPLAYNAME);\n}\n\n";
361 void generateXCompatibilityNamesBodies(std::ostream& o, const OString & classname)
363 o << "// css::sheet::XCompatibilityNames:\n"
364 "css::uno::Sequence< css::sheet::LocalizedName > SAL_CALL " << classname
365 << "getCompatibilityNames(const OUString & aProgrammaticName) throw "
366 "(css::uno::RuntimeException)\n{\n css::uno::Sequence< "
367 "css::sheet::LocalizedName > seqLocalizedNames;\n try {\n "
368 "OUStringBuffer buf("
369 "aProgrammaticName);\n buf.appendAscii(\"/CompatibilityName\");\n"
370 " OUString hname(buf.makeStringAndClear());\n\n "
371 "if ( m_xCompAccess->hasByHierarchicalName(hname) ) {\n"
372 " css::uno::Reference< css::container::XNameAccess > "
373 "xNameAccess(\n"
374 " m_xCompAccess->getByHierarchicalName(hname), "
375 "css::uno::UNO_QUERY);\n\n css::uno::Sequence< OUString"
376 " > elems = \n xNameAccess->getElementNames();"
377 "\n ::sal_Int32 len = elems.getLength();\n\n "
378 "seqLocalizedNames.realloc(len);\n\n OUString "
379 "sCompatibilityName;\n for (::sal_Int32 i=0; i < len; ++i) {\n"
380 " OUString sLocale(elems[i]);\n "
381 "xNameAccess->getByName(sLocale) >>= sCompatibilityName;\n\n"
382 " css::lang::Locale aLocale;\n "
383 "::sal_Int32 nIndex = 0, nToken = 0;\n "
384 /* FIXME-BCP47: this will break. */
385 "do {\n OUString aToken = sLocale.getToken(0, '-', "
386 "nIndex);\n switch (nToken++) {\n "
387 "case 0:\n aLocale.Language = aToken;\n"
388 " break;\n case 1:\n"
389 " aLocale.Country = aToken;\n "
390 " break;\n default:\n "
391 "aLocale.Variant = sLocale.copy(nIndex-aToken.getLength()-1);\n"
392 " nIndex = -1;\n }\n"
393 " } while ( nIndex >= 0 );\n\n "
394 "seqLocalizedNames[i].Locale = aLocale;\n "
395 "seqLocalizedNames[i].Name = sCompatibilityName;\n }"
396 "\n }\n }\n catch ( const css::uno::RuntimeException & e ) {\n "
397 "throw e;\n }\n catch ( css::uno::Exception & ) {\n }\n\n"
398 " return seqLocalizedNames;\n}\n\n";
401 void generateXInitialization(std::ostream& o, const OString & classname)
403 o << "// css::lang::XInitialization:\n"
404 "void SAL_CALL " << classname << "initialize( const css::uno::Sequence< "
405 "css::uno::Any >& aArguments ) "
406 "throw (css::uno::Exception, css::uno::RuntimeException)\n{\n"
407 " css::uno::Reference < css::frame::XFrame > xFrame;\n"
408 " if ( aArguments.getLength() ) {\n aArguments[0] >>= xFrame;\n"
409 " m_xFrame = xFrame;\n }\n}\n\n";
412 void generateXDispatch(std::ostream& o,
413 const OString & classname,
414 const ProtocolCmdMap & protocolCmdMap)
416 // com.sun.star.frame.XDispatch
417 // dispatch
418 o << "// css::frame::XDispatch:\n"
419 "void SAL_CALL " << classname << "dispatch( const css::util::URL& aURL, const "
420 "css::uno::Sequence< css::beans::PropertyValue >& aArguments ) throw"
421 "(css::uno::RuntimeException)\n{\n";
423 for (const auto& rEntry : protocolCmdMap) {
424 o << " if ( aURL.Protocol.equalsAscii(\"" << rEntry.first
425 << "\") == 0 )\n {\n";
427 for (const auto& rCmd : rEntry.second) {
428 o << " if ( aURL.Path.equalsAscii(\"" << rCmd << "\") )\n"
429 " {\n // add your own code here\n"
430 " return;\n }\n";
433 o << " }\n";
435 o << "}\n\n";
437 // addStatusListener
438 o << "void SAL_CALL " << classname << "addStatusListener( const css::uno::Reference< "
439 "css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) "
440 "throw (css::uno::RuntimeException)\n{\n"
441 " // add your own code here\n}\n\n";
443 // removeStatusListener
444 o << "void SAL_CALL " << classname << "removeStatusListener( const css::uno::Reference"
445 "< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) "
446 "throw (css::uno::RuntimeException)\n{\n"
447 " // add your own code here\n}\n\n";
450 void generateXDispatchProvider(std::ostream& o,
451 const OString & classname,
452 const ProtocolCmdMap & protocolCmdMap)
455 // com.sun.star.frame.XDispatchProvider
456 // queryDispatch
457 o << "// css::frame::XDispatchProvider:\n"
458 "css::uno::Reference< css::frame::XDispatch > SAL_CALL " << classname
459 << "queryDispatch( const css::util::URL& aURL,"
460 " const OUString& sTargetFrameName, sal_Int32 nSearchFlags ) "
461 "throw(css::uno::RuntimeException)\n{\n css::uno::Reference< "
462 "css::frame::XDispatch > xRet;\n"
463 " if ( !m_xFrame.is() )\n return 0;\n\n";
465 for (const auto& rEntry : protocolCmdMap) {
466 o << " if ( aURL.Protocol.equalsAscii(\"" << rEntry.first
467 << "\") == 0 )\n {\n";
469 for (const auto& rCmd : rEntry.second) {
470 o << " if ( aURL.Path.equalsAscii(\"" << rCmd << "\") == 0 )\n"
471 " xRet = this;\n";
474 o << " }\n";
476 o << " return xRet;\n}\n\n";
478 // queryDispatches
479 o << "css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL "
480 << classname << "queryDispatches( const css::uno::Sequence< "
481 "css::frame::DispatchDescriptor >& seqDescripts ) throw("
482 "css::uno::RuntimeException)\n{\n"
483 " sal_Int32 nCount = seqDescripts.getLength();\n"
484 " css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > "
485 "lDispatcher(nCount);\n\n"
486 " for( sal_Int32 i=0; i<nCount; ++i ) {\n"
487 " lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL,\n"
488 " seqDescripts[i].FrameName,\n"
489 " seqDescripts[i].SearchFlags );\n"
490 " }\n\n return lDispatcher;\n}\n\n";
493 static void generateAddinConstructorAndHelper(std::ostream& o,
494 ProgramOptions const & options,
495 rtl::Reference< TypeManager > const & manager, const OString & classname,
496 const std::set< OUString >& interfaces)
498 o << classname << "::" << classname
499 << "(css::uno::Reference< css::uno::XComponentContext > const & context) :\n"
500 " m_xContext(context), m_locale()\n{\n";
502 if (options.backwardcompatible) {
503 o << " try {\n";
505 generateFunctionParameterMap(o, options, manager, interfaces);
507 o << " css::uno::Reference< css::lang::XMultiServiceFactory > xProvider"
508 "(\n m_xContext->getServiceManager()->createInstanceWithContext"
509 "(\n OUString(\n "
510 " \"com.sun.star.configuration.ConfigurationProvider\"),"
511 "\n m_xContext ), css::uno::UNO_QUERY );\n\n";
513 o << " OUString sReadOnlyView(\n"
514 " \"com.sun.star.configuration.ConfigurationAccess\");\n\n";
516 o << " OUStringBuffer sPath(OUString(\n"
517 " \"/org.openoffice.Office.CalcAddIns/AddInInfo/\"));\n"
518 " sPath.appendAscii(sADDIN_SERVICENAME);\n"
519 " sPath.appendAscii(\"/AddInFunctions\");\n\n"
520 " // create arguments: nodepath\n"
521 " css::beans::PropertyValue aArgument;\n"
522 " aArgument.Name = OUString(\"nodepath\");\n"
523 " aArgument.Value <<= sPath.makeStringAndClear();\n\n"
524 " css::uno::Sequence< css::uno::Any > aArguments(1);\n"
525 " aArguments[0] <<= aArgument;\n\n";
527 o << " // create the default view using default UI locale\n"
528 " css::uno::Reference< css::uno::XInterface > xIface =\n"
529 " xProvider->createInstanceWithArguments(sReadOnlyView, "
530 "aArguments);\n\n"
531 " m_xHAccess.set(xIface, css::uno::UNO_QUERY);"
532 "\n\n";
534 o << " // extend arguments to create a view for all locales to get "
535 "simple\n // access to the compatibilityname property\n"
536 " aArgument.Name = OUString(\"locale\");\n"
537 " aArgument.Value <<= OUString(\"*\");\n"
538 " aArguments.realloc(2);\n"
539 " aArguments[1] <<= aArgument;\n\n"
540 " // create view for all locales\n"
541 " xIface = xProvider->createInstanceWithArguments(sReadOnlyView, "
542 "aArguments);\n\n"
543 " m_xCompAccess.set(xIface, css::uno::UNO_QUERY);\n";
545 o << " }\n catch ( css::uno::Exception & ) {\n }\n}\n\n";
547 o << "// addin configuration property helper function:\nOUString "
548 "SAL_CALL " << classname << "::getAddinProperty(const OUString &"
549 " funcName, const OUString & paramName, const char * propName) "
550 "throw (css::uno::RuntimeException)\n{\n"
551 " OUString ret;\n try {\n "
552 "OUStringBuffer buf(funcName);\n"
553 " if (!paramName.isEmpty()) {\n"
554 " buf.appendAscii(\"/Parameters/\");\n"
555 " buf.append(paramName);\n }\n\n"
556 " css::uno::Reference< css::beans::XPropertySet > xPropSet(\n"
557 " m_xHAccess->getByHierarchicalName(\n"
558 " buf.makeStringAndClear()), css::uno::UNO_QUERY);\n"
559 " xPropSet->getPropertyValue(\n "
560 "OUString(propName)) >>= ret;\n }\n"
561 " catch ( const css::uno::RuntimeException & e ) {\n throw e;\n }\n"
562 " catch ( css::uno::Exception & ) {\n }\n return ret;\n";
564 o <<"}\n\n";
567 static void generateMemberInitialization(std::ostream& o,
568 ProgramOptions const & options,
569 rtl::Reference< TypeManager > const & manager,
570 AttributeInfo const & members)
572 for (const auto& rMember : members)
574 sal_Int32 rank;
575 if ((manager->decompose(rMember.type, true, nullptr, &rank, nullptr, nullptr)
576 <= codemaker::UnoType::Sort::Char)
577 && rank == 0)
579 o << ",\n m_" << rMember.name << "(";
580 printType(o, options, manager, rMember.type, 16, true);
581 o << ")";
586 static void generateMemberDeclaration(std::ostream& o,
587 ProgramOptions const & options,
588 rtl::Reference< TypeManager > const & manager,
589 AttributeInfo const & members)
591 for (const auto& rMember : members)
593 o << " ";
594 printType(o, options, manager, rMember.type, 1);
595 o << " m_" << rMember.name << ";\n";
599 static OString generateClassDefinition(std::ostream& o,
600 ProgramOptions const & options,
601 rtl::Reference< TypeManager > const & manager,
602 OString const & classname,
603 std::set< OUString > const & interfaces,
604 AttributeInfo const & properties,
605 AttributeInfo const & attributes,
606 std::set< OUString > const & propinterfaces,
607 OUString const & propertyhelper, bool supportxcomponent)
609 OStringBuffer parentname(64);
610 o << "class " << classname << ":\n";
612 if (!interfaces.empty()) {
613 if (supportxcomponent) {
614 parentname.append("::cppu::WeakComponentImplHelper");
615 parentname.append(static_cast<sal_Int32>(interfaces.size()));
616 o << " private ::cppu::BaseMutex,\n"
617 " public ::cppu::WeakComponentImplHelper"
618 << interfaces.size() << "<";
619 } else {
620 parentname.append("::cppu::WeakImplHelper");
621 parentname.append(static_cast<sal_Int32>(interfaces.size()));
622 o << " public ::cppu::WeakImplHelper" << interfaces.size() << "<";
625 std::set< OUString >::const_iterator iter = interfaces.begin();
626 while (iter != interfaces.end())
628 o << "\n " << scopedCppName(u2b(*iter));
629 ++iter;
630 if (iter != interfaces.end())
631 o << ",";
632 else
633 o << ">";
637 if (propertyhelper.getLength() > 1) {
638 o << ",\n public ::cppu::PropertySetMixin< "
639 << scopedCppName(u2b(propertyhelper)) << " >";
642 o << "\n{\npublic:\n"
643 " explicit " << classname << "("
644 "css::uno::Reference< css::uno::XComponentContext > const & context);\n\n";
646 // generate component/service helper functions
647 // o << " // component and service helper functions:\n"
648 // << " static OUString SAL_CALL _getImplementationName();\n"
649 // << " static css::uno::Sequence< OUString > SAL_CALL "
650 // << "_getSupportedServiceNames();\n"
651 // << " static css::uno::Reference< css::uno::XInterface > SAL_CALL _create("
652 // << "\n css::uno::Reference< css::uno::XComponentContext > const & "
653 // << "context);\n\n";
655 // override queryInterface
656 if (propertyhelper.getLength() > 1) {
657 o << " // css::uno::XInterface:\n"
658 " virtual css::uno::Any SAL_CALL queryInterface("
659 "css::uno::Type const & type) throw ("
660 "css::uno::RuntimeException);\n";
662 OStringBuffer buffer(256);
663 buffer.append(parentname.toString());
664 buffer.append("< ");
665 std::set< OUString >::const_iterator iter = interfaces.begin();
666 while (iter != interfaces.end())
668 buffer.append(scopedCppName(u2b(*iter)));
669 ++iter;
670 if (iter != interfaces.end())
671 buffer.append(", ");
672 else
673 buffer.append(" >");
675 OString parent(buffer.makeStringAndClear());
676 o << " virtual void SAL_CALL acquire() throw ()\n { "
677 << parent << "::acquire(); }\n";
678 o << " virtual void SAL_CALL release() throw ()\n { "
679 << parent << "::release(); }\n\n";
682 codemaker::GeneratedTypeSet generated;
683 for (const auto& rIface : interfaces)
685 printMethods(o, options, manager, rIface, generated, "", "", " ",
686 true, propertyhelper);
689 o << "private:\n " << classname << "(const " << classname << " &); // not defined\n"
690 " " << classname << "& operator=(const " << classname << " &); // not defined\n\n"
691 " // destructor is private and will be called indirectly by the release call"
692 " virtual ~" << classname << "() {}\n\n";
694 if (options.componenttype == 2) {
695 o << " typedef boost::unordered_map< ::sal_Int32, OUString, "
696 "boost::hash<::sal_Int32> > ParamMap;\n"
697 " typedef boost::unordered_map< OUString, ParamMap, "
698 "OUStringHash > FunctionMap;\n\n"
699 " OUString SAL_CALL getAddinProperty(const OUString & "
700 "funcName, const OUString & paramName, const char * propName) "
701 "throw (css::uno::RuntimeException);\n\n";
704 if (supportxcomponent) {
705 o << " // override WeakComponentImplHelperBase::disposing()\n"
706 " // This function is called upon disposing the component,\n"
707 " // if your component needs special work when it becomes\n"
708 " // disposed, do it here.\n"
709 " virtual void SAL_CALL disposing();\n\n";
712 // members
713 o << " css::uno::Reference< css::uno::XComponentContext > m_xContext;\n";
714 if (!supportxcomponent && !attributes.empty())
715 o << " mutable ::osl::Mutex m_aMutex;\n";
717 // additional member for add-ons
718 if (options.componenttype == 3) {
719 o << " css::uno::Reference< css::frame::XFrame > m_xFrame;\n";
722 if (options.componenttype == 2) {
723 if (options.backwardcompatible) {
724 o <<" css::uno::Reference< css::container::XHierarchicalNameAccess > "
725 "m_xHAccess;\n"
726 " css::uno::Reference< css::container::XHierarchicalNameAccess > "
727 "m_xCompAccess;\n"
728 " FunctionMap m_functionMap;\n";
730 o << " css::lang::Locale m_locale;\n";
733 generateMemberDeclaration(o, options, manager, properties);
734 generateMemberDeclaration(o, options, manager, attributes);
736 // if (!properties.empty())
737 // {
738 // AttributeInfo::const_iterator iter = properties.begin();
739 // while (iter != properties.end())
740 // {
741 // o << " ";
742 // printType(o, options, manager, iter->second.first.replace('.','/'),
743 // 1, false);
744 // o << " m_" << iter->first << ";\n";
745 // ++iter;
746 // }
747 // }
748 // if (!attributes.empty())
749 // {
750 // AttributeInfo::const_iterator iter = attributes.begin();
751 // while (iter != attributes.end())
752 // {
753 // o << " ";
754 // printType(o, options, manager, iter->second.first.replace('.','/'),
755 // 1, false);
756 // o << " m_" << iter->first << ";\n";
757 // ++iter;
758 // }
759 // }
761 o << "};\n\n";
763 // generate constructor
764 if (options.componenttype == 2) {
765 generateAddinConstructorAndHelper(o, options, manager,
766 classname, interfaces);
767 } else {
768 o << classname << "::" << classname
769 << "(css::uno::Reference< css::uno::XComponentContext > const & context) :\n";
770 if (supportxcomponent) {
771 o << " ::cppu::WeakComponentImplHelper" << interfaces.size() << "<";
772 std::set< OUString >::const_iterator iter = interfaces.begin();
773 while (iter != interfaces.end()) {
774 o << "\n " << scopedCppName(u2b(*iter));
775 ++iter;
776 if (iter != interfaces.end())
777 o << ",";
778 else
779 o << ">(m_aMutex),\n";
782 if (propertyhelper.getLength() > 1) {
783 o << " ::cppu::PropertySetMixin< "
784 << scopedCppName(u2b(propertyhelper)) << " >(\n"
785 " context, static_cast< Implements >(\n ";
786 OStringBuffer buffer(128);
787 if (propinterfaces.find("com/sun/star/beans/XPropertySet")
788 != propinterfaces.end()) {
789 buffer.append("IMPLEMENTS_PROPERTY_SET");
791 if (propinterfaces.find("com/sun/star/beans/XFastPropertySet")
792 != propinterfaces.end()) {
793 if (!buffer.isEmpty())
794 buffer.append(" | IMPLEMENTS_FAST_PROPERTY_SET");
795 else
796 buffer.append("IMPLEMENTS_FAST_PROPERTY_SET");
798 if (propinterfaces.find("com/sun/star/beans/XPropertyAccess")
799 != propinterfaces.end()) {
800 if (!buffer.isEmpty())
801 buffer.append(" | IMPLEMENTS_PROPERTY_ACCESS");
802 else
803 buffer.append("IMPLEMENTS_PROPERTY_ACCESS");
805 o << buffer.makeStringAndClear()
806 << "), css::uno::Sequence< OUString >()),\n";
808 o << " m_xContext(context)";
810 generateMemberInitialization(o, options, manager, properties);
811 generateMemberInitialization(o, options, manager, attributes);
813 o << "\n{}\n\n";
816 // generate service/component helper function implementations
817 // generateServiceHelper(o, options.implname, classname, services);
819 if (supportxcomponent) {
820 o << "// override WeakComponentImplHelperBase::disposing()\n"
821 "// This function is called upon disposing the component,\n"
822 "// if your component needs special work when it becomes\n"
823 "// disposed, do it here.\n"
824 "void SAL_CALL " << classname << "::disposing()\n{\n\n}\n\n";
827 return parentname.makeStringAndClear();
830 static void generateXServiceInfoBodies(std::ostream& o,
831 OString const & classname,
832 OString const & comphelpernamespace)
834 o << "// com.sun.star.uno.XServiceInfo:\n"
835 "OUString SAL_CALL " << classname << "getImplementationName() "
836 "throw (css::uno::RuntimeException)\n{\n "
837 "return " << comphelpernamespace << "::_getImplementationName();\n}\n\n";
839 o << "sal_Bool SAL_CALL " << classname
840 << "supportsService(OUString const & "
841 "serviceName) throw (css::uno::RuntimeException)\n{\n "
842 "css::uno::Sequence< OUString > serviceNames = "
843 << comphelpernamespace << "::_getSupportedServiceNames();\n "
844 "for (::sal_Int32 i = 0; i < serviceNames.getLength(); ++i) {\n "
845 " if (serviceNames[i] == serviceName)\n return sal_True;\n"
846 " }\n return sal_False;\n}\n\n";
848 o << "css::uno::Sequence< OUString > SAL_CALL " << classname
849 << "getSupportedServiceNames() throw (css::uno::RuntimeException)\n{\n "
850 "return " << comphelpernamespace
851 << "::_getSupportedServiceNames();\n}\n\n";
855 static void generateMethodBodies(std::ostream& o,
856 ProgramOptions const & options,
857 rtl::Reference< TypeManager > const & manager,
858 std::set< OUString > const & interfaces,
859 OString const & classname,
860 OString const & comphelpernamespace,
861 OUString const & propertyhelper)
863 OString name = classname + "::";
864 codemaker::GeneratedTypeSet generated;
865 for (const auto& rIface : interfaces) {
866 if ( rIface == "com.sun.star.lang.XServiceInfo" ) {
867 generateXServiceInfoBodies(o, name, comphelpernamespace);
868 generated.add(u2b(rIface));
869 } else {
870 printMethods(o, options, manager, rIface, generated, "_",
871 name, "", true, propertyhelper);
876 static void generateQueryInterface(std::ostream& o,
877 ProgramOptions const & options,
878 rtl::Reference< TypeManager > const & manager,
879 const std::set< OUString >& interfaces,
880 OString const & parentname,
881 OString const & classname,
882 OUString const & propertyhelper)
884 if (propertyhelper.isEmpty())
885 return;
887 o << "css::uno::Any " << classname
888 << "::queryInterface(css::uno::Type const & type) throw ("
889 "css::uno::RuntimeException)\n{\n ";
891 if (!propertyhelper.isEmpty())
892 o << "return ";
893 else
894 o << "css::uno::Any a(";
896 o << parentname << "<";
897 std::set< OUString >::const_iterator iter = interfaces.begin();
898 while (iter != interfaces.end())
900 o << "\n " << scopedCppName(u2b(*iter));
901 ++iter;
902 if (iter != interfaces.end())
903 o << ",";
904 else
905 o << ">";
908 if (!propertyhelper.isEmpty()) {
909 o << "::queryInterface(type);\n";
910 } else {
911 o << "::queryInterface(type));\n";
912 o << " return a.hasValue() ? a\n : (";
913 if (propertyhelper == "_") {
914 o << "::cppu::OPropertySetHelper::queryInterface(type));\n";
915 } else {
916 o << "::cppu::PropertySetMixin<\n ";
917 printType(o, options, manager, propertyhelper, 0);
918 o << " >::queryInterface(\n type));\n";
921 o << "}\n\n";
924 void generateSkeleton(ProgramOptions const & options,
925 rtl::Reference< TypeManager > const & manager,
926 std::vector< OString > const & types)
928 // special handling of calc add-ins
929 if (options.componenttype == 2) {
930 generateCalcAddin(options, manager, types);
931 return;
934 std::set< OUString > interfaces;
935 std::set< OUString > services;
936 AttributeInfo properties;
937 AttributeInfo attributes;
938 std::set< OUString > propinterfaces;
939 bool serviceobject = false;
940 bool supportxcomponent = false;
942 for (const auto& rType : types) {
943 checkType(manager, b2u(rType), interfaces, services, properties);
946 if (options.componenttype == 3) {
947 // the Protocolhandler service is mandatory for a protocol handler add-on,
948 // so it is defaulted. The XDispatchProvider provides Dispatch objects for
949 // certain functions and the generated impl object implements XDispatch
950 // directly for simplicity reasons.
951 checkType(manager, "com.sun.star.frame.ProtocolHandler",
952 interfaces, services, properties);
953 checkType(manager, "com.sun.star.frame.XDispatch",
954 interfaces, services, properties);
957 // check if service object or simple UNO object
958 if (!services.empty())
959 serviceobject = true;
961 OUString propertyhelper = checkPropertyHelper(
962 options, manager, services, interfaces, attributes, propinterfaces);
964 checkDefaultInterfaces(interfaces, services, propertyhelper);
966 if (interfaces.size() > 12)
967 throw CannotDumpException(
968 "the skeletonmaker supports components with 12 interfaces "
969 "only (limitation of the UNO implementation helpers)!");
972 supportxcomponent = checkXComponentSupport(manager, interfaces);
974 OString compFileName;
975 OString tmpFileName;
976 std::ostream* pofs = nullptr;
977 bool standardout = getOutputStream(options, ".cxx",
978 &pofs, compFileName, tmpFileName);
980 try {
981 if (!standardout && options.license) {
982 printLicenseHeader(*pofs, compFileName);
985 generateIncludes(*pofs, interfaces, propertyhelper, serviceobject,
986 supportxcomponent);
988 if (options.componenttype == 3) {
989 *pofs << "#include \"com/sun/star/frame/XFrame.hpp\"\n";
992 // namespace
993 OString nmspace;
994 short nm = 0;
996 if (serviceobject) {
997 nmspace = generateCompHelperDeclaration(*pofs, options.implname);
999 *pofs <<
1000 "\n\n/// anonymous implementation namespace\nnamespace {\n\n"
1001 "namespace css = ::com::sun::star;\n\n";
1002 } else {
1003 nm = generateNamespace(*pofs, options.implname, false, nmspace);
1004 *pofs << "namespace css = ::com::sun::star;\n\n";
1007 sal_Int32 index = 0;
1008 OString classname(options.implname);
1009 if ((index = classname.lastIndexOf('.')) > 0)
1010 classname = classname.copy(index+1);
1012 OString parentname(
1013 generateClassDefinition(*pofs,
1014 options, manager, classname, interfaces, properties,
1015 attributes, propinterfaces, propertyhelper, supportxcomponent));
1017 generateQueryInterface(*pofs, options, manager, interfaces, parentname,
1018 classname, propertyhelper);
1020 generateMethodBodies(*pofs, options, manager, interfaces, classname,
1021 nmspace, propertyhelper);
1023 if (serviceobject) {
1024 // close namespace
1025 *pofs << "} // closing anonymous implementation namespace\n\n";
1027 generateCompHelperDefinition(*pofs, options.implname,
1028 classname, services);
1029 generateCompFunctions(*pofs, nmspace);
1030 } else {
1031 // close namespace
1032 for (short i=0; i < nm; i++)
1033 *pofs << "} ";
1034 *pofs << (nm > 0 ? "// closing namespace\n\n" : "\n");
1037 if (!standardout)
1039 if (static_cast<std::ofstream*>(pofs)->is_open())
1040 static_cast<std::ofstream*>(pofs)->close();
1041 delete pofs;
1042 OSL_VERIFY(makeValidTypeFile(compFileName, tmpFileName, false));
1044 } catch (CannotDumpException & e) {
1045 std::cerr << "ERROR: " << e.getMessage() << "\n";
1046 if ( !standardout ) {
1047 if (static_cast<std::ofstream*>(pofs)->is_open())
1048 static_cast<std::ofstream*>(pofs)->close();
1049 delete pofs;
1050 // remove existing type file if something goes wrong to ensure
1051 // consistency
1052 if (fileExists(compFileName))
1053 removeTypeFile(compFileName);
1055 // remove tmp file if something goes wrong
1056 removeTypeFile(tmpFileName);
1061 void generateCalcAddin(ProgramOptions const & options,
1062 rtl::Reference< TypeManager > const & manager,
1063 std::vector< OString > const & types)
1065 std::set< OUString > interfaces;
1066 std::set< OUString > services;
1067 AttributeInfo properties;
1068 AttributeInfo attributes;
1069 std::set< OUString > propinterfaces;
1070 bool serviceobject = false;
1071 bool supportxcomponent = false;
1074 for (const auto& rType : types) {
1075 checkType(manager, b2u(rType), interfaces, services, properties);
1078 OUString sAddinService;
1079 if (services.size() != 1) {
1080 throw CannotDumpException(
1081 "for calc add-in components one and only one service type is necessary!"
1082 " Please reference a valid type with the '-t' option.");
1086 // get the one and only add-in service for later use
1087 std::set< OUString >::const_iterator iter2 = services.begin();
1088 sAddinService = *iter2;
1089 if (sAddinService == "com.sun.star.sheet.AddIn") {
1090 sAddinService = *(++iter2);
1093 // if backwardcompatible==true the AddIn service needs to be added to the
1094 // supported service list, the necessary interfaces are mapped to the add-in
1095 // configuration. Since OO.org 2.0.4 this is obsolete and the add-in is
1096 // taken from the configuration from Calc directly, this simplifies the
1097 // add-in code
1098 if (options.backwardcompatible) {
1099 checkType(manager, "com.sun.star.sheet.AddIn",
1100 interfaces, services, properties);
1101 } else {
1102 // special case for the optional XLocalization interface. It should be
1103 // implemented always. But it is parent of the XAddIn and we need it only
1104 // if backwardcompatible is false.
1105 interfaces.insert("com.sun.star.lang.XLocalizable");
1108 OUString propertyhelper = checkPropertyHelper(
1109 options, manager, services, interfaces, attributes, propinterfaces);
1111 if (!propertyhelper.isEmpty())
1112 std::cerr << "WARNING: interfaces specifying calc add-in functions "
1113 "shouldn't support attributes!\n";
1115 checkDefaultInterfaces(interfaces, services, propertyhelper);
1117 if (interfaces.size() > 12) {
1118 throw CannotDumpException(
1119 "the skeletonmaker supports components with 12 interfaces "
1120 "only (limitation of the UNO implementation helpers)!");
1123 // check if service object or simple UNO object
1124 if (!services.empty())
1125 serviceobject = true;
1127 supportxcomponent = checkXComponentSupport(manager, interfaces);
1128 if (supportxcomponent)
1129 std::cerr << "WARNING: add-ins shouldn't support "
1130 "com.sun.star.uno.XComponent!\n";
1132 OString compFileName;
1133 OString tmpFileName;
1134 std::ostream* pofs = nullptr;
1135 bool standardout = getOutputStream(options, ".cxx",
1136 &pofs, compFileName, tmpFileName);
1138 try {
1139 if (!standardout && options.license) {
1140 printLicenseHeader(*pofs, compFileName);
1143 generateIncludes(*pofs, interfaces, propertyhelper, serviceobject,
1144 supportxcomponent);
1146 *pofs <<
1147 "#include \"com/sun/star/beans/PropertyValue.hpp\"\n"
1148 "#include \"com/sun/star/beans/XPropertySet.hpp\"\n"
1149 "#include \"com/sun/star/container/XNameAccess.hpp\"\n"
1150 "#include \"com/sun/star/container/XHierarchicalNameAccess.hpp\"\n\n"
1151 "#include \"rtl/ustrbuf.hxx\"\n\n"
1152 "#include <boost/unordered_map.hpp>\n"
1153 "#include <set>\n";
1155 // namespace
1156 OString nmspace(generateCompHelperDeclaration(*pofs, options.implname));
1158 *pofs <<
1159 "\n\n// anonymous implementation namespace\nnamespace {\n\n"
1160 "namespace css = ::com::sun::star;\n\n";
1162 sal_Int32 index = 0;
1163 OString classname(options.implname);
1164 if ((index = classname.lastIndexOf('.')) > 0) {
1165 classname = classname.copy(index+1);
1168 if (options.backwardcompatible) {
1169 *pofs << "static const char * sADDIN_SERVICENAME = \""
1170 << sAddinService << "\";\n\n";
1171 *pofs << "static const char * sDISPLAYNAME = \"DisplayName\";\n"
1172 "static const char * sDESCRIPTION = \"Description\";\n"
1173 "static const char * sCATEGORY = \"Category\";\n"
1174 "static const char * sCATEGORYDISPLAYNAME = \"CategoryDisplayName\";"
1175 "\n\n";
1178 OString parentname(
1179 generateClassDefinition(*pofs,
1180 options, manager, classname, interfaces, properties,
1181 attributes, propinterfaces, propertyhelper, supportxcomponent));
1183 generateQueryInterface(*pofs, options, manager, interfaces, parentname,
1184 classname, propertyhelper);
1186 generateMethodBodies(*pofs, options, manager, interfaces, classname,
1187 nmspace, propertyhelper);
1189 // close namespace
1190 *pofs << "} // closing anonymous implementation namespace\n\n";
1192 generateCompHelperDefinition(*pofs, options.implname, classname,
1193 services);
1195 generateCompFunctions(*pofs, nmspace);
1197 if (!standardout)
1199 if (static_cast<std::ofstream*>(pofs)->is_open())
1200 static_cast<std::ofstream*>(pofs)->close();
1201 delete pofs;
1202 OSL_VERIFY(makeValidTypeFile(compFileName, tmpFileName, false));
1204 } catch (CannotDumpException & e) {
1205 std::cerr << "ERROR: " << e.getMessage() << "\n";
1206 if ( !standardout ) {
1207 if (static_cast<std::ofstream*>(pofs)->is_open())
1208 static_cast<std::ofstream*>(pofs)->close();
1209 delete pofs;
1210 // remove existing type file if something goes wrong to ensure
1211 // consistency
1212 if (fileExists(compFileName))
1213 removeTypeFile(compFileName);
1215 // remove tmp file if something goes wrong
1216 removeTypeFile(tmpFileName);
1224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */