Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / unodevtools / source / skeletonmaker / cppcompskeleton.cxx
blob0fba9d46ab1429f261576a5401b61e7e302de939
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 { namespace cpp {
34 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 std::set< OUString >::const_iterator iter = interfaces.begin();
61 while (iter != interfaces.end())
63 o << "#include \""
64 << (*iter).replace('.', '/')
65 << ".hpp\"\n";
66 ++iter;
70 short generateNamespace(std::ostream & o,
71 const OString & implname,
72 bool serviceobject,
73 OString & nm)
75 short count=0;
76 sal_Int32 index = implname.lastIndexOf('.');
77 if (serviceobject) {
78 o << "\n\n// component helper namespace\n";
79 } else {
80 o << "\n";
82 OStringBuffer buf;
83 if (index == -1) {
84 if (serviceobject) {
85 buf.append("comp_");
86 buf.append(implname);
87 nm = buf.makeStringAndClear();
88 o << "namespace comp_" << implname << " {\n\n";
89 count=1;
90 } else {
91 nm.clear();
93 } else {
94 sal_Int32 nPos=0;
95 do {
96 OString token(implname.getToken(0, '.', nPos));
97 if (nPos < 0 && serviceobject) {
98 buf.append("::comp_");
99 buf.append(token);
100 o << "namespace comp_" << token << " { ";
101 count++;
102 } else {
103 buf.append("::");
104 buf.append(token);
105 o << "namespace " << token << " { ";
106 count++;
108 } while( nPos <= index );
109 nm = buf.makeStringAndClear();
110 o << "\n\n";
112 return count;
115 OString generateCompHelperDeclaration(std::ostream & o,
116 const OString & implname)
118 OString nm;
119 short nbrackets = generateNamespace(o, implname, true, nm);
121 o << "namespace css = ::com::sun::star;\n\n";
123 // generate component/service helper functions
124 o << "// component and service helper functions:\n"
125 "::rtl::OUString SAL_CALL _getImplementationName();\n"
126 "css::uno::Sequence< ::rtl::OUString > SAL_CALL "
127 "_getSupportedServiceNames();\n"
128 "css::uno::Reference< css::uno::XInterface > SAL_CALL _create("
129 " css::uno::Reference< css::uno::XComponentContext > const & "
130 "context );\n\n";
132 // close namespace
133 for (short i=0; i < nbrackets; i++)
134 o << "} ";
135 o << "// closing component helper namespace\n\n";
137 return nm;
140 void generateCompHelperDefinition(std::ostream & o,
141 const OString & implname,
142 const OString & classname,
143 const std::set< OUString >& services)
145 OString nm;
146 short nbrackets = generateNamespace(o, implname, true, nm);
148 o << "::rtl::OUString SAL_CALL _getImplementationName() {\n"
149 " return ::rtl::OUString(\n"
150 " \"" << implname << "\");\n}\n\n";
152 o << "css::uno::Sequence< ::rtl::OUString > SAL_CALL "
153 "_getSupportedServiceNames()\n{\n css::uno::Sequence< "
154 "::rtl::OUString > s(" << services.size() << ");\n";
156 std::set< OUString >::const_iterator iter = services.begin();
157 short i=0;
158 while (iter != services.end())
160 o << " s[" << i++ << "] = ::rtl::OUString(\""
161 << *iter << "\");\n";
162 ++iter;
164 o << " return s;\n}\n\n";
166 o << "css::uno::Reference< css::uno::XInterface > SAL_CALL _create("
167 "\n const css::uno::Reference< css::uno::XComponentContext > & "
168 "context)\n{\n"
169 " return static_cast< ::cppu::OWeakObject * >(new "
170 << classname << "(context));\n}\n\n";
172 // close namespace
173 for (short j=0; j < nbrackets; j++)
174 o << "} ";
175 o << "// closing component helper namespace\n\n";
179 void generateCompFunctions(std::ostream & o, const OString & nmspace)
181 o << "static ::cppu::ImplementationEntry const entries[] = {\n"
182 " { &" << nmspace << "::_create,\n &"
183 << nmspace << "::_getImplementationName,\n &"
184 << nmspace << "::_getSupportedServiceNames,\n"
185 " &::cppu::createSingleComponentFactory, 0, 0 },\n"
186 " { 0, 0, 0, 0, 0, 0 }\n};\n\n";
188 o << "extern \"C\" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(\n"
189 " const char * implName, void * serviceManager, void * registryKey)\n{\n"
190 " return ::cppu::component_getFactoryHelper(\n"
191 " implName, serviceManager, registryKey, entries);\n}\n\n";
193 o << "extern \"C\" sal_Bool SAL_CALL component_writeInfo(\n"
194 " void * serviceManager, void * registryKey)\n{\n"
195 " return ::cppu::component_writeInfoHelper("
196 "serviceManager, registryKey, entries);\n}\n";
199 void generateXPropertySetBodies(std::ostream& o,
200 const OString & classname,
201 const OString & propertyhelper)
203 o << "// com.sun.star.beans.XPropertySet:\n";
205 o << "css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL "
206 << classname << "getPropertySetInfo() throw ("
207 "css::uno::RuntimeException)\n{\n return ::cppu::PropertySetMixin< "
208 << propertyhelper
209 << " >::getPropertySetInfo();\n}\n\n";
211 o << "void SAL_CALL " << classname << "setPropertyValue(const ::rtl::OUString"
212 " & aPropertyName, const css::uno::Any & aValue) throw ("
213 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
214 "css::beans::PropertyVetoException, css::lang::IllegalArgumentException, "
215 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
216 << propertyhelper << " >::setPropertyValue(aPropertyName, aValue);\n}\n\n";
219 o << "css::uno::Any SAL_CALL " << classname << "getPropertyValue(const "
220 "::rtl::OUString & aPropertyName) throw (css::uno::RuntimeException, "
221 "css::beans::UnknownPropertyException, css::lang::WrappedTargetException)"
222 "\n{\n return ::cppu::PropertySetMixin< "
223 << propertyhelper << " >::getPropertyValue(aPropertyName);\n}\n\n";
225 o << "void SAL_CALL " << classname << "addPropertyChangeListener(const "
226 "::rtl::OUString & aPropertyName, const css::uno::Reference< "
227 "css::beans::XPropertyChangeListener > & xListener) throw ("
228 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
229 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
230 << propertyhelper
231 << " >::addPropertyChangeListener(aPropertyName, xListener);\n}\n\n";
233 o << "void SAL_CALL " << classname << "removePropertyChangeListener(const "
234 "::rtl::OUString & aPropertyName, const css::uno::Reference< "
235 "css::beans::XPropertyChangeListener > & xListener) throw ("
236 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
237 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
238 << propertyhelper
239 << " >::removePropertyChangeListener(aPropertyName, xListener);\n}\n\n";
241 o << "void SAL_CALL " << classname << "addVetoableChangeListener(const "
242 "::rtl::OUString & aPropertyName, const css::uno::Reference< "
243 "css::beans::XVetoableChangeListener > & xListener) throw ("
244 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
245 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
246 << propertyhelper
247 << " >::addVetoableChangeListener(aPropertyName, xListener);\n}\n\n";
249 o << "void SAL_CALL " << classname << "removeVetoableChangeListener(const "
250 "::rtl::OUString & aPropertyName, const css::uno::Reference< "
251 "css::beans::XVetoableChangeListener > & xListener) throw ("
252 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
253 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
254 << propertyhelper
255 << " >::removeVetoableChangeListener(aPropertyName, xListener);\n}\n\n";
258 void generateXFastPropertySetBodies(std::ostream& o,
259 const OString & classname,
260 const OString & propertyhelper)
262 o << "// com.sun.star.beans.XFastPropertySet:\n";
264 o << "void SAL_CALL " << classname << "setFastPropertyValue( ::sal_Int32 "
265 "nHandle, const css::uno::Any& aValue ) throw ("
266 "css::beans::UnknownPropertyException, css::beans::PropertyVetoException, "
267 "css::lang::IllegalArgumentException, css::lang::WrappedTargetException, "
268 "css::uno::RuntimeException)\n{\n ::cppu::PropertySetMixin< "
269 << propertyhelper << " >::setFastPropertyValue(nHandle, aValue);\n}\n\n";
272 o << "css::uno::Any SAL_CALL " << classname << "getFastPropertyValue( "
273 "::sal_Int32 nHandle ) throw (css::beans::UnknownPropertyException, "
274 "css::lang::WrappedTargetException, css::uno::RuntimeException)\n{\n"
275 " return ::cppu::PropertySetMixin< "
276 << propertyhelper << " >::getFastPropertyValue(nHandle);\n}\n\n";
279 void generateXPropertyAccessBodies(std::ostream& o,
280 const OString & classname,
281 const OString & propertyhelper)
283 o << " // com.sun.star.beans.XPropertyAccess:\n";
285 o << "css::uno::Sequence< css::beans::PropertyValue > SAL_CALL "
286 << classname << "getPropertyValues( ) throw ("
287 "css::uno::RuntimeException)\n{\n"
288 " return ::cppu::PropertySetMixin< "
289 << propertyhelper << " >::getPropertyValues();\n}\n\n";
291 o << "void SAL_CALL " << classname << "setPropertyValues( const "
292 "css::uno::Sequence< css::beans::PropertyValue >& aProps ) throw ("
293 "css::beans::UnknownPropertyException, css::beans::PropertyVetoException, "
294 "css::lang::IllegalArgumentException, css::lang::WrappedTargetException, "
295 "css::uno::RuntimeException)\n{\n"
296 " ::cppu::PropertySetMixin< "
297 << propertyhelper << " >::setPropertyValues(aProps);\n}\n\n";
300 void generateXLocalizable(std::ostream& o, const OString & classname)
302 o << "// css::lang::XLocalizable:\n"
303 "void SAL_CALL " << classname << "setLocale(const css::lang::"
304 "Locale & eLocale) throw (css::uno::RuntimeException)\n{\n"
305 " m_locale = eLocale;\n}\n\n"
306 "css::lang::Locale SAL_CALL " << classname << "getLocale() "
307 "throw (css::uno::RuntimeException)\n{\n return m_locale;\n}\n\n";
310 void generateXAddInBodies(std::ostream& o, const OString & classname)
312 o << "// css::sheet::XAddIn:\n";
314 o << "::rtl::OUString SAL_CALL " << classname << "getProgrammaticFuntionName("
315 "const ::rtl::OUString & aDisplayName) throw (css::uno::RuntimeException)"
316 "\n{\n ::rtl::OUString ret;\n try {\n css::uno::Reference< "
317 "css::container::XNameAccess > xNAccess(m_xHAccess, css::uno::UNO_QUERY);\n"
318 " css::uno::Sequence< ::rtl::OUString > functions = "
319 "xNAccess->getElementNames();\n sal_Int32 len = functions."
320 "getLength();\n ::rtl::OUString sDisplayName;\n"
321 " for (sal_Int32 i=0; i < len; ++i) {\n"
322 " sDisplayName = getAddinProperty(functions[i], "
323 "::rtl::OUString(),\n "
324 "sDISPLAYNAME);\n if (sDisplayName.equals(aDisplayName))\n"
325 " return functions[i];\n }\n }\n"
326 " catch ( const css::uno::RuntimeException & e ) {\n throw e;\n }\n"
327 " catch ( css::uno::Exception & ) {\n }\n return ret;\n}\n\n";
329 o << "::rtl::OUString SAL_CALL " << classname << "getDisplayFunctionName(const "
330 "::rtl::OUString & aProgrammaticName) throw (css::uno::RuntimeException)\n"
331 "{\n return getAddinProperty(aProgrammaticName, ::rtl::OUString(), "
332 "sDISPLAYNAME);\n}\n\n";
334 o << "::rtl::OUString SAL_CALL " << classname << "getFunctionDescription(const "
335 "::rtl::OUString & aProgrammaticName) throw (css::uno::RuntimeException)\n"
336 "{\n return getAddinProperty(aProgrammaticName, ::rtl::OUString(), "
337 "sDESCRIPTION);\n}\n\n";
339 o << "::rtl::OUString SAL_CALL " << classname << "getDisplayArgumentName(const "
340 "::rtl::OUString & aProgrammaticFunctionName, ::sal_Int32 nArgument) throw "
341 "(css::uno::RuntimeException)\n{\n return getAddinProperty("
342 "aProgrammaticFunctionName,\n m_functionMap["
343 "aProgrammaticFunctionName][nArgument],\n"
344 " sDISPLAYNAME);\n}\n\n";
346 o << "::rtl::OUString SAL_CALL " << classname << "getArgumentDescription(const "
347 "::rtl::OUString & aProgrammaticFunctionName, ::sal_Int32 nArgument) throw "
348 "(css::uno::RuntimeException)\n{\n return getAddinProperty("
349 "aProgrammaticFunctionName,\n "
350 "m_functionMap[aProgrammaticFunctionName][nArgument],\n"
351 " sDESCRIPTION);\n}\n\n";
353 o << "::rtl::OUString SAL_CALL " << classname << "getProgrammaticCategoryName("
354 "const ::rtl::OUString & aProgrammaticFunctionName) throw ("
355 "css::uno::RuntimeException)\n{\n return getAddinProperty("
356 "aProgrammaticFunctionName, ::rtl::OUString(), sCATEGORY);\n}\n\n";
358 o << "::rtl::OUString SAL_CALL " << classname << "getDisplayCategoryName(const "
359 "::rtl::OUString & aProgrammaticFunctionName) throw ("
360 "css::uno::RuntimeException)\n{\n return getAddinProperty("
361 "aProgrammaticFunctionName, ::rtl::OUString(), "
362 "sCATEGORYDISPLAYNAME);\n}\n\n";
365 void generateXCompatibilityNamesBodies(std::ostream& o, const OString & classname)
367 o << "// css::sheet::XCompatibilityNames:\n"
368 "css::uno::Sequence< css::sheet::LocalizedName > SAL_CALL " << classname
369 << "getCompatibilityNames(const ::rtl::OUString & aProgrammaticName) throw "
370 "(css::uno::RuntimeException)\n{\n css::uno::Sequence< "
371 "css::sheet::LocalizedName > seqLocalizedNames;\n try {\n "
372 "::rtl::OUStringBuffer buf("
373 "aProgrammaticName);\n buf.appendAscii(\"/CompatibilityName\");\n"
374 " ::rtl::OUString hname(buf.makeStringAndClear());\n\n "
375 "if ( m_xCompAccess->hasByHierarchicalName(hname) ) {\n"
376 " css::uno::Reference< css::container::XNameAccess > "
377 "xNameAccess(\n"
378 " m_xCompAccess->getByHierarchicalName(hname), "
379 "css::uno::UNO_QUERY);\n\n css::uno::Sequence< ::rtl::OUString"
380 " > elems = \n xNameAccess->getElementNames();"
381 "\n ::sal_Int32 len = elems.getLength();\n\n "
382 "seqLocalizedNames.realloc(len);\n\n ::rtl::OUString "
383 "sCompatibilityName;\n for (::sal_Int32 i=0; i < len; ++i) {\n"
384 " ::rtl::OUString sLocale(elems[i]);\n "
385 "xNameAccess->getByName(sLocale) >>= sCompatibilityName;\n\n"
386 " css::lang::Locale aLocale;\n "
387 "::sal_Int32 nIndex = 0, nToken = 0;\n "
388 /* FIXME-BCP47: this will break. */
389 "do {\n ::rtl::OUString aToken = sLocale.getToken(0, '-', "
390 "nIndex);\n switch (nToken++) {\n "
391 "case 0:\n aLocale.Language = aToken;\n"
392 " break;\n case 1:\n"
393 " aLocale.Country = aToken;\n "
394 " break;\n default:\n "
395 "aLocale.Variant = sLocale.copy(nIndex-aToken.getLength()-1);\n"
396 " nIndex = -1;\n }\n"
397 " } while ( nIndex >= 0 );\n\n "
398 "seqLocalizedNames[i].Locale = aLocale;\n "
399 "seqLocalizedNames[i].Name = sCompatibilityName;\n }"
400 "\n }\n }\n catch ( const css::uno::RuntimeException & e ) {\n "
401 "throw e;\n }\n catch ( css::uno::Exception & ) {\n }\n\n"
402 " return seqLocalizedNames;\n}\n\n";
405 void generateXInitialization(std::ostream& o, const OString & classname)
407 o << "// css::lang::XInitialization:\n"
408 "void SAL_CALL " << classname << "initialize( const css::uno::Sequence< "
409 "css::uno::Any >& aArguments ) "
410 "throw (css::uno::Exception, css::uno::RuntimeException)\n{\n"
411 " css::uno::Reference < css::frame::XFrame > xFrame;\n"
412 " if ( aArguments.getLength() ) {\n aArguments[0] >>= xFrame;\n"
413 " m_xFrame = xFrame;\n }\n}\n\n";
416 void generateXDispatch(std::ostream& o,
417 const OString & classname,
418 const ProtocolCmdMap & protocolCmdMap)
420 // com.sun.star.frame.XDispatch
421 // dispatch
422 o << "// css::frame::XDispatch:\n"
423 "void SAL_CALL " << classname << "dispatch( const css::util::URL& aURL, const "
424 "css::uno::Sequence< css::beans::PropertyValue >& aArguments ) throw"
425 "(css::uno::RuntimeException)\n{\n";
427 ProtocolCmdMap::const_iterator iter = protocolCmdMap.begin();
428 while (iter != protocolCmdMap.end()) {
429 o << " if ( aURL.Protocol.equalsAscii(\"" << (*iter).first
430 << "\") == 0 )\n {\n";
432 for (std::vector< OString >::const_iterator i = (*iter).second.begin();
433 i != (*iter).second.end(); ++i) {
434 o << " if ( aURL.Path.equalsAscii(\"" << (*i) << "\") )\n"
435 " {\n // add your own code here\n"
436 " return;\n }\n";
439 o << " }\n";
440 ++iter;
442 o << "}\n\n";
444 // addStatusListener
445 o << "void SAL_CALL " << classname << "addStatusListener( const css::uno::Reference< "
446 "css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) "
447 "throw (css::uno::RuntimeException)\n{\n"
448 " // add your own code here\n}\n\n";
450 // removeStatusListener
451 o << "void SAL_CALL " << classname << "removeStatusListener( const css::uno::Reference"
452 "< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) "
453 "throw (css::uno::RuntimeException)\n{\n"
454 " // add your own code here\n}\n\n";
457 void generateXDispatchProvider(std::ostream& o,
458 const OString & classname,
459 const ProtocolCmdMap & protocolCmdMap)
462 // com.sun.star.frame.XDispatchProvider
463 // queryDispatch
464 o << "// css::frame::XDispatchProvider:\n"
465 "css::uno::Reference< css::frame::XDispatch > SAL_CALL " << classname
466 << "queryDispatch( const css::util::URL& aURL,"
467 " const ::rtl::OUString& sTargetFrameName, sal_Int32 nSearchFlags ) "
468 "throw(css::uno::RuntimeException)\n{\n css::uno::Reference< "
469 "css::frame::XDispatch > xRet;\n"
470 " if ( !m_xFrame.is() )\n return 0;\n\n";
472 ProtocolCmdMap::const_iterator iter = protocolCmdMap.begin();
473 while (iter != protocolCmdMap.end()) {
474 o << " if ( aURL.Protocol.equalsAscii(\"" << (*iter).first
475 << "\") == 0 )\n {\n";
477 for (std::vector< OString >::const_iterator i = (*iter).second.begin();
478 i != (*iter).second.end(); ++i) {
479 o << " if ( aURL.Path.equalsAscii(\"" << (*i) << "\") == 0 )\n"
480 " xRet = this;\n";
483 o << " }\n";
484 ++iter;
486 o << " return xRet;\n}\n\n";
488 // queryDispatches
489 o << "css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL "
490 << classname << "queryDispatches( const css::uno::Sequence< "
491 "css::frame::DispatchDescriptor >& seqDescripts ) throw("
492 "css::uno::RuntimeException)\n{\n"
493 " sal_Int32 nCount = seqDescripts.getLength();\n"
494 " css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > "
495 "lDispatcher(nCount);\n\n"
496 " for( sal_Int32 i=0; i<nCount; ++i ) {\n"
497 " lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL,\n"
498 " seqDescripts[i].FrameName,\n"
499 " seqDescripts[i].SearchFlags );\n"
500 " }\n\n return lDispatcher;\n}\n\n";
503 void generateAddinConstructorAndHelper(std::ostream& o,
504 ProgramOptions const & options,
505 rtl::Reference< TypeManager > const & manager, const OString & classname,
506 const std::set< OUString >& interfaces)
508 o << classname << "::" << classname
509 << "(css::uno::Reference< css::uno::XComponentContext > const & context) :\n"
510 " m_xContext(context), m_locale()\n{\n";
512 if (options.backwardcompatible) {
513 o << " try {\n";
515 generateFunctionParameterMap(o, options, manager, interfaces);
517 o << " css::uno::Reference< css::lang::XMultiServiceFactory > xProvider"
518 "(\n m_xContext->getServiceManager()->createInstanceWithContext"
519 "(\n ::rtl::OUString(\n "
520 " \"com.sun.star.configuration.ConfigurationProvider\"),"
521 "\n m_xContext ), css::uno::UNO_QUERY );\n\n";
523 o << " ::rtl::OUString sReadOnlyView(\n"
524 " \"com.sun.star.configuration.ConfigurationAccess\");\n\n";
526 o << " ::rtl::OUStringBuffer sPath(::rtl::OUString(\n"
527 " \"/org.openoffice.Office.CalcAddIns/AddInInfo/\"));\n"
528 " sPath.appendAscii(sADDIN_SERVICENAME);\n"
529 " sPath.appendAscii(\"/AddInFunctions\");\n\n"
530 " // create arguments: nodepath\n"
531 " css::beans::PropertyValue aArgument;\n"
532 " aArgument.Name = ::rtl::OUString(\"nodepath\");\n"
533 " aArgument.Value <<= sPath.makeStringAndClear();\n\n"
534 " css::uno::Sequence< css::uno::Any > aArguments(1);\n"
535 " aArguments[0] <<= aArgument;\n\n";
537 o << " // create the default view using default UI locale\n"
538 " css::uno::Reference< css::uno::XInterface > xIface =\n"
539 " xProvider->createInstanceWithArguments(sReadOnlyView, "
540 "aArguments);\n\n"
541 " m_xHAccess.set(xIface, css::uno::UNO_QUERY);"
542 "\n\n";
544 o << " // extend arguments to create a view for all locales to get "
545 "simple\n // access to the compatibilityname property\n"
546 " aArgument.Name = ::rtl::OUString(\"locale\");\n"
547 " aArgument.Value <<= ::rtl::OUString(\"*\");\n"
548 " aArguments.realloc(2);\n"
549 " aArguments[1] <<= aArgument;\n\n"
550 " // create view for all locales\n"
551 " xIface = xProvider->createInstanceWithArguments(sReadOnlyView, "
552 "aArguments);\n\n"
553 " m_xCompAccess.set(xIface, css::uno::UNO_QUERY);\n";
555 o << " }\n catch ( css::uno::Exception & ) {\n }\n}\n\n";
557 o << "// addin configuration property helper function:\n::rtl::OUString "
558 "SAL_CALL " << classname << "::getAddinProperty(const ::rtl::OUString &"
559 " funcName, const ::rtl::OUString & paramName, const char * propName) "
560 "throw (css::uno::RuntimeException)\n{\n"
561 " ::rtl::OUString ret;\n try {\n "
562 "::rtl::OUStringBuffer buf(funcName);\n"
563 " if (!paramName.isEmpty()) {\n"
564 " buf.appendAscii(\"/Parameters/\");\n"
565 " buf.append(paramName);\n }\n\n"
566 " css::uno::Reference< css::beans::XPropertySet > xPropSet(\n"
567 " m_xHAccess->getByHierarchicalName(\n"
568 " buf.makeStringAndClear()), css::uno::UNO_QUERY);\n"
569 " xPropSet->getPropertyValue(\n "
570 "::rtl::OUString(propName)) >>= ret;\n }\n"
571 " catch ( const css::uno::RuntimeException & e ) {\n throw e;\n }\n"
572 " catch ( css::uno::Exception & ) {\n }\n return ret;\n";
574 o <<"}\n\n";
577 void generateMemberInitialization(std::ostream& o,
578 ProgramOptions const & options,
579 rtl::Reference< TypeManager > const & manager,
580 AttributeInfo const & members)
582 if (!members.empty()) {
583 for (AttributeInfo::const_iterator i(members.begin());
584 i != members.end(); ++i)
586 sal_Int32 rank;
587 if ((manager->decompose(i->type, true, nullptr, &rank, nullptr, nullptr)
588 <= codemaker::UnoType::Sort::Char)
589 && rank == 0)
591 o << ",\n m_" << i->name << "(";
592 printType(o, options, manager, i->type, 16, true);
593 o << ")";
599 void generateMemberDeclaration(std::ostream& o,
600 ProgramOptions const & options,
601 rtl::Reference< TypeManager > const & manager,
602 AttributeInfo const & members)
604 for (AttributeInfo::const_iterator i(members.begin());
605 i != members.end(); ++i)
607 o << " ";
608 printType(o, options, manager, i->type, 1);
609 o << " m_" << i->name << ";\n";
613 OString generateClassDefinition(std::ostream& o,
614 ProgramOptions const & options,
615 rtl::Reference< TypeManager > const & manager,
616 OString const & classname,
617 std::set< OUString > const & interfaces,
618 AttributeInfo const & properties,
619 AttributeInfo const & attributes,
620 std::set< OUString > const & propinterfaces,
621 OUString const & propertyhelper, bool supportxcomponent)
623 OStringBuffer parentname(64);
624 o << "class " << classname << ":\n";
626 if (!interfaces.empty()) {
627 if (supportxcomponent) {
628 parentname.append("::cppu::WeakComponentImplHelper");
629 parentname.append(static_cast<sal_Int32>(interfaces.size()));
630 o << " private ::cppu::BaseMutex,\n"
631 " public ::cppu::WeakComponentImplHelper"
632 << interfaces.size() << "<";
633 } else {
634 parentname.append("::cppu::WeakImplHelper");
635 parentname.append(static_cast<sal_Int32>(interfaces.size()));
636 o << " public ::cppu::WeakImplHelper" << interfaces.size() << "<";
639 std::set< OUString >::const_iterator iter = interfaces.begin();
640 while (iter != interfaces.end())
642 o << "\n " << scopedCppName(u2b(*iter));
643 ++iter;
644 if (iter != interfaces.end())
645 o << ",";
646 else
647 o << ">";
651 if (propertyhelper.getLength() > 1) {
652 o << ",\n public ::cppu::PropertySetMixin< "
653 << scopedCppName(u2b(propertyhelper)) << " >";
656 o << "\n{\npublic:\n"
657 " explicit " << classname << "("
658 "css::uno::Reference< css::uno::XComponentContext > const & context);\n\n";
660 // generate component/service helper functions
661 // o << " // component and service helper functions:\n"
662 // << " static ::rtl::OUString SAL_CALL _getImplementationName();\n"
663 // << " static css::uno::Sequence< ::rtl::OUString > SAL_CALL "
664 // << "_getSupportedServiceNames();\n"
665 // << " static css::uno::Reference< css::uno::XInterface > SAL_CALL _create("
666 // << "\n css::uno::Reference< css::uno::XComponentContext > const & "
667 // << "context);\n\n";
669 // override queryInterface
670 if (propertyhelper.getLength() > 1) {
671 o << " // css::uno::XInterface:\n"
672 " virtual css::uno::Any SAL_CALL queryInterface("
673 "css::uno::Type const & type) throw ("
674 "css::uno::RuntimeException);\n";
676 OStringBuffer buffer(256);
677 buffer.append(parentname.toString());
678 buffer.append("< ");
679 std::set< OUString >::const_iterator iter = interfaces.begin();
680 while (iter != interfaces.end())
682 buffer.append(scopedCppName(u2b(*iter)));
683 ++iter;
684 if (iter != interfaces.end())
685 buffer.append(", ");
686 else
687 buffer.append(" >");
689 OString parent(buffer.makeStringAndClear());
690 o << " virtual void SAL_CALL acquire() throw ()\n { "
691 << parent << "::acquire(); }\n";
692 o << " virtual void SAL_CALL release() throw ()\n { "
693 << parent << "::release(); }\n\n";
696 std::set< OUString >::const_iterator it = interfaces.begin();
697 codemaker::GeneratedTypeSet generated;
698 while (it != interfaces.end())
700 printMethods(o, options, manager, *it, generated, "", "", " ",
701 true, propertyhelper);
702 ++it;
705 o << "private:\n " << classname << "(const " << classname << " &); // not defined\n"
706 " " << classname << "& operator=(const " << classname << " &); // not defined\n\n"
707 " // destructor is private and will be called indirectly by the release call"
708 " virtual ~" << classname << "() {}\n\n";
710 if (options.componenttype == 2) {
711 o << " typedef boost::unordered_map< ::sal_Int32, rtl::OUString, "
712 "boost::hash<::sal_Int32> > ParamMap;\n"
713 " typedef boost::unordered_map< rtl::OUString, ParamMap, "
714 "rtl::OUStringHash > FunctionMap;\n\n"
715 " ::rtl::OUString SAL_CALL getAddinProperty(const ::rtl::OUString & "
716 "funcName, const ::rtl::OUString & paramName, const char * propName) "
717 "throw (css::uno::RuntimeException);\n\n";
720 if (supportxcomponent) {
721 o << " // override WeakComponentImplHelperBase::disposing()\n"
722 " // This function is called upon disposing the component,\n"
723 " // if your component needs special work when it becomes\n"
724 " // disposed, do it here.\n"
725 " virtual void SAL_CALL disposing();\n\n";
728 // members
729 o << " css::uno::Reference< css::uno::XComponentContext > m_xContext;\n";
730 if (!supportxcomponent && !attributes.empty())
731 o << " mutable ::osl::Mutex m_aMutex;\n";
733 // additional member for add-ons
734 if (options.componenttype == 3) {
735 o << " css::uno::Reference< css::frame::XFrame > m_xFrame;\n";
738 if (options.componenttype == 2) {
739 if (options.backwardcompatible) {
740 o <<" css::uno::Reference< css::container::XHierarchicalNameAccess > "
741 "m_xHAccess;\n"
742 " css::uno::Reference< css::container::XHierarchicalNameAccess > "
743 "m_xCompAccess;\n"
744 " FunctionMap m_functionMap;\n";
746 o << " css::lang::Locale m_locale;\n";
749 generateMemberDeclaration(o, options, manager, properties);
750 generateMemberDeclaration(o, options, manager, attributes);
752 // if (!properties.empty())
753 // {
754 // AttributeInfo::const_iterator iter = properties.begin();
755 // while (iter != properties.end())
756 // {
757 // o << " ";
758 // printType(o, options, manager, iter->second.first.replace('.','/'),
759 // 1, false);
760 // o << " m_" << iter->first << ";\n";
761 // ++iter;
762 // }
763 // }
764 // if (!attributes.empty())
765 // {
766 // AttributeInfo::const_iterator iter = attributes.begin();
767 // while (iter != attributes.end())
768 // {
769 // o << " ";
770 // printType(o, options, manager, iter->second.first.replace('.','/'),
771 // 1, false);
772 // o << " m_" << iter->first << ";\n";
773 // ++iter;
774 // }
775 // }
777 o << "};\n\n";
779 // generate constructor
780 if (options.componenttype == 2) {
781 generateAddinConstructorAndHelper(o, options, manager,
782 classname, interfaces);
783 } else {
784 o << classname << "::" << classname
785 << "(css::uno::Reference< css::uno::XComponentContext > const & context) :\n";
786 if (supportxcomponent) {
787 o << " ::cppu::WeakComponentImplHelper" << interfaces.size() << "<";
788 std::set< OUString >::const_iterator iter = interfaces.begin();
789 while (iter != interfaces.end()) {
790 o << "\n " << scopedCppName(u2b(*iter));
791 ++iter;
792 if (iter != interfaces.end())
793 o << ",";
794 else
795 o << ">(m_aMutex),\n";
798 if (propertyhelper.getLength() > 1) {
799 o << " ::cppu::PropertySetMixin< "
800 << scopedCppName(u2b(propertyhelper)) << " >(\n"
801 " context, static_cast< Implements >(\n ";
802 OStringBuffer buffer(128);
803 if (propinterfaces.find("com/sun/star/beans/XPropertySet")
804 != propinterfaces.end()) {
805 buffer.append("IMPLEMENTS_PROPERTY_SET");
807 if (propinterfaces.find("com/sun/star/beans/XFastPropertySet")
808 != propinterfaces.end()) {
809 if (!buffer.isEmpty())
810 buffer.append(" | IMPLEMENTS_FAST_PROPERTY_SET");
811 else
812 buffer.append("IMPLEMENTS_FAST_PROPERTY_SET");
814 if (propinterfaces.find("com/sun/star/beans/XPropertyAccess")
815 != propinterfaces.end()) {
816 if (!buffer.isEmpty())
817 buffer.append(" | IMPLEMENTS_PROPERTY_ACCESS");
818 else
819 buffer.append("IMPLEMENTS_PROPERTY_ACCESS");
821 o << buffer.makeStringAndClear()
822 << "), css::uno::Sequence< ::rtl::OUString >()),\n";
824 o << " m_xContext(context)";
826 generateMemberInitialization(o, options, manager, properties);
827 generateMemberInitialization(o, options, manager, attributes);
829 o << "\n{}\n\n";
832 // generate service/component helper function implementations
833 // generateServiceHelper(o, options.implname, classname, services);
835 if (supportxcomponent) {
836 o << "// override WeakComponentImplHelperBase::disposing()\n"
837 "// This function is called upon disposing the component,\n"
838 "// if your component needs special work when it becomes\n"
839 "// disposed, do it here.\n"
840 "void SAL_CALL " << classname << "::disposing()\n{\n\n}\n\n";
843 return parentname.makeStringAndClear();
846 void generateXServiceInfoBodies(std::ostream& o,
847 OString const & classname,
848 OString const & comphelpernamespace)
850 o << "// com.sun.star.uno.XServiceInfo:\n"
851 "::rtl::OUString SAL_CALL " << classname << "getImplementationName() "
852 "throw (css::uno::RuntimeException)\n{\n "
853 "return " << comphelpernamespace << "::_getImplementationName();\n}\n\n";
855 o << "sal_Bool SAL_CALL " << classname
856 << "supportsService(::rtl::OUString const & "
857 "serviceName) throw (css::uno::RuntimeException)\n{\n "
858 "css::uno::Sequence< ::rtl::OUString > serviceNames = "
859 << comphelpernamespace << "::_getSupportedServiceNames();\n "
860 "for (::sal_Int32 i = 0; i < serviceNames.getLength(); ++i) {\n "
861 " if (serviceNames[i] == serviceName)\n return sal_True;\n"
862 " }\n return sal_False;\n}\n\n";
864 o << "css::uno::Sequence< ::rtl::OUString > SAL_CALL " << classname
865 << "getSupportedServiceNames() throw (css::uno::RuntimeException)\n{\n "
866 "return " << comphelpernamespace
867 << "::_getSupportedServiceNames();\n}\n\n";
871 void generateMethodBodies(std::ostream& o,
872 ProgramOptions const & options,
873 rtl::Reference< TypeManager > const & manager,
874 std::set< OUString > const & interfaces,
875 OString const & classname,
876 OString const & comphelpernamespace,
877 OUString const & propertyhelper)
879 OString name(classname.concat("::"));
880 std::set< OUString >::const_iterator iter = interfaces.begin();
881 codemaker::GeneratedTypeSet generated;
882 while (iter != interfaces.end()) {
883 if ( *iter == "com.sun.star.lang.XServiceInfo" ) {
884 generateXServiceInfoBodies(o, name, comphelpernamespace);
885 generated.add(u2b(*iter));
886 } else {
887 printMethods(o, options, manager, *iter, generated, "_",
888 name, "", true, propertyhelper);
890 ++iter;
894 void generateQueryInterface(std::ostream& o,
895 ProgramOptions const & options,
896 rtl::Reference< TypeManager > const & manager,
897 const std::set< OUString >& interfaces,
898 OString const & parentname,
899 OString const & classname,
900 OUString const & propertyhelper)
902 if (propertyhelper.isEmpty())
903 return;
905 o << "css::uno::Any " << classname
906 << "::queryInterface(css::uno::Type const & type) throw ("
907 "css::uno::RuntimeException)\n{\n ";
909 if (!propertyhelper.isEmpty())
910 o << "return ";
911 else
912 o << "css::uno::Any a(";
914 o << parentname << "<";
915 std::set< OUString >::const_iterator iter = interfaces.begin();
916 while (iter != interfaces.end())
918 o << "\n " << scopedCppName(u2b(*iter));
919 ++iter;
920 if (iter != interfaces.end())
921 o << ",";
922 else
923 o << ">";
926 if (!propertyhelper.isEmpty()) {
927 o << "::queryInterface(type);\n";
928 } else {
929 o << "::queryInterface(type));\n";
930 o << " return a.hasValue() ? a\n : (";
931 if (propertyhelper == "_") {
932 o << "::cppu::OPropertySetHelper::queryInterface(type));\n";
933 } else {
934 o << "::cppu::PropertySetMixin<\n ";
935 printType(o, options, manager, propertyhelper, 0);
936 o << " >::queryInterface(\n type));\n";
939 o << "}\n\n";
942 void generateSkeleton(ProgramOptions const & options,
943 rtl::Reference< TypeManager > const & manager,
944 std::vector< OString > const & types)
946 // special handling of calc add-ins
947 if (options.componenttype == 2) {
948 generateCalcAddin(options, manager, types);
949 return;
952 std::set< OUString > interfaces;
953 std::set< OUString > services;
954 AttributeInfo properties;
955 AttributeInfo attributes;
956 std::set< OUString > propinterfaces;
957 bool serviceobject = false;
958 bool supportxcomponent = false;
960 std::vector< OString >::const_iterator iter = types.begin();
961 while (iter != types.end()) {
962 checkType(manager, b2u(*iter), interfaces, services, properties);
963 ++iter;
966 if (options.componenttype == 3) {
967 // the Protocolhandler service is mandatory for an protocol handler add-on,
968 // so it is defaulted. The XDispatchProvider provides Dispatch objects for
969 // certain functions and the generated impl object implements XDispatch
970 // directly for simplicity reasons.
971 checkType(manager, "com.sun.star.frame.ProtocolHandler",
972 interfaces, services, properties);
973 checkType(manager, "com.sun.star.frame.XDispatch",
974 interfaces, services, properties);
977 // check if service object or simple UNO object
978 if (!services.empty())
979 serviceobject = true;
981 OUString propertyhelper = checkPropertyHelper(
982 options, manager, services, interfaces, attributes, propinterfaces);
984 checkDefaultInterfaces(interfaces, services, propertyhelper);
986 if (interfaces.size() > 12)
987 throw CannotDumpException(
988 "the skeletonmaker supports components with 12 interfaces "
989 "only (limitation of the UNO implementation helpers)!");
992 supportxcomponent = checkXComponentSupport(manager, interfaces);
994 OString compFileName;
995 OString tmpFileName;
996 std::ostream* pofs = nullptr;
997 bool standardout = getOutputStream(options, ".cxx",
998 &pofs, compFileName, tmpFileName);
1000 try {
1001 if (!standardout && options.license) {
1002 printLicenseHeader(*pofs, compFileName);
1005 generateIncludes(*pofs, interfaces, propertyhelper, serviceobject,
1006 supportxcomponent);
1008 if (options.componenttype == 3) {
1009 *pofs << "#include \"com/sun/star/frame/XFrame.hpp\"\n";
1012 // namespace
1013 OString nmspace;
1014 short nm = 0;
1016 if (serviceobject) {
1017 nmspace = generateCompHelperDeclaration(*pofs, options.implname);
1019 *pofs <<
1020 "\n\n/// anonymous implementation namespace\nnamespace {\n\n"
1021 "namespace css = ::com::sun::star;\n\n";
1022 } else {
1023 nm = generateNamespace(*pofs, options.implname, false, nmspace);
1024 *pofs << "namespace css = ::com::sun::star;\n\n";
1027 sal_Int32 index = 0;
1028 OString classname(options.implname);
1029 if ((index = classname.lastIndexOf('.')) > 0)
1030 classname = classname.copy(index+1);
1032 OString parentname(
1033 generateClassDefinition(*pofs,
1034 options, manager, classname, interfaces, properties,
1035 attributes, propinterfaces, propertyhelper, supportxcomponent));
1037 generateQueryInterface(*pofs, options, manager, interfaces, parentname,
1038 classname, propertyhelper);
1040 generateMethodBodies(*pofs, options, manager, interfaces, classname,
1041 nmspace, propertyhelper);
1043 if (serviceobject) {
1044 // close namespace
1045 *pofs << "} // closing anonymous implementation namespace\n\n";
1047 generateCompHelperDefinition(*pofs, options.implname,
1048 classname, services);
1049 generateCompFunctions(*pofs, nmspace);
1050 } else {
1051 // close namespace
1052 for (short i=0; i < nm; i++)
1053 *pofs << "} ";
1054 *pofs << (nm > 0 ? "// closing namespace\n\n" : "\n");
1057 if ( !standardout && pofs && static_cast<std::ofstream*>(pofs)->is_open()) {
1058 static_cast<std::ofstream*>(pofs)->close();
1059 delete pofs;
1060 OSL_VERIFY(makeValidTypeFile(compFileName, tmpFileName, false));
1062 } catch (CannotDumpException & e) {
1063 std::cerr << "ERROR: " << e.getMessage() << "\n";
1064 if ( !standardout ) {
1065 if (pofs && static_cast<std::ofstream*>(pofs)->is_open()) {
1066 static_cast<std::ofstream*>(pofs)->close();
1067 delete pofs;
1069 // remove existing type file if something goes wrong to ensure
1070 // consistency
1071 if (fileExists(compFileName))
1072 removeTypeFile(compFileName);
1074 // remove tmp file if something goes wrong
1075 removeTypeFile(tmpFileName);
1080 void generateCalcAddin(ProgramOptions const & options,
1081 rtl::Reference< TypeManager > const & manager,
1082 std::vector< OString > const & types)
1084 std::set< OUString > interfaces;
1085 std::set< OUString > services;
1086 AttributeInfo properties;
1087 AttributeInfo attributes;
1088 std::set< OUString > propinterfaces;
1089 bool serviceobject = false;
1090 bool supportxcomponent = false;
1093 std::vector< OString >::const_iterator iter = types.begin();
1094 while (iter != types.end()) {
1095 checkType(manager, b2u(*iter), interfaces, services, properties);
1096 ++iter;
1099 OUString sAddinService;
1100 if (services.size() != 1) {
1101 throw CannotDumpException(
1102 "for calc add-in components one and only one service type is necessary!"
1103 " Please reference a valid type with the '-t' option.");
1107 // get the one and only add-in service for later use
1108 std::set< OUString >::const_iterator iter2 = services.begin();
1109 sAddinService = *iter2;
1110 if (sAddinService == "com.sun.star.sheet.AddIn") {
1111 sAddinService = *(++iter2);
1114 // if backwardcompatible==true the AddIn service needs to be added to the
1115 // supported service list, the necessary intefaces are mapped to the add-in
1116 // configuration. Since OO.org 2.0.4 this is obsolete and the add-in is
1117 // take form the configuration from Calc directly, this simplifies the
1118 // add-in code
1119 if (options.backwardcompatible) {
1120 checkType(manager, "com.sun.star.sheet.AddIn",
1121 interfaces, services, properties);
1122 } else {
1123 // special case for the optional XLocalization interface. It should be
1124 // implemented always. But it is parent of the XAddIn and we need it only
1125 // if backwardcompatible is false.
1126 if (interfaces.find("com.sun.star.lang.XLocalizable") == interfaces.end()) {
1127 interfaces.insert("com.sun.star.lang.XLocalizable");
1131 OUString propertyhelper = checkPropertyHelper(
1132 options, manager, services, interfaces, attributes, propinterfaces);
1134 if (!propertyhelper.isEmpty())
1135 std::cerr << "WARNING: interfaces specifying calc add-in functions "
1136 "shouldn't support attributes!\n";
1138 checkDefaultInterfaces(interfaces, services, propertyhelper);
1140 if (interfaces.size() > 12) {
1141 throw CannotDumpException(
1142 "the skeletonmaker supports components with 12 interfaces "
1143 "only (limitation of the UNO implementation helpers)!");
1146 // check if service object or simple UNO object
1147 if (!services.empty())
1148 serviceobject = true;
1150 supportxcomponent = checkXComponentSupport(manager, interfaces);
1151 if (supportxcomponent)
1152 std::cerr << "WARNING: add-ins shouldn't support "
1153 "com.sun.star.uno.XComponent!\n";
1155 OString compFileName;
1156 OString tmpFileName;
1157 std::ostream* pofs = nullptr;
1158 bool standardout = getOutputStream(options, ".cxx",
1159 &pofs, compFileName, tmpFileName);
1161 try {
1162 if (!standardout && options.license) {
1163 printLicenseHeader(*pofs, compFileName);
1166 generateIncludes(*pofs, interfaces, propertyhelper, serviceobject,
1167 supportxcomponent);
1169 *pofs <<
1170 "#include \"com/sun/star/beans/PropertyValue.hpp\"\n"
1171 "#include \"com/sun/star/beans/XPropertySet.hpp\"\n"
1172 "#include \"com/sun/star/container/XNameAccess.hpp\"\n"
1173 "#include \"com/sun/star/container/XHierarchicalNameAccess.hpp\"\n\n"
1174 "#include \"rtl/ustrbuf.hxx\"\n\n"
1175 "#include <boost/unordered_map.hpp>\n"
1176 "#include <set>\n";
1178 // namespace
1179 OString nmspace(generateCompHelperDeclaration(*pofs, options.implname));
1181 *pofs <<
1182 "\n\n// anonymous implementation namespace\nnamespace {\n\n"
1183 "namespace css = ::com::sun::star;\n\n";
1185 sal_Int32 index = 0;
1186 OString classname(options.implname);
1187 if ((index = classname.lastIndexOf('.')) > 0) {
1188 classname = classname.copy(index+1);
1191 if (options.backwardcompatible) {
1192 *pofs << "static const char * sADDIN_SERVICENAME = \""
1193 << sAddinService << "\";\n\n";
1194 *pofs << "static const char * sDISPLAYNAME = \"DisplayName\";\n"
1195 "static const char * sDESCRIPTION = \"Description\";\n"
1196 "static const char * sCATEGORY = \"Category\";\n"
1197 "static const char * sCATEGORYDISPLAYNAME = \"CategoryDisplayName\";"
1198 "\n\n";
1201 OString parentname(
1202 generateClassDefinition(*pofs,
1203 options, manager, classname, interfaces, properties,
1204 attributes, propinterfaces, propertyhelper, supportxcomponent));
1206 generateQueryInterface(*pofs, options, manager, interfaces, parentname,
1207 classname, propertyhelper);
1209 generateMethodBodies(*pofs, options, manager, interfaces, classname,
1210 nmspace, propertyhelper);
1212 // close namespace
1213 *pofs << "} // closing anonymous implementation namespace\n\n";
1215 generateCompHelperDefinition(*pofs, options.implname, classname,
1216 services);
1218 generateCompFunctions(*pofs, nmspace);
1220 if ( !standardout && pofs && static_cast<std::ofstream*>(pofs)->is_open()) {
1221 static_cast<std::ofstream*>(pofs)->close();
1222 delete pofs;
1223 OSL_VERIFY(makeValidTypeFile(compFileName, tmpFileName, false));
1225 } catch (CannotDumpException & e) {
1226 std::cerr << "ERROR: " << e.getMessage() << "\n";
1227 if ( !standardout ) {
1228 if (pofs && static_cast<std::ofstream*>(pofs)->is_open()) {
1229 static_cast<std::ofstream*>(pofs)->close();
1230 delete pofs;
1232 // remove existing type file if something goes wrong to ensure
1233 // consistency
1234 if (fileExists(compFileName))
1235 removeTypeFile(compFileName);
1237 // remove tmp file if something goes wrong
1238 removeTypeFile(tmpFileName);
1246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */