/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * 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. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * 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. *
*************************************************************************/
/** The purpose of this class is to provide a factory for creating the service * (<CODE>__getServiceFactory</CODE>) and writes the information into the given * registry key (<CODE>__writeRegistryServiceInfo</CODE>).
*/ publicclass Inspector{ publicstaticfinal String sIDLDOCUMENTSUBFOLDER = "docs/idl/ref/";
/** This class implements the method of the interface XInstanceInspector. * Also the class implements the interfaces XServiceInfo, and XTypeProvider.
*/ publicstaticclass _Inspector extends WeakBase implements XInstanceInspector, XServiceInfo{
privatestaticfinal String __serviceName = "org.openoffice.InstanceInspector"; private HashMap<String, String> aApplicationHashMap = new HashMap<String, String>(); private String sTitle = "Object Inspector"; private ArrayList<XComponent> aHiddenDocuments = new ArrayList<XComponent>(); private XComponentContext m_xComponentContext; private HashMap<String, InspectorPane> aInspectorPanes = new HashMap<String, InspectorPane>(); private XDialogProvider m_oSwingDialogProvider; private TDocSupplier oTDocSupplier; private Introspector m_oIntrospector = null; // TODO: improve these strings: privatestaticfinal String sWRONGINSTALLATIONPATH = "Your selected path does not refer to an SDK-Installation!"; /** Creates a new instance of Dialog */ public _Inspector(XComponentContext _xComponentContext) {
m_xComponentContext = _xComponentContext;
m_oIntrospector = Introspector.getIntrospector(m_xComponentContext);
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);
}
public XComponentContext getXComponentContext(){ return m_xComponentContext;
}
public HashMap<String, InspectorPane> getInspectorPages(){ return aInspectorPanes;
}
publicvoid setSourceCodeLanguage(finalint _nLanguage){ try{
String sLanguage = "Java";
XNameAccess xNameAccess = getConfigurationAccess("org.openoffice.inspector.ObjectInspector", true);
XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xNameAccess); switch (_nLanguage){ case XLanguageSourceCodeGenerator.nJAVA:
sLanguage = "Java"; break; case XLanguageSourceCodeGenerator.nCPLUSPLUS:
sLanguage = "CPlusPlus"; break; case XLanguageSourceCodeGenerator.nBASIC:
sLanguage = "Basic"; break; default:
System.out.println("Warning: Sourcecode language is not defined!");
}
xPropertySet.setPropertyValue("Language", sLanguage);
XChangesBatch xBatch = UnoRuntime.queryInterface(XChangesBatch.class, xNameAccess);
xBatch.commitChanges(); for (int i = 0; i < m_oSwingDialogProvider.getInspectorPageCount(); i++){
m_oSwingDialogProvider.getInspectorPage(i).convertCompleteSourceCode(_nLanguage);
}
}catch( Exception exception ) {
exception.printStackTrace(System.err);
}}
private TDocSupplier getTDocSupplier(){ if (oTDocSupplier == null){
oTDocSupplier = new TDocSupplier(m_xComponentContext);
} return oTDocSupplier;
}
public String[] getTDocUrls(){ return getTDocSupplier().getTDocUrls();
}
public String[] getTDocTitles(String[] _sTDocUrls){ return getTDocSupplier().getTDocTitles(_sTDocUrls);
}
public String[][] getApplicationUrls(){
Set<String> aSet = aApplicationHashMap.keySet();
String[][] sReturnList = new String[aSet.size()][]; int n= 0; for ( Iterator<String> i = aSet.iterator(); i.hasNext(); ){
String[] sSingleApplication = new String[2];
sSingleApplication[0] = i.next(); // assign the title in the second index
sSingleApplication[1] = aApplicationHashMap.get(sSingleApplication[0]);
sReturnList[n++] = sSingleApplication;
} return sReturnList;
}
publicvoid disposeHiddenDocuments(){ int nHiddenCount = aHiddenDocuments.size(); if (nHiddenCount > 0){ for (int i = nHiddenCount - 1; i >= 0; i--){
XComponent xComponent = aHiddenDocuments.get(i); if (xComponent != null){ try {
XCloseable xCloseable = UnoRuntime.queryInterface(XCloseable.class, xComponent);
xCloseable.close(true);
aHiddenDocuments.remove(i);
} catch (CloseVetoException ex) {
ex.printStackTrace();
}
}
}
}
}
// Implement the interface XServiceInfo /** Get all supported service names. * @return Supported service names.
*/ public String[] getSupportedServiceNames() { return getServiceNames();
}
// Implement the interface XServiceInfo /** Test, if the given service will be supported. * @return Return true, if the service will be supported.
*/ publicboolean supportsService( String sServiceName ) { return sServiceName.equals( __serviceName );
}
// Implement the interface XServiceInfo /** Get the implementation name of the component. * @return Implementation name of the component.
*/ public String getImplementationName() { return _Inspector.class.getName();
}
/** * Gives a factory for creating the service. * This method is called by the <code>JavaLoader</code> * <p> * @return returns a <code>XSingleComponentFactory</code> for creating * the component * @param sImplName the name of the implementation for which a * service is desired * @see com.sun.star.comp.loader.JavaLoader
*/ publicstatic XSingleComponentFactory __getComponentFactory( String sImplName )
{
XSingleComponentFactory xFactory = null; if ( sImplName.equals( _Inspector.class.getName() ) )
xFactory = Factory.createComponentFactory(_Inspector.class, _Inspector.getServiceNames()); if ( xFactory == null )
xFactory = InspectorAddon.__getComponentFactory(sImplName); return xFactory;
}
/** * Writes the service information into the given registry key. * This method is called by the <code>JavaLoader</code> * <p> * @return returns true if the operation succeeded * @param regKey the registryKey * @see com.sun.star.comp.loader.JavaLoader
*/ publicstaticboolean __writeRegistryServiceInfo(XRegistryKey regKey) { return (Factory.writeRegistryServiceInfo(_Inspector.class.getName(), _Inspector.getServiceNames(), regKey)
&& InspectorAddon.__writeRegistryServiceInfo(regKey));
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.