diff options
Diffstat (limited to 'svx/source/dialog/srchdlg.cxx')
-rw-r--r-- | svx/source/dialog/srchdlg.cxx | 122 |
1 files changed, 78 insertions, 44 deletions
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index 3e4d0d49f3..86987695f4 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,7 +29,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -// include --------------------------------------------------------------- +#include <sal/macros.h> #include <vcl/wrkwin.hxx> #include <vcl/morebtn.hxx> #include <vcl/msgbox.hxx> @@ -144,12 +145,12 @@ struct SearchDlg_Impl bDeltaCalculated( FALSE ), pRanges ( NULL ) { - aCommand1URL.Complete = aCommand1URL.Main = rtl::OUString::createFromAscii("vnd.sun.search:SearchViaComponent1"); - aCommand1URL.Protocol = rtl::OUString::createFromAscii("vnd.sun.search:"); - aCommand1URL.Path = rtl::OUString::createFromAscii("SearchViaComponent1"); - aCommand2URL.Complete = aCommand2URL.Main = rtl::OUString::createFromAscii("vnd.sun.search:SearchViaComponent2"); - aCommand2URL.Protocol = rtl::OUString::createFromAscii("vnd.sun.search:"); - aCommand2URL.Path = rtl::OUString::createFromAscii("SearchViaComponent2"); + aCommand1URL.Complete = aCommand1URL.Main = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.search:SearchViaComponent1")); + aCommand1URL.Protocol = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.search:")); + aCommand1URL.Path = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SearchViaComponent1")); + aCommand2URL.Complete = aCommand2URL.Main = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.search:SearchViaComponent2")); + aCommand2URL.Protocol = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.search:")); + aCommand2URL.Path = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SearchViaComponent2")); } ~SearchDlg_Impl() { delete[] pRanges; } }; @@ -498,7 +499,7 @@ void SvxSearchDialog::Construct_Impl() // vnd.sun.star::SearchViaComponent1 and 2 are supported const uno::Reference< frame::XFrame >xFrame = rBindings.GetActiveFrame(); const uno::Reference< frame::XDispatchProvider > xDispatchProv(xFrame, uno::UNO_QUERY); - rtl::OUString sTarget = rtl::OUString::createFromAscii("_self"); + rtl::OUString sTarget(RTL_CONSTASCII_USTRINGPARAM("_self")); bool bSearchComponent1 = false; bool bSearchComponent2 = false; @@ -659,6 +660,11 @@ INT32 SvxSearchDialog::GetTransliterationFlags() const return nTransliterationFlags; } +void SvxSearchDialog::SetSaveToModule(bool b) +{ + pImpl->bSaveToModule = b; +} + // ----------------------------------------------------------------------- void SvxSearchDialog::ApplyTransliterationFlags_Impl( INT32 nSettings ) @@ -777,10 +783,10 @@ void SvxSearchDialog::CalculateDelta_Impl() try { ::rtl::OUString aModuleIdentifier = xModuleManager->identify( xFrame ); - bCalcApp = aModuleIdentifier.equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" ); - bDrawApp = aModuleIdentifier.equalsAscii( "com.sun.star.drawing.DrawingDocument" ); - bImpressApp = aModuleIdentifier.equalsAscii( "com.sun.star.presentation.PresentationDocument" ); - bWriterApp = aModuleIdentifier.equalsAscii( "com.sun.star.text.TextDocument" ); + bCalcApp = aModuleIdentifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.sheet.SpreadsheetDocument" ) ); + bDrawApp = aModuleIdentifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.DrawingDocument" ) ); + bImpressApp = aModuleIdentifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ); + bWriterApp = aModuleIdentifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.text.TextDocument" ) ); } catch ( uno::Exception& ) { @@ -889,7 +895,7 @@ void SvxSearchDialog::CalculateDelta_Impl() if ( nOffset > 0 ) { long nH = LogicToPixel( Size( 0, nOffset ), MAP_APPFONT ).Height(); - for ( i = 0; i < sizeof( pWins ) / sizeof( pWins[ 0 ] ); ++i, ++pCurrent ) + for ( i = 0; i < SAL_N_ELEMENTS( pWins ); ++i, ++pCurrent ) { if ( ( bCalcApp && i < nCalcCtrlCount ) || ( i == nCalcCtrlCount && aCJKOptions.IsCJKFontEnabled() ) @@ -926,9 +932,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; @@ -979,7 +1012,7 @@ void SvxSearchDialog::Init_Impl( int bSearchPattern ) CalculateDelta_Impl(); - FASTBOOL bDraw = FALSE; + bool bDraw = FALSE; if ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_CALC ) { Link aLink = LINK( this, SvxSearchDialog, FlagHdl_Impl ); @@ -1078,12 +1111,10 @@ 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; + bool bDisableSearch = FALSE; SfxViewShell* pViewShell = SfxViewShell::Current(); if ( pViewShell ) @@ -1142,14 +1173,14 @@ void SvxSearchDialog::Init_Impl( int bSearchPattern ) } else { - FASTBOOL bSetSearch = ( ( nModifyFlag & MODIFY_SEARCH ) == 0 ); - FASTBOOL bSetReplace = ( ( nModifyFlag & MODIFY_REPLACE ) == 0 ); + bool bSetSearch = ( ( nModifyFlag & MODIFY_SEARCH ) == 0 ); + bool bSetReplace = ( ( nModifyFlag & MODIFY_REPLACE ) == 0 ); if ( pSearchItem->GetSearchString().Len() && bSetSearch ) aSearchLB.SetText( pSearchItem->GetSearchString() ); else if ( aSearchStrings.Count() ) { - FASTBOOL bAttributes = + bool bAttributes = ( ( pSearchList && pSearchList->Count() ) || ( pReplaceList && pReplaceList->Count() ) ); @@ -1434,7 +1465,7 @@ IMPL_LINK( SvxSearchDialog, FlagHdl_Impl, Control *, pCtrl ) IMPL_LINK( SvxSearchDialog, CommandHdl_Impl, Button *, pBtn ) { - FASTBOOL bInclusive = ( aLayoutBtn.GetText() == aLayoutStr ); + bool bInclusive = ( aLayoutBtn.GetText() == aLayoutStr ); if ( ( pBtn == &aSearchBtn ) || ( pBtn == &aSearchAllBtn ) || @@ -1531,12 +1562,6 @@ IMPL_LINK( SvxSearchDialog, CommandHdl_Impl, Button *, pBtn ) } else if ( pBtn == &aSimilarityBtn ) { -//CHINA001 SvxSearchSimilarityDialog* pDlg = -//CHINA001 new SvxSearchSimilarityDialog( this, -//CHINA001 pSearchItem->IsLEVRelaxed(), -//CHINA001 pSearchItem->GetLEVOther(), -//CHINA001 pSearchItem->GetLEVShorter(), -//CHINA001 pSearchItem->GetLEVLonger() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if(pFact) { @@ -1545,7 +1570,7 @@ IMPL_LINK( SvxSearchDialog, CommandHdl_Impl, Button *, pBtn ) pSearchItem->GetLEVOther(), pSearchItem->GetLEVShorter(), pSearchItem->GetLEVLonger() ); - DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001 + DBG_ASSERT(pDlg, "Dialogdiet fail!"); if ( pDlg && pDlg->Execute() == RET_OK ) { pSearchItem->SetLEVRelaxed( pDlg->IsRelaxed() ); @@ -1570,20 +1595,20 @@ IMPL_LINK( SvxSearchDialog, CommandHdl_Impl, Button *, pBtn ) int nRet = aDlg->Execute(); //CHINA001 int nRet = aDlg.Execute(); if (RET_OK == nRet) //! true only if FillItemSet of SvxJSearchOptionsPage returns true { - INT32 nFlags = aDlg->GetTransliterationFlags(); //CHINA001 INT32 nFlags = aDlg.GetTransliterationFlags(); + INT32 nFlags = aDlg->GetTransliterationFlags(); pSearchItem->SetTransliterationFlags( nFlags ); ApplyTransliterationFlags_Impl( nFlags ); } - delete aDlg; //add for CHINA001 + delete aDlg; } } else if(pBtn == &aSearchComponent1PB || pBtn == &aSearchComponent2PB ) { uno::Sequence < beans::PropertyValue > aArgs(2); beans::PropertyValue* pArgs = aArgs.getArray(); - pArgs[0].Name = ::rtl::OUString::createFromAscii("SearchString"); + pArgs[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SearchString")); pArgs[0].Value <<= ::rtl::OUString(aSearchLB.GetText()); - pArgs[1].Name = ::rtl::OUString::createFromAscii("ParentWindow"); + pArgs[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow")); pArgs[1].Value <<= VCLUnoHelper::GetInterface( LAYOUT_THIS_WINDOW (this) ); if(pBtn == &aSearchComponent1PB) { @@ -1609,16 +1634,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 ); @@ -1842,19 +1874,19 @@ void SvxSearchDialog::EnableControls_Impl( const USHORT nFlags ) } else if ( !IsVisible() ) Show(); - FASTBOOL bNoSearch = TRUE; + bool bNoSearch = true; sal_Bool bEnableSearch = ( SEARCH_OPTIONS_SEARCH & nOptions ) != 0; aSearchBtn.Enable(bEnableSearch); if( bEnableSearch ) - bNoSearch = FALSE; + bNoSearch = false; if ( ( SEARCH_OPTIONS_SEARCH_ALL & nOptions ) != 0 ) { aSearchAllBtn.Enable(); - bNoSearch = FALSE; + bNoSearch = false; } else aSearchAllBtn.Disable(); @@ -1864,7 +1896,7 @@ void SvxSearchDialog::EnableControls_Impl( const USHORT nFlags ) aReplaceText.Enable(); aReplaceLB.Enable(); aReplaceTmplLB.Enable(); - bNoSearch = FALSE; + bNoSearch = false; } else { @@ -1876,7 +1908,7 @@ void SvxSearchDialog::EnableControls_Impl( const USHORT nFlags ) if ( ( SEARCH_OPTIONS_REPLACE_ALL & nOptions ) != 0 ) { aReplaceAllBtn.Enable(); - bNoSearch = FALSE; + bNoSearch = false; } else aReplaceAllBtn.Disable(); @@ -2170,12 +2202,12 @@ IMPL_LINK( SvxSearchDialog, FormatHdl_Impl, Button *, EMPTYARG ) aSet.DisableItem(rPool.GetWhich(SID_ATTR_PARA_PAGEBREAK)); aSet.DisableItem(rPool.GetWhich(SID_ATTR_PARA_KEEP)); - //CHINA001 SvxSearchFormatDialog* pDlg = new SvxSearchFormatDialog( this, aSet ); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if(pFact) { SfxAbstractTabDialog* pDlg = pFact->CreateTabItemDialog( LAYOUT_THIS_WINDOW (this), aSet, RID_SVXDLG_SEARCHFORMAT ); - DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001 + DBG_ASSERT(pDlg, "Dialogdiet fail!"); aTxt.Insert( pDlg->GetText(), 0 ); pDlg->SetText( aTxt ); @@ -2247,7 +2279,6 @@ IMPL_LINK( SvxSearchDialog, AttributeHdl_Impl, Button *, EMPTYARG ) if ( !pSearchList || !pImpl->pRanges ) return 0; - //CHINA001 SvxSearchAttributeDialog* pDlg = new SvxSearchAttributeDialog( this, *pSearchList, pImpl->pRanges ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if(pFact) { @@ -2352,6 +2383,8 @@ String& SvxSearchDialog::BuildAttrText_Impl( String& rStr, ResStringArray aAttrNames( SVX_RES( RID_ATTR_NAMES ) ); + ResStringArray aAttrNames( SVX_RES( RID_ATTR_NAMES ) ); + for ( USHORT i = 0; i < pList->Count(); ++i ) { const SearchAttrItem& rItem = pList->GetObject(i); @@ -2547,3 +2580,4 @@ SfxChildWinInfo SvxSearchDialogWrapper::GetInfo() const return aInfo; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |