Thanks again for the help. Attached a new series of patches (cumulative
with the previously sent ones and Caolan's), in which (I think) all the
Java invocations have been removed in favor of using the C++ components:
1) Implemented the 'resultsforquery.cxx' using CLucene. This adds the
HelpSearch class to the source tree.
2) Removed UNIX-specific code for directory access, now using OSL.
3) Fixed a bug in UOString -> TCHAR* conversion.
The remaining problems are:
1) I haven't implemented the XInvocations stuff. What's the point of
doing that? The code is a lot simpler if HelpIndexer/HelpSearch are
invoked directly. Is there a scripting interface to either of these
components or something? If so, how do I test it?
2) CLucene is still not built as part of the build process.
3) When creating the CLucene FileReader (HelpIndexer.cxx), the path is
converted to plain ASCII, that's probably dangerous. There is probably a
way to work around this, but I haven't gotten around to it yet.
Unfortunately the patches are not as well-tested as I'd like, a new
build is still running and I'm out of time, so YMMV.
On 02/15/2012 01:59 PM, Caolán McNamara wrote:
On Tue, 2012-02-14 at 22:27 +0100, Gert van Valkenhoef wrote:
1. how to convert the rtl::UOString to the TCHAR* that CLucene needs.
There was a small bug here (null-termination character was not being
copied along with the rest of the string), fixed.
2. In xmlhelp/source/cxxhelp/provider/makefile.mk, I've hacked the
include path to include l10ntools/source/help
Attached patch hopefully basically takes care of those two
Great, I wouldn't have figured that out on my own :-)
3. The conversion from using UNIX dirent.h and friends to using 'sal'
still needs to happen, and I think that will help get rid of some
awkward string conversions too.
Straight forward enough, e.g. search for FiltersTest::recursiveScan on
http://opengrok.libreoffice.org for similar.
Indeed, done.
C.
From 3219b8502a93b0346e0b76c1a4dc41399653ecd4 Mon Sep 17 00:00:00 2001
From: Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Date: Sun, 19 Feb 2012 13:49:08 +0100
Subject: [PATCH 6/9] Add C++ HelpSearch and call from XMLHelp. Fix string conversion bug.
---
l10ntools/inc/l10ntools/HelpSearch.hxx | 36 +++
l10ntools/prj/d.lst | 1 +
l10ntools/source/help/HelpIndexer.cxx | 17 +-
l10ntools/source/help/HelpSearch.cxx | 40 +++
l10ntools/source/help/LuceneHelper.cxx | 33 ++
l10ntools/source/help/LuceneHelper.hxx | 13 +
l10ntools/source/help/makefile.mk | 9 +-
xmlhelp/source/cxxhelp/provider/databases.cxx | 10 -
.../source/cxxhelp/provider/resultsetforquery.cxx | 315 +++++++++-----------
.../source/helpcomponent/CLuceneHelpWrapper.cxx | 2 +
10 files changed, 270 insertions(+), 206 deletions(-)
create mode 100644 l10ntools/inc/l10ntools/HelpSearch.hxx
create mode 100644 l10ntools/source/help/HelpSearch.cxx
create mode 100644 l10ntools/source/help/LuceneHelper.cxx
create mode 100644 l10ntools/source/help/LuceneHelper.hxx
diff --git a/l10ntools/inc/l10ntools/HelpSearch.hxx b/l10ntools/inc/l10ntools/HelpSearch.hxx
new file mode 100644
index 0000000..4885b56
--- /dev/null
+++ b/l10ntools/inc/l10ntools/HelpSearch.hxx
@@ -0,0 +1,36 @@
+#ifndef HELPSEARCH_HXX
+#define HELPSEARCH_HXX
+
+#include <l10ntools/dllapi.h>
+
+#include <CLucene/StdHeader.h>
+#include <CLucene.h>
+
+#include <rtl/ustring.hxx>
+#include <vector>
+
+class L10N_DLLPUBLIC HelpSearch {
+ private:
+ rtl::OUString d_lang;
+ rtl::OUString d_indexDir;
+
+ public:
+
+ /**
+ * @param lang Help files language.
+ * @param indexDir The directory where the index files are stored.
+ */
+ HelpSearch(rtl::OUString const &lang, rtl::OUString const &indexDir);
+
+ /**
+ * Query the index for a certain query string.
+ * @param queryStr The query.
+ * @param captionOnly Set to true to search in the caption, not the content.
+ * @param rDocuments Vector to write the paths of the found documents.
+ * @param rScores Vector to write the scores to.
+ */
+ bool query(rtl::OUString const &queryStr, bool captionOnly,
+ std::vector<rtl::OUString> &rDocuments, std::vector<float> &rScores);
+};
+
+#endif
diff --git a/l10ntools/prj/d.lst b/l10ntools/prj/d.lst
index 44cf5f0..e9329dc 100644
--- a/l10ntools/prj/d.lst
+++ b/l10ntools/prj/d.lst
@@ -48,6 +48,7 @@ mkdir: %_DEST%\bin\help\com\sun\star\help
..\inc\l10ntools\directory.hxx %_DEST%\inc\l10ntools\directory.hxx
..\inc\l10ntools\file.hxx %_DEST%\inc\l10ntools\file.hxx
..\inc\l10ntools\HelpIndexer.hxx %_DEST%\inc\l10ntools\HelpIndexer.hxx
+..\inc\l10ntools\HelpSearch.hxx %_DEST%\inc\l10ntools\HelpSearch.hxx
..\source\filter\merge\FCFGMerge.cfg %_DEST%\inc\l10ntools\FCFGMerge.cfg
..\%__SRC%\lib\transex.lib %_DEST%\lib\transex.lib
diff --git a/l10ntools/source/help/HelpIndexer.cxx b/l10ntools/source/help/HelpIndexer.cxx
index b54814a..793348b 100644
--- a/l10ntools/source/help/HelpIndexer.cxx
+++ b/l10ntools/source/help/HelpIndexer.cxx
@@ -1,4 +1,5 @@
#include <l10ntools/HelpIndexer.hxx>
+#include "LuceneHelper.hxx"
#define TODO
@@ -100,22 +101,6 @@ bool HelpIndexer::scanForFiles(rtl::OUString const & path) {
return true;
}
-std::vector<TCHAR> OUStringToTCHARVec(rtl::OUString const &rStr)
-{
- //UTF-16
- if (sizeof(wchar_t) == sizeof(sal_Unicode))
- return std::vector<TCHAR>(rStr.getStr(), rStr.getStr() + rStr.getLength());
-
- //UTF-32
- std::vector<TCHAR> aRet;
- for (sal_Int32 nStrIndex = 0; nStrIndex < rStr.getLength();)
- {
- const sal_uInt32 nCode = rStr.iterateCodePoints(&nStrIndex);
- aRet.push_back(nCode);
- }
- return aRet;
-}
-
bool HelpIndexer::helpDocument(rtl::OUString const & fileName, Document *doc) {
// Add the help path as an indexed, untokenized field.
rtl::OUString path = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("#HLP#")) + d_module +
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + fileName;
diff --git a/l10ntools/source/help/HelpSearch.cxx b/l10ntools/source/help/HelpSearch.cxx
new file mode 100644
index 0000000..f50c44e
--- /dev/null
+++ b/l10ntools/source/help/HelpSearch.cxx
@@ -0,0 +1,40 @@
+#include <l10ntools/HelpSearch.hxx>
+#include "LuceneHelper.hxx"
+
+#include <iostream>
+
+HelpSearch::HelpSearch(rtl::OUString const &lang, rtl::OUString const &indexDir) :
+d_lang(lang), d_indexDir(indexDir) {}
+
+bool HelpSearch::query(rtl::OUString const &queryStr, bool captionOnly,
+ std::vector<rtl::OUString> &rDocuments, std::vector<float> &rScores) {
+ rtl::OString pathStr;
+ d_indexDir.convertToString(&pathStr, RTL_TEXTENCODING_ASCII_US, 0);
+ lucene::index::IndexReader *reader = lucene::index::IndexReader::open(pathStr.getStr());
+ lucene::search::IndexSearcher searcher(reader);
+
+ TCHAR captionField[] = L"caption";
+ TCHAR contentField[] = L"content";
+ TCHAR *field = captionOnly ? captionField : contentField;
+
+ bool isWildcard = queryStr[queryStr.getLength() - 1] == L'*';
+ std::vector<TCHAR> aQueryStr(OUStringToTCHARVec(queryStr));
+ lucene::search::Query *aQuery = (isWildcard ?
+ (lucene::search::Query*)new lucene::search::WildcardQuery(new
lucene::index::Term(field, &aQueryStr[0])) :
+ (lucene::search::Query*)new lucene::search::TermQuery(new
lucene::index::Term(field, &aQueryStr[0])));
+ // FIXME: who is responsible for the Term*?
+
+ lucene::search::Hits *hits = searcher.search(aQuery);
+ for (unsigned i = 0; i < hits->length(); ++i) {
+ lucene::document::Document &doc = hits->doc(i); // Document* belongs to Hits.
+ wchar_t const *path = doc.get(L"path");
+ rDocuments.push_back(TCHARArrayToOUString(path != 0 ? path : L""));
+ rScores.push_back(hits->score(i));
+ }
+
+ delete hits;
+ delete aQuery;
+
+ reader->close();
+ return true;
+}
diff --git a/l10ntools/source/help/LuceneHelper.cxx b/l10ntools/source/help/LuceneHelper.cxx
new file mode 100644
index 0000000..a88542f
--- /dev/null
+++ b/l10ntools/source/help/LuceneHelper.cxx
@@ -0,0 +1,33 @@
+#include "LuceneHelper.hxx"
+
+std::vector<TCHAR> OUStringToTCHARVec(rtl::OUString const &rStr)
+{
+ //UTF-16
+ if (sizeof(TCHAR) == sizeof(sal_Unicode))
+ return std::vector<TCHAR>(rStr.getStr(), rStr.getStr() + rStr.getLength() + 1);
+
+ //UTF-32
+ std::vector<TCHAR> aRet;
+ for (sal_Int32 nStrIndex = 0; nStrIndex < rStr.getLength() + 1; )
+ {
+ const sal_uInt32 nCode = rStr.iterateCodePoints(&nStrIndex);
+ aRet.push_back(nCode);
+ }
+ return aRet;
+}
+
+inline unsigned tstrlen(TCHAR const *str) {
+ unsigned i;
+ for (i = 0; str[i] != 0; ++i) {}
+ return i;
+}
+
+rtl::OUString TCHARArrayToOUString(TCHAR const *str)
+{
+ // UTF-16
+ if (sizeof(TCHAR) == sizeof(sal_Unicode))
+ return rtl::OUString((sal_Unicode*) str);
+
+ // UTF-32
+ return rtl::OUString((char*) str, tstrlen(str), RTL_TEXTENCODING_UCS4);
+}
diff --git a/l10ntools/source/help/LuceneHelper.hxx b/l10ntools/source/help/LuceneHelper.hxx
new file mode 100644
index 0000000..7591b8c
--- /dev/null
+++ b/l10ntools/source/help/LuceneHelper.hxx
@@ -0,0 +1,13 @@
+#ifndef LUCENEHELPER_HXX
+#define LUCENEHELPER_HXX
+
+#include <CLucene/StdHeader.h>
+#include <CLucene.h>
+
+#include <rtl/ustring.hxx>
+#include <vector>
+
+std::vector<TCHAR> OUStringToTCHARVec(rtl::OUString const &rStr);
+rtl::OUString TCHARArrayToOUString(TCHAR const *str);
+
+#endif
diff --git a/l10ntools/source/help/makefile.mk b/l10ntools/source/help/makefile.mk
index 2ae3232..a466e2c 100644
--- a/l10ntools/source/help/makefile.mk
+++ b/l10ntools/source/help/makefile.mk
@@ -56,12 +56,16 @@ OBJFILES=\
$(OBJ)$/HelpLinker.obj \
$(OBJ)$/HelpCompiler.obj \
$(OBJ)$/HelpIndexer.obj \
- $(OBJ)$/HelpIndexer_main.obj
+ $(OBJ)$/HelpIndexer_main.obj \
+ $(OBJ)$/HelpSearch.obj \
+ $(OBJ)$/LuceneHelper.obj
SLOFILES=\
$(SLO)$/HelpLinker.obj \
$(SLO)$/HelpCompiler.obj \
- $(SLO)$/HelpIndexer.obj
+ $(SLO)$/LuceneHelper.obj \
+ $(SLO)$/HelpIndexer.obj \
+ $(SLO)$/HelpSearch.obj
.IF "$(OS)" == "MACOSX" && "$(CPU)" == "P" && "$(COM)" == "GCC"
# There appears to be a GCC 4.0.1 optimization error causing _file:good() to
@@ -85,6 +89,7 @@ APP1STDLIBS+=$(SALLIB) $(BERKELEYLIB) $(XSLTLIB) $(EXPATASCII3RDLIB)
APP2TARGET=HelpIndexer
APP2OBJS=\
+ $(OBJ)$/LuceneHelper.obj \
$(OBJ)$/HelpIndexer.obj \
$(OBJ)$/HelpIndexer_main.obj
APP2RPATH = NONE
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx
b/xmlhelp/source/cxxhelp/provider/databases.cxx
index bef8ae5..ca090e5 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -39,12 +39,8 @@
#include <algorithm>
#include <string.h>
-// EDIT FROM HERE
-
#include <l10ntools/HelpIndexer.hxx>
-// EDIT ENDS HERE
-
// Extensible help
#include "com/sun/star/deployment/ExtensionManager.hpp"
#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
@@ -2092,8 +2088,6 @@ rtl::OUString IndexFolderIterator::nextIndexFolder( bool& o_rbExtension,
bool& o
rtl::OUString IndexFolderIterator::implGetIndexFolderFromPackage( bool& o_rbTemporary, Reference<
deployment::XPackage > xPackage )
{
- fprintf(stderr, "IndexFolderIterator::implGetIndexFolderFromPackage\n");
-
rtl::OUString aIndexFolder =
implGetFileFromPackage( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ".idxl" )), xPackage );
@@ -2121,7 +2115,6 @@ rtl::OUString IndexFolderIterator::implGetIndexFolderFromPackage( bool&
o_rbTemp
// TEST
//bIsWriteAccess = false;
-// EDIT FROM HERE
try
{
rtl::OUString aLang;
@@ -2172,9 +2165,6 @@ rtl::OUString IndexFolderIterator::implGetIndexFolderFromPackage( bool&
o_rbTemp
}
catch (Exception &)
{}
-
-// EDIT UNTIL HERE
-
}
}
diff --git a/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx
b/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx
index 767ce89..d0dea28 100644
--- a/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx
+++ b/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx
@@ -33,6 +33,8 @@
#include <com/sun/star/lang/Locale.hpp>
#include <com/sun/star/script/XInvocation.hpp>
+#include <l10ntools/HelpSearch.hxx>
+
#ifndef INCLUDED_STL_ALGORITHM
#include <algorithm>
#define INCLUDED_STL_ALGORITHM
@@ -96,10 +98,7 @@ ResultSetForQuery::ResultSetForQuery( const uno::Reference< lang::XMultiServiceF
xTrans->loadModule(TransliterationModules_UPPERCASE_LOWERCASE,
aLocale );
- // Access CLucene via XInvocation
- Reference< script::XInvocation > xInvocation(
- xMSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.help.HelpSearch" )) ),
- UNO_QUERY );
+ // EDIT FROM HERE
vector< vector< rtl::OUString > > queryList;
{
@@ -132,228 +131,188 @@ ResultSetForQuery::ResultSetForQuery( const uno::Reference<
lang::XMultiServiceF
}
vector< rtl::OUString > aCompleteResultVector;
- if( xInvocation.is() )
+ rtl::OUString scope = m_aURLParameter.get_scope();
+ bool bCaptionsOnly = ( scope.compareToAscii( "Heading" ) == 0 );
+ sal_Int32 hitCount = m_aURLParameter.get_hitCount();
+
+ IndexFolderIterator aIndexFolderIt( *pDatabases, m_aURLParameter.get_module(),
m_aURLParameter.get_language() );
+ rtl::OUString idxDir;
+ bool bExtension = false;
+ int iDir = 0;
+ vector< vector<HitItem>* > aIndexFolderResultVectorVector;
+
+ bool bTemporary;
+ while( !(idxDir = aIndexFolderIt.nextIndexFolder( bExtension, bTemporary )).isEmpty() )
{
- rtl::OUString scope = m_aURLParameter.get_scope();
- bool bCaptionsOnly = ( scope.compareToAscii( "Heading" ) == 0 );
- sal_Int32 hitCount = m_aURLParameter.get_hitCount();
-
- IndexFolderIterator aIndexFolderIt( *pDatabases, m_aURLParameter.get_module(),
m_aURLParameter.get_language() );
- rtl::OUString idxDir;
- bool bExtension = false;
- int iDir = 0;
- vector< vector<HitItem>* > aIndexFolderResultVectorVector;
-
- bool bTemporary;
- while( !(idxDir = aIndexFolderIt.nextIndexFolder( bExtension, bTemporary )).isEmpty() )
+ vector<HitItem> aIndexFolderResultVector;
+
+ try
{
- vector<HitItem> aIndexFolderResultVector;
+ vector< vector<HitItem>* > aQueryListResultVectorVector;
+ set< rtl::OUString > aSet,aCurrent,aResultSet;
- try
- {
- vector< vector<HitItem>* > aQueryListResultVectorVector;
- set< rtl::OUString > aSet,aCurrent,aResultSet;
+ int nQueryListSize = queryList.size();
+ if( nQueryListSize > 1 )
+ hitCount = 2000;
- int nQueryListSize = queryList.size();
+ for( int i = 0; i < nQueryListSize; ++i )
+ {
+ vector<HitItem>* pQueryResultVector;
if( nQueryListSize > 1 )
- hitCount = 2000;
-
- for( int i = 0; i < nQueryListSize; ++i )
{
- vector<HitItem>* pQueryResultVector;
- if( nQueryListSize > 1 )
- {
- pQueryResultVector = new vector<HitItem>();
- aQueryListResultVectorVector.push_back( pQueryResultVector );
- }
- else
- {
- pQueryResultVector = &aIndexFolderResultVector;
- }
- pQueryResultVector->reserve( hitCount );
-
- int nParamCount = bCaptionsOnly ? 7 : 6;
- Sequence<uno::Any> aParamsSeq( nParamCount );
-
- aParamsSeq[0] = uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"-lang" )) );
- aParamsSeq[1] = uno::makeAny( m_aURLParameter.get_language() );
-
- aParamsSeq[2] = uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"-index" )) );
- rtl::OUString aSystemPath;
- osl::FileBase::getSystemPathFromFileURL( idxDir, aSystemPath );
- aParamsSeq[3] = uno::makeAny( aSystemPath );
-
- aParamsSeq[4] = uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"-query" )) );
-
- const std::vector< rtl::OUString >& aListItem = queryList[i];
- ::rtl::OUString aNewQueryStr = aListItem[0];
- aParamsSeq[5] = uno::makeAny( aNewQueryStr );
+ pQueryResultVector = new vector<HitItem>();
+ aQueryListResultVectorVector.push_back( pQueryResultVector );
+ }
+ else
+ {
+ pQueryResultVector = &aIndexFolderResultVector;
+ }
+ pQueryResultVector->reserve( hitCount );
- if( bCaptionsOnly )
- aParamsSeq[6] = uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"-caption" )) );
+// INVOCATION HERE
+ rtl::OUString aLang = m_aURLParameter.get_language();
+ rtl::OUString aSystemPath;
+ osl::FileBase::getSystemPathFromFileURL( idxDir, aSystemPath );
+ const std::vector< rtl::OUString >& aListItem = queryList[i];
+ ::rtl::OUString aNewQueryStr = aListItem[0];
- Sequence< sal_Int16 > aOutParamIndex;
- Sequence< uno::Any > aOutParam;
+ vector<float> aScoreVector;
+ vector<rtl::OUString> aPathVector;
- uno::Any aRet = xInvocation->invoke(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "search" )),
- aParamsSeq, aOutParamIndex, aOutParam );
+ HelpSearch searcher(aLang, aSystemPath);
+ searcher.query(aNewQueryStr, bCaptionsOnly, aPathVector, aScoreVector);
- Sequence< float > aScoreSeq;
- int nScoreCount = 0;
- int nOutParamCount = aOutParam.getLength();
- if( nOutParamCount == 1 )
- {
- const uno::Any* pScoreAnySeq = aOutParam.getConstArray();
- if( pScoreAnySeq[0] >>= aScoreSeq )
- nScoreCount = aScoreSeq.getLength();
- }
+ if( nQueryListSize > 1 )
+ aSet.clear();
- Sequence<rtl::OUString> aRetSeq;
- if( aRet >>= aRetSeq )
+ for (unsigned j = 0; j < aPathVector.size(); ++i) {
+ pQueryResultVector->push_back(HitItem(aPathVector[j], aScoreVector[j]));
+ if (nQueryListSize > 1)
+ aSet.insert(aPathVector[j]);
+ }
+// INVOCATION END
+ // intersect
+ if( nQueryListSize > 1 )
+ {
+ if( i == 0 )
{
- if( nQueryListSize > 1 )
- aSet.clear();
-
- const rtl::OUString* pRetSeq = aRetSeq.getConstArray();
- int nCount = aRetSeq.getLength();
- if( nCount > hitCount )
- nCount = hitCount;
- for( int j = 0 ; j < nCount ; ++j )
- {
- float fScore = 0.0;
- if( j < nScoreCount )
- fScore = aScoreSeq[j];
-
- rtl::OUString aURL = pRetSeq[j];
- pQueryResultVector->push_back( HitItem( aURL, fScore ) );
- if( nQueryListSize > 1 )
- aSet.insert( aURL );
- }
+ aResultSet = aSet;
}
-
- // intersect
- if( nQueryListSize > 1 )
+ else
{
- if( i == 0 )
- {
- aResultSet = aSet;
- }
- else
- {
- aCurrent = aResultSet;
- aResultSet.clear();
- set_intersection( aSet.begin(),aSet.end(),
- aCurrent.begin(),aCurrent.end(),
- inserter(aResultSet,aResultSet.begin()));
- }
+ aCurrent = aResultSet;
+ aResultSet.clear();
+ set_intersection( aSet.begin(),aSet.end(),
+ aCurrent.begin(),aCurrent.end(),
+ inserter(aResultSet,aResultSet.begin()));
}
}
+ }
- // Combine results in aIndexFolderResultVector
- if( nQueryListSize > 1 )
+ // Combine results in aIndexFolderResultVector
+ if( nQueryListSize > 1 )
+ {
+ for( int n = 0 ; n < nQueryListSize ; ++n )
{
- for( int n = 0 ; n < nQueryListSize ; ++n )
- {
- vector<HitItem>* pQueryResultVector = aQueryListResultVectorVector[n];
- vector<HitItem>& rQueryResultVector = *pQueryResultVector;
+ vector<HitItem>* pQueryResultVector = aQueryListResultVectorVector[n];
+ vector<HitItem>& rQueryResultVector = *pQueryResultVector;
- int nItemCount = rQueryResultVector.size();
- for( int i = 0 ; i < nItemCount ; ++i )
+ int nItemCount = rQueryResultVector.size();
+ for( int i = 0 ; i < nItemCount ; ++i )
+ {
+ const HitItem& rItem = rQueryResultVector[ i ];
+ set< rtl::OUString >::iterator it;
+ if( (it = aResultSet.find( rItem.m_aURL )) != aResultSet.end() )
{
- const HitItem& rItem = rQueryResultVector[ i ];
- set< rtl::OUString >::iterator it;
- if( (it = aResultSet.find( rItem.m_aURL )) != aResultSet.end() )
+ HitItem aItemCopy( rItem );
+ aItemCopy.m_fScore /= nQueryListSize; // To get average score
+ if( n == 0 )
{
- HitItem aItemCopy( rItem );
- aItemCopy.m_fScore /= nQueryListSize; // To get average score
- if( n == 0 )
- {
- // Use first pass to create entry
- aIndexFolderResultVector.push_back( aItemCopy );
- }
- else
+ // Use first pass to create entry
+ aIndexFolderResultVector.push_back( aItemCopy );
+ }
+ else
+ {
+ // Find entry in vector
+ int nCount = aIndexFolderResultVector.size();
+ for( int j = 0 ; j < nCount ; ++j )
{
- // Find entry in vector
- int nCount = aIndexFolderResultVector.size();
- for( int j = 0 ; j < nCount ; ++j )
+ HitItem& rFindItem = aIndexFolderResultVector[ j ];
+ if( rFindItem.m_aURL.equals( aItemCopy.m_aURL ) )
{
- HitItem& rFindItem = aIndexFolderResultVector[ j ];
- if( rFindItem.m_aURL.equals( aItemCopy.m_aURL ) )
- {
- rFindItem.m_fScore += aItemCopy.m_fScore;
- break;
- }
+ rFindItem.m_fScore += aItemCopy.m_fScore;
+ break;
}
}
}
}
-
- delete pQueryResultVector;
}
- sort( aIndexFolderResultVector.begin(), aIndexFolderResultVector.end() );
+ delete pQueryResultVector;
}
- vector<HitItem>* pIndexFolderHitItemVector = new vector<HitItem>(
aIndexFolderResultVector );
- aIndexFolderResultVectorVector.push_back( pIndexFolderHitItemVector );
- aIndexFolderResultVector.clear();
- }
- catch( const Exception& )
- {
+ sort( aIndexFolderResultVector.begin(), aIndexFolderResultVector.end() );
}
- ++iDir;
+ vector<HitItem>* pIndexFolderHitItemVector = new vector<HitItem>(
aIndexFolderResultVector );
+ aIndexFolderResultVectorVector.push_back( pIndexFolderHitItemVector );
+ aIndexFolderResultVector.clear();
+ }
+ catch( const Exception& )
+ {
+ }
+
+ ++iDir;
- if( bTemporary )
- aIndexFolderIt.deleteTempIndexFolder( idxDir );
+ if( bTemporary )
+ aIndexFolderIt.deleteTempIndexFolder( idxDir );
- } // Iterator
+ } // Iterator
- int nVectorCount = aIndexFolderResultVectorVector.size();
- vector<HitItem>::size_type* pCurrentVectorIndex = new
vector<HitItem>::size_type[nVectorCount];
- for( int j = 0 ; j < nVectorCount ; ++j )
- pCurrentVectorIndex[j] = 0;
+ int nVectorCount = aIndexFolderResultVectorVector.size();
+ vector<HitItem>::size_type* pCurrentVectorIndex = new vector<HitItem>::size_type[nVectorCount];
+ for( int j = 0 ; j < nVectorCount ; ++j )
+ pCurrentVectorIndex[j] = 0;
- sal_Int32 nTotalHitCount = m_aURLParameter.get_hitCount();
- sal_Int32 nHitCount = 0;
- while( nHitCount < nTotalHitCount )
+ sal_Int32 nTotalHitCount = m_aURLParameter.get_hitCount();
+ sal_Int32 nHitCount = 0;
+ while( nHitCount < nTotalHitCount )
+ {
+ int iVectorWithBestScore = -1;
+ float fBestScore = 0.0;
+ for( int k = 0 ; k < nVectorCount ; ++k )
{
- int iVectorWithBestScore = -1;
- float fBestScore = 0.0;
- for( int k = 0 ; k < nVectorCount ; ++k )
+ vector<HitItem>& rIndexFolderVector = *aIndexFolderResultVectorVector[k];
+ if( pCurrentVectorIndex[k] < rIndexFolderVector.size() )
{
- vector<HitItem>& rIndexFolderVector = *aIndexFolderResultVectorVector[k];
- if( pCurrentVectorIndex[k] < rIndexFolderVector.size() )
- {
- const HitItem& rItem = rIndexFolderVector[ pCurrentVectorIndex[k] ];
+ const HitItem& rItem = rIndexFolderVector[ pCurrentVectorIndex[k] ];
- if( fBestScore < rItem.m_fScore )
- {
- fBestScore = rItem.m_fScore;
- iVectorWithBestScore = k;
- }
+ if( fBestScore < rItem.m_fScore )
+ {
+ fBestScore = rItem.m_fScore;
+ iVectorWithBestScore = k;
}
}
+ }
- if( iVectorWithBestScore == -1 ) // No item left at all
- break;
+ if( iVectorWithBestScore == -1 ) // No item left at all
+ break;
- vector<HitItem>& rIndexFolderVector =
*aIndexFolderResultVectorVector[iVectorWithBestScore];
- const HitItem& rItem = rIndexFolderVector[ pCurrentVectorIndex[iVectorWithBestScore] ];
+ vector<HitItem>& rIndexFolderVector =
*aIndexFolderResultVectorVector[iVectorWithBestScore];
+ const HitItem& rItem = rIndexFolderVector[ pCurrentVectorIndex[iVectorWithBestScore] ];
- pCurrentVectorIndex[iVectorWithBestScore]++;
+ pCurrentVectorIndex[iVectorWithBestScore]++;
- aCompleteResultVector.push_back( rItem.m_aURL );
- ++nHitCount;
- }
+ aCompleteResultVector.push_back( rItem.m_aURL );
+ ++nHitCount;
+ }
- delete[] pCurrentVectorIndex;
- for( int n = 0 ; n < nVectorCount ; ++n )
- {
- vector<HitItem>* pIndexFolderVector = aIndexFolderResultVectorVector[n];
- delete pIndexFolderVector;
- }
+ delete[] pCurrentVectorIndex;
+ for( int n = 0 ; n < nVectorCount ; ++n )
+ {
+ vector<HitItem>* pIndexFolderVector = aIndexFolderResultVectorVector[n];
+ delete pIndexFolderVector;
}
sal_Int32 replIdx = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "#HLP#" )).getLength();
diff --git a/xmlhelp/source/helpcomponent/CLuceneHelpWrapper.cxx
b/xmlhelp/source/helpcomponent/CLuceneHelpWrapper.cxx
index 6e800f8..fb53fab 100644
--- a/xmlhelp/source/helpcomponent/CLuceneHelpWrapper.cxx
+++ b/xmlhelp/source/helpcomponent/CLuceneHelpWrapper.cxx
@@ -81,6 +81,8 @@ public:
}
};
+#include <stdio.h> // FIXME: remove once the fprintf() calls below are gone
+
Any CLuceneHelpWrapper::invoke(const OUString& rFunctionName, const Sequence< Any >& Params,
Sequence< sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam)
throw( IllegalArgumentException, CannotConvertException, InvocationTargetException,
RuntimeException )
{
--
1.7.0.4
From f2b4fe680591f228dcb763e70791f6d7c0b83436 Mon Sep 17 00:00:00 2001
From: Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Date: Sun, 19 Feb 2012 17:21:19 +0100
Subject: [PATCH 7/9] HelpIndexer: use OSL for directory access
---
l10ntools/source/help/HelpIndexer.cxx | 38 ++++++++++++--------------------
1 files changed, 14 insertions(+), 24 deletions(-)
diff --git a/l10ntools/source/help/HelpIndexer.cxx b/l10ntools/source/help/HelpIndexer.cxx
index 793348b..a3ab752 100644
--- a/l10ntools/source/help/HelpIndexer.cxx
+++ b/l10ntools/source/help/HelpIndexer.cxx
@@ -8,12 +8,7 @@
#endif
#include <rtl/string.hxx>
-
-#include <unistd.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <errno.h>
-#include <string.h>
+#include <osl/file.hxx>
#include <algorithm>
@@ -77,27 +72,20 @@ bool HelpIndexer::scanForFiles() {
}
bool HelpIndexer::scanForFiles(rtl::OUString const & path) {
- rtl::OString pathStr;
- path.convertToString(&pathStr, RTL_TEXTENCODING_ASCII_US, 0);
- DIR *dir = opendir(pathStr.getStr());
- if (dir == 0) {
- d_error = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Error reading directory ")) +
path +
- rtl::OUString::createFromAscii(strerror(errno));
+ osl::Directory dir(path);
+ if (osl::FileBase::E_None != dir.open()) {
+ d_error = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Error reading directory ")) +
path;
return true;
}
- struct dirent *ent;
- struct stat info;
- while ((ent = readdir(dir)) != 0) {
- rtl::OString entPath(pathStr);
- entPath += rtl::OString(RTL_CONSTASCII_STRINGPARAM("/")) +
rtl::OString(ent->d_name);
- if (stat(entPath.getStr(), &info) == 0 && S_ISREG(info.st_mode)) {
- d_files.insert(rtl::OUString::createFromAscii(ent->d_name));
+ osl::DirectoryItem item;
+ osl::FileStatus fileStatus(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Type);
+ while (dir.getNextItem(item) == osl::FileBase::E_None) {
+ if (fileStatus.getFileType() == osl::FileStatus::Regular) {
+ d_files.insert(fileStatus.getFileName());
}
}
- closedir(dir);
-
return true;
}
@@ -121,9 +109,11 @@ bool HelpIndexer::helpDocument(rtl::OUString const & fileName, Document *doc) {
}
lucene::util::Reader *HelpIndexer::helpFileReader(rtl::OUString const & path) {
- rtl::OString pathStr;
- path.convertToString(&pathStr, RTL_TEXTENCODING_ASCII_US, 0);
- if (access(pathStr.getStr(), R_OK) == 0) {
+ osl::File file(path);
+ if (osl::FileBase::E_None == file.open(osl_File_OpenFlag_Read)) {
+ file.close();
+ rtl::OString pathStr;
+ path.convertToString(&pathStr, RTL_TEXTENCODING_ASCII_US, 0); // FIXME: path
encoding?
return new lucene::util::FileReader(pathStr.getStr(), "UTF-8");
} else {
return new lucene::util::StringReader(L"");
--
1.7.0.4
From b604d421f55a77ca87a37524851066bcdc72708a Mon Sep 17 00:00:00 2001
From: Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Date: Sun, 19 Feb 2012 18:31:16 +0100
Subject: [PATCH 8/9] Bugfix resultsetforquery
---
.../source/cxxhelp/provider/resultsetforquery.cxx | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx
b/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx
index d0dea28..e8fe9d8 100644
--- a/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx
+++ b/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx
@@ -98,8 +98,6 @@ ResultSetForQuery::ResultSetForQuery( const uno::Reference< lang::XMultiServiceF
xTrans->loadModule(TransliterationModules_UPPERCASE_LOWERCASE,
aLocale );
- // EDIT FROM HERE
-
vector< vector< rtl::OUString > > queryList;
{
sal_Int32 idx;
@@ -169,7 +167,7 @@ ResultSetForQuery::ResultSetForQuery( const uno::Reference< lang::XMultiServiceF
}
pQueryResultVector->reserve( hitCount );
-// INVOCATION HERE
+ // START Invoke CLucene HelpSearch
rtl::OUString aLang = m_aURLParameter.get_language();
rtl::OUString aSystemPath;
osl::FileBase::getSystemPathFromFileURL( idxDir, aSystemPath );
@@ -185,12 +183,13 @@ ResultSetForQuery::ResultSetForQuery( const uno::Reference<
lang::XMultiServiceF
if( nQueryListSize > 1 )
aSet.clear();
- for (unsigned j = 0; j < aPathVector.size(); ++i) {
+ for (unsigned j = 0; j < aPathVector.size(); ++j) {
pQueryResultVector->push_back(HitItem(aPathVector[j], aScoreVector[j]));
if (nQueryListSize > 1)
aSet.insert(aPathVector[j]);
}
-// INVOCATION END
+ // END Invoke CLucene HelpSearch
+
// intersect
if( nQueryListSize > 1 )
{
--
1.7.0.4
From aa80cd2a6561d7892cbbfbedb562ff34266cc146 Mon Sep 17 00:00:00 2001
From: Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Date: Sun, 19 Feb 2012 18:34:44 +0100
Subject: [PATCH 9/9] HelpIndexer and HelpSearch: remove Java
---
l10ntools/source/help/HelpFileDocument.java | 86 -----
l10ntools/source/help/HelpIndexerTool.java | 387 --------------------
.../source/com/sun/star/help/HelpComponent.java | 77 ----
xmlhelp/source/com/sun/star/help/HelpIndexer.java | 194 ----------
xmlhelp/source/com/sun/star/help/HelpSearch.java | 329 -----------------
.../com/sun/star/help/LuceneHelpWrapper.component | 37 --
xmlhelp/source/com/sun/star/help/MANIFEST.MF | 1 -
xmlhelp/source/com/sun/star/help/helplinker.pmk | 31 --
xmlhelp/source/com/sun/star/help/makefile.mk | 90 -----
9 files changed, 0 insertions(+), 1232 deletions(-)
delete mode 100644 l10ntools/source/help/HelpFileDocument.java
delete mode 100644 l10ntools/source/help/HelpIndexerTool.java
delete mode 100755 xmlhelp/source/com/sun/star/help/HelpComponent.java
delete mode 100755 xmlhelp/source/com/sun/star/help/HelpIndexer.java
delete mode 100755 xmlhelp/source/com/sun/star/help/HelpSearch.java
delete mode 100755 xmlhelp/source/com/sun/star/help/LuceneHelpWrapper.component
delete mode 100755 xmlhelp/source/com/sun/star/help/MANIFEST.MF
delete mode 100755 xmlhelp/source/com/sun/star/help/helplinker.pmk
delete mode 100755 xmlhelp/source/com/sun/star/help/makefile.mk
diff --git a/l10ntools/source/help/HelpFileDocument.java
b/l10ntools/source/help/HelpFileDocument.java
deleted file mode 100644
index 15e62d6..0000000
--- a/l10ntools/source/help/HelpFileDocument.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.help;
-
-import java.io.File;
-import java.io.Reader;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-//import java.io.FileReader;
-import java.io.StringReader;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-
-/** Lucene Document for help files */
-public class HelpFileDocument
-{
- /** Creates reader for UTF-8 files
- */
- private static Reader getReaderForFile( File aFile )
- throws java.io.FileNotFoundException, java.io.UnsupportedEncodingException {
- Reader aReader;
- if( aFile != null ) {
- FileInputStream fis = new FileInputStream( aFile );
- aReader = new InputStreamReader( fis, "UTF-8" );
- }
- else {
- aReader = new StringReader( "" );
- }
- return aReader;
- }
-
- /** Makes a document for a File.
- */
- public static Document Document( String aModule, File aCaptionFile, File aContentFile )
- throws java.io.FileNotFoundException, java.io.UnsupportedEncodingException {
- Document doc = new Document();
-
- // Add the path of the file as a field named "path". Use a field that is
- // indexed (i.e. searchable), but don't tokenize the field into words.
- File aFile = aCaptionFile != null ? aCaptionFile : aContentFile;
- if( aFile != null )
- {
- String aPath = "#HLP#" + aModule + "/" + aFile.getName();
- doc.add(new Field("path", aPath, Field.Store.YES, Field.Index.UN_TOKENIZED));
- }
-
- // Add the caption of the file to a field named "caption". Specify a Reader,
- // so that the text of the file is tokenized and indexed, but not stored.
- doc.add( new Field( "caption", getReaderForFile( aCaptionFile ) ) );
-
- // Add the contents of the file to a field named "content". Specify a Reader,
- // so that the text of the file is tokenized and indexed, but not stored.
- doc.add( new Field( "content", getReaderForFile( aContentFile ) ) );
-
- // return the document
- return doc;
- }
-
- private HelpFileDocument() {}
-}
diff --git a/l10ntools/source/help/HelpIndexerTool.java b/l10ntools/source/help/HelpIndexerTool.java
deleted file mode 100644
index d1d0873..0000000
--- a/l10ntools/source/help/HelpIndexerTool.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.help;
-
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-import java.util.zip.CRC32;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.analysis.cjk.CJKAnalyzer;
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.index.IndexWriter;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Date;
-
-
-/**
- When this tool is used with long path names on Windows, that is paths which start
- with \\?\, then the caller must make sure that the path is unique. This is achieved
- by removing '.' and '..' from the path. Paths which are created by
- osl_getSystemPathFromFileURL fulfill this requirement. This is necessary because
- lucene is patched to not use File.getCanonicalPath. See long_path.patch in the lucene
- module.
- */
-public class HelpIndexerTool
-{
- public HelpIndexerTool()
- {
- }
-
-
- /**
- * @param args the command line arguments
- */
- public static void main( String[] args )
- {
- boolean bExtensionMode = false;
- mainImpl( args, bExtensionMode );
- }
-
- public static void mainImpl( String[] args, boolean bExtensionMode )
- {
- String aDirToZipStr = "";
- String aSrcDirStr = "";
- String aLanguageStr = "";
- String aModule = "";
- String aTargetZipFileStr = "";
- String aCfsName = "";
- String aSegmentName = "";
-
- // Scan arguments
- //If this tool is invoked in the build process for extensions help,
- //then -extension must be set.
- boolean bExtension = false;
- boolean bLang = false;
- boolean bMod = false;
- boolean bZipDir = false;
- boolean bSrcDir = false;
- boolean bOutput = false;
- boolean bCfsName = false;
- boolean bSegmentName = false;
-
- int nArgCount = args.length;
- for( int i = 0 ; i < nArgCount ; i++ )
- {
- if( "-extension".equals(args[i]) )
- {
- bExtension = true;
- }
- else if( "-lang".equals(args[i]) )
- {
- if( i + 1 < nArgCount )
- {
- aLanguageStr = args[i + 1];
- bLang = true;
- }
- i++;
- }
- else if( "-mod".equals(args[i]) )
- {
- if( i + 1 < nArgCount )
- {
- aModule = args[i + 1];
- bMod = true;
- }
- i++;
- }
- else if( "-zipdir".equals(args[i]) )
- {
- if( i + 1 < nArgCount )
- {
- aDirToZipStr = args[i + 1];
- bZipDir = true;
- }
- i++;
- }
- else if( "-srcdir".equals(args[i]) )
- {
- if( i + 1 < nArgCount )
- {
- aSrcDirStr = args[i + 1];
- bSrcDir = true;
- }
- i++;
- }
- else if( "-o".equals(args[i]) )
- {
- if( i + 1 < nArgCount )
- {
- aTargetZipFileStr = args[i + 1];
- bOutput = true;
- }
- i++;
- }
- else if( "-checkcfsandsegname".equals(args[i]) )
- {
- if( i + 1 < nArgCount )
- {
- aCfsName = args[i + 1] + ".cfs";
- bCfsName = true;
- }
- i++;
- if( i + 1 < nArgCount )
- {
- aSegmentName = "segments" + args[i + 1];
- bSegmentName = true;
- }
- i++;
- if (!(bCfsName && bSegmentName))
- {
- System.out.println("Usage: HelpIndexer -checkcfsandsegname _0 _3 (2 arguments
needed)");
- System.exit( -1 );
- }
- }
- }
-
- if( !bLang || !bMod || !bZipDir || (!bOutput && !bExtensionMode && !bExtension) )
- {
- if( bExtensionMode )
- return;
-
- System.out.println("Usage: HelpIndexer -lang ISOLangCode -mod HelpModule -zipdir
TempZipDir -o OutputZipFile");
- System.out.println("Usage: HelpIndexer -extension -lang ISOLangCode -mod HelpModule
-zipdir PathToLangDir");
- System.exit( -1 );
- }
-
- String aIndexDirName = aModule + ".idxl";
- File aIndexDir = new File( aDirToZipStr + File.separator + aIndexDirName );
- if( !bSrcDir )
- aSrcDirStr = aDirToZipStr;
- File aCaptionFilesDir = new File( aSrcDirStr + File.separator + "caption" );
- File aContentFilesDir = new File( aSrcDirStr + File.separator + "content" );
-
- try
- {
- Analyzer analyzer = aLanguageStr.equals("ja") ? (Analyzer)new CJKAnalyzer() :
(Analyzer)new StandardAnalyzer();
- IndexWriter writer = new IndexWriter( aIndexDir, analyzer, true );
- int nRet = indexDocs( writer, aModule, bExtensionMode, aCaptionFilesDir,
aContentFilesDir );
- if( nRet != -1 )
- writer.optimize();
- writer.close();
-
- boolean bCfsFileOk = true;
- boolean bSegmentFileOk = true;
- if( bCfsName && bSegmentName && !bExtensionMode && nRet != -1 )
- {
- String aCompleteCfsFileName = aDirToZipStr + File.separator + aIndexDirName +
File.separator + aCfsName;
- String aCompleteSegmentFileName = aDirToZipStr + File.separator + aIndexDirName +
File.separator + aSegmentName;
- File aCfsFile = new File( aCompleteCfsFileName );
- File aSegmentFile = new File( aCompleteSegmentFileName );
- bCfsFileOk = aCfsFile.exists();
- bSegmentFileOk = aSegmentFile.exists();
- System.out.println( "Checking cfs file " + aCfsName+ ": " + (bCfsFileOk ? "Found"
: "Not found") );
- System.out.println( "Checking segment file " + aSegmentName+ ": " +
(bSegmentFileOk ? "Found" : "Not found") );
- }
-
- if( bExtensionMode || bExtension)
- {
- if( !bSrcDir )
- {
- deleteRecursively( aCaptionFilesDir );
- deleteRecursively( aContentFilesDir );
- }
- }
- else
- {
- if( nRet == -1 )
- deleteRecursively( aIndexDir );
-
- File aDirToZipFile = new File( aDirToZipStr );
- createZipFile( aDirToZipFile, aTargetZipFileStr );
- deleteRecursively( aDirToZipFile );
- }
-
- if( !bCfsFileOk )
- {
- System.out.println( "cfs file check failed, terminating..." );
- System.exit( -1 );
- }
-
- if( !bSegmentFileOk )
- {
- System.out.println( "segment file check failed, terminating..." );
- System.exit( -1 );
- }
- }
- catch (IOException e)
- {
- if( bExtensionMode )
- return;
-
- System.out.println(" caught a " + e.getClass() +
- "\n with message: " + e.getMessage());
- System.exit( -1 );
- }
- }
-
- private static int indexDocs(IndexWriter writer, String aModule, boolean bExtensionMode,
- File aCaptionFilesDir, File aContentFilesDir) throws IOException
- {
- if( !aCaptionFilesDir.canRead() || !aCaptionFilesDir.isDirectory() )
- {
- if( !bExtensionMode )
- System.out.println( "Not found: " + aCaptionFilesDir );
- return -1;
- }
- if( !aContentFilesDir.canRead() || !aContentFilesDir.isDirectory() )
- {
- if( !bExtensionMode )
- System.out.println( "Not found: " + aContentFilesDir );
- return -1;
- }
-
- String[] aCaptionFiles = aCaptionFilesDir.list();
- List aCaptionFilesList = Arrays.asList( aCaptionFiles );
- HashSet aCaptionFilesHashSet = new HashSet( aCaptionFilesList );
-
- String[] aContentFiles = aContentFilesDir.list();
- List aContentFilesList = Arrays.asList( aContentFiles );
- HashSet aContentFilesHashSet = new HashSet( aContentFilesList );
-
- // Loop over caption files and find corresponding content file
- int nCaptionFilesLen = aCaptionFiles.length;
- for( int i = 0 ; i < nCaptionFilesLen ; i++ )
- {
- String aCaptionFileStr = aCaptionFiles[i];
- File aCaptionFile = new File( aCaptionFilesDir, aCaptionFileStr );
- File aContentFile = null;
- if( aContentFilesHashSet.contains( aCaptionFileStr ) )
- aContentFile = new File( aContentFilesDir, aCaptionFileStr );
- writer.addDocument( HelpFileDocument.Document( aModule, aCaptionFile, aContentFile ) );
- }
-
- // Loop over content files to find remaining files not mapped to caption files
- int nContentFilesLen = aContentFiles.length;
- for( int i = 0 ; i < nContentFilesLen ; i++ )
- {
- String aContentFileStr = aContentFiles[i];
- if( !aCaptionFilesHashSet.contains( aContentFileStr ) )
- {
- // Not already handled in caption files loop
- File aCaptionFile = null;
- File aContentFile = new File( aContentFilesDir, aContentFileStr );
- writer.addDocument( HelpFileDocument.Document( aModule, aCaptionFile, aContentFile
) );
- }
- }
- return 0;
- }
-
- public static void createZipFile( File aDirToZip, String aTargetZipFileStr )
- throws FileNotFoundException, IOException
- {
- FileOutputStream fos = new FileOutputStream( aTargetZipFileStr );
- ZipOutputStream zos = new ZipOutputStream( fos );
-
- File[] aChildrenFiles = aDirToZip.listFiles();
- int nFileCount = aChildrenFiles.length;
- for( int i = 0 ; i < nFileCount ; i++ )
- addToZipRecursively( zos, aChildrenFiles[i], null );
-
- zos.close();
- }
-
- public static void addToZipRecursively( ZipOutputStream zos, File aFile, String aBasePath )
- throws FileNotFoundException, IOException
- {
- if( aFile.isDirectory() )
- {
- String aDirName = aFile.getName();
- if( aDirName.equalsIgnoreCase( "caption" ) || aDirName.equalsIgnoreCase( "content" ) )
- return;
-
- File[] aChildrenFiles = aFile.listFiles();
- String aNewBasePath = "";
- if( aBasePath != null )
- aNewBasePath += aBasePath + File.separator;
- aNewBasePath += aDirName;
-
- int nFileCount = aChildrenFiles.length;
- for( int i = 0 ; i < nFileCount ; i++ )
- addToZipRecursively( zos, aChildrenFiles[i], aNewBasePath );
-
- return;
- }
-
- // No directory
- // read contents of file we are going to put in the zip
- int fileLength = (int) aFile.length();
- FileInputStream fis = new FileInputStream( aFile );
- byte[] wholeFile = new byte[fileLength];
- int bytesRead = fis.read( wholeFile, 0, fileLength );
- fis.close();
-
- String aFileName = aFile.getName();
- String aEntryName = "";
- if( aBasePath != null )
- aEntryName += aBasePath + "/";
- aEntryName += aFileName;
- ZipEntry aZipEntry = new ZipEntry( aEntryName );
- aZipEntry.setTime( aFile.lastModified() );
- aZipEntry.setSize( fileLength );
-
- int nMethod = ( aFileName.toLowerCase().endsWith( ".jar" ) )
- ? ZipEntry.STORED : ZipEntry.DEFLATED;
- aZipEntry.setMethod( nMethod );
-
- CRC32 tempCRC = new CRC32();
- tempCRC.update( wholeFile, 0, wholeFile.length );
- aZipEntry.setCrc( tempCRC.getValue() );
-
- // write the contents into the zip element
- zos.putNextEntry( aZipEntry );
- zos.write( wholeFile, 0, fileLength );
- zos.closeEntry();
- }
-
- static public boolean deleteRecursively( File aFile )
- {
- if( aFile.isDirectory() )
- {
- File[] aChildrenFiles = aFile.listFiles();
- int nFileCount = aChildrenFiles.length;
- for( int i = 0 ; i < nFileCount ; i++ )
- {
- File aChildrenFile = aChildrenFiles[i];
- boolean bSuccess = deleteRecursively( aChildrenFile );
- if( !bSuccess )
- return false;
- }
- }
-
- return aFile.delete();
- }
-}
-
diff --git a/xmlhelp/source/com/sun/star/help/HelpComponent.java
b/xmlhelp/source/com/sun/star/help/HelpComponent.java
deleted file mode 100755
index bb5b092..0000000
--- a/xmlhelp/source/com/sun/star/help/HelpComponent.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.help;
-
-import com.sun.star.lib.uno.helper.Factory;
-import com.sun.star.lang.XSingleComponentFactory;
-import com.sun.star.registry.XRegistryKey;
-
-/** This class capsulates the class, that implements the minimal component and a
- * factory for creating the service (<CODE>__getComponentFactory</CODE>).
- */
-public class HelpComponent
-{
- /**
- * 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
- */
- public static XSingleComponentFactory __getComponentFactory(String sImplName)
- {
- XSingleComponentFactory xFactory = null;
-
- if ( sImplName.equals( HelpSearch._HelpSearch.class.getName() ) )
- xFactory = Factory.createComponentFactory(HelpSearch._HelpSearch.class,
- HelpSearch._HelpSearch.getServiceNames());
- else if ( sImplName.equals( HelpIndexer.class.getName() ) )
- xFactory = Factory.createComponentFactory(HelpIndexer.class,
- HelpIndexer.getServiceNames());
- return xFactory;
- }
-
- /** This method is a member of the interface for initializing an object
- * directly after its creation.
- * @param object This array of arbitrary objects will be passed to the
- * component after its creation.
- * @throws Exception Every exception will not be handled, but will be
- * passed to the caller.
- */
- public void initialize( Object[] object )
- throws com.sun.star.uno.Exception
- {
- /* The component describes what arguments its expected and in which
- * order!At this point you can read the objects and can intialize
- * your component using these objects.
- */
- }
-}
diff --git a/xmlhelp/source/com/sun/star/help/HelpIndexer.java
b/xmlhelp/source/com/sun/star/help/HelpIndexer.java
deleted file mode 100755
index abb8668..0000000
--- a/xmlhelp/source/com/sun/star/help/HelpIndexer.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.help;
-
-import com.sun.star.lib.uno.helper.WeakBase;
-import com.sun.star.lang.XServiceInfo;
-import com.sun.star.script.XInvocation;
-import com.sun.star.beans.XIntrospectionAccess;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.XComponentContext;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Date;
-import java.util.zip.ZipOutputStream;
-
-/**
- When this tool is used with long path names on Windows, that is paths which start
- with \\?\, then the caller must make sure that the path is unique. This is achieved
- by removing '.' and '..' from the path. Paths which are created by
- osl_getSystemPathFromFileURL fulfill this requirement. This is necessary because
- lucene is patched to not use File.getCanonicalPath. See long_path.patch in the lucene
- module.
- */
-public class HelpIndexer extends WeakBase
- implements XServiceInfo, XInvocation
-{
- static private final String __serviceName =
- "com.sun.star.help.HelpIndexer";
- static private final String aCreateIndexMethodName = "createIndex";
-
- static private com.sun.star.help.HelpIndexerTool helpindexer = new
com.sun.star.help.HelpIndexerTool();
-
- public HelpIndexer()
- {
- }
-
- public HelpIndexer(XComponentContext xCompContext)
- {
- }
-
- public static void mainImpl( String[] args, boolean bExtensionMode )
- {
- helpindexer.mainImpl( args , bExtensionMode );
- }
-
- public static void createZipFile( File aDirToZip, String aTargetZipFileStr )
- throws FileNotFoundException, IOException
- {
- helpindexer.createZipFile( aDirToZip , aTargetZipFileStr );
- }
-
- public static void addToZipRecursively( ZipOutputStream zos, File aFile, String aBasePath )
- throws FileNotFoundException, IOException
- {
- helpindexer.addToZipRecursively( zos , aFile , aBasePath );
- }
-
- static public boolean deleteRecursively( File aFile )
- {
- return helpindexer.deleteRecursively( aFile );
- }
-
- //===================================================
- // XInvocation
- public XIntrospectionAccess getIntrospection()
- {
- return null;
- }
-
- public Object invoke( String aFunctionName, java.lang.Object[] aParams,
- short[][] aOutParamIndex, java.lang.Object[][] aOutParam )
- throws com.sun.star.lang.IllegalArgumentException,
- com.sun.star.script.CannotConvertException,
- com.sun.star.reflection.InvocationTargetException
- {
- if(
- !aFunctionName.equals( aCreateIndexMethodName ) )
- throw new com.sun.star.lang.IllegalArgumentException();
-
- aOutParamIndex[0] = new short[0];
- aOutParam[0] = new Object[0];
-
- int nParamCount = aParams.length;
- String aStrs[] = new String[nParamCount];
- for( int i = 0 ; i < nParamCount ; i++ )
- {
- try
- {
- aStrs[i] = AnyConverter.toString( aParams[i] );
- }
- catch( IllegalArgumentException e )
- {
- aStrs[i] = "";
- }
- }
-
- boolean bExtensionMode = true;
- mainImpl( aStrs, bExtensionMode );
-
- return null;
- }
-
- public void setValue( String aPropertyName, java.lang.Object aValue )
- throws com.sun.star.beans.UnknownPropertyException,
- com.sun.star.script.CannotConvertException,
- com.sun.star.reflection.InvocationTargetException
- {
- throw new com.sun.star.beans.UnknownPropertyException();
- }
-
- public Object getValue( String aPropertyName )
- throws com.sun.star.beans.UnknownPropertyException
- {
- throw new com.sun.star.beans.UnknownPropertyException();
- }
-
- public boolean hasMethod( String aMethodName )
- {
- boolean bRet = (aMethodName.equals( aCreateIndexMethodName ) );
- return bRet;
- }
- public boolean hasProperty( String aName ) {
- return false;
- }
-
-
-
- /** This method returns an array of all supported service names.
- * @return Array of supported service names.
- */
- public String[] getSupportedServiceNames()
- {
- return getServiceNames();
- }
-
- /** This method is a simple helper function to used in the
- * static component initialisation functions as well as in
- * getSupportedServiceNames.
- */
- public static String[] getServiceNames()
- {
- String[] sSupportedServiceNames = { __serviceName };
- return sSupportedServiceNames;
- }
-
-
- /** This method returns true, if the given service will be
- * supported by the component.
- * @param sServiceName Service name.
- * @return True, if the given service name will be supported.
- */
- public boolean supportsService( String sServiceName )
- {
- return sServiceName.equals( __serviceName );
- }
-
-
- /** Return the class name of the component.
- * @return Class name of the component.
- */
- public String getImplementationName()
- {
- return HelpIndexer.class.getName();
- }
-
-}
-
diff --git a/xmlhelp/source/com/sun/star/help/HelpSearch.java
b/xmlhelp/source/com/sun/star/help/HelpSearch.java
deleted file mode 100755
index dc31514..0000000
--- a/xmlhelp/source/com/sun/star/help/HelpSearch.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.help;
-
-import com.sun.star.lib.uno.helper.Factory;
-import com.sun.star.lang.XMultiComponentFactory;
-import com.sun.star.lang.XSingleComponentFactory;
-import com.sun.star.lib.uno.helper.WeakBase;
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.registry.XRegistryKey;
-import com.sun.star.lang.XServiceInfo;
-import com.sun.star.uno.Type;
-import com.sun.star.uno.Any;
-import com.sun.star.uno.AnyConverter;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.analysis.cjk.CJKAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.Searcher;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.WildcardQuery;
-
-import com.sun.star.script.XInvocation;
-import com.sun.star.beans.XIntrospectionAccess;
-
-/** This class capsulates the class, that implements the minimal component and a
- * factory for creating the service (<CODE>__getComponentFactory</CODE>).
- */
-public class HelpSearch
-{
- /** This class implements the component. At least the interfaces XServiceInfo,
- * XTypeProvider, and XInitialization should be provided by the service.
- */
- public static class _HelpSearch extends WeakBase
- implements XServiceInfo, XInvocation
- {
- /** The service name, that must be used to get an instance of this service.
- */
- static private final String __serviceName =
- "com.sun.star.help.HelpSearch";
- static private final String aSearchMethodName = "search";
-
- /** The initial component contextr, that gives access to
- * the service manager, supported singletons, ...
- * It's often later used
- */
- private XComponentContext m_cmpCtx;
-
- /** The service manager, that gives access to all registered services.
- * It's often later used
- */
- private XMultiComponentFactory m_xMCF;
-
- /** The constructor of the inner class has a XMultiServiceFactory parameter.
- * @param xmultiservicefactoryInitialization A special service factory
- * could be introduced while initializing.
- */
- public _HelpSearch(XComponentContext xCompContext)
- {
- try {
- m_cmpCtx = xCompContext;
- m_xMCF = m_cmpCtx.getServiceManager();
- }
- catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
- /** This method returns an array of all supported service names.
- * @return Array of supported service names.
- */
- public String[] getSupportedServiceNames()
- {
- return getServiceNames();
- }
-
- /** This method is a simple helper function to used in the
- * static component initialisation functions as well as in
- * getSupportedServiceNames.
- */
- public static String[] getServiceNames()
- {
- String[] sSupportedServiceNames = { __serviceName };
- return sSupportedServiceNames;
- }
-
- /** This method returns true, if the given service will be
- * supported by the component.
- * @param sServiceName Service name.
- * @return True, if the given service name will be supported.
- */
- public boolean supportsService( String sServiceName )
- {
- return sServiceName.equals( __serviceName );
- }
-
- /** Return the class name of the component.
- * @return Class name of the component.
- */
- public String getImplementationName()
- {
- return _HelpSearch.class.getName();
- }
-
- //===================================================
- // XInvocation
- public XIntrospectionAccess getIntrospection()
- {
- return null;
- }
-
- public Object invoke( String aFunctionName, java.lang.Object[] aParams,
- short[][] aOutParamIndex, java.lang.Object[][] aOutParam )
- throws com.sun.star.lang.IllegalArgumentException,
- com.sun.star.script.CannotConvertException,
- com.sun.star.reflection.InvocationTargetException
- {
- String[] aRet = null;
- if( !aFunctionName.equals( aSearchMethodName ) )
- throw new com.sun.star.lang.IllegalArgumentException();
-
- Object[] aScoreOutArray = new Object[1];
- aScoreOutArray[0] = null;
- try
- {
- aRet = doQuery( aParams, aScoreOutArray );
- }
- catch( Exception e )
- {
- aRet = null;
- }
-
- Object aScoreArray = aScoreOutArray[0];
- if( aScoreArray == null )
- {
- aOutParamIndex[0] = new short[0];
- aOutParam[0] = new Object[0];
- }
- else
- {
- short nInParamCount = (short)aParams.length;
- aOutParamIndex[0] = new short[1];
- aOutParamIndex[0][0] = nInParamCount;
- aOutParam[0] = new Object[1];
- aOutParam[0][0] = aScoreArray;
- }
-
- Any aRetAny = new Any( new Type( String[].class ), aRet );
- return aRetAny;
- }
-
- public void setValue( String aPropertyName, java.lang.Object aValue )
- throws com.sun.star.beans.UnknownPropertyException,
- com.sun.star.script.CannotConvertException,
- com.sun.star.reflection.InvocationTargetException {
- throw new com.sun.star.beans.UnknownPropertyException();
- }
-
- public Object getValue( String aPropertyName )
- throws com.sun.star.beans.UnknownPropertyException {
- throw new com.sun.star.beans.UnknownPropertyException();
- }
-
- public boolean hasMethod( String aMethodName ) {
- boolean bRet = (aMethodName.equals( aSearchMethodName ) );
- return bRet;
- }
- public boolean hasProperty( String aName ) {
- return false;
- }
-
- // Command line interface for testing
- private static String[] doQuery( Object[] args, Object[] aScoreOutArray ) throws Exception
- {
- String aLanguageStr = "";
- String aIndexStr = "";
- String aQueryStr = "";
- boolean bCaptionOnly = false;
-
- int nParamCount = args.length;
- String aStrs[] = new String[nParamCount];
- for( int i = 0 ; i < nParamCount ; i++ )
- {
- try
- {
- aStrs[i] = AnyConverter.toString( args[i] );
- }
- catch( IllegalArgumentException e )
- {
- aStrs[i] = "";
- }
- }
-
- // TODO: Error handling
- for( int i = 0 ; i < nParamCount ; i++ )
- {
- if ("-lang".equals(aStrs[i]) )
- {
- aLanguageStr = aStrs[i + 1];
- i++;
- }
- else if( "-index".equals(aStrs[i]) )
- {
- aIndexStr = aStrs[i+1];
- i++;
- }
- else if( "-query".equals(aStrs[i]) )
- {
- aQueryStr = aStrs[i+1];
- i++;
- }
- else if( "-caption".equals(aStrs[i]) )
- {
- bCaptionOnly = true;
- }
- }
- String[] aDocs = queryImpl( aLanguageStr, aIndexStr, aQueryStr, bCaptionOnly,
aScoreOutArray );
-
- return aDocs;
- }
-
- private static String[] queryImpl( String aLanguageStr, String aIndexStr, String aQueryStr,
- boolean bCaptionOnly, Object[] aScoreOutArray ) throws Exception
- {
- IndexReader reader = IndexReader.open( aIndexStr );
- Searcher searcher = new IndexSearcher( reader );
- Analyzer analyzer = aLanguageStr.equals("ja") ? (Analyzer)new CJKAnalyzer() :
(Analyzer)new StandardAnalyzer();
-
- String aField;
- if( bCaptionOnly )
- aField = "caption";
- else
- aField = "content";
-
- Query aQuery;
- if( aQueryStr.endsWith( "*" ) )
- aQuery = new WildcardQuery( new Term( aField, aQueryStr ) );
- else
- aQuery = new TermQuery( new Term( aField, aQueryStr ) );
-
- // Perform search
- Hits aHits = searcher.search( aQuery );
- int nHitCount = aHits.length();
-
- String aDocs[] = new String[nHitCount];
- float aScores[] = null;
- aScores = new float[nHitCount];
- for( int iHit = 0 ; iHit < nHitCount ; iHit++ )
- {
- Document aDoc = aHits.doc( iHit );
- String aPath = aDoc.get( "path" );
- aDocs[iHit] = ( aPath != null ) ? aPath : "";
- aScores[iHit] = aHits.score( iHit );
- }
- aScoreOutArray[0] = aScores;
-
- reader.close();
-
- return aDocs;
- }
- }
-
- /**
- * 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
- */
- public static XSingleComponentFactory __getComponentFactory(String sImplName)
- {
- XSingleComponentFactory xFactory = null;
-
- if ( sImplName.equals( _HelpSearch.class.getName() ) )
- xFactory = Factory.createComponentFactory(_HelpSearch.class,
- _HelpSearch.getServiceNames());
-
- return xFactory;
- }
-
- /** This method is a member of the interface for initializing an object
- * directly after its creation.
- * @param object This array of arbitrary objects will be passed to the
- * component after its creation.
- * @throws Exception Every exception will not be handled, but will be
- * passed to the caller.
- */
- public void initialize( Object[] object )
- throws com.sun.star.uno.Exception {
- /* The component describes what arguments its expected and in which
- * order!At this point you can read the objects and can intialize
- * your component using these objects.
- */
- }
-}
diff --git a/xmlhelp/source/com/sun/star/help/LuceneHelpWrapper.component
b/xmlhelp/source/com/sun/star/help/LuceneHelpWrapper.component
deleted file mode 100755
index 04b35bc..0000000
--- a/xmlhelp/source/com/sun/star/help/LuceneHelpWrapper.component
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--**********************************************************************
-*
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2000, 2010 Oracle and/or its affiliates.
-*
-* OpenOffice.org - a multi-platform office productivity suite
-*
-* This file is part of OpenOffice.org.
-*
-* OpenOffice.org is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License version 3
-* only, as published by the Free Software Foundation.
-*
-* OpenOffice.org is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Lesser General Public License version 3 for more details
-* (a copy is included in the LICENSE file that accompanied this code).
-*
-* You should have received a copy of the GNU Lesser General Public License
-* version 3 along with OpenOffice.org. If not, see
-* <http://www.openoffice.org/license.html>
-* for a copy of the LGPLv3 License.
-*
-**********************************************************************-->
-
-<component loader="com.sun.star.loader.Java2"
- xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.help.HelpIndexer">
- <service name="com.sun.star.help.HelpIndexer"/>
- </implementation>
- <implementation name="com.sun.star.help.HelpSearch$_HelpSearch">
- <service name="com.sun.star.help.HelpSearch"/>
- </implementation>
-</component>
diff --git a/xmlhelp/source/com/sun/star/help/MANIFEST.MF
b/xmlhelp/source/com/sun/star/help/MANIFEST.MF
deleted file mode 100755
index a4c5d50..0000000
--- a/xmlhelp/source/com/sun/star/help/MANIFEST.MF
+++ /dev/null
@@ -1 +0,0 @@
-RegistrationClassName: com.sun.star.help.HelpComponent
diff --git a/xmlhelp/source/com/sun/star/help/helplinker.pmk
b/xmlhelp/source/com/sun/star/help/helplinker.pmk
deleted file mode 100755
index 6e99d32..0000000
--- a/xmlhelp/source/com/sun/star/help/helplinker.pmk
+++ /dev/null
@@ -1,31 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-# define HELPLINKER_DLLIMPLEMENTATION (see @ inc/xmlhelp/helplinkerdllapi.h)
-CDEFS += -DHELPLINKER_DLLIMPLEMENTATION
-
-VISIBILITY_HIDDEN=TRUE
diff --git a/xmlhelp/source/com/sun/star/help/makefile.mk
b/xmlhelp/source/com/sun/star/help/makefile.mk
deleted file mode 100755
index a67f755..0000000
--- a/xmlhelp/source/com/sun/star/help/makefile.mk
+++ /dev/null
@@ -1,90 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ = ..$/..$/..$/..$/..
-PRJNAME = xmlhelp
-TARGET = HelpLinker
-PACKAGE = com$/sun$/star$/help
-
-.IF "$(SOLAR_JAVA)"!=""
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-
-JAVACLASSFILES = \
- $(CLASSDIR)$/$(PACKAGE)$/HelpSearch.class \
- $(CLASSDIR)$/$(PACKAGE)$/HelpComponent.class \
- $(CLASSDIR)$/$(PACKAGE)$/HelpIndexer.class
-
-TRANSEX3FILES = \
- $(SOLARBINDIR)$/help$/$(PACKAGE)$/HelpIndexerTool.class \
- $(SOLARBINDIR)$/help$/$(PACKAGE)$/HelpFileDocument.class
-
-ADDFILES = $(subst,$(SOLARBINDIR)$/help,$(CLASSDIR) $(TRANSEX3FILES))
-
-JARFILES = ridl.jar jurt.jar unoil.jar juh.jar
-.IF "$(SYSTEM_LUCENE)" == "YES"
-EXTRAJARFILES = $(LUCENE_CORE_JAR) $(LUCENE_ANALYZERS_JAR)
-JARCLASSPATH = $(EXTRAJARFILES)
-.ELSE
-JARFILES += lucene-core-2.3.jar lucene-analyzers-2.3.jar
-JARCLASSPATH = lucene-core-2.3.jar lucene-analyzers-2.3.jar
-.ENDIF
-
-JARTARGET = LuceneHelpWrapper.jar
-JARCOMPRESS = TRUE
-CUSTOMMANIFESTFILE = MANIFEST.MF
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
-
-.IF "$(JARTARGETN)"!=""
-$(JAVATARGET) : $(ADDFILES)
-$(JARTARGETN) : $(ADDFILES)
-.ENDIF
-
-$(ADDFILES) : $(SOLARBINDIR)$/help$/$(PACKAGE)$/$$(@:f)
- $(MKDIRHIER) $(@:d)
- $(COPY) $< $@
-
-fix_system_lucene:
- @echo "Fix Java Class-Path entry for Lucene libraries from system."
- @$(SED) -r -e "s#^(Class-Path:).*#\1 file://$(LUCENE_CORE_JAR)
file://$(LUCENE_ANALYZERS_JAR)#" \
- -i ../../../../../$(INPATH)/class/HelpLinker/META-INF/MANIFEST.MF
-
-ALLTAR : $(MISC)/LuceneHelpWrapper.component
-
-$(MISC)/LuceneHelpWrapper.component .ERRREMOVE : \
- $(SOLARENV)/bin/createcomponent.xslt LuceneHelpWrapper.component
- $(XSLTPROC) --nonet --stringparam uri \
- '$(COMPONENTPREFIX_BASIS_JAVA)$(JARTARGET)' -o $@ \
- $(SOLARENV)/bin/createcomponent.xslt LuceneHelpWrapper.component
-.ELSE
-all:
- @echo java disabled
-.ENDIF
--
1.7.0.4
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.