[Libreoffice-commits] core.git: sd/source sd/uiconfig sd/UIConfig_simpress.mk sfx2/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Feb 4 10:01:37 UTC 2020


 sd/UIConfig_simpress.mk                             |    1 
 sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx |    6 
 sd/source/ui/sidebar/MasterPagesSelector.cxx        |  156 ++++++++++----------
 sd/source/ui/sidebar/MasterPagesSelector.hxx        |   13 +
 sd/source/ui/sidebar/PreviewValueSet.cxx            |   23 +-
 sd/source/ui/sidebar/PreviewValueSet.hxx            |    8 -
 sd/source/ui/sidebar/RecentMasterPagesSelector.cxx  |   10 -
 sd/uiconfig/simpress/ui/masterpagepanel.ui          |   24 +++
 sfx2/source/sidebar/SidebarPanelBase.cxx            |    7 
 9 files changed, 145 insertions(+), 103 deletions(-)

New commits:
commit 739e3b25bbaf9305f779e8821fd7aee4fccc6f5d
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Feb 3 16:13:17 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Feb 4 11:01:03 2020 +0100

    weld MasterPagesSelector
    
    Change-Id: Ie63d7f8f83bae4f9641ab9713c6e46cd2090767b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87906
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sd/UIConfig_simpress.mk b/sd/UIConfig_simpress.mk
index fe0dcce15873..fa7796736897 100644
--- a/sd/UIConfig_simpress.mk
+++ b/sd/UIConfig_simpress.mk
@@ -131,6 +131,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/simpress,\
 	sd/uiconfig/simpress/ui/layoutwindow \
 	sd/uiconfig/simpress/ui/masterlayoutdlg \
 	sd/uiconfig/simpress/ui/mastermenu \
+	sd/uiconfig/simpress/ui/masterpagepanel \
 	sd/uiconfig/simpress/ui/navigatorpanel \
 	sd/uiconfig/simpress/ui/notebookbar \
 	sd/uiconfig/simpress/ui/notebookbar_compact \
diff --git a/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx b/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx
index c27bb31f976a..70e53010e163 100644
--- a/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx
+++ b/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx
@@ -184,13 +184,13 @@ void CurrentMasterPagesSelector::UpdateSelection()
     }
 
     // Find the items for the master pages in the set.
-    sal_uInt16 nItemCount (PreviewValueSet::GetItemCount());
+    sal_uInt16 nItemCount (mxPreviewValueSet->GetItemCount());
     for (nIndex=1; nIndex<=nItemCount && bLoop; nIndex++)
     {
-        OUString sName (PreviewValueSet::GetItemText (nIndex));
+        OUString sName (mxPreviewValueSet->GetItemText (nIndex));
         if (aNames.find(sName) != aNames.end())
         {
-            PreviewValueSet::SelectItem (nIndex);
+            mxPreviewValueSet->SelectItem (nIndex);
         }
     }
 }
diff --git a/sd/source/ui/sidebar/MasterPagesSelector.cxx b/sd/source/ui/sidebar/MasterPagesSelector.cxx
index 560f061db87c..43d12ce319c5 100644
--- a/sd/source/ui/sidebar/MasterPagesSelector.cxx
+++ b/sd/source/ui/sidebar/MasterPagesSelector.cxx
@@ -58,9 +58,11 @@ MasterPagesSelector::MasterPagesSelector (
     ViewShellBase& rBase,
     const std::shared_ptr<MasterPageContainer>& rpContainer,
     const css::uno::Reference<css::ui::XSidebar>& rxSidebar)
-    : PreviewValueSet(pParent),
+    : PanelLayout( pParent, "MasterPagePanel", "modules/simpress/ui/masterpagepanel.ui", nullptr, true ),
       maMutex(),
       mpContainer(rpContainer),
+      mxPreviewValueSet(new PreviewValueSet),
+      mxPreviewValueSetWin(new weld::CustomWeld(*m_xBuilder, "valueset", *mxPreviewValueSet)),
       mrDocument(rDocument),
       mrBase(rBase),
       maCurrentItemList(),
@@ -68,20 +70,19 @@ MasterPagesSelector::MasterPagesSelector (
       maLockedMasterPages(),
       mxSidebar(rxSidebar)
 {
-    PreviewValueSet::SetSelectHdl (
+    mxPreviewValueSet->SetSelectHdl (
         LINK(this, MasterPagesSelector, ClickHandler));
-    PreviewValueSet::SetRightMouseClickHandler (
+    mxPreviewValueSet->SetRightMouseClickHandler (
         LINK(this, MasterPagesSelector, RightClickHandler));
-    PreviewValueSet::SetStyle(PreviewValueSet::GetStyle() | WB_NO_DIRECTSELECT);
+    mxPreviewValueSet->SetStyle(mxPreviewValueSet->GetStyle() | WB_NO_DIRECTSELECT);
 
     if ( GetDPIScaleFactor() > 1 )
         mpContainer->SetPreviewSize(MasterPageContainer::LARGE);
 
-    PreviewValueSet::SetPreviewSize(mpContainer->GetPreviewSizePixel());
-    PreviewValueSet::Show();
+    mxPreviewValueSet->SetPreviewSize(mpContainer->GetPreviewSizePixel());
+    mxPreviewValueSet->Show();
 
-    SetBackground(sfx2::sidebar::Theme::GetWallpaper(sfx2::sidebar::Theme::Paint_PanelBackground));
-    SetColor(sfx2::sidebar::Theme::GetColor(sfx2::sidebar::Theme::Paint_PanelBackground));
+    mxPreviewValueSet->SetColor(sfx2::sidebar::Theme::GetColor(sfx2::sidebar::Theme::Paint_PanelBackground));
 
     Link<MasterPageContainerChangeEvent&,void> aChangeListener (LINK(this,MasterPagesSelector,ContainerChangeListener));
     mpContainer->AddChangeListener(aChangeListener);
@@ -100,7 +101,10 @@ void MasterPagesSelector::dispose()
     Link<MasterPageContainerChangeEvent&,void> aChangeListener (LINK(this,MasterPagesSelector,ContainerChangeListener));
     mpContainer->RemoveChangeListener(aChangeListener);
     mpContainer.reset();
-    PreviewValueSet::dispose();
+    mxPreviewValueSetWin.reset();
+    mxPreviewValueSet.reset();
+
+    PanelLayout::dispose();
 }
 
 void MasterPagesSelector::LateInit()
@@ -111,7 +115,7 @@ sal_Int32 MasterPagesSelector::GetPreferredHeight (sal_Int32 nWidth)
 {
     const ::osl::MutexGuard aGuard (maMutex);
 
-    return PreviewValueSet::GetPreferredHeight (nWidth);
+    return mxPreviewValueSet->GetPreferredHeight (nWidth);
 }
 
 void MasterPagesSelector::UpdateLocks (const ItemList& rItemList)
@@ -153,7 +157,7 @@ OUString MasterPagesSelector::GetContextMenuUIFile() const
     return "modules/simpress/ui/mastermenu.ui";
 }
 
-IMPL_LINK_NOARG(MasterPagesSelector, ClickHandler, ValueSet*, void)
+IMPL_LINK_NOARG(MasterPagesSelector, ClickHandler, SvtValueSet*, void)
 {
     // We use the framework to assign the clicked-on master page because we
     // so use the same mechanism as the context menu does (where we do not
@@ -164,66 +168,68 @@ IMPL_LINK_NOARG(MasterPagesSelector, ClickHandler, ValueSet*, void)
 IMPL_LINK(MasterPagesSelector, RightClickHandler, const MouseEvent&, rEvent, void)
 {
     // Here we only prepare the display of the context menu: the item under
-    // the mouse is selected.  The actual display of the context menu is
-    // done in ContextMenuCallback which is called indirectly through
-    // PreviewValueSet::Command().
-    PreviewValueSet::GrabFocus ();
-    PreviewValueSet::ReleaseMouse();
+    // the mouse is selected.
+    mxPreviewValueSet->GrabFocus ();
+    mxPreviewValueSet->ReleaseMouse();
     SfxViewFrame* pViewFrame = mrBase.GetViewFrame();
     if (pViewFrame != nullptr)
     {
         SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
         if (pDispatcher != nullptr)
         {
-            sal_uInt16 nIndex = PreviewValueSet::GetItemId (rEvent.GetPosPixel());
+            sal_uInt16 nIndex = mxPreviewValueSet->GetItemId (rEvent.GetPosPixel());
             if (nIndex > 0)
-                PreviewValueSet::SelectItem (nIndex);
+            {
+                mxPreviewValueSet->SelectItem (nIndex);
+                // Now do the the actual display of the context menu
+                ShowContextMenu(&rEvent.GetPosPixel());
+            }
         }
     }
 }
 
-void MasterPagesSelector::Command (const CommandEvent& rEvent)
+void MasterPagesSelector::ShowContextMenu(const Point* pPos)
 {
-    switch (rEvent.GetCommand())
+    // Use the currently selected item and show the popup menu in its
+    // center.
+    const sal_uInt16 nIndex = mxPreviewValueSet->GetSelectedItemId();
+    if (nIndex > 0)
     {
-        case CommandEventId::ContextMenu:
+        // The position of the upper left corner of the context menu is
+        // taken either from the mouse position (when the command was sent
+        // as reaction to a right click) or in the center of the selected
+        // item (when the command was sent as reaction to Shift+F10.)
+        Point aPosition;
+        if (!pPos)
         {
-            // Use the currently selected item and show the popup menu in its
-            // center.
-            const sal_uInt16 nIndex = PreviewValueSet::GetSelectedItemId();
-            if (nIndex > 0)
-            {
-                // The position of the upper left corner of the context menu is
-                // taken either from the mouse position (when the command was sent
-                // as reaction to a right click) or in the center of the selected
-                // item (when the command was sent as reaction to Shift+F10.)
-                Point aPosition (rEvent.GetMousePosPixel());
-                if ( ! rEvent.IsMouseEvent())
-                {
-                    ::tools::Rectangle aBBox (PreviewValueSet::GetItemRect(nIndex));
-                    aPosition = aBBox.Center();
-                }
-
-                // Setup the menu.
-                VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), GetContextMenuUIFile(), "");
-                VclPtr<PopupMenu> pMenu(aBuilder.get_menu("menu"));
-                FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow());
-                if (pMenuWindow != nullptr)
-                    pMenuWindow->SetPopupModeFlags(
-                        pMenuWindow->GetPopupModeFlags() | FloatWinPopupFlags::NoMouseUpClose);
-                pMenu->SetSelectHdl(LINK(this, MasterPagesSelector, OnMenuItemSelected));
-
-                ProcessPopupMenu(*pMenu);
-
-                // Show the menu.
-                pMenu->Execute(this, ::tools::Rectangle(aPosition,Size(1,1)), PopupMenuFlags::ExecuteDown);
-            }
+            ::tools::Rectangle aBBox (mxPreviewValueSet->GetItemRect(nIndex));
+            aPosition = aBBox.Center();
         }
-        break;
-        default: break;
+        else
+            aPosition = *pPos;
+
+        // Setup the menu.
+        VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), GetContextMenuUIFile(), "");
+        VclPtr<PopupMenu> pMenu(aBuilder.get_menu("menu"));
+        FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow());
+        if (pMenuWindow != nullptr)
+            pMenuWindow->SetPopupModeFlags(
+                pMenuWindow->GetPopupModeFlags() | FloatWinPopupFlags::NoMouseUpClose);
+        pMenu->SetSelectHdl(LINK(this, MasterPagesSelector, OnMenuItemSelected));
+
+        ProcessPopupMenu(*pMenu);
+
+        // Show the menu.
+        pMenu->Execute(this, ::tools::Rectangle(aPosition,Size(1,1)), PopupMenuFlags::ExecuteDown);
     }
 }
 
+void MasterPagesSelector::Command (const CommandEvent& rEvent)
+{
+    if (rEvent.GetCommand() == CommandEventId::ContextMenu)
+        ShowContextMenu(rEvent.IsMouseEvent() ? &rEvent.GetMousePosPixel() : nullptr);
+}
+
 void MasterPagesSelector::ProcessPopupMenu (Menu& rMenu)
 {
     // Disable some entries.
@@ -290,9 +296,9 @@ void MasterPagesSelector::ExecuteCommand(const OString &rIdent)
             SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
             if (pDispatcher != nullptr)
             {
-                sal_uInt16 nIndex = PreviewValueSet::GetSelectedItemId();
+                sal_uInt16 nIndex = mxPreviewValueSet->GetSelectedItemId();
                 pDispatcher->Execute(SID_MASTERPAGE, SfxCallMode::SYNCHRON);
-                PreviewValueSet::SelectItem (nIndex);
+                mxPreviewValueSet->SelectItem (nIndex);
                 mrBase.GetDrawController().setCurrentPage(xSelectedMaster);
             }
         }
@@ -309,7 +315,7 @@ SdPage* MasterPagesSelector::GetSelectedMasterPage()
     const ::osl::MutexGuard aGuard (maMutex);
 
     SdPage* pMasterPage = nullptr;
-    sal_uInt16 nIndex = PreviewValueSet::GetSelectedItemId();
+    sal_uInt16 nIndex = mxPreviewValueSet->GetSelectedItemId();
     UserData* pData = GetUserData(nIndex);
     if (pData != nullptr)
     {
@@ -390,7 +396,7 @@ void MasterPagesSelector::NotifyContainerChangeEvent (const MasterPageContainerC
     switch (rEvent.meEventType)
     {
         case MasterPageContainerChangeEvent::EventType::SIZE_CHANGED:
-            PreviewValueSet::SetPreviewSize(mpContainer->GetPreviewSizePixel());
+            mxPreviewValueSet->SetPreviewSize(mpContainer->GetPreviewSizePixel());
             UpdateAllPreviews();
             break;
 
@@ -399,10 +405,10 @@ void MasterPagesSelector::NotifyContainerChangeEvent (const MasterPageContainerC
             int nIndex (GetIndexForToken(rEvent.maChildToken));
             if (nIndex >= 0)
             {
-                PreviewValueSet::SetItemImage (
+                mxPreviewValueSet->SetItemImage (
                     static_cast<sal_uInt16>(nIndex),
                     mpContainer->GetPreviewForToken(rEvent.maChildToken));
-                PreviewValueSet::Invalidate(PreviewValueSet::GetItemRect(static_cast<sal_uInt16>(nIndex)));
+                mxPreviewValueSet->Invalidate(mxPreviewValueSet->GetItemRect(static_cast<sal_uInt16>(nIndex)));
             }
         }
         break;
@@ -430,8 +436,8 @@ MasterPagesSelector::UserData* MasterPagesSelector::GetUserData (int nIndex) con
 {
     const ::osl::MutexGuard aGuard (maMutex);
 
-    if (nIndex>0 && o3tl::make_unsigned(nIndex)<=PreviewValueSet::GetItemCount())
-        return static_cast<UserData*>(PreviewValueSet::GetItemData(static_cast<sal_uInt16>(nIndex)));
+    if (nIndex>0 && o3tl::make_unsigned(nIndex)<=mxPreviewValueSet->GetItemCount())
+        return static_cast<UserData*>(mxPreviewValueSet->GetItemData(static_cast<sal_uInt16>(nIndex)));
     else
         return nullptr;
 }
@@ -441,7 +447,7 @@ void MasterPagesSelector::SetUserData (int nIndex, std::unique_ptr<UserData> pDa
     const ::osl::MutexGuard aGuard (maMutex);
 
     delete GetUserData(nIndex);
-    PreviewValueSet::SetItemData(static_cast<sal_uInt16>(nIndex), pData.release());
+    mxPreviewValueSet->SetItemData(static_cast<sal_uInt16>(nIndex), pData.release());
 }
 
 void MasterPagesSelector::SetItem (
@@ -462,14 +468,14 @@ void MasterPagesSelector::SetItem (
 
         if (aPreview.GetSizePixel().Width()>0)
         {
-            if (PreviewValueSet::GetItemPos(nIndex) != VALUESET_ITEM_NOTFOUND)
+            if (mxPreviewValueSet->GetItemPos(nIndex) != VALUESET_ITEM_NOTFOUND)
             {
-                PreviewValueSet::SetItemImage(nIndex,aPreview);
-                PreviewValueSet::SetItemText(nIndex, mpContainer->GetPageNameForToken(aToken));
+                mxPreviewValueSet->SetItemImage(nIndex,aPreview);
+                mxPreviewValueSet->SetItemText(nIndex, mpContainer->GetPageNameForToken(aToken));
             }
             else
             {
-                PreviewValueSet::InsertItem (
+                mxPreviewValueSet->InsertItem (
                     nIndex,
                     aPreview,
                     mpContainer->GetPageNameForToken(aToken),
@@ -485,7 +491,7 @@ void MasterPagesSelector::SetItem (
     }
     else
     {
-        PreviewValueSet::RemoveItem(nIndex);
+        mxPreviewValueSet->RemoveItem(nIndex);
     }
 
 }
@@ -523,7 +529,7 @@ void MasterPagesSelector::InvalidatePreview (const SdPage* pPage)
 {
     const ::osl::MutexGuard aGuard (maMutex);
 
-    for (size_t nIndex=1; nIndex<=PreviewValueSet::GetItemCount(); nIndex++)
+    for (size_t nIndex=1; nIndex<=mxPreviewValueSet->GetItemCount(); nIndex++)
     {
         UserData* pData = GetUserData(nIndex);
         if (pData != nullptr)
@@ -543,39 +549,39 @@ void MasterPagesSelector::UpdateAllPreviews()
 {
     const ::osl::MutexGuard aGuard (maMutex);
 
-    for (size_t nIndex=1; nIndex<=PreviewValueSet::GetItemCount(); nIndex++)
+    for (size_t nIndex=1; nIndex<=mxPreviewValueSet->GetItemCount(); nIndex++)
     {
         UserData* pData = GetUserData(nIndex);
         if (pData != nullptr)
         {
             MasterPageContainer::Token aToken (pData->second);
-            PreviewValueSet::SetItemImage(
+            mxPreviewValueSet->SetItemImage(
                 nIndex,
                 mpContainer->GetPreviewForToken(aToken));
             if (mpContainer->GetPreviewState(aToken) == MasterPageContainer::PS_CREATABLE)
                 mpContainer->RequestPreview(aToken);
         }
     }
-    PreviewValueSet::Rearrange();
+    mxPreviewValueSet->Rearrange();
 }
 
 void MasterPagesSelector::ClearPageSet()
 {
     const ::osl::MutexGuard aGuard (maMutex);
 
-    for (size_t nIndex=1; nIndex<=PreviewValueSet::GetItemCount(); nIndex++)
+    for (size_t nIndex=1; nIndex<=mxPreviewValueSet->GetItemCount(); nIndex++)
     {
         UserData* pData = GetUserData(nIndex);
         delete pData;
     }
-    PreviewValueSet::Clear();
+    mxPreviewValueSet->Clear();
 }
 
 void MasterPagesSelector::SetHelpId( const OString& aId )
 {
     const ::osl::MutexGuard aGuard (maMutex);
 
-    PreviewValueSet::SetHelpId( aId );
+    mxPreviewValueSet->SetHelpId( aId );
 }
 
 sal_Int32 MasterPagesSelector::GetIndexForToken (MasterPageContainer::Token aToken) const
@@ -638,7 +644,7 @@ void MasterPagesSelector::UpdateItemList (::std::unique_ptr<ItemList> && pNewIte
 
     maCurrentItemList.swap(*pNewItemList);
 
-    PreviewValueSet::Rearrange();
+    mxPreviewValueSet->Rearrange();
     if (mxSidebar.is())
         mxSidebar->requestLayout();
 }
diff --git a/sd/source/ui/sidebar/MasterPagesSelector.hxx b/sd/source/ui/sidebar/MasterPagesSelector.hxx
index 76cb262e4f8a..a816cca70093 100644
--- a/sd/source/ui/sidebar/MasterPagesSelector.hxx
+++ b/sd/source/ui/sidebar/MasterPagesSelector.hxx
@@ -25,6 +25,7 @@
 #include "MasterPageContainer.hxx"
 #include "PreviewValueSet.hxx"
 #include <sfx2/sidebar/ILayoutableWindow.hxx>
+#include <svx/sidebar/PanelLayout.hxx>
 
 #include <osl/mutex.hxx>
 
@@ -42,9 +43,8 @@ namespace sd { namespace sidebar {
 /** Base class of a menu that lets the user select from a list of
     templates or designs that are loaded from files.
 */
-class MasterPagesSelector
-    : public PreviewValueSet,
-      public sfx2::sidebar::ILayoutableWindow
+class MasterPagesSelector : public PanelLayout
+                          , public sfx2::sidebar::ILayoutableWindow
 {
 public:
     MasterPagesSelector (
@@ -80,6 +80,8 @@ public:
 
     void UpdateAllPreviews();
 
+    void ShowContextMenu(const Point* pPos);
+
     // ILayoutableWindow
     virtual css::ui::LayoutSize GetHeightForWidth (const sal_Int32 nWidth) override;
 
@@ -87,6 +89,9 @@ protected:
     mutable ::osl::Mutex maMutex;
     std::shared_ptr<MasterPageContainer> mpContainer;
 
+    std::unique_ptr<PreviewValueSet> mxPreviewValueSet;
+    std::unique_ptr<weld::CustomWeld> mxPreviewValueSetWin;
+
     SdDrawDocument& mrDocument;
     ViewShellBase& mrBase;
 
@@ -157,7 +162,7 @@ private:
         last seen.  This value is used heuristically to speed up the lookup
         of an index for a token.
     */
-    DECL_LINK(ClickHandler, ValueSet*, void);
+    DECL_LINK(ClickHandler, SvtValueSet*, void);
     DECL_LINK(RightClickHandler, const MouseEvent&, void);
     DECL_LINK(ContainerChangeListener, MasterPageContainerChangeEvent&, void);
     DECL_LINK(OnMenuItemSelected, Menu*, bool);
diff --git a/sd/source/ui/sidebar/PreviewValueSet.cxx b/sd/source/ui/sidebar/PreviewValueSet.cxx
index 33a16004c856..44d578576b4f 100644
--- a/sd/source/ui/sidebar/PreviewValueSet.cxx
+++ b/sd/source/ui/sidebar/PreviewValueSet.cxx
@@ -25,15 +25,21 @@ namespace sd::sidebar {
 static const int gnBorderWidth(3);
 static const int gnBorderHeight(3);
 
-PreviewValueSet::PreviewValueSet (vcl::Window* pParent)
-    : ValueSet (pParent, WB_TABSTOP),
-      maPreviewSize(10,10)
+PreviewValueSet::PreviewValueSet()
+    : SvtValueSet(nullptr)
+    , maPreviewSize(10,10)
 {
     SetStyle (
         GetStyle()
         & ~(WB_ITEMBORDER)// | WB_MENUSTYLEVALUESET)
         //        | WB_FLATVALUESET);
         );
+}
+
+void PreviewValueSet::SetDrawingArea(weld::DrawingArea* pDrawingArea)
+{
+    SvtValueSet::SetDrawingArea(pDrawingArea);
+
     SetColCount(2);
     SetExtraSpacing (2);
 }
@@ -52,18 +58,19 @@ void PreviewValueSet::SetRightMouseClickHandler (const Link<const MouseEvent&,vo
     maRightMouseClickHandler = rLink;
 }
 
-void PreviewValueSet::MouseButtonDown (const MouseEvent& rEvent)
+bool PreviewValueSet::MouseButtonDown (const MouseEvent& rEvent)
 {
     if (rEvent.IsRight())
+    {
         maRightMouseClickHandler.Call(rEvent);
-    else
-        ValueSet::MouseButtonDown(rEvent);
-
+        return true;
+    }
+    return SvtValueSet::MouseButtonDown(rEvent);
 }
 
 void PreviewValueSet::Resize()
 {
-    ValueSet::Resize ();
+    SvtValueSet::Resize();
 
     Size aWindowSize (GetOutputSizePixel());
     if (aWindowSize.Width()>0 && aWindowSize.Height()>0)
diff --git a/sd/source/ui/sidebar/PreviewValueSet.hxx b/sd/source/ui/sidebar/PreviewValueSet.hxx
index dcc326e4005a..ba50d481a206 100644
--- a/sd/source/ui/sidebar/PreviewValueSet.hxx
+++ b/sd/source/ui/sidebar/PreviewValueSet.hxx
@@ -26,11 +26,11 @@ namespace sd { namespace sidebar {
 
 /** Adapt the svtools valueset to the needs of the master page controls.
 */
-class PreviewValueSet
-    : public ValueSet
+class PreviewValueSet : public SvtValueSet
 {
 public:
-    explicit PreviewValueSet (vcl::Window* pParent);
+    explicit PreviewValueSet();
+    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
     virtual ~PreviewValueSet() override;
 
     void SetRightMouseClickHandler (const Link<const MouseEvent&,void>& rLink);
@@ -46,7 +46,7 @@ public:
     void Rearrange();
 
 protected:
-    virtual void MouseButtonDown (const MouseEvent& rEvent) override;
+    virtual bool MouseButtonDown (const MouseEvent& rEvent) override;
 
 private:
     Link<const MouseEvent&,void> maRightMouseClickHandler;
diff --git a/sd/source/ui/sidebar/RecentMasterPagesSelector.cxx b/sd/source/ui/sidebar/RecentMasterPagesSelector.cxx
index 4d52bb96a566..43949d410ecb 100644
--- a/sd/source/ui/sidebar/RecentMasterPagesSelector.cxx
+++ b/sd/source/ui/sidebar/RecentMasterPagesSelector.cxx
@@ -125,17 +125,17 @@ void RecentMasterPagesSelector::AssignMasterPageToPageList (
     SdPage* pMasterPage,
     const std::shared_ptr<std::vector<SdPage*> >& rpPageList)
 {
-    sal_uInt16 nSelectedItemId = PreviewValueSet::GetSelectedItemId();
+    sal_uInt16 nSelectedItemId = mxPreviewValueSet->GetSelectedItemId();
 
     MasterPagesSelector::AssignMasterPageToPageList(pMasterPage, rpPageList);
 
     // Restore the selection.
-    if (PreviewValueSet::GetItemCount() > 0)
+    if (mxPreviewValueSet->GetItemCount() > 0)
     {
-        if (PreviewValueSet::GetItemCount() >= nSelectedItemId)
-            PreviewValueSet::SelectItem(nSelectedItemId);
+        if (mxPreviewValueSet->GetItemCount() >= nSelectedItemId)
+            mxPreviewValueSet->SelectItem(nSelectedItemId);
         else
-            PreviewValueSet::SelectItem(PreviewValueSet::GetItemCount());
+            mxPreviewValueSet->SelectItem(mxPreviewValueSet->GetItemCount());
     }
 }
 
diff --git a/sd/uiconfig/simpress/ui/masterpagepanel.ui b/sd/uiconfig/simpress/ui/masterpagepanel.ui
new file mode 100644
index 000000000000..97c68a6f6d1b
--- /dev/null
+++ b/sd/uiconfig/simpress/ui/masterpagepanel.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="sd">
+  <requires lib="gtk+" version="3.18"/>
+  <object class="GtkGrid" id="MasterPagePanel">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="hexpand">True</property>
+    <property name="vexpand">True</property>
+    <child>
+      <object class="GtkDrawingArea" id="valueset">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">0</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/sfx2/source/sidebar/SidebarPanelBase.cxx b/sfx2/source/sidebar/SidebarPanelBase.cxx
index 0ada01c391cb..3f9d00fe59ba 100644
--- a/sfx2/source/sidebar/SidebarPanelBase.cxx
+++ b/sfx2/source/sidebar/SidebarPanelBase.cxx
@@ -156,15 +156,14 @@ ui::LayoutSize SAL_CALL SidebarPanelBase::getHeightForWidth (const sal_Int32 nWi
     else
     {
         ILayoutableWindow* pLayoutableWindow = dynamic_cast<ILayoutableWindow*>(mpControl.get());
-
-        if (isLayoutEnabled(mpControl))
+        if (pLayoutableWindow)
+            return pLayoutableWindow->GetHeightForWidth(nWidth);
+        else if (isLayoutEnabled(mpControl))
         {
             // widget layout-based sidebar
             Size aSize(mpControl->get_preferred_size());
             return ui::LayoutSize(aSize.Height(), aSize.Height(), aSize.Height());
         }
-        else if (pLayoutableWindow != nullptr)
-            return pLayoutableWindow->GetHeightForWidth(nWidth);
         else if (mpControl != nullptr)
         {
             const sal_Int32 nHeight (mpControl->GetSizePixel().Height());


More information about the Libreoffice-commits mailing list