diff options
Diffstat (limited to 'wizards/com/sun/star/wizards/common')
27 files changed, 8930 insertions, 0 deletions
diff --git a/wizards/com/sun/star/wizards/common/ConfigGroup.java b/wizards/com/sun/star/wizards/common/ConfigGroup.java new file mode 100644 index 000000000000..1b260132a5f4 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/ConfigGroup.java @@ -0,0 +1,183 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +import java.lang.reflect.Field; + +/** + * + * @author rpiterman + */ +public class ConfigGroup implements ConfigNode +{ + + public Object root; + + public void writeConfiguration(Object configurationView, Object param) + { + Field[] fields = getClass().getFields(); + for (int i = 0; i < fields.length; i++) + { + if (fields[i].getName().startsWith((String) param)) + { + try + { + writeField(fields[i], configurationView, (String) param); + } + catch (Exception ex) + { + System.out.println("Error writing field: " + fields[i].getName()); + ex.printStackTrace(); + } + } + } + } + + private void writeField(Field field, Object configView, String prefix) throws Exception + { + String propertyName = field.getName().substring(prefix.length()); + //System.out.println("Going to save:" + propertyName); + Class fieldType = field.getType(); + if (ConfigNode.class.isAssignableFrom(fieldType)) + { + Object childView = Configuration.addConfigNode(configView, propertyName); + ConfigNode child = (ConfigNode) field.get(this); + child.writeConfiguration(childView, prefix); + } + else if (fieldType.isPrimitive()) + { + Configuration.set(convertValue(field), propertyName, configView); + } + else if (fieldType.equals(String.class)) + { + Configuration.set(field.get(this), propertyName, configView); + } + } + + /** + * convert the primitive type value of the + * given Field object to the corresponding + * Java Object value. + * @param field + * @return the value of the field as a Object. + * @throws IllegalAccessException + */ + public Object convertValue(Field field) throws IllegalAccessException + { + if (field.getType().equals(Boolean.TYPE)) + { + return (field.getBoolean(this) ? Boolean.TRUE : Boolean.FALSE); + } + if (field.getType().equals(Integer.TYPE)) + { + return new Integer(field.getInt(this)); + } + if (field.getType().equals(Short.TYPE)) + { + return new Short(field.getShort(this)); + } + if (field.getType().equals(Float.TYPE)) + { + return new Double(field.getFloat(this)); + } + if (field.getType().equals(Double.TYPE)) + { + return new Double(field.getDouble(this)); + } + //System.out.println("ohoh..."); + return null; //and good luck with it :-) ... + } + + public void readConfiguration(Object configurationView, Object param) + { + Field[] fields = getClass().getFields(); + for (int i = 0; i < fields.length; i++) + { + if (fields[i].getName().startsWith((String) param)) + { + try + { + readField(fields[i], configurationView, (String) param); + } + catch (Exception ex) + { + System.out.println("Error reading field: " + fields[i].getName()); + ex.printStackTrace(); + } + } + } + } + + private void readField(Field field, Object configView, String prefix) throws Exception + { + String propertyName = field.getName().substring(prefix.length()); + + Class fieldType = field.getType(); + if (ConfigNode.class.isAssignableFrom(fieldType)) + { + ConfigNode child = (ConfigNode) field.get(this); + child.setRoot(root); + child.readConfiguration(Configuration.getNode(propertyName, configView), prefix); + } + else if (fieldType.isPrimitive()) + { + if (fieldType.equals(Boolean.TYPE)) + { + field.setBoolean(this, Configuration.getBoolean(propertyName, configView)); + } + else if (fieldType.equals(Integer.TYPE)) + { + field.setInt(this, Configuration.getInt(propertyName, configView)); + } + else if (fieldType.equals(Short.TYPE)) + { + field.setShort(this, Configuration.getShort(propertyName, configView)); + } + else if (fieldType.equals(Float.TYPE)) + { + field.setFloat(this, Configuration.getFloat(propertyName, configView)); + } + else if (fieldType.equals(Double.TYPE)) + { + field.setDouble(this, Configuration.getDouble(propertyName, configView)); + } + } + else if (fieldType.equals(String.class)) + { + field.set(this, Configuration.getString(propertyName, configView)); + } + } + + public void setRoot(Object newRoot) + { + root = newRoot; + } + + /* (non-Javadoc) + * @see com.sun.star.wizards.common.ConfigNode#writeConfiguration(java.lang.Object, java.lang.Object) + */ +} diff --git a/wizards/com/sun/star/wizards/common/ConfigNode.java b/wizards/com/sun/star/wizards/common/ConfigNode.java new file mode 100644 index 000000000000..23c0f9c5ba81 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/ConfigNode.java @@ -0,0 +1,53 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +/** + * This Interface specifies a method of an object which is + * capable of reading adn writing its data out of the + * OO Configuration. <br/> + * There are 2 direct implementations: ConfigGroup and ConfigSet. + * The root is the first Java Object in the configuration hirarchie. + * @author rpiterman + */ +public interface ConfigNode +{ + + /** + * reads the object data out of the configuration. + * @param configurationView is a ::com::sun::star::configuration::HierarchyElement + * which represents the node corresponding to the Object. + * @param param a free parameter. Since the intension of this interface is + * to be used in a tree like way, reading objects and subobjects and so on, + * it might be practical to be able to pass an extra parameter, for a free use. + */ + public void readConfiguration(Object configurationView, Object param); + + public void writeConfiguration(Object configurationView, Object param); + + public void setRoot(Object root); +} diff --git a/wizards/com/sun/star/wizards/common/ConfigSet.java b/wizards/com/sun/star/wizards/common/ConfigSet.java new file mode 100644 index 000000000000..216f91b5e430 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/ConfigSet.java @@ -0,0 +1,452 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +import java.util.*; + +import javax.swing.ListModel; +import javax.swing.event.ListDataEvent; + + +import org.w3c.dom.*; + +/** + * + * @author rpiterman + */ +public class ConfigSet implements ConfigNode, XMLProvider, ListModel +{ + + private Class childClass; + private Map childrenMap = new HashMap(); + private List childrenList = new Vector(); + public Object root; + /** + * After reading the configuration set items, + * the ConfigSet checks this field. + * If it is true, it will remove any nulls from + * the vector. + * subclasses can change this field in the constructor + * to avoid this "deletion" of nulls. + */ + protected boolean noNulls = true; + /** Utility field used by event firing mechanism. */ + private javax.swing.event.EventListenerList listenerList = null; + + public ConfigSet(Class childType) + { + childClass = childType; + } + + public void add(String name, Object child) + { + childrenMap.put(name, child); + try + { + int i = ((Indexable) child).getIndex(); + int oldSize = getSize(); + while (getSize() <= i) + { + childrenList.add(null); + } + childrenList.set(i, child); + if (oldSize > i) + { + oldSize = i; + } + fireListDataListenerIntervalAdded(oldSize, i); + } + catch (ClassCastException cce) + { + childrenList.add(child); + fireListDataListenerIntervalAdded(getSize() - 1, getSize() - 1); + } + } + + public void add(int i, Object o) + { + int name = i; + while (getElement("" + name) != null) + { + name++; + } + childrenMap.put("" + name, o); + childrenList.add(i, o); + + fireListDataListenerIntervalAdded(i, i); + } + + protected Object createChild() throws InstantiationException, IllegalAccessException + { + return childClass.newInstance(); + } + + public void writeConfiguration(Object configView, Object param) + { + Object[] names = childrenMap.keySet().toArray(); + + if (ConfigNode.class.isAssignableFrom(childClass)) + { + //first I remove all the children from the configuration. + String children[] = Configuration.getChildrenNames(configView); + for (int i = 0; i < children.length; i++) + { + try + { + Configuration.removeNode(configView, children[i]); + } + catch (Exception ex) + { + ex.printStackTrace(); + } // and add them new. + } + for (int i = 0; i < names.length; i++) + { + try + { + ConfigNode child = (ConfigNode) getElement(names[i]); + Object childView = Configuration.addConfigNode(configView, (String) names[i]); + child.writeConfiguration(childView, param); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + } + //for a set of primitive / String type. + else + { + throw new IllegalArgumentException("Unable to write primitive sets to configuration (not implemented)"); + } + } + + public void readConfiguration(Object configurationView, Object param) + { + String[] names = Configuration.getChildrenNames(configurationView); + + if (ConfigNode.class.isAssignableFrom(childClass)) + { + + for (int i = 0; i < names.length; i++) + { + try + { + ConfigNode child = (ConfigNode) createChild(); + child.setRoot(root); + child.readConfiguration(Configuration.getNode(names[i], configurationView), param); + add(names[i], child); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + //remove any nulls from the list + if (noNulls) + { + for (int i = 0; i < childrenList.size(); i++) + { + if (childrenList.get(i) == null) + { + childrenList.remove(i--); + } + } + } + } + //for a set of primitive / String type. + else + { + for (int i = 0; i < names.length; i++) + { + try + { + Object child = Configuration.getNode(names[i], configurationView); + add(names[i], child); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + } + } + + public void remove(Object obj) + { + Object key = getKey(obj); + childrenMap.remove(key); + int i = childrenList.indexOf(obj); + childrenList.remove(obj); + fireListDataListenerIntervalRemoved(i, i); + } + + public void remove(int i) + { + Object o = getElementAt(i); + remove(o); + } + + public void clear() + { + childrenMap.clear(); + childrenList.clear(); + } + + public void update(int i) + { + fireListDataListenerContentsChanged(i, i); + } + + public Node createDOM(Node parent) + { + + Object[] items = items(); + + for (int i = 0; i < items.length; i++) + { + Object item = items[i]; + if (item instanceof XMLProvider) + { + ((XMLProvider) item).createDOM(parent); + } + } + return parent; + } + + public Object[] items() + { + return childrenList.toArray(); + } + + public Object getKey(Object object) + { + for (Iterator i = childrenMap.entrySet().iterator(); i.hasNext();) + { + + Map.Entry me = (Map.Entry) i.next(); + if (me.getValue() == object) + { + return me.getKey(); + } + } + return null; + } + + public Object getKey(int i) + { + int c = 0; + while (i > -1) + { + if (getElementAt(c) != null) + { + i--; + } + c++; + } + if (c == 0) + { + return null; + } + else + { + return getKey(getElementAt(c - 1)); + } + } + + public void setRoot(Object newRoot) + { + root = newRoot; + } + + /** Registers ListDataListener to receive events. + * @param listener The listener to register. + * + */ + public synchronized void addListDataListener(javax.swing.event.ListDataListener listener) + { + if (listenerList == null) + { + listenerList = new javax.swing.event.EventListenerList(); + } + listenerList.add(javax.swing.event.ListDataListener.class, listener); + } + + /** Removes ListDataListener from the list of listeners. + * @param listener The listener to remove. + * + */ + public synchronized void removeListDataListener(javax.swing.event.ListDataListener listener) + { + listenerList.remove(javax.swing.event.ListDataListener.class, listener); + } + + /** Notifies all registered listeners about the event. + * + * @param event The event to be fired + * + */ + private void fireListDataListenerIntervalAdded(int i0, int i1) + { + ListDataEvent event = new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, i0, i1); + if (listenerList == null) + { + return; + } + Object[] listeners = listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) + { + if (listeners[i] == javax.swing.event.ListDataListener.class) + { + ((javax.swing.event.ListDataListener) listeners[i + 1]).intervalAdded(event); + } + } + } + + /** Notifies all registered listeners about the event. + * + * @param event The event to be fired + * + */ + private void fireListDataListenerIntervalRemoved(int i0, int i1) + { + ListDataEvent event = new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, i0, i1); + if (listenerList == null) + { + return; + } + Object[] listeners = listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) + { + if (listeners[i] == javax.swing.event.ListDataListener.class) + { + ((javax.swing.event.ListDataListener) listeners[i + 1]).intervalRemoved(event); + } + } + } + + /** Notifies all registered listeners about the event. + * + * @param event The event to be fired + * + */ + private void fireListDataListenerContentsChanged(int i0, int i1) + { + ListDataEvent event = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, i0, i1); + if (listenerList == null) + { + return; + } + Object[] listeners = listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) + { + if (listeners[i] == javax.swing.event.ListDataListener.class) + { + ((javax.swing.event.ListDataListener) listeners[i + 1]).contentsChanged(event); + } + } + } + + public Object getElementAt(int i) + { + return childrenList.get(i); + } + + public Object getElement(Object o) + { + return childrenMap.get(o); + } + + public int getSize() + { + return childrenList.size(); + } + + public Set keys() + { + return childrenMap.keySet(); + } + + public int getIndexOf(Object item) + { + return childrenList.indexOf(item); + } + + /** + * Set members might include a property + * which orders them. + * This method reindexes the given member to be + * the index number 0 + * Do not forget to call commit() after calling this method. + * @param confView + * @param memebrName + */ + public void reindexSet(Object confView, String memberName, String indexPropertyName) throws Exception + { + /* + * First I read all memebrs of the set, + * except the one that should be number 0 + * to a vector, ordered by there index property + */ + String[] names = Configuration.getChildrenNames(confView); + Vector v = new Vector(names.length); + Object member = null; + int index = 0; + for (int i = 0; i < names.length; i++) + { + if (!names[i].equals(memberName)) + { + member = Configuration.getConfigurationNode(names[i], confView); + index = Configuration.getInt(indexPropertyName, member); + while (index >= v.size()) + { + v.add(null); + } + v.setElementAt(member, index); + + } + /** + * Now I reindex them + */ + } + index = 1; + for (int i = 0; i < v.size(); i++) + { + member = v.get(i); + if (member != null) + { + Configuration.set(index++, indexPropertyName, member); + } + } + + } + + public void sort(Comparator comparator) + { + Collections.sort(this.childrenList, comparator); + } +} diff --git a/wizards/com/sun/star/wizards/common/Configuration.java b/wizards/com/sun/star/wizards/common/Configuration.java new file mode 100644 index 000000000000..cbe724335cf8 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Configuration.java @@ -0,0 +1,457 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +import com.sun.star.beans.*; +import com.sun.star.container.*; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.lang.Locale; +import com.sun.star.util.XChangesBatch; + +/** + * This class gives access to the OO configuration api. + * It contains 4 get and 4 set convenience methods for getting and settings properties + * in the configuration. <br/> + * For the get methods, two parameters must be given: name and parent, where name is the + * name of the property, parent is a HierarchyElement (::com::sun::star::configuration::HierarchyElement)<br/> + * The get and set methods support hieryrchical property names like "options/gridX". <br/> + * NOTE: not yet supported, but sometime later, + * If you will ommit the "parent" parameter, then the "name" parameter must be in hierarchy form from + * the root of the registry. + * @author rpiterman + */ +public abstract class Configuration +{ + + public static int getInt(String name, Object parent) throws Exception + { + Object o = getNode(name, parent); + if (AnyConverter.isVoid(o)) + { + return 0; + } + return AnyConverter.toInt(o); + } + + public static short getShort(String name, Object parent) throws Exception + { + Object o = getNode(name, parent); + if (AnyConverter.isVoid(o)) + { + return (short) 0; + } + return AnyConverter.toShort(o); + } + + public static float getFloat(String name, Object parent) throws Exception + { + Object o = getNode(name, parent); + if (AnyConverter.isVoid(o)) + { + return (float) 0; + } + return AnyConverter.toFloat(o); + } + + public static double getDouble(String name, Object parent) throws Exception + { + Object o = getNode(name, parent); + if (AnyConverter.isVoid(o)) + { + return (double) 0; + } + return AnyConverter.toDouble(o); + } + + public static String getString(String name, Object parent) throws Exception + { + Object o = getNode(name, parent); + if (AnyConverter.isVoid(o)) + { + return ""; + } + return (String) o; + } + + public static boolean getBoolean(String name, Object parent) throws Exception + { + Object o = getNode(name, parent); + if (AnyConverter.isVoid(o)) + { + return false; + } + return AnyConverter.toBoolean(o); + } + + public static Object getNode(String name, Object parent) throws Exception + { + return ((XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, parent)).getByName(name); + } + + public static void set(int value, String name, Object parent) throws Exception + { + set(new Integer(value), name, parent); + } + + public static void set(short value, String name, Object parent) throws Exception + { + set(new Short(value), name, parent); + } + + public static void set(String value, String name, Object parent) throws Exception + { + set((Object) value, name, parent); + } + + public static void set(boolean value, String name, Object parent) throws Exception + { + if (value == true) + { + set(Boolean.TRUE, name, parent); + } + else + { + set(Boolean.FALSE, name, parent); + } + } + + public static void set(Object value, String name, Object parent) throws com.sun.star.lang.IllegalArgumentException, PropertyVetoException, UnknownPropertyException, WrappedTargetException + { + ((XHierarchicalPropertySet) UnoRuntime.queryInterface(XHierarchicalPropertySet.class, parent)).setHierarchicalPropertyValue(name, value); + } + + /** Creates a new instance of RegistryEntry + * @param name + * @param parent + * @return + * @throws Exception + */ + public static Object getConfigurationNode(String name, Object parent) throws Exception + { + return ((XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, parent)).getByName(name); + } + + public static Object getConfigurationRoot(XMultiServiceFactory xmsf, String sPath, boolean updateable) throws com.sun.star.uno.Exception + { + + Object oConfigProvider; + oConfigProvider = xmsf.createInstance("com.sun.star.configuration.ConfigurationProvider"); + XMultiServiceFactory confMsf = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oConfigProvider); + + final String sView = updateable ? "com.sun.star.configuration.ConfigurationUpdateAccess" : "com.sun.star.configuration.ConfigurationAccess"; + + Object args[] = new Object[updateable ? 2 : 1]; + + PropertyValue aPathArgument = new PropertyValue(); + aPathArgument.Name = "nodepath"; + aPathArgument.Value = sPath; + + args[0] = aPathArgument; + + if (updateable) + { + + PropertyValue aModeArgument = new PropertyValue(); + aModeArgument.Name = "lazywrite"; + aModeArgument.Value = Boolean.FALSE; + + args[1] = aModeArgument; + } + + return confMsf.createInstanceWithArguments(sView, args); + } + + public static String[] getChildrenNames(Object configView) + { + XNameAccess nameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, configView); + return nameAccess.getElementNames(); + } + + public static String getProductName(XMultiServiceFactory xMSF) + { + try + { + Object oProdNameAccess = getConfigurationRoot(xMSF, "org.openoffice.Setup/Product", false); + String ProductName = (String) Helper.getUnoObjectbyName(oProdNameAccess, "ooName"); + return ProductName; + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + return null; + } + } + + public static String getOfficeLocaleString(XMultiServiceFactory xMSF) + { + String sLocale = ""; + try + { + Locale aLocLocale = new Locale(); + Object oMasterKey = getConfigurationRoot(xMSF, "org.openoffice.Setup/L10N/", false); + sLocale = (String) Helper.getUnoObjectbyName(oMasterKey, "ooLocale"); + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + } + return sLocale; + } + + public static Locale getOfficeLocale(XMultiServiceFactory xMSF) + { + Locale aLocLocale = new Locale(); + // Object oMasterKey = getConfigurationRoot(xMSF, "org.openoffice.Setup/L10N/", false); + // String sLocale = (String) Helper.getUnoObjectbyName(oMasterKey, "ooLocale"); + String sLocale = getOfficeLocaleString(xMSF); + String[] sLocaleList = JavaTools.ArrayoutofString(sLocale, "-"); + aLocLocale.Language = sLocaleList[0]; + if (sLocaleList.length > 1) + { + aLocLocale.Country = sLocaleList[1]; + } + return aLocLocale; + } + + public static String getOfficeLinguistic(XMultiServiceFactory xMSF) + { + try + { + Object oMasterKey = getConfigurationRoot(xMSF, "org.openoffice.Setup/L10N/", false); + String sLinguistic = (String) Helper.getUnoObjectbyName(oMasterKey, "ooLocale"); + return sLinguistic; + } + catch (Exception exception) + { + exception.printStackTrace(); + return null; + } + } + + /** + * This method creates a new configuration node and adds it + * to the given view. Note that if a node with the given name + * already exists it will be completely removed from + * the configuration. + * @param configView + * @param name + * @return the new created configuration node. + * @throws com.sun.star.lang.WrappedTargetException + * @throws ElementExistException + * @throws NoSuchElementException + * @throws com.sun.star.uno.Exception + */ + public static Object addConfigNode(Object configView, String name) throws com.sun.star.lang.WrappedTargetException, ElementExistException, NoSuchElementException, com.sun.star.uno.Exception + { + + XNameContainer xNameContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, configView); + + if (xNameContainer == null) + { + XNameReplace xNameReplace = (XNameReplace) UnoRuntime.queryInterface(XNameReplace.class, configView); + return xNameReplace.getByName(name); + } + else + { + + /*if (xNameContainer.hasByName(name)) + xNameContainer.removeByName(name);*/ + + // create a new detached set element (instance of DataSourceDescription) + XSingleServiceFactory xElementFactory = (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, configView); + + // the new element is the result ! + Object newNode = xElementFactory.createInstance(); + // insert it - this also names the element + xNameContainer.insertByName(name, newNode); + + return newNode; + } + } + + public static void removeNode(Object configView, String name) throws NoSuchElementException, WrappedTargetException + { + XNameContainer xNameContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, configView); + + if (xNameContainer.hasByName(name)) + { + xNameContainer.removeByName(name); + } + } + + public static void commit(Object configView) throws WrappedTargetException + { + XChangesBatch xUpdateControl = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class, configView); + xUpdateControl.commitChanges(); + } + + public static void updateConfiguration(XMultiServiceFactory xmsf, String path, String name, ConfigNode node, Object param) throws com.sun.star.uno.Exception, com.sun.star.container.ElementExistException, NoSuchElementException, WrappedTargetException + { + Object view = Configuration.getConfigurationRoot(xmsf, path, true); + addConfigNode(path, name); + node.writeConfiguration(view, param); + XChangesBatch xUpdateControl = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class, view); + xUpdateControl.commitChanges(); + } + + public static void removeNode(XMultiServiceFactory xmsf, String path, String name) throws com.sun.star.uno.Exception, com.sun.star.container.ElementExistException, NoSuchElementException, WrappedTargetException + { + Object view = Configuration.getConfigurationRoot(xmsf, path, true); + removeNode(view, name); + XChangesBatch xUpdateControl = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class, view); + xUpdateControl.commitChanges(); + } + + public static String[] getNodeDisplayNames(XNameAccess _xNameAccessNode) + { + String[] snames = null; + return getNodeChildNames(_xNameAccessNode, "Name"); + } + + public static String[] getNodeChildNames(XNameAccess xNameAccessNode, String _schildname) + { + String[] snames = null; + try + { + snames = xNameAccessNode.getElementNames(); + String[] sdisplaynames = new String[snames.length]; + for (int i = 0; i < snames.length; i++) + { + Object oContent = Helper.getUnoPropertyValue(xNameAccessNode.getByName(snames[i]), _schildname); + if (!AnyConverter.isVoid(oContent)) + { + sdisplaynames[i] = (String) Helper.getUnoPropertyValue(xNameAccessNode.getByName(snames[i]), _schildname); + } + else + { + sdisplaynames[i] = snames[i]; + } + } + return sdisplaynames; + } + catch (Exception e) + { + e.printStackTrace(System.out); + return snames; + } + } + + public static XNameAccess getChildNodebyIndex(XNameAccess _xNameAccess, int _index) + { + try + { + String[] snames = _xNameAccess.getElementNames(); + Object oNode = _xNameAccess.getByName(snames[_index]); + XNameAccess xNameAccessNode = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oNode); + return xNameAccessNode; + } + catch (Exception e) + { + e.printStackTrace(System.out); + return null; + } + } + + public static XNameAccess getChildNodebyName(XNameAccess _xNameAccessNode, String _SubNodeName) + { + try + { + if (_xNameAccessNode.hasByName(_SubNodeName)) + { + return (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, _xNameAccessNode.getByName(_SubNodeName)); + } + } + catch (Exception e) + { + e.printStackTrace(System.out); + } + return null; + } + + public static XNameAccess getChildNodebyDisplayName(XNameAccess _xNameAccessNode, String _displayname) + { + String[] snames = null; + return getChildNodebyDisplayName(_xNameAccessNode, _displayname, "Name"); + } + + public static XNameAccess getChildNodebyDisplayName(XNameAccess _xNameAccessNode, String _displayname, String _nodename) + { + String[] snames = null; + try + { + snames = _xNameAccessNode.getElementNames(); + String[] sdisplaynames = new String[snames.length]; + for (int i = 0; i < snames.length; i++) + { + String curdisplayname = (String) Helper.getUnoPropertyValue(_xNameAccessNode.getByName(snames[i]), _nodename); + if (curdisplayname.equals(_displayname)) + { + return (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, _xNameAccessNode.getByName(snames[i])); + } + } + } + catch (Exception e) + { + e.printStackTrace(System.out); + } + return null; + } + + public static XNameAccess getChildNodebyDisplayName(XMultiServiceFactory _xMSF, Locale _aLocale, XNameAccess _xNameAccessNode, String _displayname, String _nodename, int _nmaxcharcount) + { + String[] snames = null; + try + { + snames = _xNameAccessNode.getElementNames(); + String[] sdisplaynames = new String[snames.length]; + for (int i = 0; i < snames.length; i++) + { + String curdisplayname = (String) Helper.getUnoPropertyValue(_xNameAccessNode.getByName(snames[i]), _nodename); + if ((_nmaxcharcount > 0) && (_nmaxcharcount < curdisplayname.length())) + { + curdisplayname = curdisplayname.substring(0, _nmaxcharcount); + } + curdisplayname = Desktop.removeSpecialCharacters(_xMSF, _aLocale, curdisplayname); + + if (curdisplayname.equals(_displayname)) + { + return (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, _xNameAccessNode.getByName(snames[i])); + } + } + } + catch (Exception e) + { + e.printStackTrace(System.out); + } + return null; + } +} diff --git a/wizards/com/sun/star/wizards/common/DebugHelper.java b/wizards/com/sun/star/wizards/common/DebugHelper.java new file mode 100644 index 000000000000..b560fb643a40 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/DebugHelper.java @@ -0,0 +1,58 @@ +/* + ************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +import com.sun.star.uno.Exception; + +/** + * + * @author ll93751 + */ +public class DebugHelper +{ + + public static void exception(String DetailedMessage, Exception ex, int err, String additionalArgument) throws java.lang.Exception + { +// throw new UnsupportedOperationException("Not supported yet."); + } + + public static void exception(int err, String additionalArgument) throws java.lang.Exception + { +// throw new UnsupportedOperationException("Not supported yet."); + } + + public static void exception(Exception ex) throws java.lang.Exception + { +// throw new UnsupportedOperationException("Not supported yet."); + } + + public static void writeInfo(String msg) + { +// throw new UnsupportedOperationException("Not supported yet."); + } +} diff --git a/wizards/com/sun/star/wizards/common/Desktop.java b/wizards/com/sun/star/wizards/common/Desktop.java new file mode 100644 index 000000000000..8902696c37b4 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Desktop.java @@ -0,0 +1,509 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +// import java.util.Date; + +// import com.sun.star.awt.XToolkit; +import com.sun.star.beans.PropertyValue; +// import com.sun.star.frame.XDesktop; +// import com.sun.star.frame.XFrame; +// import com.sun.star.frame.XFramesSupplier; + +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Any; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uno.XNamingService; +import com.sun.star.util.XURLTransformer; +import com.sun.star.lang.Locale; +import com.sun.star.uno.XInterface; +import com.sun.star.bridge.XUnoUrlResolver; +import com.sun.star.comp.helper.Bootstrap; +import com.sun.star.container.NoSuchElementException; +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XHierarchicalNameAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.util.XStringSubstitution; +import com.sun.star.frame.*; +import com.sun.star.i18n.KParseType; +import com.sun.star.i18n.ParseResult; +import com.sun.star.i18n.XCharacterClassification; + +public class Desktop +{ + + /** Creates a new instance of Desktop */ + public Desktop() + { + } + + public static XDesktop getDesktop(XMultiServiceFactory xMSF) + { + com.sun.star.uno.XInterface xInterface = null; + XDesktop xDesktop = null; + if (xMSF != null) + { + try + { + xInterface = (com.sun.star.uno.XInterface) xMSF.createInstance("com.sun.star.frame.Desktop"); + xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, xInterface); + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + } + } + else + { + System.out.println("Can't create a desktop. null pointer !"); + } + return xDesktop; + } + + public static XFrame getActiveFrame(XMultiServiceFactory xMSF) + { + XDesktop xDesktop = getDesktop(xMSF); + XFramesSupplier xFrameSuppl = (XFramesSupplier) UnoRuntime.queryInterface(XFramesSupplier.class, xDesktop); + XFrame xFrame = xFrameSuppl.getActiveFrame(); + return xFrame; + } + + public static XComponent getActiveComponent(XMultiServiceFactory _xMSF) + { + XFrame xFrame = getActiveFrame(_xMSF); + return (XComponent) UnoRuntime.queryInterface(XComponent.class, xFrame.getController().getModel()); + } + + public static XTextDocument getActiveTextDocument(XMultiServiceFactory _xMSF) + { + XComponent xComponent = getActiveComponent(_xMSF); + return (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent); + } + + public static XSpreadsheetDocument getActiveSpreadsheetDocument(XMultiServiceFactory _xMSF) + { + XComponent xComponent = getActiveComponent(_xMSF); + return (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, xComponent); + } + + public static XDispatch getDispatcher(XMultiServiceFactory xMSF, XFrame xFrame, String _stargetframe, com.sun.star.util.URL oURL) + { + try + { + com.sun.star.util.URL[] oURLArray = new com.sun.star.util.URL[1]; + oURLArray[0] = oURL; + XDispatchProvider xDispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, xFrame); + XDispatch xDispatch = xDispatchProvider.queryDispatch(oURLArray[0], _stargetframe, FrameSearchFlag.ALL); // "_self" + return xDispatch; + } + catch (Exception e) + { + e.printStackTrace(System.out); + } + return null; + } + + public static com.sun.star.util.URL getDispatchURL(XMultiServiceFactory xMSF, String _sURL) + { + try + { + Object oTransformer = xMSF.createInstance("com.sun.star.util.URLTransformer"); + XURLTransformer xTransformer = (XURLTransformer) UnoRuntime.queryInterface(XURLTransformer.class, oTransformer); + com.sun.star.util.URL[] oURL = new com.sun.star.util.URL[1]; + oURL[0] = new com.sun.star.util.URL(); + oURL[0].Complete = _sURL; + xTransformer.parseStrict(oURL); + return oURL[0]; + } + catch (Exception e) + { + e.printStackTrace(System.out); + } + return null; + } + + public static void dispatchURL(XMultiServiceFactory xMSF, String sURL, XFrame xFrame, String _stargetframe) + { + com.sun.star.util.URL oURL = getDispatchURL(xMSF, sURL); + XDispatch xDispatch = getDispatcher(xMSF, xFrame, _stargetframe, oURL); + dispatchURL(xDispatch, oURL); + } + + public static void dispatchURL(XMultiServiceFactory xMSF, String sURL, XFrame xFrame) + { + dispatchURL(xMSF, sURL, xFrame, ""); + } + + public static void dispatchURL(XDispatch _xDispatch, com.sun.star.util.URL oURL) + { + PropertyValue[] oArg = new PropertyValue[0]; + _xDispatch.dispatch(oURL, oArg); + } + + public static XMultiComponentFactory getMultiComponentFactory() throws com.sun.star.uno.Exception, RuntimeException, java.lang.Exception + { + XComponentContext xcomponentcontext = Bootstrap.createInitialComponentContext(null); + // initial serviceManager + return xcomponentcontext.getServiceManager(); + } + + public static XMultiServiceFactory connect(String connectStr) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException, Exception + { + XMultiComponentFactory componentFactory = getMultiComponentFactory(); + Object xUrlResolver = componentFactory.createInstanceWithContext( "com.sun.star.bridge.UnoUrlResolver", null ); + XUnoUrlResolver urlResolver = UnoRuntime.queryInterface(XUnoUrlResolver.class, xUrlResolver); + XMultiServiceFactory orb = UnoRuntime.queryInterface(XMultiServiceFactory.class, urlResolver.resolve( connectStr ) ); + return orb; + } + + public static String getIncrementSuffix(XNameAccess xElementContainer, String ElementName) + { + boolean bElementexists = true; + int i = 1; + String sIncSuffix = ""; + String BaseName = ElementName; + while (bElementexists == true) + { + bElementexists = xElementContainer.hasByName(ElementName); + if (bElementexists == true) + { + i += 1; + ElementName = BaseName + Integer.toString(i); + } + } + if (i > 1) + { + sIncSuffix = Integer.toString(i); + } + return sIncSuffix; + } + + public static String getIncrementSuffix(XHierarchicalNameAccess xElementContainer, String ElementName) + { + boolean bElementexists = true; + int i = 1; + String sIncSuffix = ""; + String BaseName = ElementName; + while (bElementexists == true) + { + bElementexists = xElementContainer.hasByHierarchicalName(ElementName); + if (bElementexists == true) + { + i += 1; + ElementName = BaseName + Integer.toString(i); + } + } + if (i > 1) + { + sIncSuffix = Integer.toString(i); + } + return sIncSuffix; + } + + public static int checkforfirstSpecialCharacter(XMultiServiceFactory _xMSF, String _sString, Locale _aLocale) + { + try + { + int nStartFlags = com.sun.star.i18n.KParseTokens.ANY_LETTER_OR_NUMBER + com.sun.star.i18n.KParseTokens.ASC_UNDERSCORE; + int nContFlags = nStartFlags; + Object ocharservice = _xMSF.createInstance("com.sun.star.i18n.CharacterClassification"); + XCharacterClassification xCharacterClassification = (XCharacterClassification) UnoRuntime.queryInterface(XCharacterClassification.class, ocharservice); + ParseResult aResult = xCharacterClassification.parsePredefinedToken(KParseType.IDENTNAME, _sString, 0, _aLocale, nStartFlags, "", nContFlags, " "); + return aResult.EndPos; + } + catch (Exception e) + { + e.printStackTrace(System.out); + return -1; + } + } + + public static String removeSpecialCharacters(XMultiServiceFactory _xMSF, Locale _aLocale, String _sname) + { + String snewname = _sname; + int i = 0; + while (i < snewname.length()) + { + i = Desktop.checkforfirstSpecialCharacter(_xMSF, snewname, _aLocale); + if (i < snewname.length()) + { + String sspecialchar = snewname.substring(i, i + 1); + snewname = JavaTools.replaceSubString(snewname, "", sspecialchar); + } + } + return snewname; + } + + /** + * Checks if the passed Element Name already exists in the ElementContainer. If yes it appends a + * suffix to make it unique + * @param xElementContainer + * @param sElementName + * @return a unique Name ready to be added to the container. + */ + public static String getUniqueName(XNameAccess xElementContainer, String sElementName) + { + String sIncSuffix = getIncrementSuffix(xElementContainer, sElementName); + return sElementName + sIncSuffix; + } + + /** + * Checks if the passed Element Name already exists in the ElementContainer. If yes it appends a + * suffix to make it unique + * @param xElementContainer + * @param sElementName + * @return a unique Name ready to be added to the container. + */ + public static String getUniqueName(XHierarchicalNameAccess xElementContainer, String sElementName) + { + String sIncSuffix = getIncrementSuffix(xElementContainer, sElementName); + return sElementName + sIncSuffix; + } + + /** + * Checks if the passed Element Name already exists in the list If yes it appends a + * suffix to make it unique + * @param _slist + * @param _sElementName + * @param _sSuffixSeparator + * @return a unique Name not being in the passed list. + */ + public static String getUniqueName(String[] _slist, String _sElementName, String _sSuffixSeparator) + { + int a = 2; + String scompname = _sElementName; + boolean bElementexists = true; + if (_slist == null) + { + return _sElementName; + } + if (_slist.length == 0) + { + return _sElementName; + } + while (bElementexists == true) + { + for (int i = 0; i < _slist.length; i++) + { + if (JavaTools.FieldInList(_slist, scompname) == -1) + { + return scompname; + } + } + scompname = _sElementName + _sSuffixSeparator + a++; + } + return ""; + } + + /** + * @deprecated use Configuration.getConfigurationRoot() with the same parameters instead + * @param xMSF + * @param KeyName + * @param bForUpdate + * @return + */ + public static XInterface getRegistryKeyContent(XMultiServiceFactory xMSF, String KeyName, boolean bForUpdate) + { + try + { + Object oConfigProvider; + PropertyValue[] aNodePath = new PropertyValue[1]; + oConfigProvider = xMSF.createInstance("com.sun.star.configuration.ConfigurationProvider"); + aNodePath[0] = new PropertyValue(); + aNodePath[0].Name = "nodepath"; + aNodePath[0].Value = KeyName; + XMultiServiceFactory xMSFConfig = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oConfigProvider); + if (bForUpdate == true) + { + return (XInterface) xMSFConfig.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aNodePath); + } + else + { + return (XInterface) xMSFConfig.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", aNodePath); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + return null; + } + } + + /** + * @deprecated used to retrieve the most common paths used in the office application + * @author bc93774 + * + */ + public class OfficePathRetriever + { + + public String TemplatePath; + public String BitmapPath; + public String UserTemplatePath; + public String WorkPath; + + public OfficePathRetriever(XMultiServiceFactory xMSF) + { + try + { + TemplatePath = FileAccess.getOfficePath(xMSF, "Template", "share", "/wizard"); + UserTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "user", ""); + BitmapPath = FileAccess.combinePaths(xMSF, TemplatePath, "/../wizard/bitmap"); + WorkPath = FileAccess.getOfficePath(xMSF, "Work", "", ""); + } + catch (NoValidPathException nopathexception) + { + } + } + } + + public static String getTemplatePath(XMultiServiceFactory _xMSF) + { + try + { + String sTemplatePath = FileAccess.getOfficePath(_xMSF, "Template", "share", "/wizard"); + return sTemplatePath; + } + catch (NoValidPathException nopathexception) + { + } + return ""; + } + + public static String getUserTemplatePath(XMultiServiceFactory _xMSF) + { + try + { + String sUserTemplatePath = FileAccess.getOfficePath(_xMSF, "Template", "user", ""); + return sUserTemplatePath; + } + catch (NoValidPathException nopathexception) + { + } + return ""; + } + + public static String getBitmapPath(XMultiServiceFactory _xMSF) + { + try + { + String sBitmapPath = FileAccess.combinePaths(_xMSF, getTemplatePath(_xMSF), "/../wizard/bitmap"); + return sBitmapPath; + } + catch (NoValidPathException nopathexception) + { + } + return ""; + } + + public static String getWorkPath(XMultiServiceFactory _xMSF) + { + try + { + String sWorkPath = FileAccess.getOfficePath(_xMSF, "Work", "", ""); + return sWorkPath; + } + catch (NoValidPathException nopathexception) + { + } + return ""; + } + + public static XStringSubstitution createStringSubstitution(XMultiServiceFactory xMSF) + { + Object xPathSubst = null; + try + { + xPathSubst = xMSF.createInstance("com.sun.star.util.PathSubstitution"); + } + catch (com.sun.star.uno.Exception e) + { + e.printStackTrace(); + } + if (xPathSubst != null) + { + return (XStringSubstitution) UnoRuntime.queryInterface(XStringSubstitution.class, xPathSubst); + } + else + { + return null; + } + } + + /** + * This method searches (and hopefully finds...) a frame + * with a componentWindow. + * It does it in three phases: + * 1. Check if the given desktop argument has a componentWindow. + * If it is null, the myFrame argument is taken. + * 2. Go up the tree of frames and search a frame with a component window. + * 3. Get from the desktop all the components, and give the first one + * which has a frame. + * @param xMSF + * @param myFrame + * @param desktop + * @return + * @throws NoSuchElementException + * @throws WrappedTargetException + */ + public static XFrame findAFrame(XMultiServiceFactory xMSF, XFrame myFrame, XFrame desktop) + throws NoSuchElementException, + WrappedTargetException + { + if (desktop == null) + { + desktop = myFrame; // we go up in the tree... + } + while (desktop != null && desktop.getComponentWindow() == null) + { + desktop = desktop.findFrame("_parent", FrameSearchFlag.PARENT); + } + if (desktop == null) + { + + for (XEnumeration e = Desktop.getDesktop(xMSF).getComponents().createEnumeration(); e.hasMoreElements();) + { + + Object comp = ((Any) e.nextElement()).getObject(); + XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, comp); + XFrame xFrame = xModel.getCurrentController().getFrame(); + + if (xFrame != null && xFrame.getComponentWindow() != null) + { + return xFrame; + } + } + } + return desktop; + } +} diff --git a/wizards/com/sun/star/wizards/common/FileAccess.java b/wizards/com/sun/star/wizards/common/FileAccess.java new file mode 100644 index 000000000000..6278d7e71a97 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/FileAccess.java @@ -0,0 +1,1200 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.Locale; +import com.sun.star.uno.Exception; +import com.sun.star.util.XMacroExpander; +// import com.sun.star.wizards.common.NoValidPathException; +import java.io.File; +import java.util.ArrayList; +import java.util.Vector; + +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XInputStream; +// import com.sun.star.io.XStream; +import com.sun.star.io.XTextInputStream; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.*; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.DateTime; +import com.sun.star.beans.PropertyValue; +import com.sun.star.document.XDocumentProperties; + +/** + * This class delivers static convenience methods + * to use with ucb SimpleFileAccess service. + * You can also instanciate the class, to encapsulate + * some functionality of SimpleFileAccess. The instance + * keeps a reference to an XSimpleFileAccess and an + * XFileIdentifierConverter, saves the permanent + * overhead of quering for those interfaces, and delivers + * conveneince methods for using them. + * These Convenince methods include mainly Exception-handling. + */ +public class FileAccess +{ + + /** + * + * @param xMSF + * @param sPath + * @param sAddPath + */ + public static void addOfficePath(XMultiServiceFactory xMSF, String sPath, String sAddPath) + { + XSimpleFileAccess xSimpleFileAccess = null; + String ResultPath = getOfficePath(xMSF, sPath, xSimpleFileAccess); + // As there are several conventions about the look of Url (e.g. with " " or with "%20") you cannot make a + // simple String comparison to find out, if a path is already in "ResultPath" + String[] PathList = JavaTools.ArrayoutofString(ResultPath, ";"); + int MaxIndex = PathList.length - 1; + String CompCurPath; + // sAddPath.replace(null, (char) 47); + String CompAddPath = JavaTools.replaceSubString(sAddPath, "", "/"); + String CurPath; + for (int i = 0; i <= MaxIndex; i++) + { + CurPath = JavaTools.convertfromURLNotation(PathList[i]); + CompCurPath = JavaTools.replaceSubString(CurPath, "", "/"); + if (CompCurPath.equals(CompAddPath)) + { + return; + } + } + ResultPath += ";" + sAddPath; + return; + } + + public static String deleteLastSlashfromUrl(String _sPath) + { + if (_sPath.endsWith("/")) + { + return _sPath.substring(0, _sPath.length() - 1); + } + else + { + return _sPath; + } + } + + /** + * Further information on arguments value see in OO Developer Guide, + * chapter 6.2.7 + * @param xMSF + * @param sPath + * @param xSimpleFileAccess + * @return the respective path of the office application. A probable following "/" at the end is trimmed. + */ + public static String getOfficePath(XMultiServiceFactory xMSF, String sPath, XSimpleFileAccess xSimpleFileAccess) + { + try + { + String ResultPath = ""; + XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.util.PathSettings"); + ResultPath = com.sun.star.uno.AnyConverter.toString(Helper.getUnoPropertyValue(xInterface, sPath)); + ResultPath = deleteLastSlashfromUrl(ResultPath); + return ResultPath; + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + return ""; + } + } + + /** + * Further information on arguments value see in OO Developer Guide, + * chapter 6.2.7 + * @param xMSF + * @param sPath + * @param sType use "share" or "user". Set to "" if not needed eg for the WorkPath; + * In the return Officepath a possible slash at the end is cut off + * @param sSearchDir + * @return + * @throws NoValidPathException + */ + public static String getOfficePath(XMultiServiceFactory xMSF, String sPath, String sType, String sSearchDir) throws NoValidPathException + { + //This method currently only works with sPath="Template" + + String ResultPath = ""; + + String Template_writable = ""; + String[] Template_internal; + String[] Template_user; + + boolean bexists = false; + try + { + XInterface xPathInterface = (XInterface) xMSF.createInstance("com.sun.star.util.PathSettings"); + XPropertySet xPropertySet = (XPropertySet) com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, xPathInterface); + String WritePath = ""; + String[] ReadPaths = null; + XInterface xUcbInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface); + + Template_writable = (String) xPropertySet.getPropertyValue(sPath + "_writable"); + Template_internal = (String[]) xPropertySet.getPropertyValue(sPath + "_internal"); + Template_user = (String[]) xPropertySet.getPropertyValue(sPath + "_user"); + int iNumEntries = Template_user.length + Template_internal.length + 1; + ReadPaths = new String[iNumEntries]; + int t = 0; + for (int i = 0; i < Template_internal.length; i++) + { + ReadPaths[t] = Template_internal[i]; + t++; + } + for (int i = 0; i < Template_user.length; i++) + { + ReadPaths[t] = Template_user[i]; + t++; + } + ReadPaths[t] = Template_writable; + WritePath = Template_writable; + + if (sType.equalsIgnoreCase("user")) + { + ResultPath = WritePath; + bexists = true; + } + else + { + //find right path using the search sub path + for (int i = 0; i < ReadPaths.length; i++) + { + String tmpPath = ReadPaths[i] + sSearchDir; + if (xSimpleFileAccess.exists(tmpPath)) + { + ResultPath = ReadPaths[i]; + bexists = true; + break; + } + } + } + ResultPath = deleteLastSlashfromUrl(ResultPath); + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + ResultPath = ""; + } + if (bexists == false) + { + throw new NoValidPathException(xMSF, ""); + } + return ResultPath; + } + + public static ArrayList<String> getOfficePaths(XMultiServiceFactory xMSF, String _sPath, String sType, String sSearchDir) throws NoValidPathException + { + //This method currently only works with sPath="Template" + + // String ResultPath = ""; + ArrayList<String> aPathList = new ArrayList<String>(); + String Template_writable = ""; + String[] Template_internal; + String[] Template_user; + + // String [] ReadPaths = null; + + // boolean bexists = false; + try + { + XInterface xPathInterface = (XInterface) xMSF.createInstance("com.sun.star.util.PathSettings"); + XPropertySet xPropertySet = (XPropertySet) com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, xPathInterface); + // String WritePath = ""; + // XInterface xUcbInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + // XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface); + + Template_writable = (String) xPropertySet.getPropertyValue(_sPath + "_writable"); + Template_internal = (String[]) xPropertySet.getPropertyValue(_sPath + "_internal"); + Template_user = (String[]) xPropertySet.getPropertyValue(_sPath + "_user"); + + // int iNumEntries = Template_user.length + Template_internal.length + 1; + for (int i = 0; i < Template_internal.length; i++) + { + String sPath = Template_internal[i]; + if (sPath.startsWith("vnd.")) + { + String sPathToExpand = sPath.substring("vnd.sun.star.Expand:".length()); + + XMacroExpander xExpander = Helper.getMacroExpander(xMSF); + sPath = xExpander.expandMacros(sPathToExpand); + } + + // if there exists a language in the directory, we try to add the right language + sPath = checkIfLanguagePathExists(xMSF, sPath); + + aPathList.add(sPath); + } + for (int i = 0; i < Template_user.length; i++) + { + aPathList.add(Template_user[i]); + } + aPathList.add(Template_writable); + // WritePath = Template_writable; + +// if (sType.equalsIgnoreCase("user")) +// { +// ResultPath = WritePath; +// bexists = true; +// } + + // There was a bug here, because we have to search through the whole list of paths +// else +// { +// //find right path using the search sub path +// for (int i = 0; i<ReadPaths.length; i++) +// { +// String tmpPath = ReadPaths[i]+sSearchDir; +// if (xSimpleFileAccess.exists(tmpPath)) +// { +// ResultPath = ReadPaths[i]; +// bexists = true; +// break; +// } +// } +// } +// ResultPath = deleteLastSlashfromUrl(ResultPath); + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + // ResultPath = ""; + } +// if (bexists == false) +// { +// throw new NoValidPathException(xMSF, ""); +// } +// return ResultPath; + return aPathList; + } + + private static String checkIfLanguagePathExists(XMultiServiceFactory _xMSF, String _sPath) + { + try + { + Object defaults = _xMSF.createInstance("com.sun.star.text.Defaults"); + Locale aLocale = (Locale) Helper.getUnoStructValue(defaults, "CharLocale"); + if (aLocale == null) + { + java.util.Locale.getDefault(); + aLocale = new com.sun.star.lang.Locale(); + aLocale.Country = java.util.Locale.getDefault().getCountry(); + aLocale.Language = java.util.Locale.getDefault().getLanguage(); + aLocale.Variant = java.util.Locale.getDefault().getVariant(); + } + + String sLanguage = aLocale.Language; + String sCountry = aLocale.Country; + String sVariant = aLocale.Variant; + + // de-DE-Bayrisch + StringBuffer aLocaleAll = new StringBuffer(); + aLocaleAll.append(sLanguage).append('-').append(sCountry).append('-').append(sVariant); + String sPath = _sPath + "/" + aLocaleAll.toString(); + + XInterface xInterface = (XInterface) _xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface); + if (xSimpleFileAccess.exists(sPath)) + { + return sPath; + } + + // de-DE + StringBuffer aLocaleLang_Country = new StringBuffer(); + aLocaleLang_Country.append(sLanguage).append('-').append(sCountry); + sPath = _sPath + "/" + aLocaleLang_Country.toString(); + + if (xSimpleFileAccess.exists(sPath)) + { + return sPath; + } + + // de + StringBuffer aLocaleLang = new StringBuffer(); + aLocaleLang.append(sLanguage); + sPath = _sPath + "/" + aLocaleLang.toString(); + + if (xSimpleFileAccess.exists(sPath)) + { + return sPath; + } + + // the absolute default is en-US or en + sPath = _sPath + "/en-US"; + if (xSimpleFileAccess.exists(sPath)) + { + return sPath; + } + + sPath = _sPath + "/en"; + if (xSimpleFileAccess.exists(sPath)) + { + return sPath; + } + + // java.util.Locale jl = new java.util.Locale( + // l.Language , l.Country, l.Variant ); + } + catch (com.sun.star.uno.Exception e) + { + } + + return _sPath; + } + + /* + public static String getOfficePath(XMultiServiceFactory xMSF, String sPath, String sType) throws NoValidPathException { + String ResultPath = ""; + Object oPathSettings; + int iPathCount; + String[] PathList; + boolean bexists = false; + try { + XInterface xUcbInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface); + ResultPath = getOfficePath(xMSF, sPath, xSimpleFileAccess); + PathList = JavaTools.ArrayoutofString(ResultPath, ";"); + if (!sType.equals("")) { + ResultPath = ""; + String CurPath = ""; + String EndString = "/" + sType; + int EndLength = EndString.length(); + sType = "/" + sType + "/"; + int MaxIndex = PathList.length - 1; + int iPos; + for (int i = 0; i <= MaxIndex; i++) { + CurPath = PathList[i]; + iPos = CurPath.length() - EndLength; + if ((CurPath.indexOf(sType) > 0) || (CurPath.indexOf(EndString) == iPos)) { + ResultPath = deleteLastSlashfromUrl(CurPath); + if (xSimpleFileAccess.exists(ResultPath)) + break; + } + } + } else + ResultPath = PathList[0]; + if (ResultPath.equals("") == false) + bexists = xSimpleFileAccess.exists(ResultPath); + } catch (Exception exception) { + exception.printStackTrace(System.out); + ResultPath = ""; + } + if (bexists == false) + throw new NoValidPathException(xMSF); + return ResultPath; + } + **/ + public static void combinePaths(XMultiServiceFactory xMSF, ArrayList _aFirstPath, String _sSecondPath) throws NoValidPathException + { + for (int i = 0; i < _aFirstPath.size(); ++i) + { + String sOnePath = (String) _aFirstPath.get(i); + sOnePath = addPath(sOnePath, _sSecondPath); + if (isPathValid(xMSF, sOnePath)) + { + _aFirstPath.add(i, sOnePath); + _aFirstPath.remove(i + 1); + } + else + { + _aFirstPath.remove(i); + --i; + } + } + } + + public static boolean isPathValid(XMultiServiceFactory xMSF, String _sPath) + { + boolean bExists = false; + try + { + XInterface xUcbInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface); + bExists = xSimpleFileAccess.exists(_sPath); + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + } + return bExists; + } + + public static String combinePaths(XMultiServiceFactory xMSF, String _sFirstPath, String _sSecondPath) throws NoValidPathException + { + boolean bexists = false; + String ReturnPath = ""; + try + { + XInterface xUcbInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface); + ReturnPath = _sFirstPath + _sSecondPath; + bexists = xSimpleFileAccess.exists(ReturnPath); + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + return ""; + } + if (bexists == false) + { + throw new NoValidPathException(xMSF, ""); + } + return ReturnPath; + } + + public static boolean createSubDirectory(XMultiServiceFactory xMSF, XSimpleFileAccess xSimpleFileAccess, String Path) + { + String sNoDirCreation = ""; + try + { + Resource oResource = new Resource(xMSF, "ImportWizard", "imp"); + if (oResource != null) + { + sNoDirCreation = oResource.getResText(1050); + String sMsgDirNotThere = oResource.getResText(1051); + String sQueryForNewCreation = oResource.getResText(1052); + String OSPath = JavaTools.convertfromURLNotation(Path); + String sQueryMessage = JavaTools.replaceSubString(sMsgDirNotThere, OSPath, "%1"); + sQueryMessage = sQueryMessage + (char) 13 + sQueryForNewCreation; + int icreate = SystemDialog.showMessageBox(xMSF, "QueryBox", VclWindowPeerAttribute.YES_NO, sQueryMessage); + if (icreate == 2) + { + xSimpleFileAccess.createFolder(Path); + return true; + } + } + return false; + } + catch (com.sun.star.ucb.CommandAbortedException exception) + { + String sMsgNoDir = JavaTools.replaceSubString(sNoDirCreation, Path, "%1"); + SystemDialog.showMessageBox(xMSF, "ErrorBox", VclWindowPeerAttribute.OK, sMsgNoDir); + return false; + } + catch (com.sun.star.uno.Exception unoexception) + { + String sMsgNoDir = JavaTools.replaceSubString(sNoDirCreation, Path, "%1"); + SystemDialog.showMessageBox(xMSF, "ErrorBox", VclWindowPeerAttribute.OK, sMsgNoDir); + return false; + } + } + + // checks if the root of a path exists. if the parameter xWindowPeer is not null then also the directory is + // created when it does not exists and the user + public static boolean PathisValid(XMultiServiceFactory xMSF, String Path, String sMsgFilePathInvalid, boolean baskbeforeOverwrite) + { + try + { + String SubDir; + String SubDirPath = ""; + int SubLen; + int NewLen; + int RestLen; + boolean bexists; + boolean bSubDirexists = true; + String LowerCasePath; + String NewPath = Path; + XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface); + if (baskbeforeOverwrite) + { + if (xSimpleFileAccess.exists(Path)) + { + Resource oResource = new Resource(xMSF, "ImportWizard", "imp"); + String sFileexists = oResource.getResText(1053); + String NewString = JavaTools.convertfromURLNotation(Path); + sFileexists = JavaTools.replaceSubString(sFileexists, NewString, "<1>"); + sFileexists = JavaTools.replaceSubString(sFileexists, String.valueOf((char) 13), "<CR>"); + int iLeave = SystemDialog.showMessageBox(xMSF, "QueryBox", VclWindowPeerAttribute.YES_NO, sFileexists); + if (iLeave == 3) + { + return false; + } + } + } + String[] DirArray = JavaTools.ArrayoutofString(Path, "/"); + int MaxIndex = DirArray.length - 1; + if (MaxIndex > 0) + { + for (int i = MaxIndex; i >= 0; i--) + { + SubDir = DirArray[i]; + SubLen = SubDir.length(); + NewLen = NewPath.length(); + RestLen = NewLen - SubLen; + if (RestLen > 0) + { + NewPath = NewPath.substring(0, NewLen - SubLen - 1); + if (i == MaxIndex) + { + SubDirPath = NewPath; + } + bexists = xSimpleFileAccess.exists(NewPath); + if (bexists) + { + LowerCasePath = NewPath.toLowerCase(); + bexists = (((LowerCasePath.equals("file:///")) || (LowerCasePath.equals("file://")) || (LowerCasePath.equals("file:/")) || (LowerCasePath.equals("file:"))) == false); + } + if (bexists) + { + if (bSubDirexists == false) + { + boolean bSubDiriscreated = createSubDirectory(xMSF, xSimpleFileAccess, SubDirPath); + return bSubDiriscreated; + } + return true; + } + else + { + bSubDirexists = false; + } + } + } + } + SystemDialog.showMessageBox(xMSF, "ErrorBox", VclWindowPeerAttribute.OK, sMsgFilePathInvalid); + return false; + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.out); + SystemDialog.showMessageBox(xMSF, "ErrorBox", VclWindowPeerAttribute.OK, sMsgFilePathInvalid); + return false; + } + } + + /** + * searches a directory for files which start with a certain + * prefix, and returns their URLs and document-titles. + * @param xMSF + * @param FilterName the prefix of the filename. a "-" is added to the prefix ! + * @param FolderName the folder (URL) to look for files... + * @return an array with two array members. The first one, with document titles, + * the second with the corresponding URLs. + * @deprecated please use the getFolderTitles() with ArrayList + */ + public static String[][] getFolderTitles(com.sun.star.lang.XMultiServiceFactory xMSF, String FilterName, String FolderName) + { + String[][] LocLayoutFiles = new String[2][]; //{"",""}{""}; + try + { + java.util.Vector<String> TitleVector = null; + java.util.Vector<String> NameVector = null; + + XInterface xDocInterface = (XInterface) xMSF.createInstance("com.sun.star.document.DocumentProperties"); + XDocumentProperties xDocProps = (XDocumentProperties) UnoRuntime.queryInterface(XDocumentProperties.class, xDocInterface); + + XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + com.sun.star.ucb.XSimpleFileAccess xSimpleFileAccess = (com.sun.star.ucb.XSimpleFileAccess) UnoRuntime.queryInterface(com.sun.star.ucb.XSimpleFileAccess.class, xInterface); + + String[] nameList = xSimpleFileAccess.getFolderContents(FolderName, false); + + TitleVector = new java.util.Vector<String>(/*nameList.length*/); + NameVector = new java.util.Vector<String>(nameList.length); + + FilterName = FilterName == null || FilterName.equals("") ? null : FilterName + "-"; + + String fileName = ""; + PropertyValue[] noArgs = { }; + for (int i = 0; i < nameList.length; i++) + { + fileName = getFilename(nameList[i]); + + if (FilterName == null || fileName.startsWith(FilterName)) + { + xDocProps.loadFromMedium(nameList[i], noArgs); + NameVector.addElement(nameList[i]); + TitleVector.addElement(xDocProps.getTitle()); + } + } + String[] LocNameList = new String[NameVector.size()]; + String[] LocTitleList = new String[TitleVector.size()]; + + NameVector.copyInto(LocNameList); + TitleVector.copyInto(LocTitleList); + LocLayoutFiles[1] = LocNameList; + LocLayoutFiles[0] = LocTitleList; + + JavaTools.bubblesortList(LocLayoutFiles); + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + } + return LocLayoutFiles; + } + + /** + * We search in all given path for a given file + * @param _sPath + * @param _sPath2 + * @return + */ + public static String addPath(String _sPath, String _sPath2) + { + String sNewPath; + if (!_sPath.endsWith("/")) + { + _sPath += "/"; + } + if (_sPath2.startsWith("/")) + { + _sPath2 = _sPath2.substring(1); + } + sNewPath = _sPath + _sPath2; + return sNewPath; + } + + public static String getPathFromList(XMultiServiceFactory xMSF, ArrayList _aList, String _sFile) + { + String sFoundFile = ""; + try + { + XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + com.sun.star.ucb.XSimpleFileAccess xSimpleFileAccess = (com.sun.star.ucb.XSimpleFileAccess) UnoRuntime.queryInterface(com.sun.star.ucb.XSimpleFileAccess.class, xInterface); + + for (int i = 0; i < _aList.size(); i++) + { + String sPath = (String) _aList.get(i); + sPath = addPath(sPath, _sFile); + if (xSimpleFileAccess.exists(sPath)) + { + sFoundFile = sPath; + } + } + } + catch (com.sun.star.uno.Exception e) + { + } + return sFoundFile; + } + + /** + * + * @param xMSF + * @param _sStartFilterName + * @param FolderNames + * @return + * @throws com.sun.star.wizards.common.NoValidPathException + */ + public static String[][] getFolderTitles(com.sun.star.lang.XMultiServiceFactory xMSF, String _sStartFilterName, ArrayList FolderNames) + throws NoValidPathException + { + return getFolderTitles(xMSF, _sStartFilterName, FolderNames, ""); + } + + private static String getTitle(XMultiServiceFactory xMSF, String _sFile) + { + String sTitle = ""; + try + { + XInterface xDocInterface = (XInterface) xMSF.createInstance("com.sun.star.document.DocumentProperties"); + XDocumentProperties xDocProps = (XDocumentProperties) UnoRuntime.queryInterface(XDocumentProperties.class, xDocInterface); + PropertyValue[] noArgs = { }; + xDocProps.loadFromMedium(_sFile, noArgs); + sTitle = xDocProps.getTitle(); + } + catch (Exception e) + { + } + return sTitle; + } + + public static String[][] getFolderTitles(com.sun.star.lang.XMultiServiceFactory xMSF, String _sStartFilterName, ArrayList FolderName, String _sEndFilterName) + throws NoValidPathException + { + String[][] LocLayoutFiles = new String[2][]; //{"",""}{""}; + if (FolderName.size() == 0) + { + throw new NoValidPathException(null, "Path not given."); + } + ArrayList<String> TitleVector = new ArrayList<String>(); + ArrayList<String> URLVector = new ArrayList<String>(); + + com.sun.star.ucb.XSimpleFileAccess xSimpleFileAccess = null; + try + { + XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + xSimpleFileAccess = (com.sun.star.ucb.XSimpleFileAccess) UnoRuntime.queryInterface(com.sun.star.ucb.XSimpleFileAccess.class, xInterface); + } + catch (com.sun.star.uno.Exception e) + { + e.printStackTrace(); + throw new NoValidPathException(null, "Internal error."); + } + + for (int j = 0; j < FolderName.size(); j++) + { + String sFolderName = (String) FolderName.get(j); + + try + { + String[] nameList = xSimpleFileAccess.getFolderContents(sFolderName, false); + _sStartFilterName = _sStartFilterName == null || _sStartFilterName.equals("") ? null : _sStartFilterName + "-"; + + String fileName = ""; + for (int i = 0; i < nameList.length; i++) + { + fileName = getFilename(nameList[i]); + String sTitle; + + if (_sStartFilterName == null || fileName.startsWith(_sStartFilterName)) + { + if (_sEndFilterName.equals("")) + { + sTitle = getTitle(xMSF, nameList[i]); + } + else if (fileName.endsWith(_sEndFilterName)) + { + fileName = fileName.replaceAll(_sEndFilterName + "$", ""); + sTitle = fileName; + } + else + { + // no or wrong (start|end) filter + continue; + } + URLVector.add(nameList[i]); + TitleVector.add(sTitle); + } + } + } + catch (com.sun.star.ucb.CommandAbortedException exception) + { + exception.printStackTrace(System.out); + } + catch (com.sun.star.uno.Exception e) + { + } + } + + String[] LocNameList = new String[URLVector.size()]; + String[] LocTitleList = new String[TitleVector.size()]; + + // LLA: we have to check if this works + URLVector.toArray(LocNameList); + TitleVector.toArray(LocTitleList); + + LocLayoutFiles[1] = LocNameList; + LocLayoutFiles[0] = LocTitleList; + + JavaTools.bubblesortList(LocLayoutFiles); + + return LocLayoutFiles; + } + public XSimpleFileAccess2 fileAccess; + public XFileIdentifierConverter filenameConverter; + + public FileAccess(XMultiServiceFactory xmsf) throws com.sun.star.uno.Exception + { + //get a simple file access... + Object fa = xmsf.createInstance("com.sun.star.ucb.SimpleFileAccess"); + fileAccess = (XSimpleFileAccess2) UnoRuntime.queryInterface(XSimpleFileAccess2.class, fa); + //get the file identifier converter + Object fcv = xmsf.createInstance("com.sun.star.ucb.FileContentProvider"); + filenameConverter = (XFileIdentifierConverter) UnoRuntime.queryInterface(XFileIdentifierConverter.class, fcv); + } + + public String getURL(String parentPath, String childPath) + { + String parent = filenameConverter.getSystemPathFromFileURL(parentPath); + File f = new File(parent, childPath); + String r = filenameConverter.getFileURLFromSystemPath(parentPath, f.getAbsolutePath()); + return r; + } + + public String getURL(String path) + { + File f = new File(path); + String r = filenameConverter.getFileURLFromSystemPath( + path, f.getAbsolutePath()); + return r; + } + + public String getPath(String parentURL, String childURL) + { + return filenameConverter.getSystemPathFromFileURL(parentURL + (((childURL == null || childURL.equals("")) ? "" : "/" + childURL))); + } + + /** + * @author rpiterman + * @param filename + * @return the extension of the given filename. + */ + public static String getExtension(String filename) + { + int p = filename.indexOf("."); + if (p == -1) + { + return ""; + } + else + { + do + { + filename = filename.substring(p + 1); + } + while ((p = filename.indexOf(".")) > -1); + } + return filename; + } + + /** + * @author rpiterman + * @param s + * @return + */ + public boolean mkdir(String s) + { + try + { + fileAccess.createFolder(s); + return true; + } + catch (CommandAbortedException cax) + { + cax.printStackTrace(); + } + catch (com.sun.star.uno.Exception ex) + { + ex.printStackTrace(); + } + return false; + } + + /** + * @author rpiterman + * @param filename + * @param def what to return in case of an exception + * @return true if the given file exists or not. + * if an exception accures, returns the def value. + */ + public boolean exists(String filename, boolean def) + { + try + { + return fileAccess.exists(filename); + } + catch (CommandAbortedException e) + { + } + catch (Exception e) + { + } + + return def; + } + + /** + * @author rpiterman + * @param filename + * @return + */ + public boolean isDirectory(String filename) + { + try + { + return fileAccess.isFolder(filename); + } + catch (CommandAbortedException e) + { + } + catch (Exception e) + { + } + + return false; + } + + /** + * lists the files in a given directory + * @author rpiterman + * @param dir + * @param includeFolders + * @return + */ + public String[] listFiles(String dir, boolean includeFolders) + { + try + { + return fileAccess.getFolderContents(dir, includeFolders); + } + catch (CommandAbortedException e) + { + } + catch (Exception e) + { + } + + return new String[0]; + } + + /** + * @author rpiterman + * @param file + * @return + */ + public boolean delete(String file) + { + try + { + fileAccess.kill(file); + return true; + } + catch (CommandAbortedException e) + { + e.printStackTrace(System.out); + } + catch (Exception e) + { + e.printStackTrace(System.out); + } + + return false; + } + + /** + * @author rpiterman + * @param path + * @return + */ + public static String getFilename(String path) + { + return getFilename(path, "/"); + } + + /** + * return the filename out of a system-dependent path + * @param path + * @return + */ + public static String getPathFilename(String path) + { + return getFilename(path, File.separator); + } + + /** + * @author rpiterman + * @param path + * @param pathSeparator + * @return + */ + public static String getFilename(String path, String pathSeparator) + { + String[] s = JavaTools.ArrayoutofString(path, pathSeparator); + return s[s.length - 1]; + } + + public static String getBasename(String path, String pathSeparator) + { + String filename = getFilename(path, pathSeparator); + String sExtension = getExtension(filename); + String basename = filename.substring(0, filename.length() - (sExtension.length() + 1)); + return basename; + } + + /** + * @author rpiterman + * @param source + * @param target + * @return + */ + public boolean copy(String source, String target) + { + try + { + fileAccess.copy(source, target); + return true; + } + catch (CommandAbortedException e) + { + } + catch (Exception e) + { + } + + return false; + } + + public DateTime getLastModified(String url) + { + try + { + return fileAccess.getDateTimeModified(url); + } + catch (CommandAbortedException e) + { + } + catch (Exception e) + { + } + return null; + } + + /** + * + * @param url + * @return the parent dir of the given url. + * if the path points to file, gives the directory in which the file is. + */ + public static String getParentDir(String url) + { + if (url.endsWith("/")) + { + return getParentDir(url.substring(0, url.length() - 1)); + } + int pos = -1; + int lastPos = 0; + while ((pos = url.indexOf("/", pos + 1)) > -1) + { + lastPos = pos; + } + return url.substring(0, lastPos); + } + + public String createNewDir(String parentDir, String name) + { + String s = getNewFile(parentDir, name, ""); + if (mkdir(s)) + { + return s; + } + else + { + return null; + } + } + + public String getNewFile(String parentDir, String name, String extension) + { + + int i = 0; + String url; + do + { + String filename = filename(name, extension, i++); + String u = getURL(parentDir, filename); + url = u; + } + while (exists(url, true)); + + return url; + } + + private static String filename(String name, String ext, int i) + { + return name + (i == 0 ? "" : String.valueOf(i)) + (ext.equals("") ? "" : "." + ext); + } + + public int getSize(String url) + { + try + { + return fileAccess.getSize(url); + } + catch (Exception ex) + { + return -1; + } + } + + public static String connectURLs(String urlFolder, String urlFilename) + { + return urlFolder + (urlFolder.endsWith("/") ? "" : "/") + + (urlFilename.startsWith("/") ? urlFilename.substring(1) : urlFilename); + } + + public static String[] getDataFromTextFile(XMultiServiceFactory _xMSF, String _filepath) + { + String[] sFileData = null; + try + { + Vector<String> oDataVector = new Vector<String>(); + Object oSimpleFileAccess = _xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, oSimpleFileAccess); + if (xSimpleFileAccess.exists(_filepath)) + { + XInputStream xInputStream = xSimpleFileAccess.openFileRead(_filepath); + Object oTextInputStream = _xMSF.createInstance("com.sun.star.io.TextInputStream"); + XTextInputStream xTextInputStream = (XTextInputStream) UnoRuntime.queryInterface(XTextInputStream.class, oTextInputStream); + XActiveDataSink xActiveDataSink = (XActiveDataSink) UnoRuntime.queryInterface(XActiveDataSink.class, oTextInputStream); + xActiveDataSink.setInputStream(xInputStream); + while (!xTextInputStream.isEOF()) + { + oDataVector.addElement( xTextInputStream.readLine()); + } + xTextInputStream.closeInput(); + sFileData = new String[oDataVector.size()]; + oDataVector.toArray(sFileData); + + } + } + catch (Exception e) + { + e.printStackTrace(System.out); + } + return sFileData; + } + + /** + * shortens a filename to a user displayable representation. + * @param path + * @param maxLength + * @return + */ + public static String getShortFilename(String path, int maxLength) + { + int firstPart = 0; + + if (path.length() > maxLength) + { + if (path.startsWith("/")) + { // unix + int nextSlash = path.indexOf("/", 1) + 1; + firstPart = Math.min(nextSlash, (maxLength - 3) / 2); + } + else + { //windows + firstPart = Math.min(10, (maxLength - 3) / 2); + } + + String s1 = path.substring(0, firstPart); + String s2 = path.substring(path.length() - (maxLength - (3 + firstPart))); + + return s1 + "..." + s2; + } + else + { + return path; + } + } +} diff --git a/wizards/com/sun/star/wizards/common/HelpIds.java b/wizards/com/sun/star/wizards/common/HelpIds.java new file mode 100644 index 000000000000..ad8faa2b2d42 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/HelpIds.java @@ -0,0 +1,1047 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +public class HelpIds +{ + private static String array1[] = new String[] + { + "HID:WIZARDS_HID0_WEBWIZARD", // HID:34200 + "HID:WIZARDS_HID0_HELP", // HID:34201 + "HID:WIZARDS_HID0_NEXT", // HID:34202 + "HID:WIZARDS_HID0_PREV", // HID:34203 + "HID:WIZARDS_HID0_CREATE", // HID:34204 + "HID:WIZARDS_HID0_CANCEL", // HID:34205 + "HID:WIZARDS_HID0_STATUS_DIALOG", // HID:34206 + "HID:WIZARDS_HID1_LST_SESSIONS", // HID:34207 + "", + "HID:WIZARDS_HID1_BTN_DEL_SES", // HID:34209 + "HID:WIZARDS_HID2_LST_DOCS", // HID:34210 + "HID:WIZARDS_HID2_BTN_ADD_DOC", // HID:34211 + "HID:WIZARDS_HID2_BTN_REM_DOC", // HID:34212 + "HID:WIZARDS_HID2_BTN_DOC_UP", // HID:34213 + "HID:WIZARDS_HID2_BTN_DOC_DOWN", // HID:34214 + "HID:WIZARDS_HID2_TXT_DOC_TITLE", // HID:34215 + "HID:WIZARDS_HID2_TXT_DOC_DESC", // HID:34216 + "HID:WIZARDS_HID2_TXT_DOC_AUTHOR", // HID:34217 + "HID:WIZARDS_HID2_LST_DOC_EXPORT", // HID:34218 + "HID:WIZARDS_HID2_STATUS_ADD_DOCS", // HID:34219 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG1", // HID:34220 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG2", // HID:34221 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG3", // HID:34222 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG4", // HID:34223 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG5", // HID:34224 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG6", // HID:34225 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG7", // HID:34226 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG8", // HID:34227 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG9", // HID:34228 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG10", // HID:34229 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG11", // HID:34230 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG12", // HID:34231 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG13", // HID:34232 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG14", // HID:34233 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG15", // HID:34234 + "HID:WIZARDS_HID4_CHK_DISPLAY_FILENAME", // HID:34235 + "HID:WIZARDS_HID4_CHK_DISPLAY_DESCRIPTION", // HID:34236 + "HID:WIZARDS_HID4_CHK_DISPLAY_AUTHOR", // HID:34237 + "HID:WIZARDS_HID4_CHK_DISPLAY_CR_DATE", // HID:34238 + "HID:WIZARDS_HID4_CHK_DISPLAY_UP_DATE", // HID:34239 + "HID:WIZARDS_HID4_CHK_DISPLAY_FORMAT", // HID:34240 + "HID:WIZARDS_HID4_CHK_DISPLAY_F_ICON", // HID:34241 + "HID:WIZARDS_HID4_CHK_DISPLAY_PAGES", // HID:34242 + "HID:WIZARDS_HID4_CHK_DISPLAY_SIZE", // HID:34243 + "HID:WIZARDS_HID4_GRP_OPTIMAIZE_640", // HID:34244 + "HID:WIZARDS_HID4_GRP_OPTIMAIZE_800", // HID:34245 + "HID:WIZARDS_HID4_GRP_OPTIMAIZE_1024", // HID:34246 + "HID:WIZARDS_HID5_LST_STYLES", // HID:34247 + "HID:WIZARDS_HID5_BTN_BACKGND", // HID:34248 + "HID:WIZARDS_HID5_BTN_ICONS", // HID:34249 + "HID:WIZARDS_HID6_TXT_SITE_TITLE", // HID:34250 + "", + "", + "HID:WIZARDS_HID6_TXT_SITE_DESC", // HID:34253 + "", + "HID:WIZARDS_HID6_DATE_SITE_CREATED", // HID:34255 + "HID:WIZARDS_HID6_DATE_SITE_UPDATED", // HID:34256 + "", + "HID:WIZARDS_HID6_TXT_SITE_EMAIL", // HID:34258 + "HID:WIZARDS_HID6_TXT_SITE_COPYRIGHT", // HID:34259 + "HID:WIZARDS_HID7_BTN_PREVIEW", // HID:34260 + "HID:WIZARDS_HID7_CHK_PUBLISH_LOCAL", // HID:34261 + "HID:WIZARDS_HID7_TXT_LOCAL", // HID:34262 + "HID:WIZARDS_HID7_BTN_LOCAL", // HID:34263 + "HID:WIZARDS_HID7_CHK_PUBLISH_ZIP", // HID:34264 + "HID:WIZARDS_HID7_TXT_ZIP", // HID:34265 + "HID:WIZARDS_HID7_BTN_ZIP", // HID:34266 + "HID:WIZARDS_HID7_CHK_PUBLISH_FTP", // HID:34267 + "HID:WIZARDS_HID7_TXT_FTP", // HID:34268 + "HID:WIZARDS_HID7_BTN_FTP", // HID:34269 + "HID:WIZARDS_HID7_CHK_SAVE", // HID:34270 + "HID:WIZARDS_HID7_TXT_SAVE", // HID:34271 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_BG", // HID:34290 + "HID:WIZARDS_HID_BG_BTN_OTHER", // HID:34291 + "HID:WIZARDS_HID_BG_BTN_NONE", // HID:34292 + "HID:WIZARDS_HID_BG_BTN_OK", // HID:34293 + "HID:WIZARDS_HID_BG_BTN_CANCEL", // HID:34294 + "HID:WIZARDS_HID_BG_BTN_BACK", // HID:34295 + "HID:WIZARDS_HID_BG_BTN_FW", // HID:34296 + "HID:WIZARDS_HID_BG_BTN_IMG1", // HID:34297 + "HID:WIZARDS_HID_BG_BTN_IMG2", // HID:34298 + "HID:WIZARDS_HID_BG_BTN_IMG3", // HID:34299 + "HID:WIZARDS_HID_BG_BTN_IMG4", // HID:34300 + "HID:WIZARDS_HID_BG_BTN_IMG5", // HID:34301 + "HID:WIZARDS_HID_BG_BTN_IMG6", // HID:34302 + "HID:WIZARDS_HID_BG_BTN_IMG7", // HID:34303 + "HID:WIZARDS_HID_BG_BTN_IMG8", // HID:34304 + "HID:WIZARDS_HID_BG_BTN_IMG9", // HID:34305 + "HID:WIZARDS_HID_BG_BTN_IMG10", // HID:34306 + "HID:WIZARDS_HID_BG_BTN_IMG11", // HID:34307 + "HID:WIZARDS_HID_BG_BTN_IMG12", // HID:34308 + "HID:WIZARDS_HID_BG_BTN_IMG13", // HID:34309 + "HID:WIZARDS_HID_BG_BTN_IMG14", // HID:34300 + "HID:WIZARDS_HID_BG_BTN_IMG15", // HID:34311 + "HID:WIZARDS_HID_BG_BTN_IMG16", // HID:34312 + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGREPORT_DIALOG", // HID:34320 + "", + "HID:WIZARDS_HID_DLGREPORT_0_CMDPREV", // HID:34322 + "HID:WIZARDS_HID_DLGREPORT_0_CMDNEXT", // HID:34323 + "HID:WIZARDS_HID_DLGREPORT_0_CMDFINISH", // HID:34324 + "HID:WIZARDS_HID_DLGREPORT_0_CMDCANCEL", // HID:34325 + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGREPORT_1_LBTABLES", // HID:34330 + "HID:WIZARDS_HID_DLGREPORT_1_FIELDSAVAILABLE", // HID:34331 + "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVESELECTED", // HID:34332 + "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVEALL", // HID:34333 + "HID:WIZARDS_HID_DLGREPORT_1_CMDREMOVESELECTED", // HID:34334 + "HID:WIZARDS_HID_DLGREPORT_1_CMDREMOVEALL", // HID:34335 + "HID:WIZARDS_HID_DLGREPORT_1_FIELDSSELECTED", // HID:34336 + "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVEUP", // HID:34337 + "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVEDOWN", // HID:34338 + "", + "HID:WIZARDS_HID_DLGREPORT_2_GROUPING", // HID:34340 + "HID:WIZARDS_HID_DLGREPORT_2_CMDGROUP", // HID:34341 + "HID:WIZARDS_HID_DLGREPORT_2_CMDUNGROUP", // HID:34342 + "HID:WIZARDS_HID_DLGREPORT_2_PREGROUPINGDEST", // HID:34343 + "HID:WIZARDS_HID_DLGREPORT_2_CMDMOVEUPGROUP", // HID:34344 + "HID:WIZARDS_HID_DLGREPORT_2_CMDMOVEDOWNGROUP", // HID:34345 + "HID:WIZARDS_HID_DLGREPORT_3_SORT1", // HID:34346 + "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND1", // HID:34347 + "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND1", // HID:34348 + "HID:WIZARDS_HID_DLGREPORT_3_SORT2", // HID:34349 + "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND2", // HID:34350 + "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND2", // HID:34351 + "HID:WIZARDS_HID_DLGREPORT_3_SORT3", // HID:34352 + "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND3", // HID:34353 + "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND3", // HID:34354 + "HID:WIZARDS_HID_DLGREPORT_3_SORT4", // HID:34355 + "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND4", // HID:34356 + "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND4", // HID:34357 + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGREPORT_4_TITLE", // HID:34362 + "HID:WIZARDS_HID_DLGREPORT_4_DATALAYOUT", // HID:34363 + "HID:WIZARDS_HID_DLGREPORT_4_PAGELAYOUT", // HID:34364 + "HID:WIZARDS_HID_DLGREPORT_4_LANDSCAPE", // HID:34365 + "HID:WIZARDS_HID_DLGREPORT_4_PORTRAIT", // HID:34366 + "", + "", + "", + "HID:WIZARDS_HID_DLGREPORT_5_OPTDYNTEMPLATE", // HID:34370 + "HID:WIZARDS_HID_DLGREPORT_5_OPTSTATDOCUMENT", // HID:34371 + "HID:WIZARDS_HID_DLGREPORT_5_TXTTEMPLATEPATH", // HID:34372 + "HID:WIZARDS_HID_DLGREPORT_5_CMDTEMPLATEPATH", // HID:34373 + "HID:WIZARDS_HID_DLGREPORT_5_OPTEDITTEMPLATE", // HID:34374 + "HID:WIZARDS_HID_DLGREPORT_5_OPTUSETEMPLATE", // HID:34375 + "HID:WIZARDS_HID_DLGREPORT_5_TXTDOCUMENTPATH", // HID:34376 + "HID:WIZARDS_HID_DLGREPORT_5_CMDDOCUMENTPATH", // HID:34377 + "HID:WIZARDS_HID_DLGREPORT_5_CHKLINKTODB", // HID:34378 + "", + "", + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_1", // HID:34381 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_2", // HID:34382 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_3", // HID:34383 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_4", // HID:34384 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_5", // HID:34385 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_6", // HID:34386 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_7", // HID:34387 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGFORM_DIALOG", // HID:34400 + "", + "HID:WIZARDS_HID_DLGFORM_CMDPREV", // HID:34402 + "HID:WIZARDS_HID_DLGFORM_CMDNEXT", // HID:34403 + "HID:WIZARDS_HID_DLGFORM_CMDFINISH", // HID:34404 + "HID:WIZARDS_HID_DLGFORM_CMDCANCEL", // HID:34405 + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGFORM_MASTER_LBTABLES", // HID:34411 + "HID:WIZARDS_HID_DLGFORM_MASTER_FIELDSAVAILABLE", // HID:34412 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVESELECTED", // HID:34413 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVEALL", // HID:34414 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDREMOVESELECTED", // HID:34415 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDREMOVEALL", // HID:34416 + "HID:WIZARDS_HID_DLGFORM_MASTER_FIELDSSELECTED", // HID:34417 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVEUP", // HID:34418 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVEDOWN", // HID:34419 + "", + "HID:WIZARDS_HID_DLGFORM_CHKCREATESUBFORM", // HID:34421 + "HID:WIZARDS_HID_DLGFORM_OPTONEXISTINGRELATION", // HID:34422 + "HID:WIZARDS_HID_DLGFORM_OPTSELECTMANUALLY", // HID:34423 + "HID:WIZARDS_HID_DLGFORM_lstRELATIONS", // HID:34424 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGFORM_SUB_LBTABLES", // HID:34431 + "HID:WIZARDS_HID_DLGFORM_SUB_FIELDSAVAILABLE", // HID:34432 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVESELECTED", // HID:34433 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVEALL", // HID:34434 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDREMOVESELECTED", // HID:34435 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDREMOVEALL", // HID:34436 + "HID:WIZARDS_HID_DLGFORM_SUB_FIELDSSELECTED", // HID:34437 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVEUP", // HID:34438 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVEDOWN", // HID:34439 + "", + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK1", // HID:34441 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK1", // HID:34442 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK2", // HID:34443 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK2", // HID:34444 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK3", // HID:34445 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK3", // HID:34446 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK4", // HID:34447 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK4", // HID:34448 + "", + "", + "HID:WIZARDS_HID_DLGFORM_CMDALIGNLEFT", // HID:34451 + "HID:WIZARDS_HID_DLGFORM_CMDALIGNRIGHT", // HID:34452 + "HID:WIZARDS_HID_DLGFORM_CMDLEFTLABELED", // HID:34453 + "HID:WIZARDS_HID_DLGFORM_CMDTOPLABELED", // HID:34454 + "HID:WIZARDS_HID_DLGFORM_CMDTABLESTYLE", // HID:34455 + "HID:WIZARDS_HID_DLGFORM_CMDTOPJUSTIFIED", // HID:34456 + "HID:WIZARDS_HID_DLGFORM_CMDLEFTLABELED2", // HID:34457 + "HID:WIZARDS_HID_DLGFORM_CMDTOPLABELED2", // HID:34458 + "HID:WIZARDS_HID_DLGFORM_CMDTABLESTYLE2", // HID:34459 + "HID:WIZARDS_HID_DLGFORM_CMDTOPJUSTIFIED2", // HID:34460 + "HID:WIZARDS_HID_DLGFORM_OPTNEWDATAONLY", // HID:34461 + "HID:WIZARDS_HID_DLGFORM_OPTDISPLAYALLDATA", // HID:34462 + "HID:WIZARDS_HID_DLGFORM_CHKNOMODIFICATION", // HID:34463 + "HID:WIZARDS_HID_DLGFORM_CHKNODELETION", // HID:34464 + "HID:WIZARDS_HID_DLGFORM_CHKNOADDITION", // HID:34465 + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGFORM_LSTSTYLES", // HID:34471 + "HID:WIZARDS_HID_DLGFORM_CMDNOBORDER", // HID:34472 + "HID:WIZARDS_HID_DLGFORM_CMD3DBORDER", // HID:34473 + "HID:WIZARDS_HID_DLGFORM_CMDSIMPLEBORDER", // HID:34474 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGFORM_TXTPATH", // HID:34481 + "HID:WIZARDS_HID_DLGFORM_OPTWORKWITHFORM", // HID:34482 + "HID:WIZARDS_HID_DLGFORM_OPTMODIFYFORM", // HID:34483 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGNEWSLTR_DIALOG", // HID:34500 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTSTANDARDLAYOUT", // HID:34501 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTPARTYLAYOUT", // HID:34502 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTBROCHURELAYOUT", // HID:34503 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTSINGLESIDED", // HID:34504 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTDOUBLESIDED", // HID:34505 + "HID:WIZARDS_HID_DLGNEWSLTR_CMDGOON", // HID:34506 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGDEPOT_DIALOG_SELLBUY", // HID:34520 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTSTOCKID_SELLBUY", // HID:34521 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTQUANTITY", // HID:34522 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTRATE", // HID:34523 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTDATE", // HID:34524 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTCOMMISSION", // HID:34525 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTFIX", // HID:34526 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTMINIMUM", // HID:34527 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDCANCEL_SELLBUY", // HID:34528 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDGOON_SELLBUY", // HID:34529 + "HID:WIZARDS_HID_DLGDEPOT_1_LSTSELLSTOCKS", // HID:34530 + "HID:WIZARDS_HID_DLGDEPOT_2_LSTBUYSTOCKS", // HID:34531 + "HID:WIZARDS_HID_DLGDEPOT_DIALOG_SPLIT", // HID:34532 + "HID:WIZARDS_HID_DLGDEPOT_0_LSTSTOCKNAMES", // HID:34533 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTSTOCKID_SPLIT", // HID:34534 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDCANCEL_SPLIT", // HID:34535 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDGOON_SPLIT", // HID:34536 + "HID:WIZARDS_HID_DLGDEPOT_1_OPTPERSHARE", // HID:34537 + "HID:WIZARDS_HID_DLGDEPOT_1_OPTTOTAL", // HID:34538 + "HID:WIZARDS_HID_DLGDEPOT_1_TXTDIVIDEND", // HID:34539 + "HID:WIZARDS_HID_DLGDEPOT_2_TXTOLDRATE", // HID:34540 + "HID:WIZARDS_HID_DLGDEPOT_2_TXTNEWRATE", // HID:34541 + "HID:WIZARDS_HID_DLGDEPOT_2_TXTDATE", // HID:34542 + "HID:WIZARDS_HID_DLGDEPOT_3_TXTSTARTDATE", // HID:34543 + "HID:WIZARDS_HID_DLGDEPOT_3_TXTENDDATE", // HID:34544 + "HID:WIZARDS_HID_DLGDEPOT_3_OPTDAILY", // HID:34545 + "HID:WIZARDS_HID_DLGDEPOT_3_OPTWEEKLY", // HID:34546 + "HID:WIZARDS_HID_DLGDEPOT_DIALOG_HISTORY", // HID:34547 + "HID:WIZARDS_HID_DLGDEPOT_LSTMARKETS", // HID:34548 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDCANCEL_HISTORY", // HID:34549 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDGOON_HISTORY", // HID:34550 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGIMPORT_DIALOG", // HID:34570 + "HID:WIZARDS_HID_DLGIMPORT_0_CMDHELP", // HID:34571 + "HID:WIZARDS_HID_DLGIMPORT_0_CMDCANCEL", // HID:34572 + "HID:WIZARDS_HID_DLGIMPORT_0_CMDPREV", // HID:34573 + "HID:WIZARDS_HID_DLGIMPORT_0_CMDNEXT", // HID:34574 + "HID:WIZARDS_HID_DLGIMPORT_0_OPTSODOCUMENTS", // HID:34575 + "HID:WIZARDS_HID_DLGIMPORT_0_OPTMSDOCUMENTS", // HID:34576 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKLOGFILE", // HID:34577 + "HID:WIZARDS_HID_DLGIMPORT_2_CHKWORD", // HID:34578 + "HID:WIZARDS_HID_DLGIMPORT_2_CHKEXCEL", // HID:34579 + "HID:WIZARDS_HID_DLGIMPORT_2_CHKPOWERPOINT", // HID:34580 + "HID:WIZARDS_HID_DLGIMPORT_2_CBTEMPLATE", // HID:34581 + "HID:WIZARDS_HID_DLGIMPORT_2_CBTEMPLATERECURSE", // HID:34582 + "HID:WIZARDS_HID_DLGIMPORT_2_LBTEMPLATEPATH", // HID:34583 + "HID:WIZARDS_HID_DLGIMPORT_2_EDTEMPLATEPATH", // HID:34584 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDTEMPLATEPATHSELECT", // HID:34585 + "HID:WIZARDS_HID_DLGIMPORT_2_CBDOCUMENT", // HID:34586 + "HID:WIZARDS_HID_DLGIMPORT_2_CBDOCUMENTRECURSE", // HID:34587 + "HID:WIZARDS_HID_DLGIMPORT_2_LBDOCUMENTPATH", // HID:34588 + "HID:WIZARDS_HID_DLGIMPORT_2_EDDOCUMENTPATH", // HID:34589 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDDOCUMENTPATHSELECT", // HID:34590 + "HID:WIZARDS_HID_DLGIMPORT_2_LBEXPORTDOCUMENTPATH", // HID:34591 + "HID:WIZARDS_HID_DLGIMPORT_2_EDEXPORTDOCUMENTPATH", // HID:34592 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDEXPORTPATHSELECT", // HID:34593 + "", + "HID:WIZARDS_HID_DLGIMPORT_3_TBSUMMARY", // HID:34595 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKWRITER", // HID:34596 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKCALC", // HID:34597 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKIMPRESS", // HID:34598 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKMATHGLOBAL", // HID:34599 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDTEMPLATEPATHSELECT2", // HID:34600 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDDOCUMENTPATHSELECT2", // HID:34601 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGCORRESPONDENCE_DIALOG", // HID:34630 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_CANCEL", // HID:34631 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONAGENDA1", // HID:34632 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONAGENDA2", // HID:34633 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_AGENDAOKAY", // HID:34634 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONLETTER1", // HID:34635 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONLETTER2", // HID:34636 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_LETTEROKAY", // HID:34637 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGSTYLES_DIALOG", // HID:34650 + "HID:WIZARDS_HID_DLGSTYLES_LISTBOX", // HID:34651 + "HID:WIZARDS_HID_DLGSTYLES_CANCEL", // HID:34652 + "HID:WIZARDS_HID_DLGSTYLES_OKAY", // HID:34653 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGCONVERT_DIALOG", // HID:34660 + "HID:WIZARDS_HID_DLGCONVERT_CHECKBOX1", // HID:34661 + "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON1", // HID:34662 + "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON2", // HID:34663 + "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON3", // HID:34664 + "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON4", // HID:34665 + "HID:WIZARDS_HID_DLGCONVERT_LISTBOX1", // HID:34666 + "HID:WIZARDS_HID_DLGCONVERT_OBFILE", // HID:34667 + "HID:WIZARDS_HID_DLGCONVERT_OBDIR", // HID:34668 + "HID:WIZARDS_HID_DLGCONVERT_COMBOBOX1", // HID:34669 + "HID:WIZARDS_HID_DLGCONVERT_TBSOURCE", // HID:34670 + "HID:WIZARDS_HID_DLGCONVERT_CHECKRECURSIVE", // HID:34671 + "HID:WIZARDS_HID_DLGCONVERT_TBTARGET", // HID:34672 + "HID:WIZARDS_HID_DLGCONVERT_CBCANCEL", // HID:34673 + "HID:WIZARDS_HID_DLGCONVERT_CBHELP", // HID:34674 + "HID:WIZARDS_HID_DLGCONVERT_CBBACK", // HID:34675 + "HID:WIZARDS_HID_DLGCONVERT_CBGOON", // HID:34676 + "HID:WIZARDS_HID_DLGCONVERT_CBSOURCEOPEN", // HID:34677 + "HID:WIZARDS_HID_DLGCONVERT_CBTARGETOPEN", // HID:34678 + "HID:WIZARDS_HID_DLGCONVERT_CHKPROTECT", // HID:34679 + "HID:WIZARDS_HID_DLGCONVERT_CHKTEXTDOCUMENTS", // HID:34680 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGPASSWORD_CMDGOON", // HID:34690 + "HID:WIZARDS_HID_DLGPASSWORD_CMDCANCEL", // HID:34691 + "HID:WIZARDS_HID_DLGPASSWORD_CMDHELP", // HID:34692 + "HID:WIZARDS_HID_DLGPASSWORD_TXTPASSWORD", // HID:34693 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGHOLIDAYCAL_DIALOG", // HID:34700 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_PREVIEW", // HID:34701 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_OPYEAR", // HID:34702 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_OPMONTH", // HID:34703 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_EDYEAR", // HID:34704 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_EDMONTH", // HID:34705 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_SPINYEAR", // HID:34706 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_SPINMONTH", // HID:34707 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_CMBSTATE", // HID:34708 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_LBOWNDATA", // HID:34709 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_CMDINSERT", // HID:34710 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_CMDDELETE", // HID:34711 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENT", // HID:34712 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_CHKEVENT", // HID:34713 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENTDAY", // HID:34714 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_SPINEVENTDAY", // HID:34715 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENTMONTH", // HID:34716 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_SPINEVENTMONTH", // HID:34717 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENTYEAR", // HID:34718 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_SPINEVENTYEAR", // HID:34719 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_0_CMDOWNDATA", // HID:34720 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_0_CMDCANCEL", // HID:34721 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_0_CMDOK" // HID:34722 + }; + private static String array2[] = new String[] + { + "HID:WIZARDS_HID_LTRWIZ_OPTBUSINESSLETTER", // HID:40769 + "HID:WIZARDS_HID_LTRWIZ_OPTPRIVOFFICIALLETTER", // HID:40770 + "HID:WIZARDS_HID_LTRWIZ_OPTPRIVATELETTER", // HID:40771 + "HID:WIZARDS_HID_LTRWIZ_LSTBUSINESSSTYLE", // HID:40772 + "HID:WIZARDS_HID_LTRWIZ_CHKBUSINESSPAPER", // HID:40773 + "HID:WIZARDS_HID_LTRWIZ_LSTPRIVOFFICIALSTYLE", // HID:40774 + "HID:WIZARDS_HID_LTRWIZ_LSTPRIVATESTYLE", // HID:40775 + "HID:WIZARDS_HID_LTRWIZ_CHKPAPERCOMPANYLOGO", // HID:40776 + "HID:WIZARDS_HID_LTRWIZ_NUMLOGOHEIGHT", // HID:40777 + "HID:WIZARDS_HID_LTRWIZ_NUMLOGOX", // HID:40778 + "HID:WIZARDS_HID_LTRWIZ_NUMLOGOWIDTH", // HID:40779 + "HID:WIZARDS_HID_LTRWIZ_NUMLOGOY", // HID:40780 + "HID:WIZARDS_HID_LTRWIZ_CHKPAPERCOMPANYADDRESS", // HID:40781 + "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSHEIGHT", // HID:40782 + "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSX", // HID:40783 + "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSWIDTH", // HID:40784 + "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSY", // HID:40785 + "HID:WIZARDS_HID_LTRWIZ_CHKCOMPANYRECEIVER", // HID:40786 + "HID:WIZARDS_HID_LTRWIZ_CHKPAPERFOOTER", // HID:40787 + "HID:WIZARDS_HID_LTRWIZ_NUMFOOTERHEIGHT", // HID:40788 + "HID:WIZARDS_HID_LTRWIZ_LSTLETTERNORM", // HID:40789 + "HID:WIZARDS_HID_LTRWIZ_CHKUSELOGO", // HID:40790 + "HID:WIZARDS_HID_LTRWIZ_CHKUSEADDRESSRECEIVER", // HID:40791 + "HID:WIZARDS_HID_LTRWIZ_CHKUSESIGNS", // HID:40792 + "HID:WIZARDS_HID_LTRWIZ_CHKUSESUBJECT", // HID:40793 + "HID:WIZARDS_HID_LTRWIZ_CHKUSESALUTATION", // HID:40794 + "HID:WIZARDS_HID_LTRWIZ_LSTSALUTATION", // HID:40795 + "HID:WIZARDS_HID_LTRWIZ_CHKUSEBENDMARKS", // HID:40796 + "HID:WIZARDS_HID_LTRWIZ_CHKUSEGREETING", // HID:40797 + "HID:WIZARDS_HID_LTRWIZ_LSTGREETING", // HID:40798 + "HID:WIZARDS_HID_LTRWIZ_CHKUSEFOOTER", // HID:40799 + "HID:WIZARDS_HID_LTRWIZ_OPTSENDERPLACEHOLDER", // HID:40800 + "HID:WIZARDS_HID_LTRWIZ_OPTSENDERDEFINE", // HID:40801 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERNAME", // HID:40802 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERSTREET", // HID:40803 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERPOSTCODE", // HID:40804 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERSTATE_TEXT", // HID:40805 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERCITY", // HID:40806 + "HID:WIZARDS_HID_LTRWIZ_OPTRECEIVERPLACEHOLDER", // HID:40807 + "HID:WIZARDS_HID_LTRWIZ_OPTRECEIVERDATABASE", // HID:40808 + "HID:WIZARDS_HID_LTRWIZ_TXTFOOTER", // HID:40809 + "HID:WIZARDS_HID_LTRWIZ_CHKFOOTERNEXTPAGES", // HID:40810 + "HID:WIZARDS_HID_LTRWIZ_CHKFOOTERPAGENUMBERS", // HID:40811 + "HID:WIZARDS_HID_LTRWIZ_TXTTEMPLATENAME", // HID:40812 + "HID:WIZARDS_HID_LTRWIZ_OPTCREATELETTER", // HID:40813 + "HID:WIZARDS_HID_LTRWIZ_OPTMAKECHANGES", // HID:40814 + "HID:WIZARDS_HID_LTRWIZ_TXTPATH", // HID:40815 + "HID:WIZARDS_HID_LTRWIZ_CMDPATH", // HID:40816 + "", + "", + "", + "HID:WIZARDS_HID_LTRWIZARD", // HID:40820 + "HID:WIZARDS_HID_LTRWIZARD_HELP", // HID:40821 + "HID:WIZARDS_HID_LTRWIZARD_BACK", // HID:40822 + "HID:WIZARDS_HID_LTRWIZARD_NEXT", // HID:40823 + "HID:WIZARDS_HID_LTRWIZARD_CREATE", // HID:40824 + "HID:WIZARDS_HID_LTRWIZARD_CANCEL", // HID:40825 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD_LSTTABLES", // HID:40850 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDS", // HID:40851 + "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVESELECTED", // HID:40852 + "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVEALL", // HID:40853 + "HID:WIZARDS_HID_QUERYWIZARD_CMDREMOVESELECTED", // HID:40854 + "HID:WIZARDS_HID_QUERYWIZARD_CMDREMOVEALL", // HID:40855 + "HID:WIZARDS_HID_QUERYWIZARD_LSTSELFIELDS", // HID:40856 + "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVEUP", // HID:40857 + "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVEDOWN", // HID:40858 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD_SORT1", // HID:40865 + "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND1", // HID:40866 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND1", // HID:40867 + "HID:WIZARDS_HID_QUERYWIZARD_SORT2", // HID:40868 + "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND2", // HID:40869 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND2", // HID:40870 + "HID:WIZARDS_HID_QUERYWIZARD_SORT3", // HID:40871 + "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND3", // HID:40872 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND3", // HID:40873 + "HID:WIZARDS_HID_QUERYWIZARD_SORT4", // HID:40874 + "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND4", // HID:40875 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND4", // HID:40876 + "", + "HID:WIZARDS_HID_QUERYWIZARD_OPTMATCHALL", // HID:40878 + "HID:WIZARDS_HID_QUERYWIZARD_OPTMATCHANY", // HID:40879 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDNAME_1", // HID:40880 + "HID:WIZARDS_HID_QUERYWIZARD_LSTOPERATOR_1", // HID:40881 + "HID:WIZARDS_HID_QUERYWIZARD_TXTVALUE_1", // HID:40882 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDNAME_2", // HID:40883 + "HID:WIZARDS_HID_QUERYWIZARD_LSTOPERATOR_2", // HID:40884 + "HID:WIZARDS_HID_QUERYWIZARD_TXTVALUE_2", // HID:40885 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDNAME_3", // HID:40886 + "HID:WIZARDS_HID_QUERYWIZARD_LSTOPERATOR_3", // HID:40887 + "HID:WIZARDS_HID_QUERYWIZARD_TXTVALUE_3", // HID:40888 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD_OPTAGGREGATEDETAILQUERY", // HID:40895 + "HID:WIZARDS_HID_QUERYWIZARD_OPTAGGREGATESUMMARYQUERY", // HID:40896 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_1", // HID:40897 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_1", // HID:40898 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_2", // HID:40899 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_2", // HID:40900 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_3", // HID:40901 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_3", // HID:40902 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_4", // HID:40903 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_4", // HID:40904 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_5", // HID:40905 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_5", // HID:40906 + "HID:WIZARDS_HID_QUERYWIZARD_BTNAGGREGATEPLUS", // HID:40907 + "HID:WIZARDS_HID_QUERYWIZARD_BTNAGGREGATEMINUS", // HID:40908 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDS", // HID:40915 + "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERMOVESELECTED", // HID:40916 + "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERREMOVESELECTED", // HID:40917 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERSELFIELDS", // HID:40918 + "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERMOVEUP", // HID:40919 + "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERMOVEDOWN", // HID:40920 + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD_OPTGROUPMATCHALL", // HID:40923 + "HID:WIZARDS_HID_QUERYWIZARD_OPTGROUPMATCHANY", // HID:40924 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDNAME_1", // HID:40925 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTEROPERATOR_1", // HID:40926 + "HID:WIZARDS_HID_QUERYWIZARD_TXTFILTERVALUE_1", // HID:40927 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDNAME_2", // HID:40928 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTEROPERATOR_2", // HID:40929 + "HID:WIZARDS_HID_QUERYWIZARD_TXTFILTERVALUE_2", // HID:40930 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDNAME_3", // HID:40931 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTEROPERATOR_3", // HID:40932 + "HID:WIZARDS_HID_QUERYWIZARD_TXTFILTERVALUE_3", // HID:40933 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_1", // HID:40940 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_2", // HID:40941 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_3", // HID:40942 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_4", // HID:40943 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_5", // HID:40944 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_6", // HID:40945 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_7", // HID:40946 + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD_TXTQUERYTITLE", // HID:40955 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDISPLAYQUERY", // HID:40956 + "HID:WIZARDS_HID_QUERYWIZARD_OPTMODIFYQUERY", // HID:40957 + "HID:WIZARDS_HID_QUERYWIZARD_TXTSUMMARY", // HID:40958 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD", // HID:40970 + "", + "HID:WIZARDS_HID_QUERYWIZARD_BACK", // HID:40972 + "HID:WIZARDS_HID_QUERYWIZARD_NEXT", // HID:40973 + "HID:WIZARDS_HID_QUERYWIZARD_CREATE", // HID:40974 + "HID:WIZARDS_HID_QUERYWIZARD_CANCEL", // HID:40975 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_IS", // HID:41000 + "", + "HID:WIZARDS_HID_IS_BTN_NONE", // HID:41002 + "HID:WIZARDS_HID_IS_BTN_OK", // HID:41003 + "HID:WIZARDS_HID_IS_BTN_CANCEL", // HID:41004 + "HID:WIZARDS_HID_IS_BTN_IMG1", // HID:41005 + "HID:WIZARDS_HID_IS_BTN_IMG2", // HID:41006 + "HID:WIZARDS_HID_IS_BTN_IMG3", // HID:41007 + "HID:WIZARDS_HID_IS_BTN_IMG4", // HID:41008 + "HID:WIZARDS_HID_IS_BTN_IMG5", // HID:41009 + "HID:WIZARDS_HID_IS_BTN_IMG6", // HID:41010 + "HID:WIZARDS_HID_IS_BTN_IMG7", // HID:41011 + "HID:WIZARDS_HID_IS_BTN_IMG8", // HID:41012 + "HID:WIZARDS_HID_IS_BTN_IMG9", // HID:41013 + "HID:WIZARDS_HID_IS_BTN_IMG10", // HID:41014 + "HID:WIZARDS_HID_IS_BTN_IMG11", // HID:41015 + "HID:WIZARDS_HID_IS_BTN_IMG12", // HID:41016 + "HID:WIZARDS_HID_IS_BTN_IMG13", // HID:41017 + "HID:WIZARDS_HID_IS_BTN_IMG14", // HID:41018 + "HID:WIZARDS_HID_IS_BTN_IMG15", // HID:41019 + "HID:WIZARDS_HID_IS_BTN_IMG16", // HID:41020 + "HID:WIZARDS_HID_IS_BTN_IMG17", // HID:41021 + "HID:WIZARDS_HID_IS_BTN_IMG18", // HID:41022 + "HID:WIZARDS_HID_IS_BTN_IMG19", // HID:41023 + "HID:WIZARDS_HID_IS_BTN_IMG20", // HID:41024 + "HID:WIZARDS_HID_IS_BTN_IMG21", // HID:41025 + "HID:WIZARDS_HID_IS_BTN_IMG22", // HID:41026 + "HID:WIZARDS_HID_IS_BTN_IMG23", // HID:41027 + "HID:WIZARDS_HID_IS_BTN_IMG24", // HID:41028 + "HID:WIZARDS_HID_IS_BTN_IMG25", // HID:41029 + "HID:WIZARDS_HID_IS_BTN_IMG26", // HID:41030 + "HID:WIZARDS_HID_IS_BTN_IMG27", // HID:41031 + "HID:WIZARDS_HID_IS_BTN_IMG28", // HID:41032 + "HID:WIZARDS_HID_IS_BTN_IMG29", // HID:41033 + "HID:WIZARDS_HID_IS_BTN_IMG30", // HID:41034 + "HID:WIZARDS_HID_IS_BTN_IMG31", // HID:41035 + "HID:WIZARDS_HID_IS_BTN_IMG32", // HID:41036 + "", + "", + "", + "HID:WIZARDS_HID_FTP", // HID:41040 + "HID:WIZARDS_HID_FTP_SERVER", // HID:41041 + "HID:WIZARDS_HID_FTP_USERNAME", // HID:41042 + "HID:WIZARDS_HID_FTP_PASS", // HID:41043 + "HID:WIZARDS_HID_FTP_TEST", // HID:41044 + "HID:WIZARDS_HID_FTP_TXT_PATH", // HID:41045 + "HID:WIZARDS_HID_FTP_BTN_PATH", // HID:41046 + "HID:WIZARDS_HID_FTP_OK", // HID:41047 + "HID:WIZARDS_HID_FTP_CANCEL", // HID:41048 + "", + "", + "HID:WIZARDS_HID_AGWIZ", // HID:41051 + "HID:WIZARDS_HID_AGWIZ_HELP", // HID:41052 + "HID:WIZARDS_HID_AGWIZ_NEXT", // HID:41053 + "HID:WIZARDS_HID_AGWIZ_PREV", // HID:41054 + "HID:WIZARDS_HID_AGWIZ_CREATE", // HID:41055 + "HID:WIZARDS_HID_AGWIZ_CANCEL", // HID:41056 + "HID:WIZARDS_HID_AGWIZ_1_LIST_PAGEDESIGN", // HID:41057 + "HID:WIZARDS_HID_AGWIZ_1_CHK_MINUTES", // HID:41058 + "HID:WIZARDS_HID_AGWIZ_2_TXT_TIME", // HID:41059 + "HID:WIZARDS_HID_AGWIZ_2_TXT_DATE", // HID:41060 + "HID:WIZARDS_HID_AGWIZ_2_TXT_TITLE", // HID:41061 + "HID:WIZARDS_HID_AGWIZ_2_TXT_LOCATION", // HID:41062 + "HID:WIZARDS_HID_AGWIZ_3_CHK_MEETING_TYPE", // HID:41063 + "HID:WIZARDS_HID_AGWIZ_3_CHK_READ", // HID:41064 + "HID:WIZARDS_HID_AGWIZ_3_CHK_BRING", // HID:41065 + "HID:WIZARDS_HID_AGWIZ_3_CHK_NOTES", // HID:41066 + "HID:WIZARDS_HID_AGWIZ_4_CHK_CALLED_BY", // HID:41067 + "HID:WIZARDS_HID_AGWIZ_4_CHK_FACILITATOR", // HID:41068 + "HID:WIZARDS_HID_AGWIZ_4_CHK_NOTETAKER", // HID:41069 + "HID:WIZARDS_HID_AGWIZ_4_CHK_TIMEKEEPER", // HID:41070 + "HID:WIZARDS_HID_AGWIZ_4_CHK_ATTENDEES", // HID:41071 + "HID:WIZARDS_HID_AGWIZ_4_CHK_OBSERVERS", // HID:41072 + "HID:WIZARDS_HID_AGWIZ_4_CHK_RESOURCEPERSONS", // HID:41073 + "HID:WIZARDS_HID_AGWIZ_6_TXT_TEMPLATENAME", // HID:41074 + "HID:WIZARDS_HID_AGWIZ_6_TXT_TEMPLATEPATH", // HID:41075 + "HID:WIZARDS_HID_AGWIZ_6_BTN_TEMPLATEPATH", // HID:41076 + "HID:WIZARDS_HID_AGWIZ_6_OPT_CREATEAGENDA", // HID:41077 + "HID:WIZARDS_HID_AGWIZ_6_OPT_MAKECHANGES", // HID:41078 + "HID:WIZARDS_HID_AGWIZ_5_BTN_INSERT", // HID:41079 + "HID:WIZARDS_HID_AGWIZ_5_BTN_REMOVE", // HID:41080 + "HID:WIZARDS_HID_AGWIZ_5_BTN_UP", // HID:41081 + "HID:WIZARDS_HID_AGWIZ_5_BTN_DOWN", // HID:41082 + "HID:WIZARDS_HID_AGWIZ_5_SCROLL_BAR", // HID:41083 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_1", // HID:41084 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_1", // HID:41085 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_1", // HID:41086 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_2", // HID:41087 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_2", // HID:41088 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_2", // HID:41089 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_3", // HID:41090 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_3", // HID:41091 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_3", // HID:41092 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_4", // HID:41093 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_4", // HID:41094 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_4", // HID:41095 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_5", // HID:41096 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_5", // HID:41097 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_5", // HID:41098 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_FAXWIZ_OPTBUSINESSFAX", // HID:41120 + "HID:WIZARDS_HID_FAXWIZ_LSTBUSINESSSTYLE", // HID:41121 + "HID:WIZARDS_HID_FAXWIZ_OPTPRIVATEFAX", // HID:41122 + "HID:WIZARDS_HID_LSTPRIVATESTYLE", // HID:41123 + "HID:WIZARDS_HID_IMAGECONTROL3", // HID:41124 + "HID:WIZARDS_HID_CHKUSELOGO", // HID:41125 + "HID:WIZARDS_HID_CHKUSEDATE", // HID:41126 + "HID:WIZARDS_HID_CHKUSECOMMUNICATIONTYPE", // HID:41127 + "HID:WIZARDS_HID_LSTCOMMUNICATIONTYPE", // HID:41128 + "HID:WIZARDS_HID_CHKUSESUBJECT", // HID:41129 + "HID:WIZARDS_HID_CHKUSESALUTATION", // HID:41130 + "HID:WIZARDS_HID_LSTSALUTATION", // HID:41131 + "HID:WIZARDS_HID_CHKUSEGREETING", // HID:41132 + "HID:WIZARDS_HID_LSTGREETING", // HID:41133 + "HID:WIZARDS_HID_CHKUSEFOOTER", // HID:41134 + "HID:WIZARDS_HID_OPTSENDERPLACEHOLDER", // HID:41135 + "HID:WIZARDS_HID_OPTSENDERDEFINE", // HID:41136 + "HID:WIZARDS_HID_TXTSENDERNAME", // HID:41137 + "HID:WIZARDS_HID_TXTSENDERSTREET", // HID:41138 + "HID:WIZARDS_HID_TXTSENDERPOSTCODE", // HID:41139 + "HID:WIZARDS_HID_TXTSENDERSTATE", // HID:41140 + "HID:WIZARDS_HID_TXTSENDERCITY", // HID:41141 + "HID:WIZARDS_HID_TXTSENDERFAX", // HID:41142 + "HID:WIZARDS_HID_OPTRECEIVERPLACEHOLDER", // HID:41143 + "HID:WIZARDS_HID_OPTRECEIVERDATABASE", // HID:41144 + "HID:WIZARDS_HID_TXTFOOTER", // HID:41145 + "HID:WIZARDS_HID_CHKFOOTERNEXTPAGES", // HID:41146 + "HID:WIZARDS_HID_CHKFOOTERPAGENUMBERS", // HID:41147 + "HID:WIZARDS_HID_TXTTEMPLATENAME", // HID:41148 + "HID:WIZARDS_HID_FILETEMPLATEPATH", // HID:41149 + "HID:WIZARDS_HID_OPTCREATEFAX", // HID:41150 + "HID:WIZARDS_HID_OPTMAKECHANGES", // HID:41151 + "HID:WIZARDS_HID_IMAGECONTROL2", // HID:41152 + "HID:WIZARDS_HID_FAXWIZ_TXTPATH", // HID:41153 + "HID:WIZARDS_HID_FAXWIZ_CMDPATH", // HID:41154 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_FAXWIZARD", // HID:41180 + "HID:WIZARDS_HID_FAXWIZARD_HELP", // HID:41181 + "HID:WIZARDS_HID_FAXWIZARD_BACK", // HID:41182 + "HID:WIZARDS_HID_FAXWIZARD_NEXT", // HID:41183 + "HID:WIZARDS_HID_FAXWIZARD_CREATE", // HID:41184 + "HID:WIZARDS_HID_FAXWIZARD_CANCEL", // HID:41185 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGTABLE_DIALOG", // HID:41200 + "", + "HID:WIZARDS_HID_DLGTABLE_CMDPREV", // HID:41202 + "HID:WIZARDS_HID_DLGTABLE_CMDNEXT", // HID:41203 + "HID:WIZARDS_HID_DLGTABLE_CMDFINISH", // HID:41204 + "HID:WIZARDS_HID_DLGTABLE_CMDCANCEL", // HID:41205 + "HID:WIZARDS_HID_DLGTABLE_OPTBUSINESS", // HID:41206 + "HID:WIZARDS_HID_DLGTABLE_OPTPRIVATE", // HID:41207 + "HID:WIZARDS_HID_DLGTABLE_LBTABLES", // HID:41208 + "HID:WIZARDS_HID_DLGTABLE_FIELDSAVAILABLE", // HID:41209 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVESELECTED", // HID:41210 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEALL", // HID:41211 + "HID:WIZARDS_HID_DLGTABLE_CMDREMOVESELECTED", // HID:41212 + "HID:WIZARDS_HID_DLGTABLE_CMDREMOVEALL", // HID:41213 + "HID:WIZARDS_HID_DLGTABLE_FIELDSSELECTED", // HID:41214 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEUP", // HID:41215 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEDOWN", // HID:41216 + "", + "", + "", + "HID:WIZARDS_HID_DLGTABLE_LB_SELFIELDNAMES", // HID:41220 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEFIELDUP", // HID:41221 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEFIELDDOWN", // HID:41222 + "HID:WIZARDS_HID_DLGTABLE_CMDMINUS", // HID:41223 + "HID:WIZARDS_HID_DLGTABLE_CMDPLUS", // HID:41224 + "HID:WIZARDS_HID_DLGTABLE_COLNAME", // HID:41225 + "HID:WIZARDS_HID_DLGTABLE_COLMODIFIER", // HID:41226 + "HID:WIZARDS_HID_DLGTABLE_CHK_USEPRIMEKEY", // HID:41227 + "HID:WIZARDS_HID_DLGTABLE_OPT_PK_AUTOMATIC", // HID:41228 + "HID:WIZARDS_HID_DLGTABLE_CK_PK_AUTOVALUE_AUTOMATIC", // HID:41229 + "HID:WIZARDS_HID_DLGTABLE_OPT_PK_SINGLE", // HID:41230 + "HID:WIZARDS_HID_DLGTABLE_LB_PK_FIELDNAME", // HID:41231 + "HID:WIZARDS_HID_DLGTABLE_CK_PK_AUTOVALUE", // HID:41232 + "HID:WIZARDS_HID_DLGTABLE_OPT_PK_SEVERAL", // HID:41233 + "HID:WIZARDS_HID_DLGTABLE_FIELDS_PK_AVAILABLE", // HID:41234 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVE_PK_SELECTED", // HID:41235 + "HID:WIZARDS_HID_DLGTABLE_CMDREMOVE_PK_SELECTED", // HID:41236 + "HID:WIZARDS_HID_DLGTABLE_FIELDS_PK_SELECTED", // HID:41237 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEUP_PK_SELECTED", // HID:41238 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEDOWN_PK_SELECTED", // HID:41239 + "HID:WIZARDS_HID_DLGTABLE_TXT_NAME", // HID:41240 + "HID:WIZARDS_HID_DLGTABLE_OPT_MODIFYTABLE", // HID:41241 + "HID:WIZARDS_HID_DLGTABLE_OPT_WORKWITHTABLE", // HID:41242 + "HID:WIZARDS_HID_DLGTABLE_OPT_STARTFORMWIZARD", // HID:41243 + "HID:WIZARDS_HID_DLGTABLE_LST_CATALOG", // HID:41244 + "HID:WIZARDS_HID_DLGTABLE_LST_SCHEMA" // HID:41245 + }; + + public static String getHelpIdString( int nHelpId ) + { + if ( nHelpId >= 34200 && nHelpId <= 34722 ) + return array1[ nHelpId - 34200 ]; + else if ( nHelpId >= 40769 && nHelpId <= 41245 ) + return array2[ nHelpId - 40769 ]; + else + return new String(); + } +} diff --git a/wizards/com/sun/star/wizards/common/Helper.java b/wizards/com/sun/star/wizards/common/Helper.java new file mode 100644 index 000000000000..0df16b360de0 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Helper.java @@ -0,0 +1,444 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +import com.sun.star.uno.XComponentContext; +import com.sun.star.util.XMacroExpander; +import java.util.Calendar; + +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +// import com.sun.star.i18n.NumberFormatIndex; +import com.sun.star.lang.Locale; +import com.sun.star.lang.XMultiServiceFactory; +// import com.sun.star.uno.Any; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.RuntimeException; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.DateTime; +import com.sun.star.util.XNumberFormatsSupplier; +import com.sun.star.util.XNumberFormatter; + +public class Helper +{ + + /** Creates a new instance of Helper */ + public Helper() + { + } + + public static long convertUnoDatetoInteger(com.sun.star.util.Date DateValue) + { + java.util.Calendar oCal = java.util.Calendar.getInstance(); + oCal.set(DateValue.Year, DateValue.Month, DateValue.Day); + java.util.Date dTime = oCal.getTime(); + long lTime = dTime.getTime(); + long lDate = lTime / (3600 * 24000); + return lDate; + } + + public static void setUnoPropertyValue(Object oUnoObject, String PropertyName, Object PropertyValue) + { + try + { + XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oUnoObject); + if (xPSet.getPropertySetInfo().hasPropertyByName(PropertyName)) + { + xPSet.setPropertyValue(PropertyName, PropertyValue); + } + else + { + Property[] selementnames = xPSet.getPropertySetInfo().getProperties(); + throw new java.lang.IllegalArgumentException("No Such Property: '" + PropertyName + "'"); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + } + } + + public static Object getUnoObjectbyName(Object oUnoObject, String ElementName) + { + try + { + com.sun.star.container.XNameAccess xName = (com.sun.star.container.XNameAccess) UnoRuntime.queryInterface(com.sun.star.container.XNameAccess.class, oUnoObject); + if (xName.hasByName(ElementName) == true) + { + return xName.getByName(ElementName); + } + else + { + throw new RuntimeException(); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + return null; + } + } + + public static Object getPropertyValue(PropertyValue[] CurPropertyValue, String PropertyName) + { + int MaxCount = CurPropertyValue.length; + for (int i = 0; i < MaxCount; i++) + { + if (CurPropertyValue[i] != null) + { + if (CurPropertyValue[i].Name.equals(PropertyName)) + { + return CurPropertyValue[i].Value; + } + } + } + throw new RuntimeException(); + } + + public static Object getUnoPropertyValue(Object oUnoObject, String PropertyName, java.lang.Class xClass) + { + try + { + if (oUnoObject != null) + { + XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oUnoObject); + Object oObject = xPSet.getPropertyValue(PropertyName); + if (AnyConverter.isVoid(oObject)) + { + return null; + } + else + { + return com.sun.star.uno.AnyConverter.toObject(new com.sun.star.uno.Type(xClass), oObject); + } + } + return null; + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + return null; + } + } + + public static Object getPropertyValuefromAny(Object[] CurPropertyValue, String PropertyName) + { + if (CurPropertyValue != null) + { + int MaxCount = CurPropertyValue.length; + for (int i = 0; i < MaxCount; i++) + { + if (CurPropertyValue[i] != null) + { + PropertyValue aValue = (PropertyValue) CurPropertyValue[i]; + if (aValue != null && aValue.Name.equals(PropertyName)) + { + return aValue.Value; + } + } + } + } + // System.out.println("Property not found: " + PropertyName); + return null; + } + + public static Object getPropertyValuefromAny(Object[] CurPropertyValue, String PropertyName, java.lang.Class xClass) + { + try + { + if (CurPropertyValue != null) + { + int MaxCount = CurPropertyValue.length; + for (int i = 0; i < MaxCount; i++) + { + if (CurPropertyValue[i] != null) + { + PropertyValue aValue = (PropertyValue) CurPropertyValue[i]; + if (aValue != null && aValue.Name.equals(PropertyName)) + { + return com.sun.star.uno.AnyConverter.toObject(new com.sun.star.uno.Type(xClass), aValue.Value); + } + } + } + } + // System.out.println("Property not found: " + PropertyName); + return null; + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + return null; + } + } + + public static Object getUnoPropertyValue(Object oUnoObject, String PropertyName) + { + try + { + if (oUnoObject != null) + { + XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oUnoObject); + // Property[] aProps = xPSet.getPropertySetInfo().getProperties(); + Object oObject = xPSet.getPropertyValue(PropertyName); + return oObject; + } + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + } + return null; + } + + public static Object getUnoArrayPropertyValue(Object oUnoObject, String PropertyName) + { + try + { + if (oUnoObject != null) + { + XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oUnoObject); + Object oObject = xPSet.getPropertyValue(PropertyName); + if (AnyConverter.isArray(oObject)) + { + return getArrayValue(oObject); + } + } + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + } + return null; + } + + public static Object getUnoStructValue(Object oUnoObject, String PropertyName) + { + try + { + if (oUnoObject != null) + { + XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oUnoObject); + if (xPSet.getPropertySetInfo().hasPropertyByName(PropertyName) == true) + { + Object oObject = xPSet.getPropertyValue(PropertyName); + return oObject; + } + } + return null; + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + return null; + } + } + + public static void setUnoPropertyValues(Object oUnoObject, String[] PropertyNames, Object[] PropertyValues) + { + try + { + com.sun.star.beans.XMultiPropertySet xMultiPSetLst = (com.sun.star.beans.XMultiPropertySet) UnoRuntime.queryInterface(com.sun.star.beans.XMultiPropertySet.class, oUnoObject); + if (xMultiPSetLst != null) + { + xMultiPSetLst.setPropertyValues(PropertyNames, PropertyValues); + } + else + { + for (int i = 0; i < PropertyNames.length; i++) + { + //System.out.println(PropertyNames[i] + "=" + PropertyValues[i]); + setUnoPropertyValue(oUnoObject, PropertyNames[i], PropertyValues[i]); + } + } + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + } + } + + /** + * @author bc93774 + * checks if the value of an object that represents an array is null. + * check beforehand if the Object is really an array with "AnyConverter.IsArray(oObject) + * @param oValue the paramter that has to represent an object + * @return a null reference if the array is empty + */ + public static Object getArrayValue(Object oValue) + { + try + { + Object oPropList = com.sun.star.uno.AnyConverter.toArray(oValue); + int nlen = java.lang.reflect.Array.getLength(oPropList); + if (nlen == 0) + { + return null; + } + else + { + return oPropList; + } + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + return null; + } + } + private static long DAY_IN_MILLIS = (24 * 60 * 60 * 1000); + + public static class DateUtils + { + + private long docNullTime; + private XNumberFormatter formatter; + private XNumberFormatsSupplier formatSupplier; + private Calendar calendar; + + public DateUtils(XMultiServiceFactory xmsf, Object document) throws Exception + { + XMultiServiceFactory docMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, document); + + Object defaults = docMSF.createInstance("com.sun.star.text.Defaults"); + Locale l = (Locale) Helper.getUnoStructValue(defaults, "CharLocale"); + + java.util.Locale jl = new java.util.Locale( + l.Language, l.Country, l.Variant); + + calendar = Calendar.getInstance(jl); + + formatSupplier = (XNumberFormatsSupplier) UnoRuntime.queryInterface(XNumberFormatsSupplier.class, document); + + Object formatSettings = formatSupplier.getNumberFormatSettings(); + com.sun.star.util.Date date = (com.sun.star.util.Date) Helper.getUnoPropertyValue(formatSettings, "NullDate"); + + calendar.set(date.Year, date.Month - 1, date.Day); + docNullTime = getTimeInMillis(); + + formatter = NumberFormatter.createNumberFormatter(xmsf, formatSupplier); + } + + /** + * @param format a constant of the enumeration NumberFormatIndex + * @return + */ + public int getFormat(short format) + { + return NumberFormatter.getNumberFormatterKey(formatSupplier, format); + } + + public XNumberFormatter getFormatter() + { + return formatter; + } + + private long getTimeInMillis() + { + java.util.Date dDate = calendar.getTime(); + return dDate.getTime(); + } + + /** + * @param date a VCL date in form of 20041231 + * @return a document relative date + */ + public synchronized double getDocumentDateAsDouble(int date) + { + calendar.clear(); + calendar.set(date / 10000, + (date % 10000) / 100 - 1, + date % 100); + + long date1 = getTimeInMillis(); + /* + * docNullTime and date1 are in millis, but + * I need a day... + */ + double daysDiff = (date1 - docNullTime) / DAY_IN_MILLIS + 1; + + return daysDiff; + } + + public double getDocumentDateAsDouble(DateTime date) + { + return getDocumentDateAsDouble(date.Year * 10000 + date.Month * 100 + date.Day); + } + + public synchronized double getDocumentDateAsDouble(long javaTimeInMillis) + { + calendar.clear(); + JavaTools.setTimeInMillis(calendar, javaTimeInMillis); + + long date1 = getTimeInMillis(); + + /* + * docNullTime and date1 are in millis, but + * I need a day... + */ + double daysDiff = (date1 - docNullTime) / DAY_IN_MILLIS + 1; + + return daysDiff; + + } + + public String format(int formatIndex, int date) + { + return formatter.convertNumberToString(formatIndex, getDocumentDateAsDouble(date)); + } + + public String format(int formatIndex, DateTime date) + { + return formatter.convertNumberToString(formatIndex, getDocumentDateAsDouble(date)); + } + + public String format(int formatIndex, long javaTimeInMillis) + { + return formatter.convertNumberToString(formatIndex, getDocumentDateAsDouble(javaTimeInMillis)); + } + } + + public static XComponentContext getComponentContext(XMultiServiceFactory _xMSF) + { + // Get the path to the extension and try to add the path to the class loader + final XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, _xMSF); + final PropertySetHelper aHelper = new PropertySetHelper(xProps); + final Object aDefaultContext = aHelper.getPropertyValueAsObject("DefaultContext"); + final XComponentContext xComponentContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, aDefaultContext); + return xComponentContext; + } + + public static XMacroExpander getMacroExpander(XMultiServiceFactory _xMSF) + { + final XComponentContext xComponentContext = getComponentContext(_xMSF); + final Object aSingleton = xComponentContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander"); + XMacroExpander xExpander = (XMacroExpander) UnoRuntime.queryInterface(XMacroExpander.class, aSingleton); + // String[][] aStrListList = xProvider.getExtensionList(); +// final String sLocation = xProvider.getPackageLocation("com.sun.reportdesigner"); + return xExpander; + } +} diff --git a/wizards/com/sun/star/wizards/common/IRenderer.java b/wizards/com/sun/star/wizards/common/IRenderer.java new file mode 100644 index 000000000000..1aa73eaa599b --- /dev/null +++ b/wizards/com/sun/star/wizards/common/IRenderer.java @@ -0,0 +1,40 @@ +/* + ************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +/** + * A General interface which gives a string + * that represents the rendered argument object. + * Can be used to reference resources, internationalizartion + * a.s.o + */ +public interface IRenderer +{ + + public String render(Object object); +} diff --git a/wizards/com/sun/star/wizards/common/Indexable.java b/wizards/com/sun/star/wizards/common/Indexable.java new file mode 100644 index 000000000000..d95640f1ec70 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Indexable.java @@ -0,0 +1,44 @@ +/* + ************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +/* + * Indexable.java + * + * Created on 16. September 2003, 11:38 + */ + +package com.sun.star.wizards.common; + +/** + * + * @author rpiterman + */ +public interface Indexable { + + public int getIndex(); + +} diff --git a/wizards/com/sun/star/wizards/common/InvalidQueryException.java b/wizards/com/sun/star/wizards/common/InvalidQueryException.java new file mode 100644 index 000000000000..325f6fdc3760 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/InvalidQueryException.java @@ -0,0 +1,40 @@ +/* + ************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +import com.sun.star.lang.XMultiServiceFactory; + +public class InvalidQueryException extends java.lang.Throwable +{ +// TODO don't show messages in Excetions + public InvalidQueryException(XMultiServiceFactory xMSF, String sCommand) + { + final int RID_REPORT = 2400; + SystemDialog.showErrorBox(xMSF, "ReportWizard", "dbw", RID_REPORT + 65, "<STATEMENT>", sCommand); // Querycreationnotpossible + } +} diff --git a/wizards/com/sun/star/wizards/common/JavaTools.java b/wizards/com/sun/star/wizards/common/JavaTools.java new file mode 100644 index 000000000000..836b2a7ea242 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/JavaTools.java @@ -0,0 +1,785 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.util.DateTime; +import com.sun.star.beans.PropertyValue; +import java.util.*; +import java.io.File; + +import com.sun.star.lib.util.UrlToFileMapper; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; + +/** + * + * @author bc93774 + */ +public class JavaTools +{ + + /** Creates a new instance of JavaTools */ + public JavaTools() + { + } + +/* + public static void main(String args[]) + { + String sPath = ""; + DateTime oDateTime = null; + long n; + String ConnectStr = "uno:socket,host=localhost,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.NamingService"; //localhost ;Lo-1.Germany.sun.com; 10.16.65.155 + try + { + XMultiServiceFactory xLocMSF = com.sun.star.wizards.common.Desktop.connect(ConnectStr); + if (xLocMSF != null) + { + System.out.println("Connected to " + ConnectStr); + oDateTime = getDateTime(9500000); + sPath = convertfromURLNotation("file:///E:/trash/Web%20Wizard.xcu"); + n = getMillis(oDateTime); + int a = 1; + } + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + } + } +*/ + public static String[] copyStringArray(String[] FirstArray) + { + if (FirstArray != null) + { + String[] SecondArray = new String[FirstArray.length]; + for (int i = 0; i < FirstArray.length; i++) + { + SecondArray[i] = FirstArray[i]; + } + return SecondArray; + } + else + { + return null; + } + } + + public static Object[] initializeArray(Object[] olist, Object ovalue) + { + for (int i = 0; i < olist.length; i++) + { + olist[i] = ovalue; + } + return olist; + } + + public static Object[][] initializeMultiDimArray(Object[][] olist, Object[] ovalue) + { + for (int i = 0; i < olist.length; i++) + { + olist[i] = ovalue; + } + return olist; + } + + public static String[] ArrayOutOfMultiDimArray(String _sMultiDimArray[][], int _index) + { + String[] sRetArray = null; + if (_sMultiDimArray != null) + { + sRetArray = new String[_sMultiDimArray.length]; + for (int i = 0; i < _sMultiDimArray.length; i++) + { + sRetArray[i] = _sMultiDimArray[i][_index]; + } + } + return sRetArray; + } + + public static int[] initializeintArray(int FieldCount, int nValue) + { + int[] LocintArray = new int[FieldCount]; + for (int i = 0; i < LocintArray.length; i++) + { + LocintArray[i] = nValue; + } + return LocintArray; + } + + /**converts a list of Integer values included in an Integer vector to a list of int values + * + * + * @param _aIntegerVector + * @return + */ + public static int[] IntegerTointList(Vector<Integer> _aIntegerVector) + { + try + { + Integer[] nIntegerValues = new Integer[_aIntegerVector.size()]; + int[] nintValues = new int[_aIntegerVector.size()]; + _aIntegerVector.toArray(nIntegerValues); + for (int i = 0; i < nIntegerValues.length; i++) + { + nintValues[i] = nIntegerValues[i].intValue(); + } + return nintValues; + } + catch (RuntimeException e) + { + e.printStackTrace(System.out); + return null; + } + } + + /**converts a list of Boolean values included in a Boolean vector to a list of boolean values + * + * + * @param _aBooleanVector + * @return + */ + public static boolean[] BooleanTobooleanList(Vector<Boolean> _aBooleanVector) + { + try + { + Boolean[] bBooleanValues = new Boolean[_aBooleanVector.size()]; + boolean[] bbooleanValues = new boolean[_aBooleanVector.size()]; + _aBooleanVector.toArray(bBooleanValues); + for (int i = 0; i < bBooleanValues.length; i++) + { + bbooleanValues[i] = bBooleanValues[i].booleanValue(); + } + return bbooleanValues; + } + catch (RuntimeException e) + { + e.printStackTrace(System.out); + return null; + } + } + + public static String[] multiDimListToArray(String[][] multidimlist) + { + String[] retlist = new String[] + { + }; + retlist = new String[multidimlist.length]; + for (int i = 0; i < multidimlist.length; i++) + { + retlist[i] = multidimlist[i][0]; + } + return retlist; + } + + public static String getlongestArrayItem(String[] StringArray) + { + String sLongestItem = ""; + int FieldCount = StringArray.length; + int iOldLength = 0; + int iCurLength = 0; + for (int i = 0; i < FieldCount; i++) + { + iCurLength = StringArray[i].length(); + if (iCurLength > iOldLength) + { + iOldLength = iCurLength; + sLongestItem = StringArray[i]; + } + } + return sLongestItem; + } + + public static String ArraytoString(String[] LocArray) + { + String ResultString = ""; + int iLen = LocArray.length; + for (int i = 0; i < iLen; i++) + { + ResultString += LocArray[i]; + if (i < iLen - 1) + { + ResultString += ";"; + } + } + return ResultString; + } + + /** + * @author bc93774 + * @param SearchList + * @param SearchString + * @return the index of the field that contains the string 'SearchString' or '-1' if not it is + * not contained within the array + */ + public static int FieldInList(String[] SearchList, String SearchString) + { + int FieldLen = SearchList.length; + int retvalue = -1; + for (int i = 0; i < FieldLen; i++) + { + if (SearchList[i].compareTo(SearchString) == 0) + { + retvalue = i; + break; + } + } + return retvalue; + } + + public static int FieldInList(String[] SearchList, String SearchString, int StartIndex) + { + int FieldLen = SearchList.length; + int retvalue = -1; + if (StartIndex < FieldLen) + { + for (int i = StartIndex; i < FieldLen; i++) + { + if (SearchList[i].compareTo(SearchString) == 0) + { + retvalue = i; + break; + } + } + } + return retvalue; + } + + public static int FieldInTable(String[][] SearchList, String SearchString) + { + int retvalue; + if (SearchList.length > 0) + { + int FieldLen = SearchList.length; + retvalue = -1; + for (int i = 0; i < FieldLen; i++) + { + if (SearchList[i][0] != null) + { + if (SearchList[i][0].compareTo(SearchString) == 0) + { + retvalue = i; + break; + } + } + } + } + else + { + retvalue = -1; + } + return retvalue; + } + + public static int FieldInIntTable(int[][] SearchList, int SearchValue) + { + int retvalue = -1; + for (int i = 0; i < SearchList.length; i++) + { + if (SearchList[i][0] == SearchValue) + { + retvalue = i; + break; + } + } + return retvalue; + } + + public static int FieldInIntTable(int[] SearchList, int SearchValue, int _startindex) + { + int retvalue = -1; + for (int i = _startindex; i < SearchList.length; i++) + { + if (SearchList[i] == SearchValue) + { + retvalue = i; + break; + } + } + return retvalue; + } + + public static int FieldInIntTable(int[] SearchList, int SearchValue) + { + return FieldInIntTable(SearchList, SearchValue, 0); + } + + public static int getArraylength(Object[] MyArray) + { + int FieldCount = 0; + if (MyArray != null) + { + FieldCount = MyArray.length; + } + return FieldCount; + } + + /** + * @author bc93774 + * This function bubble sorts an array of with 2 dimensions. + * The default sorting order is the first dimension + * Only if sort2ndValue is True the second dimension is the relevant for the sorting order + */ + public static String[][] bubblesortList(String[][] SortList) + { + String DisplayDummy; + int SortCount = SortList[0].length; + int DimCount = SortList.length; + for (int s = 0; s < SortCount; s++) + { + for (int t = 0; t < SortCount - s - 1; t++) + { + if (SortList[0][t].compareTo(SortList[0][t + 1]) > 0) + { + for (int k = 0; k < DimCount; k++) + { + DisplayDummy = SortList[k][t]; + SortList[k][t] = SortList[k][t + 1]; + SortList[k][t + 1] = DisplayDummy; + } + } + } + } + return SortList; + } + + /** + * @param MainString + * @param Token + * @return + */ + public static String[] ArrayoutofString(String MainString, String Token) + { + String[] StringArray; + if (MainString.equals("") == false) + { + Vector StringVector = new Vector(); + String LocString = null; + int iIndex; + do + { + iIndex = MainString.indexOf(Token); + if (iIndex < 0) + { + StringVector.addElement(MainString); + } + else + { + StringVector.addElement(MainString.substring(0, iIndex)); + MainString = MainString.substring(iIndex + 1, MainString.length()); + } + } + while (iIndex >= 0); + int FieldCount = StringVector.size(); + StringArray = new String[FieldCount]; + StringVector.copyInto(StringArray); + } + else + { + StringArray = new String[0]; + } + return StringArray; + } + + public static String replaceSubString(String MainString, String NewSubString, String OldSubString) + { + try + { + int NewIndex = 0; + int OldIndex = 0; + int NewSubLen = NewSubString.length(); + int OldSubLen = OldSubString.length(); + while (NewIndex != -1) + { + NewIndex = MainString.indexOf(OldSubString, OldIndex); + if (NewIndex != -1) + { + MainString = MainString.substring(0, NewIndex) + NewSubString + MainString.substring(NewIndex + OldSubLen); + OldIndex = NewIndex + NewSubLen; + } + } + return MainString; + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + return null; + } + } + + public static String getFilenameOutOfPath(String sPath) + { + String[] Hierarchy = ArrayoutofString(sPath, "/"); + return Hierarchy[Hierarchy.length - 1]; + } + + public static String getFileDescription(String sPath) + { + String sFilename = getFilenameOutOfPath(sPath); + String[] FilenameList = ArrayoutofString(sFilename, "."); + String FileDescription = ""; + for (int i = 0; i < FilenameList.length - 1; i++) + { + FileDescription += FilenameList[i]; + } + return FileDescription; + } + + public static String convertfromURLNotation(String _sURLPath) + { + String sPath = ""; + try + { + URL oJavaURL = new URL(_sURLPath); + File oFile = UrlToFileMapper.mapUrlToFile(oJavaURL); + sPath = oFile.getAbsolutePath(); + } + catch (MalformedURLException e) + { + e.printStackTrace(System.out); + } + catch (IOException e) + { + e.printStackTrace(System.out); + } + return sPath; + } + + public static DateTime getDateTime(long timeMillis) + { + java.util.Calendar cal = java.util.Calendar.getInstance(); + setTimeInMillis(cal, timeMillis); + DateTime dt = new DateTime(); + dt.Year = (short) cal.get(Calendar.YEAR); + dt.Day = (short) cal.get(Calendar.DAY_OF_MONTH); + dt.Month = (short) (cal.get(Calendar.MONTH) + 1); + dt.Hours = (short) cal.get(Calendar.HOUR); + dt.Minutes = (short) cal.get(Calendar.MINUTE); + dt.Seconds = (short) cal.get(Calendar.SECOND); + dt.HundredthSeconds = (short) cal.get(Calendar.MILLISECOND); + return dt; + } + + public static long getTimeInMillis(Calendar _calendar) + { + java.util.Date dDate = _calendar.getTime(); + return dDate.getTime(); + } + + public static void setTimeInMillis(Calendar _calendar, long _timemillis) + { + java.util.Date dDate = new java.util.Date(); + dDate.setTime(_timemillis); + _calendar.setTime(dDate); + } + + public static long getMillis(DateTime time) + { + java.util.Calendar cal = java.util.Calendar.getInstance(); + cal.set(time.Year, time.Month, time.Day, time.Hours, time.Minutes, time.Seconds); + return getTimeInMillis(cal); + } + + public static String[] removeOutdatedFields(String[] baselist, String[] _complist) + { + String[] retarray = new String[] + { + }; + if ((baselist != null) && (_complist != null)) + { + Vector retvector = new Vector(); +// String[] orderedcomplist = new String[_complist.length]; +// System.arraycopy(_complist, 0, orderedcomplist, 0, _complist.length); + for (int i = 0; i < baselist.length; i++) +// if (Arrays.binarySearch(orderedcomplist, baselist[i]) != -1) + { + if (FieldInList(_complist, baselist[i]) > -1) + { + retvector.add(baselist[i]); + // else + // here you could call the method of a defined interface to notify the calling method + // } + } + } + retarray = new String[retvector.size()]; + retvector.toArray(retarray); + } + return (retarray); + } + + public static String[][] removeOutdatedFields(String[][] baselist, String[] _complist, int _compindex) + { + String[][] retarray = new String[][] {}; + if ((baselist != null) && (_complist != null)) + { + if (baselist.length > 0) + { + Vector retvector = new Vector(); + for (int i = 0; i < baselist.length; i++) + { + String sValue = baselist[i][_compindex]; + if (FieldInList(_complist, sValue) != -1) + { + retvector.add(baselist[i]); + // else + // here you could call the method of a defined interface to notify the calling method + } + } + retarray = new String[retvector.size()][2]; + retvector.toArray(retarray); + } + } + return (retarray); + } + + public static String[][] removeOutdatedFields(String[][] baselist, String[] _complist) + { + return removeOutdatedFields(baselist, _complist, 0); + } + + public static PropertyValue[][] removeOutdatedFields(PropertyValue[][] baselist, String[] _complist) + { + PropertyValue[][] retarray = new PropertyValue[][] + { + }; + if ((baselist != null) && (_complist != null)) + { + Vector firstdimvector = new Vector(); + int b = 0; + for (int n = 0; n < baselist.length; n++) + { + Vector secdimvector = new Vector(); + PropertyValue[] internalArray; + int a = 0; + for (int m = 0; m < baselist[n].length; m++) + { + if (FieldInList(_complist, baselist[n][m].Name) > -1) + { + secdimvector.add(baselist[n][m]); + a++; + } + } + if (a > 0) + { + internalArray = new PropertyValue[a]; + secdimvector.toArray(internalArray); + firstdimvector.add(internalArray); + b++; + } + } + retarray = new PropertyValue[b][]; + firstdimvector.toArray(retarray); + } + return (retarray); + } + + /** + * searches a multidimensional array for duplicate fields. According to the following example + * SlaveFieldName1 ;SlaveFieldName2; SlaveFieldName3 + * MasterFieldName1;MasterFieldName2;MasterFieldName3 + * The entries SlaveFieldNameX and MasterFieldNameX are grouped together and then the created groups are compared + * If a group is duplicate the entry of the second group is returned. + * @param _scomplist + * @return + */ + public static int getDuplicateFieldIndex(String[][] _scomplist) + { + int retvalue = -1; + if (_scomplist.length > 0) + { + int fieldcount = _scomplist[0].length; + String[] sDescList = new String[fieldcount]; + for (int m = 0; m < fieldcount; m++) + { + for (int n = 0; n < _scomplist.length; n++) + { + if (n == 0) + { + sDescList[m] = new String(); + } + sDescList[m] += _scomplist[n][m]; + } + } + return getDuplicateFieldIndex(sDescList); + } + return retvalue; + } + + /** + * not tested!!!!! + * @param scomplist + * @return + */ + public static int getDuplicateFieldIndex(String[] scomplist) + { + for (int n = 0; n < scomplist.length; n++) + { + String scurvalue = scomplist[n]; + for (int m = n; m < scomplist.length; m++) + { + if (m != n) + { + if (scurvalue.equals(scomplist[m])) + { + return m; + } + } + } + } + return -1; + } + + public static int getDuplicateFieldIndex(String[] _scomplist, String _fieldname) + { + int iduplicate = 0; + for (int n = 0; n < _scomplist.length; n++) + { + if (_scomplist[n].equals(_fieldname)) + { + iduplicate++; + if (iduplicate == 2) + { + return n; + } + } + } + return -1; + } + + public static boolean isEqual(PropertyValue firstPropValue, PropertyValue secPropValue) + { + if (!firstPropValue.Name.equals(secPropValue.Name)) + { + return false; + //TODO replace 'equals' with AnyConverter.getType(firstpropValue).equals(secPropValue) to check content and Type + } + if (!firstPropValue.Value.equals(secPropValue.Value)) + { + return false; + } + return (firstPropValue.Handle == secPropValue.Handle); + } + + public static int[] getDuplicateFieldIndex(PropertyValue[][] ocomplist) + { + for (int n = 0; n < ocomplist.length; n++) + { + PropertyValue[] ocurValue = ocomplist[n]; + for (int m = n; m < ocurValue.length; m++) + { + PropertyValue odetValue = ocurValue[m]; + for (int s = 0; s < ocurValue.length; s++) + { + if (s != m) + { + if (isEqual(odetValue, ocurValue[s])) + { + return new int[] + { + n, s + }; + } + } + } + } + } + return new int[] + { + -1, -1 + }; + } + + public static String getSuffixNumber(String _sbasestring) + { + int suffixcharcount = 0; + for (int i = _sbasestring.length() - 1; i >= 0; i--) + { + char b = _sbasestring.charAt(i); + if ((b >= '0') && (b <= '9')) + { + suffixcharcount++; + } + else + { + break; + } + } + int istart = _sbasestring.length() - suffixcharcount; + return _sbasestring.substring(istart, _sbasestring.length()); + } + + public static String[] removefromList(String[] _sbaselist, String[] _sdellist) + { + Vector tempbaselist = new Vector(); + for (int i = 0; i < _sbaselist.length; i++) + { + if (FieldInList(_sdellist, _sbaselist[i]) == -1) + { + tempbaselist.add(_sbaselist[i]); + } + } + String[] sretlist = new String[tempbaselist.size()]; + tempbaselist.toArray(sretlist); + return sretlist; + } + + /** + * compares two strings. If one of them is empty and the other one is null it also returns true + * @param sFirstString + * @param sSecondString + * @return + */ + public static boolean isSame(String sFirstString, String sSecondString) + { + boolean bissame = false; + if (sFirstString == null) + { + if (sSecondString != null) + { + bissame = sSecondString.equals(""); + } + else + { + bissame = (sSecondString == null); + } + } + else + { + if (sFirstString.equals("")) + { + bissame = (sSecondString == null); + } + else if (sSecondString != null) + { + bissame = sFirstString.equals(sSecondString); + } + } + return bissame; + } +} diff --git a/wizards/com/sun/star/wizards/common/MANIFEST.MF b/wizards/com/sun/star/wizards/common/MANIFEST.MF new file mode 100644 index 000000000000..a670e80c31e7 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/MANIFEST.MF @@ -0,0 +1 @@ +Class-Path: saxon9.jar diff --git a/wizards/com/sun/star/wizards/common/NamedValueCollection.java b/wizards/com/sun/star/wizards/common/NamedValueCollection.java new file mode 100644 index 000000000000..f8f2cd05224a --- /dev/null +++ b/wizards/com/sun/star/wizards/common/NamedValueCollection.java @@ -0,0 +1,90 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.sun.star.wizards.common; + +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.PropertyState; +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +/** + * + * @author frank.schoenheit@sun.com + */ +public class NamedValueCollection +{ + final private HashMap< String, Object > m_values = new HashMap< String, Object >(); + + public NamedValueCollection() + { + } + + public NamedValueCollection( final PropertyValue[] i_values ) + { + for ( int i = 0; i < i_values.length; ++i ) + m_values.put( i_values[i].Name, i_values[i].Value ); + } + + public final void put( final String i_name, final Object i_value ) + { + m_values.put( i_name, i_value ); + } + + @SuppressWarnings("unchecked") + public final < T extends Object > T getOrDefault( final String i_key, final T i_default ) + { + if ( m_values.containsKey( i_key ) ) + { + final Object value = m_values.get( i_key ); + try + { + return (T)value; + } + catch ( ClassCastException e ) { } + } + return i_default; + } + + @SuppressWarnings("unchecked") + public final < T extends XInterface > T queryOrDefault( final String i_key, final T i_default, Class i_interfaceClass ) + { + if ( m_values.containsKey( i_key ) ) + { + final Object value = m_values.get( i_key ); + return (T)UnoRuntime.queryInterface( i_interfaceClass, value ); + } + return i_default; + } + + public final boolean has( final String i_key ) + { + return m_values.containsKey( i_key ); + } + + public final PropertyValue[] getPropertyValues() + { + PropertyValue[] values = new PropertyValue[ m_values.size() ]; + + Iterator< Entry< String, Object > > iter = m_values.entrySet().iterator(); + int i = 0; + while ( iter.hasNext() ) + { + Entry< String, Object > entry = iter.next(); + values[i++] = new PropertyValue( + entry.getKey(), + 0, + entry.getValue(), + PropertyState.DIRECT_VALUE + ); + } + + return values; + } +} diff --git a/wizards/com/sun/star/wizards/common/NoValidPathException.java b/wizards/com/sun/star/wizards/common/NoValidPathException.java new file mode 100644 index 000000000000..f4975d2fff0c --- /dev/null +++ b/wizards/com/sun/star/wizards/common/NoValidPathException.java @@ -0,0 +1,44 @@ +/* + ************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.wizards.common; + +import com.sun.star.lang.XMultiServiceFactory; + +public class NoValidPathException extends Exception +{ + public NoValidPathException(XMultiServiceFactory xMSF, String _sText) + { + super(_sText); + // TODO: NEVER open a dialog in an exception + if (xMSF != null) + { + SystemDialog.showErrorBox(xMSF, "dbwizres", "dbw", 521); // OfficePathnotavailable + } + } +} diff --git a/wizards/com/sun/star/wizards/common/NumberFormatter.java b/wizards/com/sun/star/wizards/common/NumberFormatter.java new file mode 100644 index 000000000000..ccfbee303f98 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/NumberFormatter.java @@ -0,0 +1,333 @@ +/************************************************************************* +* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.wizards.common; + +import java.util.Date; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.Locale; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.NumberFormat; +import com.sun.star.util.XNumberFormatTypes; +import com.sun.star.util.XNumberFormats; +import com.sun.star.util.XNumberFormatsSupplier; +import com.sun.star.util.XNumberFormatter; + + +public class NumberFormatter +{ + + public int iDateFormatKey = -1; + public int iDateTimeFormatKey = -1; + public int iNumberFormatKey = -1; + public int iTextFormatKey = -1; + public int iTimeFormatKey = -1; + public int iLogicalFormatKey = -1; + public long lDateCorrection; + public XNumberFormatter xNumberFormatter; + public XNumberFormats xNumberFormats; + public XNumberFormatTypes xNumberFormatTypes; + public XPropertySet xNumberFormatSettings; + private boolean bNullDateCorrectionIsDefined = false; + private Locale aLocale; + + + public NumberFormatter(XMultiServiceFactory _xMSF, XNumberFormatsSupplier _xNumberFormatsSupplier, Locale _aLocale) throws Exception + { + aLocale = _aLocale; + Object oNumberFormatter = _xMSF.createInstance("com.sun.star.util.NumberFormatter"); + xNumberFormats = _xNumberFormatsSupplier.getNumberFormats(); + xNumberFormatSettings = _xNumberFormatsSupplier.getNumberFormatSettings(); + xNumberFormatter = (XNumberFormatter) UnoRuntime.queryInterface(XNumberFormatter.class, oNumberFormatter); + xNumberFormatter.attachNumberFormatsSupplier(_xNumberFormatsSupplier); + xNumberFormatTypes = (XNumberFormatTypes) UnoRuntime.queryInterface(XNumberFormatTypes.class, xNumberFormats); + + } + + public NumberFormatter(XNumberFormatsSupplier _xNumberFormatsSupplier, Locale _aLocale) throws Exception + { + aLocale = _aLocale; + xNumberFormats = _xNumberFormatsSupplier.getNumberFormats(); + xNumberFormatSettings = _xNumberFormatsSupplier.getNumberFormatSettings(); + xNumberFormatTypes = (XNumberFormatTypes) UnoRuntime.queryInterface(XNumberFormatTypes.class, xNumberFormats); + } + + + /** + * @param _xMSF + * @param _xNumberFormatsSupplier + * @return + * @throws Exception + * @deprecated + * + */ + public static XNumberFormatter createNumberFormatter(XMultiServiceFactory _xMSF, XNumberFormatsSupplier _xNumberFormatsSupplier) throws Exception + { + Object oNumberFormatter = _xMSF.createInstance("com.sun.star.util.NumberFormatter"); + XNumberFormatter xNumberFormatter = (XNumberFormatter) UnoRuntime.queryInterface(XNumberFormatter.class, oNumberFormatter); + xNumberFormatter.attachNumberFormatsSupplier(_xNumberFormatsSupplier); + return xNumberFormatter; + } + + + /** + * gives a key to pass to a NumberFormat object. <br/> + * example: <br/> + * <pre> + * XNumberFormatsSupplier nsf = (XNumberFormatsSupplier)UnoRuntime.queryInterface(...,document); + * int key = Desktop.getNumberFormatterKey( nsf, ...star.i18n.NumberFormatIndex.DATE...); + * XNumberFormatter nf = Desktop.createNumberFormatter(xmsf, nsf); + * nf.convertNumberToString( key, 1972 ); + * </pre> + * @param numberFormatsSupplier + * @param type - a constant out of i18n.NumberFormatIndex enumeration. + * @return a key to use with a util.NumberFormat instance. + * + */ + public static int getNumberFormatterKey( Object numberFormatsSupplier, short type) + { + Object numberFormatTypes = ((XNumberFormatsSupplier)UnoRuntime.queryInterface(XNumberFormatsSupplier.class,numberFormatsSupplier)).getNumberFormats(); + Locale l = new Locale(); + return ((XNumberFormatTypes)UnoRuntime.queryInterface(XNumberFormatTypes.class,numberFormatTypes)).getFormatIndex(type, l); + } + + + public String convertNumberToString(int _nkey, double _dblValue) + { + return xNumberFormatter.convertNumberToString(_nkey, _dblValue); + } + + + public static String convertNumberToString(XNumberFormatter _xNumberFormatter, int _nkey, double _dblValue) + { + return _xNumberFormatter.convertNumberToString(_nkey, _dblValue); + } + + + public double convertStringToNumber(int _nkey, String _sString)throws Exception + { + return xNumberFormatter.convertStringToNumber(_nkey, _sString); + } + + + /** + * @param dateCorrection The lDateCorrection to set. + */ + public void setNullDateCorrection(long dateCorrection) + { + lDateCorrection = dateCorrection; + } + + + public int defineNumberFormat(String _FormatString) + { + try + { + int NewFormatKey = xNumberFormats.queryKey(_FormatString, aLocale, true); + if (NewFormatKey == -1) + { + NewFormatKey = xNumberFormats.addNew(_FormatString, aLocale); + } + return NewFormatKey; + } + catch (Exception e) + { + e.printStackTrace(System.out); + return -1; + } + } + + + /** + * returns a numberformat for a FormatString. + * @param _FormatString + * @param _aLocale + * @return + */ + public int defineNumberFormat(String _FormatString, Locale _aLocale) + { + try + { + int NewFormatKey = xNumberFormats.queryKey(_FormatString, _aLocale, true); + if (NewFormatKey == -1) + { + NewFormatKey = xNumberFormats.addNew(_FormatString, _aLocale); + } + return NewFormatKey; + } + catch (Exception e) + { + e.printStackTrace(System.out); + return -1; + } + } + + + + public void setNumberFormat(XInterface _xFormatObject, int _FormatKey, NumberFormatter _oNumberFormatter) + { + try + { + XPropertySet xNumberFormat = _oNumberFormatter.xNumberFormats.getByKey(_FormatKey); //CurDBField.DBFormatKey); + String FormatString = AnyConverter.toString(Helper.getUnoPropertyValue(xNumberFormat, "FormatString")); + Locale oLocale = (Locale) Helper.getUnoPropertyValue(xNumberFormat, "Locale"); + int NewFormatKey = defineNumberFormat(FormatString, oLocale); + XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, _xFormatObject); + xPSet.setPropertyValue("FormatsSupplier", _oNumberFormatter.xNumberFormatter.getNumberFormatsSupplier()); + if (xPSet.getPropertySetInfo().hasPropertyByName("NumberFormat")) + { + xPSet.setPropertyValue("NumberFormat", new Integer(NewFormatKey)); + } + else if (xPSet.getPropertySetInfo().hasPropertyByName("FormatKey")) + { + xPSet.setPropertyValue("FormatKey", new Integer(NewFormatKey)); + } + else + { + // TODO: throws a exception in a try catch environment, very helpful? + throw new Exception(); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + } + } + + + public long getNullDateCorrection() + { + if (!this.bNullDateCorrectionIsDefined) + { + com.sun.star.util.Date dNullDate = (com.sun.star.util.Date) Helper.getUnoStructValue(this.xNumberFormatSettings, "NullDate"); + long lNullDate = Helper.convertUnoDatetoInteger(dNullDate); + java.util.Calendar oCal = java.util.Calendar.getInstance(); + oCal.set(1900, 1, 1); + Date dTime = oCal.getTime(); + long lTime = dTime.getTime(); + long lDBNullDate = lTime / (3600 * 24000); + lDateCorrection = lDBNullDate - lNullDate; + return lDateCorrection; + } + else + { + return this.lDateCorrection; + } + } + + + public int setBooleanReportDisplayNumberFormat() + { + String FormatString = "[=1]" + '"' + (char)9745 + '"' + ";[=0]" + '"' + (char)58480 + '"' + ";0"; + iLogicalFormatKey = xNumberFormats.queryKey(FormatString, aLocale, true); + try + { + if (iLogicalFormatKey == -1) + { + iLogicalFormatKey = xNumberFormats.addNew(FormatString, aLocale); + } + } + catch (Exception e) + { //MalformedNumberFormat + e.printStackTrace(); + iLogicalFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.LOGICAL, aLocale); + } + return iLogicalFormatKey; + } + + + /** + * @return Returns the iDateFormatKey. + */ + public int getDateFormatKey() + { + if (iDateFormatKey == -1) + { + iDateFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.DATE, aLocale); + } + return iDateFormatKey; + } + /** + * @return Returns the iDateTimeFormatKey. + */ + public int getDateTimeFormatKey() + { + if (iDateTimeFormatKey == -1) + { + iDateTimeFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.DATETIME, aLocale); + } + return iDateTimeFormatKey; + } + /** + * @return Returns the iLogicalFormatKey. + */ + public int getLogicalFormatKey() + { + if (iLogicalFormatKey == -1) + { + iLogicalFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.LOGICAL, aLocale); + } + return iLogicalFormatKey; + } + /** + * @return Returns the iNumberFormatKey. + */ + public int getNumberFormatKey() + { + if (iNumberFormatKey == -1) + { + iNumberFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.NUMBER, aLocale); + } + return iNumberFormatKey; + } + /** + * @return Returns the iTextFormatKey. + */ + public int getTextFormatKey() + { + if (iTextFormatKey == -1) + { + iTextFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.TEXT, aLocale); + } + return iTextFormatKey; + } + /** + * @return Returns the iTimeFormatKey. + */ + public int getTimeFormatKey() + { + if (iTimeFormatKey == -1) + { + iTimeFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.TIME, aLocale); + } + return iTimeFormatKey; + } +} diff --git a/wizards/com/sun/star/wizards/common/NumericalHelper.java b/wizards/com/sun/star/wizards/common/NumericalHelper.java new file mode 100644 index 000000000000..109affffd5ef --- /dev/null +++ b/wizards/com/sun/star/wizards/common/NumericalHelper.java @@ -0,0 +1,1625 @@ +/* + ************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +// import com.sun.star.beans.XPropertySet; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.TypeClass; + +/** + * A class for helping with all kinds of numerical conversions. + * Optional or named parameters in SO are of the Object type in Java. + * These objects must be converted to the right simple value type. + * Unfortunately, StarBasic does not know the original desired type, + * and a value that should be a "Float" is delivered as "Byte". This class + * handles the conversions of these types.<br> + * This class does not log warnings (or throws Exceptions) when the precision + * of a value is lost. + */ +public class NumericalHelper +{ + + public static final int UNKNOWN_TYPE = -32768; + public static final int BYTE_TYPE = 0; + public static final int SHORT_TYPE = 1; + public static final int INT_TYPE = 2; + public static final int LONG_TYPE = 3; + public static final int FLOAT_TYPE = 4; + public static final int DOUBLE_TYPE = 5; + public static final int CHAR_TYPE = 6; + public static final int STRING_TYPE = -1; + public static final int BOOLEAN_TYPE = -2; + public static final int ARRAY_TYPE = -3; + public static final int SEQUENCE_TYPE = -4; + public static final int ASCII_VALUE_0 = 48; + public static final int ASCII_VALUE_A = 65; + public static final int COUNT_CHARS_IN_ALPHABET = 26; + private static final int HEX_BASE = 16; + private static final int DEC_BASE = 10; + private static final int ASCII_LETTER_A_OFFSET = 55; + + /** + * private c'tor to prevent instantiation + */ + private NumericalHelper() + { + // private c'tor, so noone can instantiate + } + + /** + * get the type of an object: returns all types that can possibly converted + * with this class. + * @param obj an object that is checked for conversion + * @return the type of the object + */ + public static int getType(Object obj) + { + try + { + TypeObject aTypeObject = getTypeObject(obj); + return aTypeObject.iType; + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + // ignore this one; just return unknown type + } + return UNKNOWN_TYPE; + } + + /** + * get a byte value from the object + * @param aValue + * @return a byte + * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted + */ + public static byte toByte(Object aValue) + throws com.sun.star.lang.IllegalArgumentException + { + + byte retValue = 0; + // boolean hasConversionWarning = false; + TypeObject aTypeObject = getTypeObject(aValue); + switch (aTypeObject.iType) + { + case BYTE_TYPE: + retValue = getByte(aTypeObject); + break; + case CHAR_TYPE: + retValue = (byte) getChar(aTypeObject); + break; + case SHORT_TYPE: + retValue = (byte) getShort(aTypeObject); + break; + case INT_TYPE: + retValue = (byte) getInt(aTypeObject); + break; + case LONG_TYPE: + retValue = (byte) getLong(aTypeObject); + break; + case FLOAT_TYPE: + retValue = (byte) getFloat(aTypeObject); + break; + case DOUBLE_TYPE: + retValue = (byte) getDouble(aTypeObject); + break; + case STRING_TYPE: + try + { + Byte b = new Byte((String) aTypeObject.aValue); + retValue = b.byteValue(); + } + catch (java.lang.NumberFormatException e) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert to byte: " + aTypeObject.aValue); + } + break; + case BOOLEAN_TYPE: + retValue = getBool(aTypeObject) ? (byte) -1 : (byte) 0; + break; + default: + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert this type: " + aValue.getClass().getName()); + } + return retValue; + } + + /** + * get a char value from the object + * @param aValue + * @return a char + * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted + */ + public static char toChar(Object aValue) + throws com.sun.star.lang.IllegalArgumentException + { + + char retValue = 0; + boolean hasConversionWarning = false; + TypeObject aTypeObject = getTypeObject(aValue); + switch (aTypeObject.iType) + { + case CHAR_TYPE: + retValue = getChar(aTypeObject); + break; + case BYTE_TYPE: + retValue = (char) getByte(aTypeObject); + break; + case SHORT_TYPE: + retValue = (char) getShort(aTypeObject); + break; + case INT_TYPE: + retValue = (char) getInt(aTypeObject); + break; + case LONG_TYPE: + retValue = (char) getLong(aTypeObject); + break; + case FLOAT_TYPE: + retValue = (char) getFloat(aTypeObject); + break; + case DOUBLE_TYPE: + retValue = (char) getDouble(aTypeObject); + break; + case STRING_TYPE: + try + { + String s = (String) aTypeObject.aValue; + if (s.length() > 0) + { + retValue = s.charAt(0); + } + else + { + retValue = (char) 0; + } + } + catch (java.lang.NumberFormatException e) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert to char: " + aTypeObject.aValue); + } + break; + case BOOLEAN_TYPE: + retValue = getBool(aTypeObject) ? (char) -1 : (char) 0; + break; + default: + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert this type: " + aValue.getClass().getName()); + } + return retValue; + } + + /** + * get a short value from the object + * @param aValue + * @return a short + * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted + */ + public static short toShort(Object aValue) + throws com.sun.star.lang.IllegalArgumentException + { + short retValue = 0; + TypeObject aTypeObject = getTypeObject(aValue); + switch (aTypeObject.iType) + { + case BYTE_TYPE: + retValue = (short) getByte(aTypeObject); + break; + case CHAR_TYPE: + retValue = (byte) getChar(aTypeObject); + break; + case SHORT_TYPE: + retValue = getShort(aTypeObject); + break; + case INT_TYPE: + retValue = (short) getInt(aTypeObject); + break; + case LONG_TYPE: + retValue = (short) getLong(aTypeObject); + break; + case FLOAT_TYPE: + retValue = (short) getFloat(aTypeObject); + break; + case DOUBLE_TYPE: + retValue = (short) getDouble(aTypeObject); + break; + case STRING_TYPE: + try + { + Short s = new Short((String) aTypeObject.aValue); + retValue = s.shortValue(); + } + catch (java.lang.NumberFormatException e) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert to short: " + aTypeObject.aValue); + } + break; + case BOOLEAN_TYPE: + retValue = getBool(aTypeObject) ? (short) -1 : (short) 0; + break; + default: + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert this type: " + aValue.getClass().getName()); + } + return retValue; + } + + public static boolean isValidAndNumerical(Object aValue) throws com.sun.star.lang.IllegalArgumentException + { + if (aValue != null) + { + if (!AnyConverter.isVoid(aValue)) + { + return (NumericalHelper.isNumerical(aValue)); + } + } + return false; + } + + public static boolean isValidAndBoolean(Object aValue) throws com.sun.star.lang.IllegalArgumentException + { + if (aValue != null) + { + if (!AnyConverter.isVoid(aValue)) + { + int nType = AnyConverter.getType(aValue).getTypeClass().getValue(); + return (nType == TypeClass.BOOLEAN_value); + } + } + return false; + } + + public static boolean isValid(Object aValue) + { + if (aValue != null) + { + if (!AnyConverter.isVoid(aValue)) + { + return true; + } + } + return false; + } + + /** + @param aValue a object this can contain anything + @return true, if the parameter aValue is type of real numbers + @deprecate, use isRealNumber() instead. + */ + public static boolean isNumerical(Object aValue) + { + try + { + TypeObject aTypeObject = getTypeObject(aValue); + switch (aTypeObject.iType) + { + case BYTE_TYPE: + case CHAR_TYPE: + case SHORT_TYPE: + case INT_TYPE: + case LONG_TYPE: + case DOUBLE_TYPE: + case FLOAT_TYPE: + return true; + default: + return false; + } + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + return false; + } + } + + /** + @param _aValue a object this can contain anything + @return true, if the parameter aValue is type of real numbers + + see also http://en.wikipedia.org/wiki/Mathematics + */ + public static boolean isRealNumber(Object _aValue) + { + return isNumerical(_aValue); + } + + /** + @param aValue a object this can contain anything + * @return true, if the value is type of any integer values. double / float are not(!) integer values + * @throws com.sun.star.lang.IllegalArgumentException + */ + public static boolean isInteger(Object aValue) throws com.sun.star.lang.IllegalArgumentException + { + TypeObject aTypeObject = getTypeObject(aValue); + switch (aTypeObject.iType) + { + case BYTE_TYPE: + case CHAR_TYPE: + case SHORT_TYPE: + case INT_TYPE: + case LONG_TYPE: + return true; + default: + return false; + } + } + + /** + * Can a given object be converted to a String array? + * @param aValue the object to test + * @return true, if the object can be converted to a String array. + */ + public static boolean isStringArray(Object aValue) + { + try + { + toStringArray(aValue); + return true; + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + // ignore + } + return false; + } + + /** + * Can a given object be converted to an int array? + * @param aValue the object to test + * @return true, if the object can be converted to an Integer array. + */ + public static boolean isIntegerArray(Object aValue) + { + try + { + toIntArray(aValue); + return true; + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + // ignore + } + return false; + } +// public static int toIntWithErrorMessage(Object _aValue) throws com.sun.star.script.BasicErrorException{ +// try { +// return toInt(_aValue); +// } +// catch(com.sun.star.lang.IllegalArgumentException e) { +// DebugHelper.exception(BasicErrorCode.SbERR_CONVERSION, ""); +// return 0; +// }} +// +// +// public static String toStringWithErrorMessage(Object _aValue) throws com.sun.star.script.BasicErrorException{ +// try { +// return toString(_aValue); +// } +// catch(com.sun.star.lang.IllegalArgumentException e) { +// DebugHelper.exception(BasicErrorCode.SbERR_CONVERSION, ""); +// return ""; +// }} +// +// +// public static int toIntWithErrorMessage(Object _aValue, int _ndefaultValue) throws com.sun.star.script.BasicErrorException{ +// try { +// return toInt(_aValue, _ndefaultValue); +// } +// catch(com.sun.star.uno.Exception e) { +// DebugHelper.exception(BasicErrorCode.SbERR_CONVERSION, ""); +// return 0; +// }} +// +// public static boolean toBooleanWithErrorMessage(Object _oObject, int _nTrueField, int _nFalseField) throws com.sun.star.script.BasicErrorException{ +// return toBooleanWithErrorMessage(_oObject, new int[]{_nTrueField}, new int[]{_nFalseField}); +// } +// +// +// public static boolean toBooleanWithErrorMessage(Object _oObject) throws com.sun.star.script.BasicErrorException{ +// try{ +// return toBoolean(_oObject); +// } +// catch (java.lang.Exception e){ +// DebugHelper.exception(BasicErrorCode.SbERR_BAD_ARGUMENT, ""); +// return false; +// } +// } +// +// +// public static boolean toBooleanWithErrorMessage(Object _oObject, int[] _nTrueFields, int[] _nFalseFields) throws com.sun.star.script.BasicErrorException{ +// try{ +// int nValue = NumericalHelper.toIntWithErrorMessage(_oObject); +// if (ContainerUtilities.FieldInIntTable(_nTrueFields, nValue) > -1){ +// return true; +// } +// else if (ContainerUtilities.FieldInIntTable(_nFalseFields, nValue) > -1){ +// return false; +// } +// else{ +// DebugHelper.exception(BasicErrorCode.SbERR_OUT_OF_RANGE, ""); +// return false; +// } +// }catch (java.lang.Exception e){ +// DebugHelper.exception(BasicErrorCode.SbERR_OUT_OF_RANGE, ""); +// return false; +// }} +// +// +// public static boolean toBooleanWithErrorMessage(Object _oObject, int _nTrueField, int _nFalseField, boolean _bdefaultValue) throws com.sun.star.script.BasicErrorException{ +// return toBooleanWithErrorMessage(_oObject, new int[]{_nTrueField}, new int[]{_nFalseField}, _bdefaultValue); +// } +// +// +// public static boolean toBooleanWithErrorMessage(Object _oObject, int[] _nTrueFields, int[] _nFalseFields, boolean _bdefaultValue) throws com.sun.star.script.BasicErrorException{ +// try{ +// if ((_oObject == null) || (AnyConverter.isVoid(_oObject))){ +// return _bdefaultValue; +// } +// else{ +// int nValue = NumericalHelper.toIntWithErrorMessage(_oObject); +// if (ContainerUtilities.FieldInIntTable(_nTrueFields, nValue) > -1){ +// return true; +// } +// else if (ContainerUtilities.FieldInIntTable(_nFalseFields, nValue) > -1){ +// return false; +// } +// else{ +// DebugHelper.exception(BasicErrorCode.SbERR_OUT_OF_RANGE, ""); +// return false; +// } +// } +// }catch (java.lang.Exception e){ +// DebugHelper.exception(BasicErrorCode.SbERR_OUT_OF_RANGE, ""); +// return false; +// }} + /** + * get an int value from the object + * @param aValue + * @return an int + * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted + */ + public static int toInt(Object aValue) + throws com.sun.star.lang.IllegalArgumentException + { + int retValue = 0; + TypeObject aTypeObject = getTypeObject(aValue); + switch (aTypeObject.iType) + { + case BYTE_TYPE: + retValue = (int) getByte(aTypeObject); + break; + case CHAR_TYPE: + retValue = (int) getChar(aTypeObject); + break; + case SHORT_TYPE: + retValue = (int) getShort(aTypeObject); + break; + case INT_TYPE: + retValue = getInt(aTypeObject); + break; + case LONG_TYPE: + retValue = (int) getLong(aTypeObject); + break; + case FLOAT_TYPE: + retValue = (int) getFloat(aTypeObject); + break; + case DOUBLE_TYPE: + retValue = (int) getDouble(aTypeObject); + break; + case STRING_TYPE: + try + { + Integer i = new Integer((String) aTypeObject.aValue); + retValue = i.intValue(); + } + catch (java.lang.NumberFormatException e) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert to int: " + aTypeObject.aValue); + } + break; + case BOOLEAN_TYPE: + retValue = getBool(aTypeObject) ? -1 : 0; + break; + default: + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert this type: " + aValue.getClass().getName()); + } + return retValue; + } + + /** + * get a long value from the object + * @param aValue + * @return a long + * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted + */ + public static long toLong(Object aValue) + throws com.sun.star.lang.IllegalArgumentException + { + long retValue = 0; + TypeObject aTypeObject = getTypeObject(aValue); + switch (aTypeObject.iType) + { + case BYTE_TYPE: + retValue = (long) getByte(aTypeObject); + break; + case CHAR_TYPE: + retValue = (long) getChar(aTypeObject); + break; + case SHORT_TYPE: + retValue = (long) getShort(aTypeObject); + break; + case INT_TYPE: + retValue = (long) getInt(aTypeObject); + break; + case LONG_TYPE: + retValue = getLong(aTypeObject); + break; + case FLOAT_TYPE: + retValue = (long) getFloat(aTypeObject); + break; + case DOUBLE_TYPE: + retValue = (long) getDouble(aTypeObject); + break; + case STRING_TYPE: + try + { + Long l = new Long((String) aTypeObject.aValue); + retValue = l.longValue(); + } + catch (java.lang.NumberFormatException e) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert to short: " + aTypeObject.aValue); + } + break; + case BOOLEAN_TYPE: + retValue = getBool(aTypeObject) ? -1 : 0; + break; + default: + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert this type: " + aValue.getClass().getName()); + } + return retValue; + } + + /** + * get a float value from the object + * @param aValue + * @return a float + * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted + */ + public static float toFloat(Object aValue) + throws com.sun.star.lang.IllegalArgumentException + { + float retValue = (float) 0.0; + TypeObject aTypeObject = getTypeObject(aValue); + switch (aTypeObject.iType) + { + case BYTE_TYPE: + retValue = (float) getByte(aTypeObject); + break; + case CHAR_TYPE: + retValue = (float) getChar(aTypeObject); + break; + case SHORT_TYPE: + retValue = (float) getShort(aTypeObject); + break; + case INT_TYPE: + retValue = (float) getInt(aTypeObject); + break; + case LONG_TYPE: + retValue = (float) getLong(aTypeObject); + break; + case FLOAT_TYPE: + retValue = getFloat(aTypeObject); + break; + case DOUBLE_TYPE: + retValue = (float) getDouble(aTypeObject); + break; + case STRING_TYPE: + try + { + Float f = new Float((String) aTypeObject.aValue); + retValue = f.floatValue(); + } + catch (java.lang.NumberFormatException e) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert to short: " + aTypeObject.aValue); + } + break; + case BOOLEAN_TYPE: + retValue = getBool(aTypeObject) ? (float) -1 : (float) 0; + break; + default: + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert this type: " + aValue.getClass().getName()); + } + return retValue; + } + + /** + * get a double value from the object + * @param aValue + * @return a double + * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted + */ + public static double toDouble(Object aValue) + throws com.sun.star.lang.IllegalArgumentException + { + double retValue = 0.0; + TypeObject aTypeObject = getTypeObject(aValue); + switch (aTypeObject.iType) + { + case BYTE_TYPE: + retValue = (double) getByte(aTypeObject); + break; + case CHAR_TYPE: + retValue = (double) getChar(aTypeObject); + break; + case SHORT_TYPE: + retValue = (double) getShort(aTypeObject); + break; + case INT_TYPE: + retValue = (double) getInt(aTypeObject); + break; + case LONG_TYPE: + retValue = (double) getLong(aTypeObject); + break; + case FLOAT_TYPE: + retValue = (double) getFloat(aTypeObject); + break; + case DOUBLE_TYPE: + retValue = getDouble(aTypeObject); + break; + case STRING_TYPE: + try + { + Float f = new Float((String) aTypeObject.aValue); + retValue = f.floatValue(); + } + catch (java.lang.NumberFormatException e) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert to short: " + aTypeObject.aValue); + } + break; + case BOOLEAN_TYPE: + retValue = getBool(aTypeObject) ? (double) -1 : (double) 0; + break; + default: + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert this type: " + aValue.getClass().getName()); + } + return retValue; + } + + /** + * get a String value from the object + * @param aValue + * @return a String + * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted + */ + public static String toString(Object aValue) + throws com.sun.star.lang.IllegalArgumentException + { + String retValue = null; + TypeObject aTypeObject = getTypeObject(aValue); + switch (aTypeObject.iType) + { + case BYTE_TYPE: + retValue = ((Byte) aTypeObject.aValue).toString(); + break; + case CHAR_TYPE: + retValue = ((Character) aTypeObject.aValue).toString(); + break; + case SHORT_TYPE: + retValue = ((Short) aTypeObject.aValue).toString(); + break; + case INT_TYPE: + retValue = ((Integer) aTypeObject.aValue).toString(); + break; + case LONG_TYPE: + retValue = ((Long) aTypeObject.aValue).toString(); + break; + case FLOAT_TYPE: + retValue = ((Float) aTypeObject.aValue).toString(); + break; + case DOUBLE_TYPE: + retValue = ((Double) aTypeObject.aValue).toString(); + break; + case STRING_TYPE: + retValue = (String) aTypeObject.aValue; + break; + case BOOLEAN_TYPE: + retValue = ((Boolean) aTypeObject.aValue).toString(); + break; + case ARRAY_TYPE: + retValue = new String(toByteArray((aValue))); + break; + default: + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert this type: " + aValue.getClass().getName()); + } + return retValue; + } + + /** + * get a boolean value from the object + * @param aValue + * @return a boolean + * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted + */ + public static boolean toBoolean(Object aValue) + throws com.sun.star.lang.IllegalArgumentException + { + boolean retValue = true; + TypeObject aTypeObject = getTypeObject(aValue); + switch (aTypeObject.iType) + { + case BYTE_TYPE: + retValue = (((Byte) aTypeObject.aValue).byteValue() != 0); + break; + case CHAR_TYPE: + retValue = (((Character) aTypeObject.aValue).charValue() != 0); + break; + case SHORT_TYPE: + retValue = (((Short) aTypeObject.aValue).shortValue() != 0); + break; + case INT_TYPE: + retValue = (((Integer) aTypeObject.aValue).intValue() != 0); + break; + case LONG_TYPE: + retValue = (((Long) aTypeObject.aValue).longValue() != 0); + break; + case FLOAT_TYPE: + retValue = (((Float) aTypeObject.aValue).floatValue() != 0); + break; + case DOUBLE_TYPE: + retValue = (((Double) aTypeObject.aValue).doubleValue() != 0); + break; + case STRING_TYPE: + try + { + Boolean b = Boolean.valueOf((String) aTypeObject.aValue); + retValue = b.booleanValue(); + } + catch (java.lang.NumberFormatException e) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert to short: " + aTypeObject.aValue); + } + break; + case BOOLEAN_TYPE: + retValue = ((Boolean) aTypeObject.aValue).booleanValue(); + break; + default: + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert this type: " + aValue.getClass().getName()); + } + return retValue; + } + + /** + * get an int array from an object + * @param anArrayValue a value that is constructed into an array + * @return an integer array + * @throws com.sun.star.lang.IllegalArgumentException + */ + public static int[] toIntArray(Object anArrayValue) + throws com.sun.star.lang.IllegalArgumentException + { + int[] retValue = null; + TypeObject aTypeObject = getTypeObject(anArrayValue); + if (aTypeObject.iType == SEQUENCE_TYPE) + { + aTypeObject = convertSequenceToObjectArray(aTypeObject); + } + if (aTypeObject.iType == ARRAY_TYPE) + { + Object[] obj = (Object[]) aTypeObject.aValue; + retValue = new int[obj.length]; + for (int i = 0; i < obj.length; i++) + { + retValue[i] = toInt(obj[i]); + } + } + else + { // object is not really an array + retValue = new int[] + { + toInt(anArrayValue) + }; + } + return retValue; + } + + /** + * get an byte array from an object + * @param anArrayValue a value that is constructed into an array + * @return a byte array + * @throws com.sun.star.lang.IllegalArgumentException + */ + public static byte[] toByteArray(Object anArrayValue) + throws com.sun.star.lang.IllegalArgumentException + { + byte[] retValue = null; + TypeObject aTypeObject = getTypeObject(anArrayValue); + if (aTypeObject.iType == SEQUENCE_TYPE) + { + aTypeObject = convertSequenceToObjectArray(aTypeObject); + } + if (aTypeObject.iType == ARRAY_TYPE) + { + Object[] obj = (Object[]) aTypeObject.aValue; + retValue = new byte[obj.length]; + for (int i = 0; i < obj.length; i++) + { + retValue[i] = toByte(obj[i]); + } + } + else + { // object is not really an array + retValue = new byte[] + { + toByte(anArrayValue) + }; + } + return retValue; + } + + /** + * get a short array from an object + * @param anArrayValue a value that is constructed into an array + * @return a short array + * @throws com.sun.star.lang.IllegalArgumentException + */ + public static short[] toShortArray(Object anArrayValue) + throws com.sun.star.lang.IllegalArgumentException + { + short[] retValue = null; + TypeObject aTypeObject = getTypeObject(anArrayValue); + if (aTypeObject.iType == SEQUENCE_TYPE) + { + aTypeObject = convertSequenceToObjectArray(aTypeObject); + } + if (aTypeObject.iType == ARRAY_TYPE) + { + Object[] obj = (Object[]) aTypeObject.aValue; + retValue = new short[obj.length]; + for (int i = 0; i < obj.length; i++) + { + retValue[i] = toShort(obj[i]); + } + } + else + { // object is not really an array + retValue = new short[] + { + toShort(anArrayValue) + }; + } + return retValue; + } + + /** + * get a string array from an object + * @param anArrayValue a value that is constructed into an array + * @return a short array + * @throws com.sun.star.lang.IllegalArgumentException + */ + public static String[] toStringArray(Object anArrayValue) + throws com.sun.star.lang.IllegalArgumentException + { + String[] retValue = null; + TypeObject aTypeObject = getTypeObject(anArrayValue); + if (aTypeObject.iType == SEQUENCE_TYPE) + { + aTypeObject = convertSequenceToObjectArray(aTypeObject); + } + if (aTypeObject.iType == ARRAY_TYPE) + { + Object[] obj = (Object[]) aTypeObject.aValue; + retValue = new String[obj.length]; + for (int i = 0; i < obj.length; i++) + { + retValue[i] = toString(obj[i]); + } + } + else + { // object is not really an array + retValue = new String[] + { + toString(anArrayValue) + }; + } + return retValue; + } + + /** + * get an int from an object + * @param _aValue a value that is constructed into an int + * @param _ndefaultValue the value that is returned, if conversion fails, or if 'aValue' is null + * @return an int value + * @throws java.lang.Exception + */ + public static int toInt(Object _aValue, int _ndefaultValue) throws Exception + { + int nreturn = _ndefaultValue; + try + { + if ((_aValue != null) && (!(AnyConverter.isVoid(_aValue)))) + { + if (isInteger(_aValue)) + { + nreturn = toInt(_aValue); + } + else + { + DebugHelper.exception(1/* BasicErrorCode.SbERR_CONVERSION*/, ""); + } + } + } + catch (com.sun.star.uno.Exception e) + { + DebugHelper.exception(1 /*BasicErrorCode.SbERR_METHOD_FAILED*/, ""); + } + return nreturn; + } + + /** + * get a long from an object + * @param aValue a value that is constructed into a long + * @param defaultValue the value that is returned, if conversion fails + * @return a long value + */ + public static long toLong(Object aValue, long defaultValue) + { + try + { + return toLong(aValue); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + // ignore exception + } + return defaultValue; + } + + /** + * get a float from an object + * @param aValue a value that is constructed into a float + * @param defaultValue the value that is returned, if conversion fails + * @return a long value + */ + public static float toFloat(Object aValue, float defaultValue) + { + try + { + return toFloat(aValue); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + // ignore exception + } + return defaultValue; + } + + /** + * get a double from an object + * @param aValue a value that is constructed into a double + * @param defaultValue the value that is returned, if conversion fails + * @return a double value + */ + public static double toDouble(Object aValue, double defaultValue) + { + try + { + return toDouble(aValue); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + // ignore exception + } + return defaultValue; + } + + /** + * get a string from an object + * @param aValue a value that is constructed into a string + * @param defaultValue the value that is returned, if conversion fails + * @return a string value + */ + public static String toString(Object aValue, String defaultValue) + { + try + { + return toString(aValue); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + // ignore exception + } + return defaultValue; + } + + /** + * get a boolean from an object + * @param aValue a value that is constructed into a boolean + * @param defaultValue the value that is returned, if conversion fails + * @return a boolean value + */ + public static boolean toBoolean(Object aValue, boolean defaultValue) + { + try + { + return toBoolean(aValue); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + // ignore exception + } + return defaultValue; + } + + /** + * get a int array from an object + * @param anArrayValue a value that is constructed into an int array + * @param defaultValue the value that is returned, if conversion fails + * @return an int array + */ + public static int[] toIntArray(Object anArrayValue, int[] defaultValue) + { + try + { + return toIntArray(anArrayValue); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + // ignore exception + } + return defaultValue; + } + + /** + * get a short array from an object + * @param anArrayValue a value that is constructed into a short array + * @param defaultValue the value that is returned, if conversion fails + * @return a short array + */ + public static short[] toShortArray(Object anArrayValue, short[] defaultValue) + { + try + { + return toShortArray(anArrayValue); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + // ignore exception + } + return defaultValue; + } + + /** + * get a string array from an object + * @param anArrayValue a value that is constructed into a string array + * @param defaultValue the value that is returned, if conversion fails + * @return a string array + */ + public static String[] toStringArray(Object anArrayValue, String[] defaultValue) + { + try + { + return toStringArray(anArrayValue); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + // ignore exception + } + return defaultValue; + } + + /** + * get a hexadecimal representation from a number + * @param number the number to transform + * @return a String with the hex code of the number + */ + public static String getHexStringFromNumber(long number) + { + TransformNumToHex num = new TransformNumToHex(number); + return num.getResult(); + } + + /** + * Get the roman equivalent to an arabic number, e.g. 17 -> XVII. + * The allowed range for numbers goes from 1 to 3999. These can be + * converted using ASCII letters (3999 -> MMMCMXCIX). + * @param n the arabic number + * @return the roman equivalent as string + * @throws BasicErrorException if the number cannot be converted. + */ +// public static String getRomanEquivalent(int n) +// throws com.sun.star.script.BasicErrorException { +// return RomanNumbering.getRomanEquivalent(n); +// } + /** + * get the type object from the given object + * @param aValue an object representing a (numerical) value; can also be an 'any' + * @return a type object: the object together with the its type information + * @throws com.sun.star.lang.IllegalArgumentException if the object is unknown + */ + private static TypeObject getTypeObject(Object aValue) + throws com.sun.star.lang.IllegalArgumentException + { + TypeObject aTypeObject = new TypeObject(); + if (aValue == null || AnyConverter.isVoid(aValue)) + { + throw new com.sun.star.lang.IllegalArgumentException("Cannot convert a null object."); + } + int type = AnyConverter.getType(aValue).getTypeClass().getValue(); + switch (type) + { + case TypeClass.CHAR_value: + aTypeObject.iType = CHAR_TYPE; + aTypeObject.aValue = new Character(AnyConverter.toChar(aValue)); + break; + case TypeClass.BYTE_value: + aTypeObject.iType = BYTE_TYPE; + aTypeObject.aValue = new Byte(AnyConverter.toByte(aValue)); + break; + case TypeClass.SHORT_value: + aTypeObject.iType = SHORT_TYPE; + aTypeObject.aValue = new Short(AnyConverter.toShort(aValue)); + break; + case TypeClass.LONG_value: + aTypeObject.iType = INT_TYPE; + aTypeObject.aValue = new Integer(AnyConverter.toInt(aValue)); + break; + case TypeClass.HYPER_value: + aTypeObject.iType = LONG_TYPE; + aTypeObject.aValue = new Long(AnyConverter.toLong(aValue)); + break; + case TypeClass.FLOAT_value: + aTypeObject.iType = FLOAT_TYPE; + aTypeObject.aValue = new Float(AnyConverter.toFloat(aValue)); + break; + case TypeClass.DOUBLE_value: + aTypeObject.iType = DOUBLE_TYPE; + aTypeObject.aValue = new Double(AnyConverter.toDouble(aValue)); + break; + case TypeClass.STRING_value: + aTypeObject.iType = STRING_TYPE; + aTypeObject.aValue = AnyConverter.toString(aValue); + break; + case TypeClass.BOOLEAN_value: + aTypeObject.iType = BOOLEAN_TYPE; + aTypeObject.aValue = Boolean.valueOf(AnyConverter.toBoolean(aValue)); + break; + case TypeClass.ARRAY_value: + aTypeObject.iType = ARRAY_TYPE; + aTypeObject.aValue = new Object[] + { + AnyConverter.toArray(aValue) + }; + break; + case TypeClass.SEQUENCE_value: + aTypeObject.iType = SEQUENCE_TYPE; + aTypeObject.aValue = aValue; + break; + default: + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert this type: " + aValue.getClass().getName()); + } + return aTypeObject; + } + + /** + * get the simple byte type + */ + private static byte getByte(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != BYTE_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not a byte type."); + } + return ((Byte) typeObject.aValue).byteValue(); + } + + /** + * get the simple char type + */ + private static char getChar(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != CHAR_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not a char type."); + } + return ((Character) typeObject.aValue).charValue(); + } + + /** + * get the simple short type + */ + private static short getShort(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != SHORT_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not a short type."); + } + return ((Short) typeObject.aValue).shortValue(); + } + + /** + * get the simple int type + * @param typeObject + * @return + * @throws com.sun.star.lang.IllegalArgumentException + */ + static int getInt(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != INT_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not an int type."); + } + return ((Integer) typeObject.aValue).intValue(); + } + + /** + * get the simple float type + * @throws com.sun.star.lang.IllegalArgumentException + */ + static float getFloat(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != FLOAT_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not a float type."); + } + return ((Float) typeObject.aValue).floatValue(); + } + + /** + * get the simple double type + */ + private static double getDouble(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != DOUBLE_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not a double type."); + } + return ((Double) typeObject.aValue).doubleValue(); + } + + /** + * get the simple long type + */ + private static long getLong(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != LONG_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not a long type."); + } + return ((Long) typeObject.aValue).longValue(); + } + + /** + * get the simple boolean type + */ + private static boolean getBool(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != BOOLEAN_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not a boolean type."); + } + return ((Boolean) typeObject.aValue).booleanValue(); + } + + /** + * a class to contain a type and a value for easier conversions + */ + private static class TypeObject + { + + public int iType; + public Object aValue; + } + + /** + * simple class to construct a hexadecimal value from a long number + */ + private static class TransformNumToHex + { + + private StringBuffer val; + + public TransformNumToHex(long number) + { + val = new StringBuffer(); + transform(number); + } + + private void transform(long number) + { + int index = (int) (number % HEX_BASE); + number = number / HEX_BASE; + if (index < DEC_BASE) + { + val.insert(0, index); + } + else + { + val.insert(0, (char) (ASCII_LETTER_A_OFFSET + index)); + } + if (number > 0) + { + transform(number); + } + } + + public String getResult() + { + return val.toString(); + } + } + + private static TypeObject convertSequenceToObjectArray( + TypeObject sourceObject) + throws com.sun.star.lang.IllegalArgumentException + { + TypeObject destObject = new TypeObject(); + Object array = sourceObject.aValue; + destObject.iType = ARRAY_TYPE; + Class c = array.getClass(); + Object[] aShortVal = null; + if (c.equals(byte[].class)) + { + byte[] vals = (byte[]) array; + aShortVal = new Object[vals.length]; + for (int i = 0; i < vals.length; i++) + { + aShortVal[i] = new Byte(vals[i]); + } + } + else if (c.equals(short[].class)) + { + short[] vals = (short[]) array; + aShortVal = new Object[vals.length]; + for (int i = 0; i < vals.length; i++) + { + aShortVal[i] = new Short(vals[i]); + } + } + else if (c.equals(int[].class)) + { + int[] vals = (int[]) array; + aShortVal = new Object[vals.length]; + for (int i = 0; i < vals.length; i++) + { + aShortVal[i] = new Integer(vals[i]); + } + } + else if (c.equals(long[].class)) + { + long[] vals = (long[]) array; + aShortVal = new Object[vals.length]; + for (int i = 0; i < vals.length; i++) + { + aShortVal[i] = new Long(vals[i]); + } + } + else if (c.equals(float[].class)) + { + float[] vals = (float[]) array; + aShortVal = new Object[vals.length]; + for (int i = 0; i < vals.length; i++) + { + aShortVal[i] = new Float(vals[i]); + } + } + else if (c.equals(double[].class)) + { + double[] vals = (double[]) array; + aShortVal = new Object[vals.length]; + for (int i = 0; i < vals.length; i++) + { + aShortVal[i] = new Double(vals[i]); + } + } + else if (c.equals(boolean[].class)) + { + boolean[] vals = (boolean[]) array; + aShortVal = new Object[vals.length]; + for (int i = 0; i < vals.length; i++) + { + aShortVal[i] = Boolean.valueOf(vals[i]); + } + } + // if nothing did match, try this + if (aShortVal == null) + { + try + { + aShortVal = (Object[]) array; + } + catch (java.lang.ClassCastException e) + { + // unknown type cannot be converted + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert unknown type: '" + e.getMessage() + "'"); + } + } + destObject.aValue = aShortVal; + return destObject; + } + +// public static boolean isObjectNumericRepresentation(Object _oValue, NumberFormatter _oNumberFormatter, XPropertySet _xPropertySet) throws com.sun.star.script.BasicErrorException{ +// try{ +// int nNumberFormat = AnyConverter.toInt(_xPropertySet.getPropertyValue("NumberFormat")); +// if (AnyConverter.isString(_oValue)){ +// String sCellContent = AnyConverter.toString(_oValue); +// try{ +// _oNumberFormatter.convertStringToNumber(nNumberFormat, sCellContent); +// return true; +// }catch (Exception e){ +// return false; +// } +// } +// else{ +// return true; +// } +// } +// catch (com.sun.star.uno.Exception e){ +// DebugHelper.exception(1 /*BasicErrorCode.SbERR_METHOD_FAILED*/, ""); +// return false; +// }} + /** + * Helper class for roman numbering + */ + private static class RomanNumbering + { + + /** the used roman lettesrs **/ + private static final String[] ROMAN_EQUIV = new String[] + { + "I", "V", "X", "L", "C", "D", "M" + }; + /** max number that can be converted **/ + private static final int MAX_NUMBER = 3999; + /** min number that can be converted **/ + private static final int MIN_NUMBER = 1; + /** ASCII code for the number 0 **/ + private static final int ASCII_CODE_0 = 48; + /** special number for the conversion algorithm **/ + private static final int FOUR = 4; + /** special number for the conversion algorithm **/ + private static final int FIVE = 5; + /** special number for the conversion algorithm **/ + private static final int NINE = 9; + + /** + * Get the roman equivalent to an arabic number, e.g. 17 -> XVII. + * The allowed range for numbers goes from 1 to 3999. These can be + * converted using ASCII letters (3999 -> MMMCMXCIX). + * @param n the arabic number + * @return the roman equivalent as string + * @throws BasicErrorException if the number cannot be converted. + */ + public static String getRomanEquivalent(int n) + throws Exception + { + StringBuffer romanNumber = new StringBuffer(); + try + { + if (n > MAX_NUMBER || n < MIN_NUMBER) + { + DebugHelper.exception(1 /*BasicErrorCode.SbERR_OUT_OF_RANGE*/, ""); + } + String number = NumericalHelper.toString(new Integer(n)); + /* converison idea: every digit is written with a maximum of two + * different roman symbols, using three in total, e.g. CC, CD, + * DCC, CM for the hundreds (meaning 200, 400, 700 and 900). + * So every digit is converted seperately with regard to the + * special cases 4 and 9. + */ + int symbolIndex = 0; + for (int i = number.length() - 1; i >= 0; i--) + { + StringBuffer romanDigit = new StringBuffer(); + int b = (int) number.charAt(i) - ASCII_CODE_0; + if (b == FOUR) + { // special case IV + romanDigit.append(ROMAN_EQUIV[symbolIndex]); + romanDigit.append(ROMAN_EQUIV[symbolIndex + 1]); + } + else if (b == NINE) + { // special case IX + romanDigit.append(ROMAN_EQUIV[symbolIndex]); + romanDigit.append(ROMAN_EQUIV[symbolIndex + 2]); + } + else + { + if (b >= FIVE) + { // special case V + romanDigit.append(ROMAN_EQUIV[symbolIndex + 1]); + b = b - FIVE; + } + for (int j = 0; j < b; j++) + { // append I's + romanDigit.append(ROMAN_EQUIV[symbolIndex]); + } + } + // next group of three symbols + symbolIndex += 2; + // append in reverse: we are starting at the right + romanNumber.append(romanDigit.reverse()); + } + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + DebugHelper.exception(e); + } + // reverse again to get the number + return romanNumber.reverse().toString(); + } + } + + public static boolean representsIntegerNumber(double _dblvalue) + { + double dblsecvalue = (double) ((int) _dblvalue); + return Double.compare(_dblvalue, dblsecvalue) == 0; + } + + public static double roundDouble(Double _Dblvalue, int _ndecimals) + { + return roundDouble(_Dblvalue.doubleValue(), _ndecimals); + } + + public static double roundDouble(double _dblvalue, int _ndecimals) + { + double dblfactor = java.lang.Math.pow(10.0, (double) _ndecimals); + double dblretvalue = ((double) ((int) (_dblvalue * dblfactor))) / dblfactor; + return dblretvalue; + } +} diff --git a/wizards/com/sun/star/wizards/common/Properties.java b/wizards/com/sun/star/wizards/common/Properties.java new file mode 100644 index 000000000000..6b4155d15adf --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Properties.java @@ -0,0 +1,126 @@ +/* + ************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +/* + * Properties.java + * + * Created on 1. Oktober 2003, 17:16 + */ +package com.sun.star.wizards.common; + +import com.sun.star.beans.PropertyValue; +import java.util.*; + +/** + * Simplifies handling Arrays of PropertyValue. + * To make a use of this class, instantiate it, and call + * the put(propName,propValue) method. + * caution: propName should always be a String. + * When finished, call the getProperties() method to get an array of the set properties. + * @author rp + */ +public class Properties extends Hashtable +{ + + public static Object getPropertyValue(PropertyValue[] props, String propName) + { + for (int i = 0; i < props.length; i++) + { + if (propName.equals(props[i].Name)) + { + return props[i].Value; + } + } + throw new IllegalArgumentException("Property '" + propName + "' not found."); + } + + public static boolean hasPropertyValue(PropertyValue[] props, String propName) + { + for (int i = 0; i < props.length; i++) + { + if (propName.equals(props[i].Name)) + { + return true; + } + } + return false; + } + + public PropertyValue[] getProperties() + { + return getProperties(this); + } + + public static PropertyValue[] getProperties(Map map) + { + PropertyValue[] pv = new PropertyValue[map.size()]; + + Iterator it = map.keySet().iterator(); + for (int i = 0; i < pv.length; i++) + { + pv[i] = createProperty((String) it.next(), map); + } + return pv; + } + + public static PropertyValue createProperty(String name, Map map) + { + return createProperty(name, map.get(name)); + } + + public static PropertyValue createProperty(String name, Object value) + { + PropertyValue pv = new PropertyValue(); + pv.Name = name; + pv.Value = value; + return pv; + } + + public static PropertyValue createProperty(String name, Object value, int handle) + { + PropertyValue pv = createProperty(name, value); + pv.Handle = handle; + return pv; + } + + public static PropertyValue[] convertToPropertyValueArray(Object[] _oObjectArray) + { + PropertyValue[] retproperties = null; + if (_oObjectArray != null) + { + if (_oObjectArray.length > 0) + { + retproperties = new PropertyValue[_oObjectArray.length]; + for (int i = 0; i < _oObjectArray.length; i++) + { + retproperties[i] = (PropertyValue) _oObjectArray[i]; + } + } + } + return retproperties; + } +} diff --git a/wizards/com/sun/star/wizards/common/PropertySetHelper.java b/wizards/com/sun/star/wizards/common/PropertySetHelper.java new file mode 100644 index 000000000000..aec166a5c1c5 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/PropertySetHelper.java @@ -0,0 +1,396 @@ +/* + ************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +import com.sun.star.beans.Property; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; +import com.sun.star.uno.AnyConverter; +import com.sun.star.lang.XServiceInfo; + +// import com.sun.star.container.XNameAccess; +import java.util.HashMap; + +public class PropertySetHelper +{ + + protected XPropertySet m_xPropertySet; + private HashMap<String, Object> m_aHashMap; + + public PropertySetHelper(Object _aObj) + { + if (_aObj == null) + { + return; + } + m_xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, _aObj); + } + + private HashMap<String, Object> getHashMap() + { + if (m_aHashMap == null) + { + m_aHashMap = new HashMap<String, Object>(); + } + return m_aHashMap; + } + + /** + set a property, don't throw any exceptions, they will only write down as a hint in the helper debug output + @param _sName name of the property to set + @param _aValue property value as object + */ + public void setPropertyValueDontThrow(String _sName, Object _aValue) + { + try + { + setPropertyValue(_sName, _aValue); + } + catch (Exception e) + { + DebugHelper.writeInfo("Don't throw the exception with property name(" + _sName + " ) : " + e.getMessage()); + } + } + + /** + set a property, + @param _sName name of the property to set + @param _aValue property value as object + * @throws java.lang.Exception + */ + public void setPropertyValue(String _sName, Object _aValue) throws java.lang.Exception + { + if (m_xPropertySet != null) + { + try + { + m_xPropertySet.setPropertyValue(_sName, _aValue); + } + // Exceptions are not from interest + catch (com.sun.star.beans.UnknownPropertyException e) + { + DebugHelper.writeInfo(e.getMessage()); + DebugHelper.exception(e); + } + catch (com.sun.star.beans.PropertyVetoException e) + { + DebugHelper.writeInfo(e.getMessage()); + DebugHelper.exception(e); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + DebugHelper.writeInfo(e.getMessage()); + DebugHelper.exception(e); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + DebugHelper.writeInfo(e.getMessage()); + DebugHelper.exception(e); + } + } + else + { + // DebugHelper.writeInfo("PropertySetHelper.setProperty() can't get XPropertySet"); + getHashMap().put(_sName, _aValue); + } + } + + /** + get a property and convert it to a int value + @param _sName the string name of the property + @param _nDefault if an error occur, return this value + @return the int value of the property + */ + public int getPropertyValueAsInteger(String _sName, int _nDefault) + { + Object aObject = null; + int nValue = _nDefault; + + if (m_xPropertySet != null) + { + try + { + aObject = m_xPropertySet.getPropertyValue(_sName); + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + } + if (aObject != null) + { + try + { + nValue = NumericalHelper.toInt(aObject); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + DebugHelper.writeInfo("can't convert a object to integer."); + } + } + return nValue; + } + + /** + get a property and convert it to a short value + @param _sName the string name of the property + @param _nDefault if an error occur, return this value + @return the int value of the property + */ + public short getPropertyValueAsShort(String _sName, short _nDefault) + { + Object aObject = null; + short nValue = _nDefault; + + if (m_xPropertySet != null) + { + try + { + aObject = m_xPropertySet.getPropertyValue(_sName); + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + } + if (aObject != null) + { + try + { + nValue = NumericalHelper.toShort(aObject); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + DebugHelper.writeInfo("can't convert a object to short."); + } + } + return nValue; + } + + /** + get a property and convert it to a double value + @param _sName the string name of the property + @param _nDefault if an error occur, return this value + @return the int value of the property + */ + public double getPropertyValueAsDouble(String _sName, double _nDefault) + { + Object aObject = null; + double nValue = _nDefault; + + if (m_xPropertySet != null) + { + try + { + aObject = m_xPropertySet.getPropertyValue(_sName); + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + } + if (aObject == null) + { + if (getHashMap().containsKey(_sName)) + { + aObject = getHashMap().get(_sName); + } + } + if (aObject != null) + { + try + { + nValue = NumericalHelper.toDouble(aObject); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + DebugHelper.writeInfo("can't convert a object to integer."); + } + } + return nValue; + } + + /** + get a property and convert it to a boolean value + @param _sName the string name of the property + @param _bDefault if an error occur, return this value + @return the boolean value of the property + */ + public boolean getPropertyValueAsBoolean(String _sName, boolean _bDefault) + { + Object aObject = null; + boolean bValue = _bDefault; + + if (m_xPropertySet != null) + { + try + { + aObject = m_xPropertySet.getPropertyValue(_sName); + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + DebugHelper.writeInfo(e.getMessage()); + DebugHelper.writeInfo("UnknownPropertyException caught: Name:=" + _sName); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + } + if (aObject != null) + { + try + { + bValue = NumericalHelper.toBoolean(aObject); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + DebugHelper.writeInfo("can't convert a object to boolean."); + } + } + return bValue; + } + + /** + get a property and convert it to a string value + @param _sName the string name of the property + @param _sDefault if an error occur, return this value + @return the string value of the property + */ + public String getPropertyValueAsString(String _sName, String _sDefault) + { + Object aObject = null; + String sValue = _sDefault; + + if (m_xPropertySet != null) + { + try + { + aObject = m_xPropertySet.getPropertyValue(_sName); + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + } + if (aObject != null) + { + try + { + sValue = AnyConverter.toString(aObject); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + DebugHelper.writeInfo("can't convert a object to string."); + } + } + return sValue; + } + + /** + get a property and don't convert it + @param _sName the string name of the property + @return the object value of the property without any conversion + */ + public Object getPropertyValueAsObject(String _sName) + { + Object aObject = null; + + if (m_xPropertySet != null) + { + try + { + aObject = m_xPropertySet.getPropertyValue(_sName); + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + } + return aObject; + } + + /** + * Debug helper, to show all properties which are available in the given object. + * @param _xObj the object of which the properties should shown + */ + public static void showProperties(Object _xObj) + { + PropertySetHelper aHelper = new PropertySetHelper(_xObj); + aHelper.showProperties(); + } + + /** + Debug helper, to show all properties which are available in the current object. + */ + public void showProperties() + { + String sName = ""; + + if (m_xPropertySet != null) + { + XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, m_xPropertySet); + if (xServiceInfo != null) + { + sName = xServiceInfo.getImplementationName(); + } + XPropertySetInfo xInfo = m_xPropertySet.getPropertySetInfo(); + Property[] aAllProperties = xInfo.getProperties(); + DebugHelper.writeInfo("Show all properties of Implementation of :'" + sName + "'"); + for (int i = 0; i < aAllProperties.length; i++) + { + DebugHelper.writeInfo(" - " + aAllProperties[i].Name); + } + } + else + { + DebugHelper.writeInfo("The given object don't support XPropertySet interface."); + } + } +} diff --git a/wizards/com/sun/star/wizards/common/Resource.java b/wizards/com/sun/star/wizards/common/Resource.java new file mode 100644 index 000000000000..8dc660b21d07 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Resource.java @@ -0,0 +1,143 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.wizards.common; + +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.script.XInvocation; +import com.sun.star.beans.PropertyValue; + +public class Resource +{ + + XInvocation xInvocation; + XMultiServiceFactory xMSF; + String Unit; + String Module; + + /** Creates a new instance of Resource + * @param _xMSF + * @param _Unit + * @param _Module + */ + public Resource(XMultiServiceFactory _xMSF, String _Unit, String _Module) + { + this.xMSF = _xMSF; + this.Unit = _Unit; + this.Module = _Module; + this.xInvocation = initResources(); + } + + public String getResText(int nID) + { + try + { + short[][] PointerArray = new short[1][]; + Object[][] DummyArray = new Object[1][]; + Object[] nIDArray = new Object[1]; + nIDArray[0] = new Integer(nID); + final String IDString = (String) xInvocation.invoke("getString", nIDArray, PointerArray, DummyArray); + return IDString; + } + catch (Exception exception) + { + exception.printStackTrace(); + throw new java.lang.IllegalArgumentException("Resource with ID not" + String.valueOf(nID) + "not found"); + } + } + + public PropertyValue[] getStringList(int nID) + { + try + { + short[][] PointerArray = new short[1][]; + Object[][] DummyArray = new Object[1][]; + Object[] nIDArray = new Object[1]; + nIDArray[0] = new Integer(nID); + //Object bla = xInvocation.invoke("getStringList", nIDArray, PointerArray, DummyArray); + PropertyValue[] ResProp = (PropertyValue[]) xInvocation.invoke("getStringList", nIDArray, PointerArray, DummyArray); + return ResProp; + } + catch (Exception exception) + { + exception.printStackTrace(); + throw new java.lang.IllegalArgumentException("Resource with ID not" + String.valueOf(nID) + "not found"); + } + } + + public String[] getResArray(int nID, int iCount) + { + try + { + String[] ResArray = new String[iCount]; + for (int i = 0; i < iCount; i++) + { + ResArray[i] = getResText(nID + i); + } + return ResArray; + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + throw new java.lang.IllegalArgumentException("Resource with ID not" + String.valueOf(nID) + "not found"); + } + } + + public XInvocation initResources() + { + try + { + com.sun.star.uno.XInterface xResource = (com.sun.star.uno.XInterface) xMSF.createInstance("com.sun.star.resource.VclStringResourceLoader"); + if (xResource == null) + { + showCommonResourceError(xMSF); + throw new IllegalArgumentException(); + } + else + { + XInvocation xResInvoke = (XInvocation) com.sun.star.uno.UnoRuntime.queryInterface(XInvocation.class, xResource); + xResInvoke.setValue("FileName", Module); + return xResInvoke; + } + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + showCommonResourceError(xMSF); + return null; + } + } + + public static void showCommonResourceError(XMultiServiceFactory xMSF) + { + String ProductName = Configuration.getProductName(xMSF); + String sError = "The files required could not be found.\nPlease start the %PRODUCTNAME Setup and choose 'Repair'."; + sError = JavaTools.replaceSubString(sError, ProductName, "%PRODUCTNAME"); + SystemDialog.showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sError); + } +} diff --git a/wizards/com/sun/star/wizards/common/SystemDialog.java b/wizards/com/sun/star/wizards/common/SystemDialog.java new file mode 100644 index 000000000000..ac3a38c9cf7d --- /dev/null +++ b/wizards/com/sun/star/wizards/common/SystemDialog.java @@ -0,0 +1,428 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ui.dialogs.*; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.AnyConverter; +import com.sun.star.util.XStringSubstitution; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XInitialization; +import com.sun.star.frame.XFrame; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XMessageBox; +import com.sun.star.beans.PropertyValue; + +public class SystemDialog +{ + + Object systemDialog; + XFilePicker xFilePicker; + XFolderPicker xFolderPicker; + XFilterManager xFilterManager; + XInitialization xInitialize; + XExecutableDialog xExecutable; + XComponent xComponent; + XFilePickerControlAccess xFilePickerControlAccess; + XMultiServiceFactory xMSF; + public XStringSubstitution xStringSubstitution; + public String sStorePath; + + /** + * + * @param xMSF + * @param ServiceName + * @param type according to com.sun.star.ui.dialogs.TemplateDescription + */ + public SystemDialog(XMultiServiceFactory xMSF, String ServiceName, short type) + { + try + { + this.xMSF = xMSF; + systemDialog = (XInterface) xMSF.createInstance(ServiceName); + xFilePicker = (XFilePicker) UnoRuntime.queryInterface(XFilePicker.class, systemDialog); + xFolderPicker = (XFolderPicker) UnoRuntime.queryInterface(XFolderPicker.class, systemDialog); + xFilterManager = (XFilterManager) UnoRuntime.queryInterface(XFilterManager.class, systemDialog); + xInitialize = (XInitialization) UnoRuntime.queryInterface(XInitialization.class, systemDialog); + xExecutable = (XExecutableDialog) UnoRuntime.queryInterface(XExecutableDialog.class, systemDialog); + xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, systemDialog); + xFilePickerControlAccess = (XFilePickerControlAccess) UnoRuntime.queryInterface(XFilePickerControlAccess.class, systemDialog); + xStringSubstitution = createStringSubstitution(xMSF); + Short[] listAny = new Short[] + { + new Short(type) + }; + if (xInitialize != null) + { + xInitialize.initialize(listAny); + } + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(); + } + } + + public static SystemDialog createStoreDialog(XMultiServiceFactory xmsf) + { + return new SystemDialog(xmsf, "com.sun.star.ui.dialogs.FilePicker", TemplateDescription.FILESAVE_AUTOEXTENSION); + } + + public static SystemDialog createOpenDialog(XMultiServiceFactory xmsf) + { + return new SystemDialog(xmsf, "com.sun.star.ui.dialogs.FilePicker", TemplateDescription.FILEOPEN_SIMPLE); + } + + public static SystemDialog createFolderDialog(XMultiServiceFactory xmsf) + { + return new SystemDialog(xmsf, "com.sun.star.ui.dialogs.FolderPicker", (short) 0); + } + + public static SystemDialog createOfficeFolderDialog(XMultiServiceFactory xmsf) + { + return new SystemDialog(xmsf, "com.sun.star.ui.dialogs.OfficeFolderPicker", (short) 0); + } + + private String subst(String path) + { + try + { + //System.out.println("SystemDialog.subst:"); + //System.out.println(path); + String s = xStringSubstitution.substituteVariables(path, false); + //System.out.println(s); + return s; + + } + catch (Exception ex) + { + ex.printStackTrace(); + return path; + } + } + + /** + * ATTENTION a BUG : The extension calculated + * here gives the last 3 chars of the filename - what + * if the extension is of 4 or more chars? + * + * @param DisplayDirectory + * @param DefaultName + * @param sDocuType + * @return + */ + public String callStoreDialog(String DisplayDirectory, String DefaultName, String sDocuType) + { + String sExtension = DefaultName.substring(DefaultName.length() - 3, DefaultName.length()); + addFilterToDialog(sExtension, sDocuType, true); + return callStoreDialog(DisplayDirectory, DefaultName); + } + + /** + * + * @param displayDir + * @param defaultName + * given url to a local path. + * @return + */ + public String callStoreDialog(String displayDir, String defaultName) + { + sStorePath = null; + try + { + xFilePickerControlAccess.setValue(com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_AUTOEXTENSION, (short) 0, new Boolean(true)); + xFilePicker.setDefaultName(defaultName); + xFilePicker.setDisplayDirectory(subst(displayDir)); + if (execute(xExecutable)) + { + String[] sPathList = xFilePicker.getFiles(); + sStorePath = sPathList[0]; + } + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(); + } + return sStorePath; + } + + public String callFolderDialog(String title, String description, String displayDir) + { + try + { + xFolderPicker.setDisplayDirectory(subst(displayDir)); + } + catch (com.sun.star.lang.IllegalArgumentException iae) + { + iae.printStackTrace(); + throw new IllegalArgumentException(iae.getMessage()); + } + xFolderPicker.setTitle(title); + xFolderPicker.setDescription(description); + if (execute(xFolderPicker)) + { + return xFolderPicker.getDirectory(); + } + else + { + return null; + } + } + + private boolean execute(XExecutableDialog execDialog) + { + return execDialog.execute() == 1; + } + + public String[] callOpenDialog(boolean multiSelect, String displayDirectory) + { + + try + { + xFilePicker.setMultiSelectionMode(multiSelect); + xFilePicker.setDisplayDirectory(subst(displayDirectory)); + if (execute(xExecutable)) + { + return xFilePicker.getFiles(); + } + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(); + } + return null; + } + + //("writer_StarOffice_XML_Writer_Template") 'StarOffice XML (Writer) + public void addFilterToDialog(String sExtension, String filterName, boolean setToDefault) + { + try + { + //get the localized filtername + String uiName = getFilterUIName(filterName); + String pattern = "*." + sExtension; + + //add the filter + addFilter(uiName, pattern, setToDefault); + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + } + } + + public void addFilter(String uiName, String pattern, boolean setToDefault) + { + try + { + xFilterManager.appendFilter(uiName, pattern); + if (setToDefault) + { + xFilterManager.setCurrentFilter(uiName); + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + + /** + * converts the name returned from getFilterUIName_(...) so the + * product name is correct. + * @param filterName + * @return + */ + private String getFilterUIName(String filterName) + { + String prodName = Configuration.getProductName(xMSF); + String[][] s = new String[][] + { + { + getFilterUIName_(filterName) + } + }; + s[0][0] = JavaTools.replaceSubString(s[0][0], prodName, "%productname%"); + return s[0][0]; + } + + /** + * note the result should go through conversion of the product name. + * @param filterName + * @return the UI localized name of the given filter name. + */ + private String getFilterUIName_(String filterName) + { + try + { + Object oFactory = xMSF.createInstance("com.sun.star.document.FilterFactory"); + Object oObject = Helper.getUnoObjectbyName(oFactory, filterName); + Object oArrayObject = AnyConverter.toArray(oObject); + PropertyValue[] xPropertyValue = (PropertyValue[]) oArrayObject; //UnoRuntime.queryInterface(XPropertyValue.class, oObject); + int MaxCount = xPropertyValue.length; + for (int i = 0; i < MaxCount; i++) + { + PropertyValue aValue = xPropertyValue[i]; + if (aValue != null && aValue.Name.equals("UIName")) + { + return AnyConverter.toString(aValue.Value); + } + } + throw new NullPointerException("UIName property not found for Filter " + filterName); + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.out); + return null; + } + } + + public static int showErrorBox(XMultiServiceFactory xMSF, String ResName, String ResPrefix, int ResID, String AddTag, String AddString) + { + Resource oResource; + String ProductName = Configuration.getProductName(xMSF); + oResource = new Resource(xMSF, ResName, ResPrefix); + String sErrorMessage = oResource.getResText(ResID); + sErrorMessage = JavaTools.replaceSubString(sErrorMessage, ProductName, "%PRODUCTNAME"); + sErrorMessage = JavaTools.replaceSubString(sErrorMessage, String.valueOf((char) 13), "<BR>"); + sErrorMessage = JavaTools.replaceSubString(sErrorMessage, AddString, AddTag); + return SystemDialog.showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sErrorMessage); + } + + public static int showErrorBox(XMultiServiceFactory xMSF, String ResName, String ResPrefix, int ResID) + { + Resource oResource; + String ProductName = Configuration.getProductName(xMSF); + oResource = new Resource(xMSF, ResName, ResPrefix); + String sErrorMessage = oResource.getResText(ResID); + sErrorMessage = JavaTools.replaceSubString(sErrorMessage, ProductName, "%PRODUCTNAME"); + sErrorMessage = JavaTools.replaceSubString(sErrorMessage, String.valueOf((char) 13), "<BR>"); + return showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sErrorMessage); + } + + /* + * example: + * (xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, "message") + */ + /** + * @param windowServiceName one of the following strings: + * "ErrorBox", "WarningBox", "MessBox", "InfoBox", "QueryBox". + * There are other values possible, look + * under src/toolkit/source/awt/vcltoolkit.cxx + * @param windowAttribute see com.sun.star.awt.VclWindowPeerAttribute + * @return 0 = cancel, 1 = ok, 2 = yes, 3 = no(I'm not sure here) + * other values check for yourself ;-) + */ + public static int showMessageBox(XMultiServiceFactory xMSF, String windowServiceName, int windowAttribute, String MessageText) + { + + short iMessage = 0; + try + { + if (MessageText == null) + { + return 0; + } + XFrame xFrame = Desktop.getActiveFrame(xMSF); + XWindowPeer xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xFrame.getComponentWindow()); + return showMessageBox(xMSF, xWindowPeer, windowServiceName, windowAttribute, MessageText); + } + catch (Exception exception) + { + exception.printStackTrace(System.out); + } + return iMessage; + } + + /** + * just like the other showMessageBox(...) method, but recieves a + * peer argument to use to create the message box. + * @param xMSF + * @param peer + * @param windowServiceName + * @param windowAttribute + * @param MessageText + * @return + */ + public static int showMessageBox(XMultiServiceFactory xMSF, XWindowPeer peer, String windowServiceName, int windowAttribute, String MessageText) + { + // If the peer is null we try to get one from the desktop... + if (peer == null) + { + return showMessageBox(xMSF, windowServiceName, windowAttribute, MessageText); + } + short iMessage = 0; + try + { + XInterface xAWTToolkit = (XInterface) xMSF.createInstance("com.sun.star.awt.Toolkit"); + XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, xAWTToolkit); + com.sun.star.awt.WindowDescriptor oDescriptor = new com.sun.star.awt.WindowDescriptor(); + oDescriptor.WindowServiceName = windowServiceName; + oDescriptor.Parent = peer; + oDescriptor.Type = com.sun.star.awt.WindowClass.MODALTOP; + oDescriptor.WindowAttributes = windowAttribute; + XWindowPeer xMsgPeer = xToolkit.createWindow(oDescriptor); + XMessageBox xMsgbox = (XMessageBox) UnoRuntime.queryInterface(XMessageBox.class, xMsgPeer); + XComponent xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xMsgbox); + xMsgbox.setMessageText(MessageText); + iMessage = xMsgbox.execute(); + xComponent.dispose(); + } + catch (Exception e) + { + // TODO Auto-generated catch block + e.printStackTrace(System.out); + } + return iMessage; + } + + public static XStringSubstitution createStringSubstitution(XMultiServiceFactory xMSF) + { + Object xPathSubst = null; + try + { + xPathSubst = xMSF.createInstance( + "com.sun.star.util.PathSubstitution"); + } + catch (com.sun.star.uno.Exception e) + { + e.printStackTrace(); + } + if (xPathSubst != null) + { + return (XStringSubstitution) UnoRuntime.queryInterface( + XStringSubstitution.class, xPathSubst); + } + else + { + return null; + } + } +} diff --git a/wizards/com/sun/star/wizards/common/TerminateWizardException.java b/wizards/com/sun/star/wizards/common/TerminateWizardException.java new file mode 100644 index 000000000000..124d98f9ff31 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/TerminateWizardException.java @@ -0,0 +1,43 @@ +/* + ************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.common; + +// import com.sun.star.wizards.common.Resource; +import com.sun.star.lang.XMultiServiceFactory; + +public class TerminateWizardException extends Exception +{ + + public TerminateWizardException(XMultiServiceFactory xMSF) + { + Resource oResource = new Resource(xMSF, "AutoPilot", "dbw"); + String sErrorMessage = oResource.getResText(1006); + SystemDialog.showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sErrorMessage); + printStackTrace(System.out); + } +} diff --git a/wizards/com/sun/star/wizards/common/UCB.java b/wizards/com/sun/star/wizards/common/UCB.java new file mode 100644 index 000000000000..5e3ad00698df --- /dev/null +++ b/wizards/com/sun/star/wizards/common/UCB.java @@ -0,0 +1,269 @@ +/* + ************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +/* + * Created on 31.10.2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package com.sun.star.wizards.common; + +import java.util.List; +import java.util.Vector; + +import com.sun.star.beans.Property; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbc.XRow; +import com.sun.star.ucb.*; +import com.sun.star.uno.UnoRuntime; + +/** + * @author rpiterman + * This class is used to copy the content of a folder to + * another folder. + * There is an incosistency with argument order. + * It should be always: dir,filename. + */ +public class UCB +{ + + private Object ucb; + private FileAccess fa; + + public UCB(XMultiServiceFactory xmsf) throws Exception + { + String[] keys = new String[2]; + keys[ 0 ] = "Local"; + keys[ 1 ] = "Office"; + ucb = xmsf.createInstanceWithArguments( + "com.sun.star.ucb.UniversalContentBroker", keys ); + fa = new FileAccess(xmsf); + } + + public void deleteDirContent(String dir) + throws Exception + { + if (!fa.exists(dir,true)) + { + return; + } + List l = listFiles(dir,null); + for (int i = 0; i<l.size(); i++) + { + delete(FileAccess.connectURLs(dir ,(String)l.get(i))); + } + } + + public void delete(String filename) throws Exception + { + //System.out.println("UCB.delete(" + filename); + executeCommand( getContent(filename),"delete",Boolean.TRUE); + } + + public void copy(String sourceDir, String targetDir) throws Exception + { + copy(sourceDir,targetDir,(Verifier)null); + } + + public void copy(String sourceDir, String targetDir, Verifier verifier) throws Exception + { + List files = listFiles(sourceDir,verifier); + for (int i = 0; i<files.size(); i++) + { + copy(sourceDir, (String)files.get(i), targetDir); + } + + } + + public void copy(String sourceDir, String filename, String targetDir, String targetName) throws Exception + { + if (!fa.exists(targetDir,true)) + { + fa.fileAccess.createFolder(targetDir); + } + //System.out.println("UCB.copy(" + sourceDir + ", " + filename + ", " + targetDir+ ", " + targetName); + executeCommand(ucb, "globalTransfer", copyArg(sourceDir,filename, targetDir,targetName)); + } + + /** + * @deprecated + * @param sourceDir + * @param filename + * @param targetDir + * @throws Exception + */ + public void copy(String sourceDir, String filename, String targetDir) throws Exception + { + copy(sourceDir,filename, targetDir, ""); + } + + /** + * target name can be "", in which case the name stays lige the source name + * @param sourceDir + * @param sourceFilename + * @param targetDir + * @param targetFilename + * @return + */ + public GlobalTransferCommandArgument copyArg(String sourceDir, String sourceFilename, String targetDir, String targetFilename) + { + + GlobalTransferCommandArgument aArg = new GlobalTransferCommandArgument(); + aArg.Operation = TransferCommandOperation.COPY; + aArg.SourceURL = fa.getURL(sourceDir,sourceFilename); + aArg.TargetURL = targetDir; + aArg.NewTitle = targetFilename; + // fail, if object with same name exists in target folder + aArg.NameClash = NameClash.OVERWRITE; + return aArg; + } + + public Object executeCommand(Object xContent, String aCommandName, Object aArgument) + throws com.sun.star.ucb.CommandAbortedException, + com.sun.star.uno.Exception + { + XCommandProcessor xCmdProcessor = (XCommandProcessor)UnoRuntime.queryInterface( + XCommandProcessor.class, xContent); + Command aCommand = new Command(); + aCommand.Name = aCommandName; + aCommand.Handle = -1; // not available + aCommand.Argument = aArgument; + return xCmdProcessor.execute(aCommand, 0, null); + } + + public List listFiles(String path, Verifier verifier) throws Exception + { + Object xContent = getContent(path); + + OpenCommandArgument2 aArg = new OpenCommandArgument2(); + aArg.Mode = OpenMode.ALL; + aArg.Priority = 32768; + + // Fill info for the properties wanted. + aArg.Properties = new Property[] {new Property()}; + + aArg.Properties[0].Name = "Title"; + aArg.Properties[0].Handle = -1; + + XDynamicResultSet xSet; + + xSet = (XDynamicResultSet)UnoRuntime.queryInterface( + XDynamicResultSet.class,executeCommand(xContent, "open", aArg)); + + XResultSet xResultSet = xSet.getStaticResultSet(); + + List files = new Vector(); + + if (xResultSet.first()) + { + // obtain XContentAccess interface for child content access and XRow for properties + XContentAccess xContentAccess = (XContentAccess)UnoRuntime.queryInterface( + XContentAccess.class, xResultSet); + XRow xRow = (XRow)UnoRuntime.queryInterface(XRow.class, xResultSet); + do + { + // Obtain URL of child. + String aId = xContentAccess.queryContentIdentifierString(); + // First column: Title (column numbers are 1-based!) + String aTitle = xRow.getString(1); + if (aTitle.length() == 0 && xRow.wasNull()) + { + ; //ignore + } + else + { + files.add(aTitle); + } + } + while (xResultSet.next()); // next child + } + + if (verifier != null) + { + for (int i = 0; i<files.size(); i++) + { + if (!verifier.verify(files.get(i))) + { + files.remove(i--); + } + } + } + + return files; + } + + public Object getContentProperty(Object content, String propName, Class type) + throws Exception + { + Property[] pv = new Property[1]; + pv[0] = new Property(); + pv[0].Name = propName; + pv[0].Handle = -1; + + Object row = executeCommand(content,"getPropertyValues",pv); + XRow xrow = (XRow)UnoRuntime.queryInterface(XRow.class,row); + if (type.equals(String.class)) + { + return xrow.getString(1); + } + else if (type.equals(Boolean.class)) + { + return xrow.getBoolean(1) ? Boolean.TRUE : Boolean.FALSE; + } + else if (type.equals(Integer.class)) + { + return new Integer(xrow.getInt(1)); + } + else if (type.equals(Short.class)) + { + return new Short(xrow.getShort(1)); + } + else + { + return null; + } + + } + + public Object getContent(String path) throws Exception + { + //System.out.println("Getting Content for : " + path); + XContentIdentifier id = ((XContentIdentifierFactory) UnoRuntime.queryInterface(XContentIdentifierFactory.class, ucb)).createContentIdentifier(path); + + return ((XContentProvider)UnoRuntime.queryInterface( + XContentProvider.class,ucb)).queryContent(id); + } + + public static interface Verifier + { + + public boolean verify(Object object); + } +} diff --git a/wizards/com/sun/star/wizards/common/XMLHelper.java b/wizards/com/sun/star/wizards/common/XMLHelper.java new file mode 100644 index 000000000000..326ba03fbeea --- /dev/null +++ b/wizards/com/sun/star/wizards/common/XMLHelper.java @@ -0,0 +1,74 @@ +/* + ************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +/* + * XMLHelper.java + * + * Created on 30. September 2003, 15:38 + */ +package com.sun.star.wizards.common; + +import org.w3c.dom.*; + +/** + * + * @author rpiterman + */ +public class XMLHelper +{ + + public static Node addElement(Node parent, String name, String[] attNames, String[] attValues) + { + Document doc = parent.getOwnerDocument(); + if (doc == null) + { + doc = (Document) parent; + } + Element e = doc.createElement(name); + for (int i = 0; i < attNames.length; i++) + { + if (attValues[i] != null && (!attValues[i].equals(""))) + { + e.setAttribute(attNames[i], attValues[i]); + } + } + parent.appendChild(e); + return e; + } + + public static Node addElement(Node parent, String name, String attNames, String attValues) + { + return addElement(parent, name, new String[] + { + attNames + }, new String[] + { + attValues + }); + } +} diff --git a/wizards/com/sun/star/wizards/common/XMLProvider.java b/wizards/com/sun/star/wizards/common/XMLProvider.java new file mode 100644 index 000000000000..f5c2fd662d31 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/XMLProvider.java @@ -0,0 +1,46 @@ +/* + ************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +/* + * XMLSupplier.java + * + * Created on 19. September 2003, 11:52 + */ +package com.sun.star.wizards.common; + +import org.w3c.dom.Node; + +/** + * + * @author rpiterman + */ +public interface XMLProvider +{ + + public Node createDOM(Node parent); +} diff --git a/wizards/com/sun/star/wizards/common/delzip b/wizards/com/sun/star/wizards/common/delzip new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/delzip |