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