Kaydet (Commit) 8524330a authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Simplify addition of optional components to URE_MORE_{SERVICES,TYPES}.

Those bootstrap variables now support <XXX>* syntax to include all files (non-
recursively) contained in the directory denoted by XXX.  Optional components can
put their data simply into program/services/ and program/types/.
üst 4ab6d284
......@@ -75,6 +75,8 @@ using namespace ::osl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
namespace css = com::sun::star;
namespace cppu
{
......@@ -198,6 +200,105 @@ OUString findBootstrapArgument(
return result;
}
css::uno::Reference< css::registry::XSimpleRegistry > readRdbFile(
rtl::OUString const & url, bool fatalErrors,
css::uno::Reference< css::registry::XSimpleRegistry > const & lastRegistry,
css::uno::Reference< css::lang::XSingleServiceFactory > const &
simpleRegistryFactory,
css::uno::Reference< css::lang::XSingleServiceFactory > const &
nestedRegistryFactory)
{
OSL_ASSERT(simpleRegistryFactory.is() && nestedRegistryFactory.is());
try {
css::uno::Reference< css::registry::XSimpleRegistry > simple(
simpleRegistryFactory->createInstance(), css::uno::UNO_QUERY_THROW);
simple->open(url, true, false);
if (lastRegistry.is()) {
css::uno::Reference< css::registry::XSimpleRegistry > nested(
nestedRegistryFactory->createInstance(),
css::uno::UNO_QUERY_THROW);
css::uno::Sequence< css::uno::Any > args(2);
args[0] <<= lastRegistry;
args[1] <<= simple;
css::uno::Reference< css::lang::XInitialization >(
nested, css::uno::UNO_QUERY_THROW)->
initialize(args);
return nested;
} else {
return simple;
}
} catch (css::registry::InvalidRegistryException & e) {
(void) e; // avoid warnings
OSL_TRACE(
OSL_LOG_PREFIX "warning, could not open \"%s\": \"%s\"",
rtl::OUStringToOString(url, RTL_TEXTENCODING_UTF8).getStr(),
rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
if (fatalErrors) {
throw;
}
return lastRegistry;
}
}
Reference< registry::XSimpleRegistry > readRdbDirectory(
rtl::OUString const & url, bool fatalErrors,
css::uno::Reference< css::registry::XSimpleRegistry > const & lastRegistry,
css::uno::Reference< css::lang::XSingleServiceFactory > const &
simpleRegistryFactory,
css::uno::Reference< css::lang::XSingleServiceFactory > const &
nestedRegistryFactory)
{
OSL_ASSERT(simpleRegistryFactory.is() && nestedRegistryFactory.is());
osl::Directory dir(url);
switch (dir.open()) {
case osl::FileBase::E_None:
break;
case osl::FileBase::E_NOENT:
if (!fatalErrors) {
return lastRegistry;
}
// fall through
default:
throw css::uno::RuntimeException(
(rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("cannot open directory ")) +
url),
css::uno::Reference< css::uno::XInterface >());
}
for (css::uno::Reference< css::registry::XSimpleRegistry > last(
lastRegistry);;)
{
osl::DirectoryItem i;
switch (dir.getNextItem(i, SAL_MAX_UINT32)) {
case osl::FileBase::E_None:
break;
case osl::FileBase::E_NOENT:
return last;
default:
throw css::uno::RuntimeException(
(rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("cannot iterate directory ")) +
url),
css::uno::Reference< css::uno::XInterface >());
}
osl::FileStatus stat(
osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName |
osl_FileStatus_Mask_FileURL);
if (i.getFileStatus(stat) != osl::FileBase::E_None) {
throw css::uno::RuntimeException(
(rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("cannot stat in directory ")) +
url),
css::uno::Reference< css::uno::XInterface >());
}
if (stat.getFileType() != osl::FileStatus::Directory) { //TODO: symlinks
last = readRdbFile(
stat.getFileURL(), fatalErrors, last, simpleRegistryFactory,
nestedRegistryFactory);
}
}
}
Reference< registry::XSimpleRegistry > nestRegistries(
const OUString &baseDir,
const Reference< lang::XSingleServiceFactory > & xSimRegFac,
......@@ -238,54 +339,30 @@ Reference< registry::XSimpleRegistry > nestRegistries(
OUString rdb_name = (index == -1) ? csl_rdbs : csl_rdbs.copy(0, index);
csl_rdbs = (index == -1) ? OUString() : csl_rdbs.copy(index + 1);
if (! rdb_name.getLength())
if (rdb_name.isEmpty()) {
continue;
}
bool optional = ('?' == rdb_name[ 0 ]);
if (optional)
rdb_name = rdb_name.copy( 1 );
try
{
Reference<registry::XSimpleRegistry> simpleRegistry(
xSimRegFac->createInstance(), UNO_QUERY_THROW );
osl::FileBase::getAbsoluteFileURL(baseDir, rdb_name, rdb_name);
simpleRegistry->open(rdb_name, sal_True, sal_False);
if(lastRegistry.is())
{
Reference< registry::XSimpleRegistry > nestedRegistry(
xNesRegFac->createInstance(), UNO_QUERY );
Reference< lang::XInitialization > nestedRegistry_xInit(
nestedRegistry, UNO_QUERY );
Sequence<Any> aArgs(2);
aArgs[0] <<= lastRegistry;
aArgs[1] <<= simpleRegistry;
nestedRegistry_xInit->initialize(aArgs);
lastRegistry = nestedRegistry;
}
else
lastRegistry = simpleRegistry;
bool fatalErrors = !bFallenBack;
if (rdb_name[0] == '?') {
rdb_name = rdb_name.copy(1);
fatalErrors = false;
}
catch(registry::InvalidRegistryException & e)
{
(void) e; // avoid warnings
OSL_TRACE(
OSL_LOG_PREFIX "warning, could not open \"%s\": \"%s\"",
OUStringToOString(rdb_name, RTL_TEXTENCODING_UTF8).getStr(),
OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
if (! optional)
{
// if a registry was explicitly given, the exception shall fly
if( ! bFallenBack )
throw;
}
bool directory = rdb_name.getLength() >= 3 && rdb_name[0] == '<' &&
rdb_name[rdb_name.getLength() - 2] == '>' &&
rdb_name[rdb_name.getLength() -1] == '*';
if (directory) {
rdb_name = rdb_name.copy(1, rdb_name.getLength() - 3);
}
osl::FileBase::getAbsoluteFileURL(baseDir, rdb_name, rdb_name);
lastRegistry = directory
? readRdbDirectory(
rdb_name, fatalErrors, lastRegistry, xSimRegFac, xNesRegFac)
: readRdbFile(
rdb_name, fatalErrors, lastRegistry, xSimRegFac, xNesRegFac);
}
while(index != -1 && csl_rdbs.getLength()); // are there more rdbs in list?
......
......@@ -1168,7 +1168,7 @@ ProfileItem gid_Brand_Profileitem_Fundamental_Ure_More_Types
ProfileID = gid_Brand_Profile_Fundamental_Ini;
Section = "Bootstrap";
Key = "URE_MORE_TYPES";
Value = "$ORIGIN/offapi.rdb $ORIGIN/oovbaapi.rdb ${${$ORIGIN/" PROFILENAME(uno) ":PKG_UserUnoFile}:UNO_TYPES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_SharedUnoFile}:UNO_TYPES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_BundledUnoFile}:UNO_TYPES}";
Value = "<$ORIGIN/types>* ${${$ORIGIN/" PROFILENAME(uno) ":PKG_UserUnoFile}:UNO_TYPES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_SharedUnoFile}:UNO_TYPES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_BundledUnoFile}:UNO_TYPES}";
End
ProfileItem gid_Brand_Profileitem_Fundamental_Ure_More_Services
......@@ -1176,7 +1176,7 @@ ProfileItem gid_Brand_Profileitem_Fundamental_Ure_More_Services
ProfileID = gid_Brand_Profile_Fundamental_Ini;
Section = "Bootstrap";
Key = "URE_MORE_SERVICES";
Value = "${${$ORIGIN/" PROFILENAME(uno) ":PKG_UserUnoFile}:UNO_SERVICES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_SharedUnoFile}:UNO_SERVICES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_BundledUnoFile}:UNO_SERVICES} $ORIGIN/services.rdb";
Value = "${${$ORIGIN/" PROFILENAME(uno) ":PKG_UserUnoFile}:UNO_SERVICES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_SharedUnoFile}:UNO_SERVICES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_BundledUnoFile}:UNO_SERVICES} <$ORIGIN/services>*";
End
ProfileItem gid_Brand_Profileitem_Fundamental_Ure_More_Java_Types
......
......@@ -1435,3 +1435,13 @@ Directory gid_Dir_Template_Common_Presnt
ParentID = gid_Dir_Template_Common;
DosName = "presnt";
End
Directory gid_Brand_Dir_Program_Services
ParentID = gid_Brand_Dir_Program;
DosName = "services";
End
Directory gid_Brand_Dir_Program_Types
ParentID = gid_Brand_Dir_Program;
DosName = "types";
End
......@@ -629,14 +629,14 @@ End
File gid_File_Rdb_Offapi
TXT_FILE_BODY;
Dir = gid_Brand_Dir_Program;
Dir = gid_Brand_Dir_Program_Types;
Styles = (PACKED);
Name = "offapi.rdb";
End
File gid_File_Rdb_TypesVba
TXT_FILE_BODY;
Dir = gid_Brand_Dir_Program;
Dir = gid_Brand_Dir_Program_Types;
Styles = (PACKED, OVERWRITE);
Name = "oovbaapi.rdb";
End
......@@ -1142,7 +1142,7 @@ End
File gid_Starregistry_Services_Rdb
TXT_FILE_BODY;
Name = "services.rdb";
Dir = gid_Brand_Dir_Program;
Dir = gid_Brand_Dir_Program_Services;
Styles = (PACKED);
End
......
......@@ -273,6 +273,11 @@ types.rdb and services.rdb files. That is, you cannot store additional
types.rdb and services.rdb files in a Documents and Settings\All
Users\Application Data\URE directory.
URE_MORE_TYPES and URE_MORE_SERVICES each contain zero or more space-separated
URI descriptors. A URI descriptor is either a URI (denoting an individual file)
or a URI embeded in "<" and ">*" (denoting all the files contained non-
recursively within the directory denoted by the given URI).
The Java UNO environment needs type information in the form of Java class files
instead of rdb files. Additional types are searched for in any URLs listed in
the public deployment variable URE_MORE_JAVA_TYPES.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment