svx/source/dialog/srchdlg.cxx |   42 +++++++++++++++++-------------------------
 1 file changed, 17 insertions(+), 25 deletions(-)

New commits:
commit 9a28fdb9f508204b886ddbc57d6a5aaa53ffc929
Author: Caolán McNamara <caol...@redhat.com>
Date:   Tue Feb 20 13:59:08 2018 +0000

    Resolves: rhbz#1546997 'search not found' at 0,0 when window too narrow
    
    if the statusbar hadn't got space for the initial label, then it doesn't 
get set a position,
    so when later forced visible it draws at 0,0
    
    call Resize on the toolbox to get it to relayout, and while we're at it
    set the required size of the label so we might have space for it if that
    text is shorter than the original len allocation
    
    Change-Id: I37d20125d8195b2c75e83e9673c82c2011ceda8e
    Reviewed-on: https://gerrit.libreoffice.org/50043
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>

diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index 2fbeeaf30088..e94f1da3b81c 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -2369,11 +2369,11 @@ SfxChildWinInfo SvxSearchDialogWrapper::GetInfo() const
 }
 
 
-static vcl::Window* lcl_GetSearchLabelWindow()
+static void lcl_SetSearchLabelWindow(const OUString& rStr)
 {
     SfxViewFrame* pViewFrame = SfxViewFrame::Current();
     if (!pViewFrame)
-        return nullptr;
+        return;
 
     css::uno::Reference< css::beans::XPropertySet > xPropSet(
             pViewFrame->GetFrame().GetFrameInterface(), 
css::uno::UNO_QUERY_THROW);
@@ -2382,7 +2382,7 @@ static vcl::Window* lcl_GetSearchLabelWindow()
     css::uno::Reference< css::ui::XUIElement > xUIElement =
         xLayoutManager->getElement("private:resource/toolbar/findbar");
     if (!xUIElement.is())
-        return nullptr;
+        return;
     css::uno::Reference< css::awt::XWindow > xWindow(
             xUIElement->getRealInterface(), css::uno::UNO_QUERY_THROW);
     VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>( 
VCLUnoHelper::GetWindow(xWindow).get() );
@@ -2390,9 +2390,19 @@ static vcl::Window* lcl_GetSearchLabelWindow()
     {
         sal_uInt16 id = pToolBox->GetItemId(i);
         if (pToolBox->GetItemCommand(id) == ".uno:SearchLabel")
-            return pToolBox->GetItemWindow(id);
+        {
+            vcl::Window* pSearchLabel = pToolBox->GetItemWindow(id);
+            assert(pSearchLabel);
+            pSearchLabel->Hide();
+            pSearchLabel->SetText(rStr);
+            if (!rStr.isEmpty())
+            {
+                pSearchLabel->SetSizePixel(pSearchLabel->get_preferred_size());
+                pSearchLabel->Show();
+            }
+        }
     }
-    return nullptr;
+    pToolBox->Resize();
 }
 
 void SvxSearchDialogWrapper::SetSearchLabel(const SearchLabel& rSL)
@@ -2407,16 +2417,7 @@ void SvxSearchDialogWrapper::SetSearchLabel(const 
SearchLabel& rSL)
     else if (rSL == SearchLabel::NotFound)
         sStr = SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND);
 
-    if (vcl::Window *pSearchLabel = lcl_GetSearchLabelWindow())
-    {
-        if (sStr.isEmpty())
-            pSearchLabel->Hide();
-        else
-        {
-            pSearchLabel->SetText(sStr);
-            pSearchLabel->Show();
-        }
-    }
+    lcl_SetSearchLabelWindow(sStr);
     if (SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>( 
SfxViewFrame::Current()->
             GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() )))
         pWrp->getDialog()->SetSearchLabel(sStr);
@@ -2425,16 +2426,7 @@ void SvxSearchDialogWrapper::SetSearchLabel(const 
SearchLabel& rSL)
 void SvxSearchDialogWrapper::SetSearchLabel(const OUString& sStr)
 {
 
-    if (vcl::Window *pSearchLabel = lcl_GetSearchLabelWindow())
-    {
-        if (sStr.isEmpty())
-            pSearchLabel->Hide();
-        else
-        {
-            pSearchLabel->SetText(sStr);
-            pSearchLabel->Show();
-        }
-    }
+    lcl_SetSearchLabelWindow(sStr);
     if (SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>( 
SfxViewFrame::Current()->
             GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() )))
         pWrp->getDialog()->SetSearchLabel(sStr);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to