LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/inc - tbunosearchcontrollers.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 12 100.0 %
Date: 2013-07-09 Functions: 6 6 100.0 %
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             : #ifndef __TBUNOSEARCHCONTROLLERS_HXX_
      21             : #define __TBUNOSEARCHCONTROLLERS_HXX_
      22             : 
      23             : #include <com/sun/star/beans/PropertyValue.hpp>
      24             : #include <com/sun/star/frame/DispatchDescriptor.hpp>
      25             : #include <com/sun/star/frame/XDispatch.hpp>
      26             : #include <com/sun/star/frame/XDispatchHelper.hpp>
      27             : #include <com/sun/star/frame/XDispatchProvider.hpp>
      28             : #include <com/sun/star/frame/XStatusListener.hpp>
      29             : #include <com/sun/star/lang/XServiceInfo.hpp>
      30             : #include <com/sun/star/lang/XInitialization.hpp>
      31             : 
      32             : #include <comphelper/sequenceasvector.hxx>
      33             : #include <cppuhelper/implbase1.hxx>
      34             : #include <cppuhelper/weak.hxx>
      35             : #include <svtools/toolboxcontroller.hxx>
      36             : #include <vcl/button.hxx>
      37             : #include <vcl/combobox.hxx>
      38             : #include <vcl/window.hxx>
      39             : 
      40             : #include <map>
      41             : #include <vector>
      42             : 
      43             : namespace svx
      44             : {
      45             : 
      46             : class FindTextFieldControl : public ComboBox
      47             : {
      48             : public:
      49             :     FindTextFieldControl( Window* pParent, WinBits nStyle,
      50             :         css::uno::Reference< css::frame::XFrame >& xFrame,
      51             :         const css::uno::Reference< css::uno::XComponentContext >& xContext );
      52             :     virtual ~FindTextFieldControl();
      53             : 
      54             :     virtual long PreNotify( NotifyEvent& rNEvt );
      55             : 
      56             :     void Remember_Impl(const String& rStr);
      57             :     void SetTextToSelected_Impl();
      58             : 
      59             : private:
      60             : 
      61             :     css::uno::Reference< css::frame::XFrame > m_xFrame;
      62             :     css::uno::Reference< css::uno::XComponentContext > m_xContext;
      63             : };
      64             : 
      65             : class SearchToolbarControllersManager
      66             : {
      67             : public:
      68             : 
      69             :     SearchToolbarControllersManager();
      70             :     ~SearchToolbarControllersManager();
      71             : 
      72             :     static SearchToolbarControllersManager& createControllersManager();
      73             : 
      74             :     void registryController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const OUString& sCommandURL );
      75             :     void freeController ( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const OUString& sCommandURL );
      76             :     css::uno::Reference< css::frame::XStatusListener > findController( const css::uno::Reference< css::frame::XFrame >& xFrame, const OUString& sCommandURL );
      77             : 
      78             :     void saveSearchHistory(const FindTextFieldControl* m_pFindTextFieldControl);
      79             :     void loadSearchHistory(FindTextFieldControl* m_pFindTextFieldControl);
      80             : 
      81             : private:
      82             : 
      83             :     typedef ::comphelper::SequenceAsVector< css::beans::PropertyValue > SearchToolbarControllersVec;
      84             :     typedef ::std::map< css::uno::Reference< css::frame::XFrame >, SearchToolbarControllersVec > SearchToolbarControllersMap;
      85             :     SearchToolbarControllersMap aSearchToolbarControllersMap;
      86             :     std::vector<OUString> m_aSearchStrings;
      87             : 
      88             : };
      89             : 
      90             : class FindTextToolbarController : public svt::ToolboxController,
      91             :                                   public css::lang::XServiceInfo
      92             : {
      93             : public:
      94             : 
      95             :     FindTextToolbarController( const css::uno::Reference< css::uno::XComponentContext > & rxContext );
      96             :     ~FindTextToolbarController();
      97             : 
      98             :     // XInterface
      99             :     virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
     100             :     virtual void SAL_CALL acquire() throw ();
     101             :     virtual void SAL_CALL release() throw ();
     102             : 
     103             :     // XServiceInfo
     104             :     virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
     105             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException );
     106             :     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
     107             : 
     108          16 :     static OUString getImplementationName_Static() throw()
     109             :     {
     110          16 :         return OUString("com.sun.star.svx.FindTextToolboxController");
     111             :     }
     112             : 
     113             :     static ::com::sun::star::uno::Sequence< OUString >  getSupportedServiceNames_Static() throw();
     114             : 
     115             :     // XComponent
     116             :     virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException );
     117             : 
     118             :     // XInitialization
     119             :     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException );
     120             : 
     121             :     // XToolbarController
     122             :     virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException);
     123             :     virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException );
     124             : 
     125             :     // XStatusListener
     126             :     virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException );
     127             : 
     128             :     DECL_LINK(EditModifyHdl, void*);
     129             : 
     130             : private:
     131             : 
     132             :     FindTextFieldControl* m_pFindTextFieldControl;
     133             : 
     134             :     sal_uInt16 m_nDownSearchId; // item position of findbar
     135             :     sal_uInt16 m_nUpSearchId;   // item position of findbar
     136             : 
     137             : };
     138             : 
     139             : class ExitSearchToolboxController   : public svt::ToolboxController,
     140             :                                       public css::lang::XServiceInfo
     141             : {
     142             : public:
     143             :     ExitSearchToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
     144             :     ~ExitSearchToolboxController();
     145             : 
     146             :     // XInterface
     147             :     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
     148             :     virtual void SAL_CALL acquire() throw ();
     149             :     virtual void SAL_CALL release() throw ();
     150             : 
     151             :     // XServiceInfo
     152             :     virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
     153             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException );
     154             :     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
     155             : 
     156          16 :     static OUString getImplementationName_Static( ) throw()
     157             :     {
     158          16 :         return OUString( "com.sun.star.svx.ExitFindbarToolboxController" );
     159             :     }
     160             : 
     161             :     static css::uno::Sequence< OUString >  getSupportedServiceNames_Static() throw();
     162             : 
     163             :     // XComponent
     164             :     virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException );
     165             : 
     166             :     // XInitialization
     167             :     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException);
     168             : 
     169             :     // XToolbarController
     170             :     virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException );
     171             : 
     172             :     // XStatusListener
     173             :     virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException );
     174             : };
     175             : 
     176             : class UpDownSearchToolboxController : public svt::ToolboxController,
     177             :                                       public css::lang::XServiceInfo
     178             : {
     179             : public:
     180             :     enum Type { UP, DOWN };
     181             : 
     182             :     UpDownSearchToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext, Type eType );
     183             :     ~UpDownSearchToolboxController();
     184             : 
     185             :     // XInterface
     186             :     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
     187             :     virtual void SAL_CALL acquire() throw ();
     188             :     virtual void SAL_CALL release() throw ();
     189             : 
     190             :     // XServiceInfo
     191             :     virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
     192             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException );
     193             :     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
     194             : 
     195          32 :     static OUString getImplementationName_Static( Type eType ) throw()
     196             :     {
     197             :         return eType == UP? OUString( "com.sun.star.svx.UpSearchToolboxController" ) :
     198          32 :                             OUString( "com.sun.star.svx.DownSearchToolboxController" );
     199             :     }
     200             : 
     201             :     static css::uno::Sequence< OUString >  getSupportedServiceNames_Static() throw();
     202             : 
     203             :     // XComponent
     204             :     virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException );
     205             : 
     206             :     // XInitialization
     207             :     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException);
     208             : 
     209             :     // XToolbarController
     210             :     virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException );
     211             : 
     212             :     // XStatusListener
     213             :     virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException );
     214             : 
     215             : private:
     216             :     Type meType;
     217             : };
     218             : 
     219             : class MatchCaseToolboxController : public svt::ToolboxController,
     220             :                                       public css::lang::XServiceInfo
     221             : {
     222             : public:
     223             :     MatchCaseToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
     224             :     ~MatchCaseToolboxController();
     225             : 
     226             :     // XInterface
     227             :     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
     228             :     virtual void SAL_CALL acquire() throw ();
     229             :     virtual void SAL_CALL release() throw ();
     230             : 
     231             :     // XServiceInfo
     232             :     virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
     233             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException );
     234             :     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
     235             : 
     236          16 :     static OUString getImplementationName_Static( ) throw()
     237             :     {
     238          16 :         return OUString( "com.sun.star.svx.MatchCaseToolboxController" );
     239             :     }
     240             : 
     241             :     static css::uno::Sequence< OUString >  getSupportedServiceNames_Static() throw();
     242             : 
     243             :     // XComponent
     244             :     virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException );
     245             : 
     246             :     // XInitialization
     247             :     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException);
     248             : 
     249             :     // XToolbarController
     250             :     virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException );
     251             :     virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException );
     252             : 
     253             :     // XStatusListener
     254             :     virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException );
     255             : 
     256             : private:
     257             :     CheckBox* m_pMatchCaseControl;
     258             : };
     259             : 
     260             : class FindAllToolboxController   : public svt::ToolboxController,
     261             :                                       public css::lang::XServiceInfo
     262             : {
     263             : public:
     264             :     FindAllToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
     265             :     ~FindAllToolboxController();
     266             : 
     267             :     // XInterface
     268             :     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
     269             :     virtual void SAL_CALL acquire() throw ();
     270             :     virtual void SAL_CALL release() throw ();
     271             : 
     272             :     // XServiceInfo
     273             :     virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
     274             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException );
     275             :     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
     276             : 
     277          16 :     static OUString getImplementationName_Static( ) throw()
     278             :     {
     279          16 :         return OUString( "com.sun.star.svx.FindAllToolboxController" );
     280             :     }
     281             : 
     282             :     static css::uno::Sequence< OUString >  getSupportedServiceNames_Static() throw();
     283             : 
     284             :     // XComponent
     285             :     virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException );
     286             : 
     287             :     // XInitialization
     288             :     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException);
     289             : 
     290             :     // XToolbarController
     291             :     virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException );
     292             : 
     293             :     // XStatusListener
     294             :     virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException );
     295             : };
     296             : 
     297             : // protocol handler for "vnd.sun.star.findbar:*" URLs
     298             : // The dispatch object will be used for shortcut commands for findbar
     299             : class FindbarDispatcher : public css::lang::XServiceInfo,
     300             :                           public css::lang::XInitialization,
     301             :                           public css::frame::XDispatchProvider,
     302             :                           public css::frame::XDispatch,
     303             :                           public ::cppu::OWeakObject
     304             : {
     305             : public:
     306             : 
     307             :     FindbarDispatcher();
     308             :     virtual ~FindbarDispatcher();
     309             : 
     310             :     // XInterface
     311             :     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
     312             :     virtual void SAL_CALL acquire() throw();
     313             :     virtual void SAL_CALL release() throw();
     314             : 
     315             :     // XServiceInfo
     316             :     virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
     317             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException );
     318             :     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
     319             : 
     320          17 :     static OUString getImplementationName_Static() throw()
     321             :     {
     322          17 :         return OUString("com.sun.star.comp.svx.Impl.FindbarDispatcher");
     323             :     }
     324             : 
     325             :     static css::uno::Sequence< OUString >  getSupportedServiceNames_Static() throw();
     326             : 
     327             :     // XInitialization
     328             :     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException );
     329             : 
     330             :     // XDispatchProvider
     331             :     virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL& aURL, const OUString& sTargetFrameName , sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException );
     332             :     virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptions    ) throw( css::uno::RuntimeException );
     333             : 
     334             :     // XDispatch
     335             :     virtual void SAL_CALL dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException );
     336             :     virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) throw( css::uno::RuntimeException );
     337             :     virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) throw( css::uno::RuntimeException );
     338             : 
     339             : private:
     340             : 
     341             :     css::uno::Reference< css::frame::XFrame > m_xFrame;
     342             : 
     343             : };
     344             : 
     345             : // createInstance
     346             : css::uno::Reference< css::uno::XInterface > SAL_CALL FindTextToolbarController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
     347             : css::uno::Reference< css::uno::XInterface > SAL_CALL DownSearchToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
     348             : css::uno::Reference< css::uno::XInterface > SAL_CALL UpSearchToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
     349             : css::uno::Reference< css::uno::XInterface > SAL_CALL MatchCaseToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
     350             : css::uno::Reference< css::uno::XInterface > SAL_CALL FindAllToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
     351             : css::uno::Reference< css::uno::XInterface > SAL_CALL ExitFindbarToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
     352             : css::uno::Reference< css::uno::XInterface > SAL_CALL FindbarDispatcher_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
     353             : 
     354             : }
     355             : 
     356             : #endif // __TBUNOSEARCHCONTROLLERS_HXX_
     357             : 
     358             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10