Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
0f691cc6
Kaydet (Commit)
0f691cc6
authored
Şub 14, 2012
tarafından
Gert van Valkenhoef
Kaydeden (comit)
Caolán McNamara
Şub 23, 2012
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
HelpIndexer using rtl::OUString, called from xmlhelp
üst
db4bc712
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
105 additions
and
102 deletions
+105
-102
HelpIndexer.cxx
l10ntools/source/help/HelpIndexer.cxx
+33
-26
HelpIndexer.hxx
l10ntools/source/help/HelpIndexer.hxx
+15
-17
HelpIndexer_main.cxx
l10ntools/source/help/HelpIndexer_main.cxx
+7
-2
databases.cxx
xmlhelp/source/cxxhelp/provider/databases.cxx
+45
-57
makefile.mk
xmlhelp/source/cxxhelp/provider/makefile.mk
+5
-0
No files found.
l10ntools/source/help/HelpIndexer.cxx
Dosyayı görüntüle @
0f691cc6
...
...
@@ -6,6 +6,8 @@
#include <CLucene/analysis/LanguageBasedAnalyzer.h>
#endif
#include <rtl/string.hxx>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
...
...
@@ -16,9 +18,10 @@
using
namespace
lucene
::
document
;
HelpIndexer
::
HelpIndexer
(
std
::
string
const
&
lang
,
std
::
string
const
&
module
,
std
::
string
const
&
captionDir
,
std
::
string
const
&
contentDir
,
std
::
string
const
&
indexDir
)
:
d_lang
(
lang
),
d_module
(
module
),
d_captionDir
(
captionDir
),
d_contentDir
(
contentDir
),
d_indexDir
(
indexDir
),
d_error
(
""
),
d_files
()
{}
HelpIndexer
::
HelpIndexer
(
rtl
::
OUString
const
&
lang
,
rtl
::
OUString
const
&
module
,
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
()
{}
bool
HelpIndexer
::
indexDocuments
()
{
if
(
!
scanForFiles
())
{
...
...
@@ -28,7 +31,7 @@ bool HelpIndexer::indexDocuments() {
#ifdef TODO
// Construct the analyzer appropriate for the given language
lucene
::
analysis
::
Analyzer
*
analyzer
=
(
d_lang
.
compare
(
"ja"
)
==
0
?
d_lang
.
compare
ToAscii
(
"ja"
)
==
0
?
(
lucene
::
analysis
::
Analyzer
*
)
new
lucene
::
analysis
::
LanguageBasedAnalyzer
(
L"cjk"
)
:
(
lucene
::
analysis
::
Analyzer
*
)
new
lucene
::
analysis
::
standard
::
StandardAnalyzer
());
#else
...
...
@@ -36,11 +39,13 @@ bool HelpIndexer::indexDocuments() {
(
lucene
::
analysis
::
Analyzer
*
)
new
lucene
::
analysis
::
standard
::
StandardAnalyzer
());
#endif
lucene
::
index
::
IndexWriter
writer
(
d_indexDir
.
c_str
(),
analyzer
,
true
);
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
<
std
::
s
tring
>::
iterator
i
=
d_files
.
begin
();
i
!=
d_files
.
end
();
++
i
)
{
for
(
std
::
set
<
rtl
::
OUS
tring
>::
iterator
i
=
d_files
.
begin
();
i
!=
d_files
.
end
();
++
i
)
{
doc
.
clear
();
if
(
!
helpDocument
(
*
i
,
&
doc
))
{
delete
analyzer
;
...
...
@@ -56,7 +61,7 @@ bool HelpIndexer::indexDocuments() {
return
true
;
}
std
::
s
tring
const
&
HelpIndexer
::
getErrorMessage
()
{
rtl
::
OUS
tring
const
&
HelpIndexer
::
getErrorMessage
()
{
return
d_error
;
}
...
...
@@ -70,18 +75,23 @@ bool HelpIndexer::scanForFiles() {
return
true
;
}
bool
HelpIndexer
::
scanForFiles
(
std
::
string
const
&
path
)
{
DIR
*
dir
=
opendir
(
path
.
c_str
());
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
=
"Error reading directory "
+
path
+
strerror
(
errno
);
d_error
=
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"Error reading directory "
))
+
path
+
rtl
::
OUString
::
createFromAscii
(
strerror
(
errno
));
return
true
;
}
struct
dirent
*
ent
;
struct
stat
info
;
while
((
ent
=
readdir
(
dir
))
!=
0
)
{
if
(
stat
((
path
+
"/"
+
ent
->
d_name
).
c_str
(),
&
info
)
==
0
&&
S_ISREG
(
info
.
st_mode
))
{
d_files
.
insert
(
ent
->
d_name
);
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
));
}
}
...
...
@@ -90,34 +100,31 @@ bool HelpIndexer::scanForFiles(std::string const & path) {
return
true
;
}
bool
HelpIndexer
::
helpDocument
(
std
::
s
tring
const
&
fileName
,
Document
*
doc
)
{
bool
HelpIndexer
::
helpDocument
(
rtl
::
OUS
tring
const
&
fileName
,
Document
*
doc
)
{
// Add the help path as an indexed, untokenized field.
std
::
wstring
path
(
L"#HLP#"
+
string2wstring
(
d_module
)
+
L"/"
+
string2wstring
(
fileName
));
doc
->
add
(
*
new
Field
(
_T
(
"path"
),
path
.
c_str
(),
Field
::
STORE_YES
|
Field
::
INDEX_UNTOKENIZED
));
rtl
::
OUString
path
=
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"#HLP#"
))
+
d_module
+
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"/"
))
+
fileName
;
// FIXME: the (TCHAR*) cast is a problem, because TCHAR does not match sal_Unicode
doc
->
add
(
*
new
Field
(
_T
(
"path"
),
(
TCHAR
*
)
path
.
getStr
(),
Field
::
STORE_YES
|
Field
::
INDEX_UNTOKENIZED
));
// Add the caption as a field.
std
::
string
captionPath
=
d_captionDir
+
"/"
+
fileName
;
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.
std
::
string
contentPath
=
d_contentDir
+
"/"
+
fileName
;
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
;
}
lucene
::
util
::
Reader
*
HelpIndexer
::
helpFileReader
(
std
::
string
const
&
path
)
{
if
(
access
(
path
.
c_str
(),
R_OK
)
==
0
)
{
return
new
lucene
::
util
::
FileReader
(
path
.
c_str
(),
"UTF-8"
);
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
)
{
return
new
lucene
::
util
::
FileReader
(
pathStr
.
getStr
(),
"UTF-8"
);
}
else
{
return
new
lucene
::
util
::
StringReader
(
L""
);
}
}
std
::
wstring
HelpIndexer
::
string2wstring
(
std
::
string
const
&
source
)
{
std
::
wstring
target
(
source
.
length
(),
L' '
);
std
::
copy
(
source
.
begin
(),
source
.
end
(),
target
.
begin
());
return
target
;
}
l10ntools/source/help/HelpIndexer.hxx
Dosyayı görüntüle @
0f691cc6
...
...
@@ -4,20 +4,20 @@
#include <CLucene/StdHeader.h>
#include <CLucene.h>
#include <
string
>
#include <
rtl/ustring.hxx
>
#include <set>
// I assume that TCHAR is defined as wchar_t throughout
class
HelpIndexer
{
private
:
std
::
s
tring
d_lang
;
std
::
s
tring
d_module
;
std
::
s
tring
d_captionDir
;
std
::
s
tring
d_contentDir
;
std
::
s
tring
d_indexDir
;
std
::
s
tring
d_error
;
std
::
set
<
std
::
s
tring
>
d_files
;
rtl
::
OUS
tring
d_lang
;
rtl
::
OUS
tring
d_module
;
rtl
::
OUS
tring
d_captionDir
;
rtl
::
OUS
tring
d_contentDir
;
rtl
::
OUS
tring
d_indexDir
;
rtl
::
OUS
tring
d_error
;
std
::
set
<
rtl
::
OUS
tring
>
d_files
;
public
:
...
...
@@ -28,9 +28,9 @@ class HelpIndexer {
* @param contentDir The directory to scan for content files.
* @param indexDir The directory to write the index to.
*/
HelpIndexer
(
std
::
string
const
&
lang
,
std
::
s
tring
const
&
module
,
std
::
string
const
&
captionDir
,
std
::
s
tring
const
&
contentDir
,
std
::
s
tring
const
&
indexDir
);
HelpIndexer
(
rtl
::
OUString
const
&
lang
,
rtl
::
OUS
tring
const
&
module
,
rtl
::
OUString
const
&
captionDir
,
rtl
::
OUS
tring
const
&
contentDir
,
rtl
::
OUS
tring
const
&
indexDir
);
/**
* Run the indexer.
...
...
@@ -41,7 +41,7 @@ class HelpIndexer {
/**
* Get the error string (empty if no error occurred).
*/
std
::
s
tring
const
&
getErrorMessage
();
rtl
::
OUS
tring
const
&
getErrorMessage
();
private
:
...
...
@@ -53,19 +53,17 @@ class HelpIndexer {
/**
* Scan for files in the given directory.
*/
bool
scanForFiles
(
std
::
s
tring
const
&
path
);
bool
scanForFiles
(
rtl
::
OUS
tring
const
&
path
);
/**
* Fill the Document with information on the given help file.
*/
bool
helpDocument
(
std
::
s
tring
const
&
fileName
,
lucene
::
document
::
Document
*
doc
);
bool
helpDocument
(
rtl
::
OUS
tring
const
&
fileName
,
lucene
::
document
::
Document
*
doc
);
/**
* Create a reader for the given file, and create an "empty" reader in case the file doesn't exist.
*/
lucene
::
util
::
Reader
*
helpFileReader
(
std
::
string
const
&
path
);
std
::
wstring
string2wstring
(
std
::
string
const
&
source
);
lucene
::
util
::
Reader
*
helpFileReader
(
rtl
::
OUString
const
&
path
);
};
#endif
l10ntools/source/help/HelpIndexer_main.cxx
Dosyayı görüntüle @
0f691cc6
...
...
@@ -57,9 +57,14 @@ int main(int argc, char **argv) {
std
::
string
captionDir
(
srcDir
+
"/caption"
);
std
::
string
contentDir
(
srcDir
+
"/content"
);
std
::
string
indexDir
(
outDir
+
"/"
+
module
+
".idxl"
);
HelpIndexer
indexer
(
lang
,
module
,
captionDir
,
contentDir
,
indexDir
);
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
::
cerr
<<
indexer
.
getErrorMessage
()
<<
std
::
endl
;
std
::
wcerr
<<
indexer
.
getErrorMessage
().
getStr
()
<<
std
::
endl
;
return
2
;
}
return
0
;
...
...
xmlhelp/source/cxxhelp/provider/databases.cxx
Dosyayı görüntüle @
0f691cc6
...
...
@@ -39,6 +39,12 @@
#include <algorithm>
#include <string.h>
// EDIT FROM HERE
#include <HelpIndexer.hxx>
// EDIT ENDS HERE
// Extensible help
#include "com/sun/star/deployment/ExtensionManager.hpp"
#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
...
...
@@ -2115,78 +2121,60 @@ rtl::OUString IndexFolderIterator::implGetIndexFolderFromPackage( bool& o_rbTemp
// TEST
//bIsWriteAccess = false;
Reference
<
script
::
XInvocation
>
xInvocation
;
Reference
<
XMultiComponentFactory
>
xSMgr
(
m_xContext
->
getServiceManager
(),
UNO_QUERY
);
// EDIT FROM HERE
try
{
xInvocation
=
Reference
<
script
::
XInvocation
>
(
m_xContext
->
getServiceManager
()
->
createInstanceWithContext
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"com.sun.star.help.HelpIndexer"
)),
m_xContext
)
,
UNO_QUERY
);
if
(
xInvocation
.
is
()
)
{
Sequence
<
uno
::
Any
>
aParamsSeq
(
bIsWriteAccess
?
6
:
8
);
aParamsSeq
[
0
]
=
uno
::
makeAny
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"-lang"
))
);
rtl
::
OUString
aLang
;
sal_Int32
nLastSlash
=
aLangURL
.
lastIndexOf
(
'/'
);
if
(
nLastSlash
!=
-
1
)
aLang
=
aLangURL
.
copy
(
nLastSlash
+
1
);
else
aLang
=
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"en"
));
aParamsSeq
[
1
]
=
uno
::
makeAny
(
aLang
);
rtl
::
OUString
aLang
;
sal_Int32
nLastSlash
=
aLangURL
.
lastIndexOf
(
'/'
);
if
(
nLastSlash
!=
-
1
)
aLang
=
aLangURL
.
copy
(
nLastSlash
+
1
);
else
aLang
=
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"en"
));
aParamsSeq
[
2
]
=
uno
::
makeAny
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"-mod"
))
);
aParamsSeq
[
3
]
=
uno
::
makeAny
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"help"
))
);
rtl
::
OUString
aMod
(
RTL_CONSTASCII_USTRINGPARAM
(
"help"
));
rtl
::
OUString
aZipDir
=
aLangURL
;
if
(
!
bIsWriteAccess
)
rtl
::
OUString
aZipDir
=
aLangURL
;
if
(
!
bIsWriteAccess
)
{
rtl
::
OUString
aTempFileURL
;
::
osl
::
FileBase
::
RC
eErr
=
::
osl
::
File
::
createTempFile
(
0
,
0
,
&
aTempFileURL
);
if
(
eErr
==
::
osl
::
FileBase
::
E_None
)
{
rtl
::
OUString
aTempFileURL
;
::
osl
::
FileBase
::
RC
eErr
=
::
osl
::
File
::
createTempFile
(
0
,
0
,
&
aTempFileURL
);
if
(
eErr
==
::
osl
::
FileBase
::
E_None
)
rtl
::
OUString
aTempDirURL
=
aTempFileURL
;
try
{
rtl
::
OUString
aTempDirURL
=
aTempFileURL
;
try
{
m_xSFA
->
kill
(
aTempDirURL
);
}
catch
(
Exception
&
)
{}
m_xSFA
->
createFolder
(
aTempDirURL
);
aZipDir
=
aTempDirURL
;
o_rbTemporary
=
true
;
m_xSFA
->
kill
(
aTempDirURL
);
}
catch
(
Exception
&
)
{}
m_xSFA
->
createFolder
(
aTempDirURL
);
aZipDir
=
aTempDirURL
;
o_rbTemporary
=
true
;
}
}
aParamsSeq
[
4
]
=
uno
::
makeAny
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"-zipdir"
))
);
rtl
::
OUString
aSystemPath
;
osl
::
FileBase
::
getSystemPathFromFileURL
(
aZipDir
,
aSystemPath
);
aParamsSeq
[
5
]
=
uno
::
makeAny
(
aSystemPath
);
rtl
::
OUString
aTargetDir
;
osl
::
FileBase
::
getSystemPathFromFileURL
(
aZipDir
,
aTargetDir
);
if
(
!
bIsWriteAccess
)
{
aParamsSeq
[
6
]
=
uno
::
makeAny
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"-srcdir"
))
);
rtl
::
OUString
aSrcDirVal
;
osl
::
FileBase
::
getSystemPathFromFileURL
(
aLangURL
,
aSrcDirVal
);
aParamsSeq
[
7
]
=
uno
::
makeAny
(
aSrcDirVal
);
}
rtl
::
OUString
aSourceDir
;
osl
::
FileBase
::
getSystemPathFromFileURL
(
aLangURL
,
aSourceDir
);
Sequence
<
sal_Int16
>
aOutParamIndex
;
Sequence
<
uno
::
Any
>
aOutParam
;
uno
::
Any
aRet
=
xInvocation
->
invoke
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"createIndex"
)),
aParamsSeq
,
aOutParamIndex
,
aOutParam
);
rtl
::
OUString
aCaption
(
RTL_CONSTASCII_USTRINGPARAM
(
"/caption"
));
rtl
::
OUString
aContent
(
RTL_CONSTASCII_USTRINGPARAM
(
"/content"
));
if
(
bIsWriteAccess
)
aIndexFolder
=
implGetFileFromPackage
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
".idxl"
)),
xPackage
);
else
aIndexFolder
=
aZipDir
+
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"/help.idxl"
));
}
HelpIndexer
aIndexer
(
aLang
,
aMod
,
aSourceDir
+
aCaption
,
aSourceDir
+
aContent
,
aTargetDir
);
if
(
bIsWriteAccess
)
aIndexFolder
=
implGetFileFromPackage
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
".idxl"
)),
xPackage
);
else
aIndexFolder
=
aZipDir
+
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"/help.idxl"
));
}
catch
(
Exception
&
)
{}
// EDIT UNTIL HERE
}
}
...
...
xmlhelp/source/cxxhelp/provider/makefile.mk
Dosyayı görüntüle @
0f691cc6
...
...
@@ -67,6 +67,11 @@ LIBXSLTINCDIR=external$/libxslt
CFLAGS
+=
-I
$(SOLARINCDIR)$/$(LIBXSLTINCDIR)
.ENDIF
CFLAGS
+=
-I
$(SRC_ROOT)$/
l10ntools
$/
source
$/
help
PKGCONFIG_MODULES
=
libclucene-core libclucene-contribs-lib
.INCLUDE
:
pkg_config.mk
.IF
"$(GUI)"
==
"WNT"
.IF
"$(COM)"
==
"MSC"
CFLAGS
+=
-GR
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment