[Libreoffice-commits] core.git: sw/source

Juergen Funk juergen.funk_ml at cib.de
Mon Oct 27 10:24:20 PDT 2014


 sw/source/uibase/inc/workctrl.hxx    |    4 -
 sw/source/uibase/ribbar/workctrl.cxx |   92 +++++++----------------------------
 2 files changed, 21 insertions(+), 75 deletions(-)

New commits:
commit 4aa2791ea6ee72d429cb8ddcaffd0a9fe647e3db
Author: Juergen Funk <juergen.funk_ml at cib.de>
Date:   Wed Oct 22 15:52:04 2014 +0200

    fdo#84408 Toolbar: Insert Field dropdown doesn't contain icons
    
    Change-Id: I3c8db72a84f2a68f1f68a0be1b21e2454707d84a
    Reviewed-on: https://gerrit.libreoffice.org/12068
    Reviewed-by: Samuel Mehrbrodt <s.mehrbrodt at gmail.com>
    Tested-by: Samuel Mehrbrodt <s.mehrbrodt at gmail.com>

diff --git a/sw/source/uibase/inc/workctrl.hxx b/sw/source/uibase/inc/workctrl.hxx
index 5a56dd4..567a0d0 100644
--- a/sw/source/uibase/inc/workctrl.hxx
+++ b/sw/source/uibase/inc/workctrl.hxx
@@ -96,10 +96,6 @@ public:
 
 class SwTbxFieldCtrl : public SfxToolBoxControl
 {
-    PopupMenu*              pPopup;
-    SwView*                 pView;
-
-    void                    DelPopup();
 public:
     SFX_DECL_TOOLBOX_CONTROL();
 
diff --git a/sw/source/uibase/ribbar/workctrl.cxx b/sw/source/uibase/ribbar/workctrl.cxx
index 6984554..ef1e5b7 100644
--- a/sw/source/uibase/ribbar/workctrl.cxx
+++ b/sw/source/uibase/ribbar/workctrl.cxx
@@ -25,6 +25,8 @@
 #include <sfx2/dispatch.hxx>
 #include <sfx2/bindings.hxx>
 #include <sfx2/imagemgr.hxx>
+#include <sfx2/mnumgr.hxx>
+#include <sfx2/msgpool.hxx>
 #include <swmodule.hxx>
 #include <view.hxx>
 #include <initui.hxx>
@@ -47,6 +49,8 @@
 
 #include <vcl/svapp.hxx>
 
+
+
 // Size check
 #define NAVI_ENTRIES 20
 #if NAVI_ENTRIES != NID_COUNT
@@ -282,57 +286,48 @@ SwTbxFieldCtrl::SwTbxFieldCtrl(
     sal_uInt16 nSlotId,
     sal_uInt16 nId,
     ToolBox& rTbx ) :
-    SfxToolBoxControl( nSlotId, nId, rTbx ),
-    pPopup(0),
-    pView(0)
+    SfxToolBoxControl( nSlotId, nId, rTbx )
 {
     rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWNONLY | rTbx.GetItemBits( nId ) );
 }
 
 SwTbxFieldCtrl::~SwTbxFieldCtrl()
 {
-    DelPopup();
 }
 
 SfxPopupWindow* SwTbxFieldCtrl::CreatePopupWindow()
 {
-    pView = ::GetActiveView();
+    SwView* pView = ::GetActiveView();
     if(pView && !pView->GetDocShell()->IsReadOnly() &&
        !pView->GetWrtShell().HasReadonlySel() )
     {
-        ToolBox& rBox = GetToolBox();
+        PopupMenu* pPopup = new PopupMenu(SW_RES(RID_INSERT_FIELD_CTRL));
 
-        Rectangle aItemRect( rBox.GetItemRect( GetId() ) );
-        Point aPt(rBox.OutputToScreenPixel(aItemRect.TopLeft()));
-        aPt.X() += aItemRect.GetWidth()/2;
-        aPt.Y() += aItemRect.GetHeight()/2;
-        if(pView)
+        if (::GetHtmlMode(pView->GetDocShell()) & HTMLMODE_ON)
         {
-            Link aLnk = LINK(this, SwTbxFieldCtrl, PopupHdl);
+            pPopup->RemoveItem(pPopup->GetItemPos(FN_INSERT_FLD_PGCOUNT));
+            pPopup->RemoveItem(pPopup->GetItemPos(FN_INSERT_FLD_TOPIC));
+        }
 
-            pPopup = new PopupMenu(SW_RES(RID_INSERT_FIELD_CTRL));
-            pPopup->SetSelectHdl(aLnk);
+        ToolBox*      pToolBox = &GetToolBox();
+        sal_uInt16    nId      = GetId();
+        SfxDispatcher *rDispat = pView->GetViewFrame()->GetDispatcher();
+
+        // set the icons in the Popup-Menu, delete the pPopup
+        SfxPopupMenuManager aPop( pPopup, rDispat->GetFrame()->GetBindings() );
 
-            if (::GetHtmlMode(pView->GetDocShell()) & HTMLMODE_ON)
-            {
-                pPopup->RemoveItem(pPopup->GetItemPos(FN_INSERT_FLD_PGCOUNT));
-                pPopup->RemoveItem(pPopup->GetItemPos(FN_INSERT_FLD_TOPIC));
-            }
-        }
-        ToolBox* pToolBox = &GetToolBox();
-        sal_uInt16 nId = GetId();
         pToolBox->SetItemDown( nId, true );
 
         pPopup->Execute( pToolBox, pToolBox->GetItemRect( nId ),
-            (pToolBox->GetAlign() == WINDOWALIGN_TOP || pToolBox->GetAlign() == WINDOWALIGN_BOTTOM) ?
-                POPUPMENU_EXECUTE_DOWN : POPUPMENU_EXECUTE_RIGHT );
+                (pToolBox->GetAlign() == WINDOWALIGN_TOP || pToolBox->GetAlign() == WINDOWALIGN_BOTTOM) ?
+                 POPUPMENU_EXECUTE_DOWN : POPUPMENU_EXECUTE_RIGHT );
 
         pToolBox->SetItemDown( nId, false );
     }
+
     GetToolBox().EndSelection();
-    DelPopup();
-    return 0;
 
+    return 0;
 }
 
 SfxPopupWindowType SwTbxFieldCtrl::GetPopupWindowType() const
@@ -351,51 +346,6 @@ void SwTbxFieldCtrl::StateChanged( sal_uInt16,
     }
 }
 
-IMPL_LINK(SwTbxFieldCtrl, PopupHdl, PopupMenu*, pMenu)
-{
-    sal_uInt16 nId = pMenu->GetCurItemId();
-
-    Sequence< PropertyValue > aArgs;
-    const char* pChar = 0;
-    switch(nId)
-    {
-        case FN_INSERT_FLD_DATE:
-            pChar = ".uno:InsertDateField";
-        break;
-        case FN_INSERT_FLD_TIME:
-            pChar = ".uno:InsertTimeField";
-        break;
-        case FN_INSERT_FLD_PGNUMBER:
-            pChar = ".uno:InsertPageNumberField";
-        break;
-        case FN_INSERT_FLD_PGCOUNT:
-            pChar = ".uno:InsertPageCountField";
-        break;
-        case FN_INSERT_FLD_TOPIC:
-            pChar = ".uno:InsertTopicField";
-        break;
-        case FN_INSERT_FLD_TITLE:
-            pChar = ".uno:InsertTitleField";
-        break;
-        case FN_INSERT_FLD_AUTHOR:
-            pChar = ".uno:InsertAuthorField";
-        break;
-        default:
-            pChar = ".uno:InsertFieldCtrl";
-    }
-    Dispatch( OUString::createFromAscii( pChar ),aArgs );
-
-    return 0;
-}
-
-void SwTbxFieldCtrl::DelPopup()
-{
-    if(pPopup)
-    {
-        delete pPopup;
-        pPopup = 0;
-    }
-}
 
 // Navigation-Popup
 // determine the order of the toolbox items


More information about the Libreoffice-commits mailing list