summaryrefslogtreecommitdiff
path: root/src/org/openoffice/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/openoffice/tools')
-rw-r--r--src/org/openoffice/tools/LanguageHelper.java63
-rw-r--r--src/org/openoffice/tools/OptionsHelper.java7
-rw-r--r--src/org/openoffice/tools/SkeletonMaker.java109
-rw-r--r--src/org/openoffice/tools/TypeChecker.java129
-rw-r--r--src/org/openoffice/tools/language/Language.java106
-rw-r--r--src/org/openoffice/tools/language/LanguageHelper.java68
-rw-r--r--src/org/openoffice/tools/language/LanguageTemplateLoader.java33
-rw-r--r--src/org/openoffice/tools/tests/LanguageHelperTest.java91
-rw-r--r--src/org/openoffice/tools/types/TypeManager.java2
9 files changed, 484 insertions, 124 deletions
diff --git a/src/org/openoffice/tools/LanguageHelper.java b/src/org/openoffice/tools/LanguageHelper.java
deleted file mode 100644
index 5a702d8..0000000
--- a/src/org/openoffice/tools/LanguageHelper.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.openoffice.tools;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FilenameFilter;
-import java.net.URISyntaxException;
-import java.util.Properties;
-
-public class LanguageHelper {
-
- private static final String LANGS_DIR = "langs";
- private static final String DESCRIPTION_FILENAME = "lang.properties";
-
- public static String[] getLanguages() {
- File langsDir = getLangsDir();
-
- String[] langs = langsDir.list( new FilenameFilter() {
-
- @Override
- public boolean accept(File pDir, String pName) {
- return !pName.startsWith(".");
- }
- });
-
- return langs;
- }
-
- public static String getDescription( String pLang ) {
- String description = null;
- File langsDir = getLangsDir();
- File langDir = new File( langsDir, pLang );
-
- if ( langDir.isDirectory() ) {
- File descFile = new File( langDir, DESCRIPTION_FILENAME );
- if ( descFile.isFile() && descFile.canRead() ) {
- Properties props = new Properties( );
- FileInputStream in = null;
- try {
- in = new FileInputStream( descFile );
- props.load( in );
- description = props.getProperty( "description" );
- } catch ( Exception e ) {
- } finally {
- try { in.close(); } catch ( Exception e) { };
- }
- }
- }
-
- return description;
- }
-
- private static File getLangsDir( ) {
- File dir = null;
- try {
- File jarFile = new File(LanguageHelper.class.getProtectionDomain()
- .getCodeSource().getLocation().toURI());
- dir = new File( jarFile.getParentFile(), LANGS_DIR );
-
- } catch (URISyntaxException e) {
- }
- return dir;
- }
-}
diff --git a/src/org/openoffice/tools/OptionsHelper.java b/src/org/openoffice/tools/OptionsHelper.java
index 01633d2..c1adcf9 100644
--- a/src/org/openoffice/tools/OptionsHelper.java
+++ b/src/org/openoffice/tools/OptionsHelper.java
@@ -3,6 +3,8 @@ package org.openoffice.tools;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionGroup;
import org.apache.commons.cli.Options;
+import org.openoffice.tools.language.Language;
+import org.openoffice.tools.language.LanguageHelper;
import org.openoffice.tools.options.Command;
import org.openoffice.tools.options.SubCommand;
@@ -25,9 +27,10 @@ public class OptionsHelper {
Options generalOptions = new Options();
OptionGroup langGroup = new OptionGroup();
- String[] langs = LanguageHelper.getLanguages( );
+ String[] langs = LanguageHelper.getLanguagesIds( );
for (String lang : langs) {
- Option langOpt = new Option( lang, false, LanguageHelper.getDescription( lang ) );
+ Language langDef = LanguageHelper.getLanguage( lang );
+ Option langOpt = new Option( lang, false, langDef.getDescription() );
langGroup.addOption( langOpt );
}
langGroup.setRequired( true );
diff --git a/src/org/openoffice/tools/SkeletonMaker.java b/src/org/openoffice/tools/SkeletonMaker.java
index ad319b6..febb932 100644
--- a/src/org/openoffice/tools/SkeletonMaker.java
+++ b/src/org/openoffice/tools/SkeletonMaker.java
@@ -1,67 +1,55 @@
package org.openoffice.tools;
-import java.util.ArrayList;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
+import org.openoffice.tools.language.Language;
+import org.openoffice.tools.language.LanguageHelper;
import org.openoffice.tools.options.Command;
import org.openoffice.tools.options.HelpFormatter;
import org.openoffice.tools.options.SubcommandLine;
import org.openoffice.tools.types.TypeManager;
-import com.sun.star.reflection.XInterfaceAttributeTypeDescription2;
-import com.sun.star.reflection.XPropertyTypeDescription;
+import freemarker.template.Template;
public class SkeletonMaker {
- private static final int MAX_INTERFACES = 12;
-
+ // The file template names
+ public static final String COMPONENT = "component.tpl";
+
public static void generateComponent( CommandLine pArgs ) {
TypeManager manager = null;
+ PrintWriter writer = null;
try {
- // Get the language first
- String lang = getLanguage( pArgs );
-
// Load the types manager
String inifile = pArgs.getOptionValue( "unoinstall" );
manager = new TypeManager( inifile );
manager.initRegistries( pArgs.getOptionValues( "l" ) );
- // Check the types
- String[] types = pArgs.getOptionValues( "t" );
- ArrayList<String> interfaces = new ArrayList<String>();
- ArrayList<String> services = new ArrayList<String>();
- ArrayList<XPropertyTypeDescription> members = new ArrayList<XPropertyTypeDescription>();
-
- // Get the service, interfaces and members from the types
- for (String type : types) {
- manager.checkType( type, services, interfaces, members );
- }
-
- // TODO For ProtocolHandler case, check the frame.ProtocolHandler and frame.XDispatch types
+ // Extract all the informations from the types
+ TypeChecker checker = new TypeChecker( manager );
+ checker.check( pArgs );
- // Check for the property helper
- ArrayList<XInterfaceAttributeTypeDescription2> attributes = new ArrayList<XInterfaceAttributeTypeDescription2>();
- ArrayList<String> propinterfaces = new ArrayList<String>();
- String propertyHelper = manager.checkPropertyHelper( pArgs, services, interfaces, attributes, propinterfaces );
+ // Print everything
+ writer = getWriter( pArgs );
- // Check the default interfaces
- checkDefaultInterfaces( interfaces, services, propertyHelper );
-
- if ( interfaces.size() > MAX_INTERFACES ) {
- throw new DumpException( "The skeletonmaker supports components with 12 interfaces only (limitation of the UNO implementation helpers)!" );
- }
-
- boolean supportXComp = manager.checkXComponentSupport( interfaces );
-
- // TODO Print everything
+ Language lang = getLanguage( pArgs );
+ Template tpl = lang.getTemplate( COMPONENT );
+ tpl.process( checker.getTemplateModel( ), writer );
+ writer.flush();
} catch ( Exception e ) {
e.printStackTrace();
} finally {
+ // Close the file stream if possible
+ try { writer.close(); } catch ( Exception e ) { }
+
// Close the running OOo
if ( manager != null ) {
manager.dispose();
@@ -69,22 +57,47 @@ public class SkeletonMaker {
}
}
- private static void checkDefaultInterfaces(ArrayList<String> pInterfaces,
- ArrayList<String> pServices, String pPropertyHelper) {
+ private static PrintWriter getWriter( CommandLine pArgs ) throws IOException {
+ PrintWriter writer = new PrintWriter( System.out );
+ String outPath = pArgs.getOptionValue( "o" );
+ if ( outPath != null && !outPath.equals( "stdout" ) ) {
+ String implName = pArgs.getOptionValue( "n" ).replace( '.', '/' );
+ Language lang = getLanguage( pArgs );
+ String ext = lang.getExtension();
+
+ String targetPath = getFilenameFromType( outPath, implName, ext );
+
+ File out = new File( targetPath );
+ writer = new PrintWriter( out );
+ }
- if ( pServices.isEmpty() ) {
- pInterfaces.remove( "com.sun.star.lang.XServiceInfo" );
+ return writer;
+ }
+
+ private static String getFilenameFromType(String pOutPath,
+ String pImplName, String pExt) {
+ StringBuffer buf = new StringBuffer();
+ if ( pOutPath.isEmpty() ) {
+ buf.append( "." );
} else {
- if ( !pInterfaces.contains( "com.sun.star.lang.XServiceInfo" ) ) {
- pInterfaces.add( "com.sun.star.lang.XServiceInfo" );
- }
+ buf.append( pOutPath );
}
- if ( pPropertyHelper.equals( TypeManager.NOPROPERTYHELPER ) ) {
- pInterfaces.remove( "com.sun.star.beans.XPropertySet" );
- pInterfaces.remove( "com.sun.star.beans.XFastPropertySet" );
- pInterfaces.remove( "com.sun.star.beans.XPropertyAccess" );
+ String sep = System.getProperty( "file.separator" );
+
+ buf.append( sep );
+ buf.append( pImplName );
+ buf.append( pExt );
+
+ String filename = buf.toString();
+ // Clean up the separators
+ if ( sep.equals( "/" ) ) {
+ filename = filename.replace( "\\\\", sep );
+ } else {
+ filename = filename.replace( "/", sep );
}
+
+ return filename;
}
public static void main(String[] args) {
@@ -108,8 +121,8 @@ public class SkeletonMaker {
}
}
- private static String getLanguage( CommandLine pArgs ) {
- String[] langs = LanguageHelper.getLanguages();
+ private static Language getLanguage( CommandLine pArgs ) {
+ String[] langs = LanguageHelper.getLanguagesIds();
String lang = null;
int i = 0;
while ( lang == null && i < langs.length ) {
@@ -118,6 +131,6 @@ public class SkeletonMaker {
}
i++;
}
- return lang;
+ return LanguageHelper.getLanguage( lang );
}
}
diff --git a/src/org/openoffice/tools/TypeChecker.java b/src/org/openoffice/tools/TypeChecker.java
new file mode 100644
index 0000000..30c88af
--- /dev/null
+++ b/src/org/openoffice/tools/TypeChecker.java
@@ -0,0 +1,129 @@
+package org.openoffice.tools;
+
+import java.util.ArrayList;
+
+import org.apache.commons.cli.CommandLine;
+import org.openoffice.tools.types.TypeManager;
+
+import com.sun.star.reflection.XInterfaceAttributeTypeDescription2;
+import com.sun.star.reflection.XPropertyTypeDescription;
+
+public class TypeChecker {
+
+ private static final int MAX_INTERFACES = 12;
+
+ private TypeManager mManager;
+
+ private boolean mSupportXComp;
+ private ArrayList<String> mInterfaces;
+ private ArrayList<String> mServices;
+ private ArrayList<XPropertyTypeDescription> mProperties;
+ private ArrayList<XInterfaceAttributeTypeDescription2> mAttributes;
+ private ArrayList<String> mPropinterfaces;
+ private String mPropertyHelper;
+
+
+ public TypeChecker(TypeManager pManager) {
+ mManager = pManager;
+
+ mInterfaces = new ArrayList<String>();
+ mServices = new ArrayList<String>();
+ mProperties = new ArrayList<XPropertyTypeDescription>();
+ mAttributes = new ArrayList<XInterfaceAttributeTypeDescription2>();
+ mPropinterfaces = new ArrayList<String>();
+ mPropertyHelper = null;
+ }
+
+ public boolean isSupportXComp() {
+ return mSupportXComp;
+ }
+
+ public ArrayList<String> getInterfaces() {
+ return mInterfaces;
+ }
+
+ public ArrayList<String> getServices() {
+ return mServices;
+ }
+
+ public ArrayList<XPropertyTypeDescription> getProperties() {
+ return mProperties;
+ }
+
+ public ArrayList<XInterfaceAttributeTypeDescription2> getAttributes() {
+ return mAttributes;
+ }
+
+ public ArrayList<String> getPropinterfaces() {
+ return mPropinterfaces;
+ }
+
+ public String getPropertyHelper() {
+ return mPropertyHelper;
+ }
+
+ public void check( CommandLine pArgs ) throws DumpException {
+ // Check the types
+ String[] types = pArgs.getOptionValues( "t" );
+
+
+ // Get the service, interfaces and members from the types
+ for (String type : types) {
+ mManager.checkType( type, mServices, mInterfaces, mProperties );
+ }
+
+ // TODO For ProtocolHandler case, check the frame.ProtocolHandler and frame.XDispatch types
+
+ // Check for the property helper
+ mPropertyHelper = mManager.checkPropertyHelper( pArgs, mServices, mInterfaces, mAttributes, mPropinterfaces );
+
+ // Check the default interfaces
+ checkDefaultInterfaces( );
+
+ if ( mInterfaces.size() > MAX_INTERFACES ) {
+ throw new DumpException( "The skeletonmaker supports components with 12 interfaces only (limitation of the UNO implementation helpers)!" );
+ }
+
+ mSupportXComp = mManager.checkXComponentSupport( mInterfaces );
+ }
+
+ /**
+ * Variables usable in the template model:
+ * <ul>
+ * <li>hasLicense: boolean</li>
+ * <li>serviceObject: boolean</li>
+ * <li>supportsXComponent: boolean</li>
+ * <li>interfaces: array of interfaces properties</li>
+ * <li>propertyHelper: string (empty string or the property helper name)</li>
+ * <li>classname: string (the name of the class to create)</li>
+ * </ul>
+ *
+ * Interface objet:
+ * <ul>
+ * <li>name: string for the interface name</li>
+ * <li></li>
+ * </ul>
+ * @return
+ */
+ public Object getTemplateModel() {
+ // TODO Setup the template model using the checked infos.
+ return null;
+ }
+
+ private void checkDefaultInterfaces( ) {
+
+ if ( mServices.isEmpty() ) {
+ mInterfaces.remove( "com.sun.star.lang.XServiceInfo" );
+ } else {
+ if ( !mInterfaces.contains( "com.sun.star.lang.XServiceInfo" ) ) {
+ mInterfaces.add( "com.sun.star.lang.XServiceInfo" );
+ }
+ }
+
+ if ( mPropertyHelper.equals( TypeManager.NOPROPERTYHELPER ) ) {
+ mInterfaces.remove( "com.sun.star.beans.XPropertySet" );
+ mInterfaces.remove( "com.sun.star.beans.XFastPropertySet" );
+ mInterfaces.remove( "com.sun.star.beans.XPropertyAccess" );
+ }
+ }
+}
diff --git a/src/org/openoffice/tools/language/Language.java b/src/org/openoffice/tools/language/Language.java
new file mode 100644
index 0000000..a4e9d31
--- /dev/null
+++ b/src/org/openoffice/tools/language/Language.java
@@ -0,0 +1,106 @@
+package org.openoffice.tools.language;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.NoSuchElementException;
+import java.util.Properties;
+
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+
+/**
+ * TODO Implement hierarchical language definitions.
+ *
+ * @author cbosdonnat
+ *
+ */
+public class Language {
+
+ private static final String PROP_DESCRIPTION = "description";
+ private static final String PROP_EXTENSION = "extension";
+
+ private static final String DESCRIPTION_FILENAME = "lang.properties";
+
+ private String mId;
+ private File mLangDir;
+
+ private Configuration mTemplateConfig;
+
+ private Properties mProps;
+
+ /**
+ * Constructor.
+ *
+ * @param pId the language identifier.
+ * @param pDir the language root directory (eg. cpp for C++).
+ *
+ * @throws IOException if the file provided isn't a proper language directory.
+ */
+ public Language( String pId, File pDir ) throws IOException {
+
+ mId = pId;
+ if ( !pDir.isDirectory() ) {
+ throw new IOException( "Invalid language directory" );
+ }
+ mLangDir = pDir;
+
+ // Define a template config for each language
+ mTemplateConfig = new Configuration();
+ mTemplateConfig.setTemplateLoader( new LanguageTemplateLoader( this ) );
+ }
+
+ public String getDescription( ) {
+ return getProperty( PROP_DESCRIPTION );
+ }
+
+ public String getExtension( ) {
+ return getProperty( PROP_EXTENSION );
+ }
+
+ public String getProperty( String pPropName ) {
+ if ( mProps == null ) {
+ loadProperties( );
+ }
+ String serialized = null;
+ Object value = mProps.get( pPropName );
+ if ( value != null ) {
+ serialized = value.toString();
+ }
+ return serialized;
+ }
+
+ public Template getTemplate( String pName ) throws IOException {
+ return mTemplateConfig.getTemplate( pName );
+ }
+
+ protected File getTemplateFile( String pName ) {
+ File result = null;
+
+ result = new File( mLangDir, pName );
+ if ( !result.isFile() || !result.canRead() ) {
+ String msg = MessageFormat.format( "No template {0} for language {1}", pName, mId );
+ throw new NoSuchElementException( msg );
+ }
+
+ return result;
+ }
+
+ private void loadProperties() {
+ mProps = new Properties();
+ File descFile = new File( mLangDir, DESCRIPTION_FILENAME );
+ if ( descFile.isFile() && descFile.canRead() ) {
+ Properties props = new Properties( );
+ FileInputStream in = null;
+ try {
+ in = new FileInputStream( descFile );
+ props.load( in );
+ mProps.putAll( props );
+ } catch ( Exception e ) {
+ } finally {
+ try { in.close(); } catch ( Exception e) { };
+ }
+ }
+ }
+}
diff --git a/src/org/openoffice/tools/language/LanguageHelper.java b/src/org/openoffice/tools/language/LanguageHelper.java
new file mode 100644
index 0000000..b2d23b0
--- /dev/null
+++ b/src/org/openoffice/tools/language/LanguageHelper.java
@@ -0,0 +1,68 @@
+package org.openoffice.tools.language;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+/**
+ * Utility methods handling the language definitions and templates.
+ *
+ * TODO Store the language objects in a static way for perf. reasons
+ *
+ * @author cbosdonnat
+ *
+ */
+public class LanguageHelper {
+
+ private static final String DEFAULT_LANGS_DIR = "langs";
+
+ private static File sLangsDir;
+
+ /**
+ * Changes the languages configuration directory.
+ *
+ * @param pConfigDir the new directory containing the languages definitions.
+ */
+ public static void setLanguagesDir( File pConfigDir ) {
+ sLangsDir = pConfigDir;
+ }
+
+ public static String[] getLanguagesIds() {
+ File langsDir = getLangsDir();
+
+ String[] langs = langsDir.list( new FilenameFilter() {
+
+ @Override
+ public boolean accept(File pDir, String pName) {
+ return !pName.startsWith(".");
+ }
+ });
+
+ return langs;
+ }
+
+ public static Language getLanguage( String pLang ) {
+ Language language = null;
+ try {
+ language = new Language( pLang, new File( getLangsDir( ), pLang ) );
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return language;
+ }
+
+ private static File getLangsDir( ) {
+
+ if ( sLangsDir == null ) {
+ try {
+ File jarFile = new File(LanguageHelper.class.getProtectionDomain()
+ .getCodeSource().getLocation().toURI());
+ sLangsDir = new File( jarFile.getParentFile(), DEFAULT_LANGS_DIR );
+
+ } catch (URISyntaxException e) {
+ }
+ }
+ return sLangsDir;
+ }
+}
diff --git a/src/org/openoffice/tools/language/LanguageTemplateLoader.java b/src/org/openoffice/tools/language/LanguageTemplateLoader.java
new file mode 100644
index 0000000..4f6226f
--- /dev/null
+++ b/src/org/openoffice/tools/language/LanguageTemplateLoader.java
@@ -0,0 +1,33 @@
+package org.openoffice.tools.language;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.NoSuchElementException;
+
+import freemarker.cache.FileTemplateLoader;
+
+public class LanguageTemplateLoader extends FileTemplateLoader {
+
+ private Language mLang;
+
+ public LanguageTemplateLoader( Language pLangDef ) throws IOException {
+ mLang = pLangDef;
+ }
+
+ /**
+ * Delegate the template finding to the language itself.
+ *
+ * @param pName the template name to find
+ *
+ * @return the template File if found, or <code>null</code>.
+ */
+ @Override
+ public Object findTemplateSource(String pName ) throws IOException {
+ File file = null;
+ try {
+ file = mLang.getTemplateFile( pName );
+ } catch ( NoSuchElementException e ) {
+ }
+ return file;
+ }
+}
diff --git a/src/org/openoffice/tools/tests/LanguageHelperTest.java b/src/org/openoffice/tools/tests/LanguageHelperTest.java
index f6e0597..49c5b34 100644
--- a/src/org/openoffice/tools/tests/LanguageHelperTest.java
+++ b/src/org/openoffice/tools/tests/LanguageHelperTest.java
@@ -2,12 +2,21 @@ package org.openoffice.tools.tests;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import java.io.File;
+import java.io.StringWriter;
+import java.net.URISyntaxException;
import java.util.Arrays;
+import java.util.HashMap;
+import org.junit.Before;
import org.junit.Test;
-import org.openoffice.tools.LanguageHelper;
+import org.openoffice.tools.language.Language;
+import org.openoffice.tools.language.LanguageHelper;
+
+import freemarker.template.Template;
/**
* ATM, the fixture of this class is the main language configuration: it
@@ -18,30 +27,92 @@ import org.openoffice.tools.LanguageHelper;
*/
public class LanguageHelperTest {
- private static final String LANG = "cpp";
- private static final Object DESCRIPTION = "generate output for C++";
+ private static final String TESTS_LANGS_DIR = "test_langs";
+
+ private static final String WORKING_LANG = "working";
+ private static final Object WORKING_DESCRIPTION = "Working test lang";
+
+ private static final String MISSING_LANG = "missing";
+ private static final String UNCOMPLETE_LANG = "uncomplete";
- private static final String ERR_LANG = "err";
+ private static final String SIMPLE_TPL = "simple.tpl";
+ private static final String NESTED_TPL = "nested.tpl";
+
+ private static final String VAR_SOMETEXT_NAME = "sometext";
+ private static final String VAR_SOMETEXT_VALUE = "some text";
+
+ @Before
+ public void setup( ) throws URISyntaxException {
+ File jarFile = new File(LanguageHelperTest.class.getProtectionDomain()
+ .getCodeSource().getLocation().toURI());
+ File dir = new File( jarFile.getParentFile(), TESTS_LANGS_DIR );
+ LanguageHelper.setLanguagesDir( dir );
+ }
@Test
public void testGetLanguages( ) {
- String[] result = LanguageHelper.getLanguages();
- String[] expected = new String[] { "cpp", "java4", "java5" };
+ String[] result = LanguageHelper.getLanguagesIds();
+ String[] expected = new String[] { WORKING_LANG, UNCOMPLETE_LANG };
// The order in results aren't guaranteed
Arrays.sort( result );
+ Arrays.sort( expected );
assertArrayEquals( "Different values", expected, result );
}
@Test
public void testGetDescriptionOk( ) {
- String actual = LanguageHelper.getDescription( LANG );
- assertEquals( DESCRIPTION , actual );
+ Language langDef = LanguageHelper.getLanguage( WORKING_LANG );
+ assertNotNull( langDef );
+ String actual = langDef.getDescription( );
+ assertEquals( WORKING_DESCRIPTION , actual );
}
@Test
- public void testGetDescriptionError( ) {
- String actual = LanguageHelper.getDescription( ERR_LANG );
+ public void testGetLanguageMissing( ) {
+ Language langDef = LanguageHelper.getLanguage( MISSING_LANG );
+ assertNull( langDef );
+ }
+
+ @Test
+ public void testGetLanguageMissingProp( ) {
+ Language langDef = LanguageHelper.getLanguage( UNCOMPLETE_LANG );
+ assertNotNull( langDef );
+ String actual = langDef.getDescription();
assertNull( actual );
}
+
+ @Test
+ public void testSimpleTemplate( ) throws Exception {
+ Language langDef = LanguageHelper.getLanguage( WORKING_LANG );
+ assertNotNull( langDef );
+
+ Template tpl = langDef.getTemplate( SIMPLE_TPL );
+ StringWriter out = new StringWriter();
+ tpl.process( getTestTemplateModel(), out );
+ out.flush();
+
+ String expected = VAR_SOMETEXT_VALUE;
+ assertEquals( expected, out.toString() );
+ }
+
+ @Test
+ public void testNestedTemplate( ) throws Exception {
+ Language langDef = LanguageHelper.getLanguage( WORKING_LANG );
+ assertNotNull( langDef );
+
+ Template tpl = langDef.getTemplate( NESTED_TPL );
+ StringWriter out = new StringWriter();
+ tpl.process( getTestTemplateModel(), out );
+ out.flush();
+
+ String expected = VAR_SOMETEXT_VALUE + "\n" + VAR_SOMETEXT_VALUE;
+ assertEquals( expected, out.toString() );
+ }
+
+ private Object getTestTemplateModel() {
+ HashMap<String, Object> model = new HashMap<String, Object>();
+ model.put( VAR_SOMETEXT_NAME, VAR_SOMETEXT_VALUE );
+ return model;
+ }
}
diff --git a/src/org/openoffice/tools/types/TypeManager.java b/src/org/openoffice/tools/types/TypeManager.java
index b105a4f..c8b9085 100644
--- a/src/org/openoffice/tools/types/TypeManager.java
+++ b/src/org/openoffice/tools/types/TypeManager.java
@@ -147,6 +147,7 @@ public class TypeManager {
}
boolean oldStyleWithProps = false;
+ boolean propMixin = Boolean.parseBoolean( pArgs.getOptionValue( "propertysetmixin" ) );
while ( it.hasNext() && result.isEmpty() ) {
String typename = it.next( );
try {
@@ -154,7 +155,6 @@ public class TypeManager {
if ( !pServices.isEmpty() ) {
Service service = new Service( typeDesc );
- boolean propMixin = Boolean.parseBoolean( pArgs.getOptionValue( "propertysetmixin" ) );
if ( propMixin && service.getSupertype() != null ) {
Interface iface = new Interface( service.getSupertype() );
iface.checkAttributes( pAttributes, pPropinterfaces );