summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Fischer <af@apache.org>2013-05-17 09:44:46 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-22 11:34:39 +0100
commit485a5ff16ab355a6e51050539d94b5ceedde6021 (patch)
treeb0aefeae5934fb79104ff672211e7a5a9d2bc09e
parent52181e48798a9fdee6788f723d4ed0478ed40683 (diff)
Resolves: #i122315# Disable 'More Options' buttons when...
their commands are disabled (cherry picked from commit 10e1831ad2e9597c5197bafb6e03b098f8e81454) Conflicts: sfx2/inc/sfx2/sidebar/SidebarToolBox.hxx sfx2/source/sidebar/SidebarToolBox.cxx sfx2/source/sidebar/TitleBar.cxx Change-Id: Iff83e024bd58ce4a6f27a8cde66b287d3bf710a3 (cherry picked from commit 76ca8f7f178f5e9698d23ac0b1212922f2ddf39b)
-rw-r--r--include/sfx2/sidebar/SidebarToolBox.hxx9
-rw-r--r--sfx2/source/sidebar/Deck.cxx1
-rw-r--r--sfx2/source/sidebar/DeckLayouter.cxx4
-rw-r--r--sfx2/source/sidebar/FocusManager.cxx1
-rw-r--r--sfx2/source/sidebar/Panel.cxx13
-rw-r--r--sfx2/source/sidebar/Panel.hxx3
-rw-r--r--sfx2/source/sidebar/PanelTitleBar.cxx68
-rw-r--r--sfx2/source/sidebar/PanelTitleBar.hxx8
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx15
-rw-r--r--sfx2/source/sidebar/SidebarToolBox.cxx94
-rw-r--r--sfx2/source/sidebar/TitleBar.cxx2
-rw-r--r--sfx2/source/sidebar/TitleBar.hxx4
12 files changed, 164 insertions, 58 deletions
diff --git a/include/sfx2/sidebar/SidebarToolBox.hxx b/include/sfx2/sidebar/SidebarToolBox.hxx
index bb96a9ee69eb..b22bbc8e13fe 100644
--- a/include/sfx2/sidebar/SidebarToolBox.hxx
+++ b/include/sfx2/sidebar/SidebarToolBox.hxx
@@ -48,6 +48,8 @@ public:
Window* pParentWindow,
const ResId& rResId,
const cssu::Reference<css::frame::XFrame>& rxFrame);
+ SidebarToolBox (
+ Window* pParentWindow);
virtual ~SidebarToolBox (void);
void SetBorderWindow (const Window* pBorderWindow);
@@ -67,6 +69,11 @@ public:
sal_uInt16 GetItemIdForSubToolbarName (
const ::rtl::OUString& rsCOmmandName) const;
+ void SetController (
+ const sal_uInt16 nItemId,
+ const cssu::Reference<css::frame::XToolbarController>& rxController,
+ const ::rtl::OUString& rsCommandName);
+
private:
bool mbParentIsBorder;
Image maItemSeparator;
@@ -79,6 +86,7 @@ private:
};
typedef ::std::map<sal_uInt16, ItemDescriptor> ControllerContainer;
ControllerContainer maControllers;
+ bool mbAreHandlersRegistered;
DECL_LINK(DropDownClickHandler, ToolBox*);
DECL_LINK(ClickHandler, ToolBox*);
@@ -93,6 +101,7 @@ private:
const sal_Int32 nItemWidth = 0);
void UpdateIcons (
const cssu::Reference<css::frame::XFrame>& rxFrame);
+ void RegisterHandlers (void);
};
diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index 6534ec77eff9..0fed648f41a5 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -21,6 +21,7 @@
#include "DeckLayouter.hxx"
#include "DrawHelper.hxx"
#include "DeckTitleBar.hxx"
+#include "PanelTitleBar.hxx"
#include "Paint.hxx"
#include "Panel.hxx"
#include "ToolBoxBackground.hxx"
diff --git a/sfx2/source/sidebar/DeckLayouter.cxx b/sfx2/source/sidebar/DeckLayouter.cxx
index b04f83b633d4..8d7cb898c7c2 100644
--- a/sfx2/source/sidebar/DeckLayouter.cxx
+++ b/sfx2/source/sidebar/DeckLayouter.cxx
@@ -19,7 +19,7 @@
#include "DeckLayouter.hxx"
#include "sfx2/sidebar/Theme.hxx"
#include "Panel.hxx"
-#include "TitleBar.hxx"
+#include "PanelTitleBar.hxx"
#include "Deck.hxx"
#include <vcl/window.hxx>
@@ -212,7 +212,7 @@ sal_Int32 DeckLayouter::PlacePanels (
nY += nDeckSeparatorHeight;
// Place the title bar.
- TitleBar* pTitleBar = rPanel.GetTitleBar();
+ PanelTitleBar* pTitleBar = rPanel.GetTitleBar();
if (pTitleBar != NULL)
{
if (iItem->mbShowTitleBar)
diff --git a/sfx2/source/sidebar/FocusManager.cxx b/sfx2/source/sidebar/FocusManager.cxx
index 6ed64a50b68e..51d4c5e51b21 100644
--- a/sfx2/source/sidebar/FocusManager.cxx
+++ b/sfx2/source/sidebar/FocusManager.cxx
@@ -19,6 +19,7 @@
#include "FocusManager.hxx"
#include "Panel.hxx"
#include "DeckTitleBar.hxx"
+#include "PanelTitleBar.hxx"
#include "sfx2/sidebar/Tools.hxx"
#include "TitleBar.hxx"
#include <vcl/button.hxx>
diff --git a/sfx2/source/sidebar/Panel.cxx b/sfx2/source/sidebar/Panel.cxx
index 0840c4c5f805..3b81121bf223 100644
--- a/sfx2/source/sidebar/Panel.cxx
+++ b/sfx2/source/sidebar/Panel.cxx
@@ -82,17 +82,6 @@ Panel::~Panel (void)
-void Panel::SetShowMenuFunctor( const ::boost::function<void(void)>& rShowMenuFunctor )
-{
- if ( mpTitleBar.get() )
- {
- mpTitleBar->SetMenuAction( rShowMenuFunctor );
- }
-}
-
-
-
-
void Panel::Dispose (void)
{
mxPanelComponent = NULL;
@@ -123,7 +112,7 @@ void Panel::Dispose (void)
-TitleBar* Panel::GetTitleBar (void) const
+PanelTitleBar* Panel::GetTitleBar (void) const
{
return mpTitleBar.get();
}
diff --git a/sfx2/source/sidebar/Panel.hxx b/sfx2/source/sidebar/Panel.hxx
index 27c771a34d3f..cbf1781e184c 100644
--- a/sfx2/source/sidebar/Panel.hxx
+++ b/sfx2/source/sidebar/Panel.hxx
@@ -53,8 +53,7 @@ public:
void Dispose (void);
- void SetShowMenuFunctor( const ::boost::function<void(void)>& rShowMenuFunctor );
- TitleBar* GetTitleBar (void) const;
+ PanelTitleBar* GetTitleBar (void) const;
bool IsTitleBarOptional (void) const;
void SetUIElement (const cssu::Reference<css::ui::XUIElement>& rxElement);
cssu::Reference<css::ui::XSidebarPanel> GetPanelComponent (void) const;
diff --git a/sfx2/source/sidebar/PanelTitleBar.cxx b/sfx2/source/sidebar/PanelTitleBar.cxx
index 3446acac5b81..bf94ff40eb8a 100644
--- a/sfx2/source/sidebar/PanelTitleBar.cxx
+++ b/sfx2/source/sidebar/PanelTitleBar.cxx
@@ -23,15 +23,18 @@
#include "Paint.hxx"
#include "Panel.hxx"
#include "sfx2/sidebar/Theme.hxx"
-
+#include "sfx2/sidebar/ControllerFactory.hxx"
#include <tools/svborder.hxx>
#include <vcl/gradient.hxx>
#include <vcl/image.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
#ifdef DEBUG
#include "sfx2/sidebar/Tools.hxx"
#endif
+using namespace css;
+using namespace cssu;
namespace sfx2 { namespace sidebar {
@@ -48,7 +51,8 @@ PanelTitleBar::PanelTitleBar (
mbIsLeftButtonDown(false),
mpPanel(pPanel),
mnMenuItemIndex(1),
- maMenuAction()
+ mxFrame(),
+ msMoreOptionsCommand()
{
OSL_ASSERT(mpPanel != NULL);
@@ -73,23 +77,38 @@ PanelTitleBar::~PanelTitleBar (void)
-void PanelTitleBar::SetMenuAction ( const ::boost::function<void(void)>& rMenuAction )
+void PanelTitleBar::SetMoreOptionsCommand (
+ const ::rtl::OUString& rsCommandName,
+ const ::cssu::Reference<css::frame::XFrame>& rxFrame)
{
- if ( !maMenuAction && rMenuAction )
- {
- maToolBox.InsertItem(
- mnMenuItemIndex,
- Theme::GetImage(Theme::Image_PanelMenu));
- maToolBox.SetOutStyle(TOOLBOX_STYLE_FLAT);
- maToolBox.SetQuickHelpText(
- mnMenuItemIndex,
- String(SfxResId(SFX_STR_SIDEBAR_MORE_OPTIONS)));
- }
- else if ( maMenuAction && !rMenuAction )
+ if ( ! rsCommandName.equals(msMoreOptionsCommand))
{
- maToolBox.RemoveItem( maToolBox.GetItemPos( mnMenuItemIndex ) );
+ if (msMoreOptionsCommand.getLength() > 0)
+ maToolBox.RemoveItem(maToolBox.GetItemPos(mnMenuItemIndex));
+
+ msMoreOptionsCommand = rsCommandName;
+ mxFrame = rxFrame;
+
+ if (msMoreOptionsCommand.getLength() > 0)
+ {
+ maToolBox.InsertItem(
+ mnMenuItemIndex,
+ Theme::GetImage(Theme::Image_PanelMenu));
+ Reference<frame::XToolbarController> xController (
+ ControllerFactory::CreateToolBoxController(
+ &maToolBox,
+ mnMenuItemIndex,
+ msMoreOptionsCommand,
+ rxFrame,
+ VCLUnoHelper::GetInterface(&maToolBox),
+ 0));
+ maToolBox.SetController(mnMenuItemIndex, xController, msMoreOptionsCommand);
+ maToolBox.SetOutStyle(TOOLBOX_STYLE_FLAT);
+ maToolBox.SetQuickHelpText(
+ mnMenuItemIndex,
+ String(SfxResId(SFX_STR_SIDEBAR_MORE_OPTIONS)));
+ }
}
- maMenuAction = rMenuAction;
}
@@ -153,8 +172,21 @@ Color PanelTitleBar::GetTextColor (void)
void PanelTitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex)
{
if (nItemIndex == mnMenuItemIndex)
- if (maMenuAction)
- maMenuAction();
+ if (msMoreOptionsCommand.getLength() > 0)
+ {
+ try
+ {
+ const util::URL aURL (Tools::GetURL(msMoreOptionsCommand));
+ Reference<frame::XDispatch> xDispatch (Tools::GetDispatch(mxFrame, aURL));
+ if (xDispatch.is())
+ xDispatch->dispatch(aURL, Sequence<beans::PropertyValue>());
+ }
+ catch(Exception& rException)
+ {
+ OSL_TRACE("caught exception: %s",
+ OUStringToOString(rException.Message, RTL_TEXTENCODING_ASCII_US).getStr());
+ }
+ }
}
diff --git a/sfx2/source/sidebar/PanelTitleBar.hxx b/sfx2/source/sidebar/PanelTitleBar.hxx
index dff82a9661bb..f47f86e8c539 100644
--- a/sfx2/source/sidebar/PanelTitleBar.hxx
+++ b/sfx2/source/sidebar/PanelTitleBar.hxx
@@ -20,6 +20,7 @@
#include "TitleBar.hxx"
+#include <com/sun/star/frame/XFrame.hpp>
#include <boost/function.hpp>
@@ -37,7 +38,9 @@ public:
Panel* pPanel );
virtual ~PanelTitleBar (void);
- void SetMenuAction ( const ::boost::function<void(void)>& rMenuAction );
+ void SetMoreOptionsCommand (
+ const ::rtl::OUString& rsCommandName,
+ const ::cssu::Reference<css::frame::XFrame>& rxFrame);
virtual void DataChanged (const DataChangedEvent& rEvent);
virtual void MouseButtonDown (const MouseEvent& rMouseEvent);
@@ -54,7 +57,8 @@ private:
bool mbIsLeftButtonDown;
Panel* mpPanel;
const sal_uInt16 mnMenuItemIndex;
- ::boost::function<void(void)> maMenuAction;
+ cssu::Reference<css::frame::XFrame> mxFrame;
+ ::rtl::OUString msMoreOptionsCommand;
};
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 5f1b6acc85ba..d831cee05977 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -19,6 +19,7 @@
#include "Deck.hxx"
#include "DeckTitleBar.hxx"
#include "Panel.hxx"
+#include "PanelTitleBar.hxx"
#include "SidebarPanel.hxx"
#include "SidebarResource.hxx"
#include "TabBar.hxx"
@@ -578,11 +579,15 @@ void SidebarController::SwitchToDeck (
}
if (aNewPanels[nWriteIndex] != NULL)
{
- // Depending on the context we have to apply the show menu functor.
- aNewPanels[nWriteIndex]->SetShowMenuFunctor(
- rPanelContexDescriptor.msMenuCommand.getLength()>0
- ? ::boost::bind(&SidebarController::ShowDetailMenu,this,rPanelContexDescriptor.msMenuCommand)
- : ::boost::function<void(void)>() );
+ // Depending on the context we have to change the command
+ // for the "more options" dialog.
+ PanelTitleBar* pTitleBar = aNewPanels[nWriteIndex]->GetTitleBar();
+ if (pTitleBar != NULL)
+ {
+ pTitleBar->SetMoreOptionsCommand(
+ rPanelContexDescriptor.msMenuCommand,
+ mxFrame);
+ }
++nWriteIndex;
}
diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx
index d4aa7b6afe78..291b82f1db08 100644
--- a/sfx2/source/sidebar/SidebarToolBox.cxx
+++ b/sfx2/source/sidebar/SidebarToolBox.cxx
@@ -43,7 +43,9 @@ SidebarToolBox::SidebarToolBox (
const cssu::Reference<css::frame::XFrame>& rxFrame)
: ToolBox(pParentWindow, rResId),
mbParentIsBorder(false),
- maItemSeparator(Theme::GetImage(Theme::Image_ToolBoxItemSeparator))
+ maItemSeparator(Theme::GetImage(Theme::Image_ToolBoxItemSeparator)),
+ maControllers(),
+ mbAreHandlersRegistered(false)
{
SetBackground(Wallpaper());
SetPaintTransparent(true);
@@ -65,12 +67,7 @@ SidebarToolBox::SidebarToolBox (
SetSizePixel(CalcWindowSizePixel());
- SetDropdownClickHdl(LINK(this, SidebarToolBox, DropDownClickHandler));
- SetClickHdl(LINK(this, SidebarToolBox, ClickHandler));
- SetDoubleClickHdl(LINK(this, SidebarToolBox, DoubleClickHandler));
- SetSelectHdl(LINK(this, SidebarToolBox, SelectHandler));
- SetActivateHdl(LINK(this, SidebarToolBox, ActivateToolBox));
- SetDeactivateHdl(LINK(this, SidebarToolBox, DeactivateToolBox));
+ RegisterHandlers();
}
#ifdef DEBUG
@@ -81,6 +78,24 @@ SidebarToolBox::SidebarToolBox (
+SidebarToolBox::SidebarToolBox (Window* pParentWindow)
+ : ToolBox(pParentWindow, 0),
+ mbParentIsBorder(false),
+ maItemSeparator(Theme::GetImage(Theme::Image_ToolBoxItemSeparator)),
+ maControllers(),
+ mbAreHandlersRegistered(false)
+{
+ SetBackground(Wallpaper());
+ SetPaintTransparent(true);
+
+#ifdef DEBUG
+ SetText(A2S("SidebarToolBox"));
+#endif
+}
+
+
+
+
SidebarToolBox::~SidebarToolBox (void)
{
ControllerContainer aControllers;
@@ -94,13 +109,15 @@ SidebarToolBox::~SidebarToolBox (void)
xComponent->dispose();
}
- SetDropdownClickHdl(Link());
- SetClickHdl(Link());
- SetDoubleClickHdl(Link());
- SetSelectHdl(Link());
- SetActivateHdl(Link());
- SetDeactivateHdl(Link());
-
+ if (mbAreHandlersRegistered)
+ {
+ SetDropdownClickHdl(Link());
+ SetClickHdl(Link());
+ SetDoubleClickHdl(Link());
+ SetSelectHdl(Link());
+ SetActivateHdl(Link());
+ SetDeactivateHdl(Link());
+ }
}
@@ -261,6 +278,37 @@ Reference<frame::XToolbarController> SidebarToolBox::GetControllerForItemId (con
+void SidebarToolBox::SetController(
+ const sal_uInt16 nItemId,
+ const cssu::Reference<css::frame::XToolbarController>& rxController,
+ const ::rtl::OUString& rsCommandName)
+{
+ ItemDescriptor aDescriptor;
+ aDescriptor.mxController = rxController;
+ aDescriptor.maURL = sfx2::sidebar::Tools::GetURL(rsCommandName);
+ aDescriptor.msCurrentCommand = rsCommandName;
+
+ ControllerContainer::iterator iController (maControllers.find(nItemId));
+ if (iController != maControllers.end())
+ {
+ Reference<lang::XComponent> xComponent (iController->second.mxController, UNO_QUERY);
+ if (xComponent.is())
+ xComponent->dispose();
+
+ iController->second = aDescriptor;
+ }
+ else
+ {
+ maControllers[nItemId] = aDescriptor;
+ }
+
+ if (rxController.is())
+ RegisterHandlers();
+}
+
+
+
+
void SidebarToolBox::UpdateIcons (const Reference<frame::XFrame>& rxFrame)
{
for (ControllerContainer::iterator iController(maControllers.begin()), iEnd(maControllers.end());
@@ -296,6 +344,24 @@ sal_uInt16 SidebarToolBox::GetItemIdForSubToolbarName (const OUString& rsSubTool
+
+void SidebarToolBox::RegisterHandlers (void)
+{
+ if ( ! mbAreHandlersRegistered)
+ {
+ mbAreHandlersRegistered = true;
+ SetDropdownClickHdl(LINK(this, SidebarToolBox, DropDownClickHandler));
+ SetClickHdl(LINK(this, SidebarToolBox, ClickHandler));
+ SetDoubleClickHdl(LINK(this, SidebarToolBox, DoubleClickHandler));
+ SetSelectHdl(LINK(this, SidebarToolBox, SelectHandler));
+ SetActivateHdl(LINK(this, SidebarToolBox, ActivateToolBox));
+ SetDeactivateHdl(LINK(this, SidebarToolBox, DeactivateToolBox));
+ }
+}
+
+
+
+
IMPL_LINK(SidebarToolBox, DropDownClickHandler, ToolBox*, pToolBox)
{
if (pToolBox != NULL)
diff --git a/sfx2/source/sidebar/TitleBar.cxx b/sfx2/source/sidebar/TitleBar.cxx
index 2240006ca6c8..bab96310ba84 100644
--- a/sfx2/source/sidebar/TitleBar.cxx
+++ b/sfx2/source/sidebar/TitleBar.cxx
@@ -117,7 +117,7 @@ void TitleBar::setPosSizePixel (
// Place the toolbox.
const sal_Int32 nToolBoxWidth (maToolBox.GetItemPosRect(0).GetWidth());
- maToolBox.setPosSizePixel(nWidth-nToolBoxWidth,0,nToolBoxWidth,nHeight);
+ maToolBox.setPosSizePixel(nWidth-nToolBoxWidth,0, nToolBoxWidth,nHeight, WINDOW_POSSIZE_POSSIZE);
maToolBox.Show();
}
diff --git a/sfx2/source/sidebar/TitleBar.hxx b/sfx2/source/sidebar/TitleBar.hxx
index c16cfbc4c5e2..229d3b7edcc1 100644
--- a/sfx2/source/sidebar/TitleBar.hxx
+++ b/sfx2/source/sidebar/TitleBar.hxx
@@ -21,7 +21,7 @@
#include "Paint.hxx"
#include <vcl/window.hxx>
-#include <vcl/toolbox.hxx>
+#include "sfx2/sidebar/SidebarToolBox.hxx"
namespace sfx2 { namespace sidebar {
@@ -52,7 +52,7 @@ public:
const ToolBox& GetToolBox (void) const;
protected:
- ToolBox maToolBox;
+ SidebarToolBox maToolBox;
virtual Rectangle GetTitleArea (const Rectangle& rTitleBarBox) = 0;
virtual void PaintDecoration (const Rectangle& rTitleBarBox) = 0;