diff options
Diffstat (limited to 'basctl/source/basicide/basides1.cxx')
-rw-r--r-- | basctl/source/basicide/basides1.cxx | 125 |
1 files changed, 90 insertions, 35 deletions
diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 95025f859bf9..da1c86f1872d 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -44,7 +44,6 @@ #include <svx/svxids.hrc> #include <svl/aeitem.hxx> #include <svl/intitem.hxx> -#include <svl/srchitem.hxx> #include <svl/visitem.hxx> #include <svl/whiter.hxx> #include <vcl/xtextedt.hxx> @@ -58,40 +57,56 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::frame; -void Shell::ExecuteCurrent( SfxRequest& rReq ) +void Shell::ExecuteSearch( SfxRequest& rReq ) { if ( !pCurWin ) return; - switch ( rReq.GetSlot() ) + const SfxItemSet* pArgs = rReq.GetArgs(); + sal_uInt16 nSlot = rReq.GetSlot(); + + // if searching has not been done before this time + if (nSlot == SID_BASICIDE_REPEAT_SEARCH && !mpSearchItem) { - case SID_BASICIDE_HIDECURPAGE: - { - pCurWin->StoreData(); - RemoveWindow( pCurWin, false ); - } - break; - case SID_BASICIDE_RENAMECURRENT: - { - pTabBar->StartEditMode( pTabBar->GetCurPageId() ); - } - break; + rReq.SetReturnValue(SfxBoolItem(nSlot, false)); + nSlot = 0; + } + + switch ( nSlot ) + { + case SID_SEARCH_OPTIONS: + break; + case SID_SEARCH_ITEM: + mpSearchItem.reset( static_cast<SvxSearchItem*>( pArgs->Get(SID_SEARCH_ITEM).Clone() )); + break; + case FID_SEARCH_ON: + mbJustOpened = true; + GetViewFrame()->GetBindings().Invalidate(SID_SEARCH_ITEM); + break; + case SID_BASICIDE_REPEAT_SEARCH: case FID_SEARCH_NOW: { if (!pCurWin->HasActiveEditor()) break; - DBG_ASSERT( rReq.GetArgs(), "arguments expected" ); - SfxItemSet const& rArgs = *rReq.GetArgs(); - // unfortunately I don't know the ID: - sal_uInt16 nWhich = rArgs.GetWhichByPos( 0 ); - DBG_ASSERT( nWhich, "Which for SearchItem?" ); - SfxPoolItem const& rItem = rArgs.Get(nWhich); - DBG_ASSERT(dynamic_cast<SvxSearchItem const*>(&rItem), "no searchitem!"); - SvxSearchItem const& rSearchItem = static_cast<SvxSearchItem const&>(rItem); - // memorize item because of the adjustments... - GetExtraData()->SetSearchItem(rSearchItem); + + // If it is a repeat searching + if ( nSlot == SID_BASICIDE_REPEAT_SEARCH ) + { + if( !mpSearchItem ) + mpSearchItem.reset( new SvxSearchItem( SID_SEARCH_ITEM )); + } + else + { + // Get SearchItem from request if it is the first searching + if ( pArgs ) + { + mpSearchItem.reset( static_cast<SvxSearchItem*>( pArgs->Get( SID_SEARCH_ITEM ).Clone() )); + } + } + sal_Int32 nFound = 0; - if (rSearchItem.GetCommand() == SvxSearchCmd::REPLACE_ALL) + + if ( mpSearchItem->GetCommand() == SvxSearchCmd::REPLACE_ALL ) { sal_uInt16 nActModWindows = 0; for (auto const& window : aWindowTable) @@ -116,11 +131,11 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) for (auto const& window : aWindowTable) { BaseWindow* pWin = window.second; - nFound += pWin->StartSearchAndReplace(rSearchItem); + nFound += pWin->StartSearchAndReplace( *mpSearchItem ); } } else - nFound = pCurWin->StartSearchAndReplace(rSearchItem); + nFound = pCurWin->StartSearchAndReplace( *mpSearchItem ); OUString aReplStr(IDEResId(RID_STR_SEARCHREPLACES)); aReplStr = aReplStr.replaceAll("XX", OUString::number(nFound)); @@ -133,8 +148,8 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) else { bool bCanceled = false; - nFound = pCurWin->StartSearchAndReplace(rSearchItem); - if ( !nFound && !rSearchItem.GetSelection() ) + nFound = pCurWin->StartSearchAndReplace( *mpSearchItem ); + if ( !nFound && !mpSearchItem->GetSelection() ) { // search other modules... bool bChangeCurWindow = false; @@ -176,7 +191,7 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) { if ( pCurWin ) pWin->SetSizePixel( pCurWin->GetSizePixel() ); - nFound = pWin->StartSearchAndReplace(rSearchItem, true); + nFound = pWin->StartSearchAndReplace( *mpSearchItem, true ); } if ( nFound ) { @@ -194,7 +209,7 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) pWin = nullptr; } if ( !nFound && bSearchedFromStart ) - nFound = pCurWin->StartSearchAndReplace(rSearchItem, true); + nFound = pCurWin->StartSearchAndReplace( *mpSearchItem, true ); if ( bChangeCurWindow ) SetCurWindow( pWin, true ); } @@ -208,6 +223,29 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) } rReq.Done(); + break; + } + default: + pCurWin->ExecuteCommand( rReq ); + } +} + +void Shell::ExecuteCurrent( SfxRequest& rReq ) +{ + if ( !pCurWin ) + return; + + switch ( rReq.GetSlot() ) + { + case SID_BASICIDE_HIDECURPAGE: + { + pCurWin->StoreData(); + RemoveWindow( pCurWin, false ); + } + break; + case SID_BASICIDE_RENAMECURRENT: + { + pTabBar->StartEditMode( pTabBar->GetCurPageId() ); } break; case SID_UNDO: @@ -889,10 +927,27 @@ void Shell::GetState(SfxItemSet &rSet) break; case SID_SEARCH_ITEM: { - OUString aSelected = GetSelectionText(true); - SvxSearchItem& rItem = GetExtraData()->GetSearchItem(); - rItem.SetSearchString( aSelected ); - rSet.Put( rItem ); + if ( !mpSearchItem ) + { + mpSearchItem.reset( new SvxSearchItem( SID_SEARCH_ITEM )); + mpSearchItem->SetSearchString( GetSelectionText( true )); + } + + if ( mbJustOpened && HasSelection() ) + { + OUString aText = GetSelectionText( true ); + + if ( !aText.isEmpty() ) + { + mpSearchItem->SetSearchString( aText ); + mpSearchItem->SetSelection( false ); + } + else + mpSearchItem->SetSelection( true ); + } + + mbJustOpened = false; + rSet.Put( *mpSearchItem ); } break; case SID_BASICIDE_STAT_DATE: |