merge the formfield patch from ooo-build
[ooovba.git] / xmlhelp / source / com / sun / star / help / HelpComponent.java
blobb27ea5bb788cf5f17371dd1b1f69160502e66216
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: HelpSearch.java,v $
10 * $Revision: 1.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package com.sun.star.help;
33 import com.sun.star.lib.uno.helper.Factory;
34 import com.sun.star.lang.XSingleComponentFactory;
35 import com.sun.star.registry.XRegistryKey;
38 import com.sun.star.lib.uno.helper.Factory;
39 import com.sun.star.lang.XMultiComponentFactory;
40 import com.sun.star.lang.XSingleComponentFactory;
41 import com.sun.star.lib.uno.helper.WeakBase;
42 import com.sun.star.uno.UnoRuntime;
43 import com.sun.star.uno.XComponentContext;
44 import com.sun.star.registry.XRegistryKey;
45 import com.sun.star.lang.XInitialization;
46 import com.sun.star.lang.XTypeProvider;
47 import com.sun.star.lang.XServiceInfo;
48 import com.sun.star.uno.Type;
49 import com.sun.star.uno.Any;
50 import com.sun.star.uno.AnyConverter;
52 import org.apache.lucene.analysis.Analyzer;
53 import org.apache.lucene.analysis.standard.StandardAnalyzer;
54 import org.apache.lucene.document.Document;
55 import org.apache.lucene.index.FilterIndexReader;
56 import org.apache.lucene.index.IndexReader;
57 import org.apache.lucene.index.Term;
58 import org.apache.lucene.queryParser.QueryParser;
59 import org.apache.lucene.search.Hits;
60 import org.apache.lucene.search.IndexSearcher;
61 import org.apache.lucene.search.Query;
62 import org.apache.lucene.search.Searcher;
63 import org.apache.lucene.search.TermQuery;
64 import org.apache.lucene.search.WildcardQuery;
66 import com.sun.star.script.XInvocation;
67 import com.sun.star.beans.XIntrospectionAccess;
69 import java.io.FileOutputStream;
70 import java.io.PrintStream;
71 import java.io.File;
74 /** This class capsulates the class, that implements the minimal component, a
75 * factory for creating the service (<CODE>__getComponentFactory</CODE>) and a
76 * method, that writes the information into the given registry key
77 * (<CODE>__writeRegistryServiceInfo</CODE>).
79 public class HelpComponent
81 /**
82 * Gives a factory for creating the service.
83 * This method is called by the <code>JavaLoader</code>
84 * <p>
85 * @return returns a <code>XSingleComponentFactory</code> for creating
86 * the component
87 * @param sImplName the name of the implementation for which a
88 * service is desired
89 * @see com.sun.star.comp.loader.JavaLoader
91 public static XSingleComponentFactory __getComponentFactory(String sImplName)
93 XSingleComponentFactory xFactory = null;
95 if ( sImplName.equals( HelpSearch._HelpSearch.class.getName() ) )
96 xFactory = Factory.createComponentFactory(HelpSearch._HelpSearch.class,
97 HelpSearch._HelpSearch.getServiceNames());
98 else if ( sImplName.equals( HelpIndexer.class.getName() ) )
99 xFactory = Factory.createComponentFactory(HelpIndexer.class,
100 HelpIndexer.getServiceNames());
101 return xFactory;
105 * Writes the service information into the given registry key.
106 * This method is called by the <code>JavaLoader</code>
107 * <p>
108 * @return returns true if the operation succeeded
109 * @param regKey the registryKey
110 * @see com.sun.star.comp.loader.JavaLoader
112 public static boolean __writeRegistryServiceInfo(XRegistryKey regKey)
114 boolean bSuccessHelpSearch = Factory.writeRegistryServiceInfo
115 (HelpSearch._HelpSearch.class.getName(),
116 HelpSearch._HelpSearch.getServiceNames(), regKey);
117 boolean bSuccessHelpIndexer = Factory.writeRegistryServiceInfo
118 (HelpIndexer.class.getName(),
119 HelpIndexer.getServiceNames(), regKey);
121 return bSuccessHelpSearch && bSuccessHelpIndexer;
123 /** This method is a member of the interface for initializing an object
124 * directly after its creation.
125 * @param object This array of arbitrary objects will be passed to the
126 * component after its creation.
127 * @throws Exception Every exception will not be handled, but will be
128 * passed to the caller.
130 public void initialize( Object[] object )
131 throws com.sun.star.uno.Exception
133 /* The component describes what arguments its expected and in which
134 * order!At this point you can read the objects and can intialize
135 * your component using these objects.