Any numbers that show that these complications of the code are worth it?
On 02/21/2017 12:54 AM, Maxim Monastirsky wrote:
commit 8f381b47f5493151f06d77453ff5153cd075a68b
Author: Maxim Monastirsky
Date: Mon Feb 20 13:01:46 2017 +0200
Try to cut some costs
Change-Id: I0f541a020232960541bccdf970c042cf3303671e
diff --git a/vcl/source/helper/commandinfoprovider.cxx
b/vcl/source/helper/commandinfoprovider.cxx
index dad5b58..d95ea55 100644
--- a/vcl/source/helper/commandinfoprovider.cxx
+++ b/vcl/source/helper/commandinfoprovider.cxx
@@ -22,6 +22,7 @@
#include
#include
#include
+#include
#include
#include
@@ -37,6 +38,48 @@ using namespace css::uno;
namespace vcl { namespace CommandInfoProvider {
+Reference const GetCommandDescription()
+{
+static WeakReference xWeakRef;
+css::uno::Reference xRef(xWeakRef);
+
+if (!xRef.is())
+{
+xRef =
frame::theUICommandDescription::get(comphelper::getProcessComponentContext());
+xWeakRef = xRef;
+}
+
+return xRef;
+}
+
+Reference const
GetModuleConfigurationSupplier()
+{
+static WeakReference xWeakRef;
+css::uno::Reference
xRef(xWeakRef);
+
+if (!xRef.is())
+{
+xRef =
ui::theModuleUIConfigurationManagerSupplier::get(comphelper::getProcessComponentContext());
+xWeakRef = xRef;
+}
+
+return xRef;
+}
+
+Reference const
GetGlobalAcceleratorConfiguration()
+{
+static WeakReference xWeakRef;
+css::uno::Reference xRef(xWeakRef);
+
+if (!xRef.is())
+{
+xRef =
ui::GlobalAcceleratorConfiguration::create(comphelper::getProcessComponentContext());
+xWeakRef = xRef;
+}
+
+return xRef;
+}
+
Reference const GetDocumentAcceleratorConfiguration(const
Reference& rxFrame)
{
Reference xController = rxFrame->getController();
@@ -49,8 +92,7 @@ Reference const
GetDocumentAcceleratorConfigurati
if (xSupplier.is())
{
Reference xConfigurationManager(
-xSupplier->getUIConfigurationManager(),
-UNO_QUERY);
+xSupplier->getUIConfigurationManager());
if (xConfigurationManager.is())
{
return xConfigurationManager->getShortCutManager();
@@ -66,7 +108,7 @@ Reference const
GetModuleAcceleratorConfiguration
css::uno::Reference
curModuleAcceleratorConfiguration;
try
{
-Reference xSupplier =
ui::theModuleUIConfigurationManagerSupplier::get(comphelper::getProcessComponentContext());
+Reference
xSupplier(GetModuleConfigurationSupplier());
Reference xManager (
xSupplier->getUIConfigurationManager(GetModuleIdentifier(rxFrame)));
if (xManager.is())
@@ -80,13 +122,6 @@ Reference const
GetModuleAcceleratorConfiguration
return curModuleAcceleratorConfiguration;
}
-Reference const
GetGlobalAcceleratorConfiguration()
-{
-// Get the global accelerator configuration.
-return
ui::GlobalAcceleratorConfiguration::create(comphelper::getProcessComponentContext());
-
-}
-
vcl::KeyCode AWTKey2VCLKey(const awt::KeyEvent& aAWTKey)
{
bool bShift = ((aAWTKey.Modifiers & awt::KeyModifier::SHIFT) ==
awt::KeyModifier::SHIFT );
@@ -132,7 +167,7 @@ bool ResourceHasKey(const OUString& rsResourceName, const
OUString& rsCommandNam
{
if (!rsModuleName.isEmpty())
{
-Reference xNameAccess =
frame::theUICommandDescription::get(comphelper::getProcessComponentContext());
+Reference
xNameAccess(GetCommandDescription());
Reference xUICommandLabels;
if (xNameAccess->getByName(rsModuleName) >>= xUICommandLabels)
{
@@ -159,7 +194,7 @@ Sequence GetCommandProperties(const
OUString& rsCommandNam
{
if (!rsModuleName.isEmpty())
{
-Reference xNameAccess =
frame::theUICommandDescription::get(comphelper::getProcessComponentContext());
+Reference
xNameAccess(GetCommandDescription());
Reference xUICommandLabels;
if (xNameAccess->getByName(rsModuleName) >>= xUICommandLabels)
xUICommandLabels->getByName(rsCommandName) >>= aProperties;
@@ -285,7 +320,7 @@ BitmapEx GetBitmapForCommand(const OUString& rsCommandName,
Reference xSupplier(xModel,
UNO_QUERY);
if (xSupplier.is())
{
-Reference
xDocUICfgMgr(xSupplier->getUIConfigurationManager(), UNO_QUERY);
+Reference
xDocUICfgMgr(xSupplier->getUIConfigurationManager());
Reference
xDocImgMgr(xDocUICfgMgr->getImageManager(), UNO_QUERY);
Sequence< Reference > aGraphicSeq;
@@ -305,7 +340,7 @@ BitmapEx GetBitmapForCommand(const OUString& rsCommandName,
}
try {
-Reference
xModuleCfgMgrSupplier(ui::theModuleUIConfigurationManagerSupplier::get(comphelper::getProcessComponentContext()));
+Reference
xModuleCfgMgrSupplier(GetModuleConf