summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRohan Kumar <rohankanojia420@gmail.com>2017-01-24 21:18:00 +0530
committerMaxim Monastirsky <momonasmon@gmail.com>2017-02-21 01:39:01 +0200
commit33c51e8002f58847ba43bc111dabc49278e36daf (patch)
treea1e276b24a26d4fe594b08dd47dfdaeda31cd020 /include
parente25bf8505cfaa3599c2e78a7c56729280f27373e (diff)
tdf#95844 Refactor CommandInfoProvider
Instead of a singleton, CommandInfoProvider should just be a set of static methods. Change-Id: I16d4406e361a72f013d78f18d6bd0ae20c0cc5e9
Diffstat (limited to 'include')
-rw-r--r--include/vcl/commandinfoprovider.hxx72
-rw-r--r--include/vcl/vclstatuslistener.hxx6
2 files changed, 33 insertions, 45 deletions
diff --git a/include/vcl/commandinfoprovider.hxx b/include/vcl/commandinfoprovider.hxx
index 0a8e53e5ef7b..2a3eaea347ad 100644
--- a/include/vcl/commandinfoprovider.hxx
+++ b/include/vcl/commandinfoprovider.hxx
@@ -27,6 +27,9 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
+using namespace css;
+using namespace css::uno;
+
namespace vcl {
@@ -36,16 +39,8 @@ namespace vcl {
class VCL_DLLPUBLIC CommandInfoProvider
{
public:
- /** Return the singleton instance.
-
- It caches some objects for the last XFrame object given to
- GetLabelForCommand. These objects are release and created new
- when that method is called with a different XFrame from the
- last call.
-
- Lifetime control should work but could be more elegant.
- */
- static CommandInfoProvider& Instance();
+ CommandInfoProvider();
+ ~CommandInfoProvider();
/** Return a label for the given command.
@param rsCommandName
@@ -55,15 +50,15 @@ public:
@return
The command labe.
*/
- OUString GetLabelForCommand (
+ static OUString GetLabelForCommand (
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
- OUString GetMenuLabelForCommand (
+ static OUString GetMenuLabelForCommand (
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
- OUString GetPopupLabelForCommand (
+ static OUString GetPopupLabelForCommand (
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
@@ -76,67 +71,54 @@ public:
The returned label contains the keyboard accelerator, if
one is defined and bIncludeShortcut is true.
*/
- OUString GetTooltipForCommand (
+ static OUString GetTooltipForCommand (
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
/** Returns the shortcut for a command in human-readable form */
- OUString GetCommandShortcut (const OUString& rCommandName,
+ static OUString GetCommandShortcut (const OUString& rCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
- OUString GetRealCommandForCommand( const OUString& rCommandName,
+ static OUString GetRealCommandForCommand( const OUString& rCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame );
- OUString GetCommandPropertyFromModule( const OUString& rCommandName, const OUString& rModuleName );
+ static OUString GetCommandPropertyFromModule( const OUString& rCommandName, const OUString& rModuleName );
- BitmapEx GetBitmapForCommand(
+ static BitmapEx GetBitmapForCommand(
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame,
vcl::ImageType eImageType = vcl::ImageType::Small);
- Image GetImageForCommand(
+ static Image GetImageForCommand(
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame,
vcl::ImageType eImageType = vcl::ImageType::Small);
- sal_Int32 GetPropertiesForCommand(
+ static sal_Int32 GetPropertiesForCommand(
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
- bool IsRotated(const OUString& rsCommandName);
- bool IsMirrored(const OUString& rsCommandName);
+ static bool IsRotated(const OUString& rsCommandName,const Reference<frame::XFrame>& rxFrame);
+ static bool IsMirrored(const OUString& rsCommandName, const Reference<frame::XFrame>& rxFrame);
/** Returns whether the command is experimental. */
- bool IsExperimental(
+ static bool IsExperimental(
const OUString& rsCommandName,
const OUString& rModuleName);
/** Do not call. Should be part of a local and hidden interface.
*/
- void SetFrame (const css::uno::Reference<css::frame::XFrame>& rxFrame);
-
- void dispose();
+ static void SetFrame (const css::uno::Reference<css::frame::XFrame>& rxFrame);
private:
- css::uno::Reference<css::uno::XComponentContext> mxContext;
- css::uno::Reference<css::frame::XFrame> mxCachedDataFrame;
- css::uno::Reference<css::ui::XAcceleratorConfiguration> mxCachedDocumentAcceleratorConfiguration;
- css::uno::Reference<css::ui::XAcceleratorConfiguration> mxCachedModuleAcceleratorConfiguration;
- css::uno::Reference<css::ui::XAcceleratorConfiguration> mxCachedGlobalAcceleratorConfiguration;
- OUString msCachedModuleIdentifier;
- css::uno::Reference<css::lang::XComponent> mxFrameListener;
-
- CommandInfoProvider();
- ~CommandInfoProvider();
-
- css::uno::Reference<css::ui::XAcceleratorConfiguration> const & GetDocumentAcceleratorConfiguration();
- css::uno::Reference<css::ui::XAcceleratorConfiguration> const & GetModuleAcceleratorConfiguration();
- css::uno::Reference<css::ui::XAcceleratorConfiguration> const & GetGlobalAcceleratorConfiguration();
- OUString const & GetModuleIdentifier();
- css::uno::Sequence<css::beans::PropertyValue> GetCommandProperties (
- const OUString& rsCommandName);
- OUString GetCommandProperty(const OUString& rsProperty, const OUString& rsCommandName);
- bool ResourceHasKey(const OUString& rsResourceName, const OUString& rsCommandName);
+ static css::uno::Reference<css::ui::XAcceleratorConfiguration> const GetDocumentAcceleratorConfiguration(const Reference<frame::XFrame>& rxFrame);
+ static css::uno::Reference<css::ui::XAcceleratorConfiguration> const GetModuleAcceleratorConfiguration(const Reference<frame::XFrame>& rxFrame);
+ static css::uno::Reference<css::ui::XAcceleratorConfiguration> const GetGlobalAcceleratorConfiguration();
+ static OUString const GetModuleIdentifier(const Reference<frame::XFrame>& rxFrame);
+ static css::uno::Sequence<css::beans::PropertyValue> GetCommandProperties (
+ const OUString& rsCommandName, const Reference<frame::XFrame>& rxFrame);
+ static OUString GetCommandProperty(const OUString& rsProperty, const OUString& rsCommandName,const Reference<frame::XFrame>& rxFrame);
+ static bool ResourceHasKey(const OUString& rsResourceName, const OUString& rsCommandName, const Reference<frame::XFrame>& rxFrame);
static OUString RetrieveShortcutsFromConfiguration(
const css::uno::Reference<css::ui::XAcceleratorConfiguration>& rxConfiguration,
const OUString& rsCommandName);
diff --git a/include/vcl/vclstatuslistener.hxx b/include/vcl/vclstatuslistener.hxx
index ae461f8d9cb3..c18d2acbed14 100644
--- a/include/vcl/vclstatuslistener.hxx
+++ b/include/vcl/vclstatuslistener.hxx
@@ -32,12 +32,15 @@ private:
/** Dispatcher. Need to keep a reference to it as long as this StatusListener exists. */
css::uno::Reference<css::frame::XDispatch> mxDispatch;
css::util::URL maCommandURL;
+ css::uno::Reference<css::frame::XFrame> mxFrame;
public:
void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& rEvent) override;
void SAL_CALL disposing(const css::lang::EventObject& /*Source*/) override;
+ const css::uno::Reference<css::frame::XFrame>& getFrame() { return mxFrame; }
+
void dispose();
};
@@ -52,6 +55,8 @@ VclStatusListener<T>::VclStatusListener(T* widget, const rtl::OUString& aCommand
if (!xFrame.is())
xFrame = css::uno::Reference<css::frame::XFrame>(xDesktop, css::uno::UNO_QUERY);
+ mxFrame = xFrame;
+
css::uno::Reference<css::frame::XDispatchProvider> xDispatchProvider(xFrame, css::uno::UNO_QUERY);
if (!xDispatchProvider.is())
return;
@@ -86,6 +91,7 @@ void VclStatusListener<T>::dispose()
mxDispatch->removeStatusListener(this, maCommandURL);
mxDispatch.clear();
}
+ mxFrame.clear();
mWidget.clear();
}