diff --git svx/inc/srchdlg.hxx svx/inc/srchdlg.hxx index 69b5315..5cf88d0 100644 --- svx/inc/srchdlg.hxx +++ svx/inc/srchdlg.hxx @@ -177,6 +177,8 @@ public: INT32 GetTransliterationFlags() const; + void SetSaveToModule(bool b); + private: FixedText aSearchText; ComboBox aSearchLB; diff --git svx/source/dialog/srchdlg.cxx svx/source/dialog/srchdlg.cxx index d57c0a1..ddceeab 100644 --- svx/source/dialog/srchdlg.cxx +++ svx/source/dialog/srchdlg.cxx @@ -704,6 +704,11 @@ INT32 SvxSearchDialog::GetTransliterationFlags() const return nTransliterationFlags; } +void SvxSearchDialog::SetSaveToModule(bool b) +{ + pImpl->bSaveToModule = b; +} + // ----------------------------------------------------------------------- void SvxSearchDialog::ApplyTransliterationFlags_Impl( INT32 nSettings ) @@ -956,9 +961,36 @@ void SvxSearchDialog::CalculateDelta_Impl() // ----------------------------------------------------------------------- +namespace { + +class ToggleSaveToModule +{ +public: + ToggleSaveToModule(SvxSearchDialog& rDialog, bool bValue) : + mrDialog(rDialog), mbValue(bValue) + { + mrDialog.SetSaveToModule(mbValue); + } + + ~ToggleSaveToModule() + { + mrDialog.SetSaveToModule(!mbValue); + } +private: + SvxSearchDialog& mrDialog; + bool mbValue; +}; + +} + void SvxSearchDialog::Init_Impl( int bSearchPattern ) { DBG_ASSERT( pSearchItem, "SearchItem == 0" ); + + // We don't want to save any intermediate state to the module while the + // dialog is being initialized. + ToggleSaveToModule aNoModuleSave(*this, false); + bWriter = ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_WRITER ); pImpl->bMultiLineEdit = FALSE; @@ -1106,10 +1138,8 @@ void SvxSearchDialog::Init_Impl( int bSearchPattern ) aSimilarityBox.Check( pSearchItem->IsLevenshtein() ); bSet = TRUE; - pImpl->bSaveToModule = FALSE; FlagHdl_Impl( &aSimilarityBox ); FlagHdl_Impl( &aJapOptionsCB ); - pImpl->bSaveToModule = TRUE; FASTBOOL bDisableSearch = FALSE; SfxViewShell* pViewShell = SfxViewShell::Current(); @@ -1638,16 +1668,23 @@ IMPL_LINK( SvxSearchDialog, ModifyHdl_Impl, ComboBox *, pEd ) else bSet = FALSE; + // Calc allows searching for empty cells. + bool bAllowEmptySearch = (pSearchItem->GetAppFlag() == SVX_SEARCHAPP_CALC); + if ( pEd == &aSearchLB || pEd == &aReplaceLB ) { - xub_StrLen nLBTxtLen = aSearchLB.GetText().Len(), nTxtLen; + xub_StrLen nSrchTxtLen = aSearchLB.GetText().Len(); + xub_StrLen nReplTxtLen = 0; + if (bAllowEmptySearch) + nReplTxtLen = aReplaceLB.GetText().Len(); + xub_StrLen nAttrTxtLen = 0; if ( !pImpl->bMultiLineEdit ) - nTxtLen = aSearchAttrText.GetText().Len(); + nAttrTxtLen = aSearchAttrText.GetText().Len(); else - nTxtLen = pImpl->aSearchFormats.GetText().Len(); + nAttrTxtLen = pImpl->aSearchFormats.GetText().Len(); - if ( nLBTxtLen || nTxtLen ) + if (nSrchTxtLen || nReplTxtLen || nAttrTxtLen) { EnableControl_Impl( &aSearchBtn ); EnableControl_Impl( &aReplaceBtn );