Blame SOURCES/0001-Resolves-rhbz-1546997-search-not-found-at-0-0-when-w.patch

91334d
From d83c1e5de554b7722d0a3161ba757e6e4785810e Mon Sep 17 00:00:00 2001
91334d
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
91334d
Date: Tue, 20 Feb 2018 13:59:08 +0000
91334d
Subject: [PATCH] Resolves: rhbz#1546997 'search not found' at 0,0 when window
91334d
 too narrow
91334d
MIME-Version: 1.0
91334d
Content-Type: text/plain; charset=UTF-8
91334d
Content-Transfer-Encoding: 8bit
91334d
91334d
if the statusbar hadn't got space for the initial label, then it doesn't get set a position,
91334d
so when later forced visible it draws at 0,0
91334d
91334d
call Resize on the toolbox to get it to relayout, and while we're at it
91334d
set the required size of the label so we might have space for it if that
91334d
text is shorter than the original len allocation
91334d
91334d
Change-Id: I37d20125d8195b2c75e83e9673c82c2011ceda8e
91334d
Reviewed-on: https://gerrit.libreoffice.org/50041
91334d
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
91334d
Tested-by: Caolán McNamara <caolanm@redhat.com>
91334d
---
91334d
 svx/source/dialog/srchdlg.cxx | 48 ++++++++++++++++++++-----------------------
91334d
 1 file changed, 22 insertions(+), 26 deletions(-)
91334d
91334d
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
91334d
index 4cea924..50c19a3 100644
91334d
--- a/svx/source/dialog/srchdlg.cxx
91334d
+++ b/svx/source/dialog/srchdlg.cxx
91334d
@@ -2375,11 +2375,11 @@ SfxChildWinInfo SvxSearchDialogWrapper::GetInfo() const
91334d
 }
91334d
 
91334d
 
91334d
-static vcl::Window* lcl_GetSearchLabelWindow()
91334d
+static void lcl_SetSearchLabelWindow(const OUString& rStr)
91334d
 {
91334d
     SfxViewFrame* pViewFrame = SfxViewFrame::Current();
91334d
     if (!pViewFrame)
91334d
-        return nullptr;
91334d
+        return;
91334d
 
91334d
     css::uno::Reference< css::beans::XPropertySet > xPropSet(
91334d
             pViewFrame->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY_THROW);
91334d
@@ -2388,14 +2388,28 @@ static vcl::Window* lcl_GetSearchLabelWindow()
91334d
     css::uno::Reference< css::ui::XUIElement > xUIElement =
91334d
         xLayoutManager->getElement("private:resource/toolbar/findbar");
91334d
     if (!xUIElement.is())
91334d
-        return nullptr;
91334d
+        return;
91334d
     css::uno::Reference< css::awt::XWindow > xWindow(
91334d
             xUIElement->getRealInterface(), css::uno::UNO_QUERY_THROW);
91334d
     VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>( VCLUnoHelper::GetWindow(xWindow).get() );
91334d
-    for (size_t i = 0; pToolBox && i < pToolBox->GetItemCount(); ++i)
91334d
+    if (!pToolBox)
91334d
+        return;
91334d
+    for (size_t i = 0; i < pToolBox->GetItemCount(); ++i)
91334d
+    {
91334d
         if (pToolBox->GetItemCommand(i) == ".uno:SearchLabel")
91334d
-            return pToolBox->GetItemWindow(i);
91334d
-    return nullptr;
91334d
+        {
91334d
+            vcl::Window* pSearchLabel = pToolBox->GetItemWindow(i);
91334d
+            assert(pSearchLabel);
91334d
+            pSearchLabel->Hide();
91334d
+            pSearchLabel->SetText(rStr);
91334d
+            if (!rStr.isEmpty())
91334d
+            {
91334d
+                pSearchLabel->SetSizePixel(pSearchLabel->get_preferred_size());
91334d
+                pSearchLabel->Show();
91334d
+            }
91334d
+        }
91334d
+    }
91334d
+    pToolBox->Resize();
91334d
 }
91334d
 
91334d
 void SvxSearchDialogWrapper::SetSearchLabel(const SearchLabel& rSL)
91334d
@@ -2410,16 +2424,7 @@ void SvxSearchDialogWrapper::SetSearchLabel(const SearchLabel& rSL)
91334d
     else if (rSL == SearchLabel::NotFound)
91334d
         sStr = SVX_RESSTR(RID_SVXSTR_SEARCH_NOT_FOUND);
91334d
 
91334d
-    if (vcl::Window *pSearchLabel = lcl_GetSearchLabelWindow())
91334d
-    {
91334d
-        if (sStr.isEmpty())
91334d
-            pSearchLabel->Hide();
91334d
-        else
91334d
-        {
91334d
-            pSearchLabel->SetText(sStr);
91334d
-            pSearchLabel->Show();
91334d
-        }
91334d
-    }
91334d
+    lcl_SetSearchLabelWindow(sStr);
91334d
     if (SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>( SfxViewFrame::Current()->
91334d
             GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() )))
91334d
         pWrp->getDialog()->SetSearchLabel(sStr);
91334d
@@ -2428,16 +2433,7 @@ void SvxSearchDialogWrapper::SetSearchLabel(const SearchLabel& rSL)
91334d
 void SvxSearchDialogWrapper::SetSearchLabel(const OUString& sStr)
91334d
 {
91334d
 
91334d
-    if (vcl::Window *pSearchLabel = lcl_GetSearchLabelWindow())
91334d
-    {
91334d
-        if (sStr.isEmpty())
91334d
-            pSearchLabel->Hide();
91334d
-        else
91334d
-        {
91334d
-            pSearchLabel->SetText(sStr);
91334d
-            pSearchLabel->Show();
91334d
-        }
91334d
-    }
91334d
+    lcl_SetSearchLabelWindow(sStr);
91334d
     if (SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>( SfxViewFrame::Current()->
91334d
             GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() )))
91334d
         pWrp->getDialog()->SetSearchLabel(sStr);
91334d
-- 
91334d
2.14.3
91334d