include/sfx2/sidebar/SidebarToolBox.hxx   |    9 ++
 offapi/UnoApi_offapi.mk                   |    3 
 sfx2/source/sidebar/Deck.cxx              |    1 
 sfx2/source/sidebar/DeckLayouter.cxx      |    4 -
 sfx2/source/sidebar/FocusManager.cxx      |    1 
 sfx2/source/sidebar/Panel.cxx             |   13 ----
 sfx2/source/sidebar/Panel.hxx             |    3 
 sfx2/source/sidebar/PanelTitleBar.cxx     |   72 ++++++++++++++++------
 sfx2/source/sidebar/PanelTitleBar.hxx     |    8 +-
 sfx2/source/sidebar/SidebarController.cxx |   15 +++-
 sfx2/source/sidebar/SidebarToolBox.cxx    |   94 +++++++++++++++++++++++++-----
 sfx2/source/sidebar/TitleBar.cxx          |    2 
 sfx2/source/sidebar/TitleBar.hxx          |    4 -
 13 files changed, 167 insertions(+), 62 deletions(-)

New commits:
commit 8a8fee316a565c050ef1a8531ded130ff9959bfd
Author: Caolán McNamara <caol...@redhat.com>
Date:   Tue May 21 16:56:49 2013 +0100

    restore missing XUIControllerRegistration from list
    
    Change-Id: I733a6e94e28c08779303d8b720602c71791b5bd6

diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index f1e935e..0e3bb60 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2633,7 +2633,8 @@ $(eval $(call 
gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/frame,\
        XToolbarController \
        XToolbarControllerListener \
        XTransientDocumentsDocumentContentFactory \
-    XUIControllerFactory \
+       XUIControllerFactory \
+       XUIControllerRegistration \
        XUntitledNumbers \
        XUrlList \
        XWindowArranger \
commit b7d74cba368a682b275adcd5d533ad067d636016
Author: Andre Fischer <a...@apache.org>
Date:   Fri May 17 11:58:45 2013 +0000

    Related: #i122315# Include the Tools.hxx header always
    
    (cherry picked from commit e65bf3376ec742e2d5e69cad097d17f77fb19a73)
    
    Change-Id: I5ba72f2e30e4e3a306fafc45dfc2c38997f07f0f

diff --git a/sfx2/source/sidebar/PanelTitleBar.cxx 
b/sfx2/source/sidebar/PanelTitleBar.cxx
index bf94ff4..738593a 100644
--- a/sfx2/source/sidebar/PanelTitleBar.cxx
+++ b/sfx2/source/sidebar/PanelTitleBar.cxx
@@ -24,14 +24,12 @@
 #include "Panel.hxx"
 #include "sfx2/sidebar/Theme.hxx"
 #include "sfx2/sidebar/ControllerFactory.hxx"
+#include "sfx2/sidebar/Tools.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;
commit 76ca8f7f178f5e9698d23ac0b1212922f2ddf39b
Author: Andre Fischer <a...@apache.org>
Date:   Fri May 17 09:44:46 2013 +0000

    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

diff --git a/include/sfx2/sidebar/SidebarToolBox.hxx 
b/include/sfx2/sidebar/SidebarToolBox.hxx
index bb96a9e..b22bbc8 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 6534ec7..0fed648 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 b04f83b..8d7cb89 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 6ed64a5..51d4c5e 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 0840c4c..3b81121 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 27c771a..cbf1781 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 3446aca..bf94ff4 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 dff82a9..f47f86e 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 5f1b6ac..d831cee 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 d4aa7b6..291b82f 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 2240006..bab9631 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 c16cfbc..229d3b7 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;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to