summaryrefslogtreecommitdiff
path: root/unodevtools/source/skeletonmaker
diff options
context:
space:
mode:
authorJuergen Schmidt <jsc@openoffice.org>2005-08-25 14:30:34 +0000
committerJuergen Schmidt <jsc@openoffice.org>2005-08-25 14:30:34 +0000
commit58236a94eddfe310e8cc4bd60e33198926ab8a0c (patch)
treee32b9a737b00e5712fa9312afe94c50b7b9d3282 /unodevtools/source/skeletonmaker
parentc0c96af9e5006fd78dabd3292a02c1e554662d49 (diff)
#i52208# updated
Diffstat (limited to 'unodevtools/source/skeletonmaker')
-rw-r--r--unodevtools/source/skeletonmaker/javacompskeleton.cxx115
-rw-r--r--unodevtools/source/skeletonmaker/javatypemaker.cxx116
-rw-r--r--unodevtools/source/skeletonmaker/skeletoncommon.cxx17
-rw-r--r--unodevtools/source/skeletonmaker/skeletonjava.hxx8
4 files changed, 219 insertions, 37 deletions
diff --git a/unodevtools/source/skeletonmaker/javacompskeleton.cxx b/unodevtools/source/skeletonmaker/javacompskeleton.cxx
index dcd449454326..d22893c110e4 100644
--- a/unodevtools/source/skeletonmaker/javacompskeleton.cxx
+++ b/unodevtools/source/skeletonmaker/javacompskeleton.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: javacompskeleton.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jsc $ $Date: 2005-08-23 11:23:43 $
+ * last change: $Author: jsc $ $Date: 2005-08-25 15:30:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -144,6 +144,81 @@ void generateXServiceInfoBodies(std::ostream& o)
<< " return m_serviceNames;\n }\n\n";
}
+void generateXPropertySetBodies(std::ostream& o)
+{
+ o << " /* com.sun.star.lang.XPropertySet */\n";
+ o << " public com.sun.star.beans.XPropertySetInfo getPropertySetInfo()\n"
+ " {\n return m_prophlp.getPropertySetInfo();\n }\n\n";
+
+ o << " public void setPropertyValue(java.lang.String aPropertyName, "
+ "java.lang.Object aValue) throws com.sun.star.beans.UnknownPropertyException, "
+ "com.sun.star.beans.PropertyVetoException, "
+ "com.sun.star.lang.IllegalArgumentException,"
+ "com.sun.star.lang.WrappedTargetException\n {\n "
+ "m_prophlp.setPropertyValue(aPropertyName, aValue);\n }\n\n";
+
+ o << " public java.lang.Object getPropertyValue(java.lang.String aPropertyName) "
+ "throws com.sun.star.beans.UnknownPropertyException, "
+ "com.sun.star.lang.WrappedTargetException\n {\n return "
+ "m_prophlp.getPropertyValue(aPropertyName);\n }\n\n";
+
+ o << " public void addPropertyChangeListener(java.lang.String aPropertyName, "
+ "com.sun.star.beans.XPropertyChangeListener xListener) throws "
+ "com.sun.star.beans.UnknownPropertyException, "
+ "com.sun.star.lang.WrappedTargetException\n {\n "
+ "m_prophlp.addPropertyChangeListener(aPropertyName, xListener);\n }\n\n";
+
+ o << " public void removePropertyChangeListener(java.lang.String aPropertyName, "
+ "com.sun.star.beans.XPropertyChangeListener xListener) throws "
+ "com.sun.star.beans.UnknownPropertyException, "
+ "com.sun.star.lang.WrappedTargetException\n {\n "
+ "m_prophlp.removePropertyChangeListener(aPropertyName, xListener);\n }\n\n";
+
+ o << " public void addVetoableChangeListener(java.lang.String aPropertyName, "
+ "com.sun.star.beans.XVetoableChangeListener xListener) throws "
+ "com.sun.star.beans.UnknownPropertyException, "
+ "com.sun.star.lang.WrappedTargetException\n {\n "
+ "m_prophlp.addVetoableChangeListener(aPropertyName, xListener);\n }\n\n";
+
+ o << " public void removeVetoableChangeListener(java.lang.String aPropertyName, "
+ "com.sun.star.beans.XVetoableChangeListener xListener) throws "
+ "com.sun.star.beans.UnknownPropertyException, "
+ "com.sun.star.lang.WrappedTargetException\n {\n "
+ "m_prophlp.removeVetoableChangeListener(aPropertyName, xListener);\n }\n\n";
+}
+
+void generateXFastPropertySetBodies(std::ostream& o)
+{
+ o << " /* com.sun.star.lang.XFastPropertySet */\n";
+
+ o << " public void setFastPropertyValue(int nHandle, java.lang.Object aValue) "
+ "throws com.sun.star.beans.UnknownPropertyException, "
+ "com.sun.star.beans.PropertyVetoException, "
+ "com.sun.star.lang.IllegalArgumentException, "
+ "com.sun.star.lang.WrappedTargetException\n {\n "
+ "m_prophlp.setFastPropertyValue(nHandle, aValue);\n }\n\n";
+
+ o << " public java.lang.Object getFastPropertyValue(int nHandle) throws "
+ "com.sun.star.beans.UnknownPropertyException, "
+ "com.sun.star.lang.WrappedTargetException\n {\n return "
+ "m_prophlp.getFastPropertyValue(nHandle);\n }\n\n";
+}
+
+void generateXPropertyAccessBodies(std::ostream& o)
+{
+ o << " /* com.sun.star.lang.XPropertyAccess */\n";
+
+ o << " public com.sun.star.beans.PropertyValue[] getPropertyValues()\n {\n"
+ << " return m_prophlp.getPropertyValues();\n }\n\n";
+
+ o << " public void setPropertyValues(com.sun.star.beans.PropertyValue[] aProps) "
+ "throws com.sun.star.beans.UnknownPropertyException, "
+ "com.sun.star.beans.PropertyVetoException, "
+ "com.sun.star.lang.IllegalArgumentException, "
+ "com.sun.star.lang.WrappedTargetException\n {\n "
+ "m_prophlp.setPropertyValues(aProps);\n }\n\n";
+}
+
bool checkAttribute(rtl::OStringBuffer& attributeValue, sal_uInt16 attribute) {
bool cast = false;
@@ -236,8 +311,9 @@ void registerProperties(std::ostream& o,
void generateMethodBodies(std::ostream& o,
ProgramOptions const & options,
TypeManager const & manager,
+ StringPairHashMap& attributes,
const std::hash_set< rtl::OString, rtl::OStringHash >& interfaces,
- const rtl::OString& indentation)
+ const rtl::OString& indentation, bool usepropertymixin)
{
std::hash_set< rtl::OString, rtl::OStringHash >::const_iterator iter =
interfaces.begin();
@@ -247,13 +323,18 @@ void generateMethodBodies(std::ostream& o,
generateXServiceInfoBodies(o);
} else {
typereg::Reader reader(manager.getTypeReader((*iter).replace('.','/')));
- printMethods(o, options, manager, reader, generated, "_",
- indentation, true);
+ printMethods(o, options, manager, reader, attributes, generated, "_",
+ indentation, true, usepropertymixin);
}
iter++;
}
}
+static const char* propcomment=
+" // use the last parameter of the PropertySetMixin constructor\n"
+" // for your optional attributes if necessary. See the documentation\n"
+" // of the PropertySetMixin helper for further information\n";
+
void generateClassDefinition(std::ostream& o,
ProgramOptions const & options,
TypeManager const & manager,
@@ -315,9 +396,9 @@ void generateClassDefinition(std::ostream& o,
registerProperties(o, manager, properties, " ");
} else {
if (propertyhelper.getLength() > 1) {
- o << " m_prophlp = new PropertySetMixin(\n"
- << " m_context, this, new Type(" << propertyhelper
- << ".class));\n";
+ o << propcomment
+ << " m_prophlp = new PropertySetMixin(m_context, this,\n"
+ << " new Type(" << propertyhelper << ".class), null);\n";
}
}
o << " };\n\n";
@@ -325,11 +406,15 @@ void generateClassDefinition(std::ostream& o,
if (!services.empty())
generateCompFunctions(o, classname);
- generateMethodBodies(o, options, manager, interfaces, " ");
+ StringPairHashMap attributes;
+ generateMethodBodies(o, options, manager, attributes, interfaces,
+ " ", propertyhelper.getLength() > 1);
+
if (!properties.empty()) {
StringPairHashMap::const_iterator iter =
properties.begin();
+ o << " // properties\n";
while (iter != properties.end()) {
o << " protected ";
printType(o, options, manager, iter->second.first.replace('.','/'),
@@ -337,8 +422,20 @@ void generateClassDefinition(std::ostream& o,
o << " m_" << iter->first << ";\n";
iter++;
}
+ } else if (!attributes.empty()) {
+ StringPairHashMap::const_iterator iter =
+ attributes.begin();
+ o << " // attributes\n";
+ while (iter != attributes.end()) {
+ o << " protected ";
+ printType(o, options, manager, iter->second.first.replace('.','/'),
+ false, false);
+ o << " m_" << iter->first << ";\n";
+ iter++;
+ }
}
+
// end of class definition
o << "}\n";
}
diff --git a/unodevtools/source/skeletonmaker/javatypemaker.cxx b/unodevtools/source/skeletonmaker/javatypemaker.cxx
index 5b8ed625741d..ac8073b61e41 100644
--- a/unodevtools/source/skeletonmaker/javatypemaker.cxx
+++ b/unodevtools/source/skeletonmaker/javatypemaker.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: javatypemaker.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jsc $ $Date: 2005-08-23 08:30:21 $
+ * last change: $Author: jsc $ $Date: 2005-08-25 15:30:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -259,11 +259,61 @@ void printExceptionSpecification(std::ostream & o,
}
}
+
+void generateXPropertySetBodies(std::ostream& o);
+void generateXFastPropertySetBodies(std::ostream& o);
+void generateXPropertyAccessBodies(std::ostream& o);
+
+void printSetPropertyMixinBody(std::ostream & o,
+ typereg::Reader const & reader,
+ sal_uInt16 fieldno,
+ rtl::OString const & indentation)
+{
+ RTFieldAccess fieldAccess = reader.getFieldFlags(fieldno);
+ rtl::OString fieldname = codemaker::convertString(reader.getFieldName(fieldno));
+ bool bound = (fieldAccess & RT_ACCESS_BOUND ? true : false);
+
+ o << "\n" << indentation << "{\n";
+
+ if (bound) {
+ o << indentation << " PropertySetMixin.BoundListeners l = "
+ "new PropertySetMixin.BoundListeners();\n\n";
+ }
+
+ if (fieldAccess & RT_ACCESS_CONSTRAINED ||
+ fieldAccess & RT_ACCESS_MAYBEDEFAULT ||
+ fieldAccess & RT_ACCESS_MAYBEAMBIGUOUS ||
+ fieldAccess & RT_ACCESS_MAYBEVOID ) {
+
+ // TODO
+
+ } else {
+ o << indentation << " m_prophlp.prepareSet(\""
+ << fieldname << "\", ";
+ if (bound)
+ o << "l";
+ else
+ o << "null";
+ o << ");\n";
+ }
+
+ o << indentation << " synchronized (this) {\n"
+ << indentation << " m_" << fieldname
+ << " = the_value;\n" << indentation << " }\n";
+
+ if (bound) {
+ o << indentation << " l.notifyListeners();\n";
+ }
+ o << indentation << "}\n\n";
+}
+
void printMethods(std::ostream & o,
ProgramOptions const & options, TypeManager const & manager,
- typereg::Reader const & reader, codemaker::GeneratedTypeSet & generated,
+ typereg::Reader const & reader,
+ StringPairHashMap& attributes,
+ codemaker::GeneratedTypeSet & generated,
rtl::OString const & delegate, rtl::OString const & indentation,
- bool defaultvalue)
+ bool defaultvalue, bool usepropertymixin)
{
rtl::OString type(codemaker::convertString(reader.getTypeName()));
if (generated.contains(type) || type == "com/sun/star/uno/XInterface" ||
@@ -274,6 +324,22 @@ void printMethods(std::ostream & o,
return;
}
+ if (usepropertymixin) {
+ if ( type.equals("com/sun/star/beans/XPropertySet")) {
+ generated.add(type);
+ generateXPropertySetBodies(o);
+ return;
+ } else if ( type.equals("com/sun/star/beans/XFastPropertySet")) {
+ generated.add(type);
+ generateXFastPropertySetBodies(o);
+ return;
+ } else if ( type.equals("com/sun/star/beans/XPropertyAccess")) {
+ generated.add(type);
+ generateXPropertyAccessBodies(o);
+ return;
+ }
+ }
+
static rtl::OString sd(RTL_CONSTASCII_STRINGPARAM("_"));
bool body = ((delegate.getLength() > 0) ? true : false);
bool defaultbody = ((delegate.equals(sd)) ? true : false);
@@ -291,8 +357,8 @@ void printMethods(std::ostream & o,
+ codemaker::convertString(
reader.getSuperTypeName(i)));
}
- printMethods(o, options, manager, super, generated, delegate,
- indentation, defaultvalue);
+ printMethods(o, options, manager, super, attributes, generated, delegate,
+ indentation, defaultvalue, usepropertymixin);
}
if (reader.getFieldCount() > 0 || reader.getMethodCount() > 0) {
o << indentation << "/* ";
@@ -302,6 +368,17 @@ void printMethods(std::ostream & o,
}
sal_uInt16 method = 0;
for (sal_uInt16 i = 0; i < reader.getFieldCount(); ++i) {
+ rtl::OString fieldName(
+ codemaker::convertString(reader.getFieldName(i)).
+ replace('/', '.'));
+ rtl::OString fieldType(
+ codemaker::convertString(reader.getFieldTypeName(i)).
+ replace('/', '.'));
+ attributes.insert(StringPairHashMap::value_type(fieldName,
+ std::pair<rtl::OString, sal_Int16>(
+ fieldType, reader.getFieldFlags(i))));
+
+
o << indentation << "public ";
printType(o,
options, manager,
@@ -317,12 +394,18 @@ void printMethods(std::ostream & o,
}
if (body) {
if (defaultbody) {
- o << "\n" << indentation << "{\n" << indentation << " return ";
- printType(o,
- options, manager,
- codemaker::convertString(reader.getFieldTypeName(i)),
- false, defaultvalue);
- o << ";\n" << indentation << "}\n\n";
+ if (usepropertymixin) {
+ o << "\n" << indentation << "{\n" << indentation << " return m_"
+ << codemaker::convertString(reader.getFieldName(i)).getStr()
+ << ";\n" << indentation << "}\n\n";
+ } else {
+ o << "\n" << indentation << "{\n" << indentation << " return ";
+ printType(o,
+ options, manager,
+ codemaker::convertString(reader.getFieldTypeName(i)),
+ false, defaultvalue);
+ o << ";\n" << indentation << "}\n\n";
+ }
} else {
o << "\n" << indentation << " { return "
<< delegate.getStr() << "get"
@@ -353,7 +436,11 @@ void printMethods(std::ostream & o,
}
if (body) {
if (defaultbody) {
- o << "\n" << indentation << "{\n\n" << indentation << "}\n\n";
+ if (usepropertymixin) {
+ printSetPropertyMixinBody(o, reader, i, indentation);
+ } else {
+ o << "\n" << indentation << "{\n\n" << indentation << "}\n\n";
+ }
} else {
o << "\n" << indentation << " { "
<< delegate.getStr() << "set"
@@ -610,7 +697,8 @@ void generateDocumentation(std::ostream & o,
<< "; " << (options.all ? "all" : "direct")
<< " methods:\n";
codemaker::GeneratedTypeSet generated;
- printMethods(o, options, manager, reader, generated,
+ StringPairHashMap attributes;
+ printMethods(o, options, manager, reader, attributes, generated,
"", "", false);
}
break;
diff --git a/unodevtools/source/skeletonmaker/skeletoncommon.cxx b/unodevtools/source/skeletonmaker/skeletoncommon.cxx
index 526d0dba0a63..e7260f6de19a 100644
--- a/unodevtools/source/skeletonmaker/skeletoncommon.cxx
+++ b/unodevtools/source/skeletonmaker/skeletoncommon.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: skeletoncommon.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jsc $ $Date: 2005-08-23 08:30:44 $
+ * last change: $Author: jsc $ $Date: 2005-08-25 15:30:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -106,7 +106,7 @@ void checkType(TypeManager const & manager,
switch (reader.getTypeClass()) {
case RT_TYPE_INTERFACE:
{
- // com/sun/star/lang/XComponent should also not in the list
+ // com/sun/star/lang/XComponent should be also not in the list
// but it will be used for checking the impl helper and will be
// removed later if necessary.
if ( binType.equals("com/sun/star/lang/XTypeProvider") ||
@@ -151,11 +151,6 @@ void checkType(TypeManager const & manager,
codemaker::convertString(reader.getFieldTypeName(i)).
replace('/', '.'));
-// std::pair<rtl::OString, sal_Int16> prop(
-// fieldType, reader.getFieldFlags(i));
-
-// properties[fieldName] = std::pair<rtl::OString, sal_Int16>(
-// fieldType, reader.getFieldFlags(i));
properties.insert(StringPairHashMap::value_type(fieldName,
std::pair<rtl::OString, sal_Int16>(
fieldType, reader.getFieldFlags(i))));
@@ -182,13 +177,13 @@ void checkDefaultInterfaces(
interfaces.insert("com.sun.star.lang.XServiceInfo");
}
- if (propertyhelper.getLength() > 0) {
+ if (propertyhelper.equals("_")) {
if (interfaces.find("com.sun.star.beans.XPropertySet") != interfaces.end())
interfaces.erase("com.sun.star.beans.XPropertySet");
if (interfaces.find("com.sun.star.beans.XFastPropertySet") != interfaces.end())
interfaces.erase("com.sun.star.beans.XFastPropertySet");
- if (interfaces.find("com.sun.star.beans.XMultiPropertySet") != interfaces.end())
- interfaces.erase("com.sun.star.beans.XMultiPropertySet");
+ if (interfaces.find("com.sun.star.beans.XPropertyAccess") != interfaces.end())
+ interfaces.erase("com.sun.star.beans.XPropertyAccess");
}
}
diff --git a/unodevtools/source/skeletonmaker/skeletonjava.hxx b/unodevtools/source/skeletonmaker/skeletonjava.hxx
index 84001d021618..1e2f7b2fa232 100644
--- a/unodevtools/source/skeletonmaker/skeletonjava.hxx
+++ b/unodevtools/source/skeletonmaker/skeletonjava.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: skeletonjava.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jsc $ $Date: 2005-08-23 08:31:23 $
+ * last change: $Author: jsc $ $Date: 2005-08-25 15:30:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -106,10 +106,12 @@ void printExceptionSpecification(std::ostream & o,
void printMethods(std::ostream & o,
ProgramOptions const & options, TypeManager const & manager,
typereg::Reader const & reader,
+ StringPairHashMap& attributes,
codemaker::GeneratedTypeSet & generated,
rtl::OString const & delegate,
rtl::OString const & indentation=rtl::OString(),
- bool defaultvalue=false);
+ bool defaultvalue=false,
+ bool usepropertymixin=false);
void printConstructionMethods(std::ostream & o,
ProgramOptions const & options,