fdo#74132: Do not interrupt search in Writer.

Instead of "Do you want to continue at the beginning?" dialog,
just inform that we were at the end of the document in new label.

Also replace 'Search key not found' dialog with label.

Change-Id: I6a140cbad93406b73996f87a6d05fcc5d245fdbf
This commit is contained in:
Matúš Kukan
2014-02-04 15:46:41 +01:00
parent d6f13b6a84
commit f25cdaa78d
14 changed files with 231 additions and 63 deletions

View File

@@ -242,11 +242,13 @@
#define RID_SVXSTR_LANGUAGE_ALL (RID_SVX_START + 15)
// Strings from the search dialog
#define RID_SVXSTR_SEARCH_END (RID_SVX_START + 79)
#define RID_SVXSTR_SEARCH_STYLES (RID_SVX_START + 80)
#define RID_SVXSTR_SEARCH (RID_SVX_START + 81)
#define RID_SVXSTR_REPLACE (RID_SVX_START + 82)
#define RID_SVXSTR_WRITER_STYLES (RID_SVX_START + 83)
#define RID_SVXSTR_CALC_STYLES (RID_SVX_START + 85)
#define RID_SVXSTR_SEARCH_NOT_FOUND (RID_SVX_START + 88)
// ResIds for the PageDialog
// Strings of the ToolBox-Controls from tbcontrl.cxx

View File

@@ -79,6 +79,13 @@ public:
// class SvxSearchDialogWrapper ------------------------------------------
enum SearchLabel
{
SL_Empty,
SL_NotFound,
SL_End
};
class SvxSearchDialog;
class SVX_DLLPUBLIC SvxSearchDialogWrapper : public SfxChildWindow
{
@@ -89,6 +96,7 @@ public:
~SvxSearchDialogWrapper ();
SvxSearchDialog *getDialog ();
static void SetSearchLabel(const SearchLabel& rSL);
SFX_DECL_CHILDWINDOW_WITHID(SvxSearchDialogWrapper);
};
@@ -139,6 +147,8 @@ public:
void SetSaveToModule(bool b);
void SetSearchLabel(const OUString& rStr) { m_pSearchLabel->SetText(rStr); }
private:
Window* mpDocWin;
sal_Bool mbSuccess;
@@ -147,6 +157,7 @@ private:
ComboBox* m_pSearchLB;
ListBox* m_pSearchTmplLB;
FixedText* m_pSearchAttrText;
FixedText* m_pSearchLabel;
VclFrame* m_pReplaceFrame;
ComboBox* m_pReplaceLB;

View File

@@ -396,6 +396,17 @@
<value>com.sun.star.svx.FindTextToolboxController</value>
</prop>
</node>
<node oor:name="com.sun.star.svx.SearchLabelToolboxController" oor:op="replace">
<prop oor:name="Command">
<value>.uno:SearchLabel</value>
</prop>
<prop oor:name="Module">
<value/>
</prop>
<prop oor:name="Controller">
<value>com.sun.star.svx.SearchLabelToolboxController</value>
</prop>
</node>
<node oor:name="com.sun.star.svx.DownSearchToolboxController" oor:op="replace">
<prop oor:name="Command">
<value>.uno:DownSearch</value>

View File

@@ -111,7 +111,6 @@ public:
virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException );
// XToolbarController
virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException);
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException );
// XStatusListener
@@ -217,7 +216,6 @@ public:
virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException);
// XToolbarController
virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException );
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException );
// XStatusListener
@@ -257,6 +255,36 @@ public:
virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException );
};
class SearchLabelToolboxController : public svt::ToolboxController,
public css::lang::XServiceInfo
{
public:
SearchLabelToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
~SearchLabelToolboxController();
// XInterface
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException ) SAL_OVERRIDE;
virtual void SAL_CALL acquire() throw () SAL_OVERRIDE;
virtual void SAL_CALL release() throw () SAL_OVERRIDE;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException ) SAL_OVERRIDE;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException ) SAL_OVERRIDE;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException ) SAL_OVERRIDE;
// XComponent
virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException ) SAL_OVERRIDE;
// XInitialization
virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException) SAL_OVERRIDE;
// XToolbarController
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException ) SAL_OVERRIDE;
// XStatusListener
virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException ) SAL_OVERRIDE;
};
// protocol handler for "vnd.sun.star.findbar:*" URLs
// The dispatch object will be used for shortcut commands for findbar
class FindbarDispatcher : public css::lang::XServiceInfo,

View File

@@ -34,14 +34,17 @@
#include <sfx2/basedlgs.hxx>
#include <svl/cjkoptions.hxx>
#include <svl/ctloptions.hxx>
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/i18n/TransliterationModules.hpp>
#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/configuration/theDefaultProvider.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
#include <com/sun/star/ui/XUIElement.hpp>
#include <comphelper/processfactory.hxx>
#include <svl/itempool.hxx>
#include <svl/intitem.hxx>
@@ -63,6 +66,7 @@
#include <editeng/brushitem.hxx>
#include <tools/resary.hxx>
#include <svx/svxdlg.hxx>
#include <vcl/toolbox.hxx>
using namespace com::sun::star::i18n;
using namespace com::sun::star::uno;
@@ -285,6 +289,10 @@ SvxSearchDialog::SvxSearchDialog( Window* pParent, SfxChildWindow* pChildWin, Sf
get(m_pSearchAllBtn, "searchall");
get(m_pSearchAttrText, "searchdesc");
m_pSearchAttrText->SetStyle(m_pSearchAttrText->GetStyle() | WB_PATHELLIPSIS);
m_pSearchAttrText->Show();
get(m_pSearchLabel, "searchlabel");
m_pSearchLabel->SetStyle(m_pSearchLabel->GetStyle() | WB_PATHELLIPSIS);
m_pSearchLabel->Show();
get(m_pReplaceFrame, "replaceframe");
get(m_pReplaceLB, "replaceterm");
@@ -294,6 +302,7 @@ SvxSearchDialog::SvxSearchDialog( Window* pParent, SfxChildWindow* pChildWin, Sf
get(m_pReplaceAllBtn, "replaceall");
get(m_pReplaceAttrText, "replacedesc");
m_pReplaceAttrText->SetStyle(m_pReplaceAttrText->GetStyle() | WB_PATHELLIPSIS);
m_pReplaceAttrText->Show();
get(m_pComponentFrame, "componentframe");
get(m_pSearchComponent1PB, "component1");
@@ -2324,4 +2333,47 @@ SfxChildWinInfo SvxSearchDialogWrapper::GetInfo() const
return aInfo;
}
static Window* lcl_GetSearchLabelWindow()
{
css::uno::Reference< css::beans::XPropertySet > xPropSet(
SfxViewFrame::Current()->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
xPropSet->getPropertyValue("LayoutManager") >>= xLayoutManager;
css::uno::Reference< css::ui::XUIElement > xUIElement =
xLayoutManager->getElement("private:resource/toolbar/findbar");
if (!xUIElement.is())
return 0;
css::uno::Reference< css::awt::XWindow > xWindow(
xUIElement->getRealInterface(), css::uno::UNO_QUERY_THROW);
ToolBox* pToolBox = (ToolBox*) VCLUnoHelper::GetWindow(xWindow);
for (size_t i = 0; pToolBox && i < pToolBox->GetItemCount(); ++i)
if (pToolBox->GetItemCommand(i) == ".uno:SearchLabel")
return pToolBox->GetItemWindow(i);
return 0;
}
void SvxSearchDialogWrapper::SetSearchLabel(const SearchLabel& rSL)
{
OUString sStr;
if (rSL == SL_End)
sStr = SVX_RESSTR(RID_SVXSTR_SEARCH_END);
else if (rSL == SL_NotFound)
sStr = SVX_RESSTR(RID_SVXSTR_SEARCH_NOT_FOUND);
if (Window *pSearchLabel = lcl_GetSearchLabelWindow())
{
if (sStr.isEmpty())
pSearchLabel->Hide();
else
{
pSearchLabel->SetText(sStr);
pSearchLabel->Show();
}
}
if (SvxSearchDialogWrapper *pWrp = (SvxSearchDialogWrapper*) SfxViewFrame::Current()->
GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() ))
pWrp->getDialog()->SetSearchLabel(sStr);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -42,5 +42,13 @@ String RID_SVXSTR_REPLACE
{
Text [ en-US ] = "(Replace)" ;
};
String RID_SVXSTR_SEARCH_END
{
Text [ en-US ] = "Reached the end of the document" ;
};
String RID_SVXSTR_SEARCH_NOT_FOUND
{
Text [ en-US ] = "Search key not found" ;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -42,6 +42,8 @@
#include <rtl/ref.hxx>
#include <rtl/instance.hxx>
#include <vcl/fixed.hxx>
using namespace css;
namespace {
@@ -439,11 +441,6 @@ void SAL_CALL FindTextToolbarController::initialize( const css::uno::Sequence< :
SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
}
// XToolbarController
void SAL_CALL FindTextToolbarController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException )
{
}
css::uno::Reference< css::awt::XWindow > SAL_CALL FindTextToolbarController::createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException )
{
css::uno::Reference< css::awt::XWindow > xItemWindow;
@@ -674,11 +671,6 @@ void SAL_CALL MatchCaseToolboxController::initialize( const css::uno::Sequence<
SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
}
// XToolbarController
void SAL_CALL MatchCaseToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException )
{
}
css::uno::Reference< css::awt::XWindow > SAL_CALL MatchCaseToolboxController::createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException )
{
css::uno::Reference< css::awt::XWindow > xItemWindow;
@@ -888,6 +880,88 @@ void SAL_CALL ExitSearchToolboxController::statusChanged( const css::frame::Feat
{
}
//-----------------------------------------------------------------------------------------------------------
// class SearchLabelToolboxController
SearchLabelToolboxController::SearchLabelToolboxController( const css::uno::Reference< css::uno::XComponentContext > & rxContext )
: svt::ToolboxController( rxContext,
css::uno::Reference< css::frame::XFrame >(),
OUString( ".uno:SearchLabel" ) )
{
}
SearchLabelToolboxController::~SearchLabelToolboxController()
{
}
// XInterface
css::uno::Any SAL_CALL SearchLabelToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException )
{
css::uno::Any a = ToolboxController::queryInterface( aType );
if ( a.hasValue() )
return a;
return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) );
}
void SAL_CALL SearchLabelToolboxController::acquire() throw ()
{
ToolboxController::acquire();
}
void SAL_CALL SearchLabelToolboxController::release() throw ()
{
ToolboxController::release();
}
// XServiceInfo
OUString SAL_CALL SearchLabelToolboxController::getImplementationName() throw( css::uno::RuntimeException )
{
return OUString( "com.sun.star.svx.SearchLabelToolboxController" );
}
sal_Bool SAL_CALL SearchLabelToolboxController::supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException )
{
return cppu::supportsService(this, ServiceName);
}
css::uno::Sequence< OUString > SAL_CALL SearchLabelToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException )
{
css::uno::Sequence< OUString > aSNS( 1 );
aSNS[0] = "com.sun.star.frame.ToolbarController";
return aSNS;
}
// XComponent
void SAL_CALL SearchLabelToolboxController::dispose() throw ( css::uno::RuntimeException )
{
SolarMutexGuard aSolarMutexGuard;
SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
svt::ToolboxController::dispose();
}
// XInitialization
void SAL_CALL SearchLabelToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException )
{
svt::ToolboxController::initialize( aArguments );
SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
}
// XStatusListener
void SAL_CALL SearchLabelToolboxController::statusChanged( const css::frame::FeatureStateEvent& ) throw ( css::uno::RuntimeException )
{
}
css::uno::Reference< css::awt::XWindow > SAL_CALL SearchLabelToolboxController::createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException )
{
Window *pSL= new FixedText(VCLUnoHelper::GetWindow( Parent ));
pSL->SetSizePixel(Size(250, 25));
return VCLUnoHelper::GetInterface(pSL);
}
//-----------------------------------------------------------------------------------------------------------
// class FindbarDispatcher
@@ -1086,6 +1160,14 @@ com_sun_star_svx_FindAllToolboxController_get_implementation(
return cppu::acquire(new FindAllToolboxController(context));
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_svx_SearchLabelToolboxController_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new SearchLabelToolboxController(context));
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_comp_svx_Impl_FindbarDispatcher_get_implementation(
SAL_UNUSED_PARAMETER css::uno::XComponentContext *,

View File

@@ -197,7 +197,7 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="searchformat">
<object class="GtkLabel" id="searchlabel">
<property name="width_request">1</property>
<property name="can_focus">False</property>
<property name="no_show_all">True</property>

View File

@@ -60,6 +60,10 @@
constructor="com_sun_star_svx_FindAllToolboxController_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>
<implementation name="com.sun.star.svx.SearchLabelToolboxController"
constructor="com_sun_star_svx_SearchLabelToolboxController_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>
<implementation name="com.sun.star.svx.FontHeightToolBoxController"
constructor="com_sun_star_svx_FontHeightToolBoxController_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/>

View File

@@ -23,6 +23,7 @@
#include <boost/scoped_ptr.hpp>
#include <hintids.hxx>
#include <com/sun/star/util/SearchOptions.hpp>
#include <svl/cjkoptions.hxx>
#include <svl/ctloptions.hxx>
@@ -86,18 +87,6 @@ static Window* GetParentWindow( SvxSearchDialog* m_pSrchDlg )
return pWin;
}
static void ShowNotFoundInfoBox( SvxSearchDialog* m_pSrchDlg )
{
Window* pParentWindow = GetParentWindow( m_pSrchDlg );
MessageDialog aBox(pParentWindow, "InfoNotFoundDialog",
"modules/swriter/ui/infonotfounddialog.ui");
if (pParentWindow)
{
aBox.SetText(pParentWindow->GetText());
}
aBox.Execute();
}
void SwView::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage)
{
const SfxItemSet* pArgs = rReq.GetArgs();
@@ -231,9 +220,7 @@ void SwView::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage)
if( !bRet )
{
if( !bApi )
{
ShowNotFoundInfoBox( m_pSrchDlg );
}
SvxSearchDialogWrapper::SetSearchLabel(SL_NotFound);
m_bFound = sal_False;
}
rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
@@ -349,9 +336,7 @@ void SwView::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage)
if( !nFound )
{
if( !bApi )
{
ShowNotFoundInfoBox( m_pSrchDlg );
}
SvxSearchDialogWrapper::SetSearchLabel(SL_NotFound);
m_bFound = sal_False;
return;
}
@@ -527,9 +512,7 @@ sal_Bool SwView::SearchAndWrap(sal_Bool bApi)
{
m_pWrtShell->EndAllAction();
if( !bApi )
{
ShowNotFoundInfoBox( m_pSrchDlg );
}
SvxSearchDialogWrapper::SetSearchLabel(SL_NotFound);
m_bFound = sal_False;
m_pWrtShell->Pop();
return sal_False;
@@ -537,27 +520,6 @@ sal_Bool SwView::SearchAndWrap(sal_Bool bApi)
m_pWrtShell->EndAllAction();
// Try again with WrapAround?
int nRet = RET_NO;
if( !bApi )
{
if (DOCPOS_START == aOpts.eEnd)
{
nRet = MessageDialog(GetParentWindow(m_pSrchDlg), "QueryContinueEndDialog",
"modules/swriter/ui/querycontinueenddialog.ui").Execute();
}
else
{
nRet = MessageDialog(GetParentWindow(m_pSrchDlg), "QueryContinueBeginDialog",
"modules/swriter/ui/querycontinuebegindialog.ui").Execute();
}
}
if (nRet == RET_NO)
{
m_bFound = sal_False;
m_pWrtShell->Pop();
return sal_False;
}
m_pWrtShell->StartAllAction();
m_pWrtShell->Pop(sal_False);
pWait.reset(new SwWait( *GetDocShell(), true ));
@@ -576,16 +538,15 @@ sal_Bool SwView::SearchAndWrap(sal_Bool bApi)
m_pWrtShell->SttDoc();
}
m_bFound = 0 != FUNC_Search( aOpts );
m_bFound = bool(FUNC_Search( aOpts ));
m_pWrtShell->EndAllAction();
pWait.reset();
if ( m_bFound )
return m_bFound;
if(!bApi)
{
ShowNotFoundInfoBox( m_pSrchDlg );
}
return m_bFound = sal_False;
if (m_bFound)
SvxSearchDialogWrapper::SetSearchLabel(SL_End);
else if(!bApi)
SvxSearchDialogWrapper::SetSearchLabel(SL_NotFound);
return m_bFound;
}
@@ -728,6 +689,8 @@ SwSearchOptions::SwSearchOptions( SwWrtShell* pSh, sal_Bool bBackward )
sal_uLong SwView::FUNC_Search( const SwSearchOptions& rOptions )
{
SvxSearchDialogWrapper::SetSearchLabel(SL_Empty);
sal_Bool bDoReplace = m_pSrchItem->GetCommand() == SVX_SEARCHCMD_REPLACE ||
m_pSrchItem->GetCommand() == SVX_SEARCHCMD_REPLACE_ALL;

View File

@@ -26,4 +26,6 @@
<toolbar:toolbaritem xlink:href=".uno:MatchCase"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchDialog"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchLabel"/>
</toolbar:toolbar>

View File

@@ -26,4 +26,6 @@
<toolbar:toolbaritem xlink:href=".uno:MatchCase"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchDialog"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchLabel"/>
</toolbar:toolbar>

View File

@@ -30,4 +30,5 @@
<toolbar:toolbaritem xlink:href=".uno:ScrollToPrevious"/>
<toolbar:toolbaritem xlink:href=".uno:NavigationPopup"/>
<toolbar:toolbaritem xlink:href=".uno:ScrollToNext"/>
<toolbar:toolbaritem xlink:href=".uno:SearchLabel"/>
</toolbar:toolbar>

View File

@@ -26,4 +26,6 @@
<toolbar:toolbaritem xlink:href=".uno:MatchCase"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchDialog"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchLabel"/>
</toolbar:toolbar>