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

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