diff options
author | Palenik Mihály <palenik.mihaly@gmail.com> | 2015-02-04 18:27:35 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-02-05 10:54:49 +0000 |
commit | 1485acc3e86bf6c7e32672c6d36d86e3eb5ddc9e (patch) | |
tree | c64f5182f7cc27017f9e1c4580c1da9a71a90ab1 /cui/source | |
parent | 47230a036fe35b9a7a7c0609232849fcbb51efcc (diff) |
Implement search funtion in Expert Configuration dialog.
Change-Id: I5a594b3d6ef84b022ce4a92a865beba735d47113
Reviewed-on: https://gerrit.libreoffice.org/14322
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui/source')
-rw-r--r-- | cui/source/options/optaboutconfig.cxx | 79 | ||||
-rw-r--r-- | cui/source/options/optaboutconfig.hxx | 8 |
2 files changed, 85 insertions, 2 deletions
diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx index 87321458fff1..3b2b0f9113fc 100644 --- a/cui/source/options/optaboutconfig.cxx +++ b/cui/source/options/optaboutconfig.cxx @@ -24,6 +24,9 @@ #include <com/sun/star/container/XHierarchicalName.hpp> #include <com/sun/star/container/XHierarchicalNameAccess.hpp> #include <com/sun/star/util/XChangesBatch.hpp> +#include <com/sun/star/i18n/TransliterationModules.hpp> +#include <com/sun/star/util/SearchFlags.hpp> +#include <unotools/textsearch.hxx> #include <vector> #include <boost/shared_ptr.hpp> @@ -124,9 +127,10 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage( vcl::Window* pParent/*, const SfxI m_pPrefCtrl( get<SvSimpleTableContainer>("preferences") ), m_pResetBtn( get<PushButton>("reset") ), m_pEditBtn( get<PushButton>("edit") ), + m_pSearchBtn( get<PushButton>("searchButton") ), + m_pSearchEdit( get<Edit>("searchEntry") ), m_vectorOfModified(), - m_pPrefBox( new SvSimpleTable(*m_pPrefCtrl, - WB_SCROLL | WB_HSCROLL | WB_VSCROLL ) ) + m_pPrefBox( new SvSimpleTable(*m_pPrefCtrl, WB_SCROLL | WB_HSCROLL | WB_VSCROLL ) ) { Size aControlSize(LogicToPixel(Size(385, 230), MAP_APPFONT)); m_pPrefCtrl->set_width_request(aControlSize.Width()); @@ -135,6 +139,7 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage( vcl::Window* pParent/*, const SfxI m_pEditBtn->SetClickHdl( LINK( this, CuiAboutConfigTabPage, StandardHdl_Impl ) ); m_pResetBtn->SetClickHdl( LINK( this, CuiAboutConfigTabPage, ResetBtnHdl_Impl ) ); m_pPrefBox->SetDoubleClickHdl( LINK(this, CuiAboutConfigTabPage, StandardHdl_Impl) ); + m_pSearchBtn->SetClickHdl( LINK(this, CuiAboutConfigTabPage, SearchHdl_Impl) ); m_pPrefBox->InsertHeaderEntry(get<FixedText>("preference")->GetText()); m_pPrefBox->InsertHeaderEntry(get<FixedText>("property")->GetText()); @@ -150,6 +155,11 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage( vcl::Window* pParent/*, const SfxI aTabs[3] = aTabs[2] + fWidth * 20; aTabs[4] = aTabs[3] + fWidth * 8; + m_options.algorithmType = util::SearchAlgorithms_ABSOLUTE; + m_options.transliterateFlags |= i18n::TransliterationModules_IGNORE_CASE; + m_options.searchFlag |= (util::SearchFlags::REG_NOT_BEGINOFLINE | + util::SearchFlags::REG_NOT_ENDOFLINE); + m_pPrefBox->SetTabs(aTabs, MAP_PIXEL); m_pPrefBox->SetAlternatingRowColors( true ); } @@ -165,6 +175,10 @@ void CuiAboutConfigTabPage::InsertEntry(const OUString& rProp, const OUString& r pEntry->AddItem( new SvLBoxString( pEntry, 0, rValue)); m_pPrefBox->Insert( pEntry ); + + SvTreeListEntry* pEntryClone = new SvTreeListEntry; + pEntryClone->Clone( pEntry ); + m_prefBoxEntries.push_back( pEntryClone ); } void CuiAboutConfigTabPage::Reset() @@ -654,6 +668,15 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl ) //update listbox value. m_pPrefBox->SetEntryText( sDialogValue, pEntry, 3 ); + //update m_prefBoxEntries + SvTreeListEntries::iterator it = std::find_if(m_prefBoxEntries.begin(), m_prefBoxEntries.end(), + [sPropertyPath, sPropertyName](SvTreeListEntry &entry) -> bool + { + return static_cast< SvLBoxString* >( entry.GetItem(1) )->GetText().equals( sPropertyPath ) && + static_cast< SvLBoxString* >( entry.GetItem(2) )->GetText().equals( sPropertyName ); + } + ); + it->ReplaceItem( new SvLBoxString( &(*it), 0, sDialogValue ), 4 ); } catch( uno::Exception& ) { @@ -662,4 +685,56 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl ) return 0; } +IMPL_LINK_NOARG( CuiAboutConfigTabPage, SearchHdl_Impl) +{ + m_pPrefBox->Clear(); + m_pPrefBox->SetUpdateMode( false ); + + SvSortMode sortMode = m_pPrefBox->GetModel()->GetSortMode(); + sal_uInt16 sortedCol = m_pPrefBox->GetSortedCol(); + + if( sortMode != SortNone ) + m_pPrefBox->SortByCol( 0xFFFF ); + + if( m_pSearchEdit->GetText().isEmpty() ) + { + for( auto it = m_prefBoxEntries.begin(); it != m_prefBoxEntries.end(); ++it ) + { + SvTreeListEntry* pEntry = new SvTreeListEntry; + pEntry->Clone( &(*it) ) ; + m_pPrefBox->Insert( pEntry ); + } + } + else + { + m_options.searchString = m_pSearchEdit->GetText(); + utl::TextSearch textSearch( m_options ); + + for(auto it = m_prefBoxEntries.begin(); it != m_prefBoxEntries.end(); ++it) + { + sal_Int32 endPos, startPos = 0; + + for(size_t i = 1; i < it->ItemCount(); ++i) + { + OUString scrTxt = static_cast< SvLBoxString* >( it->GetItem(i) )->GetText(); + endPos = scrTxt.getLength(); + if( textSearch.SearchForward( scrTxt, &startPos, &endPos ) ) + { + SvTreeListEntry* pEntry = new SvTreeListEntry; + pEntry->Clone( &(*it) ) ; + m_pPrefBox->Insert( pEntry ); + break; + } + } + } + } + + if( sortMode != SortNone ) + m_pPrefBox->SortByCol(sortedCol, sortMode == SortAscending); + + m_pPrefBox->SetUpdateMode( true ); + + return 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/optaboutconfig.hxx b/cui/source/options/optaboutconfig.hxx index 4714cb2e01e5..dc19e4ae6539 100644 --- a/cui/source/options/optaboutconfig.hxx +++ b/cui/source/options/optaboutconfig.hxx @@ -12,6 +12,7 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/util/SearchOptions.hpp> #include <sfx2/tabdlg.hxx> #include <svtools/simptabl.hxx> @@ -45,15 +46,22 @@ private: SvSimpleTableContainer* m_pPrefCtrl; PushButton* m_pResetBtn; PushButton* m_pEditBtn; + PushButton* m_pSearchBtn; + Edit* m_pSearchEdit; std::vector< boost::shared_ptr< Prop_Impl > > m_vectorOfModified; boost::scoped_ptr< SvSimpleTable > m_pPrefBox; + //for search + ::com::sun::star::util::SearchOptions m_options; + SvTreeListEntries m_prefBoxEntries; + void AddToModifiedVector( const boost::shared_ptr< Prop_Impl >& rProp ); std::vector< OUString > commaStringToSequence( const OUString& rCommaSepString ); DECL_LINK( StandardHdl_Impl, void * ); DECL_LINK( ResetBtnHdl_Impl, void * ); + DECL_LINK( SearchHdl_Impl, void* ); public: CuiAboutConfigTabPage(vcl::Window* pParent); |