From 9a85743766e8a063d20d5f93ee88758e243397f4 Mon Sep 17 00:00:00 2001 From: Dennis Francis Date: Sat, 17 Oct 2015 23:14:35 +0530 Subject: tdf#48456 : when searching for a number, consider formatting Change-Id: I4a1e3e269a269bb37e88aa8810a46d0f4ecfc518 Reviewed-on: https://gerrit.libreoffice.org/19420 Reviewed-by: Eike Rathke Tested-by: Eike Rathke --- svx/inc/tbunosearchcontrollers.hxx | 33 +++++++ svx/source/dialog/srchdlg.cxx | 7 ++ svx/source/tbxctrls/tbunosearchcontrollers.cxx | 114 ++++++++++++++++++++++++- svx/source/tbxctrls/tbunosearchcontrollers.src | 5 ++ svx/uiconfig/ui/findreplacedialog.ui | 17 +++- svx/util/svx.component | 4 + 6 files changed, 178 insertions(+), 2 deletions(-) (limited to 'svx') diff --git a/svx/inc/tbunosearchcontrollers.hxx b/svx/inc/tbunosearchcontrollers.hxx index c180023d28a3..f7477dfacd15 100644 --- a/svx/inc/tbunosearchcontrollers.hxx +++ b/svx/inc/tbunosearchcontrollers.hxx @@ -222,6 +222,39 @@ private: VclPtr m_pMatchCaseControl; }; +class SearchFormattedToolboxController : public svt::ToolboxController, + public css::lang::XServiceInfo +{ +public: + SearchFormattedToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~SearchFormattedToolboxController(); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException, std::exception ) override; + virtual void SAL_CALL acquire() throw () override; + virtual void SAL_CALL release() throw () override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException, std::exception ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException, std::exception ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception ) override; + + // XComponent + virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException, std::exception ) override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException, std::exception) override; + + // XToolbarController + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException, std::exception ) override; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException, std::exception ) override; + +private: + VclPtr m_pSearchFormattedControl; +}; + class FindAllToolboxController : public svt::ToolboxController, public css::lang::XServiceInfo { diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index 49533b2cf6f3..c3e58152a1bd 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -300,6 +300,7 @@ SvxSearchDialog::SvxSearchDialog( vcl::Window* pParent, SfxChildWindow* pChildWi get(m_pSearchComponent2PB, "component2"); get(m_pMatchCaseCB, "matchcase"); + get(m_pSearchFormattedCB, "searchformatted"); get(m_pWordBtn, "wholewords"); aCalcStr = get("entirecells")->GetText(); @@ -383,6 +384,7 @@ void SvxSearchDialog::dispose() m_pSearchComponent1PB.clear(); m_pSearchComponent2PB.clear(); m_pMatchCaseCB.clear(); + m_pSearchFormattedCB.clear(); m_pWordBtn.clear(); m_pCloseBtn.clear(); m_pIgnoreDiacritics.clear(); @@ -740,6 +742,7 @@ void SvxSearchDialog::ShowOptionalControls_Impl() m_pRowsBtn->Show(); m_pColumnsBtn->Show(); m_pAllSheetsCB->Show(); + m_pSearchFormattedCB->Show(); } } @@ -813,6 +816,7 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern ) m_pRowsBtn->SetClickHdl( aLink ); m_pColumnsBtn->SetClickHdl( aLink ); m_pAllSheetsCB->SetClickHdl( aLink ); + m_pSearchFormattedCB->SetClickHdl( aLink ); sal_uIntPtr nModifyFlagCheck; switch ( pSearchItem->GetCellType() ) @@ -854,6 +858,7 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern ) } else { + m_pSearchFormattedCB->Hide(); m_pWordBtn->SetText( aCalcStr.getToken( 1, '#' ) ); if ( pSearchItem->GetAppFlag() == SvxSearchApp::DRAW ) @@ -1293,6 +1298,7 @@ IMPL_LINK_TYPED( SvxSearchDialog, CommandHdl_Impl, Button *, pBtn, void ) pSearchItem->SetRowDirection( m_pRowsBtn->IsChecked() ); pSearchItem->SetAllTables( m_pAllSheetsCB->IsChecked() ); + pSearchItem->SetSearchFormatted( m_pSearchFormattedCB->IsChecked() ); } if (pBtn == m_pSearchBtn) @@ -2230,6 +2236,7 @@ void SvxSearchDialog::SaveToModule_Impl() pSearchItem->SetRowDirection( m_pRowsBtn->IsChecked() ); pSearchItem->SetAllTables( m_pAllSheetsCB->IsChecked() ); + pSearchItem->SetSearchFormatted( m_pSearchFormattedCB->IsChecked() ); } pSearchItem->SetCommand( SvxSearchCmd::FIND ); diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index b7e71b5bee98..0dd67acaf7d9 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -53,6 +53,7 @@ namespace { static const char SEARCHITEM_COMMAND[] = "SearchItem.Command"; static const char SEARCHITEM_SEARCHSTRING[] = "SearchItem.SearchString"; static const char SEARCHITEM_SEARCHBACKWARD[] = "SearchItem.Backward"; +static const char SEARCHITEM_SEARCHFORMATTED[] = "SearchItem.SearchFormatted"; static const char SEARCHITEM_SEARCHFLAGS[] = "SearchItem.SearchFlags"; static const char SEARCHITEM_TRANSLITERATEFLAGS[] = "SearchItem.TransliterateFlags"; static const char SEARCHITEM_ALGORITHMTYPE[] = "SearchItem.AlgorithmType"; @@ -63,6 +64,7 @@ static const char COMMAND_DOWNSEARCH[] = ".uno:DownSearch"; static const char COMMAND_UPSEARCH[] = ".uno:UpSearch"; static const char COMMAND_EXITSEARCH[] = ".uno:ExitSearch"; static const char COMMAND_MATCHCASE[] = ".uno:MatchCase"; +static const char COMMAND_SEARCHFORMATTED[] = ".uno:SearchFormattedDisplayString"; static const char COMMAND_APPENDSEARCHHISTORY[] = "AppendSearchHistory"; static const sal_Int32 REMEMBER_SIZE = 10; @@ -80,6 +82,7 @@ void impl_executeSearch( const css::uno::Reference< css::uno::XComponentContext OUString sFindText; bool aMatchCase = false; + bool bSearchFormatted = false; if ( pToolBox ) { sal_uInt16 nItemCount = pToolBox->GetItemCount(); @@ -96,11 +99,16 @@ void impl_executeSearch( const css::uno::Reference< css::uno::XComponentContext CheckBox* pItemWin = static_cast( pToolBox->GetItemWindow(i) ); if (pItemWin) aMatchCase = pItemWin->IsChecked(); + } else if ( sItemCommand == COMMAND_SEARCHFORMATTED ) + { + CheckBox* pItemWin = static_cast( pToolBox->GetItemWindow(i) ); + if (pItemWin) + bSearchFormatted = pItemWin->IsChecked(); } } } - css::uno::Sequence< css::beans::PropertyValue > lArgs(6); + css::uno::Sequence< css::beans::PropertyValue > lArgs(7); lArgs[0].Name = SEARCHITEM_SEARCHSTRING; lArgs[0].Value <<= sFindText; lArgs[1].Name = SEARCHITEM_SEARCHBACKWARD; @@ -119,6 +127,8 @@ void impl_executeSearch( const css::uno::Reference< css::uno::XComponentContext SvxSearchCmd::FIND_ALL : SvxSearchCmd::FIND ); lArgs[5].Name = SEARCHITEM_ALGORITHMTYPE; lArgs[5].Value <<= (sal_Int16)0; // 0 == SearchAlgorithms_ABSOLUTE + lArgs[6].Name = SEARCHITEM_SEARCHFORMATTED; + lArgs[6].Value <<= bSearchFormatted; css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider(xFrame, css::uno::UNO_QUERY); if ( xDispatchProvider.is() ) @@ -699,6 +709,100 @@ void SAL_CALL MatchCaseToolboxController::statusChanged( const css::frame::Featu { } +SearchFormattedToolboxController::SearchFormattedToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) + : svt::ToolboxController( rxContext, + css::uno::Reference< css::frame::XFrame >(), + OUString(COMMAND_SEARCHFORMATTED) ) + , m_pSearchFormattedControl(NULL) +{ +} + +SearchFormattedToolboxController::~SearchFormattedToolboxController() +{ +} + +// XInterface +css::uno::Any SAL_CALL SearchFormattedToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException, std::exception ) +{ + 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 SearchFormattedToolboxController::acquire() throw () +{ + ToolboxController::acquire(); +} + +void SAL_CALL SearchFormattedToolboxController::release() throw () +{ + ToolboxController::release(); +} + +// XServiceInfo +OUString SAL_CALL SearchFormattedToolboxController::getImplementationName() throw( css::uno::RuntimeException, std::exception ) +{ + return OUString( "com.sun.star.svx.SearchFormattedToolboxController" ); +} + +sal_Bool SAL_CALL SearchFormattedToolboxController::supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException, std::exception ) +{ + return cppu::supportsService(this, ServiceName); +} + +css::uno::Sequence< OUString > SAL_CALL SearchFormattedToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception ) +{ + css::uno::Sequence< OUString > aSNS( 1 ); + aSNS[0] = "com.sun.star.frame.ToolbarController"; + return aSNS; +} + +// XComponent +void SAL_CALL SearchFormattedToolboxController::dispose() throw ( css::uno::RuntimeException, std::exception ) +{ + 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(); + + m_pSearchFormattedControl.disposeAndClear(); +} + +// XInitialization +void SAL_CALL SearchFormattedToolboxController::initialize( const css::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException, std::exception) +{ + 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); +} + +css::uno::Reference< css::awt::XWindow > SAL_CALL SearchFormattedToolboxController::createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException, std::exception ) +{ + css::uno::Reference< css::awt::XWindow > xItemWindow; + + css::uno::Reference< css::awt::XWindow > xParent( Parent ); + vcl::Window* pParent = VCLUnoHelper::GetWindow( xParent ); + if ( pParent ) + { + ToolBox* pToolbar = static_cast(pParent); + m_pSearchFormattedControl = VclPtr::Create( pToolbar, 0 ); + m_pSearchFormattedControl->SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_SEARCHFORMATTED ) ); + Size aSize( m_pSearchFormattedControl->GetOptimalSize() ); + m_pSearchFormattedControl->SetSizePixel( aSize ); + } + xItemWindow = VCLUnoHelper::GetInterface( m_pSearchFormattedControl ); + + return xItemWindow; +} + +// XStatusListener +void SAL_CALL SearchFormattedToolboxController::statusChanged( const css::frame::FeatureStateEvent& ) throw ( css::uno::RuntimeException, std::exception ) +{ +} + FindAllToolboxController::FindAllToolboxController( const css::uno::Reference< css::uno::XComponentContext > & rxContext ) : svt::ToolboxController( rxContext, css::uno::Reference< css::frame::XFrame >(), @@ -1144,6 +1248,14 @@ com_sun_star_svx_MatchCaseToolboxController_get_implementation( return cppu::acquire(new MatchCaseToolboxController(context)); } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_svx_SearchFormattedToolboxController_get_implementation( + css::uno::XComponentContext *context, + css::uno::Sequence const &) +{ + return cppu::acquire(new SearchFormattedToolboxController(context)); +} + extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_svx_FindAllToolboxController_get_implementation( css::uno::XComponentContext *context, diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.src b/svx/source/tbxctrls/tbunosearchcontrollers.src index d3b89201994c..e722d649d602 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.src +++ b/svx/source/tbxctrls/tbunosearchcontrollers.src @@ -29,4 +29,9 @@ String RID_SVXSTR_FINDBAR_MATCHCASE Text [ en-US ] = "Match Case" ; }; +String RID_SVXSTR_FINDBAR_SEARCHFORMATTED +{ + Text [ en-US ] = "Search Formatted Display String" ; +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/uiconfig/ui/findreplacedialog.ui b/svx/uiconfig/ui/findreplacedialog.ui index 49305d5da51a..aa25614eb5fe 100644 --- a/svx/uiconfig/ui/findreplacedialog.ui +++ b/svx/uiconfig/ui/findreplacedialog.ui @@ -920,6 +920,21 @@ 0 + + + Search formatted display string + True + True + False + False + 0 + True + + + 1 + 0 + + True @@ -955,7 +970,7 @@ - 1 + 2 0 diff --git a/svx/util/svx.component b/svx/util/svx.component index 967677befed0..0cff72e9b423 100644 --- a/svx/util/svx.component +++ b/svx/util/svx.component @@ -56,6 +56,10 @@ constructor="com_sun_star_svx_MatchCaseToolboxController_get_implementation"> + + + -- cgit