Author: af
Date: Fri May 17 09:44:46 2013
New Revision: 1483715
URL: http://svn.apache.org/r1483715
Log:
122315: Disable 'More Options' buttons when their commands are disabled.
Modified:
openoffice/trunk/main/sfx2/inc/sfx2/sidebar/SidebarToolBox.hxx
openoffice/trunk/main/sfx2/source/sidebar/Deck.cxx
openoffice/trunk/main/sfx2/source/sidebar/DeckLayouter.cxx
openoffice/trunk/main/sfx2/source/sidebar/FocusManager.cxx
openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx
openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx
openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.cxx
openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.hxx
openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx
openoffice/trunk/main/sfx2/source/sidebar/SidebarToolBox.cxx
openoffice/trunk/main/sfx2/source/sidebar/TitleBar.cxx
openoffice/trunk/main/sfx2/source/sidebar/TitleBar.hxx
Modified: openoffice/trunk/main/sfx2/inc/sfx2/sidebar/SidebarToolBox.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/inc/sfx2/sidebar/SidebarToolBox.hxx?rev=1483715&r1=1483714&r2=1483715&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/inc/sfx2/sidebar/SidebarToolBox.hxx (original)
+++ openoffice/trunk/main/sfx2/inc/sfx2/sidebar/SidebarToolBox.hxx Fri May 17
09:44:46 2013
@@ -52,6 +52,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);
@@ -71,6 +73,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;
@@ -83,6 +90,7 @@ private:
};
typedef ::std::map<sal_uInt16, ItemDescriptor> ControllerContainer;
ControllerContainer maControllers;
+ bool mbAreHandlersRegistered;
DECL_LINK(DropDownClickHandler, ToolBox*);
DECL_LINK(ClickHandler, ToolBox*);
@@ -97,6 +105,7 @@ private:
const sal_Int32 nItemWidth = 0);
void UpdateIcons (
const cssu::Reference<css::frame::XFrame>& rxFrame);
+ void RegisterHandlers (void);
};
Modified: openoffice/trunk/main/sfx2/source/sidebar/Deck.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/Deck.cxx?rev=1483715&r1=1483714&r2=1483715&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/Deck.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/Deck.cxx Fri May 17 09:44:46 2013
@@ -26,6 +26,7 @@
#include "DeckLayouter.hxx"
#include "DrawHelper.hxx"
#include "DeckTitleBar.hxx"
+#include "PanelTitleBar.hxx"
#include "Paint.hxx"
#include "Panel.hxx"
#include "ToolBoxBackground.hxx"
Modified: openoffice/trunk/main/sfx2/source/sidebar/DeckLayouter.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/DeckLayouter.cxx?rev=1483715&r1=1483714&r2=1483715&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/DeckLayouter.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/DeckLayouter.cxx Fri May 17
09:44:46 2013
@@ -24,7 +24,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>
@@ -222,7 +222,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)
Modified: openoffice/trunk/main/sfx2/source/sidebar/FocusManager.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/FocusManager.cxx?rev=1483715&r1=1483714&r2=1483715&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/FocusManager.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/FocusManager.cxx Fri May 17
09:44:46 2013
@@ -24,6 +24,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>
Modified: openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx?rev=1483715&r1=1483714&r2=1483715&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx Fri May 17 09:44:46 2013
@@ -87,17 +87,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;
@@ -128,7 +117,7 @@ void Panel::Dispose (void)
-TitleBar* Panel::GetTitleBar (void) const
+PanelTitleBar* Panel::GetTitleBar (void) const
{
return mpTitleBar.get();
}
Modified: openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx?rev=1483715&r1=1483714&r2=1483715&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx Fri May 17 09:44:46 2013
@@ -57,8 +57,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;
Modified: openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.cxx?rev=1483715&r1=1483714&r2=1483715&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.cxx Fri May 17
09:44:46 2013
@@ -28,15 +28,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 {
@@ -53,7 +56,8 @@ PanelTitleBar::PanelTitleBar (
mbIsLeftButtonDown(false),
mpPanel(pPanel),
mnMenuItemIndex(1),
- maMenuAction()
+ mxFrame(),
+ msMoreOptionsCommand()
{
OSL_ASSERT(mpPanel != NULL);
@@ -78,23 +82,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;
}
@@ -158,8 +177,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());
+ }
+ }
}
Modified: openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.hxx?rev=1483715&r1=1483714&r2=1483715&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.hxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.hxx Fri May 17
09:44:46 2013
@@ -24,6 +24,7 @@
#include "TitleBar.hxx"
+#include <com/sun/star/frame/XFrame.hpp>
#include <boost/function.hpp>
@@ -41,7 +42,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);
@@ -58,7 +61,8 @@ private:
bool mbIsLeftButtonDown;
Panel* mpPanel;
const sal_uInt16 mnMenuItemIndex;
- ::boost::function<void(void)> maMenuAction;
+ cssu::Reference<css::frame::XFrame> mxFrame;
+ ::rtl::OUString msMoreOptionsCommand;
};
Modified: openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx?rev=1483715&r1=1483714&r2=1483715&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx Fri May 17
09:44:46 2013
@@ -25,6 +25,7 @@
#include "Deck.hxx"
#include "DeckTitleBar.hxx"
#include "Panel.hxx"
+#include "PanelTitleBar.hxx"
#include "SidebarPanel.hxx"
#include "SidebarResource.hxx"
#include "TabBar.hxx"
@@ -586,11 +587,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;
}
Modified: openoffice/trunk/main/sfx2/source/sidebar/SidebarToolBox.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/SidebarToolBox.cxx?rev=1483715&r1=1483714&r2=1483715&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/SidebarToolBox.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/SidebarToolBox.cxx Fri May 17
09:44:46 2013
@@ -48,7 +48,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);
@@ -69,12 +71,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, Activate));
- SetDeactivateHdl(LINK(this, SidebarToolBox, Deactivate));
+ RegisterHandlers();
}
#ifdef DEBUG
@@ -85,6 +82,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;
@@ -98,13 +113,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());
+ }
}
@@ -265,6 +282,37 @@ Reference<frame::XToolbarController> Sid
+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)
{
const sal_Bool bBigImages (SvtMiscOptions().AreCurrentSymbolsLarge());
@@ -303,6 +351,24 @@ sal_uInt16 SidebarToolBox::GetItemIdForS
+
+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, Activate));
+ SetDeactivateHdl(LINK(this, SidebarToolBox, Deactivate));
+ }
+}
+
+
+
+
IMPL_LINK(SidebarToolBox, DropDownClickHandler, ToolBox*, pToolBox)
{
if (pToolBox != NULL)
Modified: openoffice/trunk/main/sfx2/source/sidebar/TitleBar.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/TitleBar.cxx?rev=1483715&r1=1483714&r2=1483715&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/TitleBar.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/TitleBar.cxx Fri May 17 09:44:46
2013
@@ -124,7 +124,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();
}
Modified: openoffice/trunk/main/sfx2/source/sidebar/TitleBar.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/TitleBar.hxx?rev=1483715&r1=1483714&r2=1483715&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/TitleBar.hxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/TitleBar.hxx Fri May 17 09:44:46
2013
@@ -25,7 +25,7 @@
#include "Paint.hxx"
#include <vcl/window.hxx>
-#include <vcl/toolbox.hxx>
+#include "sfx2/sidebar/SidebarToolBox.hxx"
namespace sfx2 { namespace sidebar {
@@ -56,7 +56,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;