LCOV - code coverage report
Current view: top level - cui/source/dialogs - cuifmsearch.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 485 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 38 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <tools/debug.hxx>
      21             : #include <vcl/layout.hxx>
      22             : #include <vcl/svapp.hxx>
      23             : #include <dialmgr.hxx>
      24             : #include <sfx2/tabdlg.hxx>
      25             : #include <osl/mutex.hxx>
      26             : #include <sfx2/app.hxx>
      27             : #include <cuires.hrc>
      28             : #include <svx/fmsrccfg.hxx>
      29             : #include <svx/fmsrcimp.hxx>
      30             : #include "fmsearch.hrc"
      31             : #include "cuifmsearch.hxx"
      32             : #include <svx/srchdlg.hxx>
      33             : #include <svl/cjkoptions.hxx>
      34             : #include <com/sun/star/i18n/TransliterationModules.hpp>
      35             : #include <comphelper/processfactory.hxx>
      36             : #include <comphelper/string.hxx>
      37             : #include <svx/svxdlg.hxx>
      38             : #include <sal/macros.h>
      39             : #include <boost/scoped_ptr.hpp>
      40             : 
      41             : using namespace ::com::sun::star::uno;
      42             : using namespace ::com::sun::star::i18n;
      43             : using namespace ::svxform;
      44             : using namespace ::com::sun::star::sdbc;
      45             : using namespace ::com::sun::star::util;
      46             : 
      47             : #define MAX_HISTORY_ENTRIES     50
      48             : 
      49           0 : void FmSearchDialog::initCommon( const Reference< XResultSet >& _rxCursor )
      50             : {
      51             :     // init the engine
      52             :     DBG_ASSERT( m_pSearchEngine, "FmSearchDialog::initCommon: have no engine!" );
      53           0 :     m_pSearchEngine->SetProgressHandler(LINK(this, FmSearchDialog, OnSearchProgress));
      54             : 
      55             :     // some layout changes according to available CJK options
      56           0 :     SvtCJKOptions aCJKOptions;
      57           0 :     if (!aCJKOptions.IsJapaneseFindEnabled())
      58             :     {
      59             :         // hide the options for the japanese search
      60           0 :         m_pSoundsLikeCJK->Hide();
      61           0 :         m_pSoundsLikeCJKSettings->Hide();
      62             :     }
      63             : 
      64           0 :     if (!aCJKOptions.IsCJKFontEnabled())
      65             :     {
      66           0 :         m_pHalfFullFormsCJK->Hide();
      67             : 
      68             :         // never ignore the width (ignoring is expensive) if the option is not available at all
      69           0 :         m_pSearchEngine->SetIgnoreWidthCJK( false );
      70             :     }
      71             : 
      72             :     // some initial record texts
      73           0 :     m_pftRecord->SetText( OUString::number(_rxCursor->getRow()) );
      74           0 :     m_pbClose->SetHelpText(OUString());
      75           0 : }
      76             : 
      77           0 : FmSearchDialog::FmSearchDialog(vcl::Window* pParent, const OUString& sInitialText, const ::std::vector< OUString >& _rContexts, sal_Int16 nInitialContext,
      78             :     const Link<>& lnkContextSupplier)
      79             :     :ModalDialog(pParent, "RecordSearchDialog", "cui/ui/fmsearchdialog.ui")
      80             :     ,m_sCancel( Button::GetStandardText( StandardButtonType::Cancel ) )
      81             :     ,m_pPreSearchFocus( NULL )
      82             :     ,m_lnkContextSupplier(lnkContextSupplier)
      83           0 :     ,m_pConfig( NULL )
      84             : {
      85           0 :     get(m_prbSearchForText,"rbSearchForText");
      86           0 :     get(m_prbSearchForNull,"rbSearchForNull");
      87           0 :     get(m_prbSearchForNotNull,"rbSearchForNotNull");
      88           0 :     get(m_pcmbSearchText,"cmbSearchText");
      89           0 :     m_pcmbSearchText->set_width_request(m_pcmbSearchText->approximate_char_width() * 42);
      90           0 :     get(m_plbForm,"lbForm");
      91           0 :     m_plbForm->set_width_request(m_plbForm->approximate_char_width() * 42);
      92           0 :     get(m_prbAllFields,"rbAllFields");
      93           0 :     get(m_prbSingleField,"rbSingleField");
      94           0 :     get(m_plbField,"lbField");
      95           0 :     get(m_plbPosition,"lbPosition");
      96           0 :     get(m_pcbUseFormat,"cbUseFormat");
      97           0 :     get(m_pcbCase,"cbCase");
      98           0 :     get(m_pcbBackwards,"cbBackwards");
      99           0 :     get(m_pcbStartOver,"cbStartOver");
     100           0 :     get(m_pcbWildCard,"cbWildCard");
     101           0 :     get(m_pcbRegular,"cbRegular");
     102           0 :     get(m_pcbApprox,"cbApprox");
     103           0 :     get(m_ppbApproxSettings,"pbApproxSettings");
     104           0 :     get(m_pHalfFullFormsCJK,"HalfFullFormsCJK");
     105           0 :     get(m_pSoundsLikeCJK,"SoundsLikeCJK");
     106           0 :     get(m_pSoundsLikeCJKSettings,"SoundsLikeCJKSettings");
     107           0 :     get(m_pbSearchAgain,"pbSearchAgain");
     108           0 :     m_sSearch = m_pbSearchAgain->GetText();
     109           0 :     get(m_pftRecord,"ftRecord");
     110           0 :     get(m_pftHint,"ftHint");
     111           0 :     get(m_pftPosition,"ftPosition");
     112           0 :     get(m_pftForm,"ftForm");
     113           0 :     get(m_pbClose,"close");
     114             : 
     115             :     DBG_ASSERT(m_lnkContextSupplier.IsSet(), "FmSearchDialog::FmSearchDialog : have no ContextSupplier !");
     116             : 
     117           0 :     FmSearchContext fmscInitial;
     118           0 :     fmscInitial.nContext = nInitialContext;
     119           0 :     m_lnkContextSupplier.Call(&fmscInitial);
     120             :     DBG_ASSERT(fmscInitial.xCursor.is(), "FmSearchDialog::FmSearchDialog : invalid data supplied by ContextSupplier !");
     121             :     DBG_ASSERT(comphelper::string::getTokenCount(fmscInitial.strUsedFields, ';') == (sal_Int32)fmscInitial.arrFields.size(),
     122             :         "FmSearchDialog::FmSearchDialog : invalid data supplied by ContextSupplied !");
     123             : #if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
     124             :     for (sal_Int32 i=0; i<(sal_Int32)fmscInitial.arrFields.size(); ++i)
     125             :         DBG_ASSERT(fmscInitial.arrFields.at(i).is(), "FmSearchDialog::FmSearchDialog : invalid data supplied by ContextSupplier !");
     126             : #endif // (OSL_DEBUG_LEVEL > 1) || DBG_UTIL
     127             : 
     128           0 :     for (   ::std::vector< OUString >::const_iterator context = _rContexts.begin();
     129           0 :             context != _rContexts.end();
     130             :             ++context
     131             :         )
     132             :     {
     133           0 :         m_arrContextFields.push_back(OUString());
     134           0 :         m_plbForm->InsertEntry(*context);
     135             :     }
     136           0 :     m_plbForm->SelectEntryPos(nInitialContext);
     137             : 
     138           0 :     m_plbForm->SetSelectHdl(LINK(this, FmSearchDialog, OnContextSelection));
     139             : 
     140           0 :     if (m_arrContextFields.size() == 1)
     141             :     {
     142             :         // hide dispensable controls
     143           0 :         m_pftForm->Hide();
     144           0 :         m_plbForm->Hide();
     145             :     }
     146             : 
     147             :     m_pSearchEngine = new FmSearchEngine(
     148           0 :         ::comphelper::getProcessComponentContext(), fmscInitial.xCursor, fmscInitial.strUsedFields, fmscInitial.arrFields, SM_ALLOWSCHEDULE );
     149           0 :     initCommon( fmscInitial.xCursor );
     150             : 
     151           0 :     if ( !fmscInitial.sFieldDisplayNames.isEmpty() )
     152             :     {   // use the display names if supplied
     153             :         DBG_ASSERT(comphelper::string::getTokenCount(fmscInitial.sFieldDisplayNames, ';') == comphelper::string::getTokenCount(fmscInitial.strUsedFields, ';'),
     154             :             "FmSearchDialog::FmSearchDialog : invalid initial context description !");
     155           0 :         Init(fmscInitial.sFieldDisplayNames, sInitialText);
     156             :     }
     157             :     else
     158           0 :         Init(fmscInitial.strUsedFields, sInitialText);
     159           0 : }
     160             : 
     161           0 : FmSearchDialog::~FmSearchDialog()
     162             : {
     163           0 :     disposeOnce();
     164           0 : }
     165             : 
     166           0 : void FmSearchDialog::dispose()
     167             : {
     168           0 :     if (m_aDelayedPaint.IsActive())
     169           0 :         m_aDelayedPaint.Stop();
     170             : 
     171           0 :     SaveParams();
     172             : 
     173           0 :     delete m_pConfig;
     174           0 :     m_pConfig = NULL;
     175             : 
     176           0 :     delete m_pSearchEngine;
     177           0 :     m_pSearchEngine = NULL;
     178             : 
     179           0 :     m_prbSearchForText.clear();
     180           0 :     m_prbSearchForNull.clear();
     181           0 :     m_prbSearchForNotNull.clear();
     182           0 :     m_pcmbSearchText.clear();
     183           0 :     m_pftForm.clear();
     184           0 :     m_plbForm.clear();
     185           0 :     m_prbAllFields.clear();
     186           0 :     m_prbSingleField.clear();
     187           0 :     m_plbField.clear();
     188           0 :     m_pftPosition.clear();
     189           0 :     m_plbPosition.clear();
     190           0 :     m_pcbUseFormat.clear();
     191           0 :     m_pcbCase.clear();
     192           0 :     m_pcbBackwards.clear();
     193           0 :     m_pcbStartOver.clear();
     194           0 :     m_pcbWildCard.clear();
     195           0 :     m_pcbRegular.clear();
     196           0 :     m_pcbApprox.clear();
     197           0 :     m_ppbApproxSettings.clear();
     198           0 :     m_pHalfFullFormsCJK.clear();
     199           0 :     m_pSoundsLikeCJK.clear();
     200           0 :     m_pSoundsLikeCJKSettings.clear();
     201           0 :     m_pftRecord.clear();
     202           0 :     m_pftHint.clear();
     203           0 :     m_pbSearchAgain.clear();
     204           0 :     m_pbClose.clear();
     205           0 :     m_pPreSearchFocus.clear();
     206             : 
     207           0 :     ModalDialog::dispose();
     208           0 : }
     209             : 
     210           0 : void FmSearchDialog::Init(const OUString& strVisibleFields, const OUString& sInitialText)
     211             : {
     212             :     //the initialization of all the Controls
     213           0 :     m_prbSearchForText->SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
     214           0 :     m_prbSearchForNull->SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
     215           0 :     m_prbSearchForNotNull->SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
     216             : 
     217           0 :     m_prbAllFields->SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
     218           0 :     m_prbSingleField->SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
     219             : 
     220           0 :     m_pbSearchAgain->SetClickHdl(LINK(this, FmSearchDialog, OnClickedSearchAgain));
     221           0 :     m_ppbApproxSettings->SetClickHdl(LINK(this, FmSearchDialog, OnClickedSpecialSettings));
     222           0 :     m_pSoundsLikeCJKSettings->SetClickHdl(LINK(this, FmSearchDialog, OnClickedSpecialSettings));
     223             : 
     224           0 :     m_plbPosition->SetSelectHdl(LINK(this, FmSearchDialog, OnPositionSelected));
     225           0 :     m_plbField->SetSelectHdl(LINK(this, FmSearchDialog, OnFieldSelected));
     226             : 
     227           0 :     m_pcmbSearchText->SetModifyHdl(LINK(this, FmSearchDialog, OnSearchTextModified));
     228           0 :     m_pcmbSearchText->EnableAutocomplete(false);
     229           0 :     m_pcmbSearchText->SetGetFocusHdl(LINK(this, FmSearchDialog, OnFocusGrabbed));
     230             : 
     231           0 :     m_pcbUseFormat->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
     232           0 :     m_pcbBackwards->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
     233           0 :     m_pcbStartOver->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
     234           0 :     m_pcbCase->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
     235           0 :     m_pcbWildCard->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
     236           0 :     m_pcbRegular->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
     237           0 :     m_pcbApprox->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
     238           0 :     m_pHalfFullFormsCJK->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
     239           0 :     m_pSoundsLikeCJK->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
     240             : 
     241             :     // fill the listboxes
     242             :     // method of field comparison
     243             :     sal_uInt16 nResIds[] = {
     244             :         RID_STR_SEARCH_ANYWHERE,
     245             :         RID_STR_SEARCH_BEGINNING,
     246             :         RID_STR_SEARCH_END,
     247             :         RID_STR_SEARCH_WHOLE
     248           0 :     };
     249           0 :     for ( size_t i=0; i<SAL_N_ELEMENTS(nResIds); ++i )
     250           0 :         m_plbPosition->InsertEntry( OUString( CUI_RES( nResIds[i] ) ) );
     251           0 :     m_plbPosition->SelectEntryPos(MATCHING_ANYWHERE);
     252             : 
     253             :     // the field listbox
     254           0 :     for (sal_Int32 i=0; i < comphelper::string::getTokenCount(strVisibleFields, ';'); ++i)
     255           0 :         m_plbField->InsertEntry(strVisibleFields.getToken(i, ';'));
     256             : 
     257             : 
     258           0 :     m_pConfig = new FmSearchConfigItem;
     259           0 :     LoadParams();
     260             : 
     261           0 :     m_pcmbSearchText->SetText(sInitialText);
     262             :     // if the Edit-line has changed the text (e.g. because it contains
     263             :     // control characters, as can be the case with memo fields), I use
     264             :     // an empty OUString.
     265           0 :     OUString sRealSetText = m_pcmbSearchText->GetText();
     266           0 :     if (!sRealSetText.equals(sInitialText))
     267           0 :         m_pcmbSearchText->SetText(OUString());
     268           0 :     LINK(this, FmSearchDialog, OnSearchTextModified).Call(m_pcmbSearchText);
     269             : 
     270             :     // initial
     271           0 :     m_aDelayedPaint.SetTimeoutHdl(LINK(this, FmSearchDialog, OnDelayedPaint));
     272           0 :     m_aDelayedPaint.SetTimeout(500);
     273           0 :     EnableSearchUI(true);
     274             : 
     275           0 :     if ( m_prbSearchForText->IsChecked() )
     276           0 :         m_pcmbSearchText->GrabFocus();
     277             : 
     278           0 : }
     279             : 
     280           0 : bool FmSearchDialog::Close()
     281             : {
     282             :     // If the close button is disabled and ESC is pressed in a dialog,
     283             :     // then Frame will call Close anyway, which I don't want to happen
     284             :     // while I'm in the middle of a search (maybe one that's running
     285             :     // in its own thread)
     286           0 :     if (!m_pbClose->IsEnabled())
     287           0 :         return false;
     288           0 :     return ModalDialog::Close();
     289             : }
     290             : 
     291           0 : IMPL_LINK(FmSearchDialog, OnClickedFieldRadios, Button*, pButton)
     292             : {
     293           0 :     if ((pButton == m_prbSearchForText) || (pButton == m_prbSearchForNull) || (pButton == m_prbSearchForNotNull))
     294             :     {
     295           0 :         EnableSearchForDependees(true);
     296             :     }
     297             :     else
     298             :         // en- or disable field list box accordingly
     299           0 :         if (pButton == m_prbSingleField)
     300             :         {
     301           0 :             m_plbField->Enable();
     302           0 :             m_pSearchEngine->RebuildUsedFields(m_plbField->GetSelectEntryPos());
     303             :         }
     304             :         else
     305             :         {
     306           0 :             m_plbField->Disable();
     307           0 :             m_pSearchEngine->RebuildUsedFields(-1);
     308             :         }
     309             : 
     310           0 :     return 0;
     311             : }
     312             : 
     313           0 : IMPL_LINK_NOARG(FmSearchDialog, OnClickedSearchAgain)
     314             : {
     315           0 :     if (m_pbClose->IsEnabled())
     316             :     {   // the button has the function 'search'
     317           0 :         OUString strThisRoundText = m_pcmbSearchText->GetText();
     318             :         // to history
     319           0 :         m_pcmbSearchText->RemoveEntry(strThisRoundText);
     320           0 :         m_pcmbSearchText->InsertEntry(strThisRoundText, 0);
     321             :         // the remove/insert makes sure that a) the OUString does not appear twice and
     322             :         // that b) the last searched strings are at the beginning and limit the list length
     323           0 :         while (m_pcmbSearchText->GetEntryCount() > MAX_HISTORY_ENTRIES)
     324           0 :             m_pcmbSearchText->RemoveEntryAt(m_pcmbSearchText->GetEntryCount()-1);
     325             : 
     326             :         // take out the 'overflow' hint
     327           0 :         m_pftHint->SetText(OUString());
     328           0 :         m_pftHint->Invalidate();
     329             : 
     330           0 :         if (m_pcbStartOver->IsChecked())
     331             :         {
     332           0 :             m_pcbStartOver->Check(false);
     333           0 :             EnableSearchUI(false);
     334           0 :             if (m_prbSearchForText->IsChecked())
     335           0 :                 m_pSearchEngine->StartOver(strThisRoundText);
     336             :             else
     337           0 :                 m_pSearchEngine->StartOverSpecial(m_prbSearchForNull->IsChecked());
     338             :         }
     339             :         else
     340             :         {
     341           0 :             EnableSearchUI(false);
     342           0 :             if (m_prbSearchForText->IsChecked())
     343           0 :                 m_pSearchEngine->SearchNext(strThisRoundText);
     344             :             else
     345           0 :                 m_pSearchEngine->SearchNextSpecial(m_prbSearchForNull->IsChecked());
     346           0 :         }
     347             :     }
     348             :     else
     349             :     {   // the button has the function 'cancel'
     350             :         DBG_ASSERT(m_pSearchEngine->GetSearchMode() != SM_BRUTE, "FmSearchDialog, OnClickedSearchAgain : falscher Modus !");
     351             :             // the CancelButton is usually only disabled, when working in a thread or with reschedule
     352           0 :         m_pSearchEngine->CancelSearch();
     353             :             // the ProgressHandler is called when it's really finished, here it's only a demand
     354             :     }
     355           0 :     return 0;
     356             : }
     357             : 
     358           0 : IMPL_LINK(FmSearchDialog, OnClickedSpecialSettings, Button*, pButton )
     359             : {
     360           0 :     if (m_ppbApproxSettings == pButton)
     361             :     {
     362           0 :         boost::scoped_ptr<AbstractSvxSearchSimilarityDialog> pDlg;
     363             : 
     364           0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     365           0 :         if ( pFact )
     366           0 :             pDlg.reset(pFact->CreateSvxSearchSimilarityDialog( this, m_pSearchEngine->GetLevRelaxed(), m_pSearchEngine->GetLevOther(),
     367           0 :                         m_pSearchEngine->GetLevShorter(), m_pSearchEngine->GetLevLonger() ));
     368             :         DBG_ASSERT( pDlg, "FmSearchDialog, OnClickedSpecialSettings: could not load the dialog!" );
     369             : 
     370           0 :         if ( pDlg && pDlg->Execute() == RET_OK )
     371             :         {
     372           0 :             m_pSearchEngine->SetLevRelaxed( pDlg->IsRelaxed() );
     373           0 :             m_pSearchEngine->SetLevOther( pDlg->GetOther() );
     374           0 :             m_pSearchEngine->SetLevShorter(pDlg->GetShorter() );
     375           0 :             m_pSearchEngine->SetLevLonger( pDlg->GetLonger() );
     376           0 :         }
     377             :     }
     378           0 :     else if (m_pSoundsLikeCJKSettings == pButton)
     379             :     {
     380           0 :         SfxItemSet aSet( SfxGetpApp()->GetPool() );
     381           0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     382           0 :         if(pFact)
     383             :         {
     384           0 :             boost::scoped_ptr<AbstractSvxJSearchOptionsDialog> aDlg(pFact->CreateSvxJSearchOptionsDialog( this, aSet, m_pSearchEngine->GetTransliterationFlags() ));
     385             :             DBG_ASSERT(aDlg, "Dialog creation failed!");
     386           0 :             aDlg->Execute();
     387             : 
     388             : 
     389           0 :             sal_Int32 nFlags = aDlg->GetTransliterationFlags();
     390           0 :             m_pSearchEngine->SetTransliterationFlags(nFlags);
     391             : 
     392           0 :             m_pcbCase->Check(m_pSearchEngine->GetCaseSensitive());
     393           0 :             OnCheckBoxToggled( m_pcbCase );
     394           0 :             m_pHalfFullFormsCJK->Check( !m_pSearchEngine->GetIgnoreWidthCJK() );
     395           0 :             OnCheckBoxToggled( m_pHalfFullFormsCJK );
     396           0 :         }
     397             :     }
     398             : 
     399           0 :     return 0;
     400             : }
     401             : 
     402           0 : IMPL_LINK_NOARG(FmSearchDialog, OnSearchTextModified)
     403             : {
     404           0 :     if ((!m_pcmbSearchText->GetText().isEmpty()) || !m_prbSearchForText->IsChecked())
     405           0 :         m_pbSearchAgain->Enable();
     406             :     else
     407           0 :         m_pbSearchAgain->Disable();
     408             : 
     409           0 :     m_pSearchEngine->InvalidatePreviousLoc();
     410           0 :     return 0;
     411             : }
     412             : 
     413           0 : IMPL_LINK(FmSearchDialog, OnFocusGrabbed, ComboBox*,)
     414             : {
     415           0 :     m_pcmbSearchText->SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
     416           0 :     return 0;
     417             : }
     418             : 
     419           0 : IMPL_LINK(FmSearchDialog, OnPositionSelected, ListBox*, pBox)
     420             : {
     421             :     (void) pBox; // avoid warning
     422             :     DBG_ASSERT(pBox->GetSelectEntryCount() == 1, "FmSearchDialog::OnMethodSelected : unerwartet : nicht genau ein Eintrag selektiert !");
     423             : 
     424           0 :     m_pSearchEngine->SetPosition(m_plbPosition->GetSelectEntryPos());
     425           0 :     return 0;
     426             : }
     427             : 
     428           0 : IMPL_LINK(FmSearchDialog, OnFieldSelected, ListBox*, pBox)
     429             : {
     430             :     (void) pBox; // avoid warning
     431             :     DBG_ASSERT(pBox->GetSelectEntryCount() == 1, "FmSearchDialog::OnFieldSelected : unerwartet : nicht genau ein Eintrag selektiert !");
     432             : 
     433           0 :     m_pSearchEngine->RebuildUsedFields(m_prbAllFields->IsChecked() ? -1 : (sal_Int16)m_plbField->GetSelectEntryPos());
     434             :         // calls m_pSearchEngine->InvalidatePreviousLoc too
     435             : 
     436           0 :     sal_Int32 nCurrentContext = m_plbForm->GetSelectEntryPos();
     437           0 :     if (nCurrentContext != LISTBOX_ENTRY_NOTFOUND)
     438           0 :         m_arrContextFields[nCurrentContext] = OUString(m_plbField->GetSelectEntry());
     439           0 :     return 0;
     440             : }
     441             : 
     442           0 : IMPL_LINK(FmSearchDialog, OnCheckBoxToggled, CheckBox*, pBox)
     443             : {
     444           0 :     bool bChecked = pBox->IsChecked();
     445             : 
     446             :     // formatter or case -> pass on to the engine
     447           0 :     if (pBox == m_pcbUseFormat)
     448           0 :         m_pSearchEngine->SetFormatterUsing(bChecked);
     449           0 :     else if (pBox == m_pcbCase)
     450           0 :         m_pSearchEngine->SetCaseSensitive(bChecked);
     451             :     // direction -> pass on and reset the checkbox-text for StartOver
     452           0 :     else if (pBox == m_pcbBackwards)
     453             :     {
     454           0 :         m_pcbStartOver->SetText( OUString( CUI_RES( bChecked ? RID_STR_FROM_BOTTOM : RID_STR_FROM_TOP ) ) );
     455           0 :         m_pSearchEngine->SetDirection(!bChecked);
     456             :     }
     457             :     // similarity-search or regular expression
     458           0 :     else if ((pBox == m_pcbApprox) || (pBox == m_pcbRegular) || (pBox == m_pcbWildCard))
     459             :     {
     460           0 :         CheckBox* pBoxes[] = { m_pcbWildCard, m_pcbRegular, m_pcbApprox };
     461           0 :         for (sal_uInt32 i=0; i< SAL_N_ELEMENTS(pBoxes); ++i)
     462             :         {
     463           0 :             if (pBoxes[i] != pBox)
     464             :             {
     465           0 :                 if (bChecked)
     466           0 :                     pBoxes[i]->Disable();
     467             :                 else
     468           0 :                     pBoxes[i]->Enable();
     469             :             }
     470             :         }
     471             : 
     472             :         // pass on to the engine
     473           0 :         m_pSearchEngine->SetWildcard(m_pcbWildCard->IsEnabled() && m_pcbWildCard->IsChecked());
     474           0 :         m_pSearchEngine->SetRegular(m_pcbRegular->IsEnabled() && m_pcbRegular->IsChecked());
     475           0 :         m_pSearchEngine->SetLevenshtein(m_pcbApprox->IsEnabled() && m_pcbApprox->IsChecked());
     476             :             // (disabled boxes have to be passed to the engine as sal_False)
     477             : 
     478             :         // adjust the Position-Listbox (which is not allowed during Wildcard-search)
     479           0 :         if (pBox == m_pcbWildCard)
     480             :         {
     481           0 :             if (bChecked)
     482             :             {
     483           0 :                 m_pftPosition->Disable();
     484           0 :                 m_plbPosition->Disable();
     485             :             }
     486             :             else
     487             :             {
     488           0 :                 m_pftPosition->Enable();
     489           0 :                 m_plbPosition->Enable();
     490             :             }
     491             :         }
     492             : 
     493             :         // and the button for similarity-search
     494           0 :         if (pBox == m_pcbApprox)
     495             :         {
     496           0 :             if (bChecked)
     497           0 :                 m_ppbApproxSettings->Enable();
     498             :             else
     499           0 :                 m_ppbApproxSettings->Disable();
     500             :         }
     501             :     }
     502           0 :     else if (pBox == m_pHalfFullFormsCJK)
     503             :     {
     504             :         // forward to the search engine
     505           0 :         m_pSearchEngine->SetIgnoreWidthCJK( !bChecked );
     506             :     }
     507           0 :     else if (pBox == m_pSoundsLikeCJK)
     508             :     {
     509           0 :         m_pSoundsLikeCJKSettings->Enable(bChecked);
     510             : 
     511             :         // two other buttons which depend on this one
     512           0 :         bool bEnable =  (   m_prbSearchForText->IsChecked()
     513           0 :                             &&  !m_pSoundsLikeCJK->IsChecked()
     514             :                             )
     515           0 :                          || !SvtCJKOptions().IsJapaneseFindEnabled();
     516           0 :         m_pcbCase->Enable(bEnable);
     517           0 :         m_pHalfFullFormsCJK->Enable(bEnable);
     518             : 
     519             :         // forward to the search engine
     520           0 :         m_pSearchEngine->SetTransliteration( bChecked );
     521             :     }
     522             : 
     523           0 :     return 0;
     524             : }
     525             : 
     526           0 : void FmSearchDialog::InitContext(sal_Int16 nContext)
     527             : {
     528           0 :     FmSearchContext fmscContext;
     529           0 :     fmscContext.nContext = nContext;
     530             : 
     531             : #ifdef DBG_UTIL
     532             :     sal_uInt32 nResult =
     533             : #endif
     534           0 :     m_lnkContextSupplier.Call(&fmscContext);
     535             :     DBG_ASSERT(nResult > 0, "FmSearchDialog::InitContext : ContextSupplier didn't give me any controls !");
     536             : 
     537             :     // put the field names into the respective listbox
     538           0 :     m_plbField->Clear();
     539             : 
     540           0 :     if (!fmscContext.sFieldDisplayNames.isEmpty())
     541             :     {
     542             :         // use the display names if supplied
     543             :         DBG_ASSERT(comphelper::string::getTokenCount(fmscContext.sFieldDisplayNames, ';') == comphelper::string::getTokenCount(fmscContext.strUsedFields, ';'),
     544             :             "FmSearchDialog::InitContext : invalid context description supplied !");
     545           0 :         for (sal_Int32 i=0; i < comphelper::string::getTokenCount(fmscContext.sFieldDisplayNames, ';'); ++i)
     546           0 :             m_plbField->InsertEntry(fmscContext.sFieldDisplayNames.getToken(i, ';'));
     547             :     }
     548             :     else
     549             :     {
     550             :         // else use the field names
     551           0 :         for (sal_Int32 i=0; i < comphelper::string::getTokenCount(fmscContext.strUsedFields, ';'); ++i)
     552           0 :             m_plbField->InsertEntry(fmscContext.strUsedFields.getToken(i, ';'));
     553             :     }
     554             : 
     555           0 :     if (nContext < (sal_Int32)m_arrContextFields.size() && !m_arrContextFields[nContext].isEmpty())
     556             :     {
     557           0 :         m_plbField->SelectEntry(m_arrContextFields[nContext]);
     558             :     }
     559             :     else
     560             :     {
     561           0 :         m_plbField->SelectEntryPos(0);
     562           0 :         if (m_prbSingleField->IsChecked() && (m_plbField->GetEntryCount() > 1))
     563           0 :             m_plbField->GrabFocus();
     564             :     }
     565             : 
     566             :     m_pSearchEngine->SwitchToContext(fmscContext.xCursor, fmscContext.strUsedFields, fmscContext.arrFields,
     567           0 :         m_prbAllFields->IsChecked() ? -1 : 0);
     568             : 
     569           0 :     m_pftRecord->SetText(OUString::number(fmscContext.xCursor->getRow()));
     570           0 : }
     571             : 
     572           0 : IMPL_LINK( FmSearchDialog, OnContextSelection, ListBox*, pBox)
     573             : {
     574           0 :     InitContext(pBox->GetSelectEntryPos());
     575           0 :     return 0L;
     576             : }
     577             : 
     578           0 : void FmSearchDialog::EnableSearchUI(bool bEnable)
     579             : {
     580             :     // when the controls shall be disabled their paint is turned off and then turned on again after a delay
     581           0 :     if (!bEnable)
     582           0 :         EnableControlPaint(false);
     583             :     else
     584             :     {
     585           0 :         if (m_aDelayedPaint.IsActive())
     586           0 :             m_aDelayedPaint.Stop();
     587             :     }
     588             :     // (the whole thing goes on below)
     589             :     // this small intricateness hopfully leads to no flickering when turning the SearchUI off
     590             :     // and on again shortly after (like it's the case during a short search process)
     591             : 
     592           0 :     if ( !bEnable )
     593             :     {
     594             :         // if one of my children has the focus, remember it
     595           0 :         vcl::Window* pFocusWindow = Application::GetFocusWindow( );
     596           0 :         if ( pFocusWindow && IsChild( pFocusWindow ) )
     597           0 :             m_pPreSearchFocus = pFocusWindow;
     598             :         else
     599           0 :             m_pPreSearchFocus = NULL;
     600             :     }
     601             : 
     602             :     // the search button has two functions -> adjust its text accordingly
     603           0 :     OUString sButtonText( bEnable ? m_sSearch : m_sCancel );
     604           0 :     m_pbSearchAgain->SetText( sButtonText );
     605             : 
     606           0 :     if (m_pSearchEngine->GetSearchMode() != SM_BRUTE)
     607             :     {
     608           0 :         m_prbSearchForText->Enable    (bEnable);
     609           0 :         m_prbSearchForNull->Enable    (bEnable);
     610           0 :         m_prbSearchForNotNull->Enable (bEnable);
     611           0 :         m_plbForm->Enable             (bEnable);
     612           0 :         m_prbAllFields->Enable        (bEnable);
     613           0 :         m_prbSingleField->Enable      (bEnable);
     614           0 :         m_plbField->Enable            (bEnable && m_prbSingleField->IsChecked());
     615           0 :         m_pcbBackwards->Enable        (bEnable);
     616           0 :         m_pcbStartOver->Enable        (bEnable);
     617           0 :         m_pbClose->Enable            (bEnable);
     618           0 :         EnableSearchForDependees    (bEnable);
     619             : 
     620           0 :         if ( !bEnable )
     621             :         {   // this means we're preparing for starting a search
     622             :             // In this case, EnableSearchForDependees disabled the search button
     623             :             // But as we're about to use it for cancelling the search, we really need to enable it, again
     624           0 :             m_pbSearchAgain->Enable( true );
     625             :         }
     626             :     }
     627             : 
     628           0 :     if (!bEnable)
     629           0 :         m_aDelayedPaint.Start();
     630             :     else
     631           0 :         EnableControlPaint(true);
     632             : 
     633           0 :     if ( bEnable )
     634             :     {   // restore focus
     635           0 :         if ( m_pPreSearchFocus )
     636             :         {
     637           0 :             m_pPreSearchFocus->GrabFocus();
     638           0 :             if ( WINDOW_EDIT == m_pPreSearchFocus->GetType() )
     639             :             {
     640           0 :                 Edit* pEdit = static_cast< Edit* >( m_pPreSearchFocus.get() );
     641           0 :                 pEdit->SetSelection( Selection( 0, pEdit->GetText().getLength() ) );
     642             :             }
     643             :         }
     644           0 :         m_pPreSearchFocus = NULL;
     645           0 :     }
     646             : 
     647           0 : }
     648             : 
     649           0 : void FmSearchDialog::EnableSearchForDependees(bool bEnable)
     650             : {
     651           0 :     bool bSearchingForText = m_prbSearchForText->IsChecked();
     652           0 :     m_pbSearchAgain->Enable(bEnable && (!bSearchingForText || (!m_pcmbSearchText->GetText().isEmpty())));
     653             : 
     654           0 :     bEnable = bEnable && bSearchingForText;
     655             : 
     656           0 :     bool bEnableRedundants = !m_pSoundsLikeCJK->IsChecked() || !SvtCJKOptions().IsJapaneseFindEnabled();
     657             : 
     658           0 :     m_pcmbSearchText->Enable          (bEnable);
     659           0 :     m_pftPosition->Enable             (bEnable && !m_pcbWildCard->IsChecked());
     660           0 :     m_pcbWildCard->Enable             (bEnable && !m_pcbRegular->IsChecked() && !m_pcbApprox->IsChecked());
     661           0 :     m_pcbRegular->Enable              (bEnable && !m_pcbWildCard->IsChecked() && !m_pcbApprox->IsChecked());
     662           0 :     m_pcbApprox->Enable               (bEnable && !m_pcbWildCard->IsChecked() && !m_pcbRegular->IsChecked());
     663           0 :     m_ppbApproxSettings->Enable       (bEnable && m_pcbApprox->IsChecked());
     664           0 :     m_pHalfFullFormsCJK->Enable      (bEnable && bEnableRedundants);
     665           0 :     m_pSoundsLikeCJK->Enable         (bEnable);
     666           0 :     m_pSoundsLikeCJKSettings->Enable (bEnable && m_pSoundsLikeCJK->IsChecked());
     667           0 :     m_plbPosition->Enable             (bEnable && !m_pcbWildCard->IsChecked());
     668           0 :     m_pcbUseFormat->Enable            (bEnable);
     669           0 :     m_pcbCase->Enable                 (bEnable && bEnableRedundants);
     670           0 : }
     671             : 
     672           0 : void FmSearchDialog::EnableControlPaint(bool bEnable)
     673             : {
     674             :     Control* pAffectedControls[] = { m_prbSearchForText, m_pcmbSearchText, m_prbSearchForNull, m_prbSearchForNotNull,
     675             :         m_prbSearchForText, m_prbAllFields, m_prbSingleField, m_plbField, m_pftPosition, m_plbPosition,
     676             :         m_pcbUseFormat, m_pcbCase, m_pcbBackwards, m_pcbStartOver, m_pcbWildCard, m_pcbRegular, m_pcbApprox, m_ppbApproxSettings,
     677           0 :         m_pbSearchAgain, m_pbClose };
     678             : 
     679           0 :     if (!bEnable)
     680           0 :         for (sal_uInt32 i=0; i<SAL_N_ELEMENTS(pAffectedControls); ++i)
     681             :         {
     682           0 :             pAffectedControls[i]->SetUpdateMode(bEnable);
     683           0 :             pAffectedControls[i]->EnablePaint(bEnable);
     684             :         }
     685             :     else
     686           0 :         for (sal_uInt32 i=0; i<SAL_N_ELEMENTS(pAffectedControls); ++i)
     687             :         {
     688           0 :             pAffectedControls[i]->EnablePaint(bEnable);
     689           0 :             pAffectedControls[i]->SetUpdateMode(bEnable);
     690             :         }
     691           0 : }
     692             : 
     693           0 : IMPL_LINK_NOARG_TYPED(FmSearchDialog, OnDelayedPaint, Timer *, void)
     694             : {
     695           0 :     EnableControlPaint(true);
     696           0 : }
     697             : 
     698           0 : void FmSearchDialog::OnFound(const ::com::sun::star::uno::Any& aCursorPos, sal_Int16 nFieldPos)
     699             : {
     700           0 :     FmFoundRecordInformation friInfo;
     701           0 :     friInfo.nContext = m_plbForm->GetSelectEntryPos();
     702             :     // if I don't do a search in a context, this has an invalid value - but then it doesn't matter anyway
     703           0 :     friInfo.aPosition = aCursorPos;
     704           0 :     if (m_prbAllFields->IsChecked())
     705           0 :         friInfo.nFieldPos = nFieldPos;
     706             :     else
     707           0 :         friInfo.nFieldPos = m_plbField->GetSelectEntryPos();
     708             :         // this of course implies that I have really searched in the field that is selected in the listbox,
     709             :         // which is made sure in RebuildUsedFields
     710             : 
     711           0 :     m_lnkFoundHandler.Call(&friInfo);
     712             : 
     713           0 :     m_pcmbSearchText->GrabFocus();
     714           0 : }
     715             : 
     716           0 : IMPL_LINK(FmSearchDialog, OnSearchProgress, FmSearchProgress*, pProgress)
     717             : {
     718           0 :     SolarMutexGuard aGuard;
     719             :         // make this single method thread-safe (it's an overkill to block the whole application for this,
     720             :         // but we don't have another safety concept at the moment)
     721             : 
     722           0 :     switch (pProgress->aSearchState)
     723             :     {
     724             :         case FmSearchProgress::STATE_PROGRESS:
     725           0 :             if (pProgress->bOverflow)
     726             :             {
     727           0 :                 OUString sHint( CUI_RES( m_pcbBackwards->IsChecked() ? RID_STR_OVERFLOW_BACKWARD : RID_STR_OVERFLOW_FORWARD ) );
     728           0 :                 m_pftHint->SetText( sHint );
     729           0 :                 m_pftHint->Invalidate();
     730             :             }
     731             : 
     732           0 :             m_pftRecord->SetText(OUString::number(1 + pProgress->nCurrentRecord));
     733           0 :             m_pftRecord->Invalidate();
     734           0 :             break;
     735             : 
     736             :         case FmSearchProgress::STATE_PROGRESS_COUNTING:
     737           0 :             m_pftHint->SetText(CUI_RESSTR(RID_STR_SEARCH_COUNTING));
     738           0 :             m_pftHint->Invalidate();
     739             : 
     740           0 :             m_pftRecord->SetText(OUString::number(pProgress->nCurrentRecord));
     741           0 :             m_pftRecord->Invalidate();
     742           0 :             break;
     743             : 
     744             :         case FmSearchProgress::STATE_SUCCESSFULL:
     745           0 :             OnFound(pProgress->aBookmark, (sal_Int16)pProgress->nFieldIndex);
     746           0 :             EnableSearchUI(true);
     747           0 :             break;
     748             : 
     749             :         case FmSearchProgress::STATE_ERROR:
     750             :         case FmSearchProgress::STATE_NOTHINGFOUND:
     751             :         {
     752           0 :             sal_uInt16 nErrorId = (FmSearchProgress::STATE_ERROR == pProgress->aSearchState)
     753             :                 ? RID_STR_SEARCH_GENERAL_ERROR
     754           0 :                 : RID_STR_SEARCH_NORECORD;
     755           0 :             ScopedVclPtrInstance<MessageDialog>::Create(this, CUI_RES(nErrorId))->Execute();
     756             :         }
     757             :             // NO break !
     758             :         case FmSearchProgress::STATE_CANCELED:
     759           0 :             EnableSearchUI(true);
     760           0 :             if (m_lnkCanceledNotFoundHdl.IsSet())
     761             :             {
     762           0 :                 FmFoundRecordInformation friInfo;
     763           0 :                 friInfo.nContext = m_plbForm->GetSelectEntryPos();
     764             :                 // if I don't do a search in a context, this has an invalid value - but then it doesn't matter anyway
     765           0 :                 friInfo.aPosition = pProgress->aBookmark;
     766           0 :                 m_lnkCanceledNotFoundHdl.Call(&friInfo);
     767             :             }
     768           0 :             break;
     769             :     }
     770             : 
     771           0 :     m_pftRecord->SetText(OUString::number(1 + pProgress->nCurrentRecord));
     772             : 
     773           0 :     return 0L;
     774             : }
     775             : 
     776           0 : void FmSearchDialog::LoadParams()
     777             : {
     778           0 :     FmSearchParams aParams(m_pConfig->getParams());
     779             : 
     780           0 :     const OUString* pHistory     =                   aParams.aHistory.getConstArray();
     781           0 :     const OUString* pHistoryEnd  =   pHistory    +   aParams.aHistory.getLength();
     782           0 :     for (; pHistory != pHistoryEnd; ++pHistory)
     783           0 :         m_pcmbSearchText->InsertEntry( *pHistory );
     784             : 
     785             :     // I do the settings at my UI-elements and then I simply call the respective change-handler,
     786             :     // that way the data is handed on to the SearchEngine and all dependent settings are done
     787             : 
     788             :     // current field
     789           0 :     sal_Int32 nInitialField = m_plbField->GetEntryPos( OUString( aParams.sSingleSearchField ) );
     790           0 :     if (nInitialField == LISTBOX_ENTRY_NOTFOUND)
     791           0 :         nInitialField = 0;
     792           0 :     m_plbField->SelectEntryPos(nInitialField);
     793           0 :     LINK(this, FmSearchDialog, OnFieldSelected).Call(m_plbField);
     794             :     // all fields/single field (AFTER selcting the field because OnClickedFieldRadios expects a valid value there)
     795           0 :     if (aParams.bAllFields)
     796             :     {
     797           0 :         m_prbSingleField->Check(false);
     798           0 :         m_prbAllFields->Check(true);
     799           0 :         LINK(this, FmSearchDialog, OnClickedFieldRadios).Call(m_prbAllFields);
     800             :         // OnClickedFieldRadios also calls to RebuildUsedFields
     801             :     }
     802             :     else
     803             :     {
     804           0 :         m_prbAllFields->Check(false);
     805           0 :         m_prbSingleField->Check(true);
     806           0 :         LINK(this, FmSearchDialog, OnClickedFieldRadios).Call(m_prbSingleField);
     807             :     }
     808             : 
     809           0 :     m_plbPosition->SelectEntryPos(aParams.nPosition);
     810           0 :     LINK(this, FmSearchDialog, OnPositionSelected).Call(m_plbPosition);
     811             : 
     812             :     // field formatting/case sensitivity/direction
     813           0 :     m_pcbUseFormat->Check(aParams.bUseFormatter);
     814           0 :     m_pcbCase->Check( aParams.isCaseSensitive() );
     815           0 :     m_pcbBackwards->Check(aParams.bBackwards);
     816           0 :     LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(m_pcbUseFormat);
     817           0 :     LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(m_pcbCase);
     818           0 :     LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(m_pcbBackwards);
     819             : 
     820           0 :     m_pHalfFullFormsCJK->Check( !aParams.isIgnoreWidthCJK( ) );  // BEWARE: this checkbox has a inverse semantics!
     821           0 :     m_pSoundsLikeCJK->Check( aParams.bSoundsLikeCJK );
     822           0 :     LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(m_pHalfFullFormsCJK);
     823           0 :     LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(m_pSoundsLikeCJK);
     824             : 
     825           0 :     m_pcbWildCard->Check(false);
     826           0 :     m_pcbRegular->Check(false);
     827           0 :     m_pcbApprox->Check(false);
     828           0 :     LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(m_pcbWildCard);
     829           0 :     LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(m_pcbRegular);
     830           0 :     LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(m_pcbApprox);
     831             : 
     832           0 :     CheckBox* pToCheck = NULL;
     833           0 :     if (aParams.bWildcard)
     834           0 :         pToCheck = m_pcbWildCard;
     835           0 :     if (aParams.bRegular)
     836           0 :         pToCheck = m_pcbRegular;
     837           0 :     if (aParams.bApproxSearch)
     838           0 :         pToCheck = m_pcbApprox;
     839           0 :     if (aParams.bSoundsLikeCJK)
     840           0 :         pToCheck = m_pSoundsLikeCJK;
     841           0 :     if (pToCheck)
     842             :     {
     843           0 :         pToCheck->Check(true);
     844           0 :         LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(pToCheck);
     845             :     }
     846             : 
     847             :     // set Levenshtein-parameters directly at the SearchEngine
     848           0 :     m_pSearchEngine->SetLevRelaxed(aParams.bLevRelaxed);
     849           0 :     m_pSearchEngine->SetLevOther(aParams.nLevOther);
     850           0 :     m_pSearchEngine->SetLevShorter(aParams.nLevShorter);
     851           0 :     m_pSearchEngine->SetLevLonger(aParams.nLevLonger);
     852             : 
     853           0 :     m_pSearchEngine->SetTransliterationFlags( aParams.getTransliterationFlags( ) );
     854             : 
     855           0 :     m_prbSearchForText->Check(false);
     856           0 :     m_prbSearchForNull->Check(false);
     857           0 :     m_prbSearchForNotNull->Check(false);
     858           0 :     switch (aParams.nSearchForType)
     859             :     {
     860           0 :         case 1: m_prbSearchForNull->Check(true); break;
     861           0 :         case 2: m_prbSearchForNotNull->Check(true); break;
     862           0 :         default: m_prbSearchForText->Check(true); break;
     863             :     }
     864           0 :     LINK(this, FmSearchDialog, OnClickedFieldRadios).Call(m_prbSearchForText);
     865           0 : }
     866             : 
     867           0 : void FmSearchDialog::SaveParams() const
     868             : {
     869           0 :     if (!m_pConfig)
     870           0 :         return;
     871             : 
     872           0 :     FmSearchParams aCurrentSettings;
     873             : 
     874           0 :     aCurrentSettings.aHistory.realloc( m_pcmbSearchText->GetEntryCount() );
     875           0 :     OUString* pHistory = aCurrentSettings.aHistory.getArray();
     876           0 :     for (sal_Int32 i=0; i<m_pcmbSearchText->GetEntryCount(); ++i, ++pHistory)
     877           0 :         *pHistory = m_pcmbSearchText->GetEntry(i);
     878             : 
     879           0 :     aCurrentSettings.sSingleSearchField         = m_plbField->GetSelectEntry();
     880           0 :     aCurrentSettings.bAllFields                 = m_prbAllFields->IsChecked();
     881           0 :     aCurrentSettings.nPosition                  = m_pSearchEngine->GetPosition();
     882           0 :     aCurrentSettings.bUseFormatter              = m_pSearchEngine->GetFormatterUsing();
     883           0 :     aCurrentSettings.setCaseSensitive           ( m_pSearchEngine->GetCaseSensitive() );
     884           0 :     aCurrentSettings.bBackwards                 = !m_pSearchEngine->GetDirection();
     885           0 :     aCurrentSettings.bWildcard                  = m_pSearchEngine->GetWildcard();
     886           0 :     aCurrentSettings.bRegular                   = m_pSearchEngine->GetRegular();
     887           0 :     aCurrentSettings.bApproxSearch              = m_pSearchEngine->GetLevenshtein();
     888           0 :     aCurrentSettings.bLevRelaxed                = m_pSearchEngine->GetLevRelaxed();
     889           0 :     aCurrentSettings.nLevOther                  = m_pSearchEngine->GetLevOther();
     890           0 :     aCurrentSettings.nLevShorter                = m_pSearchEngine->GetLevShorter();
     891           0 :     aCurrentSettings.nLevLonger                 = m_pSearchEngine->GetLevLonger();
     892             : 
     893           0 :     aCurrentSettings.bSoundsLikeCJK             = m_pSearchEngine->GetTransliteration();
     894           0 :     aCurrentSettings.setTransliterationFlags    ( m_pSearchEngine->GetTransliterationFlags() );
     895             : 
     896           0 :     if (m_prbSearchForNull->IsChecked())
     897           0 :         aCurrentSettings.nSearchForType = 1;
     898           0 :     else if (m_prbSearchForNotNull->IsChecked())
     899           0 :         aCurrentSettings.nSearchForType = 2;
     900             :     else
     901           0 :         aCurrentSettings.nSearchForType = 0;
     902             : 
     903           0 :     m_pConfig->setParams( aCurrentSettings );
     904           0 : }
     905             : 
     906             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11