summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-02-22 09:13:10 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-02-23 10:31:19 +0000
commit170b9551b24b400fd98ef226e54a837a132870de (patch)
treeed775f1777a3cd43fa230cc68ef86c737b8730a5 /l10ntools
parent561cbe2bd5f5983bb3f95e226f3c3230030fe532 (diff)
tweak for cross-platformity
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/inc/l10ntools/HelpSearch.hxx2
-rw-r--r--l10ntools/source/help/HelpIndexer.cxx216
-rw-r--r--l10ntools/source/help/HelpIndexer_main.cxx184
-rw-r--r--l10ntools/source/help/HelpSearch.cxx104
-rw-r--r--l10ntools/source/help/LuceneHelper.cxx31
-rw-r--r--l10ntools/source/help/LuceneHelper.hxx31
6 files changed, 384 insertions, 184 deletions
diff --git a/l10ntools/inc/l10ntools/HelpSearch.hxx b/l10ntools/inc/l10ntools/HelpSearch.hxx
index 4885b5698222..8c11aba7f832 100644
--- a/l10ntools/inc/l10ntools/HelpSearch.hxx
+++ b/l10ntools/inc/l10ntools/HelpSearch.hxx
@@ -12,7 +12,7 @@
class L10N_DLLPUBLIC HelpSearch {
private:
rtl::OUString d_lang;
- rtl::OUString d_indexDir;
+ rtl::OString d_indexDir;
public:
diff --git a/l10ntools/source/help/HelpIndexer.cxx b/l10ntools/source/help/HelpIndexer.cxx
index fdae9e63d273..9182005b100d 100644
--- a/l10ntools/source/help/HelpIndexer.cxx
+++ b/l10ntools/source/help/HelpIndexer.cxx
@@ -1,117 +1,161 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
+ * (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
#include <l10ntools/HelpIndexer.hxx>
#include "LuceneHelper.hxx"
#include <CLucene/analysis/LanguageBasedAnalyzer.h>
#include <rtl/string.hxx>
+#include <rtl/uri.hxx>
+#include <rtl/ustrbuf.hxx>
#include <osl/file.hxx>
+#include <osl/thread.h>
#include <algorithm>
using namespace lucene::document;
HelpIndexer::HelpIndexer(rtl::OUString const &lang, rtl::OUString const &module,
- rtl::OUString const &captionDir, rtl::OUString const &contentDir, rtl::OUString const &indexDir) :
+ rtl::OUString const &captionDir, rtl::OUString const &contentDir, rtl::OUString const &indexDir) :
d_lang(lang), d_module(module), d_captionDir(captionDir), d_contentDir(contentDir), d_indexDir(indexDir),
-d_error(), d_files() {}
+d_error(), d_files()
+{
+}
bool HelpIndexer::indexDocuments() {
- if (!scanForFiles()) {
- return false;
- }
-
- rtl::OUString sLang = d_lang.getToken(0, '-');
- bool bUseCJK =
- sLang.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ja")) ||
- sLang.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ko")) ||
- sLang.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("zh"));
-
- // Construct the analyzer appropriate for the given language
- lucene::analysis::Analyzer *analyzer = (
- bUseCJK ?
- (lucene::analysis::Analyzer*)new lucene::analysis::LanguageBasedAnalyzer(L"cjk") :
- (lucene::analysis::Analyzer*)new lucene::analysis::standard::StandardAnalyzer());
-
- rtl::OString indexDirStr;
- d_indexDir.convertToString(&indexDirStr, RTL_TEXTENCODING_ASCII_US, 0);
- lucene::index::IndexWriter writer(indexDirStr.getStr(), analyzer, true);
-
- // Index the identified help files
- Document doc;
- for (std::set<rtl::OUString>::iterator i = d_files.begin(); i != d_files.end(); ++i) {
- doc.clear();
- if (!helpDocument(*i, &doc)) {
- delete analyzer;
- return false;
- }
- writer.addDocument(&doc);
- }
-
- // Optimize the index
- writer.optimize();
-
- delete analyzer;
- return true;
+ if (!scanForFiles()) {
+ return false;
+ }
+
+ rtl::OUString sLang = d_lang.getToken(0, '-');
+ bool bUseCJK =
+ sLang.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ja")) ||
+ sLang.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ko")) ||
+ sLang.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("zh"));
+
+ // Construct the analyzer appropriate for the given language
+ lucene::analysis::Analyzer *analyzer;
+ if (bUseCJK)
+ analyzer = new lucene::analysis::LanguageBasedAnalyzer(L"cjk");
+ else
+ analyzer = new lucene::analysis::standard::StandardAnalyzer();
+
+ rtl::OUString ustrSystemPath;
+ osl::File::getSystemPathFromFileURL(d_indexDir, ustrSystemPath);
+
+ rtl::OString indexDirStr = rtl::OUStringToOString(ustrSystemPath, osl_getThreadTextEncoding());
+ lucene::index::IndexWriter writer(indexDirStr.getStr(), analyzer, true);
+
+ // Index the identified help files
+ Document doc;
+ for (std::set<rtl::OUString>::iterator i = d_files.begin(); i != d_files.end(); ++i) {
+ helpDocument(*i, &doc);
+ writer.addDocument(&doc);
+ doc.clear();
+ }
+ writer.optimize();
+
+ // Optimize the index
+ writer.optimize();
+
+ delete analyzer;
+ return true;
}
rtl::OUString const & HelpIndexer::getErrorMessage() {
- return d_error;
+ return d_error;
}
bool HelpIndexer::scanForFiles() {
- if (!scanForFiles(d_contentDir)) {
- return false;
- }
- if (!scanForFiles(d_captionDir)) {
- return false;
- }
- return true;
+ if (!scanForFiles(d_contentDir)) {
+ return false;
+ }
+ if (!scanForFiles(d_captionDir)) {
+ return false;
+ }
+ return true;
}
bool HelpIndexer::scanForFiles(rtl::OUString const & path) {
- osl::Directory dir(path);
- if (osl::FileBase::E_None != dir.open()) {
- d_error = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Error reading directory ")) + path;
- return true;
- }
-
- 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());
- }
- }
-
- return true;
+
+ osl::Directory dir(path);
+ if (osl::FileBase::E_None != dir.open()) {
+ d_error = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Error reading directory ")) + path;
+ return true;
+ }
+
+ osl::DirectoryItem item;
+ osl::FileStatus fileStatus(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Type);
+ while (dir.getNextItem(item) == osl::FileBase::E_None) {
+ item.getFileStatus(fileStatus);
+ if (fileStatus.getFileType() == osl::FileStatus::Regular) {
+ d_files.insert(fileStatus.getFileName());
+ }
+ }
+
+ return true;
}
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;
- std::vector<TCHAR> aPath(OUStringToTCHARVec(path));
- doc->add(*new Field(_T("path"), &aPath[0], Field::STORE_YES | Field::INDEX_UNTOKENIZED));
-
- // Add the caption as a field.
- rtl::OUString captionPath = d_captionDir + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + fileName;
- doc->add(*new Field(_T("caption"), helpFileReader(captionPath), Field::STORE_NO | Field::INDEX_TOKENIZED));
- // FIXME: does the Document take responsibility for the FileReader or should I free it somewhere?
-
- // Add the content as a field.
- rtl::OUString contentPath = d_contentDir + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + fileName;
- doc->add(*new Field(_T("content"), helpFileReader(contentPath), Field::STORE_NO | Field::INDEX_TOKENIZED));
- // FIXME: does the Document take responsibility for the FileReader or should I free it somewhere?
-
- return true;
+ // 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;
+ std::vector<TCHAR> aPath(OUStringToTCHARVec(path));
+ doc->add(*_CLNEW Field(_T("path"), &aPath[0], Field::STORE_YES | Field::INDEX_UNTOKENIZED));
+
+ rtl::OUString sEscapedFileName =
+ rtl::Uri::encode(fileName,
+ rtl_UriCharClassUric, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8);
+
+ // Add the caption as a field.
+ rtl::OUString captionPath = d_captionDir + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sEscapedFileName;
+ doc->add(*_CLNEW Field(_T("caption"), helpFileReader(captionPath), Field::STORE_NO | Field::INDEX_TOKENIZED));
+
+ // Add the content as a field.
+ rtl::OUString contentPath = d_contentDir + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sEscapedFileName;
+ doc->add(*_CLNEW Field(_T("content"), helpFileReader(contentPath), Field::STORE_NO | Field::INDEX_TOKENIZED));
+
+ return true;
}
lucene::util::Reader *HelpIndexer::helpFileReader(rtl::OUString const & path) {
- 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"");
- }
+ osl::File file(path);
+ if (osl::FileBase::E_None == file.open(osl_File_OpenFlag_Read)) {
+ file.close();
+ rtl::OUString ustrSystemPath;
+ osl::File::getSystemPathFromFileURL(path, ustrSystemPath);
+ rtl::OString pathStr = rtl::OUStringToOString(ustrSystemPath, osl_getThreadTextEncoding());
+ return _CLNEW lucene::util::FileReader(pathStr.getStr(), "UTF-8");
+ } else {
+ return _CLNEW lucene::util::StringReader(L"");
+ }
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/help/HelpIndexer_main.cxx b/l10ntools/source/help/HelpIndexer_main.cxx
index ecea92847735..937f273b5c07 100644
--- a/l10ntools/source/help/HelpIndexer_main.cxx
+++ b/l10ntools/source/help/HelpIndexer_main.cxx
@@ -1,71 +1,125 @@
-#include <l10ntools/HelpIndexer.hxx>
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
+ * (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#include <l10ntools/HelpIndexer.hxx>
+#include <osl/file.hxx>
+#include <osl/process.h>
+#include <osl/thread.h>
#include <string>
#include <iostream>
int main(int argc, char **argv) {
- const std::string pLang("-lang");
- const std::string pModule("-mod");
- const std::string pOutDir("-zipdir");
- const std::string pSrcDir("-srcdir");
-
- std::string lang;
- std::string module;
- std::string srcDir;
- std::string outDir;
-
- bool error = false;
- for (int i = 1; i < argc; ++i) {
- if (pLang.compare(argv[i]) == 0) {
- if (i + 1 < argc) {
- lang = argv[++i];
- } else {
- error = true;
- }
- } else if (pModule.compare(argv[i]) == 0) {
- if (i + 1 < argc) {
- module = argv[++i];
- } else {
- error = true;
- }
- } else if (pOutDir.compare(argv[i]) == 0) {
- if (i + 1 < argc) {
- outDir = argv[++i];
- } else {
- error = true;
- }
- } else if (pSrcDir.compare(argv[i]) == 0) {
- if (i + 1 < argc) {
- srcDir = argv[++i];
- } else {
- error = true;
- }
- } else {
- error = true;
- }
- }
-
- if (error) {
- std::cerr << "Error parsing command-line arguments" << std::endl;
- }
-
- if (error || lang.empty() || module.empty() || srcDir.empty() || outDir.empty()) {
- std::cerr << "Usage: HelpIndexer -lang ISOLangCode -mod HelpModule -srcdir SourceDir -zipdir OutputDir" << std::endl;
- return 1;
- }
-
- std::string captionDir(srcDir + "/caption");
- std::string contentDir(srcDir + "/content");
- std::string indexDir(outDir + "/" + module + ".idxl");
- HelpIndexer indexer(
- rtl::OUString::createFromAscii(lang.c_str()),
- rtl::OUString::createFromAscii(module.c_str()),
- rtl::OUString::createFromAscii(captionDir.c_str()),
- rtl::OUString::createFromAscii(contentDir.c_str()),
- rtl::OUString::createFromAscii(indexDir.c_str()));
- if (!indexer.indexDocuments()) {
- std::wcerr << indexer.getErrorMessage().getStr() << std::endl;
- return 2;
- }
- return 0;
+ const std::string pLang("-lang");
+ const std::string pModule("-mod");
+ const std::string pOutDir("-zipdir");
+ const std::string pSrcDir("-srcdir");
+
+ std::string lang;
+ std::string module;
+ std::string srcDir;
+ std::string outDir;
+
+ bool error = false;
+ for (int i = 1; i < argc; ++i) {
+ if (pLang.compare(argv[i]) == 0) {
+ if (i + 1 < argc) {
+ lang = argv[++i];
+ } else {
+ error = true;
+ }
+ } else if (pModule.compare(argv[i]) == 0) {
+ if (i + 1 < argc) {
+ module = argv[++i];
+ } else {
+ error = true;
+ }
+ } else if (pOutDir.compare(argv[i]) == 0) {
+ if (i + 1 < argc) {
+ outDir = argv[++i];
+ } else {
+ error = true;
+ }
+ } else if (pSrcDir.compare(argv[i]) == 0) {
+ if (i + 1 < argc) {
+ srcDir = argv[++i];
+ } else {
+ error = true;
+ }
+ } else {
+ error = true;
+ }
+ }
+
+ if (error) {
+ std::cerr << "Error parsing command-line arguments" << std::endl;
+ }
+
+ if (error || lang.empty() || module.empty() || srcDir.empty() || outDir.empty()) {
+ std::cerr << "Usage: HelpIndexer -lang ISOLangCode -mod HelpModule -srcdir SourceDir -zipdir OutputDir" << std::endl;
+ return 1;
+ }
+
+ std::string captionDir(srcDir + SAL_PATHDELIMITER + "caption");
+ std::string contentDir(srcDir + SAL_PATHDELIMITER + "content");
+ std::string indexDir(outDir + SAL_PATHDELIMITER + module + ".idxl");
+
+ rtl::OUString sCaptionDir, sContentDir, sIndexDir;
+
+ osl::File::getFileURLFromSystemPath(
+ rtl::OUString(captionDir.c_str(), captionDir.size(), osl_getThreadTextEncoding()),
+ sCaptionDir);
+
+ osl::File::getFileURLFromSystemPath(
+ rtl::OUString(contentDir.c_str(), contentDir.size(), osl_getThreadTextEncoding()),
+ sContentDir);
+
+ osl::File::getFileURLFromSystemPath(
+ rtl::OUString(indexDir.c_str(), indexDir.size(), osl_getThreadTextEncoding()),
+ sIndexDir);
+
+ rtl::OUString cwd;
+ osl_getProcessWorkingDir(&cwd.pData);
+
+ osl::File::getAbsoluteFileURL(cwd, sCaptionDir, sCaptionDir);
+ osl::File::getAbsoluteFileURL(cwd, sContentDir, sContentDir);
+ osl::File::getAbsoluteFileURL(cwd, sIndexDir, sIndexDir);
+
+ HelpIndexer indexer(
+ rtl::OUString(lang.c_str(), lang.size(), osl_getThreadTextEncoding()),
+ rtl::OUString(module.c_str(), module.size(), osl_getThreadTextEncoding()),
+ sCaptionDir, sContentDir, sIndexDir);
+
+ if (!indexer.indexDocuments()) {
+ std::wcerr << indexer.getErrorMessage().getStr() << std::endl;
+ return 2;
+ }
+ return 0;
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/help/HelpSearch.cxx b/l10ntools/source/help/HelpSearch.cxx
index f50c44eb7cbd..d54b278d1ea4 100644
--- a/l10ntools/source/help/HelpSearch.cxx
+++ b/l10ntools/source/help/HelpSearch.cxx
@@ -1,40 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
+ * (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
#include <l10ntools/HelpSearch.hxx>
+#include <osl/file.hxx>
+#include <osl/thread.hxx>
#include "LuceneHelper.hxx"
#include <iostream>
-HelpSearch::HelpSearch(rtl::OUString const &lang, rtl::OUString const &indexDir) :
-d_lang(lang), d_indexDir(indexDir) {}
+HelpSearch::HelpSearch(rtl::OUString const &lang, rtl::OUString const &indexDir)
+ : d_lang(lang)
+{
+ rtl::OUString ustrSystemPath;
+ osl::File::getSystemPathFromFileURL(indexDir, ustrSystemPath);
+ d_indexDir = rtl::OUStringToOString(ustrSystemPath, osl_getThreadTextEncoding());
+}
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;
+ std::vector<rtl::OUString> &rDocuments, std::vector<float> &rScores) {
+
+ lucene::index::IndexReader *reader = lucene::index::IndexReader::open(d_indexDir.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 *pQuery;
+ if (isWildcard)
+ pQuery = _CLNEW lucene::search::WildcardQuery(_CLNEW lucene::index::Term(field, &aQueryStr[0]));
+ else
+ pQuery = _CLNEW lucene::search::TermQuery(_CLNEW lucene::index::Term(field, &aQueryStr[0]));
+
+ lucene::search::Hits *hits = searcher.search(pQuery);
+ 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));
+ }
+
+ _CLDELETE(hits);
+ _CLDELETE(pQuery);
+
+ reader->close();
+ _CLDELETE(reader);
+
+ return true;
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/help/LuceneHelper.cxx b/l10ntools/source/help/LuceneHelper.cxx
index f83d888f6222..bee9090cc2b7 100644
--- a/l10ntools/source/help/LuceneHelper.cxx
+++ b/l10ntools/source/help/LuceneHelper.cxx
@@ -1,3 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
+ * (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
#include "LuceneHelper.hxx"
std::vector<TCHAR> OUStringToTCHARVec(rtl::OUString const &rStr)
@@ -26,3 +55,5 @@ rtl::OUString TCHARArrayToOUString(TCHAR const *str)
// UTF-32
return rtl::OUString((const sal_uInt32*)str, wcslen(str));
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/help/LuceneHelper.hxx b/l10ntools/source/help/LuceneHelper.hxx
index 7591b8ca0760..53ed763d59b8 100644
--- a/l10ntools/source/help/LuceneHelper.hxx
+++ b/l10ntools/source/help/LuceneHelper.hxx
@@ -1,3 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
+ * (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
#ifndef LUCENEHELPER_HXX
#define LUCENEHELPER_HXX
@@ -11,3 +40,5 @@ std::vector<TCHAR> OUStringToTCHARVec(rtl::OUString const &rStr);
rtl::OUString TCHARArrayToOUString(TCHAR const *str);
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */