diff options
Diffstat (limited to 'odk/examples/java/Inspector')
36 files changed, 1301 insertions, 1301 deletions
diff --git a/odk/examples/java/Inspector/Addons.xcu b/odk/examples/java/Inspector/Addons.xcu index 0daa83fb392b..ee44a8d68773 100755 --- a/odk/examples/java/Inspector/Addons.xcu +++ b/odk/examples/java/Inspector/Addons.xcu @@ -15,7 +15,7 @@ </prop> <prop oor:name="Context" oor:type="xs:string"> <value></value> - </prop> + </prop> </node> </node> </node> diff --git a/odk/examples/java/Inspector/HideableMutableTreeNode.java b/odk/examples/java/Inspector/HideableMutableTreeNode.java index c7f10ee69c41..37ac35f116b1 100644 --- a/odk/examples/java/Inspector/HideableMutableTreeNode.java +++ b/odk/examples/java/Inspector/HideableMutableTreeNode.java @@ -1,73 +1,73 @@ // *** HideableMutableTreeNode *** import javax.swing.*; import javax.swing.tree.*; - + /** - * <code>HideableMutableTreeNode</code> is a <code>DefaultMutableTreeNode</code> - * implementation that works with <code>HideableTreeModel</code>. + * <code>HideableMutableTreeNode</code> is a <code>DefaultMutableTreeNode</code> + * implementation that works with <code>HideableTreeModel</code>. */ public class HideableMutableTreeNode extends DefaultMutableTreeNode { /** - * The node is visible flag. + * The node is visible flag. */ public boolean bIsvisible = true; - private static final String SDUMMY = "Dummy"; - - + private static final String SDUMMY = "Dummy"; + + /** - * Creates a tree node that has no parent and no children, but which + * Creates a tree node that has no parent and no children, but which * allows children. */ public HideableMutableTreeNode() { super(); } - + /** - * Creates a tree node with no parent, no children, but which allows + * Creates a tree node with no parent, no children, but which allows * children, and initializes it with the specified user object. - * - * @param userObject - an Object provided by the user that + * + * @param userObject - an Object provided by the user that * constitutes the node's data */ public HideableMutableTreeNode(Object _userObject) { super(_userObject); } - + /** - * Creates a tree node with no parent, no children, initialized with the + * Creates a tree node with no parent, no children, initialized with the * specified user object, and that allows children only if specified. - * + * * @param _userObject - an Object provided by the user that describes the node's data * @param _ballowsChildren - if true, the node is allowed to have childnodes -- otherwise, it is always a leaf node */ public HideableMutableTreeNode(Object _userObject, boolean _ballowsChildren) { super(_userObject, _ballowsChildren); } - + /** - * Checks if the node is visible. - * + * Checks if the node is visible. + * * @return true if the node is visible, else false */ public boolean isVisible() { return this.bIsvisible; } - + /** - * Sets if the node is visible. - * + * Sets if the node is visible. + * * @param returns true if the node is visible, else false */ public void setVisible(boolean _bIsVisible) { - this.bIsvisible = _bIsVisible; + this.bIsvisible = _bIsVisible; } - + public void addDummyNode(){ removeDummyNode(); DefaultMutableTreeNode oDefaultMutableTreeNode = new DefaultMutableTreeNode(SDUMMY); add(oDefaultMutableTreeNode); - + } @@ -84,5 +84,5 @@ public class HideableMutableTreeNode extends DefaultMutableTreeNode { } return breturn; } - + }
\ No newline at end of file diff --git a/odk/examples/java/Inspector/HideableTreeModel.java b/odk/examples/java/Inspector/HideableTreeModel.java index a4a18553ca87..91444d1478a8 100644 --- a/odk/examples/java/Inspector/HideableTreeModel.java +++ b/odk/examples/java/Inspector/HideableTreeModel.java @@ -8,34 +8,34 @@ import java.util.Vector; import javax.swing.*; import javax.swing.event.*; import javax.swing.tree.*; - + public class HideableTreeModel implements TreeModel { private Vector modelListeners = new Vector(); private Object root = null; - - + + public HideableTreeModel(TreeNode _root) { super(); - setRoot(_root); + setRoot(_root); } - - + + public Object getRoot() { return this.root; } - + protected void setRoot(Object r) { this.root = r; } - + public Object[] getPathToRoot(Object node) { return getPathToRoot(node, 0); } - + private Object[] getPathToRoot(Object node, int i) { Object anode[]; @@ -55,22 +55,22 @@ public class HideableTreeModel implements TreeModel { } return anode; } - + public void addTreeModelListener(TreeModelListener l) { modelListeners.addElement(l); } - + public void removeTreeModelListener(TreeModelListener l) { modelListeners.removeElement(l); } - + public void reload() { reload(getRoot()); } - + public void reload(Object node) { if(node != null) { @@ -78,16 +78,16 @@ public class HideableTreeModel implements TreeModel { fireTreeStructureChanged(new TreeModelEvent(this, tp)); } } - + public void valueForPathChanged(TreePath path, Object newValue) { nodeChanged(path.getLastPathComponent()); } - + public void nodeInserted(Object node, Object child) { nodeInserted(node, child, -1); } - + public void nodeInserted(Object node, Object child, int index) { if(index < 0) { @@ -100,7 +100,7 @@ public class HideableTreeModel implements TreeModel { fireTreeNodesInserted(new TreeModelEvent(this, tp, ai, ac)); } } - + public void nodeRemoved(Object node, Object child, int index) { if(node != null && child != null && index >= 0) { @@ -110,7 +110,7 @@ public class HideableTreeModel implements TreeModel { fireTreeNodesRemoved(new TreeModelEvent(this, tp, ai, ac)); } } - + public void nodeChanged(Object node) { if(node != null) { @@ -118,41 +118,41 @@ public class HideableTreeModel implements TreeModel { fireTreeNodesChanged(new TreeModelEvent(this, tp, null, null)); } } - + protected void fireTreeNodesChanged(TreeModelEvent event) { for(int i = 0; i < modelListeners.size(); i++) { ((TreeModelListener)modelListeners.elementAt(i)).treeNodesChanged(event); } } - + protected void fireTreeNodesInserted(TreeModelEvent event) { for(int i = 0; i < modelListeners.size(); i++) { ((TreeModelListener)modelListeners.elementAt(i)).treeNodesInserted(event); } } - + protected void fireTreeNodesRemoved(TreeModelEvent event) { for(int i = 0; i < modelListeners.size(); i++) { ((TreeModelListener)modelListeners.elementAt(i)).treeNodesRemoved(event); } } - + protected void fireTreeStructureChanged(TreeModelEvent event) { for(int i = 0; i < modelListeners.size(); i++) { ((TreeModelListener)modelListeners.elementAt(i)).treeStructureChanged(event); } } - + public ArrayList getExpandedPaths(JTree tree) { ArrayList expandedPaths = new ArrayList(); addExpandedPaths(tree, tree.getPathForRow(0), expandedPaths); return expandedPaths; } - + private void addExpandedPaths(JTree tree, TreePath path, ArrayList pathlist) { Enumeration aEnum = tree.getExpandedDescendants(path); @@ -162,14 +162,14 @@ public class HideableTreeModel implements TreeModel { addExpandedPaths(tree, tp, pathlist); } } - + public void expandPaths(JTree tree, ArrayList pathlist) { for(int i = 0; i < pathlist.size(); i++) { tree.expandPath((TreePath)pathlist.get(i)); } } - + public boolean isLeaf(Object _oNode) { if(_oNode instanceof TreeNode) { @@ -177,16 +177,16 @@ public class HideableTreeModel implements TreeModel { } return true; } - - - + + + public Object getParent(Object node) { if(node != getRoot() && (node instanceof TreeNode)) { return ((TreeNode)node).getParent(); } return null; } - + public boolean isNodeVisible(Object node) { if(node != getRoot()) { @@ -196,7 +196,7 @@ public class HideableTreeModel implements TreeModel { } return true; } - + public boolean setNodeVisible(Object node, boolean v) { // can't hide root @@ -222,7 +222,7 @@ public class HideableTreeModel implements TreeModel { } return false; } - + public boolean isPathToNodeVisible(Object node) { Object[] path = getPathToRoot(node); @@ -233,7 +233,7 @@ public class HideableTreeModel implements TreeModel { } return true; } - + public void ensurePathToNodeVisible(Object node) { Object[] path = getPathToRoot(node); @@ -241,7 +241,7 @@ public class HideableTreeModel implements TreeModel { setNodeVisible(path[i], true); } } - + public Object getChild(Object parent, int index) { if(parent instanceof TreeNode) { @@ -258,7 +258,7 @@ public class HideableTreeModel implements TreeModel { } return null; } - + public int getChildCount(Object parent) { int count = 0; @@ -273,7 +273,7 @@ public class HideableTreeModel implements TreeModel { } return count; } - + public int getIndexOfChild(Object parent, Object child) { int index = -1; diff --git a/odk/examples/java/Inspector/Inspector.java b/odk/examples/java/Inspector/Inspector.java index c8887d4c0344..78f5cc182ee4 100644 --- a/odk/examples/java/Inspector/Inspector.java +++ b/odk/examples/java/Inspector/Inspector.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.awt.Rectangle; @@ -69,19 +69,19 @@ import org.openoffice.XInstanceInspector; public class Inspector{ public static final String sIDLDOCUMENTSUBFOLDER = "docs/common/ref/"; - + /** This class implements the method of the interface XInstanceInspector. * Also the class implements the interfaces XServiceInfo, and XTypeProvider. */ static public class _Inspector extends WeakBase implements XInstanceInspector, XServiceInfo{ - - static private final String __serviceName = "org.openoffice.InstanceInspector"; + + static private final String __serviceName = "org.openoffice.InstanceInspector"; private HashMap aApplicationHashMap = new HashMap(); private String sTitle = "Object Inspector"; private Vector aHiddenDocuments = new Vector(); // private String[] sApplicationDocUrls = new String[]{"private:factory/swriter", "private:factory/scalc", "private:factory/simpress", "private:factory/sdraw", "private:factory/sbase"}; // private String[] sApplicationDocNames = new String[]{"Text Document", "Spreadsheet", "Presentation", "Drawing", "Database"}; - private XComponentContext m_xComponentContext; + private XComponentContext m_xComponentContext; private HashMap aInspectorPanes = new HashMap(); private XDialogProvider m_oSwingDialogProvider; private TDocSupplier oTDocSupplier; @@ -92,39 +92,39 @@ public class Inspector{ public _Inspector(XComponentContext _xComponentContext) { m_xComponentContext = _xComponentContext; m_oIntrospector = Introspector.getIntrospector(m_xComponentContext); - aApplicationHashMap.put("private:factory/swriter", "Text Document"); + aApplicationHashMap.put("private:factory/swriter", "Text Document"); aApplicationHashMap.put("private:factory/scalc", "Spreadsheet"); aApplicationHashMap.put("private:factory/simpress", "Presentation"); aApplicationHashMap.put("private:factory/sdraw", "Drawing"); aApplicationHashMap.put("private:factory/smath", "Formula"); m_oSwingDialogProvider = new SwingDialogProvider(this, sTitle); -// aApplicationHashMap.put("private:factory/sbase", "Database"); +// aApplicationHashMap.put("private:factory/sbase", "Database"); } - - + + public XComponentContext getXComponentContext(){ return m_xComponentContext; } - - + + public HashMap getInspectorPages(){ return aInspectorPanes; } - - + + protected String getSDKPath(){ String sRetPath = ""; try{ XNameAccess xNameAccess = getConfigurationAccess("org.openoffice.inspector.ObjectInspector", true); XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xNameAccess); - sRetPath = (String) xPropertySet.getPropertyValue("SDKPath"); + sRetPath = (String) xPropertySet.getPropertyValue("SDKPath"); }catch( Exception exception ) { exception.printStackTrace(System.out); } return sRetPath; } - - + + public String getIDLPath(){ String sRetPath = getSDKPath(); if (m_oIntrospector.isValidSDKInstallationPath(sRetPath)){ @@ -135,8 +135,8 @@ public class Inspector{ } return sRetPath; } - - + + public void openIdlFileforSelectedNode(){ InspectorPane oInspectorPane = m_oSwingDialogProvider.getSelectedInspectorPage(); if (oInspectorPane != null){ @@ -146,9 +146,9 @@ public class Inspector{ oUnoNode.openIdlDescription(sPath); } } - } - - + } + + public void assignSDKPath() { try { String sInstallationFolder = ""; @@ -169,7 +169,7 @@ public class Inspector{ XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xNameAccess); xPropertySet.setPropertyValue("SDKPath", sInstallationFolder); XChangesBatch xBatch = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class, xNameAccess); - xBatch.commitChanges(); + xBatch.commitChanges(); } else{ XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xFolderPicker); @@ -183,8 +183,8 @@ public class Inspector{ }catch( Exception exception ) { exception.printStackTrace(System.out); }} - - + + public void showErrorMessageBox(XWindowPeer _xWindowPeer, String _sTitle, String _sMessage){ try { Object oToolkit = m_xComponentContext.getServiceManager().createInstanceWithContext("com.sun.star.awt.Toolkit", m_xComponentContext); @@ -199,8 +199,8 @@ public class Inspector{ } catch (com.sun.star.uno.Exception ex) { ex.printStackTrace(System.out); }} - - + + public void inspect(java.lang.Object _oUserDefinedObject, String _sTitle) throws com.sun.star.uno.RuntimeException { try { int nPageIndex = m_oSwingDialogProvider.getInspectorPageCount(); @@ -212,23 +212,23 @@ public class Inspector{ }catch( Exception exception ) { exception.printStackTrace(System.out); }} - - + + public void inspectOpenEmptyDocument(String _sApplicationDocUrl){ XComponent xComponent = getTDocSupplier().openEmptyDocument(_sApplicationDocUrl); String sRootTitle = (String) aApplicationHashMap.get(_sApplicationDocUrl); inspect(xComponent, sRootTitle); aHiddenDocuments.add(xComponent); } - - + + public void inspectOpenDocument(String _sTDocUrl){ String sTreeNodeName = getTDocSupplier().getTitleByTDocUrl(_sTDocUrl); XModel xTDocModel = getTDocSupplier().getXModelByTDocUrl(_sTDocUrl); inspect(xTDocModel, sTreeNodeName); - } - - + } + + public void inspectSelectedNode(){ InspectorPane oInspectorPane = m_oSwingDialogProvider.getSelectedInspectorPage(); if (oInspectorPane != null){ @@ -241,14 +241,14 @@ public class Inspector{ } } - + public void addSourceCodeOfSelectedNode(){ InspectorPane oInspectorPane = m_oSwingDialogProvider.getSelectedInspectorPage(); if (oInspectorPane != null){ oInspectorPane.addSourceCodeOfSelectedNode(); } } - + public void invokeSelectedMethod(){ InspectorPane oInspectorPane = m_oSwingDialogProvider.getSelectedInspectorPage(); @@ -256,8 +256,8 @@ public class Inspector{ oInspectorPane.invokeSelectedMethodNode(); } } - - + + public void setSourceCodeLanguage(final int _nLanguage){ try{ String sLanguage = "Java"; @@ -285,11 +285,11 @@ public class Inspector{ }catch( Exception exception ) { exception.printStackTrace(System.out); }} - - + + private TDocSupplier getTDocSupplier(){ if (oTDocSupplier == null){ - oTDocSupplier = new TDocSupplier(m_xComponentContext); + oTDocSupplier = new TDocSupplier(m_xComponentContext); } return oTDocSupplier; } @@ -297,13 +297,13 @@ public class Inspector{ public String[] getTDocUrls(){ return getTDocSupplier().getTDocUrls(); } - - + + public String[] getTDocTitles(String[] _sTDocUrls){ return getTDocSupplier().getTDocTitles(_sTDocUrls); } - - + + public String[][] getApplicationUrls(){ Set aSet = aApplicationHashMap.keySet(); String[][] sReturnList = new String[aSet.size()][]; @@ -318,7 +318,7 @@ public class Inspector{ return sReturnList; } - + public void disposeHiddenDocuments(){ int nHiddenCount = aHiddenDocuments.size(); if (nHiddenCount > 0){ @@ -336,13 +336,13 @@ public class Inspector{ } } } - - + + public static String[] getServiceNames() { String[] sSupportedServiceNames = { __serviceName }; return sSupportedServiceNames; } - + // Implement the interface XServiceInfo /** Get all supported service names. * @return Supported service names. @@ -350,7 +350,7 @@ public class Inspector{ public String[] getSupportedServiceNames() { return getServiceNames(); } - + // Implement the interface XServiceInfo /** Test, if the given service will be supported. * @param sService Service name. @@ -359,7 +359,7 @@ public class Inspector{ public boolean supportsService( String sServiceName ) { return sServiceName.equals( __serviceName ); } - + // Implement the interface XServiceInfo /** Get the implementation name of the component. * @return Implementation name of the component. @@ -367,7 +367,7 @@ public class Inspector{ public String getImplementationName() { return _Inspector.class.getName(); } - + private int getSourceCodeLanguage(){ int nLanguage = XLanguageSourceCodeGenerator.nJAVA; @@ -378,10 +378,10 @@ public class Inspector{ nLanguage = XLanguageSourceCodeGenerator.nJAVA; } else if (sLanguage.toUpperCase().equals("BASIC")){ - nLanguage = XLanguageSourceCodeGenerator.nBASIC; + nLanguage = XLanguageSourceCodeGenerator.nBASIC; } else if (sLanguage.toUpperCase().equals("CPLUSPLUS")){ - nLanguage = XLanguageSourceCodeGenerator.nCPLUSPLUS; + nLanguage = XLanguageSourceCodeGenerator.nCPLUSPLUS; } else{ System.out.println("Warning: Sourcecode language " + sLanguage + " is not defined!"); @@ -391,9 +391,9 @@ public class Inspector{ exception.printStackTrace(System.out); } return nLanguage; - } - - + } + + public XNameAccess getConfigurationAccess(boolean _bUpdate){ return getConfigurationAccess("org.openoffice.inspector.ObjectInspector", _bUpdate); } @@ -411,20 +411,20 @@ public class Inspector{ } XMultiComponentFactory xMCF = m_xComponentContext.getServiceManager(); Object oDefaultProvider = xMCF.createInstanceWithContext("com.sun.star.configuration.DefaultProvider", this.getXComponentContext()); - XMultiServiceFactory xMSFCfg = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDefaultProvider); + XMultiServiceFactory xMSFCfg = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDefaultProvider); Object oAccess = xMSFCfg.createInstanceWithArguments(sAccess, new Object[]{new NamedValue("nodepath", _sNodePath)}); xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oAccess); - } catch (com.sun.star.uno.Exception e) { + } catch (com.sun.star.uno.Exception e) { } return xNameAccess; } - - + + } - + // end of inner class - - + + /** * Gives a factory for creating the service. * This method is called by the <code>JavaLoader</code> @@ -454,8 +454,8 @@ public class Inspector{ * @see com.sun.star.comp.loader.JavaLoader */ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { - return (Factory.writeRegistryServiceInfo(_Inspector.class.getName(), _Inspector.getServiceNames(), regKey) + return (Factory.writeRegistryServiceInfo(_Inspector.class.getName(), _Inspector.getServiceNames(), regKey) && InspectorAddon.__writeRegistryServiceInfo(regKey)); } } - + diff --git a/odk/examples/java/Inspector/InspectorAddon.java b/odk/examples/java/Inspector/InspectorAddon.java index be35f8a1988e..92c8ab5c43fa 100644 --- a/odk/examples/java/Inspector/InspectorAddon.java +++ b/odk/examples/java/Inspector/InspectorAddon.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.beans.XPropertySet; import com.sun.star.frame.DispatchDescriptor; @@ -66,12 +66,12 @@ public class InspectorAddon { "com.sun.star.frame.ProtocolHandler" }; ; private XComponentContext m_xContext = null; - + /** Creates a new instance of InspectorAddon */ public InspectorAddonImpl(XComponentContext _xContext) { m_xContext = _xContext; } - + public XDispatch queryDispatch( /*IN*/com.sun.star.util.URL aURL, /*IN*/String sTargetFrameName, /*IN*/int iSearchFlags ) { XDispatch xRet = null; if ( aURL.Protocol.compareTo("org.openoffice.Office.addon.Inspector:") == 0 ) { @@ -86,37 +86,37 @@ public class InspectorAddon { public XDispatch[] queryDispatches( /*IN*/DispatchDescriptor[] seqDescripts ) { int nCount = seqDescripts.length; - XDispatch[] lDispatcher = new XDispatch[nCount]; + XDispatch[] lDispatcher = new XDispatch[nCount]; for( int i=0; i<nCount; ++i ) lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL, seqDescripts[i].FrameName, seqDescripts[i].SearchFlags ); - return lDispatcher; + return lDispatcher; } public void initialize( Object[] object ) throws com.sun.star.uno.Exception { if ( object.length > 0 ){ m_xFrame = ( XFrame ) UnoRuntime.queryInterface(XFrame.class, object[ 0 ] ); - } + } } - + public class Dispatcher implements XDispatch{ private XFrame m_xFrame = null; private XModel xModel = null; - + public Dispatcher(XFrame _xFrame){ m_xFrame = _xFrame; if (m_xFrame != null){ XController xController = m_xFrame.getController(); if (xController != null){ xModel = xController.getModel(); - } + } } } // XDispatch public void dispatch( /*IN*/com.sun.star.util.URL _aURL, /*IN*/com.sun.star.beans.PropertyValue[] aArguments ) { try{ - if ( _aURL.Protocol.compareTo("org.openoffice.Office.addon.Inspector:") == 0 ){ + if ( _aURL.Protocol.compareTo("org.openoffice.Office.addon.Inspector:") == 0 ){ if ( _aURL.Path.equals("inspect")){ Object oUnoInspectObject = xModel; com.sun.star.lang.XMultiComponentFactory xMCF = m_xContext.getServiceManager(); @@ -130,7 +130,7 @@ public class InspectorAddon { oUnoInspectObject = m_xFrame; } XPropertySet xFramePropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_xFrame); - String sTitle = (String) xFramePropertySet.getPropertyValue("Title"); + String sTitle = (String) xFramePropertySet.getPropertyValue("Title"); String[] sTitleList = sTitle.split(" - "); if (sTitleList.length > 0){ sTitle = sTitleList[0]; @@ -148,15 +148,15 @@ public class InspectorAddon { public void removeStatusListener( /*IN*/XStatusListener xControl, /*IN*/com.sun.star.util.URL aURL ) { } - - + + } - - + + public static String[] getServiceNames() { return m_serviceNames; } - + // Implement the interface XServiceInfo /** Get all supported service names. * @return Supported service names. @@ -164,7 +164,7 @@ public class InspectorAddon { public String[] getSupportedServiceNames() { return getServiceNames(); } - + // Implement the interface XServiceInfo /** Test, if the given service will be supported. * @param sService Service name. @@ -172,15 +172,15 @@ public class InspectorAddon { */ public boolean supportsService( String sServiceName ) { int len = m_serviceNames.length; - + for( int i=0; i < len; i++) { if ( sServiceName.equals( m_serviceNames[i] ) ) return true; } - + return false; } - + // Implement the interface XServiceInfo /** Get the implementation name of the component. * @return Implementation name of the component. @@ -188,10 +188,10 @@ public class InspectorAddon { public String getImplementationName() { return InspectorAddonImpl.class.getName(); } - - } - - + + } + + /** * Gives a factory for creating the service. * This method is called by the <code>JavaLoader</code> @@ -221,8 +221,8 @@ public class InspectorAddon { public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { return Factory.writeRegistryServiceInfo(InspectorAddonImpl.class.getName(), InspectorAddonImpl.getServiceNames(), regKey); } - + // __create( XComponentContext ){ // -// } +// } } diff --git a/odk/examples/java/Inspector/InspectorPane.java b/odk/examples/java/Inspector/InspectorPane.java index 4748c1a62f77..14d144781943 100644 --- a/odk/examples/java/Inspector/InspectorPane.java +++ b/odk/examples/java/Inspector/InspectorPane.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ @@ -62,7 +62,7 @@ import javax.swing.event.TreeWillExpandListener; private XTreeControlProvider m_xTreeControlProvider; private String sTitle = ""; - + /** The constructor of the inner class has a XMultiServiceFactory parameter. * @param xMultiServiceFactory XMultiServiceFactory */ @@ -74,15 +74,15 @@ import javax.swing.event.TreeWillExpandListener; m_oSourceCodeGenerator = new SourceCodeGenerator(_nLanguage); _xTreeControlProvider.addInspectorPane(this); } - + private void setMaximumOfProgressBar(Object _oUnoObject){ int nMaxValue = 0; xIdlMethods = m_oIntrospector.getMethods(_oUnoObject); - aProperties = m_oIntrospector.getProperties(_oUnoObject); + aProperties = m_oIntrospector.getProperties(_oUnoObject); } - - + + /** Inspect the given object for methods, properties, interfaces, and * services. * @param a The object to inspect @@ -96,8 +96,8 @@ import javax.swing.event.TreeWillExpandListener; catch( Exception exception ) { exception.printStackTrace(System.out); }} - - + + public void setTitle(String _sTitle){ if (_sTitle != null){ if (_sTitle.length() > 0){ @@ -106,13 +106,13 @@ import javax.swing.event.TreeWillExpandListener; } } - + public String getTitle(){ return sTitle; } - - - + + + private Type[] getTypes(Object _oUnoObject){ Type[] aTypes = null; if (m_oIntrospector.isArray(_oUnoObject)){ @@ -123,8 +123,8 @@ import javax.swing.event.TreeWillExpandListener; } return aTypes; } - - + + private Object invoke(XUnoMethodNode _oUnoMethodNode){ try{ String sParamValueDescription = ""; @@ -140,23 +140,23 @@ import javax.swing.event.TreeWillExpandListener; if (_oUnoMethodNode.getXIdlMethod().getReturnType().getTypeClass().getValue() == TypeClass.VOID_value){ sNodeDescription += _oUnoMethodNode.getXIdlMethod().getReturnType().getName() + " " + _oUnoMethodNode.getXIdlMethod().getName() + sParamValueDescription; _oUnoMethodNode.setLabel(sNodeDescription); - m_xTreeControlProvider.nodeChanged(_oUnoMethodNode); + m_xTreeControlProvider.nodeChanged(_oUnoMethodNode); } else if (bHasParameters || !bIsPrimitive){ if (bIsPrimitive){ sNodeDescription += m_oSourceCodeGenerator.getStringValueOfObject(oUnoReturnObject, _oUnoMethodNode.getTypeClass()); } - else{ + else{ Any aReturnObject = Any.complete(oUnoReturnObject); String sShortClassName = m_oIntrospector.getShortClassName(aReturnObject.getType().getTypeName()); - sNodeDescription += m_oSourceCodeGenerator.getVariableNameforUnoObject(sShortClassName); + sNodeDescription += m_oSourceCodeGenerator.getVariableNameforUnoObject(sShortClassName); } if (m_oIntrospector.isArray(oUnoReturnObject)){ if (m_oIntrospector.isUnoTypeObject(oUnoReturnObject)){ oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SINTERFACEDESCRIPTION, _oUnoMethodNode.getUnoObject()); } else if(m_oIntrospector.isUnoPropertyTypeObject(oUnoReturnObject)){ - oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SPROPERTYINFODESCRIPTION, oUnoReturnObject); + oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SPROPERTYINFODESCRIPTION, oUnoReturnObject); } else if(m_oIntrospector.isUnoPropertyValueTypeObject(oUnoReturnObject)){ oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SPROPERTYVALUEDESCRIPTION, oUnoReturnObject); @@ -182,7 +182,7 @@ import javax.swing.event.TreeWillExpandListener; if (bIsPrimitive){ sNodeDescription = _oUnoMethodNode.getStandardMethodDescription() + "=" + UnoMethodNode.getDisplayValueOfPrimitiveType(oUnoReturnObject); _oUnoMethodNode.setLabel(sNodeDescription); - m_xTreeControlProvider.nodeChanged(_oUnoMethodNode); + m_xTreeControlProvider.nodeChanged(_oUnoMethodNode); } } } @@ -192,7 +192,7 @@ import javax.swing.event.TreeWillExpandListener; _oUnoMethodNode.setLabel(_oUnoMethodNode.getLabel() + " = null"); } else{ - _oUnoMethodNode.setLabel(_oUnoMethodNode.getXIdlMethod().getName() + sParamValueDescription + " = null"); + _oUnoMethodNode.setLabel(_oUnoMethodNode.getXIdlMethod().getName() + sParamValueDescription + " = null"); } m_xTreeControlProvider.nodeChanged(_oUnoMethodNode); } @@ -200,8 +200,8 @@ import javax.swing.event.TreeWillExpandListener; }catch(Exception exception ) { return null; }} - - + + public void invokeSelectedMethodNode(){ XTreePathProvider xTreePathProvider = m_xTreeControlProvider.getSelectedPath(); XUnoNode oUnoNode = xTreePathProvider.getLastPathComponent(); @@ -211,7 +211,7 @@ import javax.swing.event.TreeWillExpandListener; } } - + public void addSourceCodeOfSelectedNode(){ XTreePathProvider oTreePathProvider = m_xTreeControlProvider.getSelectedPath(); XUnoNode oUnoNode = oTreePathProvider.getLastPathComponent(); @@ -225,29 +225,29 @@ import javax.swing.event.TreeWillExpandListener; m_xTreeControlProvider.setSourceCode(sSourceCode); } - + public void convertCompleteSourceCode(int _nLanguage){ String sSourceCode = m_oSourceCodeGenerator.convertAllUnoObjects(_nLanguage); - m_xTreeControlProvider.setSourceCode(sSourceCode); + m_xTreeControlProvider.setSourceCode(sSourceCode); } - - protected XUnoNode getSelectedNode(){ + + protected XUnoNode getSelectedNode(){ return m_xTreeControlProvider.getSelectedNode(); } - - + + // add the object to the hashtable for a possible access in the tree private XUnoFacetteNode addUnoFacetteNode(XUnoNode _oParentNode, String _sNodeDescription, Object _oUnoObject){ return m_xTreeControlProvider.addUnoFacetteNode( _oParentNode, _sNodeDescription, _oUnoObject); } - - + + private XUnoMethodNode addMethodNode(Object _objectElement, XIdlMethod _xIdlMethod){ return m_xTreeControlProvider.addMethodNode(_objectElement, _xIdlMethod); } - - - + + + public void addMethodsToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoParentObject, XIdlMethod[] _xIdlMethods){ if (this.m_oIntrospector.isValid(_xIdlMethods)){ for ( int n = 0; n < _xIdlMethods.length; n++ ) { @@ -258,11 +258,11 @@ import javax.swing.event.TreeWillExpandListener; _oGrandParentNode.addChildNode(oChildNode); } } - } + } } } - - + + private void addFacetteNodesToTreeNode(XUnoNode _oParentNode, Object _oUnoObject){ if (m_oIntrospector.hasMethods(_oUnoObject)){ XUnoFacetteNode oUnoFacetteNode = addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SMETHODDESCRIPTION, _oUnoObject); @@ -281,7 +281,7 @@ import javax.swing.event.TreeWillExpandListener; } } - + private void addInterfacesToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoParentObject, Type[] _aTypes) { try { if (_oUnoParentObject != null){ @@ -293,14 +293,14 @@ import javax.swing.event.TreeWillExpandListener; catch( Exception exception ) { exception.printStackTrace(System.out); }} - - + + // add all services for the given object to the tree under the node parent private void addServicesToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoObject) { try{ - XServiceInfo xServiceInfo = ( XServiceInfo ) UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject ); + XServiceInfo xServiceInfo = ( XServiceInfo ) UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject ); if ( xServiceInfo != null ){ - String[] sSupportedServiceNames = xServiceInfo.getSupportedServiceNames(); + String[] sSupportedServiceNames = xServiceInfo.getSupportedServiceNames(); for ( int m = 0; m < sSupportedServiceNames.length; m++ ) { String sServiceName = sSupportedServiceNames[m]; if (sServiceName.length() > 0){ @@ -313,16 +313,16 @@ import javax.swing.event.TreeWillExpandListener; catch(Exception exception) { exception.printStackTrace(System.out); }} - - + + private void addPropertiesAndInterfacesOfService(XUnoNode _oUnoServiceNode){ String sServiceName = _oUnoServiceNode.getClassName(); Object oUnoObject = _oUnoServiceNode.getUnoObject(); addInterfacesToTreeNode(_oUnoServiceNode, oUnoObject, m_oIntrospector.getInterfaces(oUnoObject, sServiceName)); - addPropertiesToTreeNode(_oUnoServiceNode, oUnoObject, m_oIntrospector.getProperties(oUnoObject, sServiceName)); + addPropertiesToTreeNode(_oUnoServiceNode, oUnoObject, m_oIntrospector.getProperties(oUnoObject, sServiceName)); } - + private void addPropertiesToTreeNode(XUnoNode _oParentNode, Object _oUnoParentObject, Property[] _aProperties) { try { if (_aProperties.length > 0){ @@ -339,7 +339,7 @@ import javax.swing.event.TreeWillExpandListener; _oParentNode.addChildNode(oChildNode); } } - } + } } } } @@ -347,8 +347,8 @@ import javax.swing.event.TreeWillExpandListener; catch(Exception exception) { exception.printStackTrace(System.out); }} - - + + public void addContainerElementsToTreeNode(XUnoNode _oParentNode, Object _oUnoParentObject){ Object[] oUnoContainerElements = m_oIntrospector.getUnoObjectsOfContainer(_oUnoParentObject); if (m_oIntrospector.isValid(oUnoContainerElements)){ @@ -361,37 +361,37 @@ import javax.swing.event.TreeWillExpandListener; } } - + private XUnoNode addUnoNode(XUnoNode _oParentNode, Object _oUnoObject, String _sLabel ){ XUnoNode oUnoNode = this.m_xTreeControlProvider.addUnoNode(_oUnoObject); oUnoNode.setLabel(_sLabel); - if (_oParentNode != null){ - _oParentNode.addChildNode(oUnoNode); + if (_oParentNode != null){ + _oParentNode.addChildNode(oUnoNode); } setNodeFoldable(oUnoNode, _oUnoObject); return oUnoNode; } - - + + private void setNodeFoldable(XUnoNode _oUnoNode, Object _oUnoObject){ if (_oUnoObject != null){ if (!m_oIntrospector.isObjectPrimitive(_oUnoObject)){ _oUnoNode.setFoldable(true); } - } + } } - - + + private XUnoNode addUnoNode(XUnoNode _oParentNode, Object _oUnoObject, Type _aType){ XUnoNode oUnoNode = this.m_xTreeControlProvider.addUnoNode(_oUnoObject, _aType); - if (_oParentNode != null){ - _oParentNode.addChildNode(oUnoNode); + if (_oParentNode != null){ + _oParentNode.addChildNode(oUnoNode); } setNodeFoldable(oUnoNode, _oUnoObject); return oUnoNode; } - - + + private void addPropertySetInfoNodesToTreeNode(XUnoFacetteNode _oUnoFacetteNode, Object _oUnoObject){ if (_oUnoObject.getClass().isArray()){ Object[] object = ( Object[] ) _oUnoObject; @@ -412,19 +412,19 @@ import javax.swing.event.TreeWillExpandListener; for ( int i = 0; i < object.length; i++ ) { if (m_oIntrospector.isObjectPrimitive(object[i])){ XUnoNode oChildNode = addUnoNode(_oUnoNode, null, UnoNode.getNodeDescription(object[i])); - } + } } } else{ String[] sDisplayValues = UnoNode.getDisplayValuesofPrimitiveArray(_oUnoObject); for ( int i = 0; i < sDisplayValues.length; i++ ) { XUnoNode oUnoNode = addUnoNode(_oUnoNode, null, sDisplayValues[i]); - } + } } } } - - + + private void addPropertySetInfoSubNodes(XUnoPropertyNode _oUnoPropertyNode){ Property aProperty = _oUnoPropertyNode.getProperty(); _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithName(aProperty)); @@ -432,8 +432,8 @@ import javax.swing.event.TreeWillExpandListener; _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithHandle(aProperty)); _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithAttributesDescription(aProperty)); } - - + + private void addPropertyValueSubNodes(XUnoFacetteNode _oUnoFacetteNode, Object _oUnoObject){ if (m_oIntrospector.isUnoPropertyValueTypeObject(_oUnoObject)){ Object[] object = ( Object[] ) _oUnoObject; @@ -455,8 +455,8 @@ import javax.swing.event.TreeWillExpandListener; } } } - - + + public boolean expandNode(XUnoNode _oUnoNode, XTreePathProvider _xTreePathProvider){ if ( _oUnoNode != null ) { _oUnoNode.setFoldable(false); @@ -489,7 +489,7 @@ import javax.swing.event.TreeWillExpandListener; } else if (m_xTreeControlProvider.isFacetteNode(_oUnoNode)){ XUnoFacetteNode oUnoFacetteNode = (XUnoFacetteNode) _oUnoNode; - Object oUnoObject = _oUnoNode.getUnoObject(); + Object oUnoObject = _oUnoNode.getUnoObject(); if (oUnoFacetteNode.isMethodNode()){ addMethodsToTreeNode(oUnoFacetteNode, oUnoObject, m_oIntrospector.getMethods(oUnoObject)); } @@ -512,7 +512,7 @@ import javax.swing.event.TreeWillExpandListener; if (oUnoFacetteNode.isInterfaceNode()){ addInterfacesToTreeNode(oUnoFacetteNode, oUnoObject, getTypes(oUnoObject)); } - if (oUnoFacetteNode.isContainerNode()){ + if (oUnoFacetteNode.isContainerNode()){ addContainerElementsToTreeNode(oUnoFacetteNode, oUnoObject); } } @@ -534,13 +534,13 @@ import javax.swing.event.TreeWillExpandListener; else{ addFacetteNodesToTreeNode(_oUnoNode, oUnoObject); } - } + } } return true; } - - - + + + public void applyFilter(XUnoFacetteNode _oUnoFacetteNode, String _sFilter){ for (int i = 0; i < _oUnoFacetteNode.getChildCount(); i++){ XUnoNode oUnoNode = _oUnoFacetteNode.getChild(i); @@ -549,8 +549,8 @@ import javax.swing.event.TreeWillExpandListener; } _oUnoFacetteNode.setFilter(_sFilter); } - - + + /** In opposition to 'getUnoObjectOfTreeNode' this method inspects the passed node if it represents a Uno object * If not it returns null * @@ -563,7 +563,7 @@ import javax.swing.event.TreeWillExpandListener; return null; } - + public String getFilter(XUnoNode _oUnoNode){ String sFilter = ""; if (_oUnoNode != null){ @@ -586,8 +586,8 @@ import javax.swing.event.TreeWillExpandListener; } return sFilter; } - - + + /** In opposition to 'getUnoObjectOfexplictTreeNode' this method inspects the passed node if it represents a Uno object * if not it keeps checking all ancestors until it finds a Uno representation */ @@ -608,11 +608,11 @@ import javax.swing.event.TreeWillExpandListener; } xTreePathProvider = xTreePathProvider.getParentPath(); } - return null; - } - - - public void showPopUpMenu(Object _invoker, int x, int y) throws ClassCastException{ + return null; + } + + + public void showPopUpMenu(Object _invoker, int x, int y) throws ClassCastException{ XUnoNode oUnoNode = getSelectedNode(); boolean bdoEnableInvoke = oUnoNode instanceof XUnoMethodNode; // boolean bdoEnableSourceCodeGeneration = true; diff --git a/odk/examples/java/Inspector/InstanceInspector.idl b/odk/examples/java/Inspector/InstanceInspector.idl index 79e43cb181e4..8de7e920acd8 100644 --- a/odk/examples/java/Inspector/InstanceInspector.idl +++ b/odk/examples/java/Inspector/InstanceInspector.idl @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,16 +29,16 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ #ifndef INCLUDED_ORG_OPENOFFICE_INSTANCEINSPECTOR_IDL #define INCLUDED_ORG_OPENOFFICE_INSTANCEINSPECTOR_IDL -#include <XInstanceInspector.idl> - - -module org { module openoffice { +#include <XInstanceInspector.idl> + + +module org { module openoffice { /** * This service describes an instance inspector which can inspect @@ -46,7 +46,7 @@ module org { module openoffice { * interfaces, the supported services and properties of this onject. */ service InstanceInspector: XInstanceInspector; - + }; }; #endif diff --git a/odk/examples/java/Inspector/Introspector.java b/odk/examples/java/Inspector/Introspector.java index f4078931e1ed..cdae4f4d88b2 100644 --- a/odk/examples/java/Inspector/Introspector.java +++ b/odk/examples/java/Inspector/Introspector.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.beans.IllegalTypeException; @@ -81,18 +81,18 @@ import java.util.Vector; import javax.swing.JOptionPane; public class Introspector extends WeakBase{ - + private XIntrospection m_xIntrospection; private XMultiComponentFactory m_xMultiComponentFactory; private XComponentContext m_xComponentContext; - private XTypeDescriptionEnumerationAccess m_xTDEnumerationAccess; + private XTypeDescriptionEnumerationAccess m_xTDEnumerationAccess; private static XComponentContext xOfficeComponentContext; private XIdlReflection mxIdlReflection; private URL openHyperlink; private static Introspector m_oIntrospector = null; private XSimpleFileAccess xSimpleFileAccess = null; - + public static Introspector getIntrospector(){ if (m_oIntrospector == null){ @@ -102,22 +102,22 @@ public class Introspector extends WeakBase{ return m_oIntrospector; } } - + public static Introspector getIntrospector(XComponentContext _xComponentContext){ if (m_oIntrospector == null){ m_oIntrospector = new Introspector(_xComponentContext); } return m_oIntrospector; } - - + + /** Creates a new instance of Introspection */ private Introspector(XComponentContext _xComponentContext) { try{ m_xComponentContext = _xComponentContext; m_xMultiComponentFactory = m_xComponentContext.getServiceManager(); Object o = m_xMultiComponentFactory.createInstanceWithContext("com.sun.star.beans.Introspection", m_xComponentContext); - m_xIntrospection = ( XIntrospection ) UnoRuntime.queryInterface(XIntrospection.class, o ); + m_xIntrospection = ( XIntrospection ) UnoRuntime.queryInterface(XIntrospection.class, o ); Object oCoreReflection = getXMultiComponentFactory().createInstanceWithContext("com.sun.star.reflection.CoreReflection", getXComponentContext()); mxIdlReflection = (XIdlReflection) UnoRuntime.queryInterface(XIdlReflection.class, oCoreReflection); initTypeDescriptionManager(); @@ -125,23 +125,23 @@ public class Introspector extends WeakBase{ catch( Exception exception ) { System.err.println( exception ); }} - - + + protected XComponentContext getXComponentContext(){ return m_xComponentContext; } - - + + protected XMultiComponentFactory getXMultiComponentFactory(){ return m_xMultiComponentFactory; } - - + + protected XIntrospectionAccess getXIntrospectionAccess(Object _oUnoComponent){ return m_xIntrospection.inspect(_oUnoComponent); } - - + + public boolean isContainer(Object _oUnoObject){ boolean bIsContainer = false; try { @@ -164,8 +164,8 @@ public class Introspector extends WeakBase{ } return bIsContainer; } - - + + // add all containers for the given object to the tree under the node // parent public Object[] getUnoObjectsOfContainer(Object _oUnoParentObject) { @@ -201,36 +201,36 @@ public class Introspector extends WeakBase{ } return oRetComponents; } - + protected XIdlMethod[] getMethodsOfInterface(Type _aType){ try{ - XIdlClass xIdlClass = mxIdlReflection.forName(_aType.getTypeName()); + XIdlClass xIdlClass = mxIdlReflection.forName(_aType.getTypeName()); return xIdlClass.getMethods(); } catch( Exception e ) { System.err.println( e ); return null; - }} + }} protected XIdlField[] getFieldsOfType(Type _aType){ try{ - XIdlClass xIdlClass = mxIdlReflection.forName(_aType.getTypeName()); + XIdlClass xIdlClass = mxIdlReflection.forName(_aType.getTypeName()); return xIdlClass.getFields(); } catch( Exception e ) { System.err.println( e ); return null; - }} - + }} + public boolean hasMethods(Object _oUnoObject){ boolean bHasMethods = (getMethods(_oUnoObject).length > 0); return bHasMethods; } - - + + // add all methods for the given object to the tree under the node parent public XIdlMethod[] getMethods(Object _oUnoParentObject) { try { @@ -246,18 +246,18 @@ public class Introspector extends WeakBase{ return null; } - + public boolean hasProperties(Object _oUnoObject){ boolean bHasProperties = (getProperties(_oUnoObject).length > 0); return bHasProperties; } - - + + protected Property[] getProperties( Object _oUnoParentObject){ try { XIntrospectionAccess xIntrospectionAccess = getXIntrospectionAccess(_oUnoParentObject); if (xIntrospectionAccess != null){ - Property[] aProperties = xIntrospectionAccess.getProperties(com.sun.star.beans.PropertyConcept.ATTRIBUTES + com.sun.star.beans.PropertyConcept.PROPERTYSET); + Property[] aProperties = xIntrospectionAccess.getProperties(com.sun.star.beans.PropertyConcept.ATTRIBUTES + com.sun.star.beans.PropertyConcept.PROPERTYSET); return aProperties; } } @@ -266,8 +266,8 @@ public class Introspector extends WeakBase{ } return null; } - - + + protected Property[] getProperties(Object _oUnoObject, String _sServiceName){ Property[] aProperties = getProperties(_oUnoObject); List aListOfProperties = java.util.Arrays.asList(aProperties); @@ -284,7 +284,7 @@ public class Introspector extends WeakBase{ aPropertiesVector.toArray(aRetProperties); return aRetProperties; } - + protected Type[] getInterfaces(Object _oUnoObject, String _sServiceName){ Type[] aTypes = getInterfaces(_oUnoObject); @@ -303,12 +303,12 @@ public class Introspector extends WeakBase{ return aRetTypes; } - + public boolean hasInterfaces(Object _oUnoObject){ return (getInterfaces(_oUnoObject).length > 0); } - + protected Type[] getInterfaces(Object _oUnoParentObject){ Type[] aTypes = new Type[]{}; XTypeProvider xTypeProvider = ( XTypeProvider ) UnoRuntime.queryInterface( XTypeProvider.class, _oUnoParentObject); @@ -317,25 +317,25 @@ public class Introspector extends WeakBase{ } return aTypes; } - - - + + + public static boolean isObjectSequence(Object _oUnoObject){ Type aType = AnyConverter.getType(_oUnoObject); return aType.getTypeClass().getValue() == TypeClass.SEQUENCE_value; } - - + + public static boolean isObjectPrimitive(Object _oUnoObject){ boolean breturn = false; if (_oUnoObject != null){ Type aType = AnyConverter.getType(_oUnoObject); - breturn = isObjectPrimitive(_oUnoObject.getClass(), aType.getTypeClass()); + breturn = isObjectPrimitive(_oUnoObject.getClass(), aType.getTypeClass()); } return breturn; } - - + + public static boolean isPrimitive(TypeClass _typeClass){ return (( _typeClass == TypeClass.BOOLEAN ) || ( _typeClass == TypeClass.BYTE ) @@ -351,7 +351,7 @@ public class Introspector extends WeakBase{ || ( _typeClass == TypeClass.UNSIGNED_LONG ) || ( _typeClass == TypeClass.UNSIGNED_SHORT )); } - + public static boolean isObjectPrimitive(Class _oUnoClass, TypeClass _typeClass){ return !( ( !_oUnoClass.isPrimitive() ) && ( _typeClass != TypeClass.ARRAY ) && ( _typeClass != TypeClass.BOOLEAN ) @@ -367,9 +367,9 @@ public class Introspector extends WeakBase{ && ( _typeClass != TypeClass.UNSIGNED_HYPER ) && ( _typeClass != TypeClass.UNSIGNED_LONG ) && ( _typeClass != TypeClass.UNSIGNED_SHORT )); - } - - + } + + protected void initTypeDescriptionManager() { try { Object oTypeDescriptionManager = getXComponentContext().getValueByName("/singletons/com.sun.star.reflection.theTypeDescriptionManager"); @@ -382,14 +382,14 @@ public class Introspector extends WeakBase{ protected XTypeDescriptionEnumerationAccess getXTypeDescriptionEnumerationAccess(){ return m_xTDEnumerationAccess; } - - + + protected XConstantTypeDescription[] getFieldsOfConstantGroup(String _sTypeClass){ XConstantTypeDescription[] xConstantTypeDescriptions = null; try { TypeClass[] eTypeClasses = new com.sun.star.uno.TypeClass[1]; eTypeClasses[0] = com.sun.star.uno.TypeClass.CONSTANTS; - XTypeDescriptionEnumeration xTDEnumeration = m_xTDEnumerationAccess.createTypeDescriptionEnumeration(getModuleName(_sTypeClass), eTypeClasses, TypeDescriptionSearchDepth.INFINITE); + XTypeDescriptionEnumeration xTDEnumeration = m_xTDEnumerationAccess.createTypeDescriptionEnumeration(getModuleName(_sTypeClass), eTypeClasses, TypeDescriptionSearchDepth.INFINITE); while (xTDEnumeration.hasMoreElements()) { XTypeDescription xTD = xTDEnumeration.nextTypeDescription(); if (xTD.getName().equals(_sTypeClass)){ @@ -397,21 +397,21 @@ public class Introspector extends WeakBase{ xConstantTypeDescriptions = xConstantsTypeDescription.getConstants(); } String sName = xTD.getName(); - } + } return xConstantTypeDescriptions; } catch ( java.lang.Exception e) { System.out.println(System.out); } return null; } - + private XServiceTypeDescription getServiceTypeDescription(String _sServiceName, TypeClass _eTypeClass){ try{ if (_sServiceName.length() > 0){ TypeClass[] eTypeClasses = new com.sun.star.uno.TypeClass[2]; eTypeClasses[0] = com.sun.star.uno.TypeClass.SERVICE; eTypeClasses[1] = _eTypeClass; - XTypeDescriptionEnumeration xTDEnumeration = getXTypeDescriptionEnumerationAccess().createTypeDescriptionEnumeration(Introspector.getModuleName(_sServiceName), eTypeClasses, TypeDescriptionSearchDepth.INFINITE); + XTypeDescriptionEnumeration xTDEnumeration = getXTypeDescriptionEnumerationAccess().createTypeDescriptionEnumeration(Introspector.getModuleName(_sServiceName), eTypeClasses, TypeDescriptionSearchDepth.INFINITE); while (xTDEnumeration.hasMoreElements()) { XTypeDescription xTD = xTDEnumeration.nextTypeDescription(); if (xTD.getName().equals(_sServiceName)){ @@ -425,8 +425,8 @@ public class Introspector extends WeakBase{ ex.printStackTrace(System.out); return null; }} - - + + public XPropertyTypeDescription[] getPropertyDescriptionsOfService(String _sServiceName){ try { XServiceTypeDescription xServiceTypeDescription = getServiceTypeDescription(_sServiceName, com.sun.star.uno.TypeClass.PROPERTY); @@ -439,8 +439,8 @@ public class Introspector extends WeakBase{ } return new XPropertyTypeDescription[]{}; } - - + + public XTypeDescription getReferencedType(String _sTypeName){ XTypeDescription xTypeDescription = null; try{ @@ -458,8 +458,8 @@ public class Introspector extends WeakBase{ } return xTypeDescription; } - - + + public XInterfaceTypeDescription[] getInterfaceDescriptionsOfService(String _sServiceName){ try { XServiceTypeDescription xServiceTypeDescription = getServiceTypeDescription(_sServiceName, com.sun.star.uno.TypeClass.INTERFACE); @@ -473,7 +473,7 @@ public class Introspector extends WeakBase{ return new XInterfaceTypeDescription[]{}; } - + static boolean hasByName(XTypeDescription[] _xTypeDescriptions, String _sTypeName){ for (int i = 0; i < _xTypeDescriptions.length; i++){ if (_xTypeDescriptions[i].getName().equals(_sTypeName)){ @@ -482,8 +482,8 @@ public class Introspector extends WeakBase{ } return false; } - - + + public static String getModuleName(String _sTypeClass){ int nlastindex = _sTypeClass.lastIndexOf("."); if (nlastindex > -1){ @@ -492,9 +492,9 @@ public class Introspector extends WeakBase{ else{ return ""; } - } - + } + public static String getShortClassName(String _sClassName){ String sShortClassName = _sClassName; int nindex = _sClassName.lastIndexOf("."); @@ -502,25 +502,25 @@ public class Introspector extends WeakBase{ sShortClassName = _sClassName.substring(nindex + 1); } return sShortClassName; - } - - + } + + public static boolean isUnoTypeObject(Object _oUnoObject){ return isOfUnoType(_oUnoObject, "com.sun.star.uno.Type"); } - + public static boolean isUnoPropertyTypeObject(Object _oUnoObject){ return isOfUnoType(_oUnoObject, "com.sun.star.beans.Property"); } - + public static boolean isUnoPropertyValueTypeObject(Object _oUnoObject){ return isOfUnoType(_oUnoObject, "com.sun.star.beans.PropertyValue"); } - - + + public static boolean isOfUnoType(Object _oUnoObject, String _sTypeName){ boolean bIsUnoObject = false; if (_oUnoObject != null){ @@ -530,7 +530,7 @@ public class Introspector extends WeakBase{ if (oUnoArray.length > 0){ bIsUnoObject = ( oUnoArray[0].getClass().getName().equals(_sTypeName)); } - } + } } } else{ @@ -538,8 +538,8 @@ public class Introspector extends WeakBase{ } return bIsUnoObject; } - - + + public String getConstantDisplayString(int _nValue, XConstantTypeDescription[] _xConstantTypeDescription, String _sDisplayString){ String sPrefix = ""; int[] nbits = new int[_xConstantTypeDescription.length]; @@ -553,7 +553,7 @@ public class Introspector extends WeakBase{ } return _sDisplayString; } - + public static boolean isValid(Object[] _oObject){ if (_oObject != null){ @@ -576,20 +576,20 @@ public class Introspector extends WeakBase{ public static boolean isArray(Object _oObject){ return _oObject.getClass().isArray(); } - - + + public boolean hasSupportedServices(Object _oUnoObject){ boolean bHasSupportedServices = false; XServiceInfo xServiceInfo = ( XServiceInfo ) UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject); if ( xServiceInfo != null ){ - String[] sSupportedServiceNames = xServiceInfo.getSupportedServiceNames(); + String[] sSupportedServiceNames = xServiceInfo.getSupportedServiceNames(); bHasSupportedServices = sSupportedServiceNames.length > 0; } return bHasSupportedServices; } - - - public Object getValueOfText(TypeClass aTypeClass, String sText){ + + + public Object getValueOfText(TypeClass aTypeClass, String sText){ Object oReturn = null; switch (aTypeClass.getValue()){ case TypeClass.CHAR_value: @@ -600,7 +600,7 @@ public class Introspector extends WeakBase{ case TypeClass.ENUM_value: break; case TypeClass.FLOAT_value: - oReturn = Float.valueOf(sText); + oReturn = Float.valueOf(sText); break; case TypeClass.HYPER_value: oReturn = Long.valueOf(sText); @@ -609,7 +609,7 @@ public class Introspector extends WeakBase{ oReturn = Integer.valueOf(sText); break; case TypeClass.SHORT_value: - oReturn = Byte.valueOf(sText); + oReturn = Byte.valueOf(sText); break; case TypeClass.STRING_value: oReturn = sText; @@ -621,14 +621,14 @@ public class Introspector extends WeakBase{ oReturn = Integer.valueOf(sText); break; case TypeClass.UNSIGNED_SHORT_value: - oReturn = Byte.valueOf(sText); + oReturn = Byte.valueOf(sText); break; - default: + default: } return oReturn; - } - + } + public XSimpleFileAccess getXSimpleFileAccess(){ try { if (xSimpleFileAccess == null){ @@ -640,22 +640,22 @@ public class Introspector extends WeakBase{ ex.printStackTrace(System.out); return null; }} - - + + public boolean isValidSDKInstallationPath(String _sSDKInstallationPath){ boolean bIsValid = false; try { String sIDLFolder = Introspector.addToPath(_sSDKInstallationPath, Inspector.sIDLDOCUMENTSUBFOLDER); String sIndexFile = Introspector.addToPath(_sSDKInstallationPath, "index.html"); if (getXSimpleFileAccess() != null){ - bIsValid = (getXSimpleFileAccess().exists(sIDLFolder) && getXSimpleFileAccess().exists(sIndexFile)); + bIsValid = (getXSimpleFileAccess().exists(sIDLFolder) && getXSimpleFileAccess().exists(sIndexFile)); } } catch (com.sun.star.uno.Exception ex) { ex.printStackTrace(System.out); } return bIsValid; } - + public static String addToPath(String _sPath, String _sSubPath){ if (!_sPath.endsWith("/")){ @@ -663,5 +663,5 @@ public class Introspector extends WeakBase{ } return _sPath + _sSubPath; } - + } diff --git a/odk/examples/java/Inspector/MethodParametersDialog.java b/odk/examples/java/Inspector/MethodParametersDialog.java index a2ebf7e66c41..803873703afb 100644 --- a/odk/examples/java/Inspector/MethodParametersDialog.java +++ b/odk/examples/java/Inspector/MethodParametersDialog.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.reflection.ParamInfo; @@ -63,7 +63,7 @@ public class MethodParametersDialog extends JDialog{ private ActionListener oActionListener; private JButton jHelpButton = new JButton("Help"); private JButton jOKButton = new JButton("Ok"); - private JButton jInvokeButton = new JButton("Invoke"); + private JButton jInvokeButton = new JButton("Invoke"); private Object m_oReturnButton = null; private Object m_oUnoObject = null; private Object m_oUnoReturnObject = null; @@ -71,8 +71,8 @@ public class MethodParametersDialog extends JDialog{ private JPanel jResultPanel = null; private boolean bisdiposed = false; private XUnoMethodNode m_xUnoMethodNode; - - + + public MethodParametersDialog(XUnoMethodNode _xUnoMethodNode){ m_xUnoMethodNode = _xUnoMethodNode; m_xIdlMethod = _xUnoMethodNode.getXIdlMethod(); @@ -80,8 +80,8 @@ public class MethodParametersDialog extends JDialog{ m_oUnoObject = m_xUnoMethodNode.getUnoObject(); Object[] m_aParameterObjects = new Object[m_aParamInfo.length]; } - - + + public Vector getMethodObjects() { super.setModal(true); addBorderPanel(getContentPane(), BorderLayout.NORTH); @@ -99,7 +99,7 @@ public class MethodParametersDialog extends JDialog{ for (int i = 0; i < m_aParameterPanels.length; i++){ m_aParameterPanels[i] = new ParameterPanel(m_aParamInfo[i]); jPnlParamContainer.add(m_aParameterPanels[i]); - } + } jPnlParamContainer.add(new ButtonPanel(), java.awt.BorderLayout.SOUTH); getContentPane().add(jPnlParamContainer, java.awt.BorderLayout.CENTER); pack(); @@ -108,7 +108,7 @@ public class MethodParametersDialog extends JDialog{ super.setFocusable(true); super.setFocusableWindowState(true); super.requestFocus(); - m_aParameterPanels[0].getInputComponent().requestFocusInWindow(); + m_aParameterPanels[0].getInputComponent().requestFocusInWindow(); setVisible(true); if (!bisdiposed){ Vector aMethodObjects = new Vector(); @@ -122,8 +122,8 @@ public class MethodParametersDialog extends JDialog{ return null; } } - - + + private void insertResultPanel(Exception _oInvocationException){ boolean bAddPanel = false; if (jResultPanel == null){ @@ -143,22 +143,22 @@ public class MethodParametersDialog extends JDialog{ } jResultPanel.add(jLblResult,BorderLayout.WEST); if (bAddPanel){ - int nPos = jPnlParamContainer.getComponentCount() - 1; + int nPos = jPnlParamContainer.getComponentCount() - 1; jPnlParamContainer.add(jResultPanel, nPos); } super.pack(); super.validate(); } - - + + private Object[] getParameterValues(){ Object[] oParameterValues = new Object[m_aParameterPanels.length]; for (int i = 0; i < m_aParameterPanels.length; i++){ oParameterValues[i] = m_aParameterPanels[i].getValue(); - } + } return oParameterValues; } - + private boolean isCompleted(){ boolean bIsCompleted = true; @@ -167,11 +167,11 @@ public class MethodParametersDialog extends JDialog{ if (!bIsCompleted){ break; } - } + } return bIsCompleted; } - - + + private void addBorderPanel(java.awt.Container _jContainer, String _sLayout){ JPanel jPnlBorder = new JPanel(); jPnlBorder.setPreferredSize(new java.awt.Dimension(10, 10)); @@ -184,8 +184,8 @@ public class MethodParametersDialog extends JDialog{ jPnlBorder.setMaximumSize(new java.awt.Dimension(10, 10)); _jContainer.add(jPnlBorder); } - - + + private class ParameterPanel extends JPanel{ private JComponent m_jComponent; private TypeClass m_aTypeClass = null; @@ -207,13 +207,13 @@ public class MethodParametersDialog extends JDialog{ addGapPanel(jPnlCenter1); switch (m_aTypeClass.getValue()){ case TypeClass.BOOLEAN_value: - jComboBox.setBackground(new java.awt.Color(255, 255, 255)); + jComboBox.setBackground(new java.awt.Color(255, 255, 255)); jComboBox.setPreferredSize(new java.awt.Dimension(50, 19)); jComboBox.addItem("True"); jComboBox.addItem("False"); jComboBox.addKeyListener(new UpdateUIAdapter()); jPnlCenter1.add(jComboBox); - m_jComponent = jComboBox; + m_jComponent = jComboBox; break; case TypeClass.BYTE_value: case TypeClass.CHAR_value: @@ -230,20 +230,20 @@ public class MethodParametersDialog extends JDialog{ jTextField.setPreferredSize(new java.awt.Dimension(50, 19)); jTextField.addKeyListener(new UpdateUIAdapter()); jPnlCenter1.add(jTextField); - m_jComponent = jTextField; + m_jComponent = jTextField; break; default: System.out.println("Type " + m_aTypeClass.getValue() + " not yet defined in 'ParameterPanel()'"); - } + } add(jPnlCenter1, java.awt.BorderLayout.CENTER); JPanel jPnlEast = new JPanel(); - add(jPnlEast, BorderLayout.EAST); + add(jPnlEast, BorderLayout.EAST); } - + private JComponent getInputComponent(){ return m_jComponent; } - + public Object getValue(){ Object oReturn = null; if (m_jComponent instanceof JTextField){ @@ -256,8 +256,8 @@ public class MethodParametersDialog extends JDialog{ } return oReturn; } - - + + public boolean isCompleted(){ if (m_jComponent instanceof JTextField){ return !((JTextField) m_jComponent).getText().equals(""); @@ -268,7 +268,7 @@ public class MethodParametersDialog extends JDialog{ } } - + private class UpdateUIAdapter extends KeyAdapter{ public void keyReleased(KeyEvent e){ boolean bIsCompleted = isCompleted(); @@ -280,8 +280,8 @@ public class MethodParametersDialog extends JDialog{ } } } - - + + private class ButtonPanel extends JPanel{ public ButtonPanel(){ @@ -295,7 +295,7 @@ public class MethodParametersDialog extends JDialog{ public void actionPerformed(ActionEvent e) { oActionListener.actionPerformed(e); } - }); + }); jHelpButton.setEnabled(oActionListener != null); jPnlBottomCenter.add(jHelpButton); addGapPanel(jPnlBottomCenter); @@ -305,7 +305,7 @@ public class MethodParametersDialog extends JDialog{ invokeParameterMethod(); dispose(); } - }); + }); jOKButton.setEnabled(isCompleted()); jInvokeButton.setEnabled(isCompleted()); jInvokeButton.addActionListener(new ActionListener() { @@ -313,7 +313,7 @@ public class MethodParametersDialog extends JDialog{ invokeParameterMethod(); } }); - + jPnlBottomCenter.add(jOKButton); addGapPanel(jPnlBottomCenter); jPnlBottomCenter.add(jInvokeButton); @@ -327,18 +327,18 @@ public class MethodParametersDialog extends JDialog{ dispose(); } }); - + jPnlBottomCenter.add(jCancelButton); add(jPnlBottomCenter); } } - - + + public void addActionListener(ActionListener _oActionListener){ oActionListener = _oActionListener; - jHelpButton.setEnabled(oActionListener != null); + jHelpButton.setEnabled(oActionListener != null); } - + public void invokeParameterMethod(){ try{ @@ -348,6 +348,6 @@ public class MethodParametersDialog extends JDialog{ } catch (Exception ex) { insertResultPanel(ex); m_oUnoReturnObject = null; - }} - + }} + } diff --git a/odk/examples/java/Inspector/ObjectInspector.xcu b/odk/examples/java/Inspector/ObjectInspector.xcu index 79459ab48f24..93c2711f2ec8 100755 --- a/odk/examples/java/Inspector/ObjectInspector.xcu +++ b/odk/examples/java/Inspector/ObjectInspector.xcu @@ -3,8 +3,8 @@ <!ENTITY ProductName "Object Inspector"> <!ENTITY ProductVersion "0.8"> ]> -<oor:component-data - xmlns:oor="http://openoffice.org/2001/registry" +<oor:component-data + xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="ObjectInspector" oor:package="org.openoffice.inspector"> <prop oor:name="Language" oor:type="xs:string"> diff --git a/odk/examples/java/Inspector/ProtocolHandlerAddon.java b/odk/examples/java/Inspector/ProtocolHandlerAddon.java index ad3b0efe8747..2844d25e3def 100644 --- a/odk/examples/java/Inspector/ProtocolHandlerAddon.java +++ b/odk/examples/java/Inspector/ProtocolHandlerAddon.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.uno.XComponentContext; @@ -42,12 +42,12 @@ import com.sun.star.lang.XInitialization; import com.sun.star.lang.XTypeProvider; import com.sun.star.lang.XServiceInfo; import com.sun.star.uno.Type; -import com.sun.star.frame.XStatusListener; -import com.sun.star.frame.XDispatchProvider; -import com.sun.star.frame.XDispatch; -import com.sun.star.frame.XModel; -import com.sun.star.frame.XFrame; -import com.sun.star.frame.DispatchDescriptor; +import com.sun.star.frame.XStatusListener; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XModel; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.DispatchDescriptor; import com.sun.star.awt.XToolkit; import com.sun.star.awt.XWindowPeer; import com.sun.star.awt.XMessageBox; @@ -62,14 +62,14 @@ public class ProtocolHandlerAddon { */ public static class ProtocolHandlerAddonImpl extends WeakBase implements XDispatchProvider, - XDispatch, + XDispatch, XInitialization, XServiceInfo { /** The service name, that must be used to get an instance of this service. */ static private final String[] m_serviceNames = { "com.sun.star.frame.ProtocolHandler" }; - + /** The component context, that gives access to the service manager and all registered services. */ private XComponentContext m_xCmpCtx; @@ -83,7 +83,7 @@ public class ProtocolHandlerAddon { private XFrame m_xFrame; private XStatusListener m_xStatusListener; - + /** The constructor of the inner class has a XMultiServiceFactory parameter. * @param xmultiservicefactoryInitialization A special service factory * could be introduced while initializing. @@ -91,7 +91,7 @@ public class ProtocolHandlerAddon { public ProtocolHandlerAddonImpl( XComponentContext xComponentContext ) { m_xCmpCtx = xComponentContext; } - + /** This method is a member of the interface for initializing an object * directly after its creation. * @param object This array of arbitrary objects will be passed to the @@ -114,7 +114,7 @@ public class ProtocolHandlerAddon { m_xCmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.awt.Toolkit", m_xCmpCtx)); } - + /** This method returns an array of all supported service names. * @return Array of supported service names. */ @@ -125,7 +125,7 @@ public class ProtocolHandlerAddon { public static String[] getServiceNames() { return m_serviceNames; } - + /** This method returns true, if the given service will be * supported by the component. * @param stringService Service name. @@ -133,22 +133,22 @@ public class ProtocolHandlerAddon { */ public boolean supportsService( String sService ) { int len = m_serviceNames.length; - + for( int i=0; i < len; i++) { if ( sService.equals( m_serviceNames[i] ) ) return true; } - + return false; } - + /** Return the class name of the component. * @return Class name of the component. */ public String getImplementationName() { return ProtocolHandlerAddonImpl.class.getName(); } - + // XDispatchProvider public XDispatch queryDispatch( /*IN*/com.sun.star.util.URL aURL, /*IN*/String sTargetFrameName, @@ -164,23 +164,23 @@ public class ProtocolHandlerAddon { } return xRet; } - + public XDispatch[] queryDispatches( /*IN*/DispatchDescriptor[] seqDescripts ) { int nCount = seqDescripts.length; XDispatch[] lDispatcher = new XDispatch[nCount]; - + for( int i=0; i<nCount; ++i ) lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL, seqDescripts[i].FrameName, seqDescripts[i].SearchFlags ); - - return lDispatcher; + + return lDispatcher; } // XDispatch public void dispatch( /*IN*/com.sun.star.util.URL aURL, /*IN*/com.sun.star.beans.PropertyValue[] aArguments ) { - + if ( aURL.Protocol.compareTo("org.openoffice.Office.addon.example:") == 0 ) { if ( aURL.Path.compareTo( "Function1" ) == 0 ) @@ -197,11 +197,11 @@ public class ProtocolHandlerAddon { } } } - + public void addStatusListener( /*IN*/XStatusListener xControl, /*IN*/com.sun.star.util.URL aURL ) { } - + public void removeStatusListener( /*IN*/XStatusListener xControl, /*IN*/com.sun.star.util.URL aURL ) { } @@ -221,7 +221,7 @@ public class ProtocolHandlerAddon { aDescriptor.WindowAttributes = WindowAttribute.BORDER | WindowAttribute.MOVEABLE | WindowAttribute.CLOSEABLE; - + XWindowPeer xPeer = m_xToolkit.createWindow( aDescriptor ); if ( null != xPeer ) { XMessageBox xMsgBox = (XMessageBox)UnoRuntime.queryInterface( @@ -235,12 +235,12 @@ public class ProtocolHandlerAddon { } } } catch ( com.sun.star.uno.Exception e) { - // do your error handling + // do your error handling } } } - - + + /** Gives a factory for creating the service. * This method is called by the <code>JavaLoader</code> * <p> @@ -256,14 +256,14 @@ public class ProtocolHandlerAddon { */ public static XSingleComponentFactory __getComponentFactory( String sImplementationName ) { XSingleComponentFactory xFactory = null; - + if ( sImplementationName.equals( ProtocolHandlerAddonImpl.class.getName() ) ) xFactory = Factory.createComponentFactory(ProtocolHandlerAddonImpl.class, ProtocolHandlerAddonImpl.getServiceNames()); - + return xFactory; } - + /** Writes the service information into the given registry key. * This method is called by the <code>JavaLoader</code>. * @return returns true if the operation succeeded diff --git a/odk/examples/java/Inspector/SourceCodeGenerator.java b/odk/examples/java/Inspector/SourceCodeGenerator.java index 6661fe9604ad..932854cd0d28 100644 --- a/odk/examples/java/Inspector/SourceCodeGenerator.java +++ b/odk/examples/java/Inspector/SourceCodeGenerator.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.beans.UnknownPropertyException; @@ -60,12 +60,12 @@ public class SourceCodeGenerator { private XLanguageSourceCodeGenerator m_xLanguageSourceCodeGenerator; private String sHeaderCode = ""; private String sStatementCode = ""; - private String sMainMethodSignature = ""; - + private String sMainMethodSignature = ""; + private Hashtable aVariables = new Hashtable(); private final String SSUFFIXSEPARATOR = "_"; private final String SVARIABLENAME = "VariableName"; - private final String SARRAYVARIABLENAME = "VariableNameList"; + private final String SARRAYVARIABLENAME = "VariableNameList"; private final String SUNOOBJECTNAME = "oUnobject"; private final String SUNOSTRUCTNAME = "aUnoStruct"; private Introspector m_oIntrospector; @@ -75,17 +75,17 @@ public class SourceCodeGenerator { private boolean bXPropertySetExceptionsAreAdded = false; private XUnoNode oInitialUnoNode = null; private final String sINITIALVARIABLENAME = "_oUnoEntryObject"; - - + + /** Creates a new instance of SourceCodeGenerator */ public SourceCodeGenerator(int _nLanguage) { this.setLanguage(_nLanguage); m_oIntrospector = Introspector.getIntrospector(); } - + public String addSourceCodeOfUnoObject(XTreePathProvider _xTreepathProvider, boolean _brememberPath, boolean _bAddMethodSignature, boolean _baddHeader){ - String sSourceCode = ""; + String sSourceCode = ""; String sVariableName = ""; if (_xTreepathProvider != null) { for (int i = 0; i < _xTreepathProvider.getPathCount(); i++){ @@ -106,7 +106,7 @@ public class SourceCodeGenerator { sVariableName = oUnoReturnObjectDefinition.getVariableName(); } } - else if (oUnoNode instanceof XUnoPropertyNode){ + else if (oUnoNode instanceof XUnoPropertyNode){ XUnoPropertyNode oUnoPropertyNode = (XUnoPropertyNode) oUnoNode; Any oReturnObject = com.sun.star.uno.Any.complete(oUnoPropertyNode.getUnoReturnObject()); UnoObjectDefinition oUnoReturnObjectDefinition = new UnoObjectDefinition(oReturnObject); @@ -118,7 +118,7 @@ public class SourceCodeGenerator { } } } - } + } String sCompleteCode = combineCompleteSourceCode(sMainMethodSignature, _baddHeader); xTreepathProvider = _xTreepathProvider; if (_brememberPath){ @@ -126,10 +126,10 @@ public class SourceCodeGenerator { } return sCompleteCode; } - - + + private void setLanguage(int _nLanguage){ - XLanguageSourceCodeGenerator xLanguageSourceCodeGenerator = null; + XLanguageSourceCodeGenerator xLanguageSourceCodeGenerator = null; switch(_nLanguage){ case XLanguageSourceCodeGenerator.nJAVA: xLanguageSourceCodeGenerator = new JavaCodeGenerator(); @@ -147,15 +147,15 @@ public class SourceCodeGenerator { m_xLanguageSourceCodeGenerator = xLanguageSourceCodeGenerator; } } - + private void resetSourceCodeGeneration(int _nLanguage){ - aVariables.clear(); + aVariables.clear(); this.sHeaderStatements.clear(); setLanguage(_nLanguage); String sHeaderCode = ""; sStatementCode = ""; } - + private String generateVariableNameFromMethod(String _sMethodName, String _sPrefix, boolean _bConsiderAll){ String sReturn = ""; if (_sMethodName.startsWith(_sPrefix)){ @@ -175,8 +175,8 @@ public class SourceCodeGenerator { } return sReturn; } - - + + private String generateVariableNameFromMethod(XIdlMethod _xIdlMethod){ // todo: refactor this!!! String sMethodName = _xIdlMethod.getName(); @@ -208,18 +208,18 @@ public class SourceCodeGenerator { } return sReturn; } - - + + public String convertAllUnoObjects(int _nLanguage){ - String sSourceCode = ""; + String sSourceCode = ""; resetSourceCodeGeneration(_nLanguage); int ncount = aTreepathProviders.size(); for (int i=0; i< ncount; i++){ - sSourceCode = addSourceCodeOfUnoObject((XTreePathProvider) aTreepathProviders.get(i), false, (i==0), (i == (ncount-1))); + sSourceCode = addSourceCodeOfUnoObject((XTreePathProvider) aTreepathProviders.get(i), false, (i==0), (i == (ncount-1))); } return sSourceCode; } - + private UnoObjectDefinition getUnoObjectDefinition(XTreePathProvider _xTreePathProvider, XUnoMethodNode _oUnoMethodNode, int _nindex){ XUnoNode oUnoNode = null; Object oUnoReturnObject = null; @@ -250,12 +250,12 @@ public class SourceCodeGenerator { } return oUnoObjectDefinition; } - - + + private String combineCompleteSourceCode(String _sMethodSignature, boolean _bAddHeader){ String sCompleteCode = ""; if (_bAddHeader){ - sMainMethodSignature = m_xLanguageSourceCodeGenerator.getMainMethodSignatureSourceCode(oInitialUnoNode, sINITIALVARIABLENAME); + sMainMethodSignature = m_xLanguageSourceCodeGenerator.getMainMethodSignatureSourceCode(oInitialUnoNode, sINITIALVARIABLENAME); m_xLanguageSourceCodeGenerator.assignqueryInterfaceHeaderSourceCode(); sCompleteCode += getHeaderSourceCode(); } @@ -263,12 +263,12 @@ public class SourceCodeGenerator { sCompleteCode += sStatementCode; if (_bAddHeader){ sCompleteCode += m_xLanguageSourceCodeGenerator.getMethodTerminationSourceCode(); - sCompleteCode += "\n" + m_xLanguageSourceCodeGenerator.getCommentSign() + "..."; + sCompleteCode += "\n" + m_xLanguageSourceCodeGenerator.getCommentSign() + "..."; } return sCompleteCode; } - + public String getPropertyStatementSourceCode(XUnoPropertyNode _oUnoPropertyNode, String _sVariableName, UnoObjectDefinition _oUnoReturnObjectDefinition){ String sReturnObjectVariableDefinition = ""; String sStatement = ""; @@ -280,7 +280,7 @@ public class SourceCodeGenerator { sReturnObjectVariableDefinition = getVariableInitialization(_oUnoReturnObjectDefinition, false); sStatement += m_xLanguageSourceCodeGenerator.getStructSourceCode(sReturnObjectVariableDefinition, oUnoObjectDefinition.getVariableName(), sPropertyName); return sStatement; - } + } } sStatement += addQueryInterfaceSourceCode(oUnoObjectDefinition, _sVariableName, "com.sun.star.beans.XPropertySet"); if (_oUnoReturnObjectDefinition.getTypeClass().getValue() != TypeClass.VOID_value){ @@ -290,8 +290,8 @@ public class SourceCodeGenerator { addXPropertySetRelatedExceptions(); return sStatement; } - - + + public String getMethodStatementSourceCode(XUnoMethodNode _oUnoMethodNode, String _sVariableName, UnoObjectDefinition _oUnoReturnObjectDefinition){ String sReturnObjectVariableDefinition = ""; String sStatement = ""; @@ -311,8 +311,8 @@ public class SourceCodeGenerator { addExceptions(xIdlMethod); return sStatement; } - - + + private String addQueryInterfaceSourceCode(UnoObjectDefinition _oUnoObjectDefinition, String _sVariableName, String _sTypeName){ String sLocStatement = ""; if (m_xLanguageSourceCodeGenerator.needsqueryInterface()){ @@ -321,13 +321,13 @@ public class SourceCodeGenerator { sLocStatement += m_xLanguageSourceCodeGenerator.getqueryInterfaceSourceCode(_sTypeName, sObjectVariableDefinition, _sVariableName); } } - else{ + else{ _oUnoObjectDefinition.setVariableName(_sVariableName); } return sLocStatement; } - - + + private void addXPropertySetRelatedExceptions(){ if (!bXPropertySetExceptionsAreAdded){ sExceptions.add("com.sun.star.beans.UnknownPropertyException"); @@ -337,8 +337,8 @@ public class SourceCodeGenerator { baddExceptionHandling = true; } } - - + + private void addExceptions(XIdlMethod _xIdlMethod){ XIdlClass[] xIdlClasses = _xIdlMethod.getExceptionTypes(); for (int i = 0; i > xIdlClasses.length; i++){ @@ -346,12 +346,12 @@ public class SourceCodeGenerator { baddExceptionHandling = true; } } - + private String getRootDescription(XUnoNode _oUnoNode){ return "_o" + _oUnoNode.toString(); } - - + + private String getHeaderSourceCode(){ Enumeration aEnumeration = aVariables.elements(); while(aEnumeration.hasMoreElements()){ @@ -369,10 +369,10 @@ public class SourceCodeGenerator { sHeaderSourcecode += m_xLanguageSourceCodeGenerator.getFinalHeaderStatements(); return sHeaderSourcecode +"\n" + m_xLanguageSourceCodeGenerator.getCommentSign() + "...\n"; } - - + + private class HeaderStatements extends Vector{ - + public boolean contains(Object _oElement){ String sCompName = (String) _oElement; for (int i = 0; i < this.size(); i++){ @@ -383,8 +383,8 @@ public class SourceCodeGenerator { } return false; } - - + + public boolean add(Object _oElement){ if (_oElement instanceof String){ if (!contains(_oElement)){ @@ -394,9 +394,9 @@ public class SourceCodeGenerator { } return false; } - } - - + } + + private boolean isVariableDeclared(UnoObjectDefinition _oUnoObjectDefinition, String _sDefaultStemName){ boolean bisDeclared = false; if (!_sDefaultStemName.equals("")){ @@ -436,11 +436,11 @@ public class SourceCodeGenerator { } return bisDeclared; } - - + + private String addUniqueVariableName(String _sStemVariableName, UnoObjectDefinition _oUnoObjectDefinition){ boolean bElementexists = true; - int a = 2; + int a = 2; String sCompName = _sStemVariableName; while (bElementexists){ if (! aVariables.containsKey(sCompName)){ @@ -452,9 +452,9 @@ public class SourceCodeGenerator { return sCompName; } - - - private String getTypeString(String _sTypeName, TypeClass _aTypeClass, boolean _bAsHeaderSourceCode){ + + + private String getTypeString(String _sTypeName, TypeClass _aTypeClass, boolean _bAsHeaderSourceCode){ String sTypeString = ""; switch (_aTypeClass.getValue()){ case TypeClass.BOOLEAN_value: @@ -464,49 +464,49 @@ public class SourceCodeGenerator { sTypeString = m_xLanguageSourceCodeGenerator.getbyteTypeDescription(); break; case TypeClass.CHAR_value: - sTypeString = m_xLanguageSourceCodeGenerator.getcharTypeDescription(); + sTypeString = m_xLanguageSourceCodeGenerator.getcharTypeDescription(); break; case TypeClass.DOUBLE_value: - sTypeString = m_xLanguageSourceCodeGenerator.getdoubleTypeDescription(); - break; + sTypeString = m_xLanguageSourceCodeGenerator.getdoubleTypeDescription(); + break; case TypeClass.FLOAT_value: - sTypeString = m_xLanguageSourceCodeGenerator.getfloatTypeDescription(); - break; + sTypeString = m_xLanguageSourceCodeGenerator.getfloatTypeDescription(); + break; case TypeClass.HYPER_value: - sTypeString = m_xLanguageSourceCodeGenerator.gethyperTypeDescription(); - break; + sTypeString = m_xLanguageSourceCodeGenerator.gethyperTypeDescription(); + break; case TypeClass.LONG_value: - sTypeString = m_xLanguageSourceCodeGenerator.getlongTypeDescription(); - break; + sTypeString = m_xLanguageSourceCodeGenerator.getlongTypeDescription(); + break; case TypeClass.SHORT_value: - sTypeString = m_xLanguageSourceCodeGenerator.getshortTypeDescription(); - break; + sTypeString = m_xLanguageSourceCodeGenerator.getshortTypeDescription(); + break; case TypeClass.STRING_value: - sTypeString = m_xLanguageSourceCodeGenerator.getstringTypeDescription(_bAsHeaderSourceCode); - break; + sTypeString = m_xLanguageSourceCodeGenerator.getstringTypeDescription(_bAsHeaderSourceCode); + break; case TypeClass.UNSIGNED_HYPER_value: - sTypeString = m_xLanguageSourceCodeGenerator.getunsignedhyperTypeDescription(); - break; + sTypeString = m_xLanguageSourceCodeGenerator.getunsignedhyperTypeDescription(); + break; case TypeClass.UNSIGNED_LONG_value: - sTypeString = m_xLanguageSourceCodeGenerator.getunsignedlongTypeDescription(); - break; + sTypeString = m_xLanguageSourceCodeGenerator.getunsignedlongTypeDescription(); + break; case TypeClass.UNSIGNED_SHORT_value: - sTypeString = m_xLanguageSourceCodeGenerator.getdoubleTypeDescription(); - break; + sTypeString = m_xLanguageSourceCodeGenerator.getdoubleTypeDescription(); + break; case TypeClass.SEQUENCE_value: //TODO consider mulitdimensional Arrays XTypeDescription xTypeDescription = Introspector.getIntrospector().getReferencedType(_sTypeName); if (xTypeDescription != null){ sTypeString = getTypeString(xTypeDescription.getName(), xTypeDescription.getTypeClass(), _bAsHeaderSourceCode); } - break; + break; case TypeClass.ANY_value: sTypeString = m_xLanguageSourceCodeGenerator.getanyTypeDescription(_bAsHeaderSourceCode); break; case TypeClass.TYPE_value: sTypeString = m_xLanguageSourceCodeGenerator.getObjectTypeDescription("com.sun.star.uno.Type", _bAsHeaderSourceCode); break; - case TypeClass.ENUM_value: + case TypeClass.ENUM_value: case TypeClass.STRUCT_value: case TypeClass.INTERFACE_ATTRIBUTE_value: case TypeClass.INTERFACE_METHOD_value: @@ -514,14 +514,14 @@ public class SourceCodeGenerator { case TypeClass.PROPERTY_value: sTypeString = m_xLanguageSourceCodeGenerator.getObjectTypeDescription(_sTypeName, _bAsHeaderSourceCode); break; - default: + default: } return sTypeString; - } - - + } + + private String getVariableDeclaration(UnoObjectDefinition _oUnoObjectDefinition, boolean _bInitialize, String _sVariableDefaultName){ - TypeClass aTypeClass = _oUnoObjectDefinition.getTypeClass(); + TypeClass aTypeClass = _oUnoObjectDefinition.getTypeClass(); TypeClass aLocTypeClass = aTypeClass; boolean bIsArray = false; if (_oUnoObjectDefinition.getUnoObject() != null){ @@ -543,8 +543,8 @@ public class SourceCodeGenerator { addUniqueVariableName(sVariableName, _oUnoObjectDefinition); return sVariableDeclaration; } - - + + public String getVariableInitialization(UnoObjectDefinition _oUnoObjectDefinition, boolean _bInitialize){ String sObjectVariableDeclaration = ""; String sVariableName = _oUnoObjectDefinition.getVariableName(); @@ -556,9 +556,9 @@ public class SourceCodeGenerator { } return sObjectVariableDeclaration; } - - - + + + public String getVariableNameforUnoObject(String _sShortClassName){ if (_sShortClassName.startsWith("X")){ return "x" + _sShortClassName.substring(1); @@ -567,18 +567,18 @@ public class SourceCodeGenerator { return _sShortClassName; } } - - + + class UnoObjectDefinition{ Object m_oUnoObject = null; Type aType = null; - String sVariableStemName = ""; + String sVariableStemName = ""; String m_sCentralVariableStemName = ""; String sVariableName = ""; String m_sTypeName = ""; TypeClass m_aTypeClass = null; Object[] m_oParameterObjects = null; - + public UnoObjectDefinition(Any _oUnoObject){ m_sTypeName = _oUnoObject.getType().getTypeName(); @@ -586,8 +586,8 @@ class UnoObjectDefinition{ m_oUnoObject = _oUnoObject; m_sCentralVariableStemName = getCentralVariableStemName(m_aTypeClass); } - - + + public UnoObjectDefinition(Object _oUnoObject, String _sTypeName, TypeClass _aTypeClass){ m_oUnoObject = _oUnoObject; m_sTypeName = _sTypeName; @@ -595,15 +595,15 @@ class UnoObjectDefinition{ m_sCentralVariableStemName = getCentralVariableStemName(m_aTypeClass); } - + public UnoObjectDefinition(Object _oUnoObject, String _sTypeName){ m_oUnoObject = _oUnoObject; m_sTypeName = _sTypeName; m_aTypeClass = AnyConverter.getType(_oUnoObject).getTypeClass(); m_sCentralVariableStemName = getCentralVariableStemName(m_aTypeClass); } - - + + private String getCentralVariableStemName(TypeClass _aTypeClass){ String sCentralVariableStemName = ""; int nTypeClass = _aTypeClass.getValue(); @@ -614,7 +614,7 @@ class UnoObjectDefinition{ if (xTypeDescription != null){ sCentralVariableStemName = getCentralVariableStemName(xTypeDescription.getTypeClass()); } - break; + break; case TypeClass.TYPE_value: sCentralVariableStemName = SVARIABLENAME; break; @@ -627,64 +627,64 @@ class UnoObjectDefinition{ case TypeClass.PROPERTY_value: String sShortClassName = m_oIntrospector.getShortClassName(getTypeName()); sCentralVariableStemName = getVariableNameforUnoObject(sShortClassName); - default: + default: sCentralVariableStemName = SVARIABLENAME; - } + } return sCentralVariableStemName; } - + /** may return null */ public Object getUnoObject(){ return m_oUnoObject; } - + public void setTypeClass(TypeClass _aTypeClass){ sVariableStemName = ""; m_aTypeClass = _aTypeClass; } - - + + public TypeClass getTypeClass(){ return m_aTypeClass; } - - + + public void setTypeName(String _sTypeName){ sVariableStemName = ""; m_sTypeName = _sTypeName; - } - - + } + + public String getTypeName(){ return m_sTypeName; - } - - + } + + public void setCentralVariableStemName(String _sCentralVariableStemName){ m_sCentralVariableStemName = _sCentralVariableStemName; } - - + + public String getVariableStemName(){ if (sVariableStemName.equals("")){ sVariableStemName = getVariableStemName(m_aTypeClass); } return sVariableStemName; } - - + + public void addParameterObjects(Object[] _oParameterObjects){ m_oParameterObjects = _oParameterObjects; } - + public Object[] getParameterObjects(){ return m_oParameterObjects; } - + public boolean hasParameterObjects(){ boolean breturn = false; if (m_oParameterObjects != null){ @@ -692,8 +692,8 @@ class UnoObjectDefinition{ } return breturn; } - - + + public String getVariableStemName(TypeClass _aTypeClass){ int nTypeClass = _aTypeClass.getValue(); switch(nTypeClass){ @@ -703,7 +703,7 @@ class UnoObjectDefinition{ case TypeClass.DOUBLE_value: case TypeClass.FLOAT_value: sVariableStemName = "f" + m_sCentralVariableStemName; - break; + break; case TypeClass.BYTE_value: case TypeClass.HYPER_value: case TypeClass.LONG_value: @@ -712,18 +712,18 @@ class UnoObjectDefinition{ case TypeClass.UNSIGNED_SHORT_value: case TypeClass.SHORT_value: sVariableStemName = "n" + m_sCentralVariableStemName; - break; + break; case TypeClass.CHAR_value: case TypeClass.STRING_value: sVariableStemName = "s" + m_sCentralVariableStemName; - break; + break; case TypeClass.SEQUENCE_value: //TODO consider mulitdimensional Arrays XTypeDescription xTypeDescription = Introspector.getIntrospector().getReferencedType(getTypeName()); if (xTypeDescription != null){ sVariableStemName = getVariableStemName(xTypeDescription.getTypeClass()); } - break; + break; case TypeClass.TYPE_value: sVariableStemName = "a" + m_sCentralVariableStemName; break; @@ -731,7 +731,7 @@ class UnoObjectDefinition{ sVariableStemName = "o" + m_sCentralVariableStemName; break; case TypeClass.STRUCT_value: - case TypeClass.ENUM_value: + case TypeClass.ENUM_value: sVariableStemName = "a" + m_sCentralVariableStemName; break; case TypeClass.INTERFACE_ATTRIBUTE_value: @@ -740,35 +740,35 @@ class UnoObjectDefinition{ case TypeClass.PROPERTY_value: String sShortClassName = m_oIntrospector.getShortClassName(getTypeName()); sVariableStemName = getVariableNameforUnoObject(sShortClassName); - default: - } + default: + } return sVariableStemName; } - - + + private void setVariableName(String _sVariableName){ sVariableName = _sVariableName; } - - + + private String getVariableName(String _sCentralVariableStemName){ if (!_sCentralVariableStemName.equals("")){ this.m_sCentralVariableStemName = _sCentralVariableStemName; } return getVariableName(); } - - + + private String getVariableName() throws NullPointerException{ if (sVariableName.equals("")){ - int a = 2; + int a = 2; sVariableName = getVariableStemName(); boolean bleaveloop = false; while (!bleaveloop){ if (aVariables.containsKey(sVariableName)){ String sUnoObjectIdentity = ((UnoObjectDefinition) aVariables.get(sVariableName)).getUnoObject().toString(); if (m_oUnoObject != null){ - if ((sUnoObjectIdentity.equals(m_oUnoObject.toString()) && (!m_oIntrospector.isPrimitive(this.getTypeClass())) && + if ((sUnoObjectIdentity.equals(m_oUnoObject.toString()) && (!m_oIntrospector.isPrimitive(this.getTypeClass())) && (! m_oIntrospector.isObjectSequence(m_oUnoObject)))){ bleaveloop = true; } @@ -789,8 +789,8 @@ class UnoObjectDefinition{ return sVariableName; } } - - + + public String getStringValueOfObject(Object _oUnoObject, TypeClass _aTypeClass){ String sReturn = ""; switch (_aTypeClass.getValue()){ @@ -836,13 +836,13 @@ class UnoObjectDefinition{ nshortValue = ((Short) _oUnoObject).shortValue(); sReturn += Short.toString(nshortValue); break; - default: + default: System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'getStringValueOfObject()'"); - } + } return sReturn; } - - + + public String getMethodParameterValueDescription(XUnoMethodNode _oUnoMethodNode, Object[] _oParamObjects, boolean _bIncludeParameterNames){ String sParamSourceCode = ""; ParamInfo[] aParamInfos = _oUnoMethodNode.getXIdlMethod().getParameterInfos(); @@ -855,7 +855,7 @@ class UnoObjectDefinition{ String sParamDescription = getStringValueOfObject(_oParamObjects[i], aTypeClass); sParamDescription = this.m_xLanguageSourceCodeGenerator.castLiteral(sParamDescription, aTypeClass); sParamSourceCode += sParamDescription; - + if (i < _oParamObjects.length - 1){ sParamSourceCode += ", "; } @@ -863,33 +863,33 @@ class UnoObjectDefinition{ } return sParamSourceCode; } - - + + public class JavaCodeGenerator implements XLanguageSourceCodeGenerator{ String sStatementsCode = ""; boolean bAddAnyConverter = false; // boolean bAddTypeImport = false; boolean bIsPropertyUnoObjectDefined = false; - + public JavaCodeGenerator(){ } - - + + public String getStatementTerminationCharacter(){ return ";"; } - - + + public String getHeaderSourceCode(Object _oUnoObject, String _sClassName, TypeClass _aTypeClass){ String sClassName = _sClassName; String sHeaderStatement = ""; if (_oUnoObject != null){ - if (!m_oIntrospector.isObjectPrimitive(_oUnoObject)){ + if (!m_oIntrospector.isObjectPrimitive(_oUnoObject)){ if (m_oIntrospector.isObjectSequence(_oUnoObject)){ XTypeDescription xTypeDescription = m_oIntrospector.getReferencedType(sClassName); if (xTypeDescription != null){ if (!m_oIntrospector.isPrimitive(xTypeDescription.getTypeClass())){ - sClassName = getTypeString(xTypeDescription.getName(), xTypeDescription.getTypeClass(), true); + sClassName = getTypeString(xTypeDescription.getName(), xTypeDescription.getTypeClass(), true); } // primitive Types are not supposed to turn up in the import section... else{ @@ -909,27 +909,27 @@ class UnoObjectDefinition{ } if (!sClassName.equals("")){ sHeaderStatement = "import " + sClassName + ";\n"; - } + } } return sHeaderStatement; } - - + + public String getFinalHeaderStatements(){ return ""; } - - + + public void assignqueryInterfaceHeaderSourceCode(){ sHeaderStatements.add("import com.sun.star.uno.UnoRuntime;\n"); sHeaderStatements.add("import com.sun.star.uno.XInterface;\n"); if (bAddAnyConverter){ sHeaderStatements.add("import com.sun.star.uno.AnyConverter;\n"); - } + } } - - - + + + public String getConvertedSourceCodeValueOfObject(String _sReturnVariableName, String _sObjectDescription, TypeClass _aTypeClass, String _sTypeName){ boolean bLocAddAnyConverter = true; String sReturn = ""; @@ -964,7 +964,7 @@ class UnoObjectDefinition{ case TypeClass.SHORT_value: sReturn = _sReturnVariableName + " = AnyConverter.toShort(" + _sObjectDescription + ")"; break; - case TypeClass.UNSIGNED_SHORT_value: + case TypeClass.UNSIGNED_SHORT_value: sReturn = _sReturnVariableName + " = AnyConverter.toUnsignedShort(" + _sObjectDescription + ")"; break; case TypeClass.STRING_value: @@ -988,12 +988,12 @@ class UnoObjectDefinition{ } return sReturn; } - - + + public String getStructSourceCode(String _sReturnVariableDescription, String _sObjectDescription, String _sMember){ return "\t" + _sReturnVariableDescription + " = " + _sObjectDescription + "." + _sMember + ";"; } - + public String getMainMethodSignatureSourceCode(XUnoNode _oUnoNode, String _soReturnObjectDescription){ //TODO try to use + _oUnoNode.getClassName() instead of the hack String sReturn = "public void codesnippet(XInterface " + _soReturnObjectDescription + "){"; @@ -1005,18 +1005,18 @@ class UnoObjectDefinition{ public String getMethodSeparator(){ return "."; - } + } public boolean needsqueryInterface(){ return true; } - + public String getqueryInterfaceSourceCode(String _sClassName, String _sReturnVariableName, String _sIncomingObjectName){ String sShortClassName = m_oIntrospector.getShortClassName(_sClassName); return "\t" + _sReturnVariableName + " = (" + sShortClassName + ") UnoRuntime.queryInterface(" + sShortClassName + ".class, " + _sIncomingObjectName + ");\n"; } - + public String getPropertyValueGetterSourceCode(String _sPropertyName, String _sReturnVariableName, String _sIncomingObjectName, TypeClass _aTypeClass, String _sTypeName){ String sObjectDescription = _sIncomingObjectName + ".getPropertyValue(\"" + _sPropertyName + "\")"; String sReturn = getConvertedSourceCodeValueOfObject(_sReturnVariableName, sObjectDescription, _aTypeClass, _sTypeName); @@ -1025,8 +1025,8 @@ class UnoObjectDefinition{ return sReturn; // return "\t" + _sReturnVariableName + " = " + _sIncomingObjectName + ".getPropertyValue(\"" + _sPropertyName + "\");"; } - - + + public String getObjectTypeDescription(String _sClassName, boolean _bAsHeader){ String sReturn = ""; if (_bAsHeader){ @@ -1037,8 +1037,8 @@ class UnoObjectDefinition{ } return sReturn; } - - + + public String getMethodTerminationSourceCode(){ String sReturn = ""; int nIndex = 1; @@ -1063,7 +1063,7 @@ class UnoObjectDefinition{ sReturn += "\n}"; return sReturn; } - + public String castLiteral(String _sExpression, TypeClass _aTypeClass){ String sReturn = ""; switch (_aTypeClass.getValue()){ @@ -1074,7 +1074,7 @@ class UnoObjectDefinition{ sReturn = "(byte) " + _sExpression; break; case TypeClass.CHAR_value: - sReturn = "'" + _sExpression + "'"; + sReturn = "'" + _sExpression + "'"; break; case TypeClass.DOUBLE_value: sReturn = "(double) " + _sExpression; @@ -1097,56 +1097,56 @@ class UnoObjectDefinition{ sReturn = _sExpression; break; case TypeClass.ENUM_value: - default: - sReturn = _sExpression; + default: + sReturn = _sExpression; System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'castliteral()'"); - } + } return sReturn; } - - + + public String getbooleanTypeDescription(){ - return "boolean"; + return "boolean"; } public String getbyteTypeDescription(){ - return "byte"; + return "byte"; } public String getshortTypeDescription(){ - return "short"; + return "short"; } public String getunsignedshortTypeDescription(){ - return "short"; + return "short"; } public String getlongTypeDescription(){ - return "int"; + return "int"; } public String getunsignedlongTypeDescription(){ - return "int"; + return "int"; } public String gethyperTypeDescription(){ - return "long"; + return "long"; } public String getunsignedhyperTypeDescription(){ - return "long"; + return "long"; } public String getfloatTypeDescription(){ - return "float"; + return "float"; } public String getdoubleTypeDescription(){ - return "double"; + return "double"; } public String getcharTypeDescription(){ - return "char"; + return "char"; } public String getstringTypeDescription(boolean _bAsHeaderSourceCode){ @@ -1154,7 +1154,7 @@ class UnoObjectDefinition{ return ""; } else{ - return "String"; + return "String"; } } @@ -1175,13 +1175,13 @@ class UnoObjectDefinition{ return "Object"; } } - - + + public String getStringValue(String _sValue){ return _sValue; } - - + + public String getVariableDeclaration(String _sTypeString, String _sVariableName, boolean _bIsArray, TypeClass _aTypeClass, boolean _bInitialize){ String sReturn = ""; if (_bIsArray){ @@ -1192,8 +1192,8 @@ class UnoObjectDefinition{ } return sReturn; } - - + + public String getArrayDeclaration(String _sVariableDeclaration){ String sReturn = ""; String[] sDeclarations = _sVariableDeclaration.split(" "); @@ -1208,28 +1208,28 @@ class UnoObjectDefinition{ } return sReturn; } - + public String getCommentSign(){ return "//"; } - } - - + } + + public class BasicCodeGenerator implements XLanguageSourceCodeGenerator{ String sStatementsCode = ""; - + public BasicCodeGenerator(){ } - + public String getHeaderSourceCode(Object _oUnoObject, String _sClassName, TypeClass _aTypeClass){ String sHeaderStatement = ""; return sHeaderStatement; } - + public String getFinalHeaderStatements(){ return ""; } - + public String getMainMethodSignatureSourceCode(XUnoNode _oUnoNode, String _soReturnObjectDescription){ //TODO try to use + _oUnoNode.getClassName() instead of the hack return "Sub Main(" + _soReturnObjectDescription + " as " + getanyTypeDescription(false) + ")"; @@ -1241,41 +1241,41 @@ class UnoObjectDefinition{ public void assignqueryInterfaceHeaderSourceCode(){ } - + public String getMethodSeparator(){ return "."; - } - - + } + + public String getqueryInterfaceSourceCode(String _sClassName, String _sReturnVariableName, String _sIncomingObjectName){ return _sIncomingObjectName; } - + public String getPropertyValueGetterSourceCode(String _sPropertyName, String _sReturnVariableName, String _sIncomingObjectName, TypeClass _aTypeClass, String _sTypeName){ return "\t" + _sReturnVariableName + " = " + _sIncomingObjectName + "." + _sPropertyName; } - - - public String getStructSourceCode(String _sReturnVariableDescription, String _sObjectDescription, String _sMember){ + + + public String getStructSourceCode(String _sReturnVariableDescription, String _sObjectDescription, String _sMember){ return getPropertyValueGetterSourceCode(_sMember, _sReturnVariableDescription, _sObjectDescription, null, "" ); - } + } public String getConvertedSourceCodeValueOfObject(String _sReturnVariableName, String _sObjectDescription, TypeClass _aTypeClass, String _sTypeName){ - return _sReturnVariableName + " = " + _sObjectDescription; + return _sReturnVariableName + " = " + _sObjectDescription; } - + public String getObjectTypeDescription(String _sClassName, boolean _bAsHeader){ return "Object"; } - - + + public String getMethodTerminationSourceCode(){ - return "\nEnd Sub\n"; + return "\nEnd Sub\n"; } - + public String castLiteral(String _sExpression, TypeClass _aTypeClass){ String sReturn = ""; switch (_aTypeClass.getValue()){ @@ -1296,57 +1296,57 @@ class UnoObjectDefinition{ sReturn = "\"" +_sExpression + "\""; break; case TypeClass.ENUM_value: - default: - sReturn = _sExpression; + default: + sReturn = _sExpression; System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'castliteral()'"); - } + } return sReturn; - } - - - + } + + + public String getbooleanTypeDescription(){ - return "Boolean"; + return "Boolean"; } public String getbyteTypeDescription(){ - return "Integer"; + return "Integer"; } public String getshortTypeDescription(){ - return "Integer"; + return "Integer"; } public String getunsignedshortTypeDescription(){ - return "Integer"; + return "Integer"; } public String getlongTypeDescription(){ - return "Integer"; + return "Integer"; } public String getunsignedlongTypeDescription(){ - return "Long"; + return "Long"; } public String gethyperTypeDescription(){ - return "Long"; + return "Long"; } public String getunsignedhyperTypeDescription(){ - return "Long"; + return "Long"; } public String getfloatTypeDescription(){ - return "Double"; + return "Double"; } public String getdoubleTypeDescription(){ - return "Double"; + return "Double"; } public String getcharTypeDescription(){ - return "String"; + return "String"; } public String getstringTypeDescription(boolean _bAsHeaderSourceCode){ @@ -1354,7 +1354,7 @@ class UnoObjectDefinition{ return ""; } else{ - return "String"; + return "String"; } } @@ -1375,12 +1375,12 @@ class UnoObjectDefinition{ return "Object"; } } - + public String getStatementTerminationCharacter(){ return ""; } - - + + public String getVariableDeclaration(String _sTypeString, String _sVariableName, boolean bIsArray, TypeClass _aTypeClass, boolean _bInitialize){ String sReturn = ""; if (bIsArray){ @@ -1392,12 +1392,12 @@ class UnoObjectDefinition{ return sReturn; } - + public String getStringValue(String _sValue){ return _sValue; } - - + + public String getArrayDeclaration(String _sVariableDeclaration){ String sReturn = ""; String[] sDeclarations = _sVariableDeclaration.split(" "); @@ -1416,37 +1416,37 @@ class UnoObjectDefinition{ public String getCommentSign(){ return "'"; } - - } + + } public class CPlusPlusCodeGenerator implements XLanguageSourceCodeGenerator{ String sStatementsCode = ""; boolean bIncludeStringHeader = false; boolean bIncludeAny = false; boolean bIncludeSequenceHeader = false; - + public CPlusPlusCodeGenerator(){ } - + private String getCSSNameSpaceString(){ return "css"; } - + public String getStatementTerminationCharacter(){ return ";"; } - - + + public String getHeaderSourceCode(Object _oUnoObject, String _sClassName, TypeClass _aTypeClass){ String sClassName = _sClassName; String sHeaderStatement = ""; if (_oUnoObject != null){ - if (!m_oIntrospector.isObjectPrimitive(_oUnoObject)){ + if (!m_oIntrospector.isObjectPrimitive(_oUnoObject)){ if (m_oIntrospector.isObjectSequence(_oUnoObject)){ XTypeDescription xTypeDescription = m_oIntrospector.getReferencedType(sClassName); if (xTypeDescription != null){ if (!m_oIntrospector.isPrimitive(xTypeDescription.getTypeClass())){ - sClassName = getTypeString(xTypeDescription.getName(), xTypeDescription.getTypeClass(), true); + sClassName = getTypeString(xTypeDescription.getName(), xTypeDescription.getTypeClass(), true); } // primitive Types are not supposed to turn up in the import section... else{ @@ -1465,22 +1465,22 @@ class UnoObjectDefinition{ return sHeaderStatement; } - - + + public String getFinalHeaderStatements(){ String sReturn = ""; sReturn += "\nnamespace " + getCSSNameSpaceString() + " = com::sun::star;\n"; sReturn += "using namespace rtl;\n"; return sReturn; } - - + + private String getHeaderOfClass(String _sClassName){ return "#include \"" + _sClassName.replace('.', '/') + ".hpp\"\n"; // #include <com/sun/star/uno/XComponentContext.hpp> } + - - + public void assignqueryInterfaceHeaderSourceCode(){ sHeaderStatements.add("#include \"sal/config.h\"\n"); sHeaderStatements.add("#include \"sal/types.h\"\n"); @@ -1496,8 +1496,8 @@ class UnoObjectDefinition{ sHeaderStatements.add(getHeaderOfClass("com.sun.star.uno.Any")); } } - - + + public String getMainMethodSignatureSourceCode(XUnoNode _oUnoNode, String _soReturnObjectDescription){ String sReturn = ""; sReturn = "void codesnippet(const " + getCSSNameSpaceString() + "::uno::Reference<" + getCSSNameSpaceString() + "::uno::XInterface>& " + _soReturnObjectDescription + " ){"; @@ -1514,10 +1514,10 @@ class UnoObjectDefinition{ sReturn += ", "; } sReturn += getObjectTypeDescription(sCurException, false); - + } } - + } sReturn += "{"; return sReturn; @@ -1527,13 +1527,13 @@ class UnoObjectDefinition{ public boolean needsqueryInterface(){ return true; } - - + + public String getqueryInterfaceSourceCode(String _sClassName, String _sReturnVariableName, String _sIncomingObjectName){ return "\t" + _sReturnVariableName + "( " + _sIncomingObjectName + ", " + getCSSNameSpaceString() + "::uno::UNO_QUERY_THROW);\n"; } - - + + public String getPropertyValueGetterSourceCode(String _sPropertyName, String _sReturnVariableName, String _sIncomingObjectName, TypeClass _aTypeClass, String _sTypeName){ String sFirstLine = "\t"; String sReturnVariableName = _sReturnVariableName; @@ -1552,12 +1552,12 @@ class UnoObjectDefinition{ return sFirstLine + sSecondLine; } - - public String getStructSourceCode(String _sReturnVariableDescription, String _sObjectDescription, String _sMember){ + + public String getStructSourceCode(String _sReturnVariableDescription, String _sObjectDescription, String _sMember){ return "\t" + _sReturnVariableDescription + " = " + _sObjectDescription + "->" + _sMember + ";"; } - - + + public String getConvertedSourceCodeValueOfObject(String _sReturnVariableName, String _sObjectDescription, TypeClass _aTypeClass, String _sTypeName){ // if (m_oIntrospector.isPrimitive(_aTypeClass)){ return _sObjectDescription + " >>= " + _sReturnVariableName; @@ -1565,15 +1565,15 @@ class UnoObjectDefinition{ // else{ // return _sReturnVariableName + " = " + _sObjectDescription; // } - } - - + } + + public String getStringValue(String _sValue){ bIncludeStringHeader = true; return "OUString(RTL_CONSTASCII_USTRINGPARAM(\"" + _sValue + "\"))"; } - - + + public String getObjectTypeDescription(String _sClassName, boolean _bAsHeader){ String sReturn = ""; if (_bAsHeader){ @@ -1586,17 +1586,17 @@ class UnoObjectDefinition{ } return sReturn; } - - + + public String getMethodTerminationSourceCode(){ - return "\n}"; + return "\n}"; } - + public String getMethodSeparator(){ return "->"; - } - - + } + + public String castLiteral(String _sExpression, TypeClass _aTypeClass){ String sReturn = ""; switch (_aTypeClass.getValue()){ @@ -1619,55 +1619,55 @@ class UnoObjectDefinition{ sReturn = getStringValue(_sExpression); break; case TypeClass.ENUM_value: - default: - sReturn = _sExpression; + default: + sReturn = _sExpression; System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'castliteral()'"); - } + } return sReturn; - } - + } + public String getbooleanTypeDescription(){ - return "sal_Bool"; + return "sal_Bool"; } public String getbyteTypeDescription(){ - return "sal_Int8"; + return "sal_Int8"; } public String getshortTypeDescription(){ - return "sal_Int16"; + return "sal_Int16"; } public String getunsignedshortTypeDescription(){ - return "sal_uInt16"; + return "sal_uInt16"; } public String getlongTypeDescription(){ - return "sal_Int32"; + return "sal_Int32"; } public String getunsignedlongTypeDescription(){ - return "sal_uInt32"; + return "sal_uInt32"; } public String gethyperTypeDescription(){ - return "sal_Int64"; + return "sal_Int64"; } public String getunsignedhyperTypeDescription(){ - return "sal_uInt64"; + return "sal_uInt64"; } public String getfloatTypeDescription(){ - return "float"; + return "float"; } public String getdoubleTypeDescription(){ - return "double"; + return "double"; } public String getcharTypeDescription(){ - return "sal_Unicode"; + return "sal_Unicode"; } public String getstringTypeDescription(boolean _bAsHeaderSourceCode){ @@ -1676,7 +1676,7 @@ class UnoObjectDefinition{ return ""; } else{ - return "OUString"; + return "OUString"; } } @@ -1685,7 +1685,7 @@ class UnoObjectDefinition{ return "com/sun/star/uno/Type"; } else{ - return "Type"; + return "Type"; } } @@ -1697,8 +1697,8 @@ class UnoObjectDefinition{ return "XInterface"; } } - - + + public String getVariableDeclaration(String _sTypeString, String _sVariableName, boolean bIsArray, TypeClass _aTypeClass, boolean _bInitialize){ boolean bIsPrimitive = m_oIntrospector.isPrimitive(_aTypeClass); @@ -1706,7 +1706,7 @@ class UnoObjectDefinition{ String sReturn = ""; if (bIsArray){ bIncludeSequenceHeader = true; - sReturn = getCSSNameSpaceString() + "::uno::Sequence<" + _sTypeString + "> " + _sVariableName; + sReturn = getCSSNameSpaceString() + "::uno::Sequence<" + _sTypeString + "> " + _sVariableName; } else{ if (bIsPrimitive){ @@ -1735,10 +1735,10 @@ class UnoObjectDefinition{ case TypeClass.STRING_value: sReturn = _sTypeString + " " + _sVariableName; break; - default: + default: sReturn = _sTypeString + " " + _sVariableName; System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'getVariableDeclaration()'"); - } + } } } else{ @@ -1747,20 +1747,20 @@ class UnoObjectDefinition{ } return sReturn; } - + public String getArrayDeclaration(String _sVariableDeclaration){ this.bIncludeSequenceHeader = true; String sReturn = ""; String[] sDeclarations = _sVariableDeclaration.split(" "); if (sDeclarations.length == 2){ - sReturn = getCSSNameSpaceString() +"::uno::Sequence<" + sDeclarations[1] + ">"; + sReturn = getCSSNameSpaceString() +"::uno::Sequence<" + sDeclarations[1] + ">"; } return sReturn; } - + public String getCommentSign(){ return "//"; } - - } + + } } diff --git a/odk/examples/java/Inspector/SwingDialogProvider.java b/odk/examples/java/Inspector/SwingDialogProvider.java index 59a35726e11e..7b85070c2491 100644 --- a/odk/examples/java/Inspector/SwingDialogProvider.java +++ b/odk/examples/java/Inspector/SwingDialogProvider.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.uno.XComponentContext; @@ -64,8 +64,8 @@ public class SwingDialogProvider implements XDialogProvider{ private Inspector._Inspector m_oInspector; private JDialog m_jInspectorDialog = new JDialog(); private JTabbedPane m_jTabbedPane1 = new JTabbedPane(); - private Container cp; - + private Container cp; + private JMenu jMnuOptions = new JMenu("Options"); private JRadioButtonMenuItem jJavaMenuItem = null; private JRadioButtonMenuItem jCPlusPlusMenuItem = null; @@ -74,31 +74,31 @@ public class SwingDialogProvider implements XDialogProvider{ /** Creates a new instance of SwingPopupMentuProvider */ public SwingDialogProvider(Inspector._Inspector _oInspector, String _sTitle) { m_oInspector = _oInspector; - m_xComponentContext = _oInspector.getXComponentContext(); - insertMenus(); - initializePopupMenu(); + m_xComponentContext = _oInspector.getXComponentContext(); + insertMenus(); + initializePopupMenu(); cp = m_jInspectorDialog.getContentPane(); cp.setLayout(new java.awt.BorderLayout(0, 10)); - m_jTabbedPane1.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); + m_jTabbedPane1.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); m_jInspectorDialog.addWindowListener(new InspectorWindowAdapter()); m_jInspectorDialog.addComponentListener(new InspectorComponentAdapter()); m_jInspectorDialog.setTitle(_sTitle); m_jInspectorDialog.setLocation(100, 50); - m_jInspectorDialog.getContentPane().add(m_jTabbedPane1); + m_jInspectorDialog.getContentPane().add(m_jTabbedPane1); } - - - + + + public JDialog getDialog(){ return m_jInspectorDialog; } - + public void addMenuBar(JMenuBar _jMenuBar){ - getDialog().setJMenuBar(_jMenuBar); + getDialog().setJMenuBar(_jMenuBar); } - - + + public void removeTabPaneByIndex(int _nIndex){ if (_nIndex > -1){ String sSelInspectorPanelTitle = m_jTabbedPane1.getTitleAt(_nIndex); @@ -107,28 +107,28 @@ public class SwingDialogProvider implements XDialogProvider{ } } - + public void selectInspectorPageByIndex(int nTabIndex){ m_jTabbedPane1.setSelectedIndex(nTabIndex); } - - + + public int getInspectorPageCount(){ return m_jTabbedPane1.getTabCount(); } - - + + public JTabbedPane getTabbedPane(){ return m_jTabbedPane1; } - - + + public InspectorPane getSelectedInspectorPage(){ int nIndex = m_jTabbedPane1.getSelectedIndex(); return getInspectorPage(nIndex); } - - + + public InspectorPane getInspectorPage(int _nIndex){ InspectorPane oInspectorPane = null; if (_nIndex > -1){ @@ -138,8 +138,8 @@ public class SwingDialogProvider implements XDialogProvider{ } return oInspectorPane; } - - + + public void removeTabPanes(){ int nCount = m_jTabbedPane1.getTabCount(); if (nCount > 0){ @@ -148,13 +148,13 @@ public class SwingDialogProvider implements XDialogProvider{ } } } - + public void removeSelectedTabPane(){ int nIndex = getTabbedPane().getSelectedIndex(); removeTabPaneByIndex(nIndex); } - - + + private class InspectorComponentAdapter extends ComponentAdapter{ public void componentHidden(ComponentEvent e){ m_jInspectorDialog.pack(); @@ -165,23 +165,23 @@ public class SwingDialogProvider implements XDialogProvider{ public void componentShown(ComponentEvent e){ m_jInspectorDialog.pack(); m_jInspectorDialog.invalidate(); - } + } } - + private class InspectorWindowAdapter extends WindowAdapter{ public void windowClosed(WindowEvent e){ removeTabPanes(); m_oInspector.disposeHiddenDocuments(); } - + public void windowClosing(WindowEvent e){ removeTabPanes(); m_oInspector.disposeHiddenDocuments(); } - } - - - + } + + + private void initializePopupMenu(){ m_jPopupMenu.add(getInspectMenuItem("Inspect")); m_jPopupMenu.add(getSourceCodeMenuItem(SADDTOSOURCECODE)); @@ -189,8 +189,8 @@ public class SwingDialogProvider implements XDialogProvider{ m_jPopupMenu.addSeparator(); m_jPopupMenu.add(getHelpMenuItem("Help")); } - - + + private void addOpenDocumentMenu(JMenu _jMnuRoot){ ActionListener oActionListener = new ActionListener(){ public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -215,7 +215,7 @@ public class SwingDialogProvider implements XDialogProvider{ }; String[][] sApplUrls = m_oInspector.getApplicationUrls(); for (int i = 0; i < sApplUrls.length; i++){ - addSingleMenuItem(_jMnuRoot, sApplUrls[i][1], sApplUrls[i][0], oActionListener); + addSingleMenuItem(_jMnuRoot, sApplUrls[i][1], sApplUrls[i][0], oActionListener); } } @@ -226,14 +226,14 @@ public class SwingDialogProvider implements XDialogProvider{ jMnuItemOpenDoc.addActionListener(_oActionListener); _jMnuOpenDocs.add(jMnuItemOpenDoc); } - - + + private void addHelpMenu(JMenuBar _jInspectMenuBar){ JMenu jMnuHelp = new JMenu("Help"); jMnuHelp.add(getHelpMenuItem("Idl-Help")); _jInspectMenuBar.add(jMnuHelp); } - + private JMenuItem getHelpMenuItem(String _sMenuTitle){ JMenuItem jMnuHelpItem = new JMenuItem(_sMenuTitle); @@ -241,31 +241,31 @@ public class SwingDialogProvider implements XDialogProvider{ jMnuHelpItem.setMnemonic('H'); jMnuHelpItem.addActionListener(new ActionListener(){ public void actionPerformed(java.awt.event.ActionEvent evt) { - m_oInspector.openIdlFileforSelectedNode(); + m_oInspector.openIdlFileforSelectedNode(); } - }); + }); return jMnuHelpItem; } - + private void addFileMenu(JMenuBar _jInspectMenuBar){ JMenu jMnuFile = new JMenu("File"); - JMenuItem jMnuItemRemoveInspector = new JMenuItem("Remove"); + JMenuItem jMnuItemRemoveInspector = new JMenuItem("Remove"); jMnuItemRemoveInspector.addActionListener(new ActionListener(){ public void actionPerformed(java.awt.event.ActionEvent evt) { removeSelectedTabPane(); } }); jMnuFile.add(jMnuItemRemoveInspector); - JMenuItem jMnuItemExit = new JMenuItem("Exit"); + JMenuItem jMnuItemExit = new JMenuItem("Exit"); jMnuItemExit.addActionListener(new ActionListener(){ public void actionPerformed(java.awt.event.ActionEvent evt) { getDialog().dispose(); } - }); - jMnuFile.add(jMnuItemExit); + }); + jMnuFile.add(jMnuItemExit); _jInspectMenuBar.add(jMnuFile); } - + private JMenuItem getInspectMenuItem(String _sLabel){ JMenuItem jMnuSelectedObject = new JMenuItem(_sLabel); jMnuSelectedObject.addActionListener(new ActionListener(){ @@ -275,8 +275,8 @@ public class SwingDialogProvider implements XDialogProvider{ }); return jMnuSelectedObject; } - - + + private JMenuItem getSourceCodeMenuItem(String _sLabel){ JMenuItem jMnuSelectedObject = new JMenuItem(_sLabel); jMnuSelectedObject.addActionListener(new ActionListener(){ @@ -286,7 +286,7 @@ public class SwingDialogProvider implements XDialogProvider{ }); return jMnuSelectedObject; } - + private JMenuItem getInvokeMenuItem(String _sLabel){ JMenuItem jMnuSelectedObject = new JMenuItem(_sLabel); jMnuSelectedObject.addActionListener(new ActionListener(){ @@ -296,25 +296,25 @@ public class SwingDialogProvider implements XDialogProvider{ }); return jMnuSelectedObject; } - - + + private void addInspectMenu(JMenuBar _jInspectMenuBar){ JMenu jMnuInspect = new JMenu("Inspect"); addApplicationDocumentMenu(jMnuInspect); jMnuInspect.addSeparator(); addGlobalServiceManagerMenu(jMnuInspect); jMnuInspect.addSeparator(); - jMnuInspect.add(getInspectMenuItem("Selected Object")); + jMnuInspect.add(getInspectMenuItem("Selected Object")); jMnuInspect.addSeparator(); - addOpenDocumentMenu(jMnuInspect); - _jInspectMenuBar.add(jMnuInspect); + addOpenDocumentMenu(jMnuInspect); + _jInspectMenuBar.add(jMnuInspect); } public int getLanguage(){ return XLanguageSourceCodeGenerator.nJAVA; } - - + + public void selectSourceCodeLanguage(int _nLanguage){ switch (_nLanguage){ case XLanguageSourceCodeGenerator.nJAVA: @@ -332,7 +332,7 @@ public class SwingDialogProvider implements XDialogProvider{ } private JRadioButtonMenuItem addLanguageMenuItem(ButtonGroup _group, String _sLanguageTitle, boolean _bSelect, char _sMnemonic, final int _nLanguage){ - JRadioButtonMenuItem jMenuItem = new JRadioButtonMenuItem(_sLanguageTitle, _bSelect); + JRadioButtonMenuItem jMenuItem = new JRadioButtonMenuItem(_sLanguageTitle, _bSelect); jMenuItem.setMnemonic(_sMnemonic); _group.add(jMenuItem); jMenuItem.addActionListener(new ActionListener(){ @@ -342,19 +342,19 @@ public class SwingDialogProvider implements XDialogProvider{ }); return jMenuItem; } - - + + public String getIDLPath(){ return this.m_oInspector.getIDLPath(); } - + private void addOptionsMenu(JMenuBar _jInspectMenuBar){ ButtonGroup oButtonGroup = new ButtonGroup(); jJavaMenuItem = addLanguageMenuItem(oButtonGroup, "Generate Java Sourcecode", true, 'J', XLanguageSourceCodeGenerator.nJAVA); jMnuOptions.add(jJavaMenuItem); jCPlusPlusMenuItem = addLanguageMenuItem(oButtonGroup, "Generate C++ Sourcecode", false, 'C', XLanguageSourceCodeGenerator.nCPLUSPLUS); jMnuOptions.add(jCPlusPlusMenuItem); - jBasicMenuItem = addLanguageMenuItem(oButtonGroup, "Generate OpenOffice.org Basic Sourcecode", false, 'B', XLanguageSourceCodeGenerator.nBASIC); + jBasicMenuItem = addLanguageMenuItem(oButtonGroup, "Generate OpenOffice.org Basic Sourcecode", false, 'B', XLanguageSourceCodeGenerator.nBASIC); jMnuOptions.add(jBasicMenuItem); jMnuOptions.addSeparator(); JMenuItem jMenuItem = new JMenuItem("Path to SDK-Installation"); @@ -364,12 +364,12 @@ public class SwingDialogProvider implements XDialogProvider{ m_oInspector.assignSDKPath(); } }); - + jMnuOptions.add(jMenuItem); - _jInspectMenuBar.add(jMnuOptions); + _jInspectMenuBar.add(jMnuOptions); } - - + + private void insertMenus(){ JMenuBar jMenuBar1 = new javax.swing.JMenuBar(); addFileMenu(jMenuBar1); @@ -380,10 +380,10 @@ public class SwingDialogProvider implements XDialogProvider{ jMenuBar1.setFont(new java.awt.Font("Dialog", 0, 12)); jMenuBar1.add(jMnuEdit); jMenuBar1.add(jMnuView); - addHelpMenu(jMenuBar1); + addHelpMenu(jMenuBar1); addMenuBar(jMenuBar1); } - + private void addGlobalServiceManagerMenu(JMenu _jMnuRoot){ JMenuItem jMnuGlobalServiceManager = new JMenuItem("Global Service Manager"); jMnuGlobalServiceManager.addActionListener(new ActionListener(){ @@ -394,8 +394,8 @@ public class SwingDialogProvider implements XDialogProvider{ _jMnuRoot.add(jMnuGlobalServiceManager); } - - + + public void enablePopupMenuItem(String _sMenuTitle, boolean _bdoEnable){ Component[] oComponents = m_jPopupMenu.getComponents(); for (int i = 0; i < oComponents.length; i++){ @@ -414,8 +414,8 @@ public class SwingDialogProvider implements XDialogProvider{ m_jPopupMenu.show((Component) _invoker, x, y); } } - - + + public void show(int _nPageIndex){ Dimension aDimension = m_jInspectorDialog.getSize(); selectInspectorPageByIndex(_nPageIndex); @@ -430,13 +430,13 @@ public class SwingDialogProvider implements XDialogProvider{ } public void paint(){ - m_jTabbedPane1.paintImmediately(m_jTabbedPane1.getBounds()); + m_jTabbedPane1.paintImmediately(m_jTabbedPane1.getBounds()); } - + public void addInspectorPage(String _sTitle, Object _oContainer) throws ClassCastException{ if (_oContainer instanceof Component){ m_jTabbedPane1.addTab(_sTitle, (Component) _oContainer); } - } + } } diff --git a/odk/examples/java/Inspector/SwingTreeControlProvider.java b/odk/examples/java/Inspector/SwingTreeControlProvider.java index 2405e8bc36ce..bf00acd77d0b 100644 --- a/odk/examples/java/Inspector/SwingTreeControlProvider.java +++ b/odk/examples/java/Inspector/SwingTreeControlProvider.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.beans.Property; @@ -75,27 +75,27 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ private JLabel jLblPath = new JLabel("Generated source code"); private JProgressBar jProgressBar1 = new JProgressBar(); private JTree jTree = new javax.swing.JTree(); - private XDialogProvider m_xDialogProvider; + private XDialogProvider m_xDialogProvider; private HideableTreeModel treeModel; private UnoTreeRenderer oUnoTreeRenderer; private InspectorPane m_oInspectorPane; private Object oUserDefinedObject = null; private boolean bIsUserDefined = false; private SwingUnoNode oRootNode; - + private final int nDIALOGWIDTH = 800; - - - + + + public SwingTreeControlProvider(XDialogProvider _xDialogProvider){ - m_xDialogProvider = _xDialogProvider; + m_xDialogProvider = _xDialogProvider; } - + public void addInspectorPane(InspectorPane _oInspectorPane){ m_oInspectorPane = _oInspectorPane; } - + public InspectorPane getInspectorPane() throws NullPointerException{ if (m_oInspectorPane == null){ throw new NullPointerException("InspectorPage has not been added to TreeControl"); @@ -104,21 +104,21 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ return m_oInspectorPane; } } - + private void ComponentSelector(Object _oRootObject, String _sRootTreeNodeName) { String sTreeNodeName = _sRootTreeNodeName; oRootNode = new SwingUnoNode(_oRootObject); oRootNode.setLabel(_sRootTreeNodeName); treeModel = new HideableTreeModel(oRootNode); jTree.setModel(treeModel); - jTree.setRootVisible(true); + jTree.setRootVisible(true); jTree.setVisible(true); oRootNode.setFoldable(true); enableFilterElements(null); } - - + + private void insertTopPanel(JPanel _jPnlCenter){ javax.swing.JPanel jPnlTop = new javax.swing.JPanel(new BorderLayout(10, 10)); jPnlTop.setPreferredSize(new java.awt.Dimension(nDIALOGWIDTH, 20)); @@ -129,10 +129,10 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ jtxtFilter.setPreferredSize(new java.awt.Dimension(200, 10)); jtxtFilter.addKeyListener(new InspectorKeyFilterAdapter()); jPnlTop.add(jtxtFilter, java.awt.BorderLayout.CENTER); - _jPnlCenter.add(jPnlTop, java.awt.BorderLayout.NORTH); + _jPnlCenter.add(jPnlTop, java.awt.BorderLayout.NORTH); } - - + + private void insertBottomPanel(JSplitPane _jSplitPane){ //JPanel _jPnlCenter){ jtxtGeneratedSourceCode.setTabSize(4); jtxtGeneratedSourceCode.getAccessibleContext().setAccessibleName("generated SourceCode"); @@ -141,7 +141,7 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ jtxtGeneratedSourceCode.setEditable(false); _jSplitPane.setBottomComponent(jScrollPane); } - + private void insertBorderPanes(Container _cp){ JPanel jPnlEast = new JPanel(new BorderLayout()); JPanel jPnlNorth = new JPanel(new BorderLayout()); @@ -154,9 +154,9 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ _cp.add(jPnlEast, java.awt.BorderLayout.EAST); jPnlSouth.setPreferredSize(new java.awt.Dimension(10, 10)); _cp.add(jPnlSouth, java.awt.BorderLayout.SOUTH); - } - - + } + + public String enableFilterElements(XUnoNode _oUnoNode){ String sFilter =""; boolean bIsFacetteNode = isFacetteNode(_oUnoNode); @@ -166,8 +166,8 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ jtxtFilter.setText(sFilter); return sFilter; } - - + + private class InspectorKeyFilterAdapter extends KeyAdapter{ public void keyReleased(KeyEvent e){ String sFilter = jtxtFilter.getText(); @@ -178,16 +178,16 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ } } } - - - + + + /** Inspect the given object for methods, properties, interfaces, and * services. * @param a The object to inspect * @throws RuntimeException If */ public Object inspect(java.lang.Object _oUserDefinedObject, String _sTitle) throws com.sun.star.uno.RuntimeException { - JPanel jPnlContainer = new javax.swing.JPanel(new BorderLayout(10, 10)); + JPanel jPnlContainer = new javax.swing.JPanel(new BorderLayout(10, 10)); try { javax.swing.JPanel jPnlCenter = new javax.swing.JPanel(); bIsUserDefined = (_oUserDefinedObject != null); @@ -197,7 +197,7 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ } javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane(); TreeSelectionModel tsm = new DefaultTreeSelectionModel(); - tsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + tsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); jTree.setSelectionModel(tsm); jTree.setVisible(false); jPnlCenter.setLayout(new java.awt.BorderLayout(10, 10)); @@ -206,15 +206,15 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ jScrollPane1.setViewportView(jTree); jScrollPane1.setPreferredSize(new java.awt.Dimension(600, 600)); jScrollPane1.getAccessibleContext().setAccessibleName("API view scroll pane"); - + JScrollBar jHScrollBar = jScrollPane1.createHorizontalScrollBar(); jHScrollBar.getAccessibleContext().setAccessibleName("API view horizontal scroll bar"); jScrollPane1.setHorizontalScrollBar(jHScrollBar); - + JScrollBar jVScrollBar = jScrollPane1.createVerticalScrollBar(); jVScrollBar.getAccessibleContext().setAccessibleName("API view vertical scroll bar"); jScrollPane1.setVerticalScrollBar(jVScrollBar); - + JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); jSplitPane.setTopComponent(jScrollPane1); jPnlCenter.add(jSplitPane, java.awt.BorderLayout.CENTER); @@ -251,11 +251,11 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ } //unfortunately under Windows the method "isPopupTrigger" always returns false else if ((e.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) == MouseEvent.BUTTON3_DOWN_MASK){ - m_oInspectorPane.showPopUpMenu(e.getComponent(), e.getX(), e.getY()); + m_oInspectorPane.showPopUpMenu(e.getComponent(), e.getX(), e.getY()); } } }); - jPnlContainer.add(jPnlCenter, java.awt.BorderLayout.CENTER); + jPnlContainer.add(jPnlCenter, java.awt.BorderLayout.CENTER); insertBorderPanes(jPnlContainer); if (this.bIsUserDefined){ ComponentSelector(oUserDefinedObject, m_oInspectorPane.getTitle()); @@ -265,15 +265,15 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ } catch( Exception exception ) { exception.printStackTrace(System.out); - } + } return jPnlContainer; } - + public HideableTreeModel getModel(){ return treeModel; } - - + + public void addTreeExpandListener(){ jTree.addTreeWillExpandListener( new TreeWillExpandListener() { @@ -288,26 +288,26 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ public void treeWillCollapse( javax.swing.event.TreeExpansionEvent evt) throws javax.swing.tree.ExpandVetoException { } }); - } - - + } + + public void setSourceCode(String _sSourceCode){ jtxtGeneratedSourceCode.setText(_sSourceCode); } - - + + public XTreePathProvider getSelectedPath(){ return new SwingTreePathProvider(jTree.getSelectionPath()); } - - + + public void expandPath(XTreePathProvider _xTreePathProvider) throws ClassCastException{ SwingTreePathProvider oSwingTreePathProvider = (SwingTreePathProvider) _xTreePathProvider; jTree.expandPath(oSwingTreePathProvider.getSwingTreePath()); } - - - public XUnoNode getSelectedNode(){ + + + public XUnoNode getSelectedNode(){ XUnoNode oUnoNode = null; TreePath aTreePath = jTree.getSelectionPath(); Object oNode = aTreePath.getLastPathComponent(); @@ -317,27 +317,27 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ return oUnoNode; } - + public void nodeInserted(XUnoNode _oParentNode, XUnoNode _oChildNode, int index) { getModel().nodeInserted(_oParentNode, _oChildNode, _oParentNode.getChildCount()-1); - } - - + } + + public void nodeChanged(XUnoNode _oNode) { getModel().nodeChanged(_oNode); } - - - public boolean setNodeVisible(Object node, boolean v) { + + + public boolean setNodeVisible(Object node, boolean v) { return getModel().setNodeVisible(node, v); - } - + } + public boolean isPropertyNode(XUnoNode _oUnoNode){ return (_oUnoNode instanceof SwingUnoPropertyNode); } - + public boolean isMethodNode(XUnoNode _oUnoNode){ return (_oUnoNode instanceof SwingUnoMethodNode); } @@ -345,19 +345,19 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ public boolean isFacetteNode(XUnoNode _oUnoNode){ return (_oUnoNode instanceof SwingUnoFacetteNode); - } - + } + public XUnoNode addUnoNode(Object _oUnoObject){ return new SwingUnoNode(_oUnoObject); } - - + + public XUnoNode addUnoNode(Object _oUnoObject, Type _aType){ return new SwingUnoNode(_oUnoObject, _aType); } - - + + public XUnoFacetteNode addUnoFacetteNode(XUnoNode _oParentNode, String _sNodeDescription, Object _oUnoObject){ SwingUnoFacetteNode oSwingUnoFacetteNode = new SwingUnoFacetteNode(_oUnoObject); oSwingUnoFacetteNode.setLabel(_sNodeDescription); @@ -367,34 +367,34 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ return oSwingUnoFacetteNode; } - + public XUnoMethodNode addMethodNode(Object _objectElement, XIdlMethod _xIdlMethod){ SwingUnoMethodNode oSwingUnoMethodNode = new SwingUnoMethodNode(_xIdlMethod, _objectElement, m_xDialogProvider); return oSwingUnoMethodNode; } - - + + public XUnoPropertyNode addUnoPropertyNodeWithName(Property _aProperty){ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aProperty); oUnoPropertyNode.setLabel("Name: " + _aProperty.Name); return oUnoPropertyNode; } - + public XUnoPropertyNode addUnoPropertyNodeWithHandle(Property _aProperty){ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aProperty); oUnoPropertyNode.setLabel("Handle: " + _aProperty.Handle); return oUnoPropertyNode; } - + public XUnoPropertyNode addUnoPropertyNodeWithType(Property _aProperty){ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aProperty); oUnoPropertyNode.setLabel("Type: " + _aProperty.Type.getTypeName()); return oUnoPropertyNode; } - - + + public XUnoPropertyNode addUnoPropertyNodeWithAttributesDescription(Property _aProperty){ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aProperty); XConstantTypeDescription[] xPropertyAttributesTypeDescriptions = Introspector.getIntrospector().getFieldsOfConstantGroup("com.sun.star.beans.PropertyAttribute"); @@ -402,22 +402,22 @@ public class SwingTreeControlProvider implements XTreeControlProvider{ oUnoPropertyNode.setLabel(sDisplay); return oUnoPropertyNode; } - - + + public XUnoPropertyNode addUnoPropertyNode(Object _oUnoObject, Property _aProperty){ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aProperty, _oUnoObject, null); oUnoPropertyNode.setPropertyNodeType(XUnoPropertyNode.nPROPERTYSETINFOTYPE); oUnoPropertyNode.setLabel(UnoPropertyNode.getStandardPropertyDescription(_aProperty, null)); return oUnoPropertyNode; } - - + + public XUnoPropertyNode addUnoPropertyNode(Object _oUnoObject, Property _aProperty, Object _oUnoReturnObject){ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aProperty, _oUnoObject, _oUnoReturnObject); oUnoPropertyNode.setLabel(UnoPropertyNode.getStandardPropertyDescription(_aProperty, _oUnoReturnObject)); return oUnoPropertyNode; } - + public XUnoPropertyNode addUnoPropertyNode(Object _oUnoObject, PropertyValue _aPropertyValue, Object _oReturnObject){ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aPropertyValue, _oUnoObject, _oReturnObject); diff --git a/odk/examples/java/Inspector/SwingTreePathProvider.java b/odk/examples/java/Inspector/SwingTreePathProvider.java index 02829682bc50..37376c269b42 100644 --- a/odk/examples/java/Inspector/SwingTreePathProvider.java +++ b/odk/examples/java/Inspector/SwingTreePathProvider.java @@ -3,37 +3,37 @@ import javax.swing.tree.TreePath; public class SwingTreePathProvider implements XTreePathProvider { TreePath m_aTreePath; - + /** Creates a new instance of TreePathProvider */ public SwingTreePathProvider(TreePath _aTreePath) { m_aTreePath = _aTreePath; } - - + + public XUnoNode getLastPathComponent(){ return (XUnoNode) m_aTreePath.getLastPathComponent(); } - - + + public XUnoNode getPathComponent(int i){ return (XUnoNode) m_aTreePath.getPathComponent(i); } - + public int getPathCount(){ return m_aTreePath.getPathCount(); } - - + + public XTreePathProvider getParentPath(){ return new SwingTreePathProvider(m_aTreePath.getParentPath()); } - - + + public XTreePathProvider pathByAddingChild(XUnoNode _oUnoNode){ TreePath aTreePath = m_aTreePath.pathByAddingChild(_oUnoNode); return new SwingTreePathProvider(aTreePath); } - + public TreePath getSwingTreePath(){ return m_aTreePath; } diff --git a/odk/examples/java/Inspector/SwingUnoFacetteNode.java b/odk/examples/java/Inspector/SwingUnoFacetteNode.java index 96374f1e5b9e..1fbc0f1acb93 100644 --- a/odk/examples/java/Inspector/SwingUnoFacetteNode.java +++ b/odk/examples/java/Inspector/SwingUnoFacetteNode.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.reflection.XIdlMethod; @@ -38,27 +38,27 @@ import com.sun.star.uno.XComponentContext; import javax.swing.tree.DefaultMutableTreeNode; public class SwingUnoFacetteNode extends SwingUnoNode implements XUnoFacetteNode{ - String m_sFilter = ""; - + String m_sFilter = ""; + /** Creates a new instance of UnoMethodNode */ public SwingUnoFacetteNode(Object _oUnoObject){ super(_oUnoObject); setFoldable(true); } - - + + public String getFilter(){ return m_sFilter; } - + public void setFilter(String _sFilter){ m_sFilter = _sFilter; } - + public String getName(){ return toString(); } - + // TODO The implementation of the following methods is not really robust and should be changed!!! public boolean isMethodNode(){ return ((String) getUserObject()).equals(SMETHODDESCRIPTION); @@ -76,7 +76,7 @@ public class SwingUnoFacetteNode extends SwingUnoNode implements XUnoFacetteNode public boolean isServiceNode(){ return ((String) getUserObject()).equals(SSERVICEDESCRIPTION); } - + public boolean isInterfaceNode(){ return ((String) getUserObject()).equals(SINTERFACEDESCRIPTION); } diff --git a/odk/examples/java/Inspector/SwingUnoMethodNode.java b/odk/examples/java/Inspector/SwingUnoMethodNode.java index c01c6074b795..3487d430dfb5 100644 --- a/odk/examples/java/Inspector/SwingUnoMethodNode.java +++ b/odk/examples/java/Inspector/SwingUnoMethodNode.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.reflection.XIdlMethod; import com.sun.star.uno.TypeClass; @@ -43,9 +43,9 @@ public class SwingUnoMethodNode extends SwingUnoNode implements ActionListener, private UnoMethodNode m_oUnoMethodNode; private XDialogProvider m_xDialogProvider = null; - + public SwingUnoMethodNode(XIdlMethod _xIdlMethod, Object _oUnoObject, XDialogProvider _xDialogProvider) { - super(_oUnoObject); + super(_oUnoObject); m_oUnoMethodNode = new UnoMethodNode(_xIdlMethod, _oUnoObject, this); m_xDialogProvider = _xDialogProvider; setUserObject(m_oUnoMethodNode.getNodeDescription()); @@ -57,11 +57,11 @@ public class SwingUnoMethodNode extends SwingUnoNode implements ActionListener, public boolean isFoldable(){ return m_oUnoMethodNode.isFoldable(); } - + public String getName(){ return m_oUnoMethodNode.getName(); - } - + } + public String getClassName(){ String sClassName = ""; sClassName = getXIdlMethod().getDeclaringClass().getName(); @@ -69,17 +69,17 @@ public class SwingUnoMethodNode extends SwingUnoNode implements ActionListener, sClassName = super.getClassName(); } return sClassName; - } - + } + public String getAnchor(){ return m_oUnoMethodNode.getAnchor(); } - + public Object invoke(Object _oUnoObject, Object[] _oParameters) throws com.sun.star.uno.Exception{ return m_oUnoMethodNode.invoke(_oUnoObject, _oParameters); } - - + + public Object[] getLastParameterObjects(){ return m_oUnoMethodNode.getLastParameterObjects(); } @@ -108,30 +108,30 @@ public class SwingUnoMethodNode extends SwingUnoNode implements ActionListener, return m_oUnoMethodNode.isInvoked(); } - public boolean isInvokable(){ + public boolean isInvokable(){ return m_oUnoMethodNode.isInvokable(); } - + public boolean isPrimitive() { return m_oUnoMethodNode.isPrimitive(); } - + public void actionPerformed(ActionEvent e){ openIdlDescription(m_xDialogProvider.getIDLPath()); } - + public Vector getMethodObjects(){ MethodParametersDialog oMethodParametersDialog = new MethodParametersDialog(this); oMethodParametersDialog.addActionListener(this); - return oMethodParametersDialog.getMethodObjects(); + return oMethodParametersDialog.getMethodObjects(); } - - + + public String getParameterDescription(){ return m_oUnoMethodNode.getParameterDescription(); } - - + + public String getStandardMethodDescription(){ return m_oUnoMethodNode.getStandardMethodDescription(); } diff --git a/odk/examples/java/Inspector/SwingUnoNode.java b/odk/examples/java/Inspector/SwingUnoNode.java index 19295cc4b4d0..14f23e94ad6d 100644 --- a/odk/examples/java/Inspector/SwingUnoNode.java +++ b/odk/examples/java/Inspector/SwingUnoNode.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.uno.Type; import javax.swing.tree.TreeNode; @@ -37,31 +37,31 @@ import javax.swing.tree.TreeNode; public class SwingUnoNode extends HideableMutableTreeNode implements XUnoNode{ private UnoNode m_oUnoNode; - + /** Creates a new instance of SwingUnoNode */ public SwingUnoNode(Object _oUnoObject) { - super(); + super(); m_oUnoNode = new UnoNode(_oUnoObject); } - + public SwingUnoNode(Object _oUnoObject, Type _aType) { super(); - m_oUnoNode = new UnoNode(_oUnoObject, _aType); + m_oUnoNode = new UnoNode(_oUnoObject, _aType); if (_aType != null){ this.setLabel(_aType.getTypeName()); } } - - + + public Object getUnoObject(){ return m_oUnoNode.getUnoObject(); } - + public void setVisible(String _sFilter){ boolean bisVisible = isFilterApplicable(_sFilter); super.setVisible(bisVisible); - } + } public boolean isFilterApplicable(String _sFilter) { return m_oUnoNode.isFilterApplicable(_sFilter, getName()); @@ -91,13 +91,13 @@ public class SwingUnoNode extends HideableMutableTreeNode implements XUnoNode{ } } return sClassName; - } + } public String getAnchor() { return m_oUnoNode.getAnchor(); } - - + + public void setFoldable(boolean _bIsFoldable){ if (_bIsFoldable){ addDummyNode(); @@ -107,16 +107,16 @@ public class SwingUnoNode extends HideableMutableTreeNode implements XUnoNode{ } } - + public XUnoNode getParentNode(){ return (SwingUnoNode) super.getParent(); } - - + + public void addChildNode(XUnoNode _xUnoNode) { super.add((SwingUnoNode) _xUnoNode); } - + public void setLabel(String _sLabel){ super.setUserObject(_sLabel); this.m_oUnoNode.setLabel(_sLabel); @@ -126,30 +126,30 @@ public class SwingUnoNode extends HideableMutableTreeNode implements XUnoNode{ return (String) super.getUserObject(); } - + public int getChildCount(){ return super.getChildCount(); } - - + + public XUnoNode getChild(int _i){ return (SwingUnoNode) super.getChildAt(_i); } - + public int getNodeType(){ return m_oUnoNode.getNodeType(); } - + public void setNodeType(int _nNodeType){ m_oUnoNode.setNodeType(_nNodeType); } - - + + public String getName(){ return getClassName(); } - - + + public Type getUnoType(){ return m_oUnoNode.getUnoType(); } diff --git a/odk/examples/java/Inspector/SwingUnoPropertyNode.java b/odk/examples/java/Inspector/SwingUnoPropertyNode.java index f72229db6f10..34decfec1d1c 100644 --- a/odk/examples/java/Inspector/SwingUnoPropertyNode.java +++ b/odk/examples/java/Inspector/SwingUnoPropertyNode.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,16 +29,16 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.beans.Property; import com.sun.star.beans.PropertyValue; public class SwingUnoPropertyNode extends SwingUnoNode implements XUnoPropertyNode{ - + private UnoPropertyNode m_oUnoPropertyNode = null; - - + + public SwingUnoPropertyNode(Property _aProperty, Object _oUnoObject, Object _oUnoReturnObject) { super(_oUnoObject); m_oUnoPropertyNode = new UnoPropertyNode(_aProperty, _oUnoObject, _oUnoReturnObject); @@ -46,51 +46,51 @@ public class SwingUnoPropertyNode extends SwingUnoNode implements XUnoPropertyNo setFoldable(m_oUnoPropertyNode.isFoldable()); } - + public SwingUnoPropertyNode(Property _aProperty){ super(null); m_oUnoPropertyNode = new UnoPropertyNode(_aProperty); } - - public SwingUnoPropertyNode(PropertyValue _aPropertyValue, Object _oUnoObject, Object _oUnoReturnObject) { + + public SwingUnoPropertyNode(PropertyValue _aPropertyValue, Object _oUnoObject, Object _oUnoReturnObject) { super(_oUnoObject); m_oUnoPropertyNode = new UnoPropertyNode(_aPropertyValue, _oUnoObject, _oUnoReturnObject); } - + public String getName(){ return m_oUnoPropertyNode.getName(); } - - + + public Object getUnoReturnObject(){ return m_oUnoPropertyNode.getUnoReturnObject(); } - + public String getClassName(){ String sClassName = m_oUnoPropertyNode.getClassName(); if (sClassName.equals("")){ sClassName = super.getClassName(); - } + } return sClassName; - } - + } + public String getAnchor(){ return m_oUnoPropertyNode.getAnchor(); } - + public int getPropertyNodeType(){ return m_oUnoPropertyNode.getPropertyNodeType(); } - - + + public void setPropertyNodeType(int _nPropertyType){ m_oUnoPropertyNode.setPropertyNodeType(_nPropertyType); } - + public Property getProperty(){ return m_oUnoPropertyNode.getProperty(); } - + } diff --git a/odk/examples/java/Inspector/TDocSupplier.java b/odk/examples/java/Inspector/TDocSupplier.java index 1022507eb387..81d8ca05e533 100644 --- a/odk/examples/java/Inspector/TDocSupplier.java +++ b/odk/examples/java/Inspector/TDocSupplier.java @@ -3,7 +3,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -30,7 +30,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.beans.Property; @@ -55,31 +55,31 @@ import javax.swing.JOptionPane; public class TDocSupplier { private XMultiComponentFactory m_xMultiComponentFactory; private XComponentContext m_xComponentContext; - - + + /** Creates a new instance of TDocSupplier */ public TDocSupplier(XComponentContext _xComponentContext) { m_xComponentContext = _xComponentContext; m_xMultiComponentFactory = m_xComponentContext.getServiceManager(); } - - + + protected XComponentContext getXComponentContext(){ return m_xComponentContext; } - - + + protected XMultiComponentFactory getXMultiComponentFactory(){ return m_xMultiComponentFactory; } - + public XModel getXModelByTDocUrl(String _sTDocUrl){ try{ XRow xRow = getXRowOfTDocUrl(_sTDocUrl, "DocumentModel"); if (xRow != null){ Object oModel = xRow.getObject(1, null); XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, oModel); - return xModel; + return xModel; } }catch(Exception exception){ exception.printStackTrace(System.out); @@ -87,8 +87,8 @@ public class TDocSupplier { JOptionPane.showMessageDialog(new javax.swing.JFrame(), "The selected Document could not be opened!", "Object Inspector", JOptionPane.ERROR_MESSAGE); return null; } - - + + public String getTitleByTDocUrl(String _sTDocUrl){ try{ XRow xRow = this.getXRowOfTDocUrl(_sTDocUrl, "Title"); @@ -101,18 +101,18 @@ public class TDocSupplier { JOptionPane.showMessageDialog(new javax.swing.JFrame(), "The selected Document could not be opened!", "Object Inspector", JOptionPane.ERROR_MESSAGE); return ""; } - - + + private XRow getXRowOfTDocUrl(String _sTDocUrl, String _sPropertyName){ try{ String[] keys = new String[2]; keys[ 0 ] = "Local"; keys[ 1 ] = "Office"; - Object oUCB = getXMultiComponentFactory().createInstanceWithArgumentsAndContext( "com.sun.star.ucb.UniversalContentBroker", keys, getXComponentContext() ); + Object oUCB = getXMultiComponentFactory().createInstanceWithArgumentsAndContext( "com.sun.star.ucb.UniversalContentBroker", keys, getXComponentContext() ); XContentIdentifierFactory xIdFactory = (XContentIdentifierFactory)UnoRuntime.queryInterface(XContentIdentifierFactory.class, oUCB); XContentProvider xProvider = (XContentProvider)UnoRuntime.queryInterface(XContentProvider.class, oUCB); XContentIdentifier xId = xIdFactory.createContentIdentifier(_sTDocUrl); - XContent xContent = xProvider.queryContent(xId); + XContent xContent = xProvider.queryContent(xId); XCommandProcessor xCmdProcessor = (XCommandProcessor) UnoRuntime.queryInterface(XCommandProcessor.class, xContent); Property aProperty = new Property(); aProperty.Name = _sPropertyName; // "DocumentModel"; //DocumentModel @@ -127,8 +127,8 @@ public class TDocSupplier { exception.printStackTrace(System.out); return null; }} - - + + protected String[] getTDocTitles(String[] _sTDocUrls){ String[] sTitles = new String[_sTDocUrls.length]; for (int i = 0; i < _sTDocUrls.length; i++){ @@ -136,33 +136,33 @@ public class TDocSupplier { } return sTitles; } - - + + protected String[] getTDocUrls(){ try{ Object oSimpleFileAccess = getXMultiComponentFactory().createInstanceWithContext("com.sun.star.ucb.SimpleFileAccess", getXComponentContext()); XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, oSimpleFileAccess); String[] sContent = xSimpleFileAccess.getFolderContents("vnd.sun.star.tdoc:/", false); - return sContent; + return sContent; } catch( Exception e ) { System.err.println( e ); return new String[]{}; }} - - + + public XComponent openEmptyDocument(String _sUrl){ try{ PropertyValue[] aPropertyValues = new PropertyValue[1]; aPropertyValues[0] = new PropertyValue(); aPropertyValues[0].Name = "Hidden"; - aPropertyValues[0].Value = Boolean.TRUE; + aPropertyValues[0].Value = Boolean.TRUE; Object oDesktop = getXMultiComponentFactory().createInstanceWithContext("com.sun.star.frame.Desktop", getXComponentContext()); XComponentLoader xCL = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, oDesktop); - return xCL.loadComponentFromURL(_sUrl, "_default", 0, aPropertyValues); + return xCL.loadComponentFromURL(_sUrl, "_default", 0, aPropertyValues); } catch( Exception exception ) { System.err.println( exception ); return null; - }} - + }} + } diff --git a/odk/examples/java/Inspector/TestInspector.java b/odk/examples/java/Inspector/TestInspector.java index a2255dff859a..e7583f944d09 100644 --- a/odk/examples/java/Inspector/TestInspector.java +++ b/odk/examples/java/Inspector/TestInspector.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.lang.XSingleComponentFactory; @@ -38,7 +38,7 @@ import com.sun.star.uno.UnoRuntime; import java.io.DataInputStream; public class TestInspector { - + public static void main(String args[]) { com.sun.star.uno.XComponentContext xContext = null; try { @@ -55,24 +55,24 @@ public class TestInspector { try { com.sun.star.lang.XMultiComponentFactory xMCF = xContext.getServiceManager(); // Creating an instance of the instance inspector with arguments - + XSingleComponentFactory xFactory = Inspector.__getComponentFactory(Inspector._Inspector.class.getName()); Object obj= null; if (xFactory != null) { - obj = xFactory.createInstanceWithContext(xContext); + obj = xFactory.createInstanceWithContext(xContext); } org.openoffice.XInstanceInspector xInstInspector = null; if (obj != null) { - xInstInspector = (org.openoffice.XInstanceInspector)UnoRuntime.queryInterface(org.openoffice.XInstanceInspector.class, obj); + xInstInspector = (org.openoffice.XInstanceInspector)UnoRuntime.queryInterface(org.openoffice.XInstanceInspector.class, obj); } - + /* A desktop environment contains tasks with one or more frames in which components can be loaded. Desktop is the environment for components which can instanciate within frames. */ com.sun.star.frame.XComponentLoader xCmpLoader = (com.sun.star.frame.XComponentLoader)UnoRuntime.queryInterface( com.sun.star.frame.XComponentLoader.class, xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext)); - + // Load a new spreadsheet document, which will be automaticly // displayed and is used for inspection com.sun.star.lang.XComponent xComp = xCmpLoader.loadComponentFromURL("private:factory/scalc", "_blank", 0, new com.sun.star.beans.PropertyValue[0] ); diff --git a/odk/examples/java/Inspector/UnoFacetteNode.java b/odk/examples/java/Inspector/UnoFacetteNode.java index 53296129b2da..0fd91e434736 100644 --- a/odk/examples/java/Inspector/UnoFacetteNode.java +++ b/odk/examples/java/Inspector/UnoFacetteNode.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.reflection.XIdlMethod; @@ -39,27 +39,27 @@ import javax.swing.tree.DefaultMutableTreeNode; public class UnoFacetteNode extends UnoNode{ String m_sFilter = ""; - - + + /** Creates a new instance of UnoMethodNode */ public UnoFacetteNode(Object _oUnoObject){ super(_oUnoObject); - addDummyNode(); + addDummyNode(); } - - + + public String getFilter(){ return m_sFilter; } - + public void setFilter(String _sFilter){ m_sFilter = _sFilter; } - + public String getName(){ return toString(); } - + // TODO The implementation of the following nodes is not really robust and should be changed!!! public boolean isMethodNode(){ return ((String) getUserObject()).equals(SMETHODDESCRIPTION); @@ -77,7 +77,7 @@ public class UnoFacetteNode extends UnoNode{ public boolean isServiceNode(){ return ((String) getUserObject()).equals(SSERVICEDESCRIPTION); } - + public boolean isInterfaceNode(){ return ((String) getUserObject()).equals(SINTERFACEDESCRIPTION); } diff --git a/odk/examples/java/Inspector/UnoMethodNode.java b/odk/examples/java/Inspector/UnoMethodNode.java index 57793809bc5e..d80aa6f70d6b 100644 --- a/odk/examples/java/Inspector/UnoMethodNode.java +++ b/odk/examples/java/Inspector/UnoMethodNode.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.reflection.ParamInfo; @@ -47,8 +47,8 @@ public class UnoMethodNode extends UnoNode{ Object m_oUnoReturnObject = null; boolean m_bisInvoked = false; XUnoMethodNode m_xUnoMethodNode = null; - - + + /** Creates a new instance of UnoMethodNode */ public UnoMethodNode(XIdlMethod _xIdlMethod, Object _oUnoObject, XUnoMethodNode _xUnoMethodNode) { super(_oUnoObject); @@ -56,11 +56,11 @@ public class UnoMethodNode extends UnoNode{ m_oParamObjects = new Object[m_xIdlMethod.getParameterInfos().length]; m_xUnoMethodNode = _xUnoMethodNode; } - + protected boolean isFoldable(){ return ((!this.isPrimitive()) && (getTypeClass().getValue() != TypeClass.VOID_value)); } - + protected boolean isInvokable(){ boolean bisFoldable = true; XIdlClass[] xIdlClasses = m_xIdlMethod.getParameterTypes(); @@ -72,22 +72,22 @@ public class UnoMethodNode extends UnoNode{ } return bisFoldable; } - + public XIdlMethod getXIdlMethod(){ return m_xIdlMethod; } - - + + public String getAnchor(){ return getXIdlMethod().getName(); } - + public String getName(){ return getXIdlMethod().getName(); } - - + + public Object invoke(){ Object oUnoReturnObject = null; if (!hasParameters()){ @@ -109,13 +109,13 @@ public class UnoMethodNode extends UnoNode{ m_oUnoReturnObject = oUnoReturnObject; return oUnoReturnObject; } - - + + public boolean isInvoked(){ return m_bisInvoked; } - - + + protected String getNodeDescription(){ String sNodeDescription = ""; String sParameters = getParameterDescription(); @@ -124,7 +124,7 @@ public class UnoMethodNode extends UnoNode{ } else{ TypeClass typeClass = getTypeClass(); - if (typeClass != TypeClass.VOID){ + if (typeClass != TypeClass.VOID){ sNodeDescription = getStandardMethodDescription(); } else{ @@ -133,7 +133,7 @@ public class UnoMethodNode extends UnoNode{ } return sNodeDescription; } - + public String getStandardMethodDescription(){ String sNodeDescription = m_xIdlMethod.getReturnType().getName() + " " + m_xIdlMethod.getName() + " (" + getParameterDescription() + " )"; @@ -142,23 +142,23 @@ public class UnoMethodNode extends UnoNode{ } return sNodeDescription; } - - + + public boolean hasParameters(){ return (m_xIdlMethod.getParameterInfos().length > 0); } - - + + public Object[] getLastParameterObjects(){ return m_oParamObjects; } - - + + public Object getLastUnoReturnObject(){ return m_oUnoReturnObject; } - + public String getParameterDescription(){ ParamInfo[] paramInfo = m_xIdlMethod.getParameterInfos(); String sParameters = ""; @@ -180,7 +180,7 @@ public class UnoMethodNode extends UnoNode{ return sParameters; } - + // return the parameter mode (IN, OUT, INOUT) private static String getParamMode(ParamMode paramMode) { String toReturn = ""; @@ -195,34 +195,34 @@ public class UnoMethodNode extends UnoNode{ } return( toReturn ); } - + public TypeClass getTypeClass(){ XIdlClass xIdlClass = m_xIdlMethod.getReturnType(); return xIdlClass.getTypeClass(); } - + private Object invokeParameterlessMethod(){ try { Object[][] aParamInfo = new Object[1][]; aParamInfo[0] = new Object[] {}; - return getXIdlMethod().invoke(getUnoObject(), aParamInfo); + return getXIdlMethod().invoke(getUnoObject(), aParamInfo); } catch (Exception ex) { ex.printStackTrace(System.out); return null; }} - + public boolean isPrimitive(){ return Introspector.isObjectPrimitive(m_xIdlMethod.getClass(), getTypeClass()); } - - + + protected Object invoke(Object _oUnoObject, Object[] oParameters) throws com.sun.star.uno.Exception{ Object[][] aParams = new Object[1][oParameters.length]; for ( int i = 0; i < oParameters.length; i++ ) { aParams[0][i] = oParameters[i]; } return m_xIdlMethod.invoke(_oUnoObject, aParams); - } + } } diff --git a/odk/examples/java/Inspector/UnoNode.java b/odk/examples/java/Inspector/UnoNode.java index 2bfaaf34a356..50d6ec3243d5 100644 --- a/odk/examples/java/Inspector/UnoNode.java +++ b/odk/examples/java/Inspector/UnoNode.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.beans.PropertyValue; @@ -56,8 +56,8 @@ import java.util.List; import java.util.Vector; public class UnoNode{ - - String sPath = null; + + String sPath = null; Object m_oUnoObject; private XMultiComponentFactory m_xMultiComponentFactory; private XComponentContext m_xComponentContext; @@ -65,54 +65,54 @@ public class UnoNode{ private int m_nNodeType = XUnoNode.nOTHERS; private Type aType = null; private String sLabel = ""; - - - + + + /** Creates a new instance of UnoNode */ public UnoNode(Object _oUnoObject) { m_xComponentContext = Introspector.getIntrospector().getXComponentContext(); - m_xMultiComponentFactory = m_xComponentContext.getServiceManager(); + m_xMultiComponentFactory = m_xComponentContext.getServiceManager(); m_oUnoObject = _oUnoObject; } - + public UnoNode(Object _oUnoObject, Type _aType) { this(_oUnoObject); aType = _aType; m_nNodeType = XUnoNode.nINTERFACE; } - + public Object getUnoObject(){ return m_oUnoObject; - } - - + } + + protected XComponentContext getXComponentContext(){ return m_xComponentContext; } - - + + protected XMultiComponentFactory getXMultiComponentFactory(){ return m_xMultiComponentFactory; } - - + + private static XTypeDescriptionEnumerationAccess getXTypeDescriptionEnumerationAccess(){ return Introspector.getIntrospector().getXTypeDescriptionEnumerationAccess(); } - + public String getAnchor(){ return ""; } - + public int getNodeType(){ return m_nNodeType; } - + public void setNodeType(int _nNodeType){ m_nNodeType = _nNodeType; } - + public String getClassName(){ String sClassName = ""; if (m_nNodeType == XUnoNode.nINTERFACE){ @@ -123,8 +123,8 @@ public class UnoNode{ } return sClassName; } - - + + public Type getUnoType(){ return aType; } @@ -132,7 +132,7 @@ public class UnoNode{ protected void setLabel(String _sLabel){ sLabel = _sLabel; } - + public void openIdlDescription(String _sIDLUrl, String _sClassName, String _sAnchor){ try{ String sIDLUrl = _sIDLUrl; @@ -164,7 +164,7 @@ public class UnoNode{ getXDispatcher(openHyperlink).dispatch(openHyperlink, new PropertyValue[] {pv}); } catch(Exception exception) { exception.printStackTrace(System.out); - }} + }} private com.sun.star.util.URL getDispatchURL(String _sURL){ @@ -204,7 +204,7 @@ public class UnoNode{ } catch (Exception e) { e.printStackTrace(System.out); return null; - }} + }} private PropertyValue[] loadArgs(String url) { @@ -212,21 +212,21 @@ public class UnoNode{ pv.Name = "URL"; pv.Value = url; return new PropertyValue[] {pv}; - } - - - + } + + + public boolean isFilterApplicable(String _sFilter, String _sName){ boolean bFilterDoesApply = true; if (_sFilter.length() > 0){ - if (_sName.indexOf(_sFilter) == -1){ + if (_sName.indexOf(_sFilter) == -1){ bFilterDoesApply = false; } } return bFilterDoesApply; } - - + + // public static String getServiceDescription(Object _oUnoObject){ // String sClassName = ""; // XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, _oUnoObject); @@ -238,15 +238,15 @@ public class UnoNode{ // } // return sClassName; // } - - - + + + private static String[] getMandatoryServiceNames(String _sServiceName){ String[] sMandatoryServiceNames = new String[]{}; try { TypeClass[] eTypeClasses = new com.sun.star.uno.TypeClass[1]; eTypeClasses[0] = com.sun.star.uno.TypeClass.SERVICE; - XTypeDescriptionEnumeration xTDEnumeration = getXTypeDescriptionEnumerationAccess().createTypeDescriptionEnumeration(Introspector.getModuleName(_sServiceName), eTypeClasses, TypeDescriptionSearchDepth.INFINITE); + XTypeDescriptionEnumeration xTDEnumeration = getXTypeDescriptionEnumerationAccess().createTypeDescriptionEnumeration(Introspector.getModuleName(_sServiceName), eTypeClasses, TypeDescriptionSearchDepth.INFINITE); while (xTDEnumeration.hasMoreElements()) { XTypeDescription xTD = xTDEnumeration.nextTypeDescription(); if (xTD.getName().equals(_sServiceName)){ @@ -257,16 +257,16 @@ public class UnoNode{ for (int i = 0; i < nlength; i++){ sMandatoryServiceNames[i] = xMandatoryServiceTypeDescriptions[i].getName(); } - - } - } + + } + } } catch ( java.lang.Exception e) { System.out.println(System.out); } return sMandatoryServiceNames; } - - + + private static String[] removeMandatoryServiceNames(String[] _sServiceNames){ try{ List aList = java.util.Arrays.asList(_sServiceNames); @@ -288,8 +288,8 @@ public class UnoNode{ } return new String[]{}; } - - + + public static String getDisplayValueOfPrimitiveType(Object _objectElement){ String sValue =""; try{ @@ -297,41 +297,41 @@ public class UnoNode{ sValue = AnyConverter.toString(_objectElement); } else if (AnyConverter.isBoolean(_objectElement)){ - sValue += AnyConverter.toBoolean(_objectElement); + sValue += AnyConverter.toBoolean(_objectElement); } else if (AnyConverter.isByte(_objectElement)){ - sValue += AnyConverter.toByte(_objectElement); + sValue += AnyConverter.toByte(_objectElement); } else if (AnyConverter.isChar(_objectElement)){ - sValue += AnyConverter.toChar(_objectElement); + sValue += AnyConverter.toChar(_objectElement); } else if (AnyConverter.isDouble(_objectElement)){ - sValue += AnyConverter.toDouble(_objectElement); + sValue += AnyConverter.toDouble(_objectElement); } else if (AnyConverter.isFloat(_objectElement)){ - sValue += AnyConverter.toFloat(_objectElement); + sValue += AnyConverter.toFloat(_objectElement); } else if (AnyConverter.isInt(_objectElement)){ - sValue += AnyConverter.toInt(_objectElement); + sValue += AnyConverter.toInt(_objectElement); } else if (AnyConverter.isLong(_objectElement)){ - sValue += AnyConverter.toLong(_objectElement); + sValue += AnyConverter.toLong(_objectElement); } else if (AnyConverter.isShort(_objectElement)){ - sValue += AnyConverter.toShort(_objectElement); - } + sValue += AnyConverter.toShort(_objectElement); + } } catch( Exception e ) { System.err.println( e ); } return sValue; } - + protected static String[] getDisplayValuesofPrimitiveArray(Object _oUnoObject){ String[] sDisplayValues = null; try{ Type aType = AnyConverter.getType(_oUnoObject); - TypeClass aTypeClass = aType.getTypeClass(); + TypeClass aTypeClass = aType.getTypeClass(); int nTypeValue = aTypeClass.getValue(); if (nTypeValue == TypeClass.SEQUENCE_value){ nTypeValue = (sequenceComponentType(aType)).getTypeClass().getValue(); @@ -387,7 +387,7 @@ public class UnoNode{ } break; case TypeClass.CHAR_value: - break; + break; default: System.out.println("Value could not be retrieved: " + aType.getTypeClass().getClass().getName()); } @@ -396,9 +396,9 @@ public class UnoNode{ catch( Exception e ) { System.err.println( e ); return null; - }} - - + }} + + private static Type sequenceComponentType(Type sequenceType) { // assert sequenceType.getTypeClass() == TypeClass.SEQUENCE; String n = sequenceType.getTypeName(); @@ -406,15 +406,15 @@ public class UnoNode{ // assert n.startsWith(PREFIX); return new Type(n.substring(PREFIX.length())); } - - + + public static String getNodeDescription(Object _oUnoObject, int _nIndex){ return getNodeDescription(_oUnoObject) + "[" + (_nIndex + 1) + "]"; } public static String getNodeDescription(Object _oUnoObject){ - XServiceInfo xServiceInfo = ( XServiceInfo ) UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject ); + XServiceInfo xServiceInfo = ( XServiceInfo ) UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject ); if ( xServiceInfo != null ) { return xServiceInfo.getImplementationName(); } @@ -425,13 +425,13 @@ public class UnoNode{ else{ return _oUnoObject.getClass().getName(); } - } - + } + public void setParameterObjects(Object[] _oParamObjects){ m_oParamObjects = _oParamObjects; } - + public Object[] getParameterObjects(){ return m_oParamObjects; - } + } } diff --git a/odk/examples/java/Inspector/UnoPropertyNode.java b/odk/examples/java/Inspector/UnoPropertyNode.java index 4b22b01f1b8a..e9efe526a24b 100644 --- a/odk/examples/java/Inspector/UnoPropertyNode.java +++ b/odk/examples/java/Inspector/UnoPropertyNode.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.beans.Property; @@ -48,17 +48,17 @@ import com.sun.star.uno.XComponentContext; import javax.swing.tree.DefaultMutableTreeNode; public class UnoPropertyNode extends UnoNode{ - + Property aProperty; PropertyValue aPropertyValue; String m_sPropertyName; Object m_oUnoReturnObject; private int m_nPropertyType = XUnoPropertyNode.nDEFAULT; private String sLabel = ""; - + private static XConstantTypeDescription[] xPropertyAttributesTypeDescriptions = null; - - + + /** Creates a new instance of UnoMethodNode */ public UnoPropertyNode(Property _aProperty, Object _oUnoObject, Object _oUnoReturnObject) { super(_oUnoObject); @@ -74,7 +74,7 @@ public class UnoPropertyNode extends UnoNode{ m_sPropertyName = aProperty.Name; m_oUnoReturnObject = null; } - + public UnoPropertyNode(PropertyValue _aPropertyValue, Object _oUnoObject, Object _oUnoReturnObject) { super(_oUnoObject); m_oUnoReturnObject = _oUnoReturnObject; @@ -82,17 +82,17 @@ public class UnoPropertyNode extends UnoNode{ m_sPropertyName = aPropertyValue.Name; } - + public int getPropertyNodeType(){ return m_nPropertyType; } - - + + public void setPropertyNodeType(int _nPropertyType){ m_nPropertyType = _nPropertyType; } - - + + public String getPropertyName(){ return m_sPropertyName; } @@ -101,7 +101,7 @@ public class UnoPropertyNode extends UnoNode{ return this.m_sPropertyName; } - + public String getClassName(){ String sClassName = ""; if (m_oUnoObject != null){ @@ -120,15 +120,15 @@ public class UnoPropertyNode extends UnoNode{ sClassName = "com.sun.star.beans.Property"; } return sClassName; - } - - + } + + public String getAnchor(){ return m_sPropertyName; } - - - + + + protected boolean doesServiceSupportProperty(String _sServiceName, String _sPropertyName){ try { XPropertyTypeDescription[] xPropertyTypeDescriptions = Introspector.getIntrospector().getPropertyDescriptionsOfService(_sServiceName); @@ -142,18 +142,18 @@ public class UnoPropertyNode extends UnoNode{ } return false; } - - + + public Object getUnoReturnObject(){ return m_oUnoReturnObject; } - - + + private boolean isPrimitive(){ boolean bIsPrimitive = true; if (getUnoReturnObject() != null){ if (getProperty() != null){ - bIsPrimitive = Introspector.isObjectPrimitive(getUnoReturnObject().getClass(), getProperty().Type.getTypeClass()); + bIsPrimitive = Introspector.isObjectPrimitive(getUnoReturnObject().getClass(), getProperty().Type.getTypeClass()); } else{ bIsPrimitive = Introspector.isObjectPrimitive(getUnoReturnObject().getClass()); @@ -164,8 +164,8 @@ public class UnoPropertyNode extends UnoNode{ } return bIsPrimitive; } - - + + protected boolean isFoldable(){ boolean bIsFoldable = false; if (! isPrimitive()){ @@ -174,8 +174,8 @@ public class UnoPropertyNode extends UnoNode{ } return bIsFoldable; } - - + + protected String getLabel(){ if (!sLabel.equals("")){ if (! isPrimitive()){ @@ -186,32 +186,32 @@ public class UnoPropertyNode extends UnoNode{ sLabel = getStandardPropertyDescription(aProperty, getUnoReturnObject()); } } - else { + else { sLabel = getStandardPropertyDescription(aProperty, getUnoReturnObject()); } } return sLabel; } - + public Property getProperty(){ return aProperty; } - + protected static String getPropertyTypeDescription(Property _aProperty, Object _oUnoObject){ - return _aProperty.Type.getTypeName() + " " + _aProperty.Name + " = " + _oUnoObject.toString(); - } + return _aProperty.Type.getTypeName() + " " + _aProperty.Name + " = " + _oUnoObject.toString(); + } protected static String getStandardPropertyDescription(Property _aProperty, Object _objectElement){ if (!Introspector.isObjectPrimitive(_objectElement)){ - return _aProperty.Name + " = (" + _aProperty.Type.getTypeName() + ") "; + return _aProperty.Name + " = (" + _aProperty.Type.getTypeName() + ") "; } else{ - return _aProperty.Name + " (" + _aProperty.Type.getTypeName() + ") = " + getDisplayValueOfPrimitiveType(_objectElement); + return _aProperty.Name + " (" + _aProperty.Type.getTypeName() + ") = " + getDisplayValueOfPrimitiveType(_objectElement); } } - + protected static String getStandardPropertyValueDescription(PropertyValue _aPropertyValue){ if (!Introspector.isObjectPrimitive(_aPropertyValue.Value)){ return _aPropertyValue.Name; @@ -219,7 +219,7 @@ public class UnoPropertyNode extends UnoNode{ else{ return _aPropertyValue.Name + " : " + UnoNode.getDisplayValueOfPrimitiveType(_aPropertyValue.Value); } - } + } } diff --git a/odk/examples/java/Inspector/UnoTreeRenderer.java b/odk/examples/java/Inspector/UnoTreeRenderer.java index 54094275606c..9c2772124658 100644 --- a/odk/examples/java/Inspector/UnoTreeRenderer.java +++ b/odk/examples/java/Inspector/UnoTreeRenderer.java @@ -55,13 +55,13 @@ public class UnoTreeRenderer extends DefaultTreeCellRenderer{ private Icon m_oPropertyValueIcon; private boolean bSelected; private int nWidth = 0; - - + + /** Creates a new instance of UnoTreeRenderer */ public UnoTreeRenderer(){ super(); try { - + final ClassLoader loader = ClassLoader.getSystemClassLoader(); m_oMethodIcon = new ImageIcon(loader.getResource("images/methods_16.png")); m_oPropertyIcon = new ImageIcon("images/properties_16.png"); @@ -74,14 +74,14 @@ public class UnoTreeRenderer extends DefaultTreeCellRenderer{ System.out.println("Sorry, could not locate resourecs, treecell icons will not be displayed."); } } - - + + public synchronized Component getTreeCellRendererComponent(JTree tree,Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus){ try{ bSelected = sel; DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; Component rc = super.getTreeCellRendererComponent( tree, value, sel,expanded, leaf, row,hasFocus); - String sLabelText = (String)node.getUserObject(); + String sLabelText = (String)node.getUserObject(); if (sLabelText != null){ if (sLabelText.equals(XUnoFacetteNode.SCONTAINERDESCRIPTION)){ // setIcon(m_oContainerIcon); @@ -113,9 +113,9 @@ public class UnoTreeRenderer extends DefaultTreeCellRenderer{ } return this; } - - - + + + public void paintComponent(Graphics g) { FontMetrics fm = getFontMetrics(getFont()); int x, y; diff --git a/odk/examples/java/Inspector/XDialogProvider.java b/odk/examples/java/Inspector/XDialogProvider.java index e8bfadc1873f..fdf406273b7e 100644 --- a/odk/examples/java/Inspector/XDialogProvider.java +++ b/odk/examples/java/Inspector/XDialogProvider.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,37 +29,37 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ public interface XDialogProvider { - - public static String SINVOKE = "Invoke"; - + + public static String SINVOKE = "Invoke"; + public static String SADDTOSOURCECODE = "Add to Sourcecode"; - - public void enablePopupMenuItem(String _sMenuTitle, boolean _bdoEnable); - + + public void enablePopupMenuItem(String _sMenuTitle, boolean _bdoEnable); + public void showPopUpMenu(Object invoker, int x, int y) throws java.lang.ClassCastException; - + public InspectorPane getSelectedInspectorPage(); public void addInspectorPage(String _sTitle, Object _oContainer); - + public InspectorPane getInspectorPage(int _nIndex); public int getInspectorPageCount(); - + public void selectInspectorPageByIndex(int nTabIndex); - + public void show(int _nPageIndex) throws java.lang.ClassCastException; - + public void selectSourceCodeLanguage(int _nLanguage); - + public void paint(); - + // returns one of the constants defined in XLanguageSourceCodeGenerator public int getLanguage(); - + public String getIDLPath(); } diff --git a/odk/examples/java/Inspector/XInstanceInspector.idl b/odk/examples/java/Inspector/XInstanceInspector.idl index 134879f68cee..2749535816b2 100644 --- a/odk/examples/java/Inspector/XInstanceInspector.idl +++ b/odk/examples/java/Inspector/XInstanceInspector.idl @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,28 +29,28 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ #ifndef INCLUDED_ORG_OPENOFFICE_XINSTANCEINSPECTOR_IDL #define INCLUDED_ORG_OPENOFFICE_XINSTANCEINSPECTOR_IDL -#include <com/sun/star/uno/XInterface.idl> +#include <com/sun/star/uno/XInterface.idl> + +module org { module openoffice { -module org { module openoffice { - - interface XInstanceInspector { + interface XInstanceInspector { /** * For a given instance this method displays all services, interfaces, * methods, attributes, and contents in a tree. All dependend * instances are also inspected and displayed, so the user could browse * the tree. If you press the key "F1", the API-documentation from - * www.openoffice.org for the current instance will be displayed in a + * www.openoffice.org for the current instance will be displayed in a * new window. */ - void inspect( [in] any aInstance, [in] string sTitle ); + void inspect( [in] any aInstance, [in] string sTitle ); }; - + }; }; #endif diff --git a/odk/examples/java/Inspector/XLanguageSourceCodeGenerator.java b/odk/examples/java/Inspector/XLanguageSourceCodeGenerator.java index 832f0aa51d4b..aaf424607a8a 100644 --- a/odk/examples/java/Inspector/XLanguageSourceCodeGenerator.java +++ b/odk/examples/java/Inspector/XLanguageSourceCodeGenerator.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,78 +29,78 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.uno.TypeClass; import java.util.Vector; public interface XLanguageSourceCodeGenerator { - + public static final int nJAVA = 0; public static final int nCPLUSPLUS = 1; public static final int nBASIC = 2; - + public String getHeaderSourceCode(Object _oUnoObject, String _sClassName, TypeClass _aTypeClass); - public String getFinalHeaderStatements(); + public String getFinalHeaderStatements(); public void assignqueryInterfaceHeaderSourceCode(); - + public String getMainMethodSignatureSourceCode(XUnoNode _oUnoNode, String _soReturnObjectDescription); - + public String getMethodTerminationSourceCode(); - + public String getStatementTerminationCharacter(); - public boolean needsqueryInterface(); - + public boolean needsqueryInterface(); + public String getqueryInterfaceSourceCode(String _sReturnValueDescription, String _sClassName, String _sObjectDescription); - + public String getPropertyValueGetterSourceCode(String _sPropertyName, String _sReturnVariableName, String _sIncomingObjectName, TypeClass _aTypeClass, String _sTypeName); - + public String getStructSourceCode(String _sReturnVariableDescription, String _sObjectDescription, String _sMember); - + public String getObjectTypeDescription(String _sClassName, boolean _bAsHeader); - + public String getbooleanTypeDescription(); public String getbyteTypeDescription(); public String getshortTypeDescription(); - + public String getunsignedshortTypeDescription(); public String getlongTypeDescription(); public String getunsignedlongTypeDescription(); - + public String gethyperTypeDescription(); public String getunsignedhyperTypeDescription(); public String getfloatTypeDescription(); - + public String getdoubleTypeDescription(); public String getcharTypeDescription(); - + public String getstringTypeDescription(boolean _bAsHeaderSourceCode); - + public String gettypeTypeDescription(boolean _bAsHeaderSourceCode); - + public String getanyTypeDescription(boolean _bAsHeaderSourceCode); - + public String getArrayDeclaration(String sVariableDeclaration); - + public String getVariableDeclaration(String _sTypeString, String _sVariableName, boolean _bIsArray, TypeClass aTypeClass, boolean _bInitialize); - + public String getMethodSeparator(); - + public String getStringValue(String _sValue); - + public String getConvertedSourceCodeValueOfObject(String _sReturnVariableName, String _sObjectDescription, TypeClass _aTypeClass, String _sTypeName); - + public String castLiteral(String _sExpression, TypeClass _aTypeClass); - + public String getCommentSign(); } diff --git a/odk/examples/java/Inspector/XMethodParametersDialog.java b/odk/examples/java/Inspector/XMethodParametersDialog.java index 8bad4f19b9c5..d8fcdb13c9b1 100644 --- a/odk/examples/java/Inspector/XMethodParametersDialog.java +++ b/odk/examples/java/Inspector/XMethodParametersDialog.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,9 +29,9 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ public interface XMethodParametersDialog { - + } diff --git a/odk/examples/java/Inspector/XTreeControlProvider.java b/odk/examples/java/Inspector/XTreeControlProvider.java index ca40d70afae2..8f0d951e1a29 100644 --- a/odk/examples/java/Inspector/XTreeControlProvider.java +++ b/odk/examples/java/Inspector/XTreeControlProvider.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.beans.Property; @@ -42,52 +42,52 @@ public interface XTreeControlProvider { public static String sTitle = "User defined"; public String enableFilterElements(XUnoNode _oUnoNode); - + public void setSourceCode(String _sSourceCode); - + public Object inspect(java.lang.Object _oUserDefinedObject, String _sTitle) throws com.sun.star.uno.RuntimeException; - + public void nodeInserted(XUnoNode _oParentNode, XUnoNode _oChildNode, int index); - + public void nodeChanged(XUnoNode _oNode); - - public boolean setNodeVisible(Object node, boolean v); - + + public boolean setNodeVisible(Object node, boolean v); + public XUnoNode getSelectedNode(); - + public XTreePathProvider getSelectedPath(); - + public void expandPath(XTreePathProvider xTreePathProvider) throws java.lang.ClassCastException; - + public void addTreeExpandListener(); - - public void addInspectorPane(InspectorPane _oInspectorPane); - + + public void addInspectorPane(InspectorPane _oInspectorPane); + public boolean isPropertyNode(XUnoNode _oUnoNode); - + public boolean isMethodNode(XUnoNode _oUnoNode); public boolean isFacetteNode(XUnoNode _oUnoNode); - + public XUnoNode addUnoNode(Object _oUnoObject); - + public XUnoNode addUnoNode(Object _oUnoObject, Type _aType); public XUnoFacetteNode addUnoFacetteNode(XUnoNode _oParentNode, String _sNodeDescription, Object _oUnoObject); - + public XUnoMethodNode addMethodNode(Object _objectElement, XIdlMethod _xIdlMethod); - + public XUnoPropertyNode addUnoPropertyNodeWithName(Property _aProperty); public XUnoPropertyNode addUnoPropertyNodeWithHandle(Property _aProperty); public XUnoPropertyNode addUnoPropertyNodeWithType(Property _aProperty); - + public XUnoPropertyNode addUnoPropertyNodeWithAttributesDescription(Property _aProperty); - + public XUnoPropertyNode addUnoPropertyNode(Object _oUnoObject, Property _aProperty); - + public XUnoPropertyNode addUnoPropertyNode(Object _oUnoObject, PropertyValue _aPropertyValue, Object _oReturnObject); - - public XUnoPropertyNode addUnoPropertyNode(Object _oUnoObject, Property _aProperty, Object _oUnoReturnObject); + + public XUnoPropertyNode addUnoPropertyNode(Object _oUnoObject, Property _aProperty, Object _oUnoReturnObject); } diff --git a/odk/examples/java/Inspector/XTreePathProvider.java b/odk/examples/java/Inspector/XTreePathProvider.java index 5067bad409c1..8a2f1ba58b59 100644 --- a/odk/examples/java/Inspector/XTreePathProvider.java +++ b/odk/examples/java/Inspector/XTreePathProvider.java @@ -12,14 +12,14 @@ * @author bc93774 */ public interface XTreePathProvider { - + public XUnoNode getLastPathComponent(); - + public XUnoNode getPathComponent(int i); - - public int getPathCount(); - + + public int getPathCount(); + public XTreePathProvider getParentPath(); - - public XTreePathProvider pathByAddingChild(XUnoNode _oUnoNode); + + public XTreePathProvider pathByAddingChild(XUnoNode _oUnoNode); } diff --git a/odk/examples/java/Inspector/XUnoFacetteNode.java b/odk/examples/java/Inspector/XUnoFacetteNode.java index 6ef4bf4d67a9..9bf091b234f3 100644 --- a/odk/examples/java/Inspector/XUnoFacetteNode.java +++ b/odk/examples/java/Inspector/XUnoFacetteNode.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ @@ -44,20 +44,20 @@ public interface XUnoFacetteNode extends XUnoNode { public static String SINTERFACEDESCRIPTION = "Interfaces"; public static String SCONTENTDESCRIPTION = "Content"; public static String SPROPERTYVALUEDESCRIPTION = "PropertyValues"; - - + + public boolean isMethodNode(); - + public boolean isPropertyNode(); - + public boolean isContainerNode(); - + public boolean isServiceNode(); - + public boolean isInterfaceNode(); - + public String getFilter(); - + public void setFilter(String _sFilter); - + } diff --git a/odk/examples/java/Inspector/XUnoMethodNode.java b/odk/examples/java/Inspector/XUnoMethodNode.java index 074c2fe913ba..93167840a978 100644 --- a/odk/examples/java/Inspector/XUnoMethodNode.java +++ b/odk/examples/java/Inspector/XUnoMethodNode.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.reflection.XIdlMethod; @@ -38,31 +38,31 @@ import java.util.Vector; public interface XUnoMethodNode extends XUnoNode { - + public XIdlMethod getXIdlMethod(); - + public boolean isInvoked(); - + public Object invoke() throws com.sun.star.uno.Exception; - + public Object invoke(Object _oUnoObject, Object[] _oParameters) throws com.sun.star.uno.Exception; - + public boolean isInvokable(); - + public boolean hasParameters(); - + public Object[] getLastParameterObjects(); - + public Object getLastUnoReturnObject(); - + public TypeClass getTypeClass(); - + public boolean isPrimitive(); - + public Vector getMethodObjects(); - + public boolean isFoldable(); - + public String getStandardMethodDescription(); - + } diff --git a/odk/examples/java/Inspector/XUnoNode.java b/odk/examples/java/Inspector/XUnoNode.java index ae65374aca7a..a27c0aa3a4ab 100644 --- a/odk/examples/java/Inspector/XUnoNode.java +++ b/odk/examples/java/Inspector/XUnoNode.java @@ -3,7 +3,7 @@ import com.sun.star.uno.Type; * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -30,7 +30,7 @@ import com.sun.star.uno.Type; * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ @@ -39,44 +39,44 @@ public interface XUnoNode { public static final int nINTERFACE = 1; public static final int nSERVICE = 2; public static final int nOTHERS = 3; - + public String getAnchor(); - + public String getClassName(); - + public void openIdlDescription(String _sIDLUrl); - + public boolean isFilterApplicable(String _sFilter); - + public void setVisible(String _sFilter); - + public void setParameterObjects(Object[] _oParamObjects); - + public Object[] getParameterObjects(); - + public String getName(); - + public void setFoldable(boolean _bIsFoldable); - + public Object getUnoObject(); - + public XUnoNode getParentNode(); - + public void addChildNode(XUnoNode _xUnoNode); - + public void setLabel(String _sLabel); public String getLabel(); - + public int getChildCount(); - + public XUnoNode getChild(int _index); - + public int getNodeType(); - + // possible values are nINTERFACE, nSERVICE, nOTHERS public void setNodeType(int _nNodeType); - + /** delivers only the Uno-Type when the NodeType is set to nINTERFACE * otherwise (when the NodeType has not been set returns null */ diff --git a/odk/examples/java/Inspector/XUnoPropertyNode.java b/odk/examples/java/Inspector/XUnoPropertyNode.java index e4aa4caba668..27d6c5021e1d 100644 --- a/odk/examples/java/Inspector/XUnoPropertyNode.java +++ b/odk/examples/java/Inspector/XUnoPropertyNode.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ import com.sun.star.beans.Property; @@ -39,13 +39,13 @@ public interface XUnoPropertyNode extends XUnoNode { public static int nDEFAULT = 0; public static int nPROPERTYSETINFOTYPE = 1; public static int nPROPERTYVALUETYPE = 2; - + public Object getUnoReturnObject(); - + public int getPropertyNodeType(); - + public void setPropertyNodeType(int _nPropertyType); public Property getProperty(); - + } |