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