diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2006-08-01 15:24:24 +0000 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2006-08-01 15:24:24 +0000 |
commit | ef93b3b37d753ad9ff04394f3f211b8c88d1525e (patch) | |
tree | b35ebc49afc557c721c503bff1bb0409ae70bc4c /unodevtools/source | |
parent | fdf4805b18eae87ca5b2a602986621a626eece1d (diff) |
INTEGRATION: CWS jsc12 (1.7.4); FILE MERGED
2006/07/31 14:53:23 jsc 1.7.4.1: #i67879# simplify calc add-in skeleton
Diffstat (limited to 'unodevtools/source')
-rw-r--r-- | unodevtools/source/skeletonmaker/cppcompskeleton.cxx | 201 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/cpptypemaker.cxx | 31 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/javacompskeleton.cxx | 65 |
3 files changed, 169 insertions, 128 deletions
diff --git a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx index c4874245db60..e9b6df22333f 100644 --- a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx +++ b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx @@ -4,9 +4,9 @@ * * $RCSfile: cppcompskeleton.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: obo $ $Date: 2006-07-13 11:56:39 $ + * last change: $Author: ihi $ $Date: 2006-08-01 16:23:54 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -317,7 +317,7 @@ void generateXPropertyAccessBodies(std::ostream& o, << propertyhelper << " >::setPropertyValues(aProps);\n}\n\n"; } -void generateXAddInBodies(std::ostream& o, +void generateXLocalizable(std::ostream& o, const OString & classname) { o << "// ::com::sun::star::lang::XLocalizable:\n" @@ -326,7 +326,11 @@ void generateXAddInBodies(std::ostream& o, " m_locale = eLocale;\n}\n\n" "css::lang::Locale SAL_CALL " << classname << "getLocale() " "throw (css::uno::RuntimeException)\n{\n return m_locale;\n}\n\n"; +} +void generateXAddInBodies(std::ostream& o, + const OString & classname) +{ o << "// ::com::sun::star::sheet::XAddIn:\n"; o << "::rtl::OUString SAL_CALL " << classname << "getProgrammaticFuntionName(" @@ -428,71 +432,74 @@ void generateAddinConstructorAndHelper(std::ostream& o, { o << classname << "::" << classname << "(css::uno::Reference< css::uno::XComponentContext > const & context) :\n" - << " m_xContext(context)\n{\n"; - - o << " try {\n"; - - generateFunctionParameterMap(o, options, manager, interfaces); - - o << " css::uno::Reference< css::lang::XMultiServiceFactory > xProvider" - "(\n m_xContext->getServiceManager()->createInstanceWithContext" - "(\n ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(\n " - " \"com.sun.star.configuration.ConfigurationProvider\"))," - "\n m_xContext ), css::uno::UNO_QUERY );\n\n"; - - o << " ::rtl::OUString sReadOnlyView(\n" - " RTL_CONSTASCII_USTRINGPARAM(\n" - " \"com.sun.star.configuration.ConfigurationAccess\"));\n\n"; - - o << " ::rtl::OUStringBuffer sPath(::rtl::OUString::createFromAscii(\n" - " \"/org.openoffice.Office.CalcAddIns/AddInInfo/\"));\n" - " sPath.appendAscii(sADDIN_SERVICENAME);\n" - " sPath.appendAscii(\"/AddInFunctions\");\n\n" - " // create arguments: nodepath\n" - " css::beans::PropertyValue aArgument;\n" - " aArgument.Name = ::rtl::OUString::createFromAscii(\"nodepath\");\n" - " aArgument.Value <<= sPath.makeStringAndClear();\n\n" - " css::uno::Sequence< css::uno::Any > aArguments(1);\n" - " aArguments[0] <<= aArgument;\n\n"; - - o << " // create the default view using default UI locale\n" - " css::uno::Reference< css::uno::XInterface > xIface =\n" - " xProvider->createInstanceWithArguments(sReadOnlyView, " - "aArguments);\n\n" - " m_xHAccess = css::uno::Reference<\n " - "css::container::XHierarchicalNameAccess >(xIface, css::uno::UNO_QUERY);" - "\n\n"; - - o << " // extend arguments to create a view for all locales to get " - "simple\n // access to the compatibilityname property\n" - " aArgument.Name = ::rtl::OUString::createFromAscii(\"locale\");\n" - " aArgument.Value <<= ::rtl::OUString::createFromAscii(\"*\");\n" - " aArguments.realloc(2);\n" - " aArguments[1] <<= aArgument;\n\n" - " // create view for all locales\n" - " xIface = xProvider->createInstanceWithArguments(sReadOnlyView, " - "aArguments);\n\n" - " m_xCompAccess = css::uno::Reference<\n " - "css::container::XHierarchicalNameAccess >(xIface, css::uno::UNO_QUERY);\n"; - - o << " }\n catch ( css::uno::Exception & ) {\n }\n}\n\n"; - - o << "// addin configuration property helper function:\n::rtl::OUString " - "SAL_CALL " << classname << "::getAddinProperty(const ::rtl::OUString &" - " funcName, const ::rtl::OUString & paramName, const char * propName) " - "throw (css::uno::RuntimeException)\n{\n" - " ::rtl::OUString ret;\n try {\n " - "::rtl::OUStringBuffer buf(funcName);\n" - " if (paramName.getLength() > 0) {\n" - " buf.appendAscii(\"/Parameters/\");\n" - " buf.append(paramName);\n }\n\n" - " css::uno::Reference< css::beans::XPropertySet > xPropSet(\n" - " m_xHAccess->getByHierarchicalName(\n" - " buf.makeStringAndClear()), css::uno::UNO_QUERY);\n" - " xPropSet->getPropertyValue(\n " - "::rtl::OUString::createFromAscii(propName)) >>= ret;\n }\n" - " catch ( css::uno::RuntimeException & e ) {\n throw e;\n }\n" - " catch ( css::uno::Exception & ) {\n }\n return ret;\n}\n\n"; + << " m_xContext(context), m_locale()\n{\n"; + + if (options.backwardcompatible) { + o << " try {\n"; + + generateFunctionParameterMap(o, options, manager, interfaces); + + o << " css::uno::Reference< css::lang::XMultiServiceFactory > xProvider" + "(\n m_xContext->getServiceManager()->createInstanceWithContext" + "(\n ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(\n " + " \"com.sun.star.configuration.ConfigurationProvider\"))," + "\n m_xContext ), css::uno::UNO_QUERY );\n\n"; + + o << " ::rtl::OUString sReadOnlyView(\n" + " RTL_CONSTASCII_USTRINGPARAM(\n" + " \"com.sun.star.configuration.ConfigurationAccess\"));\n\n"; + + o << " ::rtl::OUStringBuffer sPath(::rtl::OUString::createFromAscii(\n" + " \"/org.openoffice.Office.CalcAddIns/AddInInfo/\"));\n" + " sPath.appendAscii(sADDIN_SERVICENAME);\n" + " sPath.appendAscii(\"/AddInFunctions\");\n\n" + " // create arguments: nodepath\n" + " css::beans::PropertyValue aArgument;\n" + " aArgument.Name = ::rtl::OUString::createFromAscii(\"nodepath\");\n" + " aArgument.Value <<= sPath.makeStringAndClear();\n\n" + " css::uno::Sequence< css::uno::Any > aArguments(1);\n" + " aArguments[0] <<= aArgument;\n\n"; + + o << " // create the default view using default UI locale\n" + " css::uno::Reference< css::uno::XInterface > xIface =\n" + " xProvider->createInstanceWithArguments(sReadOnlyView, " + "aArguments);\n\n" + " m_xHAccess = css::uno::Reference<\n " + "css::container::XHierarchicalNameAccess >(xIface, css::uno::UNO_QUERY);" + "\n\n"; + + o << " // extend arguments to create a view for all locales to get " + "simple\n // access to the compatibilityname property\n" + " aArgument.Name = ::rtl::OUString::createFromAscii(\"locale\");\n" + " aArgument.Value <<= ::rtl::OUString::createFromAscii(\"*\");\n" + " aArguments.realloc(2);\n" + " aArguments[1] <<= aArgument;\n\n" + " // create view for all locales\n" + " xIface = xProvider->createInstanceWithArguments(sReadOnlyView, " + "aArguments);\n\n" + " m_xCompAccess = css::uno::Reference<\n " + "css::container::XHierarchicalNameAccess >(xIface, css::uno::UNO_QUERY);\n"; + + o << " }\n catch ( css::uno::Exception & ) {\n }\n}\n\n"; + + o << "// addin configuration property helper function:\n::rtl::OUString " + "SAL_CALL " << classname << "::getAddinProperty(const ::rtl::OUString &" + " funcName, const ::rtl::OUString & paramName, const char * propName) " + "throw (css::uno::RuntimeException)\n{\n" + " ::rtl::OUString ret;\n try {\n " + "::rtl::OUStringBuffer buf(funcName);\n" + " if (paramName.getLength() > 0) {\n" + " buf.appendAscii(\"/Parameters/\");\n" + " buf.append(paramName);\n }\n\n" + " css::uno::Reference< css::beans::XPropertySet > xPropSet(\n" + " m_xHAccess->getByHierarchicalName(\n" + " buf.makeStringAndClear()), css::uno::UNO_QUERY);\n" + " xPropSet->getPropertyValue(\n " + "::rtl::OUString::createFromAscii(propName)) >>= ret;\n }\n" + " catch ( css::uno::RuntimeException & e ) {\n throw e;\n }\n" + " catch ( css::uno::Exception & ) {\n }\n return ret;\n"; + } + o <<"}\n\n"; } void generateMemberInitialization(std::ostream& o, @@ -663,12 +670,14 @@ OString generateClassDefinition(std::ostream& o, o << " mutable ::osl::Mutex m_aMutex;\n"; if (options.componenttype == 2) { - o <<" css::uno::Reference< css::container::XHierarchicalNameAccess > " - "m_xHAccess;\n" - " css::uno::Reference< css::container::XHierarchicalNameAccess > " - "m_xCompAccess;\n" - " FunctionMap m_functionMap;\n" - " css::lang::Locale m_locale;\n"; + if (options.backwardcompatible) { + o <<" css::uno::Reference< css::container::XHierarchicalNameAccess > " + "m_xHAccess;\n" + " css::uno::Reference< css::container::XHierarchicalNameAccess > " + "m_xCompAccess;\n" + " FunctionMap m_functionMap;\n"; + } + o << " css::lang::Locale m_locale;\n"; } generateMemberDeclaration(o, options, manager, properties); @@ -1025,18 +1034,22 @@ void generateCalcAddin(ProgramOptions const & options, sAddinService = (*(++iter2)).replace('/', '.'); } - // add AddIn in suported service list, this service is currently necessary - // to identify all calc add-ins and to support the necessary add-in helper - // interfaces. - // This becomes obsolete in the future when this information is collected - // from the configuration - checkType(manager, "com.sun.star.sheet.AddIn", - interfaces, services, properties); - // special case for XLocalization, it is exlicitly handled and will be - // necessary in the future as well -// if (interfaces.find("com.sun.star.lang.XLocalizable") == -// interfaces.end()) -// interfaces.insert("com.sun.star.lang.XLocalizable"); + // if backwardcompatible==true the AddIn service needs to be added to the + // suported service list, the necessary intefaces are mapped to the add-in + // configuration. Since OO.org 2.0.4 this is obsolete and the add-in is + // take form the configuration from Calc directly, this simplifies the + // add-in code + if (options.backwardcompatible) { + checkType(manager, "com.sun.star.sheet.AddIn", + interfaces, services, properties); + } else { + // special case for the optional XLocalization interface. It should be + // implemented always. But it is parent of the XAddIn and we need it only + // if backwardcompatible is false. + if (interfaces.find("com.sun.star.lang.XLocalizable") == interfaces.end()) { + interfaces.insert("com.sun.star.lang.XLocalizable"); + } + } OString propertyhelper = checkPropertyHelper( options, manager, services, interfaces, attributes, propinterfaces); @@ -1098,13 +1111,15 @@ void generateCalcAddin(ProgramOptions const & options, classname = classname.copy(index+1); } - *pofs << "static const char * sADDIN_SERVICENAME = \"" - << sAddinService << "\";\n\n"; - *pofs << "static const char * sDISPLAYNAME = \"DisplayName\";\n" - "static const char * sDESCRIPTION = \"Description\";\n" - "static const char * sCATEGORY = \"Category\";\n" - "static const char * sCATEGORYDISPLAYNAME = \"CategoryDisplayName\";" - "\n\n"; + if (options.backwardcompatible) { + *pofs << "static const char * sADDIN_SERVICENAME = \"" + << sAddinService << "\";\n\n"; + *pofs << "static const char * sDISPLAYNAME = \"DisplayName\";\n" + "static const char * sDESCRIPTION = \"Description\";\n" + "static const char * sCATEGORY = \"Category\";\n" + "static const char * sCATEGORYDISPLAYNAME = \"CategoryDisplayName\";" + "\n\n"; + } OString parentname( generateClassDefinition(*pofs, diff --git a/unodevtools/source/skeletonmaker/cpptypemaker.cxx b/unodevtools/source/skeletonmaker/cpptypemaker.cxx index f23870055d13..7650949cfeec 100644 --- a/unodevtools/source/skeletonmaker/cpptypemaker.cxx +++ b/unodevtools/source/skeletonmaker/cpptypemaker.cxx @@ -4,9 +4,9 @@ * * $RCSfile: cpptypemaker.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: obo $ $Date: 2006-07-13 11:56:52 $ + * last change: $Author: ihi $ $Date: 2006-08-01 16:24:09 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -368,6 +368,9 @@ void generateXPropertyAccessBodies(std::ostream& o, void generateXAddInBodies(std::ostream& o, const OString & classname); +void generateXLocalizable(std::ostream& o, + const OString & classname); + void generateXCompatibilityNamesBodies(std::ostream& o, const OString & classname); @@ -424,26 +427,22 @@ void printMethods(std::ostream & o, } else if (type.equals("com/sun/star/sheet/XAddIn")) { generateXAddInBodies(o, classname); generated.add(type); + + // special handling of XLocalizable -> parent of XAddIn + if (!generated.contains("com/sun/star/lang/XLocalizable")) { + generateXLocalizable(o, classname); + generated.add("com/sun/star/lang/XLocalizable"); + } + return; + } else if (type.equals("com/sun/star/lang/XLocalizable")) { + generateXLocalizable(o, classname); + generated.add(type); return; } else if (type.equals("com/sun/star/sheet/XCompatibilityNames")) { generateXCompatibilityNamesBodies(o, classname); generated.add(type); return; } - - // As long as XAddIn is necessary, XLocalizable is handled by XAddIn -// } -// else if (type.equals("com/sun/star/lang/XLocalizable")) -// { -// o << "// ::com::sun::star::lang::XLocalizable:\n" -// "void SAL_CALL " << classname << "setLocale(const css::lang::" -// "Locale & eLocale) throw (css::uno::RuntimeException)\n{\n" -// " m_locale = eLocale;\n}\n\n" -// "css::lang::Locale SAL_CALL " << classname << "getLocale() " -// "throw (css::uno::RuntimeException)\n{\n return m_locale;\n}\n"; -// generated.add(type); -// return; -// } } generated.add(type); diff --git a/unodevtools/source/skeletonmaker/javacompskeleton.cxx b/unodevtools/source/skeletonmaker/javacompskeleton.cxx index 23f6fb2be7d8..2536a609c539 100644 --- a/unodevtools/source/skeletonmaker/javacompskeleton.cxx +++ b/unodevtools/source/skeletonmaker/javacompskeleton.cxx @@ -4,9 +4,9 @@ * * $RCSfile: javacompskeleton.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: obo $ $Date: 2006-07-13 11:57:06 $ + * last change: $Author: ihi $ $Date: 2006-08-01 16:24:24 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -297,8 +297,7 @@ void registerProperties(std::ostream& o, } } -void generateXAddInBodies(std::ostream& o, ProgramOptions const & options) -{ +void generateXLocalizableBodies(std::ostream& o) { // com.sun.star.lang.XLocalizable: // setLocale o << " // com.sun.star.lang.XLocalizable:\n" @@ -308,7 +307,10 @@ void generateXAddInBodies(std::ostream& o, ProgramOptions const & options) // getLocale o << " public com.sun.star.lang.Locale getLocale()\n {\n" " return m_locale;\n }\n\n"; +} +void generateXAddInBodies(std::ostream& o, ProgramOptions const & options) +{ // com.sun.star.sheet.XAddIn: // getProgrammaticFuntionName o << " // com.sun.star.sheet.XAddIn:\n" @@ -453,6 +455,7 @@ void generateMethodBodies(std::ostream& o, iter++; if (type.equals("com.sun.star.lang.XServiceInfo")) { generateXServiceInfoBodies(o); + generated.add(type); } else { if (options.componenttype == 2) { if (type.equals("com.sun.star.lang.XServiceName")) { @@ -464,6 +467,16 @@ void generateMethodBodies(std::ostream& o, } else if (type.equals("com.sun.star.sheet.XAddIn")) { generateXAddInBodies(o, options); generated.add(type); + + // special handling of XLocalizable -> parent of XAddIn + if (!generated.contains("com.sun.star.lang.XLocalizable")) { + generateXLocalizableBodies(o); + generated.add("com.sun.star.lang.XLocalizable"); + } + continue; + } else if (type.equals("com.sun.star.lang.XLocalizable")) { + generateXLocalizableBodies(o); + generated.add(type); continue; } else if (type.equals("com.sun.star.sheet.XCompatibilityNames")) { generateXCompatibilityNamesBodies(o); @@ -492,6 +505,17 @@ void generateAddinConstructorAndHelper(std::ostream& o, const std::hash_set< OString, OStringHash >& services, const std::hash_set< OString, OStringHash >& interfaces) { + o << " private com.sun.star.lang.Locale m_locale = " + "new com.sun.star.lang.Locale();\n"; + + if (!options.backwardcompatible) { + // Constructor + o << "\n public " << classname << "( XComponentContext context )\n" + " {\n m_xContext = context;\n }\n\n"; + return; + } + + // get the one and only add-in service for later use std::hash_set< OString, OStringHash >::const_iterator iter = services.begin(); OString sAddinService = (*iter).replace('/', '.'); @@ -499,6 +523,7 @@ void generateAddinConstructorAndHelper(std::ostream& o, sAddinService = (*(++iter)).replace('/', '.'); } + // add-in specific fields o << "\n private static final String sADDIN_SERVICENAME = \"" << sAddinService << "\";\n\n"; @@ -510,9 +535,7 @@ void generateAddinConstructorAndHelper(std::ostream& o, " private static final String sCATEGORYDISPLAYNAME = " "\"CategoryDisplayName\";\n\n"; - o << " private com.sun.star.lang.Locale m_locale = " - "new com.sun.star.lang.Locale();\n" - " private com.sun.star.container.XHierarchicalNameAccess " + o << " private com.sun.star.container.XHierarchicalNameAccess " "m_xHAccess = null;\n" " private com.sun.star.container.XHierarchicalNameAccess " "m_xCompAccess = null;\n"; @@ -763,18 +786,22 @@ void generateSkeleton(ProgramOptions const & options, "necessary! Please reference a valid type with the '-t' option."); } - // add AddIn in suported service list, this service is currently necessary - // to identify all calc add-ins and to support the necessary add-in helper - // interfaces. - // This becomes obsolete in the future when this information is collected - // from the configuration - checkType(manager, "com.sun.star.sheet.AddIn", - interfaces, services, properties); - // special case for XLocalization, it is exlicitly handled and will be - // necessary in the future as well -// if (interfaces.find("com.sun.star.lang.XLocalizable") == -// interfaces.end()) -// interfaces.insert("com.sun.star.lang.XLocalizable"); + // if backwardcompatible==true the AddIn service needs to be added to the + // suported service list, the necessary intefaces are mapped to the add-in + // configuration. Since OO.org 2.0.4 this is obsolete and the add-in is + // take form the configuration from Calc directly, this simplifies the + // add-in code + if (options.backwardcompatible) { + checkType(manager, "com.sun.star.sheet.AddIn", + interfaces, services, properties); + } else { + // special case for the optional XLocalization interface. It should be + // implemented always. But it is parent of the XAddIn and we need it only + // if backwardcompatible is false. + if (interfaces.find("com.sun.star.lang.XLocalizable") == interfaces.end()) { + interfaces.insert("com.sun.star.lang.XLocalizable"); + } + } } |