svx/source/tbxctrls/tbunosearchcontrollers.cxx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
New commits: commit 2b92546ee3aa3d56f64c68ff3e8e782b3c56dba4 Author: Miklos Vajna <vmik...@suse.cz> Date: Mon May 14 10:02:12 2012 +0200 fdo#49750 findbar: try to fill empty textfield with selected text Change-Id: I583bb91e7fc325557abcc0756506133112da895c diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index 4e63eef..5fddc89 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> +#include <com/sun/star/text/XTextRange.hpp> #include <com/sun/star/ui/XUIElement.hpp> #include <com/sun/star/util/URL.hpp> @@ -185,7 +186,24 @@ long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) case EVENT_GETFOCUS: if ( m_bToClearTextField ) { - SetText( String() ); + String aString; + + try + { + css::uno::Reference<css::frame::XController> xController(m_xFrame->getController(), css::uno::UNO_QUERY_THROW); + css::uno::Reference<css::frame::XModel> xModel(xController->getModel(), css::uno::UNO_QUERY_THROW); + css::uno::Reference<css::container::XIndexAccess> xIndexAccess(xModel->getCurrentSelection(), css::uno::UNO_QUERY_THROW); + if (xIndexAccess->getCount() > 0) + { + css::uno::Reference<css::text::XTextRange> xTextRange(xIndexAccess->getByIndex(0), css::uno::UNO_QUERY_THROW); + aString = xTextRange->getString(); + } + } + catch ( ... ) + { + } + + SetText( aString ); m_bToClearTextField = sal_False; } SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits