LCOV - code coverage report
Current view: top level - svx/source/tbxctrls - tbunosearchcontrollers.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 31 570 5.4 %
Date: 2014-11-03 Functions: 13 120 10.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <tbunosearchcontrollers.hxx>
      21             : 
      22             : #include <svx/dialogs.hrc>
      23             : #include <svx/dialmgr.hxx>
      24             : 
      25             : #include <comphelper/processfactory.hxx>
      26             : #include <cppuhelper/supportsservice.hxx>
      27             : #include <com/sun/star/beans/XPropertySet.hpp>
      28             : #include <com/sun/star/frame/XLayoutManager.hpp>
      29             : #include <com/sun/star/i18n/TransliterationModules.hpp>
      30             : #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
      31             : #include <com/sun/star/text/XTextRange.hpp>
      32             : #include <com/sun/star/ui/XUIElement.hpp>
      33             : #include <com/sun/star/util/URL.hpp>
      34             : #include <com/sun/star/util/URLTransformer.hpp>
      35             : 
      36             : #include <svl/ctloptions.hxx>
      37             : #include <svl/srchitem.hxx>
      38             : #include <toolkit/helper/vclunohelper.hxx>
      39             : #include <vcl/toolbox.hxx>
      40             : #include <vcl/svapp.hxx>
      41             : #include <osl/mutex.hxx>
      42             : #include <rtl/ref.hxx>
      43             : #include <rtl/instance.hxx>
      44             : 
      45             : #include <vcl/fixed.hxx>
      46             : 
      47             : using namespace css;
      48             : 
      49             : namespace {
      50             : 
      51             : static const char SEARCHITEM_COMMAND[] = "SearchItem.Command";
      52             : static const char SEARCHITEM_SEARCHSTRING[] = "SearchItem.SearchString";
      53             : static const char SEARCHITEM_SEARCHBACKWARD[] = "SearchItem.Backward";
      54             : static const char SEARCHITEM_SEARCHFLAGS[] = "SearchItem.SearchFlags";
      55             : static const char SEARCHITEM_TRANSLITERATEFLAGS[] = "SearchItem.TransliterateFlags";
      56             : static const char SEARCHITEM_ALGORITHMTYPE[] = "SearchItem.AlgorithmType";
      57             : 
      58             : static const char COMMAND_EXECUTESEARCH[] = ".uno:ExecuteSearch";
      59             : static const char COMMAND_FINDTEXT[] = ".uno:FindText";
      60             : static const char COMMAND_DOWNSEARCH[] = ".uno:DownSearch";
      61             : static const char COMMAND_UPSEARCH[] = ".uno:UpSearch";
      62             : static const char COMMAND_EXITSEARCH[] = ".uno:ExitSearch";
      63             : static const char COMMAND_MATCHCASE[] = ".uno:MatchCase";
      64             : static const char COMMAND_APPENDSEARCHHISTORY[] = "AppendSearchHistory";
      65             : 
      66             : static const sal_Int32       REMEMBER_SIZE = 10;
      67             : 
      68           0 : void impl_executeSearch( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
      69             :                          const css::uno::Reference< css::frame::XFrame >& xFrame,
      70             :                          const ToolBox* pToolBox,
      71             :                          const bool aSearchBackwards = false,
      72             :                          const bool aFindAll = false )
      73             : {
      74           0 :     css::uno::Reference< css::util::XURLTransformer > xURLTransformer( css::util::URLTransformer::create( rxContext ) );
      75           0 :     css::util::URL aURL;
      76           0 :     aURL.Complete = OUString(COMMAND_EXECUTESEARCH);
      77           0 :     xURLTransformer->parseStrict(aURL);
      78             : 
      79           0 :     OUString sFindText;
      80           0 :     bool aMatchCase = false;
      81           0 :     if ( pToolBox )
      82             :     {
      83           0 :         sal_uInt16 nItemCount = pToolBox->GetItemCount();
      84           0 :         for ( sal_uInt16 i=0; i<nItemCount; ++i )
      85             :         {
      86           0 :             OUString sItemCommand = pToolBox->GetItemCommand(i);
      87           0 :             if ( sItemCommand == COMMAND_FINDTEXT )
      88             :             {
      89           0 :                 vcl::Window* pItemWin = pToolBox->GetItemWindow(i);
      90           0 :                 if (pItemWin)
      91           0 :                     sFindText = pItemWin->GetText();
      92           0 :             } else if ( sItemCommand == COMMAND_MATCHCASE )
      93             :             {
      94           0 :                 CheckBox* pItemWin = static_cast<CheckBox*>( pToolBox->GetItemWindow(i) );
      95           0 :                 if (pItemWin)
      96           0 :                     aMatchCase = pItemWin->IsChecked();
      97             :             }
      98           0 :         }
      99             :     }
     100             : 
     101           0 :     css::uno::Sequence< css::beans::PropertyValue > lArgs(6);
     102           0 :     lArgs[0].Name = OUString(SEARCHITEM_SEARCHSTRING);
     103           0 :     lArgs[0].Value <<= sFindText;
     104           0 :     lArgs[1].Name = OUString(SEARCHITEM_SEARCHBACKWARD);
     105           0 :     lArgs[1].Value <<= aSearchBackwards;
     106           0 :     lArgs[2].Name = OUString(SEARCHITEM_SEARCHFLAGS);
     107           0 :     lArgs[2].Value <<= (sal_Int32)0;
     108           0 :     lArgs[3].Name = OUString(SEARCHITEM_TRANSLITERATEFLAGS);
     109           0 :     SvtCTLOptions aCTLOptions;
     110           0 :     sal_Int32 nFlags = 0;
     111           0 :     nFlags |= (!aMatchCase ? static_cast<int>(com::sun::star::i18n::TransliterationModules_IGNORE_CASE) : 0);
     112           0 :     nFlags |= (aCTLOptions.IsCTLFontEnabled() ? com::sun::star::i18n::TransliterationModulesExtra::IGNORE_DIACRITICS_CTL:0 );
     113           0 :     nFlags |= (aCTLOptions.IsCTLFontEnabled() ? com::sun::star::i18n::TransliterationModulesExtra::IGNORE_KASHIDA_CTL:0 );
     114           0 :     lArgs[3].Value <<= nFlags;
     115           0 :     lArgs[4].Name = OUString(SEARCHITEM_COMMAND);
     116           0 :     lArgs[4].Value <<= (sal_Int16)(aFindAll ?
     117           0 :         SVX_SEARCHCMD_FIND_ALL : SVX_SEARCHCMD_FIND );
     118           0 :     lArgs[5].Name = OUString(SEARCHITEM_ALGORITHMTYPE);
     119           0 :     lArgs[5].Value <<= (sal_Int16)0;  // 0 == SearchAlgorithms_ABSOLUTE
     120             : 
     121           0 :     css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider(xFrame, css::uno::UNO_QUERY);
     122           0 :     if ( xDispatchProvider.is() )
     123             :     {
     124           0 :         css::uno::Reference< css::frame::XDispatch > xDispatch = xDispatchProvider->queryDispatch( aURL, OUString(), 0 );
     125           0 :         if ( xDispatch.is() && !aURL.Complete.isEmpty() )
     126           0 :             xDispatch->dispatch( aURL, lArgs );
     127           0 :     }
     128           0 : }
     129             : 
     130           0 : FindTextFieldControl::FindTextFieldControl( vcl::Window* pParent, WinBits nStyle,
     131             :     css::uno::Reference< css::frame::XFrame >& xFrame,
     132             :     const css::uno::Reference< css::uno::XComponentContext >& xContext) :
     133             :     ComboBox( pParent, nStyle ),
     134             :     m_xFrame(xFrame),
     135           0 :     m_xContext(xContext)
     136             : {
     137           0 :     SetPlaceholderText(SVX_RESSTR(RID_SVXSTR_FINDBAR_FIND));
     138           0 :     EnableAutocomplete(true, true);
     139           0 : }
     140             : 
     141           0 : FindTextFieldControl::~FindTextFieldControl()
     142             : {
     143           0 : }
     144             : 
     145           0 : void FindTextFieldControl::Remember_Impl(const OUString& rStr)
     146             : {
     147           0 :     sal_uInt16 nCount = GetEntryCount();
     148             : 
     149           0 :     for (sal_uInt16 i=0; i<nCount; ++i)
     150             :     {
     151           0 :         if ( rStr == GetEntry(i))
     152           0 :             return;
     153             :     }
     154             : 
     155           0 :     if (nCount == REMEMBER_SIZE)
     156           0 :         RemoveEntryAt(REMEMBER_SIZE-1);
     157             : 
     158           0 :     InsertEntry(rStr, 0);
     159             : }
     160             : 
     161           0 : void FindTextFieldControl::SetTextToSelected_Impl()
     162             : {
     163           0 :     OUString aString;
     164             : 
     165             :     try
     166             :     {
     167           0 :         css::uno::Reference<css::frame::XController> xController(m_xFrame->getController(), css::uno::UNO_QUERY_THROW);
     168           0 :         css::uno::Reference<css::frame::XModel> xModel(xController->getModel(), css::uno::UNO_QUERY_THROW);
     169           0 :         css::uno::Reference<css::container::XIndexAccess> xIndexAccess(xModel->getCurrentSelection(), css::uno::UNO_QUERY_THROW);
     170           0 :         if (xIndexAccess->getCount() > 0)
     171             :         {
     172           0 :             css::uno::Reference<css::text::XTextRange> xTextRange(xIndexAccess->getByIndex(0), css::uno::UNO_QUERY_THROW);
     173           0 :             aString = xTextRange->getString();
     174           0 :         }
     175             :     }
     176           0 :     catch ( ... )
     177             :     {
     178             :     }
     179             : 
     180           0 :     if ( !aString.isEmpty() )
     181             :     {
     182             :         // If something is selected in the document, prepopulate with this
     183           0 :         SetText( aString );
     184           0 :         GetModifyHdl().Call(this); // FIXME why SetText doesn't trigger this?
     185             :     }
     186           0 :     else if (GetEntryCount() > 0)
     187             :     {
     188             :         // Else, prepopulate with last search word (fdo#84256)
     189           0 :         SetText(GetEntry(0));
     190           0 :     }
     191           0 : }
     192             : 
     193           0 : bool FindTextFieldControl::PreNotify( NotifyEvent& rNEvt )
     194             : {
     195           0 :     bool nRet= ComboBox::PreNotify( rNEvt );
     196             : 
     197           0 :     switch ( rNEvt.GetType() )
     198             :     {
     199             :         case EVENT_KEYINPUT:
     200             :         {
     201           0 :             const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
     202           0 :             bool bShift = pKeyEvent->GetKeyCode().IsShift();
     203           0 :             bool bMod1 = pKeyEvent->GetKeyCode().IsMod1();
     204           0 :             sal_uInt16 nCode = pKeyEvent->GetKeyCode().GetCode();
     205             : 
     206             :             // Close the search bar on Escape
     207           0 :             if ( KEY_ESCAPE == nCode )
     208             :             {
     209           0 :                 nRet = true;
     210           0 :                 GrabFocusToDocument();
     211             : 
     212             :                 // hide the findbar
     213           0 :                 css::uno::Reference< css::beans::XPropertySet > xPropSet(m_xFrame, css::uno::UNO_QUERY);
     214           0 :                 if (xPropSet.is())
     215             :                 {
     216           0 :                     css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
     217           0 :                     css::uno::Any aValue = xPropSet->getPropertyValue("LayoutManager");
     218           0 :                     aValue >>= xLayoutManager;
     219           0 :                     if (xLayoutManager.is())
     220             :                     {
     221           0 :                         const OUString sResourceURL( "private:resource/toolbar/findbar" );
     222           0 :                         xLayoutManager->hideElement( sResourceURL );
     223           0 :                         xLayoutManager->destroyElement( sResourceURL );
     224           0 :                     }
     225           0 :                 }
     226             :             }
     227             :             // Select text in the search box when Ctrl-F pressed
     228           0 :             if ( bMod1 && nCode == KEY_F )
     229           0 :                 SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
     230             : 
     231             :             // Execute the search when Return, Ctrl-G or F3 pressed
     232           0 :             if ( KEY_RETURN == nCode || (bMod1 && (KEY_G == nCode)) || (KEY_F3 == nCode) )
     233             :             {
     234           0 :                 Remember_Impl(GetText());
     235             : 
     236           0 :                 vcl::Window* pWindow = GetParent();
     237           0 :                 ToolBox* pToolBox = static_cast<ToolBox*>(pWindow);
     238             : 
     239           0 :                 impl_executeSearch( m_xContext, m_xFrame, pToolBox, bShift);
     240           0 :                 nRet = true;
     241             :             }
     242           0 :             break;
     243             :         }
     244             : 
     245             :         case EVENT_GETFOCUS:
     246           0 :             SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
     247           0 :             break;
     248             :     }
     249             : 
     250           0 :     return nRet;
     251             : }
     252             : 
     253           0 : SearchToolbarControllersManager::SearchToolbarControllersManager()
     254             : {
     255           0 : }
     256             : 
     257           0 : SearchToolbarControllersManager::~SearchToolbarControllersManager()
     258             : {
     259           0 : }
     260             : 
     261             : namespace
     262             : {
     263             :     class theSearchToolbarControllersManager
     264             :         : public rtl::Static<SearchToolbarControllersManager,
     265             :             theSearchToolbarControllersManager>
     266             :     {
     267             :     };
     268             : }
     269             : 
     270           0 : SearchToolbarControllersManager& SearchToolbarControllersManager::createControllersManager()
     271             : {
     272           0 :     return theSearchToolbarControllersManager::get();
     273             : }
     274             : 
     275           0 : void SearchToolbarControllersManager::saveSearchHistory(const FindTextFieldControl* pFindTextFieldControl)
     276             : {
     277           0 :     sal_uInt16 nECount( pFindTextFieldControl->GetEntryCount() );
     278           0 :     m_aSearchStrings.resize( nECount );
     279           0 :     for( sal_uInt16 i=0; i<nECount; ++i )
     280             :     {
     281           0 :         m_aSearchStrings[i] = pFindTextFieldControl->GetEntry(i);
     282             :     }
     283           0 : }
     284             : 
     285           0 : void SearchToolbarControllersManager::loadSearchHistory(FindTextFieldControl* pFindTextFieldControl)
     286             : {
     287           0 :     for( sal_uInt16 i=0; i<m_aSearchStrings.size(); ++i )
     288             :     {
     289           0 :         pFindTextFieldControl->InsertEntry(m_aSearchStrings[i],i);
     290             :     }
     291           0 : }
     292             : 
     293           0 : void SearchToolbarControllersManager::registryController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const OUString& sCommandURL )
     294             : {
     295           0 :     SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame);
     296           0 :     if (pIt == aSearchToolbarControllersMap.end())
     297             :     {
     298           0 :         SearchToolbarControllersVec lControllers(1);
     299           0 :         lControllers[0].Name = sCommandURL;
     300           0 :         lControllers[0].Value <<= xStatusListener;
     301           0 :         aSearchToolbarControllersMap.insert(SearchToolbarControllersMap::value_type(xFrame, lControllers));
     302             :     }
     303             :     else
     304             :     {
     305           0 :         sal_Int32 nSize = pIt->second.size();
     306           0 :         for (sal_Int32 i=0; i<nSize; ++i)
     307             :         {
     308           0 :             if (pIt->second[i].Name.equals(sCommandURL))
     309           0 :                 return;
     310             :         }
     311             : 
     312           0 :         pIt->second.resize(nSize+1);
     313           0 :         pIt->second[nSize].Name = sCommandURL;
     314           0 :         pIt->second[nSize].Value <<= xStatusListener;
     315             :     }
     316             : }
     317             : 
     318           0 : void SearchToolbarControllersManager::freeController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& /*xStatusListener*/, const OUString& sCommandURL )
     319             : {
     320           0 :     SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame);
     321           0 :     if (pIt != aSearchToolbarControllersMap.end())
     322             :     {
     323           0 :         for (SearchToolbarControllersVec::iterator pItCtrl=pIt->second.begin(); pItCtrl!=pIt->second.end(); ++pItCtrl)
     324             :         {
     325           0 :             if (pItCtrl->Name.equals(sCommandURL))
     326             :             {
     327           0 :                 pIt->second.erase(pItCtrl);
     328           0 :                 break;
     329             :             }
     330             :         }
     331             : 
     332           0 :         if (pIt->second.empty())
     333           0 :             aSearchToolbarControllersMap.erase(pIt);
     334             :     }
     335           0 : }
     336             : 
     337           0 : css::uno::Reference< css::frame::XStatusListener > SearchToolbarControllersManager::findController( const css::uno::Reference< css::frame::XFrame >& xFrame, const OUString& sCommandURL )
     338             : {
     339           0 :     css::uno::Reference< css::frame::XStatusListener > xStatusListener;
     340             : 
     341           0 :     SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame);
     342           0 :     if (pIt != aSearchToolbarControllersMap.end())
     343             :     {
     344           0 :         for (SearchToolbarControllersVec::iterator pItCtrl =pIt->second.begin(); pItCtrl != pIt->second.end(); ++pItCtrl)
     345             :         {
     346           0 :             if (pItCtrl->Name.equals(sCommandURL))
     347             :             {
     348           0 :                 pItCtrl->Value >>= xStatusListener;
     349           0 :                 break;
     350             :             }
     351             :         }
     352             :     }
     353             : 
     354           0 :     return xStatusListener;
     355             : }
     356             : 
     357           0 : FindTextToolbarController::FindTextToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext )
     358             :     : svt::ToolboxController(rxContext, css::uno::Reference< css::frame::XFrame >(), OUString(COMMAND_FINDTEXT))
     359             :     , m_pFindTextFieldControl(NULL)
     360             :     , m_nDownSearchId(0)
     361           0 :     , m_nUpSearchId(0)
     362             : {
     363           0 : }
     364             : 
     365           0 : FindTextToolbarController::~FindTextToolbarController()
     366             : {
     367           0 : }
     368             : 
     369             : // XInterface
     370           0 : css::uno::Any SAL_CALL FindTextToolbarController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException, std::exception )
     371             : {
     372           0 :     css::uno::Any a = ToolboxController::queryInterface( aType );
     373           0 :     if ( a.hasValue() )
     374           0 :         return a;
     375             : 
     376           0 :     return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) );
     377             : }
     378             : 
     379           0 : void SAL_CALL FindTextToolbarController::acquire() throw ()
     380             : {
     381           0 :     ToolboxController::acquire();
     382           0 : }
     383             : 
     384           0 : void SAL_CALL FindTextToolbarController::release() throw ()
     385             : {
     386           0 :     ToolboxController::release();
     387           0 : }
     388             : 
     389             : // XServiceInfo
     390           0 : OUString SAL_CALL FindTextToolbarController::getImplementationName() throw( css::uno::RuntimeException, std::exception )
     391             : {
     392           0 :     return OUString("com.sun.star.svx.FindTextToolboxController");
     393             : }
     394             : 
     395           0 : sal_Bool SAL_CALL FindTextToolbarController::supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException, std::exception )
     396             : {
     397           0 :     return cppu::supportsService(this, ServiceName);
     398             : }
     399             : 
     400           0 : css::uno::Sequence< OUString > SAL_CALL FindTextToolbarController::getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception )
     401             : {
     402           0 :     css::uno::Sequence< OUString > aSNS( 1 );
     403           0 :     aSNS[0] = "com.sun.star.frame.ToolbarController";
     404           0 :     return aSNS;
     405             : }
     406             : 
     407             : // XComponent
     408           0 : void SAL_CALL FindTextToolbarController::dispose() throw ( css::uno::RuntimeException, std::exception )
     409             : {
     410           0 :     SolarMutexGuard aSolarMutexGuard;
     411             : 
     412           0 :     SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
     413             : 
     414           0 :     svt::ToolboxController::dispose();
     415           0 :     SearchToolbarControllersManager::createControllersManager().saveSearchHistory(m_pFindTextFieldControl);
     416           0 :     delete m_pFindTextFieldControl;
     417           0 :     m_pFindTextFieldControl = 0;
     418           0 : }
     419             : 
     420             : // XInitialization
     421           0 : void SAL_CALL FindTextToolbarController::initialize( const css::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException, std::exception)
     422             : {
     423           0 :     svt::ToolboxController::initialize(aArguments);
     424             : 
     425           0 :     vcl::Window* pWindow = VCLUnoHelper::GetWindow( getParent() );
     426           0 :     ToolBox* pToolBox = static_cast<ToolBox*>(pWindow);
     427           0 :     if ( pToolBox )
     428             :     {
     429           0 :         sal_uInt16 nItemCount = pToolBox->GetItemCount();
     430           0 :         for ( sal_uInt16 i=0; i<nItemCount; ++i )
     431             :         {
     432           0 :             OUString sItemCommand = pToolBox->GetItemCommand(i);
     433           0 :             if ( sItemCommand == COMMAND_DOWNSEARCH )
     434             :             {
     435           0 :                 pToolBox->EnableItem(i, false);
     436           0 :                 m_nDownSearchId = i;
     437             :             }
     438           0 :             else if ( sItemCommand == COMMAND_UPSEARCH )
     439             :             {
     440           0 :                 pToolBox->EnableItem(i, false);
     441           0 :                 m_nUpSearchId = i;
     442             :             }
     443           0 :         }
     444             :     }
     445             : 
     446           0 :     SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
     447           0 : }
     448             : 
     449           0 : css::uno::Reference< css::awt::XWindow > SAL_CALL FindTextToolbarController::createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException, std::exception )
     450             : {
     451           0 :     css::uno::Reference< css::awt::XWindow > xItemWindow;
     452             : 
     453           0 :     css::uno::Reference< css::awt::XWindow > xParent( Parent );
     454           0 :     vcl::Window* pParent = VCLUnoHelper::GetWindow( xParent );
     455           0 :     if ( pParent )
     456             :     {
     457           0 :         ToolBox* pToolbar = static_cast<ToolBox*>(pParent);
     458           0 :         m_pFindTextFieldControl = new FindTextFieldControl( pToolbar, WinBits( WB_DROPDOWN | WB_VSCROLL), m_xFrame, m_xContext  );
     459             : 
     460           0 :         Size aSize(250, m_pFindTextFieldControl->GetTextHeight() + 200);
     461           0 :         m_pFindTextFieldControl->SetSizePixel( aSize );
     462           0 :         m_pFindTextFieldControl->SetModifyHdl(LINK(this, FindTextToolbarController, EditModifyHdl));
     463           0 :         SearchToolbarControllersManager::createControllersManager().loadSearchHistory(m_pFindTextFieldControl);
     464             :     }
     465           0 :     xItemWindow = VCLUnoHelper::GetInterface( m_pFindTextFieldControl );
     466             : 
     467           0 :     return xItemWindow;
     468             : }
     469             : 
     470             : // XStatusListener
     471           0 : void SAL_CALL FindTextToolbarController::statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException, std::exception )
     472             : {
     473           0 :     SolarMutexGuard aSolarMutexGuard;
     474           0 :     if ( m_bDisposed )
     475           0 :         return;
     476             : 
     477           0 :     OUString aFeatureURL = rEvent.FeatureURL.Complete;
     478           0 :     if ( aFeatureURL == "AppendSearchHistory" )
     479             :     {
     480           0 :         m_pFindTextFieldControl->Remember_Impl(m_pFindTextFieldControl->GetText());
     481           0 :     }
     482             : }
     483             : 
     484           0 : IMPL_LINK_NOARG(FindTextToolbarController, EditModifyHdl)
     485             : {
     486             :     // enable or disable item DownSearch/UpSearch of findbar
     487           0 :     vcl::Window* pWindow = VCLUnoHelper::GetWindow( getParent() );
     488           0 :     ToolBox* pToolBox = static_cast<ToolBox*>(pWindow);
     489           0 :     if ( pToolBox && m_pFindTextFieldControl )
     490             :     {
     491           0 :         if (!m_pFindTextFieldControl->GetText().isEmpty())
     492             :         {
     493           0 :             if ( !pToolBox->IsItemEnabled(m_nDownSearchId) )
     494           0 :                 pToolBox->EnableItem(m_nDownSearchId, true);
     495           0 :             if ( !pToolBox->IsItemEnabled(m_nUpSearchId) )
     496           0 :                 pToolBox->EnableItem(m_nUpSearchId, true);
     497             :         }
     498             :         else
     499             :         {
     500           0 :             if ( pToolBox->IsItemEnabled(m_nDownSearchId) )
     501           0 :                 pToolBox->EnableItem(m_nDownSearchId, false);
     502           0 :             if ( pToolBox->IsItemEnabled(m_nUpSearchId) )
     503           0 :                 pToolBox->EnableItem(m_nUpSearchId, false);
     504             :         }
     505             :     }
     506             : 
     507           0 :     return 0;
     508             : }
     509             : 
     510           0 : UpDownSearchToolboxController::UpDownSearchToolboxController( const css::uno::Reference< css::uno::XComponentContext > & rxContext, Type eType )
     511             :     : svt::ToolboxController( rxContext,
     512             :             css::uno::Reference< css::frame::XFrame >(),
     513             :             (eType == UP) ? OUString( COMMAND_UPSEARCH ):  OUString( COMMAND_DOWNSEARCH ) ),
     514           0 :       meType( eType )
     515             : {
     516           0 : }
     517             : 
     518           0 : UpDownSearchToolboxController::~UpDownSearchToolboxController()
     519             : {
     520           0 : }
     521             : 
     522             : // XInterface
     523           0 : css::uno::Any SAL_CALL UpDownSearchToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException, std::exception )
     524             : {
     525           0 :     css::uno::Any a = ToolboxController::queryInterface( aType );
     526           0 :     if ( a.hasValue() )
     527           0 :         return a;
     528             : 
     529           0 :     return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) );
     530             : }
     531             : 
     532           0 : void SAL_CALL UpDownSearchToolboxController::acquire() throw ()
     533             : {
     534           0 :     ToolboxController::acquire();
     535           0 : }
     536             : 
     537           0 : void SAL_CALL UpDownSearchToolboxController::release() throw ()
     538             : {
     539           0 :     ToolboxController::release();
     540           0 : }
     541             : 
     542             : // XServiceInfo
     543           0 : OUString SAL_CALL UpDownSearchToolboxController::getImplementationName() throw( css::uno::RuntimeException, std::exception )
     544             : {
     545           0 :     return meType == UpDownSearchToolboxController::UP?
     546             :         OUString( "com.sun.star.svx.UpSearchToolboxController" ) :
     547           0 :         OUString( "com.sun.star.svx.DownSearchToolboxController" );
     548             : }
     549             : 
     550           0 : sal_Bool SAL_CALL UpDownSearchToolboxController::supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException, std::exception )
     551             : {
     552           0 :     return cppu::supportsService(this, ServiceName);
     553             : }
     554             : 
     555           0 : css::uno::Sequence< OUString > SAL_CALL UpDownSearchToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception )
     556             : {
     557           0 :     css::uno::Sequence< OUString > aSNS( 1 );
     558           0 :     aSNS[0] = "com.sun.star.frame.ToolbarController";
     559           0 :     return aSNS;
     560             : }
     561             : 
     562             : // XComponent
     563           0 : void SAL_CALL UpDownSearchToolboxController::dispose() throw ( css::uno::RuntimeException, std::exception )
     564             : {
     565           0 :     SolarMutexGuard aSolarMutexGuard;
     566             : 
     567           0 :     SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
     568             : 
     569           0 :     svt::ToolboxController::dispose();
     570           0 : }
     571             : 
     572             : // XInitialization
     573           0 : void SAL_CALL UpDownSearchToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
     574             : {
     575           0 :     svt::ToolboxController::initialize( aArguments );
     576           0 :     SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
     577           0 : }
     578             : 
     579             : // XToolbarController
     580           0 : void SAL_CALL UpDownSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException, std::exception )
     581             : {
     582           0 :     if ( m_bDisposed )
     583           0 :         throw css::lang::DisposedException();
     584             : 
     585           0 :     vcl::Window* pWindow = VCLUnoHelper::GetWindow( getParent() );
     586           0 :     ToolBox* pToolBox = static_cast<ToolBox*>(pWindow);
     587             : 
     588           0 :     impl_executeSearch(m_xContext, m_xFrame, pToolBox, meType == UP );
     589             : 
     590           0 :     css::frame::FeatureStateEvent aEvent;
     591           0 :     aEvent.FeatureURL.Complete = OUString(COMMAND_APPENDSEARCHHISTORY);
     592           0 :     css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager().findController(m_xFrame, COMMAND_FINDTEXT);
     593           0 :     if (xStatusListener.is())
     594           0 :         xStatusListener->statusChanged( aEvent );
     595           0 : }
     596             : 
     597             : // XStatusListener
     598           0 : void SAL_CALL UpDownSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException, std::exception )
     599             : {
     600           0 : }
     601             : 
     602           0 : MatchCaseToolboxController::MatchCaseToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext )
     603             :     : svt::ToolboxController( rxContext,
     604             :         css::uno::Reference< css::frame::XFrame >(),
     605             :         OUString(COMMAND_MATCHCASE) )
     606           0 :     , m_pMatchCaseControl(NULL)
     607             : {
     608           0 : }
     609             : 
     610           0 : MatchCaseToolboxController::~MatchCaseToolboxController()
     611             : {
     612           0 : }
     613             : 
     614             : // XInterface
     615           0 : css::uno::Any SAL_CALL MatchCaseToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException, std::exception )
     616             : {
     617           0 :     css::uno::Any a = ToolboxController::queryInterface( aType );
     618           0 :     if ( a.hasValue() )
     619           0 :         return a;
     620             : 
     621           0 :     return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) );
     622             : }
     623             : 
     624           0 : void SAL_CALL MatchCaseToolboxController::acquire() throw ()
     625             : {
     626           0 :     ToolboxController::acquire();
     627           0 : }
     628             : 
     629           0 : void SAL_CALL MatchCaseToolboxController::release() throw ()
     630             : {
     631           0 :     ToolboxController::release();
     632           0 : }
     633             : 
     634             : // XServiceInfo
     635           0 : OUString SAL_CALL MatchCaseToolboxController::getImplementationName() throw( css::uno::RuntimeException, std::exception )
     636             : {
     637           0 :     return OUString( "com.sun.star.svx.MatchCaseToolboxController" );
     638             : }
     639             : 
     640           0 : sal_Bool SAL_CALL MatchCaseToolboxController::supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException, std::exception )
     641             : {
     642           0 :     return cppu::supportsService(this, ServiceName);
     643             : }
     644             : 
     645           0 : css::uno::Sequence< OUString > SAL_CALL MatchCaseToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception )
     646             : {
     647           0 :     css::uno::Sequence< OUString > aSNS( 1 );
     648           0 :     aSNS[0] = "com.sun.star.frame.ToolbarController";
     649           0 :     return aSNS;
     650             : }
     651             : 
     652             : // XComponent
     653           0 : void SAL_CALL MatchCaseToolboxController::dispose() throw ( css::uno::RuntimeException, std::exception )
     654             : {
     655           0 :     SolarMutexGuard aSolarMutexGuard;
     656             : 
     657           0 :     SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
     658             : 
     659           0 :     svt::ToolboxController::dispose();
     660             : 
     661           0 :     delete m_pMatchCaseControl;
     662           0 :     m_pMatchCaseControl = 0;
     663           0 : }
     664             : 
     665             : // XInitialization
     666           0 : void SAL_CALL MatchCaseToolboxController::initialize( const css::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException, std::exception)
     667             : {
     668           0 :     svt::ToolboxController::initialize(aArguments);
     669             : 
     670           0 :     SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
     671           0 : }
     672             : 
     673           0 : css::uno::Reference< css::awt::XWindow > SAL_CALL MatchCaseToolboxController::createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException, std::exception )
     674             : {
     675           0 :     css::uno::Reference< css::awt::XWindow > xItemWindow;
     676             : 
     677           0 :     css::uno::Reference< css::awt::XWindow > xParent( Parent );
     678           0 :     vcl::Window* pParent = VCLUnoHelper::GetWindow( xParent );
     679           0 :     if ( pParent )
     680             :     {
     681           0 :         ToolBox* pToolbar = static_cast<ToolBox*>(pParent);
     682           0 :         m_pMatchCaseControl = new CheckBox( pToolbar, 0 );
     683           0 :         m_pMatchCaseControl->SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_MATCHCASE ) );
     684           0 :         Size aSize( m_pMatchCaseControl->GetOptimalSize() );
     685           0 :         m_pMatchCaseControl->SetSizePixel( aSize );
     686             :     }
     687           0 :     xItemWindow = VCLUnoHelper::GetInterface( m_pMatchCaseControl );
     688             : 
     689           0 :     return xItemWindow;
     690             : }
     691             : 
     692             : // XStatusListener
     693           0 : void SAL_CALL MatchCaseToolboxController::statusChanged( const css::frame::FeatureStateEvent& ) throw ( css::uno::RuntimeException, std::exception )
     694             : {
     695           0 : }
     696             : 
     697           0 : FindAllToolboxController::FindAllToolboxController( const css::uno::Reference< css::uno::XComponentContext > & rxContext )
     698             :     : svt::ToolboxController( rxContext,
     699             :             css::uno::Reference< css::frame::XFrame >(),
     700           0 :             OUString( COMMAND_EXITSEARCH ) )
     701             : {
     702           0 : }
     703             : 
     704           0 : FindAllToolboxController::~FindAllToolboxController()
     705             : {
     706           0 : }
     707             : 
     708             : // XInterface
     709           0 : css::uno::Any SAL_CALL FindAllToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException, std::exception )
     710             : {
     711           0 :     css::uno::Any a = ToolboxController::queryInterface( aType );
     712           0 :     if ( a.hasValue() )
     713           0 :         return a;
     714             : 
     715           0 :     return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) );
     716             : }
     717             : 
     718           0 : void SAL_CALL FindAllToolboxController::acquire() throw ()
     719             : {
     720           0 :     ToolboxController::acquire();
     721           0 : }
     722             : 
     723           0 : void SAL_CALL FindAllToolboxController::release() throw ()
     724             : {
     725           0 :     ToolboxController::release();
     726           0 : }
     727             : 
     728             : // XServiceInfo
     729           0 : OUString SAL_CALL FindAllToolboxController::getImplementationName() throw( css::uno::RuntimeException, std::exception )
     730             : {
     731           0 :     return OUString( "com.sun.star.svx.FindAllToolboxController" );
     732             : }
     733             : 
     734             : 
     735           0 : sal_Bool SAL_CALL FindAllToolboxController::supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException, std::exception )
     736             : {
     737           0 :     return cppu::supportsService(this, ServiceName);
     738             : }
     739             : 
     740           0 : css::uno::Sequence< OUString > SAL_CALL FindAllToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception )
     741             : {
     742           0 :     css::uno::Sequence< OUString > aSNS( 1 );
     743           0 :     aSNS[0] = "com.sun.star.frame.ToolbarController";
     744           0 :     return aSNS;
     745             : }
     746             : 
     747             : // XComponent
     748           0 : void SAL_CALL FindAllToolboxController::dispose() throw ( css::uno::RuntimeException, std::exception )
     749             : {
     750           0 :     SolarMutexGuard aSolarMutexGuard;
     751             : 
     752           0 :     SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
     753             : 
     754           0 :     svt::ToolboxController::dispose();
     755           0 : }
     756             : 
     757             : // XInitialization
     758           0 : void SAL_CALL FindAllToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
     759             : {
     760           0 :     svt::ToolboxController::initialize( aArguments );
     761           0 :     SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
     762           0 : }
     763             : 
     764             : // XToolbarController
     765           0 : void SAL_CALL FindAllToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException, std::exception )
     766             : {
     767           0 :     if ( m_bDisposed )
     768           0 :         throw css::lang::DisposedException();
     769             : 
     770           0 :     vcl::Window* pWindow = VCLUnoHelper::GetWindow( getParent() );
     771           0 :     ToolBox* pToolBox = static_cast<ToolBox*>(pWindow);
     772             : 
     773           0 :     impl_executeSearch(m_xContext, m_xFrame, pToolBox, false, true);
     774           0 : }
     775             : 
     776             : // XStatusListener
     777           0 : void SAL_CALL FindAllToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException, std::exception )
     778             : {
     779           0 : }
     780             : 
     781           0 : ExitSearchToolboxController::ExitSearchToolboxController( const css::uno::Reference< css::uno::XComponentContext > & rxContext )
     782             :     : svt::ToolboxController( rxContext,
     783             :             css::uno::Reference< css::frame::XFrame >(),
     784           0 :             OUString( COMMAND_EXITSEARCH ) )
     785             : {
     786           0 : }
     787             : 
     788           0 : ExitSearchToolboxController::~ExitSearchToolboxController()
     789             : {
     790           0 : }
     791             : 
     792             : // XInterface
     793           0 : css::uno::Any SAL_CALL ExitSearchToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException, std::exception )
     794             : {
     795           0 :     css::uno::Any a = ToolboxController::queryInterface( aType );
     796           0 :     if ( a.hasValue() )
     797           0 :         return a;
     798             : 
     799           0 :     return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) );
     800             : }
     801             : 
     802           0 : void SAL_CALL ExitSearchToolboxController::acquire() throw ()
     803             : {
     804           0 :     ToolboxController::acquire();
     805           0 : }
     806             : 
     807           0 : void SAL_CALL ExitSearchToolboxController::release() throw ()
     808             : {
     809           0 :     ToolboxController::release();
     810           0 : }
     811             : 
     812             : // XServiceInfo
     813           0 : OUString SAL_CALL ExitSearchToolboxController::getImplementationName() throw( css::uno::RuntimeException, std::exception )
     814             : {
     815           0 :     return OUString( "com.sun.star.svx.ExitFindbarToolboxController" );
     816             : }
     817             : 
     818             : 
     819           0 : sal_Bool SAL_CALL ExitSearchToolboxController::supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException, std::exception )
     820             : {
     821           0 :     return cppu::supportsService(this, ServiceName);
     822             : }
     823             : 
     824           0 : css::uno::Sequence< OUString > SAL_CALL ExitSearchToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception )
     825             : {
     826           0 :     css::uno::Sequence< OUString > aSNS( 1 );
     827           0 :     aSNS[0] = "com.sun.star.frame.ToolbarController";
     828           0 :     return aSNS;
     829             : }
     830             : 
     831             : // XComponent
     832           0 : void SAL_CALL ExitSearchToolboxController::dispose() throw ( css::uno::RuntimeException, std::exception )
     833             : {
     834           0 :     SolarMutexGuard aSolarMutexGuard;
     835             : 
     836           0 :     SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
     837             : 
     838           0 :     svt::ToolboxController::dispose();
     839           0 : }
     840             : 
     841             : // XInitialization
     842           0 : void SAL_CALL ExitSearchToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
     843             : {
     844           0 :     svt::ToolboxController::initialize( aArguments );
     845           0 :     SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
     846           0 : }
     847             : 
     848             : // XToolbarController
     849           0 : void SAL_CALL ExitSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException, std::exception )
     850             : {
     851           0 :     vcl::Window *pFocusWindow = Application::GetFocusWindow();
     852           0 :     if ( pFocusWindow )
     853           0 :         pFocusWindow->GrabFocusToDocument();
     854             : 
     855             :     // hide the findbar
     856           0 :     css::uno::Reference< css::beans::XPropertySet > xPropSet(m_xFrame, css::uno::UNO_QUERY);
     857           0 :     if (xPropSet.is())
     858             :     {
     859           0 :         css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
     860           0 :         css::uno::Any aValue = xPropSet->getPropertyValue("LayoutManager");
     861           0 :         aValue >>= xLayoutManager;
     862           0 :         if (xLayoutManager.is())
     863             :         {
     864           0 :             const OUString sResourceURL( "private:resource/toolbar/findbar" );
     865           0 :             xLayoutManager->hideElement( sResourceURL );
     866           0 :             xLayoutManager->destroyElement( sResourceURL );
     867           0 :         }
     868           0 :     }
     869           0 : }
     870             : 
     871             : // XStatusListener
     872           0 : void SAL_CALL ExitSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException, std::exception )
     873             : {
     874           0 : }
     875             : 
     876           0 : SearchLabelToolboxController::SearchLabelToolboxController( const css::uno::Reference< css::uno::XComponentContext > & rxContext )
     877             :     : svt::ToolboxController( rxContext,
     878             :             css::uno::Reference< css::frame::XFrame >(),
     879           0 :             OUString( ".uno:SearchLabel" ) )
     880             : {
     881           0 : }
     882             : 
     883           0 : SearchLabelToolboxController::~SearchLabelToolboxController()
     884             : {
     885           0 : }
     886             : 
     887             : // XInterface
     888           0 : css::uno::Any SAL_CALL SearchLabelToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException, std::exception )
     889             : {
     890           0 :     css::uno::Any a = ToolboxController::queryInterface( aType );
     891           0 :     if ( a.hasValue() )
     892           0 :         return a;
     893             : 
     894           0 :     return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) );
     895             : }
     896             : 
     897           0 : void SAL_CALL SearchLabelToolboxController::acquire() throw ()
     898             : {
     899           0 :     ToolboxController::acquire();
     900           0 : }
     901             : 
     902           0 : void SAL_CALL SearchLabelToolboxController::release() throw ()
     903             : {
     904           0 :     ToolboxController::release();
     905           0 : }
     906             : 
     907             : // XServiceInfo
     908           0 : OUString SAL_CALL SearchLabelToolboxController::getImplementationName() throw( css::uno::RuntimeException, std::exception )
     909             : {
     910           0 :     return OUString( "com.sun.star.svx.SearchLabelToolboxController" );
     911             : }
     912             : 
     913             : 
     914           0 : sal_Bool SAL_CALL SearchLabelToolboxController::supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException, std::exception )
     915             : {
     916           0 :     return cppu::supportsService(this, ServiceName);
     917             : }
     918             : 
     919           0 : css::uno::Sequence< OUString > SAL_CALL SearchLabelToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception )
     920             : {
     921           0 :     css::uno::Sequence< OUString > aSNS( 1 );
     922           0 :     aSNS[0] = "com.sun.star.frame.ToolbarController";
     923           0 :     return aSNS;
     924             : }
     925             : 
     926             : // XComponent
     927           0 : void SAL_CALL SearchLabelToolboxController::dispose() throw ( css::uno::RuntimeException, std::exception )
     928             : {
     929           0 :     SolarMutexGuard aSolarMutexGuard;
     930             : 
     931           0 :     SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
     932             : 
     933           0 :     svt::ToolboxController::dispose();
     934           0 : }
     935             : 
     936             : // XInitialization
     937           0 : void SAL_CALL SearchLabelToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
     938             : {
     939           0 :     svt::ToolboxController::initialize( aArguments );
     940           0 :     SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
     941           0 : }
     942             : 
     943             : // XStatusListener
     944           0 : void SAL_CALL SearchLabelToolboxController::statusChanged( const css::frame::FeatureStateEvent& ) throw ( css::uno::RuntimeException, std::exception )
     945             : {
     946           0 : }
     947             : 
     948           0 : css::uno::Reference< css::awt::XWindow > SAL_CALL SearchLabelToolboxController::createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException, std::exception )
     949             : {
     950           0 :     vcl::Window *pSL= new FixedText(VCLUnoHelper::GetWindow( Parent ));
     951           0 :     pSL->SetSizePixel(Size(250, 25));
     952           0 :     return VCLUnoHelper::GetInterface(pSL);
     953             : }
     954             : 
     955           4 : FindbarDispatcher::FindbarDispatcher()
     956             : {
     957           4 : }
     958             : 
     959          12 : FindbarDispatcher::~FindbarDispatcher()
     960             : {
     961           4 :     m_xFrame = NULL;
     962           8 : }
     963             : 
     964             : // XInterface
     965           8 : css::uno::Any SAL_CALL FindbarDispatcher::queryInterface( const css::uno::Type& aType ) throw( css::uno::RuntimeException, std::exception )
     966             : {
     967             :     css::uno::Any aReturn( ::cppu::queryInterface( aType,
     968             :         static_cast< css::lang::XServiceInfo* >(this),
     969             :         static_cast< css::lang::XInitialization* >(this),
     970             :         static_cast< css::frame::XDispatchProvider* >(this),
     971           8 :         static_cast< css::frame::XDispatch* >(this)) );
     972             : 
     973           8 :     if ( aReturn.hasValue() )
     974           8 :         return aReturn;
     975             : 
     976           0 :     return OWeakObject::queryInterface( aType );
     977             : }
     978             : 
     979          56 : void SAL_CALL FindbarDispatcher::acquire() throw()
     980             : {
     981          56 :     OWeakObject::acquire();
     982          56 : }
     983             : 
     984          56 : void SAL_CALL FindbarDispatcher::release() throw()
     985             : {
     986          56 :     OWeakObject::release();
     987          56 : }
     988             : 
     989             : // XServiceInfo
     990           0 : OUString SAL_CALL FindbarDispatcher::getImplementationName() throw( css::uno::RuntimeException, std::exception )
     991             : {
     992           0 :     return OUString("com.sun.star.comp.svx.Impl.FindbarDispatcher");
     993             : }
     994             : 
     995           0 : sal_Bool SAL_CALL FindbarDispatcher::supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException, std::exception )
     996             : {
     997           0 :     return cppu::supportsService(this, ServiceName);
     998             : }
     999             : 
    1000           0 : css::uno::Sequence< OUString > SAL_CALL FindbarDispatcher::getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception )
    1001             : {
    1002           0 :     css::uno::Sequence< OUString > aSNS( 2 );
    1003           0 :     aSNS[0] = "com.sun.star.comp.svx.FindbarDispatcher";
    1004           0 :     aSNS[1] = "com.sun.star.frame.ProtocolHandler";
    1005           0 :     return aSNS;
    1006             : }
    1007             : 
    1008             : // XInitialization
    1009           4 : void SAL_CALL FindbarDispatcher::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
    1010             : {
    1011           4 :     if ( aArguments.getLength() )
    1012           4 :         aArguments[0] >>= m_xFrame;
    1013           4 : }
    1014             : 
    1015             : // XDispatchProvider
    1016           4 : css::uno::Reference< css::frame::XDispatch > SAL_CALL FindbarDispatcher::queryDispatch( const css::util::URL& aURL, const OUString& /*sTargetFrameName*/, sal_Int32 /*nSearchFlags*/ ) throw( css::uno::RuntimeException, std::exception )
    1017             : {
    1018           4 :     css::uno::Reference< css::frame::XDispatch > xDispatch;
    1019             : 
    1020           4 :     if ( aURL.Protocol == "vnd.sun.star.findbar:" )
    1021           4 :         xDispatch = this;
    1022             : 
    1023           4 :     return xDispatch;
    1024             : }
    1025             : 
    1026           0 : css::uno::Sequence < css::uno::Reference< css::frame::XDispatch > > SAL_CALL FindbarDispatcher::queryDispatches( const css::uno::Sequence < css::frame::DispatchDescriptor >& seqDescripts ) throw( css::uno::RuntimeException, std::exception )
    1027             : {
    1028           0 :     sal_Int32 nCount = seqDescripts.getLength();
    1029           0 :     css::uno::Sequence < css::uno::Reference < XDispatch > > lDispatcher( nCount );
    1030             : 
    1031           0 :     for( sal_Int32 i=0; i<nCount; ++i )
    1032           0 :         lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL, seqDescripts[i].FrameName, seqDescripts[i].SearchFlags );
    1033             : 
    1034           0 :     return lDispatcher;
    1035             : }
    1036             : 
    1037             : // XDispatch
    1038           0 : void SAL_CALL FindbarDispatcher::dispatch( const css::util::URL& aURL, const css::uno::Sequence < css::beans::PropertyValue >& /*lArgs*/ ) throw( css::uno::RuntimeException, std::exception )
    1039             : {
    1040             :     //vnd.sun.star.findbar:FocusToFindbar  - set cursor to the FindTextFieldControl of the findbar
    1041           0 :     if ( aURL.Path == "FocusToFindbar" )
    1042             :     {
    1043           0 :         css::uno::Reference< css::beans::XPropertySet > xPropSet(m_xFrame, css::uno::UNO_QUERY);
    1044           0 :         if(!xPropSet.is())
    1045           0 :             return;
    1046             : 
    1047           0 :         css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
    1048           0 :         css::uno::Any aValue = xPropSet->getPropertyValue("LayoutManager");
    1049           0 :         aValue >>= xLayoutManager;
    1050           0 :         if (!xLayoutManager.is())
    1051           0 :             return;
    1052             : 
    1053           0 :         const OUString sResourceURL( "private:resource/toolbar/findbar" );
    1054           0 :         css::uno::Reference< css::ui::XUIElement > xUIElement = xLayoutManager->getElement(sResourceURL);
    1055           0 :         if (!xUIElement.is())
    1056             :         {
    1057             :             // show the findbar if necessary
    1058           0 :             xLayoutManager->createElement( sResourceURL );
    1059           0 :             xLayoutManager->showElement( sResourceURL );
    1060           0 :             xUIElement = xLayoutManager->getElement( sResourceURL );
    1061           0 :             if ( !xUIElement.is() )
    1062           0 :                 return;
    1063             :         }
    1064             : 
    1065           0 :         css::uno::Reference< css::awt::XWindow > xWindow(xUIElement->getRealInterface(), css::uno::UNO_QUERY);
    1066           0 :         vcl::Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
    1067           0 :         ToolBox* pToolBox = static_cast<ToolBox*>(pWindow);
    1068           0 :         if ( pToolBox )
    1069             :         {
    1070           0 :             sal_uInt16 nItemCount = pToolBox->GetItemCount();
    1071           0 :             for ( sal_uInt16 i=0; i<nItemCount; ++i )
    1072             :             {
    1073           0 :                 OUString sItemCommand = pToolBox->GetItemCommand(i);
    1074           0 :                 if ( sItemCommand == COMMAND_FINDTEXT )
    1075             :                 {
    1076           0 :                     vcl::Window* pItemWin = pToolBox->GetItemWindow( i );
    1077           0 :                     if ( pItemWin )
    1078             :                     {
    1079           0 :                         FindTextFieldControl* pFindTextFieldControl = dynamic_cast<FindTextFieldControl*>(pItemWin);
    1080           0 :                         if ( pFindTextFieldControl )
    1081           0 :                             pFindTextFieldControl->SetTextToSelected_Impl();
    1082           0 :                         SolarMutexGuard aSolarMutexGuard;
    1083           0 :                         pItemWin->GrabFocus();
    1084           0 :                         return;
    1085             :                     }
    1086             :                 }
    1087           0 :             }
    1088           0 :         }
    1089             :     }
    1090             : }
    1091             : 
    1092          14 : void SAL_CALL FindbarDispatcher::addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& /*xControl*/, const css::util::URL& /*aURL*/ ) throw ( css::uno::RuntimeException, std::exception )
    1093             : {
    1094          14 : }
    1095             : 
    1096          14 : void SAL_CALL FindbarDispatcher::removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& /*xControl*/, const css::util::URL& /*aURL*/ ) throw ( css::uno::RuntimeException, std::exception )
    1097             : {
    1098          14 : }
    1099             : 
    1100             : }
    1101             : 
    1102             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
    1103           0 : com_sun_star_svx_FindTextToolboxController_get_implementation(
    1104             :     css::uno::XComponentContext *context,
    1105             :     css::uno::Sequence<css::uno::Any> const &)
    1106             : {
    1107           0 :     return cppu::acquire(new FindTextToolbarController(context));
    1108             : }
    1109             : 
    1110             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
    1111           0 : com_sun_star_svx_ExitFindbarToolboxController_get_implementation(
    1112             :     css::uno::XComponentContext *context,
    1113             :     css::uno::Sequence<css::uno::Any> const &)
    1114             : {
    1115           0 :     return cppu::acquire(new ExitSearchToolboxController(context));
    1116             : }
    1117             : 
    1118             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
    1119           0 : com_sun_star_svx_UpSearchToolboxController_get_implementation(
    1120             :     css::uno::XComponentContext *context,
    1121             :     css::uno::Sequence<css::uno::Any> const &)
    1122             : {
    1123           0 :     return cppu::acquire(new UpDownSearchToolboxController(context, UpDownSearchToolboxController::UP));
    1124             : }
    1125             : 
    1126             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
    1127           0 : com_sun_star_svx_DownSearchToolboxController_get_implementation(
    1128             :     css::uno::XComponentContext *context,
    1129             :     css::uno::Sequence<css::uno::Any> const &)
    1130             : {
    1131           0 :     return cppu::acquire(new UpDownSearchToolboxController(context, UpDownSearchToolboxController::DOWN));
    1132             : }
    1133             : 
    1134             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
    1135           0 : com_sun_star_svx_MatchCaseToolboxController_get_implementation(
    1136             :     css::uno::XComponentContext *context,
    1137             :     css::uno::Sequence<css::uno::Any> const &)
    1138             : {
    1139           0 :     return cppu::acquire(new MatchCaseToolboxController(context));
    1140             : }
    1141             : 
    1142             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
    1143           0 : com_sun_star_svx_FindAllToolboxController_get_implementation(
    1144             :     css::uno::XComponentContext *context,
    1145             :     css::uno::Sequence<css::uno::Any> const &)
    1146             : {
    1147           0 :     return cppu::acquire(new FindAllToolboxController(context));
    1148             : }
    1149             : 
    1150             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
    1151           0 : com_sun_star_svx_SearchLabelToolboxController_get_implementation(
    1152             :     css::uno::XComponentContext *context,
    1153             :     css::uno::Sequence<css::uno::Any> const &)
    1154             : {
    1155           0 :     return cppu::acquire(new SearchLabelToolboxController(context));
    1156             : }
    1157             : 
    1158             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
    1159           4 : com_sun_star_comp_svx_Impl_FindbarDispatcher_get_implementation(
    1160             :     SAL_UNUSED_PARAMETER css::uno::XComponentContext *,
    1161             :     css::uno::Sequence<css::uno::Any> const &)
    1162             : {
    1163           4 :     return cppu::acquire(new FindbarDispatcher);
    1164         594 : }
    1165             : 
    1166             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10