diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2015-08-12 14:52:39 +0300 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-08-12 13:03:51 +0000 |
commit | b137ea11db280dec3e38a306f9daf7209eacf18e (patch) | |
tree | cb09eeb656086951bca42346925737b4549f88e4 | |
parent | ce51de70c2dfa905e105d09f4ccd72014af159ac (diff) |
Related: tdf#78111 Try to guard against too wide panel layouts
The sidebar has width limit, so a panel shouldn't attempt to
resize more than that. Otherwise we'll get an endless loop.
(based on e98cf0c63d6c48ca7c1db87d7413d5c419690c76)
Change-Id: Ia36535637e3585595c673c7fc46a1a7b162b74ba
Reviewed-on: https://gerrit.libreoffice.org/17667
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | svx/source/sidebar/PanelLayout.cxx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/svx/source/sidebar/PanelLayout.cxx b/svx/source/sidebar/PanelLayout.cxx index 591dfe390eea..90123aff7536 100644 --- a/svx/source/sidebar/PanelLayout.cxx +++ b/svx/source/sidebar/PanelLayout.cxx @@ -11,9 +11,12 @@ #include <com/sun/star/util/URL.hpp> #include <com/sun/star/util/URLTransformer.hpp> #include <comphelper/processfactory.hxx> +#include <sfx2/sidebar/Theme.hxx> #include <svx/sidebar/PanelLayout.hxx> #include <vcl/layout.hxx> +using namespace sfx2::sidebar; + PanelLayout::PanelLayout(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const com::sun::star::uno::Reference<com::sun::star::frame::XFrame> &rFrame) : Control(pParent) , m_bInClose(false) @@ -40,7 +43,14 @@ void PanelLayout::dispose() Size PanelLayout::GetOptimalSize() const { if (isLayoutEnabled(this)) - return VclContainer::getLayoutRequisition(*GetWindow(GetWindowType::FirstChild)); + { + Size aSize = VclContainer::getLayoutRequisition(*GetWindow(GetWindowType::FirstChild)); + sal_Int32 nTabBarWidth = Theme::GetInteger(Theme::Int_TabItemWidth) + + Theme::GetInteger(Theme::Int_TabBarLeftPadding) + + Theme::GetInteger(Theme::Int_TabBarRightPadding); + aSize.Width() = std::min<long>(aSize.Width(), (400 - nTabBarWidth) * GetDPIScaleFactor()); + return aSize; + } return Control::GetOptimalSize(); } |