1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * The Contents of this file are made available subject to the terms of 4*cdf0e10cSrcweir * the BSD license. 5*cdf0e10cSrcweir * 6*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 7*cdf0e10cSrcweir * All rights reserved. 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * Redistribution and use in source and binary forms, with or without 10*cdf0e10cSrcweir * modification, are permitted provided that the following conditions 11*cdf0e10cSrcweir * are met: 12*cdf0e10cSrcweir * 1. Redistributions of source code must retain the above copyright 13*cdf0e10cSrcweir * notice, this list of conditions and the following disclaimer. 14*cdf0e10cSrcweir * 2. Redistributions in binary form must reproduce the above copyright 15*cdf0e10cSrcweir * notice, this list of conditions and the following disclaimer in the 16*cdf0e10cSrcweir * documentation and/or other materials provided with the distribution. 17*cdf0e10cSrcweir * 3. Neither the name of Sun Microsystems, Inc. nor the names of its 18*cdf0e10cSrcweir * contributors may be used to endorse or promote products derived 19*cdf0e10cSrcweir * from this software without specific prior written permission. 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22*cdf0e10cSrcweir * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23*cdf0e10cSrcweir * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24*cdf0e10cSrcweir * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25*cdf0e10cSrcweir * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26*cdf0e10cSrcweir * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27*cdf0e10cSrcweir * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28*cdf0e10cSrcweir * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29*cdf0e10cSrcweir * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 30*cdf0e10cSrcweir * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 31*cdf0e10cSrcweir * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32*cdf0e10cSrcweir * 33*cdf0e10cSrcweir *************************************************************************/ 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir import com.sun.star.beans.UnknownPropertyException; 36*cdf0e10cSrcweir import com.sun.star.beans.XPropertySet; 37*cdf0e10cSrcweir import com.sun.star.container.XNameAccess; 38*cdf0e10cSrcweir import com.sun.star.lang.Locale; 39*cdf0e10cSrcweir import com.sun.star.lang.WrappedTargetException; 40*cdf0e10cSrcweir import com.sun.star.lang.XServiceInfo; 41*cdf0e10cSrcweir import com.sun.star.reflection.ParamInfo; 42*cdf0e10cSrcweir import com.sun.star.reflection.XIdlClass; 43*cdf0e10cSrcweir import com.sun.star.reflection.XIdlMethod; 44*cdf0e10cSrcweir import com.sun.star.reflection.XTypeDescription; 45*cdf0e10cSrcweir import com.sun.star.text.XTextTablesSupplier; 46*cdf0e10cSrcweir import com.sun.star.uno.Any; 47*cdf0e10cSrcweir import com.sun.star.uno.AnyConverter; 48*cdf0e10cSrcweir import com.sun.star.uno.Type; 49*cdf0e10cSrcweir import com.sun.star.uno.TypeClass; 50*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 51*cdf0e10cSrcweir import java.util.Enumeration; 52*cdf0e10cSrcweir import java.util.Hashtable; 53*cdf0e10cSrcweir import java.util.Vector; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir public class SourceCodeGenerator { 58*cdf0e10cSrcweir private Vector sExceptions = new Vector(); 59*cdf0e10cSrcweir Vector sHeaderStatements = new HeaderStatements(); 60*cdf0e10cSrcweir private XLanguageSourceCodeGenerator m_xLanguageSourceCodeGenerator; 61*cdf0e10cSrcweir private String sHeaderCode = ""; 62*cdf0e10cSrcweir private String sStatementCode = ""; 63*cdf0e10cSrcweir private String sMainMethodSignature = ""; 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir private Hashtable aVariables = new Hashtable(); 66*cdf0e10cSrcweir private final String SSUFFIXSEPARATOR = "_"; 67*cdf0e10cSrcweir private final String SVARIABLENAME = "VariableName"; 68*cdf0e10cSrcweir private final String SARRAYVARIABLENAME = "VariableNameList"; 69*cdf0e10cSrcweir private final String SUNOOBJECTNAME = "oUnobject"; 70*cdf0e10cSrcweir private final String SUNOSTRUCTNAME = "aUnoStruct"; 71*cdf0e10cSrcweir private Introspector m_oIntrospector; 72*cdf0e10cSrcweir private Vector aTreepathProviders = new Vector(); 73*cdf0e10cSrcweir private XTreePathProvider xTreepathProvider = null; 74*cdf0e10cSrcweir private boolean baddExceptionHandling = false; 75*cdf0e10cSrcweir private boolean bXPropertySetExceptionsAreAdded = false; 76*cdf0e10cSrcweir private XUnoNode oInitialUnoNode = null; 77*cdf0e10cSrcweir private final String sINITIALVARIABLENAME = "_oUnoEntryObject"; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir /** Creates a new instance of SourceCodeGenerator */ 81*cdf0e10cSrcweir public SourceCodeGenerator(int _nLanguage) { 82*cdf0e10cSrcweir this.setLanguage(_nLanguage); 83*cdf0e10cSrcweir m_oIntrospector = Introspector.getIntrospector(); 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir public String addSourceCodeOfUnoObject(XTreePathProvider _xTreepathProvider, boolean _brememberPath, boolean _bAddMethodSignature, boolean _baddHeader){ 88*cdf0e10cSrcweir String sSourceCode = ""; 89*cdf0e10cSrcweir String sVariableName = ""; 90*cdf0e10cSrcweir if (_xTreepathProvider != null) { 91*cdf0e10cSrcweir for (int i = 0; i < _xTreepathProvider.getPathCount(); i++){ 92*cdf0e10cSrcweir XUnoNode oUnoNode = _xTreepathProvider.getPathComponent(i); 93*cdf0e10cSrcweir if (i == 0){ 94*cdf0e10cSrcweir sVariableName = sINITIALVARIABLENAME; 95*cdf0e10cSrcweir oInitialUnoNode = oUnoNode; 96*cdf0e10cSrcweir } 97*cdf0e10cSrcweir else{ 98*cdf0e10cSrcweir if (oUnoNode instanceof XUnoMethodNode){ 99*cdf0e10cSrcweir XUnoMethodNode oUnoMethodNode = (XUnoMethodNode) oUnoNode; 100*cdf0e10cSrcweir if (oUnoMethodNode.isInvoked()){ 101*cdf0e10cSrcweir UnoObjectDefinition oUnoReturnObjectDefinition = getUnoObjectDefinition(_xTreepathProvider, oUnoMethodNode, i); 102*cdf0e10cSrcweir if (!isVariableDeclared(oUnoReturnObjectDefinition, this.generateVariableNameFromMethod(oUnoMethodNode.getXIdlMethod()))){ 103*cdf0e10cSrcweir // sStatementCode += "\n"; 104*cdf0e10cSrcweir sStatementCode += "\n" + getMethodStatementSourceCode(oUnoMethodNode, sVariableName, oUnoReturnObjectDefinition); 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir sVariableName = oUnoReturnObjectDefinition.getVariableName(); 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir else if (oUnoNode instanceof XUnoPropertyNode){ 110*cdf0e10cSrcweir XUnoPropertyNode oUnoPropertyNode = (XUnoPropertyNode) oUnoNode; 111*cdf0e10cSrcweir Any oReturnObject = com.sun.star.uno.Any.complete(oUnoPropertyNode.getUnoReturnObject()); 112*cdf0e10cSrcweir UnoObjectDefinition oUnoReturnObjectDefinition = new UnoObjectDefinition(oReturnObject); 113*cdf0e10cSrcweir if (!isVariableDeclared(oUnoReturnObjectDefinition, oUnoPropertyNode.getProperty().Name)){ 114*cdf0e10cSrcweir // sStatementCode += "\n"; 115*cdf0e10cSrcweir sStatementCode += "\n" + getPropertyStatementSourceCode(oUnoPropertyNode, sVariableName, oUnoReturnObjectDefinition); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir sVariableName = oUnoReturnObjectDefinition.getVariableName(); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir String sCompleteCode = combineCompleteSourceCode(sMainMethodSignature, _baddHeader); 123*cdf0e10cSrcweir xTreepathProvider = _xTreepathProvider; 124*cdf0e10cSrcweir if (_brememberPath){ 125*cdf0e10cSrcweir aTreepathProviders.add(_xTreepathProvider); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir return sCompleteCode; 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir private void setLanguage(int _nLanguage){ 132*cdf0e10cSrcweir XLanguageSourceCodeGenerator xLanguageSourceCodeGenerator = null; 133*cdf0e10cSrcweir switch(_nLanguage){ 134*cdf0e10cSrcweir case XLanguageSourceCodeGenerator.nJAVA: 135*cdf0e10cSrcweir xLanguageSourceCodeGenerator = new JavaCodeGenerator(); 136*cdf0e10cSrcweir break; 137*cdf0e10cSrcweir case XLanguageSourceCodeGenerator.nCPLUSPLUS: 138*cdf0e10cSrcweir xLanguageSourceCodeGenerator = new CPlusPlusCodeGenerator(); 139*cdf0e10cSrcweir break; 140*cdf0e10cSrcweir case XLanguageSourceCodeGenerator.nBASIC: 141*cdf0e10cSrcweir xLanguageSourceCodeGenerator = new BasicCodeGenerator(); 142*cdf0e10cSrcweir break; 143*cdf0e10cSrcweir default: 144*cdf0e10cSrcweir System.out.println("Unknown Sourcecode Language. Check Menus!"); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir if (xLanguageSourceCodeGenerator != null){ 147*cdf0e10cSrcweir m_xLanguageSourceCodeGenerator = xLanguageSourceCodeGenerator; 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir private void resetSourceCodeGeneration(int _nLanguage){ 152*cdf0e10cSrcweir aVariables.clear(); 153*cdf0e10cSrcweir this.sHeaderStatements.clear(); 154*cdf0e10cSrcweir setLanguage(_nLanguage); 155*cdf0e10cSrcweir String sHeaderCode = ""; 156*cdf0e10cSrcweir sStatementCode = ""; 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir private String generateVariableNameFromMethod(String _sMethodName, String _sPrefix, boolean _bConsiderAll){ 160*cdf0e10cSrcweir String sReturn = ""; 161*cdf0e10cSrcweir if (_sMethodName.startsWith(_sPrefix)){ 162*cdf0e10cSrcweir int nPrefixLength = _sPrefix.length(); 163*cdf0e10cSrcweir if (_sMethodName.length() > nPrefixLength){ 164*cdf0e10cSrcweir String sChar = _sMethodName.substring(nPrefixLength, nPrefixLength + 1); 165*cdf0e10cSrcweir String sUpperChar = sChar.toUpperCase(); 166*cdf0e10cSrcweir if (sUpperChar.equals(sChar)){ 167*cdf0e10cSrcweir if (_bConsiderAll){ 168*cdf0e10cSrcweir sReturn = _sMethodName; 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir else{ 171*cdf0e10cSrcweir sReturn = _sMethodName.substring(nPrefixLength, _sMethodName.length()); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir return sReturn; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir private String generateVariableNameFromMethod(XIdlMethod _xIdlMethod){ 181*cdf0e10cSrcweir // todo: refactor this!!! 182*cdf0e10cSrcweir String sMethodName = _xIdlMethod.getName(); 183*cdf0e10cSrcweir String sReturn = ""; 184*cdf0e10cSrcweir sReturn = generateVariableNameFromMethod(sMethodName, "getBy", false); 185*cdf0e10cSrcweir if (sReturn.equals("")){ 186*cdf0e10cSrcweir sReturn = generateVariableNameFromMethod(sMethodName, "get", false); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir if (sReturn.equals("")){ 189*cdf0e10cSrcweir sReturn = generateVariableNameFromMethod(sMethodName, "attach", false); 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir if (sReturn.equals("")){ 192*cdf0e10cSrcweir sReturn = generateVariableNameFromMethod(sMethodName, "assign", false); 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir if (sReturn.equals("")){ 195*cdf0e10cSrcweir sReturn = generateVariableNameFromMethod(sMethodName, "attach", false); 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir if (sReturn.equals("")){ 198*cdf0e10cSrcweir sReturn = generateVariableNameFromMethod(sMethodName, "create", false); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir if (sReturn.equals("")){ 201*cdf0e10cSrcweir sReturn = generateVariableNameFromMethod(sMethodName, "is", true); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir if (sReturn.equals("")){ 204*cdf0e10cSrcweir sReturn = generateVariableNameFromMethod(sMethodName, "has", true); 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir if (sReturn.equals("")){ 207*cdf0e10cSrcweir sReturn = sMethodName; 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir return sReturn; 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir public String convertAllUnoObjects(int _nLanguage){ 214*cdf0e10cSrcweir String sSourceCode = ""; 215*cdf0e10cSrcweir resetSourceCodeGeneration(_nLanguage); 216*cdf0e10cSrcweir int ncount = aTreepathProviders.size(); 217*cdf0e10cSrcweir for (int i=0; i< ncount; i++){ 218*cdf0e10cSrcweir sSourceCode = addSourceCodeOfUnoObject((XTreePathProvider) aTreepathProviders.get(i), false, (i==0), (i == (ncount-1))); 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir return sSourceCode; 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir private UnoObjectDefinition getUnoObjectDefinition(XTreePathProvider _xTreePathProvider, XUnoMethodNode _oUnoMethodNode, int _nindex){ 224*cdf0e10cSrcweir XUnoNode oUnoNode = null; 225*cdf0e10cSrcweir Object oUnoReturnObject = null; 226*cdf0e10cSrcweir Object[] oParamObjects = null; 227*cdf0e10cSrcweir XIdlClass xIdlClass = _oUnoMethodNode.getXIdlMethod().getReturnType(); 228*cdf0e10cSrcweir String sTypeName = xIdlClass.getName(); 229*cdf0e10cSrcweir TypeClass aTypeClass = xIdlClass.getTypeClass(); 230*cdf0e10cSrcweir if (aTypeClass.getValue() != TypeClass.VOID_value){ 231*cdf0e10cSrcweir if (_xTreePathProvider.getPathCount() > _nindex + 1){ 232*cdf0e10cSrcweir oUnoNode = _xTreePathProvider.getPathComponent(_nindex + 1); 233*cdf0e10cSrcweir oUnoReturnObject = oUnoNode.getUnoObject(); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir if (oUnoReturnObject == null){ 237*cdf0e10cSrcweir oUnoReturnObject = _oUnoMethodNode.getLastUnoReturnObject(); 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir UnoObjectDefinition oUnoObjectDefinition = new UnoObjectDefinition(oUnoReturnObject, sTypeName, aTypeClass); 240*cdf0e10cSrcweir if (_oUnoMethodNode.hasParameters()){ 241*cdf0e10cSrcweir if (oUnoNode != null){ 242*cdf0e10cSrcweir oParamObjects = oUnoNode.getParameterObjects(); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir else{ 245*cdf0e10cSrcweir oParamObjects = _oUnoMethodNode.getLastParameterObjects(); 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir if (oParamObjects != null){ 249*cdf0e10cSrcweir oUnoObjectDefinition.addParameterObjects(oParamObjects); 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir return oUnoObjectDefinition; 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir private String combineCompleteSourceCode(String _sMethodSignature, boolean _bAddHeader){ 256*cdf0e10cSrcweir String sCompleteCode = ""; 257*cdf0e10cSrcweir if (_bAddHeader){ 258*cdf0e10cSrcweir sMainMethodSignature = m_xLanguageSourceCodeGenerator.getMainMethodSignatureSourceCode(oInitialUnoNode, sINITIALVARIABLENAME); 259*cdf0e10cSrcweir m_xLanguageSourceCodeGenerator.assignqueryInterfaceHeaderSourceCode(); 260*cdf0e10cSrcweir sCompleteCode += getHeaderSourceCode(); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir sCompleteCode += sMainMethodSignature; 263*cdf0e10cSrcweir sCompleteCode += sStatementCode; 264*cdf0e10cSrcweir if (_bAddHeader){ 265*cdf0e10cSrcweir sCompleteCode += m_xLanguageSourceCodeGenerator.getMethodTerminationSourceCode(); 266*cdf0e10cSrcweir sCompleteCode += "\n" + m_xLanguageSourceCodeGenerator.getCommentSign() + "..."; 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir return sCompleteCode; 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir public String getPropertyStatementSourceCode(XUnoPropertyNode _oUnoPropertyNode, String _sVariableName, UnoObjectDefinition _oUnoReturnObjectDefinition){ 273*cdf0e10cSrcweir String sReturnObjectVariableDefinition = ""; 274*cdf0e10cSrcweir String sStatement = ""; 275*cdf0e10cSrcweir String sPropertyName = _oUnoPropertyNode.getProperty().Name; 276*cdf0e10cSrcweir UnoObjectDefinition oUnoObjectDefinition = new UnoObjectDefinition(_oUnoPropertyNode.getUnoObject(), "com.sun.star.beans.XPropertySet"); 277*cdf0e10cSrcweir if (!m_xLanguageSourceCodeGenerator.needsqueryInterface() || (oUnoObjectDefinition.getTypeClass().getValue() == TypeClass.STRUCT_value)){ 278*cdf0e10cSrcweir oUnoObjectDefinition.setVariableName(_sVariableName); 279*cdf0e10cSrcweir if (oUnoObjectDefinition.getTypeClass().getValue() == TypeClass.STRUCT_value){ 280*cdf0e10cSrcweir sReturnObjectVariableDefinition = getVariableInitialization(_oUnoReturnObjectDefinition, false); 281*cdf0e10cSrcweir sStatement += m_xLanguageSourceCodeGenerator.getStructSourceCode(sReturnObjectVariableDefinition, oUnoObjectDefinition.getVariableName(), sPropertyName); 282*cdf0e10cSrcweir return sStatement; 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir sStatement += addQueryInterfaceSourceCode(oUnoObjectDefinition, _sVariableName, "com.sun.star.beans.XPropertySet"); 286*cdf0e10cSrcweir if (_oUnoReturnObjectDefinition.getTypeClass().getValue() != TypeClass.VOID_value){ 287*cdf0e10cSrcweir sReturnObjectVariableDefinition = getVariableInitialization(_oUnoReturnObjectDefinition, true); 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir sStatement += m_xLanguageSourceCodeGenerator.getPropertyValueGetterSourceCode(sPropertyName, sReturnObjectVariableDefinition, oUnoObjectDefinition.getVariableName(), _oUnoReturnObjectDefinition.getTypeClass(), _oUnoReturnObjectDefinition.getTypeName()); 290*cdf0e10cSrcweir addXPropertySetRelatedExceptions(); 291*cdf0e10cSrcweir return sStatement; 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir public String getMethodStatementSourceCode(XUnoMethodNode _oUnoMethodNode, String _sVariableName, UnoObjectDefinition _oUnoReturnObjectDefinition){ 296*cdf0e10cSrcweir String sReturnObjectVariableDefinition = ""; 297*cdf0e10cSrcweir String sStatement = ""; 298*cdf0e10cSrcweir XIdlMethod xIdlMethod = _oUnoMethodNode.getXIdlMethod(); 299*cdf0e10cSrcweir TypeClass aReturnTypeClass = xIdlMethod.getReturnType().getTypeClass(); 300*cdf0e10cSrcweir UnoObjectDefinition oUnoObjectDefinition = new UnoObjectDefinition(_oUnoMethodNode.getUnoObject(), _oUnoMethodNode.getClassName()); 301*cdf0e10cSrcweir String sVariableStemName = this.generateVariableNameFromMethod(xIdlMethod); 302*cdf0e10cSrcweir sStatement += addQueryInterfaceSourceCode(oUnoObjectDefinition, _sVariableName, oUnoObjectDefinition.getTypeName()); 303*cdf0e10cSrcweir if (_oUnoReturnObjectDefinition.getTypeClass().getValue() != TypeClass.VOID_value){ 304*cdf0e10cSrcweir sReturnObjectVariableDefinition = getVariableInitialization(_oUnoReturnObjectDefinition, false) + " = "; 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir Object[] oParamObjects = _oUnoReturnObjectDefinition.getParameterObjects(); 307*cdf0e10cSrcweir String sParameterCode = getMethodParameterValueDescription(_oUnoMethodNode, oParamObjects, false); 308*cdf0e10cSrcweir String sSeparator = m_xLanguageSourceCodeGenerator.getMethodSeparator(); 309*cdf0e10cSrcweir sStatement += "\t" + sReturnObjectVariableDefinition + oUnoObjectDefinition.getVariableName() + sSeparator + xIdlMethod.getName() + "(" + sParameterCode + ")"; 310*cdf0e10cSrcweir sStatement += m_xLanguageSourceCodeGenerator.getStatementTerminationCharacter(); 311*cdf0e10cSrcweir addExceptions(xIdlMethod); 312*cdf0e10cSrcweir return sStatement; 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir private String addQueryInterfaceSourceCode(UnoObjectDefinition _oUnoObjectDefinition, String _sVariableName, String _sTypeName){ 317*cdf0e10cSrcweir String sLocStatement = ""; 318*cdf0e10cSrcweir if (m_xLanguageSourceCodeGenerator.needsqueryInterface()){ 319*cdf0e10cSrcweir if (!isVariableDeclared(_oUnoObjectDefinition, "")){ 320*cdf0e10cSrcweir String sObjectVariableDefinition = getVariableDeclaration(_oUnoObjectDefinition, false, ""); 321*cdf0e10cSrcweir sLocStatement += m_xLanguageSourceCodeGenerator.getqueryInterfaceSourceCode(_sTypeName, sObjectVariableDefinition, _sVariableName); 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir else{ 325*cdf0e10cSrcweir _oUnoObjectDefinition.setVariableName(_sVariableName); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir return sLocStatement; 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir private void addXPropertySetRelatedExceptions(){ 332*cdf0e10cSrcweir if (!bXPropertySetExceptionsAreAdded){ 333*cdf0e10cSrcweir sExceptions.add("com.sun.star.beans.UnknownPropertyException"); 334*cdf0e10cSrcweir sExceptions.add("com.sun.star.lang.WrappedTargetException"); 335*cdf0e10cSrcweir sExceptions.add("com.sun.star.lang.IllegalArgumentException"); 336*cdf0e10cSrcweir bXPropertySetExceptionsAreAdded = true; 337*cdf0e10cSrcweir baddExceptionHandling = true; 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir private void addExceptions(XIdlMethod _xIdlMethod){ 343*cdf0e10cSrcweir XIdlClass[] xIdlClasses = _xIdlMethod.getExceptionTypes(); 344*cdf0e10cSrcweir for (int i = 0; i > xIdlClasses.length; i++){ 345*cdf0e10cSrcweir sExceptions.add(xIdlClasses[0].getName()); 346*cdf0e10cSrcweir baddExceptionHandling = true; 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir private String getRootDescription(XUnoNode _oUnoNode){ 351*cdf0e10cSrcweir return "_o" + _oUnoNode.toString(); 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir private String getHeaderSourceCode(){ 356*cdf0e10cSrcweir Enumeration aEnumeration = aVariables.elements(); 357*cdf0e10cSrcweir while(aEnumeration.hasMoreElements()){ 358*cdf0e10cSrcweir UnoObjectDefinition oUnoObjectDefinition = (UnoObjectDefinition) aEnumeration.nextElement(); 359*cdf0e10cSrcweir String sCurHeaderStatement = m_xLanguageSourceCodeGenerator.getHeaderSourceCode(oUnoObjectDefinition.getUnoObject(), oUnoObjectDefinition.getTypeName(), oUnoObjectDefinition.getTypeClass()); 360*cdf0e10cSrcweir sHeaderStatements.add(sCurHeaderStatement); 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir String sHeaderSourcecode = ""; 363*cdf0e10cSrcweir String[] sHeaderStatementArray = new String[sHeaderStatements.size()]; 364*cdf0e10cSrcweir sHeaderStatements.toArray(sHeaderStatementArray); 365*cdf0e10cSrcweir java.util.Arrays.sort(sHeaderStatementArray); 366*cdf0e10cSrcweir for (int i = 0; i < sHeaderStatementArray.length; i++){ 367*cdf0e10cSrcweir sHeaderSourcecode += sHeaderStatementArray[i]; 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir sHeaderSourcecode += m_xLanguageSourceCodeGenerator.getFinalHeaderStatements(); 370*cdf0e10cSrcweir return sHeaderSourcecode +"\n" + m_xLanguageSourceCodeGenerator.getCommentSign() + "...\n"; 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir private class HeaderStatements extends Vector{ 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir public boolean contains(Object _oElement){ 377*cdf0e10cSrcweir String sCompName = (String) _oElement; 378*cdf0e10cSrcweir for (int i = 0; i < this.size(); i++){ 379*cdf0e10cSrcweir String sElement = (String) this.get(i); 380*cdf0e10cSrcweir if (sElement.equals(sCompName)){ 381*cdf0e10cSrcweir return true; 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir return false; 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir public boolean add(Object _oElement){ 389*cdf0e10cSrcweir if (_oElement instanceof String){ 390*cdf0e10cSrcweir if (!contains(_oElement)){ 391*cdf0e10cSrcweir super.add(_oElement); 392*cdf0e10cSrcweir return true; 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir return false; 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir private boolean isVariableDeclared(UnoObjectDefinition _oUnoObjectDefinition, String _sDefaultStemName){ 401*cdf0e10cSrcweir boolean bisDeclared = false; 402*cdf0e10cSrcweir if (!_sDefaultStemName.equals("")){ 403*cdf0e10cSrcweir _oUnoObjectDefinition.setCentralVariableStemName(_sDefaultStemName); 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir String sVariableStemName = _oUnoObjectDefinition.getVariableStemName(); 406*cdf0e10cSrcweir bisDeclared = aVariables.containsKey(sVariableStemName); 407*cdf0e10cSrcweir if (bisDeclared){ 408*cdf0e10cSrcweir Object oUnoObject = _oUnoObjectDefinition.getUnoObject(); 409*cdf0e10cSrcweir if (m_oIntrospector.isObjectPrimitive(oUnoObject)){ 410*cdf0e10cSrcweir bisDeclared = false; 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir else if (m_oIntrospector.isObjectSequence(oUnoObject)){ 413*cdf0e10cSrcweir bisDeclared = false; 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir else{ 416*cdf0e10cSrcweir String sCompVariableName = sVariableStemName; 417*cdf0e10cSrcweir String sUnoObjectIdentity = oUnoObject.toString(); 418*cdf0e10cSrcweir boolean bleaveloop = false; 419*cdf0e10cSrcweir int a = 2; 420*cdf0e10cSrcweir while (!bleaveloop){ 421*cdf0e10cSrcweir if (aVariables.containsKey(sCompVariableName)){ 422*cdf0e10cSrcweir Object oUnoCompObject = ((UnoObjectDefinition) aVariables.get(sCompVariableName)).getUnoObject(); 423*cdf0e10cSrcweir String sUnoCompObjectIdentity = oUnoCompObject.toString(); 424*cdf0e10cSrcweir bleaveloop = sUnoCompObjectIdentity.equals(sUnoObjectIdentity); 425*cdf0e10cSrcweir bisDeclared = bleaveloop; 426*cdf0e10cSrcweir if (!bleaveloop){ 427*cdf0e10cSrcweir sCompVariableName = sVariableStemName + SSUFFIXSEPARATOR + a++; 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir else{ 431*cdf0e10cSrcweir bleaveloop = true; 432*cdf0e10cSrcweir bisDeclared = false; 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir return bisDeclared; 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir private String addUniqueVariableName(String _sStemVariableName, UnoObjectDefinition _oUnoObjectDefinition){ 442*cdf0e10cSrcweir boolean bElementexists = true; 443*cdf0e10cSrcweir int a = 2; 444*cdf0e10cSrcweir String sCompName = _sStemVariableName; 445*cdf0e10cSrcweir while (bElementexists){ 446*cdf0e10cSrcweir if (! aVariables.containsKey(sCompName)){ 447*cdf0e10cSrcweir aVariables.put(sCompName, _oUnoObjectDefinition); 448*cdf0e10cSrcweir break; 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir sCompName = _sStemVariableName + SSUFFIXSEPARATOR + a++; 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir return sCompName; 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir private String getTypeString(String _sTypeName, TypeClass _aTypeClass, boolean _bAsHeaderSourceCode){ 458*cdf0e10cSrcweir String sTypeString = ""; 459*cdf0e10cSrcweir switch (_aTypeClass.getValue()){ 460*cdf0e10cSrcweir case TypeClass.BOOLEAN_value: 461*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.getbooleanTypeDescription(); 462*cdf0e10cSrcweir break; 463*cdf0e10cSrcweir case TypeClass.BYTE_value: 464*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.getbyteTypeDescription(); 465*cdf0e10cSrcweir break; 466*cdf0e10cSrcweir case TypeClass.CHAR_value: 467*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.getcharTypeDescription(); 468*cdf0e10cSrcweir break; 469*cdf0e10cSrcweir case TypeClass.DOUBLE_value: 470*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.getdoubleTypeDescription(); 471*cdf0e10cSrcweir break; 472*cdf0e10cSrcweir case TypeClass.FLOAT_value: 473*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.getfloatTypeDescription(); 474*cdf0e10cSrcweir break; 475*cdf0e10cSrcweir case TypeClass.HYPER_value: 476*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.gethyperTypeDescription(); 477*cdf0e10cSrcweir break; 478*cdf0e10cSrcweir case TypeClass.LONG_value: 479*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.getlongTypeDescription(); 480*cdf0e10cSrcweir break; 481*cdf0e10cSrcweir case TypeClass.SHORT_value: 482*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.getshortTypeDescription(); 483*cdf0e10cSrcweir break; 484*cdf0e10cSrcweir case TypeClass.STRING_value: 485*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.getstringTypeDescription(_bAsHeaderSourceCode); 486*cdf0e10cSrcweir break; 487*cdf0e10cSrcweir case TypeClass.UNSIGNED_HYPER_value: 488*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.getunsignedhyperTypeDescription(); 489*cdf0e10cSrcweir break; 490*cdf0e10cSrcweir case TypeClass.UNSIGNED_LONG_value: 491*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.getunsignedlongTypeDescription(); 492*cdf0e10cSrcweir break; 493*cdf0e10cSrcweir case TypeClass.UNSIGNED_SHORT_value: 494*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.getdoubleTypeDescription(); 495*cdf0e10cSrcweir break; 496*cdf0e10cSrcweir case TypeClass.SEQUENCE_value: 497*cdf0e10cSrcweir //TODO consider mulitdimensional Arrays 498*cdf0e10cSrcweir XTypeDescription xTypeDescription = Introspector.getIntrospector().getReferencedType(_sTypeName); 499*cdf0e10cSrcweir if (xTypeDescription != null){ 500*cdf0e10cSrcweir sTypeString = getTypeString(xTypeDescription.getName(), xTypeDescription.getTypeClass(), _bAsHeaderSourceCode); 501*cdf0e10cSrcweir } 502*cdf0e10cSrcweir break; 503*cdf0e10cSrcweir case TypeClass.ANY_value: 504*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.getanyTypeDescription(_bAsHeaderSourceCode); 505*cdf0e10cSrcweir break; 506*cdf0e10cSrcweir case TypeClass.TYPE_value: 507*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.getObjectTypeDescription("com.sun.star.uno.Type", _bAsHeaderSourceCode); 508*cdf0e10cSrcweir break; 509*cdf0e10cSrcweir case TypeClass.ENUM_value: 510*cdf0e10cSrcweir case TypeClass.STRUCT_value: 511*cdf0e10cSrcweir case TypeClass.INTERFACE_ATTRIBUTE_value: 512*cdf0e10cSrcweir case TypeClass.INTERFACE_METHOD_value: 513*cdf0e10cSrcweir case TypeClass.INTERFACE_value: 514*cdf0e10cSrcweir case TypeClass.PROPERTY_value: 515*cdf0e10cSrcweir sTypeString = m_xLanguageSourceCodeGenerator.getObjectTypeDescription(_sTypeName, _bAsHeaderSourceCode); 516*cdf0e10cSrcweir break; 517*cdf0e10cSrcweir default: 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir return sTypeString; 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir private String getVariableDeclaration(UnoObjectDefinition _oUnoObjectDefinition, boolean _bInitialize, String _sVariableDefaultName){ 524*cdf0e10cSrcweir TypeClass aTypeClass = _oUnoObjectDefinition.getTypeClass(); 525*cdf0e10cSrcweir TypeClass aLocTypeClass = aTypeClass; 526*cdf0e10cSrcweir boolean bIsArray = false; 527*cdf0e10cSrcweir if (_oUnoObjectDefinition.getUnoObject() != null){ 528*cdf0e10cSrcweir bIsArray = m_oIntrospector.isObjectSequence(_oUnoObjectDefinition.getUnoObject()); 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir else{ 531*cdf0e10cSrcweir bIsArray = _oUnoObjectDefinition.getTypeClass().getValue() == TypeClass.SEQUENCE_value; 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir String sVariableName = _oUnoObjectDefinition.getVariableName(_sVariableDefaultName); 534*cdf0e10cSrcweir String sTypeName = _oUnoObjectDefinition.getTypeName(); 535*cdf0e10cSrcweir String sTypeString = getTypeString(sTypeName, aLocTypeClass, false); 536*cdf0e10cSrcweir if (bIsArray){ 537*cdf0e10cSrcweir XTypeDescription xTypeDescription = Introspector.getIntrospector().getReferencedType(sTypeName); 538*cdf0e10cSrcweir if (xTypeDescription != null){ 539*cdf0e10cSrcweir aLocTypeClass = xTypeDescription.getTypeClass(); 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir String sVariableDeclaration = m_xLanguageSourceCodeGenerator.getVariableDeclaration(sTypeString, sVariableName, bIsArray, aLocTypeClass, _bInitialize); 543*cdf0e10cSrcweir addUniqueVariableName(sVariableName, _oUnoObjectDefinition); 544*cdf0e10cSrcweir return sVariableDeclaration; 545*cdf0e10cSrcweir } 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir public String getVariableInitialization(UnoObjectDefinition _oUnoObjectDefinition, boolean _bInitialize){ 549*cdf0e10cSrcweir String sObjectVariableDeclaration = ""; 550*cdf0e10cSrcweir String sVariableName = _oUnoObjectDefinition.getVariableName(); 551*cdf0e10cSrcweir if (isVariableDeclared(_oUnoObjectDefinition, "")){ 552*cdf0e10cSrcweir sObjectVariableDeclaration = sVariableName; 553*cdf0e10cSrcweir } 554*cdf0e10cSrcweir else{ 555*cdf0e10cSrcweir sObjectVariableDeclaration = getVariableDeclaration(_oUnoObjectDefinition, _bInitialize, ""); 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir return sObjectVariableDeclaration; 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir public String getVariableNameforUnoObject(String _sShortClassName){ 563*cdf0e10cSrcweir if (_sShortClassName.startsWith("X")){ 564*cdf0e10cSrcweir return "x" + _sShortClassName.substring(1); 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir else{ 567*cdf0e10cSrcweir return _sShortClassName; 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir } 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir class UnoObjectDefinition{ 573*cdf0e10cSrcweir Object m_oUnoObject = null; 574*cdf0e10cSrcweir Type aType = null; 575*cdf0e10cSrcweir String sVariableStemName = ""; 576*cdf0e10cSrcweir String m_sCentralVariableStemName = ""; 577*cdf0e10cSrcweir String sVariableName = ""; 578*cdf0e10cSrcweir String m_sTypeName = ""; 579*cdf0e10cSrcweir TypeClass m_aTypeClass = null; 580*cdf0e10cSrcweir Object[] m_oParameterObjects = null; 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir 583*cdf0e10cSrcweir public UnoObjectDefinition(Any _oUnoObject){ 584*cdf0e10cSrcweir m_sTypeName = _oUnoObject.getType().getTypeName(); 585*cdf0e10cSrcweir m_aTypeClass = _oUnoObject.getType().getTypeClass(); 586*cdf0e10cSrcweir m_oUnoObject = _oUnoObject; 587*cdf0e10cSrcweir m_sCentralVariableStemName = getCentralVariableStemName(m_aTypeClass); 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir public UnoObjectDefinition(Object _oUnoObject, String _sTypeName, TypeClass _aTypeClass){ 592*cdf0e10cSrcweir m_oUnoObject = _oUnoObject; 593*cdf0e10cSrcweir m_sTypeName = _sTypeName; 594*cdf0e10cSrcweir m_aTypeClass = _aTypeClass; 595*cdf0e10cSrcweir m_sCentralVariableStemName = getCentralVariableStemName(m_aTypeClass); 596*cdf0e10cSrcweir } 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir public UnoObjectDefinition(Object _oUnoObject, String _sTypeName){ 600*cdf0e10cSrcweir m_oUnoObject = _oUnoObject; 601*cdf0e10cSrcweir m_sTypeName = _sTypeName; 602*cdf0e10cSrcweir m_aTypeClass = AnyConverter.getType(_oUnoObject).getTypeClass(); 603*cdf0e10cSrcweir m_sCentralVariableStemName = getCentralVariableStemName(m_aTypeClass); 604*cdf0e10cSrcweir } 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir private String getCentralVariableStemName(TypeClass _aTypeClass){ 608*cdf0e10cSrcweir String sCentralVariableStemName = ""; 609*cdf0e10cSrcweir int nTypeClass = _aTypeClass.getValue(); 610*cdf0e10cSrcweir switch(nTypeClass){ 611*cdf0e10cSrcweir case TypeClass.SEQUENCE_value: 612*cdf0e10cSrcweir //TODO consider mulitdimensional Arrays 613*cdf0e10cSrcweir XTypeDescription xTypeDescription = Introspector.getIntrospector().getReferencedType(getTypeName()); 614*cdf0e10cSrcweir if (xTypeDescription != null){ 615*cdf0e10cSrcweir sCentralVariableStemName = getCentralVariableStemName(xTypeDescription.getTypeClass()); 616*cdf0e10cSrcweir } 617*cdf0e10cSrcweir break; 618*cdf0e10cSrcweir case TypeClass.TYPE_value: 619*cdf0e10cSrcweir sCentralVariableStemName = SVARIABLENAME; 620*cdf0e10cSrcweir break; 621*cdf0e10cSrcweir case TypeClass.STRUCT_value: 622*cdf0e10cSrcweir sCentralVariableStemName = Introspector.getShortClassName(getTypeName()); 623*cdf0e10cSrcweir break; 624*cdf0e10cSrcweir case TypeClass.INTERFACE_ATTRIBUTE_value: 625*cdf0e10cSrcweir case TypeClass.INTERFACE_METHOD_value: 626*cdf0e10cSrcweir case TypeClass.INTERFACE_value: 627*cdf0e10cSrcweir case TypeClass.PROPERTY_value: 628*cdf0e10cSrcweir String sShortClassName = m_oIntrospector.getShortClassName(getTypeName()); 629*cdf0e10cSrcweir sCentralVariableStemName = getVariableNameforUnoObject(sShortClassName); 630*cdf0e10cSrcweir default: 631*cdf0e10cSrcweir sCentralVariableStemName = SVARIABLENAME; 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir return sCentralVariableStemName; 634*cdf0e10cSrcweir } 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir /** may return null 637*cdf0e10cSrcweir */ 638*cdf0e10cSrcweir public Object getUnoObject(){ 639*cdf0e10cSrcweir return m_oUnoObject; 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir public void setTypeClass(TypeClass _aTypeClass){ 644*cdf0e10cSrcweir sVariableStemName = ""; 645*cdf0e10cSrcweir m_aTypeClass = _aTypeClass; 646*cdf0e10cSrcweir } 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir public TypeClass getTypeClass(){ 650*cdf0e10cSrcweir return m_aTypeClass; 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir public void setTypeName(String _sTypeName){ 655*cdf0e10cSrcweir sVariableStemName = ""; 656*cdf0e10cSrcweir m_sTypeName = _sTypeName; 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir public String getTypeName(){ 661*cdf0e10cSrcweir return m_sTypeName; 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir public void setCentralVariableStemName(String _sCentralVariableStemName){ 666*cdf0e10cSrcweir m_sCentralVariableStemName = _sCentralVariableStemName; 667*cdf0e10cSrcweir } 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir 670*cdf0e10cSrcweir public String getVariableStemName(){ 671*cdf0e10cSrcweir if (sVariableStemName.equals("")){ 672*cdf0e10cSrcweir sVariableStemName = getVariableStemName(m_aTypeClass); 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir return sVariableStemName; 675*cdf0e10cSrcweir } 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir public void addParameterObjects(Object[] _oParameterObjects){ 679*cdf0e10cSrcweir m_oParameterObjects = _oParameterObjects; 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir 682*cdf0e10cSrcweir 683*cdf0e10cSrcweir public Object[] getParameterObjects(){ 684*cdf0e10cSrcweir return m_oParameterObjects; 685*cdf0e10cSrcweir } 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir 688*cdf0e10cSrcweir public boolean hasParameterObjects(){ 689*cdf0e10cSrcweir boolean breturn = false; 690*cdf0e10cSrcweir if (m_oParameterObjects != null){ 691*cdf0e10cSrcweir breturn = m_oParameterObjects.length > 0; 692*cdf0e10cSrcweir } 693*cdf0e10cSrcweir return breturn; 694*cdf0e10cSrcweir } 695*cdf0e10cSrcweir 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir public String getVariableStemName(TypeClass _aTypeClass){ 698*cdf0e10cSrcweir int nTypeClass = _aTypeClass.getValue(); 699*cdf0e10cSrcweir switch(nTypeClass){ 700*cdf0e10cSrcweir case TypeClass.BOOLEAN_value: 701*cdf0e10cSrcweir sVariableStemName = "b" + m_sCentralVariableStemName; 702*cdf0e10cSrcweir break; 703*cdf0e10cSrcweir case TypeClass.DOUBLE_value: 704*cdf0e10cSrcweir case TypeClass.FLOAT_value: 705*cdf0e10cSrcweir sVariableStemName = "f" + m_sCentralVariableStemName; 706*cdf0e10cSrcweir break; 707*cdf0e10cSrcweir case TypeClass.BYTE_value: 708*cdf0e10cSrcweir case TypeClass.HYPER_value: 709*cdf0e10cSrcweir case TypeClass.LONG_value: 710*cdf0e10cSrcweir case TypeClass.UNSIGNED_HYPER_value: 711*cdf0e10cSrcweir case TypeClass.UNSIGNED_LONG_value: 712*cdf0e10cSrcweir case TypeClass.UNSIGNED_SHORT_value: 713*cdf0e10cSrcweir case TypeClass.SHORT_value: 714*cdf0e10cSrcweir sVariableStemName = "n" + m_sCentralVariableStemName; 715*cdf0e10cSrcweir break; 716*cdf0e10cSrcweir case TypeClass.CHAR_value: 717*cdf0e10cSrcweir case TypeClass.STRING_value: 718*cdf0e10cSrcweir sVariableStemName = "s" + m_sCentralVariableStemName; 719*cdf0e10cSrcweir break; 720*cdf0e10cSrcweir case TypeClass.SEQUENCE_value: 721*cdf0e10cSrcweir //TODO consider mulitdimensional Arrays 722*cdf0e10cSrcweir XTypeDescription xTypeDescription = Introspector.getIntrospector().getReferencedType(getTypeName()); 723*cdf0e10cSrcweir if (xTypeDescription != null){ 724*cdf0e10cSrcweir sVariableStemName = getVariableStemName(xTypeDescription.getTypeClass()); 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir break; 727*cdf0e10cSrcweir case TypeClass.TYPE_value: 728*cdf0e10cSrcweir sVariableStemName = "a" + m_sCentralVariableStemName; 729*cdf0e10cSrcweir break; 730*cdf0e10cSrcweir case TypeClass.ANY_value: 731*cdf0e10cSrcweir sVariableStemName = "o" + m_sCentralVariableStemName; 732*cdf0e10cSrcweir break; 733*cdf0e10cSrcweir case TypeClass.STRUCT_value: 734*cdf0e10cSrcweir case TypeClass.ENUM_value: 735*cdf0e10cSrcweir sVariableStemName = "a" + m_sCentralVariableStemName; 736*cdf0e10cSrcweir break; 737*cdf0e10cSrcweir case TypeClass.INTERFACE_ATTRIBUTE_value: 738*cdf0e10cSrcweir case TypeClass.INTERFACE_METHOD_value: 739*cdf0e10cSrcweir case TypeClass.INTERFACE_value: 740*cdf0e10cSrcweir case TypeClass.PROPERTY_value: 741*cdf0e10cSrcweir String sShortClassName = m_oIntrospector.getShortClassName(getTypeName()); 742*cdf0e10cSrcweir sVariableStemName = getVariableNameforUnoObject(sShortClassName); 743*cdf0e10cSrcweir default: 744*cdf0e10cSrcweir } 745*cdf0e10cSrcweir return sVariableStemName; 746*cdf0e10cSrcweir } 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir 749*cdf0e10cSrcweir private void setVariableName(String _sVariableName){ 750*cdf0e10cSrcweir sVariableName = _sVariableName; 751*cdf0e10cSrcweir } 752*cdf0e10cSrcweir 753*cdf0e10cSrcweir 754*cdf0e10cSrcweir private String getVariableName(String _sCentralVariableStemName){ 755*cdf0e10cSrcweir if (!_sCentralVariableStemName.equals("")){ 756*cdf0e10cSrcweir this.m_sCentralVariableStemName = _sCentralVariableStemName; 757*cdf0e10cSrcweir } 758*cdf0e10cSrcweir return getVariableName(); 759*cdf0e10cSrcweir } 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir private String getVariableName() throws NullPointerException{ 763*cdf0e10cSrcweir if (sVariableName.equals("")){ 764*cdf0e10cSrcweir int a = 2; 765*cdf0e10cSrcweir sVariableName = getVariableStemName(); 766*cdf0e10cSrcweir boolean bleaveloop = false; 767*cdf0e10cSrcweir while (!bleaveloop){ 768*cdf0e10cSrcweir if (aVariables.containsKey(sVariableName)){ 769*cdf0e10cSrcweir String sUnoObjectIdentity = ((UnoObjectDefinition) aVariables.get(sVariableName)).getUnoObject().toString(); 770*cdf0e10cSrcweir if (m_oUnoObject != null){ 771*cdf0e10cSrcweir if ((sUnoObjectIdentity.equals(m_oUnoObject.toString()) && (!m_oIntrospector.isPrimitive(this.getTypeClass())) && 772*cdf0e10cSrcweir (! m_oIntrospector.isObjectSequence(m_oUnoObject)))){ 773*cdf0e10cSrcweir bleaveloop = true; 774*cdf0e10cSrcweir } 775*cdf0e10cSrcweir else{ 776*cdf0e10cSrcweir sVariableName = getVariableStemName() + SSUFFIXSEPARATOR + a++; 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir } 779*cdf0e10cSrcweir else{ 780*cdf0e10cSrcweir bleaveloop = true; 781*cdf0e10cSrcweir } 782*cdf0e10cSrcweir } 783*cdf0e10cSrcweir else{ 784*cdf0e10cSrcweir bleaveloop = true; 785*cdf0e10cSrcweir // throw new NullPointerException("SourceCode Variable " + _sStemVariableName + " not defined"); 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir } 788*cdf0e10cSrcweir } 789*cdf0e10cSrcweir return sVariableName; 790*cdf0e10cSrcweir } 791*cdf0e10cSrcweir } 792*cdf0e10cSrcweir 793*cdf0e10cSrcweir 794*cdf0e10cSrcweir public String getStringValueOfObject(Object _oUnoObject, TypeClass _aTypeClass){ 795*cdf0e10cSrcweir String sReturn = ""; 796*cdf0e10cSrcweir switch (_aTypeClass.getValue()){ 797*cdf0e10cSrcweir case TypeClass.BOOLEAN_value: 798*cdf0e10cSrcweir boolean bbooleanValue = ((Boolean) _oUnoObject).booleanValue(); 799*cdf0e10cSrcweir sReturn += Boolean.toString(bbooleanValue); 800*cdf0e10cSrcweir case TypeClass.CHAR_value: 801*cdf0e10cSrcweir break; 802*cdf0e10cSrcweir case TypeClass.DOUBLE_value: 803*cdf0e10cSrcweir double fdoubleValue = ((Double) _oUnoObject).doubleValue(); 804*cdf0e10cSrcweir sReturn += Double.toString(fdoubleValue); 805*cdf0e10cSrcweir break; 806*cdf0e10cSrcweir case TypeClass.ENUM_value: 807*cdf0e10cSrcweir break; 808*cdf0e10cSrcweir case TypeClass.FLOAT_value: 809*cdf0e10cSrcweir float floatValue = ((Float) _oUnoObject).floatValue(); 810*cdf0e10cSrcweir sReturn += Float.toString(floatValue); 811*cdf0e10cSrcweir break; 812*cdf0e10cSrcweir case TypeClass.HYPER_value: 813*cdf0e10cSrcweir long nlongValue = ((Long) _oUnoObject).longValue(); 814*cdf0e10cSrcweir sReturn += Long.toString(nlongValue); 815*cdf0e10cSrcweir break; 816*cdf0e10cSrcweir case TypeClass.LONG_value: 817*cdf0e10cSrcweir int nintValue = ((Integer) _oUnoObject).intValue(); 818*cdf0e10cSrcweir sReturn += Integer.toString(nintValue); 819*cdf0e10cSrcweir break; 820*cdf0e10cSrcweir case TypeClass.SHORT_value: 821*cdf0e10cSrcweir short nshortValue = ((Short) _oUnoObject).shortValue(); 822*cdf0e10cSrcweir sReturn += Short.toString(nshortValue); 823*cdf0e10cSrcweir break; 824*cdf0e10cSrcweir case TypeClass.STRING_value: 825*cdf0e10cSrcweir sReturn += (String) _oUnoObject; 826*cdf0e10cSrcweir break; 827*cdf0e10cSrcweir case TypeClass.UNSIGNED_HYPER_value: 828*cdf0e10cSrcweir nlongValue = ((Long) _oUnoObject).longValue(); 829*cdf0e10cSrcweir sReturn += Long.toString(nlongValue); 830*cdf0e10cSrcweir break; 831*cdf0e10cSrcweir case TypeClass.UNSIGNED_LONG_value: 832*cdf0e10cSrcweir nintValue = ((Integer) _oUnoObject).intValue(); 833*cdf0e10cSrcweir sReturn += Integer.toString(nintValue); 834*cdf0e10cSrcweir break; 835*cdf0e10cSrcweir case TypeClass.UNSIGNED_SHORT_value: 836*cdf0e10cSrcweir nshortValue = ((Short) _oUnoObject).shortValue(); 837*cdf0e10cSrcweir sReturn += Short.toString(nshortValue); 838*cdf0e10cSrcweir break; 839*cdf0e10cSrcweir default: 840*cdf0e10cSrcweir System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'getStringValueOfObject()'"); 841*cdf0e10cSrcweir } 842*cdf0e10cSrcweir return sReturn; 843*cdf0e10cSrcweir } 844*cdf0e10cSrcweir 845*cdf0e10cSrcweir 846*cdf0e10cSrcweir public String getMethodParameterValueDescription(XUnoMethodNode _oUnoMethodNode, Object[] _oParamObjects, boolean _bIncludeParameterNames){ 847*cdf0e10cSrcweir String sParamSourceCode = ""; 848*cdf0e10cSrcweir ParamInfo[] aParamInfos = _oUnoMethodNode.getXIdlMethod().getParameterInfos(); 849*cdf0e10cSrcweir if (_oParamObjects != null){ 850*cdf0e10cSrcweir for (int i = 0; i < _oParamObjects.length; i++){ 851*cdf0e10cSrcweir TypeClass aTypeClass = aParamInfos[i].aType.getTypeClass(); 852*cdf0e10cSrcweir if (_bIncludeParameterNames){ 853*cdf0e10cSrcweir sParamSourceCode += aParamInfos[i].aName + "="; 854*cdf0e10cSrcweir } 855*cdf0e10cSrcweir String sParamDescription = getStringValueOfObject(_oParamObjects[i], aTypeClass); 856*cdf0e10cSrcweir sParamDescription = this.m_xLanguageSourceCodeGenerator.castLiteral(sParamDescription, aTypeClass); 857*cdf0e10cSrcweir sParamSourceCode += sParamDescription; 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir if (i < _oParamObjects.length - 1){ 860*cdf0e10cSrcweir sParamSourceCode += ", "; 861*cdf0e10cSrcweir } 862*cdf0e10cSrcweir } 863*cdf0e10cSrcweir } 864*cdf0e10cSrcweir return sParamSourceCode; 865*cdf0e10cSrcweir } 866*cdf0e10cSrcweir 867*cdf0e10cSrcweir 868*cdf0e10cSrcweir public class JavaCodeGenerator implements XLanguageSourceCodeGenerator{ 869*cdf0e10cSrcweir String sStatementsCode = ""; 870*cdf0e10cSrcweir boolean bAddAnyConverter = false; 871*cdf0e10cSrcweir // boolean bAddTypeImport = false; 872*cdf0e10cSrcweir boolean bIsPropertyUnoObjectDefined = false; 873*cdf0e10cSrcweir 874*cdf0e10cSrcweir public JavaCodeGenerator(){ 875*cdf0e10cSrcweir } 876*cdf0e10cSrcweir 877*cdf0e10cSrcweir 878*cdf0e10cSrcweir public String getStatementTerminationCharacter(){ 879*cdf0e10cSrcweir return ";"; 880*cdf0e10cSrcweir } 881*cdf0e10cSrcweir 882*cdf0e10cSrcweir 883*cdf0e10cSrcweir public String getHeaderSourceCode(Object _oUnoObject, String _sClassName, TypeClass _aTypeClass){ 884*cdf0e10cSrcweir String sClassName = _sClassName; 885*cdf0e10cSrcweir String sHeaderStatement = ""; 886*cdf0e10cSrcweir if (_oUnoObject != null){ 887*cdf0e10cSrcweir if (!m_oIntrospector.isObjectPrimitive(_oUnoObject)){ 888*cdf0e10cSrcweir if (m_oIntrospector.isObjectSequence(_oUnoObject)){ 889*cdf0e10cSrcweir XTypeDescription xTypeDescription = m_oIntrospector.getReferencedType(sClassName); 890*cdf0e10cSrcweir if (xTypeDescription != null){ 891*cdf0e10cSrcweir if (!m_oIntrospector.isPrimitive(xTypeDescription.getTypeClass())){ 892*cdf0e10cSrcweir sClassName = getTypeString(xTypeDescription.getName(), xTypeDescription.getTypeClass(), true); 893*cdf0e10cSrcweir } 894*cdf0e10cSrcweir // primitive Types are not supposed to turn up in the import section... 895*cdf0e10cSrcweir else{ 896*cdf0e10cSrcweir sClassName = ""; 897*cdf0e10cSrcweir } 898*cdf0e10cSrcweir } 899*cdf0e10cSrcweir } 900*cdf0e10cSrcweir else{ 901*cdf0e10cSrcweir sClassName = getTypeString(_sClassName, _aTypeClass, true); 902*cdf0e10cSrcweir } 903*cdf0e10cSrcweir } 904*cdf0e10cSrcweir else if (_aTypeClass.getValue() == TypeClass.ENUM_value){ 905*cdf0e10cSrcweir sClassName = _sClassName; 906*cdf0e10cSrcweir } 907*cdf0e10cSrcweir else{ 908*cdf0e10cSrcweir sClassName = ""; 909*cdf0e10cSrcweir } 910*cdf0e10cSrcweir if (!sClassName.equals("")){ 911*cdf0e10cSrcweir sHeaderStatement = "import " + sClassName + ";\n"; 912*cdf0e10cSrcweir } 913*cdf0e10cSrcweir } 914*cdf0e10cSrcweir return sHeaderStatement; 915*cdf0e10cSrcweir } 916*cdf0e10cSrcweir 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir public String getFinalHeaderStatements(){ 919*cdf0e10cSrcweir return ""; 920*cdf0e10cSrcweir } 921*cdf0e10cSrcweir 922*cdf0e10cSrcweir 923*cdf0e10cSrcweir public void assignqueryInterfaceHeaderSourceCode(){ 924*cdf0e10cSrcweir sHeaderStatements.add("import com.sun.star.uno.UnoRuntime;\n"); 925*cdf0e10cSrcweir sHeaderStatements.add("import com.sun.star.uno.XInterface;\n"); 926*cdf0e10cSrcweir if (bAddAnyConverter){ 927*cdf0e10cSrcweir sHeaderStatements.add("import com.sun.star.uno.AnyConverter;\n"); 928*cdf0e10cSrcweir } 929*cdf0e10cSrcweir } 930*cdf0e10cSrcweir 931*cdf0e10cSrcweir 932*cdf0e10cSrcweir 933*cdf0e10cSrcweir public String getConvertedSourceCodeValueOfObject(String _sReturnVariableName, String _sObjectDescription, TypeClass _aTypeClass, String _sTypeName){ 934*cdf0e10cSrcweir boolean bLocAddAnyConverter = true; 935*cdf0e10cSrcweir String sReturn = ""; 936*cdf0e10cSrcweir switch (_aTypeClass.getValue()){ 937*cdf0e10cSrcweir case TypeClass.BOOLEAN_value: 938*cdf0e10cSrcweir sReturn = _sReturnVariableName + " = AnyConverter.toBoolean(" + _sObjectDescription + ")"; 939*cdf0e10cSrcweir break; 940*cdf0e10cSrcweir case TypeClass.CHAR_value: 941*cdf0e10cSrcweir sReturn = _sReturnVariableName + " = AnyConverter.toChar(" + _sObjectDescription + ")"; 942*cdf0e10cSrcweir break; 943*cdf0e10cSrcweir case TypeClass.BYTE_value: 944*cdf0e10cSrcweir sReturn = _sReturnVariableName + " = AnyConverter.toByte(" + _sObjectDescription + ")"; 945*cdf0e10cSrcweir break; 946*cdf0e10cSrcweir case TypeClass.DOUBLE_value: 947*cdf0e10cSrcweir sReturn = _sReturnVariableName + " = AnyConverter.toDouble(" + _sObjectDescription + ")"; 948*cdf0e10cSrcweir break; 949*cdf0e10cSrcweir case TypeClass.FLOAT_value: 950*cdf0e10cSrcweir sReturn = _sReturnVariableName + " = AnyConverter.toFloat(" + _sObjectDescription + ")"; 951*cdf0e10cSrcweir break; 952*cdf0e10cSrcweir case TypeClass.UNSIGNED_HYPER_value: 953*cdf0e10cSrcweir sReturn = _sReturnVariableName + " = AnyConverter.toUnsignedLong(" + _sObjectDescription + ")"; 954*cdf0e10cSrcweir break; 955*cdf0e10cSrcweir case TypeClass.HYPER_value: 956*cdf0e10cSrcweir sReturn = _sReturnVariableName + " = AnyConverter.toLong(" + _sObjectDescription + ")"; 957*cdf0e10cSrcweir break; 958*cdf0e10cSrcweir case TypeClass.UNSIGNED_LONG_value: 959*cdf0e10cSrcweir sReturn = _sReturnVariableName + " = AnyConverter.toUnsignedInt(" + _sObjectDescription + ")"; 960*cdf0e10cSrcweir break; 961*cdf0e10cSrcweir case TypeClass.LONG_value: 962*cdf0e10cSrcweir sReturn = _sReturnVariableName + " = AnyConverter.toInt(" + _sObjectDescription + ")"; 963*cdf0e10cSrcweir break; 964*cdf0e10cSrcweir case TypeClass.SHORT_value: 965*cdf0e10cSrcweir sReturn = _sReturnVariableName + " = AnyConverter.toShort(" + _sObjectDescription + ")"; 966*cdf0e10cSrcweir break; 967*cdf0e10cSrcweir case TypeClass.UNSIGNED_SHORT_value: 968*cdf0e10cSrcweir sReturn = _sReturnVariableName + " = AnyConverter.toUnsignedShort(" + _sObjectDescription + ")"; 969*cdf0e10cSrcweir break; 970*cdf0e10cSrcweir case TypeClass.STRING_value: 971*cdf0e10cSrcweir sReturn = _sReturnVariableName + " = AnyConverter.toString(" + _sObjectDescription + ")"; 972*cdf0e10cSrcweir break; 973*cdf0e10cSrcweir default: 974*cdf0e10cSrcweir String sShortTypeName = Introspector.getShortClassName(_sTypeName); 975*cdf0e10cSrcweir if (bIsPropertyUnoObjectDefined){ 976*cdf0e10cSrcweir sReturn = "oUnoObject = " + _sObjectDescription + ";\n\t"; 977*cdf0e10cSrcweir } 978*cdf0e10cSrcweir else{ 979*cdf0e10cSrcweir sReturn = "Object oUnoObject = " + _sObjectDescription + ";\n\t"; 980*cdf0e10cSrcweir bIsPropertyUnoObjectDefined = true; 981*cdf0e10cSrcweir } 982*cdf0e10cSrcweir sReturn += _sReturnVariableName + " = (" + sShortTypeName + ") AnyConverter.toObject(" + sShortTypeName + ".class, oUnoObject);"; 983*cdf0e10cSrcweir // this.bAddTypeImport = true; 984*cdf0e10cSrcweir break; 985*cdf0e10cSrcweir } 986*cdf0e10cSrcweir if (!bAddAnyConverter){ 987*cdf0e10cSrcweir bAddAnyConverter = bLocAddAnyConverter; 988*cdf0e10cSrcweir } 989*cdf0e10cSrcweir return sReturn; 990*cdf0e10cSrcweir } 991*cdf0e10cSrcweir 992*cdf0e10cSrcweir 993*cdf0e10cSrcweir public String getStructSourceCode(String _sReturnVariableDescription, String _sObjectDescription, String _sMember){ 994*cdf0e10cSrcweir return "\t" + _sReturnVariableDescription + " = " + _sObjectDescription + "." + _sMember + ";"; 995*cdf0e10cSrcweir } 996*cdf0e10cSrcweir 997*cdf0e10cSrcweir public String getMainMethodSignatureSourceCode(XUnoNode _oUnoNode, String _soReturnObjectDescription){ 998*cdf0e10cSrcweir //TODO try to use + _oUnoNode.getClassName() instead of the hack 999*cdf0e10cSrcweir String sReturn = "public void codesnippet(XInterface " + _soReturnObjectDescription + "){"; 1000*cdf0e10cSrcweir if (baddExceptionHandling){ 1001*cdf0e10cSrcweir sReturn += "\ntry{"; 1002*cdf0e10cSrcweir } 1003*cdf0e10cSrcweir return sReturn; 1004*cdf0e10cSrcweir } 1005*cdf0e10cSrcweir 1006*cdf0e10cSrcweir public String getMethodSeparator(){ 1007*cdf0e10cSrcweir return "."; 1008*cdf0e10cSrcweir } 1009*cdf0e10cSrcweir 1010*cdf0e10cSrcweir public boolean needsqueryInterface(){ 1011*cdf0e10cSrcweir return true; 1012*cdf0e10cSrcweir } 1013*cdf0e10cSrcweir 1014*cdf0e10cSrcweir public String getqueryInterfaceSourceCode(String _sClassName, String _sReturnVariableName, String _sIncomingObjectName){ 1015*cdf0e10cSrcweir String sShortClassName = m_oIntrospector.getShortClassName(_sClassName); 1016*cdf0e10cSrcweir return "\t" + _sReturnVariableName + " = (" + sShortClassName + ") UnoRuntime.queryInterface(" + sShortClassName + ".class, " + _sIncomingObjectName + ");\n"; 1017*cdf0e10cSrcweir } 1018*cdf0e10cSrcweir 1019*cdf0e10cSrcweir 1020*cdf0e10cSrcweir public String getPropertyValueGetterSourceCode(String _sPropertyName, String _sReturnVariableName, String _sIncomingObjectName, TypeClass _aTypeClass, String _sTypeName){ 1021*cdf0e10cSrcweir String sObjectDescription = _sIncomingObjectName + ".getPropertyValue(\"" + _sPropertyName + "\")"; 1022*cdf0e10cSrcweir String sReturn = getConvertedSourceCodeValueOfObject(_sReturnVariableName, sObjectDescription, _aTypeClass, _sTypeName); 1023*cdf0e10cSrcweir sReturn += ";"; 1024*cdf0e10cSrcweir sReturn = "\t" + sReturn; 1025*cdf0e10cSrcweir return sReturn; 1026*cdf0e10cSrcweir // return "\t" + _sReturnVariableName + " = " + _sIncomingObjectName + ".getPropertyValue(\"" + _sPropertyName + "\");"; 1027*cdf0e10cSrcweir } 1028*cdf0e10cSrcweir 1029*cdf0e10cSrcweir 1030*cdf0e10cSrcweir public String getObjectTypeDescription(String _sClassName, boolean _bAsHeader){ 1031*cdf0e10cSrcweir String sReturn = ""; 1032*cdf0e10cSrcweir if (_bAsHeader){ 1033*cdf0e10cSrcweir sReturn = _sClassName; 1034*cdf0e10cSrcweir } 1035*cdf0e10cSrcweir else{ 1036*cdf0e10cSrcweir sReturn = m_oIntrospector.getShortClassName(_sClassName); 1037*cdf0e10cSrcweir } 1038*cdf0e10cSrcweir return sReturn; 1039*cdf0e10cSrcweir } 1040*cdf0e10cSrcweir 1041*cdf0e10cSrcweir 1042*cdf0e10cSrcweir public String getMethodTerminationSourceCode(){ 1043*cdf0e10cSrcweir String sReturn = ""; 1044*cdf0e10cSrcweir int nIndex = 1; 1045*cdf0e10cSrcweir String sExceptionName = "e"; 1046*cdf0e10cSrcweir if (baddExceptionHandling){ 1047*cdf0e10cSrcweir for (int i = 0; i < sExceptions.size(); i++){ 1048*cdf0e10cSrcweir String sCurException = (String) sExceptions.get(i); 1049*cdf0e10cSrcweir if (sReturn.indexOf(sCurException) == -1){ 1050*cdf0e10cSrcweir if (nIndex > 1){ 1051*cdf0e10cSrcweir sExceptionName = "e"+ nIndex; 1052*cdf0e10cSrcweir } 1053*cdf0e10cSrcweir else{ 1054*cdf0e10cSrcweir sReturn +="\n}"; 1055*cdf0e10cSrcweir } 1056*cdf0e10cSrcweir sReturn += "catch (" + sCurException + " " + sExceptionName + "){\n"; 1057*cdf0e10cSrcweir sReturn += "\t" + sExceptionName + ".printStackTrace(System.out);\n"; 1058*cdf0e10cSrcweir sReturn += "\t" + getCommentSign() + "Enter your Code here...\n}"; 1059*cdf0e10cSrcweir nIndex++; 1060*cdf0e10cSrcweir } 1061*cdf0e10cSrcweir } 1062*cdf0e10cSrcweir } 1063*cdf0e10cSrcweir sReturn += "\n}"; 1064*cdf0e10cSrcweir return sReturn; 1065*cdf0e10cSrcweir } 1066*cdf0e10cSrcweir 1067*cdf0e10cSrcweir public String castLiteral(String _sExpression, TypeClass _aTypeClass){ 1068*cdf0e10cSrcweir String sReturn = ""; 1069*cdf0e10cSrcweir switch (_aTypeClass.getValue()){ 1070*cdf0e10cSrcweir case TypeClass.BOOLEAN_value: 1071*cdf0e10cSrcweir sReturn = _sExpression; 1072*cdf0e10cSrcweir break; 1073*cdf0e10cSrcweir case TypeClass.BYTE_value: 1074*cdf0e10cSrcweir sReturn = "(byte) " + _sExpression; 1075*cdf0e10cSrcweir break; 1076*cdf0e10cSrcweir case TypeClass.CHAR_value: 1077*cdf0e10cSrcweir sReturn = "'" + _sExpression + "'"; 1078*cdf0e10cSrcweir break; 1079*cdf0e10cSrcweir case TypeClass.DOUBLE_value: 1080*cdf0e10cSrcweir sReturn = "(double) " + _sExpression; 1081*cdf0e10cSrcweir break; 1082*cdf0e10cSrcweir case TypeClass.FLOAT_value: 1083*cdf0e10cSrcweir sReturn = "(float) " + _sExpression; 1084*cdf0e10cSrcweir break; 1085*cdf0e10cSrcweir case TypeClass.UNSIGNED_SHORT_value: 1086*cdf0e10cSrcweir case TypeClass.SHORT_value: 1087*cdf0e10cSrcweir sReturn = "(short) " + _sExpression; 1088*cdf0e10cSrcweir break; 1089*cdf0e10cSrcweir case TypeClass.STRING_value: 1090*cdf0e10cSrcweir sReturn = "\"" + _sExpression + "\""; 1091*cdf0e10cSrcweir break; 1092*cdf0e10cSrcweir case TypeClass.HYPER_value: 1093*cdf0e10cSrcweir case TypeClass.UNSIGNED_HYPER_value: 1094*cdf0e10cSrcweir sReturn = "(long) " + _sExpression; 1095*cdf0e10cSrcweir break; 1096*cdf0e10cSrcweir case TypeClass.LONG_value: 1097*cdf0e10cSrcweir sReturn = _sExpression; 1098*cdf0e10cSrcweir break; 1099*cdf0e10cSrcweir case TypeClass.ENUM_value: 1100*cdf0e10cSrcweir default: 1101*cdf0e10cSrcweir sReturn = _sExpression; 1102*cdf0e10cSrcweir System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'castliteral()'"); 1103*cdf0e10cSrcweir } 1104*cdf0e10cSrcweir return sReturn; 1105*cdf0e10cSrcweir } 1106*cdf0e10cSrcweir 1107*cdf0e10cSrcweir 1108*cdf0e10cSrcweir public String getbooleanTypeDescription(){ 1109*cdf0e10cSrcweir return "boolean"; 1110*cdf0e10cSrcweir } 1111*cdf0e10cSrcweir 1112*cdf0e10cSrcweir public String getbyteTypeDescription(){ 1113*cdf0e10cSrcweir return "byte"; 1114*cdf0e10cSrcweir } 1115*cdf0e10cSrcweir 1116*cdf0e10cSrcweir public String getshortTypeDescription(){ 1117*cdf0e10cSrcweir return "short"; 1118*cdf0e10cSrcweir } 1119*cdf0e10cSrcweir 1120*cdf0e10cSrcweir public String getunsignedshortTypeDescription(){ 1121*cdf0e10cSrcweir return "short"; 1122*cdf0e10cSrcweir } 1123*cdf0e10cSrcweir 1124*cdf0e10cSrcweir public String getlongTypeDescription(){ 1125*cdf0e10cSrcweir return "int"; 1126*cdf0e10cSrcweir } 1127*cdf0e10cSrcweir 1128*cdf0e10cSrcweir public String getunsignedlongTypeDescription(){ 1129*cdf0e10cSrcweir return "int"; 1130*cdf0e10cSrcweir } 1131*cdf0e10cSrcweir 1132*cdf0e10cSrcweir public String gethyperTypeDescription(){ 1133*cdf0e10cSrcweir return "long"; 1134*cdf0e10cSrcweir } 1135*cdf0e10cSrcweir 1136*cdf0e10cSrcweir public String getunsignedhyperTypeDescription(){ 1137*cdf0e10cSrcweir return "long"; 1138*cdf0e10cSrcweir } 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir public String getfloatTypeDescription(){ 1141*cdf0e10cSrcweir return "float"; 1142*cdf0e10cSrcweir } 1143*cdf0e10cSrcweir 1144*cdf0e10cSrcweir public String getdoubleTypeDescription(){ 1145*cdf0e10cSrcweir return "double"; 1146*cdf0e10cSrcweir } 1147*cdf0e10cSrcweir 1148*cdf0e10cSrcweir public String getcharTypeDescription(){ 1149*cdf0e10cSrcweir return "char"; 1150*cdf0e10cSrcweir } 1151*cdf0e10cSrcweir 1152*cdf0e10cSrcweir public String getstringTypeDescription(boolean _bAsHeaderSourceCode){ 1153*cdf0e10cSrcweir if (_bAsHeaderSourceCode){ 1154*cdf0e10cSrcweir return ""; 1155*cdf0e10cSrcweir } 1156*cdf0e10cSrcweir else{ 1157*cdf0e10cSrcweir return "String"; 1158*cdf0e10cSrcweir } 1159*cdf0e10cSrcweir } 1160*cdf0e10cSrcweir 1161*cdf0e10cSrcweir public String gettypeTypeDescription(boolean _bAsHeaderSourceCode){ 1162*cdf0e10cSrcweir if (_bAsHeaderSourceCode){ 1163*cdf0e10cSrcweir return "com.sun.star.uno.Type"; 1164*cdf0e10cSrcweir } 1165*cdf0e10cSrcweir else{ 1166*cdf0e10cSrcweir return "Type"; 1167*cdf0e10cSrcweir } 1168*cdf0e10cSrcweir } 1169*cdf0e10cSrcweir 1170*cdf0e10cSrcweir public String getanyTypeDescription(boolean _bAsHeaderSourceCode){ 1171*cdf0e10cSrcweir if (_bAsHeaderSourceCode){ 1172*cdf0e10cSrcweir return ""; 1173*cdf0e10cSrcweir } 1174*cdf0e10cSrcweir else{ 1175*cdf0e10cSrcweir return "Object"; 1176*cdf0e10cSrcweir } 1177*cdf0e10cSrcweir } 1178*cdf0e10cSrcweir 1179*cdf0e10cSrcweir 1180*cdf0e10cSrcweir public String getStringValue(String _sValue){ 1181*cdf0e10cSrcweir return _sValue; 1182*cdf0e10cSrcweir } 1183*cdf0e10cSrcweir 1184*cdf0e10cSrcweir 1185*cdf0e10cSrcweir public String getVariableDeclaration(String _sTypeString, String _sVariableName, boolean _bIsArray, TypeClass _aTypeClass, boolean _bInitialize){ 1186*cdf0e10cSrcweir String sReturn = ""; 1187*cdf0e10cSrcweir if (_bIsArray){ 1188*cdf0e10cSrcweir sReturn = _sTypeString + "[] " + _sVariableName; 1189*cdf0e10cSrcweir } 1190*cdf0e10cSrcweir else{ 1191*cdf0e10cSrcweir sReturn = _sTypeString + " " + _sVariableName; 1192*cdf0e10cSrcweir } 1193*cdf0e10cSrcweir return sReturn; 1194*cdf0e10cSrcweir } 1195*cdf0e10cSrcweir 1196*cdf0e10cSrcweir 1197*cdf0e10cSrcweir public String getArrayDeclaration(String _sVariableDeclaration){ 1198*cdf0e10cSrcweir String sReturn = ""; 1199*cdf0e10cSrcweir String[] sDeclarations = _sVariableDeclaration.split(" "); 1200*cdf0e10cSrcweir for (int i = 0; i< sDeclarations.length;i++){ 1201*cdf0e10cSrcweir sReturn += sDeclarations[i]; 1202*cdf0e10cSrcweir if (i == 0){ 1203*cdf0e10cSrcweir sReturn += "[]"; 1204*cdf0e10cSrcweir } 1205*cdf0e10cSrcweir if (i < (sDeclarations.length -1)){ 1206*cdf0e10cSrcweir sReturn += " "; 1207*cdf0e10cSrcweir } 1208*cdf0e10cSrcweir } 1209*cdf0e10cSrcweir return sReturn; 1210*cdf0e10cSrcweir } 1211*cdf0e10cSrcweir 1212*cdf0e10cSrcweir public String getCommentSign(){ 1213*cdf0e10cSrcweir return "//"; 1214*cdf0e10cSrcweir } 1215*cdf0e10cSrcweir } 1216*cdf0e10cSrcweir 1217*cdf0e10cSrcweir 1218*cdf0e10cSrcweir public class BasicCodeGenerator implements XLanguageSourceCodeGenerator{ 1219*cdf0e10cSrcweir String sStatementsCode = ""; 1220*cdf0e10cSrcweir 1221*cdf0e10cSrcweir public BasicCodeGenerator(){ 1222*cdf0e10cSrcweir } 1223*cdf0e10cSrcweir 1224*cdf0e10cSrcweir public String getHeaderSourceCode(Object _oUnoObject, String _sClassName, TypeClass _aTypeClass){ 1225*cdf0e10cSrcweir String sHeaderStatement = ""; 1226*cdf0e10cSrcweir return sHeaderStatement; 1227*cdf0e10cSrcweir } 1228*cdf0e10cSrcweir 1229*cdf0e10cSrcweir public String getFinalHeaderStatements(){ 1230*cdf0e10cSrcweir return ""; 1231*cdf0e10cSrcweir } 1232*cdf0e10cSrcweir 1233*cdf0e10cSrcweir public String getMainMethodSignatureSourceCode(XUnoNode _oUnoNode, String _soReturnObjectDescription){ 1234*cdf0e10cSrcweir //TODO try to use + _oUnoNode.getClassName() instead of the hack 1235*cdf0e10cSrcweir return "Sub Main(" + _soReturnObjectDescription + " as " + getanyTypeDescription(false) + ")"; 1236*cdf0e10cSrcweir } 1237*cdf0e10cSrcweir 1238*cdf0e10cSrcweir public boolean needsqueryInterface(){ 1239*cdf0e10cSrcweir return false; 1240*cdf0e10cSrcweir } 1241*cdf0e10cSrcweir 1242*cdf0e10cSrcweir public void assignqueryInterfaceHeaderSourceCode(){ 1243*cdf0e10cSrcweir } 1244*cdf0e10cSrcweir 1245*cdf0e10cSrcweir public String getMethodSeparator(){ 1246*cdf0e10cSrcweir return "."; 1247*cdf0e10cSrcweir } 1248*cdf0e10cSrcweir 1249*cdf0e10cSrcweir 1250*cdf0e10cSrcweir public String getqueryInterfaceSourceCode(String _sClassName, String _sReturnVariableName, String _sIncomingObjectName){ 1251*cdf0e10cSrcweir return _sIncomingObjectName; 1252*cdf0e10cSrcweir } 1253*cdf0e10cSrcweir 1254*cdf0e10cSrcweir 1255*cdf0e10cSrcweir public String getPropertyValueGetterSourceCode(String _sPropertyName, String _sReturnVariableName, String _sIncomingObjectName, TypeClass _aTypeClass, String _sTypeName){ 1256*cdf0e10cSrcweir return "\t" + _sReturnVariableName + " = " + _sIncomingObjectName + "." + _sPropertyName; 1257*cdf0e10cSrcweir } 1258*cdf0e10cSrcweir 1259*cdf0e10cSrcweir 1260*cdf0e10cSrcweir public String getStructSourceCode(String _sReturnVariableDescription, String _sObjectDescription, String _sMember){ 1261*cdf0e10cSrcweir return getPropertyValueGetterSourceCode(_sMember, _sReturnVariableDescription, _sObjectDescription, null, "" ); 1262*cdf0e10cSrcweir } 1263*cdf0e10cSrcweir 1264*cdf0e10cSrcweir public String getConvertedSourceCodeValueOfObject(String _sReturnVariableName, String _sObjectDescription, TypeClass _aTypeClass, String _sTypeName){ 1265*cdf0e10cSrcweir return _sReturnVariableName + " = " + _sObjectDescription; 1266*cdf0e10cSrcweir } 1267*cdf0e10cSrcweir 1268*cdf0e10cSrcweir 1269*cdf0e10cSrcweir public String getObjectTypeDescription(String _sClassName, boolean _bAsHeader){ 1270*cdf0e10cSrcweir return "Object"; 1271*cdf0e10cSrcweir } 1272*cdf0e10cSrcweir 1273*cdf0e10cSrcweir 1274*cdf0e10cSrcweir public String getMethodTerminationSourceCode(){ 1275*cdf0e10cSrcweir return "\nEnd Sub\n"; 1276*cdf0e10cSrcweir } 1277*cdf0e10cSrcweir 1278*cdf0e10cSrcweir 1279*cdf0e10cSrcweir public String castLiteral(String _sExpression, TypeClass _aTypeClass){ 1280*cdf0e10cSrcweir String sReturn = ""; 1281*cdf0e10cSrcweir switch (_aTypeClass.getValue()){ 1282*cdf0e10cSrcweir case TypeClass.BOOLEAN_value: 1283*cdf0e10cSrcweir case TypeClass.BYTE_value: 1284*cdf0e10cSrcweir case TypeClass.DOUBLE_value: 1285*cdf0e10cSrcweir case TypeClass.FLOAT_value: 1286*cdf0e10cSrcweir case TypeClass.UNSIGNED_SHORT_value: 1287*cdf0e10cSrcweir case TypeClass.SHORT_value: 1288*cdf0e10cSrcweir case TypeClass.LONG_value: 1289*cdf0e10cSrcweir case TypeClass.UNSIGNED_LONG_value: 1290*cdf0e10cSrcweir case TypeClass.HYPER_value: 1291*cdf0e10cSrcweir case TypeClass.UNSIGNED_HYPER_value: 1292*cdf0e10cSrcweir sReturn = _sExpression; 1293*cdf0e10cSrcweir break; 1294*cdf0e10cSrcweir case TypeClass.CHAR_value: 1295*cdf0e10cSrcweir case TypeClass.STRING_value: 1296*cdf0e10cSrcweir sReturn = "\"" +_sExpression + "\""; 1297*cdf0e10cSrcweir break; 1298*cdf0e10cSrcweir case TypeClass.ENUM_value: 1299*cdf0e10cSrcweir default: 1300*cdf0e10cSrcweir sReturn = _sExpression; 1301*cdf0e10cSrcweir System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'castliteral()'"); 1302*cdf0e10cSrcweir } 1303*cdf0e10cSrcweir return sReturn; 1304*cdf0e10cSrcweir } 1305*cdf0e10cSrcweir 1306*cdf0e10cSrcweir 1307*cdf0e10cSrcweir 1308*cdf0e10cSrcweir public String getbooleanTypeDescription(){ 1309*cdf0e10cSrcweir return "Boolean"; 1310*cdf0e10cSrcweir } 1311*cdf0e10cSrcweir 1312*cdf0e10cSrcweir public String getbyteTypeDescription(){ 1313*cdf0e10cSrcweir return "Integer"; 1314*cdf0e10cSrcweir } 1315*cdf0e10cSrcweir 1316*cdf0e10cSrcweir public String getshortTypeDescription(){ 1317*cdf0e10cSrcweir return "Integer"; 1318*cdf0e10cSrcweir } 1319*cdf0e10cSrcweir 1320*cdf0e10cSrcweir public String getunsignedshortTypeDescription(){ 1321*cdf0e10cSrcweir return "Integer"; 1322*cdf0e10cSrcweir } 1323*cdf0e10cSrcweir 1324*cdf0e10cSrcweir public String getlongTypeDescription(){ 1325*cdf0e10cSrcweir return "Integer"; 1326*cdf0e10cSrcweir } 1327*cdf0e10cSrcweir 1328*cdf0e10cSrcweir public String getunsignedlongTypeDescription(){ 1329*cdf0e10cSrcweir return "Long"; 1330*cdf0e10cSrcweir } 1331*cdf0e10cSrcweir 1332*cdf0e10cSrcweir public String gethyperTypeDescription(){ 1333*cdf0e10cSrcweir return "Long"; 1334*cdf0e10cSrcweir } 1335*cdf0e10cSrcweir 1336*cdf0e10cSrcweir public String getunsignedhyperTypeDescription(){ 1337*cdf0e10cSrcweir return "Long"; 1338*cdf0e10cSrcweir } 1339*cdf0e10cSrcweir 1340*cdf0e10cSrcweir public String getfloatTypeDescription(){ 1341*cdf0e10cSrcweir return "Double"; 1342*cdf0e10cSrcweir } 1343*cdf0e10cSrcweir 1344*cdf0e10cSrcweir public String getdoubleTypeDescription(){ 1345*cdf0e10cSrcweir return "Double"; 1346*cdf0e10cSrcweir } 1347*cdf0e10cSrcweir 1348*cdf0e10cSrcweir public String getcharTypeDescription(){ 1349*cdf0e10cSrcweir return "String"; 1350*cdf0e10cSrcweir } 1351*cdf0e10cSrcweir 1352*cdf0e10cSrcweir public String getstringTypeDescription(boolean _bAsHeaderSourceCode){ 1353*cdf0e10cSrcweir if (_bAsHeaderSourceCode){ 1354*cdf0e10cSrcweir return ""; 1355*cdf0e10cSrcweir } 1356*cdf0e10cSrcweir else{ 1357*cdf0e10cSrcweir return "String"; 1358*cdf0e10cSrcweir } 1359*cdf0e10cSrcweir } 1360*cdf0e10cSrcweir 1361*cdf0e10cSrcweir public String gettypeTypeDescription(boolean _bAsHeaderSourceCode){ 1362*cdf0e10cSrcweir if (_bAsHeaderSourceCode){ 1363*cdf0e10cSrcweir return ""; 1364*cdf0e10cSrcweir } 1365*cdf0e10cSrcweir else{ 1366*cdf0e10cSrcweir return "Object"; 1367*cdf0e10cSrcweir } 1368*cdf0e10cSrcweir } 1369*cdf0e10cSrcweir 1370*cdf0e10cSrcweir public String getanyTypeDescription(boolean _bAsHeaderSourceCode){ 1371*cdf0e10cSrcweir if (_bAsHeaderSourceCode){ 1372*cdf0e10cSrcweir return ""; 1373*cdf0e10cSrcweir } 1374*cdf0e10cSrcweir else{ 1375*cdf0e10cSrcweir return "Object"; 1376*cdf0e10cSrcweir } 1377*cdf0e10cSrcweir } 1378*cdf0e10cSrcweir 1379*cdf0e10cSrcweir public String getStatementTerminationCharacter(){ 1380*cdf0e10cSrcweir return ""; 1381*cdf0e10cSrcweir } 1382*cdf0e10cSrcweir 1383*cdf0e10cSrcweir 1384*cdf0e10cSrcweir public String getVariableDeclaration(String _sTypeString, String _sVariableName, boolean bIsArray, TypeClass _aTypeClass, boolean _bInitialize){ 1385*cdf0e10cSrcweir String sReturn = ""; 1386*cdf0e10cSrcweir if (bIsArray){ 1387*cdf0e10cSrcweir sReturn = "Dim " + _sVariableName + "() as " + _sTypeString + "\n\t" + _sVariableName; 1388*cdf0e10cSrcweir } 1389*cdf0e10cSrcweir else{ 1390*cdf0e10cSrcweir sReturn = "Dim " + _sVariableName + " as " + _sTypeString + "\n\t" + _sVariableName; 1391*cdf0e10cSrcweir } 1392*cdf0e10cSrcweir return sReturn; 1393*cdf0e10cSrcweir } 1394*cdf0e10cSrcweir 1395*cdf0e10cSrcweir 1396*cdf0e10cSrcweir public String getStringValue(String _sValue){ 1397*cdf0e10cSrcweir return _sValue; 1398*cdf0e10cSrcweir } 1399*cdf0e10cSrcweir 1400*cdf0e10cSrcweir 1401*cdf0e10cSrcweir public String getArrayDeclaration(String _sVariableDeclaration){ 1402*cdf0e10cSrcweir String sReturn = ""; 1403*cdf0e10cSrcweir String[] sDeclarations = _sVariableDeclaration.split(" "); 1404*cdf0e10cSrcweir for (int i = 0; i< sDeclarations.length;i++){ 1405*cdf0e10cSrcweir sReturn += sDeclarations[i]; 1406*cdf0e10cSrcweir if (i == 0){ 1407*cdf0e10cSrcweir sReturn += "[]"; 1408*cdf0e10cSrcweir } 1409*cdf0e10cSrcweir if (i < (sDeclarations.length -1)){ 1410*cdf0e10cSrcweir sReturn += " "; 1411*cdf0e10cSrcweir } 1412*cdf0e10cSrcweir } 1413*cdf0e10cSrcweir return sReturn; 1414*cdf0e10cSrcweir } 1415*cdf0e10cSrcweir 1416*cdf0e10cSrcweir public String getCommentSign(){ 1417*cdf0e10cSrcweir return "'"; 1418*cdf0e10cSrcweir } 1419*cdf0e10cSrcweir 1420*cdf0e10cSrcweir } 1421*cdf0e10cSrcweir 1422*cdf0e10cSrcweir public class CPlusPlusCodeGenerator implements XLanguageSourceCodeGenerator{ 1423*cdf0e10cSrcweir String sStatementsCode = ""; 1424*cdf0e10cSrcweir boolean bIncludeStringHeader = false; 1425*cdf0e10cSrcweir boolean bIncludeAny = false; 1426*cdf0e10cSrcweir boolean bIncludeSequenceHeader = false; 1427*cdf0e10cSrcweir 1428*cdf0e10cSrcweir public CPlusPlusCodeGenerator(){ 1429*cdf0e10cSrcweir } 1430*cdf0e10cSrcweir 1431*cdf0e10cSrcweir private String getCSSNameSpaceString(){ 1432*cdf0e10cSrcweir return "css"; 1433*cdf0e10cSrcweir } 1434*cdf0e10cSrcweir 1435*cdf0e10cSrcweir public String getStatementTerminationCharacter(){ 1436*cdf0e10cSrcweir return ";"; 1437*cdf0e10cSrcweir } 1438*cdf0e10cSrcweir 1439*cdf0e10cSrcweir 1440*cdf0e10cSrcweir public String getHeaderSourceCode(Object _oUnoObject, String _sClassName, TypeClass _aTypeClass){ 1441*cdf0e10cSrcweir String sClassName = _sClassName; 1442*cdf0e10cSrcweir String sHeaderStatement = ""; 1443*cdf0e10cSrcweir if (_oUnoObject != null){ 1444*cdf0e10cSrcweir if (!m_oIntrospector.isObjectPrimitive(_oUnoObject)){ 1445*cdf0e10cSrcweir if (m_oIntrospector.isObjectSequence(_oUnoObject)){ 1446*cdf0e10cSrcweir XTypeDescription xTypeDescription = m_oIntrospector.getReferencedType(sClassName); 1447*cdf0e10cSrcweir if (xTypeDescription != null){ 1448*cdf0e10cSrcweir if (!m_oIntrospector.isPrimitive(xTypeDescription.getTypeClass())){ 1449*cdf0e10cSrcweir sClassName = getTypeString(xTypeDescription.getName(), xTypeDescription.getTypeClass(), true); 1450*cdf0e10cSrcweir } 1451*cdf0e10cSrcweir // primitive Types are not supposed to turn up in the import section... 1452*cdf0e10cSrcweir else{ 1453*cdf0e10cSrcweir sClassName = ""; 1454*cdf0e10cSrcweir } 1455*cdf0e10cSrcweir } 1456*cdf0e10cSrcweir } 1457*cdf0e10cSrcweir else{ 1458*cdf0e10cSrcweir sClassName = getTypeString(_sClassName, _aTypeClass, true); 1459*cdf0e10cSrcweir } 1460*cdf0e10cSrcweir if (!sClassName.equals("")){ 1461*cdf0e10cSrcweir sHeaderStatement = getHeaderOfClass(sClassName); 1462*cdf0e10cSrcweir } 1463*cdf0e10cSrcweir } 1464*cdf0e10cSrcweir } 1465*cdf0e10cSrcweir return sHeaderStatement; 1466*cdf0e10cSrcweir } 1467*cdf0e10cSrcweir 1468*cdf0e10cSrcweir 1469*cdf0e10cSrcweir 1470*cdf0e10cSrcweir public String getFinalHeaderStatements(){ 1471*cdf0e10cSrcweir String sReturn = ""; 1472*cdf0e10cSrcweir sReturn += "\nnamespace " + getCSSNameSpaceString() + " = com::sun::star;\n"; 1473*cdf0e10cSrcweir sReturn += "using namespace rtl;\n"; 1474*cdf0e10cSrcweir return sReturn; 1475*cdf0e10cSrcweir } 1476*cdf0e10cSrcweir 1477*cdf0e10cSrcweir 1478*cdf0e10cSrcweir private String getHeaderOfClass(String _sClassName){ 1479*cdf0e10cSrcweir return "#include \"" + _sClassName.replace('.', '/') + ".hpp\"\n"; // #include <com/sun/star/uno/XComponentContext.hpp> 1480*cdf0e10cSrcweir } 1481*cdf0e10cSrcweir 1482*cdf0e10cSrcweir 1483*cdf0e10cSrcweir 1484*cdf0e10cSrcweir public void assignqueryInterfaceHeaderSourceCode(){ 1485*cdf0e10cSrcweir sHeaderStatements.add("#include \"sal/config.h\"\n"); 1486*cdf0e10cSrcweir sHeaderStatements.add("#include \"sal/types.h\"\n"); 1487*cdf0e10cSrcweir if (bIncludeStringHeader){ 1488*cdf0e10cSrcweir sHeaderStatements.add("#include \"rtl/ustring.hxx\"\n"); 1489*cdf0e10cSrcweir } 1490*cdf0e10cSrcweir sHeaderStatements.add("#include \"com/sun/star/uno/Reference.hxx\"\n"); 1491*cdf0e10cSrcweir if (bIncludeSequenceHeader){ 1492*cdf0e10cSrcweir sHeaderStatements.add("#include \"com/sun/star/uno/Sequence.hxx\"\n"); 1493*cdf0e10cSrcweir } 1494*cdf0e10cSrcweir sHeaderStatements.add(getHeaderOfClass("com.sun.star.uno.XInterface")); 1495*cdf0e10cSrcweir if (bIncludeAny){ 1496*cdf0e10cSrcweir sHeaderStatements.add(getHeaderOfClass("com.sun.star.uno.Any")); 1497*cdf0e10cSrcweir } 1498*cdf0e10cSrcweir } 1499*cdf0e10cSrcweir 1500*cdf0e10cSrcweir 1501*cdf0e10cSrcweir public String getMainMethodSignatureSourceCode(XUnoNode _oUnoNode, String _soReturnObjectDescription){ 1502*cdf0e10cSrcweir String sReturn = ""; 1503*cdf0e10cSrcweir sReturn = "void codesnippet(const " + getCSSNameSpaceString() + "::uno::Reference<" + getCSSNameSpaceString() + "::uno::XInterface>& " + _soReturnObjectDescription + " ){"; 1504*cdf0e10cSrcweir int a = 0; 1505*cdf0e10cSrcweir if (!sExceptions.contains("com.sun.star.uno.RuntimeException")){ 1506*cdf0e10cSrcweir sExceptions.add("com.sun.star.uno.RuntimeException"); 1507*cdf0e10cSrcweir } 1508*cdf0e10cSrcweir if (baddExceptionHandling){ 1509*cdf0e10cSrcweir sReturn += "\n//throw "; 1510*cdf0e10cSrcweir for (int i = 0; i < sExceptions.size(); i++){ 1511*cdf0e10cSrcweir String sCurException = (String) sExceptions.get(i); 1512*cdf0e10cSrcweir if (sReturn.indexOf(sCurException) == -1){ 1513*cdf0e10cSrcweir if (a++ > 0){ 1514*cdf0e10cSrcweir sReturn += ", "; 1515*cdf0e10cSrcweir } 1516*cdf0e10cSrcweir sReturn += getObjectTypeDescription(sCurException, false); 1517*cdf0e10cSrcweir 1518*cdf0e10cSrcweir } 1519*cdf0e10cSrcweir } 1520*cdf0e10cSrcweir 1521*cdf0e10cSrcweir } 1522*cdf0e10cSrcweir sReturn += "{"; 1523*cdf0e10cSrcweir return sReturn; 1524*cdf0e10cSrcweir } 1525*cdf0e10cSrcweir 1526*cdf0e10cSrcweir 1527*cdf0e10cSrcweir public boolean needsqueryInterface(){ 1528*cdf0e10cSrcweir return true; 1529*cdf0e10cSrcweir } 1530*cdf0e10cSrcweir 1531*cdf0e10cSrcweir 1532*cdf0e10cSrcweir public String getqueryInterfaceSourceCode(String _sClassName, String _sReturnVariableName, String _sIncomingObjectName){ 1533*cdf0e10cSrcweir return "\t" + _sReturnVariableName + "( " + _sIncomingObjectName + ", " + getCSSNameSpaceString() + "::uno::UNO_QUERY_THROW);\n"; 1534*cdf0e10cSrcweir } 1535*cdf0e10cSrcweir 1536*cdf0e10cSrcweir 1537*cdf0e10cSrcweir public String getPropertyValueGetterSourceCode(String _sPropertyName, String _sReturnVariableName, String _sIncomingObjectName, TypeClass _aTypeClass, String _sTypeName){ 1538*cdf0e10cSrcweir String sFirstLine = "\t"; 1539*cdf0e10cSrcweir String sReturnVariableName = _sReturnVariableName; 1540*cdf0e10cSrcweir // e.g. uno::Any a = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" )) ); 1541*cdf0e10cSrcweir String[] sVarDefinition = _sReturnVariableName.split("="); 1542*cdf0e10cSrcweir if (sVarDefinition.length > 0){ 1543*cdf0e10cSrcweir String sVariable = sVarDefinition[0]; 1544*cdf0e10cSrcweir String[] sVarDeclaration = sVariable.split(" "); 1545*cdf0e10cSrcweir if (sVarDeclaration.length > 0){ 1546*cdf0e10cSrcweir sFirstLine += sReturnVariableName + ";\n"; 1547*cdf0e10cSrcweir sReturnVariableName = sVarDeclaration[sVarDeclaration.length-1]; 1548*cdf0e10cSrcweir } 1549*cdf0e10cSrcweir } 1550*cdf0e10cSrcweir String sObjectDescription = _sIncomingObjectName + "->getPropertyValue(" + getStringValue(_sPropertyName) + ")"; 1551*cdf0e10cSrcweir String sSecondLine = "\t" + getConvertedSourceCodeValueOfObject(sReturnVariableName, sObjectDescription, _aTypeClass, _sTypeName) + ";"; 1552*cdf0e10cSrcweir return sFirstLine + sSecondLine; 1553*cdf0e10cSrcweir } 1554*cdf0e10cSrcweir 1555*cdf0e10cSrcweir 1556*cdf0e10cSrcweir public String getStructSourceCode(String _sReturnVariableDescription, String _sObjectDescription, String _sMember){ 1557*cdf0e10cSrcweir return "\t" + _sReturnVariableDescription + " = " + _sObjectDescription + "->" + _sMember + ";"; 1558*cdf0e10cSrcweir } 1559*cdf0e10cSrcweir 1560*cdf0e10cSrcweir 1561*cdf0e10cSrcweir public String getConvertedSourceCodeValueOfObject(String _sReturnVariableName, String _sObjectDescription, TypeClass _aTypeClass, String _sTypeName){ 1562*cdf0e10cSrcweir // if (m_oIntrospector.isPrimitive(_aTypeClass)){ 1563*cdf0e10cSrcweir return _sObjectDescription + " >>= " + _sReturnVariableName; 1564*cdf0e10cSrcweir // } 1565*cdf0e10cSrcweir // else{ 1566*cdf0e10cSrcweir // return _sReturnVariableName + " = " + _sObjectDescription; 1567*cdf0e10cSrcweir // } 1568*cdf0e10cSrcweir } 1569*cdf0e10cSrcweir 1570*cdf0e10cSrcweir 1571*cdf0e10cSrcweir public String getStringValue(String _sValue){ 1572*cdf0e10cSrcweir bIncludeStringHeader = true; 1573*cdf0e10cSrcweir return "OUString(RTL_CONSTASCII_USTRINGPARAM(\"" + _sValue + "\"))"; 1574*cdf0e10cSrcweir } 1575*cdf0e10cSrcweir 1576*cdf0e10cSrcweir 1577*cdf0e10cSrcweir public String getObjectTypeDescription(String _sClassName, boolean _bAsHeader){ 1578*cdf0e10cSrcweir String sReturn = ""; 1579*cdf0e10cSrcweir if (_bAsHeader){ 1580*cdf0e10cSrcweir sReturn = _sClassName.replace('.', '/'); 1581*cdf0e10cSrcweir } 1582*cdf0e10cSrcweir else{ 1583*cdf0e10cSrcweir String sModuleName = m_oIntrospector.getModuleName(_sClassName); 1584*cdf0e10cSrcweir sModuleName = m_oIntrospector.getShortClassName(sModuleName); 1585*cdf0e10cSrcweir sReturn = getCSSNameSpaceString() + "::" + sModuleName + "::" + m_oIntrospector.getShortClassName(_sClassName); 1586*cdf0e10cSrcweir } 1587*cdf0e10cSrcweir return sReturn; 1588*cdf0e10cSrcweir } 1589*cdf0e10cSrcweir 1590*cdf0e10cSrcweir 1591*cdf0e10cSrcweir public String getMethodTerminationSourceCode(){ 1592*cdf0e10cSrcweir return "\n}"; 1593*cdf0e10cSrcweir } 1594*cdf0e10cSrcweir 1595*cdf0e10cSrcweir public String getMethodSeparator(){ 1596*cdf0e10cSrcweir return "->"; 1597*cdf0e10cSrcweir } 1598*cdf0e10cSrcweir 1599*cdf0e10cSrcweir 1600*cdf0e10cSrcweir public String castLiteral(String _sExpression, TypeClass _aTypeClass){ 1601*cdf0e10cSrcweir String sReturn = ""; 1602*cdf0e10cSrcweir switch (_aTypeClass.getValue()){ 1603*cdf0e10cSrcweir case TypeClass.BOOLEAN_value: 1604*cdf0e10cSrcweir case TypeClass.BYTE_value: 1605*cdf0e10cSrcweir case TypeClass.DOUBLE_value: 1606*cdf0e10cSrcweir case TypeClass.FLOAT_value: 1607*cdf0e10cSrcweir case TypeClass.UNSIGNED_SHORT_value: 1608*cdf0e10cSrcweir case TypeClass.SHORT_value: 1609*cdf0e10cSrcweir case TypeClass.LONG_value: 1610*cdf0e10cSrcweir case TypeClass.UNSIGNED_LONG_value: 1611*cdf0e10cSrcweir case TypeClass.HYPER_value: 1612*cdf0e10cSrcweir case TypeClass.UNSIGNED_HYPER_value: 1613*cdf0e10cSrcweir sReturn = _sExpression; 1614*cdf0e10cSrcweir break; 1615*cdf0e10cSrcweir case TypeClass.CHAR_value: 1616*cdf0e10cSrcweir sReturn = "'" + _sExpression + "'"; 1617*cdf0e10cSrcweir break; 1618*cdf0e10cSrcweir case TypeClass.STRING_value: 1619*cdf0e10cSrcweir sReturn = getStringValue(_sExpression); 1620*cdf0e10cSrcweir break; 1621*cdf0e10cSrcweir case TypeClass.ENUM_value: 1622*cdf0e10cSrcweir default: 1623*cdf0e10cSrcweir sReturn = _sExpression; 1624*cdf0e10cSrcweir System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'castliteral()'"); 1625*cdf0e10cSrcweir } 1626*cdf0e10cSrcweir return sReturn; 1627*cdf0e10cSrcweir } 1628*cdf0e10cSrcweir 1629*cdf0e10cSrcweir public String getbooleanTypeDescription(){ 1630*cdf0e10cSrcweir return "sal_Bool"; 1631*cdf0e10cSrcweir } 1632*cdf0e10cSrcweir 1633*cdf0e10cSrcweir public String getbyteTypeDescription(){ 1634*cdf0e10cSrcweir return "sal_Int8"; 1635*cdf0e10cSrcweir } 1636*cdf0e10cSrcweir 1637*cdf0e10cSrcweir public String getshortTypeDescription(){ 1638*cdf0e10cSrcweir return "sal_Int16"; 1639*cdf0e10cSrcweir } 1640*cdf0e10cSrcweir 1641*cdf0e10cSrcweir public String getunsignedshortTypeDescription(){ 1642*cdf0e10cSrcweir return "sal_uInt16"; 1643*cdf0e10cSrcweir } 1644*cdf0e10cSrcweir 1645*cdf0e10cSrcweir public String getlongTypeDescription(){ 1646*cdf0e10cSrcweir return "sal_Int32"; 1647*cdf0e10cSrcweir } 1648*cdf0e10cSrcweir 1649*cdf0e10cSrcweir public String getunsignedlongTypeDescription(){ 1650*cdf0e10cSrcweir return "sal_uInt32"; 1651*cdf0e10cSrcweir } 1652*cdf0e10cSrcweir 1653*cdf0e10cSrcweir public String gethyperTypeDescription(){ 1654*cdf0e10cSrcweir return "sal_Int64"; 1655*cdf0e10cSrcweir } 1656*cdf0e10cSrcweir 1657*cdf0e10cSrcweir public String getunsignedhyperTypeDescription(){ 1658*cdf0e10cSrcweir return "sal_uInt64"; 1659*cdf0e10cSrcweir } 1660*cdf0e10cSrcweir 1661*cdf0e10cSrcweir public String getfloatTypeDescription(){ 1662*cdf0e10cSrcweir return "float"; 1663*cdf0e10cSrcweir } 1664*cdf0e10cSrcweir 1665*cdf0e10cSrcweir public String getdoubleTypeDescription(){ 1666*cdf0e10cSrcweir return "double"; 1667*cdf0e10cSrcweir } 1668*cdf0e10cSrcweir 1669*cdf0e10cSrcweir public String getcharTypeDescription(){ 1670*cdf0e10cSrcweir return "sal_Unicode"; 1671*cdf0e10cSrcweir } 1672*cdf0e10cSrcweir 1673*cdf0e10cSrcweir public String getstringTypeDescription(boolean _bAsHeaderSourceCode){ 1674*cdf0e10cSrcweir bIncludeStringHeader = true; 1675*cdf0e10cSrcweir if (_bAsHeaderSourceCode){ 1676*cdf0e10cSrcweir return ""; 1677*cdf0e10cSrcweir } 1678*cdf0e10cSrcweir else{ 1679*cdf0e10cSrcweir return "OUString"; 1680*cdf0e10cSrcweir } 1681*cdf0e10cSrcweir } 1682*cdf0e10cSrcweir 1683*cdf0e10cSrcweir public String gettypeTypeDescription(boolean _bAsHeaderSourceCode){ 1684*cdf0e10cSrcweir if (_bAsHeaderSourceCode){ 1685*cdf0e10cSrcweir return "com/sun/star/uno/Type"; 1686*cdf0e10cSrcweir } 1687*cdf0e10cSrcweir else{ 1688*cdf0e10cSrcweir return "Type"; 1689*cdf0e10cSrcweir } 1690*cdf0e10cSrcweir } 1691*cdf0e10cSrcweir 1692*cdf0e10cSrcweir public String getanyTypeDescription(boolean _bAsHeaderSourceCode){ 1693*cdf0e10cSrcweir if (_bAsHeaderSourceCode){ 1694*cdf0e10cSrcweir return "com/sun/star/uno/XInterface"; 1695*cdf0e10cSrcweir } 1696*cdf0e10cSrcweir else{ 1697*cdf0e10cSrcweir return "XInterface"; 1698*cdf0e10cSrcweir } 1699*cdf0e10cSrcweir } 1700*cdf0e10cSrcweir 1701*cdf0e10cSrcweir 1702*cdf0e10cSrcweir public String getVariableDeclaration(String _sTypeString, String _sVariableName, boolean bIsArray, TypeClass _aTypeClass, boolean _bInitialize){ 1703*cdf0e10cSrcweir boolean bIsPrimitive = m_oIntrospector.isPrimitive(_aTypeClass); 1704*cdf0e10cSrcweir 1705*cdf0e10cSrcweir // uno::Reference< frame::XDispatch > m_xDispatch 1706*cdf0e10cSrcweir String sReturn = ""; 1707*cdf0e10cSrcweir if (bIsArray){ 1708*cdf0e10cSrcweir bIncludeSequenceHeader = true; 1709*cdf0e10cSrcweir sReturn = getCSSNameSpaceString() + "::uno::Sequence<" + _sTypeString + "> " + _sVariableName; 1710*cdf0e10cSrcweir } 1711*cdf0e10cSrcweir else{ 1712*cdf0e10cSrcweir if (bIsPrimitive){ 1713*cdf0e10cSrcweir sReturn = _sTypeString + " " + _sVariableName; 1714*cdf0e10cSrcweir if (_bInitialize){ 1715*cdf0e10cSrcweir switch (_aTypeClass.getValue()){ 1716*cdf0e10cSrcweir case TypeClass.BOOLEAN_value: 1717*cdf0e10cSrcweir sReturn = sReturn + " = false"; 1718*cdf0e10cSrcweir break; 1719*cdf0e10cSrcweir case TypeClass.BYTE_value: 1720*cdf0e10cSrcweir case TypeClass.UNSIGNED_SHORT_value: 1721*cdf0e10cSrcweir case TypeClass.SHORT_value: 1722*cdf0e10cSrcweir case TypeClass.LONG_value: 1723*cdf0e10cSrcweir case TypeClass.UNSIGNED_LONG_value: 1724*cdf0e10cSrcweir case TypeClass.HYPER_value: 1725*cdf0e10cSrcweir case TypeClass.UNSIGNED_HYPER_value: 1726*cdf0e10cSrcweir sReturn = sReturn + " = 0"; 1727*cdf0e10cSrcweir break; 1728*cdf0e10cSrcweir case TypeClass.DOUBLE_value: 1729*cdf0e10cSrcweir case TypeClass.FLOAT_value: 1730*cdf0e10cSrcweir sReturn = sReturn + " = 0.0"; 1731*cdf0e10cSrcweir break; 1732*cdf0e10cSrcweir case TypeClass.CHAR_value: 1733*cdf0e10cSrcweir sReturn = sReturn + "'0'"; 1734*cdf0e10cSrcweir break; 1735*cdf0e10cSrcweir case TypeClass.STRING_value: 1736*cdf0e10cSrcweir sReturn = _sTypeString + " " + _sVariableName; 1737*cdf0e10cSrcweir break; 1738*cdf0e10cSrcweir default: 1739*cdf0e10cSrcweir sReturn = _sTypeString + " " + _sVariableName; 1740*cdf0e10cSrcweir System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'getVariableDeclaration()'"); 1741*cdf0e10cSrcweir } 1742*cdf0e10cSrcweir } 1743*cdf0e10cSrcweir } 1744*cdf0e10cSrcweir else{ 1745*cdf0e10cSrcweir sReturn = getCSSNameSpaceString() + "::uno::Reference<" + _sTypeString + "> " +_sVariableName; 1746*cdf0e10cSrcweir } 1747*cdf0e10cSrcweir } 1748*cdf0e10cSrcweir return sReturn; 1749*cdf0e10cSrcweir } 1750*cdf0e10cSrcweir 1751*cdf0e10cSrcweir public String getArrayDeclaration(String _sVariableDeclaration){ 1752*cdf0e10cSrcweir this.bIncludeSequenceHeader = true; 1753*cdf0e10cSrcweir String sReturn = ""; 1754*cdf0e10cSrcweir String[] sDeclarations = _sVariableDeclaration.split(" "); 1755*cdf0e10cSrcweir if (sDeclarations.length == 2){ 1756*cdf0e10cSrcweir sReturn = getCSSNameSpaceString() +"::uno::Sequence<" + sDeclarations[1] + ">"; 1757*cdf0e10cSrcweir } 1758*cdf0e10cSrcweir return sReturn; 1759*cdf0e10cSrcweir } 1760*cdf0e10cSrcweir 1761*cdf0e10cSrcweir public String getCommentSign(){ 1762*cdf0e10cSrcweir return "//"; 1763*cdf0e10cSrcweir } 1764*cdf0e10cSrcweir 1765*cdf0e10cSrcweir } 1766*cdf0e10cSrcweir } 1767