bump product version to 5.0.4.1
[LibreOffice.git] / cui / source / options / optaboutconfig.cxx
blob9b4481b56089afce14933ba684866c0f0f39dba2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "optaboutconfig.hxx"
11 #include "optHeaderTabListbox.hxx"
13 #include <vcl/builderfactory.hxx>
14 #include <svtools/svlbitm.hxx>
15 #include <svtools/treelistentry.hxx>
16 #include <comphelper/processfactory.hxx>
17 #include <comphelper/sequence.hxx>
18 #include <com/sun/star/configuration/theDefaultProvider.hpp>
19 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
20 #include <com/sun/star/beans/NamedValue.hpp>
21 #include <com/sun/star/beans/Property.hpp>
22 #include <com/sun/star/beans/XProperty.hpp>
23 #include <com/sun/star/container/XNameAccess.hpp>
24 #include <com/sun/star/container/XNameReplace.hpp>
25 #include <com/sun/star/container/XHierarchicalName.hpp>
26 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
27 #include <com/sun/star/util/XChangesBatch.hpp>
28 #include <com/sun/star/i18n/TransliterationModules.hpp>
29 #include <com/sun/star/util/SearchFlags.hpp>
30 #include <unotools/textsearch.hxx>
32 #include <vector>
33 #include <boost/shared_ptr.hpp>
34 #include <iostream>
36 using namespace svx;
37 using namespace ::com::sun::star;
38 using namespace com::sun::star::uno;
39 using namespace com::sun::star::container;
41 #define SHORT_LEN_LIMIT 7
42 #define LONG_LEN_LIMIT 11
43 #define HYPER_LEN_LIMIT 20
45 struct Prop_Impl
47 OUString Name;
48 OUString Property;
49 Any Value;
51 Prop_Impl( const OUString& sName, const OUString& sProperty, const Any& aValue )
52 : Name( sName )
53 , Property( sProperty )
54 , Value( aValue )
58 VCL_BUILDER_FACTORY_ARGS(CuiCustomMultilineEdit,WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK)
60 void CuiCustomMultilineEdit::KeyInput( const KeyEvent& rKeyEvent )
62 bool bValid = false;
63 bool bNonSpace = rKeyEvent.GetKeyCode().GetCode() != KEY_SPACE;
64 if( bNumericOnly && bNonSpace )
66 const vcl::KeyCode& rKeyCode = rKeyEvent.GetKeyCode();
67 sal_uInt16 nGroup = rKeyCode.GetGroup();
68 sal_uInt16 nKey = rKeyCode.GetCode();
70 switch ( nGroup ) {
71 case KEYGROUP_NUM :
72 case KEYGROUP_CURSOR :
74 bValid = true;
75 break;
78 case KEYGROUP_MISC :
80 switch ( nKey ) {
81 case KEY_SUBTRACT :
82 case KEY_COMMA :
83 case KEY_POINT :
85 bValid = true;
86 break;
89 default :
91 if( nKey < KEY_ADD || nKey > KEY_EQUAL )
92 bValid = true;
93 break;
96 break;
99 default :
101 bValid = false;
102 break;
106 //Select all, Copy, Paste, Cut, Undo Keys
107 if ( !bValid && ( rKeyCode.IsMod1() && (
108 KEY_A == nKey || KEY_C == nKey || KEY_V == nKey || KEY_X == nKey || KEY_Z == nKey ) ) )
109 bValid = true;
111 else
112 bValid = true;
113 if( bValid )
114 Edit::KeyInput( rKeyEvent );
117 Size CuiCustomMultilineEdit::GetOptimalSize() const
119 return LogicToPixel(Size(150, GetTextHeight()), MAP_APPFONT);
122 CuiAboutConfigTabPage::CuiAboutConfigTabPage( vcl::Window* pParent/*, const SfxItemSet& rItemSet*/ ) :
123 ModelessDialog( pParent, "AboutConfig", "cui/ui/aboutconfigdialog.ui"),
124 m_pPrefCtrl( get<SvSimpleTableContainer>("preferences") ),
125 m_pResetBtn( get<PushButton>("reset") ),
126 m_pEditBtn( get<PushButton>("edit") ),
127 m_pSearchBtn( get<PushButton>("searchButton") ),
128 m_pSearchEdit( get<Edit>("searchEntry") ),
129 m_vectorOfModified(),
130 m_pPrefBox( VclPtr<SvSimpleTable>::Create(*m_pPrefCtrl, WB_SCROLL | WB_HSCROLL | WB_VSCROLL ) )
132 Size aControlSize(LogicToPixel(Size(385, 230), MAP_APPFONT));
133 m_pPrefCtrl->set_width_request(aControlSize.Width());
134 m_pPrefCtrl->set_height_request(aControlSize.Height());
136 m_pEditBtn->SetClickHdl( LINK( this, CuiAboutConfigTabPage, StandardHdl_Impl ) );
137 m_pResetBtn->SetClickHdl( LINK( this, CuiAboutConfigTabPage, ResetBtnHdl_Impl ) );
138 m_pPrefBox->SetDoubleClickHdl( LINK(this, CuiAboutConfigTabPage, StandardHdl_Impl) );
139 m_pSearchBtn->SetClickHdl( LINK(this, CuiAboutConfigTabPage, SearchHdl_Impl) );
141 m_pPrefBox->InsertHeaderEntry(get<FixedText>("preference")->GetText());
142 m_pPrefBox->InsertHeaderEntry(get<FixedText>("property")->GetText());
143 m_pPrefBox->InsertHeaderEntry(get<FixedText>("type")->GetText());
144 m_pPrefBox->InsertHeaderEntry(get<FixedText>("value")->GetText());
146 long aTabs[] = {4,0,0,0,0};
148 float fWidth = approximate_char_width();
150 aTabs[1] = 0;
151 aTabs[2] = aTabs[1] + fWidth * 65;
152 aTabs[3] = aTabs[2] + fWidth * 20;
153 aTabs[4] = aTabs[3] + fWidth * 8;
155 m_options.algorithmType = util::SearchAlgorithms_ABSOLUTE;
156 m_options.transliterateFlags |= i18n::TransliterationModules_IGNORE_CASE;
157 m_options.searchFlag |= (util::SearchFlags::REG_NOT_BEGINOFLINE |
158 util::SearchFlags::REG_NOT_ENDOFLINE);
160 m_pPrefBox->SetTabs(aTabs, MAP_PIXEL);
161 m_pPrefBox->SetAlternatingRowColors( true );
164 CuiAboutConfigTabPage::~CuiAboutConfigTabPage()
166 disposeOnce();
169 void CuiAboutConfigTabPage::dispose()
171 m_pPrefBox.disposeAndClear();
172 m_pPrefCtrl.clear();
173 m_pResetBtn.clear();
174 m_pEditBtn.clear();
175 m_pSearchBtn.clear();
176 m_pSearchEdit.clear();
177 ModelessDialog::dispose();
180 void CuiAboutConfigTabPage::InsertEntry(const OUString& rProp, const OUString& rStatus, const OUString& rType, const OUString& rValue)
182 SvTreeListEntry* pEntry = new SvTreeListEntry;
184 pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), false)); //It is needed, otherwise causes crash
185 pEntry->AddItem( new SvLBoxString( pEntry, 0, rProp));
186 pEntry->AddItem( new SvLBoxString( pEntry, 0, rStatus));
187 pEntry->AddItem( new SvLBoxString( pEntry, 0, rType));
188 pEntry->AddItem( new SvLBoxString( pEntry, 0, rValue));
190 m_pPrefBox->Insert( pEntry );
192 SvTreeListEntry* pEntryClone = new SvTreeListEntry;
193 pEntryClone->Clone( pEntry );
194 m_prefBoxEntries.push_back( pEntryClone );
197 void CuiAboutConfigTabPage::Reset()
199 m_pPrefBox->Clear();
201 m_vectorOfModified.clear();
202 m_pPrefBox->GetModel()->SetSortMode( SortNone );
204 m_pPrefBox->SetUpdateMode(false);
205 Reference< XNameAccess > xConfigAccess = getConfigAccess( "/", false );
206 FillItems( xConfigAccess );
207 m_pPrefBox->SetUpdateMode(true);
210 bool CuiAboutConfigTabPage::FillItemSet()
212 bool bModified = false;
214 std::vector< boost::shared_ptr< Prop_Impl > >::iterator pIter;
215 for( pIter = m_vectorOfModified.begin() ; pIter != m_vectorOfModified.end(); ++pIter )
217 Reference< XNameAccess > xUpdateAccess = getConfigAccess( (*pIter)->Name , true );
218 Reference< XNameReplace > xNameReplace( xUpdateAccess, UNO_QUERY_THROW );
220 xNameReplace->replaceByName( (*pIter)->Property, (*pIter)->Value );
221 bModified = true;
223 Reference< util::XChangesBatch > xChangesBatch( xUpdateAccess, UNO_QUERY_THROW );
224 xChangesBatch->commitChanges();
227 return bModified;
230 void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAccess)
232 OUString sPath = Reference< XHierarchicalName >(
233 xNameAccess, uno::UNO_QUERY_THROW )->getHierarchicalName();
234 uno::Sequence< OUString > seqItems = xNameAccess->getElementNames();
235 for( sal_Int32 i = 0; i < seqItems.getLength(); ++i )
237 Any aNode = xNameAccess->getByName( seqItems[i] );
239 bool bNotLeaf = false;
241 Reference< XNameAccess > xNextNameAccess;
244 xNextNameAccess = Reference< XNameAccess >(aNode, uno::UNO_QUERY);
245 bNotLeaf = xNextNameAccess.is();
247 catch (const RuntimeException& e)
249 SAL_WARN( "cui.options", "CuiAboutConfigTabPage: exception " << e.Message);
252 if (bNotLeaf)
254 // not leaf node
255 FillItems( xNextNameAccess );
257 else
259 // leaf node
260 OUString sType = aNode.getValueTypeName();
262 OUString sValue;
263 switch( aNode.getValueType().getTypeClass() )
265 case ::com::sun::star::uno::TypeClass_VOID:
266 break;
268 case ::com::sun::star::uno::TypeClass_BOOLEAN:
269 sValue = OUString::boolean( aNode.get<bool>() );
270 break;
272 case ::com::sun::star::uno::TypeClass_SHORT:
273 case ::com::sun::star::uno::TypeClass_LONG:
274 case ::com::sun::star::uno::TypeClass_HYPER:
275 sValue = OUString::number( aNode.get<sal_Int64>() );
276 break;
278 case ::com::sun::star::uno::TypeClass_DOUBLE:
279 sValue = OUString::number( aNode.get<double>() );
280 break;
282 case ::com::sun::star::uno::TypeClass_STRING:
283 sValue = aNode.get<OUString>();
284 break;
286 case ::com::sun::star::uno::TypeClass_SEQUENCE:
287 if( sType == "[]boolean" )
289 uno::Sequence<sal_Bool> seq = aNode.get< uno::Sequence<sal_Bool> >();
290 for( sal_Int32 j = 0; j != seq.getLength(); ++j )
292 if( j != 0 )
294 sValue += ",";
296 sValue += OUString::boolean( seq[j] );
299 else if( sType == "[]byte" )
301 uno::Sequence<sal_Int8> seq = aNode.get< uno::Sequence<sal_Int8> >();
302 for( sal_Int32 j = 0; j != seq.getLength(); ++j )
304 OUString s = OUString::number(
305 static_cast<sal_uInt8>(seq[j]), 16 );
306 if( s.getLength() == 1 )
308 sValue += "0";
310 sValue += s.toAsciiUpperCase();
313 else if( sType == "[][]byte" )
315 uno::Sequence< uno::Sequence<sal_Int8> > seq = aNode.get< uno::Sequence< uno::Sequence<sal_Int8> > >();
316 for( sal_Int32 j = 0; j != seq.getLength(); ++j )
318 if( j != 0 )
320 sValue += ",";
322 for( sal_Int32 k = 0; k != seq[j].getLength(); ++k )
324 OUString s = OUString::number(
325 static_cast<sal_uInt8>(seq[j][k]), 16 );
326 if( s.getLength() == 1 )
328 sValue += "0";
330 sValue += s.toAsciiUpperCase();
334 else if( sType == "[]short" )
336 uno::Sequence<sal_Int16> seq = aNode.get< uno::Sequence<sal_Int16> >();
337 for( sal_Int32 j = 0; j != seq.getLength(); ++j )
339 if( j != 0 )
341 sValue += ",";
343 sValue += OUString::number( seq[j] );
346 else if( sType == "[]long" )
348 uno::Sequence<sal_Int32> seq = aNode.get< uno::Sequence<sal_Int32> >();
349 for( sal_Int32 j = 0; j != seq.getLength(); ++j )
351 if( j != 0 )
353 sValue += ",";
355 sValue += OUString::number( seq[j] );
358 else if( sType == "[]hyper" )
360 uno::Sequence<sal_Int64> seq = aNode.get< uno::Sequence<sal_Int64> >();
361 for( sal_Int32 j = 0; j != seq.getLength(); ++j )
363 if( j != 0 )
365 sValue += ",";
367 sValue += OUString::number( seq[j] );
370 else if( sType == "[]double" )
372 uno::Sequence<double> seq = aNode.get< uno::Sequence<double> >();
373 for( sal_Int32 j = 0; j != seq.getLength(); ++j )
375 if( j != 0 )
377 sValue += ",";
379 sValue += OUString::number( seq[j] );
382 else if( sType == "[]string" )
384 uno::Sequence<OUString> seq = aNode.get< uno::Sequence<OUString> >();
385 for( sal_Int32 j = 0; j != seq.getLength(); ++j )
387 if( j != 0 )
389 sValue += ",";
391 sValue += seq[j];
394 else
396 SAL_WARN(
397 "cui.options",
398 "path \"" << sPath << "\" member " << seqItems[i]
399 << " of unsupported type " << sType);
401 break;
403 default:
404 SAL_WARN(
405 "cui.options",
406 "path \"" << sPath << "\" member " << seqItems[i]
407 << " of unsupported type " << sType);
408 break;
411 InsertEntry( sPath, seqItems[i], sType, sValue);
416 Reference< XNameAccess > CuiAboutConfigTabPage::getConfigAccess( const OUString& sNodePath, bool bUpdate )
418 uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
420 uno::Reference< lang::XMultiServiceFactory > xConfigProvider(
421 com::sun::star::configuration::theDefaultProvider::get( xContext ) );
423 beans::NamedValue aProperty;
424 aProperty.Name = "nodepath";
425 aProperty.Value = uno::makeAny( sNodePath );
427 uno::Sequence< uno::Any > aArgumentList( 1 );
428 aArgumentList[0] = uno::makeAny( aProperty );
430 OUString sAccessString;
432 if( bUpdate )
433 sAccessString = "com.sun.star.configuration.ConfigurationUpdateAccess";
434 else
435 sAccessString = "com.sun.star.configuration.ConfigurationAccess";
437 uno::Reference< container::XNameAccess > xNameAccess(
438 xConfigProvider->createInstanceWithArguments(
439 sAccessString, aArgumentList ),
440 uno::UNO_QUERY_THROW );
442 return xNameAccess;
445 void CuiAboutConfigTabPage::AddToModifiedVector( const boost::shared_ptr< Prop_Impl >& rProp )
447 bool isModifiedBefore = false;
448 //Check if value modified before
449 for( size_t nInd = 0; nInd < m_vectorOfModified.size() ; ++nInd )
451 if( rProp->Name == m_vectorOfModified[nInd]->Name && rProp->Property == m_vectorOfModified[nInd]->Property )
453 //property modified before. assing reference to the modified value
454 //do your changes on this object. They will be saved later.
455 m_vectorOfModified[nInd] = rProp;
456 isModifiedBefore = true;
457 break;
461 if( !isModifiedBefore )
462 m_vectorOfModified.push_back( rProp );
463 //property is not modified before
466 std::vector< OUString > CuiAboutConfigTabPage::commaStringToSequence( const OUString& rCommaSepString )
468 std::vector<OUString> tempVector;
470 sal_Int32 index = 0;
473 OUString word = rCommaSepString.getToken(0, static_cast<sal_Unicode> (','), index);
474 word = word.trim();
475 if( !word.isEmpty())
476 tempVector.push_back(word);
477 }while( index >= 0 );
478 return tempVector;
481 CuiAboutConfigValueDialog::CuiAboutConfigValueDialog( vcl::Window* pWindow,
482 const OUString& rValue,
483 int limit ) :
484 ModalDialog( pWindow, "AboutConfigValueDialog", "cui/ui/aboutconfigvaluedialog.ui" ),
485 m_pEDValue( get<CuiCustomMultilineEdit>("valuebox") )
487 m_pEDValue->bNumericOnly = ( limit !=0 );
488 m_pEDValue->SetMaxTextLen( limit == 0 ? EDIT_NOLIMIT : limit);
489 m_pEDValue->SetText( rValue );
493 CuiAboutConfigValueDialog::~CuiAboutConfigValueDialog()
495 disposeOnce();
498 void CuiAboutConfigValueDialog::dispose()
500 m_pEDValue.clear();
501 ModalDialog::dispose();
504 IMPL_LINK_NOARG( CuiAboutConfigTabPage, ResetBtnHdl_Impl )
506 Reset();
507 return 0;
510 IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl )
512 SvTreeListEntry* pEntry = m_pPrefBox->FirstSelected();
514 OUString sPropertyPath = SvTabListBox::GetEntryText( pEntry, 0 );
515 OUString sPropertyName = SvTabListBox::GetEntryText( pEntry, 1 );
516 OUString sPropertyType = SvTabListBox::GetEntryText( pEntry, 2 );
517 OUString sPropertyValue = SvTabListBox::GetEntryText( pEntry, 3 );
519 boost::shared_ptr< Prop_Impl > pProperty (new Prop_Impl( sPropertyPath, sPropertyName, makeAny( sPropertyValue ) ) );
521 bool bOpenDialog;
522 OUString sDialogValue;
523 OUString sNewValue;
525 if( sPropertyType == "boolean" )
527 bool bValue;
528 if( sPropertyValue == "true" )
530 sDialogValue = "false";
531 bValue = false;
533 else
535 sDialogValue = "true";
536 bValue = true;
539 pProperty->Value = uno::makeAny( bValue );
540 bOpenDialog = false;
542 else if ( sPropertyType == "void" )
544 bOpenDialog = false;
546 else
548 sDialogValue = sPropertyValue;
549 bOpenDialog = true;
554 if( bOpenDialog )
556 //Cosmetic length limit for integer values.
557 int limit=0;
558 if( sPropertyType == "short" )
559 limit = SHORT_LEN_LIMIT;
560 else if( sPropertyType == "long" )
561 limit = LONG_LEN_LIMIT;
562 else if( sPropertyType == "hyper" )
563 limit = HYPER_LEN_LIMIT;
565 VclPtrInstance<CuiAboutConfigValueDialog> pValueDialog(nullptr, sDialogValue, limit);
567 if( pValueDialog->Execute() == RET_OK )
569 sNewValue = pValueDialog->getValue();
570 if ( sPropertyType == "short")
572 sal_Int16 nShort;
573 sal_Int32 nNumb = sNewValue.toInt32();
575 //if the value is 0 and length is not 1, there is something wrong
576 if( !( nNumb==0 && sNewValue.getLength()!=1 ) && nNumb < SAL_MAX_INT16 && nNumb > SAL_MIN_INT16)
577 nShort = (sal_Int16) nNumb;
578 else
579 throw uno::Exception();
580 pProperty->Value = uno::makeAny( nShort );
582 else
583 if( sPropertyType == "long" )
585 sal_Int32 nLong = sNewValue.toInt32();
586 if( !( nLong==0 && sNewValue.getLength()!=1 ) && nLong < SAL_MAX_INT32 && nLong > SAL_MIN_INT32)
587 pProperty->Value = uno::makeAny( nLong );
588 else
589 throw uno::Exception();
591 else if( sPropertyType == "hyper")
593 sal_Int64 nHyper = sNewValue.toInt64();
594 if( !( nHyper==0 && sNewValue.getLength()!=1 ) && nHyper < SAL_MAX_INT32 && nHyper > SAL_MIN_INT32)
595 pProperty->Value = uno::makeAny( nHyper );
596 else
597 throw uno::Exception();
599 else if( sPropertyType == "double")
601 double nDoub = sNewValue.toDouble();
602 if( !( nDoub ==0 && sNewValue.getLength()!=1 ) && nDoub < SAL_MAX_INT32 && nDoub > SAL_MIN_INT32)
603 pProperty->Value = uno::makeAny( nDoub );
604 else
605 throw uno::Exception();
607 else if( sPropertyType == "float")
609 float nFloat = sNewValue.toFloat();
610 if( !( nFloat ==0 && sNewValue.getLength()!=1 ) && nFloat < SAL_MAX_INT32 && nFloat > SAL_MIN_INT32)
611 pProperty->Value = uno::makeAny( nFloat );
612 else
613 throw uno::Exception();
615 else if( sPropertyType == "string" )
617 pProperty->Value = uno::makeAny( sNewValue );
619 else if( sPropertyType == "[]short" )
621 //create string sequence from comma separated string
622 //uno::Sequence< OUString > seqStr;
623 std::vector< OUString > seqStr;
624 seqStr = commaStringToSequence( sNewValue );
626 //create appropriate sequence with same size as string sequence
627 uno::Sequence< sal_Int16 > seqShort( seqStr.size() );
628 //convert all strings to appropriate type
629 for( size_t i = 0; i < seqStr.size(); ++i )
631 seqShort[i] = (sal_Int16) seqStr[i].toInt32();
633 pProperty->Value = uno::makeAny( seqShort );
635 else if( sPropertyType == "[]long" )
637 std::vector< OUString > seqStrLong;
638 seqStrLong = commaStringToSequence( sNewValue );
640 uno::Sequence< sal_Int32 > seqLong( seqStrLong.size() );
641 for( size_t i = 0; i < seqStrLong.size(); ++i )
643 seqLong[i] = seqStrLong[i].toInt32();
645 pProperty->Value = uno::makeAny( seqLong );
647 else if( sPropertyType == "[]hyper" )
649 std::vector< OUString > seqStrHyper;
650 seqStrHyper = commaStringToSequence( sNewValue );
651 uno::Sequence< sal_Int64 > seqHyper( seqStrHyper.size() );
652 for( size_t i = 0; i < seqStrHyper.size(); ++i )
654 seqHyper[i] = seqStrHyper[i].toInt64();
656 pProperty->Value = uno::makeAny( seqHyper );
658 else if( sPropertyType == "[]double" )
660 std::vector< OUString > seqStrDoub;
661 seqStrDoub = commaStringToSequence( sNewValue );
662 uno::Sequence< double > seqDoub( seqStrDoub.size() );
663 for( size_t i = 0; i < seqStrDoub.size(); ++i )
665 seqDoub[i] = seqStrDoub[i].toDouble();
667 pProperty->Value = uno::makeAny( seqDoub );
669 else if( sPropertyType == "[]float" )
671 std::vector< OUString > seqStrFloat;
672 seqStrFloat = commaStringToSequence( sNewValue );
673 uno::Sequence< sal_Int16 > seqFloat( seqStrFloat.size() );
674 for( size_t i = 0; i < seqStrFloat.size(); ++i )
676 seqFloat[i] = seqStrFloat[i].toFloat();
678 pProperty->Value = uno::makeAny( seqFloat );
680 else if( sPropertyType == "[]string" )
682 pProperty->Value = uno::makeAny( comphelper::containerToSequence( commaStringToSequence( sNewValue )));
684 else //unknown
685 throw uno::Exception();
688 sDialogValue = sNewValue;
691 AddToModifiedVector( pProperty );
693 //update listbox value.
694 m_pPrefBox->SetEntryText( sDialogValue, pEntry, 3 );
695 //update m_prefBoxEntries
696 SvTreeListEntries::iterator it = std::find_if(m_prefBoxEntries.begin(), m_prefBoxEntries.end(),
697 [&sPropertyPath, &sPropertyName](SvTreeListEntry &entry) -> bool
699 return static_cast< SvLBoxString* >( entry.GetItem(1) )->GetText().equals( sPropertyPath ) &&
700 static_cast< SvLBoxString* >( entry.GetItem(2) )->GetText().equals( sPropertyName );
703 if (it != m_prefBoxEntries.end())
704 it->ReplaceItem( new SvLBoxString( &(*it), 0, sDialogValue ), 4 );
706 catch( uno::Exception& )
710 return 0;
713 IMPL_LINK_NOARG( CuiAboutConfigTabPage, SearchHdl_Impl)
715 m_pPrefBox->Clear();
716 m_pPrefBox->SetUpdateMode( false );
718 SvSortMode sortMode = m_pPrefBox->GetModel()->GetSortMode();
719 sal_uInt16 sortedCol = m_pPrefBox->GetSortedCol();
721 if( sortMode != SortNone )
722 m_pPrefBox->SortByCol( 0xFFFF );
724 if( m_pSearchEdit->GetText().isEmpty() )
726 for( auto it = m_prefBoxEntries.begin(); it != m_prefBoxEntries.end(); ++it )
728 SvTreeListEntry* pEntry = new SvTreeListEntry;
729 pEntry->Clone( &(*it) ) ;
730 m_pPrefBox->Insert( pEntry );
733 else
735 m_options.searchString = m_pSearchEdit->GetText();
736 utl::TextSearch textSearch( m_options );
738 for(auto it = m_prefBoxEntries.begin(); it != m_prefBoxEntries.end(); ++it)
740 sal_Int32 endPos, startPos = 0;
742 for(size_t i = 1; i < it->ItemCount(); ++i)
744 OUString scrTxt = static_cast< SvLBoxString* >( it->GetItem(i) )->GetText();
745 endPos = scrTxt.getLength();
746 if( textSearch.SearchForward( scrTxt, &startPos, &endPos ) )
748 SvTreeListEntry* pEntry = new SvTreeListEntry;
749 pEntry->Clone( &(*it) ) ;
750 m_pPrefBox->Insert( pEntry );
751 break;
757 if( sortMode != SortNone )
758 m_pPrefBox->SortByCol(sortedCol, sortMode == SortAscending);
760 m_pPrefBox->SetUpdateMode( true );
762 return 0;
765 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */