36 const std::set< OUString >& interfaces,
37 std::u16string_view propertyhelper,
const bool serviceobject,
38 const bool supportxcomponent)
40 o <<
"#include \"sal/config.h\"\n";
42 o <<
"#include \"cppuhelper/factory.hxx\"\n"
43 "#include \"cppuhelper/implementationentry.hxx\"\n";
45 o <<
"#include \"com/sun/star/uno/XComponentContext.hpp\"\n";
47 if (supportxcomponent) {
48 o <<
"#include \"cppuhelper/compbase" << interfaces.size() <<
".hxx\"\n";
49 o <<
"#include \"cppuhelper/basemutex.hxx\"\n";
51 o <<
"#include \"cppuhelper/implbase" << interfaces.size() <<
".hxx\"\n";
54 if (propertyhelper.size() > 1) {
55 if (propertyhelper ==
u"_")
56 o <<
"#include \"cppuhelper/rpopshlp.hxx\"\n";
58 o <<
"#include \"cppuhelper/propertysetmixin.hxx\"\n";
61 for (
const auto& rIface : interfaces)
64 << rIface.replace(
'.',
'/')
70 const OString & implname,
75 sal_Int32
index = implname.lastIndexOf(
'.');
77 o <<
"\n\n// component helper namespace\n";
84 buf.append(
"comp_" + implname);
85 nm = buf.makeStringAndClear();
86 o <<
"namespace comp_" << implname <<
" {\n\n";
94 OString token(implname.getToken(0,
'.',
nPos));
95 if (
nPos < 0 && serviceobject) {
96 buf.append(
"::comp_" + token);
97 o <<
"namespace comp_" << token <<
" { ";
100 buf.append(
"::" + token);
101 o <<
"namespace " << token <<
" { ";
105 nm = buf.makeStringAndClear();
112 const OString & implname)
117 o <<
"namespace css = ::com::sun::star;\n\n";
120 o <<
"// component and service helper functions:\n"
121 "OUString SAL_CALL _getImplementationName();\n"
122 "css::uno::Sequence< OUString > SAL_CALL "
123 "_getSupportedServiceNames();\n"
124 "css::uno::Reference< css::uno::XInterface > SAL_CALL _create("
125 " css::uno::Reference< css::uno::XComponentContext > const & "
129 for (
short i=0;
i < nbrackets;
i++)
131 o <<
"// closing component helper namespace\n\n";
137 const OString & implname,
138 const OString & classname,
139 const std::set< OUString >& services)
144 o <<
"OUString SAL_CALL _getImplementationName() {\n"
145 " return OUString(\n"
146 " \"" << implname <<
"\");\n}\n\n";
148 o <<
"css::uno::Sequence< OUString > SAL_CALL "
149 "_getSupportedServiceNames()\n{\n css::uno::Sequence< "
150 "OUString > s(" << services.size() <<
");\n";
153 for (
const auto& rService : services)
155 o <<
" s[" <<
i++ <<
"] = OUString(\""
156 << rService <<
"\");\n";
158 o <<
" return s;\n}\n\n";
160 o <<
"css::uno::Reference< css::uno::XInterface > SAL_CALL _create("
161 "\n const css::uno::Reference< css::uno::XComponentContext > & "
163 " return static_cast< ::cppu::OWeakObject * >(new "
164 << classname <<
"(context));\n}\n\n";
167 for (
short j=0; j < nbrackets; j++)
169 o <<
"// closing component helper namespace\n\n";
175 o <<
"static ::cppu::ImplementationEntry const entries[] = {\n"
176 " { &" << nmspace <<
"::_create,\n &"
177 << nmspace <<
"::_getImplementationName,\n &"
178 << nmspace <<
"::_getSupportedServiceNames,\n"
179 " &::cppu::createSingleComponentFactory, 0, 0 },\n"
180 " { 0, 0, 0, 0, 0, 0 }\n};\n\n";
182 o <<
"extern \"C\" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(\n"
183 " const char * implName, void * serviceManager, void * registryKey)\n{\n"
184 " return ::cppu::component_getFactoryHelper(\n"
185 " implName, serviceManager, registryKey, entries);\n}\n\n";
187 o <<
"extern \"C\" sal_Bool SAL_CALL component_writeInfo(\n"
188 " void * serviceManager, void * registryKey)\n{\n"
189 " return ::cppu::component_writeInfoHelper("
190 "serviceManager, registryKey, entries);\n}\n";
194 const OString & classname,
195 const OString & propertyhelper)
197 o <<
"// com.sun.star.beans.XPropertySet:\n";
199 o <<
"css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL "
200 << classname <<
"getPropertySetInfo() throw ("
201 "css::uno::RuntimeException)\n{\n return ::cppu::PropertySetMixin< "
203 <<
" >::getPropertySetInfo();\n}\n\n";
205 o <<
"void SAL_CALL " << classname <<
"setPropertyValue(const OUString"
206 " & aPropertyName, const css::uno::Any & aValue) throw ("
207 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
208 "css::beans::PropertyVetoException, css::lang::IllegalArgumentException, "
209 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
210 << propertyhelper <<
" >::setPropertyValue(aPropertyName, aValue);\n}\n\n";
213 o <<
"css::uno::Any SAL_CALL " << classname <<
"getPropertyValue(const "
214 "OUString & aPropertyName) throw (css::uno::RuntimeException, "
215 "css::beans::UnknownPropertyException, css::lang::WrappedTargetException)"
216 "\n{\n return ::cppu::PropertySetMixin< "
217 << propertyhelper <<
" >::getPropertyValue(aPropertyName);\n}\n\n";
219 o <<
"void SAL_CALL " << classname <<
"addPropertyChangeListener(const "
220 "OUString & aPropertyName, const css::uno::Reference< "
221 "css::beans::XPropertyChangeListener > & xListener) throw ("
222 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
223 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
225 <<
" >::addPropertyChangeListener(aPropertyName, xListener);\n}\n\n";
227 o <<
"void SAL_CALL " << classname <<
"removePropertyChangeListener(const "
228 "OUString & aPropertyName, const css::uno::Reference< "
229 "css::beans::XPropertyChangeListener > & xListener) throw ("
230 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
231 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
233 <<
" >::removePropertyChangeListener(aPropertyName, xListener);\n}\n\n";
235 o <<
"void SAL_CALL " << classname <<
"addVetoableChangeListener(const "
236 "OUString & aPropertyName, const css::uno::Reference< "
237 "css::beans::XVetoableChangeListener > & xListener) throw ("
238 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
239 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
241 <<
" >::addVetoableChangeListener(aPropertyName, xListener);\n}\n\n";
243 o <<
"void SAL_CALL " << classname <<
"removeVetoableChangeListener(const "
244 "OUString & aPropertyName, const css::uno::Reference< "
245 "css::beans::XVetoableChangeListener > & xListener) throw ("
246 "css::uno::RuntimeException, css::beans::UnknownPropertyException, "
247 "css::lang::WrappedTargetException)\n{\n ::cppu::PropertySetMixin< "
249 <<
" >::removeVetoableChangeListener(aPropertyName, xListener);\n}\n\n";
253 const OString & classname,
254 const OString & propertyhelper)
256 o <<
"// com.sun.star.beans.XFastPropertySet:\n";
258 o <<
"void SAL_CALL " << classname <<
"setFastPropertyValue( ::sal_Int32 "
259 "nHandle, const css::uno::Any& aValue ) throw ("
260 "css::beans::UnknownPropertyException, css::beans::PropertyVetoException, "
261 "css::lang::IllegalArgumentException, css::lang::WrappedTargetException, "
262 "css::uno::RuntimeException)\n{\n ::cppu::PropertySetMixin< "
263 << propertyhelper <<
" >::setFastPropertyValue(nHandle, aValue);\n}\n\n";
266 o <<
"css::uno::Any SAL_CALL " << classname <<
"getFastPropertyValue( "
267 "::sal_Int32 nHandle ) throw (css::beans::UnknownPropertyException, "
268 "css::lang::WrappedTargetException, css::uno::RuntimeException)\n{\n"
269 " return ::cppu::PropertySetMixin< "
270 << propertyhelper <<
" >::getFastPropertyValue(nHandle);\n}\n\n";
274 const OString & classname,
275 const OString & propertyhelper)
277 o <<
" // com.sun.star.beans.XPropertyAccess:\n";
279 o <<
"css::uno::Sequence< css::beans::PropertyValue > SAL_CALL "
280 << classname <<
"getPropertyValues( ) throw ("
281 "css::uno::RuntimeException)\n{\n"
282 " return ::cppu::PropertySetMixin< "
283 << propertyhelper <<
" >::getPropertyValues();\n}\n\n";
285 o <<
"void SAL_CALL " << classname <<
"setPropertyValues( const "
286 "css::uno::Sequence< css::beans::PropertyValue >& aProps ) throw ("
287 "css::beans::UnknownPropertyException, css::beans::PropertyVetoException, "
288 "css::lang::IllegalArgumentException, css::lang::WrappedTargetException, "
289 "css::uno::RuntimeException)\n{\n"
290 " ::cppu::PropertySetMixin< "
291 << propertyhelper <<
" >::setPropertyValues(aProps);\n}\n\n";
296 o <<
"// css::lang::XLocalizable:\n"
297 "void SAL_CALL " << classname <<
"setLocale(const css::lang::"
298 "Locale & eLocale) throw (css::uno::RuntimeException)\n{\n"
299 " m_locale = eLocale;\n}\n\n"
300 "css::lang::Locale SAL_CALL " << classname <<
"getLocale() "
301 "throw (css::uno::RuntimeException)\n{\n return m_locale;\n}\n\n";
306 o <<
"// css::sheet::XAddIn:\n";
308 o <<
"OUString SAL_CALL " << classname <<
"getProgrammaticFuntionName("
309 "const OUString & aDisplayName) throw (css::uno::RuntimeException)"
310 "\n{\n OUString ret;\n try {\n css::uno::Reference< "
311 "css::container::XNameAccess > xNAccess(m_xHAccess, css::uno::UNO_QUERY);\n"
312 " css::uno::Sequence< OUString > functions = "
313 "xNAccess->getElementNames();\n sal_Int32 len = functions."
314 "getLength();\n OUString sDisplayName;\n"
315 " for (sal_Int32 i=0; i < len; ++i) {\n"
316 " sDisplayName = getAddinProperty(functions[i], "
318 "sDISPLAYNAME);\n if (sDisplayName.equals(aDisplayName))\n"
319 " return functions[i];\n }\n }\n"
320 " catch ( const css::uno::RuntimeException & e ) {\n throw e;\n }\n"
321 " catch ( css::uno::Exception & ) {\n }\n return ret;\n}\n\n";
323 o <<
"OUString SAL_CALL " << classname <<
"getDisplayFunctionName(const "
324 "OUString & aProgrammaticName) throw (css::uno::RuntimeException)\n"
325 "{\n return getAddinProperty(aProgrammaticName, OUString(), "
326 "sDISPLAYNAME);\n}\n\n";
328 o <<
"OUString SAL_CALL " << classname <<
"getFunctionDescription(const "
329 "OUString & aProgrammaticName) throw (css::uno::RuntimeException)\n"
330 "{\n return getAddinProperty(aProgrammaticName, OUString(), "
331 "sDESCRIPTION);\n}\n\n";
333 o <<
"OUString SAL_CALL " << classname <<
"getDisplayArgumentName(const "
334 "OUString & aProgrammaticFunctionName, ::sal_Int32 nArgument) throw "
335 "(css::uno::RuntimeException)\n{\n return getAddinProperty("
336 "aProgrammaticFunctionName,\n m_functionMap["
337 "aProgrammaticFunctionName][nArgument],\n"
338 " sDISPLAYNAME);\n}\n\n";
340 o <<
"OUString SAL_CALL " << classname <<
"getArgumentDescription(const "
341 "OUString & aProgrammaticFunctionName, ::sal_Int32 nArgument) throw "
342 "(css::uno::RuntimeException)\n{\n return getAddinProperty("
343 "aProgrammaticFunctionName,\n "
344 "m_functionMap[aProgrammaticFunctionName][nArgument],\n"
345 " sDESCRIPTION);\n}\n\n";
347 o <<
"OUString SAL_CALL " << classname <<
"getProgrammaticCategoryName("
348 "const OUString & aProgrammaticFunctionName) throw ("
349 "css::uno::RuntimeException)\n{\n return getAddinProperty("
350 "aProgrammaticFunctionName, OUString(), sCATEGORY);\n}\n\n";
352 o <<
"OUString SAL_CALL " << classname <<
"getDisplayCategoryName(const "
353 "OUString & aProgrammaticFunctionName) throw ("
354 "css::uno::RuntimeException)\n{\n return getAddinProperty("
355 "aProgrammaticFunctionName, OUString(), "
356 "sCATEGORYDISPLAYNAME);\n}\n\n";
361 o <<
"// css::sheet::XCompatibilityNames:\n"
362 "css::uno::Sequence< css::sheet::LocalizedName > SAL_CALL " << classname
363 <<
"getCompatibilityNames(const OUString & aProgrammaticName) throw "
364 "(css::uno::RuntimeException)\n{\n css::uno::Sequence< "
365 "css::sheet::LocalizedName > seqLocalizedNames;\n try {\n "
366 "OUStringBuffer buf("
367 "aProgrammaticName);\n buf.appendAscii(\"/CompatibilityName\");\n"
368 " OUString hname(buf.makeStringAndClear());\n\n "
369 "if ( m_xCompAccess->hasByHierarchicalName(hname) ) {\n"
370 " css::uno::Reference< css::container::XNameAccess > "
372 " m_xCompAccess->getByHierarchicalName(hname), "
373 "css::uno::UNO_QUERY);\n\n css::uno::Sequence< OUString"
374 " > elems = \n xNameAccess->getElementNames();"
375 "\n ::sal_Int32 len = elems.getLength();\n\n "
376 "seqLocalizedNames.realloc(len);\n\n OUString "
377 "sCompatibilityName;\n for (::sal_Int32 i=0; i < len; ++i) {\n"
378 " OUString sLocale(elems[i]);\n "
379 "xNameAccess->getByName(sLocale) >>= sCompatibilityName;\n\n"
380 " css::lang::Locale aLocale;\n "
381 "::sal_Int32 nIndex = 0, nToken = 0;\n "
383 "do {\n OUString aToken = sLocale.getToken(0, '-', "
384 "nIndex);\n switch (nToken++) {\n "
385 "case 0:\n aLocale.Language = aToken;\n"
386 " break;\n case 1:\n"
387 " aLocale.Country = aToken;\n "
388 " break;\n default:\n "
389 "aLocale.Variant = sLocale.copy(nIndex-aToken.getLength()-1);\n"
390 " nIndex = -1;\n }\n"
391 " } while ( nIndex >= 0 );\n\n "
392 "seqLocalizedNames[i].Locale = aLocale;\n "
393 "seqLocalizedNames[i].Name = sCompatibilityName;\n }"
394 "\n }\n }\n catch ( const css::uno::RuntimeException & e ) {\n "
395 "throw e;\n }\n catch ( css::uno::Exception & ) {\n }\n\n"
396 " return seqLocalizedNames;\n}\n\n";
401 o <<
"// css::lang::XInitialization:\n"
402 "void SAL_CALL " << classname <<
"initialize( const css::uno::Sequence< "
403 "css::uno::Any >& aArguments ) "
404 "throw (css::uno::Exception, css::uno::RuntimeException)\n{\n"
405 " css::uno::Reference < css::frame::XFrame > xFrame;\n"
406 " if ( aArguments.getLength() ) {\n aArguments[0] >>= xFrame;\n"
407 " m_xFrame = xFrame;\n }\n}\n\n";
411 const OString & classname,
416 o <<
"// css::frame::XDispatch:\n"
417 "void SAL_CALL " << classname <<
"dispatch( const css::util::URL& aURL, const "
418 "css::uno::Sequence< css::beans::PropertyValue >& aArguments ) throw"
419 "(css::uno::RuntimeException)\n{\n";
421 for (
const auto& rEntry : protocolCmdMap) {
422 o <<
" if ( aURL.Protocol.equalsAscii(\"" << rEntry.first
423 <<
"\") == 0 )\n {\n";
425 for (
const auto& rCmd : rEntry.second) {
426 o <<
" if ( aURL.Path.equalsAscii(\"" << rCmd <<
"\") )\n"
427 " {\n // add your own code here\n"
436 o <<
"void SAL_CALL " << classname <<
"addStatusListener( const css::uno::Reference< "
437 "css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) "
438 "throw (css::uno::RuntimeException)\n{\n"
439 " // add your own code here\n}\n\n";
442 o <<
"void SAL_CALL " << classname <<
"removeStatusListener( const css::uno::Reference"
443 "< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) "
444 "throw (css::uno::RuntimeException)\n{\n"
445 " // add your own code here\n}\n\n";
449 const OString & classname,
455 o <<
"// css::frame::XDispatchProvider:\n"
456 "css::uno::Reference< css::frame::XDispatch > SAL_CALL " << classname
457 <<
"queryDispatch( const css::util::URL& aURL,"
458 " const OUString& sTargetFrameName, sal_Int32 nSearchFlags ) "
459 "throw(css::uno::RuntimeException)\n{\n css::uno::Reference< "
460 "css::frame::XDispatch > xRet;\n"
461 " if ( !m_xFrame.is() )\n return 0;\n\n";
463 for (
const auto& rEntry : protocolCmdMap) {
464 o <<
" if ( aURL.Protocol.equalsAscii(\"" << rEntry.first
465 <<
"\") == 0 )\n {\n";
467 for (
const auto& rCmd : rEntry.second) {
468 o <<
" if ( aURL.Path.equalsAscii(\"" << rCmd <<
"\") == 0 )\n"
474 o <<
" return xRet;\n}\n\n";
477 o <<
"css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL "
478 << classname <<
"queryDispatches( const css::uno::Sequence< "
479 "css::frame::DispatchDescriptor >& seqDescripts ) throw("
480 "css::uno::RuntimeException)\n{\n"
481 " sal_Int32 nCount = seqDescripts.getLength();\n"
482 " css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > "
483 "lDispatcher(nCount);\n\n"
484 " for( sal_Int32 i=0; i<nCount; ++i ) {\n"
485 " lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL,\n"
486 " seqDescripts[i].FrameName,\n"
487 " seqDescripts[i].SearchFlags );\n"
488 " }\n\n return lDispatcher;\n}\n\n";
494 const std::set< OUString >& interfaces)
496 o << classname <<
"::" << classname
497 <<
"(css::uno::Reference< css::uno::XComponentContext > const & context) :\n"
498 " m_xContext(context), m_locale()\n{\n";
505 o <<
" css::uno::Reference< css::lang::XMultiServiceFactory > xProvider"
506 "(\n m_xContext->getServiceManager()->createInstanceWithContext"
508 " \"com.sun.star.configuration.ConfigurationProvider\"),"
509 "\n m_xContext ), css::uno::UNO_QUERY );\n\n";
511 o <<
" OUString sReadOnlyView(\n"
512 " \"com.sun.star.configuration.ConfigurationAccess\");\n\n";
514 o <<
" OUStringBuffer sPath(OUString(\n"
515 " \"/org.openoffice.Office.CalcAddIns/AddInInfo/\"));\n"
516 " sPath.appendAscii(sADDIN_SERVICENAME);\n"
517 " sPath.appendAscii(\"/AddInFunctions\");\n\n"
518 " // create arguments: nodepath\n"
519 " css::beans::PropertyValue aArgument;\n"
520 " aArgument.Name = OUString(\"nodepath\");\n"
521 " aArgument.Value <<= sPath.makeStringAndClear();\n\n"
522 " css::uno::Sequence< css::uno::Any > aArguments(1);\n"
523 " aArguments[0] <<= aArgument;\n\n";
525 o <<
" // create the default view using default UI locale\n"
526 " css::uno::Reference< css::uno::XInterface > xIface =\n"
527 " xProvider->createInstanceWithArguments(sReadOnlyView, "
529 " m_xHAccess.set(xIface, css::uno::UNO_QUERY);"
532 o <<
" // extend arguments to create a view for all locales to get "
533 "simple\n // access to the compatibilityname property\n"
534 " aArgument.Name = OUString(\"locale\");\n"
535 " aArgument.Value <<= OUString(\"*\");\n"
536 " aArguments.realloc(2);\n"
537 " aArguments[1] <<= aArgument;\n\n"
538 " // create view for all locales\n"
539 " xIface = xProvider->createInstanceWithArguments(sReadOnlyView, "
541 " m_xCompAccess.set(xIface, css::uno::UNO_QUERY);\n";
543 o <<
" }\n catch ( css::uno::Exception & ) {\n }\n}\n\n";
545 o <<
"// addin configuration property helper function:\nOUString "
546 "SAL_CALL " << classname <<
"::getAddinProperty(const OUString &"
547 " funcName, const OUString & paramName, const char * propName) "
548 "throw (css::uno::RuntimeException)\n{\n"
549 " OUString ret;\n try {\n "
550 "OUStringBuffer buf(funcName);\n"
551 " if (!paramName.isEmpty()) {\n"
552 " buf.appendAscii(\"/Parameters/\");\n"
553 " buf.append(paramName);\n }\n\n"
554 " css::uno::Reference< css::beans::XPropertySet > xPropSet(\n"
555 " m_xHAccess->getByHierarchicalName(\n"
556 " buf.makeStringAndClear()), css::uno::UNO_QUERY);\n"
557 " xPropSet->getPropertyValue(\n "
558 "OUString(propName)) >>= ret;\n }\n"
559 " catch ( const css::uno::RuntimeException & e ) {\n throw e;\n }\n"
560 " catch ( css::uno::Exception & ) {\n }\n return ret;\n";
570 for (
const auto& rMember :
members)
573 if ((
manager->decompose(rMember.type,
true,
nullptr, &rank,
nullptr,
nullptr)
577 o <<
",\n m_" << rMember.name <<
"(";
589 for (
const auto& rMember :
members)
593 o <<
" m_" << rMember.name <<
";\n";
600 OString
const & classname,
601 std::set< OUString >
const & interfaces,
604 std::set< OUString >
const & propinterfaces,
605 OUString
const & propertyhelper,
bool supportxcomponent)
607 OStringBuffer parentname(64);
608 o <<
"class " << classname <<
":\n";
610 if (!interfaces.empty()) {
611 if (supportxcomponent) {
612 parentname.append(
"::cppu::WeakComponentImplHelper" +
613 OString::number(
static_cast<sal_Int32
>(interfaces.size())));
614 o <<
" private ::cppu::BaseMutex,\n"
615 " public ::cppu::WeakComponentImplHelper"
616 << interfaces.size() <<
"<";
618 parentname.append(
"::cppu::WeakImplHelper" +
619 OString::number(
static_cast<sal_Int32
>(interfaces.size())));
620 o <<
" public ::cppu::WeakImplHelper" << interfaces.size() <<
"<";
623 std::set< OUString >::const_iterator iter = interfaces.begin();
624 while (iter != interfaces.end())
628 if (iter != interfaces.end())
635 if (propertyhelper.getLength() > 1) {
636 o <<
",\n public ::cppu::PropertySetMixin< "
640 o <<
"\n{\npublic:\n"
641 " explicit " << classname <<
"("
642 "css::uno::Reference< css::uno::XComponentContext > const & context);\n\n";
654 if (propertyhelper.getLength() > 1) {
655 o <<
" // css::uno::XInterface:\n"
656 " virtual css::uno::Any SAL_CALL queryInterface("
657 "css::uno::Type const & type) throw ("
658 "css::uno::RuntimeException);\n";
660 OStringBuffer buffer(256);
661 buffer.append(parentname +
"< ");
662 std::set< OUString >::const_iterator iter = interfaces.begin();
663 while (iter != interfaces.end())
667 if (iter != interfaces.end())
672 OString parent(buffer.makeStringAndClear());
673 o <<
" virtual void SAL_CALL acquire() throw ()\n { "
674 << parent <<
"::acquire(); }\n";
675 o <<
" virtual void SAL_CALL release() throw ()\n { "
676 << parent <<
"::release(); }\n\n";
680 for (
const auto& rIface : interfaces)
683 true, propertyhelper);
686 o <<
"private:\n " << classname <<
"(const " << classname <<
" &); // not defined\n"
687 " " << classname <<
"& operator=(const " << classname <<
" &); // not defined\n\n"
688 " // destructor is private and will be called indirectly by the release call"
689 " virtual ~" << classname <<
"() {}\n\n";
692 o <<
" typedef boost::unordered_map< ::sal_Int32, OUString, "
693 "boost::hash<::sal_Int32> > ParamMap;\n"
694 " typedef boost::unordered_map< OUString, ParamMap, "
695 "OUStringHash > FunctionMap;\n\n"
696 " OUString SAL_CALL getAddinProperty(const OUString & "
697 "funcName, const OUString & paramName, const char * propName) "
698 "throw (css::uno::RuntimeException);\n\n";
701 if (supportxcomponent) {
702 o <<
" // override WeakComponentImplHelperBase::disposing()\n"
703 " // This function is called upon disposing the component,\n"
704 " // if your component needs special work when it becomes\n"
705 " // disposed, do it here.\n"
706 " virtual void SAL_CALL disposing();\n\n";
710 o <<
" css::uno::Reference< css::uno::XComponentContext > m_xContext;\n";
711 if (!supportxcomponent && !attributes.empty())
712 o <<
" mutable ::osl::Mutex m_aMutex;\n";
716 o <<
" css::uno::Reference< css::frame::XFrame > m_xFrame;\n";
721 o <<
" css::uno::Reference< css::container::XHierarchicalNameAccess > "
723 " css::uno::Reference< css::container::XHierarchicalNameAccess > "
725 " FunctionMap m_functionMap;\n";
727 o <<
" css::lang::Locale m_locale;\n";
763 classname, interfaces);
765 o << classname <<
"::" << classname
766 <<
"(css::uno::Reference< css::uno::XComponentContext > const & context) :\n";
767 if (supportxcomponent) {
768 o <<
" ::cppu::WeakComponentImplHelper" << interfaces.size() <<
"<";
769 std::set< OUString >::const_iterator iter = interfaces.begin();
770 while (iter != interfaces.end()) {
773 if (iter != interfaces.end())
776 o <<
">(m_aMutex),\n";
779 if (propertyhelper.getLength() > 1) {
780 o <<
" ::cppu::PropertySetMixin< "
782 " context, static_cast< Implements >(\n ";
783 OStringBuffer buffer(128);
784 if (propinterfaces.find(
"com/sun/star/beans/XPropertySet")
785 != propinterfaces.end()) {
786 buffer.append(
"IMPLEMENTS_PROPERTY_SET");
788 if (propinterfaces.find(
"com/sun/star/beans/XFastPropertySet")
789 != propinterfaces.end()) {
790 if (!buffer.isEmpty())
791 buffer.append(
" | IMPLEMENTS_FAST_PROPERTY_SET");
793 buffer.append(
"IMPLEMENTS_FAST_PROPERTY_SET");
795 if (propinterfaces.find(
"com/sun/star/beans/XPropertyAccess")
796 != propinterfaces.end()) {
797 if (!buffer.isEmpty())
798 buffer.append(
" | IMPLEMENTS_PROPERTY_ACCESS");
800 buffer.append(
"IMPLEMENTS_PROPERTY_ACCESS");
802 o << buffer.makeStringAndClear()
803 <<
"), css::uno::Sequence< OUString >()),\n";
805 o <<
" m_xContext(context)";
816 if (supportxcomponent) {
817 o <<
"// override WeakComponentImplHelperBase::disposing()\n"
818 "// This function is called upon disposing the component,\n"
819 "// if your component needs special work when it becomes\n"
820 "// disposed, do it here.\n"
821 "void SAL_CALL " << classname <<
"::disposing()\n{\n\n}\n\n";
824 return parentname.makeStringAndClear();
828 OString
const & classname,
829 OString
const & comphelpernamespace)
831 o <<
"// com.sun.star.uno.XServiceInfo:\n"
832 "OUString SAL_CALL " << classname <<
"getImplementationName() "
833 "throw (css::uno::RuntimeException)\n{\n "
834 "return " << comphelpernamespace <<
"::_getImplementationName();\n}\n\n";
836 o <<
"sal_Bool SAL_CALL " << classname
837 <<
"supportsService(OUString const & "
838 "serviceName) throw (css::uno::RuntimeException)\n{\n "
839 "css::uno::Sequence< OUString > serviceNames = "
840 << comphelpernamespace <<
"::_getSupportedServiceNames();\n "
841 "for (::sal_Int32 i = 0; i < serviceNames.getLength(); ++i) {\n "
842 " if (serviceNames[i] == serviceName)\n return sal_True;\n"
843 " }\n return sal_False;\n}\n\n";
845 o <<
"css::uno::Sequence< OUString > SAL_CALL " << classname
846 <<
"getSupportedServiceNames() throw (css::uno::RuntimeException)\n{\n "
847 "return " << comphelpernamespace
848 <<
"::_getSupportedServiceNames();\n}\n\n";
855 std::set< OUString >
const & interfaces,
856 std::string_view classname,
857 OString
const & comphelpernamespace,
858 OUString
const & propertyhelper)
860 OString
name = OString::Concat(classname) +
"::";
862 for (
const auto& rIface : interfaces) {
863 if ( rIface ==
"com.sun.star.lang.XServiceInfo" ) {
865 generated.
add(
u2b(rIface));
868 name,
"",
true, propertyhelper);
876 const std::set< OUString >& interfaces,
877 OString
const & parentname,
878 OString
const & classname,
879 std::u16string_view propertyhelper)
881 if (propertyhelper.empty())
884 o <<
"css::uno::Any " << classname
885 <<
"::queryInterface(css::uno::Type const & type) throw ("
886 "css::uno::RuntimeException)\n{\n ";
888 if (!propertyhelper.empty())
891 o <<
"css::uno::Any a(";
893 o << parentname <<
"<";
894 std::set< OUString >::const_iterator iter = interfaces.begin();
895 while (iter != interfaces.end())
899 if (iter != interfaces.end())
905 if (!propertyhelper.empty()) {
906 o <<
"::queryInterface(type);\n";
908 o <<
"::queryInterface(type));\n";
909 o <<
" return a.hasValue() ? a\n : (";
910 if (propertyhelper ==
u"_") {
911 o <<
"::cppu::OPropertySetHelper::queryInterface(type));\n";
913 o <<
"::cppu::PropertySetMixin<\n ";
915 o <<
" >::queryInterface(\n type));\n";
923 std::vector< OString >
const & types)
931 std::set< OUString > interfaces;
932 std::set< OUString > services;
935 std::set< OUString > propinterfaces;
936 bool serviceobject =
false;
937 bool supportxcomponent =
false;
939 for (
const auto& rType : types) {
955 if (!services.empty())
956 serviceobject =
true;
959 options,
manager, services, interfaces, attributes, propinterfaces);
963 if (interfaces.size() > 12)
965 "the skeletonmaker supports components with 12 interfaces "
966 "only (limitation of the UNO implementation helpers)!");
971 OString compFileName;
973 std::ostream* pofs =
nullptr;
975 &pofs, compFileName, tmpFileName);
978 if (!standardout && options.
license) {
986 *pofs <<
"#include \"com/sun/star/frame/XFrame.hpp\"\n";
997 "\n\n/// anonymous implementation namespace\nnamespace {\n\n"
998 "namespace css = ::com::sun::star;\n\n";
1001 *pofs <<
"namespace css = ::com::sun::star;\n\n";
1004 sal_Int32
index = 0;
1005 OString classname(options.
implname);
1006 if ((
index = classname.lastIndexOf(
'.')) > 0)
1007 classname = classname.copy(
index+1);
1012 attributes, propinterfaces, propertyhelper, supportxcomponent));
1015 classname, propertyhelper);
1018 nmspace, propertyhelper);
1020 if (serviceobject) {
1022 *pofs <<
"} // closing anonymous implementation namespace\n\n";
1025 classname, services);
1029 for (
short i=0;
i < nm;
i++)
1031 *pofs << (nm > 0 ?
"// closing namespace\n\n" :
"\n");
1036 if (
static_cast<std::ofstream*
>(pofs)->is_open())
1037 static_cast<std::ofstream*
>(pofs)->close();
1042 std::cerr <<
"ERROR: " << e.
getMessage() <<
"\n";
1043 if ( !standardout ) {
1044 if (
static_cast<std::ofstream*
>(pofs)->is_open())
1045 static_cast<std::ofstream*
>(pofs)->
close();
1060 std::vector< OString >
const & types)
1062 std::set< OUString > interfaces;
1063 std::set< OUString > services;
1066 std::set< OUString > propinterfaces;
1067 bool serviceobject =
false;
1068 bool supportxcomponent =
false;
1071 for (
const auto& rType : types) {
1075 OUString sAddinService;
1076 if (services.size() != 1) {
1078 "for calc add-in components one and only one service type is necessary!"
1079 " Please reference a valid type with the '-t' option.");
1084 std::set< OUString >::const_iterator iter2 = services.begin();
1085 sAddinService = *iter2;
1086 if (sAddinService ==
"com.sun.star.sheet.AddIn") {
1087 sAddinService = *(++iter2);
1102 interfaces.insert(
"com.sun.star.lang.XLocalizable");
1106 options,
manager, services, interfaces, attributes, propinterfaces);
1108 if (!propertyhelper.isEmpty())
1109 std::cerr <<
"WARNING: interfaces specifying calc add-in functions "
1110 "shouldn't support attributes!\n";
1114 if (interfaces.size() > 12) {
1116 "the skeletonmaker supports components with 12 interfaces "
1117 "only (limitation of the UNO implementation helpers)!");
1121 if (!services.empty())
1122 serviceobject =
true;
1125 if (supportxcomponent)
1126 std::cerr <<
"WARNING: add-ins shouldn't support "
1127 "com.sun.star.uno.XComponent!\n";
1129 OString compFileName;
1130 OString tmpFileName;
1131 std::ostream* pofs =
nullptr;
1133 &pofs, compFileName, tmpFileName);
1136 if (!standardout && options.
license) {
1144 "#include \"com/sun/star/beans/PropertyValue.hpp\"\n"
1145 "#include \"com/sun/star/beans/XPropertySet.hpp\"\n"
1146 "#include \"com/sun/star/container/XNameAccess.hpp\"\n"
1147 "#include \"com/sun/star/container/XHierarchicalNameAccess.hpp\"\n\n"
1148 "#include \"rtl/ustrbuf.hxx\"\n\n"
1149 "#include <boost/unordered_map.hpp>\n"
1156 "\n\n// anonymous implementation namespace\nnamespace {\n\n"
1157 "namespace css = ::com::sun::star;\n\n";
1159 sal_Int32
index = 0;
1160 OString classname(options.
implname);
1161 if ((
index = classname.lastIndexOf(
'.')) > 0) {
1162 classname = classname.copy(
index+1);
1166 *pofs <<
"static const char * sADDIN_SERVICENAME = \""
1167 << sAddinService <<
"\";\n\n";
1168 *pofs <<
"static const char * sDISPLAYNAME = \"DisplayName\";\n"
1169 "static const char * sDESCRIPTION = \"Description\";\n"
1170 "static const char * sCATEGORY = \"Category\";\n"
1171 "static const char * sCATEGORYDISPLAYNAME = \"CategoryDisplayName\";"
1178 attributes, propinterfaces, propertyhelper, supportxcomponent));
1181 classname, propertyhelper);
1184 nmspace, propertyhelper);
1187 *pofs <<
"} // closing anonymous implementation namespace\n\n";
1196 if (
static_cast<std::ofstream*
>(pofs)->is_open())
1197 static_cast<std::ofstream*
>(pofs)->
close();
1202 std::cerr <<
"ERROR: " << e.
getMessage() <<
"\n";
1203 if ( !standardout ) {
1204 if (
static_cast<std::ofstream*
>(pofs)->is_open())
1205 static_cast<std::ofstream*
>(pofs)->
close();
const OUString & getMessage() const
void add(OString const &type)
rtl::Reference< ParseManager > manager
bool removeTypeFile(const OString &fileName)
bool fileExists(const OString &fileName)
bool makeValidTypeFile(const OString &targetFileName, const OString &tmpFileName, bool bFileCheck)
OString scopedCppName(OString const &type, bool ns_alias)
void generateXPropertyAccessBodies(std::ostream &o, const OString &classname, const OString &propertyhelper)
static void generateAddinConstructorAndHelper(std::ostream &o, ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, const OString &classname, const std::set< OUString > &interfaces)
void generateXCompatibilityNamesBodies(std::ostream &o, const OString &classname)
static short generateNamespace(std::ostream &o, const OString &implname, bool serviceobject, OString &nm)
static void printType(std::ostream &o, ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, codemaker::UnoType::Sort sort, std::u16string_view nucleus, sal_Int32 rank, std::vector< OUString > const &arguments, rtl::Reference< unoidl::Entity > const &entity, short referenceType, bool defaultvalue)
static void generateQueryInterface(std::ostream &o, ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, const std::set< OUString > &interfaces, OString const &parentname, OString const &classname, std::u16string_view propertyhelper)
static OString generateClassDefinition(std::ostream &o, ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, OString const &classname, std::set< OUString > const &interfaces, AttributeInfo const &properties, AttributeInfo const &attributes, std::set< OUString > const &propinterfaces, OUString const &propertyhelper, bool supportxcomponent)
static void generateMemberDeclaration(std::ostream &o, ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, AttributeInfo const &members)
void generateXInitialization(std::ostream &o, const OString &classname)
void generateXFastPropertySetBodies(std::ostream &o, const OString &classname, const OString &propertyhelper)
void generateXPropertySetBodies(std::ostream &o, const OString &classname, const OString &propertyhelper)
static OString generateCompHelperDeclaration(std::ostream &o, const OString &implname)
static void generateMemberInitialization(std::ostream &o, ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, AttributeInfo const &members)
static void generateIncludes(std::ostream &o, const std::set< OUString > &interfaces, std::u16string_view propertyhelper, const bool serviceobject, const bool supportxcomponent)
void generateXLocalizable(std::ostream &o, const OString &classname)
static void generateXServiceInfoBodies(std::ostream &o, OString const &classname, OString const &comphelpernamespace)
static void generateCompFunctions(std::ostream &o, const OString &nmspace)
void generateCalcAddin(ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, std::vector< OString > const &types)
void generateXAddInBodies(std::ostream &o, const OString &classname)
void generateXDispatch(std::ostream &o, const OString &classname, const ProtocolCmdMap &protocolCmdMap)
static void generateMethodBodies(std::ostream &o, ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, std::set< OUString > const &interfaces, std::string_view classname, OString const &comphelpernamespace, OUString const &propertyhelper)
void printMethods(std::ostream &o, ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, OUString const &name, codemaker::GeneratedTypeSet &generated, OString const &delegate, OString const &classname, OString const &indentation, bool defaultvalue, OUString const &propertyhelper)
void generateSkeleton(ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, std::vector< OString > const &types)
static void generateCompHelperDefinition(std::ostream &o, const OString &implname, const OString &classname, const std::set< OUString > &services)
void generateXDispatchProvider(std::ostream &o, const OString &classname, const ProtocolCmdMap &protocolCmdMap)
OUString checkPropertyHelper(ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, const std::set< OUString > &services, const std::set< OUString > &interfaces, AttributeInfo &attributes, std::set< OUString > &propinterfaces)
bool getOutputStream(ProgramOptions const &options, OString const &extension, std::ostream **ppOutputStream, OString &targetSourceFileName, OString &tmpSourceFileName)
create dependent on the output path, the implementation name and the extension a new output file.
::std::vector< unoidl::AccumulationBasedServiceEntity::Property > AttributeInfo
void checkDefaultInterfaces(std::set< OUString > &interfaces, const std::set< OUString > &services, std::u16string_view propertyhelper)
static bool checkXComponentSupport(rtl::Reference< TypeManager > const &manager, OUString const &name)
::std::map< OString, ::std::vector< OString > > ProtocolCmdMap
void checkType(rtl::Reference< TypeManager > const &manager, OUString const &name, std::set< OUString > &interfaceTypes, std::set< OUString > &serviceTypes, AttributeInfo &properties)
void printLicenseHeader(std::ostream &o)
print the standard OpenOffice.org license header
static void generateFunctionParameterMap(std::ostream &o, ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, OUString const &name, ::codemaker::GeneratedTypeSet &generated, bool &bFirst)
PyObject_HEAD PyUNO_callable_Internals * members
OUString b2u(std::string_view s)
OString u2b(std::u16string_view s)