1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski package com.sun.star.help; 25*b1cdbd2cSJim Jagielski 26*b1cdbd2cSJim Jagielski import com.sun.star.lib.uno.helper.WeakBase; 27*b1cdbd2cSJim Jagielski import com.sun.star.lang.XServiceInfo; 28*b1cdbd2cSJim Jagielski import com.sun.star.script.XInvocation; 29*b1cdbd2cSJim Jagielski import com.sun.star.beans.XIntrospectionAccess; 30*b1cdbd2cSJim Jagielski import com.sun.star.uno.AnyConverter; 31*b1cdbd2cSJim Jagielski import com.sun.star.uno.XComponentContext; 32*b1cdbd2cSJim Jagielski 33*b1cdbd2cSJim Jagielski import java.io.File; 34*b1cdbd2cSJim Jagielski import java.io.FileNotFoundException; 35*b1cdbd2cSJim Jagielski import java.io.IOException; 36*b1cdbd2cSJim Jagielski import java.util.Date; 37*b1cdbd2cSJim Jagielski import java.util.zip.ZipOutputStream; 38*b1cdbd2cSJim Jagielski 39*b1cdbd2cSJim Jagielski public class HelpIndexer extends WeakBase 40*b1cdbd2cSJim Jagielski implements XServiceInfo, XInvocation 41*b1cdbd2cSJim Jagielski { 42*b1cdbd2cSJim Jagielski static private final String __serviceName = 43*b1cdbd2cSJim Jagielski "com.sun.star.help.HelpIndexer"; 44*b1cdbd2cSJim Jagielski static private final String aCreateIndexMethodName = "createIndex"; 45*b1cdbd2cSJim Jagielski 46*b1cdbd2cSJim Jagielski static private com.sun.star.help.HelpIndexerTool helpindexer = new com.sun.star.help.HelpIndexerTool(); 47*b1cdbd2cSJim Jagielski HelpIndexer()48*b1cdbd2cSJim Jagielski public HelpIndexer() 49*b1cdbd2cSJim Jagielski { 50*b1cdbd2cSJim Jagielski } 51*b1cdbd2cSJim Jagielski HelpIndexer(XComponentContext xCompContext)52*b1cdbd2cSJim Jagielski public HelpIndexer(XComponentContext xCompContext) 53*b1cdbd2cSJim Jagielski { 54*b1cdbd2cSJim Jagielski } 55*b1cdbd2cSJim Jagielski mainImpl( String[] args, boolean bExtensionMode )56*b1cdbd2cSJim Jagielski public static void mainImpl( String[] args, boolean bExtensionMode ) 57*b1cdbd2cSJim Jagielski { 58*b1cdbd2cSJim Jagielski helpindexer.mainImpl( args , bExtensionMode ); 59*b1cdbd2cSJim Jagielski } 60*b1cdbd2cSJim Jagielski createZipFile( File aDirToZip, String aTargetZipFileStr )61*b1cdbd2cSJim Jagielski public static void createZipFile( File aDirToZip, String aTargetZipFileStr ) 62*b1cdbd2cSJim Jagielski throws FileNotFoundException, IOException 63*b1cdbd2cSJim Jagielski { 64*b1cdbd2cSJim Jagielski helpindexer.createZipFile( aDirToZip , aTargetZipFileStr ); 65*b1cdbd2cSJim Jagielski } 66*b1cdbd2cSJim Jagielski addToZipRecursively( ZipOutputStream zos, File aFile, String aBasePath )67*b1cdbd2cSJim Jagielski public static void addToZipRecursively( ZipOutputStream zos, File aFile, String aBasePath ) 68*b1cdbd2cSJim Jagielski throws FileNotFoundException, IOException 69*b1cdbd2cSJim Jagielski { 70*b1cdbd2cSJim Jagielski helpindexer.addToZipRecursively( zos , aFile , aBasePath ); 71*b1cdbd2cSJim Jagielski } 72*b1cdbd2cSJim Jagielski deleteRecursively( File aFile )73*b1cdbd2cSJim Jagielski static public boolean deleteRecursively( File aFile ) 74*b1cdbd2cSJim Jagielski { 75*b1cdbd2cSJim Jagielski return helpindexer.deleteRecursively( aFile ); 76*b1cdbd2cSJim Jagielski } 77*b1cdbd2cSJim Jagielski 78*b1cdbd2cSJim Jagielski //=================================================== 79*b1cdbd2cSJim Jagielski // XInvocation getIntrospection()80*b1cdbd2cSJim Jagielski public XIntrospectionAccess getIntrospection() 81*b1cdbd2cSJim Jagielski { 82*b1cdbd2cSJim Jagielski return null; 83*b1cdbd2cSJim Jagielski } 84*b1cdbd2cSJim Jagielski invoke( String aFunctionName, java.lang.Object[] aParams, short[][] aOutParamIndex, java.lang.Object[][] aOutParam )85*b1cdbd2cSJim Jagielski public Object invoke( String aFunctionName, java.lang.Object[] aParams, 86*b1cdbd2cSJim Jagielski short[][] aOutParamIndex, java.lang.Object[][] aOutParam ) 87*b1cdbd2cSJim Jagielski throws com.sun.star.lang.IllegalArgumentException, 88*b1cdbd2cSJim Jagielski com.sun.star.script.CannotConvertException, 89*b1cdbd2cSJim Jagielski com.sun.star.reflection.InvocationTargetException 90*b1cdbd2cSJim Jagielski { 91*b1cdbd2cSJim Jagielski if( 92*b1cdbd2cSJim Jagielski !aFunctionName.equals( aCreateIndexMethodName ) ) 93*b1cdbd2cSJim Jagielski throw new com.sun.star.lang.IllegalArgumentException(); 94*b1cdbd2cSJim Jagielski 95*b1cdbd2cSJim Jagielski aOutParamIndex[0] = new short[0]; 96*b1cdbd2cSJim Jagielski aOutParam[0] = new Object[0]; 97*b1cdbd2cSJim Jagielski 98*b1cdbd2cSJim Jagielski int nParamCount = aParams.length; 99*b1cdbd2cSJim Jagielski String aStrs[] = new String[nParamCount]; 100*b1cdbd2cSJim Jagielski for( int i = 0 ; i < nParamCount ; i++ ) 101*b1cdbd2cSJim Jagielski { 102*b1cdbd2cSJim Jagielski try 103*b1cdbd2cSJim Jagielski { 104*b1cdbd2cSJim Jagielski aStrs[i] = AnyConverter.toString( aParams[i] ); 105*b1cdbd2cSJim Jagielski } 106*b1cdbd2cSJim Jagielski catch( IllegalArgumentException e ) 107*b1cdbd2cSJim Jagielski { 108*b1cdbd2cSJim Jagielski aStrs[i] = ""; 109*b1cdbd2cSJim Jagielski } 110*b1cdbd2cSJim Jagielski } 111*b1cdbd2cSJim Jagielski 112*b1cdbd2cSJim Jagielski boolean bExtensionMode = true; 113*b1cdbd2cSJim Jagielski mainImpl( aStrs, bExtensionMode ); 114*b1cdbd2cSJim Jagielski 115*b1cdbd2cSJim Jagielski return null; 116*b1cdbd2cSJim Jagielski } 117*b1cdbd2cSJim Jagielski setValue( String aPropertyName, java.lang.Object aValue )118*b1cdbd2cSJim Jagielski public void setValue( String aPropertyName, java.lang.Object aValue ) 119*b1cdbd2cSJim Jagielski throws com.sun.star.beans.UnknownPropertyException, 120*b1cdbd2cSJim Jagielski com.sun.star.script.CannotConvertException, 121*b1cdbd2cSJim Jagielski com.sun.star.reflection.InvocationTargetException 122*b1cdbd2cSJim Jagielski { 123*b1cdbd2cSJim Jagielski throw new com.sun.star.beans.UnknownPropertyException(); 124*b1cdbd2cSJim Jagielski } 125*b1cdbd2cSJim Jagielski getValue( String aPropertyName )126*b1cdbd2cSJim Jagielski public Object getValue( String aPropertyName ) 127*b1cdbd2cSJim Jagielski throws com.sun.star.beans.UnknownPropertyException 128*b1cdbd2cSJim Jagielski { 129*b1cdbd2cSJim Jagielski throw new com.sun.star.beans.UnknownPropertyException(); 130*b1cdbd2cSJim Jagielski } 131*b1cdbd2cSJim Jagielski hasMethod( String aMethodName )132*b1cdbd2cSJim Jagielski public boolean hasMethod( String aMethodName ) 133*b1cdbd2cSJim Jagielski { 134*b1cdbd2cSJim Jagielski boolean bRet = (aMethodName.equals( aCreateIndexMethodName ) ); 135*b1cdbd2cSJim Jagielski return bRet; 136*b1cdbd2cSJim Jagielski } hasProperty( String aName )137*b1cdbd2cSJim Jagielski public boolean hasProperty( String aName ) { 138*b1cdbd2cSJim Jagielski return false; 139*b1cdbd2cSJim Jagielski } 140*b1cdbd2cSJim Jagielski 141*b1cdbd2cSJim Jagielski 142*b1cdbd2cSJim Jagielski 143*b1cdbd2cSJim Jagielski /** This method returns an array of all supported service names. 144*b1cdbd2cSJim Jagielski * @return Array of supported service names. 145*b1cdbd2cSJim Jagielski */ getSupportedServiceNames()146*b1cdbd2cSJim Jagielski public String[] getSupportedServiceNames() 147*b1cdbd2cSJim Jagielski { 148*b1cdbd2cSJim Jagielski return getServiceNames(); 149*b1cdbd2cSJim Jagielski } 150*b1cdbd2cSJim Jagielski 151*b1cdbd2cSJim Jagielski /** This method is a simple helper function to used in the 152*b1cdbd2cSJim Jagielski * static component initialisation functions as well as in 153*b1cdbd2cSJim Jagielski * getSupportedServiceNames. 154*b1cdbd2cSJim Jagielski */ getServiceNames()155*b1cdbd2cSJim Jagielski public static String[] getServiceNames() 156*b1cdbd2cSJim Jagielski { 157*b1cdbd2cSJim Jagielski String[] sSupportedServiceNames = { __serviceName }; 158*b1cdbd2cSJim Jagielski return sSupportedServiceNames; 159*b1cdbd2cSJim Jagielski } 160*b1cdbd2cSJim Jagielski 161*b1cdbd2cSJim Jagielski 162*b1cdbd2cSJim Jagielski /** This method returns true, if the given service will be 163*b1cdbd2cSJim Jagielski * supported by the component. 164*b1cdbd2cSJim Jagielski * @param sServiceName Service name. 165*b1cdbd2cSJim Jagielski * @return True, if the given service name will be supported. 166*b1cdbd2cSJim Jagielski */ supportsService( String sServiceName )167*b1cdbd2cSJim Jagielski public boolean supportsService( String sServiceName ) 168*b1cdbd2cSJim Jagielski { 169*b1cdbd2cSJim Jagielski return sServiceName.equals( __serviceName ); 170*b1cdbd2cSJim Jagielski } 171*b1cdbd2cSJim Jagielski 172*b1cdbd2cSJim Jagielski 173*b1cdbd2cSJim Jagielski /** Return the class name of the component. 174*b1cdbd2cSJim Jagielski * @return Class name of the component. 175*b1cdbd2cSJim Jagielski */ getImplementationName()176*b1cdbd2cSJim Jagielski public String getImplementationName() 177*b1cdbd2cSJim Jagielski { 178*b1cdbd2cSJim Jagielski return HelpIndexer.class.getName(); 179*b1cdbd2cSJim Jagielski } 180*b1cdbd2cSJim Jagielski 181*b1cdbd2cSJim Jagielski } 182*b1cdbd2cSJim Jagielski 183