diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-07-09 19:48:21 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-07-09 19:48:21 +0200 |
commit | 87bad231d6f81c611ba145aea483a568623ca42e (patch) | |
tree | 676d7455a8ee7245c2ead4660aa0341b15f4aa70 /unoidl | |
parent | 59db0c242a7c97bd40b1cc33dd37f34fcefa5019 (diff) |
fdo#65589: Treat legacy types.rdb w/o /UCR key as empty
...as they are encountered in the wild.
Change-Id: Iae46d3b4b4aca18a09680caabc0e343f8a534989
Diffstat (limited to 'unoidl')
-rw-r--r-- | unoidl/source/legacyprovider.cxx | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx index e78dfe5c8d9c..b92302d40ab5 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 () {} |