Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi,

This patch make the mentioned Toolbar to remember the searched strings after
closing and reopening. Details in patch description.


Regards,
Zolnai Tamás
From 5fed6d6f3e4a18129ae9afa9a86c72ce7c5b37dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolnai=20Tam=C3=A1s?= <zolniatamas@caesar.elte.hu>
Date: Wed, 8 Aug 2012 20:50:35 +0200
Subject: [PATCH] fdo#49750 Search Toolbar keeps its history

Until now, only the ToolBar's TextField stored the history, but
this is destructed when ToolBar is closed. The "Manager" class is alive
in case of Toolbar's invisibility, so I made this class to store history
temporarly.

Change-Id: I816dd3c83440000ab4e6caaeb2cccf390d3042fd
---
 svx/inc/tbunosearchcontrollers.hxx             |    5 +++++
 svx/source/tbxctrls/tbunosearchcontrollers.cxx |   20 ++++++++++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/svx/inc/tbunosearchcontrollers.hxx b/svx/inc/tbunosearchcontrollers.hxx
index 032662c..91ddec8 100644
--- a/svx/inc/tbunosearchcontrollers.hxx
+++ b/svx/inc/tbunosearchcontrollers.hxx
@@ -46,6 +46,7 @@
 #include <vcl/window.hxx>
 
 #include <map>
+#include <vector>
 
 namespace css = ::com::sun::star        ;
 namespace svx
@@ -86,11 +87,15 @@ public:
     void freeController ( const css::uno::Reference< css::frame::XFrame >& xFrame, const 
css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& 
sCommandURL );
     css::uno::Reference< css::frame::XStatusListener > findController( const css::uno::Reference< 
css::frame::XFrame >& xFrame, const ::rtl::OUString& sCommandURL );
 
+    void saveSearchHistory(const FindTextFieldControl* m_pFindTextFieldControl);
+    void loadSearchHistory(FindTextFieldControl* m_pFindTextFieldControl);
+
 private:
 
     typedef ::comphelper::SequenceAsVector< css::beans::PropertyValue > 
SearchToolbarControllersVec;
     typedef ::std::map< css::uno::Reference< css::frame::XFrame >, SearchToolbarControllersVec > 
SearchToolbarControllersMap;
     SearchToolbarControllersMap aSearchToolbarControllersMap;
+    std::vector<rtl::OUString>    aSearchStrings;
 
 };
 
diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx 
b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
index e58bd7f..2ad1cb1 100644
--- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx
+++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
@@ -246,6 +246,24 @@ SearchToolbarControllersManager& 
SearchToolbarControllersManager::createControll
     return theSearchToolbarControllersManager::get();
 }
 
+void SearchToolbarControllersManager::saveSearchHistory(const FindTextFieldControl* 
m_pFindTextFieldControl)
+{
+    sal_uInt16 nECount( m_pFindTextFieldControl->GetEntryCount() );
+    aSearchStrings.resize( nECount );
+    for( sal_uInt16 i=0; i<nECount; ++i )
+    {
+        aSearchStrings[i] = m_pFindTextFieldControl->GetEntry(i);
+    }
+}
+
+void SearchToolbarControllersManager::loadSearchHistory(FindTextFieldControl* 
m_pFindTextFieldControl)
+{
+    for( sal_uInt16 i=0; i<aSearchStrings.size(); ++i )
+    {
+       m_pFindTextFieldControl->InsertEntry(aSearchStrings[i],i);
+    }
+}
+
 void SearchToolbarControllersManager::registryController( const css::uno::Reference< 
css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& 
xStatusListener, const ::rtl::OUString& sCommandURL )
 {
     SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame);
@@ -382,6 +400,7 @@ void SAL_CALL FindTextToolbarController::dispose() throw ( css::uno::RuntimeExce
     SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, 
css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), 
css::uno::UNO_QUERY), m_aCommandURL);
 
     svt::ToolboxController::dispose();
+    
SearchToolbarControllersManager::createControllersManager().saveSearchHistory(m_pFindTextFieldControl);
     delete m_pFindTextFieldControl;
     m_pFindTextFieldControl = 0;
 }
@@ -428,6 +447,7 @@ css::uno::Reference< css::awt::XWindow > SAL_CALL FindTextToolbarController::cre
         Size aSize(250, m_pFindTextFieldControl->GetTextHeight() + 200);
         m_pFindTextFieldControl->SetSizePixel( aSize );
         m_pFindTextFieldControl->SetModifyHdl(LINK(this, FindTextToolbarController, 
EditModifyHdl));
+        
SearchToolbarControllersManager::createControllersManager().loadSearchHistory(m_pFindTextFieldControl);
     }
     xItemWindow = VCLUnoHelper::GetInterface( m_pFindTextFieldControl );
 
-- 
1.7.7


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.