summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-07-09 19:48:21 +0200
committerMichael Meeks <michael.meeks@suse.com>2013-07-10 09:01:25 +0000
commit78056d4186b565e8da6122446bca90f6983dc1a5 (patch)
treea7a225b6cb21c5139a947fe9ada3ade605e8df5b
parenteacf99268af767dd045754e42b24fe99964e8a52 (diff)
fdo#65589: Treat legacy types.rdb w/o /UCR key as empty
...as they are encountered in the wild. Change-Id: Iae46d3b4b4aca18a09680caabc0e343f8a534989 (cherry picked from commit 87bad231d6f81c611ba145aea483a568623ca42e) Reviewed-on: https://gerrit.libreoffice.org/4789 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Reviewed-by: David Tardon <dtardon@redhat.com> Reviewed-by: Michael Meeks <michael.meeks@suse.com> Tested-by: Michael Meeks <michael.meeks@suse.com>
-rw-r--r--unoidl/source/legacyprovider.cxx32
1 files changed, 20 insertions, 12 deletions
diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx
index 17b95dcd629c..a60424a8ceb6 100644
--- a/unoidl/source/legacyprovider.cxx
+++ b/unoidl/source/legacyprovider.cxx
@@ -96,16 +96,18 @@ Cursor::Cursor(
RegistryKey const & key):
manager_(manager), ucr_(ucr), key_(key), index_(0)
{
- prefix_ = key_.getName();
- if (!prefix_.endsWith("/")) {
- prefix_ += "/";
- }
- RegError e = key_.getKeyNames("", names_);
- if (e != REG_NO_ERROR) {
- throw FileFormatException(
- key_.getRegistryName(),
- ("legacy format: cannot get sub-key names of " + key_.getName()
- + ": " + OUString::number(e)));
+ if (ucr_.isValid()) {
+ prefix_ = key_.getName();
+ if (!prefix_.endsWith("/")) {
+ prefix_ += "/";
+ }
+ RegError e = key_.getKeyNames("", names_);
+ if (e != REG_NO_ERROR) {
+ throw FileFormatException(
+ key_.getRegistryName(),
+ ("legacy format: cannot get sub-key names of " + key_.getName()
+ + ": " + OUString::number(e)));
+ }
}
}
@@ -797,7 +799,11 @@ LegacyProvider::LegacyProvider(
uri, "legacy format: cannot open root key: " + OUString::number(e));
}
e = root.openKey("UCR", ucr_);
- if (e != REG_NO_ERROR) {
+ switch (e) {
+ case REG_NO_ERROR:
+ case REG_KEY_NOT_EXISTS: // such effectively empty files exist in the wild
+ break;
+ default:
throw FileFormatException(
uri, "legacy format: cannot open UCR key: " + OUString::number(e));
}
@@ -810,7 +816,9 @@ rtl::Reference< MapCursor > LegacyProvider::createRootCursor() const {
rtl::Reference< Entity > LegacyProvider::findEntity(OUString const & name)
const
{
- return readEntity(manager_, ucr_, ucr_, name.replace('.', '/'), true);
+ return ucr_.isValid()
+ ? readEntity(manager_, ucr_, ucr_, name.replace('.', '/'), true)
+ : rtl::Reference< Entity >();
}
LegacyProvider::~LegacyProvider() throw () {}