1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
25 #include <config_feature_desktop.h>
27 #include <svx/strings.hrc>
28 #include <svx/dialmgr.hxx>
30 #include <comphelper/propertysequence.hxx>
31 #include <cppuhelper/queryinterface.hxx>
32 #include <cppuhelper/supportsservice.hxx>
33 #include <cppuhelper/weak.hxx>
34 #include <com/sun/star/beans/PropertyValue.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/frame/DispatchDescriptor.hpp>
37 #include <com/sun/star/frame/XDispatch.hpp>
38 #include <com/sun/star/frame/XDispatchProvider.hpp>
39 #include <com/sun/star/frame/XLayoutManager.hpp>
40 #include <com/sun/star/frame/XStatusListener.hpp>
41 #include <com/sun/star/lang/XInitialization.hpp>
42 #include <com/sun/star/lang/XServiceInfo.hpp>
43 #include <com/sun/star/text/XTextRange.hpp>
44 #include <com/sun/star/ui/XUIElement.hpp>
45 #include <com/sun/star/util/URL.hpp>
46 #include <com/sun/star/util/URLTransformer.hpp>
47 #include <com/sun/star/util/SearchAlgorithms.hpp>
48 #include <com/sun/star/util/SearchAlgorithms2.hpp>
50 #include <svl/ctloptions.hxx>
51 #include <svl/srchitem.hxx>
52 #include <svtools/acceleratorexecute.hxx>
53 #include <svtools/toolboxcontroller.hxx>
54 #include <toolkit/helper/vclunohelper.hxx>
55 #include <vcl/toolbox.hxx>
56 #include <vcl/svapp.hxx>
57 #include <rtl/ref.hxx>
58 #include <rtl/instance.hxx>
59 #include <svx/srchdlg.hxx>
60 #include <vcl/button.hxx>
61 #include <vcl/combobox.hxx>
62 #include <vcl/event.hxx>
63 #include <vcl/fixed.hxx>
64 #include <vcl/window.hxx>
70 static const char COMMAND_FINDTEXT
[] = ".uno:FindText";
71 static const char COMMAND_DOWNSEARCH
[] = ".uno:DownSearch";
72 static const char COMMAND_UPSEARCH
[] = ".uno:UpSearch";
73 static const char COMMAND_FINDALL
[] = ".uno:FindAll";
74 static const char COMMAND_MATCHCASE
[] = ".uno:MatchCase";
75 static const char COMMAND_SEARCHFORMATTED
[] = ".uno:SearchFormattedDisplayString";
77 static const sal_Int32 REMEMBER_SIZE
= 10;
79 void impl_executeSearch( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
80 const css::uno::Reference
< css::frame::XFrame
>& xFrame
,
81 const ToolBox
* pToolBox
,
82 const bool aSearchBackwards
,
83 const bool aFindAll
= false )
85 css::uno::Reference
< css::util::XURLTransformer
> xURLTransformer( css::util::URLTransformer::create( rxContext
) );
87 aURL
.Complete
= ".uno:ExecuteSearch";
88 xURLTransformer
->parseStrict(aURL
);
91 bool aMatchCase
= false;
92 bool bSearchFormatted
= false;
95 ToolBox::ImplToolItems::size_type nItemCount
= pToolBox
->GetItemCount();
96 for ( ToolBox::ImplToolItems::size_type i
=0; i
<nItemCount
; ++i
)
98 sal_uInt16 id
= pToolBox
->GetItemId(i
);
99 OUString sItemCommand
= pToolBox
->GetItemCommand(id
);
100 if ( sItemCommand
== COMMAND_FINDTEXT
)
102 vcl::Window
* pItemWin
= pToolBox
->GetItemWindow(id
);
104 sFindText
= pItemWin
->GetText();
105 } else if ( sItemCommand
== COMMAND_MATCHCASE
)
107 CheckBox
* pItemWin
= static_cast<CheckBox
*>( pToolBox
->GetItemWindow(id
) );
109 aMatchCase
= pItemWin
->IsChecked();
110 } else if ( sItemCommand
== COMMAND_SEARCHFORMATTED
)
112 CheckBox
* pItemWin
= static_cast<CheckBox
*>( pToolBox
->GetItemWindow(id
) );
114 bSearchFormatted
= pItemWin
->IsChecked();
119 SvtCTLOptions aCTLOptions
;
120 TransliterationFlags nFlags
= TransliterationFlags::NONE
;
122 nFlags
|= TransliterationFlags::IGNORE_CASE
;
123 if (aCTLOptions
.IsCTLFontEnabled())
124 nFlags
|= TransliterationFlags::IGNORE_DIACRITICS_CTL
125 | TransliterationFlags::IGNORE_KASHIDA_CTL
;
127 auto aArgs( comphelper::InitPropertySequence( {
128 { "SearchItem.SearchString", css::uno::makeAny( sFindText
) },
129 { "SearchItem.Backward", css::uno::makeAny( aSearchBackwards
) },
130 { "SearchItem.SearchFlags", css::uno::makeAny( sal_Int32(0) ) },
131 { "SearchItem.TransliterateFlags", css::uno::makeAny( static_cast<sal_Int32
>(nFlags
) ) },
132 { "SearchItem.Command", css::uno::makeAny( static_cast<sal_Int16
>(aFindAll
?SvxSearchCmd::FIND_ALL
: SvxSearchCmd::FIND
) ) },
133 { "SearchItem.AlgorithmType", css::uno::makeAny( sal_Int16(css::util::SearchAlgorithms_ABSOLUTE
) ) },
134 { "SearchItem.AlgorithmType2", css::uno::makeAny( sal_Int16(css::util::SearchAlgorithms2::ABSOLUTE
) ) },
135 { "SearchItem.SearchFormatted", css::uno::makeAny( bSearchFormatted
) }
138 css::uno::Reference
< css::frame::XDispatchProvider
> xDispatchProvider(xFrame
, css::uno::UNO_QUERY
);
139 if ( xDispatchProvider
.is() )
141 css::uno::Reference
< css::frame::XDispatch
> xDispatch
= xDispatchProvider
->queryDispatch( aURL
, OUString(), 0 );
142 if ( xDispatch
.is() && !aURL
.Complete
.isEmpty() )
143 xDispatch
->dispatch( aURL
, aArgs
);
147 class FindTextFieldControl
: public ComboBox
150 FindTextFieldControl( vcl::Window
* pParent
, WinBits nStyle
,
151 css::uno::Reference
< css::frame::XFrame
> const & xFrame
,
152 const css::uno::Reference
< css::uno::XComponentContext
>& xContext
);
154 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
156 void Remember_Impl(const OUString
& rStr
);
157 void SetTextToSelected_Impl();
161 css::uno::Reference
< css::frame::XFrame
> m_xFrame
;
162 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
163 std::unique_ptr
<svt::AcceleratorExecute
> m_pAcc
;
166 FindTextFieldControl::FindTextFieldControl( vcl::Window
* pParent
, WinBits nStyle
,
167 css::uno::Reference
< css::frame::XFrame
> const & xFrame
,
168 const css::uno::Reference
< css::uno::XComponentContext
>& xContext
) :
169 ComboBox( pParent
, nStyle
),
171 m_xContext(xContext
),
172 m_pAcc(svt::AcceleratorExecute::createAcceleratorHelper())
174 SetPlaceholderText(SvxResId(RID_SVXSTR_FINDBAR_FIND
));
175 EnableAutocomplete(true, true);
176 m_pAcc
->init(m_xContext
, m_xFrame
);
179 void FindTextFieldControl::Remember_Impl(const OUString
& rStr
)
181 const sal_Int32 nCount
= GetEntryCount();
183 for (sal_Int32 i
=0; i
<nCount
; ++i
)
185 if ( rStr
== GetEntry(i
))
189 if (nCount
== REMEMBER_SIZE
)
190 RemoveEntryAt(REMEMBER_SIZE
-1);
192 InsertEntry(rStr
, 0);
195 void FindTextFieldControl::SetTextToSelected_Impl()
201 css::uno::Reference
<css::frame::XController
> xController(m_xFrame
->getController(), css::uno::UNO_SET_THROW
);
202 css::uno::Reference
<css::frame::XModel
> xModel(xController
->getModel(), css::uno::UNO_SET_THROW
);
203 css::uno::Reference
<css::container::XIndexAccess
> xIndexAccess(xModel
->getCurrentSelection(), css::uno::UNO_QUERY_THROW
);
204 if (xIndexAccess
->getCount() > 0)
206 css::uno::Reference
<css::text::XTextRange
> xTextRange(xIndexAccess
->getByIndex(0), css::uno::UNO_QUERY_THROW
);
207 aString
= xTextRange
->getString();
214 if ( !aString
.isEmpty() )
216 // If something is selected in the document, prepopulate with this
218 GetModifyHdl().Call(*this); // FIXME why SetText doesn't trigger this?
220 else if (GetEntryCount() > 0)
222 // Else, prepopulate with last search word (fdo#84256)
223 SetText(GetEntry(0));
227 bool FindTextFieldControl::PreNotify( NotifyEvent
& rNEvt
)
231 bool bRet
= ComboBox::PreNotify( rNEvt
);
233 switch ( rNEvt
.GetType() )
235 case MouseNotifyEvent::KEYINPUT
:
237 // Clear SearchLabel when altering the search string
238 #if HAVE_FEATURE_DESKTOP
239 SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::Empty
);
242 const KeyEvent
* pKeyEvent
= rNEvt
.GetKeyEvent();
243 bool bShift
= pKeyEvent
->GetKeyCode().IsShift();
244 bool bMod1
= pKeyEvent
->GetKeyCode().IsMod1();
245 sal_uInt16 nCode
= pKeyEvent
->GetKeyCode().GetCode();
247 // Close the search bar on Escape
248 if ( KEY_ESCAPE
== nCode
)
251 GrabFocusToDocument();
254 css::uno::Reference
< css::beans::XPropertySet
> xPropSet(m_xFrame
, css::uno::UNO_QUERY
);
257 css::uno::Reference
< css::frame::XLayoutManager
> xLayoutManager
;
258 css::uno::Any aValue
= xPropSet
->getPropertyValue("LayoutManager");
259 aValue
>>= xLayoutManager
;
260 if (xLayoutManager
.is())
262 const OUString
sResourceURL( "private:resource/toolbar/findbar" );
263 xLayoutManager
->hideElement( sResourceURL
);
264 xLayoutManager
->destroyElement( sResourceURL
);
268 // Select text in the search box when Ctrl-F pressed
269 else if ( bMod1
&& nCode
== KEY_F
)
270 SetSelection( Selection( SELECTION_MIN
, SELECTION_MAX
) );
272 // Execute the search when Return, Ctrl-G or F3 pressed
273 else if ( KEY_RETURN
== nCode
|| (bMod1
&& (KEY_G
== nCode
)) || (KEY_F3
== nCode
) )
275 Remember_Impl(GetText());
277 vcl::Window
* pWindow
= GetParent();
278 ToolBox
* pToolBox
= static_cast<ToolBox
*>(pWindow
);
280 impl_executeSearch( m_xContext
, m_xFrame
, pToolBox
, bShift
);
285 auto awtKey
= svt::AcceleratorExecute::st_VCLKey2AWTKey(pKeyEvent
->GetKeyCode());
286 const OUString
aCommand(m_pAcc
->findCommand(awtKey
));
287 if (aCommand
== ".uno:SearchDialog")
288 bRet
= m_pAcc
->execute(awtKey
);
293 case MouseNotifyEvent::GETFOCUS
:
294 SetSelection( Selection( SELECTION_MIN
, SELECTION_MAX
) );
304 class SearchToolbarControllersManager
308 SearchToolbarControllersManager();
310 static SearchToolbarControllersManager
& createControllersManager();
312 void registryController( const css::uno::Reference
< css::frame::XFrame
>& xFrame
, const css::uno::Reference
< css::frame::XStatusListener
>& xStatusListener
, const OUString
& sCommandURL
);
313 void freeController ( const css::uno::Reference
< css::frame::XFrame
>& xFrame
, const OUString
& sCommandURL
);
314 css::uno::Reference
< css::frame::XStatusListener
> findController( const css::uno::Reference
< css::frame::XFrame
>& xFrame
, const OUString
& sCommandURL
);
316 void saveSearchHistory(const FindTextFieldControl
* m_pFindTextFieldControl
);
317 void loadSearchHistory(FindTextFieldControl
* m_pFindTextFieldControl
);
321 typedef ::std::vector
< css::beans::PropertyValue
> SearchToolbarControllersVec
;
322 typedef ::std::map
< css::uno::Reference
< css::frame::XFrame
>, SearchToolbarControllersVec
> SearchToolbarControllersMap
;
323 SearchToolbarControllersMap aSearchToolbarControllersMap
;
324 std::vector
<OUString
> m_aSearchStrings
;
328 SearchToolbarControllersManager::SearchToolbarControllersManager()
332 class theSearchToolbarControllersManager
333 : public rtl::Static
<SearchToolbarControllersManager
,
334 theSearchToolbarControllersManager
>
338 SearchToolbarControllersManager
& SearchToolbarControllersManager::createControllersManager()
340 return theSearchToolbarControllersManager::get();
343 void SearchToolbarControllersManager::saveSearchHistory(const FindTextFieldControl
* pFindTextFieldControl
)
345 const sal_Int32
nECount( pFindTextFieldControl
->GetEntryCount() );
346 m_aSearchStrings
.resize( nECount
);
347 for( sal_Int32 i
=0; i
<nECount
; ++i
)
349 m_aSearchStrings
[i
] = pFindTextFieldControl
->GetEntry(i
);
353 void SearchToolbarControllersManager::loadSearchHistory(FindTextFieldControl
* pFindTextFieldControl
)
355 for( size_t i
=0; i
<m_aSearchStrings
.size(); ++i
)
357 pFindTextFieldControl
->InsertEntry(m_aSearchStrings
[i
],i
);
361 void SearchToolbarControllersManager::registryController( const css::uno::Reference
< css::frame::XFrame
>& xFrame
, const css::uno::Reference
< css::frame::XStatusListener
>& xStatusListener
, const OUString
& sCommandURL
)
363 SearchToolbarControllersMap::iterator pIt
= aSearchToolbarControllersMap
.find(xFrame
);
364 if (pIt
== aSearchToolbarControllersMap
.end())
366 SearchToolbarControllersVec
lControllers(1);
367 lControllers
[0].Name
= sCommandURL
;
368 lControllers
[0].Value
<<= xStatusListener
;
369 aSearchToolbarControllersMap
.emplace(xFrame
, lControllers
);
373 sal_Int32 nSize
= pIt
->second
.size();
374 for (sal_Int32 i
=0; i
<nSize
; ++i
)
376 if (pIt
->second
[i
].Name
== sCommandURL
)
380 pIt
->second
.resize(nSize
+1);
381 pIt
->second
[nSize
].Name
= sCommandURL
;
382 pIt
->second
[nSize
].Value
<<= xStatusListener
;
386 void SearchToolbarControllersManager::freeController( const css::uno::Reference
< css::frame::XFrame
>& xFrame
, const OUString
& sCommandURL
)
388 SearchToolbarControllersMap::iterator pIt
= aSearchToolbarControllersMap
.find(xFrame
);
389 if (pIt
!= aSearchToolbarControllersMap
.end())
391 auto pItCtrl
= std::find_if(pIt
->second
.begin(), pIt
->second
.end(),
392 [&sCommandURL
](const css::beans::PropertyValue
& rCtrl
) { return rCtrl
.Name
== sCommandURL
; });
393 if (pItCtrl
!= pIt
->second
.end())
394 pIt
->second
.erase(pItCtrl
);
396 if (pIt
->second
.empty())
397 aSearchToolbarControllersMap
.erase(pIt
);
401 css::uno::Reference
< css::frame::XStatusListener
> SearchToolbarControllersManager::findController( const css::uno::Reference
< css::frame::XFrame
>& xFrame
, const OUString
& sCommandURL
)
403 css::uno::Reference
< css::frame::XStatusListener
> xStatusListener
;
405 SearchToolbarControllersMap::iterator pIt
= aSearchToolbarControllersMap
.find(xFrame
);
406 if (pIt
!= aSearchToolbarControllersMap
.end())
408 auto pItCtrl
= std::find_if(pIt
->second
.begin(), pIt
->second
.end(),
409 [&sCommandURL
](const css::beans::PropertyValue
& rCtrl
) { return rCtrl
.Name
== sCommandURL
; });
410 if (pItCtrl
!= pIt
->second
.end())
411 pItCtrl
->Value
>>= xStatusListener
;
414 return xStatusListener
;
417 class FindTextToolbarController
: public svt::ToolboxController
,
418 public css::lang::XServiceInfo
422 FindTextToolbarController( const css::uno::Reference
< css::uno::XComponentContext
> & rxContext
);
425 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
426 virtual void SAL_CALL
acquire() throw () override
;
427 virtual void SAL_CALL
release() throw () override
;
430 virtual OUString SAL_CALL
getImplementationName() override
;
431 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
432 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
435 virtual void SAL_CALL
dispose() override
;
438 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
440 // XToolbarController
441 virtual css::uno::Reference
< css::awt::XWindow
> SAL_CALL
createItemWindow( const css::uno::Reference
< css::awt::XWindow
>& Parent
) override
;
444 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& Event
) override
;
446 DECL_LINK(EditModifyHdl
, Edit
&, void);
450 void textfieldChanged();
452 VclPtr
<FindTextFieldControl
> m_pFindTextFieldControl
;
454 sal_uInt16 m_nDownSearchId
;
455 sal_uInt16 m_nUpSearchId
;
456 sal_uInt16 m_nFindAllId
;
460 FindTextToolbarController::FindTextToolbarController( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
)
461 : svt::ToolboxController(rxContext
, css::uno::Reference
< css::frame::XFrame
>(), COMMAND_FINDTEXT
)
462 , m_pFindTextFieldControl(nullptr)
470 css::uno::Any SAL_CALL
FindTextToolbarController::queryInterface( const css::uno::Type
& aType
)
472 css::uno::Any a
= ToolboxController::queryInterface( aType
);
476 return ::cppu::queryInterface( aType
, static_cast< css::lang::XServiceInfo
* >( this ) );
479 void SAL_CALL
FindTextToolbarController::acquire() throw ()
481 ToolboxController::acquire();
484 void SAL_CALL
FindTextToolbarController::release() throw ()
486 ToolboxController::release();
490 OUString SAL_CALL
FindTextToolbarController::getImplementationName()
492 return "com.sun.star.svx.FindTextToolboxController";
495 sal_Bool SAL_CALL
FindTextToolbarController::supportsService( const OUString
& ServiceName
)
497 return cppu::supportsService(this, ServiceName
);
500 css::uno::Sequence
< OUString
> SAL_CALL
FindTextToolbarController::getSupportedServiceNames()
502 return { "com.sun.star.frame.ToolbarController" };
506 void SAL_CALL
FindTextToolbarController::dispose()
508 SolarMutexGuard aSolarMutexGuard
;
510 SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame
, m_aCommandURL
);
512 svt::ToolboxController::dispose();
513 if (m_pFindTextFieldControl
!= nullptr) {
514 SearchToolbarControllersManager::createControllersManager()
515 .saveSearchHistory(m_pFindTextFieldControl
);
516 m_pFindTextFieldControl
.disposeAndClear();
521 void SAL_CALL
FindTextToolbarController::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
523 svt::ToolboxController::initialize(aArguments
);
525 VclPtr
<vcl::Window
> pWindow
= VCLUnoHelper::GetWindow( getParent() );
526 ToolBox
* pToolBox
= static_cast<ToolBox
*>(pWindow
.get());
529 m_nDownSearchId
= pToolBox
->GetItemId(COMMAND_DOWNSEARCH
);
530 m_nUpSearchId
= pToolBox
->GetItemId(COMMAND_UPSEARCH
);
531 m_nFindAllId
= pToolBox
->GetItemId(COMMAND_FINDALL
);
534 SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame
, css::uno::Reference
< css::frame::XStatusListener
>(static_cast< ::cppu::OWeakObject
* >(this), css::uno::UNO_QUERY
), m_aCommandURL
);
537 css::uno::Reference
< css::awt::XWindow
> SAL_CALL
FindTextToolbarController::createItemWindow( const css::uno::Reference
< css::awt::XWindow
>& xParent
)
539 css::uno::Reference
< css::awt::XWindow
> xItemWindow
;
541 VclPtr
<vcl::Window
> pParent
= VCLUnoHelper::GetWindow( xParent
);
544 ToolBox
* pToolbar
= static_cast<ToolBox
*>(pParent
.get());
545 m_pFindTextFieldControl
= VclPtr
<FindTextFieldControl
>::Create( pToolbar
, WinBits( WB_DROPDOWN
| WB_VSCROLL
), m_xFrame
, m_xContext
);
547 Size
aSize(250, m_pFindTextFieldControl
->GetTextHeight() + 200);
548 m_pFindTextFieldControl
->SetSizePixel( aSize
);
549 m_pFindTextFieldControl
->SetModifyHdl(LINK(this, FindTextToolbarController
, EditModifyHdl
));
550 SearchToolbarControllersManager::createControllersManager().loadSearchHistory(m_pFindTextFieldControl
);
552 xItemWindow
= VCLUnoHelper::GetInterface( m_pFindTextFieldControl
);
558 void SAL_CALL
FindTextToolbarController::statusChanged( const css::frame::FeatureStateEvent
& rEvent
)
560 SolarMutexGuard aSolarMutexGuard
;
564 OUString aFeatureURL
= rEvent
.FeatureURL
.Complete
;
565 if ( aFeatureURL
== "AppendSearchHistory" )
567 m_pFindTextFieldControl
->Remember_Impl(m_pFindTextFieldControl
->GetText());
569 // enable up/down buttons in case there is already text (from the search history)
573 IMPL_LINK_NOARG(FindTextToolbarController
, EditModifyHdl
, Edit
&, void)
578 void FindTextToolbarController::textfieldChanged() {
579 // enable or disable item DownSearch/UpSearch/FindAll of findbar
580 VclPtr
<vcl::Window
> pWindow
= VCLUnoHelper::GetWindow( getParent() );
581 ToolBox
* pToolBox
= static_cast<ToolBox
*>(pWindow
.get());
582 if ( pToolBox
&& m_pFindTextFieldControl
)
584 bool enableButtons
= !m_pFindTextFieldControl
->GetText().isEmpty();
585 pToolBox
->EnableItem(m_nDownSearchId
, enableButtons
);
586 pToolBox
->EnableItem(m_nUpSearchId
, enableButtons
);
587 pToolBox
->EnableItem(m_nFindAllId
, enableButtons
);
591 class UpDownSearchToolboxController
: public svt::ToolboxController
,
592 public css::lang::XServiceInfo
595 enum Type
{ UP
, DOWN
};
597 UpDownSearchToolboxController( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
, Type eType
);
600 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
601 virtual void SAL_CALL
acquire() throw () override
;
602 virtual void SAL_CALL
release() throw () override
;
605 virtual OUString SAL_CALL
getImplementationName() override
;
606 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
607 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
610 virtual void SAL_CALL
dispose() override
;
613 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
615 // XToolbarController
616 virtual void SAL_CALL
execute( sal_Int16 KeyModifier
) override
;
619 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& rEvent
) override
;
625 UpDownSearchToolboxController::UpDownSearchToolboxController( const css::uno::Reference
< css::uno::XComponentContext
> & rxContext
, Type eType
)
626 : svt::ToolboxController( rxContext
,
627 css::uno::Reference
< css::frame::XFrame
>(),
628 (eType
== UP
) ? OUString( COMMAND_UPSEARCH
): OUString( COMMAND_DOWNSEARCH
) ),
634 css::uno::Any SAL_CALL
UpDownSearchToolboxController::queryInterface( const css::uno::Type
& aType
)
636 css::uno::Any a
= ToolboxController::queryInterface( aType
);
640 return ::cppu::queryInterface( aType
, static_cast< css::lang::XServiceInfo
* >( this ) );
643 void SAL_CALL
UpDownSearchToolboxController::acquire() throw ()
645 ToolboxController::acquire();
648 void SAL_CALL
UpDownSearchToolboxController::release() throw ()
650 ToolboxController::release();
654 OUString SAL_CALL
UpDownSearchToolboxController::getImplementationName()
656 return meType
== UpDownSearchToolboxController::UP
?
657 OUString( "com.sun.star.svx.UpSearchToolboxController" ) :
658 OUString( "com.sun.star.svx.DownSearchToolboxController" );
661 sal_Bool SAL_CALL
UpDownSearchToolboxController::supportsService( const OUString
& ServiceName
)
663 return cppu::supportsService(this, ServiceName
);
666 css::uno::Sequence
< OUString
> SAL_CALL
UpDownSearchToolboxController::getSupportedServiceNames()
668 return { "com.sun.star.frame.ToolbarController" };
672 void SAL_CALL
UpDownSearchToolboxController::dispose()
674 SolarMutexGuard aSolarMutexGuard
;
676 SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame
, m_aCommandURL
);
678 svt::ToolboxController::dispose();
682 void SAL_CALL
UpDownSearchToolboxController::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
684 svt::ToolboxController::initialize( aArguments
);
685 SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame
, css::uno::Reference
< css::frame::XStatusListener
>(static_cast< ::cppu::OWeakObject
* >(this), css::uno::UNO_QUERY
), m_aCommandURL
);
688 // XToolbarController
689 void SAL_CALL
UpDownSearchToolboxController::execute( sal_Int16
/*KeyModifier*/ )
692 throw css::lang::DisposedException();
694 VclPtr
<vcl::Window
> pWindow
= VCLUnoHelper::GetWindow( getParent() );
695 ToolBox
* pToolBox
= static_cast<ToolBox
*>(pWindow
.get());
697 impl_executeSearch(m_xContext
, m_xFrame
, pToolBox
, meType
== UP
);
699 css::frame::FeatureStateEvent aEvent
;
700 aEvent
.FeatureURL
.Complete
= "AppendSearchHistory";
701 css::uno::Reference
< css::frame::XStatusListener
> xStatusListener
= SearchToolbarControllersManager::createControllersManager().findController(m_xFrame
, COMMAND_FINDTEXT
);
702 if (xStatusListener
.is())
703 xStatusListener
->statusChanged( aEvent
);
707 void SAL_CALL
UpDownSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent
& /*rEvent*/ )
711 class MatchCaseToolboxController
: public svt::ToolboxController
,
712 public css::lang::XServiceInfo
715 MatchCaseToolboxController( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
718 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
719 virtual void SAL_CALL
acquire() throw () override
;
720 virtual void SAL_CALL
release() throw () override
;
723 virtual OUString SAL_CALL
getImplementationName() override
;
724 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
725 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
728 virtual void SAL_CALL
dispose() override
;
731 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
733 // XToolbarController
734 virtual css::uno::Reference
< css::awt::XWindow
> SAL_CALL
createItemWindow( const css::uno::Reference
< css::awt::XWindow
>& Parent
) override
;
737 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& rEvent
) override
;
740 VclPtr
<CheckBox
> m_pMatchCaseControl
;
743 MatchCaseToolboxController::MatchCaseToolboxController( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
)
744 : svt::ToolboxController( rxContext
,
745 css::uno::Reference
< css::frame::XFrame
>(),
747 , m_pMatchCaseControl(nullptr)
752 css::uno::Any SAL_CALL
MatchCaseToolboxController::queryInterface( const css::uno::Type
& aType
)
754 css::uno::Any a
= ToolboxController::queryInterface( aType
);
758 return ::cppu::queryInterface( aType
, static_cast< css::lang::XServiceInfo
* >( this ) );
761 void SAL_CALL
MatchCaseToolboxController::acquire() throw ()
763 ToolboxController::acquire();
766 void SAL_CALL
MatchCaseToolboxController::release() throw ()
768 ToolboxController::release();
772 OUString SAL_CALL
MatchCaseToolboxController::getImplementationName()
774 return "com.sun.star.svx.MatchCaseToolboxController";
777 sal_Bool SAL_CALL
MatchCaseToolboxController::supportsService( const OUString
& ServiceName
)
779 return cppu::supportsService(this, ServiceName
);
782 css::uno::Sequence
< OUString
> SAL_CALL
MatchCaseToolboxController::getSupportedServiceNames()
784 return { "com.sun.star.frame.ToolbarController" };
788 void SAL_CALL
MatchCaseToolboxController::dispose()
790 SolarMutexGuard aSolarMutexGuard
;
792 SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame
, m_aCommandURL
);
794 svt::ToolboxController::dispose();
796 m_pMatchCaseControl
.disposeAndClear();
800 void SAL_CALL
MatchCaseToolboxController::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
802 svt::ToolboxController::initialize(aArguments
);
804 SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame
, css::uno::Reference
< css::frame::XStatusListener
>(static_cast< ::cppu::OWeakObject
* >(this), css::uno::UNO_QUERY
), m_aCommandURL
);
807 css::uno::Reference
< css::awt::XWindow
> SAL_CALL
MatchCaseToolboxController::createItemWindow( const css::uno::Reference
< css::awt::XWindow
>& xParent
)
809 css::uno::Reference
< css::awt::XWindow
> xItemWindow
;
811 VclPtr
<vcl::Window
> pParent
= VCLUnoHelper::GetWindow( xParent
);
814 ToolBox
* pToolbar
= static_cast<ToolBox
*>(pParent
.get());
815 m_pMatchCaseControl
= VclPtr
<CheckBox
>::Create( pToolbar
, 0 );
816 m_pMatchCaseControl
->SetText( SvxResId( RID_SVXSTR_FINDBAR_MATCHCASE
) );
817 Size
aSize( m_pMatchCaseControl
->GetOptimalSize() );
818 m_pMatchCaseControl
->SetSizePixel( aSize
);
820 xItemWindow
= VCLUnoHelper::GetInterface( m_pMatchCaseControl
);
826 void SAL_CALL
MatchCaseToolboxController::statusChanged( const css::frame::FeatureStateEvent
& )
830 class SearchFormattedToolboxController
: public svt::ToolboxController
,
831 public css::lang::XServiceInfo
834 SearchFormattedToolboxController( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
837 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
838 virtual void SAL_CALL
acquire() throw () override
;
839 virtual void SAL_CALL
release() throw () override
;
842 virtual OUString SAL_CALL
getImplementationName() override
;
843 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
844 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
847 virtual void SAL_CALL
dispose() override
;
850 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
852 // XToolbarController
853 virtual css::uno::Reference
< css::awt::XWindow
> SAL_CALL
createItemWindow( const css::uno::Reference
< css::awt::XWindow
>& Parent
) override
;
856 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& rEvent
) override
;
859 VclPtr
<CheckBox
> m_pSearchFormattedControl
;
862 SearchFormattedToolboxController::SearchFormattedToolboxController( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
)
863 : svt::ToolboxController( rxContext
,
864 css::uno::Reference
< css::frame::XFrame
>(),
865 COMMAND_SEARCHFORMATTED
)
866 , m_pSearchFormattedControl(nullptr)
871 css::uno::Any SAL_CALL
SearchFormattedToolboxController::queryInterface( const css::uno::Type
& aType
)
873 css::uno::Any a
= ToolboxController::queryInterface( aType
);
877 return ::cppu::queryInterface( aType
, static_cast< css::lang::XServiceInfo
* >( this ) );
880 void SAL_CALL
SearchFormattedToolboxController::acquire() throw ()
882 ToolboxController::acquire();
885 void SAL_CALL
SearchFormattedToolboxController::release() throw ()
887 ToolboxController::release();
891 OUString SAL_CALL
SearchFormattedToolboxController::getImplementationName()
893 return "com.sun.star.svx.SearchFormattedToolboxController";
896 sal_Bool SAL_CALL
SearchFormattedToolboxController::supportsService( const OUString
& ServiceName
)
898 return cppu::supportsService(this, ServiceName
);
901 css::uno::Sequence
< OUString
> SAL_CALL
SearchFormattedToolboxController::getSupportedServiceNames()
903 return { "com.sun.star.frame.ToolbarController" };
907 void SAL_CALL
SearchFormattedToolboxController::dispose()
909 SolarMutexGuard aSolarMutexGuard
;
911 SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame
, m_aCommandURL
);
913 svt::ToolboxController::dispose();
915 m_pSearchFormattedControl
.disposeAndClear();
919 void SAL_CALL
SearchFormattedToolboxController::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
921 svt::ToolboxController::initialize(aArguments
);
923 SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame
, css::uno::Reference
< css::frame::XStatusListener
>(static_cast< ::cppu::OWeakObject
* >(this), css::uno::UNO_QUERY
), m_aCommandURL
);
926 css::uno::Reference
< css::awt::XWindow
> SAL_CALL
SearchFormattedToolboxController::createItemWindow( const css::uno::Reference
< css::awt::XWindow
>& xParent
)
928 css::uno::Reference
< css::awt::XWindow
> xItemWindow
;
930 VclPtr
<vcl::Window
> pParent
= VCLUnoHelper::GetWindow( xParent
);
933 ToolBox
* pToolbar
= static_cast<ToolBox
*>(pParent
.get());
934 m_pSearchFormattedControl
= VclPtr
<CheckBox
>::Create( pToolbar
, 0 );
935 m_pSearchFormattedControl
->SetText( SvxResId( RID_SVXSTR_FINDBAR_SEARCHFORMATTED
) );
936 Size
aSize( m_pSearchFormattedControl
->GetOptimalSize() );
937 m_pSearchFormattedControl
->SetSizePixel( aSize
);
939 xItemWindow
= VCLUnoHelper::GetInterface( m_pSearchFormattedControl
);
945 void SAL_CALL
SearchFormattedToolboxController::statusChanged( const css::frame::FeatureStateEvent
& )
949 class FindAllToolboxController
: public svt::ToolboxController
,
950 public css::lang::XServiceInfo
953 FindAllToolboxController( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
956 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
957 virtual void SAL_CALL
acquire() throw () override
;
958 virtual void SAL_CALL
release() throw () override
;
961 virtual OUString SAL_CALL
getImplementationName() override
;
962 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
963 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
966 virtual void SAL_CALL
dispose() override
;
969 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
971 // XToolbarController
972 virtual void SAL_CALL
execute( sal_Int16 KeyModifier
) override
;
975 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& rEvent
) override
;
978 FindAllToolboxController::FindAllToolboxController( const css::uno::Reference
< css::uno::XComponentContext
> & rxContext
)
979 : svt::ToolboxController( rxContext
,
980 css::uno::Reference
< css::frame::XFrame
>(),
986 css::uno::Any SAL_CALL
FindAllToolboxController::queryInterface( const css::uno::Type
& aType
)
988 css::uno::Any a
= ToolboxController::queryInterface( aType
);
992 return ::cppu::queryInterface( aType
, static_cast< css::lang::XServiceInfo
* >( this ) );
995 void SAL_CALL
FindAllToolboxController::acquire() throw ()
997 ToolboxController::acquire();
1000 void SAL_CALL
FindAllToolboxController::release() throw ()
1002 ToolboxController::release();
1006 OUString SAL_CALL
FindAllToolboxController::getImplementationName()
1008 return "com.sun.star.svx.FindAllToolboxController";
1012 sal_Bool SAL_CALL
FindAllToolboxController::supportsService( const OUString
& ServiceName
)
1014 return cppu::supportsService(this, ServiceName
);
1017 css::uno::Sequence
< OUString
> SAL_CALL
FindAllToolboxController::getSupportedServiceNames()
1019 return { "com.sun.star.frame.ToolbarController" };
1023 void SAL_CALL
FindAllToolboxController::dispose()
1025 SolarMutexGuard aSolarMutexGuard
;
1027 SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame
, m_aCommandURL
);
1029 svt::ToolboxController::dispose();
1033 void SAL_CALL
FindAllToolboxController::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
1035 svt::ToolboxController::initialize( aArguments
);
1036 SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame
, css::uno::Reference
< css::frame::XStatusListener
>(static_cast< ::cppu::OWeakObject
* >(this), css::uno::UNO_QUERY
), m_aCommandURL
);
1039 // XToolbarController
1040 void SAL_CALL
FindAllToolboxController::execute( sal_Int16
/*KeyModifier*/ )
1043 throw css::lang::DisposedException();
1045 VclPtr
<vcl::Window
> pWindow
= VCLUnoHelper::GetWindow( getParent() );
1046 ToolBox
* pToolBox
= static_cast<ToolBox
*>(pWindow
.get());
1048 impl_executeSearch(m_xContext
, m_xFrame
, pToolBox
, false, true);
1052 void SAL_CALL
FindAllToolboxController::statusChanged( const css::frame::FeatureStateEvent
& /*rEvent*/ )
1056 class ExitSearchToolboxController
: public svt::ToolboxController
,
1057 public css::lang::XServiceInfo
1060 ExitSearchToolboxController( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
1063 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
1064 virtual void SAL_CALL
acquire() throw () override
;
1065 virtual void SAL_CALL
release() throw () override
;
1068 virtual OUString SAL_CALL
getImplementationName() override
;
1069 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
1070 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
1073 virtual void SAL_CALL
dispose() override
;
1076 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
1078 // XToolbarController
1079 virtual void SAL_CALL
execute( sal_Int16 KeyModifier
) override
;
1082 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& rEvent
) override
;
1085 ExitSearchToolboxController::ExitSearchToolboxController( const css::uno::Reference
< css::uno::XComponentContext
> & rxContext
)
1086 : svt::ToolboxController( rxContext
,
1087 css::uno::Reference
< css::frame::XFrame
>(),
1093 css::uno::Any SAL_CALL
ExitSearchToolboxController::queryInterface( const css::uno::Type
& aType
)
1095 css::uno::Any a
= ToolboxController::queryInterface( aType
);
1099 return ::cppu::queryInterface( aType
, static_cast< css::lang::XServiceInfo
* >( this ) );
1102 void SAL_CALL
ExitSearchToolboxController::acquire() throw ()
1104 ToolboxController::acquire();
1107 void SAL_CALL
ExitSearchToolboxController::release() throw ()
1109 ToolboxController::release();
1113 OUString SAL_CALL
ExitSearchToolboxController::getImplementationName()
1115 return "com.sun.star.svx.ExitFindbarToolboxController";
1119 sal_Bool SAL_CALL
ExitSearchToolboxController::supportsService( const OUString
& ServiceName
)
1121 return cppu::supportsService(this, ServiceName
);
1124 css::uno::Sequence
< OUString
> SAL_CALL
ExitSearchToolboxController::getSupportedServiceNames()
1126 return { "com.sun.star.frame.ToolbarController" };
1130 void SAL_CALL
ExitSearchToolboxController::dispose()
1132 SolarMutexGuard aSolarMutexGuard
;
1134 SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame
, m_aCommandURL
);
1136 svt::ToolboxController::dispose();
1140 void SAL_CALL
ExitSearchToolboxController::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
1142 svt::ToolboxController::initialize( aArguments
);
1143 SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame
, css::uno::Reference
< css::frame::XStatusListener
>(static_cast< ::cppu::OWeakObject
* >(this), css::uno::UNO_QUERY
), m_aCommandURL
);
1146 // XToolbarController
1147 void SAL_CALL
ExitSearchToolboxController::execute( sal_Int16
/*KeyModifier*/ )
1149 vcl::Window
*pFocusWindow
= Application::GetFocusWindow();
1151 pFocusWindow
->GrabFocusToDocument();
1154 css::uno::Reference
< css::beans::XPropertySet
> xPropSet(m_xFrame
, css::uno::UNO_QUERY
);
1157 css::uno::Reference
< css::frame::XLayoutManager
> xLayoutManager
;
1158 css::uno::Any aValue
= xPropSet
->getPropertyValue("LayoutManager");
1159 aValue
>>= xLayoutManager
;
1160 if (xLayoutManager
.is())
1162 const OUString
sResourceURL( "private:resource/toolbar/findbar" );
1163 xLayoutManager
->hideElement( sResourceURL
);
1164 xLayoutManager
->destroyElement( sResourceURL
);
1170 void SAL_CALL
ExitSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent
& /*rEvent*/ )
1174 class SearchLabelToolboxController
: public svt::ToolboxController
,
1175 public css::lang::XServiceInfo
1178 SearchLabelToolboxController( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
1181 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
1182 virtual void SAL_CALL
acquire() throw () override
;
1183 virtual void SAL_CALL
release() throw () override
;
1186 virtual OUString SAL_CALL
getImplementationName() override
;
1187 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
1188 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
1191 virtual void SAL_CALL
dispose() override
;
1194 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
1196 // XToolbarController
1197 virtual css::uno::Reference
< css::awt::XWindow
> SAL_CALL
createItemWindow( const css::uno::Reference
< css::awt::XWindow
>& Parent
) override
;
1200 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& rEvent
) override
;
1203 VclPtr
<vcl::Window
> m_pSL
;
1206 SearchLabelToolboxController::SearchLabelToolboxController( const css::uno::Reference
< css::uno::XComponentContext
> & rxContext
)
1207 : svt::ToolboxController( rxContext
,
1208 css::uno::Reference
< css::frame::XFrame
>(),
1209 ".uno:SearchLabel" )
1214 css::uno::Any SAL_CALL
SearchLabelToolboxController::queryInterface( const css::uno::Type
& aType
)
1216 css::uno::Any a
= ToolboxController::queryInterface( aType
);
1220 return ::cppu::queryInterface( aType
, static_cast< css::lang::XServiceInfo
* >( this ) );
1223 void SAL_CALL
SearchLabelToolboxController::acquire() throw ()
1225 ToolboxController::acquire();
1228 void SAL_CALL
SearchLabelToolboxController::release() throw ()
1230 ToolboxController::release();
1234 OUString SAL_CALL
SearchLabelToolboxController::getImplementationName()
1236 return "com.sun.star.svx.SearchLabelToolboxController";
1240 sal_Bool SAL_CALL
SearchLabelToolboxController::supportsService( const OUString
& ServiceName
)
1242 return cppu::supportsService(this, ServiceName
);
1245 css::uno::Sequence
< OUString
> SAL_CALL
SearchLabelToolboxController::getSupportedServiceNames()
1247 return { "com.sun.star.frame.ToolbarController" };
1251 void SAL_CALL
SearchLabelToolboxController::dispose()
1253 SolarMutexGuard aSolarMutexGuard
;
1255 SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame
, m_aCommandURL
);
1257 svt::ToolboxController::dispose();
1258 m_pSL
.disposeAndClear();
1262 void SAL_CALL
SearchLabelToolboxController::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
1264 svt::ToolboxController::initialize( aArguments
);
1265 SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame
, css::uno::Reference
< css::frame::XStatusListener
>(static_cast< ::cppu::OWeakObject
* >(this), css::uno::UNO_QUERY
), m_aCommandURL
);
1269 void SAL_CALL
SearchLabelToolboxController::statusChanged( const css::frame::FeatureStateEvent
& )
1273 OUString aStr
= SvxSearchDialogWrapper::GetSearchLabel();
1274 m_pSL
->SetText(aStr
);
1275 long aWidth
= !aStr
.isEmpty() ? m_pSL
->get_preferred_size().getWidth() : 16;
1276 m_pSL
->SetSizePixel(Size(aWidth
, m_pSL
->get_preferred_size().getHeight()));
1280 css::uno::Reference
< css::awt::XWindow
> SAL_CALL
SearchLabelToolboxController::createItemWindow( const css::uno::Reference
< css::awt::XWindow
>& Parent
)
1282 m_pSL
= VclPtr
<FixedText
>::Create(VCLUnoHelper::GetWindow( Parent
));
1283 m_pSL
->SetSizePixel(Size(16, 25));
1284 return VCLUnoHelper::GetInterface(m_pSL
);
1287 // protocol handler for "vnd.sun.star.findbar:*" URLs
1288 // The dispatch object will be used for shortcut commands for findbar
1289 class FindbarDispatcher
: public css::lang::XServiceInfo
,
1290 public css::lang::XInitialization
,
1291 public css::frame::XDispatchProvider
,
1292 public css::frame::XDispatch
,
1293 public ::cppu::OWeakObject
1297 FindbarDispatcher();
1298 virtual ~FindbarDispatcher() override
;
1301 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
1302 virtual void SAL_CALL
acquire() throw() override
;
1303 virtual void SAL_CALL
release() throw() override
;
1306 virtual OUString SAL_CALL
getImplementationName() override
;
1307 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
1308 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
1311 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
1313 // XDispatchProvider
1314 virtual css::uno::Reference
< css::frame::XDispatch
> SAL_CALL
queryDispatch( const css::util::URL
& aURL
, const OUString
& sTargetFrameName
, sal_Int32 nSearchFlags
) override
;
1315 virtual css::uno::Sequence
< css::uno::Reference
< css::frame::XDispatch
> > SAL_CALL
queryDispatches( const css::uno::Sequence
< css::frame::DispatchDescriptor
>& lDescriptions
) override
;
1318 virtual void SAL_CALL
dispatch( const css::util::URL
& aURL
, const css::uno::Sequence
< css::beans::PropertyValue
>& lArguments
) override
;
1319 virtual void SAL_CALL
addStatusListener( const css::uno::Reference
< css::frame::XStatusListener
>& xListener
, const css::util::URL
& aURL
) override
;
1320 virtual void SAL_CALL
removeStatusListener( const css::uno::Reference
< css::frame::XStatusListener
>& xListener
, const css::util::URL
& aURL
) override
;
1324 css::uno::Reference
< css::frame::XFrame
> m_xFrame
;
1328 FindbarDispatcher::FindbarDispatcher()
1332 FindbarDispatcher::~FindbarDispatcher()
1338 css::uno::Any SAL_CALL
FindbarDispatcher::queryInterface( const css::uno::Type
& aType
)
1340 css::uno::Any
aReturn( ::cppu::queryInterface( aType
,
1341 static_cast< css::lang::XServiceInfo
* >(this),
1342 static_cast< css::lang::XInitialization
* >(this),
1343 static_cast< css::frame::XDispatchProvider
* >(this),
1344 static_cast< css::frame::XDispatch
* >(this)) );
1346 if ( aReturn
.hasValue() )
1349 return OWeakObject::queryInterface( aType
);
1352 void SAL_CALL
FindbarDispatcher::acquire() throw()
1354 OWeakObject::acquire();
1357 void SAL_CALL
FindbarDispatcher::release() throw()
1359 OWeakObject::release();
1363 OUString SAL_CALL
FindbarDispatcher::getImplementationName()
1365 return "com.sun.star.comp.svx.Impl.FindbarDispatcher";
1368 sal_Bool SAL_CALL
FindbarDispatcher::supportsService( const OUString
& ServiceName
)
1370 return cppu::supportsService(this, ServiceName
);
1373 css::uno::Sequence
< OUString
> SAL_CALL
FindbarDispatcher::getSupportedServiceNames()
1375 return { "com.sun.star.comp.svx.FindbarDispatcher", "com.sun.star.frame.ProtocolHandler" };
1379 void SAL_CALL
FindbarDispatcher::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
1381 if ( aArguments
.hasElements() )
1382 aArguments
[0] >>= m_xFrame
;
1385 // XDispatchProvider
1386 css::uno::Reference
< css::frame::XDispatch
> SAL_CALL
FindbarDispatcher::queryDispatch( const css::util::URL
& aURL
, const OUString
& /*sTargetFrameName*/, sal_Int32
/*nSearchFlags*/ )
1388 css::uno::Reference
< css::frame::XDispatch
> xDispatch
;
1390 if ( aURL
.Protocol
== "vnd.sun.star.findbar:" )
1396 css::uno::Sequence
< css::uno::Reference
< css::frame::XDispatch
> > SAL_CALL
FindbarDispatcher::queryDispatches( const css::uno::Sequence
< css::frame::DispatchDescriptor
>& seqDescripts
)
1398 sal_Int32 nCount
= seqDescripts
.getLength();
1399 css::uno::Sequence
< css::uno::Reference
< XDispatch
> > lDispatcher( nCount
);
1401 std::transform(seqDescripts
.begin(), seqDescripts
.end(), lDispatcher
.begin(),
1402 [this](const css::frame::DispatchDescriptor
& rDescript
) -> css::uno::Reference
< XDispatch
> {
1403 return queryDispatch( rDescript
.FeatureURL
, rDescript
.FrameName
, rDescript
.SearchFlags
); });
1409 void SAL_CALL
FindbarDispatcher::dispatch( const css::util::URL
& aURL
, const css::uno::Sequence
< css::beans::PropertyValue
>& /*lArgs*/ )
1411 //vnd.sun.star.findbar:FocusToFindbar - set cursor to the FindTextFieldControl of the findbar
1412 if ( aURL
.Path
!= "FocusToFindbar" )
1415 css::uno::Reference
< css::beans::XPropertySet
> xPropSet(m_xFrame
, css::uno::UNO_QUERY
);
1419 css::uno::Reference
< css::frame::XLayoutManager
> xLayoutManager
;
1420 css::uno::Any aValue
= xPropSet
->getPropertyValue("LayoutManager");
1421 aValue
>>= xLayoutManager
;
1422 if (!xLayoutManager
.is())
1425 const OUString
sResourceURL( "private:resource/toolbar/findbar" );
1426 css::uno::Reference
< css::ui::XUIElement
> xUIElement
= xLayoutManager
->getElement(sResourceURL
);
1427 if (!xUIElement
.is())
1429 // show the findbar if necessary
1430 xLayoutManager
->createElement( sResourceURL
);
1431 xLayoutManager
->showElement( sResourceURL
);
1432 xUIElement
= xLayoutManager
->getElement( sResourceURL
);
1433 if ( !xUIElement
.is() )
1437 css::uno::Reference
< css::awt::XWindow
> xWindow(xUIElement
->getRealInterface(), css::uno::UNO_QUERY
);
1438 VclPtr
<vcl::Window
> pWindow
= VCLUnoHelper::GetWindow( xWindow
);
1439 ToolBox
* pToolBox
= static_cast<ToolBox
*>(pWindow
.get());
1442 ToolBox::ImplToolItems::size_type nItemCount
= pToolBox
->GetItemCount();
1443 for ( ToolBox::ImplToolItems::size_type i
=0; i
<nItemCount
; ++i
)
1445 sal_uInt16 id
= pToolBox
->GetItemId(i
);
1446 OUString sItemCommand
= pToolBox
->GetItemCommand(id
);
1447 if ( sItemCommand
== COMMAND_FINDTEXT
)
1449 vcl::Window
* pItemWin
= pToolBox
->GetItemWindow( id
);
1452 SolarMutexGuard aSolarMutexGuard
;
1453 FindTextFieldControl
* pFindTextFieldControl
= dynamic_cast<FindTextFieldControl
*>(pItemWin
);
1454 if ( pFindTextFieldControl
)
1455 pFindTextFieldControl
->SetTextToSelected_Impl();
1456 pItemWin
->GrabFocus();
1464 void SAL_CALL
FindbarDispatcher::addStatusListener( const css::uno::Reference
< css::frame::XStatusListener
>& /*xControl*/, const css::util::URL
& /*aURL*/ )
1468 void SAL_CALL
FindbarDispatcher::removeStatusListener( const css::uno::Reference
< css::frame::XStatusListener
>& /*xControl*/, const css::util::URL
& /*aURL*/ )
1474 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1475 com_sun_star_svx_FindTextToolboxController_get_implementation(
1476 css::uno::XComponentContext
*context
,
1477 css::uno::Sequence
<css::uno::Any
> const &)
1479 return cppu::acquire(new FindTextToolbarController(context
));
1482 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1483 com_sun_star_svx_ExitFindbarToolboxController_get_implementation(
1484 css::uno::XComponentContext
*context
,
1485 css::uno::Sequence
<css::uno::Any
> const &)
1487 return cppu::acquire(new ExitSearchToolboxController(context
));
1490 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1491 com_sun_star_svx_UpSearchToolboxController_get_implementation(
1492 css::uno::XComponentContext
*context
,
1493 css::uno::Sequence
<css::uno::Any
> const &)
1495 return cppu::acquire(new UpDownSearchToolboxController(context
, UpDownSearchToolboxController::UP
));
1498 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1499 com_sun_star_svx_DownSearchToolboxController_get_implementation(
1500 css::uno::XComponentContext
*context
,
1501 css::uno::Sequence
<css::uno::Any
> const &)
1503 return cppu::acquire(new UpDownSearchToolboxController(context
, UpDownSearchToolboxController::DOWN
));
1506 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1507 com_sun_star_svx_MatchCaseToolboxController_get_implementation(
1508 css::uno::XComponentContext
*context
,
1509 css::uno::Sequence
<css::uno::Any
> const &)
1511 return cppu::acquire(new MatchCaseToolboxController(context
));
1514 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1515 com_sun_star_svx_SearchFormattedToolboxController_get_implementation(
1516 css::uno::XComponentContext
*context
,
1517 css::uno::Sequence
<css::uno::Any
> const &)
1519 return cppu::acquire(new SearchFormattedToolboxController(context
));
1522 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1523 com_sun_star_svx_FindAllToolboxController_get_implementation(
1524 css::uno::XComponentContext
*context
,
1525 css::uno::Sequence
<css::uno::Any
> const &)
1527 return cppu::acquire(new FindAllToolboxController(context
));
1530 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1531 com_sun_star_svx_SearchLabelToolboxController_get_implementation(
1532 css::uno::XComponentContext
*context
,
1533 css::uno::Sequence
<css::uno::Any
> const &)
1535 return cppu::acquire(new SearchLabelToolboxController(context
));
1538 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1539 com_sun_star_comp_svx_Impl_FindbarDispatcher_get_implementation(
1540 SAL_UNUSED_PARAMETER
css::uno::XComponentContext
*,
1541 css::uno::Sequence
<css::uno::Any
> const &)
1543 return cppu::acquire(new FindbarDispatcher
);
1546 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */