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
d5931ad3
Kaydet (Commit)
d5931ad3
authored
Şub 19, 2011
tarafından
Steven Butler
Kaydeden (comit)
Fridrich Štrba
Şub 28, 2011
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add MSI custom action capable of generating thesaurus index
üst
e1f33256
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
293 additions
and
0 deletions
+293
-0
exports.dxp
...p_native/source/win32/customactions/thesaurus/exports.dxp
+1
-0
makefile.mk
...p_native/source/win32/customactions/thesaurus/makefile.mk
+78
-0
thesaurus.cxx
...native/source/win32/customactions/thesaurus/thesaurus.cxx
+214
-0
No files found.
setup_native/source/win32/customactions/thesaurus/exports.dxp
0 → 100755
Dosyayı görüntüle @
d5931ad3
CreateIndexes
setup_native/source/win32/customactions/thesaurus/makefile.mk
0 → 100755
Dosyayı görüntüle @
d5931ad3
#*************************************************************************
#
# OpenOffice.org - a multi-platform office productivity suite
#
# The Contents of this file are made available subject to
# the terms of GNU Lesser General Public License Version 3.
#
#
# GNU Lesser General Public License Version 3
# =============================================
# Copyright 2005 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library 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 for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#*************************************************************************
PRJ
=
..
$/
..
$/
..
$/
..
PRJNAME
=
setup_native
TARGET
=
thidxmsi
.IF
"$(GUI)"
==
"WNT"
# --- Settings -----------------------------------------------------
ENABLE_EXCEPTIONS
=
TRUE
NO_DEFAULT_STL
=
TRUE
DYNAMIC_CRT
=
USE_DEFFILE
=
TRUE
.INCLUDE
:
settings.mk
CFLAGS
+=
-D_STLP_USE_STATIC_LIB
# --- Files --------------------------------------------------------
UWINAPILIB
=
SLOFILES
=
\
$(SLO)$/
thesaurus.obj
SHL1STDLIBS
=
kernel32.lib
\
user32.lib
\
advapi32.lib
\
shell32.lib
\
msi.lib
SHL1LIBS
=
$(SLB)$/$(TARGET)
.lib
SHL1TARGET
=
$(TARGET)
SHL1IMPLIB
=
i
$(TARGET)
SHL1DEF
=
$(MISC)$/$(SHL1TARGET)
.def
SHL1DEPN
=
$(SLB)$/$(TARGET)
.lib
SHL1BASE
=
0x1c000000
DEF1NAME
=
$(SHL1TARGET)
DEF1EXPORTFILE
=
exports.dxp
# --- Targets --------------------------------------------------------------
.INCLUDE
:
target.mk
# -------------------------------------------------------------------------
.ENDIF
setup_native/source/win32/customactions/thesaurus/thesaurus.cxx
0 → 100644
Dosyayı görüntüle @
d5931ad3
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 3.
*
*
* GNU Lesser General Public License Version 3
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
#define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT 0x0500
#undef WINVER
#define WINVER 0x0500
#include <windows.h>
#include <msiquery.h>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <systools/win32/uwinapi.h>
#include <io.h>
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <stdlib.h>
#include <string.h>
using
namespace
std
;
namespace
{
string
GetMsiProperty
(
MSIHANDLE
handle
,
const
string
&
sProperty
)
{
string
result
;
TCHAR
szDummy
[
1
]
=
TEXT
(
""
);
DWORD
nChars
=
0
;
if
(
MsiGetProperty
(
handle
,
sProperty
.
c_str
(),
szDummy
,
&
nChars
)
==
ERROR_MORE_DATA
)
{
DWORD
nBytes
=
++
nChars
*
sizeof
(
TCHAR
);
LPTSTR
buffer
=
reinterpret_cast
<
LPTSTR
>
(
_alloca
(
nBytes
));
ZeroMemory
(
buffer
,
nBytes
);
MsiGetProperty
(
handle
,
sProperty
.
c_str
(),
buffer
,
&
nChars
);
result
=
buffer
;
}
return
result
;
}
inline
bool
IsSetMsiProperty
(
MSIHANDLE
handle
,
const
string
&
sProperty
)
{
return
(
GetMsiProperty
(
handle
,
sProperty
).
length
()
>
0
);
}
inline
void
UnsetMsiProperty
(
MSIHANDLE
handle
,
const
string
&
sProperty
)
{
MsiSetProperty
(
handle
,
sProperty
.
c_str
(),
NULL
);
}
inline
void
SetMsiProperty
(
MSIHANDLE
handle
,
const
string
&
sProperty
,
const
string
&
)
{
MsiSetProperty
(
handle
,
sProperty
.
c_str
(),
TEXT
(
"1"
));
}
static
const
int
MAXLINE
=
1024
*
64
;
void
generateIndex
(
const
char
*
inputFile
,
const
char
*
outputFile
)
{
ifstream
in
(
inputFile
);
char
inputBuffer
[
MAXLINE
];
map
<
string
,
size_t
>
entries
;
map
<
string
,
size_t
>::
iterator
ret
(
entries
.
begin
());
int
line
(
1
);
in
.
getline
(
inputBuffer
,
MAXLINE
);
const
string
encoding
(
inputBuffer
);
size_t
currentOffset
(
encoding
.
size
()
+
1
);
while
(
true
)
{
// Extract the next word, but not the entry count
in
.
getline
(
inputBuffer
,
MAXLINE
,
'|'
);
if
(
in
.
eof
())
break
;
string
word
(
inputBuffer
);
ret
=
entries
.
insert
(
ret
,
pair
<
string
,
size_t
>
(
word
,
currentOffset
));
currentOffset
+=
word
.
size
()
+
1
;
// Next is the entry count
in
.
getline
(
inputBuffer
,
MAXLINE
);
if
(
!
in
.
good
())
{
return
;
}
currentOffset
+=
strlen
(
inputBuffer
)
+
1
;
int
entryCount
(
strtol
(
inputBuffer
,
NULL
,
10
));
for
(
int
i
(
0
);
i
<
entryCount
;
++
i
)
{
in
.
getline
(
inputBuffer
,
MAXLINE
);
currentOffset
+=
strlen
(
inputBuffer
)
+
1
;
++
line
;
}
}
// Use binary mode to prevent any translation of LF to CRLF on Windows
ofstream
outputStream
(
outputFile
,
ios_base
::
binary
|
ios_base
::
trunc
|
ios_base
::
out
);
if
(
!
outputStream
.
is_open
())
{
//cerr << "Unable to open output file " << outputFile << endl;
return
;
}
cerr
<<
"Doing it now"
<<
outputFile
<<
endl
;
outputStream
<<
encoding
<<
'\n'
<<
entries
.
size
()
<<
'\n'
;
for
(
map
<
string
,
size_t
>::
const_iterator
ii
(
entries
.
begin
());
ii
!=
entries
.
end
();
++
ii
)
{
outputStream
<<
ii
->
first
<<
'|'
<<
ii
->
second
<<
'\n'
;
}
outputStream
.
close
();
}
void
generateIndex
(
const
string
&
datFile
)
{
string
idxFile
(
datFile
.
substr
(
0
,
datFile
.
size
()
-
3
)
+
"idx"
);
generateIndex
(
datFile
.
c_str
(),
idxFile
.
c_str
());
}
void
createIndexesForThesaurusFiles
(
const
string
&
sOfficeInstallPath
)
{
vector
<
string
>
thesaurusPaths
;
string
sExtensionsPath
=
sOfficeInstallPath
+
"
\\
share
\\
extensions
\\
"
;
string
dictionariesWildcard
=
sExtensionsPath
+
"dict-*"
;
struct
_finddatai64_t
dictFind
;
long
h
=
_findfirsti64
(
dictionariesWildcard
.
c_str
(),
&
dictFind
);
if
(
h
>
0
)
{
do
{
if
(
dictFind
.
attrib
&
_A_SUBDIR
)
{
struct
_finddatai64_t
datFind
;
// Find any .dat files in the subdirectory
string
dictPath
=
sExtensionsPath
+
dictFind
.
name
+
"
\\
"
;
string
datWildCard
=
dictPath
+
"*.dat"
;
long
h2
=
_findfirsti64
(
datWildCard
.
c_str
(),
&
datFind
);
if
(
h2
>
0
)
{
do
{
thesaurusPaths
.
push_back
(
dictPath
+
datFind
.
name
);
}
while
(
_findnexti64
(
h2
,
&
datFind
)
==
0
);
}
}
}
while
(
_findnexti64
(
h
,
&
dictFind
)
==
0
);
}
for
(
vector
<
string
>::
const_iterator
ii
(
thesaurusPaths
.
begin
());
ii
!=
thesaurusPaths
.
end
();
++
ii
)
{
generateIndex
(
*
ii
);
}
}
}
// namespace
// Creates the thesaurus .idx files for all installed .dat
// thesaurus files
extern
"C"
UINT
__stdcall
CreateIndexes
(
MSIHANDLE
handle
)
{
string
sOfficeInstallPath
=
GetMsiProperty
(
handle
,
TEXT
(
"INSTALLLOCATION"
));
createIndexesForThesaurusFiles
(
sOfficeInstallPath
);
return
ERROR_SUCCESS
;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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