summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-05-10 12:28:42 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-05-11 09:21:03 +0200
commitb5303563b785115075b5f9b7b4abccd8f9d916e2 (patch)
tree60fedf68b2cfe33ca6649852a159173ba5adce02
parentd4e4c85d3cdf9faf678ea43e6a29e35bee0bc371 (diff)
SearchForAlreadyLoadedDoc does nothing useful
at least as far back as commit d32b3a714fe55892bdead03502c5a9b0e77fa61d Author: Mathias Bauer <mba@openoffice.org> Date: Sat Oct 31 00:36:06 2009 +0100 #i106421#: move svx/source/cui to cui Change-Id: Ic8284d722a6222d26fc33ef62be62435dde8e0bd Reviewed-on: https://gerrit.libreoffice.org/37462 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--cui/source/customize/acccfg.cxx140
-rw-r--r--cui/source/inc/acccfg.hxx1
2 files changed, 52 insertions, 89 deletions
diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx
index 15778e549fac..dfaf2004d173 100644
--- a/cui/source/customize/acccfg.cxx
+++ b/cui/source/customize/acccfg.cxx
@@ -1226,37 +1226,24 @@ IMPL_LINK_NOARG(SfxAcceleratorConfigPage, LoadHdl, sfx2::FileDialogHelper*, void
GetTabDialog()->EnterWait();
- uno::Reference<frame::XModel> xDoc;
uno::Reference<ui::XUIConfigurationManager> xCfgMgr;
uno::Reference<embed::XStorage> xRootStorage; // we must hold the root storage alive, if xCfgMgr is used!
try
{
- // first check if URL points to a document already loaded
- xDoc = SearchForAlreadyLoadedDoc(sCfgName);
- if (xDoc.is())
+ // don't forget to release the storage afterwards!
+ uno::Reference<lang::XSingleServiceFactory> xStorageFactory(embed::StorageFactory::create(m_xContext));
+ uno::Sequence<uno::Any> lArgs(2);
+ lArgs[0] <<= sCfgName;
+ lArgs[1] <<= css::embed::ElementModes::READ;
+
+ xRootStorage.set(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY_THROW);
+ uno::Reference<embed::XStorage> xUIConfig = xRootStorage->openStorageElement(FOLDERNAME_UICONFIG, embed::ElementModes::READ);
+ if (xUIConfig.is())
{
- // Get ui config manager. There should always be one at the model.
- uno::Reference<ui::XUIConfigurationManagerSupplier> xCfgSupplier(xDoc, uno::UNO_QUERY_THROW);
- xCfgMgr = xCfgSupplier->getUIConfigurationManager();
- }
- else
- {
- // URL doesn't point to a loaded document, try to access it as a single storage
- // don't forget to release the storage afterwards!
- uno::Reference<lang::XSingleServiceFactory> xStorageFactory(embed::StorageFactory::create(m_xContext));
- uno::Sequence<uno::Any> lArgs(2);
- lArgs[0] <<= sCfgName;
- lArgs[1] <<= css::embed::ElementModes::READ;
-
- xRootStorage.set(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY_THROW);
- uno::Reference<embed::XStorage> xUIConfig = xRootStorage->openStorageElement(FOLDERNAME_UICONFIG, embed::ElementModes::READ);
- if (xUIConfig.is())
- {
- uno::Reference<ui::XUIConfigurationManager2> xCfgMgr2 = ui::UIConfigurationManager::create(m_xContext);
- xCfgMgr2->setStorage(xUIConfig);
- xCfgMgr.set(xCfgMgr2, uno::UNO_QUERY_THROW);
- }
+ uno::Reference<ui::XUIConfigurationManager2> xCfgMgr2 = ui::UIConfigurationManager::create(m_xContext);
+ xCfgMgr2->setStorage(xUIConfig);
+ xCfgMgr.set(xCfgMgr2, uno::UNO_QUERY_THROW);
}
if (xCfgMgr.is())
@@ -1310,70 +1297,52 @@ IMPL_LINK_NOARG(SfxAcceleratorConfigPage, SaveHdl, sfx2::FileDialogHelper*, void
GetTabDialog()->EnterWait();
- uno::Reference<frame::XModel> xDoc;
- uno::Reference<ui::XUIConfigurationManager> xCfgMgr;
uno::Reference<embed::XStorage> xRootStorage;
try
{
- // first check if URL points to a document already loaded
- xDoc = SearchForAlreadyLoadedDoc(sCfgName);
- if (xDoc.is())
- {
- // get config manager, force creation if there was none before
- uno::Reference<ui::XUIConfigurationManagerSupplier> xCfgSupplier(xDoc, uno::UNO_QUERY_THROW);
- xCfgMgr = xCfgSupplier->getUIConfigurationManager();
- }
- else
- {
- // URL doesn't point to a loaded document, try to access it as a single storage
- uno::Reference<lang::XSingleServiceFactory> xStorageFactory(embed::StorageFactory::create(m_xContext));
- uno::Sequence<uno::Any> lArgs(2);
- lArgs[0] <<= sCfgName;
- lArgs[1] <<= embed::ElementModes::WRITE;
-
- xRootStorage.set( xStorageFactory->createInstanceWithArguments(lArgs),
- uno::UNO_QUERY_THROW);
-
- uno::Reference<embed::XStorage> xUIConfig(
- xRootStorage->openStorageElement(FOLDERNAME_UICONFIG, embed::ElementModes::WRITE),
- uno::UNO_QUERY_THROW);
- uno::Reference<beans::XPropertySet> xUIConfigProps(
- xUIConfig,
- uno::UNO_QUERY_THROW);
-
- // set the correct media type if the storage was new created
- OUString sMediaType;
- xUIConfigProps->getPropertyValue(MEDIATYPE_PROPNAME) >>= sMediaType;
- if (sMediaType.isEmpty())
- xUIConfigProps->setPropertyValue(MEDIATYPE_PROPNAME, uno::Any(OUString("application/vnd.sun.xml.ui.configuration")));
+ uno::Reference<lang::XSingleServiceFactory> xStorageFactory(embed::StorageFactory::create(m_xContext));
+ uno::Sequence<uno::Any> lArgs(2);
+ lArgs[0] <<= sCfgName;
+ lArgs[1] <<= embed::ElementModes::WRITE;
+
+ xRootStorage.set( xStorageFactory->createInstanceWithArguments(lArgs),
+ uno::UNO_QUERY_THROW);
+
+ uno::Reference<embed::XStorage> xUIConfig(
+ xRootStorage->openStorageElement(FOLDERNAME_UICONFIG, embed::ElementModes::WRITE),
+ uno::UNO_QUERY_THROW);
+ uno::Reference<beans::XPropertySet> xUIConfigProps(
+ xUIConfig,
+ uno::UNO_QUERY_THROW);
+
+ // set the correct media type if the storage was new created
+ OUString sMediaType;
+ xUIConfigProps->getPropertyValue(MEDIATYPE_PROPNAME) >>= sMediaType;
+ if (sMediaType.isEmpty())
+ xUIConfigProps->setPropertyValue(MEDIATYPE_PROPNAME, uno::Any(OUString("application/vnd.sun.xml.ui.configuration")));
+
+ uno::Reference<ui::XUIConfigurationManager2> xCfgMgr = ui::UIConfigurationManager::create(m_xContext);
+ xCfgMgr->setStorage(xUIConfig);
+
+ // get the target configuration access and update with all shortcuts
+ // which are set currently at the UI!
+ // Don't copy the m_xAct content to it... because m_xAct will be updated
+ // from the UI on pressing the button "OK" only. And inbetween it's not up to date!
+ uno::Reference<ui::XAcceleratorConfiguration> xTargetAccMgr(xCfgMgr->getShortCutManager(), uno::UNO_QUERY_THROW);
+ Apply(xTargetAccMgr);
+
+ // commit (order is important!)
+ uno::Reference<ui::XUIConfigurationPersistence> xCommit1(xTargetAccMgr, uno::UNO_QUERY_THROW);
+ uno::Reference<ui::XUIConfigurationPersistence> xCommit2(xCfgMgr , uno::UNO_QUERY_THROW);
+ xCommit1->store();
+ xCommit2->store();
- uno::Reference<ui::XUIConfigurationManager2> xCfgMgr2 = ui::UIConfigurationManager::create(m_xContext);
- xCfgMgr2->setStorage(xUIConfig);
- xCfgMgr.set( xCfgMgr2, uno::UNO_QUERY_THROW );
- }
-
- if (xCfgMgr.is())
+ if (xRootStorage.is())
{
- // get the target configuration access and update with all shortcuts
- // which are set currently at the UI!
- // Don't copy the m_xAct content to it... because m_xAct will be updated
- // from the UI on pressing the button "OK" only. And inbetween it's not up to date!
- uno::Reference<ui::XAcceleratorConfiguration> xTargetAccMgr(xCfgMgr->getShortCutManager(), uno::UNO_QUERY_THROW);
- Apply(xTargetAccMgr);
-
- // commit (order is important!)
- uno::Reference<ui::XUIConfigurationPersistence> xCommit1(xTargetAccMgr, uno::UNO_QUERY_THROW);
- uno::Reference<ui::XUIConfigurationPersistence> xCommit2(xCfgMgr , uno::UNO_QUERY_THROW);
- xCommit1->store();
- xCommit2->store();
-
- if (xRootStorage.is())
- {
- // Commit root storage
- uno::Reference<embed::XTransactedObject> xCommit3(xRootStorage, uno::UNO_QUERY_THROW);
- xCommit3->commit();
- }
+ // Commit root storage
+ uno::Reference<embed::XTransactedObject> xCommit3(xRootStorage, uno::UNO_QUERY_THROW);
+ xCommit3->commit();
}
if (xRootStorage.is())
@@ -1535,9 +1504,4 @@ OUString SfxAcceleratorConfigPage::GetLabel4Command(const OUString& sCommand)
return sCommand;
}
-uno::Reference<frame::XModel> SfxAcceleratorConfigPage::SearchForAlreadyLoadedDoc(const OUString& /*sName*/)
-{
- return uno::Reference<frame::XModel>();
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/inc/acccfg.hxx b/cui/source/inc/acccfg.hxx
index d59cdc06332c..3fb2fd68cb62 100644
--- a/cui/source/inc/acccfg.hxx
+++ b/cui/source/inc/acccfg.hxx
@@ -157,7 +157,6 @@ private:
OUString GetLabel4Command(const OUString& rCommand);
void InitAccCfg();
sal_uLong MapKeyCodeToPos( const vcl::KeyCode &rCode ) const;
- static css::uno::Reference< css::frame::XModel > SearchForAlreadyLoadedDoc(const OUString& sName);
void StartFileDialog( WinBits nBits, const OUString& rTitle );
void Init(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& pAccMgr);