xref: /AOO41X/main/odk/examples/java/Inspector/UnoNode.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  *  The Contents of this file are made available subject to the terms of
4*cdf0e10cSrcweir  *  the BSD license.
5*cdf0e10cSrcweir  *
6*cdf0e10cSrcweir  *  Copyright 2000, 2010 Oracle and/or its affiliates.
7*cdf0e10cSrcweir  *  All rights reserved.
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  *  Redistribution and use in source and binary forms, with or without
10*cdf0e10cSrcweir  *  modification, are permitted provided that the following conditions
11*cdf0e10cSrcweir  *  are met:
12*cdf0e10cSrcweir  *  1. Redistributions of source code must retain the above copyright
13*cdf0e10cSrcweir  *     notice, this list of conditions and the following disclaimer.
14*cdf0e10cSrcweir  *  2. Redistributions in binary form must reproduce the above copyright
15*cdf0e10cSrcweir  *     notice, this list of conditions and the following disclaimer in the
16*cdf0e10cSrcweir  *     documentation and/or other materials provided with the distribution.
17*cdf0e10cSrcweir  *  3. Neither the name of Sun Microsystems, Inc. nor the names of its
18*cdf0e10cSrcweir  *     contributors may be used to endorse or promote products derived
19*cdf0e10cSrcweir  *     from this software without specific prior written permission.
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22*cdf0e10cSrcweir  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23*cdf0e10cSrcweir  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24*cdf0e10cSrcweir  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25*cdf0e10cSrcweir  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26*cdf0e10cSrcweir  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27*cdf0e10cSrcweir  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28*cdf0e10cSrcweir  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29*cdf0e10cSrcweir  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30*cdf0e10cSrcweir  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31*cdf0e10cSrcweir  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*cdf0e10cSrcweir  *
33*cdf0e10cSrcweir  *************************************************************************/
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
36*cdf0e10cSrcweir import com.sun.star.frame.FrameSearchFlag;
37*cdf0e10cSrcweir import com.sun.star.frame.XDesktop;
38*cdf0e10cSrcweir import com.sun.star.frame.XDispatch;
39*cdf0e10cSrcweir import com.sun.star.frame.XDispatchProvider;
40*cdf0e10cSrcweir import com.sun.star.frame.XFrame;
41*cdf0e10cSrcweir import com.sun.star.lang.XMultiComponentFactory;
42*cdf0e10cSrcweir import com.sun.star.lang.XServiceInfo;
43*cdf0e10cSrcweir import com.sun.star.reflection.TypeDescriptionSearchDepth;
44*cdf0e10cSrcweir import com.sun.star.reflection.XServiceTypeDescription;
45*cdf0e10cSrcweir import com.sun.star.reflection.XTypeDescription;
46*cdf0e10cSrcweir import com.sun.star.reflection.XTypeDescriptionEnumeration;
47*cdf0e10cSrcweir import com.sun.star.reflection.XTypeDescriptionEnumerationAccess;
48*cdf0e10cSrcweir import com.sun.star.uno.AnyConverter;
49*cdf0e10cSrcweir import com.sun.star.uno.Type;
50*cdf0e10cSrcweir import com.sun.star.uno.TypeClass;
51*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
52*cdf0e10cSrcweir import com.sun.star.uno.XComponentContext;
53*cdf0e10cSrcweir import com.sun.star.util.URL;
54*cdf0e10cSrcweir import com.sun.star.util.XURLTransformer;
55*cdf0e10cSrcweir import java.util.List;
56*cdf0e10cSrcweir import java.util.Vector;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir public class UnoNode{
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir     String sPath = null;
61*cdf0e10cSrcweir     Object m_oUnoObject;
62*cdf0e10cSrcweir     private XMultiComponentFactory m_xMultiComponentFactory;
63*cdf0e10cSrcweir     private XComponentContext m_xComponentContext;
64*cdf0e10cSrcweir     private Object[] m_oParamObjects = null;
65*cdf0e10cSrcweir     private int m_nNodeType = XUnoNode.nOTHERS;
66*cdf0e10cSrcweir     private Type aType = null;
67*cdf0e10cSrcweir     private String sLabel = "";
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir     /** Creates a new instance of UnoNode */
72*cdf0e10cSrcweir     public UnoNode(Object _oUnoObject) {
73*cdf0e10cSrcweir         m_xComponentContext = Introspector.getIntrospector().getXComponentContext();
74*cdf0e10cSrcweir         m_xMultiComponentFactory = m_xComponentContext.getServiceManager();
75*cdf0e10cSrcweir         m_oUnoObject = _oUnoObject;
76*cdf0e10cSrcweir     }
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     public UnoNode(Object _oUnoObject, Type _aType) {
79*cdf0e10cSrcweir         this(_oUnoObject);
80*cdf0e10cSrcweir         aType = _aType;
81*cdf0e10cSrcweir         m_nNodeType = XUnoNode.nINTERFACE;
82*cdf0e10cSrcweir     }
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir     public Object getUnoObject(){
85*cdf0e10cSrcweir         return m_oUnoObject;
86*cdf0e10cSrcweir     }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     protected XComponentContext getXComponentContext(){
90*cdf0e10cSrcweir         return m_xComponentContext;
91*cdf0e10cSrcweir     }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     protected XMultiComponentFactory getXMultiComponentFactory(){
95*cdf0e10cSrcweir         return m_xMultiComponentFactory;
96*cdf0e10cSrcweir     }
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     private static XTypeDescriptionEnumerationAccess getXTypeDescriptionEnumerationAccess(){
100*cdf0e10cSrcweir        return Introspector.getIntrospector().getXTypeDescriptionEnumerationAccess();
101*cdf0e10cSrcweir     }
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     public String getAnchor(){
105*cdf0e10cSrcweir         return "";
106*cdf0e10cSrcweir     }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir     public int getNodeType(){
109*cdf0e10cSrcweir         return m_nNodeType;
110*cdf0e10cSrcweir     }
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     public void setNodeType(int _nNodeType){
113*cdf0e10cSrcweir         m_nNodeType = _nNodeType;
114*cdf0e10cSrcweir     }
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     public String getClassName(){
117*cdf0e10cSrcweir         String sClassName = "";
118*cdf0e10cSrcweir         if (m_nNodeType == XUnoNode.nINTERFACE){
119*cdf0e10cSrcweir             sClassName = aType.getTypeName();
120*cdf0e10cSrcweir         }
121*cdf0e10cSrcweir         else if(m_nNodeType == XUnoNode.nSERVICE){
122*cdf0e10cSrcweir             sClassName = sLabel;
123*cdf0e10cSrcweir         }
124*cdf0e10cSrcweir         return sClassName;
125*cdf0e10cSrcweir     }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     public Type getUnoType(){
129*cdf0e10cSrcweir         return aType;
130*cdf0e10cSrcweir     }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir     protected void  setLabel(String _sLabel){
133*cdf0e10cSrcweir         sLabel = _sLabel;
134*cdf0e10cSrcweir     }
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir     public void openIdlDescription(String _sIDLUrl, String _sClassName, String _sAnchor){
137*cdf0e10cSrcweir     try{
138*cdf0e10cSrcweir         String sIDLUrl = _sIDLUrl;
139*cdf0e10cSrcweir         String sAnchor = ""; // TODO find out how the Anchor may be set at the html file;  //_sAnchor;
140*cdf0e10cSrcweir         boolean bExists = Introspector.getIntrospector().getXSimpleFileAccess().exists(sIDLUrl);
141*cdf0e10cSrcweir         if (sIDLUrl.equals("") || (!bExists)){
142*cdf0e10cSrcweir             sIDLUrl = "http://api.openoffice.org/" + Inspector.sIDLDOCUMENTSUBFOLDER;
143*cdf0e10cSrcweir         }
144*cdf0e10cSrcweir         if (!sIDLUrl.endsWith("/")){
145*cdf0e10cSrcweir             sIDLUrl += "/";
146*cdf0e10cSrcweir         }
147*cdf0e10cSrcweir         if (_sClassName.equals("")){
148*cdf0e10cSrcweir             sIDLUrl += "com/sun/star/module-ix";
149*cdf0e10cSrcweir             sAnchor = "";
150*cdf0e10cSrcweir         }
151*cdf0e10cSrcweir         else{
152*cdf0e10cSrcweir             sIDLUrl += _sClassName.replace('.', '/');
153*cdf0e10cSrcweir         }
154*cdf0e10cSrcweir         if (sAnchor != null){
155*cdf0e10cSrcweir             if (!sAnchor.equals("")){
156*cdf0e10cSrcweir                 sIDLUrl += "#" + sAnchor;
157*cdf0e10cSrcweir             }
158*cdf0e10cSrcweir         }
159*cdf0e10cSrcweir         sIDLUrl += ".html";
160*cdf0e10cSrcweir         URL openHyperlink = getDispatchURL(".uno:OpenHyperlink");
161*cdf0e10cSrcweir         PropertyValue pv = new PropertyValue();
162*cdf0e10cSrcweir         pv.Name = "URL";
163*cdf0e10cSrcweir         pv.Value = sIDLUrl;
164*cdf0e10cSrcweir         getXDispatcher(openHyperlink).dispatch(openHyperlink, new PropertyValue[] {pv});
165*cdf0e10cSrcweir     } catch(Exception exception) {
166*cdf0e10cSrcweir         exception.printStackTrace(System.out);
167*cdf0e10cSrcweir     }}
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     private com.sun.star.util.URL getDispatchURL(String _sURL){
171*cdf0e10cSrcweir         try {
172*cdf0e10cSrcweir             Object oTransformer = getXMultiComponentFactory().createInstanceWithContext("com.sun.star.util.URLTransformer", getXComponentContext());
173*cdf0e10cSrcweir             XURLTransformer xTransformer = (XURLTransformer) UnoRuntime.queryInterface(XURLTransformer.class, oTransformer);
174*cdf0e10cSrcweir             com.sun.star.util.URL[] oURL = new com.sun.star.util.URL[1];
175*cdf0e10cSrcweir             oURL[0] = new com.sun.star.util.URL();
176*cdf0e10cSrcweir             oURL[0].Complete = _sURL;
177*cdf0e10cSrcweir             xTransformer.parseStrict(oURL);
178*cdf0e10cSrcweir         return oURL[0];
179*cdf0e10cSrcweir         } catch (Exception e) {
180*cdf0e10cSrcweir             e.printStackTrace(System.out);
181*cdf0e10cSrcweir         }
182*cdf0e10cSrcweir         return null;
183*cdf0e10cSrcweir     }
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     private XFrame getCurrentFrame(){
187*cdf0e10cSrcweir     try{
188*cdf0e10cSrcweir         Object oDesktop = getXMultiComponentFactory().createInstanceWithContext("com.sun.star.frame.Desktop", getXComponentContext());
189*cdf0e10cSrcweir         XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, oDesktop);
190*cdf0e10cSrcweir         return xDesktop.getCurrentFrame();
191*cdf0e10cSrcweir     } catch (Exception e) {
192*cdf0e10cSrcweir         e.printStackTrace(System.out);
193*cdf0e10cSrcweir         return null;
194*cdf0e10cSrcweir     }}
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir     private XDispatch getXDispatcher(com.sun.star.util.URL oURL) {
198*cdf0e10cSrcweir     try {
199*cdf0e10cSrcweir         com.sun.star.util.URL[] oURLArray = new com.sun.star.util.URL[1];
200*cdf0e10cSrcweir         oURLArray[0] = oURL;
201*cdf0e10cSrcweir         XDispatchProvider xDispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, getCurrentFrame());
202*cdf0e10cSrcweir         XDispatch xDispatch = xDispatchProvider.queryDispatch(oURLArray[0], "_top", FrameSearchFlag.ALL); // "_self"
203*cdf0e10cSrcweir         return xDispatch;
204*cdf0e10cSrcweir     } catch (Exception e) {
205*cdf0e10cSrcweir         e.printStackTrace(System.out);
206*cdf0e10cSrcweir         return null;
207*cdf0e10cSrcweir     }}
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir     private PropertyValue[] loadArgs(String url) {
211*cdf0e10cSrcweir         PropertyValue pv = new PropertyValue();
212*cdf0e10cSrcweir         pv.Name = "URL";
213*cdf0e10cSrcweir         pv.Value = url;
214*cdf0e10cSrcweir         return new PropertyValue[] {pv};
215*cdf0e10cSrcweir     }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir     public boolean isFilterApplicable(String _sFilter, String _sName){
220*cdf0e10cSrcweir         boolean bFilterDoesApply = true;
221*cdf0e10cSrcweir         if (_sFilter.length() > 0){
222*cdf0e10cSrcweir             if (_sName.indexOf(_sFilter) == -1){
223*cdf0e10cSrcweir                 bFilterDoesApply = false;
224*cdf0e10cSrcweir             }
225*cdf0e10cSrcweir         }
226*cdf0e10cSrcweir         return bFilterDoesApply;
227*cdf0e10cSrcweir     }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir //    public static String getServiceDescription(Object _oUnoObject){
231*cdf0e10cSrcweir //        String sClassName = "";
232*cdf0e10cSrcweir //        XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, _oUnoObject);
233*cdf0e10cSrcweir //        if (xServiceInfo != null){
234*cdf0e10cSrcweir //            String[] sChildServiceNames = removeMandatoryServiceNames(xServiceInfo.getSupportedServiceNames());
235*cdf0e10cSrcweir //            if (sChildServiceNames.length > 0){
236*cdf0e10cSrcweir //                sClassName = sChildServiceNames[0];
237*cdf0e10cSrcweir //            }
238*cdf0e10cSrcweir //        }
239*cdf0e10cSrcweir //        return sClassName;
240*cdf0e10cSrcweir //    }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir     private static String[] getMandatoryServiceNames(String _sServiceName){
245*cdf0e10cSrcweir     String[] sMandatoryServiceNames  = new String[]{};
246*cdf0e10cSrcweir     try {
247*cdf0e10cSrcweir         TypeClass[] eTypeClasses = new com.sun.star.uno.TypeClass[1];
248*cdf0e10cSrcweir         eTypeClasses[0] = com.sun.star.uno.TypeClass.SERVICE;
249*cdf0e10cSrcweir         XTypeDescriptionEnumeration xTDEnumeration = getXTypeDescriptionEnumerationAccess().createTypeDescriptionEnumeration(Introspector.getModuleName(_sServiceName), eTypeClasses, TypeDescriptionSearchDepth.INFINITE);
250*cdf0e10cSrcweir         while (xTDEnumeration.hasMoreElements()) {
251*cdf0e10cSrcweir             XTypeDescription xTD = xTDEnumeration.nextTypeDescription();
252*cdf0e10cSrcweir             if (xTD.getName().equals(_sServiceName)){
253*cdf0e10cSrcweir                 XServiceTypeDescription xServiceTypeDescription = (XServiceTypeDescription) UnoRuntime.queryInterface(XServiceTypeDescription.class, xTD);
254*cdf0e10cSrcweir                 XServiceTypeDescription[] xMandatoryServiceTypeDescriptions =  xServiceTypeDescription.getMandatoryServices();
255*cdf0e10cSrcweir                 int nlength = xMandatoryServiceTypeDescriptions.length;
256*cdf0e10cSrcweir                 sMandatoryServiceNames  = new String[nlength];
257*cdf0e10cSrcweir                 for (int i = 0; i < nlength; i++){
258*cdf0e10cSrcweir                     sMandatoryServiceNames[i] = xMandatoryServiceTypeDescriptions[i].getName();
259*cdf0e10cSrcweir                 }
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir             }
262*cdf0e10cSrcweir         }
263*cdf0e10cSrcweir     } catch ( java.lang.Exception e) {
264*cdf0e10cSrcweir         System.out.println(System.out);
265*cdf0e10cSrcweir     }
266*cdf0e10cSrcweir         return sMandatoryServiceNames;
267*cdf0e10cSrcweir     }
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir     private static String[] removeMandatoryServiceNames(String[] _sServiceNames){
271*cdf0e10cSrcweir     try{
272*cdf0e10cSrcweir         List aList = java.util.Arrays.asList(_sServiceNames);
273*cdf0e10cSrcweir         Vector aVector = new Vector(aList);
274*cdf0e10cSrcweir         for (int n = 0; n < _sServiceNames.length; n++){
275*cdf0e10cSrcweir             String[] sDelServiceNames = getMandatoryServiceNames(_sServiceNames[n]);
276*cdf0e10cSrcweir             for (int m = 0; m < sDelServiceNames.length; m++){
277*cdf0e10cSrcweir                 if (aVector.contains(sDelServiceNames[m])){
278*cdf0e10cSrcweir                     int nIndex = aVector.indexOf(sDelServiceNames[m]);
279*cdf0e10cSrcweir                     aVector.remove(nIndex);
280*cdf0e10cSrcweir                 }
281*cdf0e10cSrcweir             }
282*cdf0e10cSrcweir         }
283*cdf0e10cSrcweir         String[] sRetArray = new String[aVector.size()];
284*cdf0e10cSrcweir         aVector.toArray(sRetArray);
285*cdf0e10cSrcweir         return sRetArray;
286*cdf0e10cSrcweir     } catch (java.lang.Exception exception) {
287*cdf0e10cSrcweir         exception.printStackTrace(System.out);
288*cdf0e10cSrcweir     }
289*cdf0e10cSrcweir         return new String[]{};
290*cdf0e10cSrcweir     }
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir     public  static String getDisplayValueOfPrimitiveType(Object _objectElement){
294*cdf0e10cSrcweir     String sValue ="";
295*cdf0e10cSrcweir     try{
296*cdf0e10cSrcweir         if (AnyConverter.isString(_objectElement)){
297*cdf0e10cSrcweir             sValue = AnyConverter.toString(_objectElement);
298*cdf0e10cSrcweir         }
299*cdf0e10cSrcweir         else if (AnyConverter.isBoolean(_objectElement)){
300*cdf0e10cSrcweir             sValue += AnyConverter.toBoolean(_objectElement);
301*cdf0e10cSrcweir         }
302*cdf0e10cSrcweir         else if (AnyConverter.isByte(_objectElement)){
303*cdf0e10cSrcweir             sValue += AnyConverter.toByte(_objectElement);
304*cdf0e10cSrcweir         }
305*cdf0e10cSrcweir         else if (AnyConverter.isChar(_objectElement)){
306*cdf0e10cSrcweir             sValue += AnyConverter.toChar(_objectElement);
307*cdf0e10cSrcweir         }
308*cdf0e10cSrcweir         else if (AnyConverter.isDouble(_objectElement)){
309*cdf0e10cSrcweir             sValue += AnyConverter.toDouble(_objectElement);
310*cdf0e10cSrcweir         }
311*cdf0e10cSrcweir         else if (AnyConverter.isFloat(_objectElement)){
312*cdf0e10cSrcweir             sValue += AnyConverter.toFloat(_objectElement);
313*cdf0e10cSrcweir         }
314*cdf0e10cSrcweir         else if (AnyConverter.isInt(_objectElement)){
315*cdf0e10cSrcweir             sValue += AnyConverter.toInt(_objectElement);
316*cdf0e10cSrcweir         }
317*cdf0e10cSrcweir         else if (AnyConverter.isLong(_objectElement)){
318*cdf0e10cSrcweir             sValue += AnyConverter.toLong(_objectElement);
319*cdf0e10cSrcweir         }
320*cdf0e10cSrcweir         else if (AnyConverter.isShort(_objectElement)){
321*cdf0e10cSrcweir             sValue += AnyConverter.toShort(_objectElement);
322*cdf0e10cSrcweir         }
323*cdf0e10cSrcweir     }
324*cdf0e10cSrcweir     catch( Exception e ) {
325*cdf0e10cSrcweir         System.err.println( e );
326*cdf0e10cSrcweir     }
327*cdf0e10cSrcweir         return sValue;
328*cdf0e10cSrcweir     }
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir     protected static String[] getDisplayValuesofPrimitiveArray(Object _oUnoObject){
331*cdf0e10cSrcweir     String[] sDisplayValues = null;
332*cdf0e10cSrcweir     try{
333*cdf0e10cSrcweir         Type aType = AnyConverter.getType(_oUnoObject);
334*cdf0e10cSrcweir         TypeClass aTypeClass = aType.getTypeClass();
335*cdf0e10cSrcweir         int nTypeValue = aTypeClass.getValue();
336*cdf0e10cSrcweir         if (nTypeValue == TypeClass.SEQUENCE_value){
337*cdf0e10cSrcweir             nTypeValue = (sequenceComponentType(aType)).getTypeClass().getValue();
338*cdf0e10cSrcweir         }
339*cdf0e10cSrcweir         switch (nTypeValue){
340*cdf0e10cSrcweir             case TypeClass.BOOLEAN_value:
341*cdf0e10cSrcweir                 boolean[] bBooleans = (boolean[]) AnyConverter.toArray(_oUnoObject);
342*cdf0e10cSrcweir                 sDisplayValues = new String[bBooleans.length];
343*cdf0e10cSrcweir                 for (int i = 0; i < bBooleans.length; i++){
344*cdf0e10cSrcweir                     sDisplayValues[i] = Boolean.toString(bBooleans[i]);
345*cdf0e10cSrcweir                 }
346*cdf0e10cSrcweir                 break;
347*cdf0e10cSrcweir             case TypeClass.BYTE_value:
348*cdf0e10cSrcweir                 byte[] bBytes = (byte[]) AnyConverter.toArray(_oUnoObject);
349*cdf0e10cSrcweir                 sDisplayValues = new String[bBytes.length];
350*cdf0e10cSrcweir                 for (int i = 0; i < bBytes.length; i++){
351*cdf0e10cSrcweir                     sDisplayValues[i] = "" + bBytes[i];
352*cdf0e10cSrcweir                 }
353*cdf0e10cSrcweir                 break;
354*cdf0e10cSrcweir             case TypeClass.DOUBLE_value:
355*cdf0e10cSrcweir                 double[] fdoubles = (double[]) AnyConverter.toArray(_oUnoObject);
356*cdf0e10cSrcweir                 sDisplayValues = new String[fdoubles.length];
357*cdf0e10cSrcweir                 for (int i = 0; i < fdoubles.length; i++){
358*cdf0e10cSrcweir                     sDisplayValues[i] = String.valueOf(fdoubles[i]);
359*cdf0e10cSrcweir                 }
360*cdf0e10cSrcweir                 break;
361*cdf0e10cSrcweir             case TypeClass.FLOAT_value:
362*cdf0e10cSrcweir                 float[] ffloats = (float[]) AnyConverter.toArray(_oUnoObject);
363*cdf0e10cSrcweir                 sDisplayValues = new String[ffloats.length];
364*cdf0e10cSrcweir                 for (int i = 0; i < ffloats.length; i++){
365*cdf0e10cSrcweir                     sDisplayValues[i] = String.valueOf(ffloats[i]);
366*cdf0e10cSrcweir                 }
367*cdf0e10cSrcweir                 break;
368*cdf0e10cSrcweir             case TypeClass.LONG_value:
369*cdf0e10cSrcweir                 int[] nints = (int[]) AnyConverter.toArray(_oUnoObject);
370*cdf0e10cSrcweir                 sDisplayValues = new String[nints.length];
371*cdf0e10cSrcweir                 for (int i = 0; i < nints.length; i++){
372*cdf0e10cSrcweir                     sDisplayValues[i] = String.valueOf(nints[i]);
373*cdf0e10cSrcweir                 }
374*cdf0e10cSrcweir                 break;
375*cdf0e10cSrcweir             case TypeClass.HYPER_value:
376*cdf0e10cSrcweir                 long[] nlongs = (long[]) AnyConverter.toArray(_oUnoObject);
377*cdf0e10cSrcweir                 sDisplayValues = new String[nlongs.length];
378*cdf0e10cSrcweir                 for (int i = 0; i < nlongs.length; i++){
379*cdf0e10cSrcweir                     sDisplayValues[i] = String.valueOf(nlongs[i]);
380*cdf0e10cSrcweir                 }
381*cdf0e10cSrcweir                 break;
382*cdf0e10cSrcweir             case TypeClass.SHORT_value:
383*cdf0e10cSrcweir                 short[] nShorts = (short[]) AnyConverter.toArray(_oUnoObject);
384*cdf0e10cSrcweir                 sDisplayValues = new String[nShorts.length];
385*cdf0e10cSrcweir                 for (int i = 0; i < nShorts.length; i++){
386*cdf0e10cSrcweir                     sDisplayValues[i] = "" +  nShorts[i];
387*cdf0e10cSrcweir                 }
388*cdf0e10cSrcweir                 break;
389*cdf0e10cSrcweir             case TypeClass.CHAR_value:
390*cdf0e10cSrcweir                 break;
391*cdf0e10cSrcweir             default:
392*cdf0e10cSrcweir                 System.out.println("Value could not be retrieved: " + aType.getTypeClass().getClass().getName());
393*cdf0e10cSrcweir             }
394*cdf0e10cSrcweir         return sDisplayValues;
395*cdf0e10cSrcweir     }
396*cdf0e10cSrcweir     catch( Exception e ) {
397*cdf0e10cSrcweir         System.err.println( e );
398*cdf0e10cSrcweir         return null;
399*cdf0e10cSrcweir     }}
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir     private static Type sequenceComponentType(Type sequenceType) {
403*cdf0e10cSrcweir //        assert sequenceType.getTypeClass() == TypeClass.SEQUENCE;
404*cdf0e10cSrcweir         String n = sequenceType.getTypeName();
405*cdf0e10cSrcweir         final String PREFIX = "[]";
406*cdf0e10cSrcweir //        assert n.startsWith(PREFIX);
407*cdf0e10cSrcweir         return new Type(n.substring(PREFIX.length()));
408*cdf0e10cSrcweir     }
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir     public static String getNodeDescription(Object _oUnoObject, int _nIndex){
412*cdf0e10cSrcweir         return getNodeDescription(_oUnoObject) + "[" + (_nIndex + 1) + "]";
413*cdf0e10cSrcweir     }
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir     public static String getNodeDescription(Object _oUnoObject){
417*cdf0e10cSrcweir         XServiceInfo xServiceInfo = ( XServiceInfo ) UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject );
418*cdf0e10cSrcweir         if ( xServiceInfo != null ) {
419*cdf0e10cSrcweir             return xServiceInfo.getImplementationName();
420*cdf0e10cSrcweir         }
421*cdf0e10cSrcweir         String sClassName = _oUnoObject.getClass().getName();
422*cdf0e10cSrcweir         if (Introspector.getIntrospector().isObjectPrimitive(_oUnoObject)){         //super.isO{sObjectClassName.equals("java.lang.String"))issClassName.equals("java.lang.String"))
423*cdf0e10cSrcweir             return _oUnoObject.toString();
424*cdf0e10cSrcweir         }
425*cdf0e10cSrcweir         else{
426*cdf0e10cSrcweir             return _oUnoObject.getClass().getName();
427*cdf0e10cSrcweir         }
428*cdf0e10cSrcweir     }
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir     public void setParameterObjects(Object[] _oParamObjects){
431*cdf0e10cSrcweir         m_oParamObjects = _oParamObjects;
432*cdf0e10cSrcweir     }
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir     public Object[] getParameterObjects(){
435*cdf0e10cSrcweir         return m_oParamObjects;
436*cdf0e10cSrcweir     }
437*cdf0e10cSrcweir }
438