diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-02-04 15:46:41 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-02-05 19:09:15 +0100 |
commit | f25cdaa78d5e7d200fbaf31cce9895bab7c5ee63 (patch) | |
tree | 4a05313e773c0182b68e00508287aaeb583668e7 /svx | |
parent | d6f13b6a84e4b12320111c2e92cd8af20ed44d4c (diff) |
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
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/tbunosearchcontrollers.hxx | 32 | ||||
-rw-r--r-- | svx/source/dialog/srchdlg.cxx | 52 | ||||
-rw-r--r-- | svx/source/dialog/srchdlg.src | 8 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbunosearchcontrollers.cxx | 102 | ||||
-rw-r--r-- | svx/uiconfig/ui/findreplacedialog.ui | 2 | ||||
-rw-r--r-- | svx/util/svx.component | 4 |
6 files changed, 187 insertions, 13 deletions
diff --git a/svx/inc/tbunosearchcontrollers.hxx b/svx/inc/tbunosearchcontrollers.hxx index f1aaa583326b..97af023e39d5 100644 --- a/svx/inc/tbunosearchcontrollers.hxx +++ b/svx/inc/tbunosearchcontrollers.hxx @@ -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, diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index 51202d288975..dd9361591a35 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -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: */ diff --git a/svx/source/dialog/srchdlg.src b/svx/source/dialog/srchdlg.src index d17fc2463576..18b5e1117c54 100644 --- a/svx/source/dialog/srchdlg.src +++ b/svx/source/dialog/srchdlg.src @@ -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: */ diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index 9ff2bb3b3d45..9a425d202b2c 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -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; @@ -889,6 +881,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 FindbarDispatcher::FindbarDispatcher() @@ -1087,6 +1161,14 @@ com_sun_star_svx_FindAllToolboxController_get_implementation( } 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 *, css::uno::Sequence<css::uno::Any> const &) diff --git a/svx/uiconfig/ui/findreplacedialog.ui b/svx/uiconfig/ui/findreplacedialog.ui index 5cfef2218282..fb50f0779cae 100644 --- a/svx/uiconfig/ui/findreplacedialog.ui +++ b/svx/uiconfig/ui/findreplacedialog.ui @@ -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> diff --git a/svx/util/svx.component b/svx/util/svx.component index 8db99d97556b..5529d276dbfd 100644 --- a/svx/util/svx.component +++ b/svx/util/svx.component @@ -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"/> |