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
f4990af4
Kaydet (Commit)
f4990af4
authored
Agu 26, 2002
tarafından
Tino Rachui
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#97684#
üst
31a40039
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
2135 additions
and
0 deletions
+2135
-0
cmdline.cxx
shell/source/tools/lngconvex/cmdline.cxx
+151
-0
cmdline.hxx
shell/source/tools/lngconvex/cmdline.hxx
+106
-0
defs.hxx
shell/source/tools/lngconvex/defs.hxx
+14
-0
lngconvex.cxx
shell/source/tools/lngconvex/lngconvex.cxx
+780
-0
makefile.mk
shell/source/tools/lngconvex/makefile.mk
+95
-0
classfactory.cxx
shell/source/win32/shlxthandler/classfactory.cxx
+220
-0
classfactory.hxx
shell/source/win32/shlxthandler/classfactory.hxx
+105
-0
exports.dxp
shell/source/win32/shlxthandler/exports.dxp
+5
-0
makefile.mk
shell/source/win32/shlxthandler/makefile.mk
+153
-0
shlxthdl.cxx
shell/source/win32/shlxthandler/shlxthdl.cxx
+506
-0
No files found.
shell/source/tools/lngconvex/cmdline.cxx
0 → 100644
Dosyayı görüntüle @
f4990af4
#include <stdexcept>
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif
#ifndef _CMDLINE_HXX_
#include "cmdline.hxx"
#endif
//---------------------------------
/** Simple command line abstraction
*/
//################################
// Creation
//################################
CommandLine
::
CommandLine
(
size_t
argc
,
char
*
argv
[],
const
std
::
string
&
ArgPrefix
)
:
m_argc
(
argc
),
m_argv
(
argv
),
m_argprefix
(
ArgPrefix
)
{
}
//################################
// Query
//################################
/** Return the argument count
*/
size_t
CommandLine
::
GetArgumentCount
()
const
{
return
m_argc
;
}
/** Return an argument by index
This method doesn't skip argument
names if any, so if the second
argument is an argument name the
function nevertheless returns it.
@precond 0 <= Index < GetArgumentCount
@throws std::out_of_range exception
if the given index is to high
*/
std
::
string
CommandLine
::
GetArgument
(
size_t
Index
)
const
{
OSL_PRECOND
(
Index
<
m_argc
,
"Index out of range"
);
if
(
Index
>
(
m_argc
-
1
))
throw
std
::
out_of_range
(
"Invalid index"
);
return
m_argv
[
Index
];
}
/** Returns all argument name found in the
command line. An argument will be identified
by a specified prefix. The standard prefix
is '-'.
If the are no argument names the returned
container is empty.
*/
StringListPtr_t
CommandLine
::
GetArgumentNames
()
const
{
StringListPtr_t
arg_cont
(
new
StringList_t
());
for
(
size_t
i
=
0
;
i
<
m_argc
;
i
++
)
{
std
::
string
argn
=
m_argv
[
i
];
if
(
IsArgumentName
(
argn
))
arg_cont
->
push_back
(
argn
);
}
return
arg_cont
;
}
/** Returns an argument by name. If there are
duplicate argument names in the command line,
the first one wins.
Argument name an the argument value must be separated
by spaces. If the argument value starts with an
argument prefix use quotes else the return value is
an empty string because the value will be interpreted
as the next argument name.
If an argument value contains spaces use quotes.
@precond GetArgumentNames() -> has element ArgumentName
@throws std::invalid_argument exception
if the specified argument could not be
found
*/
std
::
string
CommandLine
::
GetArgument
(
const
std
::
string
&
ArgumentName
)
const
{
std
::
string
arg_value
;
for
(
size_t
i
=
0
;
i
<
m_argc
;
i
++
)
{
std
::
string
arg
=
m_argv
[
i
];
if
(
ArgumentName
==
arg
&&
((
i
+
1
)
<
m_argc
)
&&
!
IsArgumentName
(
m_argv
[
i
+
1
]))
{
arg_value
=
m_argv
[
i
+
1
];
break
;
}
}
if
(
i
==
m_argc
)
throw
std
::
invalid_argument
(
"Invalid argument name"
);
return
arg_value
;
}
//################################
// Command
//################################
/** Set the prefix used to identify arguments in
the command line.
@precond prefix is not empty
@throws std::invalid_argument exception if
the prefix is empty
*/
void
CommandLine
::
SetArgumentPrefix
(
const
std
::
string
&
Prefix
)
{
OSL_PRECOND
(
Prefix
.
length
(),
"Empty argument prefix!"
);
if
(
0
==
Prefix
.
length
())
throw
std
::
invalid_argument
(
"Empty argument prefix not allowed"
);
m_argprefix
=
Prefix
;
}
/** Returns whether a given argument is an argument name
*/
bool
CommandLine
::
IsArgumentName
(
const
std
::
string
&
Argument
)
const
{
return
(
0
==
Argument
.
compare
(
0
,
m_argprefix
.
length
(),
m_argprefix
));
}
shell/source/tools/lngconvex/cmdline.hxx
0 → 100644
Dosyayı görüntüle @
f4990af4
#ifndef _CMDLINE_HXX_
#define _CMDLINE_HXX_
#ifndef _DEFS_HXX_
#include "defs.hxx"
#endif
//---------------------------------
/** Simple command line abstraction
*/
class
CommandLine
{
public
:
//################################
// Creation
//################################
CommandLine
(
size_t
argc
,
char
*
argv
[],
const
std
::
string
&
ArgPrefix
=
std
::
string
(
"-"
));
//################################
// Query
//################################
/** Return the argument count
*/
size_t
GetArgumentCount
()
const
;
/** Return an argument by index
This method doesn't skip argument
names if any, so if the second
argument is an argument name the
function nevertheless returns it.
@precond 0 <= Index < GetArgumentCount
@throws std::out_of_range exception
if the given index is to high
*/
std
::
string
GetArgument
(
size_t
Index
)
const
;
/** Returns all argument name found in the
command line. An argument will be identified
by a specified prefix. The standard prefix
is '-'.
If there are no argument names the returned
container is empty.
*/
StringListPtr_t
GetArgumentNames
()
const
;
/** Returns an argument by name. If there are
duplicate argument names in the command line,
the first one wins.
Argument name an the argument value must be separated
by spaces. If the argument value starts with an
argument prefix use quotes else the return value is
an empty string because the value will be interpreted
as the next argument name.
If an argument value contains spaces use quotes.
@precond GetArgumentNames() -> has element ArgumentName
@throws std::invalid_argument exception
if the specified argument could not be
found
*/
std
::
string
GetArgument
(
const
std
::
string
&
ArgumentName
)
const
;
//################################
// Command
//################################
/** Set the prefix used to identify arguments in
the command line.
@precond prefix is not empty
@throws std::invalid_argument exception if
the prefix is empty
*/
void
SetArgumentPrefix
(
const
std
::
string
&
Prefix
);
private
:
/** Returns whether a given argument is an argument name
*/
bool
IsArgumentName
(
const
std
::
string
&
Argument
)
const
;
private
:
size_t
m_argc
;
char
**
m_argv
;
std
::
string
m_argprefix
;
// prevent copy and assignment
private
:
CommandLine
(
const
CommandLine
&
);
CommandLine
&
operator
=
(
const
CommandLine
&
);
};
#endif
shell/source/tools/lngconvex/defs.hxx
0 → 100644
Dosyayı görüntüle @
f4990af4
#ifndef _DEFS_HXX_
#define _DEFS_HXX_
#include <vector>
#include <string>
#include <memory>
typedef
std
::
vector
<
std
::
string
>
StringList_t
;
typedef
std
::
auto_ptr
<
StringList_t
>
StringListPtr_t
;
typedef
std
::
vector
<
int
>
IntegerList_t
;
typedef
std
::
auto_ptr
<
IntegerList_t
>
IntegerListPtr_t
;
#endif
shell/source/tools/lngconvex/lngconvex.cxx
0 → 100644
Dosyayı görüntüle @
f4990af4
// Test_Stl_Stream.cpp : Definiert den Einsprungpunkt fr die Konsolenanwendung.
//
//#define WIN32_LEAN_AND_MEAN
#include <tools/presys.h>
#include <windows.h>
#include <tools/postsys.h>
#define VCL_NEED_BASETSD
#include <iostream>
#include <fstream>
#include <assert.h>
#include <map>
#include <sstream>
#include <iterator>
#include <algorithm>
#ifndef _OSL_THREAD_H_
#include <osl/thread.h>
#endif
#ifndef _TOOLS_CONFIG_HXX_
#include <tools/config.hxx>
#endif
#ifndef _TOOLS_L2TXTENC_HXX_
#include <tools/l2txtenc.hxx>
#endif
#ifndef _CMDLINE_HXX_
#include "cmdline.hxx"
#endif
#ifndef _OSL_MODULE_H_
#include <osl/module.h>
#endif
#ifndef _OSL_FILE_HXX_
#include <osl/file.hxx>
#endif
#ifndef _RTL_USTRBUF_HXX_
#include <rtl/ustrbuf.hxx>
#endif
namespace
/* private */
{
//-------------------------------
/** Various constants
*/
const
std
::
string
RC_PLACEHOLDER_LANGUAGE
=
"%LANGUAGE%"
;
const
std
::
string
RC_PLACEHOLDER_SUBLANGUAGE
=
"%SUBLANGUAGE%"
;
//####################################
typedef
int
CountryIdentifier_t
;
typedef
std
::
vector
<
CountryIdentifier_t
>
CountryIdentifierContainer_t
;
CountryIdentifierContainer_t
g_country_lng_file_countries
;
CountryIdentifierContainer_t
g_lng_file_countries
;
// we support only this languages that are
// in the ctrylng file as well as appearing
// in the lng file
CountryIdentifierContainer_t
g_country_intersection
;
//------------------------------------
// Helper function
//------------------------------------
void
ShowUsage
()
{
std
::
cout
<<
"Usage: -lng lng_file -rc rc_output_file -c country_language_file -rct rc_template_file"
<<
std
::
endl
;
std
::
cout
<<
"-lng Name of the lng file"
<<
std
::
endl
;
std
::
cout
<<
"-rc Name of the resulting resource file"
<<
std
::
endl
;
std
::
cout
<<
"-c Name of the country_language file"
<<
std
::
endl
;
std
::
cout
<<
"-rct Name of the resource template file"
<<
std
::
endl
;
std
::
cout
<<
"-rch Name of the resource file header"
<<
std
::
endl
;
std
::
cout
<<
"-rcf Name of the resource file footer"
<<
std
::
endl
;
}
//-------------------------------------------
/** Get the directory where the module
is located as system directory,
the returned directory has a trailing '\'
*/
rtl
::
OUString
GetModuleDirectory
()
{
rtl_uString
*
url
=
0
;
rtl
::
OUString
module_dir
;
bool
bSuccess
=
osl_getModuleURLFromAddress
(
ShowUsage
,
&
url
);
if
(
bSuccess
)
{
module_dir
=
rtl
::
OUString
(
url
);
rtl_uString_release
(
url
);
osl
::
FileBase
::
getSystemPathFromFileURL
(
module_dir
,
module_dir
);
module_dir
=
rtl
::
OUString
(
module_dir
.
getStr
(),
module_dir
.
lastIndexOf
(
L'\\'
)
+
1
);
}
return
module_dir
;
}
//-------------------------------------------
/** Make the absolute directory of a base and
a relative directory,
if the relative directory is absolute the
the relative directory will be returned
unchanged.
Base and relative directory should be
system paths the returned directory is
a system path too
*/
rtl
::
OUString
GetAbsoluteDirectory
(
const
rtl
::
OUString
&
BaseDir
,
const
rtl
::
OUString
&
RelDir
)
{
rtl
::
OUString
base_url
;
rtl
::
OUString
rel_url
;
osl
::
FileBase
::
getFileURLFromSystemPath
(
BaseDir
,
base_url
);
osl
::
FileBase
::
getFileURLFromSystemPath
(
RelDir
,
rel_url
);
rtl
::
OUString
abs_url
;
osl
::
FileBase
::
getAbsoluteFileURL
(
base_url
,
rel_url
,
abs_url
);
rtl
::
OUString
abs_sys_path
;
osl
::
FileBase
::
getSystemPathFromFileURL
(
abs_url
,
abs_sys_path
);
return
abs_sys_path
;
}
//--------------------------
/**
*/
rtl
::
OUString
OStr2OUStr
(
const
rtl
::
OString
&
aOStr
)
{
return
rtl
::
OStringToOUString
(
aOStr
,
osl_getThreadTextEncoding
());
}
//--------------------------
/**
*/
rtl
::
OString
OUStr2OStr
(
const
rtl
::
OUString
&
aOUStr
)
{
return
rtl
::
OUStringToOString
(
aOUStr
,
osl_getThreadTextEncoding
());
}
//####################################
//-------------------------------------------
/** A helper class, enables stream exceptions
on construction, restors the old exception
state on destruction
*/
class
StreamExceptionsEnabler
{
public
:
explicit
StreamExceptionsEnabler
(
std
::
ios
&
iostrm
,
std
::
ios
::
iostate
NewIos
=
std
::
ios
::
failbit
|
std
::
ios
::
badbit
)
:
m_IoStrm
(
iostrm
),
m_OldIos
(
m_IoStrm
.
exceptions
())
{
m_IoStrm
.
exceptions
(
NewIos
);
}
~
StreamExceptionsEnabler
()
{
m_IoStrm
.
exceptions
(
m_OldIos
);
}
private
:
std
::
ios
&
m_IoStrm
;
std
::
ios
::
iostate
m_OldIos
;
};
//####################################
//-----------------------------
/** A line struct (in order to
define line reading
operators for file streams)
*/
struct
Line
{
std
::
string
m_Line
;
};
typedef
std
::
vector
<
Line
>
LineBuffer_t
;
//-----------------------------
/** A line input operator
*/
template
<
class
charT
,
class
traits
>
std
::
basic_istream
<
charT
,
traits
>&
operator
>>
(
std
::
basic_istream
<
charT
,
traits
>&
strm
,
Line
&
l
)
{
// reset line
l
.
m_Line
=
std
::
string
();
char
chr
;
while
(
strm
.
get
(
chr
))
{
if
(
chr
!=
'\n'
)
l
.
m_Line
.
push_back
(
chr
);
else
break
;
}
return
strm
;
}
//-----------------------------
/** A line output operator
*/
template
<
class
charT
,
class
traits
>
std
::
basic_ostream
<
charT
,
traits
>&
operator
<<
(
std
::
basic_ostream
<
charT
,
traits
>&
os
,
const
Line
&
l
)
{
os
<<
l
.
m_Line
;
return
os
;
}
//#####################################
//------------------------------------
// global variables
//------------------------------------
LineBuffer_t
g_resource_template
;
//#####################################
//-------------------------------------
/** A replacement table contains pairs
of placeholders and the appropriate
substitute
*/
class
Substitutor
{
private
:
typedef
std
::
map
<
std
::
string
,
std
::
string
>
ReplacementTable_t
;
typedef
std
::
map
<
CountryIdentifier_t
,
ReplacementTable_t
*>
CountryReplacementTable_t
;
public
:
typedef
CountryReplacementTable_t
::
iterator
iterator
;
typedef
CountryReplacementTable_t
::
const_iterator
const_iterator
;
public
:
/** ctor
*/
Substitutor
()
:
m_ActiveCountry
(
0
)
{};
explicit
Substitutor
(
CountryIdentifier_t
ActiveCountry
)
:
m_ActiveCountry
(
ActiveCountry
)
{};
/** dtor
*/
~
Substitutor
()
{
CountryReplacementTable_t
::
iterator
iter_end
=
m_CountryReplacementTbl
.
end
();
CountryReplacementTable_t
::
iterator
iter
=
m_CountryReplacementTbl
.
begin
();
for
(
/* no init */
;
iter
!=
iter_end
;
++
iter
)
delete
iter
->
second
;
m_CountryReplacementTbl
.
clear
();
}
/**
*/
void
SetActiveCountry
(
CountryIdentifier_t
CtryId
)
{
m_ActiveCountry
=
CtryId
;
}
/**
*/
CountryIdentifier_t
GetActiveCountry
()
const
{
return
m_ActiveCountry
;
}
/** If Text is a placeholder substitute it with
its substitute else leave it unchanged
*/
void
Substitute
(
std
::
string
&
Text
)
{
ReplacementTable_t
*
prt
=
GetReplacementTable
(
m_ActiveCountry
);
assert
(
prt
);
ReplacementTable_t
::
iterator
iter
=
prt
->
find
(
Text
);
if
(
iter
!=
prt
->
end
())
Text
=
iter
->
second
;
}
/** Add a new substitution
*/
void
AddSubstitution
(
const
std
::
string
&
Placeholder
,
const
std
::
string
&
Substitute
)
{
ReplacementTable_t
*
prt
=
GetReplacementTable
(
m_ActiveCountry
);
assert
(
prt
);
prt
->
insert
(
std
::
make_pair
(
Placeholder
,
Substitute
));
}
private
:
/** Return the replacement table for the country id
create a new one if not already present
*/
ReplacementTable_t
*
GetReplacementTable
(
const
CountryIdentifier_t
&
CountryId
)
{
CountryReplacementTable_t
::
iterator
iter
=
m_CountryReplacementTbl
.
find
(
CountryId
);
ReplacementTable_t
*
prt
=
0
;
if
(
m_CountryReplacementTbl
.
end
()
==
iter
)
{
prt
=
new
ReplacementTable_t
();
m_CountryReplacementTbl
.
insert
(
std
::
make_pair
(
CountryId
,
prt
));
}
else
{
prt
=
iter
->
second
;
}
return
prt
;
}
private
:
CountryReplacementTable_t
m_CountryReplacementTbl
;
CountryIdentifier_t
m_ActiveCountry
;
};
//-----------------------------------------------------
/* LangSubLangPair_t contains the Languages and the
SubLanguage defines as string (see MS Platform SDK
winnt.h), e.g LANG_GERMAN, SUBLANG_GERMAN
CountryLanguageMap_t associates country identifiers
(the country phone preselection) and the appropriate
LangSubLangPair_t's
*/
typedef
std
::
pair
<
std
::
string
,
std
::
string
>
LangSubLangPair_t
;
typedef
std
::
pair
<
CountryIdentifier_t
,
LangSubLangPair_t
>
CountryLanguagePair_t
;
//-------------------------------
/** A stream input operator for
country language file lines
*/
template
<
class
charT
,
class
traits
>
std
::
basic_istream
<
charT
,
traits
>&
operator
>>
(
std
::
basic_istream
<
charT
,
traits
>&
strm
,
CountryLanguagePair_t
&
cl_pair
)
{
strm
>>
cl_pair
.
first
;
strm
>>
cl_pair
.
second
.
first
;
strm
>>
cl_pair
.
second
.
second
;
return
strm
;
}
//--------------------------------
/** Read the country language file
and add the entries to the
substitutor
The format of the country
language file is:
Country Identifier LANG_??? SUBLANG_???
...
e.g.
01 LANG_ENGLISH SUBLANG_ENGLISH_US
49 LANG_GERMAN SUBLANG_GERMAN
...
Will not detect if the entries of the
file are valid.
@param is
a file stream
@param substitutor
the substitutor
@precond the file stream is open
and the file is in a proper format
@throws std::ios::failure
if the file could not be read at all
or the format of the file is invalid
*/
void
ReadCtryLngFile
(
std
::
ifstream
&
is
,
Substitutor
&
substitutor
,
CountryIdentifierContainer_t
&
CtryContainer
)
{
CountryLanguagePair_t
cl_pair
;
StreamExceptionsEnabler
sexc
(
is
);
try
{
while
(
is
>>
cl_pair
)
{
CtryContainer
.
push_back
(
cl_pair
.
first
);
substitutor
.
SetActiveCountry
(
cl_pair
.
first
);
substitutor
.
AddSubstitution
(
RC_PLACEHOLDER_LANGUAGE
,
cl_pair
.
second
.
first
);
substitutor
.
AddSubstitution
(
RC_PLACEHOLDER_SUBLANGUAGE
,
cl_pair
.
second
.
second
);
}
}
catch
(
const
std
::
ios
::
failure
&
)
{
if
(
!
is
.
eof
())
throw
;
}
// sort the country container
std
::
sort
(
CtryContainer
.
begin
(),
CtryContainer
.
end
());
}
//####################################
//-----------------------------------
/** Convert a OUString to the MS
resource file format string
e.g.
OUString -> L"\x1A00\x2200\x3400"
*/
std
::
string
OUStringToWinResourceString
(
const
rtl
::
OUString
&
aString
)
{
std
::
ostringstream
oss
;
oss
<<
"L
\"
"
;
size_t
length
=
aString
.
getLength
();
const
sal_Unicode
*
pchr
=
aString
.
getStr
();
for
(
size_t
i
=
0
;
i
<
length
;
i
++
)
oss
<<
"
\\
x"
<<
std
::
hex
<<
(
int
)
*
pchr
++
;
oss
<<
"
\"
"
;
return
oss
.
str
();
}
//-------------------------------
/**
*/
void
AddGroupEntriesToSubstitutor
(
Config
&
aConfig
,
const
ByteString
&
GroupName
,
Substitutor
&
Substitutor
,
CountryIdentifierContainer_t
&
CtryContainer
)
{
// precondition
assert
(
aConfig
.
HasGroup
(
GroupName
));
aConfig
.
SetGroup
(
GroupName
);
size_t
key_count
=
aConfig
.
GetKeyCount
();
for
(
size_t
i
=
0
;
i
<
key_count
;
i
++
)
{
ByteString
key
=
aConfig
.
GetKeyName
(
i
);
bool
is_numeric_key
=
key
.
IsNumericAscii
();
assert
(
is_numeric_key
);
if
(
is_numeric_key
)
{
CountryIdentifier_t
country_id
=
key
.
ToInt32
();
CtryContainer
.
push_back
(
country_id
);
Substitutor
.
SetActiveCountry
(
country_id
);
ByteString
key_value
=
aConfig
.
ReadKey
(
i
);
key_value
.
EraseLeadingAndTrailingChars
(
'\"'
);
rtl
::
OUString
key_value_unicode
=
rtl
::
OStringToOUString
(
key_value
,
Langcode2TextEncoding
(
country_id
));
assert
(
key_value_unicode
.
getLength
());
Substitutor
.
AddSubstitution
(
GroupName
.
GetBuffer
(),
OUStringToWinResourceString
(
key_value_unicode
));
}
}
}
//-------------------------------
/** Read the lng file ...
*/
void
ReadLngFile
(
const
std
::
string
&
FileName
,
Substitutor
&
Substitutor
,
CountryIdentifierContainer_t
&
CtryContainer
)
{
Config
config
(
rtl
::
OStringToOUString
(
FileName
.
c_str
(),
osl_getThreadTextEncoding
()).
getStr
());
size_t
group_count
=
config
.
GetGroupCount
();
for
(
size_t
i
=
0
;
i
<
group_count
;
i
++
)
{
AddGroupEntriesToSubstitutor
(
config
,
config
.
GetGroupName
(
i
),
Substitutor
,
CtryContainer
);
}
// sort the country container
std
::
sort
(
CtryContainer
.
begin
(),
CtryContainer
.
end
());
}
//-------------------------------
/** Read the content of a file
into a line buffer
*/
void
ReadFile
(
const
std
::
string
&
FileName
,
LineBuffer_t
&
LineBuffer
)
{
std
::
ifstream
file
(
FileName
.
c_str
());
StreamExceptionsEnabler
sexc
(
file
);
try
{
Line
line
;
while
(
file
>>
line
)
LineBuffer
.
push_back
(
line
);
}
catch
(
const
std
::
ios
::
failure
&
)
{
if
(
!
file
.
eof
())
throw
;
}
}
//-------------------------------
/** A simple helper function that
appens the content of one
file to another one
@throws std::ios::failure
if a read or write error
occurs
*/
void
FileAppendFile
(
std
::
ostream
&
os
,
std
::
istream
&
is
)
{
StreamExceptionsEnabler
os_sexc
(
os
);
StreamExceptionsEnabler
is_sexc
(
is
);
try
{
std
::
istream_iterator
<
Line
>
ii
(
is
);
std
::
istream_iterator
<
Line
>
eos
;
std
::
ostream_iterator
<
Line
>
oi
(
os
,
"
\n
"
);
std
::
copy
(
ii
,
eos
,
oi
);
}
catch
(
const
std
::
ios
::
failure
&
)
{
if
(
!
is
.
eof
())
throw
;
}
}
//----------------------------
/** Helper functions for docu
purposes
*/
inline
void
ReadResourceTemplate
(
const
std
::
string
&
FileName
,
LineBuffer_t
&
LineBuffer
)
{
ReadFile
(
FileName
,
LineBuffer
);
}
inline
void
FileAppendRcHeader
(
std
::
ostream
&
os
,
std
::
istream
&
is
)
{
FileAppendFile
(
os
,
is
);
}
inline
void
FileAppendRcFooter
(
std
::
ostream
&
os
,
std
::
istream
&
is
)
{
FileAppendFile
(
os
,
is
);
}
//-------------------------------------------
/** Iterate all languages in the substitutor,
replace the all placeholder and append the
result to the output file
@throws std::ios::failure
on write errors
*/
void
InflateRcTemplateAndAppendToFile
(
std
::
ostream
&
os
,
const
LineBuffer_t
&
RcTemplate
,
Substitutor
&
substitutor
,
const
CountryIdentifierContainer_t
&
Countries
)
{
StreamExceptionsEnabler
sexc
(
os
);
CountryIdentifierContainer_t
::
const_iterator
iter
=
Countries
.
begin
();
CountryIdentifierContainer_t
::
const_iterator
iter_end
=
Countries
.
end
();
std
::
ostream_iterator
<
std
::
string
>
oi
(
os
,
"
\n
"
);
for
(
/**/
;
iter
!=
iter_end
;
++
iter
)
{
substitutor
.
SetActiveCountry
(
*
iter
);
LineBuffer_t
::
const_iterator
rct_iter
=
RcTemplate
.
begin
();
LineBuffer_t
::
const_iterator
rct_iter_end
=
RcTemplate
.
end
();
for
(
/**/
;
rct_iter
!=
rct_iter_end
;
++
rct_iter
)
{
std
::
istringstream
iss
=
rct_iter
->
m_Line
;
std
::
string
line
;
while
(
iss
)
{
std
::
string
token
;
iss
>>
token
;
substitutor
.
Substitute
(
token
);
line
+=
token
;
line
+=
" "
;
}
oi
=
line
;
}
}
}
//--------------------------------
/** It is only usefull to generate
resources for languages that
are in the lng file and in the
country-language file, that's
why we make the intersection
of the both country lists
*/
void
MakeUniqueIntersection
(
const
CountryIdentifierContainer_t
&
CtryContainer1
,
const
CountryIdentifierContainer_t
&
CtryContainer2
,
CountryIdentifierContainer_t
&
CtryContainer
)
{
std
::
back_insert_iterator
<
CountryIdentifierContainer_t
>
bii
(
CtryContainer
);
std
::
set_intersection
(
CtryContainer1
.
begin
(),
CtryContainer1
.
end
(),
CtryContainer2
.
begin
(),
CtryContainer2
.
end
(),
bii
);
std
::
unique
(
CtryContainer
.
begin
(),
CtryContainer
.
end
());
}
}
// namespace /* private */
//####################################
//-------------------------------
/** Main
The file names provided via
command line should be absolute
or relative to the directory
of this module
*/
int
main
(
int
argc
,
char
*
argv
[])
{
try
{
CommandLine
cmdline
(
argc
,
argv
);
Substitutor
substitutor
;
rtl
::
OUString
module_dir
=
GetModuleDirectory
();
rtl
::
OUString
oustr_abs_name
=
GetAbsoluteDirectory
(
module_dir
,
OStr2OUStr
(
cmdline
.
GetArgument
(
"-c"
).
c_str
()));
ReadCtryLngFile
(
std
::
ifstream
(
OUStr2OStr
(
oustr_abs_name
).
getStr
()),
substitutor
,
g_country_lng_file_countries
);
oustr_abs_name
=
GetAbsoluteDirectory
(
module_dir
,
OStr2OUStr
(
cmdline
.
GetArgument
(
"-lng"
).
c_str
()));
ReadLngFile
(
OUStr2OStr
(
oustr_abs_name
).
getStr
(),
substitutor
,
g_lng_file_countries
);
MakeUniqueIntersection
(
g_country_lng_file_countries
,
g_lng_file_countries
,
g_country_intersection
);
oustr_abs_name
=
GetAbsoluteDirectory
(
module_dir
,
OStr2OUStr
(
cmdline
.
GetArgument
(
"-rct"
).
c_str
()));
ReadResourceTemplate
(
OUStr2OStr
(
oustr_abs_name
).
getStr
(),
g_resource_template
);
oustr_abs_name
=
GetAbsoluteDirectory
(
module_dir
,
OStr2OUStr
(
cmdline
.
GetArgument
(
"-rc"
).
c_str
()));
std
::
ofstream
rc_output_file
(
OUStr2OStr
(
oustr_abs_name
).
getStr
());
oustr_abs_name
=
GetAbsoluteDirectory
(
module_dir
,
OStr2OUStr
(
cmdline
.
GetArgument
(
"-rch"
).
c_str
()));
FileAppendRcHeader
(
rc_output_file
,
std
::
ifstream
(
OUStr2OStr
(
oustr_abs_name
).
getStr
()));
InflateRcTemplateAndAppendToFile
(
rc_output_file
,
g_resource_template
,
substitutor
,
g_country_intersection
);
oustr_abs_name
=
GetAbsoluteDirectory
(
module_dir
,
OStr2OUStr
(
cmdline
.
GetArgument
(
"-rcf"
).
c_str
()));
FileAppendRcFooter
(
rc_output_file
,
std
::
ifstream
(
OUStr2OStr
(
oustr_abs_name
).
getStr
()));
}
catch
(
const
std
::
ios
::
failure
&
ex
)
{
std
::
cout
<<
ex
.
what
()
<<
std
::
endl
;
}
catch
(
std
::
exception
&
ex
)
{
std
::
cout
<<
ex
.
what
()
<<
std
::
endl
;
ShowUsage
();
}
catch
(...)
{
std
::
cout
<<
"Unexpected error..."
<<
std
::
endl
;
}
return
0
;
}
shell/source/tools/lngconvex/makefile.mk
0 → 100644
Dosyayı görüntüle @
f4990af4
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: tra $ $Date: 2002-08-26 10:50:02 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 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
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ
=
..
$/
..
$/
..
PRJNAME
=
shell
TARGET
=
lngconvex
TARGETTYPE
=
CUI
LIBTARGET
=
NO
ENABLE_EXCEPTIONS
=
TRUE
# --- Settings -----------------------------------------------------
.INCLUDE
:
settings.mk
# --- Files --------------------------------------------------------
CFLAGS
+=
/Ob0 /D_NTSDK
APP1TARGET
=
$(TARGET)
APP1OBJS
=
$(OBJ)$/$(TARGET)
.obj
\
$(OBJ)$/
cmdline.obj
# need msvcprt.lib for bad_cast exception
# symbols if we compiler with exceptions
# only valid for a tool like this
APP1STDLIBS
=
$(SALLIB)
\
$(TOOLSLIB)
\
$(SOLARLIBDIR)$/
atools.lib
\
msvcprt.lib
# --- Targets ------------------------------------------------------
.INCLUDE
:
target.mk
shell/source/win32/shlxthandler/classfactory.cxx
0 → 100644
Dosyayı görüntüle @
f4990af4
/*************************************************************************
*
* $RCSfile: classfactory.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: tra $ $Date: 2002-08-26 10:53:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 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
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _GLOBAL_HXX_
#include "global.hxx"
#endif
#ifndef _CLASSFACTORY_HXX_
#include "classfactory.hxx"
#endif
#ifndef _INFOTIP_HXX_
#include "infotip.hxx"
#endif
#ifndef _PROPSHTHDL_HXX_
#include "propshthdl.hxx"
#endif
#ifndef _COLUMNPROVIDER_HXX_
#include "columnprovider.hxx"
#endif
#ifndef _SHLXTHDL_HXX_
#include "shlxthdl.hxx"
#endif
//-----------------------------
//
//-----------------------------
long
CClassFactory
::
s_ServerLocks
=
0
;
//-----------------------------
//
//-----------------------------
CClassFactory
::
CClassFactory
(
const
CLSID
&
clsid
)
:
m_RefCnt
(
1
),
m_Clsid
(
clsid
)
{
InterlockedIncrement
(
&
g_DllRefCnt
);
}
//-----------------------------
//
//-----------------------------
CClassFactory
::~
CClassFactory
()
{
InterlockedDecrement
(
&
g_DllRefCnt
);
}
//-----------------------------
// IUnknown methods
//-----------------------------
HRESULT
STDMETHODCALLTYPE
CClassFactory
::
QueryInterface
(
REFIID
riid
,
void
__RPC_FAR
*
__RPC_FAR
*
ppvObject
)
{
*
ppvObject
=
0
;
if
(
IID_IUnknown
==
riid
||
IID_IClassFactory
==
riid
)
{
IUnknown
*
pUnk
=
this
;
pUnk
->
AddRef
();
*
ppvObject
=
pUnk
;
return
S_OK
;
}
return
E_NOINTERFACE
;
}
//-----------------------------
//
//-----------------------------
ULONG
STDMETHODCALLTYPE
CClassFactory
::
AddRef
(
void
)
{
return
InterlockedIncrement
(
&
m_RefCnt
);
}
//-----------------------------
//
//-----------------------------
ULONG
STDMETHODCALLTYPE
CClassFactory
::
Release
(
void
)
{
long
refcnt
=
InterlockedDecrement
(
&
m_RefCnt
);
if
(
0
==
refcnt
)
delete
this
;
return
refcnt
;
}
//-----------------------------
// IClassFactory methods
//-----------------------------
HRESULT
STDMETHODCALLTYPE
CClassFactory
::
CreateInstance
(
IUnknown
__RPC_FAR
*
pUnkOuter
,
REFIID
riid
,
void
__RPC_FAR
*
__RPC_FAR
*
ppvObject
)
{
if
((
pUnkOuter
!=
NULL
))
return
CLASS_E_NOAGGREGATION
;
IUnknown
*
pUnk
=
0
;
if
(
CLSID_PROPERTYSHEET_HANDLER
==
m_Clsid
)
pUnk
=
static_cast
<
IShellExtInit
*>
(
new
CPropertySheetHandler
());
#ifdef BUILD_SOSL
else
if
(
CLSID_INFOTIP_HANDLER
==
m_Clsid
)
pUnk
=
static_cast
<
IQueryInfo
*>
(
new
CInfoTip
());
#endif
#if defined(_WINXPSDK) && (BUILD_SOSL)
else
if
(
CLSID_COLUMN_HANDLER
==
m_Clsid
)
pUnk
=
static_cast
<
IColumnProvider
*>
(
new
CColumnProvider
());
#endif
POST_CONDITION
(
pUnk
!=
0
,
"Could not create COM object"
);
if
(
0
==
pUnk
)
return
E_OUTOFMEMORY
;
HRESULT
hr
=
pUnk
->
QueryInterface
(
riid
,
ppvObject
);
// if QueryInterface failed the component
// will destroy itself
pUnk
->
Release
();
return
hr
;
}
//-----------------------------
//
//-----------------------------
HRESULT
STDMETHODCALLTYPE
CClassFactory
::
LockServer
(
BOOL
fLock
)
{
if
(
fLock
)
InterlockedIncrement
(
&
s_ServerLocks
);
else
InterlockedDecrement
(
&
s_ServerLocks
);
return
S_OK
;
}
//-----------------------------
//
//-----------------------------
bool
CClassFactory
::
IsLocked
()
{
return
(
s_ServerLocks
>
0
);
}
shell/source/win32/shlxthandler/classfactory.hxx
0 → 100644
Dosyayı görüntüle @
f4990af4
/*************************************************************************
*
* $RCSfile: classfactory.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: tra $ $Date: 2002-08-26 10:53:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 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
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _CLASSFACTORY_HXX_
#define _CLASSFACTORY_HXX_
#include <objidl.h>
class
CClassFactory
:
public
IClassFactory
{
public
:
CClassFactory
(
const
CLSID
&
clsid
);
virtual
~
CClassFactory
();
//-----------------------------
// IUnknown methods
//-----------------------------
virtual
HRESULT
STDMETHODCALLTYPE
QueryInterface
(
REFIID
riid
,
void
__RPC_FAR
*
__RPC_FAR
*
ppvObject
);
virtual
ULONG
STDMETHODCALLTYPE
AddRef
(
void
);
virtual
ULONG
STDMETHODCALLTYPE
Release
(
void
);
//-----------------------------
// IClassFactory methods
//-----------------------------
virtual
HRESULT
STDMETHODCALLTYPE
CreateInstance
(
IUnknown
__RPC_FAR
*
pUnkOuter
,
REFIID
riid
,
void
__RPC_FAR
*
__RPC_FAR
*
ppvObject
);
virtual
HRESULT
STDMETHODCALLTYPE
LockServer
(
BOOL
fLock
);
static
bool
IsLocked
();
private
:
long
m_RefCnt
;
CLSID
m_Clsid
;
static
long
s_ServerLocks
;
};
#endif
shell/source/win32/shlxthandler/exports.dxp
0 → 100644
Dosyayı görüntüle @
f4990af4
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
\ No newline at end of file
shell/source/win32/shlxthandler/makefile.mk
0 → 100644
Dosyayı görüntüle @
f4990af4
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: tra $ $Date: 2002-08-26 10:54:14 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 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
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ
=
..
$/
..
$/
..
PRJNAME
=
shell
TARGET
=
shlxthdl
LIBTARGET
=
NO
ENABLE_EXCEPTIONS
=
TRUE
USE_DEFFILE
=
TRUE
TARGET1
=
regsvrex
TARGETTYPE
=
CUI
# --- Settings -----------------------------------------------------
.INCLUDE
:
settings.mk
# set the define _WINXPSDK if you compile
# with a Microsoft platform sdk for Windows
# 2000 and greater
#
# set ISOLATION_AWARE_ENABLE for activating
# the Windows XP visual styles
#/D_WINXPSDK set this for a Win2000/WinXP Platform SDK
#/DBUILD_SOSL for extended functionality (Infotip and
# Column Handler)
CFLAGS
+=
/DISOLATION_AWARE_ENABLED /DWIN32_LEAN_AND_MEAN /DXML_UNICODE /D_NTSDK /DUNICODE
# --- Files --------------------------------------------------------
RCFILES
=
$(TARGET)
.rc
LNGFILES
=
$(TARGET)
.lng
SLOFILES
=
$(SLO)$/
classfactory.obj
\
$(SLO)$/
columnprovider.obj
\
$(SLO)$/
dbgmacros.obj
\
$(SLO)$/
fileextensions.obj
\
$(SLO)$/
infotip.obj
\
$(SLO)$/
propshthdl.obj
\
$(SLO)$/
registry.obj
\
$(SLO)$/
saxdochdl.obj
\
$(SLO)$/
saxprsrexcptn.obj
\
$(SLO)$/
shlxthdl.obj
\
$(SLO)$/
xmlprsr.obj
\
$(SLO)$/
ziparchv.obj
\
$(SLO)$/
zipexcptn.obj
\
$(SLO)$/
metaaccessor.obj
\
$(SLO)$/
utilities.obj
SHL1TARGET
=
$(TARGET)
SHL1STDLIBS
=
uwinapi.lib
\
unicows.lib
\
oleaut32.lib
\
advapi32.lib
\
ole32.lib
\
uuid.lib
\
shell32.lib
\
comctl32.lib
SHL1LIBS
=
$(SOLARLIBDIR)$/
zlib.lib
\
$(SOLARLIBDIR)$/
expat_xmlparse.lib
\
$(SOLARLIBDIR)$/
expat_xmltok.lib
SHL1DEPN
=
SHL1OBJS
=
$(SLOFILES)
SHL1DEF
=
$(MISC)$/$(SHL1TARGET)
.def
SHL1RES
=
$(RES)$/$(TARGET)
.res
DEF1NAME
=
$(SHL1TARGET)
DEF1EXPORTFILE
=
exports.dxp
OBJFILES
=
$(OBJ)$/
regsvrex.obj
APP1TARGET
=
$(TARGET1)
APP1OBJS
=
$(OBJFILES)
APP1STDLIBS
=
kernel32.lib
APP1DEF
=
$(MISC)$/$(APP1TARGET)
.def
# --- Targets ------------------------------------------------------
.INCLUDE
:
target.mk
# Generate the native Windows resource file
# using lngconvex.exe
$(RCFILES)
:
$(LNGFILES) makefile.mk rcfooter.txt rcheader.txt rctmpl.txt ctrylnglist.txt
+$(BIN)$/lngconvex.exe
-lng
..\..\source\win32\shlxthandler\shlxthdl.lng
-rc
..\..\source\win32\shlxthandler\shlxthdl.rc
-c
..\..\source\win32\shlxthandler\ctrylnglist.txt
-rct
..\..\source\win32\shlxthandler\rctmpl.txt
-rch
..\..\source\win32\shlxthandler\rcheader.txt
-rcf
..\..\source\win32\shlxthandler\rcfooter.txt
shell/source/win32/shlxthandler/shlxthdl.cxx
0 → 100644
Dosyayı görüntüle @
f4990af4
/*************************************************************************
*
* $RCSfile: shlxthdl.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: tra $ $Date: 2002-08-26 10:53:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 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
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _CONFIG_HXX_
#include "config.hxx"
#endif
#ifndef _GLOBAL_HXX_
#include "global.hxx"
#endif
#ifndef _SHLXTHDL_HXX_
#include "shlxthdl.hxx"
#endif
#ifndef _CLASSFACTORY_HXX_
#include "classfactory.hxx"
#endif
#ifndef _REGISTRY_HXX_
#include "registry.hxx"
#endif
#ifndef _FILEEXTENSIONS_HXX_
#include "fileextensions.hxx"
#endif
#ifndef _UTILITIES_HXX_
#include "utilities.hxx"
#endif
#include <string>
#include <shlobj.h>
//---------------------------
// Module global
//---------------------------
long
g_DllRefCnt
=
0
;
//---------------------------
//
//---------------------------
namespace
/* private */
{
const
char
*
GUID_PLACEHOLDER
=
"{GUID}"
;
const
char
*
EXTENSION_PLACEHOLDER
=
"{EXT}"
;
const
char
*
FORWARDKEY_PLACEHOLDER
=
"{FWDKEY}"
;
const
char
*
CLSID_ENTRY
=
"CLSID
\\
{GUID}
\\
InProcServer32"
;
const
char
*
SHELLEX_IID_ENTRY
=
"{EXT}
\\
shellex
\\
{GUID}"
;
const
char
*
SHELLEX_ENTRY
=
"{EXT}
\\
shellex"
;
const
char
*
PROPSHEET_ENTRY
=
"{EXT}
\\
CLSID
\\
{GUID}
\\
InProcServer32"
;
const
char
*
EXTENSION_CLSID
=
"{EXT}
\\
CLSID"
;
const
char
*
EXTENSION_CLSID_GUID
=
"{EXT}
\\
CLSID
\\
{GUID}"
;
const
char
*
FORWARD_PROPSHEET_MYPROPSHEET_ENTRY
=
"{FWDKEY}
\\
shellex
\\
PropertySheetHandlers
\\
MyPropSheet1"
;
const
char
*
FORWARD_PROPSHEET_ENTRY
=
"{FWDKEY}
\\
shellex
\\
PropertySheetHandlers"
;
const
char
*
FORWARD_SHELLEX_ENTRY
=
"{FWDKEY}
\\
shellex"
;
const
char
*
SHELL_EXTENSION_APPROVED_KEY_NAME
=
"Software
\\
Microsoft
\\
Windows
\\
CurrentVersion
\\
Shell Extensions
\\
Approved"
;
//---------------------------
// "String Placeholder" ->
// "String Replacement"
//---------------------------
void
SubstitutePlaceholder
(
std
::
string
&
String
,
const
std
::
string
&
Placeholder
,
const
std
::
string
&
Replacement
)
{
std
::
string
::
size_type
idx
=
String
.
find
(
Placeholder
);
std
::
string
::
size_type
len
=
Placeholder
.
length
();
while
(
std
::
string
::
npos
!=
idx
)
{
String
.
replace
(
idx
,
len
,
Replacement
);
idx
=
String
.
find
(
Placeholder
);
}
}
//----------------------------------------------
// Make the registry entry
// HKCR\CLSID\{GUID}
// InProcServer32 = Path\shlxthdl.dll
// ThreadingModel = Apartment
//----------------------------------------------
HRESULT
RegisterComComponent
(
const
char
*
FilePath
,
const
CLSID
&
Guid
)
{
std
::
string
ClsidEntry
=
CLSID_ENTRY
;
SubstitutePlaceholder
(
ClsidEntry
,
GUID_PLACEHOLDER
,
ClsidToString
(
Guid
));
if
(
!
SetRegistryKey
(
HKEY_CLASSES_ROOT
,
ClsidEntry
.
c_str
(),
""
,
FilePath
))
return
E_FAIL
;
if
(
!
SetRegistryKey
(
HKEY_CLASSES_ROOT
,
ClsidEntry
.
c_str
(),
"ThreadingModel"
,
"Apartment"
))
return
E_FAIL
;
return
S_OK
;
}
//---------------------------
//
//---------------------------
HRESULT
UnregisterComComponent
(
const
CLSID
&
Guid
)
{
std
::
string
tmp
=
"CLSID
\\
"
;
tmp
+=
ClsidToString
(
Guid
);
return
DeleteRegistryKey
(
HKEY_CLASSES_ROOT
,
tmp
.
c_str
())
?
S_OK
:
E_FAIL
;
}
#ifdef _WINXPSDK
//---------------------------
//
//---------------------------
HRESULT
RegisterColumnHandler
(
const
char
*
ModuleFileName
)
{
if
(
FAILED
(
RegisterComComponent
(
ModuleFileName
,
CLSID_COLUMN_HANDLER
)))
return
E_FAIL
;
std
::
string
tmp
=
"Folder
\\
shellex
\\
ColumnHandlers
\\
"
;
tmp
+=
ClsidToString
(
CLSID_COLUMN_HANDLER
);
return
SetRegistryKey
(
HKEY_CLASSES_ROOT
,
tmp
.
c_str
(),
""
,
WStringToString
(
COLUMN_HANDLER_DESCRIPTIVE_NAME
).
c_str
())
?
S_OK
:
E_FAIL
;
}
//---------------------------
//
//---------------------------
HRESULT
UnregisterColumnHandler
()
{
std
::
string
tmp
=
"Folder
\\
shellex
\\
ColumnHandlers
\\
"
;
tmp
+=
ClsidToString
(
CLSID_COLUMN_HANDLER
);
if
(
!
DeleteRegistryKey
(
HKEY_CLASSES_ROOT
,
tmp
.
c_str
()))
return
E_FAIL
;
return
UnregisterComComponent
(
CLSID_COLUMN_HANDLER
);
}
#endif
//---------------------------
//
//---------------------------
HRESULT
RegisterInfotipHandler
(
const
char
*
ModuleFileName
)
{
if
(
FAILED
(
RegisterComComponent
(
ModuleFileName
,
CLSID_INFOTIP_HANDLER
)))
return
E_FAIL
;
std
::
string
iid
=
ClsidToString
(
IID_IQueryInfo
);
std
::
string
tmp
;
for
(
size_t
i
=
0
;
i
<
OOFileExtensionTableSize
;
i
++
)
{
tmp
=
SHELLEX_IID_ENTRY
;
SubstitutePlaceholder
(
tmp
,
EXTENSION_PLACEHOLDER
,
OOFileExtensionTable
[
i
].
ExtensionAnsi
);
SubstitutePlaceholder
(
tmp
,
GUID_PLACEHOLDER
,
iid
);
if
(
!
SetRegistryKey
(
HKEY_CLASSES_ROOT
,
tmp
.
c_str
(),
""
,
ClsidToString
(
CLSID_INFOTIP_HANDLER
).
c_str
()))
return
E_FAIL
;
}
return
S_OK
;
}
//---------------------------
//
//---------------------------
HRESULT
UnregisterInfotipHandler
()
{
std
::
string
iid
=
ClsidToString
(
IID_IQueryInfo
);
std
::
string
tmp
;
for
(
size_t
i
=
0
;
i
<
OOFileExtensionTableSize
;
i
++
)
{
tmp
=
SHELLEX_IID_ENTRY
;
SubstitutePlaceholder
(
tmp
,
EXTENSION_PLACEHOLDER
,
OOFileExtensionTable
[
i
].
ExtensionAnsi
);
SubstitutePlaceholder
(
tmp
,
GUID_PLACEHOLDER
,
iid
);
DeleteRegistryKey
(
HKEY_CLASSES_ROOT
,
tmp
.
c_str
());
// if there are no further subkey below .ext\\shellex
// delete the whole subkey
tmp
=
SHELLEX_ENTRY
;
SubstitutePlaceholder
(
tmp
,
EXTENSION_PLACEHOLDER
,
OOFileExtensionTable
[
i
].
ExtensionAnsi
);
bool
HasSubKeys
=
true
;
if
(
HasSubkeysRegistryKey
(
HKEY_CLASSES_ROOT
,
tmp
.
c_str
(),
HasSubKeys
)
&&
!
HasSubKeys
)
DeleteRegistryKey
(
HKEY_CLASSES_ROOT
,
tmp
.
c_str
());
}
return
UnregisterComComponent
(
CLSID_INFOTIP_HANDLER
);
}
//---------------------------
//
//---------------------------
HRESULT
RegisterPropSheetHandler
(
const
char
*
ModuleFileName
)
{
std
::
string
ExtEntry
;
std
::
string
FwdKeyEntry
;
if
(
FAILED
(
RegisterComComponent
(
ModuleFileName
,
CLSID_PROPERTYSHEET_HANDLER
)))
return
E_FAIL
;
for
(
size_t
i
=
0
;
i
<
OOFileExtensionTableSize
;
i
++
)
{
FwdKeyEntry
=
FORWARD_PROPSHEET_MYPROPSHEET_ENTRY
;
SubstitutePlaceholder
(
FwdKeyEntry
,
FORWARDKEY_PLACEHOLDER
,
OOFileExtensionTable
[
i
].
RegistryForwardKey
);
if
(
!
SetRegistryKey
(
HKEY_CLASSES_ROOT
,
FwdKeyEntry
.
c_str
(),
""
,
ClsidToString
(
CLSID_PROPERTYSHEET_HANDLER
).
c_str
()))
return
E_FAIL
;
}
return
S_OK
;
}
//---------------------------
//
//---------------------------
HRESULT
UnregisterPropSheetHandler
()
{
std
::
string
ExtEntry
;
std
::
string
FwdKeyEntry
;
for
(
size_t
i
=
0
;
i
<
OOFileExtensionTableSize
;
i
++
)
{
FwdKeyEntry
=
FORWARD_PROPSHEET_MYPROPSHEET_ENTRY
;
SubstitutePlaceholder
(
FwdKeyEntry
,
FORWARDKEY_PLACEHOLDER
,
OOFileExtensionTable
[
i
].
RegistryForwardKey
);
DeleteRegistryKey
(
HKEY_CLASSES_ROOT
,
FwdKeyEntry
.
c_str
());
FwdKeyEntry
=
FORWARD_PROPSHEET_ENTRY
;
SubstitutePlaceholder
(
FwdKeyEntry
,
FORWARDKEY_PLACEHOLDER
,
OOFileExtensionTable
[
i
].
RegistryForwardKey
);
bool
HasSubKeys
=
true
;
if
(
HasSubkeysRegistryKey
(
HKEY_CLASSES_ROOT
,
FwdKeyEntry
.
c_str
(),
HasSubKeys
)
&&
!
HasSubKeys
)
DeleteRegistryKey
(
HKEY_CLASSES_ROOT
,
FwdKeyEntry
.
c_str
());
FwdKeyEntry
=
FORWARD_SHELLEX_ENTRY
;
SubstitutePlaceholder
(
FwdKeyEntry
,
FORWARDKEY_PLACEHOLDER
,
OOFileExtensionTable
[
i
].
RegistryForwardKey
);
HasSubKeys
=
true
;
if
(
HasSubkeysRegistryKey
(
HKEY_CLASSES_ROOT
,
FwdKeyEntry
.
c_str
(),
HasSubKeys
)
&&
!
HasSubKeys
)
DeleteRegistryKey
(
HKEY_CLASSES_ROOT
,
FwdKeyEntry
.
c_str
());
}
return
UnregisterComComponent
(
CLSID_PROPERTYSHEET_HANDLER
);
}
//-----------------------------------
/** Approve the Shell Extension, it's
important for Windows NT/2000/XP
See MSDN: Creating Shell Extension
Handlers
*/
HRESULT
ApproveShellExtension
(
CLSID
clsid
,
const
std
::
wstring
&
Description
)
{
bool
bRet
=
SetRegistryKey
(
HKEY_LOCAL_MACHINE
,
SHELL_EXTENSION_APPROVED_KEY_NAME
,
ClsidToString
(
clsid
).
c_str
(),
WStringToString
(
Description
).
c_str
());
return
bRet
?
S_OK
:
E_FAIL
;
}
//------------------------------------
/** Unapprove the Shell Extension, it's
important under Windows NT/2000/XP
See MSDN: Creating Shell Extension
Handlers
*/
HRESULT
UnapproveShellExtension
(
CLSID
Clsid
)
{
HKEY
hkey
;
LONG
rc
=
RegOpenKeyA
(
HKEY_LOCAL_MACHINE
,
SHELL_EXTENSION_APPROVED_KEY_NAME
,
&
hkey
);
if
(
ERROR_SUCCESS
==
rc
)
{
rc
=
RegDeleteValueA
(
hkey
,
ClsidToString
(
Clsid
).
c_str
());
rc
=
RegCloseKey
(
hkey
);
}
return
rc
==
ERROR_SUCCESS
?
S_OK
:
E_FAIL
;
}
}
// namespace /* private */
//---------------------------
// COM exports
//---------------------------
extern
"C"
STDAPI
DllRegisterServer
()
{
char
ModuleFileName
[
MAX_PATH
];
GetModuleFileNameA
(
GetModuleHandleA
(
MODULE_NAME_A
),
ModuleFileName
,
sizeof
(
ModuleFileName
));
HRESULT
hr
=
S_OK
;
#if defined(_WINXPSDK) && (BUILD_SOSL)
// register column handler
if
(
FAILED
(
RegisterColumnHandler
(
ModuleFileName
)))
hr
=
E_FAIL
;
ApproveShellExtension
(
CLSID_COLUMN_HANDLER
,
COLUMN_HANDLER_DESCRIPTIVE_NAME
);
#endif
#if defined(BUILD_SOSL)
// register info tip control
if
(
FAILED
(
RegisterInfotipHandler
(
ModuleFileName
)))
hr
=
E_FAIL
;
ApproveShellExtension
(
CLSID_INFOTIP_HANDLER
,
INFOTIP_HANDLER_DESCRIPTIVE_NAME
);
#endif
// register property sheet handler
if
(
FAILED
(
RegisterPropSheetHandler
(
ModuleFileName
)))
hr
=
E_FAIL
;
ApproveShellExtension
(
CLSID_PROPERTYSHEET_HANDLER
,
PROPSHEET_HANDLER_DESCRIPTIVE_NAME
);
// notify the Shell that something has
// changed
SHChangeNotify
(
SHCNE_ASSOCCHANGED
,
0
,
0
,
0
);
return
hr
;
}
//---------------------------
//
//---------------------------
extern
"C"
STDAPI
DllUnregisterServer
()
{
HRESULT
hr
=
S_OK
;
#if defined(_WINXPSDK) && (BUILD_SOSL)
if
(
FAILED
(
UnregisterColumnHandler
()))
hr
=
E_FAIL
;
UnapproveShellExtension
(
CLSID_COLUMN_HANDLER
);
#endif
#if defined (BUILD_SOSL)
if
(
FAILED
(
UnregisterInfotipHandler
()))
hr
=
E_FAIL
;
UnapproveShellExtension
(
CLSID_INFOTIP_HANDLER
);
#endif
if
(
FAILED
(
UnregisterPropSheetHandler
()))
hr
=
E_FAIL
;
UnapproveShellExtension
(
CLSID_PROPERTYSHEET_HANDLER
);
// notify the Shell that something has
// changed
SHChangeNotify
(
SHCNE_ASSOCCHANGED
,
0
,
0
,
0
);
return
hr
;
}
//---------------------------
//
//---------------------------
extern
"C"
STDAPI
DllGetClassObject
(
REFCLSID
rclsid
,
REFIID
riid
,
void
**
ppv
)
{
*
ppv
=
0
;
if
((
rclsid
!=
CLSID_INFOTIP_HANDLER
)
&&
#ifdef _WINXPSDK
(
rclsid
!=
CLSID_COLUMN_HANDLER
)
&&
#endif
(
rclsid
!=
CLSID_PROPERTYSHEET_HANDLER
))
return
CLASS_E_CLASSNOTAVAILABLE
;
if
((
riid
!=
IID_IUnknown
)
&&
(
riid
!=
IID_IClassFactory
))
return
E_NOINTERFACE
;
IUnknown
*
pUnk
=
new
CClassFactory
(
rclsid
);
if
(
0
==
pUnk
)
return
E_OUTOFMEMORY
;
*
ppv
=
pUnk
;
return
S_OK
;
}
//---------------------------
//
//---------------------------
extern
"C"
STDAPI
DllCanUnloadNow
(
void
)
{
if
(
CClassFactory
::
IsLocked
()
||
g_DllRefCnt
>
0
)
return
S_FALSE
;
return
S_OK
;
}
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