[Libreoffice-commits] core.git: include/svx svx/source

Jim Raykowski raykowj at gmail.com
Tue Mar 27 13:30:43 UTC 2018


 include/svx/srchdlg.hxx                        |    1 
 svx/source/dialog/srchdlg.cxx                  |   29 +++++++++++++++++++++++++
 svx/source/tbxctrls/tbunosearchcontrollers.cxx |   17 ++++++++++++--
 3 files changed, 44 insertions(+), 3 deletions(-)

New commits:
commit 464d95eca4e2febc0268fe3833f0596bb4ced005
Author: Jim Raykowski <raykowj at gmail.com>
Date:   Sun Mar 18 13:10:46 2018 -0800

    tdf#81925 Make messages show in Findbar searchlabel overflow toolbar
    
    ...and add a bit more horizontal space for messages
    
    Change-Id: I4a310d7a4a649860a36ce12b775bb6b275cd6ef5
    Reviewed-on: https://gerrit.libreoffice.org/51523
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/include/svx/srchdlg.hxx b/include/svx/srchdlg.hxx
index e949ea92fe43..cf0168ca3eea 100644
--- a/include/svx/srchdlg.hxx
+++ b/include/svx/srchdlg.hxx
@@ -101,6 +101,7 @@ public:
     SvxSearchDialog *getDialog () { return dialog;}
     static void SetSearchLabel(const SearchLabel& rSL);
     static void SetSearchLabel(const OUString& sStr);
+    static OUString GetSearchLabel();
     SFX_DECL_CHILDWINDOW_WITHID(SvxSearchDialogWrapper);
 };
 
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index 0e46b65fc6a4..99e6823b3cde 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -2406,6 +2406,35 @@ static void lcl_SetSearchLabelWindow(const OUString& rStr)
     pToolBox->Resize();
 }
 
+OUString SvxSearchDialogWrapper::GetSearchLabel()
+{
+    SfxViewFrame* pViewFrame = SfxViewFrame::Current();
+    if (!pViewFrame)
+        return OUString();
+
+    css::uno::Reference< css::beans::XPropertySet > xPropSet(
+            pViewFrame->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY_THROW);
+    css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
+    xPropSet->getPropertyValue("LayoutManager") >>= xLayoutManager;
+    css::uno::Reference< css::ui::XUIElement > xUIElement =
+        xLayoutManager->getElement("private:resource/toolbar/findbar");
+    if (!xUIElement.is())
+        return OUString();
+    css::uno::Reference< css::awt::XWindow > xWindow(
+            xUIElement->getRealInterface(), css::uno::UNO_QUERY_THROW);
+    VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>( VCLUnoHelper::GetWindow(xWindow).get() );
+    for (ToolBox::ImplToolItems::size_type i = 0; pToolBox && i < pToolBox->GetItemCount(); ++i)
+    {
+        sal_uInt16 id = pToolBox->GetItemId(i);
+        if (pToolBox->GetItemCommand(id) == ".uno:SearchLabel")
+        {
+            vcl::Window* pSearchLabel = pToolBox->GetItemWindow(id);
+            return pSearchLabel ? pSearchLabel->GetText() : OUString();
+        }
+    }
+    return OUString();
+}
+
 void SvxSearchDialogWrapper::SetSearchLabel(const SearchLabel& rSL)
 {
     OUString sStr;
diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
index e41751c6beac..5177177ebca3 100644
--- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx
+++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
@@ -1196,6 +1196,9 @@ public:
 
     // XStatusListener
     virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
+
+private:
+    VclPtr<vcl::Window> m_pSL;
 };
 
 SearchLabelToolboxController::SearchLabelToolboxController( const css::uno::Reference< css::uno::XComponentContext > & rxContext )
@@ -1250,6 +1253,7 @@ void SAL_CALL SearchLabelToolboxController::dispose()
     SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, m_aCommandURL);
 
     svt::ToolboxController::dispose();
+    m_pSL.disposeAndClear();
 }
 
 // XInitialization
@@ -1262,13 +1266,20 @@ void SAL_CALL SearchLabelToolboxController::initialize( const css::uno::Sequence
 // XStatusListener
 void SAL_CALL SearchLabelToolboxController::statusChanged( const css::frame::FeatureStateEvent& )
 {
+    if (m_pSL)
+    {
+        OUString aStr = SvxSearchDialogWrapper::GetSearchLabel();
+        m_pSL->SetText(aStr);
+        long aWidth = !aStr.isEmpty() ? m_pSL->get_preferred_size().getWidth() : 300;
+        m_pSL->SetSizePixel(Size(aWidth, m_pSL->get_preferred_size().getHeight()));
+    }
 }
 
 css::uno::Reference< css::awt::XWindow > SAL_CALL SearchLabelToolboxController::createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent )
 {
-    VclPtr<vcl::Window> pSL = VclPtr<FixedText>::Create(VCLUnoHelper::GetWindow( Parent ));
-    pSL->SetSizePixel(Size(250, 25));
-    return VCLUnoHelper::GetInterface(pSL);
+    m_pSL = VclPtr<FixedText>::Create(VCLUnoHelper::GetWindow( Parent ));
+    m_pSL->SetSizePixel(Size(300, 25));
+    return VCLUnoHelper::GetInterface(m_pSL);
 }
 
 // protocol handler for "vnd.sun.star.findbar:*" URLs


More information about the Libreoffice-commits mailing list