24#include <rtl/strbuf.hxx>
37 size_t index = implname.rfind(
'.');
38 if (
index != std::string_view::npos)
39 o <<
"package " << implname.substr(0,
index) <<
";\n\n";
43 std::u16string_view propertyhelper,
44 bool serviceobject,
bool supportxcomponent)
47 o <<
"import com.sun.star.uno.UnoRuntime;\n";
48 o <<
"import com.sun.star.uno.XComponentContext;\n";
50 o <<
"import com.sun.star.lib.uno.helper.Factory;\n";
51 o <<
"import com.sun.star.lang.XSingleComponentFactory;\n";
52 o <<
"import com.sun.star.registry.XRegistryKey;\n";
55 if (propertyhelper !=
u"_") {
56 if (supportxcomponent)
57 o <<
"import com.sun.star.lib.uno.helper.ComponentBase;\n";
59 o <<
"import com.sun.star.lib.uno.helper.WeakBase;\n";
61 if (!propertyhelper.empty()) {
62 if (propertyhelper ==
u"_") {
63 o <<
"import com.sun.star.lib.uno.helper.PropertySet;\n";
64 o <<
"import com.sun.star.beans.PropertyAttribute;\n";
66 o <<
"import com.sun.star.uno.Type;\n";
67 o <<
"import com.sun.star.uno.Any;\n";
68 o <<
"import com.sun.star.beans.Ambiguous;\n";
69 o <<
"import com.sun.star.beans.Defaulted;\n";
70 o <<
"import com.sun.star.beans.Optional;\n";
71 o <<
"import com.sun.star.lib.uno.helper.PropertySetMixin;\n";
78 o <<
" public static XSingleComponentFactory __getComponentFactory("
79 " String sImplementationName ) {\n"
80 " XSingleComponentFactory xFactory = null;\n\n"
81 " if ( sImplementationName.equals( m_implementationName ) )\n"
82 " xFactory = Factory.createComponentFactory("
83 << classname <<
".class, m_serviceNames);\n"
84 " return xFactory;\n }\n\n";
86 o <<
" public static boolean __writeRegistryServiceInfo("
87 " XRegistryKey xRegistryKey ) {\n"
88 " return Factory.writeRegistryServiceInfo(m_implementationName,\n"
96 o <<
" // com.sun.star.lang.XServiceInfo:\n";
97 o <<
" public String getImplementationName() {\n"
98 " return m_implementationName;\n }\n\n";
100 o <<
" public boolean supportsService( String sService ) {\n"
101 " int len = m_serviceNames.length;\n\n"
102 " for( int i=0; i < len; i++) {\n"
103 " if (sService.equals(m_serviceNames[i]))\n"
105 " }\n return false;\n }\n\n";
107 o <<
" public String[] getSupportedServiceNames() {\n"
108 " return m_serviceNames;\n }\n\n";
113 o <<
" // com.sun.star.beans.XPropertySet:\n";
114 o <<
" public com.sun.star.beans.XPropertySetInfo getPropertySetInfo()\n"
115 " {\n return m_prophlp.getPropertySetInfo();\n }\n\n";
117 o <<
" public void setPropertyValue(String aPropertyName, "
118 "Object aValue) throws "
119 "com.sun.star.beans.UnknownPropertyException, "
120 "com.sun.star.beans.PropertyVetoException, "
121 "com.sun.star.lang.IllegalArgumentException,"
122 "com.sun.star.lang.WrappedTargetException\n {\n "
123 "m_prophlp.setPropertyValue(aPropertyName, aValue);\n }\n\n";
125 o <<
" public Object getPropertyValue(String "
126 "aPropertyName) throws com.sun.star.beans.UnknownPropertyException, "
127 "com.sun.star.lang.WrappedTargetException\n {\n return "
128 "m_prophlp.getPropertyValue(aPropertyName);\n }\n\n";
130 o <<
" public void addPropertyChangeListener(String aPropertyName"
131 ", com.sun.star.beans.XPropertyChangeListener xListener) throws "
132 "com.sun.star.beans.UnknownPropertyException, "
133 "com.sun.star.lang.WrappedTargetException\n {\n "
134 "m_prophlp.addPropertyChangeListener(aPropertyName, xListener);\n }\n\n";
136 o <<
" public void removePropertyChangeListener(String "
137 "aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener) "
138 "throws com.sun.star.beans.UnknownPropertyException, "
139 "com.sun.star.lang.WrappedTargetException\n {\n "
140 "m_prophlp.removePropertyChangeListener(aPropertyName, xListener);\n"
143 o <<
" public void addVetoableChangeListener(String aPropertyName"
144 ", com.sun.star.beans.XVetoableChangeListener xListener) throws "
145 "com.sun.star.beans.UnknownPropertyException, "
146 "com.sun.star.lang.WrappedTargetException\n {\n "
147 "m_prophlp.addVetoableChangeListener(aPropertyName, xListener);\n }\n\n";
149 o <<
" public void removeVetoableChangeListener(String "
150 "aPropertyName, com.sun.star.beans.XVetoableChangeListener xListener) "
151 "throws com.sun.star.beans.UnknownPropertyException, "
152 "com.sun.star.lang.WrappedTargetException\n {\n "
153 "m_prophlp.removeVetoableChangeListener(aPropertyName, xListener);\n }\n\n";
158 o <<
" // com.sun.star.beans.XFastPropertySet:\n";
160 o <<
" public void setFastPropertyValue(int nHandle, Object "
161 "aValue) throws com.sun.star.beans.UnknownPropertyException, "
162 "com.sun.star.beans.PropertyVetoException, "
163 "com.sun.star.lang.IllegalArgumentException, "
164 "com.sun.star.lang.WrappedTargetException\n {\n "
165 "m_prophlp.setFastPropertyValue(nHandle, aValue);\n }\n\n";
167 o <<
" public Object getFastPropertyValue(int nHandle) throws "
168 "com.sun.star.beans.UnknownPropertyException, "
169 "com.sun.star.lang.WrappedTargetException\n {\n return "
170 "m_prophlp.getFastPropertyValue(nHandle);\n }\n\n";
175 o <<
" // com.sun.star.beans.XPropertyAccess:\n";
177 o <<
" public com.sun.star.beans.PropertyValue[] getPropertyValues()\n"
178 " {\n return m_prophlp.getPropertyValues();\n }\n\n";
180 o <<
" public void setPropertyValues(com.sun.star.beans.PropertyValue[] "
181 "aProps) throws com.sun.star.beans.UnknownPropertyException, "
182 "com.sun.star.beans.PropertyVetoException, "
183 "com.sun.star.lang.IllegalArgumentException, "
184 "com.sun.star.lang.WrappedTargetException\n {\n "
185 "m_prophlp.setPropertyValues(aProps);\n }\n\n";
190 OStringBuffer& attributeValue,
194 sal_uInt16 attributes[9] = {
205 for (sal_uInt16
i = 0;
i < 9;
i++)
208 if (!attributeValue.isEmpty()) {
210 attributeValue.append(
"|");
212 switch (attributes[
i])
215 attributeValue.append(
"PropertyAttribute.MAYBEVOID");
218 attributeValue.append(
"PropertyAttribute.BOUND");
221 attributeValue.append(
"PropertyAttribute.CONSTRAINED");
224 attributeValue.append(
"PropertyAttribute.TRANSIENT");
227 attributeValue.append(
"PropertyAttribute.READONLY");
230 attributeValue.append(
"PropertyAttribute.MAYBEAMBIGUOUS");
233 attributeValue.append(
"PropertyAttribute.MAYBEDEFAULT");
236 attributeValue.append(
"PropertyAttribute.REMOVABLE");
239 attributeValue.append(
"PropertyAttribute.OPTIONAL");
245 attributeValue.insert(0,
'(');
246 attributeValue.append(
')');
254 const OString& indentation)
258 OStringBuffer attributeValue;
261 if (rProp.attributes != 0) {
265 attributeValue.append(
'0');
268 o << indentation <<
"registerProperty(\"" << rProp.name
269 <<
"\", \"m_" << rProp.name <<
"\",\n"
270 << indentation <<
" ";
274 o << attributeValue.makeStringAndClear() <<
");\n";
282 o <<
" // com.sun.star.lang.XLocalizable:\n"
283 " public void setLocale(com.sun.star.lang.Locale eLocale)\n {\n"
284 " m_locale = eLocale;\n }\n\n";
287 o <<
" public com.sun.star.lang.Locale getLocale()\n {\n"
288 " return m_locale;\n }\n\n";
295 o <<
" // com.sun.star.sheet.XAddIn:\n"
296 " public String getProgrammaticFuntionName(String "
297 "aDisplayName)\n {\n"
299 " com.sun.star.container.XNameAccess xNAccess =\n"
300 " (com.sun.star.container.XNameAccess)UnoRuntime."
302 " com.sun.star.container.XNameAccess.class, m_xHAccess);"
303 "\n String functions[] = xNAccess.getElementNames();\n"
304 " String sDisplayName = \"\";\n"
305 " int len = functions.length;\n"
306 " for (int i=0; i < len; ++i) {\n"
307 " sDisplayName = com.sun.star.uno.AnyConverter.toString(\n"
308 " getAddinProperty(functions[i], \"\", sDISPLAYNAME));\n"
309 " if (sDisplayName.equals(aDisplayName))\n"
310 " return functions[i];\n }\n"
311 " }\n catch ( com.sun.star.uno.RuntimeException e ) {\n"
313 " catch ( com.sun.star.uno.Exception e ) {\n }\n\n"
314 " return \"\";\n }\n\n";
317 o <<
" public String getDisplayFunctionName(String "
318 "aProgrammaticName)\n {\n"
319 " return getAddinProperty(aProgrammaticName, \"\", sDISPLAYNAME);\n"
323 o <<
" public String getFunctionDescription(String "
324 "aProgrammaticName)\n {\n"
325 " return getAddinProperty(aProgrammaticName, \"\", sDESCRIPTION);\n"
329 o <<
" public String getDisplayArgumentName(String "
330 "aProgrammaticFunctionName, int nArgument)\n {\n";
331 o <<
" return getAddinProperty(aProgrammaticFunctionName,\n"
332 " m_functionMap.get(\n"
333 " aProgrammaticFunctionName).get("
335 " sDISPLAYNAME);\n }\n\n";
338 o <<
" public String getArgumentDescription(String "
339 "aProgrammaticFunctionName, int nArgument)\n {\n";
340 o <<
" return getAddinProperty(aProgrammaticFunctionName,\n"
341 " m_functionMap.get(\n"
342 " aProgrammaticFunctionName).get("
344 " sDESCRIPTION);\n }\n\n";
347 o <<
" public String getProgrammaticCategoryName(String "
348 "aProgrammaticFunctionName)\n {\n"
349 " return getAddinProperty(aProgrammaticFunctionName, \"\", "
350 "sCATEGORY);\n }\n\n";
353 o <<
" public String getDisplayCategoryName(String "
354 "aProgrammaticFunctionName)\n {\n"
355 " return getAddinProperty(aProgrammaticFunctionName, \"\", "
356 "sCATEGORYDISPLAYNAME);\n }\n\n";
361 o <<
" // com.sun.star.sheet.XCompatibilityNames:\n"
362 " public com.sun.star.sheet.LocalizedName[] getCompatibilityNames("
363 "String aProgrammaticName)\n {\n"
364 " com.sun.star.sheet.LocalizedName[] seqLocalizedNames =\n"
365 " new com.sun.star.sheet.LocalizedName[0];\n\n try {\n";
367 o <<
" StringBuffer path = new StringBuffer(aProgrammaticName);\n"
368 " path.append(\"/CompatibilityName\");\n"
369 " String hname = path.toString();\n\n";
371 o <<
" if ( m_xCompAccess.hasByHierarchicalName(hname) ) {\n"
372 " com.sun.star.container.XNameAccess xNameAccess =\n"
373 " (com.sun.star.container.XNameAccess)UnoRuntime."
375 " com.sun.star.container.XNameAccess.class,\n"
376 " m_xCompAccess.getByHierarchicalName(hname));\n\n"
377 " String elems[] = xNameAccess.getElementNames();\n"
378 " int len = elems.length;\n"
379 " seqLocalizedNames = new com.sun.star.sheet.LocalizedName"
380 "[len];\n String sCompatibilityName = \"\";\n\n";
382 o <<
" for (int i=0; i < len; ++i) {\n"
383 " String sLocale = elems[i];\n"
384 " sCompatibilityName = com.sun.star.uno.AnyConverter."
385 "toString(\n xNameAccess.getByName(sLocale));\n\n"
386 " com.sun.star.lang.Locale aLocale = \n"
387 " new com.sun.star.lang.Locale();\n\n"
389 " String tokens[] = sLocale.split(\"-\");\n"
390 " int nToken = tokens.length;\n"
391 " if (nToken >= 1) aLocale.Language = tokens[0];\n"
392 " if (nToken >= 2) aLocale.Country = tokens[1];\n"
393 " if (nToken >= 3) {\n"
394 " StringBuffer buf = \n"
395 " new StringBuffer(tokens[2]);\n"
396 " for (int t=3; t < nToken; ++t)\n"
397 " buf.append(tokens[t]);\n\n"
398 " aLocale.Variant = buf.toString();\n"
400 " seqLocalizedNames[i].Locale = aLocale;\n"
401 " seqLocalizedNames[i].Name = sCompatibilityName;\n"
403 " catch ( com.sun.star.uno.RuntimeException e ) {\n"
405 " catch ( com.sun.star.uno.Exception e ) {\n }\n\n"
406 " return seqLocalizedNames;\n }\n\n";
411 o <<
" // com.sun.star.lang.XInitialization:\n"
412 " public void initialize( Object[] object )\n"
413 " throws com.sun.star.uno.Exception\n {\n"
414 " if ( object.length > 0 )\n {\n"
415 " m_xFrame = (com.sun.star.frame.XFrame)UnoRuntime.queryInterface(\n"
416 " com.sun.star.frame.XFrame.class, object[0]);\n }\n }\n\n";
423 o <<
" // com.sun.star.frame.XDispatch:\n"
424 " public void dispatch( com.sun.star.util.URL aURL,\n"
425 " com.sun.star.beans.PropertyValue[] aArguments )\n {\n";
428 o <<
" if ( aURL.Protocol.equals(\"" << rEntry.first
431 for (
const auto& rCmd : rEntry.second) {
432 o <<
" if ( aURL.Path.equals(\"" << rCmd <<
"\") )\n"
433 " {\n // add your own code here\n"
442 o <<
" public void addStatusListener( com.sun.star.frame.XStatusListener xControl,\n"
443 " com.sun.star.util.URL aURL )\n {\n"
444 " // add your own code here\n }\n\n";
447 o <<
" public void removeStatusListener( com.sun.star.frame.XStatusListener xControl,\n"
448 " com.sun.star.util.URL aURL )\n {\n"
449 " // add your own code here\n }\n\n";
456 o <<
" // com.sun.star.frame.XDispatchProvider:\n"
457 " public com.sun.star.frame.XDispatch queryDispatch( com.sun.star.util.URL aURL,\n"
458 " String sTargetFrameName,\n"
459 " int iSearchFlags )\n {\n";
462 o <<
" if ( aURL.Protocol.equals(\"" << rEntry.first
465 for (
const auto& rCmd : rEntry.second) {
466 o <<
" if ( aURL.Path.equals(\"" << rCmd <<
"\") )\n"
472 o <<
" return null;\n }\n\n";
475 o <<
" // com.sun.star.frame.XDispatchProvider:\n"
476 " public com.sun.star.frame.XDispatch[] queryDispatches(\n"
477 " com.sun.star.frame.DispatchDescriptor[] seqDescriptors )\n {\n"
478 " int nCount = seqDescriptors.length;\n"
479 " com.sun.star.frame.XDispatch[] seqDispatcher =\n"
480 " new com.sun.star.frame.XDispatch[seqDescriptors.length];\n\n"
481 " for( int i=0; i < nCount; ++i )\n {\n"
482 " seqDispatcher[i] = queryDispatch(seqDescriptors[i].FeatureURL,\n"
483 " seqDescriptors[i].FrameName,\n"
484 " seqDescriptors[i].SearchFlags );\n"
485 " }\n return seqDispatcher;\n }\n\n";
491 const std::set< OUString >& interfaces,
492 const OString& indentation,
bool usepropertymixin)
495 for (
const OUString&
type : interfaces) {
496 if (
type ==
"com.sun.star.lang.XServiceInfo") {
501 if (
type ==
"com.sun.star.lang.XServiceName") {
502 o <<
" // com.sun.star.lang.XServiceName:\n"
503 " public String getServiceName() {\n"
504 " return sADDIN_SERVICENAME;\n }\n";
507 }
else if (
type ==
"com.sun.star.sheet.XAddIn") {
512 if (!generated.
contains(
"com.sun.star.lang.XLocalizable")) {
514 generated.
add(
"com.sun.star.lang.XLocalizable");
517 }
else if (
type ==
"com.sun.star.lang.XLocalizable") {
521 }
else if (
type ==
"com.sun.star.sheet.XCompatibilityNames") {
528 if (
type ==
"com.sun.star.lang.XInitialization") {
532 }
else if (
type ==
"com.sun.star.frame.XDispatch") {
536 }
else if (
type ==
"com.sun.star.frame.XDispatchProvider") {
543 indentation,
true, usepropertymixin);
549" // use the last parameter of the PropertySetMixin constructor\n"
550" // for your optional attributes if necessary. See the documentation\n"
551" // of the PropertySetMixin helper for further information.\n"
552" // Ensure that your attributes are initialized correctly!\n";
558 const std::set< OUString >& services,
559 const std::set< OUString >& interfaces)
561 o <<
" private com.sun.star.lang.Locale m_locale = "
562 "new com.sun.star.lang.Locale();\n";
566 o <<
"\n public " << classname <<
"( XComponentContext context )\n"
567 " {\n m_xContext = context;\n }\n\n";
573 std::set< OUString >::const_iterator iter = services.begin();
574 OUString sAddinService = *iter;
575 if (sAddinService ==
"com.sun.star.sheet.AddIn") {
576 sAddinService = *(++iter);
581 o <<
"\n private static final String sADDIN_SERVICENAME = \""
582 << sAddinService <<
"\";\n\n";
583 o <<
" private static final String sDISPLAYNAME = "
585 " private static final String sDESCRIPTION = "
587 " private static final String sCATEGORY = \"Category\";\n"
588 " private static final String sCATEGORYDISPLAYNAME = "
589 "\"CategoryDisplayName\";\n\n";
591 o <<
" private com.sun.star.container.XHierarchicalNameAccess "
592 "m_xHAccess = null;\n"
593 " private com.sun.star.container.XHierarchicalNameAccess "
594 "m_xCompAccess = null;\n";
595 o <<
" private java.util.Hashtable<\n String, "
596 "java.util.Hashtable< Integer, String> > m_functionMap = null;\n\n";
599 o <<
"\n public " << classname <<
"( XComponentContext context )\n {\n"
600 " m_xContext = context;\n\n"
603 o <<
" m_functionMap = new java.util.Hashtable<\n"
604 " String, java.util.Hashtable< Integer, String > >();\n\n";
608 o <<
" com.sun.star.lang.XMultiServiceFactory xProvider = \n"
609 " (com.sun.star.lang.XMultiServiceFactory)UnoRuntime."
611 " com.sun.star.lang.XMultiServiceFactory.class,\n"
612 " m_xContext.getServiceManager().createInstanceWithContext("
613 "\n \"com.sun.star.configuration.ConfigurationProvider\""
614 ",\n m_xContext));\n\n";
616 o <<
" String sReadOnlyView = "
617 "\"com.sun.star.configuration.ConfigurationAccess\";\n\n";
619 o <<
" StringBuffer sPath = new StringBuffer(\n"
620 " \"/org.openoffice.Office.CalcAddIns/AddInInfo/\");\n"
621 " sPath.append(sADDIN_SERVICENAME);\n"
622 " sPath.append(\"/AddInFunctions\");\n\n";
624 o <<
" // create arguments: nodepath\n"
625 " com.sun.star.beans.PropertyValue aArgument = \n"
626 " new com.sun.star.beans.PropertyValue();\n"
627 " aArgument.Name = \"nodepath\";\n"
628 " aArgument.Value = new com.sun.star.uno.Any(\n"
629 " com.sun.star.uno.Type.STRING, sPath.toString());\n\n";
631 o <<
" Object aArguments[] = new Object[1];\n"
632 " aArguments[0] = new com.sun.star.uno.Any("
633 " new com.sun.star.uno.Type(\n"
634 " com.sun.star.beans.PropertyValue.class), aArgument);\n\n";
636 o <<
" // create the default view using default UI locale\n"
637 " Object xIface = \n"
638 " xProvider.createInstanceWithArguments(sReadOnlyView, "
641 o <<
" m_xHAccess = (com.sun.star.container.XHierarchicalNameAccess)\n"
642 " UnoRuntime.queryInterface(\n"
643 " com.sun.star.container.XHierarchicalNameAccess.class, "
646 o <<
" // extends arguments to create a view for all locales to get "
647 "simple\n // access to the compatibilityname property\n"
648 " aArguments = new Object[2];\n"
649 " aArguments[0] = new com.sun.star.uno.Any( "
650 "new com.sun.star.uno.Type(\n"
651 " com.sun.star.beans.PropertyValue.class), aArgument);\n"
652 " aArgument.Name = \"locale\";\n"
653 " aArgument.Value = new com.sun.star.uno.Any(\n"
654 " com.sun.star.uno.Type.STRING, \"*\");\n"
655 " aArguments[1] = new com.sun.star.uno.Any( "
656 " new com.sun.star.uno.Type(\n"
657 " com.sun.star.beans.PropertyValue.class), aArgument);\n\n";
659 o <<
" // create view for all locales\n"
660 " xIface = xProvider.createInstanceWithArguments(sReadOnlyView, "
662 " m_xCompAccess = (com.sun.star.container.XHierarchicalNameAccess)\n"
663 " UnoRuntime.queryInterface(\n"
664 " com.sun.star.container.XHierarchicalNameAccess.class, "
666 " catch ( com.sun.star.uno.Exception e ) {\n }\n }\n\n";
669 o <<
" // addin configuration property helper function:\n"
670 " String getAddinProperty(String funcName, "
671 "String paramName, String propName)\n {\n"
672 " try {\n StringBuffer buf = "
673 "new StringBuffer(funcName);\n\n"
674 " if (paramName.length() > 0) {\n"
675 " buf.append(\"/Parameters/\");\n"
676 " buf.append(paramName);\n }\n\n";
678 o <<
" com.sun.star.beans.XPropertySet xPropSet =\n"
679 " (com.sun.star.beans.XPropertySet)UnoRuntime."
681 " com.sun.star.beans.XPropertySet.class,\n"
682 " m_xHAccess.getByHierarchicalName(buf.toString()));\n\n"
683 " return com.sun.star.uno.AnyConverter.toString(\n"
684 " xPropSet.getPropertyValue(propName));\n }\n"
685 " catch ( com.sun.star.uno.RuntimeException e ) {\n"
687 " catch ( com.sun.star.uno.Exception e ) {\n }\n"
688 " return \"\";\n }\n\n";
695 const OString & classname,
696 const std::set< OUString >& services,
697 const std::set< OUString >& interfaces,
700 const OUString& propertyhelper,
bool supportxcomponent)
702 o <<
"\n\npublic final class " << classname <<
" extends ";
704 if (!interfaces.empty()) {
705 if (propertyhelper ==
"_") {
706 o <<
"PropertySet\n";
708 if (supportxcomponent)
709 o <<
"ComponentBase\n";
714 std::set< OUString >::const_iterator iter = interfaces.begin();
715 while (iter != interfaces.end()) {
718 if (iter != interfaces.end())
724 o <<
" private final XComponentContext m_xContext;\n";
728 o <<
" private com.sun.star.frame.XFrame m_xFrame;\n";
732 if (propertyhelper.getLength() > 1)
733 o <<
" private final PropertySetMixin m_prophlp;\n";
735 o <<
" private static final String m_implementationName = "
736 << classname <<
".class.getName();\n";
738 if (!services.empty()) {
739 o <<
" private static final String[] m_serviceNames = {\n";
740 std::set< OUString >::const_iterator iter = services.begin();
741 while (iter != services.end()) {
742 o <<
" \"" << (*iter).replace(
'/',
'.') <<
"\"";
744 if (iter != services.end())
753 o <<
" // properties\n";
757 o <<
" m_" << rProp.name <<
";\n";
759 }
else if (!attributes.empty()) {
760 o <<
" // attributes\n";
761 for (
const auto& rAttr : attributes) {
764 o <<
" m_" << rAttr.name <<
" = ";
774 services, interfaces);
776 o <<
"\n public " << classname <<
"( XComponentContext context )\n"
777 " {\n m_xContext = context;\n";
778 if (propertyhelper ==
"_") {
781 if (propertyhelper.getLength() > 1) {
783 <<
" m_prophlp = new PropertySetMixin(m_xContext, this,\n"
784 " new Type(" << propertyhelper
785 <<
".class), null);\n";
792 if (!services.empty())
796 " ", propertyhelper.getLength() > 1);
804 std::vector< OString >
const & types)
806 std::set< OUString > interfaces;
807 std::set< OUString > services;
810 std::set< OUString > propinterfaces;
811 bool serviceobject =
false;
812 bool supportxcomponent =
false;
814 for (
const auto& rType : types) {
830 if (services.size() != 1) {
832 "for calc add-in components one and only one service type is "
833 "necessary! Please reference a valid type with the '-t' option.");
848 interfaces.insert(
"com.sun.star.lang.XLocalizable");
854 if (!services.empty())
855 serviceobject =
true;
858 options,
manager, services, interfaces, attributes, propinterfaces);
862 if (!propertyhelper.isEmpty())
863 std::cerr <<
"WARNING: interfaces specifying calc add-in functions "
864 "shouldn't support attributes!\n";
869 OString compFileName;
871 std::ostream* pofs =
nullptr;
873 &pofs, compFileName, tmpFileName);
876 if (!standardout && options.
license) {
883 serviceobject, supportxcomponent);
885 OString classname(options.
implname);
887 if ((
index = classname.lastIndexOf(
'.')) > 0)
888 classname = classname.copy(
index+1);
891 interfaces,
properties, attributes, propertyhelper,
894 if ( !standardout && pofs &&
static_cast<std::ofstream*
>(pofs)->is_open()) {
895 static_cast<std::ofstream*
>(pofs)->
close();
900 std::cerr <<
"ERROR: " << e.
getMessage() <<
"\n";
901 if ( !standardout ) {
902 if (pofs &&
static_cast<std::ofstream*
>(pofs)->is_open()) {
903 static_cast<std::ofstream*
>(pofs)->
close();
const OUString & getMessage() const
bool contains(OString const &type) 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)
static void generateXCompatibilityNamesBodies(std::ostream &o)
static void generateXServiceInfoBodies(std::ostream &o)
static void generateAddinConstructorAndHelper(std::ostream &o, ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, const OString &classname, const std::set< OUString > &services, const std::set< OUString > &interfaces)
static void generatePackage(std::ostream &o, std::string_view implname)
static void generateCompFunctions(std::ostream &o, const OString &classname)
static void generateXAddInBodies(std::ostream &o)
static void registerProperties(std::ostream &o, const AttributeInfo &properties, const OString &indentation)
static void generateXInitializationBodies(std::ostream &o)
void generateXFastPropertySetBodies(std::ostream &o)
static bool checkAttribute(OStringBuffer &attributeValue, unoidl::AccumulationBasedServiceEntity::Property::Attributes attribute)
static void generateMethodBodies(std::ostream &o, ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, const std::set< OUString > &interfaces, const OString &indentation, bool usepropertymixin)
static void generateXDispatchBodies(std::ostream &o, ProgramOptions const &options)
const char *const propcomment
void generateXPropertySetBodies(std::ostream &o)
static void generateClassDefinition(std::ostream &o, ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, const OString &classname, const std::set< OUString > &services, const std::set< OUString > &interfaces, const AttributeInfo &properties, const AttributeInfo &attributes, const OUString &propertyhelper, bool supportxcomponent)
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, bool referenceType, bool defaultvalue)
static void generateImports(std::ostream &o, ProgramOptions const &options, std::u16string_view propertyhelper, bool serviceobject, bool supportxcomponent)
void generateXPropertyAccessBodies(std::ostream &o)
static void generateXLocalizableBodies(std::ostream &o)
void printMethods(std::ostream &o, ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, OUString const &name, codemaker::GeneratedTypeSet &generated, OString const &delegate, OString const &indentation, bool defaultvalue, bool usepropertymixin)
static void generateXDispatchProviderBodies(std::ostream &o, ProgramOptions const &options)
void generateSkeleton(ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, std::vector< OString > const &types)
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)
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)
ProtocolCmdMap protocolCmdMap
OUString b2u(std::string_view s)
OString u2b(std::u16string_view s)