Kaydet (Commit) db0e131d authored tarafından Andreas Schlüns's avatar Andreas Schlüns

#118074# handle non existing accelerator configs gracefully

üst 82e69e95
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: documentacceleratorconfiguration.cxx,v $ * $RCSfile: documentacceleratorconfiguration.cxx,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: rt $ $Date: 2004-09-20 10:05:46 $ * last change: $Author: as $ $Date: 2004-10-14 09:26:21 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -150,11 +150,6 @@ void SAL_CALL DocumentAcceleratorConfiguration::initialize(const css::uno::Seque ...@@ -150,11 +150,6 @@ void SAL_CALL DocumentAcceleratorConfiguration::initialize(const css::uno::Seque
::rtl::OUString::createFromAscii("DocumentRoot"), ::rtl::OUString::createFromAscii("DocumentRoot"),
css::uno::Reference< css::embed::XStorage >()); css::uno::Reference< css::embed::XStorage >());
if (!m_xDocumentRoot.is())
throw css::uno::RuntimeException(
::rtl::OUString::createFromAscii("The document dependend accelerator configuration was initialized with an invalid roo storage!"),
static_cast< ::cppu::OWeakObject* >(this));
aWriteLock.unlock(); aWriteLock.unlock();
// <- SAFE ---------------------------------- // <- SAFE ----------------------------------
...@@ -170,24 +165,38 @@ void DocumentAcceleratorConfiguration::impl_ts_fillCache() ...@@ -170,24 +165,38 @@ void DocumentAcceleratorConfiguration::impl_ts_fillCache()
aReadLock.unlock(); aReadLock.unlock();
// <- SAFE ---------------------------------- // <- SAFE ----------------------------------
// Sometimes we must live without a document root.
// E.g. if the document is readonly ...
if (!xDocumentRoot.is())
return;
// get current office locale ... but dont cache it. // get current office locale ... but dont cache it.
// Otherwise we must be listener on the configuration layer // Otherwise we must be listener on the configuration layer
// which seems to superflous for this small implementation .-) // which seems to superflous for this small implementation .-)
::comphelper::Locale aLocale = impl_ts_getLocale(); ::comphelper::Locale aLocale = impl_ts_getLocale();
// Note: The used preset class is threadsafe by itself ... and live if we live! // May be the current document does not contain any
// We do not need any mutex here. // accelerator config? Handle it gracefully :-)
try
// open the folder, where the configuration exists {
m_aPresetHandler.connectToResource( // Note: The used preset class is threadsafe by itself ... and live if we live!
PresetHandler::E_DOCUMENT, // We do not need any mutex here.
PresetHandler::RESOURCETYPE_ACCELERATOR(),
::rtl::OUString(), // open the folder, where the configuration exists
xDocumentRoot, m_aPresetHandler.connectToResource(
aLocale); PresetHandler::E_DOCUMENT,
PresetHandler::RESOURCETYPE_ACCELERATOR(),
AcceleratorConfiguration::reload(); ::rtl::OUString(),
m_aPresetHandler.addStorageListener(this); xDocumentRoot,
aLocale);
AcceleratorConfiguration::reload();
m_aPresetHandler.addStorageListener(this);
}
catch(const css::uno::RuntimeException& exRun)
{ throw exRun; }
catch(const css::uno::Exception&)
{}
} }
} // namespace framework } // namespace framework
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: globalacceleratorconfiguration.cxx,v $ * $RCSfile: globalacceleratorconfiguration.cxx,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: rt $ $Date: 2004-09-20 10:05:55 $ * last change: $Author: as $ $Date: 2004-10-14 09:26:21 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -159,25 +159,33 @@ void GlobalAcceleratorConfiguration::impl_ts_fillCache() ...@@ -159,25 +159,33 @@ void GlobalAcceleratorConfiguration::impl_ts_fillCache()
// which seems to superflous for this small implementation .-) // which seems to superflous for this small implementation .-)
::comphelper::Locale aLocale = impl_ts_getLocale(); ::comphelper::Locale aLocale = impl_ts_getLocale();
// Note: The used preset class is threadsafe by itself ... and live if we live! // May be there exists no accelerator config? Handle it gracefully :-)
// We do not need any mutex here. try
{
// open the folder, where the configuration exists // Note: The used preset class is threadsafe by itself ... and live if we live!
m_aPresetHandler.connectToResource( // We do not need any mutex here.
PresetHandler::E_GLOBAL,
PresetHandler::RESOURCETYPE_ACCELERATOR(), // open the folder, where the configuration exists
::rtl::OUString(), m_aPresetHandler.connectToResource(
css::uno::Reference< css::embed::XStorage >(), PresetHandler::E_GLOBAL,
aLocale); PresetHandler::RESOURCETYPE_ACCELERATOR(),
::rtl::OUString(),
// check if the user already has a current configuration css::uno::Reference< css::embed::XStorage >(),
// if not - se the default preset as new current one. aLocale);
// means: copy "share/default.xml" => "user/current.xml"
if (!m_aPresetHandler.existsTarget(PresetHandler::TARGET_CURRENT())) // check if the user already has a current configuration
m_aPresetHandler.copyPresetToTarget(PresetHandler::PRESET_DEFAULT(), PresetHandler::TARGET_CURRENT()); // if not - se the default preset as new current one.
// means: copy "share/default.xml" => "user/current.xml"
AcceleratorConfiguration::reload(); if (!m_aPresetHandler.existsTarget(PresetHandler::TARGET_CURRENT()))
m_aPresetHandler.addStorageListener(this); m_aPresetHandler.copyPresetToTarget(PresetHandler::PRESET_DEFAULT(), PresetHandler::TARGET_CURRENT());
AcceleratorConfiguration::reload();
m_aPresetHandler.addStorageListener(this);
}
catch(const css::uno::RuntimeException& exRun)
{ throw exRun; }
catch(const css::uno::Exception&)
{}
} }
} // namespace framework } // namespace framework
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: moduleacceleratorconfiguration.cxx,v $ * $RCSfile: moduleacceleratorconfiguration.cxx,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: rt $ $Date: 2004-09-20 10:06:24 $ * last change: $Author: as $ $Date: 2004-10-14 09:26:22 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -189,25 +189,34 @@ void ModuleAcceleratorConfiguration::impl_ts_fillCache() ...@@ -189,25 +189,34 @@ void ModuleAcceleratorConfiguration::impl_ts_fillCache()
// which seems to superflous for this small implementation .-) // which seems to superflous for this small implementation .-)
::comphelper::Locale aLocale = impl_ts_getLocale(); ::comphelper::Locale aLocale = impl_ts_getLocale();
// Note: The used preset class is threadsafe by itself ... and live if we live! // May be the current app module does not have any
// We do not need any mutex here. // accelerator config? Handle it gracefully :-)
try
// open the folder, where the configuration exists {
m_aPresetHandler.connectToResource( // Note: The used preset class is threadsafe by itself ... and live if we live!
PresetHandler::E_MODULES, // We do not need any mutex here.
PresetHandler::RESOURCETYPE_ACCELERATOR(),
sModule, // open the folder, where the configuration exists
css::uno::Reference< css::embed::XStorage >(), m_aPresetHandler.connectToResource(
aLocale); PresetHandler::E_MODULES,
PresetHandler::RESOURCETYPE_ACCELERATOR(),
// check if the user already has a current configuration sModule,
// if not - se the default preset as new current one. css::uno::Reference< css::embed::XStorage >(),
// means: copy "share/default.xml" => "user/current.xml" aLocale);
if (!m_aPresetHandler.existsTarget(PresetHandler::TARGET_CURRENT()))
m_aPresetHandler.copyPresetToTarget(PresetHandler::PRESET_DEFAULT(), PresetHandler::TARGET_CURRENT()); // check if the user already has a current configuration
// if not - se the default preset as new current one.
AcceleratorConfiguration::reload(); // means: copy "share/default.xml" => "user/current.xml"
m_aPresetHandler.addStorageListener(this); if (!m_aPresetHandler.existsTarget(PresetHandler::TARGET_CURRENT()))
m_aPresetHandler.copyPresetToTarget(PresetHandler::PRESET_DEFAULT(), PresetHandler::TARGET_CURRENT());
AcceleratorConfiguration::reload();
m_aPresetHandler.addStorageListener(this);
}
catch(const css::uno::RuntimeException& exRun)
{ throw exRun; }
catch(const css::uno::Exception&)
{}
} }
} // namespace framework } // namespace framework
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