26#include <config_feature_desktop.h>
27#include <officecfg/Office/Common.hxx>
29#include <svx/strings.hrc>
36#include <com/sun/star/beans/PropertyValue.hpp>
37#include <com/sun/star/beans/XPropertySet.hpp>
38#include <com/sun/star/frame/DispatchDescriptor.hpp>
39#include <com/sun/star/frame/XDispatch.hpp>
40#include <com/sun/star/frame/XDispatchProvider.hpp>
41#include <com/sun/star/frame/XLayoutManager.hpp>
42#include <com/sun/star/frame/XStatusListener.hpp>
43#include <com/sun/star/lang/XInitialization.hpp>
44#include <com/sun/star/lang/XServiceInfo.hpp>
45#include <com/sun/star/text/XTextRange.hpp>
46#include <com/sun/star/ui/XUIElement.hpp>
47#include <com/sun/star/util/URL.hpp>
48#include <com/sun/star/util/URLTransformer.hpp>
49#include <com/sun/star/util/SearchAlgorithms.hpp>
50#include <com/sun/star/util/SearchAlgorithms2.hpp>
70constexpr OUStringLiteral COMMAND_FINDTEXT =
u".uno:FindText";
71constexpr OUStringLiteral COMMAND_DOWNSEARCH =
u".uno:DownSearch";
72constexpr OUStringLiteral COMMAND_UPSEARCH =
u".uno:UpSearch";
73constexpr OUStringLiteral COMMAND_FINDALL =
u".uno:FindAll";
74constexpr OUStringLiteral COMMAND_MATCHCASE =
u".uno:MatchCase";
75constexpr OUStringLiteral COMMAND_SEARCHFORMATTED =
u".uno:SearchFormattedDisplayString";
80 CheckButtonItemWindow(
vcl::Window* pParent,
const OUString& rLabel)
82 ,
m_xWidget(m_xBuilder->weld_check_button(
"checkbutton"))
86 m_xWidget->connect_key_press(
LINK(
this, CheckButtonItemWindow, KeyInputHdl));
91 bool get_active()
const
102 virtual ~CheckButtonItemWindow()
override
108 std::unique_ptr<weld::CheckButton>
m_xWidget;
115 return ChildKeyInput(rKeyEvent);
118void impl_executeSearch(
const css::uno::Reference< css::uno::XComponentContext >& rxContext,
119 const css::uno::Reference< css::frame::XFrame >& xFrame,
121 const bool aSearchBackwards,
122 const bool aFindAll =
false )
124 css::uno::Reference< css::util::XURLTransformer > xURLTransformer( css::util::URLTransformer::create( rxContext ) );
126 aURL.Complete =
".uno:ExecuteSearch";
127 xURLTransformer->parseStrict(aURL);
130 bool aMatchCase =
false;
131 bool bSearchFormatted =
false;
134 ToolBox::ImplToolItems::size_type nItemCount = pToolBox->
GetItemCount();
135 for ( ToolBox::ImplToolItems::size_type i=0;
i<nItemCount; ++
i )
139 if ( sItemCommand == COMMAND_FINDTEXT )
148 }
else if ( sItemCommand == COMMAND_MATCHCASE )
150 CheckButtonItemWindow* pItemWin =
static_cast<CheckButtonItemWindow*
>(pToolBox->
GetItemWindow(
id));
152 aMatchCase = pItemWin->get_active();
153 }
else if ( sItemCommand == COMMAND_SEARCHFORMATTED )
155 CheckButtonItemWindow* pItemWin =
static_cast<CheckButtonItemWindow*
>(pToolBox->
GetItemWindow(
id));
157 bSearchFormatted = pItemWin->get_active();
164 nFlags |= TransliterationFlags::IGNORE_CASE;
166 nFlags |= TransliterationFlags::IGNORE_DIACRITICS_CTL
167 | TransliterationFlags::IGNORE_KASHIDA_CTL;
170 {
"SearchItem.SearchString", css::uno::Any( sFindText ) },
172 {
"SearchItem.CellType", css::uno::Any( sal_Int16(SvxSearchCellType::VALUE) ) },
173 {
"SearchItem.Backward", css::uno::Any( aSearchBackwards ) },
174 {
"SearchItem.SearchFlags", css::uno::Any( sal_Int32(0) ) },
175 {
"SearchItem.TransliterateFlags", css::uno::Any(
static_cast<sal_Int32
>(nFlags) ) },
176 {
"SearchItem.Command", css::uno::Any(
static_cast<sal_Int16
>(aFindAll ?SvxSearchCmd::FIND_ALL : SvxSearchCmd::FIND ) ) },
177 {
"SearchItem.AlgorithmType", css::uno::Any( sal_Int16(css::util::SearchAlgorithms_ABSOLUTE) ) },
178 {
"SearchItem.AlgorithmType2", css::uno::Any( sal_Int16(css::util::SearchAlgorithms2::ABSOLUTE) ) },
179 {
"SearchItem.SearchFormatted", css::uno::Any( bSearchFormatted ) }
182 css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider(xFrame, css::uno::UNO_QUERY);
183 if ( xDispatchProvider.is() )
185 css::uno::Reference< css::frame::XDispatch >
xDispatch = xDispatchProvider->queryDispatch( aURL, OUString(), 0 );
197 css::uno::Reference< css::frame::XFrame > xFrame,
198 css::uno::Reference< css::uno::XComponentContext > xContext) :
200 m_nAsyncGetFocusId(nullptr),
201 m_xWidget(m_xBuilder->weld_combo_box(
"find")),
204 m_pAcc(
svt::AcceleratorExecute::createAcceleratorHelper())
209 m_xWidget->set_entry_completion(
true,
true);
220 m_nRememberSize = officecfg::Office::Common::Misc::FindReplaceRememberedSearches::get();
245 css::uno::Reference<css::frame::XController>
xController(
m_xFrame->getController(), css::uno::UNO_SET_THROW);
246 css::uno::Reference<css::frame::XModel>
xModel(
xController->getModel(), css::uno::UNO_SET_THROW);
247 css::uno::Reference<css::container::XIndexAccess> xIndexAccess(
xModel->getCurrentSelection(), css::uno::UNO_QUERY_THROW);
248 if (xIndexAccess->getCount() > 0)
250 css::uno::Reference<css::text::XTextRange> xTextRange(xIndexAccess->getByIndex(0), css::uno::UNO_QUERY_THROW);
251 aString = xTextRange->getString();
258 if ( !aString.isEmpty() )
280 bool bShift = rKeyEvent.GetKeyCode().IsShift();
281 bool bMod1 = rKeyEvent.GetKeyCode().IsMod1();
282 sal_uInt16 nCode = rKeyEvent.GetKeyCode().GetCode();
288 GrabFocusToDocument();
291 css::uno::Reference< css::beans::XPropertySet > xPropSet(
m_xFrame, css::uno::UNO_QUERY);
294 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
295 css::uno::Any aValue = xPropSet->getPropertyValue(
"LayoutManager");
296 aValue >>= xLayoutManager;
297 if (xLayoutManager.is())
299 static constexpr OUStringLiteral sResourceURL(
u"private:resource/toolbar/findbar" );
300 xLayoutManager->hideElement( sResourceURL );
301 xLayoutManager->destroyElement( sResourceURL );
308 const OUString
aCommand(m_pAcc->findCommand(awtKey));
311 if ( bMod1 && nCode ==
KEY_F )
316 ActivateFind(bShift);
319 else if (
aCommand ==
".uno:SearchDialog")
320 bRet = m_pAcc->execute(awtKey);
323 if (
aCommand ==
"vnd.sun.star.findbar:FocusToFindbar")
330 return bRet || ChildKeyInput(rKeyEvent);
360 m_nAsyncGetFocusId =
nullptr;
429class SearchToolbarControllersManager
433 SearchToolbarControllersManager();
435 static SearchToolbarControllersManager& createControllersManager();
437 void registryController(
const css::uno::Reference< css::frame::XFrame >& xFrame,
const css::uno::Reference< css::frame::XStatusListener >& xStatusListener,
const OUString& sCommandURL );
438 void freeController (
const css::uno::Reference< css::frame::XFrame >& xFrame,
const OUString& sCommandURL );
439 css::uno::Reference< css::frame::XStatusListener > findController(
const css::uno::Reference< css::frame::XFrame >& xFrame,
const OUString& sCommandURL );
446 typedef ::std::vector< css::beans::PropertyValue > SearchToolbarControllersVec;
447 typedef ::std::map< css::uno::Reference< css::frame::XFrame >, SearchToolbarControllersVec > SearchToolbarControllersMap;
448 SearchToolbarControllersMap aSearchToolbarControllersMap;
449 std::vector<OUString> m_aSearchStrings;
453SearchToolbarControllersManager::SearchToolbarControllersManager()
457SearchToolbarControllersManager& SearchToolbarControllersManager::createControllersManager()
459 static SearchToolbarControllersManager theSearchToolbarControllersManager;
460 return theSearchToolbarControllersManager;
463void SearchToolbarControllersManager::saveSearchHistory(
const FindTextFieldControl* pFindTextFieldControl)
465 const sal_Int32 nECount( pFindTextFieldControl->
get_count() );
466 m_aSearchStrings.resize( nECount );
467 for( sal_Int32 i=0;
i<nECount; ++
i )
469 m_aSearchStrings[
i] = pFindTextFieldControl->
get_text(i);
473void SearchToolbarControllersManager::loadSearchHistory(
FindTextFieldControl* pFindTextFieldControl)
475 for(
size_t i=0;
i<m_aSearchStrings.size(); ++
i )
477 pFindTextFieldControl->
append_text(m_aSearchStrings[i]);
481void SearchToolbarControllersManager::registryController(
const css::uno::Reference< css::frame::XFrame >& xFrame,
const css::uno::Reference< css::frame::XStatusListener >& xStatusListener,
const OUString& sCommandURL )
483 SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame);
484 if (pIt == aSearchToolbarControllersMap.end())
486 SearchToolbarControllersVec lControllers(1);
487 lControllers[0].Name = sCommandURL;
488 lControllers[0].Value <<= xStatusListener;
489 aSearchToolbarControllersMap.emplace(xFrame, lControllers);
493 sal_Int32 nSize = pIt->second.size();
494 for (sal_Int32 i=0;
i<nSize; ++
i)
496 if (pIt->second[i].Name == sCommandURL)
500 pIt->second.resize(nSize+1);
501 pIt->second[nSize].Name = sCommandURL;
502 pIt->second[nSize].Value <<= xStatusListener;
506void SearchToolbarControllersManager::freeController(
const css::uno::Reference< css::frame::XFrame >& xFrame,
const OUString& sCommandURL )
508 SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame);
509 if (pIt != aSearchToolbarControllersMap.end())
511 auto pItCtrl = std::find_if(pIt->second.begin(), pIt->second.end(),
512 [&sCommandURL](
const css::beans::PropertyValue& rCtrl) { return rCtrl.Name == sCommandURL; });
513 if (pItCtrl != pIt->second.end())
514 pIt->second.erase(pItCtrl);
516 if (pIt->second.empty())
517 aSearchToolbarControllersMap.erase(pIt);
521css::uno::Reference< css::frame::XStatusListener > SearchToolbarControllersManager::findController(
const css::uno::Reference< css::frame::XFrame >& xFrame,
const OUString& sCommandURL )
523 css::uno::Reference< css::frame::XStatusListener > xStatusListener;
525 SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame);
526 if (pIt != aSearchToolbarControllersMap.end())
528 auto pItCtrl = std::find_if(pIt->second.begin(), pIt->second.end(),
529 [&sCommandURL](
const css::beans::PropertyValue& rCtrl) { return rCtrl.Name == sCommandURL; });
530 if (pItCtrl != pIt->second.end())
531 pItCtrl->Value >>= xStatusListener;
534 return xStatusListener;
537typedef cppu::ImplInheritanceHelper< ::svt::ToolboxController, css::lang::XServiceInfo> FindTextToolbarController_Base;
538class FindTextToolbarController :
public FindTextToolbarController_Base
542 FindTextToolbarController(
const css::uno::Reference< css::uno::XComponentContext > & rxContext );
550 virtual void SAL_CALL
dispose()
override;
553 virtual void SAL_CALL initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
override;
556 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow(
const css::uno::Reference< css::awt::XWindow >& Parent )
override;
559 virtual void SAL_CALL statusChanged(
const css::frame::FeatureStateEvent& Event )
override;
565 void textfieldChanged();
575FindTextToolbarController::FindTextToolbarController(
const css::uno::Reference< css::uno::XComponentContext >& rxContext )
576 : FindTextToolbarController_Base(rxContext, css::
uno::
Reference< css::frame::XFrame >(), COMMAND_FINDTEXT)
577 , m_pFindTextFieldControl(nullptr)
585OUString SAL_CALL FindTextToolbarController::getImplementationName()
587 return "com.sun.star.svx.FindTextToolboxController";
590sal_Bool SAL_CALL FindTextToolbarController::supportsService(
const OUString& ServiceName )
595css::uno::Sequence< OUString > SAL_CALL FindTextToolbarController::getSupportedServiceNames()
597 return {
"com.sun.star.frame.ToolbarController" };
601void SAL_CALL FindTextToolbarController::dispose()
605 SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, m_aCommandURL);
608 if (m_pFindTextFieldControl !=
nullptr) {
609 SearchToolbarControllersManager::createControllersManager()
610 .saveSearchHistory(m_pFindTextFieldControl);
611 m_pFindTextFieldControl.disposeAndClear();
616void SAL_CALL FindTextToolbarController::initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
624 m_nDownSearchId = pToolBox->
GetItemId(COMMAND_DOWNSEARCH);
625 m_nUpSearchId = pToolBox->
GetItemId(COMMAND_UPSEARCH);
626 m_nFindAllId = pToolBox->
GetItemId(COMMAND_FINDALL);
629 SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(
this), m_aCommandURL);
632css::uno::Reference< css::awt::XWindow > SAL_CALL FindTextToolbarController::createItemWindow(
const css::uno::Reference< css::awt::XWindow >& xParent )
634 css::uno::Reference< css::awt::XWindow > xItemWindow;
642 m_pFindTextFieldControl->connect_changed(
LINK(
this, FindTextToolbarController, EditModifyHdl));
643 SearchToolbarControllersManager::createControllersManager().loadSearchHistory(m_pFindTextFieldControl);
651void SAL_CALL FindTextToolbarController::statusChanged(
const css::frame::FeatureStateEvent& rEvent )
657 OUString aFeatureURL = rEvent.FeatureURL.Complete;
658 if ( aFeatureURL ==
"AppendSearchHistory" )
660 m_pFindTextFieldControl->Remember_Impl(m_pFindTextFieldControl->get_active_text());
669 #if HAVE_FEATURE_DESKTOP
676void FindTextToolbarController::textfieldChanged() {
680 if ( pToolBox && m_pFindTextFieldControl )
682 bool enableButtons = !m_pFindTextFieldControl->get_active_text().isEmpty();
683 pToolBox->
EnableItem(m_nDownSearchId, enableButtons);
684 pToolBox->
EnableItem(m_nUpSearchId, enableButtons);
685 pToolBox->
EnableItem(m_nFindAllId, enableButtons);
689typedef cppu::ImplInheritanceHelper< ::svt::ToolboxController, css::lang::XServiceInfo> UpDownSearchToolboxController_Base;
690class UpDownSearchToolboxController :
public UpDownSearchToolboxController_Base
695 UpDownSearchToolboxController(
const css::uno::Reference< css::uno::XComponentContext >& rxContext,
Type eType );
703 virtual void SAL_CALL
dispose()
override;
706 virtual void SAL_CALL initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
override;
709 virtual void SAL_CALL execute( sal_Int16 KeyModifier )
override;
712 virtual void SAL_CALL statusChanged(
const css::frame::FeatureStateEvent& rEvent )
override;
718UpDownSearchToolboxController::UpDownSearchToolboxController(
const css::uno::Reference< css::uno::XComponentContext > & rxContext,
Type eType )
719 : UpDownSearchToolboxController_Base( rxContext,
721 (
eType ==
UP) ? OUString( COMMAND_UPSEARCH ): OUString( COMMAND_DOWNSEARCH ) ),
727OUString SAL_CALL UpDownSearchToolboxController::getImplementationName()
729 return meType == UpDownSearchToolboxController::UP?
730 OUString(
"com.sun.star.svx.UpSearchToolboxController" ) :
731 OUString(
"com.sun.star.svx.DownSearchToolboxController" );
734sal_Bool SAL_CALL UpDownSearchToolboxController::supportsService(
const OUString& ServiceName )
739css::uno::Sequence< OUString > SAL_CALL UpDownSearchToolboxController::getSupportedServiceNames()
741 return {
"com.sun.star.frame.ToolbarController" };
745void SAL_CALL UpDownSearchToolboxController::dispose()
749 SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, m_aCommandURL);
755void SAL_CALL UpDownSearchToolboxController::initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
758 SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(
this), m_aCommandURL);
762void SAL_CALL UpDownSearchToolboxController::execute( sal_Int16 )
765 throw css::lang::DisposedException();
770 impl_executeSearch(m_xContext, m_xFrame, pToolBox, meType == UP );
772 css::frame::FeatureStateEvent
aEvent;
773 aEvent.FeatureURL.Complete =
"AppendSearchHistory";
774 css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager().findController(m_xFrame, COMMAND_FINDTEXT);
775 if (xStatusListener.is())
776 xStatusListener->statusChanged( aEvent );
780void SAL_CALL UpDownSearchToolboxController::statusChanged(
const css::frame::FeatureStateEvent& )
784typedef cppu::ImplInheritanceHelper< ::svt::ToolboxController, css::lang::XServiceInfo> MatchCaseToolboxController_Base;
785class MatchCaseToolboxController :
public MatchCaseToolboxController_Base
788 MatchCaseToolboxController(
const css::uno::Reference< css::uno::XComponentContext >& rxContext );
796 virtual void SAL_CALL
dispose()
override;
799 virtual void SAL_CALL initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
override;
802 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow(
const css::uno::Reference< css::awt::XWindow >& Parent )
override;
805 virtual void SAL_CALL statusChanged(
const css::frame::FeatureStateEvent& rEvent )
override;
811MatchCaseToolboxController::MatchCaseToolboxController(
const css::uno::Reference< css::uno::XComponentContext >& rxContext )
812 : MatchCaseToolboxController_Base( rxContext,
815 , m_xMatchCaseControl(nullptr)
820OUString SAL_CALL MatchCaseToolboxController::getImplementationName()
822 return "com.sun.star.svx.MatchCaseToolboxController";
825sal_Bool SAL_CALL MatchCaseToolboxController::supportsService(
const OUString& ServiceName )
830css::uno::Sequence< OUString > SAL_CALL MatchCaseToolboxController::getSupportedServiceNames()
832 return {
"com.sun.star.frame.ToolbarController" };
836void SAL_CALL MatchCaseToolboxController::dispose()
840 SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, m_aCommandURL);
844 m_xMatchCaseControl.disposeAndClear();
848void SAL_CALL MatchCaseToolboxController::initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
852 SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(
this), m_aCommandURL);
855css::uno::Reference< css::awt::XWindow > SAL_CALL MatchCaseToolboxController::createItemWindow(
const css::uno::Reference< css::awt::XWindow >& xParent )
857 css::uno::Reference< css::awt::XWindow > xItemWindow;
871void SAL_CALL MatchCaseToolboxController::statusChanged(
const css::frame::FeatureStateEvent& )
875typedef cppu::ImplInheritanceHelper< ::svt::ToolboxController, css::lang::XServiceInfo> SearchFormattedToolboxController_Base;
876class SearchFormattedToolboxController :
public SearchFormattedToolboxController_Base
879 SearchFormattedToolboxController(
const css::uno::Reference< css::uno::XComponentContext >& rxContext );
887 virtual void SAL_CALL
dispose()
override;
890 virtual void SAL_CALL initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
override;
893 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow(
const css::uno::Reference< css::awt::XWindow >& Parent )
override;
896 virtual void SAL_CALL statusChanged(
const css::frame::FeatureStateEvent& rEvent )
override;
902SearchFormattedToolboxController::SearchFormattedToolboxController(
const css::uno::Reference< css::uno::XComponentContext >& rxContext )
903 : SearchFormattedToolboxController_Base( rxContext,
905 COMMAND_SEARCHFORMATTED )
906 , m_xSearchFormattedControl(nullptr)
911OUString SAL_CALL SearchFormattedToolboxController::getImplementationName()
913 return "com.sun.star.svx.SearchFormattedToolboxController";
916sal_Bool SAL_CALL SearchFormattedToolboxController::supportsService(
const OUString& ServiceName )
921css::uno::Sequence< OUString > SAL_CALL SearchFormattedToolboxController::getSupportedServiceNames()
923 return {
"com.sun.star.frame.ToolbarController" };
927void SAL_CALL SearchFormattedToolboxController::dispose()
931 SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, m_aCommandURL);
935 m_xSearchFormattedControl.disposeAndClear();
939void SAL_CALL SearchFormattedToolboxController::initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
943 SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(
this), m_aCommandURL);
946css::uno::Reference< css::awt::XWindow > SAL_CALL SearchFormattedToolboxController::createItemWindow(
const css::uno::Reference< css::awt::XWindow >& xParent )
948 css::uno::Reference< css::awt::XWindow > xItemWindow;
962void SAL_CALL SearchFormattedToolboxController::statusChanged(
const css::frame::FeatureStateEvent& )
966typedef cppu::ImplInheritanceHelper< ::svt::ToolboxController, css::lang::XServiceInfo> FindAllToolboxController_Base;
967class FindAllToolboxController :
public FindAllToolboxController_Base
970 FindAllToolboxController(
const css::uno::Reference< css::uno::XComponentContext >& rxContext );
978 virtual void SAL_CALL
dispose()
override;
981 virtual void SAL_CALL initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
override;
984 virtual void SAL_CALL execute( sal_Int16 KeyModifier )
override;
987 virtual void SAL_CALL statusChanged(
const css::frame::FeatureStateEvent& rEvent )
override;
990FindAllToolboxController::FindAllToolboxController(
const css::uno::Reference< css::uno::XComponentContext > & rxContext )
991 : FindAllToolboxController_Base( rxContext,
998OUString SAL_CALL FindAllToolboxController::getImplementationName()
1000 return "com.sun.star.svx.FindAllToolboxController";
1004sal_Bool SAL_CALL FindAllToolboxController::supportsService(
const OUString& ServiceName )
1009css::uno::Sequence< OUString > SAL_CALL FindAllToolboxController::getSupportedServiceNames()
1011 return {
"com.sun.star.frame.ToolbarController" };
1015void SAL_CALL FindAllToolboxController::dispose()
1019 SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, m_aCommandURL);
1025void SAL_CALL FindAllToolboxController::initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
1028 SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(
this), m_aCommandURL);
1032void SAL_CALL FindAllToolboxController::execute( sal_Int16 )
1035 throw css::lang::DisposedException();
1040 impl_executeSearch(m_xContext, m_xFrame, pToolBox,
false,
true);
1044void SAL_CALL FindAllToolboxController::statusChanged(
const css::frame::FeatureStateEvent& )
1048typedef cppu::ImplInheritanceHelper< ::svt::ToolboxController, css::lang::XServiceInfo> ExitSearchToolboxController_Base;
1049class ExitSearchToolboxController :
public ExitSearchToolboxController_Base
1052 ExitSearchToolboxController(
const css::uno::Reference< css::uno::XComponentContext >& rxContext );
1060 virtual void SAL_CALL
dispose()
override;
1063 virtual void SAL_CALL initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
override;
1066 virtual void SAL_CALL execute( sal_Int16 KeyModifier )
override;
1069 virtual void SAL_CALL statusChanged(
const css::frame::FeatureStateEvent& rEvent )
override;
1072ExitSearchToolboxController::ExitSearchToolboxController(
const css::uno::Reference< css::uno::XComponentContext > & rxContext )
1073 : ExitSearchToolboxController_Base( rxContext,
1080OUString SAL_CALL ExitSearchToolboxController::getImplementationName()
1082 return "com.sun.star.svx.ExitFindbarToolboxController";
1086sal_Bool SAL_CALL ExitSearchToolboxController::supportsService(
const OUString& ServiceName )
1091css::uno::Sequence< OUString > SAL_CALL ExitSearchToolboxController::getSupportedServiceNames()
1093 return {
"com.sun.star.frame.ToolbarController" };
1097void SAL_CALL ExitSearchToolboxController::dispose()
1101 SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, m_aCommandURL);
1107void SAL_CALL ExitSearchToolboxController::initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
1110 SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(
this), m_aCommandURL);
1114void SAL_CALL ExitSearchToolboxController::execute( sal_Int16 )
1121 css::uno::Reference< css::beans::XPropertySet > xPropSet(m_xFrame, css::uno::UNO_QUERY);
1124 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
1125 css::uno::Any aValue = xPropSet->getPropertyValue(
"LayoutManager");
1126 aValue >>= xLayoutManager;
1127 if (xLayoutManager.is())
1129 static constexpr OUStringLiteral sResourceURL( u
"private:resource/toolbar/findbar" );
1130 xLayoutManager->hideElement( sResourceURL );
1131 xLayoutManager->destroyElement( sResourceURL );
1137void SAL_CALL ExitSearchToolboxController::statusChanged(
const css::frame::FeatureStateEvent& )
1141typedef cppu::ImplInheritanceHelper< ::svt::ToolboxController, css::lang::XServiceInfo> SearchLabelToolboxController_Base;
1142class SearchLabelToolboxController :
public SearchLabelToolboxController_Base
1145 SearchLabelToolboxController(
const css::uno::Reference< css::uno::XComponentContext >& rxContext );
1153 virtual void SAL_CALL
dispose()
override;
1156 virtual void SAL_CALL initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
override;
1159 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow(
const css::uno::Reference< css::awt::XWindow >& Parent )
override;
1162 virtual void SAL_CALL statusChanged(
const css::frame::FeatureStateEvent& rEvent )
override;
1168SearchLabelToolboxController::SearchLabelToolboxController(
const css::uno::Reference< css::uno::XComponentContext > & rxContext )
1169 : SearchLabelToolboxController_Base( rxContext,
1171 ".uno:SearchLabel" )
1176OUString SAL_CALL SearchLabelToolboxController::getImplementationName()
1178 return "com.sun.star.svx.SearchLabelToolboxController";
1182sal_Bool SAL_CALL SearchLabelToolboxController::supportsService(
const OUString& ServiceName )
1187css::uno::Sequence< OUString > SAL_CALL SearchLabelToolboxController::getSupportedServiceNames()
1189 return {
"com.sun.star.frame.ToolbarController" };
1193void SAL_CALL SearchLabelToolboxController::dispose()
1197 SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, m_aCommandURL);
1200 m_xSL.disposeAndClear();
1204void SAL_CALL SearchLabelToolboxController::initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
1207 SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(
this), m_aCommandURL);
1211void SAL_CALL SearchLabelToolboxController::statusChanged(
const css::frame::FeatureStateEvent& )
1216 m_xSL->set_label(aStr);
1217 m_xSL->SetOptimalSize();
1218 Size aSize(m_xSL->GetSizePixel());
1220 m_xSL->SetSizePixel(
Size(nWidth, aSize.Height()));
1224css::uno::Reference< css::awt::XWindow > SAL_CALL SearchLabelToolboxController::createItemWindow(
const css::uno::Reference< css::awt::XWindow >& Parent )
1228 if (getToolboxId(nId, &pToolBox))
1232 m_xSL->SetSizePixel(
Size(16, m_xSL->GetSizePixel().Height()));
1238class FindbarDispatcher :
public css::lang::XServiceInfo,
1239 public css::lang::XInitialization,
1240 public css::frame::XDispatchProvider,
1241 public css::frame::XDispatch,
1246 FindbarDispatcher();
1247 virtual ~FindbarDispatcher()
override;
1250 virtual css::uno::Any SAL_CALL
queryInterface(
const css::uno::Type& aType )
override;
1251 virtual void SAL_CALL
acquire() noexcept override;
1252 virtual
void SAL_CALL release() noexcept override;
1255 virtual OUString SAL_CALL getImplementationName() override;
1256 virtual
sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
1257 virtual css::
uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
1260 virtual
void SAL_CALL initialize( const css::
uno::Sequence< css::
uno::Any >& aArguments ) override;
1263 virtual css::
uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL& aURL, const OUString& sTargetFrameName , sal_Int32 nSearchFlags ) override;
1264 virtual css::
uno::Sequence< css::
uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::
uno::Sequence< css::frame::DispatchDescriptor >& lDescriptions ) override;
1267 virtual
void SAL_CALL dispatch( const css::util::URL& aURL, const css::
uno::Sequence< css::beans::PropertyValue >& lArguments ) override;
1268 virtual
void SAL_CALL addStatusListener( const css::
uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) override;
1269 virtual
void SAL_CALL removeStatusListener( const css::
uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) override;
1273 css::
uno::Reference< css::frame::XFrame > m_xFrame;
1277FindbarDispatcher::FindbarDispatcher()
1281FindbarDispatcher::~FindbarDispatcher()
1287css::uno::Any SAL_CALL FindbarDispatcher::queryInterface(
const css::uno::Type& aType )
1289 css::uno::Any aReturn( ::cppu::queryInterface( aType,
1290 static_cast< css::lang::XServiceInfo*
>(
this),
1291 static_cast< css::lang::XInitialization*
>(
this),
1292 static_cast< css::frame::XDispatchProvider*
>(
this),
1293 static_cast< css::frame::XDispatch*
>(
this)) );
1295 if ( aReturn.hasValue() )
1298 return OWeakObject::queryInterface( aType );
1301void SAL_CALL FindbarDispatcher::acquire() noexcept
1303 OWeakObject::acquire();
1306void SAL_CALL FindbarDispatcher::release() noexcept
1308 OWeakObject::release();
1312OUString SAL_CALL FindbarDispatcher::getImplementationName()
1314 return "com.sun.star.comp.svx.Impl.FindbarDispatcher";
1317sal_Bool SAL_CALL FindbarDispatcher::supportsService(
const OUString& ServiceName )
1322css::uno::Sequence< OUString > SAL_CALL FindbarDispatcher::getSupportedServiceNames()
1324 return {
"com.sun.star.comp.svx.FindbarDispatcher",
"com.sun.star.frame.ProtocolHandler" };
1328void SAL_CALL FindbarDispatcher::initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
1335css::uno::Reference< css::frame::XDispatch > SAL_CALL FindbarDispatcher::queryDispatch(
const css::util::URL& aURL,
const OUString& , sal_Int32 )
1337 css::uno::Reference< css::frame::XDispatch >
xDispatch;
1339 if (
aURL.Protocol ==
"vnd.sun.star.findbar:" )
1345css::uno::Sequence < css::uno::Reference< css::frame::XDispatch > > SAL_CALL FindbarDispatcher::queryDispatches(
const css::uno::Sequence < css::frame::DispatchDescriptor >& seqDescripts )
1347 sal_Int32
nCount = seqDescripts.getLength();
1348 css::uno::Sequence < css::uno::Reference < XDispatch > > lDispatcher( nCount );
1350 std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.getArray(),
1351 [
this](
const css::frame::DispatchDescriptor& rDescript) -> css::uno::Reference < XDispatch > {
1352 return queryDispatch( rDescript.FeatureURL, rDescript.FrameName, rDescript.SearchFlags ); });
1358void SAL_CALL FindbarDispatcher::dispatch(
const css::util::URL& aURL,
const css::uno::Sequence < css::beans::PropertyValue >& )
1361 if (
aURL.Path !=
"FocusToFindbar" )
1364 css::uno::Reference< css::beans::XPropertySet > xPropSet(m_xFrame, css::uno::UNO_QUERY);
1368 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
1369 css::uno::Any aValue = xPropSet->getPropertyValue(
"LayoutManager");
1370 aValue >>= xLayoutManager;
1371 if (!xLayoutManager.is())
1374 static constexpr OUStringLiteral sResourceURL( u
"private:resource/toolbar/findbar" );
1375 css::uno::Reference< css::ui::XUIElement > xUIElement = xLayoutManager->getElement(sResourceURL);
1376 if (!xUIElement.is())
1379 xLayoutManager->createElement( sResourceURL );
1380 xLayoutManager->showElement( sResourceURL );
1381 xUIElement = xLayoutManager->getElement( sResourceURL );
1382 if ( !xUIElement.is() )
1386 css::uno::Reference< css::awt::XWindow > xWindow(xUIElement->getRealInterface(), css::uno::UNO_QUERY);
1389 pToolBox->
set_id(
"FindBar");
1393 ToolBox::ImplToolItems::size_type nItemCount = pToolBox->
GetItemCount();
1394 for ( ToolBox::ImplToolItems::size_type i=0;
i<nItemCount; ++
i )
1398 if ( sItemCommand == COMMAND_FINDTEXT )
1405 if ( pFindTextFieldControl )
1414void SAL_CALL FindbarDispatcher::addStatusListener(
const css::uno::Reference< css::frame::XStatusListener >& ,
const css::util::URL& )
1418void SAL_CALL FindbarDispatcher::removeStatusListener(
const css::uno::Reference< css::frame::XStatusListener >& ,
const css::util::URL& )
1424extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1426 css::uno::XComponentContext *context,
1427 css::uno::Sequence<css::uno::Any>
const &)
1429 return cppu::acquire(
new FindTextToolbarController(context));
1432extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1434 css::uno::XComponentContext *context,
1435 css::uno::Sequence<css::uno::Any>
const &)
1437 return cppu::acquire(
new ExitSearchToolboxController(context));
1440extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1442 css::uno::XComponentContext *context,
1443 css::uno::Sequence<css::uno::Any>
const &)
1445 return cppu::acquire(
new UpDownSearchToolboxController(context, UpDownSearchToolboxController::UP));
1448extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1450 css::uno::XComponentContext *context,
1451 css::uno::Sequence<css::uno::Any>
const &)
1453 return cppu::acquire(
new UpDownSearchToolboxController(context, UpDownSearchToolboxController::DOWN));
1456extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1458 css::uno::XComponentContext *context,
1459 css::uno::Sequence<css::uno::Any>
const &)
1461 return cppu::acquire(
new MatchCaseToolboxController(context));
1464extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1466 css::uno::XComponentContext *context,
1467 css::uno::Sequence<css::uno::Any>
const &)
1469 return cppu::acquire(
new SearchFormattedToolboxController(context));
1472extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1474 css::uno::XComponentContext *context,
1475 css::uno::Sequence<css::uno::Any>
const &)
1477 return cppu::acquire(
new FindAllToolboxController(context));
1480extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1482 css::uno::XComponentContext *context,
1483 css::uno::Sequence<css::uno::Any>
const &)
1485 return cppu::acquire(
new SearchLabelToolboxController(context));
1488extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1490 SAL_UNUSED_PARAMETER css::uno::XComponentContext *,
1491 css::uno::Sequence<css::uno::Any>
const &)
1493 return cppu::acquire(
new FindbarDispatcher);
Reference< XComponentContext > m_xContext
css::uno::Reference< css::lang::XComponent > m_xFrame
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
static vcl::Window * GetFocusWindow()
std::unique_ptr< svt::AcceleratorExecute > m_pAcc
virtual ~FindTextFieldControl() override
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual void dispose() override
OUString get_active_text() const
void append_text(const OUString &rText)
css::uno::Reference< css::frame::XFrame > m_xFrame
OUString get_text(int nIndex) const
ImplSVEvent * m_nAsyncGetFocusId
sal_uInt16 m_nRememberSize
void SetTextToSelected_Impl()
void Remember_Impl(const OUString &rStr)
Link< weld::ComboBox &, void > m_aChangeHdl
void set_entry_message_type(weld::EntryMessageType eType)
void ActivateFind(bool bShift)
static OUString m_sRememberedSearchString
void connect_changed(const Link< weld::ComboBox &, void > &rLink)
std::unique_ptr< weld::ComboBox > m_xWidget
FindTextFieldControl(vcl::Window *pParent, css::uno::Reference< css::frame::XFrame > xFrame, css::uno::Reference< css::uno::XComponentContext > xContext)
bool ControlHasFocus() const
virtual void dispose() override
virtual void GetFocus() override
void InitControlBase(weld::Widget *pWidget)
static bool IsCTLFontEnabled()
static OUString GetSearchLabel()
static void SetSearchLabel(const SearchLabel &rSL)
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
reference_type * get() const
static VclPtr< reference_type > Create(Arg &&... arg)
virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) SAL_OVERRIDE
static css::awt::KeyEvent st_VCLKey2AWTKey(const vcl::KeyCode &aKey)
vcl::Window * GetParent() const
virtual void SetSizePixel(const Size &rNewSize)
void set_id(const OUString &rID)
void GrabFocusToDocument()
OUString SvxResId(TranslateId aId)
Reference< XDispatch > xDispatch
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
Sequence< PropertyValue > aArguments
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_F3
constexpr sal_uInt16 KEY_ESCAPE
constexpr sal_uInt16 KEY_F
constexpr sal_uInt16 KEY_G
#define LINK(Instance, Class, Member)
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Reference< XController > xController
Reference< XFrame > xFrame
Reference< XModel > xModel
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_svx_ExitFindbarToolboxController_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_svx_FindTextToolboxController_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_svx_UpSearchToolboxController_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_svx_DownSearchToolboxController_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
IMPL_LINK(FindTextFieldControl, KeyInputHdl, const KeyEvent &, rKeyEvent, bool)
IMPL_LINK_NOARG(FindTextFieldControl, ActivateHdl, weld::ComboBox &, bool)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_Impl_FindbarDispatcher_get_implementation(SAL_UNUSED_PARAMETER css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_svx_SearchLabelToolboxController_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_svx_SearchFormattedToolboxController_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_svx_FindAllToolboxController_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_svx_MatchCaseToolboxController_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)