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

Generated by: LCOV version 1.11