tdf#124255 Make maximum sidebar width configurable

Also change the default max width to 500px (instead of 400px).

Change-Id: Idece5aadaf4c4165cc873b4605d2c0f026c89c6e
Reviewed-on: https://gerrit.libreoffice.org/69545
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx
index c81e306..68e97c5 100644
--- a/include/sfx2/sidebar/SidebarController.hxx
+++ b/include/sfx2/sidebar/SidebarController.hxx
@@ -118,8 +118,6 @@ public:
    const static sal_Int32 SwitchFlag_ForceNewDeck = 0x02;
    const static sal_Int32 SwitchFlag_ForceNewPanels = 0x02;

    const static sal_Int32 gnMaximumSidebarWidth = 400;

    void OpenThenSwitchToDeck(const OUString& rsDeckId);
    void OpenThenToggleDeck(const OUString& rsDeckId);

@@ -170,6 +168,8 @@ public:

    css::uno::Reference<css::frame::XFrame> getXFrame() {return mxFrame;}

    sal_Int32 getMaximumWidth() { return mnMaximumSidebarWidth; }

private:
    SidebarController(
        SidebarDockingWindow* pParentWindow,
@@ -184,6 +184,7 @@ private:
    css::uno::Reference<css::frame::XController> mxCurrentController;
    /// Use a combination of SwitchFlag_* as value.
    sal_Int32 mnRequestedForceFlags;
    sal_Int32 mnMaximumSidebarWidth;
    OUString msCurrentDeckId;
    AsynchronousCall maPropertyChangeForwarder;
    AsynchronousCall maContextChangeUpdate;
diff --git a/include/svx/sidebar/PanelLayout.hxx b/include/svx/sidebar/PanelLayout.hxx
index 856785e..0932fe4 100644
--- a/include/svx/sidebar/PanelLayout.hxx
+++ b/include/svx/sidebar/PanelLayout.hxx
@@ -27,6 +27,7 @@ class SVX_DLLPUBLIC PanelLayout : public Control, public VclBuilderContainer
private:
    Idle m_aPanelLayoutIdle;
    bool m_bInClose;
    css::uno::Reference<css::frame::XFrame> mxFrame;

    DECL_DLLPRIVATE_LINK(ImplHandlePanelLayoutTimerHdl, Timer*, void);

diff --git a/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs b/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs
index 3258798..2eeed45 100644
--- a/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs
@@ -231,6 +231,17 @@
    </group>
  </templates>
  <component>
    <group oor:name="General">
      <info>
        <desc>General Sidebar settings.</desc>
      </info>
      <prop oor:name="MaximumWidth" oor:type="xs:int" oor:nillable="false">
        <info>
          <desc>Maximum width the sidebar can ever have</desc>
        </info>
        <value>500</value>
      </prop>
    </group>
    <group oor:name="Content">
      <info>
        <desc>Description of the decks and panels that can be displayed in the content area of the sidebar.</desc>
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 9aa8fc0..82ccd7c 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -45,6 +45,7 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/namedvaluecollection.hxx>
#include <sal/log.hxx>
#include <officecfg/Office/UI/Sidebar.hxx>

#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
@@ -100,6 +101,7 @@ SidebarController::SidebarController (
      maCurrentContext(OUString(), OUString()),
      maRequestedContext(),
      mnRequestedForceFlags(SwitchFlag_NoForce),
      mnMaximumSidebarWidth(officecfg::Office::UI::Sidebar::General::MaximumWidth::get()),
      msCurrentDeckId(gsDefaultDeckId),
      maPropertyChangeForwarder([this](){ return this->BroadcastPropertyChange(); }),
      maContextChangeUpdate([this](){ return this->UpdateConfigurations(); }),
@@ -1216,7 +1218,7 @@ void SidebarController::RestrictWidth (sal_Int32 nWidth)
        pSplitWindow->SetItemSizeRange(
            nSetId,
            Range(TabBar::GetDefaultWidth() * mpTabBar->GetDPIScaleFactor() + nWidth,
                  gnMaximumSidebarWidth * mpTabBar->GetDPIScaleFactor()));
                  getMaximumWidth() * mpTabBar->GetDPIScaleFactor()));
    }
}

diff --git a/svx/source/sidebar/PanelLayout.cxx b/svx/source/sidebar/PanelLayout.cxx
index e68ef41..a0b1362 100644
--- a/svx/source/sidebar/PanelLayout.cxx
+++ b/svx/source/sidebar/PanelLayout.cxx
@@ -20,6 +20,7 @@ using namespace sfx2::sidebar;
PanelLayout::PanelLayout(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame> &rFrame)
    : Control(pParent)
    , m_bInClose(false)
    , mxFrame(rFrame)
{
    SetStyle(GetStyle() | WB_DIALOGCONTROL);
    m_aPanelLayoutIdle.SetPriority(TaskPriority::RESIZE);
@@ -50,8 +51,16 @@ Size PanelLayout::GetOptimalSize() const
    if (isLayoutEnabled(this))
    {
        Size aSize = VclContainer::getLayoutRequisition(*GetWindow(GetWindowType::FirstChild));
        aSize.setWidth( std::min<long>(aSize.Width(),
            (SidebarController::gnMaximumSidebarWidth - TabBar::GetDefaultWidth()) * GetDPIScaleFactor()) );
        if (mxFrame)
        {
            SidebarController* pController
                = SidebarController::GetSidebarControllerForFrame(mxFrame);
            if (pController)
                aSize.setWidth(std::min<long>(
                    aSize.Width(), (pController->getMaximumWidth() - TabBar::GetDefaultWidth())
                                       * GetDPIScaleFactor()));
        }

        return aSize;
    }